PDA

View Full Version : [AS2] random timer used in game


ScribbleFelix
09-11-2009, 08:23 AM
I wish to create a turn based combat system for a little game im currently making. Right now, i have the character you control via an attack button (player_mc), to do the appropriote attack animation and take down the enemy's health. but what im asking is:
how would i go about creating a timer that makes the enemy attack at random inervals of time, and whilst it is attacking, the player is unable to use his attacks.

i hope that makes sense.

here is my code so far.

thanks.

hitpoints=100
hp1_txt.text=hitpoints
hitpoints2=100
hp2_txt.text=hitpoints2
win_txt._visible=false;
attack_btn.onPress=function(){
_root.player_mc.gotoAndPlay("attack1");
hp2_txt.text-=Math.round(Math.random()*15)+1;
if(hp2_txt.text<0){
hp2_txt.text=0
win_txt._visible=true;
attack_btn.enabled=false;
}
}

whitebabylon
09-15-2009, 06:24 AM
Hey bud.
http://www.youtube.com/watch?v=p8O7mNRWDiU&feature=player_embedded
sorry I am a newb
but I might be able to help. if you go to 1:15 of that video, is that what you would like to do?
basically I created a timer and said if timer = 0 (goes down according to monsters variable of speed) then
monster1
monster2
monster3 (depending on whos timer went down to 0)
variabley drains the life of partymember1 2 3 or 4 (based off of the monster damage variable).
basically doing like
health1.text = health - Monster1DMG / MaxPartymember1Health
now I can bring up specifics if you'd like but it's actionscript 3.0 think it would help you?