Home World Forum
Stars! AutoHost web forums

Jump to Stars! AutoHost


 
 
Home » Stars! 2.6/7 » The Academy » Beam damage overflowing to other stacks
Beam damage overflowing to other stacks Fri, 19 November 2004 19:20 Go to next message
Staz is currently offline Staz

 
Lieutenant

Messages: 514
Registered: November 2003
Location: UK
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 09:50 Go to previous messageGo to next message
LEit is currently offline LEit

 
Lt. Commander

Messages: 879
Registered: April 2003
Location: CT
Why do you check for kills twice? The second check will never be true.

targetArmourPerShip = targetArmourPerShip - baseDamage * damageMultiplier / targetArmourPerShip

You probably want to divide by the number of ships there.

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



- LEit

Report message to a moderator

Re: Beam damage overflowing to other stacks Sat, 20 November 2004 10:08 Go to previous messageGo to next message
Staz is currently offline Staz

 
Lieutenant

Messages: 514
Registered: November 2003
Location: UK
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 11:08 Go to previous messageGo to next message
LEit is currently offline LEit

 
Lt. Commander

Messages: 879
Registered: April 2003
Location: CT
kills = baseDamage * damageMultiplier / targetArmourPerShip

This will kill all ships that this shot can.

if baseDamage * damageMultiplier > numberOfShipsInTargetStack * targetArmourPerShip

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...



- LEit

Report message to a moderator

Re: Beam damage overflowing to other stacks Sat, 20 November 2004 15:02 Go to previous messageGo to next message
Staz is currently offline Staz

 
Lieutenant

Messages: 514
Registered: November 2003
Location: UK
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 Sat, 20 November 2004 17:41 Go to previous messageGo to next message
LEit is currently offline LEit

 
Lt. Commander

Messages: 879
Registered: April 2003
Location: CT
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.



- LEit

Report message to a moderator

Re: Beam damage overflowing to other stacks Sun, 21 November 2004 06:13 Go to previous messageGo to next message
Staz is currently offline Staz

 
Lieutenant

Messages: 514
Registered: November 2003
Location: UK
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 07:23 Go to previous messageGo to next message
Kotk

 
Commander

Messages: 1227
Registered: May 2003
Note that the

targetArmourPerShip = targetArmourPerShip - baseDamage * damageMultiplier / numberOfShipsInTargetStack

is not correct if you want to make it exactly as stars does it.

The damage is applied in steps of MaxTokenArmour/512, because stars stores the token health in 9 bits.

MaxtokenArmour at its order depends on alive ships in token Wink


[Updated on: Mon, 22 November 2004 07:27]

Report message to a moderator

Re: Beam damage overflowing to other stacks Mon, 22 November 2004 07:43 Go to previous messageGo to next message
Staz is currently offline Staz

 
Lieutenant

Messages: 514
Registered: November 2003
Location: UK
Kotk wrote on Mon, 22 November 2004 12:23

Note that the

targetArmourPerShip = targetArmourPerShip - baseDamage * damageMultiplier / numberOfShipsInTargetStack

is not correct if you want to make it exactly as stars does it.

The damage is applied in steps of MaxTokenArmour/512, because stars stores the token health in 9 bits.

MaxtokenArmour at its order depends on alive ships in token Wink



Yep, I should have included that in the algorithm I posted.

In the algorithm I actually implemented in the Java code I have

int damageUnits = Math.max( target.design.getArmour() / 512, 1 );
int damage2 = (int)(Math.ceil(1.0 * damage / damageUnits) * damageUnits);
target.damage = (damagePerShip+newDamagePerShip) * target.shipCount;

Report message to a moderator

Re: Beam damage overflowing to other stacks Mon, 22 November 2004 10:52 Go to previous messageGo to next message
Kotk

 
Commander

Messages: 1227
Registered: May 2003
It seems correct ... but i am not sure. Maybe theres something else involved too. Wink

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.


[Updated on: Mon, 22 November 2004 10:53]

Report message to a moderator

Re: Beam damage overflowing to other stacks Mon, 22 November 2004 12:57 Go to previous messageGo to next message
Staz is currently offline Staz

 
Lieutenant

