5E Character Create Playlist
  1. #1
    leozelig's Avatar
    Join Date
    Jun 2007
    Location
    Eastern USA
    Posts
    1,856
    Blog Entries
    1

    Help With Spell Cast Scripts

    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:

    Code:
    	<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:



    Code:
    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.

  2. #2
    leozelig's Avatar
    Join Date
    Jun 2007
    Location
    Eastern USA
    Posts
    1,856
    Blog Entries
    1
    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.

  3. #3
    leozelig's Avatar
    Join Date
    Jun 2007
    Location
    Eastern USA
    Posts
    1,856
    Blog Entries
    1
    Post deleted. Spelling apparently matters...
    Last edited by leozelig; May 16th, 2015 at 13:19. Reason: Problem solved

  4. #4
    leozelig's Avatar
    Join Date
    Jun 2007
    Location
    Eastern USA
    Posts
    1,856
    Blog Entries
    1
    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!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in