# SpatialFear.SFDamageTrigger

00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 |
    //=============================================================================
    // Spatial Fear
    // Class: SFDamageTrigger
    // Descripton: Subclasses of SFTrigger, rembers damage applied to it, in contrast
    //						to a normal Trigger, that is triggered only when the
    //						applied damage if bigger than the configured DamageThreshold
    //
    // Author: Markus Nuebel
    //=============================================================================

    class SFDamageTrigger extends SFTrigger;

    var float	m_fCurrentDamageThreshold;	// Private: Keeps track of current damage threshold

    // Just initializes the current threshold with the configured one.
    function resetThreshold()
    {
    	m_fCurrentDamageThreshold = DamageThreshold;
    }

    // Overwrite of IsRelevant, to not ignore projectiles with small damage
    function bool IsRelevant( actor Other )
    {
    	if( !bInitiallyActive )
    		return false;
    	switch( TriggerType )
    	{
    		case TT_PlayerProximity:
    			return Pawn(Other)!=None && Pawn(Other).bIsPlayer;
    		case TT_PawnProximity:
    			return Pawn(Other)!=None && ( Pawn(Other).Intelligence > BRAINS_None );
    		case TT_ClassProximity:
    			return ClassIsChildOf(Other.Class, ClassProximityType);
    		case TT_AnyProximity:
    			return true;
    		case TT_Shoot:
    			return (Projectile(Other) != None);
    	}
    }

    // Overwrite, to keep track of the applied damage
    function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation,
    						Vector momentum, name damageType)
    {
    	local actor A;

    	// Track damage
    	m_fCurrentDamageThreshold	-= Damage;

    	if ( bInitiallyActive && (TriggerType == TT_Shoot) &&
    		 (0 >= m_fCurrentDamageThreshold) &&  (instigatedBy != None)
    	   )
    	{
    		resetThreshold();

    		if ( ReTriggerDelay > 0 )
    		{
    			if ( Level.TimeSeconds - TriggerTime < ReTriggerDelay )
    				return;
    			TriggerTime = Level.TimeSeconds;
    		}
    		// Broadcast the Trigger message to all matching actors.
    		if( Event != '' )
    			foreach AllActors( class 'Actor', A, Event )
    				A.Trigger( instigatedBy, instigatedBy );

    		if( Message != "" )
    			// Send a string message to the toucher.
    			instigatedBy.Instigator.ClientMessage( Message );

    		if( bTriggerOnceOnly )
    			// Ignore future touches.
    			SetCollision(False);
    	}
    }

    defaultproperties
    {
    }

class file time: 12/7/2003 3:58:24 PM - creation time: 12/7/2003 4:03:44 PM
Created with UnCodeX