/* The first text game in the actionscript3.0 language [the Man of the ages is in the rivers and lakes]
Author: KKK
Date: 2010-07-22
Function.
HONG Xing's other handsome fit guy, Jin Kun, plans to attack John B to help Chen haonan fight for death and death.
At the end of the war, today is not your death or my death
*/
VaR hero: Object = new object ();
VaR BOSS: object = new object ();
Hero. Name = "@ Chen haonan @";
Hero. HP = 100; // life value
Hero. ATT = 90; // Attack Strength
Hero. Def = 88; // defensive capability
Hero. AgI = 60; // agility
Hero. skill1 = "Fist ";
Hero. skill2 = "Tie chain ";
Hero. skill3 = "steel pipe ";
Boss. Name = "# Kun #";
Boss. HP = 120; // life value
Boss. ATT = 92; // Attack Capability
Boss. Def = 90; // defensive strength
Boss. AgI = 22; // agility
Boss. skill1 = "fliggy ";
Boss. skill2 = "Knife ";
Boss. skill3 = "Machete ";
VaR Timer: timer = new timer (1000 );
// Send an event at an interval of 1000 milliseconds
Timer. addeventlistener (timerevent. Timer, round );
// Listen for events
Timer. Start ();
Function whoattacks (A: object, B: Object): Array {
Return A. AgI * Math. Random ()> B. AgI * Math. Random ()? [A, B]: [B, a];
}
Function round (E: timerevent): void {
VaR damage: number;
VaR skillindex: uint;
VaR roundfight: array = whoattacks (hero, boss );
VaR attacker: Object = roundfight [0];
VaR defender: Object = roundfight [1];
Damage = attacker. ATT * Math. Random ()-defender. Def * Math. Random ();
If (damage <= 0 ){
Damage = 0;
} Else {
Damage = math. Ceil (DAMAGE );
// The damage value is rounded up.
}
Defender. HP-= damage;
If (damage <attacker. ATT/3) {// select the attack mode based on the Damage Value
Skillindex = 1;
} Else if (damage <attacker. ATT * 2/3 ){
Skillindex = 2;
} Else {
Skillindex = 3;
}
Trace (attacker. Name + "" + defender. Name + "" +
Attacker ["skill" + skillindex] + "," + defender. Name +
"Loss" + damage + "Point HF ");
If (defender. HP <= 0 ){
Trace (defender. Name + "Top 5, down \ n" + attacker. Name +
"Win ");
Timer. removeeventlistener (timerevent. Timer, round );
// Remove the listener
Trace ("\ Ngame over ");
Return;
// Exit the program
}
Trace (hero. Name + "HP:" + hero. HP + "\ t" +
Boss. Name + "HP:" + boss. HP + "\ n ");
}