Hi again,

This is an example of key combination fetching.

UpdateMoveStatus() will check all configured keys and update status.

AnyAction() is the setup to determine the appropriate action to take. Note that since it is just a simple long list of if checks the highest priority that match will be the last if statement that matches. For more advanced moves if else or while would be needed to group special actions. str_action is the result of detected action and shown on screen when a successful move is made.

Hope this give an idea how to reliable detect actions.

Click to reveal..
////////////////////////////////////////////////////////////////////

#include <acknex.h>

#include <default.c>

////////////////////////////////////////////////////////////////////



#define vMOVE_FORWARD 17 // W = 17

#define vMOVE_REVERSE 31 // S = 31

#define vMOVE_LEFT 30 // A = 30

#define vMOVE_RIGHT 32 // D = 32

#define vMOVE_JUMP 57 // SPACE = 57

#define vMOVE_SPRINT 42 // SHIFT LEFT = 42

#define vMOVE_ADD 29 // CTRL = 29

#define vMOVE_FIRE 280 // LEFT MOUSE = 280

#define MOVE_MEMORY 100 // How long to remember status



////////////////////////////////////////////////////////////////////



var vMoveForward,vMoveReverse,vMoveLeft,vMoveRight,vMoveJump,vMoveSprint,vMoveAdd,vMoveFire;

var vMoveJumpMem;

var number_of_key;





FONT* arial_font = "Arial#16b"; // Arial, size = 16, bold

FONT* arial_font_big = "Arial#48"; // Arial, size = 24



STRING* str_lastkey = "Last key pressed:";

STRING* str_Qwerty = "tab Q W E R T Y";

STRING* str_Asdfg = "lock A S D F G H";

STRING* str_Zxcvb = "shft \ Z X C V B";

STRING* str_ctrl = "ctrl win alt space";



STRING* my_str = "#100";

STRING* str_action = str_create("#100");

STRING* str_action = "";



TEXT* action_result =

{

pos_x = 50;

pos_y = 50;

font = arial_font;

layer = 100;

string(str_action);

flags = VISIBLE;

}



TEXT* lastkeypressed =

{

pos_x = 130;

pos_y = 20;

font = arial_font;

layer = 100;

string(str_lastkey);

flags = VISIBLE;

}



TEXT* t_line1 =

{

pos_x = 70;

pos_y = 185;

font = arial_font_big;

blue = 100; green = 100; red = 100;

layer = 50;

string(str_Qwerty);

flags = VISIBLE;

}



TEXT* t_line2 =

{

pos_x = 70;

pos_y = 245;

font = arial_font_big;

blue = 100; green = 100; red = 100;

layer = 50;

string(str_Asdfg);

flags = VISIBLE;

}



TEXT* t_line3 =

{

pos_x = 70;

pos_y = 300;

font = arial_font_big;

blue = 100; green = 100; red = 100;

layer = 50;

string(str_Zxcvb);

flags = VISIBLE;

}



TEXT* t_line4 =

{

pos_x = 70;

pos_y = 350;

font = arial_font_big;

blue = 100; green = 100; red = 100;

layer = 50;

string(str_ctrl);

flags = VISIBLE;

}



////////////////////////////////////////////////////////////////////



PANEL* pDisplay =

{

digits (245, 20, 5, "Arial#16", 1, number_of_key);

layer = 60;

flags = VISIBLE;

}

PANEL* pDisplayw =

{

digits (255, 185, 5, "Arial#16", 1, vMoveForward);

layer = 60;

flags = VISIBLE;

}

PANEL* pDisplays =

{

digits (280, 242, 5, "Arial#16", 1, vMoveReverse);

layer = 60;

flags = VISIBLE;

}

PANEL* pDisplaya =

{

digits (215, 242, 5, "Arial#16", 1, vMoveLeft);

layer = 60;

flags = VISIBLE;

}

PANEL* pDisplayd =

{

digits (345, 242, 5, "Arial#16", 1, vMoveRight);

layer = 60;

flags = VISIBLE;

}

PANEL* pDisplayshift =

{

digits (90, 300, 5, "Arial#16", 1, vMoveSprint);

layer = 60;

flags = VISIBLE;

}

PANEL* pDisplayctrl =

