-
Turn Based Battle System wont work
Sup,
Firstly this is probably a basic mistake
Basically I am making a Turn Based battle system.
Each Frame is an attack.
So for the enemy I did this:
(in scene Frame)
attack = Math.round (Math.random ()*2)+0;
so it would randomly attack
then I also put in this in an object INSIDE my enemy clip
onClipEvent(enterFrame){
onClipEvent(enterFrame){
if (_root.attack == 1 || _root.attack == 2){
_root.bad.play();
}
if (_root.attack == 0){
_root.bad.gotoAndPlay(12);
}
}
you see what ive tried to do here havent you?
why isnt it working? it plays, the random value thing works(used dynamic text box to check this) so what am i missing? (using AS2)
-
-
okay it works to this extent:
if the first value is 0, it does the right attack for 0. However when the value changes to one or two, it still does the attack for 0.
if the first value one or two it does the attack for one or two, but if it changes to 0 the attack is still the attack that shud be played for one or two
i know each time the values change coz i got a dynamic text box telling me so.
EDIT: I will just use an else condition, seems to make sense
EDIT: Wont really work at all now
Last edited by cheeseman62; 09-07-2009 at 03:32 AM.
-
How come you have 1 and 2 in the same if statement?
-
try this
code:
onClipEvent(enterFrame){
if (_root.attack == 0){
_root.bad.gotoAndPlay(12);
} else {
_root.bad.play();
}
}
-
i did the code...
it works perfectly:
wen attack = 1 or 2 the enemy defends.
wen attack = 0 the enemy attacks.
the attacks randomly happen like this, most of the time the enemy defends. nice
however i have a text box telling me attacks value.
it says: 0 and sometimes the enemy will defend, or indeed attack
same wen it says either one or two... now i know i might be getting fussy but its worrying coz it might stop me from making more enemies with random attacks as i wont know if the attacks work if their unlikely to happen. such as if attack = 1 to 49 the enemy defends. if it = 50 the enemy attacks.
if attack in the dynamic text box shows 50 and the enemy still defends i might question if attack really works when it actually does, so what is going wrong in the dynamic text box?
thanks for all the help so far
-
I have no idea what you mean.. do you mean even though the value says 0 the enemy does both attack and defend?
-
sorry my wordings bad...
enemy shud ATTACK wen attack variable = 0;
however wen the dynamic text box that displays attack variable shows a value of 0 (Despite the code) the enemy EITHER defends or attacks.
and vise versa for the other two values...
is it clearer now?
-
so you mean you never know what its going to do despite the attack variable number
-
-
put this on your enemy and get rid of the line
attack = Math.round (Math.random ()*2)+0;
code:
onClipEvent(load){
attack = random(3);
}
onClipEvent(enterFrame){
_root.textbox.text = attack;
if (attack == 0){
_root.bad.gotoAndPlay(12);
} else {
_root.bad.play();
}
}
works fine for me
-
oh btw, i hope you know that the code isnt actually placed on the movie clip on stage (wer u right click the movie clip and select actions)
its all placed, even the text box, in a square clip on 2nd frame of the enemy clip.
anyway it didnt work but i guess ill hav to live with that, thanks for all the help. if you wanna check out my file and see whats wrong just ask, but anyway its not that big a deal, at least the random attacks work fine
Last edited by cheeseman62; 09-07-2009 at 11:44 AM.
-
attach your fla and i'll have a look
-
http://www.box.net/shared/zgtsx0d0be
thanks for the help
btw the game looks a bit crappy but this is a test.
-
its saying 'unexpected file format' when i try to open it.. are you running flash8 or cs3.. if its cs3 you will need to save it as flash8 so i can see it
-
-
any way to make it viewable for flash8?
-
nope, only viewable for cs3, those are the only two options that come up... still im okay with the random attacks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|