• 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

Having some trouble with tagvalue

AndrewD2

Well-known member
I'm working on a racial special that states:

If the base creature has a caster level for any of its abilities, decrease that caster level by half, the creature also loses access to its highest level of spell-like abilities and and not use any of them more than 1/day.

So what I'm trying to do is foreach through all the spelllike abilities checking the tagvalue on the sLevel.? tag and then if there is only one spell of that level it'll just disable it, otherwise it gives a picker to disable the spell.

My code thus far is:

Post-Levels 10000
Code:
var highest as number
var hiID as string
var total as number
var candexpr as string
var spell as string

highest = 0
total = 0
foreach pick in hero from BaseSpell where "Helper.SpellLike"
   perform eachpick.pulltags[sLevel.?]

   debug "ID: " & eachpick.idstring
   debug "tagvalue: " & tagvalue[sLevel.?]
   if (tagvalue[sLevel.?] > highest) then
      debug "new spell is higher level"
      highest = tagvalue[sLevel.?]
      debug "highest: " & highest
      total = 1
      debug "total: " & total
      hiID = eachpick.idstring
   elseif (tagvalue[sLevel.?] = highest) then
      debug "New spell is the same level"
      total += 1
      debug "Total: " & total
   endif

   perform eachpick.tagreplace[Usage.?,Usage.Day]
   eachpick.field[trkMax].value = 1
nexteach
	
   debug "Checking how many of that level there are"
   if (total = 1) then
     debug "Only 1 copy"
     spell = "thingid." & hiID
     perform hero.findchild[BaseSpell, "Helper.SpellLike & " & spell].assign[Hide.Spell]
   elseif (total > 1) then
     debug "more than 1 copy"
     field[usrCandid1].text = "component.BaseSpell & Helper.SpellLike & sLevel." & highest
     debug field[usrCandid1].text
     perform field[usrChosen1].chosen.assign[Hide.Spell]
  endif

And according to my debug information on my test monster when you compare the levels on the ids there is only 1 spell of that level, but it is pulling 2.

here's the debug data
[Black Dragon, Great 2.1] ID: spCharMon6
[Black Dragon, Great 2.1] tagvalue: 6
[Black Dragon, Great 2.1] new spell is higher level
[Black Dragon, Great 2.1] highest: 6
[Black Dragon, Great 2.1] total: 1
[Black Dragon, Great 2.1] ID: spDarknes2
[Black Dragon, Great 2.1] tagvalue: 6
[Black Dragon, Great 2.1] New spell is the same level
[Black Dragon, Great 2.1] Total: 2
[Black Dragon, Great 2.1] ID: spInsePla5
[Black Dragon, Great 2.1] tagvalue: 2
[Black Dragon, Great 2.1] ID: spPlanGro3
[Black Dragon, Great 2.1] tagvalue: 3
[Black Dragon, Great 2.1] ID: spSpeawit1
[Black Dragon, Great 2.1] tagvalue: 3
[Black Dragon, Great 2.1] Checking how many of that level there are
[Black Dragon, Great 2.1] more than 1 copy
[Black Dragon, Great 2.1] component.BaseSpell & Helper.SpellLike & sLevel.6

It seems like tagvalue is holding the value for multiple items, is there a better way to do this? I was trying to make it with the least about of user interaction, but I can't even be sure it'l pull the right values for each copy.
 
By pulling the tags from every spell-like ability you find, you're building up a larger and larger collection of sLevel tags on the pick running this script every time the foreach repeats, so by the time you reach even the second item, you're not sure whether you're testing the tags from the first time through or the second.
 
ah ok, I was under the impression that I needed to run pulltags before using tagvalue, I see now that I can use tagvalue on eachpick and it works, thanks for the insight.
 
Back
Top