pikachurian
Member
I'm making a turn based battle system. I have a battle manager object with a switch state machine. Each state has code that executes for the first frame in that state. The enemies in the battle are stored in an array in the battle manager. During the first frame in the enemy turn state, the battle manager loops through the enemy array, and executes the enemy's select attack function. For some reason, each enemy executes this script twice. Any ideas?
Battle Manager Code
Enemy Create Event
Battle Manager Code
GML:
case BS.enemy:
if(stateJustSwitched == true)
{
debugEnemySetupRepeats += 1
var _forLoopRepeats = 0
hasSelectedUnique = false
attackLength = 1 * room_speed
for(var i = 0; i < array_length(enemies); i++)
{
with(enemies)
{
SelectAttack()
}
_forLoopRepeats += 1;
if(enemies.attacks[enemies.currentAttack,E_ATTACK_INFO.length] > attackLength)attackLength = enemies.attacks[enemies.currentAttack,E_ATTACK_INFO.length];
}
show_debug_message(string(_forLoopRepeats))
stateJustSwitched = false
}
GML:
SelectAttack = function()
{
currentAttack = irandom_range(0,1)
if(currentAttack = 1)show_debug_message("Unique "+string(id))
}
Last edited: