Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ent_blend #317877
04/03/10 11:25
04/03/10 11:25
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
I'm using animation blending code from Wiki:

Code:
/*
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? frown Please need some advice.

Tryed to do like this:
Code:
my.blendframe = shoot;
my.animate2 = 0;
my.animblend = blend;



but no luck frown It just shakes a bit, but not playing animations frown


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: ent_blend [Re: 3run] #317880
04/03/10 11:48
04/03/10 11:48
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Just do

if(my.animblend != shoot)
my.blendframe = shoot;

Nothing else.

Re: ent_blend [Re: the_clown] #317882
04/03/10 11:53
04/03/10 11:53
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
Doen't work frown just shakes as before frown


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: ent_blend [Re: 3run] #317884
04/03/10 12:21
04/03/10 12:21
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline OP
Senior Expert
3run  Offline 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.

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: ent_blend [Re: 3run] #317895
04/03/10 13:42
04/03/10 13:42
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Hmmm... I always manage that by using states for the weapons...
I'd write that in "if(my.state == shooting)"...

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 Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
My weapon doesn't have any states like my.state == shooting frown

Here is animation.c:
Code:
/*
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:

Code:
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:

Code:
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;
	}
}




Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: ent_blend [Re: 3run] #317897
04/03/10 14:04
04/03/10 14:04
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Well, you'll have to restructure your code around that animation system I'm afraid.

Re: ent_blend [Re: the_clown] #317900
04/03/10 14:15
04/03/10 14:15
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
There should be an other way to figure this out!!! frown


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: ent_blend [Re: 3run] #317904
04/03/10 14:25
04/03/10 14:25
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
I need to do something like this?
Code:
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??


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: ent_blend [Re: 3run] #317915
04/03/10 16:14
04/03/10 16:14
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
frown frown frown No ideas? frown frown frown


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1