Member
Join Date: Apr 2014
Posts: 50
|
Hello.
I am trying to make an advancement method which consumes points based on level of existing skill. For example advancement from 1 cost 50 points, from 2 costs 100, from 3 cost 200 and so on. Currently I tried to set it by: Code:
<eval index="4" phase="Traits" priority="2000"><![CDATA[ doneif (tagis[Advance.Gizmo] = 0) if (origin.parent.tagis[Advance.Increase] > 0) then linkage[basis].field[trtAdv].value += 1 elseif (origin.parent.tagis[Advance.Decrease] > 0) then linkage[basis].field[trtAdv].value -= 1 endif ]]></eval> But when I try to use that code to determine the cost in XP: Code:
<eval index="1" phase="Setup" priority="4000"><![CDATA[ var level as number var curvesq as number var pointspent as number var advanced as number var sequence as number perform gizmo.findchild[none,"Advance.Gizmo"].setfocus if (state.isfocus <> 0) then if (focus.islinkage[basis] <> 0) then level = focus.linkage[basis].field[trtUser].value + focus.linkage[basis].field[trtAdv].value curvesq = focus.linkage[basis].field[sklLrnCrv].value pointspent = focus.linkage[basis].field[trtUser].value advanced = focus.linkage[basis].field[trtAdv].value else curvesq = 0 pointspent = 0 endif endif sequence = power(2,advanced)*curvesq doneif (origin.ishero = 0) field[advCost].value = sequence * 10 doneif (state.isfocus = 0) if (focus.islinkage[basis] = 0) then field[advCost].value = 0 endif ]]></eval> "trtUser" is getting correctly. I tried some changes with timing but still can't to manage to make it work. Thanks in advance for any help. |
#1 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
I'm sorry, but could you please elaborate on what you're trying to accomplish? I don't understand what you're saying.
|
#2 |
Member
Join Date: Apr 2014
Posts: 50
|
I am trying to make advancement cost be a continuation of creation cost.
In example: Character buys a skill in creation to 3rd level so he pays 1(for first) + 2(for second) + 4( for 3rd level) = 7 points. In advancement he would like to rise that skill to 4th level so it should pay 8 points (in assumption that each next level cost twice amount of previous level). In Creation I use skill points, and in advancement I use XPs. I try to determine current level of a skill by summarizing trtUser (assigned in creation) and trtAdv (assigned in advancement). Now it works only for first advancement, like the current advancement would not be stored, but it works for trtFinal, so I know it works somehow but not for determining current cost in XPs. |
#3 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2011
Location: Nowhere, Virginia
Posts: 3,633
|
Quote:
1=2^0, 2=2^1, 4=2^2, etc. should be doable in herolab with a power function if I am not mistaken... RavenX Pronouns: She/Her Please do not PM me to inquire about datafiles I coded "for personal use" such as Exalted, World of Darkness, AD&D, or Warhammer 40K Roleplaying. I appreciate your interest, but I do not own the Intellectual Property rights to these game systems. Nor do I have permission from any of the Publishers to distribute the data files. As such, I cannot distribute the work I have done with community on these files. They are "for personal use" only. Thank you. I am far too busy these days to answer emails. If you message me here there is no guarantee I will get back to you at all. |
|
#4 |
Member
Join Date: Apr 2014
Posts: 50
|
Equation is not the problem.
The problem is with getting a number of previous advances which will be used in this equation. Right now I only get levels before advancement. |
#5 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
trtAdv + 1 needs to be in the same script that calculates the cost, instead of adding to trtAdv in one script and calculating the cost in a different script.
That way, since advancements always process their scripts in order from oldest to newest, in each case, the total of trtAdv will include all the changes from all the ones added before this one, but none of the ones added after this advance. |
#6 |
Member
Join Date: Apr 2014
Posts: 50
|
Ok, I simplified equation for testing purposes now it looks like this:
Code:
field[advCost].value = focus.linkage[basis].field[trtUser].value + focus.linkage[basis].field[trtAdv].value + 1 right now I am getting 4th -4, 5th -4, 6th -4 = 12xp. |
#7 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
You're only showing the line of your code that calculates the cost.
What's the line of code that's adding +1 to trtAdv look like? Could you please show us the rest of the script, so we can help you figure out why the cost increase and value increase aren't working together correctly? |
#8 |
Member
Join Date: Apr 2014
Posts: 50
|
I belive it is this:
Code:
<eval index="2" phase="Setup" priority="5000"><![CDATA[ #resspent[resAdvance] += field[advCost].value ]]></eval> Code:
<eval index="4" phase="Final" priority="1000"><![CDATA[ if (herofield[acLastAdv].value < field[advOrder].value) then herofield[acLastAdv].value = field[advOrder].value endif ]]></eval> <!-- Determine if this is the most recent advancement pick --> <eval index="5" phase="Render" priority="1000"><![CDATA[ if (herofield[acLastAdv].value = field[advOrder].value) then perform assign[Advance.Newest] endif ]]></eval> <!-- Put the dynamic tagexpr for choosers into the child gizmo --> <eval index="6" phase="Render" priority="2000" name="Assign Dynamic Tagexpr"><![CDATA[ if (empty(field[advDynamic].text) = 0) then gizmo.child[advDetails].field[advTagexpr].text = field[advDynamic].text & " & !thing.showonly" endif ]]></eval> <!-- Synthesize an appropriate name for the advancement --> <eval index="7" phase="Final" priority="10000"><![CDATA[ ~if this advancement has an annotation, there is no user-selection, so build ~the name from our pieces and we're done if (tagis[Advance.Notation] <> 0) then perform gizmo.child[advDetails].setfocus field[livename].text = field[name].text & ": " & focus.field[advUser].text done endif ~start with the name of the selected advancement field[livename].text = gizmo.findchild[none,"Advance.Gizmo"].field[name].text ~determine the user-selected child associated with this advancement ~Note: If the user hasn't selected anything yet, we won't have one, so we need ~ to bail out at this point if we don't have one yet. perform gizmo.findchild[none,"Advance.Gizmo"].setfocus doneif (state.isfocus = 0) ~if we have a domain, append it to our name ~Note: If this is a boost, we need to get the domain from the basis linkage. if (focus.tagis[User.NeedDomain] <> 0) then if (tagis[Advance.AddNew] <> 0) then field[livename].text &= ": " & focus.field[domDomain].text else field[livename].text &= ": " & focus.linkage[basis].field[domDomain].text endif endif ]]></eval> |
#9 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
From Shadowrun, which also needs to calculate the cost of an advancement depending on the value of the trait, I've pulled out some of the relevant portions of the script that adds to trtBase (you're using trtAdv for the same purpose) and then calculates the cost:
Code:
<!-- If this is an increase, add one to the trait, and subtract one for a decrease --> <eval index="4" phase="Traits" priority="2000" name="Calc Advance"><![CDATA[ ~we only worry about this on actual advances - not traits added at creation doneif (tagis[Advance.Gizmo] = 0) if (origin.parent.tagis[Advance.Increase] <> 0) then linkage[basis].field[trtBase].value += 1 elseif (origin.parent.tagis[Advance.Decrease] <> 0) then linkage[basis].field[trtBase].value -= 1 endif origin.parent.field[advCost].value += field[trtAdvCost].value ]]></eval> |
#10 |
|
|