• 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

Trip/Disarm/Sunder CMB calculation script

Betsuni

New member
What HeroLab does not do:
1. Disarm CMB not increased by +2 when weilding a weapon with the "disarm" property
2. Sunder CMB not increased by +2 when weilding a weapon with the "sunder" property
3. "any bonuses you currently have on attack rolls due to spells, feats, and other effects" are not applied to TRIP, DISARM or SUNDER
4. Weapons with the "trip" property should also increase the CMB of Drag and Reposition
5. Figher Archetype - Polearm Master: Sweeping fend should treat all Spears and Polearms as if they have trip
6. Figher Archetype - Polearm Master: Sweeping fend should adjust the CMB of Bull Rush at a -4 penalty when holding a Spears or Polearms and apply bonuses as per point #3.
7. Figher Archetype - Polearm Master: Steadfast Pike ability doesn't have a way to Toggle on and off


Source:
http://paizo.com/paizo/blog/v5748dyo5lcom


Fix:
I have created two "Adjustments" (found on the adjustment tab).
One of these "Readied Action for Steadfast Pike" is to turn on/off point #7 from the errors listed above.

The second, "Weapon CMB Adjuster", deals with points #1-#6 from the errors listed above.


Notes:
This was my first attempt to do any sort of scripting within Hero Lab.
For my updated calculations I basically just grab the attack roll bonus used by the weapon, remove the BAB and the STR bonus. Then add the remainder onto the CMBs.
I'm assuming that this way I get *ALL* the applied bonuses to the weapon and because I'm removing BAB and STR the CMB isn't double-dipping on those stats.

If I have any oversights or suggestions for optimizing please let me know.

I also tested against characters who had "Weapon Finesse" or the "Agile Maneuver" feats. The calculated CMBs seem to be correct


Example Calculation:
13 BAB (level 13)
+ 5 STR
+ 1 Weapon Focus
+ 3 Polearm Training (polearm master ability)
+ 3 Weapon Bonus
+ 2 improved trip
-------
=27 new computed CMB for tripping

compared to how HeroLab computes it:
13 BAB (level 13)
+ 5 STR
+ 2 improved trip
-------
=20


Target Audience:
All Pathfinder characters! Polearm masters in particular may want to use this.


Code:

Readied Action for Steadfast Pike
Code:
~ If we're not enabled, get out now
doneif (field[pIsOn].value = 0)

var stdfst as number
stdfst = 0

foreach pick in hero where "Ability.cFtrSteadP" 
  stdfst = maximum(stdfst, eachpick.field[abValue].value) 
nexteach

foreach pick in hero where "wCategory.Melee"  
  if (eachpick.tagis[wFtrGroup.PoleArms] <> 0) then
    eachpick.field[wAttack].value += stdfst
  endif
  if (eachpick.tagis[wFtrGroup.Spears] <> 0) then
    eachpick.field[wAttack].value += stdfst
  endif
nexteach

Weapon CMB Adjuster
Code:
~ If a "melee" weapon is held then CMB is adjusted for TRIP, DISARM, SUNDER (weapons do not need these properties to take advantages of the implicit bonuses).
~ If a "melee" weapon has disarm or sunder weapon properties than a +2 bonus is granted.
~ If a "melee" weapon has trip then DRAG and REPOSITION are adjusted to use updated CMB.
~ Note to players.  If you fail your TRIP check by 10 or more then you become prone or if your weapon has a trip property you can drop the weapon - I cannot account for this penalty.


~ If we're not enabled, get out now
doneif (field[pIsOn].value = 0)


~Boolean: flags for Combat Maneuvers which need to be adjusted (note that doBllRsh is TRUE when the value is equal to 2)
var doTrip   as number
var doDisarm as number
var doSunder as number
var doBllRsh as number
doTrip   = 0
doDisarm = 0
doSunder = 0
doBllRsh = 0

~Boolean: is the hero holding a "Melee" weapon?
var isWpnFnd as number
isWpnFnd = 0

~Integer: what is the calculated Attack bonus on the weapon (this number will be modified)
var atkBonus as number
atkBonus = 0


~Check if the hero has the Polearm Ability "Sweeping Fend"; as a prereq for doing "Bull Rush" with the weapon.
foreach pick in hero where "Ability.cFtrSweepF"
  doBllRsh = 1
