Senior Member
Join Date: May 2013
Posts: 1,458
|
I'm trying to work through an issue with a set of picks where each additional pick has a higher cost than the previous one.
The first pick costs 4 points, then each additional pick costs an extra 2 points, cumulatively. So pick1 costs 4 points, pick2 costs 6 points, pick3 costs 8 points, etc. I tried to get clever with the following bit of scripting, but it didn't work as intended. Code:
~adjust the resource appropriately var schcount as number var cost as number foreach pick in hero where "component.School" schcount += 1 nexteach cost=2+(schcount*2) hero.child[resCP].field[resSpent].value += cost In retrospect, this behavior makes sense. It still leaves me confused, though, as to how to make this work. |
#1 |
Senior Member
Volunteer Data File Contributor
Join Date: Nov 2009
Posts: 1,502
|
Where do you have that script living?
|
#2 |
Senior Member
Join Date: May 2013
Posts: 1,458
|
|
#3 |
Senior Member
Join Date: Jan 2007
Location: NW Arkansas
Posts: 1,321
|
I know if this was Pathfinder, would be able to use xIndex for the multiple, but not sure how to add that field and functionality.
Maybe add a field named compIndex and have a script that only run when the pick is added to count the number of that component and assign it to the field? Then use the value in compIndex to determine the cost of the individual pick? Last edited by TCArknight; September 18th, 2017 at 07:20 AM. |
#4 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
Put the re-calculation of the cost and the adding to the overall cost inside the foreach, not outside. That way, you get to the first item, it calculates the cost as 4, and then spends 4 points. When it gets to the second item, it calculates the cost as 6, and then spends 6 points, and so on.
Right now, what it does is to calculate the cost of the last item, and then spend that amount. |
#5 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
Also, move it to the hero - actor.str, so that it only runs once, not once/item.
|
#6 |
Senior Member
Join Date: May 2013
Posts: 1,458
|
|
#7 |
|
|