items.qc 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754
  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. void() W_SetCurrentAmmo;
  16. /* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
  17. BE .8 .3 .4 IN COLOR */
  18. void() SUB_regen =
  19. {
  20. self.model = self.mdl; // restore original model
  21. self.solid = SOLID_TRIGGER; // allow it to be touched again
  22. sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM); // play respawn sound
  23. setorigin (self, self.origin);
  24. };
  25. /*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
  26. prints a warning message when spawned
  27. */
  28. void() noclass =
  29. {
  30. dprint ("noclass spawned at");
  31. dprint (vtos(self.origin));
  32. dprint ("\n");
  33. remove (self);
  34. };
  35. /*
  36. ============
  37. PlaceItem
  38. plants the object on the floor
  39. ============
  40. */
  41. void() PlaceItem =
  42. {
  43. local float oldz;
  44. self.mdl = self.model; // so it can be restored on respawn
  45. self.flags = FL_ITEM; // make extra wide
  46. self.solid = SOLID_TRIGGER;
  47. self.movetype = MOVETYPE_TOSS;
  48. self.velocity = '0 0 0';
  49. self.origin_z = self.origin_z + 6;
  50. oldz = self.origin_z;
  51. if (!droptofloor())
  52. {
  53. dprint ("Bonus item fell out of level!\n");
  54. dprint (self.classname);
  55. dprint (" at ");
  56. dprint (vtos(self.origin));
  57. dprint ("\n");
  58. remove(self);
  59. return;
  60. }
  61. };
  62. /*
  63. ============
  64. StartItem
  65. Sets the clipping size and plants the object on the floor
  66. ============
  67. */
  68. void() StartItem =
  69. {
  70. self.nextthink = time + 0.2; // items start after other solids
  71. self.think = PlaceItem;
  72. };
  73. /*
  74. =========================================================================
  75. HEALTH BOX
  76. =========================================================================
  77. */
  78. //
  79. // T_Heal: add health to an entity, limiting health to max_health
  80. // "ignore" will ignore max_health limit
  81. //
  82. float (entity e, float healamount, float ignore) T_Heal =
  83. {
  84. if (e.health <= 0)
  85. return 0;
  86. if ((!ignore) && (e.health >= other.max_health))
  87. return 0;
  88. healamount = ceil(healamount);
  89. e.health = e.health + healamount;
  90. if ((!ignore) && (e.health >= other.max_health))
  91. e.health = other.max_health;
  92. if (e.health > 250)
  93. e.health = 250;
  94. return 1;
  95. };
  96. /*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
  97. Health box. Normally gives 25 points.
  98. Rotten box heals 5-10 points,
  99. megahealth will add 100 health, then
  100. rot you down to your maximum health limit,
  101. one point per second.
  102. */
  103. float H_ROTTEN = 1;
  104. float H_MEGA = 2;
  105. .float healamount, healtype;
  106. void() health_touch;
  107. void() item_megahealth_rot;
  108. void() item_health =
  109. {
  110. self.touch = health_touch;
  111. if (self.spawnflags & H_ROTTEN)
  112. {
  113. precache_model("maps/b_bh10.bsp");
  114. precache_sound("items/r_item1.wav");
  115. setmodel(self, "maps/b_bh10.bsp");
  116. self.noise = "items/r_item1.wav";
  117. self.healamount = 15;
  118. self.healtype = 0;
  119. }
  120. else
  121. if (self.spawnflags & H_MEGA)
  122. {
  123. precache_model("maps/b_bh100.bsp");
  124. precache_sound("items/r_item2.wav");
  125. setmodel(self, "maps/b_bh100.bsp");
  126. self.noise = "items/r_item2.wav";
  127. self.healamount = 100;
  128. self.healtype = 2;
  129. }
  130. else
  131. {
  132. precache_model("maps/b_bh25.bsp");
  133. precache_sound("items/health1.wav");
  134. setmodel(self, "maps/b_bh25.bsp");
  135. self.noise = "items/health1.wav";
  136. self.healamount = 25;
  137. self.healtype = 1;
  138. }
  139. setsize (self, '0 0 0', '32 32 56');
  140. StartItem ();
  141. };
  142. void() health_touch =
  143. {
  144. local float amount;
  145. local string s;
  146. if (other.classname != "player")
  147. return;
  148. if (self.healtype == 2) // Megahealth? Ignore max_health...
  149. {
  150. if (other.health >= 250)
  151. return;
  152. if (!T_Heal(other, self.healamount, 1))
  153. return;
  154. }
  155. else
  156. {
  157. if (!T_Heal(other, self.healamount, 0))
  158. return;
  159. }
  160. sprint(other, "$qc_item_health", ftos(self.healamount));
  161. // health touch sound
  162. sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  163. stuffcmd (other, "bf\n");
  164. self.model = string_null;
  165. self.solid = SOLID_NOT;
  166. // Megahealth = rot down the player's super health
  167. if (self.healtype == 2 && !RuneHasElder(other))
  168. {
  169. other.items2 = other.items2 | IT2_SUPERHEALTH;
  170. self.nextthink = time + 5;
  171. self.think = item_megahealth_rot;
  172. self.owner = other;
  173. }
  174. else
  175. {
  176. if (deathmatch != 2) // deathmatch 2 is the silly old rules
  177. {
  178. if (deathmatch)
  179. self.nextthink = time + 20;
  180. self.think = SUB_regen;
  181. }
  182. }
  183. activator = other;
  184. SUB_UseTargets(); // fire all targets / killtargets
  185. };
  186. void() item_megahealth_rot =
  187. {
  188. other = self.owner;
  189. if (other.health > other.max_health)
  190. {
  191. other.health = other.health - 1;
  192. self.nextthink = time + 1;
  193. return;
  194. }
  195. // it is possible for a player to die and respawn between rots, so don't
  196. // just blindly subtract the flag off
  197. other.items2 = other.items2 - (other.items2 & IT2_SUPERHEALTH);
  198. if (deathmatch && deathmatch != 2) // deathmatch 2 is silly old rules
  199. {
  200. self.nextthink = time + 20;
  201. self.think = SUB_regen;
  202. }
  203. };
  204. /*
  205. ===============================================================================
  206. ARMOR
  207. ===============================================================================
  208. */
  209. void() armor_touch;
  210. void() armor_touch =
  211. {
  212. local float type, value, bit;
  213. if (other.health <= 0)
  214. return;
  215. if (other.classname != "player")
  216. return;
  217. if (self.classname == "item_armor1")
  218. {
  219. type = 0.3;
  220. value = 100;
  221. bit = IT2_ARMOR1;
  222. }
  223. if (self.classname == "item_armor2")
  224. {
  225. type = 0.6;
  226. value = 150;
  227. bit = IT2_ARMOR2;
  228. }
  229. if (self.classname == "item_armorInv")
  230. {
  231. type = 0.8;
  232. value = 200;
  233. bit = IT2_ARMOR3;
  234. }
  235. if (other.armortype*other.armorvalue >= type*value)
  236. return;
  237. other.armortype = type;
  238. other.armorvalue = value;
  239. other.items2 = other.items2 -
  240. (other.items2 & (IT2_ARMOR1 | IT2_ARMOR2 | IT2_ARMOR3)) + bit;
  241. self.solid = SOLID_NOT;
  242. self.model = string_null;
  243. if (deathmatch && deathmatch != 2)
  244. self.nextthink = time + 20;
  245. self.think = SUB_regen;
  246. sprint(other, "$qc_item_armor");
  247. // armor touch sound
  248. sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
  249. stuffcmd (other, "bf\n");
  250. activator = other;
  251. SUB_UseTargets(); // fire all targets / killtargets
  252. };
  253. /*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
  254. */
  255. void() item_armor1 =
  256. {
  257. self.touch = armor_touch;
  258. self.armortype = 0.3;
  259. self.armorvalue = 100;
  260. precache_model ("progs/armor.mdl");
  261. setmodel (self, "progs/armor.mdl");
  262. self.skin = 0;
  263. setsize (self, '-16 -16 0', '16 16 56');
  264. StartItem ();
  265. };
  266. /*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
  267. */
  268. void() item_armor2 =
  269. {
  270. self.touch = armor_touch;
  271. self.armortype = 0.6;
  272. self.armorvalue = 150;
  273. precache_model ("progs/armor.mdl");
  274. setmodel (self, "progs/armor.mdl");
  275. self.skin = 1;
  276. setsize (self, '-16 -16 0', '16 16 56');
  277. StartItem ();
  278. };
  279. /*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32)
  280. */
  281. void() item_armorInv =
  282. {
  283. self.touch = armor_touch;
  284. self.armortype = 0.8;
  285. self.armorvalue = 200;
  286. precache_model ("progs/armor.mdl");
  287. setmodel (self, "progs/armor.mdl");
  288. self.skin = 2;
  289. setsize (self, '-16 -16 0', '16 16 56');
  290. StartItem ();
  291. };
  292. /*
  293. ===============================================================================
  294. WEAPONS
  295. ===============================================================================
  296. */
  297. void() bound_other_ammo =
  298. {
  299. if (other.ammo_shells1 > 100)
  300. other.ammo_shells1 = 100;
  301. if (other.ammo_nails1 > 200)
  302. other.ammo_nails1 = 200;
  303. if (other.ammo_rockets1 > 100)
  304. other.ammo_rockets1 = 100;
  305. if (other.ammo_cells1 > 100)
  306. other.ammo_cells1 = 100;
  307. // PGM addition
  308. if (other.ammo_lava_nails > 200)
  309. other.ammo_lava_nails = 200;
  310. if (other.ammo_multi_rockets > 100)
  311. other.ammo_multi_rockets = 100;
  312. if (other.ammo_plasma > 100)
  313. other.ammo_plasma = 100;
  314. };
  315. float(float w) RankForWeapon =
  316. {
  317. if (w == IT_PLASMA_GUN)
  318. return 1;
  319. if (w == IT_LIGHTNING)
  320. return 2;
  321. if (w == IT_MULTI_ROCKET)
  322. return 3;
  323. if (w == IT_ROCKET_LAUNCHER)
  324. return 4;
  325. if (w == IT_LAVA_SUPER_NAILGUN)
  326. return 5;
  327. if (w == IT_SUPER_NAILGUN)
  328. return 6;
  329. if (w == IT_MULTI_GRENADE)
  330. return 7;
  331. if (w == IT_GRENADE_LAUNCHER)
  332. return 8;
  333. if (w == IT_LAVA_NAILGUN)
  334. return 9;
  335. if (w == IT_SUPER_SHOTGUN)
  336. return 10;
  337. if (w == IT_NAILGUN)
  338. return 11;
  339. return 12;
  340. };
  341. /*
  342. =============
  343. Deathmatch_Weapon
  344. Deathmatch weapon change rules for picking up a weapon
  345. .float ammo_shells1, ammo_nails1, ammo_rockets1, ammo_cells1;
  346. =============
  347. */
  348. void(float old, float new) Deathmatch_Weapon =
  349. {
  350. local float or, nr;
  351. if ( self.flags & FL_ISBOT ) {
  352. return;
  353. } // mal: let bots pick their own weapon.
  354. // PGM - fix for changing to weapons when grappling.
  355. if (self.weapon == IT_GRAPPLE && self.button0)
  356. return;
  357. // change self.weapon if desired
  358. or = RankForWeapon (self.weapon);
  359. nr = RankForWeapon (new);
  360. if ( nr < or )
  361. self.weapon = new;
  362. };
  363. void(entity comboOwner) EnableComboWeapons =
  364. {
  365. if (comboOwner.classname != "player")
  366. return;
  367. if (!(comboOwner.items & IT_LAVA_NAILGUN))
  368. {
  369. if (comboOwner.ammo_lava_nails > 0 && (comboOwner.items & IT_NAILGUN))
  370. {
  371. sprint (comboOwner, "$qc_lava_enabled");
  372. comboOwner.items = comboOwner.items | IT_LAVA_NAILGUN;
  373. }
  374. }
  375. if (!(comboOwner.items & IT_LAVA_SUPER_NAILGUN))
  376. {
  377. if (comboOwner.ammo_lava_nails > 0 &&
  378. (comboOwner.items & IT_SUPER_NAILGUN))
  379. {
  380. sprint (comboOwner, "$qc_super_lava_enabled");
  381. comboOwner.items = comboOwner.items | IT_LAVA_SUPER_NAILGUN;
  382. }
  383. }
  384. if (!(comboOwner.items & IT_MULTI_GRENADE))
  385. {
  386. if (comboOwner.ammo_multi_rockets > 0 &&
  387. (comboOwner.items & IT_GRENADE_LAUNCHER))
  388. {
  389. sprint (comboOwner, "$qc_multi_gl_enabled");
  390. comboOwner.items = comboOwner.items | IT_MULTI_GRENADE;
  391. }
  392. }
  393. if (!(comboOwner.items & IT_MULTI_ROCKET))
  394. {
  395. if (comboOwner.ammo_multi_rockets > 0 &&
  396. (comboOwner.items & IT_ROCKET_LAUNCHER))
  397. {
  398. sprint (comboOwner, "$qc_multi_rl_enabled");
  399. comboOwner.items = comboOwner.items | IT_MULTI_ROCKET;
  400. }
  401. }
  402. if (!(comboOwner.items & IT_PLASMA_GUN))
  403. {
  404. if (comboOwner.ammo_plasma > 0 && (comboOwner.items & IT_LIGHTNING))
  405. {
  406. sprint (comboOwner, "$qc_plasma_enabled");
  407. comboOwner.items = comboOwner.items | IT_PLASMA_GUN;
  408. }
  409. }
  410. };
  411. /*
  412. =============
  413. weapon_touch
  414. =============
  415. */
  416. float() W_BestWeapon;
  417. float(entity playerEnt, float old, float new) W_WantsToChangeWeapon;
  418. void() weapon_touch =
  419. {
  420. local float hadammo, best, new, old;
  421. local entity stemp;
  422. local float leave;
  423. if (!(other.flags & FL_CLIENT))
  424. return;
  425. // if the player was using his best weapon, change up to the new one if better
  426. stemp = self;
  427. self = other;
  428. best = W_BestWeapon();
  429. self = stemp;
  430. if (coop || deathmatch == 2 || deathmatch == 3 || deathmatch == 5)
  431. leave = 1;
  432. else
  433. leave = 0;
  434. if (self.classname == "weapon_nailgun")
  435. {
  436. if (leave && (other.items & IT_NAILGUN) )
  437. return;
  438. hadammo = other.ammo_nails1;
  439. new = IT_NAILGUN;
  440. if (leave)
  441. other.ammo_lava_nails = other.ammo_lava_nails + 20;
  442. other.ammo_nails1 = other.ammo_nails1 + 30;
  443. }
  444. else if (self.classname == "weapon_supernailgun")
  445. {
  446. if (leave && (other.items & IT_SUPER_NAILGUN) )
  447. return;
  448. hadammo = other.ammo_rockets1;
  449. new = IT_SUPER_NAILGUN;
  450. if (leave)
  451. other.ammo_lava_nails = other.ammo_lava_nails + 20;
  452. other.ammo_nails1 = other.ammo_nails1 + 30;
  453. }
  454. else if (self.classname == "weapon_supershotgun")
  455. {
  456. if (leave && (other.items & IT_SUPER_SHOTGUN) )
  457. return;
  458. hadammo = other.ammo_rockets1;
  459. new = IT_SUPER_SHOTGUN;
  460. other.ammo_shells1 = other.ammo_shells1 + 5;
  461. }
  462. else if (self.classname == "weapon_rocketlauncher")
  463. {
  464. if (leave && (other.items & IT_ROCKET_LAUNCHER) )
  465. return;
  466. hadammo = other.ammo_rockets1;
  467. new = IT_ROCKET_LAUNCHER;
  468. if (leave)
  469. other.ammo_multi_rockets = other.ammo_multi_rockets + 3;
  470. other.ammo_rockets1 = other.ammo_rockets1 + 5;
  471. }
  472. else if (self.classname == "weapon_grenadelauncher")
  473. {
  474. if (leave && (other.items & IT_GRENADE_LAUNCHER) )
  475. return;
  476. hadammo = other.ammo_rockets1;
  477. new = IT_GRENADE_LAUNCHER;
  478. if (leave)
  479. other.ammo_multi_rockets = other.ammo_multi_rockets + 3;
  480. other.ammo_rockets1 = other.ammo_rockets1 + 5;
  481. }
  482. else if (self.classname == "weapon_lightning")
  483. {
  484. if (leave && (other.items & IT_LIGHTNING) )
  485. return;
  486. hadammo = other.ammo_rockets1;
  487. new = IT_LIGHTNING;
  488. if (leave)
  489. other.ammo_plasma = other.ammo_plasma + 5;
  490. other.ammo_cells1 = other.ammo_cells1 + 15;
  491. }
  492. else
  493. objerror ("weapon_touch: unknown classname");
  494. sprint(other, "$qc_got_item", self.netname);
  495. // weapon touch sound
  496. sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
  497. stuffcmd (other, "bf\n");
  498. bound_other_ammo ();
  499. // change to the weapon
  500. old = other.items;
  501. other.items = other.items | new;
  502. EnableComboWeapons ( other );
  503. // PGM - fake picking up the plasma gun.
  504. if (new == IT_LIGHTNING)
  505. {
  506. if (other.ammo_plasma > 0)
  507. new = IT_PLASMA_GUN;
  508. }
  509. else if (new == IT_ROCKET_LAUNCHER)
  510. {
  511. if (other.ammo_multi_rockets > 0)
  512. new = IT_MULTI_ROCKET;
  513. }
  514. else if (new == IT_GRENADE_LAUNCHER)
  515. {
  516. if (other.ammo_multi_rockets > 0)
  517. new = IT_MULTI_GRENADE;
  518. }
  519. else if (new == IT_SUPER_NAILGUN)
  520. {
  521. if (other.ammo_lava_nails > 1)
  522. new = IT_LAVA_SUPER_NAILGUN;
  523. }
  524. else if (new == IT_NAILGUN)
  525. {
  526. if (other.ammo_lava_nails > 0)
  527. new = IT_LAVA_NAILGUN;
  528. }
  529. stemp = self;
  530. self = other;
  531. if(W_WantsToChangeWeapon(other, old, other.items) == 1)
  532. {
  533. if (!deathmatch)
  534. self.weapon = new;
  535. else
  536. Deathmatch_Weapon (old, new);
  537. }
  538. UpdateAmmoCounts ( self );
  539. W_SetCurrentAmmo();
  540. self = stemp;
  541. if (leave)
  542. return;
  543. // remove it in single player, or setup for respawning in deathmatch
  544. self.model = string_null;
  545. self.solid = SOLID_NOT;
  546. if (deathmatch && deathmatch != 2)
  547. self.nextthink = time + 30;
  548. self.think = SUB_regen;
  549. activator = other;
  550. SUB_UseTargets(); // fire all targets / killtargets
  551. };
  552. /*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
  553. */
  554. void() weapon_supershotgun =
  555. {
  556. precache_model ("progs/g_shot.mdl");
  557. setmodel (self, "progs/g_shot.mdl");
  558. self.weapon = IT_SUPER_SHOTGUN;
  559. self.netname = "$qc_double_shotgun";
  560. self.touch = weapon_touch;
  561. setsize (self, '-16 -16 0', '16 16 56');
  562. StartItem ();
  563. };
  564. /*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  565. */
  566. void() weapon_nailgun =
  567. {
  568. precache_model ("progs/g_nail.mdl");
  569. setmodel (self, "progs/g_nail.mdl");
  570. self.weapon = IT_NAILGUN;
  571. self.netname = "$qc_nailgun";
  572. self.touch = weapon_touch;
  573. setsize (self, '-16 -16 0', '16 16 56');
  574. StartItem ();
  575. };
  576. /*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  577. */
  578. void() weapon_supernailgun =
  579. {
  580. precache_model ("progs/g_nail2.mdl");
  581. setmodel (self, "progs/g_nail2.mdl");
  582. self.weapon = IT_SUPER_NAILGUN;
  583. self.netname = "$qc_super_nailgun";
  584. self.touch = weapon_touch;
  585. setsize (self, '-16 -16 0', '16 16 56');
  586. StartItem ();
  587. };
  588. /*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  589. */
  590. void() weapon_grenadelauncher =
  591. {
  592. precache_model ("progs/g_rock.mdl");
  593. setmodel (self, "progs/g_rock.mdl");
  594. self.weapon = IT_GRENADE_LAUNCHER;
  595. self.netname = "$qc_grenade_launcher";
  596. self.touch = weapon_touch;
  597. setsize (self, '-16 -16 0', '16 16 56');
  598. StartItem ();
  599. };
  600. /*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  601. */
  602. void() weapon_rocketlauncher =
  603. {
  604. precache_model ("progs/g_rock2.mdl");
  605. setmodel (self, "progs/g_rock2.mdl");
  606. self.weapon = IT_ROCKET_LAUNCHER;
  607. self.netname = "$qc_rocket_launcher";
  608. self.touch = weapon_touch;
  609. setsize (self, '-16 -16 0', '16 16 56');
  610. StartItem ();
  611. };
  612. /*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
  613. */
  614. void() weapon_lightning =
  615. {
  616. precache_model ("progs/g_light.mdl");
  617. setmodel (self, "progs/g_light.mdl");
  618. self.weapon = IT_LIGHTNING;
  619. self.netname = "$qc_thunderbolt";
  620. self.touch = weapon_touch;
  621. setsize (self, '-16 -16 0', '16 16 56');
  622. StartItem ();
  623. };
  624. /*
  625. ===============================================================================
  626. AMMO
  627. ===============================================================================
  628. */
  629. void() ammo_touch =
  630. {
  631. local entity stemp;
  632. local float best;
  633. if (other.classname != "player")
  634. return;
  635. if (other.health <= 0)
  636. return;
  637. // if the player was using his best weapon, change up to the new one if better
  638. stemp = self;
  639. self = other;
  640. best = W_BestWeapon();
  641. self = stemp;
  642. // by this point, other is the player and self is the ammo pack. - PGM
  643. // shotgun
  644. if (self.weapon == 1)
  645. {
  646. if (other.ammo_shells1 >= 100)
  647. return;
  648. other.ammo_shells1 = other.ammo_shells1 + self.aflag;
  649. }
  650. // spikes
  651. if (self.weapon == 2)
  652. {
  653. if (other.ammo_nails1 >= 200)
  654. return;
  655. other.ammo_nails1 = other.ammo_nails1 + self.aflag;
  656. }
  657. // rockets
  658. if (self.weapon == 3)
  659. {
  660. if (other.ammo_rockets1 >= 100)
  661. return;
  662. other.ammo_rockets1 = other.ammo_rockets1 + self.aflag;
  663. }
  664. // cells
  665. if (self.weapon == 4)
  666. {
  667. if (other.ammo_cells1 >= 100)
  668. return;
  669. other.ammo_cells1 = other.ammo_cells1 + self.aflag;
  670. }
  671. // lava spikes
  672. if (self.weapon == 5)
  673. {
  674. if(other.ammo_lava_nails >= 200)
  675. return;
  676. other.ammo_lava_nails = other.ammo_lava_nails + self.aflag;
  677. }
  678. // multi grenades
  679. if (self.weapon == 6)
  680. {
  681. if(other.ammo_multi_rockets >= 100)
  682. return;
  683. other.ammo_multi_rockets = other.ammo_multi_rockets + self.aflag;
  684. }
  685. // plasma
  686. if (self.weapon == 7)
  687. {
  688. if(other.ammo_plasma >= 100)
  689. return;
  690. other.ammo_plasma = other.ammo_plasma + self.aflag;
  691. }
  692. EnableComboWeapons ( other );
  693. UpdateAmmoCounts ( other );
  694. bound_other_ammo ();
  695. sprint(other, "$qc_got_item", self.netname);
  696. // ammo touch sound
  697. sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  698. stuffcmd (other, "bf\n");
  699. // change to a better weapon if appropriate
  700. if ( other.weapon == best && (W_WantsToChangeWeapon(other, 0, 1) == 1))
  701. {
  702. stemp = self;
  703. self = other;
  704. self.weapon = W_BestWeapon();
  705. W_SetCurrentAmmo ();
  706. self = stemp;
  707. }
  708. // if changed current ammo, update it
  709. stemp = self;
  710. self = other;
  711. W_SetCurrentAmmo();
  712. self = stemp;
  713. // remove it in single player, or setup for respawning in deathmatch
  714. self.model = string_null;
  715. self.solid = SOLID_NOT;
  716. if (deathmatch) {
  717. if (deathmatch == 3 || deathmatch == 5) {
  718. self.nextthink = time + 15;
  719. } else if (deathmatch != 2) {
  720. self.nextthink = time + 30;
  721. }
  722. }
  723. self.think = SUB_regen;
  724. activator = other;
  725. SUB_UseTargets(); // fire all targets / killtargets
  726. };
  727. float WEAPON_BIG2 = 1;
  728. /*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
  729. Small box is 20, Big box is 40.
  730. */
  731. void() item_shells =
  732. {
  733. self.touch = ammo_touch;
  734. if (self.spawnflags & WEAPON_BIG2)
  735. {
  736. precache_model ("maps/b_shell1.bsp");
  737. setmodel (self, "maps/b_shell1.bsp");
  738. self.aflag = 40;
  739. }
  740. else
  741. {
  742. precache_model ("maps/b_shell0.bsp");
  743. setmodel (self, "maps/b_shell0.bsp");
  744. self.aflag = 20;
  745. }
  746. self.weapon = 1;
  747. self.netname = "$qc_shells";
  748. setsize (self, '0 0 0', '32 32 56');
  749. StartItem ();
  750. };
  751. /*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
  752. Small box is 25, Big box is 50.
  753. */
  754. void() item_spikes =
  755. {
  756. self.touch = ammo_touch;
  757. if (self.spawnflags & WEAPON_BIG2)
  758. {
  759. precache_model ("maps/b_nail1.bsp");
  760. setmodel (self, "maps/b_nail1.bsp");
  761. self.aflag = 50;
  762. }
  763. else
  764. {
  765. precache_model ("maps/b_nail0.bsp");
  766. setmodel (self, "maps/b_nail0.bsp");
  767. self.aflag = 25;
  768. }
  769. self.weapon = 2;
  770. self.netname = "$qc_nails";
  771. setsize (self, '0 0 0', '32 32 56');
  772. StartItem ();
  773. };
  774. /*QUAKED item_lava_spikes (0 .5 .8) (0 0 0) (32 32 32) big
  775. Small box is 25, Big box is 50.
  776. */
  777. void() item_lava_spikes =
  778. {
  779. self.touch = ammo_touch;
  780. if (self.spawnflags & WEAPON_BIG2)
  781. {
  782. precache_model ("maps/b_lnail1.bsp");
  783. setmodel (self, "maps/b_lnail1.bsp");
  784. self.aflag = 50;
  785. }
  786. else
  787. {
  788. precache_model ("maps/b_lnail0.bsp");
  789. setmodel (self, "maps/b_lnail0.bsp");
  790. self.aflag = 25;
  791. }
  792. self.weapon = 5;
  793. self.netname = "$qc_lava_nails";
  794. setsize (self, '0 0 0', '32 32 56');
  795. StartItem ();
  796. };
  797. /*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
  798. Small box is 5, Big box is 10.
  799. */
  800. void() item_rockets =
  801. {
  802. self.touch = ammo_touch;
  803. if (self.spawnflags & WEAPON_BIG2)
  804. {
  805. precache_model ("maps/b_rock1.bsp");
  806. setmodel (self, "maps/b_rock1.bsp");
  807. self.aflag = 10;
  808. }
  809. else
  810. {
  811. precache_model ("maps/b_rock0.bsp");
  812. setmodel (self, "maps/b_rock0.bsp");
  813. self.aflag = 5;
  814. }
  815. self.weapon = 3;
  816. self.netname = "$qc_rockets";
  817. setsize (self, '0 0 0', '32 32 56');
  818. StartItem ();
  819. };
  820. /*QUAKED item_multi_rockets (0 .5 .8) (0 0 0) (32 32 32) big
  821. Small box is 5, Big box is 10.
  822. */
  823. void() item_multi_rockets =
  824. {
  825. self.touch = ammo_touch;
  826. if (self.spawnflags & WEAPON_BIG2)
  827. {
  828. precache_model ("maps/b_mrock1.bsp");
  829. setmodel (self, "maps/b_mrock1.bsp");
  830. self.aflag = 10;
  831. }
  832. else
  833. {
  834. precache_model ("maps/b_mrock0.bsp");
  835. setmodel (self, "maps/b_mrock0.bsp");
  836. self.aflag = 5;
  837. }
  838. self.weapon = 6;
  839. self.netname = "$qc_multi_rockets";
  840. setsize (self, '0 0 0', '32 32 56');
  841. StartItem ();
  842. };
  843. /*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
  844. Small box is 6, Big box is 12.
  845. */
  846. void() item_cells =
  847. {
  848. self.touch = ammo_touch;
  849. if (self.spawnflags & WEAPON_BIG2)
  850. {
  851. precache_model ("maps/b_batt1.bsp");
  852. setmodel (self, "maps/b_batt1.bsp");
  853. self.aflag = 12;
  854. }
  855. else
  856. {
  857. precache_model ("maps/b_batt0.bsp");
  858. setmodel (self, "maps/b_batt0.bsp");
  859. self.aflag = 6;
  860. }
  861. self.weapon = 4;
  862. self.netname = "$qc_cells";
  863. setsize (self, '0 0 0', '32 32 56');
  864. StartItem ();
  865. };
  866. /*QUAKED item_plasma (0 .5 .8) (0 0 0) (32 32 32) big
  867. Small box is 6, Big box is 12.
  868. */
  869. void() item_plasma =
  870. {
  871. self.touch = ammo_touch;
  872. if (self.spawnflags & WEAPON_BIG2)
  873. {
  874. precache_model ("maps/b_plas1.bsp");
  875. setmodel (self, "maps/b_plas1.bsp");
  876. self.aflag = 12;
  877. }
  878. else
  879. {
  880. precache_model ("maps/b_plas0.bsp");
  881. setmodel (self, "maps/b_plas0.bsp");
  882. self.aflag = 6;
  883. }
  884. self.weapon = 7;
  885. self.netname = "plasma";
  886. setsize (self, '0 0 0', '32 32 56');
  887. StartItem ();
  888. };
  889. /*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big
  890. DO NOT USE THIS!!!! IT WILL BE REMOVED!
  891. */
  892. float WEAPON_SHOTGUN = 1;
  893. float WEAPON_ROCKET = 2;
  894. float WEAPON_SPIKES = 4;
  895. float WEAPON_BIG = 8;
  896. void() item_weapon =
  897. {
  898. self.touch = ammo_touch;
  899. if (self.spawnflags & WEAPON_SHOTGUN)
  900. {
  901. if (self.spawnflags & WEAPON_BIG)
  902. {
  903. precache_model ("maps/b_shell1.bsp");
  904. setmodel (self, "maps/b_shell1.bsp");
  905. self.aflag = 40;
  906. }
  907. else
  908. {
  909. precache_model ("maps/b_shell0.bsp");
  910. setmodel (self, "maps/b_shell0.bsp");
  911. self.aflag = 20;
  912. }
  913. self.weapon = 1;
  914. self.netname = "$qc_shells";
  915. }
  916. if (self.spawnflags & WEAPON_SPIKES)
  917. {
  918. if (self.spawnflags & WEAPON_BIG)
  919. {
  920. precache_model ("maps/b_nail1.bsp");
  921. setmodel (self, "maps/b_nail1.bsp");
  922. self.aflag = 40;
  923. }
  924. else
  925. {
  926. precache_model ("maps/b_nail0.bsp");
  927. setmodel (self, "maps/b_nail0.bsp");
  928. self.aflag = 20;
  929. }
  930. self.weapon = 2;
  931. self.netname = "$qc_spikes";
  932. }
  933. if (self.spawnflags & WEAPON_ROCKET)
  934. {
  935. if (self.spawnflags & WEAPON_BIG)
  936. {
  937. precache_model ("maps/b_rock1.bsp");
  938. setmodel (self, "maps/b_rock1.bsp");
  939. self.aflag = 10;
  940. }
  941. else
  942. {
  943. precache_model ("maps/b_rock0.bsp");
  944. setmodel (self, "maps/b_rock0.bsp");
  945. self.aflag = 5;
  946. }
  947. self.weapon = 3;
  948. self.netname = "$qc_rockets";
  949. }
  950. setsize (self, '0 0 0', '32 32 56');
  951. StartItem ();
  952. };
  953. /*
  954. ===============================================================================
  955. KEYS
  956. ===============================================================================
  957. */
  958. void() key_touch =
  959. {
  960. local entity stemp;
  961. local float best;
  962. if (other.classname != "player")
  963. return;
  964. if (other.health <= 0)
  965. return;
  966. if (other.items & self.items)
  967. return;
  968. sprint(other, "$qc_got_item", self.netname);
  969. sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  970. stuffcmd (other, "bf\n");
  971. other.items = other.items | self.items;
  972. if (!coop)
  973. {
  974. self.solid = SOLID_NOT;
  975. self.model = string_null;
  976. }
  977. activator = other;
  978. SUB_UseTargets(); // fire all targets / killtargets
  979. };
  980. void() key_setsounds =
  981. {
  982. if (world.worldtype == 0)
  983. {
  984. precache_sound ("misc/medkey.wav");
  985. self.noise = "misc/medkey.wav";
  986. }
  987. if (world.worldtype == 1)
  988. {
  989. precache_sound ("misc/runekey.wav");
  990. self.noise = "misc/runekey.wav";
  991. }
  992. if (world.worldtype == 2)
  993. {
  994. precache_sound2 ("misc/basekey.wav");
  995. self.noise = "misc/basekey.wav";
  996. }
  997. };
  998. /*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32)
  999. SILVER key
  1000. In order for keys to work
  1001. you MUST set your maps
  1002. worldtype to one of the
  1003. following:
  1004. 0: medieval
  1005. 1: metal
  1006. 2: base
  1007. */
  1008. void() item_key1 =
  1009. {
  1010. if (world.worldtype == 0)
  1011. {
  1012. precache_model ("progs/w_s_key.mdl");
  1013. setmodel (self, "progs/w_s_key.mdl");
  1014. self.netname = "$qc_silver_key";
  1015. }
  1016. else if (world.worldtype == 1)
  1017. {
  1018. precache_model ("progs/m_s_key.mdl");
  1019. setmodel (self, "progs/m_s_key.mdl");
  1020. self.netname = "$qc_silver_runekey";
  1021. }
  1022. else if (world.worldtype == 2)
  1023. {
  1024. precache_model2 ("progs/b_s_key.mdl");
  1025. setmodel (self, "progs/b_s_key.mdl");
  1026. self.netname = "$qc_silver_keycard";
  1027. }
  1028. key_setsounds();
  1029. self.touch = key_touch;
  1030. self.items = IT_KEY1;
  1031. setsize (self, '-16 -16 -24', '16 16 32');
  1032. StartItem ();
  1033. };
  1034. /*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32)
  1035. GOLD key
  1036. In order for keys to work
  1037. you MUST set your maps
  1038. worldtype to one of the
  1039. following:
  1040. 0: medieval
  1041. 1: metal
  1042. 2: base
  1043. */
  1044. void() item_key2 =
  1045. {
  1046. if (world.worldtype == 0)
  1047. {
  1048. precache_model ("progs/w_g_key.mdl");
  1049. setmodel (self, "progs/w_g_key.mdl");
  1050. self.netname = "$qc_gold_key";
  1051. }
  1052. if (world.worldtype == 1)
  1053. {
  1054. precache_model ("progs/m_g_key.mdl");
  1055. setmodel (self, "progs/m_g_key.mdl");
  1056. self.netname = "$qc_gold_runekey";
  1057. }
  1058. if (world.worldtype == 2)
  1059. {
  1060. precache_model2 ("progs/b_g_key.mdl");
  1061. setmodel (self, "progs/b_g_key.mdl");
  1062. self.netname = "$qc_gold_keycard";
  1063. }
  1064. key_setsounds();
  1065. self.touch = key_touch;
  1066. self.items = IT_KEY2;
  1067. setsize (self, '-16 -16 -24', '16 16 32');
  1068. StartItem ();
  1069. };
  1070. /*
  1071. ===============================================================================
  1072. END OF LEVEL RUNES
  1073. ===============================================================================
  1074. */
  1075. void() sigil_touch =
  1076. {
  1077. local entity stemp;
  1078. local float best;
  1079. if (other.classname != "player")
  1080. return;
  1081. if (other.health <= 0)
  1082. return;
  1083. centerprint(other, "$qc_got_rune");
  1084. sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  1085. stuffcmd (other, "bf\n");
  1086. self.solid = SOLID_NOT;
  1087. self.model = string_null;
  1088. serverflags = serverflags | (self.spawnflags & 15);
  1089. self.classname = ""; // so rune doors won't find it
  1090. activator = other;
  1091. SUB_UseTargets(); // fire all targets / killtargets
  1092. };
  1093. /*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4
  1094. End of level sigil, pick up to end episode and return to jrstart.
  1095. */
  1096. void() item_sigil =
  1097. {
  1098. if (!self.spawnflags)
  1099. objerror ("no spawnflags");
  1100. precache_sound ("misc/runekey.wav");
  1101. self.noise = "misc/runekey.wav";
  1102. if (self.spawnflags & 1)
  1103. {
  1104. precache_model ("progs/end1.mdl");
  1105. setmodel (self, "progs/end1.mdl");
  1106. }
  1107. if (self.spawnflags & 2)
  1108. {
  1109. precache_model2 ("progs/end2.mdl");
  1110. setmodel (self, "progs/end2.mdl");
  1111. }
  1112. if (self.spawnflags & 4)
  1113. {
  1114. precache_model2 ("progs/end3.mdl");
  1115. setmodel (self, "progs/end3.mdl");
  1116. }
  1117. if (self.spawnflags & 8)
  1118. {
  1119. precache_model2 ("progs/end4.mdl");
  1120. setmodel (self, "progs/end4.mdl");
  1121. }
  1122. self.touch = sigil_touch;
  1123. setsize (self, '-16 -16 -24', '16 16 32');
  1124. StartItem ();
  1125. };
  1126. /*
  1127. ===============================================================================
  1128. POWERUPS
  1129. ===============================================================================
  1130. */
  1131. void() powerup_touch;
  1132. void() random_regen;
  1133. void() powerup_touch =
  1134. {
  1135. local entity stemp;
  1136. local float best;
  1137. if (other.classname != "player")
  1138. return;
  1139. if (other.health <= 0)
  1140. return;
  1141. sprint(other, "$qc_got_item", self.netname);
  1142. if (deathmatch)
  1143. {
  1144. self.mdl = self.model;
  1145. if (self.classname == "item_random_powerup")
  1146. {
  1147. self.nextthink = time + 30;
  1148. self.think = random_regen;
  1149. }
  1150. else
  1151. {
  1152. if ((self.classname == "item_artifact_invulnerability") ||
  1153. (self.classname == "item_artifact_invisibility"))
  1154. self.nextthink = time + 60*5;
  1155. else
  1156. self.nextthink = time + 60;
  1157. self.think = SUB_regen;
  1158. }
  1159. }
  1160. sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  1161. stuffcmd (other, "bf\n");
  1162. self.solid = SOLID_NOT;
  1163. other.items = other.items | self.items;
  1164. self.model = string_null;
  1165. // do the apropriate action
  1166. // if (self.classname == "item_artifact_envirosuit")
  1167. if (self.netname == "$qc_biosuit")
  1168. {
  1169. other.rad_time = 1;
  1170. other.radsuit_finished = time + 30;
  1171. }
  1172. // if (self.classname == "item_artifact_invulnerability")
  1173. if (self.netname == "$qc_pentagram_of_protection")
  1174. {
  1175. other.invincible_time = 1;
  1176. other.invincible_finished = time + 30;
  1177. }
  1178. // if (self.classname == "item_artifact_invisibility")
  1179. if (self.netname == "$qc_ring_of_shadows")
  1180. {
  1181. other.invisible_time = 1;
  1182. other.invisible_finished = time + 30;
  1183. }
  1184. // if (self.classname == "item_artifact_super_damage")
  1185. if (self.netname == "$qc_quad_damage")
  1186. {
  1187. other.super_time = 1;
  1188. other.super_damage_finished = time + 30;
  1189. }
  1190. activator = other;
  1191. SUB_UseTargets(); // fire all targets / killtargets
  1192. };
  1193. /*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32)
  1194. Player is invulnerable for 30 seconds
  1195. */
  1196. void() item_artifact_invulnerability =
  1197. {
  1198. self.touch = powerup_touch;
  1199. precache_model ("progs/invulner.mdl");
  1200. precache_sound ("items/protect.wav");
  1201. precache_sound ("items/protect2.wav");
  1202. precache_sound ("items/protect3.wav");
  1203. self.noise = "items/protect.wav";
  1204. setmodel (self, "progs/invulner.mdl");
  1205. self.netname = "$qc_pentagram_of_protection";
  1206. self.items = IT_INVULNERABILITY;
  1207. setsize (self, '-16 -16 -24', '16 16 32');
  1208. StartItem ();
  1209. };
  1210. /*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32)
  1211. Player takes no damage from water or slime for 30 seconds
  1212. */
  1213. void() item_artifact_envirosuit =
  1214. {
  1215. self.touch = powerup_touch;
  1216. precache_model ("progs/suit.mdl");
  1217. precache_sound ("items/suit.wav");
  1218. precache_sound ("items/suit2.wav");
  1219. self.noise = "items/suit.wav";
  1220. setmodel (self, "progs/suit.mdl");
  1221. self.netname = "$qc_biosuit";
  1222. self.items = IT_SUIT;
  1223. setsize (self, '-16 -16 -24', '16 16 32');
  1224. StartItem ();
  1225. };
  1226. /*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32)
  1227. Player is invisible for 30 seconds
  1228. */
  1229. void() item_artifact_invisibility =
  1230. {
  1231. self.touch = powerup_touch;
  1232. precache_model ("progs/invisibl.mdl");
  1233. precache_sound ("items/inv1.wav");
  1234. precache_sound ("items/inv2.wav");
  1235. precache_sound ("items/inv3.wav");
  1236. self.noise = "items/inv1.wav";
  1237. setmodel (self, "progs/invisibl.mdl");
  1238. self.netname = "$qc_ring_of_shadows";
  1239. self.items = IT_INVISIBILITY;
  1240. setsize (self, '-16 -16 -24', '16 16 32');
  1241. StartItem ();
  1242. };
  1243. /*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32)
  1244. The next attack from the player will do 4x damage
  1245. */
  1246. void() item_artifact_super_damage =
  1247. {
  1248. self.touch = powerup_touch;
  1249. precache_model ("progs/quaddama.mdl");
  1250. precache_sound ("items/damage.wav");
  1251. precache_sound ("items/damage2.wav");
  1252. precache_sound ("items/damage3.wav");
  1253. self.noise = "items/damage.wav";
  1254. setmodel (self, "progs/quaddama.mdl");
  1255. self.netname = "$qc_quad_damage";
  1256. self.items = IT_QUAD;
  1257. setsize (self, '-16 -16 -24', '16 16 32');
  1258. StartItem ();
  1259. };
  1260. /*
  1261. ===============================================================================
  1262. PLAYER BACKPACKS
  1263. ===============================================================================
  1264. */
  1265. void() BackpackTouch =
  1266. {
  1267. local string s;
  1268. local float best, old, new;
  1269. local entity stemp;
  1270. local float acount;
  1271. if (other.classname != "player")
  1272. return;
  1273. if (other.health <= 0)
  1274. return;
  1275. //ZOID--
  1276. // Don't let the owner pick up his own backpack for a second.
  1277. if ((other == self.owner) && ((self.nextthink - time) > 119))
  1278. return;
  1279. //--ZOID
  1280. acount = 0;
  1281. sprint(other, "$qc_backpack_got");
  1282. if (self.items)
  1283. {
  1284. if ((other.items & self.items) == 0)
  1285. {
  1286. acount = 1;
  1287. sprint(other, "{}", self.netname);
  1288. }
  1289. }
  1290. // if the player was using his best weapon, change up to the new one if better
  1291. stemp = self;
  1292. self = other;
  1293. best = W_BestWeapon();
  1294. self = stemp;
  1295. // change weapons
  1296. other.ammo_shells1 = other.ammo_shells1 + self.ammo_shells1;
  1297. other.ammo_nails1 = other.ammo_nails1 + self.ammo_nails1;
  1298. other.ammo_rockets1 = other.ammo_rockets1 + self.ammo_rockets1;
  1299. other.ammo_cells1 = other.ammo_cells1 + self.ammo_cells1;
  1300. other.ammo_lava_nails = other.ammo_lava_nails + self.ammo_lava_nails;
  1301. other.ammo_multi_rockets = other.ammo_multi_rockets +
  1302. self.ammo_multi_rockets;
  1303. other.ammo_plasma = other.ammo_plasma + self.ammo_plasma;
  1304. new = self.items;
  1305. if (!new)
  1306. new = other.weapon;
  1307. old = other.items;
  1308. other.items = other.items | self.items;
  1309. bound_other_ammo ();
  1310. if (self.ammo_shells1)
  1311. {
  1312. if (acount)
  1313. if (acount)
  1314. sprint(other, ", ");
  1315. acount = 1;
  1316. sprint(other, "$qc_backpack_shells", ftos(self.ammo_shells1));
  1317. }
  1318. if (self.ammo_nails1)
  1319. {
  1320. if (acount)
  1321. sprint(other, ", ");
  1322. acount = 1;
  1323. sprint(other, "$qc_backpack_nails", ftos(self.ammo_nails1));
  1324. }
  1325. if (self.ammo_rockets1)
  1326. {
  1327. if (acount)
  1328. sprint(other, ", ");
  1329. acount = 1;
  1330. sprint(other, "$qc_backpack_rockets", ftos(self.ammo_rockets1));
  1331. }
  1332. if (self.ammo_cells1)
  1333. {
  1334. if (acount)
  1335. sprint(other, ", ");
  1336. acount = 1;
  1337. sprint(other, "$qc_backpack_cells", ftos(self.ammo_cells1));
  1338. }
  1339. if (self.ammo_lava_nails)
  1340. {
  1341. if (acount)
  1342. sprint(other, ", ");
  1343. acount = 1;
  1344. sprint(other, "$qc_backpack_lava_nails", ftos(self.ammo_lava_nails));
  1345. }
  1346. if (self.ammo_multi_rockets)
  1347. {
  1348. if (acount)
  1349. sprint(other, ", ");
  1350. acount = 1;
  1351. sprint(other, "$qc_backpack_multi_rockets", ftos(self.ammo_multi_rockets));
  1352. }
  1353. if (self.ammo_plasma)
  1354. {
  1355. if (acount)
  1356. sprint(other, ", ");
  1357. acount = 1;
  1358. sprint(other, "$qc_backpack_plasma_balls", ftos(self.ammo_plasma));
  1359. }
  1360. sprint (other, "\n");
  1361. // backpack touch sound
  1362. sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  1363. stuffcmd (other, "bf\n");
  1364. // remove the backpack, change self to the player
  1365. remove(self);
  1366. self = other;
  1367. // fixme -- move this to after weapon choice if problematic.
  1368. EnableComboWeapons ( self );
  1369. // change to the weapon
  1370. if(W_WantsToChangeWeapon(other, old, other.items) == 1)
  1371. {
  1372. if (!deathmatch)
  1373. self.weapon = new;
  1374. else
  1375. Deathmatch_Weapon (old, new);
  1376. }
  1377. // EnableComboWeapons ( self );
  1378. UpdateAmmoCounts (self);
  1379. W_SetCurrentAmmo ();
  1380. };
  1381. /*
  1382. ===============
  1383. DropBackpack
  1384. ===============
  1385. */
  1386. void() DropBackpack =
  1387. {
  1388. local entity item;
  1389. // this is to compensate for the new way we're hacking the ammo
  1390. // counts. If they're monsters, just copy shells->shells1 etc.
  1391. if (self.flags & FL_MONSTER)
  1392. {
  1393. self.ammo_shells1 = self.ammo_shells;
  1394. self.ammo_nails1 = self.ammo_nails;
  1395. self.ammo_rockets1 = self.ammo_rockets;
  1396. self.ammo_cells1 = self.ammo_cells;
  1397. }
  1398. if (!(self.ammo_shells1 + self.ammo_nails1 + self.ammo_rockets1 +
  1399. self.ammo_cells1 + self.ammo_lava_nails + self.ammo_multi_rockets))
  1400. return; // nothing in it
  1401. item = spawn();
  1402. item.origin = self.origin - '0 0 24';
  1403. item.items = self.weapon;
  1404. item.classname = "item_backpack"; // added for bots.
  1405. if (item.items == IT_AXE)
  1406. item.netname = "$qc_axe";
  1407. else if (item.items == IT_SHOTGUN)
  1408. item.netname = "$qc_shotgun";
  1409. else if (item.items == IT_SUPER_SHOTGUN)
  1410. item.netname = "$qc_double_shotgun";
  1411. else if (item.items == IT_NAILGUN)
  1412. item.netname = "$qc_nailgun";
  1413. else if (item.items == IT_SUPER_NAILGUN)
  1414. item.netname = "$qc_super_nailgun";
  1415. else if (item.items == IT_GRENADE_LAUNCHER)
  1416. item.netname = "$qc_grenade_launcher";
  1417. else if (item.items == IT_ROCKET_LAUNCHER)
  1418. item.netname = "$qc_rocket_launcher";
  1419. else if (item.items == IT_LIGHTNING)
  1420. item.netname = "$qc_thunderbolt";
  1421. else if (item.items == IT_LAVA_NAILGUN)
  1422. {
  1423. item.netname = "$qc_got_lava_nailgun";
  1424. item.items = IT_NAILGUN;
  1425. }
  1426. else if (item.items == IT_LAVA_SUPER_NAILGUN)
  1427. {
  1428. item.netname = "$qc_got_super_lava_nailgun";
  1429. item.items = IT_SUPER_NAILGUN;
  1430. }
  1431. else if (item.items == IT_MULTI_GRENADE)
  1432. {
  1433. item.netname = "$qc_got_multi_gl";
  1434. item.items = IT_GRENADE_LAUNCHER;
  1435. }
  1436. else if (item.items == IT_MULTI_ROCKET)
  1437. {
  1438. item.netname = "$qc_got_multi_rl";
  1439. item.items = IT_ROCKET_LAUNCHER;
  1440. }
  1441. else if (item.items == IT_PLASMA_GUN)
  1442. {
  1443. item.netname = "$qc_got_plasma_gun";
  1444. item.items = IT_LIGHTNING;
  1445. }
  1446. else
  1447. item.netname = "";
  1448. item.ammo_shells1 = self.ammo_shells1;
  1449. item.ammo_nails1 = self.ammo_nails1;
  1450. item.ammo_rockets1 = self.ammo_rockets1;
  1451. item.ammo_cells1 = self.ammo_cells1;
  1452. item.ammo_lava_nails = self.ammo_lava_nails;
  1453. item.ammo_multi_rockets = self.ammo_multi_rockets;
  1454. item.ammo_plasma = self.ammo_plasma;
  1455. // include some ammo in the backpack if the weapon is being given
  1456. if (item.ammo_shells1 < 5 && (item.items == IT_SHOTGUN || item.items == IT_SUPER_SHOTGUN)) {
  1457. item.ammo_shells1 = 5;
  1458. }
  1459. if (item.ammo_nails1 < 20 && (item.items == IT_NAILGUN || item.items == IT_SUPER_NAILGUN)) {
  1460. item.ammo_nails1 = 20;
  1461. }
  1462. if (item.ammo_rockets1 < 5 && (item.items == IT_GRENADE_LAUNCHER || item.items == IT_ROCKET_LAUNCHER)) {
  1463. item.ammo_rockets1 = 5;
  1464. }
  1465. if (item.ammo_cells1 < 15 && (item.items == IT_LIGHTNING)) {
  1466. item.ammo_cells1 = 15;
  1467. }
  1468. item.velocity_z = 300;
  1469. item.velocity_x = -100 + (random() * 200);
  1470. item.velocity_y = -100 + (random() * 200);
  1471. item.flags = FL_ITEM;
  1472. item.solid = SOLID_TRIGGER;
  1473. item.movetype = MOVETYPE_TOSS;
  1474. setmodel (item, "progs/backpack.mdl");
  1475. setsize (item, '-16 -16 0', '16 16 56');
  1476. item.touch = BackpackTouch;
  1477. item.nextthink = time + 120; // remove after 2 minutes
  1478. item.think = SUB_Remove;
  1479. };