• 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

d6 Star Wars

Here's the piece of code (in advancement.core) that places the final advance cost on the resource that's storing all the advancement costs:
Code:
<!-- Each advancement consumes its cost in accrued advances -->
<eval index="1" phase="Setup" priority="5000"><![CDATA[
  #resspent[resAdvance] += field[advCost].value
  ]]></eval>

The advCost field's defvalue is what's currently defining the cost of an advancement:
Code:
<!-- Number of advancement slots consumed -->
<field
  id="advCost"
  name="Cost"
  type="static"
  defvalue="1">
  </field>

So, if you want to change advCost to depend on sklRoll, then remove the defValue, and use a script to calculate advCost. Since sklRoll isn't calcualated until Final/5000, that's not good - All of the scripts on resources that test "have we spent exactly as many of this resource as we should" start at Final/1000, so you need to get in earlier than that.

My recommendation: move the calculation of sklRoll to slightly after Calc trtFinal. Then, add a new script in the CanAdvance component in advancement.core to calculate advCost.

Now, that needs some complex code in order to deal with the gizmo, so here's a simple example:
Code:
if (tagis[Advance.Increase] <> 0) then
  origin.parent.field[advCost].value = linkage[basis].field[sklRoll].value * some multiplier
elseif (tagis[Advance.AddNew] <> 0) then
  origin.parent.field[advCost].value = the cost of gaining level 1 in something
  endif

Finally, move that calculation of #resspent[resAdvance] to slightly after your calculation of advCost.
 
Thanks! That helps point me in the right direction. I think I have already done a few changes to how and where advCost gets calculated, so hopefully combining that with your suggestions will get me closer :)
 
A couple of clarifications
Should the type for "advCost" be "static" or "derived"

In the CanAdvance component in advancement core, should the script be an "Eval" or a "Calculate"?

Right now I have advCost set to be "derived" and have an Eval Script. It didn't seem to be recognizing the Advance.Increase tag so I'm using Advance.Gizmo. I still have the problem of it recalculating the cost when I add a new advancement. I'll double check the ordering of my scripts again.

Code:
<eval index="5" phase="Traits" priority="5500"><![CDATA[
	  if (tagis[Advance.Gizmo]<> 0) then
         origin.parent.field[advCost].value = round(linkage[basis].field[sklRoll].value/3, 0, -1)
		 debug "NEW advCost: " & origin.parent.field[advCost].value
		 debug "NEW sklRoll: " & linkage[basis].field[sklRoll].value
	  elseif (tagis[Advance.AddNew] <> 0) then
	    origin.parent.field[advCost].value = 1
		 endif
      ]]></eval>
 
Here is what the code in "trtFinal" currently looks like:

Code:
    <!-- Final value for the trait -->
    <field
      id="trtFinal"
      name="Final Value"
      type="derived">
      <!-- Calculate the final value from the three distinct pieces -->
      <calculate phase="Traits" priority="3000" name="Calc trtFinal"><![CDATA[
        ~Note! If you change this calculation, you may need to change the similar
        ~       calculation in the "Derived" component.
        if (tagis[component.Attribute] = 1) then
		    @value = field[trtTemplat].value + field[trtUser].value + field[trtInPlay].value
			~Brent changed calculation
	        ~@value = field[trtMinimum].value + field[trtUser].value + field[trtInPlay].value
	        ~@value = field[trtUser].value + field[trtInPlay].value
        else
	        @value = field[trtUser].value + field[trtBonus].value + field[trtInPlay].value + field[trtTemplat].value
        endif
		if (compare(field[trtAbbrev].text,"Barg")=0) then
		debug "Calculate in Final Value " & field[trtAbbrev].text & ": " & @value
		endif
        ]]></calculate>
      </field>

When I look at my debug output I can see that my Bargain skill which has two advances to it does the calculations for it's original value then recalculates for the two advancements before I get to my advCost calculations (tagged with "NEW advCost" and "NEWsklRoll" in the debug

Code:
Creation date: 
Creation date: 

**********  Start Evaluation Cycle  **********

