Craft stat rounding effects

Want to edit the game, build your own craft and missions? Here you'll find help, tools, guides and people to discuss with.

Craft stat rounding effects

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Tue Apr 24, 2018 2:09 am

Hello brave pilots, starship designers and tactical officers.
An interesting thing I noticed while I was checking all the craft stats is that in MXvTED v4.0 both in the vanilla XWA v2.02 and with XWAUCP v1.5 installed the TIE Interceptor has a speed set to 110 MGLT, whereas in the tech library and in mission the speed is set to 111 MGLT.

According to both the new Canon Universe (Star Wars Super Graphic: A Visual Guide to a Galaxy Far, Far Away) and the old Legends continuity (The Stele Chronicles) the TIE Interceptor speed is 110 MGLT. http://starwars.wikia.com/wiki/TIE/IN_interceptor

The only explanation I have for this discrepancy between the editor and the tech library is that 111 MGLT in the tech library and in mission is due to rounding effects.

The fact that the same thing also happens with the Planetary Fighter (137 MGLT in MXvTED v4.0 vs 138 MGLT in mission) and the Toscan Fighter (86 MGLT in MXvTED v4.0 vs 87 MGLT in mission) seems to confirm my theory.

Unfortunately the Planetary Fighter and the Toscan Fighter have not been "imported" to the Canon Universe yet, so we have no canon information on their speed.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Tue Apr 24, 2018 12:04 pm

The Shield Power and Hull Rate of the Mon Calamari Star Cruisers have been updated a few months ago for both X-Wing Alliance Upgrade Craft Pack v1.5 and Darksaber's Ultimate Craft Pack v2.5.

This is a discrepancy between MXvTED v4.0 Editor and the Tech Library I've noticed:
MC80 Liberty Star Cruiser
MXvTED v4.0 Editor - Shield Power: 3968 SBD
Tech Library - Shield Rating: 3952 SBD
I think 16 SBD is a bit excessive to be explained simply with a rounding effect.




Another discrepancy worth posting concerns the Maneuverability Rating of the TIE Defender: 114 DPF in MXvTED v4.0 Editor and 110 DPF in the Tech Library.
This occurs both in vanilla X-Wing Alliance v2.02 and with X-Wing Alliance Upgrade Craft Pack v1.5 installed.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
JeremyaFr
XWAU Member
Posts: 3922
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue Apr 24, 2018 12:12 pm

Hello,

The speed shown in mission is calculated as follow:

Code: Select all

s_XwaObjects[s_XwaPlayers[s_XwaCurrentPlayerId].ObjectIndex].pMobileObject->Speed * 29127 / 65535
If the ship is in hyperspace, the shown speed is "999+".

The speed shown in the Tech Library is calculated as follow:

Code: Select all

A4->Speed = (int)(s_ExeCraftTable[ax].Speed * 0.44444444444444442 + 0.5 );
The acceleration is calculated as follow:

Code: Select all

A4->Acceleration = (int)(s_ExeCraftTable[ax].Acceleration * 0.44444444444444442 + 0.5 );
The maneuverability is calculated as follow:

Code: Select all

A4->Maneuverability = (int)(( s_ExeCraftTable[ax].Roll + s_ExeCraftTable[ax].Pitch ) * 0.00523157557f + 0.5 );

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Tue Apr 24, 2018 12:38 pm

That +0.5 for the speed shown in the Tech Library seems to confirm the rounding effect theory at first sight: decimal portion>0.5 implies that the following integer is shown.

I will try some experiments with BinHexEdit ver 0.5.25, which should be a little more accurate than MXvTED ver 4.0 Final.

I will also take a look at XWAConv 1.12 and see if I can find out which of the 2 expressions for the speed it reverses.

The maneuverability in the Tech Library is a linear combination of Roll and Pitch, so finding what happened to the TIE Defender could be a little trickier.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Sun Apr 29, 2018 1:53 am

