steelfeathers Posted August 4, 2015 Share Posted August 4, 2015 So, this puzzle has been bugging me for a while. Say I have a custom stat in my mod, like dibella statues collected, that I keep track of with a global variable. I want to find a way to use that global variable value to change the magnitude of a perk effect or a spell. But the only way I've found to do this so far is to hard code in "variable =1 > magntidue = 10" "variable = 2 > magnitude = 20" and so on for every possible value of the global variable. As you can imagine, this is unworkable if you don't know the upper limit of what the variable can be... And frankly it's an enormous pain to define the perk or spell magnitude for every possible variable value. Has anyone found a better way to approach this? Link to comment Share on other sites More sharing options...
FrankFamily Posted August 4, 2015 Share Posted August 4, 2015 The only way i know of making it different than that is making whatever effect the perk is doing though a script, that way you can multiply the global or whatever.But still making an effect for each value is the most straightforward method, and you can cap ths magnitude if for example the global gets so big that the effect is overpowered, so beyond certain value of the global magnitude wont increase. Link to comment Share on other sites More sharing options...
Mattiewagg Posted August 4, 2015 Share Posted August 4, 2015 If you're okay with using SKSE and some maintenance: http://www.creationkit.com/SetNthEffectMagnitude_-_Spell Use this and set values depending on global. So like... SetNthEffectMagnitude to set a magnitude on an effect in a spell to the value of the global, or 40 more than the global, etc. Much more flexible. Do remember it requires maintenance though (every load game, re set magnitude to whatever it was). See OnPlayerLoadGame page on the CK Wiki for info on how. Link to comment Share on other sites More sharing options...
scrivener07 Posted August 4, 2015 Share Posted August 4, 2015 And I take a stab in the dark.. ; http://www.creationkit.com/SetNthEffectMagnitude_-_Spell GlobalVariable Property AmountOfStatues Auto Spell Property MySpell Auto Event OnInit() If(MySpell != none) ; spell is not null int amount = AmountOfStatues.GetValueInt() ; get the value of the global If(amount <= 0) return ; we have no statues ElseIf(amount == 1) MySpell.SetNthEffectMagnitude(0, 10.0) ; zero would be the first magic effect on the spell return ElseIf(amount == 2) MySpell.SetNthEffectMagnitude(0, 20.0) return ElseIf(amount == 3) MySpell.SetNthEffectMagnitude(0, 30.0) return ElseIf(amount == 4) MySpell.SetNthEffectMagnitude(0, 40.0) return ElseIf(amount == 5) MySpell.SetNthEffectMagnitude(0, 50.0) return ElseIf(amount == 6) MySpell.SetNthEffectMagnitude(0, 60.0) return ElseIf(amount == 7) MySpell.SetNthEffectMagnitude(0, 70.0) return ElseIf(amount == 8) MySpell.SetNthEffectMagnitude(0, 80.0) return ElseIf(amount == 9) MySpell.SetNthEffectMagnitude(0, 90.0) return ElseIf(amount == 10) MySpell.SetNthEffectMagnitude(0, 100.0) EndIf EndIf EndEvent Link to comment Share on other sites More sharing options...
steelfeathers Posted August 4, 2015 Author Share Posted August 4, 2015 (edited) Thanks for the link, but I already knew about Skse's ability to change magnitude... i guess I should edit my post to say "maintainence free and without skse". I'm trying to create a lightweight mod, because all my mods so far have been pretty script heavy. I'm hoping there's a trick to this I just haven't discovered yet.... EDIT: Thanks for the script example. FYI it could be improved by doing setnthmagnitude( 0, value * 10 ) instead of having so many if statements. Edited August 4, 2015 by steelfeathers Link to comment Share on other sites More sharing options...
Mattiewagg Posted August 4, 2015 Share Posted August 4, 2015 @scrivener Don't put so much in the OnInit though. The OnInit can usually only handle a few functions or it will just miss the rest. You should RegisterForSingleUpdate(0.1) or 1.0 or something and OnUpdate do all the required work. Link to comment Share on other sites More sharing options...
scrivener07 Posted August 4, 2015 Share Posted August 4, 2015 Meh, its just a short sample. Trying to keep boilerplate to a minimum but good point about OnInit though. I should just toss samples in a function next time as not to distract. Link to comment Share on other sites More sharing options...
JMSFedaykin Posted August 4, 2015 Share Posted August 4, 2015 Okay, this might be a dumb suggestion... But here goes... Couldn't you just have your global variable function as a multiplier? What I mean is, for example: ; KEEP IN MIND THIS IS ALL JUST PSEUDO-CODE GlobalVariable MagnitudeTracker Auto Function MagnitudeAdjuster (Spell SpellToAdjust) int numEffects = SpellToAdjust.GetNumEffects() int effectCount = 0 while (effectCount < numEffects) ; This would be for a 20% increase per level of the tracking variable if (MagnitudeTracker = 1) SpellToAdjust.SetNthEffectMagnitude(effectCount, (SpellToAdjust.GetNthEffectMagnitude(effectCount) * 1.20)) elseif (MagnitudeTracker = 2) SpellToAdjust.SetNthEffectMagnitude(effectCount, (SpellToAdjust.GetNthEffectMagnitude(effectCount) * 1.40)) elseif (MagnitudeTracker = 3) SpellToAdjust.SetNthEffectMagnitude(effectCount, (SpellToAdjust.GetNthEffectMagnitude(effectCount) * 1.60)) elseif (MagnitudeTracker = 4) SpellToAdjust.SetNthEffectMagnitude(effectCount, (SpellToAdjust.GetNthEffectMagnitude(effectCount) * 1.80)) elseif (MagnitudeTracker = 5) SpellToAdjust.SetNthEffectMagnitude(effectCount, (SpellToAdjust.GetNthEffectMagnitude(effectCount) * 2.0)) else SpellToAdjust.SetNthEffectMagnitude(effectCount, (SpellToAdjust.GetNthEffectMagnitude(effectCount) * 1.0)) endif EndFunction Now, that's just off the top of my head. Now, you may have to have an additional global variable to keep track of what previous value of the global variable was. So for example, if for some reason you needed to reset it, you could take the multiplied value back to the original value. I'm sure there are some other considerations I'm not thinking of at this point. But, at least this is a jumping-off point... Link to comment Share on other sites More sharing options...
Mattiewagg Posted August 4, 2015 Share Posted August 4, 2015 He doesn't want to use SKSE or maintenance functions though. So SetNthEffectMagnitude is no-no. I don't think there's another way to do it than conditions and SetNthEffectMagnitude, steel. Link to comment Share on other sites More sharing options...
JMSFedaykin Posted August 4, 2015 Share Posted August 4, 2015 The only other way I can think of doing it would be to create multiple MagicEffects for each spell you want to alter the magnitude of and then check against the GlobalVariable in the MagicEffect conditions of the Spell object... Now, that would be light on scripting and no SKSE, but it's alot more work on the front end... Just a thought... Link to comment Share on other sites More sharing options...
Recommended Posts