Project Perfect Mod Forums
:: Home :: Get Hosted :: PPM FAQ :: Forum FAQ :: Privacy Policy :: Search :: Memberlist :: Usergroups :: Register :: Profile :: Log in to check your private messages :: Log in ::


The time now is Thu Mar 28, 2024 8:17 am
All times are UTC + 0
"Deep Sea" Attack Script Question
Moderators: Global Moderators, Red Alert 2 Moderators
Post new topic   Reply to topic Page 1 of 1 [12 Posts] Mark the topic unread ::  View previous topic :: View next topic
Author Message
Chrono Vortex
Medic


Joined: 23 Nov 2015

PostPosted: Mon Nov 23, 2015 12:25 pm    Post subject:  "Deep Sea" Attack Script Question Reply with quote  Mark this post and the followings unread

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

Back to top
View user's profile Send private message
RP
Commander


Joined: 12 Jul 2012
Location: Mapping God Heaven

PostPosted: Mon Nov 23, 2015 12:54 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hi there, and welcome!

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:
Code:
TYPE = 0, 1, 2, 3
CONSTANT = 65536

INDEX = ACTUALINDEX - (TYPE * CONSTANT)
7 = 131079 - (2 * 65536)

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.

Hope this helps! Smile

_________________


Mental Omega 3.0 Mission creator - Creator of FinalOmega: APYR 3.0 Map Editor

/ppm/'s stupidity

Back to top
View user's profile Send private message
Chrono Vortex
Medic


Joined: 23 Nov 2015

PostPosted: Mon Nov 23, 2015 10:51 pm    Post subject: Reply with quote  Mark this post and the followings unread

This is exactly what I was looking for, thanks!

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.

_________________

Back to top
View user's profile Send private message
G-E
Defense Minister


Joined: 09 Feb 2015

PostPosted: Wed Nov 25, 2015 10:45 am    Post subject: Reply with quote  Mark this post and the followings unread

I still disagree with the modifier meanings...

128k = attack/approach if safe to do so
192k = attack/approach ignoring all threats

_________________
http://www.moddb.com/mods/scorched-earth-ra2-mod-with-smart-ai

Back to top
View user's profile Send private message
Crimsonum
Seth


Joined: 14 Jul 2005
Location: Fineland

PostPosted: Wed Nov 25, 2015 9:26 pm    Post subject: Reply with quote  Mark this post and the followings unread

RP wrote:
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.

_________________


Back to top
View user's profile Send private message
E1 Elite
General


Joined: 28 May 2013

PostPosted: Thu Nov 26, 2015 7:19 am    Post subject: Reply with quote  Mark this post and the followings unread


Back to top
View user's profile Send private message
Blade
Cyborg Commando


Joined: 23 Dec 2003

PostPosted: Thu Nov 26, 2015 9:11 am    Post subject: Reply with quote  Mark this post and the followings unread

Crimsonum wrote:
RP wrote:
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.

Back to top
View user's profile Send private message
Crimsonum
Seth


Joined: 14 Jul 2005
Location: Fineland

PostPosted: Thu Nov 26, 2015 11:33 am    Post subject: Reply with quote  Mark this post and the followings unread

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 #Tongue

_________________


Back to top
View user's profile Send private message
RP
Commander


Joined: 12 Jul 2012
Location: Mapping God Heaven

PostPosted: Thu Nov 26, 2015 11:56 am    Post subject: Reply with quote  Mark this post and the followings unread

There is a difference, 0xFFFF = 65535, 0x10000 = 65536.

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.

_________________


Mental Omega 3.0 Mission creator - Creator of FinalOmega: APYR 3.0 Map Editor

/ppm/'s stupidity

Back to top
View user's profile Send private message
Crimsonum
Seth


Joined: 14 Jul 2005
Location: Fineland

PostPosted: Thu Nov 26, 2015 12:50 pm    Post subject: Reply with quote  Mark this post and the followings unread

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.

_________________


Back to top
View user's profile Send private message
G-E
Defense Minister


Joined: 09 Feb 2015

PostPosted: Fri Nov 27, 2015 9:10 pm    Post subject: Reply with quote  Mark this post and the followings unread

E1 Elite wrote:
@G-E: Sometimes, reading after a gap gives better understanding, unless you have decided to disagree.

Refer:
http://www.ppmforums.com/viewtopic.php?p=524088#524088
http://www.ppmforums.com/viewtopic.php?p=531799#531799

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.

Back to top
View user's profile Send private message
E1 Elite
General


Joined: 28 May 2013

PostPosted: Sat Nov 28, 2015 5:45 am    Post subject: Reply with quote  Mark this post and the followings unread

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.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [12 Posts] Mark the topic unread ::  View previous topic :: View next topic
 
Share on TwitterShare on FacebookShare on Google+Share on DiggShare on RedditShare on PInterestShare on Del.icio.usShare on Stumble Upon
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


Powered by phpBB © phpBB Group

[ Time: 0.1637s ][ Queries: 11 (0.0079s) ][ Debug on ]