Can't figure out why this mod is broken in OpenMW

Post about your mods, learn about OpenMW mod compatibility, check for problematic mods, discuss issues, and give us feedback about your experience with modded OpenMW.
Post Reply
User avatar
halbe
Posts: 65
Joined: 14 Feb 2017, 03:55

Can't figure out why this mod is broken in OpenMW

Post by halbe »

So I was working on my OpenMW overhaul modpack thing and while making a script to manage magicka I hit a brick wall and thought I was just too dumb to make it work. I can't figure out exactly what the circumstances of the failure are but it has something to do with mod/setmagicka and the intelligence being changed. If I do mod/setmagicka on their own then it works as expected, but not in the context of this. if I run the script below in vanilla MW (it has been attached to the player) then it works fine. Here's an .esp that adds it automatically on init https://a.safe.moe/pBxU1.ESP.

If you change your intelligence to 50 then you should have 32 magicka, and if you change it to 100 you should have 1024 magicka. If I load a save with 50 intelligence (in OpenMW) then it correctly gives me 32 magicka, but if I then try to change it to 100 intelligence then it just gives me 100 magicka. No matter what goes into the ModMagicka it always gives me my current intelligence when I change the player's intelligence in OpenMW. This is all assuming there are no magicka fortification modifiers, I have removed the bonuses from atronach/elves/etc in the actual mod but this is just a snippet so you'll get strange numbers if you use them.

Here is the main script:

Code: Select all

Begin chimtest

float PlayerIntelligence
float fTemp
float NewMagicka
float OldMagicka

If (MenuMode)
	Return
EndIf

If ((GetIntelligence) == PlayerIntelligence)
	Return
EndIf

Set PlayerIntelligence to (GetIntelligence)

; the goal here is so that at 25 intelligence you cant cast spells and at 100 int you have over 1k magicka: (int/25)^5
Set fTemp to PlayerIntelligence / 25
Set NewMagicka to fTemp
Set NewMagicka to NewMagicka * fTemp
Set NewMagicka to NewMagicka * fTemp
Set NewMagicka to NewMagicka * fTemp
Set NewMagicka to NewMagicka * fTemp

Set fTemp to (NewMagicka - (OldMagicka + PlayerIntelligence))

ModMagicka fTemp

Set OldMagicka to NewMagicka

End chimtest
User avatar
halbe
Posts: 65
Joined: 14 Feb 2017, 03:55

Re: Can't figure out why this mod is broken in OpenMW

Post by halbe »

Ah I've figured it out, OpenMW must recalculate magicka from Intelligence after scripts are updated each frame. Vanilla MW must do all of the derived attribute recalculations before the scripts update. I solved it by modifying it to only update magicka on the next frame and it works perfectly. I guess I'll submit a bug report but this one is pretty minor.
Post Reply