# SpatialFear.SFNPCDeco

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 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 |
    //=============================================================================
    // Spatial Fear
    // Name: SFNPCDeco
    // Description: Deco class used to show NPC bodies.
    //
    // Author: Markus Nuebel
    //=============================================================================
    class SFNPCDeco extends Decoration ;

    var bool	m_bInAnimSequence; // Private: Indicates a sequence plaback
    var int		m_nSequence;		// Private: Animation counter
    var name	m_arSequence[10];	// Private: Animation array
    var float	m_fAnimationRate;	// Private: animation rate for playback
    var float	m_fLastPheromoneSpawn;	// Private: Timestamp for last pheromon spawn.
    var (SpatialFear) bool	bSpawnPheromones; // If this is set to true, the deco actor will spawn pheromones and attract enemies like mite. Default: false

    // Overwritten to handle pheromon spawning
    function Tick(float fDelta)
    {
    	// Call to base class
    	Super.Tick(fDelta);

    	// Check for smell
    	if(bSpawnPheromones)
    		sweat(fDelta);
    }

    // Handles spawning of pheromons, to attract enemies
    function sweat(float fDelta)
    {
    	local SFPheromone oParticle;

    	m_fLastPheromoneSpawn += fDelta;
    	if(m_fLastPheromoneSpawn > 3.5f)
    	{
    		m_fLastPheromoneSpawn = 0.0f;
    		oParticle	= Spawn(class'SFPheromone');
    		oParticle.m_actInstigator = Self;
    		oParticle.bHidden = true;
    	}

    }

    // Manually fires the actors event
    function FireEvent( actor Other , Pawn Instigator)
    {
    	local actor A;

    	if( Instigator.IsA('SFPlayer') )
    	{
    		// Broadcast the Trigger message to all matching actors.
    		if( Event != '' )
    			foreach AllActors( class 'Actor', A, Event )
    				A.Trigger( Other, Instigator );

    	}
    }

    function Bump( actor Other )
    {
    	// Call to base class
    	Super.Bump(Other);

    	if(Other.IsA('SFPlayer'))
    		FireEvent(Self, Pawn(Other));

    }

    function startAnimSequence()
    {
    	m_bInAnimSequence=true;
    	m_nSequence=0;
    	PlayAnim(m_arSequence[0], 1.0, 0.1);

    }

    function stopPlaying()
    {
    	if ( AnimSequence != '' )
    		PlayAnim(AnimSequence);
    }

    function endAnimSequence()
    {
    	m_bInAnimSequence=false;
    }

    function AnimEnd()
    {
    	if(m_bInAnimSequence)
    	{
    		m_nSequence++;
    		if(10 > m_nSequence)
    		{
    			// Check for looping the end sequence
    			if(m_arSequence[m_nSequence] == 'SFLOOPEND')
    			{
    				if(0 <= m_nSequence-1)
    					LoopAnim(m_arSequence[m_nSequence-1], m_fAnimationRate, 0.1);
    				// End of animation sequence reached
    				m_bInAnimSequence = false;
    			}
    			// Check for starting over again
    			else if(m_arSequence[m_nSequence] == 'SFSTARTAGAIN')
    			{
    				// Reset counter
    				m_nSequence=0;
    				// Play the animation
    				PlayAnim(m_arSequence[m_nSequence], m_fAnimationRate, 0.1);
    			}
    			else if(m_arSequence[m_nSequence] != '')
    			// Check for normal animation playback
    			{
    				PlayAnim(m_arSequence[m_nSequence], m_fAnimationRate, 0.1);
    			}
    			else
    			{
    				// End of animation sequence reached
    				m_bInAnimSequence = false;
    			}
    		}
    		else
    		{
    			// Animation limit reached
    			m_bInAnimSequence = false;
    		}
    	}

    	Super.AnimEnd();
    }

    defaultproperties
    {
         m_fAnimationRate=1.000000
         Mass=100.000000
    }

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