I'm trying to do an RTS type fight system (like you would have in Age of Empires or something like that) in a C++ game engine. I'm having trouble with exactly what is required and it is rather buggy. I wonder if there are some tips for how to do this? I'm not including any code, as it is quite long.
My current program is something like this:
-Check if two units are on opposing teams and close enough to start a battle
-Move friendly unit to next to enemy unit.
-Mark the two units as battling and ineligible for checking for further fights.
-Start a timer for each unit. When it reaches a certain value, they deal their damage. Enemy and friendly unit have separate timers.
-If the timer reaches its value and the target is not there to hit, then end the fight for that unit.
The trouble is, this system is quite slow to respond if there are units pulled away from battles (like if a user moves away a unit from a battle manually).
Just curious, what is the advantage of "locking" them in combat with each other and preventing anyone else from attacking them? This makes Zurgling rush style swarm beatings impossible.