danno said:
danno
Hmmm, now I understand better and I have two suggestions.
Bloodbane posted a good solution, my first suggestion is the same as his. In SOR2X if you hold block key during riseattack or dodge, the character will go to block animation as soon the previous animation ends. Here is the code, need to be used in chacarter's animation script file:
Code:
void keyAni(void key, void ani)
{//Execute animation if defined key is held
void self = getlocalvar("self");
int iPIndex = getentityproperty(self,"playerindex");
if(playerkeys(iPIndex, 0, key)){
executeanimation(self, openborconstant(ani));
}
}
And here is how it should be used in character's animation. This solution was implemented in kunai throw as a alternative method, but can be used in any animation :
Code:
anim freespecial2 #standing
loop 0
delay 7
offset 37 102
bbox 21 43 29 59
frame data/chars/ninja/ku1.gif
frame data/chars/ninja/ku1.gif
frame data/chars/ninja/ku1.gif
@cmd shooter2 "kun1" 32 43 0 2.5
sound Data/chars/ninja/k.wav
frame data/chars/ninja/ku2.gif
@cmd keyAni "attack2" "ANI_FREESPECIAL12"
frame data/chars/ninja/ku2.gif
The second solution is more complex due to "atchain". For example, if you use the first method in the last frame of the "attack1" animation, depending on how fast you press the attack button to perform "atchain", the "attack2" will not be performed and the character will go to block animation.
I tried to develop a solution in character's key script but not worked well because for some reason it needs a second key to trigger the keyscript event. Holding attack button only will not trigger key script event when it use "elapsed_time" for delay counter. It works only if you hold attack and then press any other button after.
Fortunately it worked well in ondraw event, I think is because it runs even if you not press a key. All you need is to create a ondraw.c file, copy all code inside it and call in the character header as a "ondrawscript" event:
Here is an example of how the character header will be:
Code:
ondrawscript data/chars/ninja/ondraw.c
Here is the code:
Code:
void main()
{//Execute animation if defined key is held according to a defined delay
void self = getlocalvar("self");
void ani = getentityproperty(self,"animationID"); //GET CURRENT ANIMATION
int iPIndex = getentityproperty(self,"playerindex"); //GET PLAYER INDEX
float time = openborvariant("elapsed_time"); //GET CURRENT TIME
float delay = 45; //DELAY NECESSARY TO CHANGE THE ANIMATION
//THIS SCRIPT WILL ONLY WORK IN ATTACK ANIMATIONS ONLY BUT YOU CAN ADD OR REMOVE ANY OTHER ANIMATION HERE
if(ani == openborconstant("ANI_ATTACK1") || ani == openborconstant("ANI_ATTACK2") || ani == openborconstant("ANI_ATTACK3")){
if(playerkeys(iPIndex, 0, "attack")){ //ATTACK KEY IS HELD??
if(getlocalvar("start_time") == NULL()){ //FISRT TIME HOLDING THIS KEY??
setlocalvar("start_time", time); //SAVE CURRENT TIME
}
if(time - getlocalvar("start_time") > delay){ //HOLDING ATTACK BUTTON AND DELAY IS REACHED THE LIMIT??
executeanimation(self, openborconstant("ANI_FREESPECIAL12"), 1); //CHANGE TO BLOCK ANIMATION
setlocalvar("start_time", NULL()); //RESET DELAY COUNTER
}
}else{ //ATTACK KEY IS RELEASED??
if(getlocalvar("start_time") != NULL()){ //USED TO RUN ONCE
setlocalvar("start_time", NULL()); //RESET DELAY COUNTER
}
}
}else{ //NO ATTACK ANIMATION??
if(getlocalvar("start_time") != NULL()){ //USED TO RUN ONCE
setlocalvar("start_time", NULL()); //RESET DELAY COUNTER
}
}
}
Don't forget to use it together with @cmd keyLoop scripts and @cmd block, that I sent to you. You need to add all keys you want to hold and maintain the block animation:
Code:
anim freespecial12
loop 0
delay 20
offset 37 102
bbox 26 42 22 60
@cmd block 1
frame Data/chars/ninja/dj44.gif
@cmd keyLoop "attack2" 0
@cmd keyLoop "attack" 0
@cmd block 0
frame Data/chars/ninja/dj33.gif
I hope it works. From this point, you can adapt the scripts to work in other animations.