Skip to content

Commit

Permalink
Added the option to use triggered doors in Elimination
Browse files Browse the repository at this point in the history
  • Loading branch information
sago007 committed Aug 14, 2016
1 parent c5eefe1 commit 1a0b9bb
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 211 deletions.
289 changes: 103 additions & 186 deletions code/game/g_client.c

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions code/game/g_local.h
Expand Up @@ -720,6 +720,7 @@ gentity_t *fire_prox( gentity_t *self, vec3_t start, vec3_t aimdir );
//
void G_RunMover( gentity_t *ent );
void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace );
void MatchTeam( gentity_t *teamLeader, int moverState, int time );

//
// g_trigger.c
Expand Down
54 changes: 48 additions & 6 deletions code/game/g_main.c
Expand Up @@ -2122,6 +2122,42 @@ void StartLMSRound(void) {
EnableWeapons();
}

static void CloseEliminationDoors( void ) {
gentity_t* next;
next = NULL;
for (next = G_Find(next, FOFS(classname), "func_door"); next ; next = G_Find(next, FOFS(classname), "func_door") ) {
if ( Q_strequal(next->targetname, "elimination_active") ) {
if (next->moverState != MOVER_2TO1 && next->moverState != MOVER_POS1 ) {
MatchTeam(next, MOVER_2TO1, level.time);
}
}
}
}

static void CloseEliminationDoorsInstantly( void ) {
gentity_t* next;
next = NULL;
for (next = G_Find(next, FOFS(classname), "func_door"); next ; next = G_Find(next, FOFS(classname), "func_door") ) {
if ( Q_strequal(next->targetname, "elimination_active") ) {
if ( next->moverState != MOVER_POS1 ) {
MatchTeam(next, MOVER_POS1, level.time);
}
}
}
}

static void OpenEliminationDoors( void ) {
gentity_t* next;
next = NULL;
for (next = G_Find(next, FOFS(classname), "func_door"); next ; next = G_Find(next, FOFS(classname), "func_door") ) {
if ( Q_strequal(next->targetname, "elimination_active") ) {
if (next->moverState != MOVER_1TO2 && next->moverState != MOVER_POS2 ) {
MatchTeam(next, MOVER_1TO2, level.time);
}
}
}
}

