PDA

View Full Version : Racial attribute bonus


royalfa
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

<!-- 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

<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.

Mathias
January 6th, 2012, 08:19 PM
Add

perform

before each of your #traitmodify[] lines.


perform #traitmodify[attrStr,trtRacial,field[racStr].value,""]


(I also noticed that you're modifying a different field on Str than on any other attribute).

royalfa
January 7th, 2012, 09:41 PM
I was doing the testing with perform and a new error was pop up.

(I was "testing" if the trtRacial was the trouble but it wasn't that's why Str has trtBonus instead)

Finally it works. The definition file in the game system don't have this macro defined
(I think this was by default of the program) moreover I kind of intuit that this was the problem but yesterday don't find where this macro is defined.

Thanks again Mathias.

I will test this feature and try to add movement (only for race) and saving throws now.