<!-- Cloned spell pick. Bootstrapped by a feat which then selects a spell,
then the morphing spell changes itself to mimic the chosen spell. -->
<thing id="spCloneSpl" name="Cloned Spell" compset="Spell">
<tag group="Helper" tag="Helper"/>
<tag group="Helper" tag="Static"/>
<tag group="Usage" tag="Day"/>
<eval phase="Final" priority="1000" index="2"><![CDATA[
~ The charges should match the root's charges.
doneif (isroot = 0)
perform root.setfocus
doneif (state.isfocus = 0)
field[trkMax].value = focus.field[trkMax].value
]]></eval>
<eval phase="First" priority="501"><![CDATA[
~ we need to set the root as our focus, and then draw all the information
~ to ourselves that normally defines a spell.
doneif (isroot = 0)
perform root.setfocus
doneif (state.isfocus = 0)
~ Define what we prepend our name with, based on the feat which bootstraps
~ us.
var prepend as string
var searchexpr as string
if (focus.tagis[component.BaseFeat] <> 0) then
prepend = focus.field[fModTarTxt].text & " "
endif
~ If a monster chooses the same spell for two or more of our bootstrapping
~ feats (like Talmandor) , it will modify the fModTarTxt on one to include
~ both feat's text, and add a Hide.Spell tag the other. If we're the spell
~ attached to the "Hide" copy, then hide ourselves.
if (focus.tagis[Hide.Spell] <> 0) then
perform assign[Hide.Spell]
~ Alternately, we could be like Galundri, and have our root suppressed by
~ the "Customize Racial Feats" button.
elseif (focus.tagexpr[Helper.FtHide & Helper.FtDisable & thing.skipprereq] <> 0) then
perform assign[Hide.Spell]
endif
~ Define which table we should appear on in the Spells tab
~ Spells which are attached to a spellcasting class will have SpellType
~ tags, and so we need do nothing here.
if (tagis[SpellType.?] <> 0) then
~ do nothing
elseif (focus.tagis[Helper.PsychLike] <> 0) then
perform assign[Helper.PsychLike]
perform focus.delete[Helper.PsychLike]
else
perform assign[Helper.SpellLike]
perform focus.delete[Helper.SpellLike]
endif
~ We can't use focus here, because our root's selection is pointing at a
~ thing, not a pick. So we have to repeatedly transition instead... :(
~ No target tag means transition through the chooser
if (focus.tagis[Target.?] = 0) then
~ In some cases, the root which bootstraps us selects the spell we copy
~ with the second selector.
if (focus.tagis[Helper.ClonSpSel2] <> 0) then
~ Can't do anything if we haven't chosen anything
doneif (focus.field[usrChosen2].ischosen = 0)
searchexpr = focus.field[usrChosen2].chosen.idstring
else
~ Can't do anything if we haven't chosen anything
doneif (focus.field[usrChosen1].ischosen = 0)
searchexpr = focus.field[usrChosen1].chosen.idstring
endif
else
searchexpr = focus.tagids[Target.?,"|"]
searchexpr = replace(searchexpr,"Target.","",0)
endif
var starttext as string
var finaltext as string
foreach thing in idlist searchexpr
~ Set our name
starttext = eachthing.field[name].text
call CommaFlip
field[livename].text = prepend & finaltext
field[sbName].text = lowercase(prepend) & lowercase(finaltext)
~ Set our description
field[CustDesc].text = eachthing.field[descript].text
~ Set our spell info
perform eachthing.pulltags[sLevel.?]
perform eachthing.pulltags[sSchool.?]
perform eachthing.pulltags[sSubschool.?]
perform eachthing.pulltags[sDescript.?]
perform eachthing.pulltags[sComp.?]
perform eachthing.pulltags[sCastTime.?]
perform eachthing.pulltags[Helper.?]
perform eachthing.pulltags[usesource.?]
field[sFocusCost].value = eachthing.field[sCompCost].value
field[sFocusDesc].text = splice(field[sFocusDesc].text, eachthing.field[sFocusDesc].text, "|")
field[sCompCost].value = eachthing.field[sCompCost].value
field[sCompDesc].text = splice(field[sCompDesc].text, eachthing.field[sCompDesc].text, "|")
field[sArea].text = splice(field[sArea].text, eachthing.field[sArea].text, "|")
field[sEffect].text = splice(field[sEffect].text, eachthing.field[sEffect].text, "|")
field[sTarget].text = splice(field[sTarget].text, eachthing.field[sTarget].text, "|")
field[sDuration].text = splice(field[sDuration].text, eachthing.field[sDuration].text, "|")
perform eachthing.pulltags[sDuration.?]
field[sRange].text = splice(field[sRange].text, eachthing.field[sRange].text, "|")
perform eachthing.pulltags[sRange.?]
field[sSave].text = splice(field[sSave].text, eachthing.field[sSave].text, "|")
perform eachthing.pulltags[sSave.?]
field[sResist].text = splice(field[sResist].text, eachthing.field[sResist].text, "|")
perform eachthing.pulltags[sResist.?]
nexteach
]]></eval>
</thing>