A black pudding has a Split ability that comes into play if it is struck by a piercing or slashing weapon. The rule is when struck by either a piercing or slashing weapon and the pudding has more than 10 HP, the pudding splits into two identical puddings each with half the hit points (rounded down because it is Pathfinder) of the original. I decided to automate this by adding a macro to the token that would do the dividing on the current token, then I can just copy and paste it to create the duplicate. Seems pretty straightforward.
FYI, the token has properties for HP and MaxHP. I also added printed lines (e.g., [r: "line 1"], [r: "line 2"], etc.) between each of the macro steps to see where the problem lies - it didn't even get through the first step, so I really am stuck. The other weird thing is the macro changes the value of the HP property to a null set before throwing the error.
Here's what I wrote:
Code: Select all
[h: HP=getProperty(HP)]
[h: assert(HP>10, "A Black Pudding with 10 or fewer HP cannot split")]
[h: NewHP=(HP/2)]
[h: NewHP=math.floor(NewHP)]
[h: setProperty(HP, NewHP)]
[h: setProperty(MaxHP, NewHP)]
That makes me think the program must be seeing the HP variable as a text string rather than a number, but I'm not sure how to make it realize that's not the case since the HP property is only ever a number.
Any help is greatly appreciated.