anUser Posted April 9, 2013 Share Posted April 9, 2013 It starts to be maddening, I've been stuck with this for days and can't get it to work... The sentence I want to change is (XComStrategyGame >> XGStorage >> IsClassEquippable) if((((((eItem == 80) || eItem == 76) || eItem == 79) || eItem == 78) || eItem == 81) || eItem == 82) { return true; } and I want to replace it by if(((eItem >= 76) && (eItem <= 99)) || eItem == 36) { return true; eItem eItem eItem } And I actually get it to decompile like this, but once in the game it crashes when storage is accessed. Hex code for this is:84 82 99 00 72 40 00 00 2C 4C 16 98 00 72 40 00 00 2c 63 16 16 18 0E 00 9A 00 72 40 00 00 2C 24 16 16 04 27 00 72 40 00 00 00 72 40 00 00 00 72 40 00 00 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B I've checked those elements separately and it worked, but once I put them together it crashes on run-time. According to my tests the && (0x82) operator doesn't need an end token (0x16), but I couldn't get to de-compile or execute it properly once in the full condition without the second 16 after eItem <= 99. Needless to say I've checked virtual size and skip 'size' but those seem to be ok. Anyone's got any idea why this isn't working? Any help is appeciated Link to comment Share on other sites More sharing options...
johnnylump Posted April 9, 2013 Share Posted April 9, 2013 (edited) This won't resolve your coding question, but why not break it into two statements: If ((eItem >= 76) && (eItem <= 99)){ return true;}if (eItem == 36){ return true;}eItemeItem It looks like you have the 0bs and Virtual Size to spare ... (Not clear if you are trying to solve on principle or just get through this code section) Edited April 9, 2013 by johnnylump Link to comment Share on other sites More sharing options...
Amineri Posted April 9, 2013 Share Posted April 9, 2013 I've also taken a complete different approach to selecting which items can be equipped to SHIVs. I simply check whether eWP_Integrated has been set in the DGC.ini file. I'm not sure whether this would work for other classes, but I know that there is eWP_Heavy, eWP_Assault, and eWP_Sniper, eWP_Support, and eWP_AnyClass. In fact, below the code you are trying to modify in IsClassEquippable, there is a case statement which is testing: eWP_Heavy = 8, so you should be able to set the weapon property in the DGC.ini and leave the boolean code alone :) switch(eClass) { // End:0x25E case 4: return TACTICAL().WeaponHasProperty(eItem, 6); // End:0x339 break; // End:0x294 case 3: return TACTICAL().WeaponHasProperty(eItem, 4); // End:0x339 break; // End:0x2CA case 5: return TACTICAL().WeaponHasProperty(eItem, 5); // End:0x339 break; // End:0x300 case 2: return TACTICAL().WeaponHasProperty(eItem, 8); // End:0x339 break; // End:0x336 case 1: return TACTICAL().WeaponHasProperty(eItem, 7); // End:0x339 break; // End:0xFFFF default: return false; Link to comment Share on other sites More sharing options...
anUser Posted April 9, 2013 Author Share Posted April 9, 2013 Thanks for the help. Honestly it was a matter of pride and for the sake of knowing, I just wanted to get a conditional with an AND and an OR altogether, yeah maybe I'll just take the defeat and go practical and split that in two as JL says.In that range of items there are a few of the small items such as smoke grenades, battlescanner (99), and more, and some of them don't have an ini entry, that's why I put them al together in that check. Link to comment Share on other sites More sharing options...
Amineri Posted April 9, 2013 Share Posted April 9, 2013 Can we not create a new DGC.ini entry for items that didn't already have one? Link to comment Share on other sites More sharing options...
anUser Posted April 9, 2013 Author Share Posted April 9, 2013 dunno, but since it's embedded into the exe I thought that was mapping something inside the exe... no idea Link to comment Share on other sites More sharing options...
johnnylump Posted April 9, 2013 Share Posted April 9, 2013 I'm not sure that's ever been tested. Link to comment Share on other sites More sharing options...
Amineri Posted April 9, 2013 Share Posted April 9, 2013 (edited) I figured that editting the DGC.ini with something like Resource Hacker is already changing the size of the embedded text, so it wouldn't be a problem adding new line items. I confess, though, I haven't tested it yet. The relevant part of the code is dealing with the DGC.ini data is: foreach default.Weapons(W){BuildWeapon(W.iType, W.iDamage, W.iEnvironmentDamage, W.iRange, W.iReactionRange, W.iReactionAngle, W.iCritical, W.iRadius, W.iOffenseBonus, W.iSuppression, W.iSize, W.iHPBonus, W.iWillBonus, W.ABILITIES[0], W.ABILITIES[1], W.ABILITIES[2], W.ABILITIES[3], W.ABILITIES[4], W.ABILITIES[5], W.Properties[0], W.Properties[1], W.Properties[2], W.Properties[3], W.Properties[4], W.Properties[5]); } Since it is a "foreach" statement, there shouldn't be any sort of limit on how many items were built. Of course, adding items that don't have any sort of corresponding EItemType wouldn't do much good. Also, this only creates the weapon in the tactical game -- doing nothing for the strategy game side. Edited April 9, 2013 by Amineri Link to comment Share on other sites More sharing options...
Amineri Posted April 9, 2013 Share Posted April 9, 2013 I'm not sure that's ever been tested. I'd planned on using that as a part of my BuildItems() (strategy-side) refactoring. BTW, this is why the Kevlar armor could be built after messing with the settings in BuildItems() -- because there is no Kevlar item entry in the DGC.ini in the later "ItemBalance" section. The values defined in "ItemBalance" overwrite those defined in the direct BuildItems() call. My plan was to set all the cash / alloy / elerium / time / engineers values to zero (for all items) in the BuildItems() calls, and then add new entries to the DGC.ini "ItemBalance" section that would overwrite all the 1's and set the correct values (including -1s to make items non-buildable). I think this would make the whole thing a lot more easily configurable. Link to comment Share on other sites More sharing options...
Amineri Posted April 9, 2013 Share Posted April 9, 2013 UPDATE: I just did a quick test to confirm that new item lines can be added to the DGC.ini (I used Resource Hacker). I added the line: ItemBalance=(eItem=eItem_ArmorKevlar, iCash=50, iElerium=0, iAlloys=15, iTime=10, iEng=15) to the end of the ItemBalance section, and ran the game (no other changes, or XShape, or anything). Upon loading a game, the Kevlar Body armor was buildable in Engineering, with the relevant build requirements. It works, people! Link to comment Share on other sites More sharing options...
Recommended Posts