I recommend using widgets to cut down on repeated code. That's 90% of the answer you're probably looking for. All following examples will do so, and the widgets are used like so:
<<addAggression (number)>>
E.g.
<<addAgression 4>>
/% adds 4 to aggression. if berserker trait is chosen, adds 8 %/
There's a few approaches you could try. Here's some of them. You could:
/% in StoryInit, set $aggressionMod to 1; when the perk is selected increase the mod to 2 %/
<<widget "addAggression">>\
<<silently>>
<<set _increase to $args[0] * $aggressionMod>>
<<set $pc.aggression += _increase>>
<</silently>>\
<</widget>>
- Use the ternary operator (?). Works like an if/else.
<<widget "addAggression">>\
<<silently>>
<<set _increase to ($pcTraits.includes("berserker")) ? ($args[0] * 2) : $args[0]>>
<<set $pc.aggression += _increase>>
<</silently>>\
<</widget>>
Note the use of "includes" instead of "contains". Contains is deprecated.
- Use <<if>> macros as you have been, but use widgets as shown above.
<<widget "addAggression">>\
<<silently>>
<<set _increase to $args[0]>>
<<if $pcTraits.includes("berserker")>>
<<set _increase *= 2>>
<</if>>
<<set $pc.aggression += _increase>>
<</silently>>\
<</widget>>
They all work fine, which one you use will likely depend on preference.