timemach.qc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /* Copyright (C) 1996-2022 id Software LLC
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  13. See file, 'COPYING', for details.
  14. */
  15. // timemach.qc
  16. // pmack
  17. // jan97
  18. // ------------------------------------------------
  19. // time machine and related parts
  20. // ------------------------------------------------
  21. void() time_chunk =
  22. {
  23. local entity timeChunk;
  24. timeChunk = spawn();
  25. setmodel(timeChunk, "progs/timegib.mdl");
  26. timeChunk.solid = SOLID_NOT;
  27. timeChunk.movetype = MOVETYPE_TOSS;
  28. makevectors (self.owner.angles);
  29. setorigin ( timeChunk, self.owner.origin + v_forward*84 - v_up * 136);
  30. timeChunk.velocity = v_up * -50;
  31. timeChunk.avelocity = '300 300 300';
  32. timeChunk.angles = self.owner.angles;
  33. sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NONE);
  34. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  35. WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  36. WriteCoord (MSG_BROADCAST, timeChunk.origin_x);
  37. WriteCoord (MSG_BROADCAST, timeChunk.origin_y);
  38. WriteCoord (MSG_BROADCAST, timeChunk.origin_z);
  39. self.owner.frame = 1;
  40. timeChunk.think = SUB_Remove;
  41. timeChunk.nextthink = time + 5;
  42. };
  43. void() time_stop_shake =
  44. {
  45. SUB_UseTargets();
  46. remove (self);
  47. };
  48. void() time_boom =
  49. {
  50. local entity stopShakeEnt;
  51. SUB_UseTargets();
  52. if(self.owner.health < 1250 && self.owner.frame > 0)
  53. {
  54. if ( self.owner.skin < 2)
  55. {
  56. self.owner.frame = 2;
  57. self.owner.skin = 2;
  58. }
  59. }
  60. else if(self.owner.health < 1500)
  61. {
  62. if ( self.owner.frame == 0 )
  63. {
  64. time_chunk();
  65. self.owner.frame = 1;
  66. self.owner.skin = 1;
  67. }
  68. }
  69. sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NONE);
  70. if (random() < 0.5)
  71. {
  72. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  73. WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  74. WriteCoord (MSG_BROADCAST, self.origin_x);
  75. WriteCoord (MSG_BROADCAST, self.origin_y);
  76. WriteCoord (MSG_BROADCAST, self.origin_z);
  77. }
  78. else
  79. {
  80. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  81. WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
  82. WriteCoord (MSG_BROADCAST, self.origin_x);
  83. WriteCoord (MSG_BROADCAST, self.origin_y);
  84. WriteCoord (MSG_BROADCAST, self.origin_z);
  85. WriteByte (MSG_BROADCAST, 244);
  86. WriteByte (MSG_BROADCAST, 3);
  87. }
  88. BecomeExplosion();
  89. stopShakeEnt = spawn();
  90. stopShakeEnt.target = self.target;
  91. stopShakeEnt.think = time_stop_shake;
  92. stopShakeEnt.nextthink = time + 0.7;
  93. };
  94. void() time_fall =
  95. {
  96. if (!self.pain_finished)
  97. {
  98. if ( self.origin_z < -20 )
  99. {
  100. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  101. WriteByte (MSG_BROADCAST, TE_LAVASPLASH);
  102. WriteCoord (MSG_BROADCAST, self.origin_x);
  103. WriteCoord (MSG_BROADCAST, self.origin_y);
  104. WriteCoord (MSG_BROADCAST, self.origin_z - 80);
  105. self.pain_finished = 1;
  106. }
  107. else if (random() < 0.3)
  108. {
  109. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  110. WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  111. WriteCoord (MSG_BROADCAST, self.origin_x);
  112. WriteCoord (MSG_BROADCAST, self.origin_y);
  113. WriteCoord (MSG_BROADCAST, self.origin_z);
  114. }
  115. }
  116. self.velocity_z = self.velocity_z - 5;
  117. self.nextthink = time + 0.1;
  118. self.think = time_fall;
  119. };
  120. void() time_crash =
  121. {
  122. self.takedamage = DAMAGE_NO;
  123. self.movetype = MOVETYPE_FLY;
  124. self.solid = SOLID_NOT;
  125. self.velocity = '0 0 -50';
  126. self.avelocity = '15 0 5';
  127. setsize (self, '0 0 0', '0 0 0');
  128. self.think = time_fall;
  129. self.nextthink = time + 0.1;
  130. self.target = "timeramp";
  131. SUB_UseTargets();
  132. };
  133. void(entity attacker, float take) time_pain =
  134. {
  135. local entity painEnt;
  136. local vector painOrg;
  137. local float painRnd;
  138. if ( self.health > 1100 )
  139. if ( self.pain_finished > time )
  140. return;
  141. painRnd = random();
  142. if(painRnd < 0.4)
  143. {
  144. self.pain_finished = time + 2;
  145. painRnd = random();
  146. makevectors ( self.angles );
  147. painEnt = spawn();
  148. if ( painRnd < 0.33 )
  149. painEnt.origin = self.origin + v_forward*80 - v_up*64;
  150. else if (painRnd < 0.66)
  151. painEnt.origin = self.origin + v_right*80 - v_up*24;
  152. else
  153. painEnt.origin = self.origin + v_forward*64 - v_up*48 - v_right*48;
  154. painEnt.target = self.target;
  155. painEnt.owner = self;
  156. painEnt.think = time_boom;
  157. painEnt.nextthink = time + 0.2 + random() * 0.3;
  158. }
  159. if ( self.health < 1000 )
  160. {
  161. self.pain_finished = 0;
  162. self.th_pain = SUB_Null;
  163. self.th_die = SUB_Null;
  164. cutscene_running = 1;
  165. return;
  166. }
  167. };
  168. //(-16 -16 -32) (16 16 0)
  169. /*QUAKED item_time_machine (1 1 0) (-64 -64 -144) (64 64 0)
  170. */
  171. void() item_time_machine =
  172. {
  173. if (deathmatch)
  174. {
  175. remove (self);
  176. return;
  177. }
  178. precache_model("progs/timemach.mdl");
  179. precache_model("progs/timegib.mdl");
  180. setmodel(self, "progs/timemach.mdl");
  181. self.solid = SOLID_SLIDEBOX;
  182. self.movetype = MOVETYPE_STEP;
  183. self.health = 1600;
  184. self.takedamage = DAMAGE_YES;
  185. self.view_ofs = '0 0 25';
  186. self.movetype = MOVETYPE_FLY;
  187. setsize(self, '-64 -64 -144', '64 64 0');
  188. self.avelocity = '0 60 0';
  189. self.flags = self.flags | FL_MONSTER;
  190. self.th_stand = SUB_Null;
  191. self.th_walk = SUB_Null;
  192. self.th_run = SUB_Null;
  193. self.th_die = time_pain;
  194. self.th_missile = SUB_Null;
  195. self.th_pain = time_pain;
  196. theMachine = self;
  197. };
  198. /*QUAKED item_time_core (1 0 0) (-8 -8 -8) (8 8 8)
  199. */
  200. void() item_time_core =
  201. {
  202. if (deathmatch)
  203. {
  204. remove (self);
  205. return;
  206. }
  207. precache_model ("progs/timecore.mdl");
  208. setmodel(self, "progs/timecore.mdl");
  209. self.solid = SOLID_NOT;
  210. self.movetype = MOVETYPE_FLY;
  211. self.avelocity = '60 60 60';
  212. };