So, today I’m gonna drop some info about the new combat system which I’ve been writing, and compare it to the previous version that’s been running.
In the previous version, everything was very ‘literal’, each ship had armour, a list of target priorities, number of shots it can fire at each target, and the amount of damage that shot will do to a ship.
This posed a pretty significant problem with ‘partial damage’, as well as moving through ship groups. Simply, The engine calculated the number of shots needed to destroy a target, and based the amount of possible damage on that. If a shot was configured to kill 1.5 fighters, it would only ever kill one (excess damage was ignored), if a shot was configured to kill 0.8 fighters, it would take two shots to kill a target with the aforementioned ignoring of excesses damage. This resulted in a lot of ships only performing half the damage they were supposed too, which left a lot of the ‘real world’ numbers completely off from where they were supposed to be, and while adding smaller corrections to help balance them out, it was impossible to correct fully.
In addition, because the shots were handled so literally, after a ship had fired on one type of ship, it couldn’t cycle across to the next, this caused the infamous Battleship vs Bomber and Fighter scenario, where shots had been fired at one target, therefore it didn’t move onto the next. Again, I mitigated some of these behaviours, although wasn’t able to correctly resolve them.
So this brings us onto the new code, and what I’ve done to resolve this.
Primarily, everything has been simplified down to 3 variables:
- Hit Points (HP) - Amount of damage a ship can take before it’s destroyed
- Attack Points (AP) - Number of times a ship can attack
- Effective Damage (ED) - The number of hit points a single Attack Point removes from a target.
The first thing the code does is combine all fleet hit points and attack points into some relatively large numbers on a per-unit basis. Assuming you have 100 fighters, with 10 HP and 10 AP, the code will internally convert that to a total of 1000HP and 1000AP. These are the numbers the engine will now use when working with anything.
Those fighters then attack a group of 25 bombers, Bombers have 15HP and 5AP, internally represented as 375HP and 125AP.
As we know, fighters are great against bombers, so have an ED of 30 against them.
We run the maths, The number of AP needed to cause 750 points of damage is 25. The fighters easily dispatch of the bombers. The large AP number for the fighters now drops to 975 available for the next ship, or next fleet that comes along.
While the bombers are flagged as ready to be destroyed, in the interests of fairness, they’ll continue attacking while they have AP available in this fight, but they only have an ED of 5 against them. Unfortunately, It’ll require 200AP to destroy all of the fighters, and there’s only 125AP available. All AP is used to attack the fighters, causing 625HP of damage to the fighters. The bombers available AP drops to 0, and the fighters HP drops from 1000 to 375, then the next phase of combat begins, whatever that may be.
The code works by ensuring that both hit points, and attack points are generic and not ‘bound’ to any specific stage of combat or combat behaviour. They are monitored and maintained as combat progresses so if a ship class is destroyed, the remaining attack points from the attacker migrate cleanly to the next ship / battle, if a ship is damaged during a phase, that damage will persist through the rest of combat. This all obviously happens behind the scenes, and isn’t visible to the player.
Now, one of the interesting things which this allows, is to reorganise how combat actually occurs. Before now the following happens:
- All Fleets are Merged into ‘Allied’ Fleets
- Fleets are ordered by score (the only real persistent metric I’ve had)
- The current highest scoring fleets will fight the next highest scoring fleet it’s not faced before
- Unit Counts and Fleet Scores are updated
- Goto 2, until all fleets have fought all fleets.
This has always historically had the negative effect of potentially having a fleet, which has completely exhausted it’s ability to shoot (due to an earlier large fight), having smaller fleets getting lots of ‘free kills’ because it can’t shoot back.
What I’m able to do now, is change point 2 to be based on the available AP of a fleet, this should allow larger fleets which go first to shuffle down the list and allow the smaller fleets to fight amongst themselves for a while before they become involved again, where hopefully the smaller fleets will have exhausted a lot of their ability to attack before getting free reign over a larger fleet.
Anyway, hope that helps people understand the problems and solutions to combat, and give us some better performance going forwards.
Until next time.