User Tools

Site Tools


damage_logic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
damage_logic [2025/04/21 19:49] justindamage_logic [2025/04/22 13:45] (current) justin
Line 1: Line 1:
 ======Damage Logic====== ======Damage Logic======
 ---- ----
-In RPG in a Box, any time one [[character]] attacks another, a calculation is done to determine how much damage is applied to the [[character]] being attacked. If you'd like to customize this logic for your game, you can do so by creating a [[script]] named "damage_logic" in your project. The name must be exact, including case. The [[script]] should return a [[number|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_editor|stats]] or [[set_entity_property|properties]] of those characters. The **$weapon** variable will be the [[item]] [[codex]] of the attacking character's [[weapons|weapon]], or null if no [[weapons|weapon]] is equipped.+In RPG in a Box, any time one [[character]] attacks another, a calculation is done to determine how much damage is done to the [[character]] being attacked. If you'd like to customize this logic for your game, you can do so by creating a [[script]] named "damage_logic" in your project. The name must be exact, including case. The [[script]] should return a [[number|numeric value]], which will be used for the damage amount applied to the defending [[character]]. The **$attacker** and **$defender** variables  will be the attacking [[character]] and defending [[character]], respectively, so you can use these to check various [[stats_editor|stats]] or [[set_entity_property|properties]] of those characters. The **$weapon** variable will be the [[item]] [[codex]] of the attacking character's [[weapons|weapon]], or null if no [[weapons|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.+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 [[number|numeric value]].
 <code bauxite> <code bauxite>
 $diff = $attacker.stat["attack"] - $defender.stat["defense"]; $diff = $attacker.stat["attack"] - $defender.stat["defense"];
damage_logic.1745290175.txt.gz · Last modified: 2025/04/21 19:49 by justin