Dehardcode spellutil

Adds lua implementations of the functions in mwmechanics/spellutil.cpp under openmw_aux.spellutil, adapted from code provided by @magicaldave1.

I was originally working on a dehardcode/modding API for bartering, but this came up as a dependency. I feel good about the utility and correctness of the implementation of spellutil.lua.

Currently, the cpp spellutil functions forward calls to the lua implementations, and checks whether the cpp result matches the lua result (logging on a mismatch). This is a good testing harness, and means that the cpp implementations can be nuked and replaced with their forwarding stubs if that's desired. I added MWLua::callGlobalInterface as an equivalent of MWLua::callPlayerInterface because spellutil is called from multiple contexts (eg. calcSpellCost from mwworld/worldimp.cpp).

My goal for this kind of lifting of mechanics is to allow gradual removal of cpp mechanics implementations, and to make the lua implementations accessible to modding. @magicaldave1 has been giving me pointers about this kind of change in a discussion about the Barter API (#8015).


Edited by Dan Anderson

Merge request reports

Loading
Loading