SpazmoJones Posted March 18, 2015 Share Posted March 18, 2015 This is rather technical but hopefully somebody can help. I'm trying to make a name list mod that's gender aware. I plan to store the gender info in the surname as the first character. e.g. "1" for male, "2" for female Now I need to update the soldier gender depending on the surname that's been picked. I'm trying to avoid using if/then because it seems that I'll have to calculate offsets and things which I don't really want to get into. So instead I'm trying to use conditional assignments. I want to add a few lines of code after the following call in XGCharacterGenerator.CreateTSoldier which is in XComGame.upk // existing code line:GenerateName(kSoldier.kAppearance.iGender, kSoldier.iCountry, kSoldier.strFirstName, kSoldier.strLastName, kSoldier.kAppearance.iRace) // new lines below // iCountry var will hold gender// Gender is first character of surname 1=Male 2=FemaleiCountry = int( Mid( kSoldier.strLastName, 0, 1 ) ); // set the gender if it's specified in the namekSoldier.kAppearance.iGender = iCountry > 0 ? iCountry : kSoldier.kAppearance.iGender; // remove the first char from the surname if gender was specifiedkSoldier.strLastName = iCountry > 0 ? Mid( kSoldier.strLastName, 1 ) : kSoldier.strLastName; Now for the life of me I can't get the conditional hex code right. I've tried a few things, checked the result with UE Explorer and it's a mess. If I look at some working conditional examples using UE Explorer it doesn't seem to decode all of the bytes, e.g.: (65-77;1C3/127) [0F 35 82 0F 00 00 84 0F 00 00 00 00 35 8E 0F 00 00 99 0F 00 00 00 01 00 E7 B9 00 00 45 9A A7 2C 03 16 25 16 02 00 2C 02 01 00 26]LetToken(63/43)kSoldier.kAppearance.iGender = ((Rand(3) == 0) ? 2 : 1) (66-68;1C4/128) [35 82 0F 00 00 84 0F 00 00 00 00 35 8E 0F 00 00 99 0F 00 00 00 01 00 E7 B9 00 00] StructMemberToken(47/27) kSoldier.kAppearance.iGender (67-68;1D7/133) [35 8E 0F 00 00 99 0F 00 00 00 01 00 E7 B9 00 00] StructMemberToken(28/16) kSoldier.kAppearance (68-68;1EA/13E) [00 E7 B9 00 00] LocalVariableToken(9/5) kSoldier (69-77;1F3/143) [45 9A A7 2C 03 16 25 16 02 00 2C 02 01 00 26] ConditionalToken(15/15) ((Rand(3) == 0) ? 2 : 1) (70-75;1F4/144) [9A A7 2C 03 16 25 16] NativeFunctionToken(7/7) Rand(3) == 0 (71-73;1F5/145) [A7 2C 03 16] NativeFunctionToken(4/4) Rand(3) (72-72;1F6/146) [2C 03] IntConstByteToken(2/2) 3 (73-73;1F8/148) [16] EndFunctionParmsToken(1/1) ) (74-74;1F9/149) [25] IntZeroToken(1/1) 0 (75-75;1FA/14A) [16] EndFunctionParmsToken(1/1) ) (76-76;1FD/14D) [2C 02] IntConstByteToken(2/2) 2 (77-77;201/151) [26] IntOneToken(1/1) 1 You see the actual last few bytes are16 02 00 2C 02 01 00 26 but in the decoded data above the last few bytes are 16 2C 02 26 What do the extra bytes "02 00" and "01 00" in the conditional hex code mean? Does anyone here know the exact hex format used by conditionals is? Link to comment Share on other sites More sharing options...
johnnylump Posted March 18, 2015 Share Posted March 18, 2015 The extra bytes are relative jumps. Set them to the length of the result that immediately follows it. So 02 00 2c 02 01 00 26 is correct2c 02 (integer 2) is two bytes, so the relative jump is 02 0026 (integer/byte 1) is one byte, so the relative jump is 01 00 Link to comment Share on other sites More sharing options...
SpazmoJones Posted March 18, 2015 Author Share Posted March 18, 2015 Thanks johnny :) It makes perfect sense now. Link to comment Share on other sites More sharing options...
Recommended Posts