Advertisement
Guest User

Untitled

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