Amphibious Posted August 10, 2014 Author Share Posted August 10, 2014 Hmmm... I have a problem. The scripts writes well and doesn't cause the game to crash however desired effect is left out for some reason. So I tried to rewrite it to set all males to snipers and all female to heavies; I got 1 male support, 2 male and 1 female heavy. great :mad: here is the script itself: OBJECT=XGFacility_Barracks.DEMOAddNewSoldiers:AUTO [REPLACEMENT_CODE]// m_arrClassWaitingList.Length = 0;0F 36 01 <@m_arrClassWaitingList> 2C 00 // kSoldier = GetSoldierByID(iNumSoldiers)0F 00 <.kSoldier> 1B <GetSoldierByID> 00 <.iNumSoldiers> 16 // if (kSoldier != none) {07 [@SoldierFound_END] 77 00 <.kSoldier> 2A 16 // if (kSoldier.m_kChar.aStats[1] > 70) { 07 [@Aim68] 97 1A 2C 01 35 <XComGame.XGTacticalGameCoreNativeBase.TCharacter.aStats> <XComGame.XGTacticalGameCoreNativeBase.TCharacter> 00 01 19 00 <.kSoldier> 09 00 <XGStrategySoldier.m_kChar> 00 01 <XGStrategySoldier.m_kChar> 2C 46 16 // if (kSoldier.kAppearance.iGender == 1) { 07 [@Aim76_Mid] 9A 35 <XComGame.XGTacticalGameCoreNativeBase.TAppearance.iGender> <XComGame.XGTacticalGameCoreNativeBase.TAppearance> 00 00 35 <XComGame.XGTacticalGameCoreNativeBase.TSoldier.kAppearance> <XComGame.XGTacticalGameCoreNativeBase.TSoldier> 00 01 00 <.kSoldier> 2C 01 16 // m_arrClassWaitingList.add(1); 55 01 <@m_arrClassWaitingList> 03 00 2C 01 16 06 [@Aim76_END] // } else if (kSoldier.kAppearance.iGender == 2) { [#Aim76_Mid] 07 [@Aim76_Low] 9A 35 <XComGame.XGTacticalGameCoreNativeBase.TAppearance.iGender> <XComGame.XGTacticalGameCoreNativeBase.TAppearance> 00 00 35 <XComGame.XGTacticalGameCoreNativeBase.TSoldier.kAppearance> <XComGame.XGTacticalGameCoreNativeBase.TSoldier> 00 01 00 <.kSoldier> 2C 02 16 // m_arrClassWaitingList.add(2); 55 01 <@m_arrClassWaitingList> 03 00 2C 02 16 06 [@Aim76_END] // } else { [#Aim76_Low] // m_arrClassWaitingList.Length = 1; 0F 36 01 <@m_arrClassWaitingList> 2C 01 // m_arrClassWaitingList[0] = 1; 0F 10 25 01 <@m_arrClassWaitingList> 2C 01 // } [#Aim76_END] // } 06 [@Aim_END] // else if (kSoldier.m_kChar.aStats[1] > 62) { [#Aim68] 07 [@Aim60] 97 1A 2C 01 35 <XComGame.XGTacticalGameCoreNativeBase.TCharacter.aStats> <XComGame.XGTacticalGameCoreNativeBase.TCharacter> 00 01 19 00 <.kSoldier> 09 00 <XGStrategySoldier.m_kChar> 00 01 <XGStrategySoldier.m_kChar> 2C 3E 16 // if (kSoldier.kAppearance.iGender == 1) { 07 [@Aim68_Mid] 9A 35 <XComGame.XGTacticalGameCoreNativeBase.TAppearance.iGender> <XComGame.XGTacticalGameCoreNativeBase.TAppearance> 00 00 35 <XComGame.XGTacticalGameCoreNativeBase.TSoldier.kAppearance> <XComGame.XGTacticalGameCoreNativeBase.TSoldier> 00 01 00 <.kSoldier> 2C 01 16 // m_arrClassWaitingList.add(1); 55 01 <@m_arrClassWaitingList> 03 00 2C 01 16 06 [@Aim68_END] // } else if (kSoldier.kAppearance.iGender == 2) { [#Aim68_Mid] 07 [@Aim68_Low] 9A 35 <XComGame.XGTacticalGameCoreNativeBase.TAppearance.iGender> <XComGame.XGTacticalGameCoreNativeBase.TAppearance> 00 00 35 <XComGame.XGTacticalGameCoreNativeBase.TSoldier.kAppearance> <XComGame.XGTacticalGameCoreNativeBase.TSoldier> 00 01 00 <.kSoldier> 2C 02 16 // m_arrClassWaitingList.add(2); 55 01 <@m_arrClassWaitingList> 03 00 2C 02 16 06 [@Aim68_END] // } else { [#Aim68_Low] // m_arrClassWaitingList.Length = 1; 0F 36 01 <@m_arrClassWaitingList> 2C 01 // m_arrClassWaitingList[0] = 2; 0F 10 25 01 <@m_arrClassWaitingList> 2C 02 // } [#Aim68_END] // } 06 [@Aim_END] // else if (kSoldier.m_kChar.aStats[1] > 54) { [#Aim60] 07 [@AimOther] 97 1A 2C 01 35 <XComGame.XGTacticalGameCoreNativeBase.TCharacter.aStats> <XComGame.XGTacticalGameCoreNativeBase.TCharacter> 00 01 19 00 <.kSoldier> 09 00 <XGStrategySoldier.m_kChar> 00 01 <XGStrategySoldier.m_kChar> 2C 36 16 // if (kSoldier.kAppearance.iGender == 1) { 07 [@Aim60_Mid] 9A 35 <XComGame.XGTacticalGameCoreNativeBase.TAppearance.iGender> <XComGame.XGTacticalGameCoreNativeBase.TAppearance> 00 00 35 <XComGame.XGTacticalGameCoreNativeBase.TSoldier.kAppearance> <XComGame.XGTacticalGameCoreNativeBase.TSoldier> 00 01 00 <.kSoldier> 2C 01 16 // m_arrClassWaitingList.add(1); 55 01 <@m_arrClassWaitingList> 03 00 2C 01 16 06 [@Aim60_END] // } else if (kSoldier.kAppearance.iGender == 2) { [#Aim60_Mid] 07 [@Aim60_Low] 9A 35 <XComGame.XGTacticalGameCoreNativeBase.TAppearance.iGender> <XComGame.XGTacticalGameCoreNativeBase.TAppearance> 00 00 35 <XComGame.XGTacticalGameCoreNativeBase.TSoldier.kAppearance> <XComGame.XGTacticalGameCoreNativeBase.TSoldier> 00 01 00 <.kSoldier> 2C 02 16 // m_arrClassWaitingList.add(2); 55 01 <@m_arrClassWaitingList> 03 00 2C 02 16 06 [@Aim60_END] // } else { [#Aim60_Low] // m_arrClassWaitingList.Length = 1; 0F 36 01 <@m_arrClassWaitingList> 2C 01 // m_arrClassWaitingList[0] = 3; 0F 10 25 01 <@m_arrClassWaitingList> 2C 03 // } [#Aim60_END] // } 06 [@Aim_END] // else { [#AimOther] // if (kSoldier.kAppearance.iGender == 1) { 07 [@AimOther_Low] 9A 35 <XComGame.XGTacticalGameCoreNativeBase.TAppearance.iGender> <XComGame.XGTacticalGameCoreNativeBase.TAppearance> 00 00 35 <XComGame.XGTacticalGameCoreNativeBase.TSoldier.kAppearance> <XComGame.XGTacticalGameCoreNativeBase.TSoldier> 00 01 00 <.kSoldier> 2C 01 16 // m_arrClassWaitingList.add(1); 55 01 <@m_arrClassWaitingList> 03 00 2C 01 16 06 [@AimOther_END] // } else { [#AimOther_Low] // m_arrClassWaitingList.add(2); 55 01 <@m_arrClassWaitingList> 03 00 2C 02 16 // } [#AimOther_END] // } [#Aim_END] // if (m_arrClassWaitingList.length > 1) { 07 [@EmptyWaitingList_END] 97 36 01 <@m_arrClassWaitingList> 2C 01 16 // GetLeastCommonClass(); 1B <GetLeastCommonClass> 16 // } [#EmptyWaitingList_END] // }[#SoldierFound_END] // return04 0B // EOS53 Obviously I don't understand how this function/script works exactly. The bold part at the end of each aim range is unclear to me, what does it do exactly? I thought that is class isn't listed under set certain set of condition it won't be assigned to that soldier. Either that or gender conditions don0't work here what would be even worse. I'll make some more test on the original script perhaps I manage to figure how it behaves. Link to comment Share on other sites More sharing options...
Amphibious Posted August 10, 2014 Author Share Posted August 10, 2014 Ok, after testing I know that the problems is in this part of the script: // if (kSoldier.kAppearance.iGender == 1) { 07 [@Aim68_Mid] 9A 35 <XComGame.XGTacticalGameCoreNativeBase.TAppearance.iGender> <XComGame.XGTacticalGameCoreNativeBase.TAppearance> 00 00 35 <XComGame.XGTacticalGameCoreNativeBase.TSoldier.kAppearance> <XComGame.XGTacticalGameCoreNativeBase.TSoldier> 00 01 00 <.kSoldier> 2C 01 16 If written like this it's simply ignored as if no soldier at all fit this description, and that is the best case scenario. Tried to alter it and I either get crash at start or crash upon returning to base. I don't now what else to try. Link to comment Share on other sites More sharing options...
wghost81 Posted August 10, 2014 Share Posted August 10, 2014 (edited) This code or the code which gets executed if the condition is true? I suggest you invite original mod author to this topic. He changed how original scripts work very much, so it will take a lot of work for me to read through this new code and understand it. And, as I said, I'm devoting all my XCOM time to LW Linux version now. :smile: PS Download UPKModder archive. It has operand_data.ini file inside, which contains all the XCOM tokens. This will help you to read through scripts, as you don't have access to UE Explorer. Edited August 10, 2014 by wghost81 Link to comment Share on other sites More sharing options...
Amphibious Posted August 10, 2014 Author Share Posted August 10, 2014 Actually you are the author of the piece of code im trying to insert into projectmercy mod. It is from soldier gender probability mod. His code works fine. Problem is in this new part which simply gets ignored. Link to comment Share on other sites More sharing options...
Amphibious Posted August 10, 2014 Author Share Posted August 10, 2014 (edited) This code if i set different condition like aim or mob or even will it works quite fine. Problem is not in code that gets executed. It seems that this condition is never met. Edited August 10, 2014 by Amphibious Link to comment Share on other sites More sharing options...
Amphibious Posted August 10, 2014 Author Share Posted August 10, 2014 (edited) @Amineri could you please post the script for XGCharacterGenerator.GenerateName as well. Thx I think I know what's making troubles. It seems that referencing is slightly different when setting a variable and when calling it. Perhaps something useful might surface in function mentioned above. Edited August 10, 2014 by Amphibious Link to comment Share on other sites More sharing options...
wghost81 Posted August 11, 2014 Share Posted August 11, 2014 You can't simply copy a part of one code into another code. kSoldier variable has different type for both functions. DEMOAddNewSoldiers has it defined as local XGStrategySoldier kSoldier and CreateTSoldier defines it as local TSoldier kSoldier So, ultimately, you're working with different objects and kSoldier variable of XGStrategySoldier has TSoldier variables stored inside member variable named m_kSoldier: var TSoldier m_kSoldier So, to access soldier gender of XGStrategySoldier toy have to look for it in kSoldier.m_kSoldier: kSoldier.m_kSoldier.kAppearance.iGender Link to comment Share on other sites More sharing options...
Amineri Posted August 11, 2014 Share Posted August 11, 2014 Yes, this is part of the joy of doing object-oriented programming via hex-editing :D Even better, local variables such as : local XGStrategySoldier kSoldier; have a different export object reference for each function they are defined in, and the values are unrelated to each other. For example, in XGFacility_Barracks.AddNewSoldiers, kSoldier has reference 18 32 00 00However, in XGFacility_Barracks.ChooseHQAssaultSquad, kSoldier has reference 4B 32 00 00 Using the wrong reference will, in the best case, result in code that doesn't work, and in the worst case, code that crashes the game. Link to comment Share on other sites More sharing options...
Amphibious Posted August 11, 2014 Author Share Posted August 11, 2014 ok, i roughly understand why it isn't working now. but still i i don't understand how it should be written to work....a and actually i didn't even try to access XGStrategySoldier with my piece of code but the one from xcomgame. i think i'll probably give up on this since i don't understand how it works Link to comment Share on other sites More sharing options...
Amphibious Posted August 11, 2014 Author Share Posted August 11, 2014 (edited) I get i now!!! I figured out how it works, thanks wghost81 it's exactly as you said I just didn't understand how it works at the beggining. this is the final code that actually gets the job done: // if (kSoldier.m_kSoldier.kAppearance.iGender == 1) { 07 [@AimOther] 9A 35 <XComGame.XGTacticalGameCoreNativeBase.TAppearance.iGender> <XComGame.XGTacticalGameCoreNativeBase.TAppearance> 00 00 35 <XComGame.XGTacticalGameCoreNativeBase.TSoldier.kAppearance> <XComGame.XGTacticalGameCoreNativeBase.TSoldier> 00 01 19 00 <.kSoldier> 90 00 <XGStrategySoldier.m_kSoldier> 00 01 <XGStrategySoldier.m_kSoldier> 2C 01 16 In my test mod I got all females set to snipers and males to support. Now can can go and edit the main mod file to get the desired effect. Thank you so very much again. Edited August 11, 2014 by Amphibious Link to comment Share on other sites More sharing options...
Recommended Posts