2 registered members (Akow, 1 invisible),
1,423
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
somethings not working with bone animations
#380197
08/14/11 14:45
08/14/11 14:45
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
So I decided to use bone animations (with meens I have to bone all my models ) However, I have a little problem. When I press mouse left, my player does the attack animation while the legs are moving and that pretty good. But when the animation is finished and I want to attack again, my player does`t really react... Here is the function; function handle_animaten() { var DoCombat = TRUE; ent_animate(my, NULL, 0, 0); if(key_shift && key_w) { player.animblend = blend; my.skill1 += 8 * time_step; ent_animate(me,"run",my.skill1,ANM_CYCLE); DoCombat = FALSE; } if(key_w) { player.animblend = blend; my.skill2 += 6 * time_step; ent_animate(me,"run",my.skill2,ANM_CYCLE); DoCombat = FALSE; } if(key_s) { player.animblend = blend; my.skill3 -= 6 * time_step; ent_animate(me,"run",my.skill3,ANM_CYCLE); DoCombat = FALSE; } if(key_a) { player.animblend = blend; my.skill4 += 6 * time_step; ent_animate(me,"strafe_left",my.skill4,ANM_CYCLE); DoCombat = FALSE; } if(key_d) { player.animblend = blend; my.skill5 += 6 * time_step; ent_animate(me,"strafe_right",my.skill5,ANM_CYCLE); DoCombat = FALSE; } if(mouse_left) { player.animblend = attack_c; handle_sword_collision(); my.skill6 += 8 * time_step; if (!mouse_left && (my.skill6 > 0)) my.skill6 -= 10 * time_step; ent_animate(me,"attack_c",my.skill6,ANM_ADD); DoCombat = FALSE; } if(my_height > 10) { player.animblend = blend; my.skill9 += 3 * time_step; ent_animate(me,"fall",my.skill9,ANM_CYCLE); DoCombat = FALSE; } if (DoCombat) { player.animblend = blend; my.skill8 += 1 * time_step; ent_animate(me,"stand",my.skill10,ANM_CYCLE); } } Hope somebody can help ...
|
|
|
Re: somethings not working with bone animations
[Re: Random]
#380217
08/14/11 18:44
08/14/11 18:44
|
Joined: Jul 2006
Posts: 40 North Europe
DeepReflection
Newbie
|
Newbie
Joined: Jul 2006
Posts: 40
North Europe
|
Hi Random,
With just a quick glimpse on your code I notice this depending on the frame this function is executed and current keys pressed might give unpredictable results.
You have a flag for DoCombat after your first attack do your character stand still or can you still move?
Last edited by DeepReflection; 08/15/11 07:10. Reason: Too long from the inital question
|
|
|
Re: somethings not working with bone animations
[Re: DeepReflection]
#380327
08/15/11 17:59
08/15/11 17:59
|
Joined: Jul 2006
Posts: 40 North Europe
DeepReflection
Newbie
|
Newbie
Joined: Jul 2006
Posts: 40
North Europe
|
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. ////////////////////////////////////////////////////////////////////
#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?)
|
|
|
|