• 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

Getting value of second item selection

udalrich

Member
I am trying to implement a dual skill focus feat, which is like skill focus except that the user selects two feats and gets +2/+4 for each.

I've looked through the wiki, and I am sure the answer is there, but I cannot find it.

I've copied Skill Focus, and added a second item selection. The script will add +2 to the first skill, but I cannot figure out how to select the second skill.

I start with

Code:
      ~ If we're disabled, do nothing
      doneif (tagis[Helper.FtDisable] <> 0)

      ~set our focus to the selected pick
      call fTargetFoc
      doneif (state.isfocus = 0)

This appears to set focus so that if references the values for the first item. I could not find any documentation for fTargetFoc. At this point, the rest of the skill focus script (with 3 replaced with 2) works to modify the first skill. However, I cannot figure out how to access the second skill. Call fTargetFoc a second time does not seem to advance to the next skill. It also looks like fTargetFoc is defined as bytecode or something similar, so looking at the definition in the source file is not useful.

Here's my current version from the .user file.

Code:
  <thing id="fDualSkill" name="Dual Skill Focus" description="Choose two skills. You are particularly adept at those skills.\n\n{b}Benefit{/b}: You get a +2 bonus on all checks involving the chosen skill. If you have 10 or more ranks in that skill, this bonus increases to +4.\n\n{b}Special{/b}: You can gain this feat multiple times. Its effects do not stack. Each time you take the feat, it applies to a new pair of skills.  It does not stack with other feats that grant +2 to two skills.  It {i}does{/i} stack with Skill Focus." compset="Feat" summary="You get a +2 bonus on all checks  involving two skills.">
    <fieldval field="usrCandid1" value="baseSkill1"/>
    <fieldval field="usrCandid2" value="baseSkill2"/>
    <tag group="fShowWhat" tag="Skills"/>
    <tag group="fShowWhat2" tag="Skills"/>
    <tag group="ChooseSrc1" tag="Hero" name="All Picks on Hero" abbrev="All Picks on Hero"/>
    <tag group="ChooseSrc2" tag="Hero"/>
    <tag group="fCategory" tag="Custom"/>
    <tag group="fCategory" tag="General"/>
    <tag group="SpecType" tag="Skill"/>
    <eval phase="PreLevel" priority="5000" name="Skill Bonus Feats"><![CDATA[
      ~ If we're disabled, do nothing
      doneif (tagis[Helper.FtDisable] <> 0)

      ~set our focus to the selected pick
      call fTargetFoc
      doneif (state.isfocus = 0)

      ~ Add 2 to our chosen skill
      focus.field[Bonus].value += 2
      field[baseSkill2].value += 2

      ~and another two once we're at 10 ranks
      if (focus.field[skUser].value + focus.field[skInnate].value >= 10) then
        focus.field[Bonus].value += 2
        endif

      ~ Assign a tag so we know we've taken skill focus
      perform focus.assign[Helper.DualSkillFocus]

      ~ Set our 'short name'
      field[shortname].text = "Dual Focus: " & focus.field[name].text]]></eval>
    </thing>

It also seems strange that customSrc2 is missing name and abbrev attributes, even though I set the two items to have the same "Restrict X List To..." values in the editor.
 
Try looking at some of the traits that select a skill and add a bonus to it - the fTargetFoc procedure is rather obsolete, so things created more recently don't use it.
 
I eventually got something that works. It's shown below, in case somebody else is trying to do the same thing in the future.

I did have some more related questions.

The script for skill focus also references focus.field[skInnate].value in addition to skUser. I couldn't find any documentation about that, but I'm guessing it's some sort of racial ranks in a skill. Do I need to be including that as well?

The #applybonus macro seems to work with focus, but #skillranks did not. Is there a general principle about what macros can or cannot use focus?

I thought that Bonus was an untyped bonus and should stack with itself. However, if I apply a bonus of 2 twice when there are more than 10 ranks, I only get a net +2 bonus. Is that how it is supposed to work?


Code:
      ~ If we're disabled, do nothing
      doneif (tagis[Helper.FtDisable] <> 0)

      if (field[usrChosen1].ischosen <> 0) then
        perform field[usrChosen1].chosen.setfocus

        ~ Add 2 to our chosen skill
        #applybonus[Bonus, focus, 2]

        ~and another two once we're at 10 ranks
        if (focus.field[skUser].value >= 10) then
          #applybonus[Bonus, focus, 4]
        endif
      endif

      ~ repeat it all with the second skill
      doneif (field[usrChosen2].ischosen = 0)

      perform field[usrChosen2].chosen.setfocus

      ~ Add 2 to our chosen skill
      #applybonus[Bonus, focus, 2]

      ~and another two once we're at 10 ranks
      if (focus.field[skUser].value >= 10) then
        #applybonus[Bonus, focus, 4]
      endif
 
skInnate is how a monstrous race gets its pre-assigned skill points, so I would recommend adding skInnate to skUser every time you reference skUser.

The #applybonus[Bonus,focus,4] macro is converted by the compiler into:

Code:
focus.field[Bonus].value = maximum(focus.field[Bonus].value, 4)
#skillbonus[] += 4 is converted into:

Code:
hero.child[focus].field[Bonus].value += 4
So that's why focus isn't working in #skillbonus, and why when you apply the bonus with #applybonus, it becomes a non-stacking bonus.

Instead, you can simply use:

Code:
focus.field[Bonus].value += 4
 
Back
Top