Ok, working on Potent Pool again. Trying to work out how to limit the number of times that the ability can be chosen. Can't use Max Limit due to it's variable nature -- the maximum number of times it can be chosen is less than or equal to the max power level for the chosen psionic class:
Custom expression: Select from classes where CasterSrc.Psionic
hero.childfound[cPUMPoPool].field[usrChosen1].chosen.field[cPsiLevMax].value
Unfortunately, despite my best efforts, this always resolves as zero, which disables the ability (it's in a pre-req script -- I pulled the example from the eidolon natural armor ability).
Code:
var allowed as number
allowed = hero.childfound[cPUMPoPool].field[usrChosen1].chosen.field[cPsiLevMax].value
~ if we're a pick, then there must be cPsiLevMax
~ or fewer copies of this ability
if (@ispick <> 0) then
validif (tagcount[HasAbility.cPUMPoPool] <= allowed)
~ otherwise, look for fewer, since we're adding this
else
validif (tagcount[HasAbility.cPUMPoPool] < allowed)
endif
@message = "You may not have more than " & allowed & " copies of this ability."
Edit: Ok, found a partial solution (in that it makes the ability active)
Code:
var allowed as number
allowed = [B]maximum(1,hero.child[cPUMPoPool].field[usrChosen1].chosen.field[cPsiLevMax].value)[/B]
~ if we're a pick, then there must be cPsiLevMax
~ or fewer copies of this ability
if (@ispick <> 0) then
validif (tagcount[Ability.cPUMPoPool] <= allowed)
~ otherwise, look for fewer, since we're adding this
else
validif (tagcount[Ability.cPUMPoPool] < allowed)
endif
@message = "You may not have more than " & allowed & " copies of this ability."
However, when choosing this ability for the fist time, it throws an error:
Attempt to access non-existent child pick 'cPUMPoPool' from script
- - -
Attempt to access non-existent child pick 'cPUMPoPool' from script
- - -
Attempt to access non-existent child pick 'cPUMPoPool' from script
- - -
Attempt to access non-existent child pick 'cPUMPoPool' from script
I know why it's throwing the error, but can't see a way around it. The pre-req requires information from the character about the maximum psionic power level for any psionic classes. This information exists, but any method of referencing it throws an error (so far). I've attempted a straight pick reference as well as a foreach loop. Any assistance would be appreciated.
Edit: looks like the solution was related to timing. Changed the timing on the script to Post-Attributes 21000 and it can be added without an error now.