PDA

View Full Version : Help With Spell Cast Scripts



leozelig
May 15th, 2015, 12:25
Hey,

I am having trouble getting my spell cast scripts to behave... I have templates set up for the controls and scripts very similar to the attack roll scripts in 3.5E. Instead of checking for melee or ranged, I want to check for class (cleric or wizard) when building the roll.

Here is the template:


<template name="number_charbasespellcheck">
<number_chartotal>
<rollable />
<displaysign />
<modifiersize>mini</modifiersize>
<script>
function action(draginfo)
local rActor, rSpellCast = CharManager.getBaseSpellCastRollStructures(window. getDatabaseNode(), self.description[1].text[1]);
Debug.Console(rSpellCast);

ActionSpell.performRoll(draginfo, rActor, rSpellCast);
return true;
end

function onDragStart(button, x, y, draginfo)
return action(draginfo);
end


function onDoubleClick(x,y)
return action();
end
</script>
</number_chartotal>
</template>

<template name="number_charbasespellcheckcleric">
<number_charbasespellcheck>
<description><text>Base Spell Check</text></description>
<modifierfield>spellcheck.cleric.temporary</modifierfield>
<source><name>level</name><op>+</op></source>
<source><name>abilities.personality.bonus</name><op>+</op></source>
</number_charbasespellcheck>
</template>

<template name="number_charbasespellcheckwizard">
<number_charbasespellcheck>
<description><text>Base Spell Check</text></description>
<modifierfield>spellcheck.wizard.temporary</modifierfield>
<source><name>level</name><op>+</op></source>
<source><name>abilities.intelligence.bonus</name><op>+</op></source>
</number_charbasespellcheck>
</template>



Here is the getBaseSpellCastRollStructures script in the character manager:




function getBaseSpellCastRollStructures(nodeChar, sSpellCast)
local rCreature = ActorManager.getActor("pc", nodeChar);


local rSpellCast = {};
rSpellCast.type = "cast";
rSpellCast.label = sSpellCast;


215 local sSpellClass = DB.getValue(rCreature, "class", "");
Debug.console(sSpellClass);

if string.match(string.lower(sSpellClass), "cleric") then
rSpellCast.modifier = DB.getValue(nodeChar, "spellcheck.cleric.total", 0);
rSpellCast.stat = "personality";
else
rSpellCast.modifier = DB.getValue(nodeChar, "spellcheck.wizard.total", 0);
rSpellCast.stat = "intelligence";
end

return rCreature, rSpellCast;
end


Here is the error I am getting:


Script Error: [string "campaign/scripts/manager_char.lua"]:215: getValue: Invalid parameter 1

Anyone know what I am doing wrong?

I did confirm that rCreature is the correct databasenode for class, and the class field is where it should be in the db.xml file. Somehow, it does not want to retrieve the string value for class.

leozelig
May 15th, 2015, 12:30
Ok, I solved my own problem. Usually it takes typing out my question to get the answer.

local sSpellClass = DB.getValue(rCreature, class, "");

rCreature should have been nodeChar. It now returns the correct value.

leozelig
May 16th, 2015, 01:43
Post deleted. Spelling apparently matters... :)

leozelig
May 16th, 2015, 13:25
The spell cast rolls are working, including critical hit and disapproval/misfire handling. I might set it up to auto-increase disapproval range, but only if the failure cut-off is the same for all spells. I have to check that. Critical hits add the PCs level to the roll, per the rules.

I have some more bugs to fix, and I need to decide which effects I want to keep. I hope to have something ready for play testing soon!