There is something wrong with combos

Posted By: Random

There is something wrong with combos - 06/18/11 22:26

So im almost finished with my new player moment.
And ofcourse there is a problem grin
What I want;

When I press mouse left, the player should start his combo.
Moreover when I press mouse left again, the player should continue his combo.

What happens;

My player only attacks with his first attack (no combo)

Here is the code part;


Click to reveal..
var combo = 0;
if(mouse_left == 0 && mouse_left_press == 1) mouse_left_press = 0;
if(mouse_left == 1 && mouse_left_press == 0 && combo == 0)
{
my.animblend = attack_a;
handle_sword_collision();
my.skill6 += 10 * time_step;
ent_animate(me,"attack_a",my.skill6,ANM_CYCLE);
DoCombat = FALSE;
mouse_left_press = 0;
combo = 1;
}
if(mouse_left == 1 && mouse_left_press == 0 && combo == 1)
{
my.animblend = attack_b;
handle_sword_collision();
my.skill7 += 10 * time_step;
ent_animate(me,"attack_b",my.skill7,ANM_CYCLE);
DoCombat = FALSE;
mouse_left_press = 0;
}


Thanks futuremore (i hope)
Posted By: Aku_Aku

Re: There is something wrong with combos - 06/19/11 16:49

Seems to me your code has some flaws but should work.
You can check wich part of your function is executed if you place printf statements in each part.
Like this:
Code:
printf("combo-0");


or
Code:
printf("combo-1");


Posted By: Redeemer

Re: There is something wrong with combos - 06/19/11 16:56

Quote:
You can check wich part of your function is executed if you place printf statements in each part.

Or, you can tackle the problem like a real programmer would with a debugger.

Figure out how the Gamestudio debugger works and trace through your code a little bit. It'll soon be clear what the problem is if you do that.

I can see the logical error you have in your code as I write this, but I think it's important that you learn to fix issues such as these yourself, so I leave this up to you as an exercise. wink
Posted By: Lukas

Re: There is something wrong with combos - 06/19/11 17:18

In case you can't solve Redemeer's exercise, notice that you check for a combo immediately after you did the first attack, which means the combo attack will always be executed at the same time as the first attack, because you just set combo = 1; before that.
Posted By: Random

Re: There is something wrong with combos - 06/19/11 18:23

Wow, that was a fast respawn grin
Thanks for the tipps, when im done I post the script here for thoses who also were interrestet.
Posted By: Random

Re: There is something wrong with combos - 06/19/11 20:08

And please, nobody tell me what the problem is now.
Posted By: Random

Re: There is something wrong with combos - 06/20/11 15:31

Ämm, why isn`t this working?

Click to reveal..
if(mouse_left == 0 && mouse_left_press == 1) mouse_left_press = 0;
if(mouse_left == 1 && mouse_left_press == 0 && combo == 0)
{
player.animblend = attack_a;
handle_sword_collision();
my.skill6 += 10 * time_step;
ent_animate(me,"attack_a",my.skill6,ANM_CYCLE);
while(my.skill6){wait(1);}
if(my.skill6 = 100){wait(1); DoCombat = FALSE; mouse_left_press = 0; combo = 1;}
}
if(mouse_left == 1 && mouse_left_press == 0 && combo == 1)
{
player.animblend = attack_b;
handle_sword_collision();
my.skill7 += 10 * time_step;
ent_animate(me,"attack_b",my.skill7,ANM_CYCLE);
while(my.skill7){wait(1);}
if(my.skill7 = 100){wait(1); DoCombat = FALSE; mouse_left_press = 0; combo = 2;}
}
if(mouse_left == 1 && mouse_left_press == 0 && combo == 2)
{
player.animblend = attack_c;
handle_sword_collision();
my.skill8 += 8 * time_step;
ent_animate(me,"attack_c",my.skill8,ANM_CYCLE);
while(my.skill8){wait(1);}
if(my.skill8 = 100){wait(1); DoCombat = FALSE; mouse_left_press = 0; combo = 0;}
}


Doesn`t (for exsample) "if(my.skill6 = 100)" meen;
If the animationen is played to 100 prozent then...???
Posted By: Pappenheimer

Re: There is something wrong with combos - 06/20/11 15:37

It is unlikely that it hits exactly the value 100.
Try f.i. >= 95
Posted By: Superku

Re: There is something wrong with combos - 06/20/11 15:39

Additionally,
if(my.skill6 = 100)
sets skill6 to 100, you forgot one "=". As Pappenheimer has already said, you should not write it, though.
Posted By: Random

Re: There is something wrong with combos - 06/20/11 16:13

Yes, youre right it doesn`t work...
But it makes to me no sence, look;

if(my.skill8 >= 95)

Everything I write after that should happen after the animation is finished, so;

DoCombat = FALSE; mouse_left_press = 0; combo = 1;

Now combo is set to 1 and mouse_left_press ist set to 0 again.

Why does this function dosen`t start then???;

if(mouse_left == 1 && mouse_left_press == 0 && combo == 1)

This is wired...
Posted By: muffel

Re: There is something wrong with combos - 06/20/11 16:44

What does the while-loop do there in the if-blocks
For me they look like endless loops

while(my.skill6){wait(1);}

Maybe you should write better:

while(my.skill6 < 99 ){wait(1);}
DoCombat = FALSE; mouse_left_press = 0; combo = 2;

muffel
Posted By: Random

Re: There is something wrong with combos - 06/20/11 16:54

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!
Posted By: Widi

Re: There is something wrong with combos - 06/20/11 16:57

while(my.skill6){wait(1);

This line wait till my.skill6 = 0 (= false)
Posted By: Random

Re: There is something wrong with combos - 06/20/11 20:31

I was so sure this would work, but it doesn`t;
(combo function full)
Click to reveal..
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.
Click to reveal..
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;
Click to reveal..
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;
Click to reveal..
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.
Posted By: Random

Re: There is something wrong with combos - 04/14/12 11:30

I totally forgotten to show, how I solved this grin :

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

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


© 2024 lite-C Forums