• 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

skill level based advancement

Gomo

Well-known member
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>
which uses "trtAdv" instead of default "trtBonus" and which works in calculation of level of skill.
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>
...then always I've got focus.linkage[basis].field[trtAdv].value as 0.
"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.
 
I'm sorry, but could you please elaborate on what you're trying to accomplish? I don't understand what you're saying.
 
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.
 
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.

It seems the point value doubles the previous cost with each advancement. If this is the case you could use a field that stores the exponents and just raise 2 to that exponent field as you apply the advances...

1=2^0, 2=2^1, 4=2^2, etc. should be doable in herolab with a power function if I am not mistaken...
 
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.
 
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.
 
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
I have set starting level to 3 so for 4th I would have to spend 4 xp, 5th 5xp, and 6th 6xp = 15 xp.
right now I am getting 4th -4, 5th -4, 6th -4 = 12xp.
 
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?
 
I belive it is this:
Code:
<eval index="2" phase="Setup" priority="5000"><![CDATA[
      #resspent[resAdvance] += field[advCost].value
      ]]></eval>

The rest of the code for the advancement:
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>
 
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>
 
Shadowrun stores the calculated cost in a field - trtAdvCost, and the calculations of that field's value is inbetween the if...elseif and the final line in the original script. You can replace what's there with whatever calculations are needed for your game.
 
I had similar code but in other component:
Code:
  <component
    id="CanAdvance"
    name="Can Advance"
    ispublic="no">

    <!-- Each advancement needs its own identity tag to support denial of duplicate advancements -->
    <identity group="IsAdvance"/>

    <!-- Each advancement needs its own identity tag to restrict enhancement to existing advances -->
    <identity group="CanAdvance"/>

    <!-- All advancements need to displace themselves to the hero -->
    <displace target="hero">Helper.Displace</displace>

    <!-- Forward all advancement tags up to the containing gizmo.
        NOTE! Only do this when we're within an advancement gizmo and NOT the hero.
        -->
    <eval index="1" phase="Setup" priority="3000"><![CDATA[
      if (tagis[Advance.Gizmo] <> 0) then
        perform forward[IsAdvance.?,origin]
        endif
      ]]></eval>

    <!-- Forward the advancement allowed tag up to the hero -->
    <eval index="2" phase="Setup" priority="3000"><![CDATA[
      perform hero.setidentity[CanAdvance]
      ]]></eval>

    <!-- If this thing is unique, forward its identity advancement tag to the hero
        NOTE! This is needed to enable deny tags so we avoid adding an existing trait again.
        NOTE! We only need to do this for user-added things.
        -->
    <eval index="3" phase="Setup" priority="3000"><![CDATA[
      if (isunique <> 0) then
        if (isuser <> 0) then
          perform hero.setidentity[IsAdvance]
          endif
        endif
      ]]></eval>

    <!-- If this is an increase, add one to the trait, and subtract one for a decrease -->
    <eval index="4" phase="Traits" priority="2000"><![CDATA[
      ~we only worry about this on actual advances - not traits added at creation
      doneif (tagis[Advance.Gizmo] = 0)

      ~apply any appropriate increase or decrease for the linked trait
      ~Note: This pick is a child of the gizmo and our parent pick is the actual "Advance"
      ~       pick that contains the appopriate "Advance" tag, so be sure to check there.
      ~Note: Since the advancement is displaced to the hero, it's "parent" is *not* the
      ~       gizmo, so we must explicitly reference through the "origin" container.
      if (origin.parent.tagis[Advance.Increase] > 0) then
        linkage[basis].field[trtAdv].value += 1
		~linkage[basis].field[trtBonus].value += 1
      elseif (origin.parent.tagis[Advance.Decrease] > 0) then
        linkage[basis].field[trtAdv].value -= 1
		~linkage[basis].field[trtBonus].value -= 1
        endif
		      ]]></eval>

    </component>
 
Looks like it's just a matter of modifying script #4 in that code - add some more lines to the end after you increase trtAdv that calculate the cost.
 
I tried to just move the script which calculate the cost to that component, but it seams that it mess up something with advancing abilities which uses other resources.
Anyway you gave me some clues how could I make it different -I'll make some test.
Thanks
 
Remember to consider the order scripts will execute in - in the Skeleton files, the script that adds the cost of an advancement to the resource:

Code:
    <!-- Each advancement consumes its cost in accrued advances -->
    <eval index="1" phase="Setup" priority="5000"><![CDATA[
      #resspent[resAdvance] += field[advCost].value
      ]]></eval>

Is at Setup/5000

The change I'm having you make means that the calculation of the cost doesn't happen until Traits/2000 - later than Setup/5000. So, you'll also need to change the timing of the script that records the cost on the resource so that it happens after you calculate the cost, instead of before.
 
Yeah, I have made it work, but after that I realized that adding a skill in advancement (as "gain new skill") complicates things and then I've made some test with adding a new incrementer for advancement but after that I moved that incrementer to skill tab instead of advancement tab, so right now I have a skill in skill tab with two incrementers - one for creation and one for advancement - it is not related to advancement mode but right now it works.
Thanks for help.
 
Back
Top