Adding Scripted Spells to OpenMW

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

Adding Scripted Spells to OpenMW

Post by zackogenic »

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
akortunov
Posts: 899
Joined: 13 Mar 2017, 13:49
Location: Samara, Russian Federation

Re: Adding Scripted Spells to OpenMW

Post by akortunov »

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