{

digits (90, 360, 5, "Arial#16", 1, vMoveAdd);

layer = 60;

flags = VISIBLE;

}

PANEL* pDisplayspace =

{

digits (350, 360, 5, "Arial#16", 1, vMoveJump);

layer = 60;

flags = VISIBLE;

}



PANEL* pDisplaymem =

{

digits (400, 360, 5, "Arial#16", 1, vMoveJumpMem);

layer = 60;

flags = VISIBLE;

}





void UpdateMoveStatus() { // Low level movement fetching with history



if (key_pressed(vMOVE_FORWARD))

{vMoveForward++; vMoveForward = maxv(vMoveForward,1);}

else

{vMoveForward--; vMoveForward = minv(vMoveForward,0);}

vMoveForward = clamp(vMoveForward,-MOVE_MEMORY,MOVE_MEMORY);



if (key_pressed(vMOVE_REVERSE))

{vMoveReverse++; vMoveReverse = maxv(vMoveReverse,1);}

else

{vMoveReverse--; vMoveReverse = minv(vMoveReverse,0);}

vMoveReverse = clamp(vMoveReverse,-MOVE_MEMORY,MOVE_MEMORY);



if (key_pressed(vMOVE_LEFT))

{vMoveLeft++; vMoveLeft = maxv(vMoveLeft,1);}

else

{vMoveLeft--; vMoveLeft = minv(vMoveLeft,0);}

vMoveLeft = clamp(vMoveLeft,-MOVE_MEMORY,MOVE_MEMORY);



if (key_pressed(vMOVE_RIGHT))

{vMoveRight++; vMoveRight = maxv(vMoveRight,1);}

else

{vMoveRight--; vMoveRight = minv(vMoveRight,0);}

vMoveRight = clamp(vMoveRight,-MOVE_MEMORY,MOVE_MEMORY);



if (key_pressed(vMOVE_JUMP))

{vMoveJump++; vMoveJump = maxv(vMoveJump,1);}

else

{vMoveJump--; vMoveJump = minv(vMoveJump,0);}

vMoveJump = clamp(vMoveJump,-MOVE_MEMORY,MOVE_MEMORY);



if (key_pressed(vMOVE_SPRINT))

{vMoveSprint++; vMoveSprint = maxv(vMoveSprint,1);}

else

{vMoveSprint--; vMoveSprint = minv(vMoveSprint,0);}

vMoveSprint = clamp(vMoveSprint,-MOVE_MEMORY,MOVE_MEMORY);



if (key_pressed(vMOVE_ADD))

{vMoveAdd++; vMoveAdd = maxv(vMoveAdd,1);}

else

{vMoveAdd--; vMoveAdd = minv(vMoveAdd,0);}

vMoveAdd = clamp(vMoveAdd,-MOVE_MEMORY,MOVE_MEMORY);



if (key_pressed(vMOVE_FIRE))

{vMoveFire++; vMoveFire = maxv(vMoveFire,1);}

else

{vMoveFire--; vMoveFire = minv(vMoveFire,0);}



vMoveJumpMem--;

vMoveJumpMem = clamp(vMoveJumpMem,-MOVE_MEMORY,MOVE_MEMORY);

}



/////////////////////////////////////////////////////////////////////