nexteach

~Only iterate over Melee weapons the character has
foreach pick in hero where "wCategory.Melee"
  ~Only bother with "Equipped" weapons.
  if (eachpick.field[gIsEquip].value = 1) then
    isWpnFnd = 1

    ~Benefit of the Doubt - use the highest attack bonus found for equipped melee weapons!
    atkBonus = maximum(eachpick.field[wAttack].value, atkBonus)

    ~Determine if hero is holding a PoleArm or a Spear
    if (doBllRsh = 1) then
      if (eachpick.tagis[wFtrGroup.PoleArms] <> 0) then
        doBllRsh = 2
      elseif (eachpick.tagis[wFtrGroup.Spears] <> 0) then
        doBllRsh = 2
      endif
    endif

    if (eachpick.tagis[wSpecial.Trip] <> 0) then
      doTrip = 1
    elseif (doBllRsh = 2) then
      doTrip = 1
    endif
    if (eachpick.tagis[wSpecial.Disarm] <> 0) then
      doDisarm = 1
    endif
    ~N.B. there are no Sunder weapons for me to test with ATM.
    if (eachpick.tagis[wSpecial.Sunder] <> 0) then
      doSunder = 1
    endif
  endif
nexteach


if (isWpnFnd = 1) then
  ~undo STR and BAB, otherwise they are counting twice
  atkBonus = atkBonus - hero.child[Attack].field[tAtkBase].value
  atkBonus = atkBonus - hero.child[aSTR].field[aBonus].value

  ~ Add to our chosen attribute
  hero.child[manTrip].field[manCMB].value   += atkBonus
  hero.child[manSunder].field[manCMB].value += atkBonus
  hero.child[manDisarm].field[manCMB].value += atkBonus

  if (doTrip = 1) then
    hero.child[manReposit].field[manCMB].value += atkBonus
    hero.child[manDrag].field[manCMB].value    += atkBonus
  endif
  if (doDisarm = 1) then
    hero.child[manDisarm].field[manCMB].value += 2
  endif
  if (doSunder = 1) then
    hero.child[manSunder].field[manCMB].value += 2
  endif
  if (doBllRsh = 2) then
    hero.child[manBullRus].field[manCMB].value += atkBonus - 4
  endif
endif
 

Attachments

Last edited:
Actually your adjustments are not actually correct by RAW. The bonuses only apply at a specific weapon level not to the character as a whole.

So just because you have a Disarm weapon does not mean your Global CMB value would go up. Just the CMB for that specific weapon.

I have adjustments file that has been around for awhile already done that allows you to get the correct CMB/CMD values on to a specific weapon. You can see the full details HERE.

While I agree that changing the global CMB/CMD values would be a nice and easy houserule its not RAW. :(

The scripts themselves look pretty good. So good job with that for your first scripts. :)
 
Last edited:
I was always assuming that Hero Lab computed numbers based on the character's current state. Including as part of that state which weapons are currently being utilized.

I'm now thinking if you print this information out then this can lead to bad values unless you print out your CMB's for each weapon you have equipped. I was looking at this from the point of that a character has a favoured weapon or the player is managing this character entirely from within Hero Lab.

I opened up your file and I like what I see. I think I may try and merge the calculated values of my script with the text replacement you have made. However if using the example used in my first post I'm not entirely sure how feasible it would be to add in text that says:
"Trip CMB +9, Reposition CMB +7, Drag CMB +7, Disarm CMB +7, Sunder CMB +7, Bull Rush CMB +3"
...just because they picked up that +3 Guisarme (lvl 13 Polearm Master). This is a pretty long string and I'm not at home to see where/how that would be displayed to the user. Would that string get cropped or cause overflow issues on printed output?

I only wished to display some of this information so that the players who are not rules savy get a good idea what the implications to their combat stats are. As you can see that is quite a bit of modified abilities.
 
Also thanks for the compliments on the scripts. I honestly found Hero Lab very unfriendly to code in. I eventually just started using Notepad++. I made a language file to colourize some keywords.

add this (or modify the existing)
<user directory>\Application Data\ Notepad++\user\userDefineLang.xml

