# SFCharacter.SFMiteEgg

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 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 |
    //=============================================================================
    // Spatial Fear
    // Class: SFMiteEgg
    // Descripton: An egg that produces a SFBabyMite.
    //				When triggered a Timer with interval: fInterval is started.
    //				After the time has expired the egg gives birth to a baby mite.
    //
    // Author: Markus Nuebel
    //=============================================================================
    class SFMiteEgg extends SFDecoration;

    #exec OBJ LOAD FILE=SPF-Content.uax  PACKAGE=SPF-Content GROUP=Creatures

    var float    Speed;               // Initial speed of projectile.
    var float	m_fCrackTimer;
    var	(SpatialFear)	sound   SpawnSound;		// Sound made when projectile is spawned.
    var	(SpatialFear)	sound	ImpactSound;	// Sound made when projectile hits something.
    var (SpatialFear)	float   Damage; // Damage applied when directly hit by a falling egg (ouch!)
    var (SpatialFear)	float	fInterval; // Interval to crack and give birth to a baby mite

    event Trigger(actor Other, Pawn EventInstigator)
    {
    	// No Call to base class
    	m_fCrackTimer=0;
    }

    function BeginPlay()
    {
    	Super.BeginPlay();

    }
    simulated function ProcessTouch(Actor Other, Vector HitLocation)
    {
    }

    function Tick(float fDelta)
    {
    	Super.Tick(fDelta);

    	if(m_fCrackTimer >= 0)
    		m_fCrackTimer += fDelta;
    	else
    		return;

    	if(m_fCrackTimer > fInterval)
    	{
    		if(FRand() < 0.2)
    			m_fCrackTimer = 0;
    		else
    		{
    			Crack();
    			GiveBirth();
    		}
    	}

    }
    // Called to destroy egg
    function Crack()
    {
    	local Actor			oDestroyEffect;
    	local GreenSmokePuff s;

    	// Play the destroy effect
    	s = spawn(class'GreenSmokePuff', Self,, Location);
    	s.RemoteRole = ROLE_None;

    	// Make some noise
    	PlaySound(ImpactSound);
    	MakeNoise(1.0);

    	// Suicide
    	Destroy();
    }

    // Give birth to a baby mite.
    function GiveBirth()
    {
    	local SFBabyMite	oBaby;
    	local vector		vecSpawnPoint;

    	vecSpawnPoint	= Location+vect(0,0,1)*CollisionHeight;
    	oBaby			= spawn(class'SFBabyMite2', Self,, vecSpawnPoint);
    	if((None != oBaby) && (None != Owner))
    		oBaby.setOwner(Owner);
    }

    function Landed(vector HitNormall)
    {
    }

    simulated singular function Touch(Actor Other)
    {
    	local actor HitActor;
    	local vector HitLocation, HitNormal, TestLocation;

    	if ( Other.IsA('BlockAll') )
    	{
    		PlaySound(ImpactSound);
    		return;
    	}

    	if ( Other.bProjTarget || (Other.bBlockActors && Other.bBlockPlayers) )
    	{
    		//get exact hitlocation
    	 	HitActor = Trace(HitLocation, HitNormal, Location, OldLocation, true);
    		if (HitActor == Other)
    		{
    			if ( Other.bIsPawn
    				&& !Pawn(Other).AdjustHitLocation(HitLocation, Velocity) )
    					return;
    			ProcessTouch(Other, HitLocation);
    		}
    		else
    			ProcessTouch(Other, Other.Location + Other.CollisionRadius * Normal(Location - Other.Location));
    	}
    }

    // Counts down the healthe to make the egg destroyable
    event TakeDamage( int Damage, Pawn EventInstigator, vector HitLocation, vector Momentum, name DamageType)
    {
    	local GreenSmokePuff s;
    	local vector HitNormal;

    	Health -= Damage;
    	if(Health <= 0)	// Destroy object
    	{
    		Crack();
    		return;
    	}

    	// Damage the object
    	if(Health > 0)
    	{
    		HitLocation	= Normal(Location - EventInstigator.Location);
    		s = spawn(class'GreenSmokePuff', Self,, Location);
    		s.RemoteRole = ROLE_None;
    	}
    }

    auto state Flying
    {
    	simulated function ProcessTouch (Actor Other, Vector HitLocation)
    	{
    		local vector momentum;

    		if ((SFMite(Other) == None) && (SFMiteEgg(Other) == None) && Pawn(Other) != None)
    		{
    			if ( Role == ROLE_Authority )
    			{
    				momentum = 10000.0 * Normal(Velocity);
    				Other.TakeDamage(Damage, instigator, HitLocation, momentum, 'egghit');
    			}
    		}
    	}

    	function BeginState()
    	{
    		Velocity = Vector(Rotation) * speed;
    		PlaySound(SpawnSound);
    		PlayAnim('Flying');
    	}

    Begin:

    }

    //Texture=Texture'Botpack.GoopEx.g2r_a00'

    defaultproperties
    {
         speed=45.000000
         m_fCrackTimer=-1.000000
         SpawnSound=Sound'SPF-Content.Creatures.MiteSpit'
         ImpactSound=Sound'SPF-Content.Creatures.MiteSpitImpact'
         Damage=5.000000
         fInterval=3.000000
         bDestroyable=True
         Health=35
         ChunkType=Class'UnrealShare.WallFragments'
         ChunksNumber=10
         ChunkScale=0.400000
         bPushable=True
         bStatic=False
         Physics=PHYS_Falling
         RemoteRole=ROLE_SimulatedProxy
         DrawType=DT_Mesh
         Texture=FireTexture'UnrealShare.Belt_fx.Damage.Pulsehit'
         Mesh=LodMesh'Botpack.BioGelm'
         DrawScale=0.900000
         AmbientGlow=255
         bUnlit=True
         MultiSkins(1)=FireTexture'UnrealShare.Belt_fx.Damage.Pulsehit'
         CollisionRadius=4.800000
         CollisionHeight=3.800000
         Mass=2000.000000
    }

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