Characters - ThePix/rpg_web GitHub Wiki
A character is set up in the data.js file as a member of an array of the type Char
. The Char
constructor takes a dictionary, and it is here that you will set everything specific to that character.
Here is a simple example, where the character is given a name and a single attack (with skill of +2). Everything else is set to the defaults.
new Char({name:"Goblin", attacks:[
new WeaponAttack("Unarmed", 3),
]}),
To see how this can be expanded, here is a more complicated example. The "hits" and "init" have been expliocitly set, the character is flagged as being a player-character. He has also been given a second attack, a silver broad sword (attacks are discussed further elsewhere.
new Char({name:"Kyle", hits:35, init:3, pc:true, attacks:[
new WeaponAttack("Broad sword", 2, {special:'silver', desc:'The silver sword of Al-Garith'),
new WeaponAttack("Unarmed", 2),
]}),
String values
name A string that must be unique to this character.
display A string; this is what seen on the screen as the character's name. The "name" will be used if absent.
link Some more powerful foes may get to act more than once per turn. To allow that, create additional characters, and give them a "link" attribute set to the name of the original. Give it an "init", a "name" (not the same as the original; must be unique) and a "display" value (probably should be the same as the original). During played these linked characters cannot be targeted.
Integer values
hits The current number of hit points (defaults to 20)
maxHits The maximum number of hit points (defaults to "hits"); only worth setting for characters that start combat already injured.
shield The shield bonus (defaults to 0)
armour The armour bonus (defaults to 0)
will The will bonus (defaults to 0)
reflex The reflexbonus (defaults to 0)
stamina The stamina bonus (defaults to 0)
init The init bonus (defaults to 0)
size The size (defaults to 3, set to 2 for a character that fits a quarter of a square, to 4 for a character that takes up 4 squares)
Boolean values
pc Set to true for player characters.
Function values
onDone25(), onBlooded(), onDone75(), onDeath() These all potentially trigger when a character has lost a proportion of her hit points; 25, 50, 75 and 100% respectively. If the function exists, when it triggers an alert is set on this character to warn the GM. The function can add further alerts or modify the character or whatever.
Note that if a single attack reduces the hits through two stages only the last function will trigger. If a character has twenty hits, and takes 17 damage, only "onDone75" will trigger, assuming all four are set. If only "onBlooded" is set, then that will trigger, as it will be the last. "onDone25" and "onDone75" should really only be set for foes with huge numbers of hits.
Each function will only ever trigger once per character; if a character goes below 50% and triggers the "onBlooded" function, and is subsequently healed, the function is not triggered if she drops below 50% a second time. It is therefore best not to have an "onDeath" function for any character that might be revived.
applyDamage(hits, s, attack, result) You can over-ride this for ultimate control of what happens when a character takes damage.
Array values
ignoreAttackTypes An array of attack types that are ignored by this character (defaults to none). Mundane, non-magical attacks should be indicated by false
, other attacks by the "special" name, typically "silver", "ice", "fire", "shock", "nether" or "mind". here is an example of a ghost that ignores non-magical attacks.
new Char({name:"Ghost", hits:35, init:4, ignoreAttackTypes:[false, 'silver'], attacks:[
new WeaponAttack("Unarmed", 2),
]}),