• 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

Counting Feats

AndrewD2

Well-known member
A feat I'm entering adds 2 HP for every feat of a specific category (Arcana in this case).

I figure I just need to count the fCategory.Arcana tags, multiply by 2 and += them to HP but I'm no sure how to do the tag counting part.

I'm thinking:

var count as num
foreach feat where tagis[fCategory.Arcana]
count += 1
end

count *= 2
container.child[Totals].field[tHP].value += count

I know my syntax is very likely wrong I just wanted to write out my idea and see if I'm on the right track.

Thanks,
Andrew
 
On the Class Level tab (not the Class tab), copy the Loremaster class - one of the prereqs on that needs to count feats by category.
 
so I could do something like:
var count as num
count = tagcount[fCategory.Metamagic] * 2
container.child[Totals]field[tHP].value += count
 
so I could do something like:
var count as num
count = tagcount[fCategory.Metamagic] * 2
container.child[Totals]field[tHP].value += count
My advice is to follow the HL standard and do
Code:
field[abValue].value += tagcount[fCategory.Metamagic] * 2
hero.child[Totals]field[tHP].value += field[abValue].value
The big advantage of using field[abValue] is that you can affect changes to this feat then from other Things. What if some feat or ability gives a -2 HP for taking this feat.

You could do
Code:
hero.childfound[ID_OF_FEAT].field[abValue].value += -2

By not using abValue you lose out on that ability.
 
I get an error using that:

Hero Lab was forced to stop compilation after the following errors were detected:

Syntax error in 'eval' script for Thing 'fRPArcaneB' (Eval Script '#1') on line 7
-> Invalid child transition syntax used
 
ShadowChemosh, as long as you're talking about best practices, I'd suggest using -= 2, rather than += -2.

Also remember that herofield[] is a shortcut for hero.child[Totals].field[], and #value[] is a shortcut for hero.childfound[].field[abValue].value, so you can cut down the typing required for that code even further.
 
AndrewD2, the error message refers to line 7. I recommend you copy and paste line #7 here (or paste your whole script, empty lines and all, if you can't figure out which one is the problem). You've probably got a typo, but without seeing the code, we can't see what it is.
 
Actually, I think I can see it, if you copied ShadowChemosh's script exactly and then modified it - he forgot a period inbetween hero.child[Totals] and field[tHP].value
 
Ok so I got it working ... kinda

Code:
~ Add to abValue first so outside things can adjust us
field[abValue].value += 1
~ add to the pool total
#trkmax[trkArcaneP] += field[abValue].value

field[abValue2].value += tagcount[fCategory.Arcana] * 2
herofield[tHP].value += field[abValue2].value

is the whole eval script.
I was running it at post-attributes 10000, but I've tried it in most every other phase and it only ever adds 2 HP even when having 4 other Arcana feats. Am I missing something?
 
ShadowChemosh, as long as you're talking about best practices, I'd suggest using -= 2, rather than += -2.
Hmm I always add a negative value rather than subtract a positive value. I can't think of it now but I swear I ran into a issue long time ago with subtracting a positive value.

So you guys would subtract a positive then? hmmmm

Also yea I forgot the period above. I did not know about the herofield is actually hero.child[totals]. That makes sense now that you say it.

So really it should be:
Code:
field[abValue].value += tagcount[fCategory.Metamagic] * 2
herofield[tHP].value += field[abValue].value
 
I was running it at post-attributes 10000, but I've tried it in most every other phase and it only ever adds 2 HP even when having 4 other Arcana feats. Am I missing something?
What value is inside "abValue2". That can help narrow down if the issue is in the count calculation or how its getting added to the HP total.
 
when I debug it tells me the tagcount[fCategory.Arcana] is 1 and abValue2 is 2 but it should be tagcount = 4 and abValue 8 with what's on the character. It seems it is only counting itself.
 
And in case it helps here's the feat:

Arcane Body
Your arcane power reinforces your body.

Benefit: When you take this feat, you gain 2 hit points for each arcana feat you have (including this one). Whenever you take a new arcana feat, you gain 2 more hit points.

You add 1 point to your arcane pool.
 
Opps my bad. I did that script a little too quick. Your right it is only looking at itself.

Code:
~ Add to abValue first so outside things can adjust us
field[abValue].value += 1
~ add to the pool total
#trkmax[trkArcaneP] += field[abValue].value

field[abValue2].value += hero.tagcount[fCategory.Arcana] * 2
herofield[tHP].value += field[abValue2].value
I forgot to add "hero." before tagcount so it would look at the hero not itself. :(
 
THANK YOU! Works beautifully. Originally when I was working this out in my head I knew it needed to have that, looks like I forgot too. :-D
 
Back
Top