Advertisement
Guest User

Untitled

a guest
May 19th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.52 KB | None | 0 0
  1. /*
  2. */
  3. void( vector pos ) placebullethole;
  4. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  5. void () player_run;
  6. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  7. void(vector org, vector vel, float damage) SpawnBlood;
  8. void() SuperDamageSound;
  9.  
  10.  
  11.  
  12. vector() wall_velocity =
  13. {
  14. local vector vel;
  15.  
  16. vel = normalize (self.velocity);
  17. vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  18. vel = vel + 2*trace_plane_normal;
  19. vel = vel * 200;
  20.  
  21. return vel;
  22. };
  23.  
  24. /*
  25. ================
  26. spawn_touchblood
  27. ================
  28. */
  29. void(float damage) spawn_touchblood =
  30. {
  31. local vector vel;
  32.  
  33. vel = wall_velocity () * 0.2;
  34. SpawnBlood (self.origin + vel*0.01, vel, damage);
  35. };
  36.  
  37.  
  38. // called by worldspawn
  39. void() W_Precache =
  40. {
  41. precache_sound ("weapons/r_exp3.wav"); // new rocket explosion
  42. precache_sound ("weapons/rocket1i.wav"); // spike gun
  43. precache_sound ("weapons/sgun1.wav");
  44. precache_sound ("weapons/guncock.wav"); // player shotgun
  45. precache_sound ("weapons/ric1.wav"); // ricochet (used in c code)
  46. precache_sound ("weapons/ric2.wav"); // ricochet (used in c code)
  47. precache_sound ("weapons/ric3.wav"); // ricochet (used in c code)
  48. precache_sound ("weapons/spike2.wav"); // super spikes
  49. precache_sound ("weapons/tink1.wav"); // spikes tink (used in c code)
  50. precache_sound ("weapons/grenade.wav"); // grenade launcher
  51. precache_sound ("weapons/bounce.wav"); // grenade bounce
  52. precache_sound ("weapons/shotgn2.wav"); // super shotgun
  53. precache_sound ("weapons/nailshrd.wav"); // infantry gun AKA nailbuster sound
  54. precache_sound ("weapons/mingn1.wav"); // gatling gun spin up
  55. precache_sound ("weapons/mingn2.wav"); // gatling gun firing loop
  56. precache_sound ("weapons/mingn3.wav"); // gatling gun spin down
  57. precache_sound ("weapons/mingn4.wav"); // gatling gun spin loop
  58. precache_sound ("weapons/expl.wav"); //new explosion sound, to allow custom explosion sounds
  59. precache_sound ("weapons/bfgprep.wav"); //bfg charging up
  60. precache_sound ("weapons/bfgfire1.wav"); //bfg firing
  61. precache_sound ("weapons/bfgcrank.wav"); //bfg recharging
  62. precache_sound ("weapons/bfgexp.wav"); //bfg explosion
  63. precache_sound ("weapons/bfgblast.wav"); //bfg blast
  64. precache_sound ("weapons/mtshot.wav");
  65. precache_model ("progs/g_infg.mdl"); //infantry gun AKA nailbuster world model
  66. precache_model ("progs/v_infg.mdl"); //infantry gun AKA nailbuster view model
  67. precache_model ("progs/v_gatlg.mdl");
  68. precache_model ("progs/g_bfg.mdl");
  69. precache_model ("progs/v_bfg.mdl");
  70. precache_model ("progs/s_bullet.spr");
  71. precache_model ("progs/bfgshot.spr");
  72. precache_model ("progs/bfgexpl.spr");
  73. precache_model ("progs/bfgblst.spr");
  74. };
  75.  
  76. float() crandom =
  77. {
  78. return 2*(random() - 0.5);
  79. };
  80.  
  81. /*
  82. ================
  83. HIPNOTIC WEAPONS
  84. ================
  85. */
  86.  
  87. .vector old_velocity;
  88. .entity lastvictim;
  89.  
  90. void() HIP_LaserTouch =
  91. {
  92. local vector org;
  93. local vector spot1,spot2;
  94. local vector oldvel;
  95. local float mag;
  96. local float r;
  97.  
  98. self.owner = world;
  99. self.cnt = self.cnt + 1;
  100. if (pointcontents(self.origin) == CONTENT_SKY)
  101. {
  102. remove(self);
  103. return;
  104. }
  105. oldvel = normalize(self.old_velocity);
  106. spot1 = self.origin - (16*oldvel);
  107. spot2 = self.origin + (16*oldvel);
  108. traceline (spot1, spot2, FALSE, self); // see through other monsters
  109. self.origin = trace_endpos;
  110.  
  111. org = self.origin;
  112.  
  113. if (other.health)
  114. {
  115. if (self.lastvictim == other)
  116. {
  117. self.dmg = self.dmg / 2;
  118. }
  119. spawn_touchblood (self.dmg);
  120. T_Damage (other, self, self.lastvictim, self.dmg);
  121. }
  122. else if ((self.cnt == 3) || (random()<0.15))
  123. {
  124. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  125. WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  126. WriteCoord (MSG_BROADCAST, org_x);
  127. WriteCoord (MSG_BROADCAST, org_y);
  128. WriteCoord (MSG_BROADCAST, org_z);
  129. }
  130. else
  131. {
  132. // self.dmg = 0.66 * self.dmg;
  133. self.dmg = 0.9 * self.dmg;
  134. // self.speed = 0.95 * self.speed;
  135. self.velocity = oldvel+(2*trace_plane_normal);
  136. self.velocity = normalize(self.velocity);
  137. self.velocity = self.speed * self.velocity;
  138. self.old_velocity = self.velocity;
  139. if (self.flags & FL_ONGROUND)
  140. self.flags = self.flags - FL_ONGROUND;
  141. r = random();
  142. sound (self, CHAN_WEAPON, "hipweap/laserric.wav", 1, ATTN_STATIC);
  143. /*
  144. if (r<0.33)
  145. sound (self, CHAN_WEAPON, "weapons/ric1.wav", 1, ATTN_STATIC);
  146. else if (r<0.66)
  147. sound (self, CHAN_WEAPON, "weapons/ric2.wav", 1, ATTN_STATIC);
  148. else
  149. sound (self, CHAN_WEAPON, "weapons/ric3.wav", 1, ATTN_STATIC);
  150. */
  151. return;
  152. }
  153. sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC);
  154. remove(self);
  155.  
  156. };
  157. void() HIP_LaserThink =
  158. {
  159. local float delta;
  160.  
  161.  
  162. if (time>self.attack_finished)
  163. {
  164. remove(self);
  165. return;
  166. }
  167. if (self.flags & FL_ONGROUND)
  168. self.flags = self.flags - FL_ONGROUND;
  169. self.velocity = self.old_velocity;
  170. self.angles = vectoangles(self.velocity);
  171. self.nextthink = time+0.1;
  172. };
  173.  
  174. void(vector org, vector vec, float light) HIP_LaunchLaser =
  175. {
  176. // sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);
  177. sound (self ,CHAN_WEAPON, "hipweap/laserg.wav", 1, ATTN_NORM);
  178.  
  179. vec = normalize(vec);
  180.  
  181. newmis = spawn();
  182. newmis.owner = self;
  183. newmis.classname = "hiplaser";
  184. newmis.lastvictim = self;
  185. newmis.movetype = MOVETYPE_FLYMISSILE;
  186. newmis.solid = SOLID_BBOX;
  187. if (light)
  188. newmis.effects = EF_DIMLIGHT;
  189.  
  190. setmodel (newmis, "progs/lasrspik.mdl");
  191. setsize (newmis, '0 0 0', '0 0 0');
  192.  
  193. setorigin (newmis, org);
  194.  
  195. newmis.speed = 1000;
  196. newmis.dmg = 18;
  197. newmis.velocity = vec * newmis.speed;
  198. newmis.old_velocity = newmis.velocity;
  199. newmis.angles = vectoangles(newmis.velocity);
  200. newmis.avelocity = '0 0 400';
  201.  
  202. newmis.nextthink = time;
  203. newmis.attack_finished = time + 5;
  204. newmis.think = HIP_LaserThink;
  205. newmis.touch = HIP_LaserTouch;
  206. newmis.count = 0;
  207.  
  208. };
  209.  
  210. /*
  211. =================
  212. HIP_FireLaser
  213. =================
  214. */
  215. void(float stat) HIP_FireLaser =
  216. {
  217. local vector org;
  218. local vector dir;
  219. local vector out;
  220. local float ofs;
  221. local float aofs;
  222.  
  223. if (!self.button0)
  224. {
  225. player_run ();
  226. return;
  227. }
  228. if (self.ammo_cells < 1)
  229. {
  230. self.weapon = W_BestWeapon ();
  231. W_SetCurrentAmmo ();
  232. return;
  233. }
  234. SuperDamageSound();
  235. self.effects = self.effects | EF_MUZZLEFLASH;
  236. makevectors (self.v_angle);
  237.  
  238. ofs = 6;
  239. out = v_forward;
  240. out_z = 0;
  241. out = normalize(out);
  242. org = self.origin + ((12-ofs) * v_up) + (12*out);
  243. // org = self.origin + (1*v_forward);
  244. dir = aim (self, 1000);
  245. aofs = ofs * 0.707;
  246. if (stat == 0)
  247. {
  248. self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  249. org = org + (aofs*v_right);
  250. org = org - (aofs*v_up);
  251. HIP_LaunchLaser(org, dir, 0);
  252. org = org - (2*aofs*v_right);
  253. HIP_LaunchLaser(org, dir, 0);
  254. }
  255. else if (stat == 1)
  256. {
  257. self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  258. org = org + (ofs*v_up);
  259. if (random()<0.1)
  260. {
  261. HIP_LaunchLaser(org, dir, 1);
  262. newmis.dmg = 25;
  263. }
  264. else
  265. HIP_LaunchLaser(org, dir, 0);
  266. }
  267. self.punchangle_x = -1;
  268. };
  269.  
  270. /*
  271. ================
  272. W_FireAxe
  273. ================
  274. */
  275. void() W_FireAxe =
  276. {
  277. local vector source;
  278. local vector org;
  279.  
  280. makevectors (self.v_angle);
  281. source = self.origin + '0 0 16';
  282. traceline (source, source + v_forward*64, FALSE, self);
  283. if (trace_fraction == 1.0)
  284. return;
  285.  
  286. org = trace_endpos - v_forward*4;
  287.  
  288. if (trace_ent.takedamage)
  289. {
  290. trace_ent.axhitme = 1;
  291. SpawnBlood (org, '0 0 0', 20);
  292. T_Damage (trace_ent, self, self, 50); //20
  293. sound (self, CHAN_AUTO, "weapons/mtshot.wav", 1, ATTN_NORM);
  294.  
  295. }
  296. else
  297. { // hit wall
  298. sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  299. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  300. WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  301. WriteCoord (MSG_BROADCAST, org_x);
  302. WriteCoord (MSG_BROADCAST, org_y);
  303. WriteCoord (MSG_BROADCAST, org_z);
  304. }
  305. };
  306.  
  307.  
  308. //============================================================================
  309.  
  310.  
  311. /*
  312. ================
  313. SpawnMeatSpray
  314. ================
  315. */
  316. void(vector org, vector vel) SpawnMeatSpray =
  317. {
  318. local entity missile, mpuff;
  319. local vector org;
  320.  
  321. missile = spawn ();
  322. missile.owner = self;
  323. missile.movetype = MOVETYPE_BOUNCE;
  324. missile.solid = SOLID_NOT;
  325.  
  326. makevectors (self.angles);
  327.  
  328. missile.velocity = vel;
  329. missile.velocity_z = missile.velocity_z + 250 + 50*random();
  330.  
  331. missile.avelocity = '3000 1000 2000';
  332.  
  333. // set missile duration
  334. missile.nextthink = time + 1;
  335. missile.think = SUB_Remove;
  336.  
  337. setmodel (missile, "progs/zom_gib.mdl");
  338. setsize (missile, '0 0 0', '0 0 0');
  339. setorigin (missile, org);
  340. };
  341.  
  342. /*
  343. ================
  344. SpawnBlood
  345. ================
  346. */
  347. void(vector org, vector vel, float damage) SpawnBlood =
  348. {
  349. particle (org, vel*0.1, 73, damage*2);
  350. };
  351.  
  352.  
  353. /*
  354. ================
  355. SpawnChunk
  356. ================
  357. */
  358. void(vector org, vector vel) SpawnChunk =
  359. {
  360. particle (org, vel*0.02, 0, 10);
  361. };
  362.  
  363. /*
  364. ==============================================================================
  365.  
  366. MULTI-DAMAGE
  367.  
  368. Collects multiple small damages into a single damage
  369.  
  370. ==============================================================================
  371. */
  372.  
  373. entity multi_ent;
  374. float multi_damage;
  375.  
  376. void() ClearMultiDamage =
  377. {
  378. multi_ent = world;
  379. multi_damage = 0;
  380. };
  381.  
  382. void() ApplyMultiDamage =
  383. {
  384. if (!multi_ent)
  385. return;
  386. T_Damage (multi_ent, self, self, multi_damage);
  387. };
  388.  
  389. void(entity hit, float damage) AddMultiDamage =
  390. {
  391. if (!hit)
  392. return;
  393.  
  394. if (hit != multi_ent)
  395. {
  396. ApplyMultiDamage ();
  397. multi_damage = damage;
  398. multi_ent = hit;
  399. }
  400. else
  401. multi_damage = multi_damage + damage;
  402. };
  403.  
  404. /*
  405. ==============================================================================
  406.  
  407. BULLETS
  408.  
  409. ==============================================================================
  410. */
  411.  
  412. /*
  413. ================
  414. TraceAttack
  415. ================
  416. */
  417. void(float damage, vector dir) TraceAttack =
  418. {
  419. local vector vel, org;
  420.  
  421. vel = normalize(dir + v_up*crandom() + v_right*crandom());
  422. vel = vel + 2*trace_plane_normal;
  423. vel = vel * 200;
  424.  
  425. org = trace_endpos - dir*4;
  426.  
  427. if (trace_ent.takedamage)
  428. {
  429. SpawnBlood (org, vel*0.2, damage);
  430. AddMultiDamage (trace_ent, damage);
  431. }
  432. else
  433. {
  434. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  435. WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  436. WriteCoord (MSG_BROADCAST, org_x);
  437. WriteCoord (MSG_BROADCAST, org_y);
  438. WriteCoord (MSG_BROADCAST, org_z);
  439. }
  440. };
  441.  
  442. /*
  443. ================
  444. FireBullets
  445.  
  446. Used by shotgun, super shotgun, and enemy soldier firing
  447. Go to the trouble of combining multiple pellets into a single damage call.
  448. ================
  449. */
  450. void(float shotcount, vector dir, vector spread) FireBullets =
  451. {
  452. local vector direction;
  453. local vector src;
  454. //JIM
  455. local float bullet;
  456. bullet = 0;
  457.  
  458. makevectors(self.v_angle);
  459.  
  460. src = self.origin + v_forward*10;
  461. src_z = self.absmin_z + self.size_z * 0.7;
  462.  
  463. ClearMultiDamage ();
  464. while (shotcount > 0)
  465. {
  466. direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  467.  
  468. traceline (src, src + direction*2048, FALSE, self);
  469. if (trace_fraction != 1.0)
  470. //JIM
  471. {
  472. TraceAttack (4, direction);
  473. if ( ( !bullet ) && ( trace_ent == world ) )
  474. {
  475. placebullethole( trace_endpos );
  476. bullet = 1;
  477. }
  478. }
  479.  
  480. shotcount = shotcount - 1;
  481. }
  482. ApplyMultiDamage ();
  483. };
  484.  
  485. /*
  486. ================
  487. FireNailShards
  488.  
  489. Used by hitscan weapons using nail ammo.
  490. ================
  491. */
  492. void(float shotcount, vector dir, vector spread) FireNailShards =
  493. {
  494. local vector direction;
  495. local vector src;
  496. float i = 0;
  497. local float len, cunt;
  498. //JIM
  499. local float bullet;
  500. bullet = 0;
  501.  
  502. makevectors(self.v_angle);
  503.  
  504. src = self.origin + v_forward*10;
  505. src_z = self.absmin_z + self.size_z * 0.7;
  506.  
  507. ClearMultiDamage ();
  508. while (shotcount > 0)
  509. {
  510. direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  511.  
  512. traceline (src, src + direction*2048, FALSE, self);
  513. if (trace_fraction != 1.0)
  514. TraceAttack (9, direction); //9
  515. //JIM
  516. if ( ( !bullet ) && ( trace_ent == world ) )
  517. {
  518. placebullethole( trace_endpos );
  519. bullet = 1;
  520. }
  521.  
  522. len = vlen(src - trace_endpos) / 4; // len = length, vlen = vector length. for example vlen(position1 - position2); will return the distance between position1 and position2
  523. cunt = 0; // cunt = alt "count"
  524. while (cunt < 4) {
  525. particle(src+direction*(cunt+0.5)*len, direction, 6, 1); //10
  526. cunt = cunt + 1;
  527.  
  528. }
  529.  
  530. shotcount = shotcount - 1;
  531. }
  532.  
  533. ApplyMultiDamage (); //It is vital to let this in! Or else no damage is registered...
  534.  
  535. //while(len > 0)
  536. //{
  537. //particle(src, trace_fraction, 8, 1);
  538. //len = len - 16; //do it spaced out by 16 units
  539. //}
  540.  
  541. //while (i < distance)
  542. //{
  543. // particle(startpoint + i*direction, '0 0 0', color, count);
  544. // i = i + gaplength;
  545. //}
  546. };
  547.  
  548. /*
  549. ================
  550. FireNailShardsInfantry
  551.  
  552. Used by the Nail Infantry
  553. ================
  554. */
  555. void(float shotcount, vector dir, vector spread) FireNailShardsInfantry =
  556. {
  557. local vector direction;
  558. local vector src;
  559. float i = 0;
  560. local float len, cunt;
  561. local float bullet;
  562.  
  563. makevectors(self.v_angle);
  564.  
  565. src = self.origin + v_forward*10;
  566. src_z = self.absmin_z + self.size_z * 0.7;
  567.  
  568. ClearMultiDamage ();
  569. while (shotcount > 0)
  570. {
  571. direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  572.  
  573. traceline (src, src + direction*2048, FALSE, self);
  574. if (trace_fraction != 1.0)
  575. TraceAttack (3, direction); //9
  576. //JIM
  577. if ( ( !bullet ) && ( trace_ent == world ) )
  578. {
  579. placebullethole( trace_endpos );
  580. bullet = 1;
  581. }
  582.  
  583. len = vlen(src - trace_endpos) / 4; // len = length, vlen = vector length. for example vlen(position1 - position2); will return the distance between position1 and position2
  584. cunt = 0; // cunt = alt "count"
  585. while (cunt < 4) {
  586. particle(src+direction*(cunt+0.5)*len, direction, 6, 1); //10
  587. cunt = cunt + 1;
  588.  
  589. }
  590.  
  591. shotcount = shotcount - 1;
  592. }
  593.  
  594. ApplyMultiDamage ();
  595.  
  596. };
  597.  
  598. /*
  599. ================
  600. FireNailShardsGatling
  601.  
  602. Used by the gatling gun, the difference is more damage.
  603. ================
  604. */
  605. void(float shotcount, vector dir, vector spread) FireNailShardsGatling =
  606. {
  607. local vector direction;
  608. local vector src;
  609. float i = 0;
  610. local float len, cunt;
  611. //JIM
  612. local float bullet;
  613. bullet = 0;
  614.  
  615. makevectors(self.v_angle);
  616.  
  617. src = self.origin + v_forward*10;
  618. src_z = self.absmin_z + self.size_z * 0.7;
  619.  
  620. ClearMultiDamage ();
  621. while (shotcount > 0)
  622. {
  623. direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  624.  
  625. traceline (src, src + direction*2048, FALSE, self);
  626. if (trace_fraction != 1.0)
  627. TraceAttack (10, direction); //9
  628. //JIM
  629. if ( ( !bullet ) && ( trace_ent == world ) )
  630. {
  631. placebullethole( trace_endpos );
  632. bullet = 1;
  633. }
  634.  
  635. len = vlen(src - trace_endpos) / 4; // len = length, vlen = vector length. for example vlen(position1 - position2); will return the distance between position1 and position2
  636. cunt = 0; // cunt = alt "count"
  637. while (cunt < 4) {
  638. particle(src+direction*(cunt+0.5)*len, direction, 6, 1); //10
  639. cunt = cunt + 1;
  640.  
  641. }
  642.  
  643. shotcount = shotcount - 1;
  644. }
  645.  
  646. ApplyMultiDamage ();
  647.  
  648. //while(len > 0)
  649. //{
  650. //particle(src, trace_fraction, 8, 1);
  651. //len = len - 16; //do it spaced out by 16 units
  652. //}
  653.  
  654. //while (i < distance)
  655. //{
  656. // particle(startpoint + i*direction, '0 0 0', color, count);
  657. // i = i + gaplength;
  658. //}
  659. };
  660.  
  661. /*
  662. ================
  663. W_FireShotgun
  664. ================
  665. */
  666. void() W_FireShotgun =
  667. {
  668. local vector dir;
  669.  
  670. sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
  671.  
  672. self.punchangle_x = -2;
  673.  
  674. self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  675. dir = aim (self, 100000);
  676. FireBullets (6, dir, '0.04 0.04 0');
  677. };
  678.  
  679.  
  680. /*
  681. ================
  682. W_FireSuperShotgun
  683. ================
  684. */
  685. void() W_FireSuperShotgun =
  686. {
  687. local vector dir;
  688.  
  689. if (self.currentammo == 1)
  690. {
  691. W_FireShotgun ();
  692. return;
  693. }
  694.  
  695. sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);
  696.  
  697. self.punchangle_x = -4;
  698.  
  699. self.currentammo = self.ammo_shells = self.ammo_shells - 2;
  700. dir = aim (self, 100000);
  701. FireBullets (14, dir, '0.14 0.08 0');
  702. };
  703.  
  704.  
  705. /*
  706. ================
  707. W_FireInfantry
  708. ================
  709. */
  710. void() W_FireInfantry =
  711. {
  712. local vector dir;
  713.  
  714. sound (self, CHAN_WEAPON, "weapons/nailshrd.wav", 1, ATTN_NORM);
  715.  
  716. self.punchangle_x = -2;
  717.  
  718. self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  719. dir = aim (self, 100000);
  720. FireNailShards (1, dir, '0.02 0.02 0');
  721. };
  722.  
  723. /*
  724. ================
  725. W_FireGatling
  726. ================
  727. */
  728. void() W_FireGatling =
  729. {
  730. local vector dir;
  731.  
  732.  
  733. self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  734. dir = aim (self, 100000);
  735. FireNailShardsGatling (1, dir, '0.04 0.04 0');
  736. };
  737.  
  738. /*
  739. ==============================================================================
  740.  
  741. BFG
  742.  
  743. ==============================================================================
  744. */
  745.  
  746. //BFG explosion sprites
  747. void() bfgexpl1 = [0, bfgexpl2] {};
  748. void() bfgexpl2 = [1, bfgexpl3] {};
  749. void() bfgexpl3 = [2, bfgexpl4] {};
  750. void() bfgexpl4 = [3, bfgexpl5] {};
  751. void() bfgexpl5 = [4, SUB_Remove] {};
  752.  
  753. //BFG blast sprites
  754. void() bfgblast1 = [4, bfgblast2] {};
  755. void() bfgblast2 = [0, bfgblast3] {};
  756. void() bfgblast3 = [1, bfgblast4] {};
  757. void() bfgblast4 = [2, bfgblast5] {};
  758. void() bfgblast5 = [3, SUB_Remove] {};
  759.  
  760.  
  761. void() bfg_ball_think =
  762. {
  763.  
  764. //continuous lightning bolt targetting nearby ennemies from BFG orb
  765. local vector org;
  766. //local float cells,damage=0;
  767. local entity head;
  768. local float damage;
  769. local entity lightcont;
  770.  
  771. org = self.origin;
  772.  
  773. head = findradius(self.origin, 250); // finds all entitys within 250 (2.5 meters?)
  774. while (head)
  775. {
  776. if (head.takedamage)
  777. {
  778. if(head != self.owner) // if the entity (head) is you (self.owner as stated in BFG_Shot), skip
  779. {
  780. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  781. WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  782. WriteEntity (MSG_BROADCAST, head); // Start position for lightning
  783. WriteCoord (MSG_BROADCAST, org_x); // Your position
  784. WriteCoord (MSG_BROADCAST, org_y);
  785. WriteCoord (MSG_BROADCAST, org_z);
  786. WriteCoord (MSG_BROADCAST, head.origin_x); // entity's position
  787. WriteCoord (MSG_BROADCAST, head.origin_y);
  788. WriteCoord (MSG_BROADCAST, head.origin_z);
  789. sound (head, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  790. damage = 20; //40 + random()*20
  791. T_Damage (head, lightcont, lightcont.owner, damage);
  792. }
  793. }
  794. head = head.chain; // cycle to next head (entity)
  795. }
  796.  
  797. };
  798.  
  799. //BFG orb sprites
  800. void() bfgshot1 = [0, bfgshot2] {self.nextthink = time + 0.05;bfg_ball_think();};
  801. void() bfgshot2 = [1, bfgshot1] {self.nextthink = time + 0.05;bfg_ball_think();};
  802.  
  803. void(vector org) BFG_Blast =
  804. {
  805.  
  806. local entity newent;
  807.  
  808. newent = spawn(); //create new entity to become the blast
  809. newent.origin = org; //set location to the ending of the lightning
  810. newent.movetype = MOVETYPE_NONE;
  811. newent.velocity = '0 0 0';
  812. newent.touch = SUB_Null;
  813. setmodel (newent, "progs/bfgblst.spr"); //self
  814. newent.solid = SOLID_NOT;
  815.  
  816. //bfgblast1();
  817. newent.nextthink = time + 0.01;
  818. newent.think = bfgblast1;
  819.  
  820. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  821. WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
  822. WriteCoord (MSG_BROADCAST, org_x); //self.origin, org_
  823. WriteCoord (MSG_BROADCAST, org_y);
  824. WriteCoord (MSG_BROADCAST, org_z);
  825. WriteByte (MSG_BROADCAST, 246);
  826. WriteByte (MSG_BROADCAST, 1);
  827. sound (newent, CHAN_WEAPON, "weapons/bfgblast.wav", 1, ATTN_NORM);
  828. };
  829.  
  830. void() BFG_Expl =
  831. {
  832.  
  833. local vector org;
  834. local entity head;
  835. local float damage;
  836. local entity bfgexpl;
  837.  
  838. self.movetype = MOVETYPE_NONE;
  839. self.velocity = '0 0 0';
  840. self.touch = SUB_Null;
  841. setmodel (self, "progs/bfgexpl.spr"); //self
  842. self.solid = SOLID_NOT;
  843. //bfgexpl1();
  844. self.nextthink = time + 0.01;
  845. self.think = bfgexpl1;
  846.  
  847. //the bfg blast fires deadlier lightning bolts to nearby enemies, comes from BFG orb on impact
  848.  
  849. org = self.origin;
  850.  
  851. head = findradius(self.origin, 300);
  852. while (head)
  853. {
  854. if (head.takedamage)
  855. {
  856. if(head != self.owner) // if the entity (head) is you (self.owner as stated in BFG_Shot), skip
  857. {
  858. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  859. WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  860. WriteEntity (MSG_BROADCAST, head); // Start position for lightning
  861. WriteCoord (MSG_BROADCAST, org_x); // Your position
  862. WriteCoord (MSG_BROADCAST, org_y);
  863. WriteCoord (MSG_BROADCAST, org_z);
  864. WriteCoord (MSG_BROADCAST, head.origin_x); // entity's position
  865. WriteCoord (MSG_BROADCAST, head.origin_y);
  866. WriteCoord (MSG_BROADCAST, head.origin_z);
  867. damage = 150;
  868. T_Damage (head, self, self.owner, damage);
  869. BFG_Blast(head.origin);
  870. }
  871. }
  872. head = head.chain; // cycle to next head (entity)
  873. }
  874.  
  875. };
  876.  
  877. void() BFG_Touch =
  878. {
  879. local float rand;
  880. if (other == self.owner)
  881. return;
  882.  
  883. if (other.solid == SOLID_TRIGGER)
  884. return; // trigger field, do nothing
  885.  
  886. if (pointcontents(self.origin) == CONTENT_SKY)
  887. {
  888. remove(self);
  889. return;
  890. }
  891.  
  892. // hit something that bleeds
  893. if (other.takedamage)
  894. {
  895. if (other.health < 265)
  896. {
  897. spawn_touchblood (32);
  898. T_Damage (other, self, self.owner, 300); //most monsters would gib on impact, so it will keep going. If the body's still in one piece when dying, the orb should explode as they're solid.
  899. }
  900. else
  901. {
  902. //spawn_touchblood (16);
  903. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  904. WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
  905. WriteCoord (MSG_BROADCAST, self.origin_x);
  906. WriteCoord (MSG_BROADCAST, self.origin_y);
  907. WriteCoord (MSG_BROADCAST, self.origin_z);
  908. WriteByte (MSG_BROADCAST, 246);
  909. WriteByte (MSG_BROADCAST, 1);
  910. sound (self, CHAN_WEAPON, "weapons/bfgexp.wav", 1, ATTN_NORM);
  911.  
  912. T_Damage (other, self, self.owner, 300);
  913. BFG_Expl();
  914. remove(self);
  915. }
  916.  
  917. }
  918. else
  919. {
  920. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  921. WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
  922. WriteCoord (MSG_BROADCAST, self.origin_x);
  923. WriteCoord (MSG_BROADCAST, self.origin_y);
  924. WriteCoord (MSG_BROADCAST, self.origin_z);
  925. WriteByte (MSG_BROADCAST, 246);
  926. WriteByte (MSG_BROADCAST, 1);
  927. sound (self, CHAN_WEAPON, "weapons/bfgexp.wav", 1, ATTN_NORM);
  928.  
  929. BFG_Expl();
  930. remove(self);
  931. }
  932.  
  933. };
  934.  
  935. void(vector org, vector vec) BFGShot =
  936. {
  937. local vector vec;
  938. local entity bfgsphere;
  939.  
  940. vec = normalize(vec);
  941.  
  942. bfgsphere = spawn();
  943. bfgsphere.owner = self;
  944. bfgsphere.movetype = MOVETYPE_FLY;
  945. bfgsphere.solid = SOLID_BBOX;
  946. bfgsphere.effects = EF_DIMLIGHT;
  947.  
  948. setmodel (bfgsphere, "progs/bfgshot.spr");
  949. setsize (bfgsphere, '0 0 0', '0 0 0');
  950. bfgsphere.think = bfgshot1;
  951.  
  952. setorigin (bfgsphere, org);
  953.  
  954. bfgsphere.velocity = vec * 800; //600
  955. bfgsphere.angles = vectoangles(bfgsphere.velocity);
  956.  
  957. //bfgsphere.nextthink = time + 5;
  958. //bfgsphere.think = SUB_Remove;
  959.  
  960. //bfgsphere.nextthink = time + 0.3; //how often lightning strikes
  961. //bfgsphere.think = bfg_ball_think; //keep repeating
  962.  
  963. bfgsphere.nextthink = time + 0.1;
  964. bfgsphere.think = bfgshot1;
  965.  
  966. //for nextthinks: the greater values ust be put at first
  967.  
  968. bfgsphere.touch = BFG_Touch;
  969. };
  970.  
  971. void() W_Bfg_Fire =
  972. {
  973. local vector org;
  974.  
  975. self.effects = self.effects | EF_MUZZLEFLASH;
  976. makevectors (self.v_angle); //v_xxx refers to the player's facing direction
  977.  
  978. org = self.origin + v_forward * 30 + '0 0 16'; //org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 16';
  979. sound (self, CHAN_WEAPON, "weapons/bfgfire1.wav", 1, ATTN_NORM);
  980.  
  981. BFGShot(org, v_forward);
  982. self.currentammo = self.ammo_cells = self.ammo_cells - 30;
  983. };
  984.  
  985. /*
  986. ==============================================================================
  987.  
  988. ROCKETS
  989.  
  990. ==============================================================================
  991. */
  992.  
  993. void() s_explode1 = [0, s_explode2] {};
  994. void() s_explode2 = [1, s_explode3] {};
  995. void() s_explode3 = [2, s_explode4] {};
  996. void() s_explode4 = [3, s_explode5] {};
  997. void() s_explode5 = [4, s_explode6] {};
  998. void() s_explode6 = [5, SUB_Remove] {};
  999.  
  1000. void() BecomeExplosion =
  1001. {
  1002. self.movetype = MOVETYPE_NONE;
  1003. self.velocity = '0 0 0';
  1004. self.touch = SUB_Null;
  1005. setmodel (self, "progs/s_explod.spr");
  1006. self.solid = SOLID_NOT;
  1007. s_explode1 ();
  1008. };
  1009.  
  1010. void() T_MissileTouch =
  1011. {
  1012. local float damg;
  1013.  
  1014. if (other == self.owner)
  1015. return; // don't explode on owner
  1016.  
  1017. if (pointcontents(self.origin) == CONTENT_SKY)
  1018. {
  1019. remove(self);
  1020. return;
  1021. }
  1022.  
  1023. damg = 100; //Quake3 damage, original is "100 + random()*20"
  1024.  
  1025. if (other.health)
  1026. {
  1027. if (other.classname == "monster_shambler")
  1028. damg = damg * 0.5; // mostly immune
  1029. T_Damage (other, self, self.owner, damg );
  1030. }
  1031.  
  1032. // don't do radius damage to the other, because all the damage
  1033. // was done in the impact
  1034. T_RadiusDamage (self, self.owner, 120, other);
  1035.  
  1036. sound (self, CHAN_WEAPON, "weapons/expl.wav", 1, ATTN_NORM);
  1037. self.origin = self.origin - 8*normalize(self.velocity);
  1038.  
  1039. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1040. WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  1041. WriteCoord (MSG_BROADCAST, self.origin_x);
  1042. WriteCoord (MSG_BROADCAST, self.origin_y);
  1043. WriteCoord (MSG_BROADCAST, self.origin_z);
  1044.  
  1045. BecomeExplosion ();
  1046. };
  1047.  
  1048.  
  1049.  
  1050. /*
  1051. ================
  1052. W_FireRocket
  1053. ================
  1054. */
  1055. void() W_FireRocket =
  1056. {
  1057. local entity missile, mpuff;
  1058.  
  1059. self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  1060.  
  1061. sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  1062.  
  1063. self.punchangle_x = -2;
  1064.  
  1065. missile = spawn ();
  1066. missile.owner = self;
  1067. missile.movetype = MOVETYPE_FLYMISSILE;
  1068. missile.solid = SOLID_BBOX;
  1069. missile.classname = "missile";
  1070.  
  1071. // set missile speed
  1072.  
  1073. makevectors (self.v_angle);
  1074. missile.velocity = aim(self, 900); //Quake3 speed, original is 1000
  1075. missile.velocity = missile.velocity * 900; //Quake3 speed, original is 1000
  1076. missile.angles = vectoangles(missile.velocity);
  1077.  
  1078. missile.touch = T_MissileTouch;
  1079.  
  1080. // set missile duration
  1081. missile.nextthink = time + 5;
  1082. missile.think = SUB_Remove;
  1083.  
  1084. setmodel (missile, "progs/missile.mdl");
  1085. setsize (missile, '0 0 0', '0 0 0');
  1086. setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  1087. };
  1088.  
  1089. /*
  1090. ===============================================================================
  1091.  
  1092. LIGHTNING
  1093.  
  1094. ===============================================================================
  1095. */
  1096.  
  1097. /*
  1098. =================
  1099. LightningDamage
  1100. =================
  1101. */
  1102. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  1103. {
  1104. local entity e1, e2;
  1105. local vector f;
  1106.  
  1107. f = p2 - p1;
  1108. normalize (f);
  1109. f_x = 0 - f_y;
  1110. f_y = f_x;
  1111. f_z = 0;
  1112. f = f*16;
  1113.  
  1114. e1 = e2 = world;
  1115.  
  1116. traceline (p1, p2, FALSE, self);
  1117. if (trace_ent.takedamage)
  1118. {
  1119. particle (trace_endpos, '0 0 100', 225, damage*4);
  1120. T_Damage (trace_ent, from, from, damage);
  1121. if (self.classname == "player")
  1122. {
  1123. if (other.classname == "player")
  1124. trace_ent.velocity_z = trace_ent.velocity_z + 400;
  1125. }
  1126. }
  1127. e1 = trace_ent;
  1128.  
  1129. traceline (p1 + f, p2 + f, FALSE, self);
  1130. if (trace_ent != e1 && trace_ent.takedamage)
  1131. {
  1132. particle (trace_endpos, '0 0 100', 225, damage*4);
  1133. T_Damage (trace_ent, from, from, damage);
  1134. }
  1135. e2 = trace_ent;
  1136.  
  1137. traceline (p1 - f, p2 - f, FALSE, self);
  1138. if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  1139. {
  1140. particle (trace_endpos, '0 0 100', 225, damage*4);
  1141. T_Damage (trace_ent, from, from, damage);
  1142. }
  1143. };
  1144.  
  1145.  
  1146. void() W_FireLightning =
  1147. {
  1148. local vector org;
  1149. local float cells;
  1150.  
  1151. if (self.ammo_cells < 1)
  1152. {
  1153. self.weapon = W_BestWeapon ();
  1154. W_SetCurrentAmmo ();
  1155. return;
  1156. }
  1157.  
  1158. // explode if under water
  1159. if (self.waterlevel > 1)
  1160. {
  1161. cells = self.ammo_cells;
  1162. self.ammo_cells = 0;
  1163. W_SetCurrentAmmo ();
  1164. T_RadiusDamage (self, self, 35*cells, world);
  1165. return;
  1166. }
  1167.  
  1168. if (self.t_width < time)
  1169. {
  1170. sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  1171. self.t_width = time + 0.6;
  1172. }
  1173. self.punchangle_x = -2;
  1174.  
  1175. self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  1176.  
  1177. org = self.origin + '0 0 16';
  1178.  
  1179. traceline (org, org + v_forward*600, TRUE, self);
  1180.  
  1181. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1182. WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  1183. WriteEntity (MSG_BROADCAST, self);
  1184. WriteCoord (MSG_BROADCAST, org_x);
  1185. WriteCoord (MSG_BROADCAST, org_y);
  1186. WriteCoord (MSG_BROADCAST, org_z);
  1187. WriteCoord (MSG_BROADCAST, trace_endpos_x);
  1188. WriteCoord (MSG_BROADCAST, trace_endpos_y);
  1189. WriteCoord (MSG_BROADCAST, trace_endpos_z);
  1190.  
  1191. LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
  1192. };
  1193.  
  1194.  
  1195. //=============================================================================
  1196.  
  1197.  
  1198. void() GrenadeExplode =
  1199. {
  1200. T_RadiusDamage (self, self.owner, 120, world);
  1201.  
  1202. sound (self, CHAN_WEAPON, "weapons/expl.wav", 1, ATTN_NORM);
  1203.  
  1204. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1205. WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  1206. WriteCoord (MSG_BROADCAST, self.origin_x);
  1207. WriteCoord (MSG_BROADCAST, self.origin_y);
  1208. WriteCoord (MSG_BROADCAST, self.origin_z);
  1209.  
  1210. BecomeExplosion ();
  1211. };
  1212.  
  1213. void() GrenadeTouch =
  1214. {
  1215. if (other == self.owner)
  1216. return; // don't explode on owner
  1217. if (other.takedamage == DAMAGE_AIM)
  1218. {
  1219. GrenadeExplode();
  1220. return;
  1221. }
  1222. sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
  1223. if (self.velocity == '0 0 0')
  1224. self.avelocity = '0 0 0';
  1225. };
  1226.  
  1227. /*
  1228. ================
  1229. W_FireGrenade
  1230. ================
  1231. */
  1232. void() W_FireGrenade =
  1233. {
  1234. local entity missile, mpuff;
  1235.  
  1236. self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  1237.  
  1238. sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  1239.  
  1240. self.punchangle_x = -2;
  1241.  
  1242. missile = spawn ();
  1243. missile.owner = self;
  1244. missile.movetype = MOVETYPE_BOUNCE;
  1245. missile.solid = SOLID_BBOX;
  1246. missile.classname = "grenade";
  1247.  
  1248. // set missile speed
  1249.  
  1250. makevectors (self.v_angle);
  1251.  
  1252. if (self.v_angle_x)
  1253. missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  1254. else
  1255. {
  1256. missile.velocity = aim(self, 10000);
  1257. missile.velocity = missile.velocity * 600;
  1258. missile.velocity_z = 200;
  1259. }
  1260.  
  1261. missile.avelocity = '300 300 300';
  1262.  
  1263. missile.angles = vectoangles(missile.velocity);
  1264.  
  1265. missile.touch = GrenadeTouch;
  1266.  
  1267. // set missile duration
  1268. missile.nextthink = time + 2.5;
  1269. missile.think = GrenadeExplode;
  1270.  
  1271. setmodel (missile, "progs/grenade.mdl");
  1272. setsize (missile, '0 0 0', '0 0 0');
  1273. setorigin (missile, self.origin);
  1274. };
  1275.  
  1276.  
  1277. //=============================================================================
  1278.  
  1279. void() spike_touch;
  1280. void() superspike_touch;
  1281. void() spike_butcher_touch;
  1282.  
  1283.  
  1284. /*
  1285. ===============
  1286. launch_spike
  1287.  
  1288. Used for both the player and the ogre
  1289. ===============
  1290. */
  1291. void(vector org, vector dir) launch_spike =
  1292. {
  1293. newmis = spawn ();
  1294. newmis.owner = self;
  1295. newmis.movetype = MOVETYPE_FLYMISSILE;
  1296. newmis.solid = SOLID_BBOX;
  1297.  
  1298. newmis.angles = vectoangles(dir);
  1299.  
  1300. newmis.touch = spike_touch;
  1301. newmis.classname = "spike";
  1302. newmis.think = SUB_Remove;
  1303. newmis.nextthink = time + 6;
  1304. setmodel (newmis, "progs/spike.mdl");
  1305. setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
  1306. setorigin (newmis, org);
  1307.  
  1308. newmis.velocity = dir * 1200; //1000
  1309. };
  1310.  
  1311. void(vector org, vector dir) launch_spike_butcher =
  1312. {
  1313. newmis = spawn ();
  1314. newmis.owner = self;
  1315. newmis.movetype = MOVETYPE_FLYMISSILE;
  1316. newmis.solid = SOLID_BBOX;
  1317.  
  1318. newmis.angles = vectoangles(dir);
  1319.  
  1320. newmis.touch = spike_butcher_touch;
  1321. newmis.classname = "spike";
  1322. newmis.think = SUB_Remove;
  1323. newmis.nextthink = time + 6;
  1324. setmodel (newmis, "progs/spike.mdl");
  1325. setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
  1326. setorigin (newmis, org);
  1327.  
  1328. newmis.velocity = dir * 900; //1000
  1329. };
  1330.  
  1331. void() W_FireSuperSpikes =
  1332. {
  1333. local vector dir;
  1334. local entity old;
  1335.  
  1336. sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  1337. self.attack_finished = time + 0.2;
  1338. self.currentammo = self.ammo_nails = self.ammo_nails - 2;
  1339. dir = aim (self, 1000);
  1340. launch_spike (self.origin + '0 0 16', dir);
  1341. newmis.touch = superspike_touch;
  1342. setmodel (newmis, "progs/s_spike.mdl");
  1343. setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
  1344. self.punchangle_x = -2;
  1345. };
  1346.  
  1347. void(float ox) W_FireSpikes =
  1348. {
  1349. local vector dir;
  1350. local entity old;
  1351.  
  1352. makevectors (self.v_angle);
  1353.  
  1354. if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
  1355. {
  1356. W_FireSuperSpikes ();
  1357. return;
  1358. }
  1359.  
  1360. if (self.ammo_nails < 1)
  1361. {
  1362. self.weapon = W_BestWeapon ();
  1363. W_SetCurrentAmmo ();
  1364. return;
  1365. }
  1366.  
  1367. sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
  1368. self.attack_finished = time + 0.2;
  1369. self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  1370. dir = aim (self, 1000);
  1371. launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
  1372.  
  1373. self.punchangle_x = -2;
  1374. };
  1375.  
  1376.  
  1377.  
  1378. .float hit_z;
  1379. void() spike_touch =
  1380. {
  1381. local float rand;
  1382. if (other == self.owner)
  1383. return;
  1384.  
  1385. if (other.solid == SOLID_TRIGGER)
  1386. return; // trigger field, do nothing
  1387.  
  1388. if (pointcontents(self.origin) == CONTENT_SKY)
  1389. {
  1390. remove(self);
  1391. return;
  1392. }
  1393.  
  1394. // hit something that bleeds
  1395. if (other.takedamage)
  1396. {
  1397. spawn_touchblood (9);
  1398. T_Damage (other, self, self.owner, 9);
  1399. }
  1400. else
  1401. {
  1402. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1403.  
  1404. if (self.classname == "wizspike")
  1405. WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  1406. else if (self.classname == "knightspike")
  1407. WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  1408. else
  1409. WriteByte (MSG_BROADCAST, TE_SPIKE);
  1410. WriteCoord (MSG_BROADCAST, self.origin_x);
  1411. WriteCoord (MSG_BROADCAST, self.origin_y);
  1412. WriteCoord (MSG_BROADCAST, self.origin_z);
  1413. }
  1414.  
  1415. remove(self);
  1416.  
  1417. };
  1418.  
  1419. void() superspike_touch =
  1420. {
  1421. local float rand;
  1422. if (other == self.owner)
  1423. return;
  1424.  
  1425. if (other.solid == SOLID_TRIGGER)
  1426. return; // trigger field, do nothing
  1427.  
  1428. if (pointcontents(self.origin) == CONTENT_SKY)
  1429. {
  1430. remove(self);
  1431. return;
  1432. }
  1433.  
  1434. // hit something that bleeds
  1435. if (other.takedamage)
  1436. {
  1437. spawn_touchblood (18);
  1438. T_Damage (other, self, self.owner, 18);
  1439. sound (self, CHAN_AUTO, "weapons/mtshot.wav", 1, ATTN_NORM);
  1440. }
  1441. else
  1442. {
  1443. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1444. WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  1445. WriteCoord (MSG_BROADCAST, self.origin_x);
  1446. WriteCoord (MSG_BROADCAST, self.origin_y);
  1447. WriteCoord (MSG_BROADCAST, self.origin_z);
  1448. }
  1449.  
  1450. remove(self);
  1451.  
  1452. };
  1453.  
  1454. void() spike_butcher_touch =
  1455. {
  1456. local float rand;
  1457. if (other == self.owner)
  1458. return;
  1459.  
  1460. if (other.solid == SOLID_TRIGGER)
  1461. return; // trigger field, do nothing
  1462.  
  1463. if (pointcontents(self.origin) == CONTENT_SKY)
  1464. {
  1465. remove(self);
  1466. return;
  1467. }
  1468.  
  1469. // hit something that bleeds
  1470. if (other.takedamage)
  1471. {
  1472. spawn_touchblood (9);
  1473. T_Damage (other, self, self.owner, 5); //9
  1474. sound (self, CHAN_AUTO, "weapons/mtshot.wav", 1, ATTN_NORM);
  1475. }
  1476. else
  1477. {
  1478. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1479.  
  1480. if (self.classname == "wizspike")
  1481. WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  1482. else if (self.classname == "knightspike")
  1483. WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  1484. else
  1485. WriteByte (MSG_BROADCAST, TE_SPIKE);
  1486. WriteCoord (MSG_BROADCAST, self.origin_x);
  1487. WriteCoord (MSG_BROADCAST, self.origin_y);
  1488. WriteCoord (MSG_BROADCAST, self.origin_z);
  1489. }
  1490.  
  1491. remove(self);
  1492.  
  1493. };
  1494.  
  1495.  
  1496. /*
  1497. ===============================================================================
  1498.  
  1499. PLAYER WEAPON USE
  1500.  
  1501. ===============================================================================
  1502. */
  1503.  
  1504. void() W_SetCurrentAmmo =
  1505. {
  1506. player_run (); // get out of any weapon firing states
  1507.  
  1508. self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
  1509.  
  1510. if (self.weapon == IT_AXE)
  1511. {
  1512. self.currentammo = 0;
  1513. self.weaponmodel = "progs/v_axe.mdl";
  1514. self.weaponframe = 0;
  1515. }
  1516. else if (self.weapon == IT_SHOTGUN)
  1517. {
  1518. self.currentammo = self.ammo_shells;
  1519. self.weaponmodel = "progs/v_shot.mdl";
  1520. self.weaponframe = 0;
  1521. self.items = self.items | IT_SHELLS;
  1522. }
  1523. else if (self.weapon == IT_SUPER_SHOTGUN)
  1524. {
  1525. self.currentammo = self.ammo_shells;
  1526. self.weaponmodel = "progs/v_shot2.mdl";
  1527. self.weaponframe = 0;
  1528. self.items = self.items | IT_SHELLS;
  1529. }
  1530. else if (self.weapon == IT_NAILGUN)
  1531. {
  1532. self.currentammo = self.ammo_nails;
  1533. self.weaponmodel = "progs/v_nail.mdl";
  1534. self.weaponframe = 0;
  1535. self.items = self.items | IT_NAILS;
  1536. }
  1537. else if (self.weapon == IT_INFANTRY_GUN)
  1538. {
  1539. self.currentammo = self.ammo_nails;
  1540. self.weaponmodel = "progs/v_infg.mdl";
  1541. self.weaponframe = 0;
  1542. self.items = self.items | IT_NAILS;
  1543. }
  1544. else if (self.weapon == IT_SUPER_NAILGUN)
  1545. {
  1546. self.currentammo = self.ammo_nails;
  1547. self.weaponmodel = "progs/v_nail2.mdl";
  1548. self.weaponframe = 0;
  1549. self.items = self.items | IT_NAILS;
  1550. }
  1551. else if (self.weapon == IT_GATLING_GUN)
  1552. {
  1553. self.currentammo = self.ammo_nails;
  1554. self.weaponmodel = "progs/v_gatlg.mdl";
  1555. self.weaponframe = 0;
  1556. self.items = self.items | IT_NAILS;
  1557. }
  1558. else if (self.weapon == IT_GRENADE_LAUNCHER)
  1559. {
  1560. self.currentammo = self.ammo_rockets;
  1561. self.weaponmodel = "progs/v_rock.mdl";
  1562. self.weaponframe = 0;
  1563. self.items = self.items | IT_ROCKETS;
  1564. }
  1565. else if (self.weapon == IT_ROCKET_LAUNCHER)
  1566. {
  1567. self.currentammo = self.ammo_rockets;
  1568. self.weaponmodel = "progs/v_rock2.mdl";
  1569. self.weaponframe = 0;
  1570. self.items = self.items | IT_ROCKETS;
  1571. }
  1572. else if (self.weapon == IT_LIGHTNING)
  1573. {
  1574. self.currentammo = self.ammo_cells;
  1575. self.weaponmodel = "progs/v_light.mdl";
  1576. self.weaponframe = 0;
  1577. self.items = self.items | IT_CELLS;
  1578. }
  1579. else if (self.weapon == IT_BFG9500)
  1580. {
  1581. self.currentammo = self.ammo_cells;
  1582. self.weaponmodel = "progs/v_bfg.mdl";
  1583. self.weaponframe = 0;
  1584. self.items = self.items | IT_CELLS;
  1585. }
  1586. else
  1587. {
  1588. self.currentammo = 0;
  1589. self.weaponmodel = "";
  1590. self.weaponframe = 0;
  1591. }
  1592. };
  1593.  
  1594. float() W_BestWeapon =
  1595. {
  1596. local float it;
  1597.  
  1598. it = self.items;
  1599.  
  1600. if(self.ammo_cells >= 30 && (it & IT_BFG9500) )
  1601. return IT_BFG9500;
  1602. if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
  1603. return IT_LIGHTNING;
  1604. if(self.ammo_nails >= 1 && (it & IT_GATLING_GUN) )
  1605. return IT_GATLING_GUN;
  1606. if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
  1607. return IT_SUPER_NAILGUN;
  1608. if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
  1609. return IT_SUPER_SHOTGUN;
  1610. if(self.ammo_nails >= 1 && (it & IT_INFANTRY_GUN) )
  1611. return IT_INFANTRY_GUN;
  1612. if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
  1613. return IT_NAILGUN;
  1614. if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
  1615. return IT_SHOTGUN;
  1616. return IT_AXE;
  1617. };
  1618.  
  1619. float() W_CheckNoAmmo =
  1620. {
  1621. if (self.currentammo > 0)
  1622. return TRUE;
  1623.  
  1624. if (self.weapon == IT_AXE)
  1625. return TRUE;
  1626.  
  1627. self.weapon = W_BestWeapon ();
  1628.  
  1629. W_SetCurrentAmmo ();
  1630.  
  1631. // drop the weapon down
  1632. return FALSE;
  1633. };
  1634.  
  1635. /*
  1636. ============
  1637. W_Attack
  1638.  
  1639. An attack impulse can be triggered now
  1640. ============
  1641. */
  1642. void() player_axe1;
  1643. void() player_axeb1;
  1644. void() player_axec1;
  1645. void() player_axed1;
  1646. void() player_shot1;
  1647. void() player_nail1;
  1648. void() player_inf1;
  1649. void() player_gatlup1;
  1650. void() player_light1;
  1651. void() player_rocket1;
  1652. void() player_bfgprep1;
  1653.  
  1654. void() W_Attack =
  1655. {
  1656. local float r;
  1657.  
  1658. if (!W_CheckNoAmmo ())
  1659. return;
  1660.  
  1661. makevectors (self.v_angle); // calculate forward angle for velocity
  1662. self.show_hostile = time + 1; // wake monsters up
  1663.  
  1664. if (self.weapon == IT_AXE)
  1665. {
  1666. sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1667. r = random();
  1668. if (r < 0.25)
  1669. player_axe1 ();
  1670. else if (r<0.5)
  1671. player_axeb1 ();
  1672. else if (r<0.75)
  1673. player_axec1 ();
  1674. else
  1675. player_axed1 ();
  1676. self.attack_finished = time + 0.5;
  1677. }
  1678. else if (self.weapon == IT_SHOTGUN)
  1679. {
  1680. player_shot1 ();
  1681. W_FireShotgun ();
  1682. self.attack_finished = time + 0.5;
  1683. }
  1684. else if (self.weapon == IT_SUPER_SHOTGUN)
  1685. {
  1686. player_shot1 ();
  1687. W_FireSuperShotgun ();
  1688. self.attack_finished = time + 0.7;
  1689. }
  1690. else if (self.weapon == IT_NAILGUN)
  1691. {
  1692. player_nail1 ();
  1693. }
  1694. else if (self.weapon == IT_INFANTRY_GUN)
  1695. {
  1696. player_inf1 ();
  1697. }
  1698. else if (self.weapon == IT_SUPER_NAILGUN)
  1699. {
  1700. player_nail1 ();
  1701. }
  1702. else if (self.weapon == IT_GATLING_GUN)
  1703. {
  1704. player_gatlup1 ();
  1705. }
  1706. else if (self.weapon == IT_GRENADE_LAUNCHER)
  1707. {
  1708. player_rocket1();
  1709. W_FireGrenade();
  1710. self.attack_finished = time + 0.6;
  1711. }
  1712. else if (self.weapon == IT_ROCKET_LAUNCHER)
  1713. {
  1714. player_rocket1();
  1715. W_FireRocket();
  1716. self.attack_finished = time + 0.8;
  1717. }
  1718. else if (self.weapon == IT_LIGHTNING)
  1719. {
  1720. player_light1();
  1721. self.attack_finished = time + 0.1;
  1722. sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  1723. }
  1724. else if (self.weapon == IT_BFG9500)
  1725. {
  1726. player_bfgprep1 ();
  1727. }
  1728. };
  1729.  
  1730. /*
  1731. ============
  1732. W_ChangeWeapon
  1733.  
  1734. ============
  1735. */
  1736. void() W_ChangeWeapon =
  1737. {
  1738. local float it, am, fl;
  1739. local float oldimpulse;
  1740.  
  1741. it = self.items;
  1742. am = 0;
  1743.  
  1744. if (self.impulse == 1)
  1745. {
  1746. fl = IT_AXE;
  1747. }
  1748. else if (self.impulse == 2)
  1749. {
  1750. fl = IT_SHOTGUN;
  1751. if (self.ammo_shells < 1)
  1752. am = 1;
  1753. }
  1754. else if (self.impulse == 3)
  1755. {
  1756. fl = IT_SUPER_SHOTGUN;
  1757. if (self.ammo_shells < 2)
  1758. am = 1;
  1759. }
  1760.  
  1761. else if (self.impulse == 4)
  1762. {
  1763. if (self.weapon == IT_NAILGUN)
  1764. {
  1765. fl = IT_INFANTRY_GUN;
  1766. }
  1767. else
  1768. {
  1769. fl = IT_NAILGUN;
  1770. }
  1771. if (self.ammo_nails < 1)
  1772. am = 1;
  1773. }
  1774.  
  1775. //else if (self.impulse == 4)
  1776. //{
  1777. // if (self.weapon == IT_NAILGUN)
  1778. // {
  1779. // fl = IT_INFANTRY_GUN;
  1780. // }
  1781. //
  1782. // if (self.weapon == IT_INFANTRY_GUN)
  1783. // {
  1784. // fl = IT_NAILGUN;
  1785. // }
  1786. //
  1787. // if (self.weapon != IT_NAILGUN)
  1788. // {
  1789. // fl = IT_NAILGUN;
  1790. // }
  1791. //
  1792. // if (self.weapon != IT_INFANTRY_GUN)
  1793. // {
  1794. // fl = IT_INFANTRY_GUN;
  1795. // }
  1796. //
  1797. // if (self.ammo_nails < 1)
  1798. // am = 1;
  1799. //
  1800. // }
  1801.  
  1802. else if (self.impulse == 5)
  1803. {
  1804. if (self.weapon == IT_SUPER_NAILGUN)
  1805. {
  1806. fl = IT_GATLING_GUN;
  1807. if (self.ammo_nails < 1)
  1808. am = 1;
  1809. }
  1810. else
  1811. {
  1812. fl = IT_SUPER_NAILGUN;
  1813. if (self.ammo_nails < 2)
  1814. am = 1;
  1815. }
  1816. }
  1817.  
  1818. //else if (self.impulse == 5)
  1819. //{
  1820. // if (self.weapon == IT_SUPER_NAILGUN)
  1821. // {
  1822. // fl = IT_GATLING_GUN;
  1823. // }
  1824. //
  1825. // if (self.weapon == IT_GATLING_GUN)
  1826. // {
  1827. // fl = IT_SUPER_NAILGUN;
  1828. // }
  1829. //
  1830. // if (self.weapon != IT_SUPER_NAILGUN)
  1831. // {
  1832. // fl = IT_SUPER_NAILGUN;
  1833. // }
  1834. //
  1835. // if (self.weapon != IT_GATLING_GUN)
  1836. // {
  1837. // fl = IT_GATLING_GUN;
  1838. // }
  1839. //
  1840. // if (self.ammo_nails < 1)
  1841. // am = 1; // < 2
  1842. // }
  1843.  
  1844. else if (self.impulse == 6)
  1845. {
  1846. fl = IT_GRENADE_LAUNCHER;
  1847. if (self.ammo_rockets < 1)
  1848. am = 1;
  1849. }
  1850. else if (self.impulse == 7)
  1851. {
  1852. fl = IT_ROCKET_LAUNCHER;
  1853. if (self.ammo_rockets < 1)
  1854. am = 1;
  1855. }
  1856.  
  1857. else if (self.impulse == 8)
  1858. {
  1859. if (self.weapon == IT_LIGHTNING)
  1860. {
  1861. fl = IT_BFG9500;
  1862. if (self.ammo_cells < 30)
  1863. am = 1;;
  1864. }
  1865. else
  1866. {
  1867. fl = IT_LIGHTNING;
  1868. if (self.ammo_cells < 1)
  1869. am = 1;
  1870. }
  1871.  
  1872. }
  1873.  
  1874. //else if (self.impulse == 8)
  1875. //{
  1876. // if (self.weapon == IT_LIGHTNING)
  1877. // {
  1878. // fl = IT_BFG9500;
  1879. // if (self.ammo_cells < 30)
  1880. // am = 1;
  1881. // }
  1882. //
  1883. // if (self.weapon == IT_BFG9500)
  1884. // {
  1885. // fl = IT_LIGHTNING;
  1886. // if (self.ammo_cells < 1)
  1887. // am = 1;
  1888. // }
  1889. //
  1890. // if (self.weapon != IT_LIGHTNING)
  1891. // {
  1892. // fl = IT_LIGHTNING;
  1893. // if (self.ammo_cells < 1)
  1894. // am = 1;
  1895. // }
  1896. //
  1897. // if (self.weapon != IT_BFG9500)
  1898. // {
  1899. // fl = IT_BFG9500;
  1900. // if (self.ammo_cells < 30)
  1901. // am = 1;
  1902. // }
  1903. }
  1904. //else if (self.impulse == 9)
  1905. //{
  1906. //fl = IT_BFG9500;
  1907. //if (self.ammo_cells < 30)
  1908. //am = 1;
  1909. //}
  1910.  
  1911. //MED
  1912. oldimpulse = self.impulse;
  1913. self.impulse = 0;
  1914.  
  1915. if (!(self.items & fl))
  1916. {
  1917. //MED
  1918. if (fl == IT_NAILGUN)
  1919. {
  1920. fl = IT_INFANTRY_GUN;
  1921. if (!(self.items & fl))
  1922. {
  1923. sprint (self, "no weapon.\n");
  1924. sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1925. return;
  1926. }
  1927. if (self.ammo_nails < 1)
  1928. am = 1;
  1929. else
  1930. am = 0;
  1931. }
  1932. else
  1933. {
  1934. sprint (self, "no weapon.\n");
  1935. sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1936. return;
  1937. }
  1938.  
  1939.  
  1940. if (fl == IT_SUPER_NAILGUN)
  1941. {
  1942. fl = IT_GATLING_GUN;
  1943. if (!(self.items & fl))
  1944. {
  1945. sprint (self, "no weapon.\n");
  1946. sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1947. return;
  1948. }
  1949. if (self.ammo_nails < 1)
  1950. am = 1;
  1951. else
  1952. am = 0;
  1953. }
  1954. else
  1955. {
  1956. sprint (self, "no weapon.\n");
  1957. sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1958. return;
  1959. }
  1960.  
  1961. if (fl == IT_LIGHTNING)
  1962. {
  1963. fl = IT_BFG9500;
  1964. if (self.ammo_cells < 30)
  1965. am = 1;
  1966. if (!(self.items & fl))
  1967. {
  1968. sprint (self, "no weapon.\n");
  1969. sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1970. return;
  1971. }
  1972. if (self.ammo_cells < 1)
  1973. am = 1;
  1974. else
  1975. am = 0;
  1976. }
  1977. else
  1978. {
  1979. sprint (self, "no weapon.\n");
  1980. return;
  1981. }
  1982.  
  1983. }
  1984.  
  1985. if (!(self.items & fl))
  1986. { // don't have the weapon or the ammo
  1987. sprint (self, "no weapon.\n");
  1988. sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1989. return;
  1990. }
  1991.  
  1992. if (am)
  1993. { // don't have the ammo
  1994. sprint (self, "not enough ammo.\n");
  1995. sound (self, CHAN_WEAPON, "weapons/noammo.wav", 1, ATTN_NORM);
  1996. return;
  1997. }
  1998.  
  1999. //
  2000. // set weapon, set ammo
  2001. //
  2002. self.weapon = fl;
  2003. W_SetCurrentAmmo ();
  2004. };
  2005.  
  2006. /*
  2007. ============
  2008. CheatCommand
  2009. ============
  2010. */
  2011. void() CheatCommand =
  2012. {
  2013. if (deathmatch || coop)
  2014. return;
  2015.  
  2016. self.ammo_rockets = 100;
  2017. self.ammo_nails = 200;
  2018. self.ammo_shells = 100;
  2019. self.items = self.items |
  2020. IT_AXE |
  2021. IT_SHOTGUN |
  2022. IT_SUPER_SHOTGUN |
  2023. IT_NAILGUN |
  2024. IT_INFANTRY_GUN |
  2025. IT_SUPER_NAILGUN |
  2026. IT_GATLING_GUN |
  2027. IT_GRENADE_LAUNCHER |
  2028. IT_ROCKET_LAUNCHER |
  2029. IT_KEY1 | IT_KEY2;
  2030.  
  2031. self.ammo_cells = 200;
  2032. self.items = self.items | IT_LIGHTNING | IT_BFG9500;
  2033.  
  2034. self.weapon = IT_ROCKET_LAUNCHER;
  2035. self.impulse = 0;
  2036. W_SetCurrentAmmo ();
  2037. };
  2038.  
  2039. /*
  2040. ============
  2041. CycleWeaponCommand
  2042.  
  2043. Go to the next weapon with ammo
  2044. ============
  2045. */
  2046. void() CycleWeaponCommand =
  2047. {
  2048. local float it, am;
  2049.  
  2050. it = self.items;
  2051. self.impulse = 0;
  2052.  
  2053. while (1)
  2054. {
  2055. am = 0;
  2056.  
  2057. if (self.weapon == IT_BFG9500)
  2058. {
  2059. self.weapon = IT_AXE;
  2060. }
  2061. else if (self.weapon == IT_AXE)
  2062. {
  2063. self.weapon = IT_SHOTGUN;
  2064. if (self.ammo_shells < 1)
  2065. am = 1;
  2066. }
  2067. else if (self.weapon == IT_SHOTGUN)
  2068. {
  2069. self.weapon = IT_SUPER_SHOTGUN;
  2070. if (self.ammo_shells < 2)
  2071. am = 1;
  2072. }
  2073. else if (self.weapon == IT_SUPER_SHOTGUN)
  2074. {
  2075. self.weapon = IT_NAILGUN;
  2076. if (self.ammo_nails < 1)
  2077. am = 1;
  2078. }
  2079. else if (self.weapon == IT_NAILGUN)
  2080. {
  2081. self.weapon = IT_INFANTRY_GUN;
  2082. if (self.ammo_nails < 1)
  2083. am = 1;
  2084. }
  2085. else if (self.weapon == IT_INFANTRY_GUN)
  2086. {
  2087. self.weapon = IT_SUPER_NAILGUN;
  2088. if (self.ammo_nails < 2)
  2089. am = 1;
  2090. }
  2091. else if (self.weapon == IT_SUPER_NAILGUN)
  2092. {
  2093. self.weapon = IT_GATLING_GUN;
  2094. if (self.ammo_nails < 1)
  2095. am = 1;
  2096. }
  2097. else if (self.weapon == IT_GATLING_GUN)
  2098. {
  2099. self.weapon = IT_GRENADE_LAUNCHER;
  2100. if (self.ammo_rockets < 1)
  2101. am = 1;
  2102. }
  2103. else if (self.weapon == IT_GRENADE_LAUNCHER)
  2104. {
  2105. self.weapon = IT_ROCKET_LAUNCHER;
  2106. if (self.ammo_rockets < 1)
  2107. am = 1;
  2108. }
  2109. else if (self.weapon == IT_ROCKET_LAUNCHER)
  2110. {
  2111. self.weapon = IT_LIGHTNING;
  2112. if (self.ammo_cells < 1)
  2113. am = 1;
  2114. }
  2115.  
  2116. else if (self.weapon == IT_LIGHTNING)
  2117. {
  2118. self.weapon = IT_BFG9500;
  2119. if (self.ammo_cells < 30)
  2120. am = 1;
  2121. }
  2122.  
  2123. if ( (it & self.weapon) && am == 0)
  2124. {
  2125. W_SetCurrentAmmo ();
  2126. return;
  2127. }
  2128. }
  2129.  
  2130. };
  2131.  
  2132. /*
  2133. ============
  2134. CycleWeaponReverseCommand
  2135.  
  2136. Go to the prev weapon with ammo
  2137. ============
  2138. */
  2139. void() CycleWeaponReverseCommand =
  2140. {
  2141. local float it, am;
  2142.  
  2143. it = self.items;
  2144. self.impulse = 0;
  2145.  
  2146. while (1)
  2147. {
  2148. am = 0;
  2149.  
  2150. if (self.weapon == IT_BFG9500)
  2151. {
  2152. self.weapon = IT_LIGHTNING;
  2153. if (self.ammo_cells < 1)
  2154. am = 1;
  2155. }
  2156. if (self.weapon == IT_LIGHTNING)
  2157. {
  2158. self.weapon = IT_ROCKET_LAUNCHER;
  2159. if (self.ammo_rockets < 1)
  2160. am = 1;
  2161. }
  2162. else if (self.weapon == IT_ROCKET_LAUNCHER)
  2163. {
  2164. self.weapon = IT_GRENADE_LAUNCHER;
  2165. if (self.ammo_rockets < 1)
  2166. am = 1;
  2167. }
  2168. else if (self.weapon == IT_GRENADE_LAUNCHER)
  2169. {
  2170. self.weapon = IT_GATLING_GUN;
  2171. if (self.ammo_nails < 1)
  2172. am = 1;
  2173. }
  2174. else if (self.weapon == IT_GATLING_GUN)
  2175. {
  2176. self.weapon = IT_SUPER_NAILGUN;
  2177. if (self.ammo_nails < 2)
  2178. am = 1;
  2179. }
  2180. else if (self.weapon == IT_SUPER_NAILGUN)
  2181. {
  2182. self.weapon = IT_INFANTRY_GUN;
  2183. if (self.ammo_nails < 1)
  2184. am = 1;
  2185. }
  2186. else if (self.weapon == IT_INFANTRY_GUN)
  2187. {
  2188. self.weapon = IT_NAILGUN;
  2189. if (self.ammo_nails < 1)
  2190. am = 1;
  2191. }
  2192. else if (self.weapon == IT_NAILGUN)
  2193. {
  2194. self.weapon = IT_SUPER_SHOTGUN;
  2195. if (self.ammo_shells < 2)
  2196. am = 1;
  2197. }
  2198. else if (self.weapon == IT_SUPER_SHOTGUN)
  2199. {
  2200. self.weapon = IT_SHOTGUN;
  2201. if (self.ammo_shells < 1)
  2202. am = 1;
  2203. }
  2204. else if (self.weapon == IT_SHOTGUN)
  2205. {
  2206. self.weapon = IT_AXE;
  2207. }
  2208. else if (self.weapon == IT_AXE)
  2209. {
  2210. self.weapon = IT_BFG9500;
  2211. if (self.ammo_cells < 30)
  2212. am = 1;
  2213. }
  2214.  
  2215. if ( (it & self.weapon) && am == 0)
  2216. {
  2217. W_SetCurrentAmmo ();
  2218. return;
  2219. }
  2220. }
  2221.  
  2222. };
  2223.  
  2224. /*
  2225. ============
  2226. ServerflagsCommand
  2227.  
  2228. Just for development
  2229. ============
  2230. */
  2231. void() ServerflagsCommand =
  2232. {
  2233. serverflags = serverflags * 2 + 1;
  2234. };
  2235.  
  2236. void() QuadCheat =
  2237. {
  2238. if (deathmatch || coop)
  2239. return;
  2240. self.super_time = 1;
  2241. self.super_damage_finished = time + 30;
  2242. self.items = self.items | IT_QUAD;
  2243. dprint ("quad cheat\n");
  2244. };
  2245.  
  2246. /*
  2247. ============
  2248. ImpulseCommands
  2249.  
  2250. ============
  2251. */
  2252. void() ImpulseCommands =
  2253. {
  2254. if (self.impulse >= 1 && self.impulse <= 8)
  2255. W_ChangeWeapon ();
  2256.  
  2257. if (self.impulse == 9)
  2258. CheatCommand ();
  2259. if (self.impulse == 10)
  2260. CycleWeaponCommand ();
  2261. if (self.impulse == 11)
  2262. ServerflagsCommand ();
  2263. if (self.impulse == 12)
  2264. CycleWeaponReverseCommand ();
  2265.  
  2266. if (self.impulse == 255)
  2267. QuadCheat ();
  2268.  
  2269. self.impulse = 0;
  2270. };
  2271.  
  2272. /*
  2273. ============
  2274. W_WeaponFrame
  2275.  
  2276. Called every frame so impulse events can be handled as well as possible
  2277. ============
  2278. */
  2279. void() W_WeaponFrame =
  2280. {
  2281. if (time < self.attack_finished)
  2282. return;
  2283.  
  2284. ImpulseCommands ();
  2285.  
  2286. // check for attack
  2287. if (self.button0)
  2288. {
  2289. SuperDamageSound ();
  2290. W_Attack ();
  2291. }
  2292. };
  2293.  
  2294. /*
  2295. ========
  2296. SuperDamageSound
  2297.  
  2298. Plays sound if needed
  2299. ========
  2300. */
  2301. void() SuperDamageSound =
  2302. {
  2303. if (self.super_damage_finished > time)
  2304. {
  2305. if (self.super_sound < time)
  2306. {
  2307. self.super_sound = time + 1;
  2308. sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
  2309. }
  2310. }
  2311. return;
  2312. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement