Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Hi again folks, this time working on a class special that adds a damage bonus equal to the number of sneak attack dice at a given level. At 11th level, the bonus doubles. I want the listname and livename to list the bonus as it scales in level. My code is
Code:
~only do this if we are the first copy doneif (tagis[Helper.FirstCopy] = 0) ~Set abValue if (#levelcount[LegeRogu] >= 11) then field[abValue].value += (field[xCount].value + 1) * 2 else field[abValue].value += field[xCount].value + 1 endif ~ Set the listname field[listname].text = field[thingname].text & " " & signed(field[abValue].value) ~ Set the livename field[livename].text = field[thingname].text & " " & signed(field[abValue].value) |
#1 |
Senior Member
Join Date: Oct 2011
Posts: 6,793
|
Is this script running on the sneak attack pick? I think you need to transition to Sneak Attack and check xCount there, or else whatever other field it stores its value in.
|
#2 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
The class has the sneak attack ability, so I could have the script check xCount there. But what would the pick be? Transitioning is something I've always struggled with...
|
#3 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
You know what? I just figured it out. The pick IS the class ability "cSneakAtt". That's a big breakthrough for me! I just changed the code, and it works (almost) perfectly. Thank you Aaron.
The listname is still updating the first instance of the ability at level 3 with the actual bonus, and the remaining instances at later levels have no bonus listed at all. |
#4 |
Senior Member
Join Date: Oct 2011
Posts: 6,793
|
So you're saying the First Copy is setting the listname, but the others are not? Do you have anything like that in your script?
|
#5 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Quote:
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) ~Set abValue if (#levelcount[LegeRogu] >= 11) then field[abValue].value += hero.child[cSneakAtt].field[xCount].value * 2 else field[abValue].value += hero.child[cSneakAtt].field[xCount].value endif ~ Set the listname field[listname].text = field[thingname].text & " " & signed(field[abValue].value) ~ Set the livename field[livename].text = field[thingname].text & " " & signed(field[abValue].value) |
|
#6 |
Senior Member
Join Date: Oct 2011
Posts: 6,793
|
Quote:
I would have thought removing the FirstCopy check would have solved your issue, but if you still aren't seeing what you expect I think it's time to add some debugs. For example Code:
debug "====================" debug "this is " & this.idstring debug "this copy's index is " & field[xIndex].value debug "this copy is meant to be added at level " & tagvalue[ClSpecWhen.?] debug "====================" ~ If we're not shown, just get out now doneif (tagis[Helper.ShowSpec] <> 1) debug "it passes the first doneif" ~ if we've been disabled, get out now doneif (tagis[Helper.SpcDisable] <> 0) debug "it passes the second doneif" ~Set abValue if (#levelcount[LegeRogu] >= 11) then dubug "this copy doubles the sneak attack dice" debug "before adding, abValue is " & field[abValue].value field[abValue].value += hero.child[cSneakAtt].field[xCount].value * 2 debug "after adding, abValue is " & field[abValue].value else dubug "this copy adds the sneak attack dice once" debug "before adding, abValue is " & field[abValue].value field[abValue].value += hero.child[cSneakAtt].field[xCount].value debug "after adding, abValue is " & field[abValue].value endif ~ Set the listname debug "before script sets the text, listname is " & field[listname].text field[listname].text = field[thingname].text & " " & signed(field[abValue].value) debug "after script sets the text, listname is " & field[listname].text ~ Set the livename debug "before script sets the text, livename is " & field[livename].text field[livename].text = field[thingname].text & " " & signed(field[abValue].value) debug "after script sets the text, livename is " & field[livename].text One other thing. I would strongly urge you not to use the #levelcount macro to determine the level of something in a script, because that limits the reusability of the pick. There are fields which store what the level is for the pick, xAllLev for class specials, xTotalLev for custom specials, and the values for those are available from the start of the PostLevels phase. If for some reason you need the current level earlier than those fields have values, you can use the "foctoclass" procedure which sets the focus to whatever class an ability is added to, and then check the cTotalLev field on that class. |
|
#7 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Thanks Aaron, I'll debug and see if I can get to the bottom of this.
|
#8 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Hi Aaron, I tried out the debugging on this ability, and learned what was happening, but not why it's happening. The debug output shows the script is successful in passing both doneif conditions at level 3, and produces the desired result. However, it fails the first doneif at level 5 and afterwards. The reason (I believe) is because the tag Helper.ShowSpec is present at level 3, but not at level 5. Can you provide any insight into why this happens?
|
#9 |
Senior Member
Join Date: Oct 2011
Posts: 6,793
|
Why don't you e-mail me the .user file and I'll take a look. I'm currently having some trouble with my work address so send it to lawfulg at yahoo.com.
|
#10 |
|
|