Deleted32045420User Posted May 26, 2016 Share Posted May 26, 2016 (edited) If you are not even showing us the important bits (ini , lines that have errors in them, important code) how can we know what you are doing and what is going wrong? what's AddAbilities( , ) doing? why are you doing AddAbilities('blablabla', 'blubblubblub'); it will execute and probably going to break something when it dosnt find that ability or weapon.I know you love XCom and want to make mods for it but just jumping in without knowing at least some coding and learning on the fly isnt going to get you far in UnrealScript before giving up (and i'm saying because i've seen this before), just a friendly advice- learn python or Java or C# and then come back to XCom2 coding- would save you a whole lot of frustration and time. Edited May 26, 2016 by Guest Link to comment Share on other sites More sharing options...
Kregano Posted May 27, 2016 Share Posted May 27, 2016 If you are not even showing us the important bits (ini , lines that have errors in them, important code) how can we know what you are doing and what is going wrong?Ask and ye shall receive a ton of code to parse. Listener: class SuppressionWeaponsListener extends UIScreenListener config(SuppressionWeapons); var config bool FirstRun; var UIPanel TestPanel;var UIText TextStuff;var UIText TextStuff2;var UIButton DismissButton; event OnInit(UIScreen Screen){ if(default.FirstRun == false) { TestPanel = Screen.Spawn(class'UIPanel', Screen); TestPanel.InitPanel('BGBoxSimple', class'UIUtilities_Controls'.const.MC_X2BackgroundSimple); TestPanel.SetPosition(100, 200); TestPanel.SetSize(300, 200); TextStuff = Screen.Spawn(class'UIText', Screen); TextStuff.InitText(, "Test!"); TextStuff.SetSize(280, 180); TextStuff.SetPosition(185, 210); TextStuff.OriginTopCenter(); TextStuff.SetHTMLText( class'UIUtilities_Text'.static.StyleText("WARNING", eUITextStyle_Title, eUIState_Bad )); TextStuff2 = Screen.Spawn(class'UIText', Screen); TextStuff2.InitText(, "Test!"); TextStuff2.SetSize(280, 160); TextStuff2.SetPosition(110, 260); TextStuff2.SetHTMLText( class'UIUtilities_Text'.static.StyleText("The Suppression Weapons Pack's generated a default config file. You'll need to restart XCOM 2. You'll only have to do this once.", eUITextStyle_Tooltip_Body, eUIState_Warning )); DismissButton = Screen.Spawn(class'UIButton', Screen); DismissButton.InitButton('TestButton', "OK", DismissButtonHandler, ); DismissButton.SetSize(280, 30); DismissButton.SetPosition(175, 340); DismissButton.SetResizeToText(true); DismissButton.OriginTopCenter(); `log("First Run!"); }} simulated function DismissButtonHandler(UIButton Button){ FirstRun = true; self.SaveConfig(); class 'SuppressionWeaponsSettings'.static.LoadSavedSettingsInitial(); TestPanel.Remove(); TextStuff.Remove(); TextStuff2.Remove(); DismissButton.Remove();} defaultproperties{ ScreenClass = class'UIFinalShell';} Defaults.uc class SuppressionWeaponsDefaults extends Object config(SuppressionWeaponsDefaults); var config int VERSION; // my settings now// sets if that tier of weaponry is enabled.var config bool RIFLE_ENABLED;var config bool PISTOL_ENABLED;var config bool CANNON_ENABLED;var config bool CENTRAL_ENABLED; // LWS SMGvar config bool LWS_SMG_ENABLED; //Total Advent Weaponryvar config bool TOTALADVENT_RIFLE_ENABLED;var config bool TOTALADVENT_SMG_ENABLED;var config bool TOTALADVENT_PISTOL_ENABLED;var config bool TOTALADVENT_CANNON_ENABLED; //Halo Reach weaponsvar config bool REACH_AR_ENABLED;var config bool REACH_SMG_ENABLED;var config bool REACH_PISTOL_ENABLED;var config bool REACH_SAW_ENABLED; Defaults.ini [suppressionWeapons.SuppressionWeaponsDefaults] VERSION = 1 ;base game gunsRIFLE_ENABLED = truePISTOL_ENABLED = trueCANNON_ENABLED = trueCENTRAL_ENABLED = false ;LWS SMGLWS_SMG_ENABLED = false ;Total Advent WeaponryTOTALADVENT_RIFLE_ENABLED = falseTOTALADVENT_SMG_ENABLED = falseTOTALADVENT_PISTOL_ENABLED = falseTOTALADVENT_CANNON_ENABLED = false ;Halo Reach weaponsREACH_AR_ENABLED = falseREACH_SMG_ENABLED = falseREACH_PISTOL_ENABLED = falseREACH_SAW_ENABLED = false Settings class SuppressionWeaponsSettings extends UIScreenListener config(SuppressionWeapons); `include(SuppressionWeapons/Src/ModConfigMenuAPI/MCM_API_Includes.uci)`include(SuppressionWeapons/Src/ModConfigMenuAPI/MCM_API_CfgHelpers.uci) var config int CONFIG_VERSION; // my settings now// sets if that tier of weaponry is enabled.var config bool RIFLE_ENABLED;var config bool PISTOL_ENABLED;var config bool CANNON_ENABLED;var config bool CENTRAL_ENABLED; // LWS SMGvar config bool LWS_SMG_ENABLED; //Total Advent Weaponryvar config bool TOTALADVENT_RIFLE_ENABLED;var config bool TOTALADVENT_SMG_ENABLED;var config bool TOTALADVENT_PISTOL_ENABLED;var config bool TOTALADVENT_CANNON_ENABLED; //Halo Reach weaponsvar config bool REACH_AR_ENABLED;var config bool REACH_SMG_ENABLED;var config bool REACH_PISTOL_ENABLED;var config bool REACH_SAW_ENABLED; //var config bool RIFLE_ENABLED;//var config bool PISTOL_ENABLED;//var config bool CANNON_ENABLED; //var config bool RIFLE_ENABLED;//var config bool PISTOL_ENABLED;//var config bool CANNON_ENABLED; event OnInit(UIScreen Screen){ `MCM_API_Register(Screen, ClientModCallback);} simulated function ClientModCallback(MCM_API_Instance ConfigAPI, int GameMode){ local MCM_API_SettingsPage Page; local MCM_API_SettingsGroup Group; LoadSavedSettings(); if (GameMode == eGameMode_MainMenu) { Page = ConfigAPI.NewSettingsPage("Suppression Weapons Pack"); Page.SetPageTitle("Suppression Weapons Pack Settings"); Page.SetSaveHandler(SaveButtonClicked); Group = Page.AddGroup('Group1', "Base Game Guns"); Group.AddCheckbox('checkbox', "Enable Suppression Rifles", "Confers Suppression to base game rifles.", RIFLE_ENABLED, RifleEnabledCheckboxSaveHandler); Group.AddCheckbox('checkbox', "Enable Suppression Pistols", "Confers Suppression to Tier 2-3 base game pistols.", PISTOL_ENABLED, PistolEnabledCheckboxSaveHandler); Group.AddCheckbox('checkbox', "Enable Suppression Cannons", "Confers Suppression to base game cannons.", CANNON_ENABLED, CannonEnabledCheckboxSaveHandler); Group.AddCheckbox('checkbox', "Infinite Multipurpose Combat Rifles", "Make Central's rifle available to Rangers/Specialists", CENTRAL_ENABLED, CentralEnabledCheckboxSaveHandler); Group = Page.AddGroup('Group2', "LWS Mod Guns"); Group.AddCheckbox('checkbox', "Enable Suppression SMGs", "Confers Suppression LWS SMGs.", LWS_SMG_ENABLED, LWSSMGEnabledCheckboxSaveHandler); Group = Page.AddGroup('Group3', "Total ADVENT Weaponry"); Group.AddCheckbox('checkbox', "Enable Suppression TA Rifles", "Confers Suppression to Total ADVENT rifles.", TOTALADVENT_RIFLE_ENABLED, TARifleEnabledCheckboxSaveHandler); Group.AddCheckbox('checkbox', "Enable Suppression TA SMGs", "Confers Suppression to Total ADVENT SMGs.", TOTALADVENT_SMG_ENABLED, TASMGEnabledCheckboxSaveHandler); Group.AddCheckbox('checkbox', "Enable Suppression TA Pistols", "Confers Suppression to Total ADVENT pistols.", TOTALADVENT_PISTOL_ENABLED, TAPistolEnabledCheckboxSaveHandler); Group.AddCheckbox('checkbox', "Enable Suppression TA Cannons", "Confers Suppression to Total ADVENT cannons.", TOTALADVENT_CANNON_ENABLED, TACannonEnabledCheckboxSaveHandler); Group = Page.AddGroup('Group3', "Halo Reach Weaponry"); Group.AddCheckbox('checkbox', "Enable Suppression MA37 Rifles", "Confers Suppression to MA37 rifles.", REACH_AR_ENABLED, ReachAREnabledCheckboxSaveHandler); Group.AddCheckbox('checkbox', "Enable Suppression M7 SMGs", "Confers Suppression to M7 SMGs.", REACH_SMG_ENABLED, ReachSMGEnabledCheckboxSaveHandler); Group.AddCheckbox('checkbox', "Enable Suppression TA Pistols", "Confers Suppression to M6 Magnum pistols.", REACH_PISTOL_ENABLED, ReachPistolEnabledCheckboxSaveHandler); Group.AddCheckbox('checkbox', "Enable Suppression Reach SAW", "Confers Suppression to Reach SAWs.", REACH_SAW_ENABLED, ReachSAWEnabledCheckboxSaveHandler); } Page.ShowSettings(); } `MCM_CH_VersionChecker(class'SuppressionWeaponsDefaults'.default.VERSION,CONFIG_VERSION) static function LoadSavedSettingsInitial(){ `log("Saving initial settings... I think"); //base game guns default.CONFIG_VERSION = class'SuppressionWeaponsDefaults'.default.VERSION; default.RIFLE_ENABLED = class'SuppressionWeaponsDefaults'.default.RIFLE_ENABLED; default.PISTOL_ENABLED = class'SuppressionWeaponsDefaults'.default.PISTOL_ENABLED; default.CANNON_ENABLED= class'SuppressionWeaponsDefaults'.default.CANNON_ENABLED; default.CENTRAL_ENABLED= class'SuppressionWeaponsDefaults'.default.CENTRAL_ENABLED; //LWS SMGs default.LWS_SMG_ENABLED = class'SuppressionWeaponsDefaults'.default.LWS_SMG_ENABLED; //Total ADVENT weaponry default.TOTALADVENT_RIFLE_ENABLED = class'SuppressionWeaponsDefaults'.default.TOTALADVENT_RIFLE_ENABLED; default.TOTALADVENT_SMG_ENABLED = class'SuppressionWeaponsDefaults'.default.TOTALADVENT_SMG_ENABLED; default.TOTALADVENT_PISTOL_ENABLED = class'SuppressionWeaponsDefaults'.default.TOTALADVENT_PISTOL_ENABLED; default.TOTALADVENT_CANNON_ENABLED = class'SuppressionWeaponsDefaults'.default.TOTALADVENT_CANNON_ENABLED; //Halo Reach guns default.REACH_AR_ENABLED = class'SuppressionWeaponsDefaults'.default.REACH_AR_ENABLED; default.REACH_SMG_ENABLED = class'SuppressionWeaponsDefaults'.default.REACH_SMG_ENABLED; default.REACH_PISTOL_ENABLED = class'SuppressionWeaponsDefaults'.default.REACH_PISTOL_ENABLED; default.REACH_SAW_ENABLED = class'SuppressionWeaponsDefaults'.default.REACH_SAW_ENABLED; } simulated function LoadSavedSettings(){//BASE GAME RIFLE_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.RIFLE_ENABLED,RIFLE_ENABLED); PISTOL_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.PISTOL_ENABLED,PISTOL_ENABLED); CANNON_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.CANNON_ENABLED,CANNON_ENABLED); CENTRAL_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.CENTRAL_ENABLED,CENTRAL_ENABLED); //LWS SMGs LWS_SMG_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.LWS_SMG_ENABLED,LWS_SMG_ENABLED); //Total Advent Weaponry TOTALADVENT_RIFLE_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.TOTALADVENT_RIFLE_ENABLED,TOTALADVENT_RIFLE_ENABLED); TOTALADVENT_SMG_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.TOTALADVENT_SMG_ENABLED,TOTALADVENT_SMG_ENABLED); TOTALADVENT_PISTOL_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.TOTALADVENT_PISTOL_ENABLED,TOTALADVENT_PISTOL_ENABLED); TOTALADVENT_CANNON_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.TOTALADVENT_CANNON_ENABLED,TOTALADVENT_CANNON_ENABLED); //Halo Reach weapons REACH_AR_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.REACH_AR_ENABLED,REACH_AR_ENABLED); REACH_SMG_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.REACH_SMG_ENABLED,REACH_SMG_ENABLED); REACH_PISTOL_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.REACH_PISTOL_ENABLED,REACH_PISTOL_ENABLED); REACH_SAW_ENABLED = `MCM_CH_GetValue(class'SuppressionWeaponsDefaults'.default.REACH_SAW_ENABLED,REACH_SAW_ENABLED);} //Base game guns`MCM_API_BasicCheckboxSaveHandler(RifleEnabledCheckboxSaveHandler, RIFLE_ENABLED)`MCM_API_BasicCheckboxSaveHandler(PistolEnabledCheckboxSaveHandler, PISTOL_ENABLED)`MCM_API_BasicCheckboxSaveHandler(CannonEnabledCheckboxSaveHandler, CANNON_ENABLED)`MCM_API_BasicCheckboxSaveHandler(CentralEnabledCheckboxSaveHandler, CENTRAL_ENABLED) //LWS SMGs`MCM_API_BasicCheckboxSaveHandler(LWSSMGEnabledCheckboxSaveHandler, LWS_SMG_ENABLED) //Total ADVENT weaponry`MCM_API_BasicCheckboxSaveHandler(TARifleEnabledCheckboxSaveHandler, TOTALADVENT_RIFLE_ENABLED)`MCM_API_BasicCheckboxSaveHandler(TASMGEnabledCheckboxSaveHandler, TOTALADVENT_SMG_ENABLED)`MCM_API_BasicCheckboxSaveHandler(TAPistolEnabledCheckboxSaveHandler, TOTALADVENT_PISTOL_ENABLED)`MCM_API_BasicCheckboxSaveHandler(TACannonEnabledCheckboxSaveHandler, TOTALADVENT_CANNON_ENABLED) //Halo Reach guns`MCM_API_BasicCheckboxSaveHandler(ReachAREnabledCheckboxSaveHandler, REACH_AR_ENABLED)`MCM_API_BasicCheckboxSaveHandler(ReachSMGEnabledCheckboxSaveHandler, REACH_SMG_ENABLED)`MCM_API_BasicCheckboxSaveHandler(ReachPistolEnabledCheckboxSaveHandler, REACH_PISTOL_ENABLED)`MCM_API_BasicCheckboxSaveHandler(ReachSAWEnabledCheckboxSaveHandler, REACH_SAW_ENABLED) simulated function SaveButtonClicked(MCM_API_SettingsPage Page){ self.CONFIG_VERSION = `MCM_CH_GetCompositeVersion(); self.SaveConfig();} defaultproperties{ ScreenClass = none;} what's AddAbilities( , )doing?All that does is list the weapons and abilities so that a separate static function can find the weapon templates and then add the ability to that template. why are you doingAddAbilities('blablabla', 'blubblubblub');it will execute and probably going to break something when it dosnt find that ability or weapon.Actually, that's there to prevent an ability/thing that isn't found breaking the function. I know you love XCom and want to make mods for it but just jumping in without knowing at least some coding and learning on the fly isnt going to get you far in UnrealScript before giving up (and i'm saying because i've seen this before), just a friendly advice- learn python or Java or C# and then come back to XCom2 coding- would save you a whole lot of frustration and time.I hear you. Link to comment Share on other sites More sharing options...
abeclancy Posted May 27, 2016 Share Posted May 27, 2016 If you're still having issues with "VERSION" and the compiler complaining about case, try just changing the variable name to something else. Unrealscript does some pretty weird and opaque things regarding naming collisions on variables that it auto-creates, such as "ReturnValue". Try "CONFIG_VERSION" or "SUPPRESSION_CONFIG_VERSION" or something and see if that gets rid of that error. Link to comment Share on other sites More sharing options...
Kregano Posted May 27, 2016 Share Posted May 27, 2016 If you're still having issues with "VERSION" and the compiler complaining about case, try just changing the variable name to something else. Unrealscript does some pretty weird and opaque things regarding naming collisions on variables that it auto-creates, such as "ReturnValue". Try "CONFIG_VERSION" or "SUPPRESSION_CONFIG_VERSION" or something and see if that gets rid of that error.Did it and got rid of the warning, but that didn't seem to have any effect on anything else. Link to comment Share on other sites More sharing options...
bunnytrain Posted June 1, 2016 Author Share Posted June 1, 2016 (edited) Hey Kregano! First of all, thanks for trying to use MCM! I took a pass through the code that you showed, and it looks like you're trying to implement a system where default settings get pushed into an INI file you want to save into the My Games folder on an initial run? This is a generally brittle approach with a bunch of pitfalls, so I can either try to help you get that working, or I can suggest my own preferred approach that generally lets you avoid needing a "first run". Tradeoff is a bit more complexity in your template loader. I only read your code once, so I might be missing something, but what is the purpose of "SuppressionWeaponsListener "? It seems like it's supposed to execute exactly once, the first time the mod runs, right? In that case, it might be missing a key line in SuppressionWeaponsSettings.LoadSavedSettingsInitial() where you need to call "StaticSaveConfig()" to make sure that those default settings are written into the INI file during your first run. Edited June 1, 2016 by bunnytrain Link to comment Share on other sites More sharing options...
Kregano Posted June 2, 2016 Share Posted June 2, 2016 Hey Kregano! First of all, thanks for trying to use MCM! I took a pass through the code that you showed, and it looks like you're trying to implement a system where default settings get pushed into an INI file you want to save into the My Games folder on an initial run? This is a generally brittle approach with a bunch of pitfalls, so I can either try to help you get that working, or I can suggest my own preferred approach that generally lets you avoid needing a "first run". Tradeoff is a bit more complexity in your template loader. I only read your code once, so I might be missing something, but what is the purpose of "SuppressionWeaponsListener "? It seems like it's supposed to execute exactly once, the first time the mod runs, right? In that case, it might be missing a key line in SuppressionWeaponsSettings.LoadSavedSettingsInitial() where you need to call "StaticSaveConfig()" to make sure that those default settings are written into the INI file during your first run.I decided to do it this way A) to draw the player's attention to a big gameplay change, and B) break things up into a more manageable setup for long term updating. SuppressionWeaponsSettings was indeed missing StaticSaveConfig, but adding it didn't fix the problem. So I did a quick test by removing the MCM hook to toggle whether or not SMGs got Suppression, loaded up a campaign save with the LWS SMGs, and they got Suppression. So I'm thinking the function that's supposed to be handling adding Suppression to the guns is picking up that stuff for some reason and just breaks. Also, I noticed this bug: MCM warnings about setting a default .ini if MCM isn't installed overlap each other, making them totally unreadable. Link to comment Share on other sites More sharing options...
bunnytrain Posted June 2, 2016 Author Share Posted June 2, 2016 I decided to do it this way A) to draw the player's attention to a big gameplay change, and B) break things up into a more manageable setup for long term updating. SuppressionWeaponsSettings was indeed missing StaticSaveConfig, but adding it didn't fix the problem. So I did a quick test by removing the MCM hook to toggle whether or not SMGs got Suppression, loaded up a campaign save with the LWS SMGs, and they got Suppression. So I'm thinking the function that's supposed to be handling adding Suppression to the guns is picking up that stuff for some reason and just breaks. Also, I noticed this bug: MCM warnings about setting a default .ini if MCM isn't installed overlap each other, making them totally unreadable. Which warnings about setting a default .ini? I wasn't aware of this bug so I'm not quite sure what you mean by it. Separately, which hook do you mean for the function that's supposed to be adding Suppression to the guns? Do you mean code that runs to register templates? Link to comment Share on other sites More sharing options...
Kregano Posted June 3, 2016 Share Posted June 3, 2016 Separately, which hook do you mean for the function that's supposed to be adding Suppression to the guns? Do you mean code that runs to register templates?This bit of code that controls whether or not the changes go through if the setting is set to true: if (class'SuppressionWeaponsSettings'.default.RIFLE_ENABLED == true) { `log("Base game rifles have Suppression!"); AddAbilities('AssaultRifle_CV', 'Suppression'); AddAbilities('AssaultRifle_MG', 'Suppression'); AddAbilities('AssaultRifle_BM', 'Suppression'); AddAbilities('AssaultRifle_Central', 'Suppression'); } It seems that the "if" statement gets picked up by the actual function because it's included in the brackets containing all the "AddAbilitiles" entries and that causes the problems. I can't be sure, since there are no errors generated by ModBuddy, but that's my best guess. Which warnings about setting a default .ini? I wasn't aware of this bug so I'm not quite sure what you mean by it.This one, from the Listener: TextStuff2.SetHTMLText( class'UIUtilities_Text'.static.StyleText("The Suppression Weapons Pack's generated a default config file. You'll need to restart XCOM 2. You'll only have to do this once.", eUITextStyle_Tooltip_Body, eUIState_Warning )); Link to comment Share on other sites More sharing options...
bunnytrain Posted June 6, 2016 Author Share Posted June 6, 2016 (edited) Sorry for the delayed response, I had to step away from modding for a few days to deal with some other things. I'm still not sure what you mean by the warning messages, but if those are warning messages that your code pops up (because MCM doesn't pop up any warning messages itself) then it sounds like something where your code just needs to make sure that you don't show both messages. It seems that the "if" statement gets picked up by the actual function because it's included in the brackets containing all the "AddAbilitiles" entries and that causes the problems. I can't be sure, since there are no errors generated by ModBuddy, but that's my best guess. So you're saying that your code works fine if you don't include the if statement and just type in those four "AddAbilities" lines literally. But when you do use the if statement, those "AddAbilities" lines never seem to be called? That would point to there being something wrong with your if condition, and the most likely reason your if condition is failing is that "class'SuppressionWeaponsSettings'.default.RIFLE_ENABLED" is always evaluating to "false". The most likely reason that would happen is that for whatever reason the ini file isn't actually getting generated correctly or isn't saving the values correctly. Maybe insert this line to check whether you're ever actually entering the interior of the if statement: if (class'SuppressionWeaponsSettings'.default.RIFLE_ENABLED == true) { `log("Base game rifles have Suppression!"); AddAbilities('AssaultRifle_CV', 'Suppression'); AddAbilities('AssaultRifle_MG', 'Suppression'); AddAbilities('AssaultRifle_BM', 'Suppression'); AddAbilities('AssaultRifle_Central', 'Suppression'); } else { `log("Suppression on base game rifles disabled."); } If it's logging that second message all of the time, I would try checking the INI file for SuppressionWeaponsSettings to see if the RIFLE_ENABLED setting is actually set to true right after you generate that INI file for the first time. Edited June 6, 2016 by bunnytrain Link to comment Share on other sites More sharing options...
Kregano Posted June 7, 2016 Share Posted June 7, 2016 Here's what I've discovered: as far as I can tell, running the mod through debug doesn't create an XComSuppressionWeapons.ini to pull values from, which is why that doesn't work. The one time I tried to use my mod on the regular game did generate an .ini, but everything was set to false. The config version is set to 0, which makes me think that renaming Version in the default files to clear that error broke the ability to pull the default values somehow. Link to comment Share on other sites More sharing options...
Recommended Posts