Hey guys, its been awhile. I would like to ask for 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.
case[COLOR=SeaGreen] "Bullseye"[/COLOR] :
if ([COLOR=Blue]_root[/COLOR].battleStatus == 6) {[COLOR=DimGray]//If it is enemy's turn [/COLOR]
if ([COLOR=Blue]_root[/COLOR].playerStatus == [COLOR=SeaGreen]"none"[/COLOR] &&[COLOR=MediumTurquoise] [COLOR=Blue]_root.enemymana>=20[/COLOR][/COLOR]) { /[COLOR=DimGray]/If player does not has a status, and enemy's mana is over 20[/COLOR]
[COLOR=Blue] _root[/COLOR].attackChance =[COLOR=Blue] random([/COLOR]10-1)+1;[COLOR=DimGray] //roll attackChance[/COLOR]
if ([COLOR=Blue]_root[/COLOR].attackChance == 1||[COLOR=Blue]_root[/COLOR].attackChance == 2||[COLOR=Blue]_root[/COLOR].attackChance == 3||[COLOR=Blue]_root[/COLOR].attackChance == 4) { [COLOR=DimGray]//40% chance[/COLOR]
enemyAttackList = [];[COLOR=DimGray] //Clears the list[/COLOR]
enemyAttackList[COLOR=Blue].push[/COLOR]([COLOR=SeaGreen]"Laser Blast"[/COLOR],"[COLOR=SeaGreen]Arrow Shot","Focus"[/COLOR]);[COLOR=DimGray] //Adds a new set of attacks[/COLOR]
currentAttack = enemyAttackList[[COLOR=Blue]random[/COLOR](3)]; [COLOR=DimGray]//randomizes the list for the current attack[/COLOR]
[COLOR=Blue]trace[/COLOR](_root.attackChance)
} else { [COLOR=DimGray]//If attackChance does not roll onto the numbers[/COLOR] above
enemyAttackList = [];
enemyAttackList.[COLOR=Blue]push[/COLOR]("[COLOR=SeaGreen]Normal[/COLOR]");
currentAttack = enemyAttackList[0]
[COLOR=Blue]trace[/COLOR]("[COLOR=SeaGreen]_root.attackChance did not return.[/COLOR]")
}
} else{[COLOR=DimGray] //If the player HAS a status and/or enemy's mana is [/COLOR][COLOR=Gray]under 20[/COLOR]
enemyAttackList = [];
enemyAttackList.[COLOR=Blue]push[/COLOR]("[COLOR=SeaGreen]Normal[/COLOR]");
currentAttack = enemyAttackList[0];
}
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