Jump to content
We are aware aware of an issue with authentication on the site. See our status page for details. ×

Changing class variable type


Daemonjax

Recommended Posts

Changing its type would also require changing the code in every place that variable is used as an operand, as different opcodes are used for int and float. But otherwise I think it should be possible. I've changed the attributes on variables successfully (e.g. config) and changed the element type of an array between two different object types, but I've never tried changing the primitive type of a variable Edited by tracktwo
Link to comment
Share on other sites

Changing its type would also require changing the code in every place that variable is used as an operand, as different opcodes are used for int and float. But otherwise I think it should be possible. I've changed the attributes on variables successfully (e.g. config) and changed the element type of an array between two different object types, but I've never tried changing the primitive type of a variable

 

m_arrUFOsShotDown isn't used in many places. I can make better use of it if it were an array of floats... but I can work around it if it's not possible or too difficult... Not having an array of floats to work with would just be a handicap of sorts.

Link to comment
Share on other sites

For Patcher:

UPK_FILE=XComStrategyGame.upk
EXPORT_ENTRY=XGStrategyAI.m_arrUFOsShotDown.m_arrUFOsShotDown
OBJIDX=Core.FloatProperty // Type
To change the type of the array you need to change the type of its inner object (first 4 bytes of corresponding export table entry). Thankfully, IntProperty and FloatProperty have the same serial data, so no further changes are needed in this case.

 

And, of course, don't forget to use proper tokens (for floating point operations) while modifying all the scripts needed.

Link to comment
Share on other sites

For Patcher:

UPK_FILE=XComStrategyGame.upk
EXPORT_ENTRY=XGStrategyAI.m_arrUFOsShotDown.m_arrUFOsShotDown
OBJIDX=Core.FloatProperty // Type
To change the type of the array you need to change the type of its inner object (first 4 bytes of corresponding export table entry). Thankfully, IntProperty and FloatProperty have the same serial data, so no further changes are needed in this case.

 

And, of course, don't forget to use proper tokens (for floating point operations) while modifying all the scripts needed.

 

 

That's awesome! Exactly what I needed. I doubt that I would have figured it out eventually... I couldn't find upkutils examples of the above, so thanks again.

 

 

Small addition so it hits the checkpoint record as well:

 

UPK_FILE=XComStrategyGame.upk
EXPORT_ENTRY=XGStrategyAI.m_arrUFOsShotDown.m_arrUFOsShotDown
OBJIDX=Core.FloatProperty // Type


EXPORT_ENTRY=XGStrategyAI.CheckpointRecord.m_arrUFOsShotDown.m_arrUFOsShotDown
OBJIDX=Core.FloatProperty // Type
Applied and looks good in UE Explorer:
struct CheckpointRecord
{
    var bool m_bFirstMission;
    var array<XGShip_UFO> m_arrUFOs;
    var array<float> m_arrUFOsShotDown;
   ...
}


var array<float> m_arrUFOsShotDown;
Edited by Daemonjax
Link to comment
Share on other sites

Yes, I tend to forget about CheckpointRecord and scratch my head when some weird bugs appear because of it. :smile:

 

Good advice for everyone: always check if the variable you modifying is the part of CheckpointRecord structure. :smile:

 

Just for the reference: CheckpointRecord structure is used to save/load saved games.

 

BTW, I saw your topic on StrategyAI mod and I recommend to try and use Mutators for this purpose, as hex-coding such a complex mod is a pain. XCOM Mutators project on GitHub: https://github.com/wghost/XCOM-Mutators

Edited by wghost81
Link to comment
Share on other sites

  • Recently Browsing   0 members

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