RCSub Posted March 2, 2016 Share Posted March 2, 2016 (edited) Hello everyone I am currently getting the hang of the XCOM 2 SDK, and I am trying to make a mod, that increases the number of turns you have to collect timed loot. Any idea on how to do this? Best regardsRCSub Edited March 2, 2016 by RCSub Link to comment Share on other sites More sharing options...
davidlallen Posted March 2, 2016 Share Posted March 2, 2016 (edited) I guess this type of question is becoming a FAQ, so here is an attempt at a FAQ answer. a. Check the pinned resource thread in this forum for tips on how to use the SDK (you already did this, great). b. Check steam workshop and search for a few keywords. Can you find a mod which already does that? Either use it, or download it and look at the files it changes. c. Use your text editor (and the pinned resource thread for suggestions), search in the game ini files for variable names, or comments which may seem relevant for what you are trying to do. If you find some, try changing them to see if you understand the effect. d. If you are pretty sure nothing in the ini file covers this, then try the same searching experiment on the unrealscript files that are found in the SDK, OrigSrc directory. If you find some, be aware that changing uc files is harder, but still possible, and try making a mod for it. e. Can't find any mod, or any ini variable, or any uc script that seems relevant? Post on a thread here, with details of where you looked. Knowing that you have looked at the easy stuff, another modder may "take the challenge" to look for harder stuff. Edited March 3, 2016 by davidlallen Link to comment Share on other sites More sharing options...
traenol Posted March 3, 2016 Share Posted March 3, 2016 (edited) Let me add an additional one to that between D and E:-- Search the forums(here and steam) and see if someone else has already asked(and possibly received and answer on this). I say this because I know I already answered this exact question on the steam workshop discussion board.http://steamcommunity.com/workshop/discussions/-1/412447613579148110/?appid=268500 Edited March 3, 2016 by traenol Link to comment Share on other sites More sharing options...
Drakous79 Posted March 3, 2016 Share Posted March 3, 2016 (edited) Hey traenol. You've found the right place - XComGameState_LootDrop. But changing the constant const MaxLootExpirationTurns = 3; won't do the trick. If you scroll down and look into function CreateLootDrop, there is: LootDrop.LootExpirationTurnsRemaining = 3;Hopefully someone can make it configurable in an ini file. Edited March 3, 2016 by Drakous79 Link to comment Share on other sites More sharing options...
Amineri Posted March 3, 2016 Share Posted March 3, 2016 Hey traenol. You've found the right place - XComGameState_LootDrop. But changing the constant const MaxLootExpirationTurns = 3; won't do the trick. If you scroll down and look into function CreateLootDrop, there is: LootDrop.LootExpirationTurnsRemaining = 3;Hopefully someone can make it configurable in an ini file. I think this is only true if you are looking at the code with UE Explorer, which isn't looking at the .uc files as released in the SDK, but instead showing the decompiled code from the .u or .upk. Constants are replaced at compile-time, so it basically is going to look like a constant to UE Explorer. In my source file, the code reads : LootDrop.LootExpirationTurnsRemaining = MaxLootExpirationTurns; indicating that is it pulling from the constant. Of course, better for modding would be if it were pulling from a config variable. Link to comment Share on other sites More sharing options...
Drakous79 Posted March 3, 2016 Share Posted March 3, 2016 Thanks Amineri, you are right. Link to comment Share on other sites More sharing options...
traenol Posted March 3, 2016 Share Posted March 3, 2016 I think this is only true if you are looking at the code with UE Explorer, which isn't looking at the .uc files as released in the SDK, but instead showing the decompiled code from the .u or .upk. Constants are replaced at compile-time, so it basically is going to look like a constant to UE Explorer. In my source file, the code reads : LootDrop.LootExpirationTurnsRemaining = MaxLootExpirationTurns; indicating that is it pulling from the constant. Of course, better for modding would be if it were pulling from a config variable. Yea, I wasn't looking at the src uc file, was pulling from ue explorer, as it makes finding these things so much easier. Good to know that it does that though(I wasn't aware of that change during compile time, so thanks for that). Link to comment Share on other sites More sharing options...
Amineri Posted March 3, 2016 Share Posted March 3, 2016 Yea, I wasn't looking at the src uc file, was pulling from ue explorer, as it makes finding these things so much easier. Good to know that it does that though(I wasn't aware of that change during compile time, so thanks for that). The other big change is that macros gets swapped out, which generally results in much longer and less readable code. For example, in the original .uc file, CoolUnderPressure reads like this : `CREATE_X2ABILITY_TEMPLATE(Template, 'CoolUnderPressure'); However, when decompiled by UE Explorer, it cannot decompile to the macro, so it ends up looking like this : Template = new (none, string('CoolUnderPressure')) class'X2AbilityTemplate'; Template.SetTemplateName('CoolUnderPressure'); Something else to consider is that comments by Firaxis coders aren't visible in UE Explorer. So you miss out on gems like : // TODO JWATS: Generalize this the association between effects and custom anim sets. i.e., modders could // add a "drunk" effect and anim set. Please modders. You know what needs done. Link to comment Share on other sites More sharing options...
RCSub Posted March 3, 2016 Author Share Posted March 3, 2016 (edited) I also found LootDrop.LootExpirationTurnsRemaining = MaxLootExpirationTurns; So I decided to create a new class "XComGameState_Mod_LootDrop", then added [Engine.Engine] +ModClassOverrides=(BaseGameClass="X2Item_DefaultWeapons" , ModClass="X2Item_Mod_Weapon_Slots") +ModClassOverrides=(BaseGameClass="XComGameState_LootDrop", ModClass="XComGameState_Mod_LootDrop") to the XComGame.ini file. My class contains this: class XComGameState_Mod_LootDrop extends XComGameState_LootDrop config(AKBalanceMod); var config int LOOT_TIMER_BASE; var config int LOOT_TIMER_RANDOM_MIN; var config int LOOT_TIMER_RANDOM_MAX; static function CreateLootDrop(XComGameState NewGameState, const out array<XComGameState_Item> LootItems, Lootable LootSource, bool bExpireLoot) { local XComGameState_LootDrop LootDrop; local XComGameState_Item ItemState; local X2EventManager EventManager; local Object ThisObj; local int rnd; `log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); `log("LOOOOOOOT"); `log("LOOOOOOOT"); `log("LOOOOOOOT"); `log("LOOOOOOOT"); `log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); rnd = default.LOOT_TIMER_BASE; if( LootItems.Length > 0 ) { LootDrop = XComGameState_LootDrop(NewGameState.CreateStateObject(class'XComGameState_LootDrop')); NewGameState.AddStateObject(LootDrop); rnd = default.LOOT_TIMER_BASE + RandRange(default.LOOT_TIMER_RANDOM_MIN , default.LOOT_TIMER_RANDOM_MAX); `log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); `log("LOOOOOOOT"); `log("LOOOOOOOT"); `log("LOOOOOOOT"); `log("LOOOOOOOT"); `log("Random roll:" @ rnd); `log("LOOOOOOOT"); `log("LOOOOOOOT"); `log("LOOOOOOOT"); `log("LOOOOOOOT"); `log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); LootDrop.LootExpirationTurnsRemaining = rnd; ThisObj = LootDrop; EventManager = `XEVENTMGR; EventManager.RegisterForEvent(ThisObj, 'PlayerTurnBegun', OnPlayerTurnBegun, ELD_OnStateSubmitted); EventManager.RegisterForEvent(ThisObj, 'LootDropCreated', OnLootDropCreated, ELD_OnStateSubmitted); EventManager.TriggerEvent('LootDropCreated', ThisObj, ThisObj, NewGameState); if( !bExpireLoot ) { ++LootDrop.LootExpirationTurnsRemaining; } LootDrop.TileLocation = LootSource.GetLootLocation(); LootDrop.LastLootOwnerName = LootSource.GetLootingName(); LootDrop.LootSourceID = XComGameState_BaseObject(LootSource).ObjectID; foreach LootItems(ItemState) { LootDrop.LootableItemRefs.AddItem(ItemState.GetReference()); } if( `CHEATMGR == None || !`CHEATMGR.bDisableLootFountain ) { NewGameState.GetContext().PostBuildVisualizationFn.AddItem(LootDrop.VisualizeLootFountain); } } } But I never see the CreateLootDrop function being called when inspecting the console when debugging. Am I overriding the function correctly ? Any advice is welcome :smile: Edited March 3, 2016 by RCSub Link to comment Share on other sites More sharing options...
RCSub Posted March 5, 2016 Author Share Posted March 5, 2016 I also found where the function CreateLootDrop is used and tried overriding there. No luck either. Are there some functions that can't be overridden? or am I doing this the wrong way? Please help Link to comment Share on other sites More sharing options...
Recommended Posts