|
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn),
581
guests, and 0
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
ent_blend
#317877
04/03/10 11:25
04/03/10 11:25
|
Joined: May 2009
Posts: 5,367 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,367
Caucasus
|
I'm using animation blending code from Wiki:
/*
calling in weapons while loop
main_anim();
handle_animation(1);
*/
#define nullframe -2
#define blend -1
#define stand 0
#define run 1
#define shoot 2
#define reload 3
#define draw 4
#define holster 5
#define animate skill31
#define animate2 skill32
#define animblend skill33
#define currentframe skill34
#define blendframe skill35
function handle_animation(var animation_speed)
{
if(animation_speed <= 0) animation_speed = 1;
if(my.animblend != blend && my.blendframe != nullframe) { my.animate2 = 0; my.animblend = blend; }
if(my.animblend == blend)
{
if (my.currentframe == stand) ent_animate(my, "idle", my.animate, ANM_CYCLE);
else if(my.currentframe == run) ent_animate(my, "run", my.animate, ANM_CYCLE);
else if(my.currentframe == shoot) ent_animate(my, "shoot", my.animate,0);
else if(my.currentframe == reload) ent_animate(my, "reload", my.animate,0);
else if(my.currentframe == draw) ent_animate(my, "draw", my.animate,0);
else if(my.currentframe == holster) ent_animate(my, "holster", my.animate,0);
if (my.blendframe == stand) ent_blend("idle",0,my.animate2);
else if(my.blendframe == run) ent_blend("run",0,my.animate2);
else if(my.blendframe == shoot) ent_blend("shoot",0,my.animate2);
else if(my.blendframe == reload) ent_blend("reload",0,my.animate2);
else if(my.blendframe == draw) ent_blend("draw",0,my.animate2);
else if(my.blendframe == holster) ent_blend("holster",0,my.animate2);
my.animate2 += 45 * time_step;
if(my.animate2 >= 100)
{
my.animate = 0;
my.animblend = my.blendframe;
my.blendframe = nullframe;
}
}
//
switch(my.animblend)
{
case stand:
ent_animate(my,"idle",my.animate,ANM_CYCLE);
my.animate += 2 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = stand;
break;
case run:
ent_animate(my,"run",my.animate,ANM_CYCLE);
my.animate += 10 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = run;
break;
case shoot:
ent_animate(my,"shoot",my.animate,0);
my.animate += 20 * animation_speed * time_step;
my.currentframe = shoot;
if(my.animate >= 100)
{
ent_animate(my,"shoot",100,0);
my.animate = 100;
my.blendframe = stand;
if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d))
{
if(key_shift == 1) my.blendframe = run;
}
}
break;
case reload:
ent_animate(my,"reload",my.animate,0);
my.animate += 15 * animation_speed * time_step;
my.currentframe = reload;
if(my.animate >= 100)
{
ent_animate(my,"reload",100,0);
my.animate = 100;
my.blendframe = stand;
if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d))
{
if(key_shift == 1) my.blendframe = run;
}
}
break;
case draw:
ent_animate(my,"draw",my.animate,0);
my.animate += 10 * animation_speed * time_step;
my.currentframe = draw;
if(my.animate >= 100)
{
ent_animate(my,"draw",100,0);
my.animate = 100;
my.blendframe = stand;
if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d))
{
if(key_shift == 1) my.blendframe = run;
}
}
break;
case holster:
ent_animate(my,"holster",my.animate,0);
my.animate += 15 * animation_speed * time_step;
my.currentframe = holster;
if(my.animate >= 100)
{
ent_animate(my,"holster",100,0);
my.animate = 100;
my.blendframe = stand;
if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d))
{
if(key_shift == 1) my.blendframe = run;
}
}
break;
}
if(my.animblend != blend && my.blendframe != nullframe) { my.animate2 = 0; my.animblend = blend; }
}
function main_anim()
{
if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d) && force_run > 5)
{
if(my.animblend == stand)
{
if(key_shift == 1) my.blendframe = run;
}
}
else
{
if(my.animblend > stand)
{
my.blendframe = stand;
}
}
}
I use it to animate my weapons, weapons can play idle and walking animations, but how do I add shooting, reloading, drawing and holster animations?  Please need some advice. Tryed to do like this:
my.blendframe = shoot;
my.animate2 = 0;
my.animblend = blend;
but no luck  It just shakes a bit, but not playing animations 
|
|
|
Re: ent_blend
[Re: 3run]
#317884
04/03/10 12:21
04/03/10 12:21
|
Joined: May 2009
Posts: 5,367 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,367
Caucasus
|
By shaking I mean, that model starts playing shoot animation, but stops in the begining animation frames and continues playing stand animation, so it looks like shaking. The_clown I tried to do what you sad, in the loop where I create bullet models, may be I was wrong? May be I need to do it some were else? Please need your advice.
Last edited by 3run; 04/03/10 12:24.
|
|
|
Re: ent_blend
[Re: the_clown]
#317896
04/03/10 13:49
04/03/10 13:49
|
Joined: May 2009
Posts: 5,367 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,367
Caucasus
|
My weapon doesn't have any states like my.state == shooting  Here is animation.c:
/*
call in player while loop
handle_animation(1);
*/
#define nullframe -2
#define blend -1
#define stand 0
#define run 1
#define shoot 2
#define reload 3
#define draw 4
#define holster 5
#define animate skill31
#define animate2 skill32
#define animblend skill33
#define currentframe skill34
#define blendframe skill35
function handle_animation(var animation_speed)
{
if(animation_speed <= 0) animation_speed = 1;
if(my.animblend != blend && my.blendframe != nullframe) { my.animate2 = 0; my.animblend = blend; }
if(my.animblend == blend)
{
if (my.currentframe == stand) ent_animate(my, "idle", my.animate, ANM_CYCLE);
else if(my.currentframe == run) ent_animate(my, "run", my.animate, ANM_CYCLE);
else if(my.currentframe == shoot) ent_animate(my, "shoot", my.animate,0);
else if(my.currentframe == reload) ent_animate(my, "reload", my.animate,0);
else if(my.currentframe == draw) ent_animate(my, "draw", my.animate,0);
else if(my.currentframe == holster) ent_animate(my, "holster", my.animate,0);
if (my.blendframe == stand) ent_blend("idle",0,my.animate2);
else if(my.blendframe == run) ent_blend("run",0,my.animate2);
else if(my.blendframe == shoot) ent_blend("shoot",0,my.animate2);
else if(my.blendframe == reload) ent_blend("reload",0,my.animate2);
else if(my.blendframe == draw) ent_blend("draw",0,my.animate2);
else if(my.blendframe == holster) ent_blend("holster",0,my.animate2);
my.animate2 += 45 * time_step;
if(my.animate2 >= 100)
{
my.animate = 0;
my.animblend = my.blendframe;
my.blendframe = nullframe;
}
}
//
switch(my.animblend)
{
case stand:
ent_animate(my,"idle",my.animate,ANM_CYCLE);
my.animate += 2 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = stand;
break;
case run:
ent_animate(my,"run",my.animate,ANM_CYCLE);
my.animate += 10 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = run;
break;
case shoot:
ent_animate(my,"shoot",my.animate,0);
my.animate += 20 * animation_speed * time_step;
my.currentframe = shoot;
if(my.animate >= 100)
{
ent_animate(my,"shoot",100,0);
my.animate = 100;
my.blendframe = stand;
if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d))
{
if(key_shift == 1) my.blendframe = run;
}
}
break;
case reload:
ent_animate(my,"reload",my.animate,0);
my.animate += 15 * animation_speed * time_step;
my.currentframe = reload;
if(my.animate >= 100)
{
ent_animate(my,"reload",100,0);
my.animate = 100;
my.blendframe = stand;
if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d))
{
if(key_shift == 1) my.blendframe = run;
}
}
break;
case draw:
ent_animate(my,"draw",my.animate,0);
my.animate += 10 * animation_speed * time_step;
my.currentframe = draw;
if(my.animate >= 100)
{
ent_animate(my,"draw",100,0);
my.animate = 100;
my.blendframe = stand;
if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d))
{
if(key_shift == 1) my.blendframe = run;
}
}
break;
case holster:
ent_animate(my,"holster",my.animate,0);
my.animate += 15 * animation_speed * time_step;
my.currentframe = holster;
if(my.animate >= 100)
{
ent_animate(my,"holster",100,0);
my.animate = 100;
my.blendframe = stand;
if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d))
{
if(key_shift == 1) my.blendframe = run;
}
}
break;
}
if(my.animblend != blend && my.blendframe != nullframe) { my.animate2 = 0; my.animblend = blend; }
}
function main_anim()
{
if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d) && force_run > 5 && climb == 0 && crawling == 0)
{
if(my.animblend == stand)
{
if(key_shift == 1) my.blendframe = run;
}
}
else
{
if(my.animblend > stand)
{
my.blendframe = stand;
}
}
}
Here is part from weapon:
action v_usp()
{
weapon = me;
set(my,ZNEAR);
while(me == weapon)
{
if ((mouse_left ==1)&&(usp_rdy ==1))
{
if (usp_clip > 0)
{
usp_shoot(1);
while(mouse_left){wait(1);}
}
}
main_anim();
handle_animation(1);
wait(1);
}
}
Here is shooting function:
function usp_shoot(t)
{
if (t ==1)
{
usp_rdy =0;
snd_play(deagle_shot_snd,100,0);
my.lightrange = 300;
vec_set(my.blue,vector(200,150,100));
vec_for_vertex(bullet_pos,my,usp_vertex);
ent_create (muzzle2, bullet_pos, display_muzzle);
if(my.animblend != shoot)
my.blendframe = shoot;
wait(-0.1);
vec_for_vertex(shotcase_pos,my,usp_shotcase_vertex);
ent_create(bullet_mdl,camera.x,bullet);
my.lightrange = 0;
cam_movements(2.5);
usp_clip -= 1;
wait(-0.3);
w_usp_reload(2);
usp_rdy =1;
}
}
|
|
|
Re: ent_blend
[Re: 3run]
#317904
04/03/10 14:25
04/03/10 14:25
|
Joined: May 2009
Posts: 5,367 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,367
Caucasus
|
I need to do something like this?
function main_anim()
{
if(my.animblend == stand)
{
if(my.state == shooting)
{
my.blendframe = shoot;
}
else
{
if(my.state == reloading)
{
my.blendframe = reload;
}
else
{
if(my.state == drawing)
{
my.blendframe = draw;
}
else
{
if(my.state == holster)
{
my.blendframe = holster;
}
else
{
if(my.state == runing)
{
my.blendframe = run;
}
else
{
if(my.state == stand_aiming)
{
my.blendframe = aim;
}
else
{
my.blendframe = stand;
}
}
}
}
}
}
}
}
And in shooting fuction I need to make state shooting??
|
|
|
Re: ent_blend
[Re: 3run]
#317915
04/03/10 16:14
04/03/10 16:14
|
Joined: May 2009
Posts: 5,367 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,367
Caucasus
|
|
|
|
|