AdvTarget: 0
AdvReal: 20140125
AdvNote:s 
AdvTarget: 0
AdvReal: 20140125
AdvNote:s 
Eval 1 in thing resAdvance
Advancing Gizmo from CanAdvance0
Advancing Gizmo from CanAdvance0
Eval 4 for CanAdvance
Eval 4 for CanAdvance
Calculate in Final Value Barg: 2
Calculate in Final Value Barg: 1
Calculate in Final Value Barg: 0
Calculate in Final Value Barg: 0
Calculate in sklRoll field Barg0
Calculate2 in sklRoll field Barg11
Calculate in sklRoll field Barg0
Calculate2 in sklRoll field Barg10
Calculate in sklRoll field Barg0
NOT IN HERO - sklRoll
Calculate2 in sklRoll field Barg0
Calculate in sklRoll field Barg0
NOT IN HERO - sklRoll
Calculate2 in sklRoll field Barg0
NEW advCost: 3
NEW sklRoll: 11
NEW advCost: 3
NEW sklRoll: 11
Eval 1 in thing advBSkill
AdvCost4: 3
AdvCost5: 3
Eval 1 End in thing advBSkill
Eval 1 in thing advBSkill
AdvCost4: 3
AdvCost5: 3
Eval 1 End in thing advBSkill
res Max(afterMove): 54
Eval 3 in sklRoll field phase Traits 11
Eval 3 in sklRoll field phase Traits 10
Eval 3 in sklRoll field phase Traits 0
NOT IN HERO
Eval 3 in sklRoll field phase Traits 0
NOT IN HERO
AdvCost*: 3
AdvCost*: 3
field[livename]: Bargain
field[livename]: Bargain
Eval 4 in sklRoll field phase Traits Bargain11
Eval 4 in sklRoll field phase Traits Bargain: Droids10
Eval 4 in sklRoll field phase Traits Bargain0
Eval 4 in sklRoll field phase Traits Bargain0
Finalize in Add Item
 
Static fields may not be changed during use - they're set by the game system and then never changed again - you want a different advCost in each case, so you need a derived field.

Calculate and eval scripts are pretty much the same thing. Just that calculate scripts are attached to a specific field, and their designed purpose is to calculate the value of that field. They normally shouldn't be used to change anything other than that field.
 
Another question

My Advancement is linked to a Skill, and that Skill is linked to an Attribute
From within my Advancement Gizmo, is there any way to get to a field in the Attribute.
I'd like to get to it at the point below where it says "debug "In Gizmo"
I believe linkage[basis] would get me access to the Skill fields but not the attribute fields

Code:
    <!-- Net final roll that includes the value of the linked attribute -->
    <field
      id="sklRoll"
      name="Net Skill Roll"
      type="derived">
      <calculate phase="Traits" priority="5000" name="Calc sklRoll">
        <after name="Calc trtFinal"/><![CDATA[
        ~only access the linkage if the skill is directly on the hero; if not, it is
        ~likely within an advancement gizmo and no linkage will exist there
		if (compare(field[trtAbbrev].text,"Barg")=0) then
		debug "Calculate in sklRoll field " & field[trtAbbrev].text & @value
		endif
        if (container.ishero <> 0) then
          @value = field[trtFinal].value + linkage[attribute].field[trtFinal].value + linkage[attribute].field[trtRacial].value + field[trtRacial].value
		  else
		  debug "NOT IN HERO - sklRoll" 
		    if (tagis[Advance.Gizmo] <> 0) then
			  debug "In Gizmo " & origin.parent.field[advOrder].value
			endif
		  endif
 	  if (compare(field[trtAbbrev].text,"Barg")=0) then
		  debug "Calculate2 in sklRoll field " & field[trtAbbrev].text & @value
		  endif
        ]]></calculate>
      </field>

    <!-- Each skill is associated with a specific attribute that must be identified -->
    <linkage linkage="attribute" optional="no"/>
    <linkage linkage="skill" optional="yes"/>
 
Have you tried something like:

Code:
	if (origin.parent.isgizmo <> 0) then
		var thisid as string
		thisid = "Skill." & idstring
		debug "In Gizmo " & origin.parent.gizmo.firstchild[thisid].linkage[attribute].field[trtFinal].value
	endif
 
Last edited:
I ended up adding an additional field to the Skill and storing the value I was looking for in there, but I'll give your suggestion a try too, just to see if it works :)
 
Import file

Ok, I think I now have "Increase Basic Skill" working, and I did some revamping on Character Generation, although I now need to go back and retest Character Generation to make sure I didn't break anything with the changes I made getting advancement working.
I'm going to attempt to add an Import file here, hopefully I created it correctly.
 

Attachments

It looks like doing Advances on Attributes could be challenging. Increasing an attribute by 1 pip will increase all the associated skills by a pip as well, I'll just have to make sure that doing that doesn't cause existing Advancements on skills to change their costs, but Advancements on skills done after the Advancement on the associated Attribute will need to use the new value. Timing will be everything :)
 
As I mentioned in that post, in Shadowrun, the script that calculates advCost and the script that adds to the trtBonus of the thing being advanced needed to be the same script. Because the Advancements are added in a particular order, and that script is tied to that particular order, each one only sees the advancements that were added before it.
 
Yeah, right now things are pretty convoluted and spread out.
In advancement.core in the "CanAdvance" component I store the current trait bonus of the Skill into the Advance in a field called "advTrtBns"

