• 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

Non-linar resource usage.

JakeMilo

Well-known member
Good Day,

I have been working on a side project with the authoring kit and have encountered a small problem.

The progression system I am trying to implement has a two tier cost system, and the cost system is also non-linar.

The first set of costs are:

rank cost (total cost)
0 0 (0)
1 10 (10)
2 15 (25)
3 20 (45)
4 25 (70)
5 30 (100)

The second set of costs are:

rank cost (total cost)
0 0 (0)
1 5 (5)
2 10 (15)
3 15 (30)
4 20 (50)
5 25 (75)

Using thread necromancy I found this:

http://forums.wolflair.com/showthread.php?t=8776&highlight=excel&page=2

Which helped resolve the second set of numbers. However, the first set of numbers are behaving strangely.

Code:
<!-- Each career skill point that is allocated by the user costs the appropriate XP -->
	<eval index="5" phase="Traits" priority="10000">
      <before name="Calc resLeft"/>
      <after name="Bound trtUser"/><![CDATA[
	    doneif (field[trtFinal].value = 0)
	    doneif (tagis[Skill.Career] = 0)
		var traitlevel as number
		var traitcost as number
		var finalvalue as number
		traitlevel = field[trtFinal].value
		traitcost = 5
		finalvalue = traitcost / 2 * (traitlevel * traitlevel + traitlevel)
		hero.child[resXP].field[resSpent].value += finalvalue
      ]]></eval>
	  
	<!-- Each non-career skill point that is allocated by the user costs the appropriate XP  -->
	<eval index="6" phase="Traits" priority="10000">
      <before name="Calc resLeft"/>
      <after name="Bound trtUser"/><![CDATA[
		doneif (field[trtUser].value = 0) 
	        doneif (tagis[Skill.Career] = 1)  
		var traitlevel as number
		var traitcost as number
		var finalvalue as number
		traitlevel = field[trtFinal].value
		traitcost = 5
		finalvalue = traitcost / 2 * (traitlevel * traitlevel + traitlevel)
		hero.child[resXP].field[resSpent].value += finalvalue + 5
      ]]></eval>

With the finalvalue + 5 in, the first and second rank cost 10 each and then increases in 5 increments.

Without the doneif (field[trtUser].value = 0) line, it causes the 0 value of the skill to cost 5 each.

Was wondering if anyone could help tell me what blindingly obvious mistake that I am making is?

I also tried this:

Code:
var traitlevel as number
                doneif (field[trtFinal].value = 0)
	        doneif (tagis[Skill.Career] = 1)
		var finalvalue as number
		traitlevel = field[trtFinal].value
		finalvalue = (2.5 * traitlevel * traitlevel) + (2.5 * traitlevel) 
		hero.child[resXP].field[resSpent].value += finalvalue - 5 -->

Which is the excel graph formula (ignoring the 0 value), which breaks in similiar ways.
 
In this case, your first set of costs are not quite the same formula.

The formula for your first table is 2.5x^2 + 7.5x

So in HL:
Code:
traitcost = 5
finalvalue = (traitcost / 2 * traitlevel * traitlevel) + (traitcost * 3/2 * traitlevel)
 
Back
Top