• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Template Script Question

dungeonguru

Well-known member
:confused:

So, I've been playing with a "Spellcasting Dragon" template over the last couple of days and I've made some progress, but I keep banging into a few things I can't seem to find any notes on.

Bootstrapping the Innate Spellcasting (xInnatSpel) for the Innate spellcasting text to get autogenerated.

Heres the code at First/10000 that allows you to pick 1st level spells on the race tab when you have a dragon loaded with this template:

Code:
perform hero.assign[Hero.Caster]
perform hero.assign[sClass.cHelpSor]
~ perform hero.assign[Helper.WarlocCast] <- not needed..
perform hero.assign[CasterSrc.Arcane]
perform hero.assign[CasterType.SpontKnow]
perform hero.assign[SplAttr.aCHA]
~ for a test just allow 1st level sorcerer spells, will need to be 1/3 the CR for max spell level
hero.findchild[BaseRace].field[rSpExLst].text = "sClass.cHelpSor & sLevel.1"
~ make the label show up as Dragon Innate Spells
hero.findchild[BaseRace].field[rSpExLstNm].text = "Dragon Innate Spells"
~ the below line is returning a string for some reason, hardcoding to 1 for now but this needs to be the Charisma modifier for number of spells
~ hero.findchild[BaseRace].field[rSpExAllw].value = hero.child[aCHA].field[aModBonus].value
hero.findchild[BaseRace].field[rSpExAllw].value = 1

~ add the atwill and 1/day
foreach pick in hero from BaseSpell
[B]  ~ assign tags
~  eachpick.assign[Helper.RaceSpell]
~  eachpick.assign[Usage.Day][/B]
  eachpick.field[trkMax].value = 1
nexteach

The commented out code in bold is where I try to add the RaceSpell and Usage tags. In a normal creature, these are autotags, the question is can you assign autotags or am I just assigning these tags wrong. I get an "Unspecified Error in parsing... " so my guess is I'm close.

The result of the above code allows a dragon to choose 1 spell from the 1st level sorcerer list and on the spells tab it shows the spell (example Fog Cloud) as:

Fog Cloud (1) and the tracker with 1 usage.

So right now I'm stuck on the /day and racial tags.
 
Last edited:
OK, had to pick through Magic Initiate.

For some reason the eachpick assigns are syntactically different and my tired brain wasn't working, correct format is:

Code:
~ add 1/day
foreach pick in hero from BaseSpell
~ assign tags
  [COLOR="Red"][B]perform[/B][/COLOR] eachpick.assign[Helper.RaceSpell]
  perform eachpick.assign[Usage.Day]
  perform eachpick.assign[Helper.SpellLike]
  ~ perform eachpick.assign[Usage.LongRest]
  eachpick.field[trkMax].value = 1
nexteach
 
OK, fixed most of my script.

I have the following that works for most case scenarios:

Timing First/10000
Code:
~ Calculate 1/3 the CR, always round down.
  var tempCR as number
  tempCR = round(hero.findchild[BaseRace].field[rCR].value/3, 0, -1)
~ Drop out if the dragon can't cast 1st level spells.
  doneif (tempCR < 1)

~ make the spell tabs show up
  perform hero.assign[Hero.Caster]

~ Dragons are normally arcane sorcerer types, so giving the basics
  perform hero.assign[sClass.cHelpSor]
  perform hero.assign[CasterSrc.Arcane]
  perform hero.assign[CasterType.SpontKnow]
  perform hero.assign[SplAttr.aCHA]

~ if 1/3 the CR is greater than 1 then add to the end of the Spell List Levels
  var foo as number
  var tempstr as string
  foo = 1
  tempstr = "sClass.cHelpSor"
  while (foo <= tempCR)
    ~ if first time through loop, make sure to add &
    if (foo = 1) then
      tempstr &= " & (sLevel." & foo
    else
      tempstr &= " | sLevel." & foo
      endif 
      foo += 1
      loop
    tempstr &= ")"
  hero.findchild[BaseRace].field[rSpExLst].text = tempstr

~ make the label show up as Dragon Innate Spells under Race Tab
  hero.findchild[BaseRace].field[rSpExLstNm].text = "Dragon Innate Spells"

~ Now to get the Modifiers on CHA to grant total number of spells.
~ Problem here is that the Final Attribute Modifier is not available.
~ So manually round down the racial start modifiers as workaround.
  var foo2 as number
  foo2 = round(hero.child[aCHA].field[aStartMod].value/2,0,-1)
  hero.findchild[BaseRace].field[rSpExAllw].value = foo2

~ add 1/day
  foreach pick in hero from BaseSpell
  ~ assign tags
    perform eachpick.assign[Helper.RaceSpell]
    perform eachpick.assign[Usage.Day]
    perform eachpick.assign[Helper.SpellLike]
    eachpick.field[trkMax].value = 1
    nexteach

A problem I'm having is that in order to get the racial spell selection on the Race tab, it has to run in First, but any Modifiers to Charisma beyond the base race modifers are ignored (like if someone wants to adjust the dragon's charisma up a point or two with any method). This is because the timing is too early. However, trying to split the code up doesn't seem to work either, if I move the code for total number of spells to a Post-Attribute segment the code in First fails to fire off and render the selection screen.
 
Back
Top