ForumsProgramming Forum[AS2] Turn-based Enemy AI.

1 3548
Jephz
offline
Jephz
2 posts
Nomad

Well guys, first time here on Xgen forums. Would like to consult some help regarding simplifying my code here.

I'm currently programming a turn-based game, and am trying to get into a more intermediate level of enemy Ai.

I tried to make it as readable as possible. Its messy I know, which is why I'm asking if there is a way to "clean up" this block of code.

Any help would be appreciated.

-Jephz

<br><br>case "Bullseye" :<br>            if (_root.battleStatus == 6) {//If it is enemy's turn<br>                if (_root.playerStatus == "none" && _root.enemymana>=20) {  //If player does not has a status, and enemy's mana is over 20<br>                    _root.attackChance = random(10-1)+1; //roll attackChance<br>                    if (_root.attackChance == 1||_root.attackChance == 2||_root.attackChance == 3||_root.attackChance == 4) { //40% chance<br>                        enemyAttackList = []; //Clears the list<br>                        enemyAttackList.push("Laser Blast","Arrow Shot","Focus"); //Adds a new set of attacks<br>                        currentAttack = enemyAttackList[random(3)]; //randomizes the list for the current attack<br>                        trace(_root.attackChance)<br>                        <br>                    } else { //If attackChance does not roll onto the numbers above<br>                        enemyAttackList = [];<br>                        enemyAttackList.push("Normal");<br>                        currentAttack = enemyAttackList[0]<br>                        trace("_root.attackChance did not return.")<br>                    }<br><br>                } else{ //If the player HAS a status and/or enemy's mana is under 20<br>                    enemyAttackList = [];<br>                    enemyAttackList.push("Normal");<br>                    currentAttack = enemyAttackList[0];<br>                }<br>                    <br><br>
  • 1 Reply
Jephz
offline
Jephz
2 posts
Nomad

Well, I just realized Armor Forums doesn't support color coding, so heres a pic of the code (More readable). I hope it works.

http://i50.tinypic.com/2ciadco.jpg

Showing 1-1 of 1