void ResetItems (void) { int i; edict_t *ent; ent = &g_edicts[1]; for (i=1; i < globals.num_edicts; i++, ent++) { if (!ent->inuse || ent->client || !ent->item) continue; if (ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)) // Remove any dropped items { ent->nextthink = level.time; ent->think = G_FreeEdict; } else if (Q_stricmp(ent->classname, "item_flag_team1") == 0 || Q_stricmp(ent->classname, "item_flag_team2") == 0) { if (!(ent->spawnflags & DROPPED_ITEM)) { ent->flags |= FL_RESPAWN; ent->svflags |= SVF_NOCLIENT; ent->solid = SOLID_NOT; } } else SetRespawn (ent, 0); } CTFCheckRules(); CTFResetFlags(); }
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("Colt .45") ) ) other->client->newweapon = ent->item; } if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)) && (deathmatch->value)) SetRespawn (ent, 30); WeighPlayer(other); return true; }
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); //} } WeighPlayer(other); return true; }
qboolean Pickup_Weapon (edict_t *ent, edict_t *other) { int index; gitem_t *ammo; index = ITEM_INDEX(ent->item); if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) && other->client->pers.inventory[index]) { if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) ) return false; // leave the weapon for others to pickup } other->client->pers.inventory[index]++; //WF if(ent->spawnflags & DROPPED_ITEM) { ammo = FindItem(ent->item->ammo); Add_Ammo(other, ammo, (int)((float)ammo->quantity * dropweapammo->value)); } //WF if (!(ent->spawnflags & DROPPED_ITEM) ) { // give them some ammo with it ammo = FindItem (ent->item->ammo); if ( (int)dmflags->value & DF_INFINITE_AMMO ) Add_Ammo (other, ammo, 1000); else Add_Ammo (other, ammo, ammo->quantity); if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) ) { if (deathmatch->value) { if ((int)(dmflags->value) & DF_WEAPONS_STAY) ent->flags |= FL_RESPAWN; else SetRespawn (ent, 30); } if (coop->value) ent->flags |= FL_RESPAWN; } } //WF other->safety_time = 0; Weapon_PickBest(ent, other); /* if (other->client->pers.weapon != ent->item && (other->client->pers.inventory[index] == 1) && ( !deathmatch->value || other->client->pers.weapon == FindItem("blaster") ) ) other->client->newweapon = ent->item; */ //WF return true; }
qboolean Pickup_Health (edict_t *ent, edict_t *other) { if (!(ent->style & HEALTH_IGNORE_MAX)) if (other->health >= other->max_health) if (other->burnout < level.time) return false; if (other->burnout) { if ((rand() % 100) < ent->count) other->burnout = 0; else other->burnout -= ent->count; } other->health += ent->count; // if(heal_wounds->value) // { // other->wound_location=0; // other->die_time=0; // } if (ent->count == 2) ent->item->pickup_sound = "items/s_health.wav"; else if (ent->count == 10) ent->item->pickup_sound = "items/n_health.wav"; else if (ent->count == 25) ent->item->pickup_sound = "items/l_health.wav"; else // (ent->count == 100) ent->item->pickup_sound = "items/m_health.wav"; if (!(ent->style & HEALTH_IGNORE_MAX)) { if (other->health > other->max_health) other->health = other->max_health; } if (ent->style & HEALTH_TIMED) { ent->think = MegaHealth_think; ent->nextthink = level.time + 5; ent->owner = other; ent->flags |= FL_RESPAWN; ent->svflags |= SVF_NOCLIENT; ent->solid = SOLID_NOT; } else { if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value)) SetRespawn (ent, 30); } return true; }
/* * Touch_Item */ void Touch_Item( edict_t *ent, edict_t *other, cplane_t *plane, int surfFlags ) { bool taken; const gsitem_t *item = ent->item; if( !other->r.client || G_ISGHOSTING( other ) ) return; if( !( other->r.client->ps.pmove.stats[PM_STAT_FEATURES] & PMFEAT_ITEMPICK ) ) return; if( !item || !( item->flags & ITFLAG_PICKABLE ) ) return; // not a grabbable item if( !G_Gametype_CanPickUpItem( item ) ) return; taken = G_PickupItem( other, item, ent->spawnflags, ent->count, ent->invpak ); if( !( ent->spawnflags & ITEM_TARGETS_USED ) ) { G_UseTargets( ent, other ); ent->spawnflags |= ITEM_TARGETS_USED; } if( !taken ) return; if( ent->spawnflags & ITEM_TIMED ) ent->r.owner = other; // flash the screen G_AddPlayerStateEvent( other->r.client, PSEV_PICKUP, ( item->flags & IT_WEAPON ? item->tag : 0 ) ); G_AwardPlayerPickup( other, ent ); // for messages other->r.client->teamstate.last_pickup = ent; // show icon and name on status bar other->r.client->ps.stats[STAT_PICKUP_ITEM] = item->tag; other->r.client->resp.pickup_msg_time = level.time + 3000; if( ent->attenuation ) Touch_ItemSound( other, item ); if( !( ent->spawnflags & DROPPED_ITEM ) && G_Gametype_CanRespawnItem( item ) ) { if( (item->type & IT_WEAPON ) && GS_RaceGametype() ) return; // weapons stay in race SetRespawn( ent, G_Gametype_RespawnTimeForItem( item ) ); return; } G_FreeEdict( ent ); }
qboolean Pickup_Weapon(edict_t *ent, edict_t *other) { int index; gitem_t *ammo; if (!ent || !other) { return false; } index = ITEM_INDEX(ent->item); if ((((int) (dmflags->value) & DF_WEAPONS_STAY) || coop->value) && other->client->pers.inventory[index]) { if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM))) { return false; /* leave the weapon for others to pickup */ } } other->client->pers.inventory[index]++; if (!(ent->spawnflags & DROPPED_ITEM)) { /* give them some ammo with it */ ammo = FindItem(ent->item->ammo); if ((int) dmflags->value & DF_INFINITE_AMMO) { Add_Ammo(other, ammo, 1000); } else { Add_Ammo(other, ammo, ammo->quantity); } if (!(ent->spawnflags & DROPPED_PLAYER_ITEM)) { if (deathmatch->value) { if ((int) (dmflags->value) & DF_WEAPONS_STAY) { ent->flags |= FL_RESPAWN; } else { SetRespawn(ent, 30); } } if (coop->value) { ent->flags |= FL_RESPAWN; } } } if ((other->client->pers.weapon != ent->item) && (other->client->pers.inventory[index] == 1) && (!deathmatch->value || (other->client->pers.weapon == FindItem("blaster")))) { other->client->newweapon = ent->item; } return true; }
void MegaHealth_think (edict_t *self) { if (self->owner->health > self->owner->max_health) { self->nextthink = level.time + 1; self->owner->health -= 1; return; } if (!(self->spawnflags & DROPPED_ITEM) && (deathmatch->value)) SetRespawn (self, 20); else G_FreeEdict (self); }
qboolean Pickup_Adrenaline (edict_t *ent, edict_t *other) { other->burnout = 0; 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); WeighPlayer(other); return true; }
qboolean Pickup_Weapon (edict_t *ent, edict_t *other) { int index; gitem_t *ammo; index = ITEM_INDEX(ent->item); if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) && other->client->pers.inventory[index]) { if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) ) return false; // leave the weapon for others to pickup } other->client->pers.inventory[index]++; if (!(ent->spawnflags & DROPPED_ITEM) && (ent->item->ammo != NULL)) { // give them some ammo with it ammo = FindItem (ent->item->ammo); if ( (int)dmflags->value & DF_INFINITE_AMMO ) Add_Ammo (other, ammo, 1000); else Add_Ammo (other, ammo, ammo->quantity); if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) ) { if (deathmatch->value) { if ((int)(dmflags->value) & DF_WEAPONS_STAY) ent->flags |= FL_RESPAWN; else SetRespawn (ent, 30); } if (coop->value) ent->flags |= FL_RESPAWN; } } if (other->client->pers.weapon != ent->item && !(ent->item->hideFlags & HIDE_FROM_SELECTION) && (other->client->pers.inventory[index] == 1) && ( !deathmatch->value || other->client->pers.weapon == FindItem("blaster") ) ) other->client->newweapon = ent->item; return true; }
/* * Touch_Item */ void Touch_Item( edict_t *ent, edict_t *other, cplane_t *plane, int surfFlags ) { qboolean taken; if( !other->r.client || G_ISGHOSTING( other ) ) return; if( !( other->r.client->ps.pmove.stats[PM_STAT_FEATURES] & PMFEAT_ITEMPICK ) ) return; if( !ent->item || !( ent->item->flags & ITFLAG_PICKABLE ) ) return; // not a grabbable item if( !G_Gametype_CanPickUpItem( ent->item ) ) return; taken = G_PickupItem( ent, other ); if( !( ent->spawnflags & ITEM_TARGETS_USED ) ) { G_UseTargets( ent, other ); ent->spawnflags |= ITEM_TARGETS_USED; } if( !taken ) return; // flash the screen G_AddPlayerStateEvent( other->r.client, PSEV_PICKUP, ( ent->item->flags & IT_WEAPON ? ent->item->tag : 0 ) ); G_AwardPlayerPickup( other, ent ); // for messages other->r.client->teamstate.last_pickup = ent; // show icon and name on status bar other->r.client->ps.stats[STAT_PICKUP_ITEM] = ent->item->tag; other->r.client->resp.pickup_msg_time = level.time + 3000; if( ent->attenuation ) Touch_ItemSound( other, ent->item ); if( !( ent->spawnflags & ( DROPPED_ITEM | DROPPED_PLAYER_ITEM ) ) && G_Gametype_CanRespawnItem( ent->item ) ) SetRespawn( ent, G_Gametype_RespawnTimeForItem( ent->item ) ); else G_FreeEdict( ent ); }
qboolean Pickup_PowerArmor (edict_t *ent, edict_t *other) { int quantity; quantity = other->client->pers.inventory[ITEM_INDEX(ent->item)]; other->client->pers.inventory[ITEM_INDEX(ent->item)]++; if (deathmatch->value) { if (!(ent->spawnflags & DROPPED_ITEM) ) SetRespawn (ent, ent->item->quantity); // auto-use for DM only if we didn't already have one if (!quantity) ent->item->use (other, ent->item); } return true; }
qboolean Pickup_Weapon (edict_t *ent, edict_t *other) { int index; const gitem_t *ammo; index = ITEM_INDEX(ent->item); if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY)) && other->client->inventory[index]) { if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) ) return false; // leave the weapon for others to pickup } other->client->inventory[index]++; if (!(ent->spawnflags & DROPPED_ITEM) ) { // give them some ammo with it ammo = GETITEM (ent->item->ammoindex); if ( (int)dmflags->value & DF_INFINITE_AMMO ) Add_Ammo (other, ammo, 1000); else Add_Ammo (other, ammo, ammo->quantity); if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) ) { if ((int)(dmflags->value) & DF_WEAPONS_STAY) ent->flags |= FL_RESPAWN; else SetRespawn (ent, 30); } } if (other->client->weapon != ent->item && (other->client->inventory[index] == 1) && other->client->weapon == GETITEM (ITEM_WEAPON_BLASTER)) other->client->newweapon = ent->item; return true; }
void MegaHealth_think( edict_t *self ) { self->nextThink = level.time + 1; if( self->r.owner ) { if( self->r.owner->r.inuse && self->r.owner->s.team != TEAM_SPECTATOR && HEALTH_TO_INT( self->r.owner->health ) > self->r.owner->max_health ) { return; } // disable the link to the owner self->r.owner = NULL; } // player is back under max health so we can set respawn time for next MH if( !( self->spawnflags & ( DROPPED_ITEM | DROPPED_PLAYER_ITEM ) ) && G_Gametype_CanRespawnItem( self->item ) ) SetRespawn( self, G_Gametype_RespawnTimeForItem( self->item ) ); else G_FreeEdict( self ); }
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_30cal < 250) other->client->pers.max_30cal = 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); WeighPlayer(other); return true; }
void G_Items_RespawnByType( unsigned int typeMask, int item_tag, float delay ) { edict_t *ent; int msecs; for( ent = game.edicts + gs.maxclients + BODY_QUEUE_SIZE; ENTNUM( ent ) < game.maxentities; ent++ ) { if( !ent->r.inuse || !ent->item ) continue; if( typeMask && !( ent->item->type & typeMask ) ) continue; if( ent->spawnflags & ( DROPPED_ITEM|DROPPED_PLAYER_ITEM ) ) { G_FreeEdict( ent ); continue; } if( !G_Gametype_CanRespawnItem( ent->item ) ) continue; // if a tag is specified, ignore others of the same type if( item_tag > 0 && ( ent->item->tag != item_tag ) ) continue; msecs = (int)( delay * 1000 ); if( msecs >= 0 ) clamp_low( msecs, 1 ); // megahealth is different if( ( ent->style & HEALTH_TIMED ) && ent->r.owner ) ent->r.owner = NULL; SetRespawn( ent, msecs ); } }
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 < 2) other->client->pers.max_grenades = 2; //bcass start - TNT if (other->client->pers.max_tnt < 1) other->client->pers.max_tnt = 1; //bcass end if (other->client->pers.max_30cal < 300) other->client->pers.max_30cal = 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_30cal) other->client->pers.inventory[index] = other->client->pers.max_30cal; } 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("Mk 2 Grenade"); 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("M24 Grenade"); 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; }
qboolean Pickup_Weapon (edict_t *ent, edict_t *other) { int index; gitem_t *ammo; gclient_t *client; // Make sure ent exists! if (!G_EntExists(other)) return false; if (other->client) client = other->client; else return false; index = ITEM_INDEX(ent->item); if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) && other->client->pers.inventory[index]) { if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) ) return false; // leave the weapon for others to pickup } if ((ent->spawnflags & DROPPED_PLAYER_ITEM) && (ent->item->flags & IT_WEAPON)) { if (!(dmflag & DF_WEAPONS_STAY)) client->pers.inventory[index]++; } else client->pers.inventory[index]++; if (!(ent->spawnflags & DROPPED_ITEM) ) { // give them some ammo with it ammo = FindItem (ent->item->ammo); if (! ( dmflag & DF_INFINITE_AMMO ) ) { Add_Ammo (other, ammo, ammo->quantity); } else { Add_Ammo (other, ammo, 1000); } if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) ) { if (deathmatch->value) { if ((int)(dmflags->value) & DF_WEAPONS_STAY) ent->flags |= FL_RESPAWN; else SetRespawn (ent, spawn_time->value);//RAV } if (coop->value) ent->flags |= FL_RESPAWN; } } if (client->pers.weapon != ent->item && (other->client->pers.inventory[index] == 1) && ( !deathmatch->value || client->pers.weapon == FindItem("blaster") ) ) client->newweapon = ent->item; return true; }