Spy
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220
|
Is there a way to stop a script from running once it's actually been run? I've tried deleting the Helper.ShowSpec and testing for it, but that doesn't work in this case (it's a Custom Ability). The script always runs, when all I want it to do is run once and stop. A general search of the board hasn't helped much.
|
#1 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,217
|
Please elaborate on what you're trying to accomplish here.
Last edited by Mathias; March 5th, 2011 at 05:12 PM. |
#2 |
Spy
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220
|
I have given the Rogue a choice in its Special Abilities to choose an Extra Skill Point, but the Extra Skill Point works like Intelligence in that it applies to the current level and every level thereafter. So, for example, a Halfling Rogue with a 10 Int gets 8 skill points per level, but at 10th level he takes this ability and gets 9 skill points per level for each level from 10th to 20th. So I've tried two approaches, one is to just add the extra 1 into herofield[tSkTotals].arrayvalue[index] where the index is for Rogue, but that only adds to the current level, or I can add 1 to hero.child[cHelpRog].field[cSkills].value, but it changes ALL the levels of Rogue. So I've determined that I can just subtract out the previous levels extra points, with the cSkills to the new points per level already set for each level afterwards. Unfortunately, every level wants to run the recalculation of the previous levels, and I want it to no longer run that script. Once the points are subtracted out the first time, and the cSkills set to add an extra point, I no longer need the script to run.
~ If we're not shown, just get out now doneif (tagis[Helper.ShowSpec] = 0) ~ Add an additional skill point per rogue level hereafter. hero.child[cHelpRog].field[cSkills].value += 1 ~ Remove skill points from previous levels in Rogue. var index as number var prev as number index = hero.child[cHelpRog].field[cClsIndex].value prev = #levelcount[Rogue] + 2 herofield[tSkTotals].arrayvalue[index] -= prev So, obviously, once this script runs the first time, it continues to run each level to subtract out the previous levels, and I would like it to no longer run the script. I've tried some control statements to ignore the critical section here, but since I don't have a static variable I can set to make sure it paths correctly, it continues to run the script. |
#3 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,217
|
You'll need a selector - the activation amount is the normal one to use for this - to let the user specify what level they took the ability at. Then have the ability figure out what it should actually grant based on that level.
|
#4 |
Senior Member
Volunteer Data File Contributor
Join Date: Mar 2007
Posts: 1,245
|
Once you have that level, you can do a foreach that looks at the Class levels (not the Class Helper) and compares the value of their Index field to the level it was taken at. If it is equal or above, add one to a variable "BonusSkill". Then, outside the foreach add "BonusSkill" number of skills to the rogue class skill total.
I did a similar thing with the "Vow of Poverty" feat from Book of Exalted Deeds if you want an example. |
#5 |
Spy
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220
|
Sorry Mathias, what do you mean by selector? Nevermind, figured it out.
Lawful_g, I was trying to avoid user tags if I could, but I'll keep that in mind if I end up needing to use it. The foreach is another way to achieve the same thing I'm doing here, and is probably more elegant if I don't really need to change cSkills. Last edited by Kendall-DM; March 10th, 2011 at 07:19 PM. |
#6 |
Spy
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220
|
Ok, I've been plugging at this for about an hour or so. How exactly do I make a selector with hit dice? I just can't seem to figure it out. I created a Hit Dice special that I could set its Value to herofield[tHitDice].value, but it never took. Even though I could get the value from tHitDice, assigning it to a Value field in xHitDice simply resulted in '0' in that field. I changed phases, timing, anything that I could think of, still stayed '0'. Of course in this case, it would only give a selector with the current level, but I was just trying to get it to work at this point. Plus I couldn't figure out how to make a list in the selector that is 1 through 20. So, I tried a few other methods, including just trying to make the selector "1|2|3|4|...|20", which it doesn't recognize. I'm at a complete loss (outside of making 20 user tags for each level, but I'd like to avoid that).
|
#7 |
Spy
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220
|
bump... still need help trying to code level in a selector (either as a list of levels, or the current level, either will do).
|
#8 |
Spy
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220
|
Bump again... still not sure how to accomplish this, if at all.
|
#9 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,217
|
Sorry, I was remembering an "activation amount" field that's somewhere else, rather than available where you need it.
You can use the tracker - give it a min of 1 and a max of 20, and let the user enter the level they took the thing at. Last edited by Mathias; March 15th, 2011 at 09:35 AM. |
#10 |
|
|