void Warzone_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; ent->s.eFlags |= EF_RADAROBJECT; #ifdef __UNUSED__ if (flag_file_loaded) { 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 ); //G_Printf("Flagnum is %i. flagent->s.otherEntityNum is %i\n", flagent->count, flagent->s.otherEntityNum); flagent->alt_fire = qtrue; } flag_spawnpoints_done = qtrue; } } else if (!ent->alt_fire) {// Have we initialized spawnpoints yet? //if (level.numConnectedClients > 0) { PreCalculate_Flag_Spawnpoints( ent->count, ent->s.angles, ent->s.origin ); //G_Printf("Flagnum is %i. ent->s.otherEntityNum is %i\n", ent->count, ent->s.otherEntityNum); ent->alt_fire = qtrue; flag_spawnpoints_done = qtrue; } } #endif //__UNUSED__ 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 (!EntityVisible(ent, hit)) { hit->client->ps.stats[STAT_CAPTURE_ENTITYNUM] = 0; continue; } if (ent->s.teamowner == TEAM_RED) {// Red flag... if ((hit->s.eType == ET_PLAYER || hit->s.eType == ET_NPC) && hit->s.teamowner == TEAM_RED) {// Red player consolidating a red 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; }
void OctLevel::CalcRenderOrderRecurse(const Vect &eye, const ViewClip &clip, MeshOrderInfo &meshOrder, OctNode *curNode, BOOL bFullyVisible) { OctNode *node = (curNode != NULL) ? curNode : objectTree->GetRoot(); DWORD i; BOOL bCheckBounds = (node->numChildren > 1) || (node->Leaves.Num() > 0); if(!bFullyVisible && bCheckBounds) { int testVal = clip.BoundsTest(node->bounds); if(testVal == BOUNDS_INSIDE) bFullyVisible = TRUE; else if(testVal == BOUNDS_OUTSIDE) return; } if(node->numChildren) { for(i=0; i<8; i++) { if(!node->children[i]) continue; OctNode *child = node->children[i]; CalcRenderOrderRecurse(eye, clip, meshOrder, child, bFullyVisible); } } for(i=0; i<node->Leaves.Num(); i++) { LevelObject *leaf = node->Leaves[i]; if(!bFullyVisible && !clip.BoundsVisible(leaf->bounds)) continue; if(leaf->type == ObjectType_Entity) { if(leaf->ent->IsOf(GetClass(MeshEntity))) { MeshEntity *meshEnt = (MeshEntity*)leaf->ent; if(meshEnt->bRenderable) { EntityVisible(meshEnt) = TRUE; meshOrder.AddEntity(meshEnt); } } else if(leaf->ent->IsOf(GetClass(Projector))) { Projector *projector = (Projector*)leaf->ent; if(projector->bRenderable) { if(projector->IsOf(GetClass(LitDecal))) renderLitDecals << (LitDecal*)projector; else renderProjectors << projector; EntityVisible(projector) = TRUE; } } else if(leaf->ent->IsOf(GetClass(Light))) { Light *light = (Light*)leaf->ent; if(light->IsOf(GetClass(SpotLight))) { SpotLight *spotLight = (SpotLight*)light; if(spotLight->IsLightmapped() && !spotLight->NumLitEntities()) continue; renderSpotLights << spotLight; } else if(light->IsOf(GetClass(PointLight))) { PointLight *pointLight = (PointLight*)light; if(pointLight->IsLightmapped() && !pointLight->NumLitEntities()) continue; renderPointLights << pointLight; } } else { Entity *ent = leaf->ent; if(ent->bRenderable) { EntityVisible(ent) = TRUE; renderEntities << ent; } } } else if(leaf->type == ObjectType_Brush) { Brush *brush = leaf->brush; brush->bVisible = TRUE; renderBrushes << brush; } } }