anUser Posted March 16, 2013 Share Posted March 16, 2013 Partial success editing this two functions. With the code Yzaxtol posted grenades can be built, and removing the whole line m_arrInfiniteItems.AddItem(85); for 0b's worked on new games, not saved ones. Though I started with 100 grenades in stock, and every grenade was automatically spent at the end of the mission and new ones already placed in soldiers slots (at least that's what it seems, I just finished the 1rst map and got 82 grenades left in stock). I've tried it with frag grenades, haven't seen yet where's the call for infiite alien grenades. Link to comment Share on other sites More sharing options...
johnnylump Posted March 17, 2013 Share Posted March 17, 2013 Check XComStrategyGame >> XGFacility_Engineering >> GrantInitialStores() sets initial stores of items, although alien grenades is not there. >> OnFoundryProjectCompleted () includes the following lines if(m_arrFoundryProjects[iProject].eTech == 2) { STORAGE().m_arrInfiniteItems.AddItem(88); BARRACKS().UpdateGrenades(88); } Doing away with the m_arrInfiniteItems call (and possibly correcting jumps and virtual size) should cover the "infinite alien grenades" issue. Link to comment Share on other sites More sharing options...
johnnylump Posted March 18, 2013 Share Posted March 18, 2013 (edited) Yzaxtol, on 15 Mar 2013 - 07:11, said:I've found what I beleive is the Alien Grenade in XGItemTree.BuildItems BuildItem(88, -1, -1, -1, 2, 6); To BuildItem(88, 10, 5, 1, 1, 25, 2, 6); Alien grenades that require $10,5 Elerium, 1 Alloy, 1 Day, 25 Engineers, #2 Foundry Project (alien grenades), and #6 image (alien grenades) The HEX code for (88, -1, -1, -1, 2, 6); 2C 58 1D FF FF FF FF 4A 4A 1D FF FF FF FF 1D FF FF FF FF 4A 4A 24 02 2C 06 16 1B 6E 04 00 00 00 00 00 00 // 2C 50 Do you programming boffins think it's possible? To make these buildable, in XComStrategyGame.upk change 2C 58 1D FF FF FF FF 4A 4A 1D FF FF FF FF 1D FF FF FF FF 4A 4A 24 02 2C 06 16 to 2c 58 2c 0a 2c 03 2c 00 2c 03 2c 14 4a 4a 24 02 2c 06 16 0b 0b 0b 0b 0b 0b 0bFor your own uses, you can change the settings. The relevant numbers are the ones AFTER the "2c" bytes. 2nd 2c: (2c 0a) Cash $103rd 2c: (2c 03) 3 Elerium4th 2c: (2c 00) 0 Alloys5th 2c: (2c 03) 3 Days construction time6th 2c: (2c 14) 20 Engineers required Don't change any of the rest! Next is an attempt to remove the infinite items code when the alien grenades technology is researched in the foundry. This is a kludge; it simply makes regular grenades infinite again. It's a lot easier to modify the script with this simple change. But it's possible it will have weird results. This is in OnFoundryProjectComplete. 00 24 58 16 0f 10 35 to 00 24 55 16 0f 10 35 Unfortunately, I can't test this at the moment! I don't have a savegame ready to go where I can develop alien grenades. I'd ask that someone try these code changes and report whether they do the trick. The only other bit I'm concerned about is how this plays with the Grenadier perk -- what happens when you use one grenade of your two, and when you have only one to equip. Edited March 18, 2013 by johnnylump Link to comment Share on other sites More sharing options...
johnnylump Posted March 18, 2013 Share Posted March 18, 2013 Clarification: The build items change has been tested and works. I don't know about the second (doing away with the infinite items code). And I don't know if this is sufficient, but it may do the trick, given you can use alien grenades without the foundry tech. Let me know! Link to comment Share on other sites More sharing options...
Yzaxtol Posted March 18, 2013 Author Share Posted March 18, 2013 (edited) Will do, I've just been told I've probably messed up the AI in my mod since the last patch so I've got that to fix as a priority. After that I'll have a good 'ol whack at making alien 'nades. Edit: Cheers for all the help. I'd be useless (no exaggeration) without you awesome coders. Edited March 18, 2013 by Yzaxtol Link to comment Share on other sites More sharing options...
anUser Posted March 18, 2013 Share Posted March 18, 2013 Yesterday I only managed to make storage unaccessible :( I've found this functions getNumAvailableItems, getInfinitePrimaryWeapon, and avobe all isInfinite. Can't remember the class or upk now, I think it's xgstorage something, or xgfacility_barracks, but I need a better understanding of jumps and gotos to get it skips those checks. If it is so simple as that we could take it to it's maximum exponent and make EVERY item consumable, including basic armor and weaponry, I'll def do it for my game. I'll post the functions on the wiki when I make it home, unless yoi get it before Link to comment Share on other sites More sharing options...
anUser Posted March 19, 2013 Share Posted March 19, 2013 The infinite items stuff doesn't seem to work... The function I mentioned before is in XComStrategyGame.upk >> XGStorage >> GetNumItemsAvailable(), which reads: function int GetNumItemsAvailable(int iItemType) { // End:0x21 if(IsInfinite(byte(iItemType))) { return 1000; } // End:0x4A else { return m_arrItems[iItemType] - m_arrClaims[iItemType]; } //return ReturnValue; } Attempting to change this failed because my lack of knowledge of jumps, BUT I managed to change XGStorage.IsInfinite() to read function bool IsInfinite(XComGame.XGGameData.EItemType eItem) { return 0; } That was (note it may differ from your code on the first 6 bytes) SF: 65 40 00 00 A9 1F 00 00 00 00 00 00 63 40 00 00 00 00 00 00 00 00 00 00 65 40 00 00 00 00 00 00 29 00 00 00 5F 05 00 00 29 00 00 00 1D 00 00 00 04 9B 46 01 5F 40 00 00 0A 00 00 65 40 00 00 16 1D FF FF FF FF 16 04 3A 64 40 00 00 53 00 00 00 02 00 02 00 78 14 00 00 00 00 00 00 RW: 65 40 00 00 A9 1F 00 00 00 00 00 00 63 40 00 00 00 00 00 00 00 00 00 00 65 40 00 00 00 00 00 00 29 00 00 00 5F 05 00 00 1D 00 00 00 1D 00 00 00 04 25 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 53 00 00 00 02 00 02 00 78 14 00 00 00 00 00 00 In this case I assumed virtual size would be identical to fisical size since there's no extra reference and there are only 1 byte elements (4a - return, and 25 - 0 or false), is that how it works? Anyway, the case is that I got 100 of everything, so in stock there's always 100 minus what my soldiers have equipped. I played a couple of missions but I always get the same amount (81 in my case, as I got 20 soldiers but 1 is wounded from 1st mission), no matter how many grenades I spend... I *think* the key maybe in some "release loadout" function, like this in XComStrategyGame.upk, but I think I've seen similar functions for the skyranger and it may be well tangled, so who knows. XGStorage.ReleaseLoadout function ReleaseLoadout(XGStrategySoldier kSoldier) { local int I, iItem; ReleaseItem(kSoldier.m_kChar.kInventory.iArmor, kSoldier); kSoldier.m_kChar.kInventory.iArmor = 0; ReleaseItem(kSoldier.m_kChar.kInventory.iPistol, kSoldier); kSoldier.m_kChar.kInventory.iPistol = 0; I = 0; J0x145: // End:0x261 [Loop If] if(I < kSoldier.m_kChar.kInventory.iNumLargeItems) { ReleaseItem(kSoldier.m_kChar.kInventory.arrLargeItems[i], kSoldier); TACTICAL().TInventoryLargeItemsSetItem(kSoldier.m_kChar.kInventory, I, 0); ++ I; // [Loop Continue] goto J0x145; } I = 0; J0x26C: // End:0x39B [Loop If] if(I < kSoldier.m_kChar.kInventory.iNumSmallItems) { iItem = kSoldier.m_kChar.kInventory.arrSmallItems[i]; ReleaseItem(iItem, kSoldier); TACTICAL().TInventorySmallItemsSetItem(kSoldier.m_kChar.kInventory, I, 0); ++ I; // [Loop Continue] goto J0x26C; } //return; } XGStorage.ReleaseSmallItems function ReleaseSmallItems(XGStrategySoldier kSoldier) { local int I; local XComGame.XGGameData.EItemType eItem; I = 0; J0x0B: // End:0x156 [Loop If] if(I < kSoldier.m_kChar.kInventory.iNumSmallItems) { eItem = byte(kSoldier.m_kChar.kInventory.arrSmallItems[i]); // End:0x148 if(!IsInfinite(eItem)) { ReleaseItem(eItem, kSoldier); TACTICAL().TInventorySmallItemsSetItem(kSoldier.m_kChar.kInventory, I, 0); } ++ I; // [Loop Continue] goto J0x0B; } //return; } I recall seeing one of those with a specific check for grenades (item 85, right), but man, it gets hard to trace someone else's code Btw, now I realized that my last comment was a complete stupidity, since armors and weapons are not consumible ... my bad... well, maybe knowing that it can be done we could give it some use now. Overheated weapons and critically hit armors rendered unusable (ie vanishing after mission)? Link to comment Share on other sites More sharing options...
Amineri Posted March 19, 2013 Share Posted March 19, 2013 @anUser I've just spent some time looking at and modifying the Release / Remove chunks of code. The most relevant chunk is In XGFacility_Barracks().UnloadSoldier(),if(!kSoldier.IsATank()){ if(kSoldier.m_bMIA || (IsOptionEnabled(14))){STORAGE().RemoveLoadout(kSoldier); }else{ STORAGE().ReleaseLoadout(kSoldier); }}else{ STORAGE().ReleaseLoadout(kSoldier);} The UnloadSoldier call refers to unloading from the Skyranger (Cargodropship). RemoveLoadout will destroy the equipment, while Release just removes the claim on the item so that it is available for other soldiers to equip. Tanks don't have to RemoveLoadout, since their items are (currently) automatically destroyed when the soldier is removed. ReleaseLoadout is also called when a soldier is wounded (to free his gear for nonwounded soldiers), or when a soldier is dismissed. If you modify ReleaseLoadout to destroy items, you'll also destroy them in those cases. I don't believe that ReleaseSmallItems() is ever called anywhere (it's an extra, dead function). This opens the possibility of completely rewriting it and using it for another purpose (if we can figure out how to call it), such as destroying certain types of items (grenades, medikits) and unclaiming others. This function could be called exclusively from the UnloadSoldier() function, so that designated items would automatically be destroyed after returning from a mission. Link to comment Share on other sites More sharing options...
anUser Posted March 19, 2013 Share Posted March 19, 2013 (edited) ... I wonder if when we finally locate it, there will be some way to tell wether the soldier has the item (grenade) equipped, and wheter that item has some charge left, if that's how the game processes grenades too... edit: sry, half post got erased before posting. I see... well, actually it sounds promising, as long as what I've said avobe isn't true, ... is there some problem calling functions from other classes or packages? Is that some sort of unexplored terrain? It'd def be great if we could use that (or some other function) to process loadout and make grenades and medikits gone Edited March 19, 2013 by anUser Link to comment Share on other sites More sharing options...
Amineri Posted March 19, 2013 Share Posted March 19, 2013 Here are a couple of places you might look, in XcomGame.upk XGUnit (technically the parent class XGUnitNativeBase) has the variables: var int m_iFragGrenades;var int m_iAlienGrenades;so each unit in the tactical game knows how many grenades it has left. These values can be get/set with the XGUnit functions:GetFragGrenades()SetFragGrenades(int iGrenades)and similar for alien grenades. I haven't seen where that information is passed back to the strategy game, though. Link to comment Share on other sites More sharing options...
Recommended Posts