//the elimination start function
void StartEliminationRound(void) {

Expand Down Expand Up @@ -2157,12 +2193,14 @@ void StartEliminationRound(void) {
if(g_elimination_ctf_oneway.integer)
SendAttackingTeamMessageToAllClients(); //Ensure that evaryone know who should attack.
EnableWeapons();
OpenEliminationDoors();
}

//things to do at end of round:
void EndEliminationRound(void)
{
DisableWeapons();
CloseEliminationDoors();
level.roundNumber++;
level.roundStartTime = level.time+1000*g_elimination_warmup.integer;
SendEliminationMessageToAllClients();
Expand All @@ -2175,6 +2213,7 @@ void EndEliminationRound(void)
//Things to do if we don't want to move the roundNumber
void RestartEliminationRound(void) {
DisableWeapons();
CloseEliminationDoors();
level.roundNumberStarted = level.roundNumber-1;
level.roundStartTime = level.time+1000*g_elimination_warmup.integer;
if(!level.intermissiontime)
Expand All @@ -2187,6 +2226,7 @@ void RestartEliminationRound(void) {
//Things to do during match warmup
void WarmupEliminationRound(void) {
EnableWeapons();
//OpenEliminationDoors();
level.roundNumberStarted = level.roundNumber-1;
level.roundStartTime = level.time+1000*g_elimination_warmup.integer;
SendEliminationMessageToAllClients();
Expand Down Expand Up @@ -2510,6 +2550,7 @@ void CheckElimination(void) {
{
level.roundRespawned = qtrue;
RespawnAll();
CloseEliminationDoorsInstantly();
SendEliminationMessageToAllClients();
}

Expand All @@ -2522,12 +2563,13 @@ void CheckElimination(void) {
if((level.roundNumber>level.roundNumberStarted)&&(level.time>=level.roundStartTime))
StartEliminationRound();

if(level.time+1000*g_elimination_warmup.integer-500>level.roundStartTime)
if(counts[TEAM_BLUE]<1 || counts[TEAM_RED]<1)
{
RespawnDead(); //Allow players to run around anyway
WarmupEliminationRound(); //Start over
return;
if(level.time+1000*g_elimination_warmup.integer-500>level.roundStartTime) {
if(counts[TEAM_BLUE]<1 || counts[TEAM_RED]<1) {
RespawnDead(); //Allow players to run around anyway
OpenEliminationDoors();
WarmupEliminationRound(); //Start over
return;
}
}

if(level.warmupTime != 0) {
Expand Down
2 changes: 1 addition & 1 deletion code/game/g_misc.c
Expand Up @@ -171,7 +171,7 @@ void locateCamera( gentity_t *ent ) {

owner = G_PickTarget( ent->target );
if ( !owner ) {
G_Printf( "Couldn't find target for misc_partal_surface\n" );
G_Printf( "Couldn't find target for misc_partal_surface\n" );
G_FreeEntity( ent );
return;
}
Expand Down
17 changes: 8 additions & 9 deletions code/game/g_mover.c
Expand Up @@ -33,7 +33,6 @@ PUSHMOVE
===============================================================================
*/

void MatchTeam( gentity_t *teamLeader, int moverState, int time );

typedef struct {
gentity_t *ent;
Expand Down Expand Up @@ -1360,8 +1359,8 @@ void Think_SetupTrainTargets( gentity_t *ent ) {

ent->nextTrain = G_Find( NULL, FOFS(targetname), ent->target );
if ( !ent->nextTrain ) {
G_Printf( "func_train at %s with an unfound target\n",
vtos(ent->r.absmin) );
G_Printf( "func_train at %s with an unfound target\n",
vtos(ent->r.absmin) );
return;
}

Expand All @@ -1372,8 +1371,8 @@ void Think_SetupTrainTargets( gentity_t *ent ) {
}

if ( !path->target ) {
G_Printf( "Train corner at %s without a target\n",
vtos(path->s.origin) );
G_Printf( "Train corner at %s without a target\n",
vtos(path->s.origin) );
return;
}

Expand All @@ -1384,8 +1383,8 @@ void Think_SetupTrainTargets( gentity_t *ent ) {
do {
next = G_Find( next, FOFS(targetname), path->target );
if ( !next ) {
G_Printf( "Train corner at %s without a target path_corner\n",
vtos(path->s.origin) );
G_Printf( "Train corner at %s without a target path_corner\n",
vtos(path->s.origin) );
return;
}
} while ( strcmp( next->classname, "path_corner" ) );
Expand All @@ -1407,7 +1406,7 @@ Target: next path corner and other targets to fire
*/
void SP_path_corner( gentity_t *self ) {
if ( !self->targetname ) {
G_Printf ("path_corner with no targetname at %s\n", vtos(self->s.origin));
G_Printf ("path_corner with no targetname at %s\n", vtos(self->s.origin));
G_FreeEntity( self );
return;
}
Expand Down Expand Up @@ -1444,7 +1443,7 @@ void SP_func_train (gentity_t *self) {
}

if ( !self->target ) {
G_Printf ("func_train without a target at %s\n", vtos(self->r.absmin));
G_Printf ("func_train without a target at %s\n", vtos(self->r.absmin));
G_FreeEntity( self );
return;
}
Expand Down
2 changes: 1 addition & 1 deletion code/game/g_spawn.c
Expand Up @@ -32,7 +32,7 @@ qboolean G_SpawnString( const char *key, const char *defaultString, char **out )
}

for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
if ( !Q_stricmp( key, level.spawnVars[i][0] ) ) {
if ( Q_strequal( key, level.spawnVars[i][0] ) ) {
*out = level.spawnVars[i][1];
return qtrue;
}
Expand Down
11 changes: 6 additions & 5 deletions code/game/g_target.c
Expand Up @@ -349,7 +349,7 @@ void target_teleporter_use( gentity_t *self, gentity_t *other, gentity_t *activa
return;
dest = G_PickTarget( self->target );
if (!dest) {
G_Printf ("Couldn't find teleporter destination\n");
G_Printf ("Couldn't find teleporter destination\n");
return;
}

Expand All @@ -360,8 +360,9 @@ void target_teleporter_use( gentity_t *self, gentity_t *other, gentity_t *activa
The activator will be teleported away.
*/
void SP_target_teleporter( gentity_t *self ) {
if (!self->targetname)
G_Printf("untargeted %s at %s\n", self->classname, vtos(self->s.origin));
if (!self->targetname) {
G_Printf("untargeted %s at %s\n", self->classname, vtos(self->s.origin));
}

self->use = target_teleporter_use;
}
Expand Down Expand Up @@ -436,8 +437,8 @@ static void target_location_linkup(gentity_t *ent)
trap_SetConfigstring( CS_LOCATIONS, "unknown" );

for (i = 0, ent = g_entities, n = 1;
i < level.num_entities;
i++, ent++) {
i < level.num_entities;
i++, ent++) {
if (ent->classname && Q_strequal(ent->classname, "target_location") ) {
// lets overload some variables!
ent->health = n; // use for location marking
Expand Down
2 changes: 1 addition & 1 deletion code/game/g_trigger.c
Expand Up @@ -287,7 +287,7 @@ void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace

dest = G_PickTarget( self->target );
if (!dest) {
G_Printf ("Couldn't find teleporter destination\n");
G_Printf ("Couldn't find teleporter destination\n");
return;
}

Expand Down
4 changes: 2 additions & 2 deletions code/game/g_utils.c
Expand Up @@ -197,7 +197,7 @@ gentity_t *G_PickTarget (char *targetname)

if (!targetname)
{
G_Printf("G_PickTarget called with NULL targetname\n");
G_Printf("G_PickTarget called with NULL targetname\n");
return NULL;
}

Expand All @@ -213,7 +213,7 @@ gentity_t *G_PickTarget (char *targetname)

if (!num_choices)
{
G_Printf("G_PickTarget: target %s not found\n", targetname);
G_Printf("G_PickTarget: target %s not found\n", targetname);
return NULL;
}

Expand Down

0 comments on commit 1a0b9bb

Please sign in to comment.