• 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

Selecting Patron Spells

AndrewD2

Well-known member
I've got a magic item that reduces the metamagic level by 1 (like the magical lineage trait) except the limit is to patron spells.

Is there a way to foreach through all the spells on a patron?

Thanks,
Andrew
 
You'll have to do this in 2 steps. First foreach through all spells on the hero to build the search expression of valid spells (which will be used in the second foreach, that actually lowers the MM cost). In the first foreach, look for the BonusSpAt.? tag and the Spellbook.cHelpWit, and confirm that it's root is a custom special ability (component.BaseCustSp), and a secondary one (Helper.Secondary). If this spell meets those requirements, then add it to the search expression.

Now for the second foreach, use the search expression you built up before to foreach through the valid spells and reduce their MM cost.
 
so setting up the initial foreach I have

Code:
foreach pick in hero from BaseSpell where "BonusSpAt.? & Spellbook.cHelpWit & component.BaseCustSp"

But that is returning nothing (just running a debug to check the ids returned. I've even tried running it with just:

Code:
foreach pick in hero from BaseSpell where "BonusSpAt.?"

foreach pick in hero from BaseSpell where "Spellbook.cHelpWit"

foreach pick in hero from BaseSpell where "component.BaseCustSp"

But the only thing that returns any values is just running BaseSpell
 
Aaron said to check if the root pick of the spell you find has component.BaseCustSp. Your foreach is checking if the spell you find has component.BaseCustSp, which no spell will ever have.
 
Code:
foreach pick in hero from BaseSpell where "BonusSpAt.? & Spellbook.cHelpWit"
  if (eachpick.isroot <> 0) then
    if (eachpick.root.tagis[component.BaseCustSp] <> 0) then
 
Also, phase & priority? This isn't going to work at First/100, for example, because the Spellbook.cHelpWit tag won't have been added yet, that early.
 
It's currently running post-attributes 14500 which was the same as the Magical Lineage trait that does similar
 
Here's what I currently have. I'm applying it to a 20th level witch with the healing patron selected. It displays nothing. Running at Post-Attributes & Final 14500

Code:
	  doneif (field[gIsEquip].value = 0)
      
      ~ Generate our search expression to target the correct spell
      var searchexpr as string
           
	  foreach pick in hero from BaseSpell where "BonusSpAt.? & Spellbook.cHelpWit"
	    if (eachpick.isroot <> 0) then
	      if (eachpick.root.tagis[component.BaseCustSp] <> 0) then
		     debug "id: " & eachpick.idstring
		  endif
		endif
	 nexteach
	
	  
      ~ Cycle through all the Custom/metamagic copies of our chosen spell,
      ~ and reduce their effective level by 1 (keeping them from going negative)
      foreach pick in hero from BaseSpell where searchexpr
        eachpick.field[sLevel].value = maximum(eachpick.field[sLevelBase].value,maximum(eachpick.field[sLevel].value - 1,0))
        nexteach
 
Typo in Aaron's instructions - BonusSplAt, not BonusSpAt

You can check that for yourself by right-clicking the spells in your test character's Familiar's Spells that came from the patron, and choosing "Show Debug Tags for XXXXX". That will allow you to verify that the tags you're looking for are present on the things that they're supposed to be on.

(You'll need to have "Enable Data File Debugging" turned on in the Develop menu before you get that option when right-clicking something).
 
Ok this is what I have now, but it doesn't seem to be changing the level.

Code:
	  doneif (field[gIsEquip].value = 0)
      
      ~ Generate our search expression to target the correct spell
      var searchexpr as string
	             
	  foreach pick in hero from BaseSpell where "BonusSplAt.? & Spellbook.cHelpWit"
	    if (eachpick.isroot <> 0) then
	      if (eachpick.root.tagis[component.BaseCustSp] <> 0) then
		     searchexpr = "thingid." & eachpick.idstring & " & HasMetMag.?"
		  endif
		endif
		
		foreach pick in hero from BaseSpell where searchexpr
        eachpick.field[sLevel].value = maximum(eachpick.field[sLevelBase].value,maximum(eachpick.field[sLevel].value - 1,0))
        nexteach
	  
	  nexteach
 
Code:
eachpick.field[sLevel].value = maximum(eachpick.field[sLevelBase].value,maximum(eachpick.field[sLevel].value - 1,0))
My thought the issue is here. I am not 100% sure what sLevelBase is but assuming its the base level of the spell I think the code does nothing.

If our spell level is 2 then we have
X = maximum(2,maximum(2-1,0))

Which gives a result of 2 as the maximum value of 2 vs 1 is 2. So we just set ourselves back to the same level actually. Is maximum suppose to be minimum?
 
Well I tried changing it to minimum with the same results. That code you quoted is directly from the magical lineage trait that does the same thing for a single spell.
 
Oh, good, glad you got it sorted. I was about to post something in response, but now there is no need.
 
Back
Top