Page 1 of 1

Fighter Combos

PostPosted: Fri Jul 04, 2008 5:25 pm
by dmuhsin
Hello world! This will be my first post I am fairly new to GE, and I am working on a "Double Dragon" type game, and I was wondering if anyone could help me with fighter combos, I wanted to setup the controls where If the player pressed the A key the character would punch but if they pressed a combination of keys like AAA on the final pressing of the A the character would change to a different animation. I have searhed the forum and could not find anyone talking about this and figured it must be common knowledge and I am just a rookie.

any information would be greatly appreciated


Plant you now, dig you later :)

Re: Fighter Combos

PostPosted: Fri Jul 04, 2008 6:16 pm
by 4erv'
To change animation when AAA is pressed, just make a key down event, with "a a a" keys, and change "Execute when:" to "Keys are pressed in order",
but on pressing first a, the actor would punch anyway. :?

Re: Fighter Combos

PostPosted: Fri Jul 04, 2008 6:35 pm
by Thanx
Well, no matter what, you'll have to do a very bit of coding....
step 1: Make a Create Actor event, the select the Script Editor as the action. Click on the variables button. Add a variable, I'll call it combos, but ou name it whatever you want. Make it an integer.
step 2: So you have the script editor open, write this line of code:
combos = 0;
instead of combos enter the name of the variable, but you know that... press ok, make this an Immediate Action...
step 3: Now I'm sure you have an action for the key down.... open it up, inthe script editor, do this:
combos ++;
if(combos == 3)
{
ChangeAnimtaion(... You'll use the generator and select whatever);
combos = 0;
}
else
{
do non-combo action
}

What this code does, is that it counts how many times yo hit the key, and if it is 3, then it changes the animation, and resets the veriable to 0.
If you want to make it so that this only happens if someone presses the keys fast, then the code is just a bit longer:
DestroyTimer(The timer you created);
combos ++;
if(combos == 3)
{
ChangeAnimation(Same as before);
combos = 0;
}
else
{
do non-combo action
}
CreateTimer("Event Actor", sometimer you created that lasts a few hundred, or maybe a little over a thousand miliseconds);
Now you'll also need to create a Timer event, use the script editor, and say
combos = 0;

What this does, is that when you press the button it destroys any ongoing timers, enabling the combos to ever reach 3. But it also creates a new one, so that if that one reaches its time, then the combos are back to three, and if you want the combo, then you have to try again...
If you have anymore questions, just ask! :wink:

Re: Fighter Combos

PostPosted: Sat Jul 05, 2008 10:41 am
by DST
Good explanation, thanx!

Creating and killing a timer is useful for many things!

Re: Fighter Combos

PostPosted: Sat Jul 05, 2008 10:21 pm
by dmuhsin
Thank you "Thanx" this was a great explanation I figured I had to do something with a variable, but you laid it out (so to speak) very clear and I also [imgthank everyone for the rapid response I think this will help a lot of people

Re: Fighter Combos

PostPosted: Sun Jul 06, 2008 11:40 pm
by dmuhsin
Hey thanx I tried using the code do non-combo action and game editor gave me an error message saying non is a undeclared identifier heres what I entered

combo++;

if (combo==3)

{
ChangeAnimation("Event Actor", "Spinbackfist", FORWARD);
}

else

{

do non-combo action

}

Re: Fighter Combos

PostPosted: Wed Jul 09, 2008 1:51 pm
by Game A Gogo
dmuhsin wrote:Hey thanx I tried using the code do non-combo action and game editor gave me an error message saying non is a undeclared identifier heres what I entered

combo++;

if (combo==3)

{
ChangeAnimation("Event Actor", "Spinbackfist", FORWARD);
}

else

{

do non-combo action

}


You need to replace that with the normal animation :3

Re: Fighter Combos

PostPosted: Wed Jul 09, 2008 3:36 pm
by DST
'do non combo action' is not a command.
Also if did you declare the variable 'combo', in the variables tab?
also, when the animation changes to spinbackfist, make sure to reset combo to 0 again.

Re: Fighter Combos

PostPosted: Mon Jul 14, 2008 8:30 pm
by Thanx
Just to make this clear to anyone who'd use this topic to do this type of a thing: "do non-combo action" is no type of command, as DST said...
I assumed that if you use a control 3 times, then you'd have an action for using it once. You obviously have your own codes for that - ChangeAnimation, PlaySound, whatever - put those codes there, and don't use what I marked it with!
Cheers! 8)