I intend to alter the bool Dodge and/or the bool PerformDodge functions, so as to make the playyer dodge in the X,Y AND Z directions that the player is aiming at, after pressing front-front. IE: if the player is aiming upwards and presses FF, the player does not just dodge forward, but upwards as well.
This guess that I can do this by simply altering the methods so as to encompass the Z axis as well as the X and Y
I made a mutator extension and a gamerules extension to do this.
here's the code for my gamerules extension, with reference to the UnrealPawn class:
Code: Select all
class Dodge1GameRules extends GameRules
function bool Dodge(eDoubleClickDir DoubleClickMove)
{
local vector X,Y,Z;
if ( bIsCrouched || bWantsToCrouch || (Physics != PHYS_Walking) )
return false;
GetAxes(Rotation,X,Y,Z);
if (DoubleClickMove == DCLICK_Forward)
Velocity = 1.5*GroundSpeed*X + (Velocity Dot Y)*Y;
else if (DoubleClickMove == DCLICK_Back)
Velocity = -1.5*GroundSpeed*X + (Velocity Dot Y)*Y;
else if (DoubleClickMove == DCLICK_Left)
Velocity = 1.5*GroundSpeed*Y + (Velocity Dot X)*X;
else if (DoubleClickMove == DCLICK_Right)
Velocity = -1.5*GroundSpeed*Y + (Velocity Dot X)*X;
Velocity.Z = 210;
CurrentDir = DoubleClickMove;
SetPhysics(PHYS_Falling);
return true;
}
defaultproperties
{
}
And here's the code for my gamerules extension, with reference to the xPawn class:
Code: Select all
class Dadge2GameRules extends GameRules
function bool Dodge(eDoubleClickDir DoubleClickMove)
{
local vector X,Y,Z, TraceStart, TraceEnd, Dir, Cross, HitLocation, HitNormal;
local Actor HitActor;
local rotator TurnRot;
if ( bIsCrouched || bWantsToCrouch || (Physics != PHYS_Walking && Physics != PHYS_Falling) )
return false;
TurnRot.Yaw = Rotation.Yaw;
GetAxes(TurnRot,X,Y,Z);
if ( Physics == PHYS_Falling )
{
if ( !bCanWallDodge )
return false;
if (DoubleClickMove == DCLICK_Forward)
TraceEnd = -X;
else if (DoubleClickMove == DCLICK_Back)
TraceEnd = X;
else if (DoubleClickMove == DCLICK_Left)
TraceEnd = Y;
else if (DoubleClickMove == DCLICK_Right)
TraceEnd = -Y;
TraceStart = Location - CollisionHeight*Vect(0,0,1) + TraceEnd*CollisionRadius;
TraceEnd = TraceStart + TraceEnd*32.0;
HitActor = Trace(HitLocation, HitNormal, TraceEnd, TraceStart, false, vect(1,1,1));
if ( (HitActor == None) || (!HitActor.bWorldGeometry && (Mover(HitActor) == None)) )
return false;
}
if (DoubleClickMove == DCLICK_Forward)
{
Dir = vect(X,Y,Z);
Cross = vect(0,0,0);
}
else if (DoubleClickMove == DCLICK_Back)
{
Dir = -1 * X;
Cross = Y;
}
else if (DoubleClickMove == DCLICK_Left)
{
Dir = -1 * Y;
Cross = X;
}
else if (DoubleClickMove == DCLICK_Right)
{
Dir = Y;
Cross = X;
}
if ( AIController(Controller) != None )
Cross = vect(0,0,0);
return PerformDodge(DoubleClickMove, Dir,Cross);
}
function bool PerformDodge(eDoubleClickDir DoubleClickMove, vector Dir, vector Cross)
{
local float VelocityZ;
local name Anim;
if ( Physics == PHYS_Falling )
{
if (DoubleClickMove == DCLICK_Forward)
Anim = WallDodgeAnims[0];
else if (DoubleClickMove == DCLICK_Back)
Anim = WallDodgeAnims[1];
else if (DoubleClickMove == DCLICK_Left)
Anim = WallDodgeAnims[2];
else if (DoubleClickMove == DCLICK_Right)
Anim = WallDodgeAnims[3];
if ( PlayAnim(Anim, 1.0, 0.1) )
bWaitForAnim = true;
AnimAction = Anim;
TakeFallingDamage();
if (Velocity.Z < -DodgeSpeedZ*0.5)
Velocity.Z += DodgeSpeedZ*0.5;
}
VelocityZ = Velocity.Z;
Velocity = DodgeSpeedFactor*GroundSpeed*Dir + (Velocity Dot Cross)*Cross;
if ( !bCanDodgeDoubleJump )
MultiJumpRemaining = 0;
if ( bCanBoostDodge || (Velocity.Z < -100) )
Velocity.Z = VelocityZ + DodgeSpeedZ;
else
Velocity.Z = DodgeSpeedZ;
CurrentDir = DoubleClickMove;
SetPhysics(PHYS_Falling);
PlayOwnedSound(GetSound(EST_Dodge), SLOT_Pain, GruntVolume,,80);
return true;
}
defaultproperties
{
}
Now I'm not sure if what I've done is going to work or is going to cause my computer to erupt in fountain of lava. Nor do I know where I am supposed to put all of this. So please help...
