1 void Item_ClearRespawnEffect (void) {
2 self.effects = self.effects - (self.effects & EF_STARDUST);
5 void Item_Respawn (void)
7 self.model = self.mdl; // restore original model
8 self.solid = SOLID_TRIGGER; // allow it to be touched again
9 sound (self, CHAN_VOICE, "misc/itemrespawn.ogg", 1, ATTN_NORM); // play respawn sound
10 setorigin (self, self.origin);
12 // Savage: Add simple Respawn effect and make sure it gets removed
13 self.effects = self.effects | EF_STARDUST;
14 self.think = Item_ClearRespawnEffect;
15 self.nextthink = time + 0.1;
18 void Item_Touch (void)
21 local float _switchweapon;
23 // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
24 if (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
29 if (other.classname != "player")
33 if (self.solid != SOLID_TRIGGER)
35 if (self.health && other.health >= other.max_health)
37 if (self.owner == other)
39 // Savage: Remove the respawn effect if still present
40 self.effects = self.effects - (self.effects & EF_STARDUST);
42 sound (self, CHAN_BODY, self.noise, 1, ATTN_NORM);
44 // in case the player has autoswitch enabled do the following:
45 // if the player is using their best weapon before items are given, they
46 // probably want to switch to an even better weapon after items are given
47 _switchweapon = (other.autoswitch && (other.switchweapon == w_getbestweapon(other)) || cvar("g_minstagib"));
49 if (cvar("g_minstagib"))
53 // play some cool sounds ;)
54 centerprint(other, "\n");
56 stuffcmd(other, "play2 announcer/robotic/lastsecond.ogg\n");
57 else if(other.health < 50)
58 stuffcmd(other, "play2 announcer/robotic/narrowly.ogg\n");
59 // sound not available
60 // else if(self.items == IT_CELLS)
61 // stuffcmd(other, "play2 announce/robotic/ammo.ogg\n");
63 if (self.items & IT_NEX)
64 W_GiveWeapon (other, IT_NEX, "Nex");
66 other.ammo_cells = min (other.ammo_cells + cvar("g_minstagib_ammo_drop"), 999);
73 // sound not available
74 // stuffcmd(other, "play2 announce/robotic/extra.ogg\nplay2 announce/robotic/_lives.ogg\n");
75 other.extralives = other.extralives + cvar("g_minstagib_extralives");
76 other.armorvalue = other.extralives;
77 sprint(other, "^3You picked up some extra lives\n");
81 if (self.strength_finished)
83 // sound not available
84 // stuffcmd(other, "play2 announce/robotic/invisible.ogg\n");
85 other.strength_finished = max(other.strength_finished, time) + cvar("g_balance_powerup_strength_time");
89 if (self.invincible_finished)
91 // sound not available
92 // stuffcmd(other, "play2 announce/robotic/speed.ogg\n");
93 other.invincible_finished = max(other.invincible_finished, time) + cvar("g_balance_powerup_strength_time");
98 if (cvar("deathmatch") == 2 && self.flags & FL_WEAPON && other.items & self.items && self.classname != "droppedweapon")
101 if (self.ammo_shells)
102 other.ammo_shells = min (other.ammo_shells + self.ammo_shells, 999);
104 other.ammo_nails = min (other.ammo_nails + self.ammo_nails, 999);
105 if (self.ammo_rockets)
106 other.ammo_rockets = min (other.ammo_rockets + self.ammo_rockets, 999);
108 other.ammo_cells = min (other.ammo_cells + self.ammo_cells, 999);
110 if (self.items & IT_UZI) W_GiveWeapon (other, IT_UZI, self.netname);
111 if (self.items & IT_SHOTGUN) W_GiveWeapon (other, IT_SHOTGUN, self.netname);
112 if (self.items & IT_GRENADE_LAUNCHER) W_GiveWeapon (other, IT_GRENADE_LAUNCHER, self.netname);
113 if (self.items & IT_ELECTRO) W_GiveWeapon (other, IT_ELECTRO, self.netname);
114 if (self.items & IT_NEX) W_GiveWeapon (other, IT_NEX, self.netname);
115 if (self.items & IT_HAGAR) W_GiveWeapon (other, IT_HAGAR, self.netname);
116 if (self.items & IT_ROCKET_LAUNCHER) W_GiveWeapon (other, IT_ROCKET_LAUNCHER, self.netname);
117 if (self.items & IT_CRYLINK) W_GiveWeapon (other, IT_CRYLINK, self.netname);
119 if (self.strength_finished)
120 other.strength_finished = max(other.strength_finished, time) + cvar("g_balance_powerup_strength_time");
121 if (self.invincible_finished)
122 other.invincible_finished = max(other.invincible_finished, time) + cvar("g_balance_powerup_invincible_time");
123 //if (self.speed_finished)
124 // other.speed_finished = max(other.speed_finished, time) + cvar("g_balance_powerup_speed_time");
125 //if (self.slowmo_finished)
126 // other.slowmo_finished = max(other.slowmo_finished, time) + (cvar("g_balance_powerup_slowmo_time") * cvar("g_balance_powerup_slowmo_speed"));
130 other.health = other.health + self.max_health;
131 other.pauserothealth_finished = max(other.pauserothealth_finished, time + 5);
133 if (self.health && other.health < other.max_health)
134 other.health = min(other.health + self.health, other.max_health);
137 other.armorvalue = other.armorvalue + self.armorvalue;
138 other.pauserotarmor_finished = max(other.pauserotarmor_finished, time + 5);
142 sound (other, CHAN_AUTO, self.item_pickupsound, 1, ATTN_NORM);
148 self.switchweapon = w_getbestweapon(self);
149 if (self.switchweapon != self.weapon)
150 self.cnt = self.weapon;
154 weapon_action(self.weapon, WR_UPDATECOUNTS);
158 if (self.classname == "droppedweapon")
162 self.solid = SOLID_NOT;
163 self.model = string_null;
164 self.nextthink = time + self.respawntime;
165 self.think = Item_Respawn;
166 setorigin (self, self.origin);
170 // Savage: used for item garbage-collection
171 // TODO: perhaps nice special effect?
172 void RemoveItem(void) = {
177 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, string itemname, float itemid, float itemflags)
179 if (!(cvar("g_pickup_items") && !cvar("g_nixnex")) && !cvar("g_minstagib") &&
180 itemid != IT_STRENGTH && itemid != IT_INVINCIBLE && itemname != "100 Health")
186 if (!self.flags & FL_WEAPON || !other.items & self.items || self.classname == "droppedweapon")
189 if (cvar("g_minstagib"))
191 // don't remove dropped items and powerups
192 if (self.classname != "droppedweapon" &&
193 self.classname != "minstagib")
200 if(cvar("g_lms") && (self.classname != "droppedweapon"))
206 if(cvar("g_instagib") || cvar("g_rocketarena"))
212 if (self.classname == "droppedweapon")
214 // don't drop if in a NODROP zone (such as lava)
215 traceline(self.origin, self.origin, MOVE_NORMAL, self);
216 if (trace_dpstartcontents & DPCONTENTS_NODROP)
223 self.mdl = itemmodel;
224 //self.noise = pickupsound;
225 self.item_pickupsound = pickupsound;
226 // let mappers override respawntime
227 if (!self.respawntime)
228 self.respawntime = defaultrespawntime;
229 self.netname = itemname;
231 self.flags = FL_ITEM | itemflags;
232 setmodel (self, self.mdl);
233 if (itemflags & FL_WEAPON)
235 setorigin (self, self.origin + '0 0 23');
236 setsize (self, '-12 -12 -12', '12 12 12');
238 // neutral team color for pickup weapons
239 self.colormap = 160 * 1024 + 160;
243 setorigin (self, self.origin + '0 0 25');
244 // setsize (self, '-8 -8 -5', '8 8 8');
246 self.movetype = MOVETYPE_TOSS;
247 self.solid = SOLID_TRIGGER;
248 self.touch = Item_Touch;
250 // Savage: remove thrown items after a certain period of time ("garbage collection")
251 if (self.classname == "droppedweapon")
253 self.think = RemoveItem;
254 self.nextthink = time + 60;
262 if (itemid == IT_SHELLS)
263 z_offset = '0 0 1' * 4;
264 else if (itemid == IT_ROCKETS)
265 z_offset = '0 0 1' * 4;
266 else if (itemid == IT_NAILS)
268 else if (self.max_health == 25)
269 z_offset = '0 0 1' * 5;
270 else if (self.armorvalue == 100)
271 z_offset = '0 0 1' * 3;
273 self.movetype = MOVETYPE_NONE;
274 traceline(self.origin, self.origin - '0 0 1' * 1024, TRUE, self);
275 setorigin(self, trace_endpos + z_offset);
278 if (cvar("g_fullbrightitems"))
279 self.effects = self.effects | EF_FULLBRIGHT;
283 /* replace items in minstagib
284 * IT_STRENGTH = invisibility
285 * IT_NAILS = extra lives
286 * IT_INVINCIBLE = speed
288 void minstagib_items (float itemid)
290 // we don't want to replace dropped weapons ;)
291 if (self.classname == "droppedweapon")
293 self.ammo_cells = 25;
294 StartItem ("models/weapons/g_nex.md3",
295 "weapons/weaponpickup.ogg", 15,
296 "Nex Gun", IT_NEX, FL_WEAPON);
301 self.classname = "minstagib";
303 // replace rocket launchers and nex guns with ammo cells
304 if (itemid == IT_CELLS)
307 StartItem ("models/items/a_cells.md3",
308 "misc/itempickup.ogg", 45,
309 "Nex Ammo", IT_CELLS, 0);
316 itemid = IT_STRENGTH;
320 itemid = IT_INVINCIBLE;
322 // replace with invis
323 if (itemid == IT_STRENGTH)
325 self.effects = EF_ADDITIVE;
326 self.strength_finished = 30;
327 StartItem ("models/items/g_strength.md3",
328 "misc/powerup.ogg", 120,
329 "Invisibility", IT_STRENGTH, FL_POWERUP);
331 // replace with extra lives
332 if (itemid == IT_NAILS)
335 StartItem ("models/items/g_h100.md3",
336 "misc/megahealth.ogg", 120,
337 "Extralife", IT_NAILS, FL_POWERUP);
341 if (itemid == IT_INVINCIBLE)
343 self.effects = EF_ADDITIVE;
344 self.invincible_finished = 30;
345 StartItem ("models/items/g_invincible.md3",
346 "misc/powerup_shield.ogg", 120,
347 "Speed", IT_INVINCIBLE, FL_POWERUP);
352 void weapon_uzi (void) {
353 self.ammo_nails = 120;
354 StartItem ("models/weapons/g_uzi.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_UZI), IT_UZI, FL_WEAPON);
357 void weapon_shotgun (void) {
358 self.ammo_shells = 15;
359 StartItem ("models/weapons/g_shotgun.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_SHOTGUN), IT_SHOTGUN, FL_WEAPON);
362 void weapon_grenadelauncher (void) {
363 self.ammo_rockets = 15;
364 StartItem ("models/weapons/g_gl.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_GRENADE_LAUNCHER), IT_GRENADE_LAUNCHER, FL_WEAPON);
367 void weapon_electro (void) {
368 self.ammo_cells = 25;
369 StartItem ("models/weapons/g_electro.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_ELECTRO), IT_ELECTRO, FL_WEAPON);
372 void weapon_crylink (void) {
373 self.ammo_cells = 25;
374 StartItem ("models/weapons/g_crylink.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_CRYLINK), IT_CRYLINK, FL_WEAPON);
377 void weapon_nex (void) {
378 if (cvar("g_minstagib")) {
379 minstagib_items(IT_CELLS);
381 self.ammo_cells = 25;
382 StartItem ("models/weapons/g_nex.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_NEX), IT_NEX, FL_WEAPON);
386 void weapon_hagar (void) {
387 self.ammo_rockets = 15;
388 StartItem ("models/weapons/g_hagar.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_HAGAR), IT_HAGAR, FL_WEAPON);
391 void weapon_rocketlauncher (void) {
392 if (cvar("g_minstagib")) {
393 minstagib_items(IT_CELLS);
395 self.ammo_rockets = 15;
396 StartItem ("models/weapons/g_rl.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_ROCKET_LAUNCHER), IT_ROCKET_LAUNCHER, FL_WEAPON);
400 void item_rockets (void) {
401 self.ammo_rockets = 15;
402 StartItem ("models/items/a_rockets.md3", "misc/itempickup.ogg", 15, "rockets", IT_ROCKETS, 0);
405 void item_bullets (void) {
406 self.ammo_nails = 120;
407 StartItem ("models/items/a_bullets.mdl", "misc/itempickup.ogg", 15, "bullets", IT_NAILS, 0);
410 void item_cells (void) {
411 self.ammo_cells = 25;
412 StartItem ("models/items/a_cells.md3", "misc/itempickup.ogg", 15, "cells", IT_CELLS, 0);
415 void item_shells (void) {
416 self.ammo_shells = 15;
417 StartItem ("models/items/a_shells.md3", "misc/itempickup.ogg", 15, "shells", IT_SHELLS, 0);
420 void item_armor1 (void) {
422 StartItem ("models/items/g_a1.md3", "misc/armor1.wav", 15, "Armor Shard", 0, 0);
425 void item_armor25 (void) {
426 self.armorvalue = 100;
427 StartItem ("models/items/g_a25.md3", "misc/armor25.wav", 30, "Armor", 0, 0);
430 void item_health1 (void) {
432 StartItem ("models/items/g_h1.md3", "misc/minihealth.ogg", 15, "5 Health", 0, 0);
435 void item_health25 (void) {
436 self.max_health = 25;
437 StartItem ("models/items/g_h25.md3", "misc/mediumhealth.ogg", 15, "25 Health", 0, 0);
440 void item_health100 (void) {
441 if(!cvar("g_powerup_superhealth"))
444 if(cvar("g_minstagib")) {
445 minstagib_items(IT_NAILS);
447 self.max_health = 100;
448 StartItem ("models/items/g_h100.md3", "misc/megahealth.ogg", 30, "100 Health", 0, 0);
452 void item_strength (void) {
453 if(!cvar("g_powerup_strength"))
456 if(cvar("g_minstagib")) {
457 minstagib_items(IT_STRENGTH);
459 self.strength_finished = 30;
460 self.effects = EF_ADDITIVE;StartItem ("models/items/g_strength.md3", "misc/powerup.ogg", 120, "Strength Powerup", IT_STRENGTH, FL_POWERUP);
464 void item_invincible (void) {
465 if(!cvar("g_powerup_shield"))
468 if(cvar("g_minstagib")) {
469 minstagib_items(IT_INVINCIBLE);
471 self.invincible_finished = 30;
472 self.effects = EF_ADDITIVE;
473 StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.ogg", 120, "Invulnerability", IT_INVINCIBLE, FL_POWERUP);
476 //void item_speed (void) {self.speed_finished = 30;StartItem ("models/items/g_speed.md3", "misc/powerup.wav", 120, "Speed Powerup", IT_SPEED, FL_POWERUP);}
477 //void item_slowmo (void) {self.slowmo_finished = 30;StartItem ("models/items/g_slowmo.md3", "misc/powerup.wav", 120, "Slow Motion", IT_SLOWMO, FL_POWERUP);}
479 void misc_models (void)
481 precache_model (self.model);
482 setmodel (self, self.model);
483 setsize (self, self.mins, self.maxs);