gentity_t *Team_ResetFlag( int team ) { const char *c; gentity_t *ent, *rent = NULL; switch ( team ) { case TEAM_RED: c = "team_CTF_redflag"; break; case TEAM_BLUE: c = "team_CTF_blueflag"; break; default: return NULL; } ent = NULL; while ( ( ent = G_Find( ent, FOFS( classname ), c ) ) != NULL ) { if ( ent->flags & FL_DROPPED_ITEM ) { G_FreeEntity( ent ); } else { rent = ent; RespawnItem( ent ); } } return rent; }
gentity_t *Team_ResetFlag( int team ) { char *c; gentity_t *ent, *rent = NULL; switch (team) { case TEAM_RED: c = "team_CTF_redflag"; break; case TEAM_BLUE: c = "team_CTF_blueflag"; break; case TEAM_FREE: c = "team_CTF_neutralflag"; break; default: return NULL; } ent = NULL; while ((ent = G_Find (ent, FOFS(classname), c)) != NULL) { if (ent->flags & FL_DROPPED_ITEM) G_FreeEntity(ent); else { rent = ent; RespawnItem(ent); } } Team_SetFlagStatus( team, FLAG_ATBASE ); return rent; }
/* ================ Use_Item Respawn the item ================ */ void Use_Item( gentity_t *ent, gentity_t *other, gentity_t *activator ) { if ( (ent->svFlags&SVF_PLAYER_USABLE) && other && !other->s.number ) {//used directly by the player, pick me up if ( (ent->spawnflags&ITMSF_USEPICKUP) ) {//player has to be touching me and hit use to pick it up, so don't allow this if ( !G_BoundsOverlap( ent->absmin, ent->absmax, other->absmin, other->absmax ) ) {//not touching return; } } GEntity_TouchFunc( ent, other, NULL ); } else {//use me if ( ent->spawnflags & 32 ) // invisible { // If it was invisible, first use makes it visible.... ent->s.eFlags &= ~EF_NODRAW; ent->contents = CONTENTS_TRIGGER|CONTENTS_ITEM; ent->spawnflags &= ~32; return; } G_ActivateBehavior( ent, BSET_USE ); RespawnItem( ent ); } }
/** * @brief Team_ResetFlag * @param[in] ent */ void Team_ResetFlag(gentity_t *ent) { if (!ent) { G_Printf("Warning: NULL passed to Team_ResetFlag\n"); return; } if (ent->flags & FL_DROPPED_ITEM) { Team_ResetFlag(&g_entities[ent->s.otherEntityNum]); G_FreeEntity(ent); } else { ent->s.density++; // do we need to respawn? if (ent->s.density == 1) { RespawnItem(ent); #ifdef FEATURE_OMNIBOT Bot_Util_SendTrigger(ent, NULL, va("Flag returned %s!", _GetEntityName(ent)), "returned"); #endif } } }
void Team_ResetFlag(gentity_t *ent) { if (ent->flags & FL_DROPPED_ITEM) { Team_ResetFlag(&g_entities[ent->s.otherEntityNum]); G_FreeEntity(ent); } else { ent->s.density++; // do we need to respawn? if (ent->s.density == 1) { RespawnItem(ent); } } }
/* =============== G_ResetPickups =============== */ void G_ResetEntities ( void ) { // Run through all the entities in the level and reset those which // need to be reset for (int i = 0; i < level.num_entities; i ++ ) { gentity_t* ent; ent = &g_entities[i]; // Skip entities not in use if ( !ent->inuse ) { continue; } // If this is a player then unlink it so then clients // spawned in dont telefrag if ( ent->s.eType == ET_PLAYER || ent->s.eType == ET_BODY ) { trap_UnlinkEntity ( ent ); } // If this is a missile else if ( ent->s.eType == ET_MISSILE ) { G_FreeEntity ( ent ); } // If the dropped flag is set then free it else if ( ent->flags & FL_DROPPED_ITEM ) { G_FreeEntity ( ent ); } // If this item is waiting to be respawned, then respawn it else if ( ent->think == RespawnItem ) { RespawnItem ( ent ); } else if ( ent->s.eType == ET_DAMAGEAREA ) { G_FreeEntity ( ent ); } } }
/* ================ Use_Item Respawn the item ================ */ void Use_Item( gentity_t *ent, gentity_t *other, gentity_t *activator ) { if ( (ent->svFlags&SVF_PLAYER_USABLE) && other && !other->s.number ) {//used directly by the player, pick me up GEntity_TouchFunc( ent, other, NULL ); } else {//use me if ( ent->spawnflags & 32 ) // invisible { // If it was invisible, first use makes it visible.... ent->s.eFlags &= ~EF_NODRAW; ent->contents = CONTENTS_TRIGGER|CONTENTS_ITEM; ent->spawnflags &= ~32; return; } G_ActivateBehavior( ent, BSET_USE ); RespawnItem( ent ); } }
/* ================ Use_Item Respawn the item ================ */ void Use_Item( gentity_t *ent, gentity_t *other, gentity_t *activator ) { RespawnItem( ent ); }
/* ============== Added by Elder RQ3_ResetWeapon Respawn a unique weapon Similar to CTF Flag reset A little quirky - maybe someone can fine-tune this! Bugs: The weapon may not return to its original location if there is more than one of the type. It just finds the closest empty spot and respawns it. ============== */ void RQ3_ResetWeapon(int weapon) { char *c = ""; gentity_t *ent; //, *rent = NULL; int numRespawned = 0; int numRemoved = 0; // JBravo: no resetting/respawning weapons and items in TP // JBravo: Bah! this is a nono! /* if (g_gametype.integer == GT_TEAMPLAY) return; */ switch (weapon) { case WP_M3: c = "weapon_m3"; break; case WP_M4: c = "weapon_m4"; break; case WP_MP5: c = "weapon_mp5"; break; case WP_SSG3000: c = "weapon_ssg3000"; break; case WP_HANDCANNON: c = "weapon_handcannon"; break; default: //Elder: shouldn't be here G_Printf("RQ3_ResetWeapon: Received bad weapon: %d\n", weapon); break; } ent = NULL; //Elder: here's the solution and another problem to RQ3 weapon respawns while ((ent = G_Find(ent, FOFS(classname), c)) != NULL) { //if it's a dropped copy, free it //if (ent->flags & FL_DROPPED_ITEM) { //Elder: only release if it's past the //default respawn time and is flagged if (numRemoved < 1 && (ent->flags & FL_DROPPED_ITEM) == FL_DROPPED_ITEM && (ent->flags & FL_RQ3_JUNKITEM) == FL_RQ3_JUNKITEM) { //Elder: removed because of possible door collision removal //level.time - ent->timestamp >= RQ3_RESPAWNTIME_DEFAULT) { G_FreeEntity(ent); numRemoved++; } else { //rent = ent; //Elder: only respawn if it's a "taken" item //It won't necessarily respawn the gun in its original spot if there's //more than one, but it will put it in an empty location... good enough? if ((ent->r.svFlags & SVF_NOCLIENT) == SVF_NOCLIENT && (ent->s.eFlags & EF_NODRAW) == EF_NODRAW && ent->r.contents == 0 && numRespawned < 1) { RespawnItem(ent); numRespawned++; } } } //return rent; }
virtual void execute( GameEntity *other, GameEntity *activator ) { RespawnItem( self_ ); }
virtual void execute() { RespawnItem(self_); }