function Any_Action() {



if (vMoveJump > 0)

{str_cpy(str_action, "Jump");

}

if (vMoveLeft > 0)

{str_cpy(str_action, "Sidestep Left");

}

if (vMoveRight > 0)

{str_cpy(str_action, "Sidestep Right");

}

if (vMoveForward > 0)

{str_cpy(str_action, "Walking forward");

}

if ((vMoveForward > 0) && (vMoveJump > 0))

{str_cpy(str_action, "Forward Jump");

}

if ((vMoveForward > 0) && (vMoveSprint > 0))

{str_cpy(str_action, "Fast running forward");

}

if ((vMoveForward > 5) && (vMoveSprint > 5) && (vMoveFire > 0))

{str_cpy(str_action, "Fast forward flip Attack");

}

if ((vMoveForward > 10) && (vMoveSprint > 0) && (vMoveJump > 0))

{str_cpy(str_action, "Fast forward flip jump");

}

if ((vMoveForward > 10) && (vMoveSprint > 10) && (vMoveJump > 0))

{str_cpy(str_action, "Forward Long Jump");

}



if ((vMoveForward > 30) && (vMoveSprint > 30) && (vMoveJump > 0))

{str_cpy(str_action, "Forward Speed Long Jump");

vMoveJumpMem = 20;

}

if ((vMoveForward > 30) && (vMoveSprint > 30) && (vMoveJump > 0) && (vMoveJumpMem > 20))

{str_cpy(str_action, "Forward Speed Long GIGANTUS Jump");

vMoveJumpMem = 60;

}

if ((vMoveForward > 30) && (vMoveSprint > 30) && (vMoveJump > -10) && (vMoveJumpMem > 10))

{str_cpy(str_action, "Forward Speed Long Jump Released");

vMoveJumpMem = 40;

}

if ((vMoveForward > 40) && (vMoveSprint > 40) && (vMoveJump < 0) && (vMoveJumpMem > 50))

{str_cpy(str_action, "Forward Speed Long GIGANTUS Jump Released");

vMoveJumpMem = 100;

}

if (vMoveFire > 0)

{str_cpy(str_action, "Fire Left Mouse Button");

}

if (vMoveReverse > 0)

{str_cpy(str_action, "Walking backwards");

}

if ((vMoveForward > 15) && (vMoveSprint > 5) && (vMoveLeft > 0))

{str_cpy(str_action, "Quick Left strafe forward");

}

if ((vMoveForward > 15) && (vMoveSprint > 5) && (vMoveRight > 0))

{str_cpy(str_action, "Quick Right strafe forward");

}

if ((vMoveForward > -30) && (vMoveReverse > 0) && (vMoveReverse < 10) && (vMoveFire > 0))

{str_cpy(str_action, "Fast turnaround back Attack from running forward");

}

if ((vMoveForward < 0) && (vMoveReverse < 0) && (vMoveAdd > 0) && (vMoveLeft > 0) && (vMoveFire > 0))

{str_cpy(str_action, "Dodge and Left Attack");

}

if ((vMoveForward < 0) && (vMoveReverse < 0) && (vMoveAdd > 0) && (vMoveRight > 0) && (vMoveFire > 0))

{str_cpy(str_action, "Dodge and Right Attack");

}

if ((vMoveForward < 0) && (vMoveReverse < 0) && (vMoveJump < 0) && (vMoveLeft < 0) && (vMoveRight < 0))

{str_cpy(str_action, "Standing");

}

if ((vMoveForward < -20) && (vMoveReverse < -20) && (vMoveLeft > 0) && (vMoveRight > 0) && (vMoveJump > 0))

{str_cpy(str_action, "Jump and split kick sideways");

}

if ((vMoveForward < -10) && (vMoveReverse < -10) && (vMoveSprint > 0) && (vMoveAdd > 0) && (vMoveJump < 0))

{str_cpy(str_action, "Throw itself down on ground");

}

if ((vMoveForward > 20) && (vMoveReverse < -30) && (vMoveSprint > 0) && (vMoveAdd > 0) && (vMoveJump < 0))

{str_cpy(str_action, "Throw itself down on ground forward");

}

if ((vMoveForward < -20) && (vMoveReverse > 10) && (vMoveSprint > 0) && (vMoveAdd > 0) && (vMoveJump < 0))

{str_cpy(str_action, "Throw itself down on ground backward");

}

if ((vMoveForward < -50) && (vMoveReverse < -50) && (vMoveJump < -50) && (vMoveLeft < -50) && (vMoveRight < -50) && (vMoveJump < -50))

{str_cpy(str_action, "Soon standing still");

}

if ((vMoveForward < -90) && (vMoveReverse < -90) && (vMoveJump < -90) && (vMoveLeft < -90) && (vMoveRight < -90) && (vMoveJump < -90))

{str_cpy(str_action, "Idle animations since player stands still");

}



}



////////////////////////////////////////////////////////////////////



function main() {

video_mode = 6;

screen_color.blue = 10;



str_cpy(str_action, "test");



while (1) { // Main loop



UpdateMoveStatus(); // Low level movement fetching

Any_Action();

number_of_key = key_lastpressed;

wait(-0.02);

}

}



////////////////////////////////////////////////////////////////////


(not sure where all the extra empty lines come from when i pasted the code?)