//=============================================================================
// PoisonPlayer.
//=============================================================================
class PoisonPlayer expands WildcardsPlayerAffecters;

var() float Slowness;
var() float RecoverRate;
var int choice;
var AnimatedSprite FX;
var Pawn PoisonedPlayer;

replication
{
	unreliable if ( Role==ROLE_Authority )
		PoisonedPlayer, choice;
}

simulated event BeginPlay()
{
 local sgSpeed sp;
 
 
 SetTimer(0.125,true);
 if( PoisonedPlayer == None ){return;}
 
    
	sp = sgSpeed(PoisonedPlayer.FindInventoryType(class'sgSpeed'));
	if (sp != None)
	{
		sp.GotoState('DeActivated');
	}
	PoisonedPlayer.GroundSpeed = PoisonedPlayer.default.GroundSpeed/Slowness;
 	//PoisonedPlayer.WaterSpeed = PoisonedPlayer.default.WaterSpeed/Slowness;
	PoisonedPlayer.AirSpeed = PoisonedPlayer.default.AirSpeed/Slowness;
}

simulated function timer()
{
	local sgSpeed sp;

	if (PoisonedPlayer != None)
		{
			if (PoisonedPlayer.Health <= 0)
				{
					ForceDefaults();
					destroy();
					return;
				}
		}
	else
		destroy();
		return;
	
	if ( PoisonedPlayer != None )
		{
			choice = Rand(32);
			if ( choice == 0 )
				{
					FX = Spawn(Class'PoisonCloud', Owner, ,PoisonedPlayer.Location);
					FX.DrawScale = 0.5;
					FX.AnimationLength = 1;
					PoisonedPlayer.PlaySound(sound'PoisonCough01',,4.0);
				}
			if ( choice == 1 )
				{
					FX = Spawn(Class'PoisonCloud', Owner, ,PoisonedPlayer.Location);
					FX.DrawScale = 0.5;
					FX.AnimationLength = 1;
					PoisonedPlayer.PlaySound(sound'PoisonCough02',,4.0);
				}
			if ( choice == 2 )
				{
					FX = Spawn(Class'PoisonCloud', Owner, ,PoisonedPlayer.Location);
					FX.DrawScale = 0.5;
					FX.AnimationLength = 1;
					PoisonedPlayer.PlaySound(sound'PoisonCough03',,4.0);
				}
			if ( choice == 3 )
				{
					FX = Spawn(Class'PoisonCloud', Owner, ,PoisonedPlayer.Location);
					FX.DrawScale = 0.5;
					FX.AnimationLength = 1;
					PoisonedPlayer.PlaySound(sound'PoisonCough04',,4.0);
				}
		}

	sp = sgSpeed(PoisonedPlayer.FindInventoryType(class'sgSpeed'));
	if (sp != None)
	{
		sp.GotoState('DeActivated');
	}
	
	Slowness -= RecoverRate;
	PoisonedPlayer.GroundSpeed = PoisonedPlayer.default.GroundSpeed/Slowness;
	//PoisonedPlayer.WaterSpeed = PoisonedPlayer.default.WaterSpeed/Slowness;
	PoisonedPlayer.AirSpeed = PoisonedPlayer.default.AirSpeed/Slowness;

	if 	(Slowness <= 1)
		{
			PoisonedPlayer.GroundSpeed = PoisonedPlayer.default.GroundSpeed;
			//PoisonedPlayer.WaterSpeed = PoisonedPlayer.default.WaterSpeed;
			PoisonedPlayer.AirSpeed = PoisonedPlayer.default.AirSpeed;

			if (sp != None)
			{
				sp.GotoState('Activated');
			}
			destroy();
			return;
		}

}

simulated function ForceDefaults()
{
	 
	 

	PoisonedPlayer.GroundSpeed = PoisonedPlayer.default.GroundSpeed;		
	//PoisonedPlayer.WaterSpeed = PoisonedPlayer.default.WaterSpeed;
	PoisonedPlayer.AirSpeed = PoisonedPlayer.default.AirSpeed;

}

defaultproperties
{
    Slowness=4.00
    RecoverRate=0.13
    bHidden=True
    bAlwaysRelevant=True
    RemoteRole=ROLE_SimulatedProxy
    Style=STY_Translucent
    Texture=Texture'SiegeUltimateRC7UB01Media.U.ToxicCloudAnimation.ToxicCloud015'
}
