weapons.qc 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544
  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 (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  16. void () player_run;
  17. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  18. void(vector org, vector vel, float damage) SpawnBlood;
  19. void() SuperDamageSound;
  20. void() HasteSound;
  21. // called by worldspawn
  22. void() W_Precache =
  23. {
  24. precache_sound ("hknight/hit.wav"); // flamethrower
  25. precache_sound ("weapons/r_exp3.wav"); // new rocket explosion
  26. precache_sound ("weapons/rocket1i.wav"); // spike gun
  27. precache_sound ("weapons/sgun1.wav");
  28. precache_sound ("weapons/guncock.wav"); // player shotgun
  29. precache_sound ("weapons/ric1.wav"); // ricochet (used in c code)
  30. precache_sound ("weapons/ric2.wav"); // ricochet (used in c code)
  31. precache_sound ("weapons/ric3.wav"); // ricochet (used in c code)
  32. precache_sound ("weapons/spike2.wav"); // super spikes
  33. precache_sound ("weapons/tink1.wav"); // spikes tink (used in c code)
  34. precache_sound ("weapons/grenade.wav"); // grenade launcher
  35. precache_sound ("weapons/bounce.wav"); // grenade bounce
  36. precache_sound ("weapons/shotgn2.wav"); // super shotgun
  37. precache_sound2 ("blob/land1.wav"); // chain go splorch!
  38. precache_sound ("weapons/chain1.wav");
  39. // precache_sound ("weapons/chain2.wav");
  40. // precache_sound ("weapons/chain3.wav");
  41. // precache_sound ("weapons/bounce2.wav");
  42. // ZOID:
  43. // normally the weapon models are precached in the individual item
  44. // creation routines. But since we've added impulse 21 we can drop
  45. // weapons at any time. Must precache all weapon models.
  46. precache_model ("progs/g_shot.mdl");
  47. precache_model ("progs/g_nail.mdl");
  48. precache_model ("progs/g_nail2.mdl");
  49. precache_model ("progs/g_rock.mdl");
  50. precache_model ("progs/g_rock2.mdl");
  51. precache_model ("progs/g_light.mdl");
  52. };
  53. float() crandom =
  54. {
  55. return 2*(random() - 0.5);
  56. };
  57. /*
  58. ================
  59. W_FireAxe
  60. ================
  61. */
  62. void() W_FireAxe =
  63. {
  64. local vector source;
  65. local vector org;
  66. makevectors (self.v_angle);
  67. source = self.origin + '0 0 16';
  68. traceline (source, source + v_forward*64, FALSE, self);
  69. if (trace_fraction == 1.0)
  70. return;
  71. org = trace_endpos - v_forward*4;
  72. if (trace_ent.takedamage)
  73. {
  74. trace_ent.axhitme = 1;
  75. SpawnBlood (org, '0 0 0', 20);
  76. T_Damage (trace_ent, self, self, 20);
  77. }
  78. else
  79. { // hit wall
  80. sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  81. //stuffcmd (self, "vibrate tactile/player/axhit2.bnvib");
  82. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  83. WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  84. WriteCoord (MSG_BROADCAST, org_x);
  85. WriteCoord (MSG_BROADCAST, org_y);
  86. WriteCoord (MSG_BROADCAST, org_z);
  87. }
  88. };
  89. //============================================================================
  90. vector() wall_velocity =
  91. {
  92. local vector vel;
  93. vel = normalize (self.velocity);
  94. vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  95. vel = vel + 2*trace_plane_normal;
  96. vel = vel * 200;
  97. return vel;
  98. };
  99. /*
  100. ================
  101. SpawnMeatSpray
  102. ================
  103. */
  104. void(vector org, vector vel) SpawnMeatSpray =
  105. {
  106. local entity missile;
  107. missile = spawn ();
  108. missile.owner = self;
  109. missile.movetype = MOVETYPE_BOUNCE;
  110. missile.solid = SOLID_NOT;
  111. makevectorsfixed(self.angles);
  112. missile.velocity = vel;
  113. missile.velocity_z = missile.velocity_z + 250 + 50*random();
  114. missile.avelocity = '3000 1000 2000';
  115. // set missile duration
  116. missile.nextthink = time + 1;
  117. missile.think = SUB_Remove;
  118. setmodel (missile, "progs/zom_gib.mdl");
  119. setsize (missile, '0 0 0', '0 0 0');
  120. setorigin (missile, org);
  121. };
  122. /*
  123. ================
  124. SpawnBlood
  125. ================
  126. */
  127. void(vector org, vector vel, float damage) SpawnBlood =
  128. {
  129. particle (org, vel*0.1, 73, damage*2);
  130. };
  131. /*
  132. ================
  133. spawn_touchblood
  134. ================
  135. */
  136. void(float damage) spawn_touchblood =
  137. {
  138. local vector vel;
  139. vel = wall_velocity () * 0.2;
  140. SpawnBlood (self.origin + vel*0.01, vel, damage);
  141. };
  142. /*
  143. ================
  144. SpawnChunk
  145. ================
  146. */
  147. void(vector org, vector vel) SpawnChunk =
  148. {
  149. particle (org, vel*0.02, 0, 10);
  150. };
  151. /*
  152. ==============================================================================
  153. MULTI-DAMAGE
  154. Collects multiple small damages into a single damage
  155. ==============================================================================
  156. */
  157. entity multi_ent;
  158. float multi_damage;
  159. void() ClearMultiDamage =
  160. {
  161. multi_ent = world;
  162. multi_damage = 0;
  163. };
  164. void() ApplyMultiDamage =
  165. {
  166. if (!multi_ent)
  167. return;
  168. T_Damage (multi_ent, self, self, multi_damage);
  169. };
  170. void(entity hit, float damage) AddMultiDamage =
  171. {
  172. if (!hit)
  173. return;
  174. if (hit != multi_ent)
  175. {
  176. ApplyMultiDamage ();
  177. multi_damage = damage;
  178. multi_ent = hit;
  179. }
  180. else
  181. multi_damage = multi_damage + damage;
  182. };
  183. /*
  184. ==============================================================================
  185. BULLETS
  186. ==============================================================================
  187. */
  188. /*
  189. ================
  190. TraceAttack
  191. ================
  192. */
  193. void(float damage, vector dir) TraceAttack =
  194. {
  195. local vector vel, org;
  196. vel = normalize(dir + v_up*crandom() + v_right*crandom());
  197. vel = vel + 2*trace_plane_normal;
  198. vel = vel * 200;
  199. org = trace_endpos - dir*4;
  200. if (trace_ent.takedamage)
  201. {
  202. SpawnBlood (org, vel*0.2, damage);
  203. AddMultiDamage (trace_ent, damage);
  204. }
  205. else
  206. {
  207. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  208. WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  209. WriteCoord (MSG_BROADCAST, org_x);
  210. WriteCoord (MSG_BROADCAST, org_y);
  211. WriteCoord (MSG_BROADCAST, org_z);
  212. }
  213. };
  214. /*
  215. ================
  216. FireBullets
  217. Used by shotgun, super shotgun, and enemy soldier firing
  218. Go to the trouble of combining multiple pellets into a single damage call.
  219. ================
  220. */
  221. void(float shotcount, vector dir, vector spread) FireBullets =
  222. {
  223. local vector direction;
  224. local vector src;
  225. makevectors(self.v_angle);
  226. src = self.origin + v_forward*10;
  227. src_z = self.absmin_z + self.size_z * 0.7;
  228. ClearMultiDamage ();
  229. while (shotcount > 0)
  230. {
  231. direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  232. traceline (src, src + direction*2048, FALSE, self);
  233. if (trace_fraction != 1.0)
  234. TraceAttack (4, direction);
  235. shotcount = shotcount - 1;
  236. }
  237. ApplyMultiDamage ();
  238. };
  239. /*
  240. ================
  241. W_FireShotgun
  242. ================
  243. */
  244. void() W_FireShotgun =
  245. {
  246. local vector dir;
  247. sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
  248. //stuffcmd (self, "vibrate tactile/weapons/guncock.bnvib");
  249. self.punchangle_x = -2;
  250. self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  251. dir = aim (self, 100000);
  252. FireBullets (6, dir, '0.04 0.04 0');
  253. };
  254. /*
  255. ================
  256. W_FireSuperShotgun
  257. ================
  258. */
  259. void() W_FireSuperShotgun =
  260. {
  261. local vector dir;
  262. if (self.currentammo == 1)
  263. {
  264. W_FireShotgun ();
  265. return;
  266. }
  267. sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);
  268. //stuffcmd (self, "vibrate tactile/weapons/shotgn2.bnvib");
  269. self.punchangle_x = -4;
  270. self.currentammo = self.ammo_shells = self.ammo_shells - 2;
  271. dir = aim (self, 100000);
  272. FireBullets (14, dir, '0.14 0.08 0');
  273. };
  274. /*
  275. ==============================================================================
  276. ROCKETS
  277. ==============================================================================
  278. */
  279. void() s_explode1 = [0, s_explode2] {};
  280. void() s_explode2 = [1, s_explode3] {};
  281. void() s_explode3 = [2, s_explode4] {};
  282. void() s_explode4 = [3, s_explode5] {};
  283. void() s_explode5 = [4, s_explode6] {};
  284. void() s_explode6 = [5, SUB_Remove] {};
  285. void() BecomeExplosion =
  286. {
  287. self.movetype = MOVETYPE_NONE;
  288. self.velocity = '0 0 0';
  289. self.touch = SUB_Null;
  290. setmodel (self, "progs/s_explod.spr");
  291. self.solid = SOLID_NOT;
  292. s_explode1 ();
  293. };
  294. void() T_MissileTouch =
  295. {
  296. local float damg;
  297. if (other == self.owner)
  298. return; // don't explode on owner
  299. if (pointcontents(self.origin) == CONTENT_SKY)
  300. {
  301. remove(self);
  302. return;
  303. }
  304. damg = 100 + random()*20;
  305. if (other.health)
  306. {
  307. if (other.classname == "monster_shambler")
  308. damg = damg * 0.5; // mostly immune
  309. T_Damage (other, self, self.owner, damg );
  310. }
  311. // don't do radius damage to the other, because all the damage
  312. // was done in the impact
  313. T_RadiusDamage (self, self.owner, 120, other);
  314. self.origin = self.origin - 8*normalize(self.velocity);
  315. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  316. WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  317. WriteCoord (MSG_BROADCAST, self.origin_x);
  318. WriteCoord (MSG_BROADCAST, self.origin_y);
  319. WriteCoord (MSG_BROADCAST, self.origin_z);
  320. BecomeExplosion ();
  321. };
  322. /*
  323. ================
  324. W_FireRocket
  325. ================
  326. */
  327. void() W_FireRocket =
  328. {
  329. local entity missile;
  330. self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  331. sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  332. //stuffcmd (self, "vibrate tactile/weapons/sgun1.bnvib");
  333. self.punchangle_x = -2;
  334. missile = spawn ();
  335. missile.owner = self;
  336. missile.movetype = MOVETYPE_FLYMISSILE;
  337. missile.solid = SOLID_BBOX;
  338. missile.classname = "missile";
  339. // set missile speed
  340. makevectors (self.v_angle);
  341. missile.velocity = aim(self, 1000);
  342. missile.velocity = missile.velocity * 1000;
  343. missile.angles = vectoangles(missile.velocity);
  344. missile.touch = T_MissileTouch;
  345. // set missile duration
  346. missile.nextthink = time + 5;
  347. missile.think = SUB_Remove;
  348. setmodel (missile, "progs/missile.mdl");
  349. setsize (missile, '0 0 0', '0 0 0');
  350. setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  351. };
  352. /*
  353. ===============================================================================
  354. LIGHTNING
  355. ===============================================================================
  356. */
  357. /*
  358. =================
  359. LightningDamage
  360. =================
  361. */
  362. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  363. {
  364. local entity e1, e2;
  365. local vector f;
  366. f = p2 - p1;
  367. normalize (f);
  368. f_x = 0 - f_y;
  369. f_y = f_x;
  370. f_z = 0;
  371. f = f*16;
  372. e1 = e2 = world;
  373. traceline (p1, p2, FALSE, self);
  374. if (trace_ent.takedamage)
  375. {
  376. particle (trace_endpos, '0 0 100', 225, damage*4);
  377. T_Damage (trace_ent, from, from, damage);
  378. if (self.classname == "player")
  379. {
  380. if (other.classname == "player")
  381. trace_ent.velocity_z = trace_ent.velocity_z + 400;
  382. }
  383. }
  384. e1 = trace_ent;
  385. traceline (p1 + f, p2 + f, FALSE, self);
  386. if (trace_ent != e1 && trace_ent.takedamage)
  387. {
  388. particle (trace_endpos, '0 0 100', 225, damage*4);
  389. T_Damage (trace_ent, from, from, damage);
  390. }
  391. e2 = trace_ent;
  392. traceline (p1 - f, p2 - f, FALSE, self);
  393. if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  394. {
  395. particle (trace_endpos, '0 0 100', 225, damage*4);
  396. T_Damage (trace_ent, from, from, damage);
  397. }
  398. };
  399. void() W_FireLightning =
  400. {
  401. local vector org;
  402. local float cells;
  403. if (self.ammo_cells < 1)
  404. {
  405. self.weapon = W_BestWeapon ();
  406. W_SetCurrentAmmo ();
  407. return;
  408. }
  409. // explode if under water
  410. if (self.waterlevel > 1)
  411. {
  412. cells = self.ammo_cells;
  413. self.ammo_cells = 0;
  414. W_SetCurrentAmmo ();
  415. T_RadiusDamage (self, self, 35*cells, world);
  416. return;
  417. }
  418. if (self.t_width < time)
  419. {
  420. sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  421. //stuffcmd (self, "vibrate tactile/weapons/lhit.bnvib");
  422. self.t_width = time + 0.6;
  423. }
  424. self.punchangle_x = -2;
  425. self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  426. org = self.origin + '0 0 16';
  427. traceline (org, org + v_forward*600, TRUE, self);
  428. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  429. WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  430. WriteEntity (MSG_BROADCAST, self);
  431. WriteCoord (MSG_BROADCAST, org_x);
  432. WriteCoord (MSG_BROADCAST, org_y);
  433. WriteCoord (MSG_BROADCAST, org_z);
  434. WriteCoord (MSG_BROADCAST, trace_endpos_x);
  435. WriteCoord (MSG_BROADCAST, trace_endpos_y);
  436. WriteCoord (MSG_BROADCAST, trace_endpos_z);
  437. LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
  438. };
  439. //=============================================================================
  440. void() GrenadeExplode =
  441. {
  442. T_RadiusDamage (self, self.owner, 120, world);
  443. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  444. WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  445. WriteCoord (MSG_BROADCAST, self.origin_x);
  446. WriteCoord (MSG_BROADCAST, self.origin_y);
  447. WriteCoord (MSG_BROADCAST, self.origin_z);
  448. BecomeExplosion ();
  449. };
  450. void() GrenadeTouch =
  451. {
  452. if (other == self.owner)
  453. return; // don't explode on owner
  454. if (other.takedamage == DAMAGE_AIM)
  455. {
  456. GrenadeExplode();
  457. return;
  458. }
  459. sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
  460. if (self.velocity == '0 0 0')
  461. self.avelocity = '0 0 0';
  462. };
  463. /*
  464. ================
  465. W_FireGrenade
  466. ================
  467. */
  468. void() W_FireGrenade =
  469. {
  470. local entity missile;
  471. self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  472. sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  473. //stuffcmd (self, "vibrate tactile/weapons/grenade.bnvib");
  474. self.punchangle_x = -2;
  475. missile = spawn ();
  476. missile.owner = self;
  477. missile.movetype = MOVETYPE_BOUNCE;
  478. missile.solid = SOLID_BBOX;
  479. missile.classname = "grenade";
  480. // set missile speed
  481. makevectors (self.v_angle);
  482. if (self.v_angle_x)
  483. missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  484. else
  485. {
  486. missile.velocity = aim(self, 10000);
  487. missile.velocity = missile.velocity * 600;
  488. missile.velocity_z = 200;
  489. }
  490. missile.avelocity = '300 300 300';
  491. missile.angles = vectoangles(missile.velocity);
  492. missile.touch = GrenadeTouch;
  493. // set missile duration
  494. missile.nextthink = time + 2.5;
  495. missile.think = GrenadeExplode;
  496. setmodel (missile, "progs/grenade.mdl");
  497. setsize (missile, '0 0 0', '0 0 0');
  498. setorigin (missile, self.origin);
  499. };
  500. //=============================================================================
  501. void() spike_touch;
  502. void() superspike_touch;
  503. /*
  504. ===============
  505. launch_spike
  506. Used for both the player and the ogre
  507. ===============
  508. */
  509. void(vector org, vector dir, float spd) launch_spike =
  510. {
  511. newmis = spawn ();
  512. newmis.owner = self;
  513. newmis.movetype = MOVETYPE_FLYMISSILE;
  514. newmis.solid = SOLID_BBOX;
  515. newmis.angles = vectoangles(dir);
  516. newmis.touch = spike_touch;
  517. newmis.classname = "spike";
  518. newmis.think = SUB_Remove;
  519. newmis.nextthink = time + 6;
  520. setmodel (newmis, "progs/spike.mdl");
  521. setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
  522. setorigin (newmis, org);
  523. newmis.velocity = dir * spd;
  524. };
  525. void() W_FireSuperSpikes =
  526. {
  527. local vector dir;
  528. sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  529. //stuffcmd (self, "vibrate tactile/weapons/spike2.bnvib");
  530. self.attack_finished = time + 0.2;
  531. self.currentammo = self.ammo_nails = self.ammo_nails - 2;
  532. dir = aim (self, 1000);
  533. if (self.player_flag & ITEM_RUNE3_FLAG) {
  534. HasteSound();
  535. launch_spike (self.origin + '0 0 16', dir, 2000);
  536. } else
  537. launch_spike (self.origin + '0 0 16', dir, 1000);
  538. newmis.classname = "super_spike";
  539. newmis.touch = superspike_touch;
  540. setmodel (newmis, "progs/s_spike.mdl");
  541. setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
  542. self.punchangle_x = -2;
  543. };
  544. void(float ox) W_FireSpikes =
  545. {
  546. local vector dir;
  547. makevectors (self.v_angle);
  548. if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
  549. {
  550. W_FireSuperSpikes ();
  551. return;
  552. }
  553. if (self.ammo_nails < 1)
  554. {
  555. self.weapon = W_BestWeapon ();
  556. W_SetCurrentAmmo ();
  557. return;
  558. }
  559. sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
  560. //stuffcmd (self, "vibrate tactile/weapons/rocket1i.bnvib");
  561. self.attack_finished = time + 0.2;
  562. self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  563. dir = aim (self, 1000);
  564. if (self.player_flag & ITEM_RUNE3_FLAG) {
  565. HasteSound();
  566. launch_spike (self.origin + '0 0 16' + v_right*ox, dir, 2000);
  567. } else
  568. launch_spike (self.origin + '0 0 16' + v_right*ox, dir, 1000);
  569. self.punchangle_x = -2;
  570. };
  571. void() spike_touch =
  572. {
  573. if (other == self.owner)
  574. return;
  575. if (other.solid == SOLID_TRIGGER)
  576. return; // trigger field, do nothing
  577. if (pointcontents(self.origin) == CONTENT_SKY)
  578. {
  579. remove(self);
  580. return;
  581. }
  582. // hit something that bleeds
  583. if (other.takedamage)
  584. {
  585. spawn_touchblood (9);
  586. T_Damage (other, self, self.owner, 9);
  587. }
  588. else
  589. {
  590. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  591. if (self.classname == "wizard_spike")
  592. WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  593. else if (self.classname == "knight_spike")
  594. WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  595. else
  596. WriteByte (MSG_BROADCAST, TE_SPIKE);
  597. WriteCoord (MSG_BROADCAST, self.origin_x);
  598. WriteCoord (MSG_BROADCAST, self.origin_y);
  599. WriteCoord (MSG_BROADCAST, self.origin_z);
  600. }
  601. remove(self);
  602. };
  603. void() superspike_touch =
  604. {
  605. if (other == self.owner)
  606. return;
  607. if (other.solid == SOLID_TRIGGER)
  608. return; // trigger field, do nothing
  609. if (pointcontents(self.origin) == CONTENT_SKY)
  610. {
  611. remove(self);
  612. return;
  613. }
  614. // hit something that bleeds
  615. if (other.takedamage)
  616. {
  617. spawn_touchblood (18);
  618. T_Damage (other, self, self.owner, 18);
  619. }
  620. else
  621. {
  622. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  623. WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  624. WriteCoord (MSG_BROADCAST, self.origin_x);
  625. WriteCoord (MSG_BROADCAST, self.origin_y);
  626. WriteCoord (MSG_BROADCAST, self.origin_z);
  627. }
  628. remove(self);
  629. };
  630. /*
  631. ===============================================================================
  632. PLAYER WEAPON USE
  633. ===============================================================================
  634. */
  635. void() W_SetCurrentAmmo =
  636. {
  637. player_run (); // get out of any weapon firing states
  638. self.weaponframe = 0;
  639. self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
  640. if (self.weapon == IT_AXE)
  641. {
  642. self.currentammo = 0;
  643. self.weaponmodel = "progs/v_axe.mdl";
  644. self.weaponframe = 0;
  645. }
  646. else if (self.weapon == IT_HOOK)
  647. {
  648. self.currentammo = 0;
  649. self.weaponmodel = "progs/v_star.mdl";
  650. }
  651. else if (self.weapon == IT_SHOTGUN)
  652. {
  653. self.currentammo = self.ammo_shells;
  654. self.weaponmodel = "progs/v_shot.mdl";
  655. self.items = self.items | IT_SHELLS;
  656. }
  657. else if (self.weapon == IT_SUPER_SHOTGUN)
  658. {
  659. self.currentammo = self.ammo_shells;
  660. self.weaponmodel = "progs/v_shot2.mdl";
  661. self.items = self.items | IT_SHELLS;
  662. }
  663. else if (self.weapon == IT_NAILGUN)
  664. {
  665. self.currentammo = self.ammo_nails;
  666. self.weaponmodel = "progs/v_nail.mdl";
  667. self.items = self.items | IT_NAILS;
  668. }
  669. else if (self.weapon == IT_SUPER_NAILGUN)
  670. {
  671. self.currentammo = self.ammo_nails;
  672. self.weaponmodel = "progs/v_nail2.mdl";
  673. self.items = self.items | IT_NAILS;
  674. }
  675. else if (self.weapon == IT_GRENADE_LAUNCHER)
  676. {
  677. self.currentammo = self.ammo_rockets;
  678. self.weaponmodel = "progs/v_rock.mdl";
  679. self.items = self.items | IT_ROCKETS;
  680. }
  681. else if (self.weapon == IT_ROCKET_LAUNCHER)
  682. {
  683. self.currentammo = self.ammo_rockets;
  684. self.weaponmodel = "progs/v_rock2.mdl";
  685. self.items = self.items | IT_ROCKETS;
  686. }
  687. else if (self.weapon == IT_LIGHTNING)
  688. {
  689. self.currentammo = self.ammo_cells;
  690. self.weaponmodel = "progs/v_light.mdl";
  691. self.items = self.items | IT_CELLS;
  692. }
  693. else
  694. {
  695. self.currentammo = 0;
  696. self.weaponmodel = string_null;
  697. }
  698. };
  699. float() W_BestWeapon =
  700. {
  701. local float it;
  702. it = self.items;
  703. if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
  704. return IT_LIGHTNING;
  705. else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
  706. return IT_SUPER_NAILGUN;
  707. else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
  708. return IT_SUPER_SHOTGUN;
  709. else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
  710. return IT_NAILGUN;
  711. else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
  712. return IT_SHOTGUN;
  713. return IT_AXE;
  714. };
  715. float(entity playerEnt, float old, float new) W_WantsToChangeWeapon =
  716. {
  717. float playerFlags = CheckPlayerEXFlags(playerEnt);
  718. if((playerFlags & PEF_CHANGENEVER) != 0)
  719. {
  720. return 0;
  721. }
  722. if(((playerFlags & PEF_CHANGEONLYNEW) != 0) && old == new)
  723. {
  724. return 0;
  725. }
  726. return 1;
  727. };
  728. float() W_HasNoAmmo =
  729. {
  730. if (self.currentammo)
  731. return FALSE;
  732. if (self.weapon == IT_AXE || self.weapon == IT_HOOK)
  733. return FALSE; // doesnt need ammo
  734. self.weapon = W_BestWeapon ();
  735. W_SetCurrentAmmo ();
  736. // drop the weapon down
  737. return TRUE;
  738. };
  739. /*
  740. ============
  741. W_Attack
  742. An attack impulse can be triggered now
  743. ============
  744. */
  745. void() player_axe1;
  746. void() player_axeb1;
  747. void() player_axec1;
  748. void() player_axed1;
  749. void() player_shot1;
  750. void() player_nail1;
  751. void() player_light1;
  752. void() player_rocket1;
  753. void() player_chain1;
  754. void() player_chain3;
  755. void() W_Attack =
  756. {
  757. local float r;
  758. if ( W_HasNoAmmo() ) {
  759. return;
  760. }
  761. makevectors (self.v_angle); // calculate forward angle for velocity
  762. self.show_hostile = time + 1; // wake monsters up
  763. if (self.weapon == IT_AXE)
  764. {
  765. sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  766. //stuffcmd (self, "vibrate tactile/weapons/ax1.bnvib");
  767. r = random();
  768. if (r < 0.25)
  769. player_axe1 ();
  770. else if (r<0.5)
  771. player_axeb1 ();
  772. else if (r<0.75)
  773. player_axec1 ();
  774. else
  775. player_axed1 ();
  776. // RUNE: rune of hell magic
  777. if (self.player_flag & ITEM_RUNE3_FLAG) {
  778. self.attack_finished = time + 0.3;
  779. HasteSound();
  780. } else
  781. self.attack_finished = time + 0.5;
  782. }
  783. else if (self.weapon == IT_SHOTGUN)
  784. {
  785. player_shot1 ();
  786. W_FireShotgun ();
  787. // RUNE: rune of hell magic
  788. if (self.player_flag & ITEM_RUNE3_FLAG) {
  789. self.attack_finished = time + 0.3;
  790. HasteSound();
  791. } else
  792. self.attack_finished = time + 0.5;
  793. }
  794. else if (self.weapon == IT_SUPER_SHOTGUN)
  795. {
  796. player_shot1 ();
  797. W_FireSuperShotgun ();
  798. // RUNE: rune of hell magic
  799. if (self.player_flag & ITEM_RUNE3_FLAG) {
  800. self.attack_finished = time + 0.4;
  801. HasteSound();
  802. } else
  803. self.attack_finished = time + 0.7;
  804. }
  805. else if (self.weapon == IT_NAILGUN)
  806. {
  807. player_nail1 ();
  808. }
  809. else if (self.weapon == IT_SUPER_NAILGUN)
  810. {
  811. player_nail1 ();
  812. }
  813. else if (self.weapon == IT_GRENADE_LAUNCHER)
  814. {
  815. player_rocket1();
  816. W_FireGrenade();
  817. // RUNE: rune of hell magic
  818. if (self.player_flag & ITEM_RUNE3_FLAG) {
  819. self.attack_finished = time + 0.3;
  820. HasteSound();
  821. } else
  822. self.attack_finished = time + 0.6;
  823. }
  824. else if (self.weapon == IT_ROCKET_LAUNCHER)
  825. {
  826. player_rocket1();
  827. W_FireRocket();
  828. // RUNE: rune of hell magic
  829. if (self.player_flag & ITEM_RUNE3_FLAG) {
  830. self.attack_finished = time + 0.4;
  831. HasteSound();
  832. } else
  833. self.attack_finished = time + 0.8;
  834. }
  835. else if (self.weapon == IT_LIGHTNING)
  836. {
  837. player_light1();
  838. self.attack_finished = time + 0.1;
  839. sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  840. //stuffcmd (self, "vibrate tactile/weapons/lstart.bnvib");
  841. }
  842. else if (self.weapon == IT_HOOK)
  843. {
  844. if (!self.hook_out)
  845. player_chain1();
  846. else
  847. player_chain3();
  848. self.attack_finished = time + 0.1;
  849. }
  850. };
  851. /*
  852. ============
  853. W_ChangeWeapon
  854. ============
  855. */
  856. void() W_ChangeWeapon =
  857. {
  858. local float it, am, fl;
  859. fl = it = self.items;
  860. am = 0;
  861. if (self.impulse == 1)
  862. {
  863. if (self.weapon == IT_HOOK)
  864. fl = IT_AXE;
  865. else
  866. fl = IT_HOOK;
  867. }
  868. else if (self.impulse == 31)
  869. {
  870. fl = IT_AXE;
  871. }
  872. else if (self.impulse == 2)
  873. {
  874. fl = IT_SHOTGUN;
  875. if (self.ammo_shells < 1)
  876. am = 1;
  877. }
  878. else if (self.impulse == 3)
  879. {
  880. fl = IT_SUPER_SHOTGUN;
  881. if (self.ammo_shells < 2)
  882. am = 1;
  883. }
  884. else if (self.impulse == 4)
  885. {
  886. fl = IT_NAILGUN;
  887. if (self.ammo_nails < 1)
  888. am = 1;
  889. }
  890. else if (self.impulse == 5)
  891. {
  892. fl = IT_SUPER_NAILGUN;
  893. if (self.ammo_nails < 2)
  894. am = 1;
  895. }
  896. else if (self.impulse == 6)
  897. {
  898. fl = IT_GRENADE_LAUNCHER;
  899. if (self.ammo_rockets < 1)
  900. am = 1;
  901. }
  902. else if (self.impulse == 7)
  903. {
  904. fl = IT_ROCKET_LAUNCHER;
  905. if (self.ammo_rockets < 1)
  906. am = 1;
  907. }
  908. else if (self.impulse == 8)
  909. {
  910. fl = IT_LIGHTNING;
  911. if (self.ammo_cells < 1)
  912. am = 1;
  913. }
  914. else if (self.impulse == 22)
  915. {
  916. fl = IT_HOOK;
  917. }
  918. self.impulse = 0;
  919. if (!(self.items & fl))
  920. { // don't have the weapon or the ammo
  921. sprint (self, "$qc_no_weapon");
  922. return;
  923. }
  924. if (am)
  925. { // don't have the ammo
  926. sprint (self, "$qc_not_enough_ammo");
  927. return;
  928. }
  929. //
  930. // set weapon, set ammo
  931. //
  932. self.weapon = fl;
  933. W_SetCurrentAmmo ();
  934. };
  935. /*
  936. ============
  937. CheatCommand
  938. ============
  939. */
  940. void CheatCommand() {
  941. if ( ( deathmatch || coop ) && cheats_allowed == 0 ) { // mal: allow impulse 9 IF cheats allowed
  942. return;
  943. }
  944. self.ammo_rockets = 100;
  945. self.ammo_nails = 200;
  946. self.ammo_shells = 100;
  947. self.items = self.items |
  948. IT_AXE |
  949. IT_HOOK |
  950. IT_SHOTGUN |
  951. IT_SUPER_SHOTGUN |
  952. IT_NAILGUN |
  953. IT_SUPER_NAILGUN |
  954. IT_GRENADE_LAUNCHER |
  955. IT_ROCKET_LAUNCHER |
  956. IT_KEY1 | IT_KEY2;
  957. self.ammo_cells = 200;
  958. self.items = self.items | IT_LIGHTNING;
  959. // mal: also give full armor...
  960. self.armortype = 0.8;
  961. self.armorvalue = 200;
  962. self.items = self.items - ( self.items & ( IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3 ) ) + IT_ARMOR3;
  963. self.weapon = IT_ROCKET_LAUNCHER;
  964. self.impulse = 0;
  965. W_SetCurrentAmmo ();
  966. };
  967. /*
  968. ============
  969. CycleWeaponCommand
  970. Go to the next weapon with ammo
  971. ============
  972. */
  973. void() CycleWeaponCommand =
  974. {
  975. local float it, am;
  976. it = self.items;
  977. self.impulse = 0;
  978. while (1)
  979. {
  980. am = 0;
  981. if (self.weapon == IT_LIGHTNING)
  982. {
  983. self.weapon = IT_AXE;
  984. }
  985. else if (self.weapon == IT_AXE)
  986. {
  987. self.weapon = IT_HOOK;
  988. }
  989. else if (self.weapon == IT_HOOK)
  990. {
  991. self.weapon = IT_SHOTGUN;
  992. if (self.ammo_shells < 1)
  993. am = 1;
  994. }
  995. else if (self.weapon == IT_SHOTGUN)
  996. {
  997. self.weapon = IT_SUPER_SHOTGUN;
  998. if (self.ammo_shells < 2)
  999. am = 1;
  1000. }
  1001. else if (self.weapon == IT_SUPER_SHOTGUN)
  1002. {
  1003. self.weapon = IT_NAILGUN;
  1004. if (self.ammo_nails < 1)
  1005. am = 1;
  1006. }
  1007. else if (self.weapon == IT_NAILGUN)
  1008. {
  1009. self.weapon = IT_SUPER_NAILGUN;
  1010. if (self.ammo_nails < 2)
  1011. am = 1;
  1012. }
  1013. else if (self.weapon == IT_SUPER_NAILGUN)
  1014. {
  1015. self.weapon = IT_GRENADE_LAUNCHER;
  1016. if (self.ammo_rockets < 1)
  1017. am = 1;
  1018. }
  1019. else if (self.weapon == IT_GRENADE_LAUNCHER)
  1020. {
  1021. self.weapon = IT_ROCKET_LAUNCHER;
  1022. if (self.ammo_rockets < 1)
  1023. am = 1;
  1024. }
  1025. else if (self.weapon == IT_ROCKET_LAUNCHER)
  1026. {
  1027. self.weapon = IT_LIGHTNING;
  1028. if (self.ammo_cells < 1)
  1029. am = 1;
  1030. }
  1031. if ( (self.items & self.weapon) && am == 0)
  1032. {
  1033. W_SetCurrentAmmo ();
  1034. return;
  1035. }
  1036. }
  1037. };
  1038. /*
  1039. ============
  1040. CycleWeaponReverseCommand
  1041. Go to the prev weapon with ammo
  1042. ============
  1043. */
  1044. void() CycleWeaponReverseCommand =
  1045. {
  1046. local float it, am;
  1047. it = self.items;
  1048. self.impulse = 0;
  1049. while (1)
  1050. {
  1051. am = 0;
  1052. if (self.weapon == IT_LIGHTNING)
  1053. {
  1054. self.weapon = IT_ROCKET_LAUNCHER;
  1055. if (self.ammo_rockets < 1)
  1056. am = 1;
  1057. }
  1058. else if (self.weapon == IT_ROCKET_LAUNCHER)
  1059. {
  1060. self.weapon = IT_GRENADE_LAUNCHER;
  1061. if (self.ammo_rockets < 1)
  1062. am = 1;
  1063. }
  1064. else if (self.weapon == IT_GRENADE_LAUNCHER)
  1065. {
  1066. self.weapon = IT_SUPER_NAILGUN;
  1067. if (self.ammo_nails < 2)
  1068. am = 1;
  1069. }
  1070. else if (self.weapon == IT_SUPER_NAILGUN)
  1071. {
  1072. self.weapon = IT_NAILGUN;
  1073. if (self.ammo_nails < 1)
  1074. am = 1;
  1075. }
  1076. else if (self.weapon == IT_NAILGUN)
  1077. {
  1078. self.weapon = IT_SUPER_SHOTGUN;
  1079. if (self.ammo_shells < 2)
  1080. am = 1;
  1081. }
  1082. else if (self.weapon == IT_SUPER_SHOTGUN)
  1083. {
  1084. self.weapon = IT_SHOTGUN;
  1085. if (self.ammo_shells < 1)
  1086. am = 1;
  1087. }
  1088. else if (self.weapon == IT_SHOTGUN)
  1089. {
  1090. self.weapon = IT_HOOK;
  1091. }
  1092. else if (self.weapon == IT_HOOK)
  1093. {
  1094. self.weapon = IT_AXE;
  1095. }
  1096. else if (self.weapon == IT_AXE)
  1097. {
  1098. self.weapon = IT_LIGHTNING;
  1099. if (self.ammo_cells < 1)
  1100. am = 1;
  1101. }
  1102. if ( (it & self.weapon) && am == 0)
  1103. {
  1104. W_SetCurrentAmmo ();
  1105. return;
  1106. }
  1107. }
  1108. };
  1109. /*
  1110. ============
  1111. ServerflagsCommand
  1112. Just for development
  1113. ============
  1114. */
  1115. void() ServerflagsCommand =
  1116. {
  1117. serverflags = serverflags * 2 + 1;
  1118. // ZOID: Bug fix
  1119. serverflags = (serverflags & 15);
  1120. };
  1121. void() QuadCheat =
  1122. {
  1123. if (!cheats_allowed)
  1124. return;
  1125. self.super_time = 1;
  1126. self.super_damage_finished = time + 30;
  1127. self.items = self.items | IT_QUAD;
  1128. dprint ("quad cheat\n");
  1129. };
  1130. //ZOID: Uhm, where am I?
  1131. void() PrintLocation =
  1132. {
  1133. local string p;
  1134. p = vtos(self.origin);
  1135. sprint(self, "You are at ");
  1136. sprint(self, p);
  1137. sprint(self, "\n");
  1138. };
  1139. /*
  1140. ============
  1141. ImpulseCommands
  1142. ============
  1143. */
  1144. void() ImpulseCommands =
  1145. {
  1146. if ((self.impulse >= 1 && self.impulse <= 8) || self.impulse == 22 || self.impulse == 31)
  1147. W_ChangeWeapon ();
  1148. if (self.impulse == 9)
  1149. CheatCommand ();
  1150. if (!self.observer && self.impulse == 10)
  1151. CycleWeaponCommand ();
  1152. if (self.impulse == 11)
  1153. ServerflagsCommand ();
  1154. if (self.impulse == 12)
  1155. CycleWeaponReverseCommand();
  1156. if (self.impulse == 99)
  1157. PrintLocation();
  1158. // *TEAMPLAY*
  1159. // If we're allowed to drop items, enable impulse 20 and 21
  1160. else if (!self.observer && (teamplay & TEAM_DROP_ITEMS) && self.impulse == 20)
  1161. TossBackpack ();
  1162. else if (!self.observer && (teamplay & TEAM_DROP_ITEMS) && self.impulse == 21)
  1163. TossWeapon ();
  1164. // *TEAMPLAY*
  1165. // Impulse 25 prints info about the current teamplay settings.
  1166. else if (self.impulse == 25)
  1167. TeamPrintSettings ();
  1168. else if (self.impulse == 255)
  1169. QuadCheat ();
  1170. self.impulse = 0;
  1171. };
  1172. /*
  1173. ============
  1174. W_WeaponFrame
  1175. Called every frame so impulse events can be handled as well as possible
  1176. ============
  1177. */
  1178. void() W_WeaponFrame =
  1179. {
  1180. if ( time < self.attack_finished ) {
  1181. return;
  1182. }
  1183. if (self.impulse)
  1184. ImpulseCommands ();
  1185. // check for attack
  1186. if ( self.button0 ) {
  1187. SuperDamageSound ();
  1188. W_Attack ();
  1189. }
  1190. };
  1191. /*
  1192. ========
  1193. Resistancesound
  1194. Plays sound if needed
  1195. ========
  1196. */
  1197. void(entity who) ResistanceSound =
  1198. {
  1199. // RUNE play resistance sound if player has Earth Magic
  1200. if (who.player_flag & ITEM_RUNE1_FLAG) {
  1201. if (who.invincible_sound < time) {
  1202. who.invincible_sound = time + 1;
  1203. sound(who, CHAN_BODY, "rune/rune1.wav", 1, ATTN_NORM);
  1204. }
  1205. }
  1206. };
  1207. /*
  1208. ========
  1209. SuperDamageSound
  1210. Plays sound if needed
  1211. ========
  1212. */
  1213. void() SuperDamageSound =
  1214. {
  1215. // RUNE play super damage sound if player has Black Magic, too
  1216. if ((self.player_flag & ITEM_RUNE2_FLAG) &&
  1217. (self.super_damage_finished > time)) {
  1218. if (self.super_sound < time) {
  1219. self.super_sound = time + 1;
  1220. sound (self, CHAN_BODY, "rune/rune22.wav", 1, ATTN_NORM);
  1221. }
  1222. }
  1223. if (self.super_damage_finished > time) {
  1224. if (self.super_sound < time) {
  1225. self.super_sound = time + 1;
  1226. sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
  1227. }
  1228. }
  1229. if (self.player_flag & ITEM_RUNE2_FLAG) {
  1230. if (self.super_sound < time) {
  1231. self.super_sound = time + 1;
  1232. sound (self, CHAN_BODY, "rune/rune2.wav", 1, ATTN_NORM);
  1233. }
  1234. }
  1235. };
  1236. /*
  1237. ========
  1238. RegenerationSound
  1239. Plays sound if needed
  1240. ========
  1241. */
  1242. void() RegenerationSound =
  1243. {
  1244. // RUNE play healing sound if player has Elder Magic
  1245. if (self.player_flag & ITEM_RUNE4_FLAG) {
  1246. if (self.regeneration_sound < time) {
  1247. self.regeneration_sound = time + 1;
  1248. sound(self, CHAN_BODY, "rune/rune4.wav", 1, ATTN_NORM);
  1249. }
  1250. }
  1251. };
  1252. /*
  1253. ========
  1254. HasteSound
  1255. Plays sound if needed
  1256. ========
  1257. */
  1258. void() HasteSound =
  1259. {
  1260. // RUNE play haste (Chthon's roar) sound if player has Hell Magic
  1261. if (self.player_flag & ITEM_RUNE3_FLAG) {
  1262. if (self.haste_sound < time) {
  1263. self.haste_sound = time + 1;
  1264. sound(self, CHAN_BODY, "rune/rune3.wav", 1, ATTN_NORM);
  1265. }
  1266. }
  1267. };