Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - Authoring Kit (http://forums.wolflair.com/forumdisplay.php?f=58)
-   -   Advancement question (http://forums.wolflair.com/showthread.php?t=63079)

ShadowWalker August 22nd, 2019 01:01 PM

Advancement question
 
I have a game system that increases the cost of increasing skills as they level.
How can I set the value of the field advCost to current value of the skill + 2.

I've added code to the advance component using
perform gizmo.findchild[none,"Advance.Gizmo"].setfocus
and
perform gizmo.child[advDetails].setfocus

to access the skill that was selected and the first seems to work. Except that all the fields are default values. It doesn't seem to matter what the phase and priority are set to, the values come back default.
It just came to me that this won't work without saving the value of the skill at the time the advancement was added, or the order they are processed in is important.

I know this has to be possible since Shadowrun works this way.

Any ideas of the direction to go in would be greatly appreciated.

Thanks,

Duggan August 22nd, 2019 05:19 PM

How does your advancement system work? Points? If so, you just need to calculate the cost of skills with a function based on the total.

ShadowWalker August 22nd, 2019 06:33 PM

Each skill costs what you are going to +1.
Buying a new skills costs 1, as you are going to a 0.
going to a 1 costs 2, 2 costs 3, and so on.
I see in the advance component where it is setting the resource picks resSpent, but I've no idea where to set advCost, which itself is static, but that is easy to change.
I thought I would put code in the advance component replacing the use of advCost but when I try to access the pick that has been selected it gives me values that are the default. I tried changing the timing of when the script is run but still get default values.
I'm thinking something needs to set advCost but I'm not sure where or how to do so.
What's worse there are three pools of points that are used in advancement not 1. Different things are increase from different pools.

Duggan August 22nd, 2019 07:30 PM

Can you post your code? Or a link to it?

ShadowWalker August 22nd, 2019 08:13 PM

Okay I got it sort of working.
I was missing the linkage[basis] in the first incarnation of the code.
This gets the proper values, sort of.
If I add another advancement for the same skill both advancements get the latest skill value and cost out at that new value.
So if I go from not having the skill to having it costs correctly at 1 point.
As soon as I add the second advancement it costs 4, 2 for each. instead of 3. 1 and 2 respectively.

Code:

perform gizmo.findchild[none,"Advance.Gizmo"].setfocus
doneif (state.isfocus = 0)
perform focus.linkage[basis].setfocus
if (focus.tagis[Skill.?] <> 0) then
  var value as number
  value = focus.field[trtBonus].value
  if (focus.tagis[User.Combat] = 0) then
    var resLeft as number
    resLeft = #resmax[resAdvNCSP] - #resspent[resAdvNCSP]
    if (resLeft >= value) then
      #resspent[resAdvNCSP] += value
    elseif (resLeft > 0) then
      #resspent[resAdvSP] += value - resLeft
      #resspent[resAdvNCSP] += resLeft
    else
      #resspent[resAdvSP] += value
      endif
  else
    #resspent[resAdvSP] += value
    endif
  endif


ShadowWalker August 23rd, 2019 03:12 PM

I was able to get this working by using the history in the field.
In the above script I count the number of items in the history.
Compare it to the value of the field.
At the end of the script I attach a tag to the pick being advanced.
That way I can tell how many times the script has already run and I can then get the right cost.
If anyone can tell me a better way to do this please do. Thankfully the game only has 5 levels in skills. So this runs quick.

ShadowWalker August 30th, 2019 02:25 PM

Ok. So After much digging and guess work I figured out how to do this.
I changed advCost to derived and persistence full.
I then added a change script to advNew and advBoost in form_advance.
The change script gets called only once and calculates the cost and stores that value in the now persistent advCost field.
Within the advance component I can now use the advCost field to assign cost to the correct pool of advancement points.


All times are GMT -8. The time now is 01:01 AM.

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