Integer Limits

For those of us who are curious and like to poke around in the game's data files and scripts as well as glitching. Caters to anything from unit/building stats to level data to telling how to glitch and stories of game errors.
User avatar
CharlotteLabyrinth
Turantul 1 (Veteran)
Turantul 1 (Veteran)
Posts: 423
Joined: Thu Mar 01, 2012 3:00 pm
Location: Schloss Charlottenburg..?

Integer Limits

Post by CharlotteLabyrinth » Fri Feb 01, 2019 9:30 am

Recently I've been contacted by one of our community members regarding the integer limits defined for various functions used in the game. So I was thinking it would be a good idea to make a coordinated thread which describes all known data limit values in more easily accessible forms...

If the data gathered in this thread are 100% proven, then they might be added to a separate wiki page later to be used as quick references. This list will be constantly updated in future. The values are based on the official UA.exe in the final release. Boolean functions are not included. Overflow functions will have the sign (*) next to them.

I will list down a few items that I can think of at the moment here:



General

Total functional faction numbers: 8 (0-7; 0 works to an extent but not fully, anything above 7 is 'broken'.)

Total functional level numbers: 255 (L0101.ldf ~ L255255.ldf; for both SINGLE and MULTI level folders.)



*.SCR

Code: Select all

dest_fx = 16

Code: Select all

kamikaze = 2147483647

Code: Select all

new_building = 127

Code: Select all

new_vehicle = 255

Code: Select all

new_vehicle; energy = 2147483647

Code: Select all

new_weapon = 127

Code: Select all

new_weapon; energy = 2147483647

Code: Select all

power = 255 (*)

Code: Select all

robo_coll_num = 16

Code: Select all

robo_num_guns = 8

Code: Select all

sbact_act = 8

Code: Select all

sec_type = 255 (*)

Code: Select all

shield = 255 (*)

Code: Select all

vo_type = 16 (0-9; A-F)

Code: Select all

weapon = 127


*.LDF

Code: Select all

begin_gate = 8

Code: Select all

begin_gem = 8

Code: Select all

begin_item = 8

Code: Select all

begin_robo = 8

Code: Select all

begin_robo; energy = 2147483647

Code: Select all

begin_squad = 96

Code: Select all

begin_squad; num = 32

Code: Select all

reload_const = 2147483647

Code: Select all

typ/own/hgt/blg_map =
        64 64


*SGM

Code: Select all

Placeholder


Please report any errors or mistakes, and if I have some time later I could look into the original UA source code or Zidane's decompiled UA:Source files which will certainly provide the entirety of concrete answers!


UPDATE: Added some new info, thanks to Ormu & medicineman!

NEW UPDATE: Added a bit more info, rearranged parameters in alphabetical order, overflow functions now have the sign (*) next to them.
Last edited by CharlotteLabyrinth on Wed Jun 05, 2019 7:00 pm, edited 12 times in total.
;--------------------------------------------------
;
; Vielleicht der niedlichste Hubi, Knuddel.
;
;--------------------------------------------------
„ Helfen - Wehren - Heilen “

Personal Declaration: I always use different usernames across different websites. Hence if you ever see my username is being used outside of Stoudson Corporation, I absolutely have no affiliation whatsoever with that!

Ormu
Turantul 1 (Veteran)
Turantul 1 (Veteran)
Posts: 867
Joined: Fri Dec 26, 2008 4:59 pm
Location: Finland

Re: Integer Limits

Post by Ormu » Fri Feb 01, 2019 8:36 pm

Isn't it robo_coll_num? :P


Code: Select all

typ_map =
        64 64
This applies to all map dumps of course. Note: Bigger maps (in one or both(?) directions) may sometimes work but are unstable. 64 sectors shouldn't be exceeded in either direction.

Code: Select all

sbact_act = ???
Is it 8?


Others:
Number of functional factions: 1 to 7; 0 works to an extent; anything above 7 is broken
Maximum numbers of level files in single/multi directories? Mario investigated this many years ago.
Image Im in ur base, stalkin ur hoststation


Not all Ormus are mine. When in doubt, please ask...

User avatar
medicineman
Firefly
Firefly
Posts: 24
Joined: Fri Sep 14, 2018 3:15 am

Re: Integer Limits

Post by medicineman » Fri Feb 01, 2019 9:28 pm

This is what I have so far:
- As mentioned in a different post, the number of voice overs can't go above the designation "F". (EDIT 2/3/19): in response to a question below, VO type "0" seems to have the effect of VO type "B". I tried adding new files for 0 and just got B sounds instead. So, 1-9 and A-F are the designations, for a total of 15.
- The maximum number of Stoudson Bombs you can place is 9.
- Also regarding the Stoudson Bombs, the countdown times need to be an integer number of seconds (not ms)... making it some fractional amount causes the bomb counter to roll over to 60:00 when it hits zero. Let me know if this statement isn't clear.
- Power stations appear to stop working for me if the map dimensions are bigger than 64, to elaborate on the above. I did have a 100x3 level in an old campaign but the goal was to race to the end so power stations weren't an issue.
- The explosion damage from the Rock Sled seems to cap at some value. I haven't been able to determine what that is but noticed that it stops at a certain point when I was trying to make a "level destroying" kamikaze unit before. EDIT (2/3/19): Host station energies, the rock sled damage, and presumably other weapon damages are limited to approximately 2^31, or 2147483600 (note that these are the values defined in the script, not what it translates to in UA).

I'll add to this post as I can think of others. This would be a very helpful reference.
Last edited by medicineman on Sun Feb 03, 2019 11:12 pm, edited 4 times in total.

User avatar
CharlotteLabyrinth
Turantul 1 (Veteran)
Turantul 1 (Veteran)
Posts: 423
Joined: Thu Mar 01, 2012 3:00 pm
Location: Schloss Charlottenburg..?

Re: Integer Limits

Post by CharlotteLabyrinth » Fri Feb 01, 2019 9:30 pm

Ormu wrote:
Fri Feb 01, 2019 8:36 pm
Isn't it robo_coll_num? :P
Oops… yes it is. :oops: What a silly little mistake, thank you very much for the correction! :P

Ormu wrote:
Fri Feb 01, 2019 8:36 pm

Code: Select all

typ_map =
        64 64
This applies to all map dumps of course. Note: Bigger maps (in one or both(?) directions) may sometimes work but are unstable. 64 sectors shouldn't be exceeded in either direction.
Added!

Ormu wrote:
Fri Feb 01, 2019 8:36 pm

Code: Select all

sbact_act = ???
Is it 8?
I believe so. I remember the valid range of values were from 0 to 7, for total 8 building components. :idea:

Ormu wrote:
Fri Feb 01, 2019 8:36 pm
Others:
Number of functional factions: 1 to 7; 0 works to an extent; anything above 7 is broken
Maximum numbers of level files in single/multi directories? Mario investigated this many years ago.
Valid faction number limit added, and yes I also remember the single/multi directories had maximum level limits of 256 or 128, there might be some posts around here which describe them in details...

medicineman wrote:
Fri Feb 01, 2019 9:28 pm
- As mentioned in a different post, the number of voice overs can't go above the designation "F"
Added. ;) So is it safe to assume the valid numbers range would be 1-9; A-F (Total 15)? Does 0 counts as well, which would make it to 16?

medicineman wrote:
Fri Feb 01, 2019 9:28 pm
- The maximum number of Stoudson Bombs you can place is 9.
Added! I initially thought it was 4 or 8. I should double-check all the parameters later.

medicineman wrote:
Fri Feb 01, 2019 9:28 pm
- Also regarding the Stoudson Bombs, the countdown times need to be an integer number of seconds (not ms)... making it some fractional amount causes the bomb counter to roll over to 60:00 when it hits zero. Let me know if this statement isn't clear.
The actual time frames calculated in the game could be slightly deviating from the real-time standard, for example: (1024'UA'ms = 1000ms). I have noticed there is a comparative loss between script defined numbers vs actual in-game timers. :) Also if a Stoudson Bomb timer exceeds 60:00, the timer number will overflow which causes it to count from 00:00 again, but only in displayed numbers.

medicineman wrote:
Fri Feb 01, 2019 9:28 pm
- Power stations appear to stop working for me if the map dimensions are bigger than 64, to elaborate on the above. I did have a 100x3 level in an old campaign but the goal was to race to the end so power stations weren't an issue.
I've probably noticed this happening before as well, pending additional investigation... :arrow:

medicineman wrote:
Fri Feb 01, 2019 9:28 pm
- The explosion damage from the Rock Sled seems to cap at some value. I haven't been able to determine what that is but noticed that it stops at a certain point when I was trying to make a "level destroying" kamikaze unit before. I'll see if I can flush it out.
This sounds very interesting, please let us know if you figure out the limit.
;--------------------------------------------------
;
; Vielleicht der niedlichste Hubi, Knuddel.
;
;--------------------------------------------------
„ Helfen - Wehren - Heilen “

Personal Declaration: I always use different usernames across different websites. Hence if you ever see my username is being used outside of Stoudson Corporation, I absolutely have no affiliation whatsoever with that!

User avatar
medicineman
Firefly
Firefly
Posts: 24
Joined: Fri Sep 14, 2018 3:15 am

Re: Integer Limits

Post by medicineman » Sun Feb 03, 2019 11:08 pm

The maximum Rock Sled damage also seems to be equal to the maximum energy a host station can have. The value is 2147483600, which differs from the number 2^31 by about 1 part in 10^8. I feel like there's a logical reason for this but I don't know enough about programming to say for sure.

If anyone is interested, the Rock Sled explosion damage itself seems to approximately follow a 1/distance dependency, which I'm guessing is radially symmetric too (though it may not be). I'm playing with some numbers to try and figure out the exact relation.

VO type 0 results in the same effect as VO type B, to answer the above question.

Ormu
Turantul 1 (Veteran)
Turantul 1 (Veteran)
Posts: 867
Joined: Fri Dec 26, 2008 4:59 pm
Location: Finland

Re: Integer Limits

Post by Ormu » Mon Feb 04, 2019 9:47 am

medicineman wrote:
Sun Feb 03, 2019 11:08 pm
The maximum Rock Sled damage also seems to be equal to the maximum energy a host station can have. The value is 2147483600, which differs from the number 2^31 by about 1 part in 10^8. I feel like there's a logical reason for this but I don't know enough about programming to say for sure.

If anyone is interested, the Rock Sled explosion damage itself seems to approximately follow a 1/distance dependency, which I'm guessing is radially symmetric too (though it may not be). I'm playing with some numbers to try and figure out the exact relation.

VO type 0 results in the same effect as VO type B, to answer the above question.
So it would be the maximum of a 32-bit signed integer. And because many numbers in UA are internally defined 100-fold it may appear as rounded into the nearest smaller number which is divisible by 100.

Isn't the Rock Sled blast also confined to a sector? I think it never damages units in the adjacent sectors.
Image Im in ur base, stalkin ur hoststation


Not all Ormus are mine. When in doubt, please ask...

User avatar
CharlotteLabyrinth
Turantul 1 (Veteran)
Turantul 1 (Veteran)
Posts: 423
Joined: Thu Mar 01, 2012 3:00 pm
Location: Schloss Charlottenburg..?

Re: Integer Limits

Post by CharlotteLabyrinth » Thu Feb 07, 2019 8:40 pm

Yes, it's a Mersenne prime number as you may already know. :) In a programming context, 2147483647 usually indicates the 32-bit signed integer limit.

There are some old posts related to this which I wrote in the other threads.
viewtopic.php?f=23&t=1151#p16700
viewtopic.php?f=13&t=1712#p17481

Info updated to the main post!
;--------------------------------------------------
;
; Vielleicht der niedlichste Hubi, Knuddel.
;
;--------------------------------------------------
„ Helfen - Wehren - Heilen “

Personal Declaration: I always use different usernames across different websites. Hence if you ever see my username is being used outside of Stoudson Corporation, I absolutely have no affiliation whatsoever with that!

User avatar
medicineman
Firefly
Firefly
Posts: 24
Joined: Fri Sep 14, 2018 3:15 am

Re: Integer Limits

Post by medicineman » Mon Feb 11, 2019 11:56 pm

A couple of minor finds:

- The shield is (probably unsurprisingly) limited from 0-255%. However it appears that UA doesn't use the raw shield value from the script but applies it mod 255, i.e. mod(shield,255). So inputting a number < 0 or > 255 causes it to roll over. (I was trying to see if you could give a unit *negative* armor whereby it takes more damage rather than less - guess you can't.) The biggest number I put in was 900, which was just a random value. I don't know if there's a limit on that number, but there's not much point in exceeding that range anyway.

- It's actually possible to input a negative energy value for the host station energy (which makes sense since damage will probably cut the HP to less than zero, rather than exactly). This, or a value of zero, causes the host station to immediately explode upon entering the arena, which I find hilarious for some reason.

User avatar
CharlotteLabyrinth
Turantul 1 (Veteran)
Turantul 1 (Veteran)
Posts: 423
Joined: Thu Mar 01, 2012 3:00 pm
Location: Schloss Charlottenburg..?

Re: Integer Limits

Post by CharlotteLabyrinth » Tue Feb 19, 2019 4:38 pm

medicineman wrote:
Mon Feb 11, 2019 11:56 pm
- The shield is (probably unsurprisingly) limited from 0-255%. However it appears that UA doesn't use the raw shield value from the script but applies it mod 255, i.e. mod(shield,255). So inputting a number < 0 or > 255 causes it to roll over. (I was trying to see if you could give a unit *negative* armor whereby it takes more damage rather than less - guess you can't.) The biggest number I put in was 900, which was just a random value. I don't know if there's a limit on that number, but there's not much point in exceeding that range anyway.
You are correct. The shield value is defined by unsigned 8-bit integer and ranges between 0-255%, making it akin to a mathematical representation of the modulo operation. When the shield values exceed the maximum value or become negative values, the integers will cycle through between valid values instead crashing the game.

There is also a modding thread which contains a story about this.

Anecdotally, a majority of unsigned 8-bit functions in UA seem to be undergoing integer overflow rather than hard crashing the game... :idea:

medicineman wrote:
Mon Feb 11, 2019 11:56 pm
- It's actually possible to input a negative energy value for the host station energy (which makes sense since damage will probably cut the HP to less than zero, rather than exactly). This, or a value of zero, causes the host station to immediately explode upon entering the arena, which I find hilarious for some reason.
Since the host station energy values are defined by 32-bit signed integer, they can possess negative values. The opposite case is also true, where if the energy exceeds the maximal limit (through manipulating energy directly in a savegame file) then the host station will explode as a result of an integer overflow (from 2147483647 to -2147483648). I probably wrote something about it in another thread before... :arrow:

Fixed several mistakes and new info added to the main post!
;--------------------------------------------------
;
; Vielleicht der niedlichste Hubi, Knuddel.
;
;--------------------------------------------------
„ Helfen - Wehren - Heilen “

Personal Declaration: I always use different usernames across different websites. Hence if you ever see my username is being used outside of Stoudson Corporation, I absolutely have no affiliation whatsoever with that!

Ormu
Turantul 1 (Veteran)
Turantul 1 (Veteran)
Posts: 867
Joined: Fri Dec 26, 2008 4:59 pm
Location: Finland

Re: Integer Limits

Post by Ormu » Wed Jun 05, 2019 5:31 pm

CharlotteLabyrinth wrote:
Wed Jun 05, 2019 4:30 pm
Has anyone profoundly investigated the cause of an issue? I should preferably update my other post as well if 9 Stoudson Bombs in a level is confirmed to be causing glitches or instabilities of any sort. :P

I've also briefly skimmed through UA:Source code and found this line:

Code: Select all

        if ( yw->field_2d90->supetItems_count > 8 )
            return 4;
If I have some time later, I may check for all other variants of the original UA executables.
I think this discussion should be continued in this thread.

This is from Zidane's yw.h:

Code: Select all

supetItemProto supetItems[8];
So there's valid memory for only 8 Stoudson bombs.

Putting 9 works to an extent and the game can recognize 9 bombs. I guess that this array overflows but the game doesn't crash immediately, for some reason. Other strange behavior seems to occur.

UA Source and the original game (UA_xp) seem to behave in a similar way.
Image Im in ur base, stalkin ur hoststation


Not all Ormus are mine. When in doubt, please ask...

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests