Beam damage overflowing to other stacks |
Fri, 19 November 2004 19:20 |
|
|
I've been trying to figure out how beam damage should overflow onto another target token. The issue is that the range and number of deflectors on the other token (both of which modify damage) are probably different to the original token.
This led me to the conclusion that Stars! must keep track of the "base" damage that has been "spent" at any particular time, leading to the following pseudo-code...
baseDamage = weaponDamage * weaponCount
while baseDamage > 0
pick most attractive target in range
if no suitable target
exit
end if
damageMultiplier = rangeMultiplier * deflectorMultiplier * capacitorMultiplier
if shields > baseDamage * damageMultiplier
shields = shields - baseDamage * damageMultiplier
baseDamage = 0
else
baseDamage = baseDamage - shields / damageMultiplier
shields = 0
if not sappers
kills = baseDamage * damageMultiplier / targetArmourPerShip
if kills > numberOfShipsInTargetStack
kills = numberOfShipsInTargetStack
end if
baseDamage = baseDamage - kills * targetArmourPerShip / damageMultiplier
numberOfShipsInTargetStack = numberOfShipsInTargetStack - kills
if numberOfShipsInTargetStack > 0
if baseDamage * damageMultiplier > numberOfShipsInTargetStack * targetArmourPerShip
kills = kills + numberOfShipsInTargetStack
baseDamage = baseDamage - kills * targetArmourPerShip / damageMultiplier
else
targetArmourPerShip = targetArmourPerShip - baseDamage * damageMultiplier / targetArmourPerShip
baseDamage = 0
end if
end if
end if
end if
end while
Would anyone care to comment on this ?
Report message to a moderator
|
|
|
|
Re: Beam damage overflowing to other stacks |
Sat, 20 November 2004 10:08 |
|
|
LEit wrote on Sat, 20 November 2004 14:50 | Why do you check for kills twice? The second check will never be true.
|
If no shot is ever enough to kill a whole ship then eventually the cumulative damage will reach 100%.
Quote: | targetArmourPerShip = targetArmourPerShip - baseDamage * damageMultiplier / targetArmourPerShip
You probably want to divide by the number of ships there.
|
Ah, yes.
Quote: | An individual beam weapon will kill at most one stack. A slot of them can go on to other stacks. For example, a slot of 3 AMPs shooting scout chaff can kill 433*3/20 or 64 chaff. However, if there is a stack of 1 chaff, and another stack, the 1 chaff will get killed, and then only 433*2 damage will apply to the other stack.
An easy way to fix this is to put this as the last line in the while:
baseDamage = baseDamage - baseDamage mod weaponDamage
|
Thanks.
Report message to a moderator
|
|
|
|
Re: Beam damage overflowing to other stacks |
Sat, 20 November 2004 15:02 |
|
|
Quote: | By the time it gets here, there is no way that baseDamage * damageMultiplier will be greater then even targetArmourPerShip, therefore this second check is unnecessary. You can leave it in if you want, since the code will never get executed...
|
OK, I follow you now.
Quote: | An individual beam weapon will kill at most one stack. A slot of them can go on to other stacks. For example, a slot of 3 AMPs shooting scout chaff can kill 433*3/20 or 64 chaff. However, if there is a stack of 1 chaff, and another stack, the 1 chaff will get killed, and then only 433*2 damage will apply to the other stack.
An easy way to fix this is to put this as the last line in the while:
baseDamage = baseDamage - baseDamage mod weaponDamage
|
From the manual...
Quote: | If an attacking token has more than one ship and its beam weapon strike destroys the target token, then the remaining damage is applied to other tokens in the same square. The maximum number of tokens targeted is the number of ships in the attacking token.
|
This implies that all the remaining damage is applied to other tokens, but there is a cap on the number of stacks killed. Your algorithm works slightly differently. The revised code below just keeps track of the number of stacks killed.
baseDamage = weaponDamage * weaponCount
stacksTargeted = 0
while (baseDamage > 0) and (stacksTargeted < shipCount)
pick most attractive target in range
if no suitable target
exit
end if
damageMultiplier = rangeMultiplier * deflectorMultiplier * capacitorMultiplier
if shields > baseDamage * damageMultiplier
shields = shields - baseDamage * damageMultiplier
baseDamage = 0
else
baseDamage = baseDamage - shields / damageMultiplier
shields = 0
if not sappers
kills = baseDamage * damageMultiplier / targetArmourPerShip
if kills > numberOfShipsInTargetStack
kills = numberOfShipsInTargetStack
end if
baseDamage = baseDamage - kills * targetArmourPerShip / damageMultiplier
numberOfShipsInTargetStack = numberOfShipsInTargetStack - kills
if numberOfShipsInTargetStack > 0
targetArmourPerShip = targetArmourPerShip - baseDamage * damageMultiplier / numberOfShipsInTargetStack
end if
end if
end if
increment stacksTargeted
end while
[Updated on: Sat, 20 November 2004 15:10] Report message to a moderator
|
|
|
|
Re: Beam damage overflowing to other stacks |
Sun, 21 November 2004 06:13 |
|
|
LEit wrote on Sat, 20 November 2004 22:41 | I really doubt that the location of the stacks matters, and I think the cap in the manual is wrong. This should probably be tested.
I do know that beams can target more then one square however.
|
Well, I just ran a quick test. One stack of four FFs each with 3 MegaDs against 50 chaff scouts in 50 stacks. With it's first shot the FFs wiped out all 50 scouts, which were spread over 3 different squares. So there is no cap on the number of stacks killed - either by number of weapons (12) or number of ships (4).
As an aside, 26 of the scouts were in range, and 13 of them fired before the FFs. Both had total iniative of 10 (4+6 or 9+1), so this is another result confirming that weapon range has no affect on firing order.
Report message to a moderator
|
|
|
|
|
|
Re: Beam damage overflowing to other stacks |
Mon, 22 November 2004 12:57 |
|
|
Kotk wrote on Mon, 22 November 2004 15:52 | It seems correct ... but i am not sure. Maybe theres something else involved too.
I suggest you say how goes battle between
15 split up colloidal DD-s (3 colloidals each) at one side
1024 std (unshielded) frigate chaff as single stack at other side
by your algorithm.
Then maybe test it too. I have always been wondering if any math can explain how these strange damages are made there. As far i know DD damage deviate between 69 and 3200 there just during very first shot.
|
That is just bizarre !
The first salvo behaved as you described and killed 23 ships, leaving 1001 damaged to 49%. By my calculations that is a total of 23107dp of damage done by 45 colloidals, or 513dp each!
Next round the chaff fires back, with 1001 x-ray lasers doing only 200dp of damage to one stack, and nothing streaming over to the other stacks.
The next DD salvo kills another 98 ships and leaves the rest damaged to 91%.
Then the chaff fires again, but this time wipes out all 14 remaining DDs.
Outside the battle engine, the fleet report also shows 903 chaff left at 91% damage.
So, even allowing for bugs in the battle board display, the actual results of the battle are that the DDs managed to inflict a grand total of 42422dp of damage in one salvo from 15 ships and one from 14. Thats 87 shots, for a total of 487dp per shot! From a 26dp weapon.
I'd like to go on record right now as saying that if my battle simulator ever sees the light of day, it will try and predict any reasonable battle result. That does not include this kind of scenario which is obviously highlighting a real bug.
Report message to a moderator
|
|
|
|
|
|
Re: Beam damage overflowing to other stacks |
Mon, 22 November 2004 17:39 |
|
|
Staz wrote on Mon, 22 November 2004 17:57 | Next round the chaff fires back, with 1001 x-ray lasers doing only 200dp of damage to one stack, and nothing streaming over to the other stacks.
|
I've just looked at this again, and only 1 DD was in range of the x-rays which is why no other tokens were hit.
Report message to a moderator
|
|
|
|
Re: Beam damage overflowing to other stacks |
Tue, 23 November 2004 05:26 |
|
|
Kotk wrote on Mon, 22 November 2004 23:35 | Dunno why you dont want to implement it as accurately as possible? If someone gated together 20 stacks of omega nubs to defend his or ally property no host will call it cheating.
|
The "bug" is exposed when a ship does less than 1dp damage per ship in the enemy stack. To deliberately take advantage of it by through fleet splitting would be cheating, similar to abuse of the 1/500 cheat. If it just happens (for example you happen to have an old DD lying around that gets a shot off at the enemy chaff) then it won't have much impact on the result. In any case, it's not worth simulating.
As for the simulator code - I haven't looked at this specifically yet, but I won't add code specifically to replicate this situation. If it happens to work out this way anyway then that's fine.
Report message to a moderator
|
|
|