//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Copyright 2005-2008 Dead Cow Studios. All Rights Reserved.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Coder: Raven
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Changed Kicker.
class RJumpPad extends Triggers;
var(Advanced) bool bDebugJump;
var() Actor JumpTarget;
var() float JumpZModifier;
var() sound JumpSound;
var() name JumpClasses;
var() bool bRandomize;
var vector RealJumoVelocity;
replication
{
reliable if( Role == ROLE_Authority )
CalculateJumpVelocity;
}
simulated function PostBeginPlay()
{
if(JumpTarget == none) Destroy();
RealJumoVelocity = CalculateJumpVelocity();
}
simulated function Touch( actor Other )
{
local Actor A;
if (!Other.IsA(JumpClasses)) return;
PendingTouch = Other.PendingTouch;
Other.PendingTouch = self;
if( Event != '' )
foreach AllActors( class 'Actor', A, Event )
A.Trigger( Other, Other.Instigator );
}
function vector CalculateJumpVelocity()
{
local vector XYDir, JumpVelocity;
local float ZDiff, Time, GravityZ;
GravityZ = Region.Zone.ZoneGravity.Z;
XYDir = JumpTarget.Location - Location;
ZDiff = XYDir.Z;
Time = 2.5f + JumpZModifier * Sqrt(Abs(ZDiff/GravityZ));
JumpVelocity = XYDir/Time;
JumpVelocity = XYDir;
JumpVelocity.Z = ZDiff + JumpZModifier;
return JumpVelocity;
}
simulated function PostTouch( actor Other )
{
local bool bWasFalling;
local vector Push;
local float PMag;
if(bDebugJump)
{
RealJumoVelocity = CalculateJumpVelocity();
BroadCastMessage("X="@RealJumoVelocity.X@" Y="@RealJumoVelocity.Y@" Z="@RealJumoVelocity.Z);
}
bWasFalling = ( Other.Physics == PHYS_Falling );
if ( bRandomize )
{
PMag = VSize(RealJumoVelocity);
Push = PMag * Normal(RealJumoVelocity + 0.5 * PMag * VRand());
}
else
Push = RealJumoVelocity;
if ( Other.IsA('Bot') )
{
if ( bWasFalling )
Bot(Other).bJumpOffPawn = true;
Bot(Other).SetFall();
}
if(JumpSound != none) PlaySound(JumpSound);
Other.SetPhysics(PHYS_Falling);
Other.Velocity = Push;
}
defaultproperties
{
JumpClasses=Pawn
}