psychoorc99 Posted May 29, 2020 Share Posted May 29, 2020 My goal is to be able to change certain companion stats using an MCM (things like how much damage they deal, how much damage they take, and how much weight they can carry). I did some googling and examined the Companion Suite perk in the GECK. It looks fairly straightforward to make those sorts of changes by modifying the magnitudes of effects under the perk itself (Companion Suite) and/or its corresponding Ability (PerkCompanionSuite), but that doesn't allow me to adjust the values on the fly with the MCM. However, I'd still like to make use of the Companion Suite perk since it addresses (or could probably be modified to address) all of the values I care about as well as conveniently applying itself to all companions. My question: is there any way besides the GECK to modify the Companion Suite perk/ability effect magnitudes? My knee-jerk reaction would be to script it, but I couldn't find any functions (including those from NVSE and JIP LN NVSE) that modify the actual perks besides adding or removing them. I'm open to other solutions besides scripting (although I would love to just see that my dumb ass missed the right function), but my main goal is for users of the mod to at most have to load a save or relaunch their game for the MCM settings to take effect as opposed to having to load up the GECK or FNVEdit in order to make the changes they want manually. A few workarounds that I've considered but would rather not use: -Run a GameMode script that checks the MCM settings and dynamically applies modifiers when it detects the appropriate circumstances. Considering the number of relevant events and the fact that these values already exist as part of the Companion Suite perk, this just seems like a pain in the ass and an unnecessary drain on resources. -Create multiple perks based around different settings for the relevant values and swap them out based on the MCM. This seems messy and disgusting as hell, it would require way too many perks to support even a small amount of customization as well as modifying a ton of references which I expect would lead to incompatibilities with other mods that modify companions. -Scrap the MCM options and offer multiple files with different presets for the relevant values. Slightly more elegant than the previous solution since I could just overwrite the perk without changing references but again would require more install options than I would like to bother with in order to support customization (although a FOMOD could maybe simplify things from the user end). The necessity of reinstalling also limits users' abilities to change their minds mid-playthrough which at best is an inconvenience and at worst game-breaking depending on the other features I end up including in the mod. -Forget the whole thing and post a specific guide on how to change the values yourself along with the mod. This is the coward's way out and the last thing I would want to do. If you got this far, thanks for reading this novel. Link to comment Share on other sites More sharing options...
dubiousintent Posted May 30, 2020 Share Posted May 30, 2020 Take a look at the post "Does anyone know of a mod that lowers companion damage ?". Sounds like you should take a look at Unofficial Patch Plus first. A collaberation or getting permission to make changes or a fork to it would advance your progress significantly. At the least it can show you one way to accomplish much of what you want. -Dubious- Link to comment Share on other sites More sharing options...
psychoorc99 Posted May 30, 2020 Author Share Posted May 30, 2020 Take a look at the post "Does anyone know of a mod that lowers companion damage ?". Sounds like you should take a look at Unofficial Patch Plus first. A collaberation or getting permission to make changes or a fork to it would advance your progress significantly. At the least it can show you one way to accomplish much of what you want. -Dubious-Thanks for pointing me to that. I checked UPP out in FNVEdit and the GECK and it looks like it makes changes to the Companion Suite perk by adding and modifying some perk entries. This is helpful because it suggests to me that the straightforward approach would produce the kinds of changes that I want (phew). However, I'm looking to modify the perk dynamically based on MCM variables instead of loading up the GECK every time I want to tweak companion abilities. Is there any method that would allow me to change the perk entries in such a way? I would be open to requiring a save load or a game relaunch for the settings to take effect if that's necessary, just not an external program. Link to comment Share on other sites More sharing options...
dubiousintent Posted May 31, 2020 Share Posted May 31, 2020 It is my impression that MCM is the rough equivalent of changing and reading an INI file from the "Pause" menu. (Not very "dynamic" in my opinion, but it does bypass exiting to the desktop.) If that impression is correct, then theoretically when it reads the changes for the MCM entries they need to become/"loaded into" variables that are global in scope that your Perk check script will then accept as the appropriate parameters for that entry point. Commonly you either use "AUX variables" or create your own at "Game Loaded" (see "TIP Best Practice Sharing Variables between Scripts" and "TIP Preload Scripts" under the "Scripting" section of the wiki "Getting started creating mods using GECK" article). Your likely problem is that "entry points" are "specific places in the code that are pre-defined". The best I think you are going to be able to do is use your global variable from MCM to run through an "If ... ElseIf ... Else ... EndIf" block to determine which actual predefined entry point to use, or use the variable as the appropriate parameter. (That conditional block might be in an "EventHandler" so it is only called as needed.) As you have to select the functions to call each "entry point" from a "drop down list", I would not expect to be able to use a variable directly as the "entry point" or function call itself; because a compiler usually cannot create an executable statement from an undefined "command" in a script outside of the runtime environment. (And a "variable" is just a "placeholder" until "runtime".) OTOH, you never know with the GECK until you try and I haven't tried this. -Dubious- Link to comment Share on other sites More sharing options...
psychoorc99 Posted May 31, 2020 Author Share Posted May 31, 2020 Thanks for responding. I think I've been unclear, the part that I don't understand is how to manipulate perks at all with scripts. The only commands related to perks that I know of are AddPerk, HasPerk, RemovePerk, GetPerkRank, and GetAltPerkRank, none of which really let me do what I want without creating new perks. I was hoping to find out that there is some sort of command like "SetPerkMagnitude [perk] [entry point] [magnitude]" but I didn't have any luck. Barring an easy solution like that, I was hoping there was a way to overwrite just the perk part of the mod by saving information to an ini and relaunching the game or something. As I side note, I thought of another workaround that might work well enough for my purposes if I can't find a solution for modifying the perk itself. I could check for the perk itself and apply actor effects that use the MCM for magnitudes and are removed and reapplied when settings are changed. It wouldn't be quite as smooth as modifying the perk itself but I think it would do the job. Link to comment Share on other sites More sharing options...
dubiousintent Posted June 1, 2020 Share Posted June 1, 2020 (edited) (Ah! It's always in the details.) I'm not an expert on Perks, but I don't think you can do what you want in such a straight forward manner. As best I can tell, Perks are essentially pre-coded functions. If it isn't an expected parameter of the Perk Event, then the closest you can come to what you want is apparently the JIP Function "GetPerkModifier". Otherwise it looks like you will have to "roll your own" Perk or otherwise find a workaround such as you suggested. Unfortunately with the departure of Mktavish we don't have many practicing scripters participating in the GECK sub-forum of late. (I'm fine with theoretical knowledge and research in addition to general scripting experience, but lacking in practical experience with the GECK itself.) -Dubious- Edited June 1, 2020 by dubiousintent Link to comment Share on other sites More sharing options...
psychoorc99 Posted June 1, 2020 Author Share Posted June 1, 2020 As it turns out, that function you linked prompted me to dig a little deeper through JIP LN NVSE's functions and I found a few that do pretty much exactly what I want (SetNthEffectTraitNumeric can set effect magnitudes for the PerkCompanionSuite Ability and SetNthPerkEntryValue1 can change parts of perk entries). I started testing things ingame and the modifications to damage given and taken by companions seem to work as intended (i.e. I can dynamically modify them at runtime). Thank you for the help finding these functions, they're going to be very useful for some of my other projects as well. However, I've run into some trouble modifying carry weight. Changing the effect magnitude with SetNthEffectTraitNumeric like I did for damage resistance doesn't seem to modify the ingame carry weight. Changing the value manually in the GECK only sort of works, an initial application of the perk will have the correct carry weight reduction but it won't change anything for actors who already have the perk. I really appreciate all the help so far, if anyone has some insights into why this might be happening with the carry weight I'd love to hear them. As I side note, I'm sorry to see that Mktavish has departed. He'll be missed. Link to comment Share on other sites More sharing options...
dubiousintent Posted June 1, 2020 Share Posted June 1, 2020 A quick search found "player.modav carryweight # (or setav to set it directly)." Did you try that, though "modav" is preferable if you don't want the new value to be permanent? If it does work, then you might have counted your "NthEffect" slot wrong. "Carryweight" is a derived attribute (Nr "13" from a base value of "0" in Actor Value Codes). See also "Movement Settings. Derived attributes can get tricksy. -Dubious- Link to comment Share on other sites More sharing options...
psychoorc99 Posted June 2, 2020 Author Share Posted June 2, 2020 You were right, I had the wrong index for the NthEffect. I tried it with zero instead of three and I can now modify carry weight as intended. Thank you so much for all your help, Dubious. I'm really pleased that we found a way to modify the perk itself instead of using a workaround. Link to comment Share on other sites More sharing options...
dubiousintent Posted June 2, 2020 Share Posted June 2, 2020 Glad to hear it. Getting an index wrong is a typical problem with arrays, so it's always worth double checking if you should be using a base of zero instead of one. -Dubious- Link to comment Share on other sites More sharing options...
Recommended Posts