Code:
      <!-- If this is an increase, add one to the trait, and subtract one for a decrease -->
    <eval index="4" phase="Effects" priority="1000"><![CDATA[
      ~we only worry about this on actual advances - not traits added at creation
      doneif (tagis[Advance.Gizmo] = 0)
 			endif
				
      ~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[trtBonus].value += 1
		origin.parent.field[advTrtBns].value = linkage[basis].field[trtBonus].value
      elseif (origin.parent.tagis[Advance.Decrease] > 0) then
        linkage[basis].field[trtBonus].value -= 1
        endif
      ]]></eval>

In traits.str I added an "ATTRoll" field to the Skill where I store the combined total of the values from the Attribute that contribute to the Net Skill so I can use them as a number that doesn't include other Skill Advances later


Code:
   <!-- Total value of the linked attribute -->
    <field
      id="ATTRoll"
      name="ATT Skill Roll"
      type="derived">
      <calculate phase="Traits" priority="4000" name="Calc ATTRoll">
          <![CDATA[
        ~only access the linkage if the skill is directly on the hero; if not, it is
        ~likely within an advancement gizmo and no linkage will exist there
        if (container.ishero <> 0) then
          @value = linkage[attribute].field[trtFinal].value + linkage[attribute].field[trtRacial].value + field[trtUser].value - field[trtUser].delta
		  debug "ATTRoll: " & @value & "  " & linkage[attribute].field[trtAbbrev].text & "  " & field[trtAbbrev].text
		  endif
        ]]></calculate>
      </field>

Then in the "sklRoll" (Net Skill Roll) field if we are in a skill the Net Skill Roll value is set, if we are in an Advance then I set the "advCost" based on the "ATTRoll" and "advTrtBns" values set earlier

Code:
    <!-- Net final roll that includes the value of the linked attribute -->
    <field
      id="sklRoll"
      name="Net Skill Roll"
      type="derived">
      <calculate phase="Traits" priority="5000" name="Calc sklRoll">
        <after name="Calc trtFinal"/><![CDATA[
        ~only access the linkage if the skill is directly on the hero; if not, it is
        ~likely within an advancement gizmo and no linkage will exist there
		if (compare(field[trtAbbrev].text,"Barg")=0) then
		debug "Calculate in sklRoll field " & field[trtAbbrev].text & @value
		endif
        if (container.ishero <> 0) then
          @value = field[trtFinal].value + linkage[attribute].field[trtFinal].value + linkage[attribute].field[trtRacial].value + field[trtRacial].value
		  else
		  debug "NOT IN HERO - sklRoll" 
		    if (tagis[Advance.Gizmo] <> 0) then
			  origin.parent.field[advCost].value = linkage[basis].field[ATTRoll].value + origin.parent.field[advTrtBns].value-1
			  origin.parent.field[advCost].value = round(origin.parent.field[advCost].value/3,0,-1)
			  if (tagis[Skill.Spec] <> 0) then
			    origin.parent.field[advCost].value = round(origin.parent.field[advCost].value/2,0,1)
			  endif
			endif
		  endif
 	  if (compare(field[trtAbbrev].text,"Barg")=0) then
		  debug "Calculate2 in sklRoll field " & field[trtAbbrev].text & @value
		  endif
        ]]></calculate>
      </field>

Then in thing_advances.dat I have the resspent

Code:
 <thing
    id="advBSkill"
    name="Increase Base Skill"
    compset="Advance"
    description="Select an base skill to increase by one.">
    <fieldval field="advAction" value="Increase Base Skill"/>
    <fieldval field="advDynamic" value="Skill.Base & !Helper.Maximum & !Hide.Attribute"/>
    <tag group="Advance" tag="Increase"/>
	   <!-- Each advancement consumes its cost in accrued advances -->
    <eval index="1" phase="Traits" priority="6000"><![CDATA[
	  perform gizmo.findchild[none,"Advance.Gizmo"].setfocus
	  doneif (state.isfocus = 0)
	  #resspent[resAdvance] += field[advCost].value
      ]]></eval>
    <!-- Attach the child entity for tracking the advance -->
    <child entity="Advance">
      <tag group="Advance" tag="MustChoose"/>
      </child>
    </thing>

It actually works okay for Skill Advances but falls apart when I throw in Attribute Advances.
I think you are correct that I will need to pull together a bunch of those pieces and put them in "CanAdvance". I'll have to spend some time looking at the Savage Worlds example and comparing to the base code and what I've got.
 
Slow :) I had some vacation time and thought I might get some work done on it then but ended up spending most of my down time playing "Sins of a Solar Empire" which I purchased ages ago but had never gotten around to playing. I'm back home now and still have a couple vacation days left so I might take another crack at it, although I've got a few projects around the house to work on too. My fear is that I may have to rework a lot of what I've already done in order to get the Attribute advances working properly
 
I can host the updated files if you want to make them available to others to test :)

I might also be able to spend some time on it as well, though I have two jobs and 60+ hrs a week, so I might not be able to contribute much.
 
Back
Top