jgbaxter Posted May 17, 2016 Share Posted May 17, 2016 (edited) So I and LeaderEnemyBoss have been trying to make a small change to hopefully get me to grok how to do other things but I can't get this thing to build... any help would be great, I'm sure it is of course something simple but can't figure out what I'm missing. Here's the error; C:\Program Files (x86)\Steam\steamapps\common\XCOM 2 SDK\binaries\..\Development\Src\PartisanWar\Classes\A_UIAvengerHUD_Listener_UpdateGame.uc : Error, Bad class definition 'X2StrategyElement_DLC_Day60Techs(X2StrategyElement'/''/2165/2165 Warning, Can't find files matching C:\Program Files (x86)\Steam\steamapps\common\XCOM 2 SDK\binaries\Win64\..\..\Development\Src\DLC_2\Classes\*.uc And the code for what I'm trying to do (make Viper autopsy pre-req for ViperKing). I've looked at others code but that only points me in a direction where assassins kill me... ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Alien Hunters -- Adding mandatory autopsy from base alien instead of bypassing and allowing autopsy of ViperKing instead of Viper beforehand. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// [UnrealEd.EditorEngine] +EditPackages=DLC_2 [Engine.ScriptPackages] +NonNativePackages=DLC_2event OnInit(UIScreen Screen) { local X2StrategyElementTemplateManager TechTemplateMgr; local X2StrategyElement Autopsy; local X2TechTemplate TechTemplate; local XComGameState_Tech stateTech; local XComGameStateHistory History; local XComGameState stateGame; Autopsy = new class'X2StrategyElement'; TechTemplate = Autopsy.CreateAutopsyViperKingTemplate(); TechTemplateMgr = class'X2StrategyElementTemplateManager'.static.GetStrategyElementTemplateManager(); TechTemplateMgr.AddStrategyElementTemplate(TechTemplate); if (TechTemplate.Requirements.RequiredTechs.Find('AutopsyViper') == -1) { TechTemplate.Requirements.RequiredTechs.AddItem('AutopsyViper') }} defaultproperties { ScreenClass=UIAvengerHUD; } Edited May 17, 2016 by jgbaxter Link to comment Share on other sites More sharing options...
LeaderEnemyBoss Posted May 18, 2016 Share Posted May 18, 2016 (edited) To elaborate: How does one use classes of other mods? (as far as I understand the dlc basically is just another modpackage). OP just wants to add a prerequisite for the Ruler autopsies, usually i do such things with an AvengerHUD-Listener. Ruler techs are located in X2StrategyElement_DLC_Day60Techs. The error message is a bit misleading, because it was the result of a later try after I got desperate. Also @OP your code is pasted wrong :wink:. Here is a simple example how I would do it: event OnInit(UIScreen Screen) { local X2StrategyElementTemplateManager TechTemplateMgr; local X2StrategyElement_DLC_Day60Techs Autopsy; local X2TechTemplate TechTemplate; local XComGameStateHistory History; Autopsy = new class'X2StrategyElement_DLC_Day60Techs'; TechTemplate = RKAutopsy.CreateAutopsyRiftkeeperTemplate(); TechTemplateMgr = class'X2StrategyElementTemplateManager'.static.GetStrategyElementTemplateManager(); TechTemplateMgr.AddStrategyElementTemplate(TechTemplate); //modify template from here } [...] Sadly modbuddy doesnt "find" X2StrategyElement_DLC_Day60Techs since its not part of the project. My current idea would be to just add the class to the project in the corresponding DLC_2 folder. The class should probably get removed before publishing the mod, XCom should be able to correctly find the dlc class? Edited May 18, 2016 by LeaderEnemyBoss Link to comment Share on other sites More sharing options...
jgbaxter Posted May 18, 2016 Author Share Posted May 18, 2016 (edited) Doah, it's parsed right in modbuddy just messed up above. :laugh: I remember reading something Josh posted on reddit, and that he wasn't sure if there was a way to even get the DLC to load in any particular order. I was kind of hoping that the DLC loads before mods and therefore the default XCom files would have the new data from the DLC which could then be altered without having to worry about the DLC files. Anyway I need some booze because this is silly complex for a simple thing, lord knows an AHA moment will happen when someone comments on how to fix this, or maybe I'll drink more beer, not sure, maybe both. :huh: Edited May 18, 2016 by jgbaxter Link to comment Share on other sites More sharing options...
AuroraDelta Posted May 18, 2016 Share Posted May 18, 2016 It seems to be that you cannot reference it in the build of your project, however if the project is somehow built it will find it (as it will be in the game, whereas not the SDK so much). So what I can say might work is to cheat it into thinking the class is there even if it isn't just to get it to build (although don't include the fakes in the build), because when it references them in-game they will actually be present in the system for it to reference, unlike when building with the SDK. For instance, if you try to have a weapon use the Archon King's Staff Damage as your own weapons damage, the SDK will have no idea what to do. To cheat that you have to modify (X2_DefaultWeapons?) Class and the (XcomGamedata? [this is all off the top of my head sorry]) to include that variable, but don't stick that in your mod folder. When the mod builds it will know where to find it, and because the DLC is in the same place afterwards that should be able to reference it in-game despite you basically having cheated it with something that wasn't there when it was built. That's my theory anyway. Link to comment Share on other sites More sharing options...
fxsjosh Posted May 18, 2016 Share Posted May 18, 2016 I'm not sure exactly what you're trying to do but from the example code provided trying to pull stuff out of scripts directly inside of a UIScreen's OnInit, that's the old way of doing things. You want to modify or reference DLC templates? You can hook into OnPostTemplatesCreated - this call only happens after all templates have been created, including ones from mods/DLC (it is after CreateTemplates gets called for every valid class). Inside of OnPostTemplatesCreated, you could look up the DLC templates like anything else (e.g. use FindDataTemplate or an equivalent function on the relevant template manager class). Link to comment Share on other sites More sharing options...
jgbaxter Posted May 18, 2016 Author Share Posted May 18, 2016 Hi Josh :) We're currently trying to make the Viper Autopsy a requirement for the Viper King Autopsy. OnPostTemplatesCreated is going to be very useful, we haven't looked into it enough obviously so we'll try something along those lines. thanks! =-= Aurora thanks for giving it some thought. :) Link to comment Share on other sites More sharing options...
LeaderEnemyBoss Posted May 18, 2016 Share Posted May 18, 2016 (edited) Thanks for the hints josh, sometimes I am a bit too "rooted in my old ways" ;p. With your help and a peek at the dlc code i cobbled together a small example that adds techrequirements to any tech or item the modauthor chooses. This also works with stuff from other mods/dlcs, since invalid entries just get ignored (so compatibility with non-dlc builds is ensured). class X2DownloadableContentInfo_MyXCOM2Mod extends X2DownloadableContentInfo; static event OnPostTemplatesCreated() { //first entry is the autopsy you want to add a requirement to, second entry is the techrequirement to add //example: adds the viper autopsy as a requirement for the sectoid autopsy AddAutopsyRequirements('AutopsySectoid', 'AutopsyViper'); //if you enter stuff that doesnt exists (i.e. ruler autopsies in builds that dont have the dlc) nothing happens, so compatibility should be assured AddAutopsyRequirements('blablabla', 'blubblubblub'); } static function AddAutopsyRequirements(Name BaseTemplateName, Name RequiredTechName) { local X2StrategyElementTemplateManager StrategyTemplateMgr; local X2TechTemplate TechTemplate; local array<X2DataTemplate> DataTemplates; local int i; StrategyTemplateMgr = class'X2StrategyElementTemplateManager'.static.GetStrategyElementTemplateManager(); StrategyTemplateMgr.FindDataTemplateAllDifficulties(BaseTemplateName, DataTemplates); for (i = 0; i < DataTemplates.Length; ++i) { TechTemplate = X2TechTemplate(DataTemplates[i]); if (TechTemplate != none) { TechTemplate.Requirements.RequiredTechs.AddItem(RequiredTechName); } } } Edited May 18, 2016 by LeaderEnemyBoss Link to comment Share on other sites More sharing options...
Recommended Posts