Junior Member
Join Date: Jul 2015
Posts: 8
|
So I am trying to enter a new data file for AMP Year 1.
One of the concepts is that you have really three resource pools. SP - Skill points LP - Loyalty points BP - Bonus points So when you purchase a skill, it can come from SPs normally, but if you run out, you can use BPs as well. Here is the code I was using: ~First is cost of 2 if (field[trtUser].value > 8) then if (#resleft[resCP] < 2) then hero.child[resBP].field[resSpent].value += (field[trtUser].value * 2) - 8 else hero.child[resCP].field[resSpent].value += (field[trtUser].value * 2) - 8 endif ~Here are skills costing 1 else if (#resleft[resCP] < 1) then hero.child[resBP].field[resSpent].value += field[trtUser].value else hero.child[resCP].field[resSpent].value += field[trtUser].value endif endif The behavior is that it always pulls out of the BP pool. So the first question is why is the macro always testing to 0? The second question is more complicated. I came to the realization that it is just calculating the value and not incrementing the resource variable. So is there a way to track values based on how I spend points? I realize my code does not do that, but I'm still considering how to implement it. |
#1 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
What I did in cases like this in Shadowrun was to put a script on the resource itself - SP calculates how many points it has, and then if it has excess, shunts the excess over to BP.
|
#2 |
Junior Member
Join Date: Jul 2015
Posts: 8
|
So in that case, would you use a common resource component? Or would you move it out to separate components?
|
#3 |
Junior Member
Join Date: Jul 2015
Posts: 8
|
Thanks for the tip! I was able to make it work with the following eval scripts placed in the Actor component:
<!-- If they have spent more CP than they have, translate it to BP --> <eval index="1" phase="Traits" priority="11000"><![CDATA[ if (hero.child[resCP].field[resMax].value - hero.child[resCP].field[resSpent].value < 0) then hero.child[resBP].field[resSpent].value += (hero.child[resCP].field[resSpent].value - hero.child[resCP].field[resMax].value) hero.child[resCP].field[resSpent].value = hero.child[resCP].field[resMax].value endif ]]></eval> <!-- Now do the same for LP and BP --> <eval index="2" phase="Traits" priority="11100"><![CDATA[ if (hero.child[resLP].field[resMax].value - hero.child[resLP].field[resSpent].value < 0) then hero.child[resBP].field[resSpent].value += (hero.child[resLP].field[resSpent].value - hero.child[resLP].field[resMax].value) hero.child[resLP].field[resSpent].value = hero.child[resLP].field[resMax].value endif ]]></eval> Both now properly translate to BP after they have spent the appropriate resource. Thanks for the help. I wanted to put this here so if people are searching they can find what the eventual solution was. Last edited by Ozob; July 20th, 2015 at 05:44 AM. |
#4 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
I would put those scripts on the CP and LP resources themselves, which are in thing_miscellaneous.dat, rather than on actor scripts. This is a script related to a particular thing, and in my experience, I like to have all the scripts related to a particular thing in one place, on that thing, so they're easier to find many months from now when I run into a bug in that thing.
|
#5 |
Junior Member
Join Date: Jul 2015
Posts: 8
|
Ah good thinking. I'm used to game programming where I want scripts relating to how an object works to be called as methods of that object. Moved and thank you. I'm sure a few months from now I'll be thanking you!
|
#6 |
|
|