diff options
-rw-r--r-- | src/game/g_trigger.c | 92 |
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 ); + } } } |