class testplayer extends TournamentMale;
[COLOR=red]
var bool bAntiBunnyHopping;
var int NoJumpingTime;
[/COLOR]
function PlayLanded(float impactVel)
{
impactVel = impactVel/JumpZ;
impactVel = 0.1 * impactVel * impactVel;
BaseEyeHeight = Default.BaseEyeHeight;
if ( impactVel > 0.17 )
PlayOwnedSound(LandGrunt, SLOT_Talk, FMin(5, 5 * impactVel),false,1200,FRand()*0.4+0.8);
if ( !FootRegion.Zone.bWaterZone && (impactVel > 0.01) )
PlayOwnedSound(Land, SLOT_Interact, FClamp(4 * impactVel,0.5,5), false,1000, 1.0);
if ( (impactVel > 0.06) || (GetAnimGroup(AnimSequence) == 'Jumping') || (GetAnimGroup(AnimSequence) == 'Ducking') )
{
if ( (Weapon == None) || (Weapon.Mass < 20) )
{
TweenAnim('LandSMFR', 0.12);
[COLOR=red]bAntiBunnyHopping=False;[/COLOR]
}
else
{
TweenAnim('LandLGFR', 0.12);
[COLOR=red]bAntiBunnyHopping=False;[/COLOR]
}
}
else if ( !IsAnimating() )
{
if ( GetAnimGroup(AnimSequence) == 'TakeHit' )
{
SetPhysics(PHYS_Walking);
AnimEnd();
[COLOR=red]bAntiBunnyHopping=False;[/COLOR]
}
else
{
if ( (Weapon == None) || (Weapon.Mass < 20) )
{
TweenAnim('LandSMFR', 0.12);
[COLOR=red]bAntiBunnyHopping=False;[/COLOR]
}
else
{
TweenAnim('LandLGFR', 0.12);
[COLOR=red]bAntiBunnyHopping=False;[/COLOR]
}
}
}
}
state PlayerWalking
{
ignores SeePlayer, HearNoise, Bump;
[COLOR=red]function Timer()
{
if(!bAntiBunnyHopping)
{
bCanJump=true;
bAntiBunnyHopping=true;
}
Disable('Timer');
}[/COLOR]
exec function FeignDeath()
{
if ( Physics == PHYS_Walking )
{
ServerFeignDeath();
Acceleration = vect(0,0,0);
GotoState('FeigningDeath');
}
}
function ServerFeignDeath()
{
local Weapon W;
W = Weapon;
PendingWeapon = None;
if ( Weapon != None )
Weapon.PutDown();
PendingWeapon = W;
GotoState('FeigningDeath');
}
function ZoneChange( ZoneInfo NewZone )
{
if (NewZone.bWaterZone)
{
setPhysics(PHYS_Swimming);
GotoState('PlayerSwimming');
}
}
function AnimEnd()
{
local name MyAnimGroup;
bAnimTransition = false;
if (Physics == PHYS_Walking)
{
if (bIsCrouching)
{
if ( !bIsTurning && ((Velocity.X * Velocity.X + Velocity.Y * Velocity.Y) < 1000) )
PlayDuck();
else
PlayCrawling();
}
else
{
MyAnimGroup = GetAnimGroup(AnimSequence);
if ((Velocity.X * Velocity.X + Velocity.Y * Velocity.Y) < 1000)
{
if ( MyAnimGroup == 'Waiting' )
PlayWaiting();
else
{
bAnimTransition = true;
TweenToWaiting(0.2);
}
}
else if (bIsWalking)
{
if ( (MyAnimGroup == 'Waiting') || (MyAnimGroup == 'Landing') || (MyAnimGroup == 'Gesture') || (MyAnimGroup == 'TakeHit') )
{
TweenToWalking(0.1);
bAnimTransition = true;
}
else
PlayWalking();
}
else
{
if ( (MyAnimGroup == 'Waiting') || (MyAnimGroup == 'Landing') || (MyAnimGroup == 'Gesture') || (MyAnimGroup == 'TakeHit') )
{
bAnimTransition = true;
TweenToRunning(0.1);
}
else
PlayRunning();
}
}
}
else
PlayInAir();
}
function Landed(vector HitNormal)
{
Global.Landed(HitNormal);
if (DodgeDir == DODGE_Active)
{
DodgeDir = DODGE_Done;
DodgeClickTimer = 0.0;
Velocity *= 0.1;
}
else
DodgeDir = DODGE_None;
}
function Dodge(eDodgeDir DodgeMove)
{
local vector X,Y,Z;
if ( bIsCrouching || (Physics != PHYS_Walking) )
return;
GetAxes(Rotation,X,Y,Z);
if (DodgeMove == DODGE_Forward)
Velocity = 1.5*GroundSpeed*X + (Velocity Dot Y)*Y;
else if (DodgeMove == DODGE_Back)
Velocity = -1.5*GroundSpeed*X + (Velocity Dot Y)*Y;
else if (DodgeMove == DODGE_Left)
Velocity = 1.5*GroundSpeed*Y + (Velocity Dot X)*X;
else if (DodgeMove == DODGE_Right)
Velocity = -1.5*GroundSpeed*Y + (Velocity Dot X)*X;
Velocity.Z = 160;
PlayOwnedSound(JumpSound, SLOT_Talk, 1.0, true, 800, 1.0 );
PlayDodge(DodgeMove);
DodgeDir = DODGE_Active;
SetPhysics(PHYS_Falling);
}
function ProcessMove(float DeltaTime, vector NewAccel, eDodgeDir DodgeMove, rotator DeltaRot)
{
local vector OldAccel;
OldAccel = Acceleration;
Acceleration = NewAccel;
bIsTurning = ( Abs(DeltaRot.Yaw/DeltaTime) > 5000 );
if ( (DodgeMove == DODGE_Active) && (Physics == PHYS_Falling) )
DodgeDir = DODGE_Active;
else if ( (DodgeMove != DODGE_None) && (DodgeMove < DODGE_Active) )
Dodge(DodgeMove);
if ( bPressedJump )
DoJump();
if ( (Physics == PHYS_Walking) && (GetAnimGroup(AnimSequence) != 'Dodge') )
{
if (!bIsCrouching)
{
if (bDuck != 0)
{
bIsCrouching = true;
PlayDuck();
}
}
else if (bDuck == 0)
{
OldAccel = vect(0,0,0);
bIsCrouching = false;
TweenToRunning(0.1);
}
if ( !bIsCrouching )
{
if ( (!bAnimTransition || (AnimFrame > 0)) && (GetAnimGroup(AnimSequence) != 'Landing') )
{
if ( Acceleration != vect(0,0,0) )
{
if ( (GetAnimGroup(AnimSequence) == 'Waiting') || (GetAnimGroup(AnimSequence) == 'Gesture') || (GetAnimGroup(AnimSequence) == 'TakeHit') )
{
bAnimTransition = true;
TweenToRunning(0.1);
}
}
else if ( (Velocity.X * Velocity.X + Velocity.Y * Velocity.Y < 1000)
&& (GetAnimGroup(AnimSequence) != 'Gesture') )
{
if ( GetAnimGroup(AnimSequence) == 'Waiting' )
{
if ( bIsTurning && (AnimFrame >= 0) )
{
bAnimTransition = true;
PlayTurning();
}
}
else if ( !bIsTurning )
{
bAnimTransition = true;
TweenToWaiting(0.2);
}
}
}
}
else
{
if ( (OldAccel == vect(0,0,0)) && (Acceleration != vect(0,0,0)) )
PlayCrawling();
else if ( !bIsTurning && (Acceleration == vect(0,0,0)) && (AnimFrame > 0.1) )
PlayDuck();
}
}
}
event PlayerTick( float DeltaTime )
{
if ( bUpdatePosition )
ClientUpdatePosition();
PlayerMove(DeltaTime);
}
function PlayerMove( float DeltaTime )
{
local vector X,Y,Z, NewAccel;
local EDodgeDir OldDodge;
local eDodgeDir DodgeMove;
local rotator OldRotation;
local float Speed2D;
local bool bSaveJump;
local name AnimGroupName;
GetAxes(Rotation,X,Y,Z);
aForward *= 0.4;
aStrafe *= 0.4;
aLookup *= 0.24;
aTurn *= 0.24;
// Update acceleration.
NewAccel = aForward*X + aStrafe*Y;
NewAccel.Z = 0;
// Check for Dodge move
if ( DodgeDir == DODGE_Active )
DodgeMove = DODGE_Active;
else
DodgeMove = DODGE_None;
if (DodgeClickTime > 0.0)
{
if ( DodgeDir < DODGE_Active )
{
OldDodge = DodgeDir;
DodgeDir = DODGE_None;
if (bEdgeForward && bWasForward)
DodgeDir = DODGE_Forward;
if (bEdgeBack && bWasBack)
DodgeDir = DODGE_Back;
if (bEdgeLeft && bWasLeft)
DodgeDir = DODGE_Left;
if (bEdgeRight && bWasRight)
DodgeDir = DODGE_Right;
if ( DodgeDir == DODGE_None)
DodgeDir = OldDodge;
else if ( DodgeDir != OldDodge )
DodgeClickTimer = DodgeClickTime + 0.5 * DeltaTime;
else
DodgeMove = DodgeDir;
}
if (DodgeDir == DODGE_Done)
{
DodgeClickTimer -= DeltaTime;
if (DodgeClickTimer < -0.35)
{
DodgeDir = DODGE_None;
DodgeClickTimer = DodgeClickTime;
}
}
else if ((DodgeDir != DODGE_None) && (DodgeDir != DODGE_Active))
{
DodgeClickTimer -= DeltaTime;
if (DodgeClickTimer < 0)
{
DodgeDir = DODGE_None;
DodgeClickTimer = DodgeClickTime;
}
}
}
AnimGroupName = GetAnimGroup(AnimSequence);
if ( (Physics == PHYS_Walking) && (AnimGroupName != 'Dodge') )
{
//if walking, look up/down stairs - unless player is rotating view
if ( !bKeyboardLook && (bLook == 0) )
{
if ( bLookUpStairs )
ViewRotation.Pitch = FindStairRotation(deltaTime);
else if ( bCenterView )
{
ViewRotation.Pitch = ViewRotation.Pitch & 65535;
if (ViewRotation.Pitch > 32768)
ViewRotation.Pitch -= 65536;
ViewRotation.Pitch = ViewRotation.Pitch * (1 - 12 * FMin(0.0833, deltaTime));
if ( Abs(ViewRotation.Pitch) < 1000 )
ViewRotation.Pitch = 0;
}
}
Speed2D = Sqrt(Velocity.X * Velocity.X + Velocity.Y * Velocity.Y);
//add bobbing when walking
if ( !bShowMenu )
CheckBob(DeltaTime, Speed2D, Y);
}
else if ( !bShowMenu )
{
BobTime = 0;
WalkBob = WalkBob * (1 - FMin(1, 8 * deltatime));
}
// Update rotation.
OldRotation = Rotation;
UpdateRotation(DeltaTime, 1);
if ( bPressedJump && (AnimGroupName == 'Dodge') )
{
bSaveJump = true;
bPressedJump = false;
}
else
bSaveJump = false;
if ( Role < ROLE_Authority ) // then save this move and replicate it
ReplicateMove(DeltaTime, NewAccel, DodgeMove, OldRotation - Rotation);
else
ProcessMove(DeltaTime, NewAccel, DodgeMove, OldRotation - Rotation);
bPressedJump = bSaveJump;
}
function BeginState()
{
if ( Mesh == None )
SetMesh();
WalkBob = vect(0,0,0);
DodgeDir = DODGE_None;
bIsCrouching = false;
bIsTurning = false;
bPressedJump = false;
if (Physics != PHYS_Falling) SetPhysics(PHYS_Walking);
if ( !IsAnimating() )
PlayWaiting();
[COLOR=red]if(bAntiBunnyHopping==false)
{
bCanJump=false;
Enable('Timer');
SetTimer(NoJumpingTime,false);
} [/COLOR]
}
function EndState()
{
WalkBob = vect(0,0,0);
bIsCrouching = false;
}
}
defaultproperties
{
[COLOR=red]NoJumpingTime=2[/COLOR]
JumpZ=200
FaceSkin=3
FixedSkin=2
TeamSkin2=1
DefaultSkinName="SoldierSkins.blkt"
DefaultPackage="SoldierSkins."
LandGrunt=Sound'Botpack.MaleSounds.(All).land10'
CarcassType=Class'Botpack.TMale2Carcass'
SelectionMesh="Botpack.SelectionMale2"
SpecialMesh="Botpack.TrophyMale2"
MenuName="Nisse"
VoiceType="BotPack.VoiceMaleTwo"
Mesh=LodMesh'Botpack.Soldier'
}