ZDCMP1_Footstep.zc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * TCOTD2 Game Code - Adapted for ZDCMP by Ozymandias81 2024 (little changes, I don't claim anything)
  3. * Copyright (C) 2020 - 2023 Nash Muhandes
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. //===========================================================================
  19. //
  20. // ZDCMPFootstep
  21. // Plays a footstep sound when spawned
  22. //
  23. //===========================================================================
  24. mixin class ZDCMPClientsideOnlyMixin //not exactly necessary for ZDCMP, but kept for the sake - ozy81
  25. {
  26. Default
  27. {
  28. FloatBobPhase 0;
  29. +SYNCHRONIZED
  30. +DONTBLAST
  31. -RANDOMIZE
  32. }
  33. }
  34. class ZDCMPFootstep : Actor
  35. {
  36. mixin ZDCMPClientsideOnlyMixin;
  37. //===========================================================================
  38. //
  39. //
  40. //
  41. //===========================================================================
  42. ZDCMPPlayer pmo;
  43. double vol;
  44. Sound snd;
  45. //===========================================================================
  46. //
  47. //
  48. //
  49. //===========================================================================
  50. Default
  51. {
  52. RenderStyle "STYLE_None";
  53. +DONTSPLASH
  54. +CORPSE
  55. +NOTIMEFREEZE
  56. -SOLID
  57. }
  58. //===========================================================================
  59. //
  60. //
  61. //
  62. //===========================================================================
  63. override void BeginPlay(void)
  64. {
  65. Super.BeginPlay();
  66. if (pmo)
  67. {
  68. A_SetSize(pmo.Radius, pmo.Height);
  69. }
  70. }
  71. override void Tick(void)
  72. {
  73. Super.Tick();
  74. if (pmo)
  75. {
  76. Vector3 fsp = (pmo.Pos.X, pmo.Pos.Y, Pos.Z);
  77. SetOrigin(fsp, false);
  78. }
  79. }
  80. //===========================================================================
  81. //
  82. //
  83. //
  84. //===========================================================================
  85. static double GetZOffset(ZDCMPPlayer self)
  86. {
  87. // determine how high up to spawn the footstep actor
  88. return abs(self.Vel.Z);
  89. }
  90. void A_PlayFootstepSound(void)
  91. {
  92. int attn = (pmo.CheckLocalView()) ? ATTN_NONE : ATTN_NORM;
  93. A_StartSound(snd, volume: vol, attenuation: attn);
  94. }
  95. //===========================================================================
  96. //
  97. //
  98. //
  99. //===========================================================================
  100. States
  101. {
  102. Spawn:
  103. TNT1 A 7;
  104. Stop;
  105. Crash:
  106. TNT1 A 10 A_PlayFootstepSound();
  107. Stop;
  108. }
  109. }