• 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

Question about increasing Attribute Cost

So this is what is my skeleton system:

<!-- Attribute component
Each attribute possessed by the actor derives from this component
-->
<component
id="Attribute"
name="Attribute"
autocompset="no">

<!-- Attributes have a minimum trait value of 1 -->
<eval index="1" phase="Initialize" priority="3000"><![CDATA[
field[trtMinimum].value = 1
]]></eval>

<!-- Each attribute point above one that is allocated by the user costs 7 CP -->
<eval index="2" phase="Traits" priority="10000">
<before name="Calc resLeft"/>
<after name="Bound trtUser"/><![CDATA[
hero.child[resCP].field[resSpent].value += (field[trtUser].value - 1) * 7
]]></eval>


I want Attributes to be based on an increasing scale as follows:

Each point up to 14 costs 15 AP(CP) each
15 costs 30 AP
16 costs 45 AP
17 costs 60 AP
you get the idea

I know it needs to go here:

<after name="Bound trtUser"/><![CDATA[
hero.child[resCP].field[resSpent].value += (field[trtUser].value - 1) * 7
]]></eval>


But I'm not sure how to go about it. Any help would be greatly appreciated.

Geoff
 
How familiar are you with scripting? Have you figured out how to use an if...then? And have you figured out how to set up a mathematical formula?

Also, please be more clear about your formula. When you say "each point up to 14 costs 15", does that mean that I have to pay a total of 150 to get a 10? And then, because the cost/point increases drastically above 14, am I paying a total of 210 for 14 and 240 for 15?
 
Actually, give me the formula in terms of total cost to get to that level, not the cost per point.

from 1-14:
AP = 15 * points
from 15-?
AP = some more complex formula

In that sort of format - the total cost is simpler to build a script around.
 
So here's the Attribute Chart

1-14 = 15 AP per point (so an STR of 10 would cost 150AP)

15 = 30
16 = 45
17 = 60
18 = 75
19 = 90
Max Attribute Value is 19

Thanks Mathias

Geoff
 
Take a look at the rest of the questions I asked, please - how are you with scripting? Can you turn those numbers into formulas that can be used to calculate the total cost?
 
Okay I may have considered this from the wrong angle.

Each Attribute defaults to an 8. Players pay no AP for this.

Costs for an Attribute value are calculated according to this table:

8 = 0
9 = 15
10 = 30
11 = 45
12 = 60
13 = 75
14 = 90
15 = 120
16 = 165
17 = 225
18 = 300
19 = 390

Players cannot purchase an Attribute above 19. (Values are the total cost)

So is there some way to use a lookup to calculate the value?
 
Okay, I did a little graphing and trendlining, and got excel to give me the formula.

You've got these two formulas:

from 8-13:
y = 15x
from 14-19:
y = 7.5x^2 - 187.5x +1245
(yeah, it's a weird-looking formula, but plug in the numbers for a few tests, and you'll see everything will be correct).

So, in the code you posted earlier, you've got an example of some math going on:
Code:
hero.child[resCP].field[resSpent].value += (field[trtUser].value - 1) * 7
Here's that, replaced with the correct function. You'll note that I also store the value in a field, and then use that field's value to actually add to the resource - that way, if you want to display the cost somewhere, you can just look up this value instead of recalculating it (take a look at the Shadowrun game system, for example - see how we list the costs for everything)? (You can load and launch a game system in demo mode to take a look at details of that system without having to pay for it).

Code:
if (field[trtUser].value <= 13) then
  field[trtAPCost].value += 15 * field[trtUser].value
else
  field[trtAPCost.value += 7.5 * field[trtUser].value * field[trtUser].value - 187.5 * field[trtUser].value + 1245
  endif

hero.child[resCP].field[resSpent].value += field[trtAPCost].value
Earlier, you mentioned a term - "AP" - is that what your game system calls its character creation points? Does that mean "attribute points", and is attribute-specific, or does it mean something more generic?

If it is specific to attributes, then instead of trtAPCost, which is intended to be generic, you'd call it attrCost, and then it's only for attributes.

Generic cost field - put this in the Traits component:

Code:
<field
  id="trtAPCost"
  name="A? Point Cost"
  type="derived">
  </field>
Or, if it's attribute-specific, put this in the Attribute component, and change all the references in my script earlier from trtAPCost to attrCost:

Code:
<field
  id="attrCost"
  name="Attribute Point Cost"
  type="derived">
  </field>
 
I was taking another look at that formula, and I think I came up with something that looks better:

Code:
field[trtAPCost.value += 15 *(field[trtUser].value * field[trtUser].value - 25 * field[trtUser].value + 166) / 2

That way, there are no decimal values.
 
Thanks Mathias. I put the lines in and now I'm getting an odd error:

Syntax error in 'eval' script for Component 'Attribute' (Eval Script '#2') on line 4
- Extra characters at end of line

Here's the information in my Traits.str file

<!-- Each attribute point above one that is allocated by the user costs 7 CP -->
<eval index="2" phase="Traits" priority="10000">
<before name="Calc resLeft"/>
<after name="Bound trtUser"/><![CDATA[
if (field[trtUser].value <= 13) then
field[trtAPCost].value += 15 * field[trtUser].value
else field[trtAPCost.value += 15 *(field[trtUser].value * field[trtUser].value - 25 * field[trtUser].value + 166) / 2
endif
hero.child[resCP].field[resSpent].value += field[trtAPCost].value
]]></eval>

Any clue as to what I did wrong?

Geoff
 
Line 4 is this:
Code:
else field[trtAPCost.value += 15 *(field[trtUser].value * field[trtUser].value - 25 * field[trtUser].value + 166) / 2
Compare that to what I wrote:
Code:
else   
   field[trtAPCost.value += 15 *(field[trtUser].value * field[trtUser].value - 25 * field[trtUser].value + 166) / 2
Keep an eye out for line breaks.

(the indendation is something I find makes the code easier to read - that's not what's causing the problem).
 
Last edited:
Line 4 is this:
Code:
else field[trtAPCost.value += 15 *(field[trtUser].value * field[trtUser].value - 25 * field[trtUser].value + 166) / 2
Compare that to what I wrote:
Code:
else   
   field[trtAPCost.value += 15 *(field[trtUser].value * field[trtUser].value - 25 * field[trtUser].value + 166) / 2
Keep an eye out for line breaks.

(the indendation is something I find makes the code easier to read - that's not what's causing the problem).

You both have a syntax error on this because the end bracket is missing on the field your referencing.
 
Back
Top