Adding Scripted Spells to OpenMW
Posted: 09 Jun 2018, 06:20
I had the idea last night to try adding a primitive form of scripted spells to OpenMW. I would simply use a new or unused magic effect(Like EXTRA SPELL) and, in the code, detect when the magic effect is on an NPC/Creature. Then, it would write to a variable in the stats class(if that would work) called "scriptOverride". It would set it to the name of the spell, with "_script" added on.
Then, on the npc.cpp, I edited getScript to return the base script if the variable is empty, and the variable if it's not.
I've spent a few hours playing with the code, and I feel like I am really starting to understand some of the code, despite only knowing C#.
But all the consts are really giving me issues.
Here is my getScript:
The major error is : error: invalid conversion from ‘const MWWorld::LiveCellRef<ESM::NPC>*’ to ‘MWWorld::LiveCellRef<ESM::NPC>*’ [-fpermissive]
Is there a better way to do this? I tried changing the parameters to Ptr instead of ConstPtr, and it compiles, but that brings a whole new set of problems.
Then, on the npc.cpp, I edited getScript to return the base script if the variable is empty, and the variable if it's not.
I've spent a few hours playing with the code, and I feel like I am really starting to understand some of the code, despite only knowing C#.
But all the consts are really giving me issues.
Here is my getScript:
- Spoiler: Show
The major error is : error: invalid conversion from ‘const MWWorld::LiveCellRef<ESM::NPC>*’ to ‘MWWorld::LiveCellRef<ESM::NPC>*’ [-fpermissive]
Is there a better way to do this? I tried changing the parameters to Ptr instead of ConstPtr, and it compiles, but that brings a whole new set of problems.