I compared all the stats for Fighters listed in the Tech Library with those written in MXvTED v4.0.
I have the XWAUCP v1.5 installed on both my computers, so I kept the Tech Library on the first monitor, and BinHexEdit, MXvTED v4.0 and XWAC on the second monitor, so I had to take note of the differences on a copybook due to space problems.
Here are the discrepancies I found and also the values obtained with XWAC used in the reverse way: https://www.dropbox.com/s/b0v7g9zk2b3le ... s.pdf?dl=0
Of course I can make a Word file if you don't like that.

Now I will explain my conclusions for each stat listed in the Tech Library. Just remember I'm talking about fighters exclusively.

HULL RATE
There are no discrepancies FOR FIGHTERS between the hull rate shown in MXvTED v4.0 editor and the Tech Library, because both of them take the hull value rounded down (checked with BinHexEdit and XWAC), and the minimum detectable difference between 2 hull values is 1 RU both for MXvTED v4.0 and the Tech Library.

SPEED
There are no discrepancies between the speed shown in the Tech Library and the speed shown in mission when all the recharges are set to maintenance level, because the speed shown in mission is rounded down if the decimal portion is <0.5, or rounded up if the decimal portion is >0.5; the speed shown in the Tech Library only takes the integer part (int), so it is always rounded down, but only after adding +0.5, therefore you obtain the same result.
This means that the speed issues I mentioned in the first post of this topic are basically in the editor MXvTED v4.0, not in the game.

