Hi, i had this old keyall script which emulated mario jump ( when you tap the button character makes small jump and when you hold button longer then character makes long jump + you can jump first then move left or right and you can move in midair) but that script didnt worked all the time, sometimes it made long regular jump even when i tapped the button fast.
Is there any new method to achieve platformer style jump ? With some kind of time release or something so it always knows that i just tap the button and makes small jump.
Here the script :
Is there any new method to achieve platformer style jump ? With some kind of time release or something so it always knows that i just tap the button and makes small jump.
Here the script :
Code:
void main(){
/*
Damon Vaughn Caskey
06/25/2009
Capture keystrokes and perform actions accordingly.
*/
int iPlIndex = getlocalvar("player"); //Player index.
void vSelf = getplayerproperty(iPlIndex, "entity"); //Get calling entity.
int iFIdl = getentityproperty(vSelf, "aiflag", "idling"); //Self idling?
int iFAtk = getentityproperty(vSelf, "aiflag", "attacking"); //Self attacking (freespecial, jumpattack, follow, or attack)?
int iFJmp = getentityproperty(vSelf, "aiflag", "jumping"); //Self jumping?
int iXDir = getentityproperty(vSelf, "xdir"); //X velocity.
int iTime = openborvariant("elapsed_time"); //Current time.
int iAni; //Current animation.
int iFrame; //Current animation frame.
float fTossV; //Vertical speed.
float fXDir; //Horizontal speed.
float fZDir; //Z axis speed.
void vTarget; //Opponent.
/* int iKUpH = playerkeys(iPlIndex, 0, "moveup"); //Hold "Up".
int iKDnH = playerkeys(iPlIndex, 0, "movedown"); //Hold "Down".
int iKLtH = playerkeys(iPlIndex, 0, "moveleft"); //Hold "Left".
int iKRtH = playerkeys(iPlIndex, 0, "moveright"); //Hold "Right".
int iKAtkH = playerkeys(iPlIndex, 0, "attack"); //Hold "Attack".
int iKAtk2H = playerkeys(iPlIndex, 0, "attack2"); //Hold "Attack2".
int iKAtk3H = playerkeys(iPlIndex, 0, "attack3"); //Hold "Attack3".
int iKAtk4H = playerkeys(iPlIndex, 0, "attack4"); //Hold "Attack4".
int iKJmpH = playerkeys(iPlIndex, 0, "jump"); //Hold "Jump".
int iKSpH = playerkeys(iPlIndex, 0, "special"); //Hold "Special".
int iKStH = playerkeys(iPlIndex, 0, "start"); //Hold "Start".
int iKEscH = playerkeys(iPlIndex, 0, "escape"); //Hold "Escape".
int iKSsH = playerkeys(iPlIndex, 0, "SCREENSHOT"); //Hold "Screenshot".
int iKAnyH = playerkeys(iPlIndex, 0, "ANYBUTTON"); //Hold any key.
int iKUp = playerkeys(iPlIndex, 1, "moveup"); //Press "Up".
int iKDn = playerkeys(iPlIndex, 1, "movedown"); //Press "Down".
*/ int iKLt = playerkeys(iPlIndex, 1, "moveleft"); //Press "Left".
int iKRt = playerkeys(iPlIndex, 1, "moveright"); //Press "Right".
/* int iKAtk = playerkeys(iPlIndex, 1, "attack"); //Press "Attack".
int iKAtk2 = playerkeys(iPlIndex, 1, "attack2"); //Press "Attack2".
int iKAtk3 = playerkeys(iPlIndex, 1, "attack3"); //Press "Attack3".
int iKAtk4 = playerkeys(iPlIndex, 1, "attack4"); //Press "Attack4".
int iKJmp = playerkeys(iPlIndex, 1, "jump"); //Press "Jump".
int iKSp = playerkeys(iPlIndex, 1, "special"); //Press "Special".
int iKSt = playerkeys(iPlIndex, 1, "start"); //Press "Start".
int iKEsc = playerkeys(iPlIndex, 1, "escape"); //Press "Escape".
int iKSs = playerkeys(iPlIndex, 1, "SCREENSHOT"); //Press "Screenshot".
int iKAny = playerkeys(iPlIndex, 1, "ANYBUTTON"); //Press any key.
int iKUpR = playerkeys(iPlIndex, 2, "moveup"); //Release "Up".
int iKDnR = playerkeys(iPlIndex, 2, "movedown"); //Release "Down".
*/ int iKLtR = playerkeys(iPlIndex, 2, "moveleft"); //Release "Left".
int iKRtR = playerkeys(iPlIndex, 2, "moveright"); //Release "Right".
/* int iKAtkR = playerkeys(iPlIndex, 2, "attack"); //Release "Attack".
int iKAtk2R = playerkeys(iPlIndex, 2, "attack2"); //Release "Attack2".
int iKAtk3R = playerkeys(iPlIndex, 2, "attack3"); //Release "Attack3".
int iKAtk4R = playerkeys(iPlIndex, 2, "attack4"); //Release "Attack4".
*/ int iKJmpR = playerkeys(iPlIndex, 2, "jump"); //Release "Jump".
/* int iKSpR = playerkeys(iPlIndex, 2, "special"); //Release "Special".
int iKStR = playerkeys(iPlIndex, 2, "start"); //Release "Start".
int iKEscR = playerkeys(iPlIndex, 2, "escape"); //Release "Escape".
int iKSsR = playerkeys(iPlIndex, 2, "SCREENSHOT"); //Release "Screenshot".
int iKAnyR = playerkeys(iPlIndex, 2, "ANYBUTTON"); //Release any key.
if (iKSp)
{
setentityvar(vSelf, KEY1SP, iTime); //Store last press of special key.
}
else if(iKAtk)
{
setentityvar(vSelf, KEY1AT, iTime); //Store last press of Attack key.
}
*/
if (iFIdl) //Idle?
{
}
else if (iFJmp) //Jumping?
{
fTossV = getentityproperty(vSelf, "tossv"); //Get Y velocity.
fXDir = getentityproperty(vSelf, "xdir"); //Get X velocity.
fZDir = getentityproperty(vSelf, "zdir"); //Get Z velocity.
//Mario style jumpheight control.
if (iKJmpR) //Jump key release?
{
if (fTossV > 0) //Not falling already?
{
fTossV /= 2; //Cut Y velcoity to 50%.
}
changeplayerproperty(vSelf, "playkeys", 0); //Clear key event.
}
if(iKLtR || iKRtR) //Left or Right released?
{
fXDir /= 2; //Cut X velocity by 50%.
changeplayerproperty(vSelf, "playkeys", 0); //Clear key event.
}
else if(iKLt) //Left pressed?
{
fXDir = -1; //Set velocity left.
changeentityproperty(vSelf, "direction", 0); //Set facing left.
changeplayerproperty(vSelf, "playkeys", 0); //Clear key event.
}
else if(iKRt) //Right pressed?
{
fXDir = 1; //Set velocity right.
changeentityproperty(vSelf, "direction", 1); //Set facing right.
changeplayerproperty(vSelf, "playkeys", 0); //Clear key event.
}
changeentityproperty(vSelf, "velocity", fXDir, fZDir, fTossV); //Apply velocity
}
else if (iFAtk) //Attacking?
{
}
}