Author Topic: Internal Player Structure  (Read 2259 times)

0 Members and 1 Guest are viewing this topic.

Offline scient

Internal Player Structure
« on: December 06, 2016, 08:17:15 AM »
I have completed my analysis of how the game parses and stores the faction related files internally. This Player structure is created from the faction text files found in the game folder (default or custom). This structure is used as the basis for the active game structure for each faction which I haven't completed yet. I tried to do a few updates to the wiki however I don't really have time to do a more through job.

I've noticed two bugs that I don't believe yitzi or kyrub have addressed. However, I could be wrong. I haven't kept up with the latest patches and do analysis on an unmodified version of the game.

  • TECH, #: Free # of player selected tech at start seems to be broken. This would only affect custom factions.
  • Social Priority Effect: Completely broken and never set. This affects the AI for all factions, including default ones.
  • Social Opposition Effect: Also broken, but not used by default factions.

While the free number of TECH value is correctly set, I've never actually received the tech at the start of the game. Perhaps I am doing something wrong, however this might be another neglected feature like COMMFREQ rule since none of the default factions use it. The default factions only grant single specific tech which is handled slightly differently. I didn't trace further to track down this potential bug since it is outside the scope of the parsing of the Player structure. If anyone can confirm this is broken or works, please let me know!

As for the social priority effect, I can 100% confirm this is broken. For example, inside gaians.txt you have the following line: Economics, Green, PLANET. The category (Economics) and model (Green) are correctly set inside the Player struct. However, no matter what the effect is (in this case PLANET) the code sets it to -1 (nil). The opposition effect is always nil in the default factions, so that would only affect custom factions. Now, if you set the custom game rule "randomize faction leader social agendas" then a non-nil value is randomly set in this field. The effect priority field is actively used in a couple functions when I did a cursory test: communicate(), social_ai(). I imagine this could cause the AI not to strive towards the effect goals they were meant to as well as incorrect reactions to factions with similar/opposing views. However, perhaps it has no real effect at all.

To bug fixers:
This happens in the read_faction() function at offset 0x586DF7 in the SMACX binary and offset 0x59DCDE inside the SMAC binary. If you look at the two loops above it, you'll see how the category and model are parsed and set (strcmp > increment > repeat). This could be expanded to properly parse the effect values.

Some undocumented things I've noticed:
  • There are 304 unused padding bytes in the Player struct that could be used to add features.
  • Noun gender can be "Neutral". Unsure if this has any difference compared to male/female.
  • Adjective names for the faction must be separated by a colon. Default faction files do not adhere to this having portions after the 1st comma ignored completely. I didn't look into what happens when colons are properly used.
  • Interlude variables: Assistant and Scientist name, Assistant City.
  • SHARETECH/TECHSHARE override one another. Contrary to the documentation, the TECHSHARE parameter is not ignored but writes to the same internal variable as SHARETECH. However, unlike SHARETECH a flag is set for TECHSHARE that must handle its spying caveat.
  • Maximum of 8 faction bonuses. Only the first 8 are parsed, any after that are ignored.

If anyone has any questions, feel free to ask and I'll do my best to answer them or try to explain further.

Offline scient

Re: Internal Player Structure
« Reply #1 on: December 09, 2016, 04:28:53 PM »
While going through and verifying my findings in the code I noticed one final thing.

ROBUST, IMMUNITY: Both of these can take a modifier value like SOCIAL. So you could for example have "ROBUST, ++EFFIC" or "IMMUNITY, --ECONOMY". The modifier value is stored in the faction_bonus_val2[] variable just like SOCIAL. However, I am not sure the significance of this value in relation to ROBUST/IMMUNITY.

For SOCIAL, ROBUST and IMMUNITY if you do not specify a modifier value it will default to 1. So "SOCIAL, +EFFIC" and "SOCIAL, EFFIC" do exactly the same thing.

Perhaps these little quirks are already known but they aren't part of the original documentation on editing faction files. For the sake of completeness, I figured I would make a note of it.


Offline Yitzi

Re: Internal Player Structure
« Reply #2 on: December 25, 2016, 06:16:29 PM »
While going through and verifying my findings in the code I noticed one final thing.

ROBUST, IMMUNITY: Both of these can take a modifier value like SOCIAL. So you could for example have "ROBUST, ++EFFIC" or "IMMUNITY, --ECONOMY". The modifier value is stored in the faction_bonus_val2[] variable just like SOCIAL. However, I am not sure the significance of this value in relation to ROBUST/IMMUNITY.

I'm pretty sure it does nothing.

 

* User

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

* Community poll

SMAC v.4 SMAX v.2 (or previous versions)
-=-
24 (7%)
XP Compatibility patch
-=-
9 (2%)
Gog version for Windows
-=-
103 (32%)
Scient (unofficial) patch
-=-
40 (12%)
Kyrub's latest patch
-=-
14 (4%)
Yitzi's latest patch
-=-
89 (28%)
AC for Mac
-=-
3 (0%)
AC for Linux
-=-
6 (1%)
Gog version for Mac
-=-
10 (3%)
No patch
-=-
16 (5%)
Total Members Voted: 314
AC2 Wiki Logo
-click pic for wik-

* Random quote

That sunny dome! Those caves of ice! And all who heard should see them there, And all should cry, Beware! Beware! His flashing eyes, his floating hair! Weave a circle round him thrice, And close your eyes with holy dread, For he on honey-dew hath fed, And drunk the milk of Paradise.
~Samuel Taylor Coleridge, Datalinks

* Select your theme

*
Templates: 5: index (default), PortaMx/Mainindex (default), PortaMx/Frames (default), Display (default), GenericControls (default).
Sub templates: 8: init, html_above, body_above, portamx_above, main, portamx_below, body_below, html_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 45 - 1228KB. (show)
Queries used: 39.

[Show Queries]