Page 1 of 1

CHARGE ATTACK

PostPosted: Sun Nov 25, 2007 6:20 am
by toshiro
Im trying to give my actor two attacks with one button. First he has a regular shooting attack. When you press z he shoots a bullet at you. So basically at the Z button keydown event he creates the actor (bullet) which flies across the screen when its created. Now what i want to do is make it so that after you hold down Z For a specific time it changes the attack to a different actor . for example (press Z once = fire one bullet) (hold Z down for 5 seconds = fire machine gun).So i tried making a variable called (charge_count) and set its start up number to 0.Then i made it so that when Z is pressed the number goes up by 1 and enabled repeat. Therefore when you press and hold Z the charge_count goes up by one and then keeps on increasing until the keyup event.At the keyup event the player will check if the charge_count is above 29 and if so then it would change the type of attack.To me all of my methods seem practical and should work, but they dont. When you hold and realse the Z button it does change the attack, but it does the same thing when you simply press it and it also creates the bullet at the same time; firing two attacks instead of one.I've tried everything i can think of so i guess my coding is off, if you can please help.

heres my coding

[PLAYER]
{DRAW ACTOR}
Code: Select all
chargecount=0;


[PLAYER]
{KEYDOWN(Z)}
Code: Select all
chargecount+1;
(REPEAT)

[PLAYER]
{KEYUP(Z)}
Code: Select all
if (charge_count > 29);
{CreateActor("player_charge1", "machine_gun", "(none)", "(none)", 10, -4, false);};


WHAT AM I DOING WRONG? :?: :?

Re: CHARGE ATTACK

PostPosted: Sun Nov 25, 2007 2:42 pm
by Spidy
[PLAYER]
{KEYDOWN(Z)}
Code: Select all
chargecount+1;(REPEAT)


maybe this chargecount=+1;

Re: CHARGE ATTACK

PostPosted: Sun Nov 25, 2007 9:59 pm
by Rux
You put the set charge_count code on Draw actor instead of Create Actor.

You see, Draw actor does all the actions every frame until destroyed. Create Actor only does the action as soon as the actor is created. If your actor is created at the very beginning of the game with no Create Actor Action, it automatically creates itself.

So put the first code you mentioned on create actor instead of draw actor ok? :)

Re: CHARGE ATTACK

PostPosted: Tue Nov 27, 2007 1:39 am
by toshiro
hey rux i tried what you said but the same thing is still happening... i dont kno maybe the way that i am going about it is wrong. How would you do it? :?: :?: :?: :idea:

Re: CHARGE ATTACK

PostPosted: Tue Nov 27, 2007 1:59 am
by Rux
Hmmmmmmmmmm, *Gasp*! I think you made a script error in the second script. Try
Code: Select all
chargecount = chargecount +1;


If that doesn't work I have something else in mind. Try it first.

Re: CHARGE ATTACK

PostPosted: Wed Nov 28, 2007 1:41 am
by toshiro
OMG! why is it still not working? :? what else can i try?

Re: CHARGE ATTACK

PostPosted: Wed Nov 28, 2007 9:35 am
by Spidy
yep i said that two :x

Re: CHARGE ATTACK

PostPosted: Wed Nov 28, 2007 10:29 am
by Kalladdolf
Spidy wrote:
[PLAYER]
{KEYDOWN(Z)}
Code: Select all
chargecount+1;(REPEAT)


maybe this chargecount=+1;

chargecount +=1
!!!

Re: CHARGE ATTACK

PostPosted: Wed Nov 28, 2007 10:57 am
by Spidy
yeah thats what i mean