View Single Post
Duggan
Senior Member
Volunteer Data File Contributor
 
Join Date: Nov 2009
Posts: 1,502

Old September 13th, 2017, 07:06 PM
So, I'm working on a more flexible way to set up the skill bonuses and penalties for the various backgrounds. This is what I've wound up with so far:

thing_miscellanous.dat (The names aren't great, I know, but fRPlusSk gives the person who picked that background a set of choices from which they pick one to apply the bonus or penalty to. fRPlusSk2 applies the same bonus or penalty to a bunch of skills that fit the list)
Code:
  <thing
    id="fRPlusSk"
    name="Skill Bonus"
    compset="cmpsetSB"
    description="Gives a bonus to the selected skill.">
    <fieldval field="usrCandid1" value="component.Skill"/>
    <tag group="Hide" tag="Special"/>
    <eval index="1" phase="PreTraits" priority="4900">
      <before name="Calc trtFinal"/><![CDATA[
      var bonus as number
      var penalty as number
      bonus = tagvalue[Bonus.?]
      penalty = tagvalue[Penalty.?]
      if (bonus = 0) then
        if (penalty = 0) then
          bonus = 2
        else
          bonus = penalty
        endif
      endif
      
      if (bonus > 0) then
        field[livename].text = "+" & bonus & " " & livename
      else
        field[livename].text = bonus & " " & livename
      endif
      
      ~build the candidate expression out of our Skill and Skills tags
      var skills as string
      skills = tagids[Skill.?, " | "]
      var skilltypes as string
      skilltypes = tagids[Skills.?, " | "]

      var combined as string
      if (tagis[Skills.?] <> 0) then
        if (tagis[Skill.?] <> 0) then
          combined = skills & " | " & skilltypes
        else
          combined = skilltypes
        endif
      else
        combined = skills
      endif
      
      ~ debug combined & ", " & empty(combined)
      if (empty(combined) = 0) then
        field[usrCandid1].text &= " & (" & combined & ")"
      endif
        
      perform field[usrChosen1].chosen.field[trtBG].modify[+,bonus,"Background"]
      ]]></eval>
    </thing>
        
  <thing
    id="fRPlusSk2"
    name="Multiple Skill Bonuses"
    compset="cmpsetSB"
    description="Gives a bonus to the selected skills.">
    <tag group="Hide" tag="Special"/>
    <eval index="1" phase="PreTraits" priority="4900">
      <before name="Calc trtFinal"/><![CDATA[
      var bonus as number
      var penalty as number
      bonus = tagvalue[Bonus.?]
      penalty = tagvalue[Penalty.?]
      if (bonus = 0) then
        if (penalty = 0) then
          bonus = 2
        endif
      endif
      
      field[usrCandid1].text = ""
      
      ~build the candidate expression out of our Skill and Skills tags
      var skills as string
      skills = tagids[Skill.?, " | "]
      var skilltypes as string
      skilltypes = tagids[Skills.?, " | "]

      if (bonus > 0) then
        field[livename].text = "+" & bonus & " to Multiple"
        
        foreach pick in hero from Skill where skills
          perform eachpick.field[trtBG].modify[+,bonus,"Background"]
        nexteach
      
        foreach pick in hero from Skill where skilltypes
          perform eachpick.field[trtBG].modify[+,bonus,"Background"]
        nexteach
      elseif (penalty > 0) then
        field[livename].text = "-" & penalty & " to Multiple"
        
        
        foreach pick in hero from Skill where skills
          perform eachpick.field[trtBonus].modify[-,penalty,"Background"]
        nexteach
      
        foreach pick in hero from Skill where skilltypes
          perform eachpick.field[trtBonus].modify[-,penalty,"Background"]
        nexteach
      endif
      
      ]]></eval>
    </thing>
Here's an example of applying it from thing_races.dat involving a (made up for this example) race which gets a +2 to Athletics and Perception, takes a -1 to Social skills, and can get a +3 to any one Mental skill, or Carbines:

Code:
    <bootstrap thing="fRPlusSk2">
      <autotag group="Skill" tag="skPercept"/>
      <autotag group="Skill" tag="skAthlete"/>
      <autotag group="Bonus" tag="Plus2"/>
      </bootstrap>
    
    <bootstrap thing="fRPlusSk2">
      <autotag group="Skills" tag="Social"/>
      <autotag group="Penalty" tag="Minus1"/>
      </bootstrap>
    
    <bootstrap thing="fRPlusSk">
      <autotag group="Skills" tag="Mental"/>
      <autotag group="Skill" tag="skCarbine"/>
      <autotag group="Bonus" tag="Plus3"/>
      </bootstrap>
That produces three SkillBonus picks which I can display in a table. I have code in the pick to suppress the dropdown menu if there is no choice (aka fRPlusSk), but I'm not certain how to display what the bonus applies to. This is what it currently does:


I'm not certain if it would make more sense to modify the text to list the items (say, "-1 Skill Penalty (Social and Carbine)" and "+2 Skill Bonus (Perception and Athletics)") or if it would be possible to make it add one for each distinct entry, so that I have 5 entries:
"+2 Skill Bonus (Perception)", "+2 Skill Bonus (Athletics)", "+3 Skill Bonus [Experimental Sciences]", "-1 Skill Penalty (Social)", and "-1 Skill Penalty (Carbines)". Or, if the latter is even feasible.
Attached Images
File Type: png Skill Bonuses.png (51.1 KB, 45 views)
Duggan is offline   #1 Reply With Quote