Freespecial Command for Down, Diagonal Up-Forward and Action Button

maxman

Well-known member
I'm trying to make a special command move with diagonals (and attack) after pressing the down button. I know the freespecial command only lets you do D F U and B. but no diagonals such as UF (up-forward), DF (down-forward). For instance, when pressing down, and diagonal up-forward with jump, it can perform a super forward jump as a freespecial animation.

What I'm trying to do is to make a player perform a super forward jump with a diagonal command after the down press. I'm using the entity script which works well for pressing diagonal buttons instead of keyscript.

Code:
name    Jimmy
type    player
speed    10
health    100
facing  0
combostyle 1
gfxshadow 1
atchain 1 2 4 3
running    19 4 2 1 1
turndelay 50
jumpheight 4.25
palette    data/chars/jimmy/map01.png
alternatepal data/chars/jimmy/idle00.png

com d u j freespecial8
com d u freespecial2
com d f freespecial3

animationscript data/scripts/script.c
script data/scripts/superfjump.c

Both freespecial2 and freespecial3 have the same animations but the commands are different.
Code:
anim    freespecial2
    bbox    124 106 72 99
    offset    162 202
    delay    7
    frame    data/chars/jimmy/idle00.png
       
anim    freespecial3
    bbox    124 106 72 99
    offset    162 202
    delay    7
    frame    data/chars/jimmy/idle00.png

superfjump.c:
Code:
void main(){
    SuperJump();
}

void SuperJump(){
    int iPlIndex = getlocalvar("player"); //Get calling player
    void vSelf = getplayerproperty(iPlIndex , "entity"); //Get calling entity
    void vAniID = getentityproperty(vSelf,"animationID"); //Get current animation ID
    void vAniPos = getentityproperty(vSelf, "animpos"); //Get current animation frame
    int iDir = getentityproperty(vSelf, "direction");  //Get current facing direction

    void iUp = playerkeys(iPlIndex, 1, "moveup"); // New key status of "Up"
    void iDown = playerkeys(iPlIndex, 1, "movedown"); // New key status of "Down"
    void iLeft = playerkeys(iPlIndex, 1, "moveleft"); // New key status of "Left"
    void iRight = playerkeys(iPlIndex, 1, "moveright"); // New key status of "Right"
    void iJump = playerkeys(iPlIndex, 1, "jump"); //New key status of "Jump"
    void iSpecial = playerkeys(iPlIndex, 1, "Special"); //New key status of "Special"
    void iAttack = playerkeys(iPlIndex, 1, "attack"); //New key status of "Attack"
    void iAttack2 = playerkeys(iPlIndex, 1, "attack2"); // New key of "Attack 2"
    void iAttack3 = playerkeys(iPlIndex, 1, "attack3"); // New key of "Attack 3"
    void iAttack4 = playerkeys(iPlIndex, 1, "attack4"); // New key of "Attack 4"

    void iLeftR = playerkeys(iPlIndex, 2, "moveleft"); // Release status of "Left"
    void iRightR = playerkeys(iPlIndex, 2, "moveright"); // Release status of "Right"
    void iDownR = playerkeys(iPlIndex, 2, "movedown"); //Release status of "Down"
    void iAttackR = playerkeys(iPlIndex, 2, "attack"); //Release status of "Attack"

    void iUpH = playerkeys(iPlIndex, 0, "moveup");
    void iDownH = playerkeys(iPlIndex, 0, "movedown");
    void iLeftH = playerkeys(iPlIndex, 0, "moveleft");
    void iRightH = playerkeys(iPlIndex, 0, "moveright");

//Super forward jump
   if(vAniID == openborconstant("ANI_FREESPECIAL2")){
       if(iRightH){
           changeentityproperty(vSelf, "direction", 1);
           //changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL6"));
           //tossentity(vSelf, 5, 3, 0);
           if(iJump){
                changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL6"));
                tossentity(vSelf, 5, 3, 0);
           }
       }else if(iLeftH){
           changeentityproperty(vSelf, "direction", 0);
           //changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL6"));
           //tossentity(vSelf, 5, -3, 0);
           if(iJump){
                changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL6"));
                tossentity(vSelf, 5, -3, 0);
           }
       }
   }
  
   if(vAniID == openborconstant("ANI_FREESPECIAL3")){
       if(iUpH && iDir == 1){
           if(iJump){
               changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL6"));
                tossentity(vSelf, 5, 3, 0);
           }
       }else if(iUpH && iDir == 0){
           if(iJump){
                changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL6"));
                tossentity(vSelf, 5, -3, 0);
           }
       }
   }

}

