// A helicopter vehicle (Created by .:..: 9.1.2008)
Class ChopperPhys extends Vehicle;

var() float MaxAirSpeed,YawTurnSpeed;
var float CurrentYawSpeed,NextCutTime;
var const float MaxYawRates[2];
var ChopperRotor MyRotor;
var() class<ChopperRotor> ChopperRotorClass;
var() vector RotorOffset,RotorSize;
var int RotorYaw;
var bool bHasRotorDmg;

simulated function PostBeginPlay()
{
	Super.PostBeginPlay();
	if( Level.NetMode!=NM_DedicatedServer && ChopperRotorClass!=None )
		MyRotor = ChopperRotor(AddAttachment(ChopperRotorClass));
	if( Level.NetMode!=NM_Client && ChopperRotorClass!=None && RotorSize!=vect(0,0,0) )
		bHasRotorDmg = True;
}
simulated singular function HitWall( vector HitNormal, Actor Wall )
{
	local vector V;

	MoveSmooth(HitNormal);
	if( bDriving )
	{
		Velocity = SetUpNewMVelocity(Velocity,HitNormal,0.05);
		Return;
	}
	V = SetUpNewMVelocity(Velocity,HitNormal,1);
	if( !bOnGround && HitNormal.Z>0.8 )
	{
		if( VSize(Normal(V)-Normal(Velocity))>0.85 && VSize(Velocity)>450 )
		{
			Velocity = SetUpNewMVelocity(Velocity,HitNormal,0.15);
			Return;
		}
		bOnGround = True;
		ActualFloorNormal = HitNormal;
		Velocity = SetUpNewMVelocity(Velocity,HitNormal,0);
		Return;
	}
	if( VSize(Normal(V)-Normal(Velocity))>0.85 || (bOnGround && !CanYawUpTo(Rotation,TransformForGroundRot(VehicleYaw,HitNormal),1500)) )
	{
		if( bOnGround && CanGetOver(35,0.85) )
			Return;
		bOnGround = False;
		Velocity = SetUpNewMVelocity(Velocity,HitNormal,0.5);
	}
	else
	{
		Velocity = SetUpNewMVelocity(Velocity,HitNormal,0);
		ActualFloorNormal = HitNormal;
		bOnGround = True;
	}
}
simulated function vector GetMovementSpeeds()
{
	local vector V;

	V = (Velocity << Rotation);
	V.Z = 0;
	Return Normal(V);
}

defaultproperties
{
	MAxAirSpeed=1400
	WAccelRate=900
	YawTurnSpeed=18000
	Mesh=Mesh'WoodenBoxM'
	CollisionHeight=22
	CollisionRadius=22
	TranslatorDescription="This is a chopper vehicle, you can fire different firemodes using [Fire] and [AltFire] buttons. To move higher or lover use [Jump] and [Crouch] buttons and to move around use movement keys. To leave this vehicle press [ThrowWeapon] key."
	Health=300
	VehicleName="Helicopter"
	CurrentYawSpeed=5
	MaxYawRates(0)=6000
	MaxYawRates(1)=-6000
	VehicleKeyInfoStr="Chopper craft keys:|%MoveForward%,%MoveBackward% to accelerate/deaccelerate|%StrafeLeft%, %StrafeRight% to strafe|%Jump%, %Duck% to move up/down|%Fire% to fire, %AltFire% to alt fire|Number keys to switch seats|%ThrowWeapon% to exit the vehicle"
}
