void Calculate_Warzone_Flag_Spawns ( void ) { #ifdef __UNUSED__ if (!flag_spawnpoints_done) {// Have we initialized spawnpoints yet? int z = 0; for (z=0;z<number_of_flags;z++) { gentity_t *flagent = flag_list[z].flagentity; PreCalculate_Flag_Spawnpoints( flagent->count, flagent->s.angles, flagent->s.origin ); flagent->alt_fire = qtrue; } flag_spawnpoints_done = qtrue; } #endif //__UNUSED__ }
void Supremacy_Flag_Think( gentity_t *ent ) { vec3_t mins; vec3_t maxs; int touch[MAX_GENTITIES]; int num = 0; int i = 0; int radius = ent->s.otherEntityNum2; if (!ent->alt_fire) {// Have we initialized spawnpoints yet? //if (level.numConnectedClients > 0) { ent->alt_fire = qtrue; PreCalculate_Flag_Spawnpoints( ent->count, ent->s.angles, ent->s.origin ); } } if (ent->nextthink > level.time) return; mins[0] = 0-radius; mins[1] = 0-radius; mins[2] = 0-(radius*0.5); maxs[0] = radius; maxs[1] = radius; maxs[2] = radius*0.5; VectorAdd( mins, ent->s.origin, mins ); VectorAdd( maxs, ent->s.origin, maxs ); // Run the think... Look for captures... num = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES ); for ( i=0 ; i<num ; i++ ) { gentity_t *hit = &g_entities[touch[i]]; if (!hit) continue; if (!hit->client) continue; if (!hit->health || hit->health <= 0) continue; if (hit->classname == "NPC_Vehicle") continue; if (hit->s.eType == ET_NPC) hit->s.teamowner = hit->client->playerTeam; if (ent->s.teamowner == TEAM_RED) {// Red flag... if ((hit->s.eType == ET_PLAYER || hit->s.eType == ET_NPC) && hit->s.teamowner == TEAM_RED) {// Blue player consolidating a blue flag for spawns... //G_Printf("Consolidating flag!\n"); ent->s.time2++; hit->client->ps.stats[STAT_CAPTURE_ENTITYNUM] = ent->s.number; if (ent->s.time2 >= 100) {// Finished consolidating.. Set new team to blue and initialize... ent->s.teamowner = TEAM_RED; ent->s.time2 = 100; ent->s.genericenemyindex = TEAM_NONE; } } else if ((hit->s.eType == ET_PLAYER || hit->s.eType == ET_NPC) && hit->s.teamowner == TEAM_BLUE) {// Blue player undoing red flag... //G_Printf("Uncapturing flag!\n"); ent->s.time2--; hit->client->ps.stats[STAT_CAPTURE_ENTITYNUM] = ent->s.number; if (ent->s.time2 <= 0) {// Finished capture.. Set new team to blue... ent->s.teamowner = TEAM_NONE; ent->s.time2 = 0; ent->s.genericenemyindex = TEAM_NONE; } } } else if (ent->s.teamowner == TEAM_BLUE) {// Blue flag... if ((hit->s.eType == ET_PLAYER || hit->s.eType == ET_NPC) && hit->s.teamowner == TEAM_BLUE) {// Blue player consolidating a blue flag for spawns... //G_Printf("Consolidating flag!\n"); ent->s.time2++; hit->client->ps.stats[STAT_CAPTURE_ENTITYNUM] = ent->s.number; if (ent->s.time2 >= 100) {// Finished consolidating.. Set new team to blue and initialize... ent->s.teamowner = TEAM_BLUE; ent->s.time2 = 100; ent->s.genericenemyindex = TEAM_NONE; } } else if ((hit->s.eType == ET_PLAYER || hit->s.eType == ET_NPC) && hit->s.teamowner == TEAM_RED) {// Red player undoing blue flag... //G_Printf("Uncapturing flag!\n"); ent->s.time2--; hit->client->ps.stats[STAT_CAPTURE_ENTITYNUM] = ent->s.number; if (ent->s.time2 <= 0) {// Finished capture.. Set new team to blue... ent->s.teamowner = TEAM_NONE; ent->s.time2 = 0; ent->s.genericenemyindex = TEAM_NONE; } } } else {// Neutral flag... if (!ent->s.genericenemyindex || ent->s.genericenemyindex == TEAM_NONE) {// Start capture... Set capturing team number... ent->s.genericenemyindex = hit->s.teamowner; ent->s.time2 = 0; hit->client->ps.stats[STAT_CAPTURE_ENTITYNUM] = ent->s.number; } else if (ent->s.genericenemyindex == hit->s.teamowner) {// Continuing partial capture... ent->s.time2++; hit->client->ps.stats[STAT_CAPTURE_ENTITYNUM] = ent->s.number; // Set the current capturing team number of a neutral flag.. ent->s.genericenemyindex = hit->s.teamowner; //G_Printf("Capturing flag!\n"); if ((hit->s.eType == ET_PLAYER || hit->s.eType == ET_NPC) && hit->s.teamowner == TEAM_BLUE && ent->s.time2 >= 50) {// Blue player capturing neutral flag... Finished capture.. Set new team to blue... ent->s.teamowner = TEAM_BLUE; ent->s.time2 = 0; ent->s.genericenemyindex = TEAM_NONE; } else if ((hit->s.eType == ET_PLAYER || hit->s.eType == ET_NPC) && hit->s.teamowner == TEAM_RED && ent->s.time2 >= 50) {// Red player capturing neutral flag... Finished capture.. Set new team to red... ent->s.teamowner = TEAM_RED; ent->s.time2 = 0; ent->s.genericenemyindex = TEAM_NONE; } } else if (ent->s.genericenemyindex != hit->s.teamowner) {// Undoing partial capture... ent->s.time2--; hit->client->ps.stats[STAT_CAPTURE_ENTITYNUM] = ent->s.number; //G_Printf("Undoing owned flag!\n"); if (ent->s.time2 <= 0) {// Initialize back to untouched flag... ent->s.teamowner = TEAM_NONE; ent->s.time2 = 0; ent->s.genericenemyindex = TEAM_NONE; } } } } // Set next think... ent->nextthink = level.time + 500; }