<thing
id="sCustPagKn"
name="- Add custom Page of spell knowledge -"
compset="MagicItem"
description="This page is covered in densely-worded arcane or divine magical runes. It contains the knowledge of a single arcane or divine spell (chosen by the creator when the item is crafted). If the bearer is a spontaneous spellcaster and has that spell on her class spell list, she may use her spell slots to cast that spell as if it were one of her spells known. A {i}page of spell knowledge{/i} is priced based on the spell's cleric or sorcerer/wizard spell level, unless the spell doesn't appear on either of those spell lists, in which case it is based on the highest spell level as it appears on any other spell list. For example, a spell that is on the 4th-level inquisitor list and the 2nd-level paladin list is priced as a 4th-level spell."
buytemplate="BuyGeneral"
xactspecial="2"> <!-- Barebones purchase, showing just coin fields -->
<usesource source="UltEquip"/>
<tag group="Helper" tag="CustomItem"/>
<tag group="Helper" tag="CustSpCont"/>
<tag group="gType" tag="Wonder"/>
<tag group="SpecialTab" tag="GRWondrous"/>
<tag group="Helper" tag="EquipMag"/>
<eval value="1" phase="Render" priority="105100">
<after name="Gen Custom Spell Name"/>
<after name="Default livename Modify"/><![CDATA[
~ Now that all spells have been accounted for, wrap us in parentheses and
~ add the item's name
field[sbName].text = "page of spell knowledge ({i}" & lowercase(field[livename].text) & "{/i})"
field[livename].text = "Page of spell knowledge ({i}" & lowercase(field[livename].text) & "{/i})"
]]></eval>
<eval index="2" phase="Final" priority="10000"><![CDATA[
~our list of spells does not include wordspells or the custom wordspell helper
gizmo.child[CustPage].field[abItemExpr].text = "!component.BaseWord & !Helper.CustomItem & !Helper.Helper & !Helper.Obsolete & !sLevel.0"
]]></eval>
<eval index="3" phase="First" priority="2000">
<before name="Fake a Spell's linkage[table]"/><![CDATA[
~if we're not equipped, hide all the spells added to our gizmo
if (field[gIsEquip].value = 0) then
foreach pick in gizmo from BaseSpell
perform eachpick.assign[Hide.Spell]
nexteach
else
~search through all the spontaneous caster classes on our hero
foreach pick in hero from Class where "CasterType.SpontKnow"
perform eachpick.pulltags[SpellType.?]
~using that class' list of spells available, search through all the
~spells in our gizmo
foreach pick in gizmo from BaseSpell where eachpick.tagids[sClass.?,"|"]
~assign each one of them to that class
perform eachpick.pushtags[SpellType.?]
nexteach
perform delete[SpellType.?]
nexteach
endif
]]></eval>
<eval index="4" phase="Final" priority="10000"><![CDATA[
~during play, this doesn't need to be on the Special tab, but we do want
~it displayed in the gear description appendix, so we add tags that will
~make it show up in that list if we're outputting this item, but *not* in
~the general special abilities list at the end of the statblock
if (state.isoutput <> 0) then
perform assign[Helper.ShowSpec]
perform assign[Hide.Statblock]
endif
]]></eval>
<evalrule index="1" phase="Validation" priority="5000" message="A Page of Spell Knowledge must be created with exactly one spell."><![CDATA[
validif (tagcount[Helper.CustHasSpl] = 1)
]]></evalrule>
<child entity="CustPage">
</child>
</thing>