Advertisement
Guest User

Untitled

a guest
Apr 26th, 2021
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.26 KB | None | 0 0
  1. .float alpha; // translucency in supported engines
  2. .entity char; // linker entity
  3. float PLAYER_TRIGGERED = 1;
  4. float MONSTER_TRIGGERED = 2;
  5. float FALL_BREAKABLE = 8; //VR
  6. float FALL_SOLID = 16; //VR
  7.  
  8. void() fall_break_fields;
  9.  
  10. void() func_fall2_think =
  11. {
  12. self.waterlevel = self.watertype = 0; // turn off quake engine splash sound
  13.  
  14. if (self.attack_finished < time)
  15. {
  16. if (self.target) // fire other targets
  17. SUB_UseAndForgetTargets();
  18. // SUB_UseTargets();
  19.  
  20. if (self.pos1 != '0 0 0')
  21. self.avelocity = self.pos1; // apply stored avelocity vector values
  22.  
  23. if (self.pos2 && !self.velocity) // Add velocity movement
  24. self.velocity = self.pos2;
  25.  
  26. if (self.cnt > 0) // cnt over 0
  27. {
  28. if (self.cnt >= 2)
  29. {
  30. self.movetype = MOVETYPE_BOUNCE;
  31. if (self.velocity_z < self.lip)
  32. self.velocity_z = self.lip;
  33. }
  34. else // cnt is 1
  35. {
  36. self.movetype = MOVETYPE_NOCLIP;
  37. if (self.velocity_z > self.lip)
  38. self.velocity_z = self.velocity_z - self.speed * (frametime * 100);
  39. else
  40. self.velocity_z = self.lip;
  41. }
  42. }
  43. else // default behavior (cnt is 0)
  44. {
  45. self.movetype = MOVETYPE_TOSS;
  46. if (self.velocity_z < self.lip)
  47. self.velocity_z = self.lip;
  48. }
  49.  
  50. if (self.pain_finished != -1)
  51. {
  52. if (self.alpha > 0.1)
  53. self.alpha = self.alpha - self.pain_finished;
  54. else
  55. {
  56. if (self.noise2)
  57. sound (self, CHAN_AUTO, self.noise2, 1, ATTN_NORM);
  58. remove(self);
  59. return;
  60. }
  61. }
  62.  
  63. if (self.flags&FL_ONGROUND && self.spawnflags&FALL_BREAKABLE) { //VR
  64. self.spawnflags(-)1; //aka BREAKABLE_NO_MONSTERS
  65. self.spawnflags(-)2; //aka BREAK_EXPLODE
  66. self.mins = self.absmin; //because of how debris origin is calculated
  67. self.maxs = self.absmax;
  68. self.health = self.lip*0.1; //debris gets velocity from health
  69. self.cnt = self.count; //func_breakable uses cnt for quantity of debris to spawn
  70. func_breakable_die(); //removes self
  71. return;
  72. }
  73. }
  74.  
  75. self.nextthink = self.ltime + 0.1;
  76. };
  77.  
  78. void() fall2_touch =
  79. {
  80. if (!other.takedamage)
  81. return;
  82. if (other.classname != "player") // player activated only
  83. return;
  84. if (self.spawnflags & MONSTER_TRIGGERED) // disable on monster only, also fixes weird issue
  85. return;
  86.  
  87. self.think = func_fall2_think;
  88. self.nextthink = self.ltime + 0.1;
  89.  
  90. self.attack_finished = time + self.wait;
  91.  
  92. if (self.spawnflags&FALL_SOLID) { //VR
  93. setsize(self, self.mins, self.maxs);
  94. self.solid = SOLID_BBOX;
  95. }
  96. else
  97. self.solid = SOLID_NOT;
  98.  
  99. if (self.noise)
  100. sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
  101.  
  102. self.touch = SUB_Null; // disable touch, only do this once!
  103.  
  104. if (self.char)
  105. remove(self.char);
  106. };
  107.  
  108. void() func_fall2_use =
  109. {
  110. self.think = func_fall2_think;
  111. self.nextthink = self.ltime + 0.1;
  112. self.touch = SUB_Null; // disable touch when used
  113.  
  114. if (self.spawnflags&FALL_SOLID) { //VR
  115. setsize(self, self.mins, self.maxs);
  116. self.solid = SOLID_BBOX;
  117. }
  118. else
  119. self.solid = SOLID_NOT;
  120.  
  121. self.attack_finished = time + self.wait;
  122. if (self.noise)
  123. sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
  124. };
  125.  
  126. void() func_fall2_field_touch =
  127. {
  128. if (other.flags & FL_FLY) // flying monsters shouldn't trigger falling platforms
  129. return;
  130.  
  131. if (other.flags & FL_MONSTER)
  132. {
  133. local entity oself;
  134.  
  135. oself = self;
  136.  
  137. self = self.owner;
  138. self.think = func_fall2_use;
  139. self.nextthink = self.owner.ltime + 0.1;
  140.  
  141. self = oself;
  142.  
  143. remove(self);
  144. }
  145. };
  146.  
  147. /*QUAKED func_fall2 (0 .5 .8) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
  148. Falling brush by RennyC
  149.  
  150. wait - how long until the brush begins falling
  151. noise - the sound to make when touched / activated
  152. noise2 - the sound to make before it's removed, pain_finished of -1 disables noise2 as the object stays forever
  153. cnt - 0 is default behavior (MOVETYPE_TOSS), 1 means collisions are disabled while falling (MOVETYPE_NOCLIP), 2 turns the brush into a bouncing entity (MOVETYPE_BOUNCE)
  154. 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
  155. 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).
  156. Recommended to use lip for max fall speed on MOVETYPE_TOSS/BOUNCE entities (cnt 0 and 2) as they follow Quake's default gravity
  157. lip - maximum fall speed that can be achieved, caps 'speed' variable. Default is -800
  158. avelocity - have it spin when activated using X, Y, Z vector coordinates. MOVETYPE_BOUNCE ignores avelocity !Use an origin brush for proper spin!
  159.  
  160. spawnflags:
  161. Default behavior allows anyone to activate func_fall2 on touch ONLY
  162. 1 - Player activated only
  163. 2 - Monster activated only
  164.  
  165. Able to .target other entities, including other func_fall2s
  166. */
  167.  
  168. void() func_fall2 =
  169. {
  170. //
  171. // This is a hack to have monsters be able to trigger it by fake touch - Thanks to Nahuel
  172. //
  173.  
  174. // Don't spawn on player only or if I'm a targetable
  175. if (!(self.spawnflags & PLAYER_TRIGGERED) && !(self.targetname))
  176. {
  177. local entity func_fall2_field;
  178.  
  179. func_fall2_field = spawn();
  180. func_fall2_field.owner = self;
  181. self.char = func_fall2_field; // Link 'em
  182. func_fall2_field.solid = SOLID_TRIGGER;
  183. setsize (func_fall2_field, self.absmin, self.absmax + '0 0 8');
  184. setorigin (func_fall2_field, self.origin);
  185. setmodel (func_fall2_field, self.model);
  186. func_fall2_field.touch = func_fall2_field_touch;
  187. }
  188.  
  189. if (self.noise)
  190. precache_sound(self.noise);
  191. if (self.noise2)
  192. precache_sound(self.noise2);
  193.  
  194. self.alpha = 1;
  195. self.solid = SOLID_BSP;
  196. self.movetype = MOVETYPE_PUSH;
  197.  
  198. if (!self.pain_finished)
  199. self.pain_finished = 0.01;
  200. if (!self.targetname)
  201. self.touch = fall2_touch; // .touch in this instance is for players only
  202. if (!self.speed)
  203. self.speed = 10;
  204. if (!self.lip)
  205. self.lip = -800;
  206. if (self.avelocity != '0 0 0')
  207. {
  208. self.pos1 = self.avelocity; // store it
  209. self.avelocity = '0 0 0';
  210. }
  211. if (self.spawnflags&FALL_BREAKABLE) { //VR
  212. self.pain_finished = -1; //dont fade if set to break
  213. fall_break_fields();
  214. }
  215. self.use = func_fall2_use;
  216.  
  217. setmodel (self, self.model);
  218. };
  219.  
  220. // * You may have to modify your multi_touch(); command in triggers.qc to allow
  221. // * both monsters & players to activate trigger_once/multiple. I recommend allowing
  222. // * the mapper themselves to select how that occurs. Default behavior is player only.
  223.  
  224. void fall_break_fields ()
  225. {
  226. break_template_setup();
  227.  
  228. self.mdl_debris = "progs/debris.mdl";
  229. precache_model (self.mdl_debris);
  230.  
  231. if (self.noise1 != "") precache_sound(self.noise1);
  232. // adding new default sounds for "simple" breakables in 1.2.0 -- dumptruck_ds
  233. // here's genreic metal breaking
  234. if (self.style == 0 || self.style == 11 || self.style == 12 || self.style == 17 || self.style == 18 || self.style == 19
  235. || self.style == 24 || self.style == 31)
  236. if !(self.noise1)
  237. {
  238. precache_sound("break/pd_metal2.wav");
  239. self.noise1 = "break/pd_metal2.wav";
  240. }
  241. if (self.style == 3 || self.style == 4 || self.style == 5)
  242. if !(self.noise1)
  243. {
  244. precache_sound("break/pd_wood1.wav");
  245. precache_sound("break/pd_wood2.wav");
  246. if (random() > 0.6) // wood only randomized
  247. self.noise1 = "break/pd_wood1.wav";
  248. else
  249. self.noise1 = "break/pd_wood2.wav";
  250. }
  251. // glass sounds -- this is more of a shattering sound anyway
  252. if (self.style == 6 || self.style == 7 || self.style == 8 || self.style == 9 || self.style == 10)
  253. if !(self.noise1)
  254. {
  255. precache_sound("break/pd_metal1.wav");
  256. self.noise1 = "break/pd_metal1.wav";
  257. }
  258. if (self.style == 1 || self.style == 2 || self.style == 13 || self.style == 14
  259. || self.style == 15 || self.style == 16 || self.style == 20 || self.style == 21
  260. || self.style == 22 || self.style == 23)
  261. if !(self.noise1)
  262. {
  263. precache_sound("break/pd_bricks1.wav");
  264. self.noise1 = "break/pd_bricks1.wav";
  265. }
  266. if (self.style == 25 || self.style == 26 || self.style == 27 || self.style == 28 || self.style == 29 || self.style == 30)
  267. if !(self.noise1)
  268. {
  269. precache_sound("break/pd_stones1.wav");
  270. self.noise1 = "break/pd_stones1.wav";
  271. }
  272.  
  273. if (!self.health)
  274. self.health = 20;
  275. if (!self.count)
  276. self.count = 5; // was 6 dumptruck_ds
  277. }
  278.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement