1 registered members (AndrewAMD),
1,486
guests, and 10
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
1 click = 1 Full Attack Animation?
#325279
05/25/10 19:25
05/25/10 19:25
|
Joined: May 2010
Posts: 23 Germany
h34dl4g
OP
Newbie
|
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:
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
Expert
|
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:
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);
}
}
|
|
|
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
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
When the whole animation is over, you can press another time on "q" to get a new attack. Hey, try something like:
#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
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: Helghast]
#325409
05/26/10 13:28
05/26/10 13:28
|
Joined: May 2010
Posts: 23 Germany
h34dl4g
OP
Newbie
|
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
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
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
OP
Newbie
|
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.
|
|
|
|