If ship A can deal 8 damage per second, and ship X can deal 2 damage per second, but ship A has 100 hp and ship X has 20 hp, then if we make the following approximations:
1) firepower of ship A is a linear function
2) firepower of ship A is 8hp/s when t=0s
3) firepower of ship A is 0hp/s when t= (health) / (damage per second of ship X) = 100 hp / (2hp/s) = 50s
and then apply the same assumptions to ship X:
4) firepower of ship X is a linear function
5) firepower of ship X is 2hp/s when t=0s
6) firepower of ship X is 0hp/s when t= (health) / (damage per second of ship A) = 20 hp / (8hp/s) = 2.5s
then we can say:
The battle will last exactly 2.5 seconds (by assumption (6), ship X has 0 firepower at t=2.5s).
damage-dealt by ship B = integral from t=0s to t=2.5s of firepower(t)dt
where firepower(t) = mt + b
and b = firepower(t=0) = 8hp/s (by assumption (2))
and firepower(t=50s) = 0 (by assumption (3))
m = ?
sub t=50s
(0) = m(50s) + 8hp/s
(-8hp/s) / (50s) = m
m = -0.16hp*s^-2 (per second squared)
sub m into firepower(t)
units in "[]" for simplification
firepower(t) = mt + b
firepower(t) = (-0.16[hp*s^-2])*t + (8[hp*s^-1])
Note: firepower = damage dealt / second
so for ship A, firepower(t) = instantaneous rate of damage
Check: At t=2.5s, ship A is destroyed i.e. damage dealt = 20hp
sub damage dealt(t=2.5s) = 20hp into equation:
damage-dealt by ship B (onto ship A) = integral from t=0s to t=2.5s of firepower(t)dt
(20hp) = integral from t=0s to t=2.5s of (-0.16[hp*s^-2]t + 8[hp/s])dt
Aside: Integral of firepower(t)dt = (1/2)(-0.16[hp*s^-2])t^2 + 8[hp/s]*t
We want the integral from t=0s to t=2.5s,
Let F(t) = Integral of firepower(t)dt
Recall: integral from t=0s to t=2.5s of firepower(t)dt = F(2.5s) - F(0s)
Substitute into equation:
20hp = (F(2.5s) - F(0s))
20hp = (-1/2[hp*s^-2*s^2] + 20[hps^-1*s]) - (0 + 0)
20hp = 19.5[hp]
LS NOT = RS
But was the assumption valid?
If LS NOT = RS, then this indicates that
while assumptions (4) to (6) (i.e. ship A deals maximum-damage to ship X for the entire battle)
give us an output of damage(t=2.5s) = 20hp;
our assumptions (1) to (3) (i.e. firepower of ship X is decreasing linearly)
gives us an output of damage(t=2.5s) = 19.5hp
In summary: Assumption (6) requires that assumption (3) is false; assumption (3) requires that assumption (6) is false. But if we do not want the server to recalculate change in firepower for ship A after every shot fired by ship X, then assumptions (3) and (6) are advantageous.
What about the damage that ship X dealt, before it was destroyed?
Damage-dealt by ship X = integral from t=0s to t=2.5s of firepower(t) FOR SHIP X.
By assumption (6), firepower(t) FOR SHIP X = mt + b
Note: This is different than firepower of ship A, as we are now looking at the damage dealt by ship X onto ship A.
b = firepower(t=0) = 2hp/s (by assumption (5))
firepower(t=2.5s) = 0hp/s (by assumption(6))
m = ?
By our method, we get:
m = -0.8hp*s^-2
Remark: It is ok to have a different m-value, because to start-with, the firepower of ship X was less than ship A's. We are just using assumptions (4) to (6) instead of (1) to (3) to calculate damage dealt by ship X onto ship A.
If firepower(t) FOR SHIP X = (-0.8[hp*s^-2])t + (2[hp*s^-1]) then
Damage dealt by ship X = integral from t=0s to t=2.5s of firepower(t) FOR SHIP X.
By our method, we get:
Damage dealt by ship X = -2.5[hp] + 5[hp] = 2.5hp
Check: ratio of damage dealt at t=2.5s ~ ratio of firepower(t=0s)?
(2.5hp) / (19.5hp) ~ (2hp/s) / (8hp/s)
0.128 ~ 0.25
Considering that firepower(t=2.5s) ~1 for ship A, but =0 for ship X, 0.128 ~ 0.25 :)
Conclusion: for t=2.5s
Damage dealt by ship A = 19.5 hp
Damage dealt by ship X = 2.5hp
19.5hp < 20 hp, therefore ship X has not been destroyed, and the battle must calculations must be redone after considering the new firepower values at t=2.5s and applying assumptions (1) to (6).
Analysis:
Question: So the above calculations need to repeated an infinite number of times before ship X is actually destroyed?
Answer: I need help determining the actual length of the battle (at what time is ship X destroyed)? We need to know when ship X reaches hp = 0, so that the client CPU can show the player and animation for the ship blowing-up (i.e. Ka-Boom) and so that firepower values never become negative.
Question: What if the battle is interrupted i.e. ship X is not engaged for a full 2.5s?
Answer: We use the above methods to calculate the damage taken at t = time of disengagement (integral from t=0s to t=time of disengagement) for each ship, update the targetting info, and use the above methods to recalculate the firepower(t) for our entire fleet.
Phenoca writes: Ships can have firepower(t) > 0 against multiple targets. Firepower of each ship is affected by on the weaponry of the attacking ship, defense of target, distance to target, and an arbitrary percent-modifier (multiplies firepower by 0.0 to 1.0). Each ship chooses from its available targets via the targetting method (a sub-method of the tactical method).
So for an entire Fleet, we actually have individual ships (or sub-groups) where the above calculations are applied. I.e. For A, B, C vs. X, Y, Z we have a calculation for firepower(t) of:
A onto X
X onto A
A onto Y
Y onto A
A onto Z
Z onto A
B onto X
X onto B
B onto Y
Y onto B
B onto Z
Z onto B
C onto X
X onto C
C onto Y
Y onto C
C onto Z
Z onto C
lol
Problem: When calculating A onto X (see above list), we assume that firepower of X onto A = 0 and that firepower Y onto A = 0, which is not true! (Firepower of both ships would not be decreasing linearly since assumptions (3) and (6) are not true in real life.)
Solution: The targetting method makes some cunning assumptions, such implementing a function, firepower(t) of Fleet (X,Y,Z) onto ship A. There would also be functions Fleet (A,B,C) onto ship X, Fleet (A,B,C) onto ship Y, and Fleet (A,B,C) onto ship Z, such that firepower(t) = (m1)t + b1 + (m2)t + b2 + (m3)t + b3
I have not considered whether or not the above targetting method is plausible. If you understand this problem, please tell me, and offer help! This is because I have never encountered a problem like this, with… A potentially infinite amount of variables involved! (If the size of either fleet is complex - hohoho :)
Feedback Requested: Can we incorporate assumptions (1) to (6) in fleet-battles, using the (as-of-yet undiscussed) "arbitrary percent-modifier" and "targetting method" to factor-in the effects of tactical-manoeuvres?