I am working on a combat system with multiple opponents. In order to create a "turn based" system in which each combtant takes their turn, I have established an array with all of the applicable characters involved. That would be, for example:
(set:$group to (a:$hero,$opp1,$opp2,$opp3))
In which the elements are datamaps that contain information like hit points (HP), weapon damage, and other values that are involved with the combat math.
What I want to do, through combat is remove one of the items from that array when that item's HP is at or below zero. The code I have is currently:
(if:$opp1's hp is <=0)[(set:$group to it - (a:$opp1))]
The idea being that as the rounds continue, $opp1 would be removed from the sequence and their turn skipped until all enemies are killed.
However, when I "kill" an opponent--$opp1-- the array $group retains $opp1 and shuffles them through the sequence of combat.
Here is a truncated version of the code I am using...
<!-Combat Init-!>
(set:$turn to 1)
(set:$group to (a:$hero,$opp1,$opp2,$opp3))
(set:$attacker to $group's ($turn))
<!-Combat Screen-!>
(link:'Attack')[(set:$target to $opp1)(goto:'Combat Roll')]
(link:'Attack')[(set:$target to $opp2)(goto:'Combat Roll')]
(link:'Attack')[(set:$target to $opp3)(goto:'Combat Roll')]
<!-Combat Roll-!>
(set:$attroll to (random:1,20))
(set:$attrolltot to $attroll + $attacker's weapon's bonus)
(if:$attrolltot is >=$target's body)[
(if:$target is $opp1)[(set:$opp1's hp to it - $attacker's weapon's dam)
(if:$opp1's hp is <1)[(set:$group to it - (a:$opp1))]]
(if:$target is $opp2)[(set:$opp2's hp to it - $attacker's weapon's dam)
(if:$opp2's hp is <1)[(set:$group to it - (a:$opp2))]]
(if:$target is $opp3)[(set:$opp3's hp to it - $attacker's weapon's dam)
(if:$opp3's hp is <1)[(set:$group to it - (a:$opp3))]]
(if:$target is $hero)[(set:$hero's hp to it - $attacker's weapon's dam)]
]
(set:$turn to it + 1)(if:$turn is > $group's length)[(set:$turn to 1)]
(set:$attacker to $group's ($turn))
(goto:'Combat Screen')
Is this method possible to have a turn-based sequence for combat? Is there a better way to do sequencing for multiple combatants than to use arrays?
Thanks!