Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Authoring Kit
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
EightBitz
Senior Member
 
Join Date: May 2013
Posts: 1,458

Old September 18th, 2017, 02:10 AM
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.
EightBitz is offline   #1 Reply With Quote
Duggan
Senior Member
Volunteer Data File Contributor
 
Join Date: Nov 2009
Posts: 1,502

Old September 18th, 2017, 02:20 AM
Where do you have that script living?
Duggan is online now   #2 Reply With Quote
EightBitz
Senior Member
 
Join Date: May 2013
Posts: 1,458

Old September 18th, 2017, 03:15 AM
Quote:
Originally Posted by Duggan View Post
Where do you have that script living?
With trait definition in trait.str
EightBitz is offline   #3 Reply With Quote
TCArknight
Senior Member
 
Join Date: Jan 2007
Location: NW Arkansas
Posts: 1,321

Old September 18th, 2017, 07:02 AM
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.
TCArknight is offline   #4 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,213

Old September 18th, 2017, 08:32 AM
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.
Mathias is offline   #5 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,213

Old September 18th, 2017, 08:33 AM
Also, move it to the hero - actor.str, so that it only runs once, not once/item.
Mathias is offline   #6 Reply With Quote
EightBitz
Senior Member
 
Join Date: May 2013
Posts: 1,458

Old September 18th, 2017, 09:17 AM
Quote:
Originally Posted by Mathias View Post
Also, move it to the hero - actor.str, so that it only runs once, not once/item.
Works perfectly now. Thank you!
EightBitz is offline   #7 Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 06:27 AM.


Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.