#include <u.h>#include <libc.h>#include <stdio.h>#include "../dat.h"#include "../fns.h" qboolean Pickup_Weapon (edict_t *ent, edict_t *other);void Use_Weapon (edict_t *ent, gitem_t *inv);void Drop_Weapon (edict_t *ent, gitem_t *inv); void Weapon_Blaster (edict_t *ent);void Weapon_Shotgun (edict_t *ent);void Weapon_SuperShotgun (edict_t *ent);void Weapon_Machinegun (edict_t *ent);void Weapon_Chaingun (edict_t *ent);void Weapon_HyperBlaster (edict_t *ent);void Weapon_RocketLauncher (edict_t *ent);void Weapon_Grenade (edict_t *ent);void Weapon_GrenadeLauncher (edict_t *ent);void Weapon_Railgun (edict_t *ent);void Weapon_BFG (edict_t *ent); gitem_armor_t jacketarmor_info = { 25, 50, .30, .00, ARMOR_JACKET};gitem_armor_t combatarmor_info = { 50, 100, .60, .30, ARMOR_COMBAT};gitem_armor_t bodyarmor_info = {100, 200, .80, .60, ARMOR_BODY}; static int jacket_armor_index;static int combat_armor_index;static int body_armor_index;static int power_screen_index;static int power_shield_index; #define HEALTH_IGNORE_MAX 1#define HEALTH_TIMED 2 void Use_Quad (edict_t *ent, gitem_t *item);static int quad_drop_timeout_hack; //====================================================================== /*===============GetItemByIndex===============*/gitem_t *GetItemByIndex (int index){ if (index == 0 || index >= game.num_items) return NULL; return &itemlist[index];} /*===============FindItemByClassname ===============*/gitem_t *FindItemByClassname (char *classname){ int i; gitem_t *it; it = itemlist; for (i=0 ; i<game.num_items ; i++, it++) { if (!it->classname) continue; if (!cistrcmp(it->classname, classname)) return it; } return NULL;} /*===============FindItem ===============*/gitem_t *FindItem (char *pickup_name){ int i; gitem_t *it; it = itemlist; for (i=0 ; i<game.num_items ; i++, it++) { if (!it->pickup_name) continue; if (!cistrcmp(it->pickup_name, pickup_name)) return it; } return NULL;} //====================================================================== void DoRespawn (edict_t *ent){ if (ent->team) { edict_t *master; int count; int choice; master = ent->teammaster; for (count = 0, ent = master; ent; ent = ent->chain, count++) ; choice = rand() % count; for (count = 0, ent = master; count < choice; ent = ent->chain, count++) ; } ent->svflags &= ~SVF_NOCLIENT; ent->solid = SOLID_TRIGGER; gi.linkentity (ent); // send an effect ent->s.event = EV_ITEM_RESPAWN;} void SetRespawn (edict_t *ent, float delay){ ent->flags |= FL_RESPAWN; ent->svflags |= SVF_NOCLIENT; ent->solid = SOLID_NOT; ent->nextthink = level.time + delay; ent->think = DoRespawn; gi.linkentity (ent);} //====================================================================== qboolean Pickup_Powerup (edict_t *ent, edict_t *other){ int quantity; quantity = other->client->pers.inventory[ITEM_INDEX(ent->item)]; if ((skill->value == 1 && quantity >= 2) || (skill->value >= 2 && quantity >= 1)) return false; if ((coop->value) && (ent->item->flags & IT_STAY_COOP) && (quantity > 0)) return false; other->client->pers.inventory[ITEM_INDEX(ent->item)]++; if (deathmatch->value) { if (!(ent->spawnflags & DROPPED_ITEM) ) SetRespawn (ent, ent->item->quantity); if (((int)dmflags->value & DF_INSTANT_ITEMS) || ((ent->item->use == Use_Quad) && (ent->spawnflags & DROPPED_PLAYER_ITEM))) { if ((ent->item->use == Use_Quad) && (ent->spawnflags & DROPPED_PLAYER_ITEM)) quad_drop_timeout_hack = (ent->nextthink - level.time) / FRAMETIME; ent->item->use (other, ent->item); } } return true;} void Drop_General (edict_t *ent, gitem_t *item){ Drop_Item (ent, item); ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent);} //====================================================================== qboolean Pickup_Adrenaline (edict_t *ent, edict_t *other){ if (!deathmatch->value) other->max_health += 1; if (other->health < other->max_health) other->health = other->max_health; if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value)) SetRespawn (ent, ent->item->quantity); return true;} qboolean Pickup_AncientHead (edict_t *ent, edict_t *other){ other->max_health += 2; if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value)) SetRespawn (ent, ent->item->quantity); return true;} qboolean Pickup_Bandolier (edict_t *ent, edict_t *other){ gitem_t *item; int index; if (other->client->pers.max_bullets < 250) other->client->pers.max_bullets = 250; if (other->client->pers.max_shells < 150) other->client->pers.max_shells = 150; if (other->client->pers.max_cells < 250) other->client->pers.max_cells = 250; if (other->client->pers.max_slugs < 75) other->client->pers.max_slugs = 75; item = FindItem("Bullets"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_bullets) other->client->pers.inventory[index] = other->client->pers.max_bullets; } item = FindItem("Shells"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_shells) other->client->pers.inventory[index] = other->client->pers.max_shells; } if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value)) SetRespawn (ent, ent->item->quantity); return true;} qboolean Pickup_Pack (edict_t *ent, edict_t *other){ gitem_t *item; int index; if (other->client->pers.max_bullets < 300) other->client->pers.max_bullets = 300; if (other->client->pers.max_shells < 200) other->client->pers.max_shells = 200; if (other->client->pers.max_rockets < 100) other->client->pers.max_rockets = 100; if (other->client->pers.max_grenades < 100) other->client->pers.max_grenades = 100; if (other->client->pers.max_cells < 300) other->client->pers.max_cells = 300; if (other->client->pers.max_slugs < 100) other->client->pers.max_slugs = 100; item = FindItem("Bullets"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_bullets) other->client->pers.inventory[index] = other->client->pers.max_bullets; } item = FindItem("Shells"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_shells) other->client->pers.inventory[index] = other->client->pers.max_shells; } item = FindItem("Cells"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_cells) other->client->pers.inventory[index] = other->client->pers.max_cells; } item = FindItem("Grenades"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_grenades) other->client->pers.inventory[index] = other->client->pers.max_grenades; } item = FindItem("Rockets"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_rockets) other->client->pers.inventory[index] = other->client->pers.max_rockets; } item = FindItem("Slugs"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_slugs) other->client->pers.inventory[index] = other->client->pers.max_slugs; } if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value)) SetRespawn (ent, ent->item->quantity); return true;} //====================================================================== void Use_Quad (edict_t *ent, gitem_t *item){ int timeout; ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent); if (quad_drop_timeout_hack) { timeout = quad_drop_timeout_hack; quad_drop_timeout_hack = 0; } else { timeout = 300; } if (ent->client->quad_framenum > level.framenum) ent->client->quad_framenum += timeout; else ent->client->quad_framenum = level.framenum + timeout; gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);} //====================================================================== void Use_Breather (edict_t *ent, gitem_t *item){ ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent); if (ent->client->breather_framenum > level.framenum) ent->client->breather_framenum += 300; else ent->client->breather_framenum = level.framenum + 300; // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);} //====================================================================== void Use_Envirosuit (edict_t *ent, gitem_t *item){ ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent); if (ent->client->enviro_framenum > level.framenum) ent->client->enviro_framenum += 300; else ent->client->enviro_framenum = level.framenum + 300; // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);} //====================================================================== void Use_Invulnerability (edict_t *ent, gitem_t *item){ ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent); if (ent->client->invincible_framenum > level.framenum) ent->client->invincible_framenum += 300; else ent->client->invincible_framenum = level.framenum + 300; gi.sound(ent, CHAN_ITEM, gi.soundindex("items/protect.wav"), 1, ATTN_NORM, 0);} //====================================================================== void Use_Silencer (edict_t *ent, gitem_t *item){ ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent); ent->client->silencer_shots += 30; // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);} //====================================================================== qboolean Pickup_Key (edict_t *ent, edict_t *other){ if (coop->value) { if (strcmp(ent->classname, "key_power_cube") == 0) { if (other->client->pers.power_cubes & ((ent->spawnflags & 0x0000ff00)>> 8)) return false; other->client->pers.inventory[ITEM_INDEX(ent->item)]++; other->client->pers.power_cubes |= ((ent->spawnflags & 0x0000ff00) >> 8); } else { if (other->client->pers.inventory[ITEM_INDEX(ent->item)]) return false; other->client->pers.inventory[ITEM_INDEX(ent->item)] = 1; } return true; } other->client->pers.inventory[ITEM_INDEX(ent->item)]++; return true;} //====================================================================== qboolean Add_Ammo (edict_t *ent, gitem_t *item, int count){ int index; int max; if (!ent->client) return false; if (item->tag == AMMO_BULLETS) max = ent->client->pers.max_bullets; else if (item->tag == AMMO_SHELLS) max = ent->client->pers.max_shells; else if (item->tag == AMMO_ROCKETS) max = ent->client->pers.max_rockets; else if (item->tag == AMMO_GRENADES) max = ent->client->pers.max_grenades; else if (item->tag == AMMO_CELLS) max = ent->client->pers.max_cells; else if (item->tag == AMMO_SLUGS) max = ent->client->pers.max_slugs; else return false; index = ITEM_INDEX(item); if (ent->client->pers.inventory[index] == max) return false; ent->client->pers.inventory[index] += count; if (ent->client->pers.inventory[index] > max) ent->client->pers.inventory[index] = max; return true;} qboolean Pickup_Ammo (edict_t *ent, edict_t *other){ int oldcount; int count; qboolean weapon; weapon = (ent->item->flags & IT_WEAPON); if ( (weapon) && ( (int)dmflags->value & DF_INFINITE_AMMO ) ) count = 1000; else if (ent->count) count = ent->count; else count = ent->item->quantity; oldcount = other->client->pers.inventory[ITEM_INDEX(ent->item)]; if (!Add_Ammo (other, ent->item, count)) return false; if (weapon && !oldcount) { if (other->client->pers.weapon != ent->item && ( !deathmatch->value || other->client->pers.weapon == FindItem("blaster") ) ) other->client->newweapon = ent->item; } if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)) && (deathmatch->value)) SetRespawn (ent, 30); return true;} void Drop_Ammo (edict_t *ent, gitem_t *item){ edict_t *dropped;Lines 1–500 of 2201. Load more
#include <u.h> #include <libc.h> #include <stdio.h> #include "../dat.h" #include "../fns.h" qboolean Pickup_Weapon (edict_t *ent, edict_t *other); void Use_Weapon (edict_t *ent, gitem_t *inv); void Drop_Weapon (edict_t *ent, gitem_t *inv); void Weapon_Blaster (edict_t *ent); void Weapon_Shotgun (edict_t *ent); void Weapon_SuperShotgun (edict_t *ent); void Weapon_Machinegun (edict_t *ent); void Weapon_Chaingun (edict_t *ent); void Weapon_HyperBlaster (edict_t *ent); void Weapon_RocketLauncher (edict_t *ent); void Weapon_Grenade (edict_t *ent); void Weapon_GrenadeLauncher (edict_t *ent); void Weapon_Railgun (edict_t *ent); void Weapon_BFG (edict_t *ent); gitem_armor_t jacketarmor_info = { 25, 50, .30, .00, ARMOR_JACKET}; gitem_armor_t combatarmor_info = { 50, 100, .60, .30, ARMOR_COMBAT}; gitem_armor_t bodyarmor_info = {100, 200, .80, .60, ARMOR_BODY}; static int jacket_armor_index; static int combat_armor_index; static int body_armor_index; static int power_screen_index; static int power_shield_index; #define HEALTH_IGNORE_MAX 1 #define HEALTH_TIMED 2 void Use_Quad (edict_t *ent, gitem_t *item); static int quad_drop_timeout_hack; //====================================================================== /* =============== GetItemByIndex =============== */ gitem_t *GetItemByIndex (int index) { if (index == 0 || index >= game.num_items) return NULL; return &itemlist[index]; } /* =============== FindItemByClassname =============== */ gitem_t *FindItemByClassname (char *classname) { int i; gitem_t *it; it = itemlist; for (i=0 ; i<game.num_items ; i++, it++) { if (!it->classname) continue; if (!cistrcmp(it->classname, classname)) return it; } return NULL; } /* =============== FindItem =============== */ gitem_t *FindItem (char *pickup_name) { int i; gitem_t *it; it = itemlist; for (i=0 ; i<game.num_items ; i++, it++) { if (!it->pickup_name) continue; if (!cistrcmp(it->pickup_name, pickup_name)) return it; } return NULL; } //====================================================================== void DoRespawn (edict_t *ent) { if (ent->team) { edict_t *master; int count; int choice; master = ent->teammaster; for (count = 0, ent = master; ent; ent = ent->chain, count++) ; choice = rand() % count; for (count = 0, ent = master; count < choice; ent = ent->chain, count++) ; } ent->svflags &= ~SVF_NOCLIENT; ent->solid = SOLID_TRIGGER; gi.linkentity (ent); // send an effect ent->s.event = EV_ITEM_RESPAWN; } void SetRespawn (edict_t *ent, float delay) { ent->flags |= FL_RESPAWN; ent->svflags |= SVF_NOCLIENT; ent->solid = SOLID_NOT; ent->nextthink = level.time + delay; ent->think = DoRespawn; gi.linkentity (ent); } //====================================================================== qboolean Pickup_Powerup (edict_t *ent, edict_t *other) { int quantity; quantity = other->client->pers.inventory[ITEM_INDEX(ent->item)]; if ((skill->value == 1 && quantity >= 2) || (skill->value >= 2 && quantity >= 1)) return false; if ((coop->value) && (ent->item->flags & IT_STAY_COOP) && (quantity > 0)) return false; other->client->pers.inventory[ITEM_INDEX(ent->item)]++; if (deathmatch->value) { if (!(ent->spawnflags & DROPPED_ITEM) ) SetRespawn (ent, ent->item->quantity); if (((int)dmflags->value & DF_INSTANT_ITEMS) || ((ent->item->use == Use_Quad) && (ent->spawnflags & DROPPED_PLAYER_ITEM))) { if ((ent->item->use == Use_Quad) && (ent->spawnflags & DROPPED_PLAYER_ITEM)) quad_drop_timeout_hack = (ent->nextthink - level.time) / FRAMETIME; ent->item->use (other, ent->item); } } return true; } void Drop_General (edict_t *ent, gitem_t *item) { Drop_Item (ent, item); ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent); } //====================================================================== qboolean Pickup_Adrenaline (edict_t *ent, edict_t *other) { if (!deathmatch->value) other->max_health += 1; if (other->health < other->max_health) other->health = other->max_health; if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value)) SetRespawn (ent, ent->item->quantity); return true; } qboolean Pickup_AncientHead (edict_t *ent, edict_t *other) { other->max_health += 2; if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value)) SetRespawn (ent, ent->item->quantity); return true; } qboolean Pickup_Bandolier (edict_t *ent, edict_t *other) { gitem_t *item; int index; if (other->client->pers.max_bullets < 250) other->client->pers.max_bullets = 250; if (other->client->pers.max_shells < 150) other->client->pers.max_shells = 150; if (other->client->pers.max_cells < 250) other->client->pers.max_cells = 250; if (other->client->pers.max_slugs < 75) other->client->pers.max_slugs = 75; item = FindItem("Bullets"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_bullets) other->client->pers.inventory[index] = other->client->pers.max_bullets; } item = FindItem("Shells"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_shells) other->client->pers.inventory[index] = other->client->pers.max_shells; } if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value)) SetRespawn (ent, ent->item->quantity); return true; } qboolean Pickup_Pack (edict_t *ent, edict_t *other) { gitem_t *item; int index; if (other->client->pers.max_bullets < 300) other->client->pers.max_bullets = 300; if (other->client->pers.max_shells < 200) other->client->pers.max_shells = 200; if (other->client->pers.max_rockets < 100) other->client->pers.max_rockets = 100; if (other->client->pers.max_grenades < 100) other->client->pers.max_grenades = 100; if (other->client->pers.max_cells < 300) other->client->pers.max_cells = 300; if (other->client->pers.max_slugs < 100) other->client->pers.max_slugs = 100; item = FindItem("Bullets"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_bullets) other->client->pers.inventory[index] = other->client->pers.max_bullets; } item = FindItem("Shells"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_shells) other->client->pers.inventory[index] = other->client->pers.max_shells; } item = FindItem("Cells"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_cells) other->client->pers.inventory[index] = other->client->pers.max_cells; } item = FindItem("Grenades"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_grenades) other->client->pers.inventory[index] = other->client->pers.max_grenades; } item = FindItem("Rockets"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_rockets) other->client->pers.inventory[index] = other->client->pers.max_rockets; } item = FindItem("Slugs"); if (item) { index = ITEM_INDEX(item); other->client->pers.inventory[index] += item->quantity; if (other->client->pers.inventory[index] > other->client->pers.max_slugs) other->client->pers.inventory[index] = other->client->pers.max_slugs; } if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value)) SetRespawn (ent, ent->item->quantity); return true; } //====================================================================== void Use_Quad (edict_t *ent, gitem_t *item) { int timeout; ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent); if (quad_drop_timeout_hack) { timeout = quad_drop_timeout_hack; quad_drop_timeout_hack = 0; } else { timeout = 300; } if (ent->client->quad_framenum > level.framenum) ent->client->quad_framenum += timeout; else ent->client->quad_framenum = level.framenum + timeout; gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0); } //====================================================================== void Use_Breather (edict_t *ent, gitem_t *item) { ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent); if (ent->client->breather_framenum > level.framenum) ent->client->breather_framenum += 300; else ent->client->breather_framenum = level.framenum + 300; // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0); } //====================================================================== void Use_Envirosuit (edict_t *ent, gitem_t *item) { ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent); if (ent->client->enviro_framenum > level.framenum) ent->client->enviro_framenum += 300; else ent->client->enviro_framenum = level.framenum + 300; // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0); } //====================================================================== void Use_Invulnerability (edict_t *ent, gitem_t *item) { ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent); if (ent->client->invincible_framenum > level.framenum) ent->client->invincible_framenum += 300; else ent->client->invincible_framenum = level.framenum + 300; gi.sound(ent, CHAN_ITEM, gi.soundindex("items/protect.wav"), 1, ATTN_NORM, 0); } //====================================================================== void Use_Silencer (edict_t *ent, gitem_t *item) { ent->client->pers.inventory[ITEM_INDEX(item)]--; ValidateSelectedItem (ent); ent->client->silencer_shots += 30; // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0); } //====================================================================== qboolean Pickup_Key (edict_t *ent, edict_t *other) { if (coop->value) { if (strcmp(ent->classname, "key_power_cube") == 0) { if (other->client->pers.power_cubes & ((ent->spawnflags & 0x0000ff00)>> 8)) return false; other->client->pers.inventory[ITEM_INDEX(ent->item)]++; other->client->pers.power_cubes |= ((ent->spawnflags & 0x0000ff00) >> 8); } else { if (other->client->pers.inventory[ITEM_INDEX(ent->item)]) return false; other->client->pers.inventory[ITEM_INDEX(ent->item)] = 1; } return true; } other->client->pers.inventory[ITEM_INDEX(ent->item)]++; return true; } //====================================================================== qboolean Add_Ammo (edict_t *ent, gitem_t *item, int count) { int index; int max; if (!ent->client) return false; if (item->tag == AMMO_BULLETS) max = ent->client->pers.max_bullets; else if (item->tag == AMMO_SHELLS) max = ent->client->pers.max_shells; else if (item->tag == AMMO_ROCKETS) max = ent->client->pers.max_rockets; else if (item->tag == AMMO_GRENADES) max = ent->client->pers.max_grenades; else if (item->tag == AMMO_CELLS) max = ent->client->pers.max_cells; else if (item->tag == AMMO_SLUGS) max = ent->client->pers.max_slugs; else return false; index = ITEM_INDEX(item); if (ent->client->pers.inventory[index] == max) return false; ent->client->pers.inventory[index] += count; if (ent->client->pers.inventory[index] > max) ent->client->pers.inventory[index] = max; return true; } qboolean Pickup_Ammo (edict_t *ent, edict_t *other) { int oldcount; int count; qboolean weapon; weapon = (ent->item->flags & IT_WEAPON); if ( (weapon) && ( (int)dmflags->value & DF_INFINITE_AMMO ) ) count = 1000; else if (ent->count) count = ent->count; else count = ent->item->quantity; oldcount = other->client->pers.inventory[ITEM_INDEX(ent->item)]; if (!Add_Ammo (other, ent->item, count)) return false; if (weapon && !oldcount) { if (other->client->pers.weapon != ent->item && ( !deathmatch->value || other->client->pers.weapon == FindItem("blaster") ) ) other->client->newweapon = ent->item; } if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)) && (deathmatch->value)) SetRespawn (ent, 30); return true; } void Drop_Ammo (edict_t *ent, gitem_t *item) { edict_t *dropped;