Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Authoring Kit

Notices

Reply
 
Thread Tools Display Modes
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,207

Old February 4th, 2014, 08:07 AM
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.
Mathias is offline   #81 Reply With Quote
ob1knorrb
Member
 
Join Date: Oct 2013
Posts: 30

Old February 4th, 2014, 09:18 AM
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
ob1knorrb is offline   #82 Reply With Quote
ob1knorrb
Member
 
Join Date: Oct 2013
Posts: 30

Old February 5th, 2014, 12:55 PM
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>
ob1knorrb is offline   #83 Reply With Quote
ob1knorrb
Member
 
Join Date: Oct 2013
Posts: 30

Old February 5th, 2014, 01:15 PM
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
ob1knorrb is offline   #84 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,207

Old February 5th, 2014, 01:26 PM
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.
Mathias is offline   #85 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,207

Old February 5th, 2014, 01:29 PM
Check around post 102 or so of this thread: http://forums.wolflair.com/showthrea...dvCost&page=10 for an existing discussion of this issue.
Mathias is offline   #86 Reply With Quote
ob1knorrb
Member
 
Join Date: Oct 2013
Posts: 30

Old February 5th, 2014, 02:38 PM
Thanks, I'll take a look at that
ob1knorrb is offline   #87 Reply With Quote
ob1knorrb
Member
 
Join Date: Oct 2013
Posts: 30

Old February 5th, 2014, 05:10 PM
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"/>
ob1knorrb is offline   #88 Reply With Quote
Kairos
Senior Member
Volunteer Data File Author
 
Join Date: Feb 2009
Posts: 173

Old February 5th, 2014, 06:42 PM
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 by Kairos; February 5th, 2014 at 06:51 PM.
Kairos is offline   #89 Reply With Quote
ob1knorrb
Member
 
Join Date: Oct 2013
Posts: 30

Old February 5th, 2014, 08:01 PM
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
ob1knorrb is offline   #90 Reply With Quote
Reply

Thread Tools
Display Modes

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 12:07 AM.


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