Building a Reliable Combat System

Sorry for all the questions recently! Thank you to everyone who spent time to read the posts and double thank you to those who replied. :smiley:

So how to build a reliable combat system in GD? I have tried several approaches but they all have problems. The main problems are:

  1. Selecting a target within range. Sometimes a target in range is selected and then immediately another is selected and then both enemies think they are being attacked when only one of them is…

  2. Releasing a target after combat - When combat finishes, units just stand around thinking they are still in combat and won’t do anything else.

  3. Units being killed by ranged units while also being attacked by melee units. Sometimes the melee units continue to stand in one place and think they are fighting the unit that just died…

I tried using linked objects and some variables to control what is happening, but there are big problems in all the implementations I have tried. :confused:

I believe I have managed to sort out the issues. If I don’t see any problems in the next few days, I’ll put the battle code up here for everyone to see. I do not think it is very good code (inefficient), it does appear to work.