I'd like ko change the player movement, so i usualy walk, but if I press shift, im run.
I tried this in the HumanPlayer.cpp:
Code: Select all
// Update Bank
State.Bank+=PlayerCommands[PCNr].DeltaBank;
VectorT WishVelocity;
bool WishJump=false;
[color=#4000FF]char Runspon=0;
const double VelX =3000.0*LookupTables::Angle16ToSin[State.Heading]; // 6000 == Client.MoveSpeed
const double VelY =3000.0*LookupTables::Angle16ToCos[State.Heading]; // 6000 == Client.MoveSpeed[/color]
const unsigned long Keys =PlayerCommands[PCNr].Keys;
if (Keys & PCK_MoveForward ) WishVelocity= VectorT( VelX, VelY, 0);
if (Keys & PCK_MoveBackward) WishVelocity=WishVelocity+VectorT(-VelX, -VelY, 0);
if (Keys & PCK_StrafeLeft ) WishVelocity=WishVelocity+VectorT(-VelY, VelX, 0);
if (Keys & PCK_StrafeRight ) WishVelocity=WishVelocity+VectorT( VelY, -VelX, 0);
if (Keys & PCK_CenterView ) { State.Pitch=0; State.Bank=0; }
if (Keys & PCK_Jump ) WishJump=true;
// if (Keys & PCK_Duck ) ;
[color=#4000FF]if (Keys & PCK_Walk )
{
WishVelocity=scale(WishVelocity, 2.0); //Run
Runspon=1;
}[/color]
VectorT WishVelLadder;
const double ViewLadderZ=-LookupTables::Angle16ToSin[State.Pitch];
const double ViewLadderY= LookupTables::Angle16ToCos[State.Pitch];
const VectorT ViewLadder =scale(VectorT(ViewLadderY*LookupTables::Angle16ToSin[State.Heading], ViewLadderY*LookupTables::Angle16ToCos[State.Heading], ViewLadderZ), 1900.0);
// TODO: Also take LATERAL movement into account.
// TODO: All this needs a HUGE clean-up! Can probably put a lot of this stuff into Physics::MoveHuman.
if (Keys & PCK_MoveForward ) WishVelLadder=WishVelLadder+ViewLadder;
if (Keys & PCK_MoveBackward) WishVelLadder=WishVelLadder-ViewLadder;
if (Keys & PCK_Walk ) WishVelLadder=scale(WishVelLadder, 2.0);
/*if (Clients[ClientNr].move_noclip)
{
// This code was simply changed and rewritten until it "worked".
// May still be buggy anyway.
double RadPitch=double(State.Pitch)/32768.0*3.141592654;
double Fak =VectorDot(WishVelocity, VectorT(LookupTables::Angle16ToSin[State.Heading], LookupTables::Angle16ToCos[State.Heading], 0));
WishVelocity.x*=cos(RadPitch);
WishVelocity.y*=cos(RadPitch);
WishVelocity.z=-sin(RadPitch)*Fak;
State.Origin=State.Origin+scale(WishVelocity, PlayerCommands[PCNr].FrameTime);
// TODO: If not already done on state change (--> "noclip"), set the model sequence to "swim". ;-)
}
else */
{
VectorT XYVel =State.Velocity; XYVel.z=0;
double OldSpeed =length(XYVel);
bool OldWishJump=(State.Flags & Flags_OldWishJump) ? true : false;
Physics::MoveHuman(State, ClipModel, PlayerCommands[PCNr].FrameTime, WishVelocity, WishVelLadder, WishJump, OldWishJump, 470.0, GameWorld->GetClipWorld());
ClipModel.SetOrigin(State.Origin);
ClipModel.Register();
// The physics world will pick-up our new origin at the next opportunity from getWorldTransform().
if (OldWishJump) State.Flags|= Flags_OldWishJump;
else State.Flags&=~Flags_OldWishJump;
XYVel=State.Velocity;
XYVel.z=0;
double NewSpeed=length(XYVel);
[color=#4000FF] if (OldSpeed<=1000.0 && NewSpeed>1000.0)
{
if (Runspon=1) State.ModelSequNr=3;
else State.ModelSequNr=4;
}[/color]
if (OldSpeed>=1000.0 && NewSpeed<1000.0) State.ModelSequNr=1;
}
// GameWorld->ModelAdvanceFrameTime() is called on client side in Draw().