View Single Post
royalfa
Member
 
Join Date: Feb 2011
Posts: 37

Old January 6th, 2012, 07:31 PM
I need to set a racial bonus for every race in the game, some are fixed some are chosen by the user.

I navigate in the 4e source files and find a "macro" to do this.

Here is my Race component in components.core

Code:
<!-- Race component
        Each race derives from this component
  -->
  <component
    id="Race"
    name="Race"
    autocompset="no">
	
    <field
      id="racStr"
      name="Strength Bonus"
      type="static">
      </field>
    <field
      id="racDex"
      name="Dexterity Bonus"
      type="static">
      </field>
    <field
      id="racCon"
      name="Constitution Bonus"
      type="static">
      </field>
    <field
      id="racInt"
      name="Intelligence Bonus"
      type="static">
      </field>
    <field
      id="racWis"
      name="Wisdom Bonus"
      type="static">
      </field>
    <field
      id="racCha"
      name="Charisma Bonus"
      type="static">
      </field>

    <!-- Each race needs its own identity tag to configure the hero appropriately -->
    <identity group="Race"/>
	
	<!-- Also a tag to use to note that certain things (e.g. feats) require
        certain races -->
    <identity group="ReqRace"/>

    <!-- Track the race on the actor by assigning the appropriate tag -->
    <eval index="1" phase="Setup" priority="5000"><![CDATA[
      perform forward[Race.?]
	  
	  ~ Add appropriate bonuses
      #traitmodify[attrStr,trtBonus,field[racStr].value,""]
      #traitmodify[attrDex,trtRacial,field[racDex].value,""]
      #traitmodify[attrCon,trtRacial,field[racCon].value,""]
      #traitmodify[attrInt,trtRacial,field[racInt].value,""]
      #traitmodify[attrWis,trtRacial,field[racWis].value,""]
      #traitmodify[attrCha,trtRacial,field[racCha].value,""]
	  
      ]]></eval>

    </component>
I add the six racXXX fields and the macros then I change the code in traits.str adding this field

Code:
<field
      id="trtRacial"
      name="Racial Bonus"
      type="derived"
      history="best"
      maxfinal="25">
      <finalize><![CDATA[
        if (@value = 0) then
          @text = "-"
          done
          endif
        @text = signed(@value)
        ]]></finalize>
      </field>
In the trait componet.

At the end I add this: + field[trtRacial].value

to the trtFinal and trtDerived fields evals.

When run the game this message pop up:

syntax error in "eval" script for component "Race" (Eval script '#1') on line 5
->unspecified error parsing script.

Don't know what I'm doing wrong.

PS: I modify the editor accordingly to capture the race bonus.
royalfa is offline   #1 Reply With Quote