|
Re: There is something wrong with combos
[Re: muffel]
#374636
06/20/11 16:54
06/20/11 16:54
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Really an endles loop?
I tryed it with while befor.(the only differens was I wrote 100 and not 99). It worked, till the last attack. After that it reapets the last one over and over. thats why im trying it with if. And without while(my.skill6){wait(1);} befor if, he woudn`t play the animation!
Last edited by Random; 06/20/11 16:55.
|
|
|
Re: There is something wrong with combos
[Re: Widi]
#374669
06/20/11 20:31
06/20/11 20:31
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
I was so sure this would work, but it doesn`t; (combo function full) var combo = 1; if(mouse_left == 1 && mouse_left_press == 0 && combo == 0) { mouse_left_press = 1; player.animblend = attack_a; } if(player.animblend == attack_a && mouse_left_press == 1 && combo == 0) { combo = 1; player.animblend = attack_a; handle_sword_collision(); my.skill6 += 10 * time_step; ent_animate(me,"attack_a",my.skill6,ANM_CYCLE); my.skill6 %= 100; while(my.skill6 < 100){wait(1);} if(mouse_left == 1 && mouse_left_press == 1 && combo == 1) { if(my.skill6 == 100) { player.animblend = attack_b; } } else { mouse_left_press = 0; combo = 0; player.animblend = blend; } DoCombat = FALSE; } if(player.animblend == attack_b && mouse_left_press == 1) { combo = 2; player.animblend = attack_b; handle_sword_collision(); my.skill7 += 10 * time_step; ent_animate(me,"attack_b",my.skill7,ANM_CYCLE); my.skill7 %= 100; while(my.skill7 < 100){wait(1);} if(mouse_left == 1 && mouse_left_press == 1 && combo == 2) { if(my.skill7 == 100) { player.animblend = attack_c; } } else { mouse_left_press = 0; combo = 0; player.animblend = blend; } DoCombat = FALSE; } if(player.animblend == attack_c && mouse_left_press == 1) { combo = 0; player.animblend = attack_c; handle_sword_collision(); my.skill8 += 8 * time_step; ent_animate(me,"attack_c",my.skill8,ANM_CYCLE); my.skill8 %= 100; while(my.skill8 < 100){wait(1);} mouse_left_press = 0; combo = 0; player.animblend = blend; DoCombat = FALSE; } (Combo function part by part) When I press the left mouse butten, the player`s animblend should become attack_a. if(mouse_left == 1 && mouse_left_press == 0 && combo == 0) { mouse_left_press = 1; player.animblend = attack_a; } The player`s animblend has become attack_a now, so the player should beginn attacking with attack_a and wait until the animation is finished. After the animation is finished and I press mouse left again, the player should play his next attack; if(player.animblend == attack_a && mouse_left_press == 1 && combo == 0) { combo = 1; player.animblend = attack_a; handle_sword_collision(); my.skill6 += 10 * time_step; ent_animate(me,"attack_a",my.skill6,ANM_CYCLE); my.skill6 %= 100; while(my.skill6 < 100){wait(1);} //play attack_a and wait untill it`s finished if(mouse_left == 1 && mouse_left_press == 1 && combo == 1 && my.skill6 < 100) //If I press mous left again while the animation is playing { if(my.skill6 == 100) //waituntil the animation is finished, to continue the combo { player.animblend = attack_b; } } else //If you didn`t press mouse left while the attack_a animation { mouse_left_press = 0; combo = 0; player.animblend = blend; //Then stop the combo } DoCombat = FALSE; } Then the same game with attack b; if(player.animblend == attack_b && mouse_left_press == 1) { combo = 2; player.animblend = attack_b; handle_sword_collision(); my.skill7 += 10 * time_step; ent_animate(me,"attack_b",my.skill7,ANM_CYCLE); my.skill7 %= 100; while(my.skill7 < 100){wait(1);} if(mouse_left == 1 && mouse_left_press == 1 && combo == 2) { if(my.skill7 == 100) { player.animblend = attack_c; } } else { mouse_left_press = 0; combo = 0; player.animblend = blend; } DoCombat = FALSE; } Untill I reach attack f. But what happens is; When press mouse left, the player does nothing. PS; everything else works fine.
Last edited by Random; 06/24/11 15:17.
|
|
|
Re: There is something wrong with combos
[Re: Random]
#399334
04/14/12 11:30
04/14/12 11:30
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
I totally forgotten to show, how I solved this :
action my_player
{
...
on_mouse_left = handle_attack;
if(mouse_left_pressed>1)
{
var player_combo_react_time = 0;
while(player_combo_react_time < 5)
{
player_combo_react_time += 1 * time_step;
wait(1);
}
mouse_left_pressed = 0;
}
...
}
and here is handle attack for two attacks a row:
function handle_attack()
{
if(player.animaten_mode == 2)
{
if (mouse_left_pressed == 0)
{
var attack_percentage = 0;
while(attack_percentage < 100)
{
ent_animate(player,NULL,0,0);
ent_animate(player,"oneh_attack_a",attack_percentage,ANM_ADD);
attack_percentage += 10 * time_step;
mouse_left_pressed = 1;
mouse_left = 0;
if(attack_percentage>50 && attack_percentage<85) {player.attacking = 1;}else{player.attacking = 0;}
wait (1);
}
player.attacking = 0;
mouse_left = 0;
mouse_left_pressed = 2;
}
if (mouse_left == 1 && mouse_left_pressed == 2)
{
var attack_percentage = 0;
while(attack_percentage < 100)
{
ent_animate(player,NULL,0,0);
ent_animate(player,"oneh_attack_b",attack_percentage,ANM_ADD);
attack_percentage += 10 * time_step;
mouse_left_pressed = 2;
mouse_left = 0;
if(attack_percentage>5 && attack_percentage<60) {player.attacking = 1;}else{player.attacking = 0;}
wait (1);
}
player.attacking = 0;
mouse_left = 0;
mouse_left_pressed = 0;//if you write mouse_left_pressed = 2, you can add easily more attacks
}
}
}
|
|
|
|