Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. void() func_fall_think =
  2. {
  3. if (self.attack_finished < time)
  4. {
  5. self.solid = SOLID_NOT;
  6. if (self.pos1 != '0 0 0')
  7. self.avelocity = self.pos1; // apply stored avelocity vector values
  8.  
  9. if (self.cnt > 0) // cnt over 0
  10. {
  11. if (self.cnt >= 2)
  12. {
  13. self.movetype = MOVETYPE_BOUNCE;
  14. if (self.velocity_z < self.lip)
  15. self.velocity_z = self.lip;
  16. }
  17. else // cnt is 1
  18. {
  19. self.movetype = MOVETYPE_NOCLIP;
  20. if (self.velocity_z > self.lip)
  21. self.velocity_z = self.velocity_z - self.speed * (frametime * 100);
  22. else
  23. self.velocity_z = self.lip;
  24. }
  25. }
  26. else // default behavior (cnt is 0)
  27. {
  28. self.movetype = MOVETYPE_TOSS;
  29. if (self.velocity_z < self.lip)
  30. self.velocity_z = self.lip;
  31. }
  32.  
  33. if (self.pain_finished != -1)
  34. {
  35. if (self.alpha > 0.1)
  36. {
  37. self.alpha = self.alpha - self.pain_finished;
  38. }
  39. else
  40. {
  41. sound (self, CHAN_AUTO, self.noise2, 1, ATTN_NORM);
  42. remove(self);
  43. return;
  44. }
  45. }
  46. }
  47. self.nextthink = self.ltime + 0.1;
  48. };
  49.  
  50. void() fall_touch =
  51. {
  52. if (!other.takedamage || self.cnt == TRUE)
  53. return;
  54. if (self.spawnflags & 1 && other.classname != "player") // Player activated only
  55. return;
  56. if (self.spawnflags & 2 && !other.flags & FL_MONSTER) // Monster activated only
  57. return;
  58.  
  59. self.think = func_fall_think;
  60. self.nextthink = self.ltime + 0.1;
  61.  
  62. self.attack_finished = time + self.wait;
  63. sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
  64. };
  65.  
  66. void() func_fall_use =
  67. {
  68. self.think = func_fall_think;
  69. self.nextthink = self.ltime + 0.1;
  70.  
  71. self.attack_finished = time + self.wait;
  72. sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
  73. };
  74.  
  75. /*QUAKED func_fall (0 .5 .8) ?
  76. Falling brush by RennyC
  77.  
  78. wait - how long until the brush begins falling
  79. noise - the sound to make when touched / activated
  80. noise2 - the sound to make before it's removed, pain_finished of -1 disables noise2 as the object stays forever
  81. cnt - 0 is default behavior (MOVETYPE_TOSS), 1 means collisions are disabled while falling (MOVETYPE_NOCLIP), 2 turns the brush into a
  82. bouncing entity (MOVETYPE_BOUNCE)
  83. pain_finished - default of 0.01, higher value has the object/brush fade out faster thus in turn affecting how long it stays. -1 stays forever
  84. speed - speed as to how fast something falls per game frame, default is 10, higher values mean faster falling. Only for cnt of 1 (MOVETYPE_NOCLIP).
  85. Recommended to use lip for max fall speed on MOVETYPE_TOSS/BOUNCE entities (cnt 0 and 2) as they follow Quake's default gravity
  86. lip - maximum fall speed that can be achieved, caps 'speed' variable. Default is -800
  87. avelocity - have it spin when activated using X, Y, Z vector coordinates. MOVETYPE_BOUNCE ignores avelocity !Use an origin brush for proper spin!
  88.  
  89. spawnflags:
  90. Default behavior allows anyone to activate func_fall on touch
  91. 1 - Player activated only
  92. 2 - Monster activated only
  93. */
  94.  
  95. void() func_fall =
  96. {
  97. precache_sound(self.noise);
  98. precache_sound(self.noise2);
  99.  
  100. self.alpha = 1;
  101. self.solid = SOLID_BSP;
  102. self.movetype = MOVETYPE_PUSH;
  103.  
  104. if (!self.pain_finished)
  105. self.pain_finished = 0.01;
  106. if (!self.targetname)
  107. self.touch = fall_touch;
  108. if (!self.speed)
  109. self.speed = 10;
  110. if (!self.lip)
  111. self.lip = -800;
  112. if (self.avelocity != '0 0 0')
  113. {
  114. self.pos1 = self.avelocity; // store it
  115. self.avelocity = '0 0 0';
  116. }
  117.  
  118. self.use = func_fall_use;
  119. setmodel (self, self.model);
  120. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement