Posted: Mon Nov 23, 2015 12:25 pm Post subject:
"Deep Sea" Attack Script Question
I've been referring to the seventh Allied mission in RA2 to try to get a survival map to work properly and I found something interesting.
Apparently the number 131079 is somehow associated with the war factory like some sort of building ID, because the dreadnought attached to that script always attacks it when it gets to that point in the script. I have no idea what the connection between that number and the war factory is though. I've tried everything I can to get the information out of FA2, I've even pulled the map apart in Notepad++ without any luck.
I'm hoping someone could shed some light on exactly what the connection is between the building and the "ID" number, and perhaps suggest a way to find the ID numbers of other buildings in other maps. _________________ Last edited by Chrono Vortex on Thu Nov 26, 2015 8:55 pm; edited 1 time in total QUICK_EDIT
It has to do with the way this War Factory is targeted. This setup requires its index in the BuildingTypes list, and some additional values:
Renegade Projects wrote:
Attack Enemy Structure, Move To Enemy Structure, ChronoSphere to Enemy Structure, Move To Friendly Structure:
argument is the building's index in the [BuildingTypes] list, with one flag having four possible values:
Values:
Value 0 - pick structure whose position poses the least threat
Value 1 - pick structure whose position poses the most threat
Value 2 - pick structure which is closest to you
Value 3 - pick structure which is the farthest away from you
In hexadecimal, the result is argument = flag * 0x10000 | buildingIndex.
In layman's terms, at first the argument is the building's index. Add (Value * 65536) to the index to get the final argument you should use. This sets a theoretical limit of max 65536 (#0 - #65535) BuildingTypes in the game, should you feel insane enough to try that.
If you want to calculate it yourself, you could use this to help you:
ACTUALINDEX = TYPE * CONSTANT + INDEX
131079 = 2 * 65536 + 7 <-- 7 is the index of a War Factory (GAWEAP) in your rules.ini?
INDEX = 131082 - (TYPE * 65536)
Basically, if you have multiple targets, and you want to specify what target comes first, you could use these 4 values (0, 1, 2, 3), multiply it by 65536 and you have your specific target.
In this case for the War Factory, it tells the Dreadnought to target the closest War Factory.
It's funny how sometimes it's so much easier to get a skirmish map to do what it's not supposed to do than it is to get it to do what it is supposed to do, like getting a dreadnought to actually fire at buildings on land correctly. _________________
In hexadecimal, the result is argument = flag * 0x10000 | buildingIndex.
This is what I've been wondering, is there a reason for the particular hex number (0x10000)? Considering the ridiculously high limit it sets for max. building count, something like 0x1000 would've been more than sufficient. _________________
In hexadecimal, the result is argument = flag * 0x10000 | buildingIndex.
This is what I've been wondering, is there a reason for the particular hex number (0x10000)? Considering the ridiculously high limit it sets for max. building count, something like 0x1000 would've been more than sufficient.
Its a bit shift of 16 places, it looks to me like it treats the 32bit number as two 16bit numbers internally, one is the index, the other is a bit field of behaviour flags. I'm sure AlexB could confirm or deny this. At any rate, the reason for it is a game code thing. QUICK_EDIT
Ah, thanks for the info. However, now I'm wondering why it's not 0xFFFF, since 16 bits can be represented by exactly 4 hex characters? Why add an extra 1? Please bear with me, I'm only beginning to learn programming _________________
As Blade says, it uses 16bits from a 32bit integer, which means the all the other bits are used for the BuildingType.
Integer:
[00000000][00000000][00000000][00000000]
[ behaviour flags data ][ building index data ]
0xFFFF refers to the latter 2 bytes, 0x10000 refers to the former 2 bytes as it has a value higher than the max of those first 2 bytes.
Both sets of bytes have entirely unique purposes, no bit from each of the set is used for the other. _________________
Ah, now I get it. So it uses multiples of 0x10000 in order to "jump over" the rightmost two bytes. Thanks for the visualization, it helped a lot. _________________
Yes I disagree because I use it all over my ai.ini for years... maybe there are cases where it works differently, but that doesn't mean it's wrong.
Secondly, ignoring our opinions, it seems much likely that they are expressions of functions already found in TeamTypes code, but as explicit override for the particular action, and not some all new arbitrary near/far calculation. QUICK_EDIT
TThere is no confirmation that you have tried the example that I made for you specifically as you mod RA2.
It has to be tested with vanilla RA2. Did you run the example or not?
Suicide, AvoidThreats, ThreatAvoidanceCoefficient etc. can be switched off and tested too. I did that when
you first mentioned them, it does not work that way. Even with fully implemented threat rating node, it
doesn't work the way you mention for 128k/192k. But the example can confirm the near/far target selection. QUICK_EDIT
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum