• 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

Help with scripting in pathfinder

riatin

Member
I'm attempting to create a Lightning gun weapon based on the bomb mechanic and am new to Hero lab scripting, but not entirely new to programming. I've taken the following bit of code:

Code:
      ~ normally, the uses of thrown weapons are shown in the tracker section
      ~ we don't want that to happen for this weapon, since our charges are
      ~ handled by the class special
      perform delete[User.Tracker]

      ~ Generate the wFixDamage text, v_total is the modifier to damage,
      ~ element is the type of damage. damage is the number of dice done and
      ~ uses #value3[cAlcBomb] for the die size.
      var v_total as number
      var damage as number
      var element as string
      var isfire as number
      var useval as number
      
      damage=1
      useval = 6
      ~isfire = 1
      element = "Lightning"
      call BombDam

and copied and pasted it. My question is this, I need to determine what my die value is for damage (level+1 /2). I imagine there's simple method to do that, but am unable to find an example on the boards.

Thanks!
 
Where is this script running on as it makes a difference in the answer? Is on a class, Class Special, Weapon???

A general script would be as follows:
Code:
var bonus as number
bonus = round(hero.tagcount[Classes.Fighter]/2,0,-1)
Timing is important and you would want to use Post-Levels/10000. Also change the "Fighter" to be the class you want to count. Or change to "Classes.?" to calculate using all classes.

If your running on a class special you can pull the class level from the class your bootstrapped from without caring what class your attached to. Means the code is now reusable.
Post-Levels/10000
Code:
~ If we're not shown, just get out now
doneif (tagis[Helper.ShowSpec] <> 1)
~ If we've been Disabled, get out now
doneif (tagis[Helper.SpcDisable] <> 0)

~ Calculate bonus of half our character level
field[abValue].value += round(field[xTotalLev].value/2,0,-1)
The abValue will contain your bonus and could then be adjusted from other scripts very easily.

damage (level+1 /2).
Do you really mean Level+1/2? I guess I am so use to 1/2 level in Pathfinder I gave you code for half-level. So at level two the above will give +1. The way you have it written it would be +3 at level 2.
 
Last edited:
This bit of code is actually on the weapon 'bomb' and outputs the text for damage based on variables that I don't have declared when sending them to the bombdam subroutine.

The bomb damage is based off of level, 1d6 at 1st, 2d6 at 3rd, 3d6 at 5th, etc.

Thank you for your timely reply, you're a great resource for this Hero Lab community.
 
Last edited:
I'm not sure you can use the procedure for your ability, since it refers specifically to an alchemist class ability. You could probably use tho procedure as a base to define your own script, but ince you don't have access to procedures, I have to post it for you. Here you go:

Code:
    ~ IN: element, damage, isfire, useval
    ~ OUT: nothing
    var v_total as number
    var damage as number
    var element as string
    var isfire as number
    var useval as number

    call TotalBonus

    ~ If we have the Pyromaniac alternate racial trait, check if we are one of
    ~ the bombs that does fire dam, we need to recalculate our damage here. We
    ~ can't just add an extra level to cAlcBomb because that affects all Bombs.
    if (hero.tagis[Helper.PyroGnome] <> 0) then
      if (isfire <> 0) then
        ~ Our damage is (level + 1)/2 rounded up
        var efflevel as number
        efflevel = #levelcount[Alchemist] + 1
        damage += round(efflevel/2, 0, 1)
      else
        damage += #value[cAlcBomb]
        endif
    ~ Otherwise just add the value of cAlcBomb
    else
      damage += #value[cAlcBomb]
      endif

    damage = maximum(damage, 0)

    ~ We need to add our INT mod, stored on the Bomb thing.
    v_total += #value2[cAlcBomb]

    if (hero.tagis[Ability.trFocuBurn] <> 0) then
      if (isfire <> 0) then
        v_total += maximum(round(damage/2,0,-1),1)
        endif
      endif

    ~ generate fixed damage text by looking up our special
    if (v_total = 0) then
      field[wFixRanDam].text = damage & "d" & useval & " " & element
    else
      field[wFixRanDam].text = damage & "d" & useval & signed(v_total) & " " & element
      endif

    ~ we gain a +1 circumstance bonus to hit from the Throw Anything feat (this
    ~ goes after we calculated the TotalBonus for damage above because it is
    ~ only for attack rolls.
    field[ModCirc].value += #hasfeat[fThrowAny]
    field[ModCirc].value += (#hasfeat[fMyThrAnyt] * 2)

Hope that helps!
 
Thank you,

V_total outputs a 0 though, I think it's because instead of using [cAlcBomb] I'm using a custom class ability called [cLightning].

How would I output my intelligence modifier after the = in the following?
field[wFixRanDam].text =


Thanks for the patience.
 
How would I output my intelligence modifier after the = in the following?
field[wFixRanDam].text =
You need to make sure your running in the Post-Attributes/10000 phase and then you can use the macro "#attrmod[aINT]". Its a macro cause of the # symbol in front and its really just a short cut for saying "hero.child[aINT].field[aModBonus].value". I think aModBonus is the right field but not near HL so can't check.

Code:
field[wFixRanDam].text = #attrmod[aINT]

This is going to list the damage "as" the intelligence modifier. So if you have a 18 int the weapon is going to list its damage as "4".
 
Back
Top