Initial Context: Pick Alternate Context: None Fields Finalized? No
The NewTurn script utilizes the following special symbols:
initiative Entry: The value zero.
Exit: Calculated initiative value to use for the actor.
secondary Entry: The value zero.
Exit: Calculated secondary initiative value (i.e. tie-breaker) to use for the actor.
The Initiative script is used to generate appropriate initiative values for each actor. It is invoked whenever a new initiative value is needed, as determined by the configuration settings in the definition file.
There are two separate initiative values that must be generated. The first is the standard initiative value used for the game system. Once it is calculated, it should be assigned to the "initiative" special symbol. The second initiative value is the tie-breaker to be used if the two actors have the exact same primary initiative score. For example, in the d20 System, the dexterity bonus is used as a tie-breaker. This value should be assigned to the "secondary" special symbol.
When invoked, the Initiative script starts with the "actor" pick of an actor in the combat as its initial context. From there, you can access whatever facets of the character are necessary to properly calculate the initiative scores.
In the d20 System, the initiative score is a d20 roll plus the initiative bonus, while the dexterity bonus is used as the tie-breaker. This yields a script that looks like the following.
~Initiative is a d20 roll (0 to 19 + 1) plus initiative bonus @initiative = random(20) + 1 + hero.child[trInit].field[trtFinal].value ~Tie-breaker is the dexterity bonus @secondary = hero.child[attrDex].field[trtFinal].value