class DumbDoll expands Decoration;

var IceOvB iceoverl;

simulated function PostBeginPlay()
{
	PlaySound(Sound'Iced',, 20.0);
	iceoverl = Spawn(Class'IceOvB', Self,, Location, Rotation);
	iceoverl.RemoteRole = ROLE_None;
	SetTimer(0.3, True);
	Super.PostBeginPlay();
}


function Bump( actor Other )
{
    local float speed, oldZ;
    if( bPushable && (Pawn(Other)!=None) && (Other.Mass > 40) && Level.NetMode == NM_StandAlone)
    {
        bBobbing = false;
        oldZ = Velocity.Z;
        speed = VSize(Other.Velocity);
        Velocity = Other.Velocity * FMin(120.0, 20 + speed)/speed;
        if ( Physics == PHYS_None ) {
            Velocity.Z = 25;
            if (!bPushSoundPlaying) PlaySound(PushSound, SLOT_Misc,0.25);
            bPushSoundPlaying = True;          
        }
        else
            Velocity.Z = oldZ;
        SetPhysics(PHYS_Falling);
        Instigator = Pawn(Other);
    }
}

simulated function Timer()
{
local bool bSomething;
local Actor A;

	if(Region.Zone.DamageType == 'Burned')
	{
		Destroy();
	}

	if (Level.NetMode == NM_StandAlone)
	{

	ForEach VisibleCollidingActors(Class'Actor', A, CollisionRadius, Location + (CollisionHeight + CollisionRadius) * vect(0,0,1))
	{
		If (A != Self)
		{
			bSomething = True;
			Mass = Default.Mass + A.Mass;
		}
	}

	if (!bSomething)
		Mass = Default.Mass;
	}
}

function TakeDamage( int NDamage, Pawn instigatedBy, Vector hitlocation, vector momentum, name damageType )
{
	If ((DamageType != 'Freezed' && NDamage > 1) || DamageType == 'Burned')
	{
		ReleaseFragEffect(class'FragmentIce', Texture'Ice', Momentum, DrawScale, 12);
		PlaySound(Sound'IceHit',, 30.0);

		Instigator = InstigatedBy;

		if (Instigator != None)
			MakeNoise(1.0);
	}
}

simulated function Destroyed()
{
	if (iceoverl != None)
		iceoverl.Destroy();

	Super.Destroyed();
}

simulated function ReleaseFragEffect(class<fragment> FragType, texture FragSkin, vector Momentum, float DSize, int NumFrags) 
{
	local int i;
	local actor A, Toucher;
	local Fragment s;

	for (i=0 ; i<NumFrags ; i++) 
	{
		s = Spawn( FragType, Owner);
		s.CalcVelocity(Momentum/100,0);
		s.Skin = FragSkin;
		s.Texture = FragSkin;
		s.DrawScale = DSize*0.5+0.7*DSize*FRand();
		s.Style = STY_Translucent;
		s.bMeshEnviroMap = True;
	}

	Destroy();
}

defaultproperties
{
	DrawType=DT_Mesh
	RemoteRole=ROLE_DumbProxy
	bCollideActors=False
	bCollideWorld=False
	bProjTarget=False
	bBlockPlayers=False
	bBlockActors=False
	Buoyancy=30.000000
	bNetTemporary=False
	Physics=PHYS_None
	LifeSpan=0.000000
	bCollideWhenPlacing=False
	bStatic=False
	bStasis=False
	bPushable=True
	Mass=150.000000
	Buoyancy=250.000000
	bGameRelevant=True
	Physics=PHYS_Falling
}
