• 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

Variable costs depending on number of picks.

EightBitz

Well-known member
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

Instead of increasing the cost for each successive pick, in increased the cost for each existing pick as well. Pick1 would cost 4 points, but if I added a second pick, they would cost 6 points each. And if I added a third, they would cost 8 points each.

In retrospect, this behavior makes sense. It still leaves me confused, though, as to how to make this work.
 
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:
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.
 
Back
Top