Despite the functions working well for the diagonals, I feel like pressing those two buttons or making commands out of those two at the same time with this kind, makes it feel like it's stiff. Because I use commands from freespecials. You just have to press up+forward at the same before the jump button. Is there a better or more functional way to do this command?
 
Last edited:
When I try using @DCurrent's diagonal script, with a new key for the down and diagonal command, I can't execute the move.

Code:
void main(){
    SuperJump();
}

void SuperJump(){
    void vSelf = getlocalvar("self"); //Get calling player
    int iPlIndex = getentityproperty(vSelf , "playerindex"); //Get calling entity
    void vAniID = getentityproperty(vSelf,"animationID"); //Get current animation ID
    //int vAniPos = getentityproperty(vSelf, "animpos"); //Get current animation frame
    int iDir = getentityproperty(vSelf, "direction");  //Get current facing direction

    int iUp = playerkeys(iPlIndex, 1, "moveup"); // New key status of "Up"
    int iDown = playerkeys(iPlIndex, 1, "movedown"); // New key status of "Down"
    int iLeft = playerkeys(iPlIndex, 1, "moveleft"); // New key status of "Left"
    int iRight = playerkeys(iPlIndex, 1, "moveright"); // New key status of "Right"
    int iJump = playerkeys(iPlIndex, 1, "jump"); //New key status of "Jump"
    int iSpecial = playerkeys(iPlIndex, 1, "Special"); //New key status of "Special"
    int iAttack = playerkeys(iPlIndex, 1, "attack"); //New key status of "Attack"
    int iAttack2 = playerkeys(iPlIndex, 1, "attack2"); // New key of "Attack 2"
    int iAttack3 = playerkeys(iPlIndex, 1, "attack3"); // New key of "Attack 3"
    int iAttack4 = playerkeys(iPlIndex, 1, "attack4"); // New key of "Attack 4"

    int iLeftR = playerkeys(iPlIndex, 2, "moveleft"); // Release status of "Left"
    int iRightR = playerkeys(iPlIndex, 2, "moveright"); // Release status of "Right"
    int iDownR = playerkeys(iPlIndex, 2, "movedown"); //Release status of "Down"
    int iAttackR = playerkeys(iPlIndex, 2, "attack"); //Release status of "Attack"

    int iUpH = playerkeys(iPlIndex, 0, "moveup");
    int iDownH = playerkeys(iPlIndex, 0, "movedown");
    int iLeftH = playerkeys(iPlIndex, 0, "moveleft");
    int iRightH = playerkeys(iPlIndex, 0, "moveright");
    
    
//    void target; int pIndex;
    int key_forward; int key_hold; int key_press;
    
//    target = getlocalvar("self");
//    pIndex = getentityproperty(target, "playerindex");
    
    key_hold    = getplayerproperty(iPlIndex, "keys");
    key_press    = getplayerproperty(iPlIndex, "newkeys");
    int HoldUp;
    
    if(key_press & openborconstant("FLAG_MOVEDOWN")){
        HoldUp = key_hold & openborconstant("FLAG_MOVEUP");
    }
    
    if(HoldUp)
    {
        key_forward = dc_check_key_forward(key_hold, vSelf);
   
        if(key_forward && iJump)
        {
            performattack(vSelf, openborconstant("ani_freespecial6"));
        }
    }

}

int dc_check_key_forward(int key_status, void vSelf)
{
    int result;
   
    // Default false.
    result = 0;
    
    int direction = getentityproperty(vSelf, "direction");
   
    if(direction == openborconstant("DIRECTION_RIGHT"))
    {
        if(key_status & openborconstant("FLAG_MOVERIGHT"))
        {
            result = 1;
        }       
    }
    else
    {
        if(key_status & openborconstant("FLAG_MOVELEFT"))
        {
            result = 1;
        }
    }
   
    return result;
}

I also tried using this one:

Code:
    if(iDown){
        HoldUp = key_hold & openborconstant("FLAG_MOVEUP");
    }

But I can't make it to work. What am I doing wrong?
 
Back
Top Bottom