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 // LordHavoc: replaced respawn stardust effect with a custom te_wizspike
13 te_wizspike(self.origin + self.mins_z * '0 0 1' + '0 0 48');
14 //// Savage: Add simple Respawn effect and make sure it gets removed
15 //self.effects = self.effects | EF_STARDUST;
16 //self.think = Item_ClearRespawnEffect;
17 //self.nextthink = time + 0.1;
20 void Item_Touch (void)
23 local float _switchweapon;
25 // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
26 if (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
31 if (other.classname != "player")
35 if (self.solid != SOLID_TRIGGER)
37 if (self.health && other.health >= other.max_health)
39 if (self.owner == other)
41 // Savage: Remove the respawn effect if still present
42 self.effects = self.effects - (self.effects & EF_STARDUST);
44 sound (self, CHAN_BODY, self.noise, 1, ATTN_NORM);
46 // in case the player has autoswitch enabled do the following:
47 // if the player is using their best weapon before items are given, they
48 // probably want to switch to an even better weapon after items are given
49 _switchweapon = (other.autoswitch && (other.switchweapon == w_getbestweapon(other)) || cvar("g_minstagib"));
51 if (cvar("g_minstagib"))
55 // play some cool sounds ;)
56 centermsg_freefor(other, CENTERMSG_MINSTAGIB);
57 centermsg_freefor(other, CENTERMSG_MINSTAGIB2);
59 stuffcmd(other, "play2 announcer/robotic/lastsecond.ogg\n");
60 else if(other.health < 50)
61 stuffcmd(other, "play2 announcer/robotic/narrowly.ogg\n");
62 // sound not available
63 // else if(self.items == IT_CELLS)
64 // stuffcmd(other, "play2 announce/robotic/ammo.ogg\n");
66 if (self.items & IT_NEX)
67 W_GiveWeapon (other, IT_NEX, "Nex");
69 other.ammo_cells = min (other.ammo_cells + cvar("g_minstagib_ammo_drop"), 999);
76 // sound not available
77 // stuffcmd(other, "play2 announce/robotic/extra.ogg\nplay2 announce/robotic/_lives.ogg\n");
78 other.extralives = other.extralives + cvar("g_minstagib_extralives");
79 other.armorvalue = other.extralives;
80 sprint(other, "^3You picked up some extra lives\n");
84 if (self.strength_finished)
86 // sound not available
87 // stuffcmd(other, "play2 announce/robotic/invisible.ogg\n");
88 other.strength_finished = max(other.strength_finished, time) + cvar("g_balance_powerup_strength_time");
92 if (self.invincible_finished)
94 // sound not available
95 // stuffcmd(other, "play2 announce/robotic/speed.ogg\n");
96 other.invincible_finished = max(other.invincible_finished, time) + cvar("g_balance_powerup_strength_time");
101 if (cvar("deathmatch") == 2 && self.flags & FL_WEAPON && other.items & self.items && self.classname != "droppedweapon")
104 if (self.ammo_shells)
105 other.ammo_shells = min (other.ammo_shells + self.ammo_shells, 999);
107 other.ammo_nails = min (other.ammo_nails + self.ammo_nails, 999);
108 if (self.ammo_rockets)
109 other.ammo_rockets = min (other.ammo_rockets + self.ammo_rockets, 999);
111 other.ammo_cells = min (other.ammo_cells + self.ammo_cells, 999);
113 if (self.items & IT_UZI) W_GiveWeapon (other, IT_UZI, self.netname);
114 if (self.items & IT_SHOTGUN) W_GiveWeapon (other, IT_SHOTGUN, self.netname);
115 if (self.items & IT_GRENADE_LAUNCHER) W_GiveWeapon (other, IT_GRENADE_LAUNCHER, self.netname);
116 if (self.items & IT_ELECTRO) W_GiveWeapon (other, IT_ELECTRO, self.netname);
117 if (self.items & IT_NEX) W_GiveWeapon (other, IT_NEX, self.netname);
118 if (self.items & IT_HAGAR) W_GiveWeapon (other, IT_HAGAR, self.netname);
119 if (self.items & IT_ROCKET_LAUNCHER) W_GiveWeapon (other, IT_ROCKET_LAUNCHER, self.netname);
120 if (self.items & IT_CRYLINK) W_GiveWeapon (other, IT_CRYLINK, self.netname);
122 if (self.strength_finished)
123 other.strength_finished = max(other.strength_finished, time) + cvar("g_balance_powerup_strength_time");
124 if (self.invincible_finished)
125 other.invincible_finished = max(other.invincible_finished, time) + cvar("g_balance_powerup_invincible_time");
126 //if (self.speed_finished)
127 // other.speed_finished = max(other.speed_finished, time) + cvar("g_balance_powerup_speed_time");
128 //if (self.slowmo_finished)
129 // other.slowmo_finished = max(other.slowmo_finished, time) + (cvar("g_balance_powerup_slowmo_time") * cvar("g_balance_powerup_slowmo_speed"));
133 other.health = other.health + self.max_health;
134 other.pauserothealth_finished = max(other.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));
136 if (self.health && other.health < other.max_health)
137 other.health = min(other.health + self.health, other.max_health);
140 other.armorvalue = other.armorvalue + self.armorvalue;
141 other.pauserotarmor_finished = max(other.pauserotarmor_finished, time + cvar("g_balance_pause_armor_rot"));
145 sound (other, CHAN_AUTO, self.item_pickupsound, 1, ATTN_NORM);
151 self.switchweapon = w_getbestweapon(self);
152 if (self.switchweapon != self.weapon)
153 self.cnt = self.weapon;
157 if (self.classname == "droppedweapon")
159 else if(self.flags & FL_WEAPON && cvar("deathmatch") == 2)
163 self.solid = SOLID_NOT;
164 self.model = string_null;
165 self.nextthink = time + self.respawntime;
166 self.think = Item_Respawn;
167 setorigin (self, self.origin);
171 // Savage: used for item garbage-collection
172 // TODO: perhaps nice special effect?
173 void RemoveItem(void) = {
177 // pickup evaluation functions
178 // these functions decide how desirable an item is to the bots
180 float(entity player, entity item) generic_pickupevalfunc = {return item.bot_pickupbasevalue;};
182 float(entity player, entity item) weapon_pickupevalfunc =
184 // if we already have the weapon, rate it 1/5th normal value
185 if ((player.items & item.items) == item.items)
186 return item.bot_pickupbasevalue * 0.2;
187 return item.bot_pickupbasevalue;
190 float(entity player, entity item) commodity_pickupevalfunc =
194 // TODO: figure out if the player even has the weapon this ammo is for?
195 // may not affect strategy much though...
196 // find out how much ammo the player has, in terms of this ammo pickup
197 // (how many of these ammo pickups it would take to total the player's
199 if (item.ammo_shells)
200 c = c + player.ammo_shells / item.ammo_shells;
202 c = c + player.ammo_nails / item.ammo_nails;
203 if (item.ammo_rockets)
204 c = c + player.ammo_rockets / item.ammo_rockets;
206 c = c + player.ammo_cells / item.ammo_cells;
208 c = c + player.armorvalue / item.armorvalue;
210 c = c + player.health / item.health / 10;
211 // the more ammo the player has, the less desirable this pickup becomes
214 if (cvar("deathmatch") == 2) // weapon stay is on, so weapons the player already has are of no interest
215 if (item.flags & FL_WEAPON)
216 if (self.items & item.items)
217 if (item.classname != "droppedweapon")
220 return item.bot_pickupbasevalue * c;
224 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, string itemname, float itemid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
229 if (self.classname != "droppedweapon" && !self.noalign)
235 if (itemid == IT_SHELLS)
237 else if (itemid == IT_ROCKETS)
239 else if (itemid == IT_NAILS)
241 else if (itemid == IT_25HP)
243 else if (itemid == IT_ARMOR)
246 org = find_floor(org) + z_offset;
247 setorigin(self, org);
250 if (self.classname != "droppedweapon")
251 waypoint_spawnforitem(self);
253 if (!(cvar("g_pickup_items") && !cvar("g_nixnex")) && !cvar("g_minstagib") &&
254 itemid != IT_STRENGTH && itemid != IT_INVINCIBLE && itemid != IT_HEALTH)
260 if (cvar("g_minstagib"))
262 // don't remove dropped items and powerups
263 if (self.classname != "droppedweapon" &&
264 self.classname != "minstagib")
271 if(cvar("g_lms") && (self.classname != "droppedweapon"))
277 if(cvar("g_instagib") || cvar("g_rocketarena"))
283 if (self.classname == "droppedweapon")
285 // don't drop if in a NODROP zone (such as lava)
286 traceline(self.origin, self.origin, MOVE_NORMAL, self);
287 if (trace_dpstartcontents & DPCONTENTS_NODROP)
294 if(itemid & (IT_STRENGTH | IT_INVINCIBLE | IT_HEALTH | IT_ARMOR | IT_KEY1 | IT_KEY2 |
295 IT_ROCKET_LAUNCHER | IT_HAGAR | IT_NEX | IT_CRYLINK | IT_ELECTRO |
296 IT_GRENADE_LAUNCHER | IT_UZI | IT_SHOTGUN | IT_LASER) && self.classname != "droppedweapon")
298 self.target = "###item###"; // for finding the nearest item using find()
300 self.bot_pickup = TRUE;
301 self.bot_pickupevalfunc = pickupevalfunc;
302 self.bot_pickupbasevalue = pickupbasevalue;
303 self.mdl = itemmodel;
304 //self.noise = pickupsound;
305 self.item_pickupsound = pickupsound;
306 // let mappers override respawntime
307 if (!self.respawntime)
308 self.respawntime = defaultrespawntime;
309 self.netname = itemname;
311 self.flags = FL_ITEM | itemflags;
312 setmodel (self, self.mdl);
313 if (itemflags & FL_WEAPON)
315 setorigin (self, self.origin + '0 0 23');
316 setsize (self, '-12 -12 -12', '12 12 12');
318 // neutral team color for pickup weapons
319 self.colormap = 160 * 1024 + 160;
323 setorigin (self, self.origin + '0 0 25');
324 // setsize (self, '-8 -8 -5', '8 8 8');
326 self.movetype = MOVETYPE_TOSS;
327 self.solid = SOLID_TRIGGER;
328 self.touch = Item_Touch;
330 // Savage: remove thrown items after a certain period of time ("garbage collection")
331 if (self.classname == "droppedweapon")
333 self.think = RemoveItem;
334 self.nextthink = time + 60;
338 self.movetype = MOVETYPE_NONE;
339 setorigin(self, org);
342 if (cvar("g_fullbrightitems"))
343 self.effects = self.effects | EF_FULLBRIGHT;
346 /* replace items in minstagib
347 * IT_STRENGTH = invisibility
348 * IT_NAILS = extra lives
349 * IT_INVINCIBLE = speed
351 void minstagib_items (float itemid)
353 // we don't want to replace dropped weapons ;)
354 if (self.classname == "droppedweapon")
356 self.ammo_cells = 25;
357 StartItem ("models/weapons/g_nex.md3",
358 "weapons/weaponpickup.ogg", 15,
359 "Nex Gun", IT_NEX, FL_WEAPON, generic_pickupevalfunc, 1000);
364 self.classname = "minstagib";
366 // replace rocket launchers and nex guns with ammo cells
367 if (itemid == IT_CELLS)
370 StartItem ("models/items/a_cells.md3",
371 "misc/itempickup.ogg", 45,
372 "Nex Ammo", IT_CELLS, 0, generic_pickupevalfunc, 100);
379 itemid = IT_STRENGTH;
383 itemid = IT_INVINCIBLE;
385 // replace with invis
386 if (itemid == IT_STRENGTH)
388 self.effects = EF_ADDITIVE;
389 self.strength_finished = 30;
390 StartItem ("models/items/g_strength.md3",
391 "misc/powerup.ogg", 120,
392 "Invisibility", IT_STRENGTH, FL_POWERUP, generic_pickupevalfunc, 1000);
394 // replace with extra lives
395 if (itemid == IT_NAILS)
398 StartItem ("models/items/g_h100.md3",
399 "misc/megahealth.ogg", 120,
400 "Extralife", IT_NAILS, FL_POWERUP, generic_pickupevalfunc, 1000);
404 if (itemid == IT_INVINCIBLE)
406 self.effects = EF_ADDITIVE;
407 self.invincible_finished = 30;
408 StartItem ("models/items/g_invincible.md3",
409 "misc/powerup_shield.ogg", 120,
410 "Speed", IT_INVINCIBLE, FL_POWERUP, generic_pickupevalfunc, 1000);
415 void weapon_uzi (void) {
416 self.ammo_nails = 120;
417 StartItem ("models/weapons/g_uzi.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_UZI), IT_UZI, FL_WEAPON, weapon_pickupevalfunc, 1000);
420 void weapon_shotgun (void) {
421 self.ammo_shells = 15;
422 StartItem ("models/weapons/g_shotgun.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_SHOTGUN), IT_SHOTGUN, FL_WEAPON, weapon_pickupevalfunc, 1000);
425 void weapon_grenadelauncher (void) {
426 self.ammo_rockets = 15;
427 StartItem ("models/weapons/g_gl.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_GRENADE_LAUNCHER), IT_GRENADE_LAUNCHER, FL_WEAPON, weapon_pickupevalfunc, 1000);
430 void weapon_electro (void) {
431 self.ammo_cells = 25;
432 StartItem ("models/weapons/g_electro.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_ELECTRO), IT_ELECTRO, FL_WEAPON, weapon_pickupevalfunc, 1000);
435 void weapon_crylink (void) {
436 self.ammo_cells = 25;
437 StartItem ("models/weapons/g_crylink.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_CRYLINK), IT_CRYLINK, FL_WEAPON, weapon_pickupevalfunc, 1000);
440 void weapon_nex (void) {
441 if (cvar("g_minstagib")) {
442 minstagib_items(IT_CELLS);
444 self.ammo_cells = 25;
445 StartItem ("models/weapons/g_nex.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_NEX), IT_NEX, FL_WEAPON, weapon_pickupevalfunc, 1000);
449 void weapon_hagar (void) {
450 self.ammo_rockets = 15;
451 StartItem ("models/weapons/g_hagar.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_HAGAR), IT_HAGAR, FL_WEAPON, weapon_pickupevalfunc, 1000);
454 void weapon_rocketlauncher (void) {
455 if (cvar("g_minstagib")) {
456 minstagib_items(IT_CELLS);
458 self.ammo_rockets = 15;
459 StartItem ("models/weapons/g_rl.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_ROCKET_LAUNCHER), IT_ROCKET_LAUNCHER, FL_WEAPON, weapon_pickupevalfunc, 1000);
463 void item_rockets (void) {
464 self.ammo_rockets = 15;
465 StartItem ("models/items/a_rockets.md3", "misc/itempickup.ogg", 15, "rockets", IT_ROCKETS, 0, commodity_pickupevalfunc, 100);
468 void item_bullets (void) {
469 self.ammo_nails = 120;
470 StartItem ("models/items/a_bullets.mdl", "misc/itempickup.ogg", 15, "bullets", IT_NAILS, 0, commodity_pickupevalfunc, 100);
473 void item_cells (void) {
474 self.ammo_cells = 25;
475 StartItem ("models/items/a_cells.md3", "misc/itempickup.ogg", 15, "cells", IT_CELLS, 0, commodity_pickupevalfunc, 100);
478 void item_shells (void) {
479 self.ammo_shells = 15;
480 StartItem ("models/items/a_shells.md3", "misc/itempickup.ogg", 15, "shells", IT_SHELLS, 0, commodity_pickupevalfunc, 100);
483 void item_armor1 (void) {
485 StartItem ("models/items/g_a1.md3", "misc/armor1.wav", 15, "Armor Shard", IT_ARMOR_SHARD, 0, commodity_pickupevalfunc, 100);
488 void item_armor25 (void) {
489 self.armorvalue = 100;
490 StartItem ("models/items/g_a25.md3", "misc/armor25.wav", 30, "Armor", IT_ARMOR, 0, commodity_pickupevalfunc, 2000);
493 void item_health1 (void) {
495 StartItem ("models/items/g_h1.md3", "misc/minihealth.ogg", 15, "5 Health", IT_5HP, 0, commodity_pickupevalfunc, 100);
498 void item_health25 (void) {
499 self.max_health = 25;
500 StartItem ("models/items/g_h25.md3", "misc/mediumhealth.ogg", 15, "25 Health", IT_25HP, 0, commodity_pickupevalfunc, 500);
503 void item_health100 (void) {
504 if(!cvar("g_powerup_superhealth"))
507 if(cvar("g_arena") && !cvar("g_arena_powerups"))
510 if(cvar("g_minstagib")) {
511 minstagib_items(IT_NAILS);
513 self.max_health = 100;
514 StartItem ("models/items/g_h100.md3", "misc/megahealth.ogg", 30, "100 Health", IT_HEALTH, 0, commodity_pickupevalfunc, 2000);
518 void item_strength (void) {
519 if(!cvar("g_powerup_strength"))
522 if(cvar("g_arena") && !cvar("g_arena_powerups"))
525 if(cvar("g_minstagib")) {
526 minstagib_items(IT_STRENGTH);
528 self.strength_finished = 30;
529 self.effects = EF_ADDITIVE;StartItem ("models/items/g_strength.md3", "misc/powerup.ogg", 120, "Strength Powerup", IT_STRENGTH, FL_POWERUP, generic_pickupevalfunc, 10000);
533 void item_invincible (void) {
534 if(!cvar("g_powerup_shield"))
537 if(cvar("g_arena") && !cvar("g_arena_powerups"))
540 if(cvar("g_minstagib")) {
541 minstagib_items(IT_INVINCIBLE);
543 self.invincible_finished = 30;
544 self.effects = EF_ADDITIVE;
545 StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.ogg", 120, "Invulnerability", IT_INVINCIBLE, FL_POWERUP, generic_pickupevalfunc, 10000);
548 //void item_speed (void) {self.speed_finished = 30;StartItem ("models/items/g_speed.md3", "misc/powerup.wav", 120, "Speed Powerup", IT_SPEED, FL_POWERUP, generic_pickupevalfunc, 10000);}
549 //void item_slowmo (void) {self.slowmo_finished = 30;StartItem ("models/items/g_slowmo.md3", "misc/powerup.wav", 120, "Slow Motion", IT_SLOWMO, FL_POWERUP, generic_pickupevalfunc, 10000);}
552 void item_quad (void) {self.classname = "item_strength";item_strength();}
554 void misc_models (void)
556 precache_model (self.model);
557 setmodel (self, self.model);
558 setsize (self, self.mins, self.maxs);