/* * 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 ); }
/* * 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 ); }
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 ); }
/* * item_timer_think */ void item_timer_think( edict_t *ent ) { edict_t *owner; owner = ent->r.owner; if( !owner || !owner->r.inuse || owner->s.type != ET_ITEM ) { G_FreeEdict( ent ); return; } if( owner->think != DoRespawn ) { // megahealth is special if( owner->style & HEALTH_TIMED && owner->r.owner ) { /* if( owner->r.owner->r.inuse && owner->r.owner->s.team != TEAM_SPECTATOR && HEALTH_TO_INT( owner->r.owner->health ) > owner->r.owner->max_health ) ent->s.frame = HEALTH_TO_INT( owner->r.owner->health ) - owner->r.owner->max_health; else*/ ent->s.frame = 0; ent->s.frame += G_Gametype_RespawnTimeForItem( owner->item ) / 1000; } else { ent->s.frame = 0; } } else { ent->s.frame = owner->nextThink - level.time; if( ent->s.frame < 0 ) ent->s.frame = 0; else ent->s.frame = (int)((float)ent->s.frame / 1000.0 + 0.5); } ent->nextThink = level.time + 1000; }