hipspawn.qc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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. //=====================================================================
  16. //
  17. // Spawning Functions (Hipnotic)
  18. //
  19. //=====================================================================
  20. //================
  21. //
  22. // spawn_think
  23. //
  24. //================
  25. void() spawn_think =
  26. {
  27. self.think = spawn_think;
  28. self.nextthink = time + 1;
  29. };
  30. //================
  31. //
  32. // spawn_use
  33. //
  34. //================
  35. void() spawn_use =
  36. {
  37. local entity spawnentity;
  38. local entity tempself;
  39. if ((self.spawnmulti == 1) || (horn_active))
  40. {
  41. // spawn the new entity
  42. spawnentity = spawn();
  43. // copy the master mold
  44. SUB_CopyEntity(self.spawnmaster,spawnentity);
  45. }
  46. else
  47. {
  48. spawnentity = self.spawnmaster;
  49. }
  50. // restore the model
  51. spawnentity.model = spawnentity.spawnmodel;
  52. //restore solid flag
  53. spawnentity.solid = spawnentity.spawnsolidtype;
  54. //restore thinking function
  55. spawnentity.think = spawnentity.spawnthink;
  56. setmodel (spawnentity, spawnentity.model);
  57. setorigin (spawnentity, spawnentity.origin);
  58. spawnentity.mins = spawnentity.spawnmins;
  59. spawnentity.maxs = spawnentity.spawnmaxs;
  60. setsize (spawnentity, spawnentity.mins, spawnentity.maxs);
  61. // spawn the teleport effect
  62. if (self.spawnsilent == 0)
  63. spawn_tfog (spawnentity.origin);
  64. // horn_active = 0;
  65. // horn_charmer = find( world, classname, "player" );
  66. // call spawnentity think function
  67. if (horn_active)
  68. {
  69. spawnentity.charmer = horn_charmer;
  70. spawnentity.charmed = 1;
  71. }
  72. // if (spawnentity.think)
  73. // {
  74. // spawnentity.nextthink = time+0.1;
  75. // tempself = self;
  76. // self = spawnentity;
  77. // self.think();
  78. // self = tempself;
  79. // spawnentity.nextthink = time+0.1;
  80. // self.nextthink = 1;
  81. // if (spawnentity.nextthink < time)
  82. // spawnentity.nextthink = 1;
  83. // }
  84. // check to see if it is a monster
  85. if (spawnentity.flags & FL_MONSTER)
  86. {
  87. if ((self.spawnmulti != 0) && (horn_active == 0))
  88. {
  89. total_monsters = total_monsters + 1;
  90. WriteByte (MSG_BROADCAST, SVC_UPDATESTAT);
  91. WriteByte (MSG_BROADCAST, STAT_TOTALMONSTERS);
  92. WriteLong (MSG_BROADCAST, total_monsters);
  93. }
  94. // spawn the telefrag effect
  95. // if (self.spawnsilent == 0)
  96. // spawn_tdeath(spawnentity.origin, spawnentity);
  97. if (horn_active)
  98. {
  99. spawnentity.effects = spawnentity.effects | EF_DIMLIGHT;
  100. // spawnentity.effects = spawnentity.effects | EF_BRIGHTFIELD;
  101. }
  102. }
  103. if ((self.spawnmulti == 0) && (horn_active == 0))
  104. {
  105. remove(self);
  106. }
  107. };
  108. //================
  109. //
  110. // func_spawn
  111. //
  112. //================
  113. /*QUAKED func_spawn (0 .5 .8) (-32 -32 -24) (32 32 64) big/ambush megahealth
  114. This will spawn a thing upon being used. The thing that
  115. is spawned depends upon the value of "spawnfunction".
  116. "spawnclassname" should contain the same value as "spawnfunction".
  117. If "spawnfunction" is unspecified a random monster is chosen.
  118. The angles, target and all flags are passed on
  119. Think of it like setting up a normal entity.
  120. "spawnsilent" set this to 1 if you want a silent spawn.
  121. "spawnmulti" set this to 1 if you want this spawn to be reoccuring.
  122. */
  123. void() func_spawn =
  124. {
  125. local entity tempself;
  126. local entity monster;
  127. local float tempdeathmatch;
  128. local float temptotal_monsters;
  129. local vector mn,mx;
  130. // if (deathmatch)
  131. // {
  132. // remove(self);
  133. // return;
  134. // }
  135. // save off deathmatch and zero it out
  136. tempself = self;
  137. tempdeathmatch = deathmatch;
  138. deathmatch = 0;
  139. if (!self.spawnfunction)
  140. {
  141. local float spawnchance;
  142. spawnchance = random();
  143. monster = tempself;
  144. // save off monster count so it doesn't get f'ed up
  145. temptotal_monsters = total_monsters;
  146. // spawn dog
  147. // spawn the new entity
  148. self = spawn();
  149. // copy over everything
  150. SUB_CopyEntity(tempself,self);
  151. self.spawnfunction = monster_dog;
  152. self.spawnclassname = "monster_dog";
  153. self.classname = self.spawnclassname;
  154. // call the named spawn function
  155. self.spawnfunction();
  156. self.spawnmodel = self.model;
  157. self.spawnmins = self.mins;
  158. self.spawnmaxs = self.maxs;
  159. setmodel (self, "");
  160. setsize (self, self.spawnmins, self.spawnmaxs);
  161. //save off solid flag
  162. self.spawnsolidtype = self.solid;
  163. self.solid = SOLID_NOT;
  164. //save off think func and
  165. //get rid of his thinking
  166. self.spawnthink = self.think;
  167. self.think = spawn_think;
  168. self.nextthink = time + 1;
  169. if (spawnchance<0.5 && monster==tempself)
  170. {
  171. monster = self;
  172. }
  173. // spawn ogre
  174. // spawn the new entity
  175. self = spawn();
  176. // copy over everything
  177. SUB_CopyEntity(tempself,self);
  178. self.spawnfunction = monster_ogre;
  179. self.spawnclassname = "monster_ogre";
  180. self.classname = self.spawnclassname;
  181. // call the named spawn function
  182. self.spawnfunction();
  183. self.spawnmodel = self.model;
  184. self.spawnmins = self.mins;
  185. self.spawnmaxs = self.maxs;
  186. setmodel (self, "");
  187. setsize (self, self.spawnmins, self.spawnmaxs);
  188. //save off solid flag
  189. self.spawnsolidtype = self.solid;
  190. self.solid = SOLID_NOT;
  191. //save off think func and
  192. //get rid of his thinking
  193. self.spawnthink = self.think;
  194. self.think = spawn_think;
  195. self.nextthink = time + 1;
  196. if (spawnchance<0.8 && monster==tempself)
  197. {
  198. monster = self;
  199. }
  200. // spawn fiend
  201. // spawn the new entity
  202. self = spawn();
  203. // copy over everything
  204. SUB_CopyEntity(tempself,self);
  205. self.spawnfunction = monster_demon1;
  206. self.spawnclassname = "monster_demon1";
  207. self.classname = self.spawnclassname;
  208. // call the named spawn function
  209. self.spawnfunction();
  210. self.spawnmodel = self.model;
  211. self.spawnmins = self.mins;
  212. self.spawnmaxs = self.maxs;
  213. setmodel (self, "");
  214. setsize (self, self.spawnmins, self.spawnmaxs);
  215. //save off solid flag
  216. self.spawnsolidtype = self.solid;
  217. self.solid = SOLID_NOT;
  218. //save off think func and
  219. //get rid of his thinking
  220. self.spawnthink = self.think;
  221. self.think = spawn_think;
  222. self.nextthink = time + 1;
  223. if (spawnchance<0.92 && monster==tempself)
  224. {
  225. monster = self;
  226. }
  227. // spawn zombie
  228. // spawn the new entity
  229. self = spawn();
  230. // copy over everything
  231. SUB_CopyEntity(tempself,self);
  232. self.spawnfunction = monster_zombie;
  233. self.spawnclassname = "monster_zombie";
  234. self.classname = self.spawnclassname;
  235. // call the named spawn function
  236. self.spawnfunction();
  237. self.spawnmodel = self.model;
  238. self.spawnmins = self.mins;
  239. self.spawnmaxs = self.maxs;
  240. setmodel (self, "");
  241. setsize (self, self.spawnmins, self.spawnmaxs);
  242. //save off solid flag
  243. self.spawnsolidtype = self.solid;
  244. self.solid = SOLID_NOT;
  245. //save off think func and
  246. //get rid of his thinking
  247. self.spawnthink = self.think;
  248. self.think = spawn_think;
  249. self.nextthink = time + 1;
  250. if (spawnchance<0.97 && monster==tempself)
  251. {
  252. monster = self;
  253. }
  254. // spawn shambler
  255. // spawn the new entity
  256. self = spawn();
  257. // copy over everything
  258. SUB_CopyEntity(tempself,self);
  259. self.spawnfunction = monster_shambler;
  260. self.spawnclassname = "monster_shambler";
  261. self.classname = self.spawnclassname;
  262. // call the named spawn function
  263. self.spawnfunction();
  264. self.spawnmodel = self.model;
  265. self.spawnmins = self.mins;
  266. self.spawnmaxs = self.maxs;
  267. setmodel (self, "");
  268. setsize (self, self.spawnmins, self.spawnmaxs);
  269. //save off solid flag
  270. self.spawnsolidtype = self.solid;
  271. self.solid = SOLID_NOT;
  272. //save off think func and
  273. //get rid of his thinking
  274. self.spawnthink = self.think;
  275. self.think = spawn_think;
  276. self.nextthink = time + 1;
  277. if (monster==tempself)
  278. {
  279. monster = self;
  280. }
  281. // make sure monster count is correct
  282. total_monsters = temptotal_monsters + 1;
  283. }
  284. else
  285. {
  286. // spawn the new entity
  287. self = spawn();
  288. // copy over everything
  289. SUB_CopyEntity(tempself,self);
  290. // save off monster count so it doesn't get f'ed up
  291. temptotal_monsters = total_monsters;
  292. if (self.spawnclassname == string_null)
  293. {
  294. objerror("No spawnclassname defined");
  295. }
  296. self.classname = self.spawnclassname;
  297. // call the named spawn function
  298. self.spawnfunction();
  299. if (self.spawnmulti != 0)
  300. {
  301. // make sure monster count is correct
  302. total_monsters = temptotal_monsters;
  303. }
  304. self.spawnmodel = self.model;
  305. self.spawnmins = self.mins;
  306. self.spawnmaxs = self.maxs;
  307. setmodel (self, "");
  308. self.model = "";
  309. setsize (self, self.spawnmins, self.spawnmaxs);
  310. //save off solid flag
  311. self.spawnsolidtype = self.solid;
  312. self.solid = SOLID_NOT;
  313. //save off think func and
  314. //get rid of his thinking
  315. self.spawnthink = self.think;
  316. self.think = spawn_think;
  317. self.nextthink = time + 1;
  318. monster = self;
  319. }
  320. self = tempself;
  321. deathmatch = tempdeathmatch;
  322. self.solid = SOLID_NOT;
  323. self.movetype = MOVETYPE_NONE;
  324. self.modelindex = 0;
  325. self.model = "";
  326. setmodel (self, self.model); // set size and link into world
  327. self.use = spawn_use;
  328. self.spawnmaster = monster;
  329. };
  330. //================
  331. //
  332. // func_spawn_small
  333. //
  334. //================
  335. /*QUAKED func_spawn_small (0 .5 .8) (-16 -16 -24) (16 16 40) big/ambush megahealth
  336. This will spawn a thing upon being used. The thing that
  337. is spawned depends upon the value of "spawnfunction".
  338. "spawnclassname" should contain the same value as "spawnfunction".
  339. If "spawnfunction" is unspecified a random monster is chosen.
  340. The angles, target and all flags are passed on
  341. Think of it like setting up a normal entity.
  342. "spawnsilent" set this to 1 if you want a silent spawn.
  343. "spawnmulti" set this to 1 if you want this spawn to be reoccuring.
  344. */
  345. void() func_spawn_small =
  346. {
  347. func_spawn();
  348. };