void keyint(void Ani, int Frame, void Key, int Hflag)
{// Change current animation if proper key is pressed or released
// Animation is changed to attack mode
void self = getlocalvar("self");
int Dir = getentityproperty(self, "direction");
int iPIndex = getentityproperty(self,"playerindex"); //Get player index
void iRKey;
if (Key=="U"){ //Up Required?
iRKey = playerkeys(iPIndex, 0, "moveup"); // "Up"
} else if (Key=="D"){ //Down Required?
iRKey = playerkeys(iPIndex, 0, "movedown"); // "Down"
} else if (Key=="L"){ //Left Required?
iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
} else if (Key=="R"){ //Right Required?
iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
} else if (Key=="F"){ //Forward Required?
if (Dir == 0){ // Facing Left?
iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
} else { // Facing Right
iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
}
} else if (Key=="B"){ //Backward Required?
if (Dir == 1){ // Facing Right?
iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
} else { // Facing Left
iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
}
} else if (Key=="J"){ //Jump Required?
iRKey = playerkeys(iPIndex, 0, "jump"); // "Jump"
} else if (Key=="A"){ //Attack Required?
iRKey = playerkeys(iPIndex, 0, "attack"); // "Attack"
} else if (Key=="S"){ //Special Required?
iRKey = playerkeys(iPIndex, 0, "special"); // "Special"
}
if (Hflag==1){ //Not holding the button case?
iRKey = !iRKey; //Take the opposite condition
}
if (iRKey){
if (Ani=="ANI_IDLE"){ // Going idle?
setidle(self, openborconstant("ANI_IDLE")); //Be idle!
} else {
performattack(self, openborconstant(Ani)); //Change the animation
}
updateframe(self, Frame); //Change frame
}
}
@cmd keyint {animation} {frame} {key} {Hflag}
void changeanibykeytoattackforself(void Ani, int Frame, void Key, int Hflag, int Limit)
{// Change current animation if proper key is pressed or released provided HP is more than limit
// V0.07
// Matman
void self = getlocalvar("self");
if ( checkent(self) == 1 ) {
changeanibykeytoattack(self, Ani, Frame, Key, Hflag, Limit);
}
}
@cmd changeanibykeytoattackforself "ANI_Attack2" 0 "A" 0 0
@cmd changeanibykeytoattackforself "ANI_Attack1" 0 "A" 0 0
anim attack1
offset 56 112
loop 0
delay 12
bbox 32 12 45 108
frame data/chars/doomguy/pistol/e3.png
bbox 52 12 45 108
offset 76 112
sound data/sfx/dspistol.wav
@cmd projectile 1 "Bullet" 72 1 88
frame data/chars/doomguy/pistol/f3.png
bbox 32 12 45 108
offset 56 112
frame data/chars/doomguy/pistol/e3.png
@cmd changeanibykeytoattackforself "ANI_Attack2" 0 "A" 0 0
frame data/chars/doomguy/pistol/e3.png
anim attack2
offset 56 112
loop 0
delay 12
bbox 32 12 45 108
frame data/chars/doomguy/pistol/e3.png
bbox 52 12 45 108
sound data/sfx/dspistol.wav
offset 76 112
@cmd projectile 1 "Bullet" 72 1 88
frame data/chars/doomguy/pistol/f3.png
bbox 32 12 45 108
offset 56 112
frame data/chars/doomguy/pistol/e3.png
@cmd changeanibykeytoattackforself "ANI_Attack1" 0 "A" 0 0
frame data/chars/doomguy/pistol/e3.png
keyscript data/scripts/ky.c
// Script for moving while attacking.
#import "data/scripts/aniScp.c"
void main(){
// get variables ready
int player = getlocalvar("player");
void self = getplayerproperty(player, "ent");
int anim = getentityproperty(self, "animationid");
/*
if ( anim == openborconstant("ANI_IDLE")
|| anim == openborconstant("ANI_WALK")
|| anim == openborconstant("ANI_RUN")
|| anim == openborconstant("ANI_Faint") )
{
if ( checkkeycombo(self, "A", 0) ) {
performattack(self, openborconstant("ANI_Attack1"), 1);
}
}
*/
//I'm sure there is a better way of doing this but....
if ( anim == openborconstant("ANI_Attack1" )
|| anim == openborconstant("ANI_Attack2")
|| anim == openborconstant("ANI_Attack3") ) {
if ( checkkeycombo(self, "UF", 0) ) {
tossself(0, -1, 0, -0.5);
} else
if ( checkkeycombo(self, "UB", 0) ) {
tossself(0, 1, 0, -0.5);
} else
if ( checkkeycombo(self, "DF", 0) ) {
tossself(0, -1, 0, 0.5);
} else
if ( checkkeycombo(self, "DB", 0) ) {
tossself(0, 1, 0, 0.5);
} else
if ( checkkeycombo(self, "F", 0) ) {
tossself(0, -1, 0, 0);
} else
if ( checkkeycombo(self, "B", 0) ) {
tossself(0, 1, 0, 0);
} else
if ( checkkeycombo(self, "U", 0) ) {
tossself(0, 0, 0, -0.5);
} else
if ( checkkeycombo(self, "D", 0) ) {
tossself(0, 0, 0, 0.5);
}
}
}
range {min} {max}
Otherwise the best method is actually how Bloodbane did his Contra mod, thou it 's a lot harder to setup.