Currently, the HaveSpell procedure works for "standard" classes who have their own spell list. However, with the introduction of hybrid classes that use other class' spell list, the HaveSpell does not properly validate these classes:
Looking for Community brainstorming on integrating this new validation requirement with the current procedure:
Code:
~ This procedure tests if a character has a specific spell and sets the valid field
~ ===How to use this Procedure===
~ var SpellID as String
~ var HaveSpell as number
~ SpellID = "spCureLig1"
~ Call HaveSpell
~ @valid = HaveSpell
var HaveSpell as number
var SpellID as string
var s2search as string
var s2classes as string
var X as number
~ Init fields here
X = 0
HaveSpell = 0
~ Add thingid to the spell id passed us
SpellID = "thingid." & SpellID
~ replace the | with |thingid. tag groups
SpellID = replace(SpellID,"|","|thingid.",0)
~ Get the classes that are valid for the spell ID(s) passed to us
foreach thing in BaseSpell where SpellID
~ only do anything if we a spell with classes
if (eachthing.tagis[sClass.?] <> 0) then
~ if loop counter not zero then add a seperator between strings
if ( X <> 0) then
~ add a seperator between each loop
s2classes &= "|"
endif
~ Build a search sting of all class tags
s2classes = eachthing.tagids[sClass.?,"|"]
~ increment loop counter
X += 1
endif
nexteach
~ Get the classes that are valid for the spell ID(s) passed to us
foreach pick in hero where SpellID
~ only do anything if we a spell with classes
if (eachpick.tagis[sClass.?] <> 0) then
~ if loop counter not zero then add a seperator between strings
if ( X <> 0) then
~ add a seperator between each loop
s2classes &= "|"
endif
~ Build a search sting of all class tags
s2classes = eachpick.tagids[sClass.?,"|"]
~ increment loop counter
X += 1
endif
nexteach
~ replace the sClass tags with thingid tag groups
s2search = replace(s2classes,"sClass","thingid",0)
~ Loop through classes and see if we have one of the classes
~ valid for casting CLW spells
foreach pick in hero where s2search
HaveSpell = 1
nexteach