However, even if it's all fine when all the recharges are set to maintenance level, there is a problem a perfectionist might notice when redirecting recharges to engines: the speed doesn't scale appropriately for all fighters (I'm not talking about the TIE Bomber), and the magnitude of the discrepancy between the actual top speed when all the recharges are redirected to engines and the theoretical maximum speed can be up to 2 MGLT.
Let's take the TIE Defender for example: 144 MGLT with all the recharges set to maintenance level, 181 MGLT (instead of 180 MGLT) with 1 recharge fully redirected to engines, 254 MGLT (instead of 252 MGLT) with 3 recharges fully redirected to engines.
By the way, this problem has obviously nothing to do with the editor MXvTED v4.0.

ACCELERATION
There are no discrepancies between the acceleration shown in MXvTED v4.0 editor and the Tech Library, but using XWAC I found some values are rounded up and others are rounded down. I won't place any bet on what could have happened.
The acceleration is not explicitly shown in mission and it has never caused any issues anyway.

MANEUVERABILITY RATING
Here is where I found the most numerous discrepancies between the editor MXvTED v4.0 and the Tech Library, and also the biggest one: the Missile Boat has a maneuverability rated at 84 DPF in MXvTED v4.0 and 91 DPF in the Tech Library. There is a difference of more than 8%.
The maneuverability rating is a linear combination of Roll and Pitch, but neither of these 2 stats is listed in the Tech Library, so I cannot do any direct comparison, and the only thing I have at my disposal is 1 equation with 2 unknowns, therefore I can't help much.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
JeremyaFr
XWAU Member
Posts: 3922
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sun Apr 29, 2018 8:23 am

Hello,
You can easily view the values shown in the Tech Library with XwaSpecRciEditor:
viewtopic.php?p=148679#p148679

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Sun Apr 29, 2018 6:26 pm

Awesome! Many thanks for this.
I already have the comparison between MXvTED v4.0 and the Tech Library for non-fighter crafts anyway: https://www.dropbox.com/s/53no8wrpncken ... s.pdf?dl=0
There are many crafts that in MXvTED v4.0 have a different Hull Rate from the Tech Library: the stat is rounded up in MXvTED v4.0 and rounded down in the Tech Library.
The magnitude of the discrepancy depends on the craft type (look at XWAC): 4 RU for "Medium" crafts (freighters and containers) and 16 RU for "Heavy" crafts (starships and stations).

A given X hull value in XWINGALLIANCE.EXE translates into Hull Rate Y for "Light" crafts, 4Y for "Medium" crafts and 16Y for "Heavy" crafts.
You can easily calculate the ratio X/Y using BinHexEdit and XWAC.
Having different conversion factors for different craft types allows you to set higher Hull Rates for bigger starships.

However, this comes with a huge drawback: you also lose sensitivity accordingly.
I mean that the minimum detectable difference between 2 Hull Rates is 1 RU for Light crafts, 4 RU for Medium crafts and 16 RU for Heavy crafts.
You can also see the thing in this way: the Hull Rate for a Medium craft must be divisible by 4 and the Hull Rate for a Heavy craft must be divisible by 16.

The same concept also applies to Shield Rating, but the only discrepancy I found is on the MC80 Liberty Star Cruiser: 3968 SBD in MXvTED v4.0 and 3952 SBD in the Tech Library.
I've checked BinHexEdit (172/289) MC80 Liberty: the Shield Strength is set to 12375, which is the equivalent of 3960 SBD for a Heavy craft according to XWAC.
And 3960 is not divisible by 16.


By the way, I will take a closer look at XwaSpecRciEditor tomorrow.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
JeremyaFr
XWAU Member
Posts: 3922
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sun Apr 29, 2018 6:42 pm

The shield and hull are calculated as follow:

Code: Select all

    if( s_ExeCraftTable[ax].HasShieldGenerator != 0 )
        A4->Shield = s_ExeCraftTable[ax].ShieldStrength / 50;
    else
        A4->Shield = 0;

    A4->Hull = s_ExeCraftTable[ax].HullStrength / 105;

    if( A4->ShipCategory == ShipCategory_Starship || A4->ShipCategory == ShipCategory_Platform )
    {
        A4->Shield *= 16;
        A4->Hull *= 16;
    }

    if( A4->ShipCategory == ShipCategory_Freighter || A4->ShipCategory == ShipCategory_Container )
    {
        A4->Shield *= 4;
        A4->Hull *= 4;
    }

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Sun Apr 29, 2018 7:30 pm

Thank you.
You have spared me the calculation of what I've called X/Y ratio in my previous post.
It's 50 for Shield Rating and 105 for Hull Rating.

The fact that both the Shield Rating and the Hull Rating are multiplied by 4 or 16 depending on Ship Category only after dividing by 50 the Shield Strength and 105 the Hull Strength confirms what I wrote in my previous post.


However, a strange thing I've noticed is that the Hull Rate for the Communication Satellites, the Probe Capsule and the Buoys is broken in MXvTED v4.0.
All these objects have a hull rated at 2 RU in the Tech Library (and in mission) and 48 RU in MXvTED v4.0.
This problem is obviously in the editor, not in the game.

Edit: I mean the problem which causes that 46 RU discrepancy between the Hull Rate in MXvTED v4.0 and the Tech Library for the Communication Satellites, the Probe Capsule and the Buoys is in MXvTED v4.0 editor, whereas the 4 RU and 16 RU rounding effects are simply game limitations, not bugs.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Tue May 01, 2018 3:19 am

To state what has not been explicitly stated: It looks like the game is truncating 12375/50 (247.5) down to 247 (i.e., integer math) and then multiplying by 16 to get 3952, whereas MXvTED is rounding 247.5 up to 248 (floating-point math with an explicit round()) which multiplies up to 3968.

My question, though, is what math does the game engine use in combat?

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Tue May 01, 2018 8:35 am

I've just tried this test: taking down an unshielded Pressure Tank and a Container A firing from a fully stopped T-65 X-Wing.

Pressure Tank - Hull Rate
BinHexEdit value: 500
20 RU according to MXvTED v4.0 (floating-point math)
16 RU according to the Tech Library (integer math)

Container A - Hull Rate
BinHexEdit value: 1000
40 RU according to MXvTED v4.0 (floating-point math)
36 RU according to the Tech Library (integer math)

A fully charged red laser shot inflicts a damage equivalent to 5 RU when fired from a fully stopped craft.

X-Wing vs Pressure Tank: 1 shot caused 25% Hull Damage, 2 shots caused 50% Hull Damage and 3 shots caused 75% Hull Damage; 4 shots are required to destroy it.

X-Wing vs Container A: 2 shots caused 25% Hull Damage, 4 shots caused 50% Hull Damage and 6 shots caused 75% Hull Damage; 8 shots are required to destroy it.

These results are consistent with MXvTED v4.0, not with the Tech Library.

Conclusion: The game engine uses floating-point math for Hull Rate in combat.
Last edited by Mark_Farlander on Tue May 01, 2018 5:11 pm, edited 2 times in total.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Tue May 01, 2018 9:11 am

Doing a similar test to investigate on Shield Rating of the MC80 Liberty Star Cruiser is trickier because the Liberty, as all the other Starships, recharges their shields, even if set to "No Duty: Craft is Stationary".

The Shield value set in BinHexEdit for all the other crafts in XWAUCP v1.5 is always divisible by 50, therefore there are no discrepancies between MXvTED v4.0 and the Tech Library, even if they round the stat with a different rule.

As for speed, thanks to that +0.5 correction there are no discrepancies between mission and the Tech Library, even if a different rounding rule is used.

That said, it seems the game engine uses floating-point math for all the main craft stats in combat.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
JeremyaFr
XWAU Member
Posts: 3922
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue May 01, 2018 3:55 pm

Hello,
At full charge, the laser becomes Turbo. LaserRebel becomes LaserRebelTurbo. LaserImp becomes LaserImpTurbo. LaserIon becomes LaserIonTurbo.
To test that, I've changed the power setting of LaserRebelTurbo from 500 to 1000. The power setting of LaserRebel is 250.
Taking down an unshielded Pressure Tank from a X-Wing:
At low charge, it takes 8 shots (LaserRebel).
At full charge, it takes 2 shots (LaserRebelTurbo).

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Tue May 01, 2018 5:20 pm

It took 4 shots to destroy the unshielded Pressure Tank firing from a fully stopped X-Wing when Full Red Laser Power was set at 500.
So it sounds logical that it took 2 shots when Full Red Laser Power was set at 1000.

I didn't report that the fourth shot destroyed the Pressure Tank because I was more interested in the hull percentage progression while taking damage to find out if the Hull Rate in mission were consistent with MXvTED v4.0 or the Tech Library.
Sorry for this oversight.
I've just edited the post.
Mark_Farlander wrote:
Tue May 01, 2018 8:35 am

Pressure Tank - Hull Rate
BinHexEdit value: 500
20 RU according to MXvTED v4.0 (floating-point math)
16 RU according to the Tech Library (integer math)

A fully charged red laser shot inflicts a damage equivalent to 5 RU when fired from a fully stopped craft.

X-Wing vs Pressure Tank: 1 shot caused 25% Hull Damage, 2 shots caused 50% Hull Damage and 3 shots caused 75% Hull Damage; 4 shots are required to destroy it.
The answer is that the Hull Rate of the Pressure Tank in mission is 20 RU, as shown in MXvTED v4.0.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Tue May 01, 2018 5:31 pm

What happens if you set the damage value to 499?

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Tue May 01, 2018 5:46 pm

I get "Permission denied".
I don't judge tactics. The Battle is the best and only Judge.

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Tue May 01, 2018 8:01 pm

Har har

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Tue May 01, 2018 9:46 pm

When I try to enter a value in BinHexEdit I get "Run-time error '70': Permission denied".

System
CPU: Intel Core -7-4700HQ @ 2.40GHz
RAM: 8,00 GB

OS: Windows 7 Professional 64 bit Service Pack 1

GOG X-Wing Alliance (18061) + X-Wing Alliance Upgrade Craft Pack v1.5

The choice to use the notebook to change values with BinHexEdit is to avoid messing up things in my primary machine, which I use to test possible solutions to solve the New Alliance Platform overlapping problems.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Tue May 01, 2018 10:12 pm

Try running BinHexEdit as admin.

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Tue May 01, 2018 10:15 pm

Already tried and I got the same result.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Tue May 01, 2018 11:43 pm

I've just tried another test, this time against 2 shielded targets.

Craft flown: T-65 X-Wing
Throttle: 0%
Weapon used: Fully charged Red Laser
Damage dealt: 5 RU

Target 1: Pressure Tank
Shield Rating: 80 SBD according to both MXvTED v4.0 and the Tech Library
Hull Rating: 20 RU according to MXvTED v4.0 / 16 RU according to the Tech Library (BinHexEdit value: 500)

Target 2: Container J
Shield Rating: 120 SBD according to both MXvTED v4.0 and the Tech Library
Hull Rating: 48 RU according to MXvTED v4.0 / 44 RU according to the Tech Library (BinHexEdit value: 1250)


X-Wing vs Target 1
After being hit by 8 shots, the Pressure Tank was at 50% shields.
After being hit by 16 shots, the Pressure Tank had 0% shields and 100% hull.
As for hull, each shot inflicted exactly 25% hull damage and 4 shots were required to take it down, just like in the previous test.

Conclusion: We already knew that the Shield Rating for the Pressure Tank is 80 SBD and the Hull Resistance in mission is 20 RU, but now we have validation of another meaningful thing: 1 SBD=1 RU when it comes to damage assessment, so 16 shots inflict a damage equivalent to 80 SBD.


X-Wing vs Target 2
After being hit by 12 shots, the Container J was at 50% shields.
After being hit by 24 shots, the Container J had 0% shields and 100% hull.
Then each shot inflicted exactly 10% hull damage (Hull integrity progression: 90%, 80%, 70%, 60%, 50%, 40%, 30%, 20%, 10%, 0%) and 10 shots were required to destroy the unshielded Container J.

Conclusion: Since we know that the Container J has a shield rated 120 SBD and we are also not wrong about the damage dealt by 1 shot of a Fully charged Red Laser (5 SBD, so 24 shots inflict the equivalent of 120 SBD), the Hull Resistance of the Container J in mission is 50 RU.
This result is strange and it could mean that Hull Resistance in mission is rounded in a different way than in the editor and the Tech Library.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
JeremyaFr
XWAU Member
Posts: 3922
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Wed May 02, 2018 6:09 pm

Hello,
The different % are calculated as follow (L00494D40):

Code: Select all

% = (value * 65536 / max) / 655
For the hull, if the % is 0, then the game shows 1 %.

The game uses integer math to compute the different %.

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Wed May 02, 2018 6:55 pm

Ok, so if hit point total is RU (or SDB, as appropriate) * 100, the observed result for the container J is inconsistent with either the tech library's or MXvTED's math. With that formula for the percentage display, hull HP max must be exactly 5000; at 4999, you'd see 19% displayed after the 8th hit (and at 5001, it wouldn't be dead after the 10th).
You do not have the required permissions to view the files attached to this post.

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Thu May 03, 2018 1:26 am

