Jump to content

Questions on a idea of mine


Krazyguy75

Recommended Posts

So, I was just wondering, when editing an ini, if you repurpose the variable in the UPK files, does the variable type (int, string, array, etc) have to remain the same in the ini file? Because I know that all the variables come with prefixes indicating their types (m_arr, m_i, m_e, m_str), and I was wondering if these are checked by the code to make sure they're the same, or if I could change the code in the ini to an array, and then have the array import correctly, as if it were the base variable (wiping out the previous code related to said variable, of course).

 

I'm to much of a n00b to test it out, but I thought that, if you could change the variable type (since the name doesn't include the type prefix internally; unless it is in the hex: I'm not familiar with the config import code) to an array, and then change the recieving side's code to read the first value of that array, and use all the spare values for additional config.

 

Ofc, I have no idea how any of this really works so it'll probably have tons of issues, but I just figured I might as well share my crazy idea, in case, by some wild coincidence, it works.

Link to comment
Share on other sites

I think it would work except for the part where you change the type of a variable. So far I've been completely unable to do this.

 

The closest I've been able to come is one time I was able to change which variables were part of a structure definition (was needed for the ammo mod so that ammo state was correctly saved via the CheckpointRecord structure).

 

So, the best I've been able to do so far is re-purposing config variables for another use. For example the BASE_FUNDING variable was changed from a 'fixed-income amount' to a '% of country income received' in the All Countries Contribute modlet. And of course any config variable that is a dynamic array can have additional entries added in the config file, which I have exploited rather mercilessly.

 

I haven't tried renaming a config variable, although I might try it out soon-ish.

Link to comment
Share on other sites

To be more precise, the variables in question that I was wondering about were not the base variables in the ini, but the variables in the arrays (characters, armor, weapons, etc). I'm pretty sure you cannot add more variables to these arrays (correct?), so I wanted to know if I could turn one of the existing variables into an array. But if my assumption that we can't add more variables to these arrays is wrong, then my idea was pointless.

Link to comment
Share on other sites

Ah, gotcha. Technically the things you are referring to aren't arrays but are instead structures.

 

For example the BalanceMods are of type :

struct native TCharacterBalance
{
    var XGGameData.ECharacter eType;
    var int iDamage;
    var int iCritHit;
    var int iAim;
    var int iDefense;
    var int iHP;
    var int iMobility;
    var int iWill;
}

So we'd have to add more entries to the struct definition, which I definitely haven't figured out how to do.

 

However, the actual config variable itself is defined like:

var config array<config TCharacterBalance> BalanceMods_Normal;

This is a dynamic array, each element of which is one of the above-defined structs. Since it is dynamic more elements can be added simply by defining more in the config file.

 

However the config file format doesn't require defining the array element number, which is why there are entries such as:

; Funding Multiplier by Difficulty Level (Easy,Normal,Classic,Impossible)
FundingBalance=1.5
FundingBalance=1
FundingBalance=1
FundingBalance=1

It's not really defining FundingBalance 4 times -- it is defining the 4 elements of the dynamic array FundingBalance. In a sense it's really doing:

; Funding Multiplier by Difficulty Level (Easy,Normal,Classic,Impossible)
FundingBalance[0]=1.5
FundingBalance[1]=1
FundingBalance[2]=1
FundingBalance[3]=1
Link to comment
Share on other sites

Ah, OK. My programmer-speak is still not fluent. Then what I was referring to is the ability to change the variable type of an individual item in said struct to an array, which I gather isn't possible. What gave me the idea was that m_i and m_e were used both in the struct and as the base variables, so I was thinking that maybe m_arr could be used in both. But if we can't change that, oh well. Just makes my planned code a little more complicated.

Link to comment
Share on other sites

Been pondering this some more...

 

I haven't been able to re-define the type of a given variable, but I have been able to change which variables are part of an already defined struct. Once. And it wasn't for a config variable but for a CheckpointRecord struct variable (for save games).

 

This was done for my EU ammo mod, and changed:

struct CheckpointRecord_XGWeapon extends CheckpointRecord_XGInventoryItem
{
    var int iAmmo;
    var int iOverheatChance;
};

into:

struct CheckpointRecord_XGWeapon extends CheckpointRecord_XGInventoryItem
{
    var int iAmmo;
    var int m_iTurnSaved;
};

So in this case I didn't change the type of the variable but just which variable was being referenced.

 

The values are changed for EW (this hex change was the one for EU patch 4), but the hex that needed changing was found in the CheckpointRecord_XGWeapon Table Buffer in UE Explorer:

(XGWeapon.CheckpointRecord_XGWeapon.iOverheatChance Table Buffer, to make m_iTurnSaved part of the CheckpointRecord instead of iOverheatChance
change:
95 FE FF FF 00 00 00 00 21 B9 00 00 35 3C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 00 07 00 28 00 00 00 7E 1C 92 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
to:
95 FE FF FF 00 00 00 00 21 B9 00 00 1E 4C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 00 07 00 28 00 00 00 7E 1C 92 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

In EU Patch 4 the '35 3C 00 00' was the reference to iOverheatChance and '1E 4C 00 00' was the reference to m_iTurnSaved.

Link to comment
Share on other sites

Another option is to digit-pack extra values into a single integer. All int types used in the game are 4 byte signed integers (bytes are only used for enums), so max value is somewhere north of 2 billion.

 

As an example, again taking the ammo mod, I took over an unused variable in the Weapon= structure iSuppression, and packed 2 values into it. For example iSuppression = 1206 would be parsed as the values 12 and 6. The low 2 digits were the number of shots for the weapon without Ammo Conservation and the high 2 digits where the number of shots with Ammo Conservation.

 

The code to do this uses mod and integer division:

iNormalShots = iSuppression % 100;
iAmmoConservationShots = iSuppression/100;
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...