Also speeds up and slides without reason like when you use the standard player and have the realistic jumping on.
Is this a bug from source coding (means out of my abilities) of a pawn.ccp -like file or does the script can fix it with appropriate commands?
Also,the jumping is worse than the standard Player,i can not change falling direction after i hit jump like he can do,and would like an example for how to do that,please.
You can try the script if you want with a scripted player and start to jump under a platform box that is low enough for the player head to hit it.
it is the old playercontrol script ,modified slightly to the move left and right direction.
the pawn i first used it had all idle animations,but it does not matter to the bug anyway.
Code: Select all
{
//Attributes
FIREEFFECT [SlowSmoke] // muzzleflash effect
GROUP [Friendly] // Pawn Group - must be targetted by enemies
PLAYERSPEED [90] // Walk Speed
HEALTHATTRIB [health] // health attribute given to pawn
HEALTHAMOUNT [500] // amount of health given to pawn
BOX [24] // Box width
WEAPONS [3]
{
0 [MartialArts]
{
MODE [melee]
STYLE [1]
SPEED [8]
POWER [5]
MOVES [0]
}
1 [Pistol]
{
MODE [ranged]
STYLE [SEMI]
POWER [0]
SPEED [8]
AMMO [pistolbullet]
}
2 [AssaultRifle]
{
MODE [ranged]
STYLE [SEMI]
POWER [0]
SPEED [20]
AMMO [riflebullet]
}
3 [Dwarfaxe1]
{
MODE [melee]
STYLE [SEMI]
SPEED [12]
POWER [25]
MOVES [1]
}
}
//Animation
IDLEANIM [Idle] // Idle AnimationSpeed
SHOOTANIM [Idle] // Shoot anim
MELEEANIM
{
SWORD [0]
{
MOVES
{
0 [Idle]
1 [Idle]
}
}
BAREHAND [0]
{
MOVES
{
0 [Idle]
}
}
}
WALKANIM [Idle] // Walk anim
RUNANIM [Idle] // Run anim
BACKANIM [Idle] // walk back anim
STRAFELEFT [Idle] // Strafe left anim
STRAFERIGHT [Idle] // Strafe right anim
INTERANIM [Idle] // Pawn interact anim
JUMPANIM [Idle] // Jump anim
JUMPSTARTANIM [Idle] // Jump initial anim
FALLANIM [Idle] // Falling anim
LANDANIM [Idle] // Landing anim
DEATHANIM [Idle] // Death Anim
ROOTBONE [DWARF FIGHTER BIP01] // Pawn root bone
WEAPONHAND [DWARF FIGHTER BIP01 R HAND] // Pawn weapon bone
//Input Keys
K_INTER [73] // INTERACT KEY - RIGHT MOUSE
K_FIRE [72] // FIRE KEY - LEFT MOUSE
K_UP [15] // FORWARD - W
K_DOWN [27] // BACK - S
K_LEFT [26] // LEFT - A
K_RIGHT [28] // RIGHT - D
K_RUN [36] // RUN - LEFT SHIFT KEY
K_JUMP [46] // JUMP - SPACEBAR
K_WEAP [57] // WEAPON CHANGE - LEFT ARROW
K_DEBUG [59] // DEBUG - F1
//Control variables
ANIM [string] // Do Not Edit
ANC [0] // Do Not Edit
LASTANC [0] // Do Not Edit
DIR [0] // Do Not Edit
AT [0.5] // Do Not Edit
INTER [string] // Do Not Edit
TM [0] // Do Not Edit
SPEED [0] // Do Not Edit
TEMP [0] //
CURAMMO [0] //
CURWEAPON [0]// Current weapon selected
MODE [string] //
STYLE [string] //
MOVES [0] //
ATTSPEED [0.8] // Speed of firing/striking or rate of auto shots
POWER [5] // Melee power
AMMO [string] // Ranged ammo type
PCURDIR [0] // Temps for iso and s-s
DIRHANDLEA [0] //
DIRHANDLEB [0] //
DIRCOUNT [0] //
DIROFFSET [0] // Camera-to-movement realignment value for rotated iso views
FALLING [false] //
FALLSTART [0] //
FTSET [false] //
LANDSET [false] //
JUMPING [false] //
JUMPFORCE [80] //
Spawn[()
{
Console(true);
BoxWidth(BOX);
SetGroup(GROUP);
AttributeOrder(HEALTHATTRIB,HEALTHAMOUNT,"Die");
SetWeapon(WEAPONS[CURWEAPON]);
LowLevel("Setup");
}]
ChangeWeapon[()
{
CURWEAPON = CURWEAPON + 1;
if(CURWEAPON > WEAPONS)
{
RemoveWeapon();
CURWEAPON = 0;
}
else
{
SetWeapon(WEAPONS[CURWEAPON]);
}
LowLevel("ConfigWeapon");
}]
ConfigWeapon[()
{
MODE = StringCopy(WEAPONS[CURWEAPON].MODE);
STYLE = StringCopy(WEAPONS[CURWEAPON].STYLE);
TEMP = Integer(WEAPONS[CURWEAPON].SPEED);
ATTSPEED = TEMP/10;
if(MODE = "melee")
{
POWER = Integer(WEAPONS[CURWEAPON].POWER);
MOVES = Integer(WEAPONS[CURWEAPON].MOVES);
}
if(MODE = "ranged")
{
AMMO = StringCopy(WEAPONS[CURWEAPON].AMMO);
}
SetPlayerWeapon(CURWEAPON+1);
TM = 0;
self.think ="RunPlayer";
}]
Setup[()
{
AttachCamera();
self.yaw_speed=18000;
AnimateHold(IDLEANIM);
ANIM=StringCopy(IDLEANIM);
MODE=StringCopy("melee");
STYLE=StringCopy("BAREHAND");
AMMO=StringCopy("pistolbullet");
ANC=0;
LASTANC=0;
TM=self.time;
self.think="RunPlayer";
}]
RunPlayer[()
{
PlayerRender(false);
if(IsKeyDown(K_DEBUG))
{
//debug(self.key_pressed);
debug(ATTSPEED);
debug(MODE);
debug(STYLE);
debug(AMMO);
debug(POWER);
debug(SPEED);
debug(MOVES);
debug(ANIM);
}
//handle health status
SetAttribute("health",self.health);
if(self.health < 1)
{
HighLevel("Die");
return 0;
}
FTSET = false;
JUMPCOUNTER = 0;
if(self.IsFalling)
{
self.think="Fall";
return 0;
}
if(JUMPING)
{
self.think="JumpUp";
return 0;
}
DIR=0; // Default straight
SPEED=0; //Default - no motion
AT=0.1; //Default
ANC=0; //Default
AnimationSpeed(1); //Default
DIRCOUNT=0;
DIRHANDLEA=0;
DIRHANDLEB=0;
//handle controls
if(IsKeyDown(K_INTER))
{
//strike/interact
AnimateBlend(INTERANIM,0.25);
self.think="Interact";
return 0;
}
if(IsKeyDown(K_WEAP))
{
HighLevel("ChangeWeapon");
return 0;
}
if(IsKeyDown(K_UP))
{
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
if(DIRCOUNT = 0)
{
DIRHANDLEA=0;
DIRCOUNT = DIRCOUNT + 1;
}
else
{
if(DIRCOUNT = 1)
{
DIRHANDLEB=0;
DIRCOUNT = DIRCOUNT + 1;
}
}
}
if(IsKeyDown(K_DOWN))
{
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
if(DIRCOUNT = 0)
{
DIRHANDLEA = 180;
DIRCOUNT = DIRCOUNT + 1;
}
else
{
if(DIRCOUNT = 1)
{
DIRHANDLEB = 180;
DIRCOUNT = DIRCOUNT + 1;
}
}
}
if(IsKeyDown(K_LEFT))
{
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
if(DIRCOUNT = 0)
{
DIRHANDLEA = 90;
DIRCOUNT = DIRCOUNT + 1;
}
else
{
if(DIRCOUNT = 1)
{
DIRHANDLEB = 90;
DIRCOUNT = DIRCOUNT + 1;
}
}
}
if(IsKeyDown(K_RIGHT))
{
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
if(DIRCOUNT = 0)
{
DIRHANDLEA = 270;
DIRCOUNT = DIRCOUNT + 1;
}
else
{
if(DIRCOUNT = 1)
{
DIRHANDLEB = 270;
DIRCOUNT = DIRCOUNT + 1;
}
}
}
if(IsKeyDown(K_JUMP))
{
ANIM=StringCopy(JUMPSTARTANIM);
AT=0.1;
ANC=8;
JUMPING=true;
}
if(IsKeyDown(K_FIRE))
{
//attack
if(ANC < 1)
{
if(MODE = "ranged")
{
ANC=1;
if(STYLE = "SEMI")
{
CURAMMO = GetAttribute(AMMO);
if((self.time > TM+ATTSPEED) and (CURAMMO > 0))
{
SetAttribute(AMMO, CURAMMO - 1);
ANIM=StringCopy(SHOOTANIM);
AT = 0.3;
FireProjectileBlind(AMMO,WEAPONHAND,0,0,0,"health");
AddExplosion(FIREEFFECT,WEAPONHAND,0,0,0);
TM=self.time;
}
}
else
{
ANIM=StringCopy(SHOOTANIM);
AnimationSpeed(3.6);
AT = 0.1;
CURAMMO = GetAttribute(AMMO);
for AUTOFIRE = 1 to ATTSPEED
{
if(CURAMMO > 0)
{
SetAttribute(AMMO, CURAMMO - 1);
FireProjectileBlind(AMMO,WEAPONHAND,0,0,0,"health");
AddExplosion(FIREEFFECT,WEAPONHAND,0,0,0);
}
}
}
}
if(MODE = "melee")
{
ANC = 1;
ANIM = StringCopy(MELEEANIM[Integer(STYLE)].MOVES[random(0,MOVES+1)]);
}
}
}
if(ANC < 1)
{
//no button
ANIM=StringCopy(IDLEANIM);
AT=0.5;
}
if(IsKeyDown(K_RUN) and (ANC = 2))
{
//left shift key - toggle run
ANIM = StringCopy(RUNANIM);
AT = 0.3;
ANC = 3;
SPEED=SPEED+(SPEED/2);
}
//handle animations
if((DIRHANDLEA = 0) and (DIRHANDLEB = 270))
{
DIRHANDLEA = 360;
}
if(DIRCOUNT > 0)
{
PCURDIR = Integer((DIRHANDLEA + DIRHANDLEB)/DIRCOUNT);
self.ideal_yaw = ConvertDegrees(PCURDIR + DIROFFSET);
ChangeYaw();
}
if(Integer(LASTANC) != Integer(ANC))
{
AnimateBlend(ANIM,AT);
}
LASTANC=Integer(ANC);
if(self.animate_at_end)
{
AnimateHold(ANIM);
}
//handle motions
walkmove(self.current_yaw + DIR,SPEED);
}]
Interact[()
{
if(self.animate_at_end)
{
INTER=TraceToActor(ROOTBONE,0,0,32);
if(INTER != "FALSE")
{
SetEventState(INTER # "Trigger",true);
}
self.think="RunPlayer";
TM = 0;
return 0;
}
}]
Fall[()
{
if(ANC > 1)
{
ForceForward(SPEED);
ANC = 0;
}
if(not FTSET)
{
FALLSTART = self.time;
FTSET = true;
}
if((self.time - FALLSTART) > 0.5)
{
AnimateHold(FALLANIM);
self.think="Land";
return 0;
}
if(not self.IsFalling)
{
self.think="RunPlayer";
return 0;
}
}]
JumpUp[()
{
if(ANC > 1)
{
ForceForward(SPEED);
ANC = 0;
}
if(JUMPING)
{
ForceUp(JUMPFORCE);
AnimationSpeed(3);
AnimateBlend(JUMPANIM,0.1);
JUMPING=false;
}
if(self.IsFalling)
{
self.think="Fall";
return 0;
}
}]
Land[()
{
if(not self.IsFalling)
{
AnimationSpeed(3);
AnimateHold(LANDANIM);
LANDSET= false;
self.think = "Delay";
TM = self.time;
return 0;
}
}]
Delay[()
{
if((self.time - TM) > 0.0)
{
self.think="RunPlayer";
return 0;
}
}]
Die[()
{
AnimateStop(DEATHANIM,0,"");
}]
}