Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,486 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
1 click = 1 Full Attack Animation? #325279
05/25/10 19:25
05/25/10 19:25
Joined: May 2010
Posts: 23
Germany
h34dl4g Offline OP
Newbie
h34dl4g  Offline OP
Newbie

Joined: May 2010
Posts: 23
Germany
I'm trying to get a attack animation which will be played if the key "q" is pressed. It should be spamable, but you can't hold "q", you have to press every time you want a attack. So basically just press one time on the key "q", and the model does one full attack animation. (not in lightning speed). When the whole animation is over, you can press another time on "q" to get a new attack.

I tried different codes but I couldn't get the right one. My basic code looks like this:

Code:
action guard_with_pointer()
{
	guard1 = my;
	while (1)
	{	
          ent_animate(my, NULL, 0, 0);
          if (key_q && guard_life > 0)
           {	
	     ent_animate(my, "attack", attack_percentage, ANM_CYCLE); 
	     attack_percentage += 3 * time_step;
	   }
           wait (1);
        }
}



Last edited by h34dl4g; 05/25/10 20:18.

1338, beyond leet.
Re: 1 click = 1 Full Attack Animation? [Re: h34dl4g] #325295
05/25/10 21:22
05/25/10 21:22
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
try it with a second loop, that checks the animation_percentage.. and runs 100% for one time...

Example:
Code:
action guard_with_pointer()
{
	guard1 = my;
	while (1)
	{	
		ent_animate(my, NULL, 0, 0);
		if (key_q && guard_life > 0)
		{
		   attack_percentage = 0;
			while(attack_percentage < 100)
			{
				ent_animate(my, "attack", attack_percentage, NULL); 
				attack_percentage += 3 * time_step;
				wait(1);
			}
		}
		wait (1);
	}
}




Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: 1 click = 1 Full Attack Animation? [Re: h34dl4g] #325325
05/26/10 00:40
05/26/10 00:40
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
Originally Posted By: h34dl4g
When the whole animation is over, you can press another time on "q" to get a new attack.


Hey, try something like:
Code:
#define anim_idle 0
#define anim_attack 1
action guard_with_pointer(){
	guard1 = my; //needed?
	
	var anim = anim_idle;
	var anim_percent = 0;
	var health = 100;
	var able_keyQ = true; //flag for identifying if 'q' is needed to be pressed
	
	while(me){ //change to me to prevent crashes when me doesn't exist
		if(health > 0){ //dont do anything if dead
			switch(anim){
				case anim_idle:
					if(able_keyQ){ //if accepting 'q'
						if(key_q){
							anim = anim_attack;
							able_keyQ = false;
						}
					}else{
						if(!key_q){
							able_keyQ = true;
						}
					}
				break;
				
				case anim_attack:
					anim_percent += 3 * time_step;
					if(anim_percent >= 100){ //if finished attack
						anim = anim_idle;
					}else{
						ent_animate(my, "attack", attack_percentage, ANM_CYCLE);
					}
				break;
			}
		}
		wait(1);
	}
}



though without wanting to do everything inside 1 loop, i'd agree with Esper and have a seperate function for checking, especially if you're already creating global entities
Code:
action guard_with_pointer(){
	//... blah!
}

change_state(){
	if(guard1){ //make sure he exists
		if(guard.anim == anim_idle){
			guard1.anim = anim_attack;
		}
	}
}

void main(){
//...
on_q = change_state;
}


hope these help
*untested!*

Re: 1 click = 1 Full Attack Animation? [Re: MrGuest] #325347
05/26/10 07:33
05/26/10 07:33
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
Have a look over at my Double Dragon 2 Remake here: http://www.designorhea.com/pages/Double_Dragon_2_Remake/

The Demo contains the source code as well, it has a built in combo check (stores keys into an array, based on that plays an attack).
It's not completely what you want, but might give you an idea.

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: 1 click = 1 Full Attack Animation? [Re: Helghast] #325409
05/26/10 13:28
05/26/10 13:28
Joined: May 2010
Posts: 23
Germany
h34dl4g Offline OP
Newbie
h34dl4g  Offline OP
Newbie

Joined: May 2010
Posts: 23
Germany
Thanks for all the codes you posted. I will try them and I will post again if I can't do it then.

-h34dl4g


EDIT: Espér's version worked perfectly thanks!

Last edited by h34dl4g; 05/26/10 13:32.

1338, beyond leet.
Re: 1 click = 1 Full Attack Animation? [Re: h34dl4g] #325434
05/26/10 15:49
05/26/10 15:49
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
Originally Posted By: h34dl4g
but you can't hold "q", you have to press every time you want a attack.
I may be wrong, but won't holding 'q' automatically replay the animation?

Re: 1 click = 1 Full Attack Animation? [Re: MrGuest] #325437
05/26/10 16:28
05/26/10 16:28
Joined: May 2010
Posts: 23
Germany
h34dl4g Offline OP
Newbie
h34dl4g  Offline OP
Newbie

Joined: May 2010
Posts: 23
Germany
Yes it will, but only if the first attack animation is already over. I'm changing the code right now so that you have to release the key "q" first.


1338, beyond leet.

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