View Single Post
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,213

Old August 12th, 2017, 10:26 AM
Oops - missed the fact that you can take the same ability multiple times, and that you expect to find more than one cost option, and you should always use the least expensive that's left over.

In that case, there's a second identity tag for each cost - AdvUsed100, AdvUsed200, etc.

And the test for which cost each advancement should use looks for the count of used tags as opposed to the count of available tags:

Code:
if (hero.countidentity[AdvCost100] - hero.countidentity[AdvUsed100] > 0) then
     cost = 100
elseif (hero.countidentity[AdvCost200] - hero.countidentity[AdvUsed200] > 0) then
     cost = 200
etc.

perform hero.assignstr["AdvUsed." & cost]
It's important that the AdvUsed tag be added to the hero in the same script that is calculating the cost of each advancement. The same script will be calculating the cost on each advancement, and because advancements are set up with an order (the order the user added them in), that script will be run in that same order.

This way, each advancement figures out its cost, and then marks the cost it used as having been used up, and then the next advancement of the same ability comes in and calculates its cost, and it will end up using the next most expensive option.
Mathias is offline   #7 Reply With Quote