I've just tried to take down a Pressure Tank again flying an X-Wing and shooting with fully charged laser cannons.
This time I took note of the shield percentage drop while taking hits: 92%/86%/80%/74%/68%/62%/56%/50%/42%/36%/30%/24%/18%/12%/6%/0%.
Can we conclude that the first shot inflicted 8% shield damage and the second shot 6% shield damage?
No, we can't. It's 6.25% each shot, but the game engine seems to always round down the shield percentage, even though the actual shield and hull values respectively in SBD and RU are stored anyway (but not shown on the CMD).

Additionally, another thing worth noting is that the shield percentage shown on the CMD is always an even number, so the minimum appreciable difference between 2 shield percentages is 2%.
The only exception is 1% shields. I think this had been allowed to have slightly more sensitivity when a starship transfers energy from weapons to shields, a common tactic to allow further protection after the main shields have been taken out.

As for hull integrity percentage, all the integer values are allowed if I'm not wrong.
I don't judge tactics. The Battle is the best and only Judge.

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Thu May 03, 2018 6:00 am

Hmm... Allow me to speculate that the "max" value for shields is doubled in order to implement the fighter shield double-charging (but the starting value isn't, unless instructed to by the mission file); that the displayed percentage is also doubled, after all the other math (i.e., after already being truncated to an integer); and that the rule that any non-zero value that would be displayed as 0 due to the truncation is instead displayed as 1, is applied last. I believe that would explain the observed behavior.

Post Reply