Advertisement
Guest User

Untitled

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