• 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

Bonus based on Hit Dice

chava

Well-known member
If you wanted to base Combat Expertise off of the hero's Hit Dice rather than BAB, how would you change the coding.

This what I got so far, but I can't figure out how to tell Hero Lab to look up the number of Hit Dice.

var bonus as number
bonus = hero.HitDice.value / 4
field[abValue].value += round(bonus,0,-1) + 1

field[livename].text = "Combat Expertise +/-" & field[abValue].value

if (field[abilActive].value <> 0) then
hero.child[ArmorClass].field[tACDodge].value += field[abValue].value
hero.child[Attack].field[tAtkMelee].value -= field[abValue].value
endif

But that doesn't work, because hero.HitDice is not how you look up the hero's hit dice.
 
Thank you Monkey God - yes that was the coding I was looking for.

Now to modify the feat to take advantage of old 3.5 books when I gets home. :)
 
Okay, I almost didn't pass the only programming class that I took, so I thank anyone for help.

Trying to recreate the Unarmored Defense feat tree from Swashbuckling Adventures.

I got this to work:
Code:
      ~ We want a bonus that is 1/3*HD + 3
      var bonus as number
      bonus = herofield[tHitDice].value / 3
      field[abValue].value += round(bonus,0,-1) + 3

      ~If we are wearing any armor, get out
      if (hero.tagis[Hero.LightArmor] + hero.tagis[Hero.MedArmor] + hero.tagis[Hero.HeavyArmor] <> 0) then
      perform assign[Helper.SpcDisable]
      done
      endif

      ~We passed, so add to our 'dodge' AC
        hero.child[ArmorClass].field[tACDodge].value += field[abValue].value

But I wanted to change the bonus from a dodge bonus to a increase in the 'base' ac (which is what happens when you select a Armor Class bonus on the Personal tab).

So I tried this... And nada:
Code:
      ~ We want a bonus that is 1/3*HD + 3
      var bonus as number
      bonus = herofield[tHitDice].value / 3
      field[abValue].value += round(bonus,0,-1) + 3

      ~If we are wearing any armor, get out
      if (hero.tagis[Hero.LightArmor] + hero.tagis[Hero.MedArmor] + hero.tagis[Hero.HeavyArmor] <> 0) then
      perform assign[Helper.SpcDisable]
      done
      endif

      ~We passed, so add to our 'dodge' AC
        hero.child[ArmorClass].field[tAC].value += field[abValue].value

I thought from the terminology page I thought that tAC was for AC. Basically which tAC increases AC, touch AC, flat-footed AC, and CMD.
 
How do you test if a hero has a feat in an 'if' statement.

I want a feat to turn 'off' if the hero has taken the next feat in tree has been taken:

Code:
      ~If we have the feat Unarmored Defense III, get out
      if (hero.hasfeat[fUnarmDef3] <> 0) then
      perform assign[Helper.SpcDisable]
      done
      endif

But, my coding in the 2nd line of the code is wrong.

Yes, it was:
'hero.hasfeat' should be #hasfeat
 
Last edited:
chava, please take another look at your quesions and read them as others see them (without the knowledge you have of what problem you've encountered) - I can't figure out what questions you're asking - for example, you give two long scripts, but don't explain what each is trying to accomplsh, and you don't say what's going wrong, and which one is wrong.

For your second recent post, did you solve it yourself, or is there still a question there?

Also remember that scripts are not generally useful if you leave them at the default phase and priority, so every script you post should have the phase and priority noted.
 
Sorry, I will try to be more clear in my questions and yes, I did manage to figure out the second question on my own.

Mostly, I know that a bonus applied to 'tACDodge' will give a bonus to everything (AC, touch, CMD) but the flat-footed AC.

I want to apply a bonus to AC, touch, flat-footed, and CMD.

I had a code that worked perfectly with when i used 'tACDodge', so I was hoping that I could just substitute 'tAC' for 'tACDodge' in the code, but when I did so nothing happened (and by that I mean the bonus wasn't applied to anything).

For the properly working 'tACDodge' code, there was no timing, Phase: Post-levels, Priority: 10000, Index: 1.

I think I could add a bonus to the 'tACFlat' as well, but I was hoping there was a cleaner way to do so.
 
Just use the "Bonus" field for a generic bonus.

(tAC doesn't work because at Final/1000, the code overwrites any value for tAC put in before then, rather than adding to it - probably not ideal, but the Bonus field is the more proper thing to modify)
 
Thank you very much.

I really appreciate that you guys are so willing to answer questions. 'Bonus' in place of 'tACDodge' works perfectly.

Are there any feats that kick in different effects at different levels. Looking at your guy's codes is slowly teaching me both the language and the syntax (and I know I'll remember it better if I have to trip over my own mistakes).

Simple question (maybe):
Phase: First, Priority: 500, Index: 1, no timing
Code:
	if (herofield[tHitDice].value >= 4) then
	perform hero.child[wUnarmed].assign[Helper.DamageUp]
        endif

I was trying to make it so that if your hit dice is 4 or greater then your unarmed damage would be increased by one step, but after I added in the 'if' statement, the damage increase was never applied.
 
Hit dice are like levels, so as when you're working with levels, you may have a problem looking up the hit dice before the Post-Levels phase.

Rule of Thumb: don't use the First phase unless you have a specific reason to work that early.
 
Again, Mathias, thank you.

It did work when i changed to Post-levels. And then I found the help section on on phases and read it. I couldn't find any explanation of priority however.

I have a code that works, but I want to know if there is a cleaner way to implement it (not actually code just the idea behind it):

---------
if character is 8th level or higher then
up damage
up damage
else

if character is 4th level or higher then
up damage

end
-------------

Is there a cleaner way to do this before I code up to 40th level or so?
 
Within each phase, the scripts are executed in ascending order of priority, so Post-Levels/5000 will come before Post-Levels/10000., but after First/20000.

How about taking the level count, dividing by 4, and then using a for loop to apply the tag that many times:

Code:
~divide our total level by 4 and round down
damageadds = roundherofield[tHitDice].value/4,0,-1)
 
~apply that many Helper.DamageUp tags
var i as number
for i = 0 to damageadds
  perform hero.child[wUnarmed].assign[Helper.DamageUp]
  next
 
See this is why I never progressed in programming, iterative programs are hard for me to come up with :).

Thank you, I am going to try. I will post with my next problem, or if successful my next project.
 
I got the iterative damage based on level code to work (thanks again Mathias), I just needed to remember for to define a variable.

However, I was running tests on the feat in HeroLab, and realized that as written it does strange things to the monk damage as they get the increase unarmed damage on top of the monk increases to unarmed damage - not what I wanted.

So I borrowed some of the code from the Robe, Monk's EvalScript.

However, what I got was where the damage leveled up correctly for non-monks, but did nothing for monk (as opposed to calculating the monk's level as 4 higher for the purposes of damage, which is what I wanted).

I think I know the problem, but am not sure how to work around it. (Other than just forbidding monks from taking the feat, which is one option.)

The problem:
Since my coding for the number of times DamageUp is applied is dependent on levels my code for that is phase: post-levels. However, the coding for the Robe, Monk's is phase: first.

Is there a good way for me to work around this, so should I just say monks can't take the feat?
 
Back
Top