Daemonjax Posted February 5, 2015 Share Posted February 5, 2015 Is it possible to change the declaration of a class variable from an array of ints to an array of floats? Particularly XGStrategyAI.m_arrUFOsShotDown (which is currently an array of ints). Link to comment Share on other sites More sharing options...
tracktwo Posted February 6, 2015 Share Posted February 6, 2015 (edited) 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 February 6, 2015 by tracktwo Link to comment Share on other sites More sharing options...
Daemonjax Posted February 7, 2015 Author Share Posted February 7, 2015 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 More sharing options...
wghost81 Posted February 7, 2015 Share Posted February 7, 2015 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 More sharing options...
Daemonjax Posted February 7, 2015 Author Share Posted February 7, 2015 (edited) 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 February 8, 2015 by Daemonjax Link to comment Share on other sites More sharing options...
wghost81 Posted February 8, 2015 Share Posted February 8, 2015 (edited) 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 February 8, 2015 by wghost81 Link to comment Share on other sites More sharing options...
Recommended Posts