SteelRook Posted February 15, 2016 Author Share Posted February 15, 2016 Well, I'm about to snap my keyboard over my knee, so I'll check out Insanity a bit later :smile: That seems like a good lead, but I haven't the foggiest idea how those work. Edit:----ModOverrides just stopped working for me sometime over the weekend as well and I just gave up on using that approach entirely. ScreenListeners with hackish injection of code is the way to go until Firaxis does something to improve the reliability of ModOverrides, I think.The worst part about it is ONE of my two mod overrides works, but the other doesn't. I was able to override X2Ability_RangerAbilitySet without issue, but I can't so much as touch X2Item_DefaultWeapons. I don't even have a guess as to what might have happened, but that really puts the kibosh on my efforts. I guess I can just either hard-code the bonuses into the code or maybe put the bonuses in whatever the ranger-specific ini file is, but that's bad coding practice. I feel dirty for saying this, but so far I've had an easier tome modding Payday 2 (and god is THAT ever a mess) than I have XCOM 2 because at least with that I could do direct code injections. Here it seems to work whenever it wants to. I'll post my full code at some point when my head cools down. Hopefully, I've made a mistake somewhere in it. Link to comment Share on other sites More sharing options...
Kvalyr Posted February 15, 2016 Share Posted February 15, 2016 My ModOverrides just gradually stopped working one by one across different mods, so I actually suspect it's some weird caching issue or something to do with how junk gets left over in ini files, but even cleaning things out didn't fix modoverrides for me. The idea is nice in theory, but has proven unreliable for me in practice.Worse, if it is somehow a caching issue or some other configuration weirdness, we don't have any guarantee that mods that work for us in testing won't just fail to work for users as they move from one version of a mod to another.For anything involving modifying existing templates I don't think ModOverrides are the way to go. I think it's best to call a function from a ScreenListener that fetches existing templates and modifies them in-place. Link to comment Share on other sites More sharing options...
davidlallen Posted February 15, 2016 Share Posted February 15, 2016 So, I fixed my own problem with mod overrides stopping working. You're right that junk gets left over in ini files. Check out your local XcomEngine.ini, the one under My Games. In the engine.engine section, I found leftover ModClassOverride lines, which shouldn't have been there. In fact some of them were lines I had written earlier, to classes which no longer exist due to my changes. I removed these junk lines, and voila! The formerly non-working mod worked again. Link to comment Share on other sites More sharing options...
Kvalyr Posted February 15, 2016 Share Posted February 15, 2016 So, I fixed my own problem with mod overrides stopping working. You're right that junk gets left over in ini files. Check out your local XcomEngine.ini, the one under My Games. In the engine.engine section, I found leftover ModClassOverride lines, which shouldn't have been there. In fact some of them were lines I had written earlier, to classes which no longer exist due to my changes. I removed these junk lines, and voila! The formerly non-working mod worked again.I've still had trouble with formerly-working ModOverrides no longer working even after clearing out junk in the UserProfile ini files, sadly. No idea why. I'll look into it some more. Link to comment Share on other sites More sharing options...
SteelRook Posted February 15, 2016 Author Share Posted February 15, 2016 (edited) Well, I found a few extraneous entries in the ini files, but now I'm facing another problem - ModBuddy will randomly fail to open its own files. "Access Denined." And then it hangs on that FOREVER. I can't stop it and it never stops, just keeps timing out over and over again. I have to restart my PC. My suspicion is that might be responsible for the extraneous code in the ini files, as it's done that a lot for me. One time it kept telling me a class file was "already open in another application" and kept reloading it, refusing to save. And now it's doing it again. ModBuddy seems very very unstable, to be honest. *edit*Nope. Cleaning up the ini files did nothing at all. The lines: ModClassOverrides=(BaseGameClass="X2Item_DefaultWeapons", ModClass="X2Item_DefaultWeapons_BE") ModClassOverrides=(BaseGameClass="X2Ability_RangerAbilitySet", ModClass="X2Ability_RangerAbilitySet_BE") Are all that I can see extra, and I need both of those. The top one doesn't work, the bottom one worked last I tried it. This is getting really frustrating, if for no reason other than I can't rely on something which randomly stops working. I'm testing it out by changing the damage on the Beam Sword in the Sword_BM definition function. Previously, I could set it to 100 (for proof of concept) and it worked just fine - displayed correct damage, did correct damage. Now it does nothing, because apparently the override doesn't work. What's different between the two overrides, then? Can I debug the code line-by-line as the game is working, maybe? Most of my programming experience is in Java using Eclipse, and that had a very awesome debugger which could execute code step by step on demand. Don't see an option for that in ModBuddy. *edit*And another thing - why do these two lines always remain in the actual game's ini files when literally none of my other ini modifications persist? Is there any easy way to confirm when a mod override has worked? Edited February 15, 2016 by SteelRook Link to comment Share on other sites More sharing options...
Kvalyr Posted February 16, 2016 Share Posted February 16, 2016 (edited) Nope. Cleaning up the ini files did nothing at all. The lines: ModClassOverrides=(BaseGameClass="X2Item_DefaultWeapons", ModClass="X2Item_DefaultWeapons_BE") ModClassOverrides=(BaseGameClass="X2Ability_RangerAbilitySet", ModClass="X2Ability_RangerAbilitySet_BE") Are all that I can see extra, and I need both of those. The top one doesn't work, the bottom one worked last I tried it. This is getting really frustrating, if for no reason other than I can't rely on something which randomly stops working. I'm testing it out by changing the damage on the Beam Sword in the Sword_BM definition function. Previously, I could set it to 100 (for proof of concept) and it worked just fine - displayed correct damage, did correct damage. Now it does nothing, because apparently the override doesn't work. What's different between the two overrides, then? Can I debug the code line-by-line as the game is working, maybe? Most of my programming experience is in Java using Eclipse, and that had a very awesome debugger which could execute code step by step on demand. Don't see an option for that in ModBuddy. *edit*And another thing - why do these two lines always remain in the actual game's ini files when literally none of my other ini modifications persist? Is there any easy way to confirm when a mod override has worked?I don't have a good answer for you because this is my exact experience as well. :sad: That said, I think the X2Item_Default[X] classes are bad candidates for overrides to begin with - The only reason it appears to work for people is that by overriding those classes we extend their class, which makes the X2DataSet (and its related native functions) pick up the new class and call its CreateTemplates(), because it sees it as "another templates factory class". Simply extending the same class without using overrides should achieve the same goal for any use-case that I can think of. The methods are all static anyway. (So they can't be overriden, or they can; but the overrides won't get called) RE: Debugging:I've seen some people talk of getting the proper UnrealScript debugger working with step-into and step-through functionality, but I haven't looked into it properly myself. I know that the game looks for a debugger dll at some point (you can see it in the console output) but I don't know where to get that DLL. I'm sure someone else here knows.Thing is, a debugger stepping through UnrealScript code isn't going to help with figuring out problems with ModOverrides or CreateTemplates(). ModOverrides is handled entirely in the game's compiled C++ code, and you'd need a debug build of the game's core executable to be able to examine that. CreateTemplates() gets called from an event handler in X2DataSet.uc but the code that actually picks up those classes and fires that event is also a native function in C++. Edited February 16, 2016 by Kvalyr Link to comment Share on other sites More sharing options...
Deleted32045420User Posted February 16, 2016 Share Posted February 16, 2016 The easiest thing to do right now is to have a class that would check for the templates on game load (there is an event you can call on that from a screen listener) and change any old sword template to the new one. we really need someone from firaxis here to help us with this kind of things because it's all clouded in mystery now and firaxis is not helping the modding community to figure this out (and i cant call those new nation "mods",new character pools and ini file editing real modding) Link to comment Share on other sites More sharing options...
SteelRook Posted February 16, 2016 Author Share Posted February 16, 2016 That said, I think the X2Item_Default[X] classes are bad candidates for overrides to begin with - The only reason it appears to work for people is that by overriding those classes we extend their class, which makes the X2DataSet (and its related native functions) pick up the new class and call its CreateTemplates(), because it sees it as "another templates factory class". Simply extending the same class without using overrides should achieve the same goal for any use-case that I can think of. The methods are all static anyway. (So they can't be overriden, or they can; but the overrides won't get called)See, the thing is that I've been able to override the X2Ability_RangerAbilitySet class and its own static functions just fine, specifically the Blademaster() function, which is static and returns the X2AbilityTemplate object for the Blademaster ability. I overrode that function to build a X2Effect_BonusEffect_Blademaster object instead of an X2Effect_BonusDamage one, and it actually works. Well, for the time being, anyway. I can very dump the weapon template entirely and just build in a tech check on the weapon which calls for this ability, but the problem is I don't know when THAT override will stop working, as well. Which brings me to another question: The easiest thing to do right now is to have a class that would check for the templates on game load (there is an event you can call on that from a screen listener) and change any old sword template to the new one. we really need someone from firaxis here to help us with this kind of things because it's all clouded in mystery now and firaxis is not helping the modding community to figure this out (and i cant call those new nation "mods",new character pools and ini file editing real modding) Yeah, that would be great and was my initial idea. However, I haven't no clue as to how that would happen. I presume you're referring to the X2DownloadableContentInfo class which does appear to have methods for loading a saved game with this mod active and for starting a new game with it. I'm not sure how well that would work, though, as both of those functions are only run once per game. Anything I do to clean up after the default classes have created the default templates would need to be done on every game load, or at the very least on every game client start. I have no idea how that would happen, though. Do you have any suggestions to get me started? Like, which classes am I looking, which functions are we talking about? Do you have an example, maybe? I'm not married to overriding core game files. Indeed, I'd rather not, as that's very bad for mod compatibility. I just couldn't think of another option. Link to comment Share on other sites More sharing options...
Deleted32045420User Posted February 16, 2016 Share Posted February 16, 2016 No, i think that there is an event you can register to, i dont remember what is his name but if you search "TriggerEvent" in all the source code (Ctrl+Shft+F) you could probably find it Link to comment Share on other sites More sharing options...
SteelRook Posted February 16, 2016 Author Share Posted February 16, 2016 (edited) No, i think that there is an event you can register to, i dont remember what is his name but if you search "TriggerEvent" in all the source code (Ctrl+Shft+F) you could probably find it Well, searching for TriggerEvent in the source code reveals 445 hits. It's something that a LOT of classes are using, but I couldn't find any references to loading a saved game. Couldn't I actually made do with the X2DownloadableContentInfo file, though? If I pull all of the sword templates from the game's "state" (I presume), will this not stick around for the rest of the game? Or would the default templates override them again at run-time the next time the game is started? Is there any way I can trigger OnLoadedSavedGame() every time the game is loaded, rather than just once? *edit*Which is not to say I don't want to follow your advise, mind you. I'm just not entirely sure how event listeners work in UnrealScript. In Java, all I'd need to do is create a class which implements the EventListener interface with a specific implementation of the the one method of what action to do, then attach an instance of that class to whatever I want to listen to, via its own method. That way, threads will notify all subscribed listeners of all listenable events, then the listeners decide what to react to. What this would mean is I'd need to know how to create an event listener (what class I'd need to extend), which object fires the "game save file is being loaded" event and how to add a new listener of my own to it. And that's just the start, since I'd then need some way to pull a list of all of the game's weapon templates (and skill templates, since I also need to tweak Blademaster), find the specific ones (probably by name, through list iteration), remove that effect and add a new one in its place. Then hope against hope that the order of items in the list doesn't matter... I don't know how to do any of those things, especifally since the "TriggerEvent" class doesn't appear to be an XCOM-specific one, and thus isn't listed under "classes." Edited February 16, 2016 by SteelRook Link to comment Share on other sites More sharing options...
Recommended Posts