— — — — —
— — — — —
— — — — —
— — — — —
— — — — —
— — — — —
— — — — —
— — — — —
This is an old revision of the document!
If you'd like customize the damage logic for your game, create a script named “damage_logic” in your project. The name must be exact, including case. The script should return a numeric value, which will be used for the damage amount when one character attacks another. The $attacker and $defender variables will be the attacking character and defending character, respectively, so you can use these to check various stats or properties of those characters. The $weapon variable will be the item codex of the attacking character's weapon, or null if no weapon is equipped.
Below is the Bauxite code for the default damage logic. You can take this and customize it as desired, or create your own logic from scratch! The only requirement is that the script returns a numeric value.
$diff = $attacker.stat["attack"] - $defender.stat["defense"]; if $diff <= 0 then $damage = random(0, 1); elseif $weapon == null then $damage = $diff + random(-1, 1); else $damage = $diff + random(-1, 1) + random($weapon.min_damage, $weapon.max_damage); end; if $damage < 0 then $damage = 0; end; return $damage;
The default damage logic is loosely based on that of Shining Force, and is subject to change in future releases of RPG in a Box.