summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author/dev/humancontroller <devhc@example.com>2014-07-13 16:54:51 +0200
committer/dev/humancontroller <devhc@example.com>2017-03-09 13:51:11 +0100
commita2b4c1c22e6d86a517f6c82af0a524816bc3871a (patch)
tree1ad771cd672262f3ff6f1268a338434641fa0206 /src
parent75653970ac34562ecbbb0fdd82f4365c60203684 (diff)
alter trigger wait timers a bit, remove duplicate code
Diffstat (limited to 'src')
-rw-r--r--src/game/g_trigger.c92
1 files changed, 37 insertions, 55 deletions
diff --git a/src/game/g_trigger.c b/src/game/g_trigger.c
index 31fcf6d6..49c0dc8e 100644
--- a/src/game/g_trigger.c
+++ b/src/game/g_trigger.c
@@ -42,6 +42,24 @@ void multi_wait( gentity_t *ent )
}
+void trigger_check_wait( gentity_t *self )
+{
+ if( self->wait > 0 )
+ {
+ self->think = multi_wait;
+ self->nextthink = level.time + ( self->wait + self->random * crandom( ) ) * 1000;
+ }
+ else
+ {
+ // we can't just remove (self) here, because this is a touch function
+ // called while looping through area links...
+ self->touch = 0;
+ self->nextthink = level.time + FRAMETIME;
+ self->think = G_FreeEntity;
+ }
+}
+
+
// the trigger was just activated
// ent->activator should be set to the activator so it can be held through a delay
// so wait for the delay time before firing
@@ -63,20 +81,7 @@ void multi_trigger( gentity_t *ent, gentity_t *activator )
}
G_UseTargets( ent, ent->activator );
-
- if( ent->wait > 0 )
- {
- ent->think = multi_wait;
- ent->nextthink = level.time + ( ent->wait + ent->random * crandom( ) ) * 1000;
- }
- else
- {
- // we can't just remove (self) here, because this is a touch function
- // called while looping through area links...
- ent->touch = 0;
- ent->nextthink = level.time + FRAMETIME;
- ent->think = G_FreeEntity;
- }
+ trigger_check_wait( ent );
}
void Use_Multi( gentity_t *ent, gentity_t *other, gentity_t *activator )
@@ -598,26 +603,18 @@ void trigger_buildable_trigger( gentity_t *self, gentity_t *activator )
if( self->s.eFlags & EF_DEAD )
{
if( !trigger_buildable_match( self, activator ) )
+ {
G_UseTargets( self, activator );
+ trigger_check_wait( self );
+ }
}
else
{
if( trigger_buildable_match( self, activator ) )
+ {
G_UseTargets( self, activator );
- }
-
- if( self->wait > 0 )
- {
- self->think = multi_wait;
- self->nextthink = level.time + ( self->wait + self->random * crandom( ) ) * 1000;
- }
- else
- {
- // we can't just remove (self) here, because this is a touch function
- // called while looping through area links...
- self->touch = 0;
- self->nextthink = level.time + FRAMETIME;
- self->think = G_FreeEntity;
+ trigger_check_wait( self );
+ }
}
}
@@ -735,27 +732,20 @@ void trigger_class_trigger( gentity_t *self, gentity_t *activator )
if( self->s.eFlags & EF_DEAD )
{
if( !trigger_class_match( self, activator ) )
+ {
G_UseTargets( self, activator );
+ trigger_check_wait( self );
+ }
}
else
{
if( trigger_class_match( self, activator ) )
+ {
G_UseTargets( self, activator );
+ trigger_check_wait( self );
+ }
}
- if( self->wait > 0 )
- {
- self->think = multi_wait;
- self->nextthink = level.time + ( self->wait + self->random * crandom( ) ) * 1000;
- }
- else
- {
- // we can't just remove (self) here, because this is a touch function
- // called while looping through area links...
- self->touch = 0;
- self->nextthink = level.time + FRAMETIME;
- self->think = G_FreeEntity;
- }
}
/*
@@ -878,26 +868,18 @@ void trigger_equipment_trigger( gentity_t *self, gentity_t *activator )
if( self->s.eFlags & EF_DEAD )
{
if( !trigger_equipment_match( self, activator ) )
+ {
G_UseTargets( self, activator );
+ trigger_check_wait( self );
+ }
}
else
{
if( trigger_equipment_match( self, activator ) )
+ {
G_UseTargets( self, activator );
- }
-
- if( self->wait > 0 )
- {
- self->think = multi_wait;
- self->nextthink = level.time + ( self->wait + self->random * crandom( ) ) * 1000;
- }
- else
- {
- // we can't just remove (self) here, because this is a touch function
- // called while looping through area links...
- self->touch = 0;
- self->nextthink = level.time + FRAMETIME;
- self->think = G_FreeEntity;
+ trigger_check_wait( self );
+ }
}
}