Messages: 514
Registered: November 2003
Location: UK
Kotk wrote on Mon, 22 November 2004 15:52

It seems correct ... but i am not sure. Maybe theres something else involved too. Wink

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 15:42 Go to previous messageGo to next message
Kotk

 
Commander

Messages: 1227
Registered: May 2003
I think i got theory how damage is calculated:

colloidal, list damage 26 fires at max range so 26*0.9 = 23.4 rounded to 23.

1) it does try to kill shields, no shields

2) it tries to kill ships with 23 damage, since all ships in fleet have 45dp it cant kill ships, 0 ships killed.

3) it does do leftover stack damage and here it seems that it does at least 1 damage to every ship in token.

int damageUnits = Math.max( target.design.getArmour() / 512, 1 )* target.shipcount;

damageUnits = 1 * 1024

Such damage is applied to stack.

......

next colloidal does same and so first dd does ~3072 damage.
next 6 dd-s do the same and so they do ~21504 damage.

8th DD is interesting one.

its first colloidal does also 1024 damage.

After that whats left of initial 46080 armor? ... 23552

Since the 23552 / 1024 = 23 the ships start to die Smile

So ... 8ths DD-s 2nd colloidal kills a ship at 2)
Because its exactly 23 what it does theres no leftover damage to token for 3).
Same happens with 3-th colloidal.
So 8th DD does 1024+23+23= ~1070 damage and kills 2 ships.

Rest of the DD-s do 69 damage and kill 3 ships each.

Wink

Report message to a moderator

Re: Beam damage overflowing to other stacks Mon, 22 November 2004 16:52 Go to previous messageGo to next message
Kotk

 
Commander

Messages: 1227
Registered: May 2003
Oh and just another thing i tested out (with nubians there)... seems that the damage is not held in 1/512 units (like listed in so lot of places) but in 1/500 units.

Turn calculator calculates it like that:
first 1024 shot 1024/46080 = 2.222% rounded up to nearest 0.2% results 2.4% damage.
second 1024 shot 2048/46080 = 4.444% rounded up to nearest 0.2% results 4.6% damage.
third 1024 shot 3072/46080 = 6.667% rounded up to nearest 0.2% results 6.8% damage.

Battle VCR gets from turn calculator that first DD did from 0% damage to 6.8% damage and calculates that int(46080*6.8%)- int(46080*0%)=3133 damage Wink

And seems that so on!

So ... that finally solves bizarreness in armour damage at least for this example! Very Happy

real damage seems to be something like:

int damageUnits = Math.max( target.design.getArmour()* target.shipcount / 500, target.shipcount);

that is converted into 0.2% units for VCR and poor VCR cant reverse engineer it correctly so armour damage deviates in VCR from shot to shot by little amount.

Report message to a moderator

Re: Beam damage overflowing to other stacks Mon, 22 November 2004 17:36 Go to previous messageGo to next message
Staz is currently offline Staz

 
Lieutenant

Messages: 514
Registered: November 2003
Location: UK
This is horrible! Shocked

Anyway, I don't think I will implement this in the simulator. In battles with stacks of a thousand ships, you wouldn't include stacks of single DDs unless you were deliberately exploiting this "feature", which most hosts would call cheating.

Report message to a moderator

Re: Beam damage overflowing to other stacks Mon, 22 November 2004 17:39 Go to previous messageGo to next message
Staz is currently offline Staz

 
Lieutenant

Messages: 514
Registered: November 2003
Location: UK
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 Mon, 22 November 2004 18:35 Go to previous messageGo to next message
Kotk

 
Commander

Messages: 1227
Registered: May 2003
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. Wink

Yes ... that beam damage did sound strange. I knew it does not go to other tokens when it targets and kills orbital. On rest of the cases it seemed always overflow to other tokens for me.


[Updated on: Mon, 22 November 2004 18:37]

Report message to a moderator

Re: Beam damage overflowing to other stacks Tue, 23 November 2004 05:26 Go to previous message
Staz is currently offline Staz

 
Lieutenant

Messages: 514
Registered: November 2003
Location: UK
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. Wink


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

Previous Topic: Shield bug?
Next Topic: Weapon range and firing order
Goto Forum:
  


Current Time: Sun May 05 07:19:58 EDT 2024