Adding Scripted Spells to OpenMW

Everything about development and the OpenMW source code.
Post Reply
Posts: 4
Joined: 21 Apr 2015, 21:17

Adding Scripted Spells to OpenMW

Post by zackogenic » 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:
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.

User avatar
Posts: 278
Joined: 13 Mar 2017, 13:49
Location: Samara, Russian Federation
Github profile:

Re: Adding Scripted Spells to OpenMW

Post by akortunov » 09 Jun 2018, 08:22

That's because you try to get writable object (ref) from readonly object (ptr with "const" prefix). This is not allowed, and compiler raises an error.
You should add "const" prefix to all your variables at least.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests