/** * @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 } } }
/** * @brief Team_TouchOurFlag * @param[in] ent * @param[in] other * @param[in] team * @return */ int Team_TouchOurFlag(gentity_t *ent, gentity_t *other, int team) { gclient_t *cl = other->client; if (ent->flags & FL_DROPPED_ITEM) { // hey, its not home. return it by teleporting it back AddScore(other, WOLF_SECURE_OBJ_BONUS); if (cl->sess.sessionTeam == TEAM_AXIS) { if (level.gameManager) { G_Script_ScriptEvent(level.gameManager, "trigger", "axis_object_returned"); } G_Script_ScriptEvent(&g_entities[ent->s.otherEntityNum], "trigger", "returned"); #ifdef FEATURE_OMNIBOT { const char *pName = ent->message ? ent->message : _GetEntityName(ent); Bot_Util_SendTrigger(ent, NULL, va("Axis have returned %s!", pName ? pName : ""), "returned"); } #endif } else { if (level.gameManager) { G_Script_ScriptEvent(level.gameManager, "trigger", "allied_object_returned"); } G_Script_ScriptEvent(&g_entities[ent->s.otherEntityNum], "trigger", "returned"); #ifdef FEATURE_OMNIBOT { const char *pName = ent->message ? ent->message : _GetEntityName(ent); Bot_Util_SendTrigger(ent, NULL, va("Allies have returned %s!", pName ? pName : ""), "returned"); } #endif } //ResetFlag will remove this entity! We must return zero Team_ReturnFlagSound(ent, team); Team_ResetFlag(ent); return 0; } // GT_WOLF doesn't support capturing the flag return 0; }
void G_Script_ScriptEvent( gentity_t *ent, char *eventStr, char *params ) { int i = G_Script_GetEventIndex(ent, eventStr, params); if (i>=0) G_Script_ScriptChange( ent, i ); // omnibot ////////////////////////////////////////////////////////////////////////// // skip these if(!Q_stricmp(eventStr, "trigger") || !Q_stricmp(eventStr, "activate") || !Q_stricmp(eventStr, "spawn") || !Q_stricmp(eventStr, "death") || !Q_stricmp(eventStr, "pain") || !Q_stricmp(eventStr, "playerstart")) return; if(!Q_stricmp(eventStr, "defused")) { Bot_Util_SendTrigger(ent, NULL, va("Defused at %s.", ent->parent ? ent->parent->track : ent->track), eventStr); } else if(!Q_stricmp(eventStr, "dynamited")) { Bot_Util_SendTrigger(ent, NULL, va("Planted at %s.", ent->parent ? ent->parent->track : ent->track), eventStr); } else if(!Q_stricmp(eventStr, "destroyed")) { Bot_Util_SendTrigger(ent, NULL, va("%s Destroyed.", ent->parent ? ent->parent->track : ent->track), eventStr); } else if(!Q_stricmp(eventStr, "exploded")) { Bot_Util_SendTrigger(ent, NULL, va("Explode_%s Exploded.", _GetEntityName(ent) ),eventStr); } // end omnibot }
/** * @brief If spawn flag is set, use this touch fn instead to turn on/off targeted spawnpoints * @param[in,out] self * @param[in,out] other * @param trace - unused */ void checkpoint_spawntouch(gentity_t *self, gentity_t *other, trace_t *trace) { gentity_t *ent = NULL; qboolean playsound = qtrue; qboolean firsttime = qfalse; #ifdef FEATURE_OMNIBOT char *flagAction = "touch"; #endif if (self->count == other->client->sess.sessionTeam) { return; } if (self->s.frame == WCP_ANIM_NOFLAG) { AddScore(other, WOLF_SP_CAPTURE); } else { AddScore(other, WOLF_SP_RECOVER); } if (self->count < 0) { firsttime = qtrue; } // Set controlling team self->count = other->client->sess.sessionTeam; // Set animation if (self->count == TEAM_AXIS) { if (self->s.frame == WCP_ANIM_NOFLAG && !(self->spawnflags & ALLIED_ONLY)) { self->s.frame = WCP_ANIM_RAISE_AXIS; #ifdef FEATURE_OMNIBOT flagAction = "capture"; #endif } else if (self->s.frame == WCP_ANIM_NOFLAG) { self->s.frame = WCP_ANIM_NOFLAG; playsound = qfalse; } else if (self->s.frame == WCP_ANIM_AMERICAN_RAISED && !(self->spawnflags & ALLIED_ONLY)) { self->s.frame = WCP_ANIM_AMERICAN_TO_AXIS; #ifdef FEATURE_OMNIBOT flagAction = "reclaims"; #endif } else if (self->s.frame == WCP_ANIM_AMERICAN_RAISED) { self->s.frame = WCP_ANIM_AMERICAN_FALLING; #ifdef FEATURE_OMNIBOT flagAction = "neutralized"; #endif } else { self->s.frame = WCP_ANIM_AXIS_RAISED; } } else { if (self->s.frame == WCP_ANIM_NOFLAG && !(self->spawnflags & AXIS_ONLY)) { self->s.frame = WCP_ANIM_RAISE_AMERICAN; #ifdef FEATURE_OMNIBOT flagAction = "capture"; #endif } else if (self->s.frame == WCP_ANIM_NOFLAG) { self->s.frame = WCP_ANIM_NOFLAG; playsound = qfalse; } else if (self->s.frame == WCP_ANIM_AXIS_RAISED && !(self->spawnflags & AXIS_ONLY)) { self->s.frame = WCP_ANIM_AXIS_TO_AMERICAN; #ifdef FEATURE_OMNIBOT flagAction = "reclaims"; #endif } else if (self->s.frame == WCP_ANIM_AXIS_RAISED) { self->s.frame = WCP_ANIM_AXIS_FALLING; #ifdef FEATURE_OMNIBOT flagAction = "neutralized"; #endif } else { self->s.frame = WCP_ANIM_AMERICAN_RAISED; } } // If this is the first time it's being touched, and it was the opposing team // touching a single-team reinforcement flag... don't do anything. if (firsttime && !playsound) { return; } // Play a sound if (playsound) { G_AddEvent(self, EV_GENERAL_SOUND, self->soundPos1); } self->parent = other; // reset player disguise on touching flag other->client->ps.powerups[PW_OPS_DISGUISED] = 0; other->client->disguiseClientNum = -1; // Run script trigger if (self->count == TEAM_AXIS) { G_Script_ScriptEvent(self, "trigger", "axis_capture"); #ifdef FEATURE_OMNIBOT Bot_Util_SendTrigger(self, NULL, va("axis_%s_%s", flagAction, _GetEntityName(self)), flagAction); #endif } else { G_Script_ScriptEvent(self, "trigger", "allied_capture"); #ifdef FEATURE_OMNIBOT Bot_Util_SendTrigger(self, NULL, va("allies_%s_%s", flagAction, _GetEntityName(self)), flagAction); #endif } // Don't allow touch again until animation is finished self->touch = NULL; self->think = checkpoint_think; self->nextthink = level.time + 1000; // activate all targets // updated this to allow toggling of initial spawnpoints as well, plus now it only // toggles spawnflags 2 for spawnpoint entities if (self->target) { while (1) { ent = G_FindByTargetname(ent, self->target); if (!ent) { break; } if (other->client->sess.sessionTeam == TEAM_AXIS) { if (!strcmp(ent->classname, "team_CTF_redspawn")) { ent->spawnflags |= 2; } else if (!strcmp(ent->classname, "team_CTF_bluespawn")) { ent->spawnflags &= ~2; } } else { if (!strcmp(ent->classname, "team_CTF_bluespawn")) { ent->spawnflags |= 2; } else if (!strcmp(ent->classname, "team_CTF_redspawn")) { ent->spawnflags &= ~2; } } } } }