• 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

Loop Help

Frodie

Well-known member
Trying to get this to work -


~ Loop through all hero
foreach pick in hero from Hero where "Hero.HitDice"
~ increase hit points
eachpick.field[tHitDice].value += #attrbonus[aWIS]
nexteach


But get this error.

Syntax error in 'eval' script for Thing 'tmNNWReven' (Eval Script '#2') on line 3
-> Non-existent component 'Hero' referenced by script
 
Why not tell us what your trying to accomplish actually because the above script is not logical. Only the "hero" will have a tag of Hero.HitDice so your foreach will find nothing.

You can "count" hitdice if you wish on the hero by just using tagcount[].

Is this all back to trying to change from using Con for HP to Wis to HP bonus?
 
Yep, it's the switch of the Wis and Con bonus just to Hit points. I was thinking maybe in a loop I could add the wisdom bonus and then subtract the Con bonus. But I guess that will not work. Back to square one then.
 
So lets step this one step at a time.

Lets start with looking what is already in HL. We find a "Hit Point" adjustment that seems to work. Only issue is its running too soon and its not affecting tBonusHP where the Con bonus gets applied. So we set it to Post-Attributes/1 so it runs REALLY early and change to tBonusHP and see if it works:
Code:
~ If we're not enabled, get out now
doneif (field[pIsOn].value = 0)

~ Add to our HP
herofield[tBonusHP].value += field[pAdjust].value

So we test the above and it works. It will easily adjust the value up or down at Post-Attributes/1. So far so good.

But we want to remove the "Con" bonus now and see if we can get the tBonusHP value to be zero. So we add logic that takes the character level times the Con Modifier, as we have to take into account negative values, and subtracts it out of the bonus. So we get the following script:
Code:
~ If we're not enabled, get out now
doneif (field[pIsOn].value = 0)

~ Add to our HP
herofield[tBonusHP].value += field[pAdjust].value

~ Remove Con Bonus from Bonus HP
herofield[tBonusHP].value -= #totallevelcount[] * #attrmod[aCON]
Now we test to make sure that a 12,14 and even 8 Con score gives us a bonus of "zero" extra Hit Points. But we can get bonus HP from FC so make sure you have a class and pick a +1 Hit Point FC. Does the bonus from it still apply? Yes so we are good. Now we should test with Toughness Feat and make sure its working. Perfect the extra HP from Toughness is still adding in.

Now we have to add in a bonus from Wis based on the modifier times the level.
Code:
~ If we're not enabled, get out now
doneif (field[pIsOn].value = 0)

~ Add to our HP
herofield[tBonusHP].value += field[pAdjust].value

~ Remove Con Bonus from Bonus HP
herofield[tBonusHP].value -= #totallevelcount[] * #attrmod[aCON]
~ Add Wis Bonus to Bonus HP
herofield[tBonusHP].value += #totallevelcount[] * #attrmod[aWIS]
We test it out and boom we get the Wis modifier to HP. We use a 12, 14 and 8 ability score to make sure its calculating it all correctly.

Now that we know it works all you want is the following running at "Post-Attributes/1" timing:
Code:
[B][COLOR="Green"]~ Remove Con Modifier from Bonus HP[/COLOR][/B]
herofield[tBonusHP].value -= #totallevelcount[] * #attrmod[aCON]
[B][COLOR="Green"]~ Add Wis Modifier to Bonus HP[/COLOR][/B]
herofield[tBonusHP].value += #totallevelcount[] * #attrmod[aWIS]
 
love it when you break stuff down like this shadow!

just didn't quite understand this part:
~ Add to our HP
herofield[tBonusHP].value += field[pAdjust].value

why was this needed?
 
love it when you break stuff down like this shadow!

just didn't quite understand this part:
~ Add to our HP
herofield[tBonusHP].value += field[pAdjust].value

why was this needed?
This was only need during the "proof of concept" stage above. So when I first changed the Hit Point adjustment to change the Bonus HP. I wanted to make sure that Post-Attributes/1 timing would work. So I wrote the script into an adjustment allowing me to up/down the value and see if the values on the character changed.

I often build these "proof of concept" adjustments to see if a script/timing works. Its pointless to go down the road of building all the Class Abilities to find out at the end that a specific concept does not work.

Once I had everything done you can see I took out the "adjustment" code and can put the two lines into any Thing else.
 
Back
Top