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 if (other.classname != "player")
27 if (self.solid != SOLID_TRIGGER)
29 if (self.health && other.health >= other.max_health)
31 if (self.owner == other)
33 // Savage: Remove the respawn effect if still present
34 self.effects = self.effects - (self.effects & EF_STARDUST);
36 sound (self, CHAN_BODY, self.noise, 1, ATTN_NORM);
38 // in case the player has autoswitch enabled do the following:
39 // if the player is using their best weapon before items are given, they
40 // probably want to switch to an even better weapon after items are given
41 _switchweapon = (other.autoswitch && (other.switchweapon == w_getbestweapon(other)));
43 if (cvar("g_minstagib"))
47 // play some cool sounds ;)
48 centerprint(other, "\n");
50 stuffcmd(other, "play2 announcer/robotic/lastsecond.ogg\n");
51 else if(other.health < 50)
52 stuffcmd(other, "play2 announcer/robotic/narrowly.ogg\n");
53 // sound not available
54 // else if(self.items == IT_CELLS)
55 // stuffcmd(other, "play2 announce/robotic/ammo.ogg\n");
57 if (self.items & IT_NEX)
58 W_GiveWeapon (other, IT_NEX, "Nex");
60 other.ammo_cells = min (other.ammo_cells + cvar("g_minstagib_ammo_drop"), 999);
67 // sound not available
68 // stuffcmd(other, "play2 announce/robotic/extra.ogg\nplay2 announce/robotic/_lives.ogg\n");
69 other.extralives = other.extralives + cvar("g_minstagib_extralives");
70 other.armorvalue = other.extralives;
71 sprint(other, "^3You picked up some extra lives\n");
75 if (self.strength_finished)
77 // sound not available
78 // stuffcmd(other, "play2 announce/robotic/invisible.ogg\n");
79 other.strength_finished = max(other.strength_finished, time) + cvar("g_balance_powerup_strength_time");
83 if (self.invincible_finished)
85 // sound not available
86 // stuffcmd(other, "play2 announce/robotic/speed.ogg\n");
87 other.invincible_finished = max(other.invincible_finished, time) + cvar("g_balance_powerup_strength_time");
93 other.ammo_shells = min (other.ammo_shells + self.ammo_shells, 999);
95 other.ammo_nails = min (other.ammo_nails + self.ammo_nails, 999);
96 if (self.ammo_rockets)
97 other.ammo_rockets = min (other.ammo_rockets + self.ammo_rockets, 999);
99 other.ammo_cells = min (other.ammo_cells + self.ammo_cells, 999);
101 if (self.items & IT_UZI) W_GiveWeapon (other, IT_UZI, "Machine gun");
102 if (self.items & IT_SHOTGUN) W_GiveWeapon (other, IT_SHOTGUN, "Shotgun");
103 if (self.items & IT_GRENADE_LAUNCHER) W_GiveWeapon (other, IT_GRENADE_LAUNCHER, "Mortar");
104 if (self.items & IT_ELECTRO) W_GiveWeapon (other, IT_ELECTRO, "Electro");
105 if (self.items & IT_NEX) W_GiveWeapon (other, IT_NEX, "Nex");
106 if (self.items & IT_HAGAR) W_GiveWeapon (other, IT_HAGAR, "Hagar");
107 if (self.items & IT_ROCKET_LAUNCHER) W_GiveWeapon (other, IT_ROCKET_LAUNCHER, "Rocket Launcher");
108 if (self.items & IT_CRYLINK) W_GiveWeapon (other, IT_CRYLINK, "Crylink");
110 if (self.strength_finished)
111 other.strength_finished = max(other.strength_finished, time) + cvar("g_balance_powerup_strength_time");
112 if (self.invincible_finished)
113 other.invincible_finished = max(other.invincible_finished, time) + cvar("g_balance_powerup_invincible_time");
114 //if (self.speed_finished)
115 // other.speed_finished = max(other.speed_finished, time) + cvar("g_balance_powerup_speed_time");
116 //if (self.slowmo_finished)
117 // other.slowmo_finished = max(other.slowmo_finished, time) + (cvar("g_balance_powerup_slowmo_time") * cvar("g_balance_powerup_slowmo_speed"));
121 other.health = other.health + self.max_health;
122 other.pauserothealth_finished = max(other.pauserothealth_finished, time + 5);
124 if (self.health && other.health < other.max_health)
125 other.health = min(other.health + self.health, other.max_health);
128 other.armorvalue = other.armorvalue + self.armorvalue;
129 other.pauserotarmor_finished = max(other.pauserotarmor_finished, time + 5);
133 sound (other, CHAN_AUTO, self.item_pickupsound, 1, ATTN_NORM);
139 self.switchweapon = w_getbestweapon(self);
140 if (self.switchweapon != self.weapon)
141 self.cnt = self.weapon;
145 weapon_action(self.weapon, WR_UPDATECOUNTS);
149 if (self.classname == "droppedweapon")
153 self.solid = SOLID_NOT;
154 self.model = string_null;
155 self.nextthink = time + self.respawntime;
156 self.think = Item_Respawn;
157 setorigin (self, self.origin);
161 // Savage: used for item garbage-collection
162 // TODO: perhaps nice special effect?
163 void RemoveItem(void) = {
168 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, string itemname, float itemid, float itemflags)
170 if (!cvar("g_pickup_items") && !cvar("g_minstagib") &&
171 itemid != IT_STRENGTH && itemid != IT_INVINCIBLE && itemname != "100 Health")
177 if (cvar("g_minstagib"))
179 // don't remove dropped items and powerups
180 if (self.classname != "droppedweapon" &&
181 self.classname != "minstagib")
188 if(cvar("g_lms") && (self.classname != "droppedweapon"))
194 if(cvar("g_instagib") || cvar("g_rocketarena"))
200 self.mdl = itemmodel;
201 //self.noise = pickupsound;
202 self.item_pickupsound = pickupsound;
203 // let mappers override respawntime
204 if (!self.respawntime)
205 self.respawntime = defaultrespawntime;
206 self.netname = itemname;
208 self.flags = FL_ITEM | itemflags;
209 setmodel (self, self.mdl);
210 if (itemflags & FL_WEAPON)
212 setorigin (self, self.origin + '0 0 22');
213 setsize (self, '-12 -12 -12', '12 12 12');
215 // neutral team color for pickup weapons
216 self.colormap = 160 * 1024 + 160;
220 setorigin (self, self.origin + '0 0 15');
221 // setsize (self, '-8 -8 -5', '8 8 8');
223 self.movetype = MOVETYPE_TOSS;
224 self.solid = SOLID_TRIGGER;
225 self.touch = Item_Touch;
227 // Savage: remove thrown items after a certain period of time ("garbage collection")
228 if (self.classname == "droppedweapon")
230 self.think = RemoveItem;
231 self.nextthink = time + 60;
234 if (cvar("g_fullbrightitems"))
235 self.effects = self.effects | EF_FULLBRIGHT;
239 /* replace items in minstagib
240 * IT_STRENGTH = invisibility
241 * IT_NAILS = extra lives
242 * IT_INVINCIBLE = speed
244 void minstagib_items (float itemid)
246 // we don't want to replace dropped weapons ;)
247 if (self.classname == "droppedweapon")
249 self.ammo_cells = 25;
250 StartItem ("models/weapons/g_nex.md3",
251 "weapons/weaponpickup.ogg", 15,
252 "Nex Gun", IT_NEX, FL_WEAPON);
257 self.classname = "minstagib";
259 // replace rocket launchers and nex guns with ammo cells
260 if (itemid == IT_CELLS)
263 StartItem ("models/items/a_cells.md3",
264 "misc/itempickup.ogg", 45,
265 "Nex Ammo", IT_CELLS, 0);
272 itemid = IT_STRENGTH;
276 itemid = IT_INVINCIBLE;
278 // replace with invis
279 if (itemid == IT_STRENGTH)
281 self.effects = EF_ADDITIVE;
282 self.strength_finished = 30;
283 StartItem ("models/items/g_strength.md3",
284 "misc/powerup.ogg", 120,
285 "Invisibility", IT_STRENGTH, FL_POWERUP);
287 // replace with extra lives
288 if (itemid == IT_NAILS)
291 StartItem ("models/items/g_h100.md3",
292 "misc/megahealth.ogg", 120,
293 "Extralife", IT_NAILS, FL_POWERUP);
297 if (itemid == IT_INVINCIBLE)
299 self.effects = EF_ADDITIVE;
300 self.invincible_finished = 30;
301 StartItem ("models/items/g_invincible.md3",
302 "misc/powerup_shield.ogg", 120,
303 "Speed", IT_INVINCIBLE, FL_POWERUP);
308 void weapon_uzi (void) {
309 self.ammo_nails = 120;
310 StartItem ("models/weapons/g_uzi.md3", "weapons/weaponpickup.ogg", 15, "Uzi", IT_UZI, FL_WEAPON);
313 void weapon_shotgun (void) {
314 self.ammo_shells = 15;
315 StartItem ("models/weapons/g_shotgun.md3", "weapons/weaponpickup.ogg", 15, "Shotgun", IT_SHOTGUN, FL_WEAPON);
318 void weapon_grenadelauncher (void) {
319 self.ammo_rockets = 15;
320 StartItem ("models/weapons/g_gl.md3", "weapons/weaponpickup.ogg", 15, "Grenade Launcher", IT_GRENADE_LAUNCHER, FL_WEAPON);
323 void weapon_electro (void) {
324 self.ammo_cells = 25;
325 StartItem ("models/weapons/g_electro.md3", "weapons/weaponpickup.ogg", 15, "Electro", IT_ELECTRO, FL_WEAPON);
328 void weapon_crylink (void) {
329 self.ammo_cells = 25;
330 StartItem ("models/weapons/g_crylink.md3", "weapons/weaponpickup.ogg", 15, "Crylink", IT_CRYLINK, FL_WEAPON);
333 void weapon_nex (void) {
334 if (cvar("g_minstagib")) {
335 minstagib_items(IT_CELLS);
337 self.ammo_cells = 25;
338 StartItem ("models/weapons/g_nex.md3", "weapons/weaponpickup.ogg", 15, "Nex Gun", IT_NEX, FL_WEAPON);
342 void weapon_hagar (void) {
343 self.ammo_rockets = 15;
344 StartItem ("models/weapons/g_hagar.md3", "weapons/weaponpickup.ogg", 15, "Hagar", IT_HAGAR, FL_WEAPON);
347 void weapon_rocketlauncher (void) {
348 if (cvar("g_minstagib")) {
349 minstagib_items(IT_CELLS);
351 self.ammo_rockets = 15;
352 StartItem ("models/weapons/g_rl.md3", "weapons/weaponpickup.ogg", 15, "Rocket Launcher", IT_ROCKET_LAUNCHER, FL_WEAPON);
356 void item_rockets (void) {
357 self.ammo_rockets = 15;
358 StartItem ("models/items/a_rockets.md3", "misc/itempickup.ogg", 15, "rockets", IT_ROCKETS, 0);
361 void item_bullets (void) {
362 self.ammo_nails = 120;
363 StartItem ("models/items/a_bullets.mdl", "misc/itempickup.ogg", 15, "bullets", IT_NAILS, 0);
366 void item_cells (void) {
367 self.ammo_cells = 25;
368 StartItem ("models/items/a_cells.md3", "misc/itempickup.ogg", 15, "cells", IT_CELLS, 0);
371 void item_shells (void) {
372 self.ammo_shells = 15;
373 StartItem ("models/items/a_shells.md3", "misc/itempickup.ogg", 15, "shells", IT_SHELLS, 0);
376 void item_armor1 (void) {
378 StartItem ("models/items/g_a1.md3", "misc/armor1.wav", 15, "Armor Shard", 0, 0);
381 void item_armor25 (void) {
382 self.armorvalue = 100;
383 StartItem ("models/items/g_a25.md3", "misc/armor25.wav", 30, "Armor", 0, 0);
386 void item_health1 (void) {
388 StartItem ("models/items/g_h1.md3", "misc/minihealth.ogg", 15, "5 Health", 0, 0);
391 void item_health25 (void) {
392 self.max_health = 25;
393 StartItem ("models/items/g_h25.md3", "misc/mediumhealth.ogg", 15, "25 Health", 0, 0);
396 void item_health100 (void) {
397 if(!cvar("g_powerup_superhealth"))
400 if(cvar("g_minstagib")) {
401 minstagib_items(IT_NAILS);
403 self.max_health = 100;
404 StartItem ("models/items/g_h100.md3", "misc/megahealth.ogg", 30, "100 Health", 0, 0);
408 void item_strength (void) {
409 if(!cvar("g_powerup_strength"))
412 if(cvar("g_minstagib")) {
413 minstagib_items(IT_STRENGTH);
415 self.strength_finished = 30;
416 self.effects = EF_ADDITIVE;StartItem ("models/items/g_strength.md3", "misc/powerup.ogg", 120, "Strength Powerup", IT_STRENGTH, FL_POWERUP);
420 void item_invincible (void) {
421 if(!cvar("g_powerup_shield"))
424 if(cvar("g_minstagib")) {
425 minstagib_items(IT_INVINCIBLE);
427 self.invincible_finished = 30;
428 self.effects = EF_ADDITIVE;
429 StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.ogg", 120, "Invulnerability", IT_INVINCIBLE, FL_POWERUP);
432 //void item_speed (void) {self.speed_finished = 30;StartItem ("models/items/g_speed.md3", "misc/powerup.wav", 120, "Speed Powerup", IT_SPEED, FL_POWERUP);}
433 //void item_slowmo (void) {self.slowmo_finished = 30;StartItem ("models/items/g_slowmo.md3", "misc/powerup.wav", 120, "Slow Motion", IT_SLOWMO, FL_POWERUP);}
435 void misc_models (void)
437 precache_model (self.model);
438 setmodel (self, self.model);
439 setsize (self, self.mins, self.maxs);