Code:
<NotepadPlus>
    <UserLang name="HeroLab" ext=".hl">
        <Settings>
            <Global caseIgnored="no" />
            <TreatAsSymbol comment="no" commentLine="yes" />
            <Prefix words1="yes" words2="no" words3="no" words4="yes" />
        </Settings>
        <KeywordLists>
            <Keywords name="Delimiters">["0]"0</Keywords>
            <Keywords name="Folder+">foreach if</Keywords>
            <Keywords name="Folder-">nexteach endif</Keywords>
            <Keywords name="Operators">- # & ( ) * / : @ [ ] + < = ></Keywords>
            <Keywords name="Comment"> 1 2 0~</Keywords>
            <Keywords name="Words1">var number string perform assign append trustme debug notify as in</Keywords>
            <Keywords name="Words2">goto if then elseif endif while loop for to next foreach where nexteach bootstrap entity done doneif </Keywords>
            <Keywords name="Words3">length left right mid pos uppercase lowercase lastpos asc chr compare replace int random minimum maximum power nthroot round signed decimals bitwise_and bitwise_or bitwise_xor bitwise_not empty plaintext today</Keywords>
            <Keywords name="Words4">this portfolio hero container pick thing field .field pool parent linkage root dynalink gearholder shadow origin master minion anchor child gizmo scene layout template portal table .value chosen state transation focus actor eachpick altpick altthing</Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" styleID="11" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" />
            <WordsStyle name="FOLDEROPEN" styleID="12" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" />
            <WordsStyle name="FOLDERCLOSE" styleID="13" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" />
            <WordsStyle name="KEYWORD1" styleID="5" fgColor="FF8000" bgColor="000000" fontName="" fontStyle="0" />
            <WordsStyle name="KEYWORD2" styleID="6" fgColor="00FFFF" bgColor="000000" fontName="" fontStyle="0" />
            <WordsStyle name="KEYWORD3" styleID="7" fgColor="FF0000" bgColor="000000" fontName="" fontStyle="0" />
            <WordsStyle name="KEYWORD4" styleID="8" fgColor="FF8040" bgColor="000000" fontName="" fontStyle="0" />
            <WordsStyle name="COMMENT" styleID="1" fgColor="00FF00" bgColor="000000" fontName="" fontStyle="0" />
            <WordsStyle name="COMMENT LINE" styleID="2" fgColor="00FF00" bgColor="000000" fontName="" fontStyle="0" />
            <WordsStyle name="NUMBER" styleID="4" fgColor="FF8000" bgColor="000000" fontName="" fontStyle="0" />
            <WordsStyle name="OPERATOR" styleID="10" fgColor="FF0080" bgColor="000000" fontName="" fontStyle="1" />
            <WordsStyle name="DELIMINER1" styleID="14" fgColor="FFFF80" bgColor="000000" fontName="" fontStyle="3" />
            <WordsStyle name="DELIMINER2" styleID="15" fgColor="FFFF00" bgColor="000000" fontName="" fontStyle="3" />
            <WordsStyle name="DELIMINER3" styleID="16" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
        </Styles>
    </UserLang>
</NotepadPlus>

Be warned that I like to use "black" as my background colour, so you may need to change this if you like "white".
 
I opened up your file and I like what I see. I think I may try and merge the calculated values of my script with the text replacement you have made. However if using the example used in my first post I'm not entirely sure how feasible it would be to add in text that says:
"Trip CMB +9, Reposition CMB +7, Drag CMB +7, Disarm CMB +7, Sunder CMB +7, Bull Rush CMB +3"
...just because they picked up that +3 Guisarme (lvl 13 Polearm Master).
LOL This is totally true if you have a character that into the different maneuvers. Though its one of the reasons my Custom Character sheet has such a huge area of room after the Weapon Names. :)

Its also why I think HL has not done anything official yet as they themselves are trying to figure out a good way to do.

On the other side of things I do agree if your in HL and "equip" a weapon then it would be nice to adjust the CMB/CMD global values on the fly. If you have no objections I plan to merge your adjustments into my adjustments file so that people have the option of going either way.

I tend to switch between using TextPad and HL Editor. Somethings are nice like setting up classes and dealing with bootstraps I like the ability to just click mouse buttons. But when writing bigger/complex scripts I find TextPad and my huge 15+ font size much easier to write in. :p
 
Back
Top