--- /dev/null
+# Gameplay rules
+
+This is the rulebook for all the rpg elements
+
+## Dice
+
+The game rolls 16-sided (d16) dice to decide what happens.
+The outcome of all mechanics is decided by one or more dice rolls.
+
+## Turns
+
+Each unit can move until all of its moves are used up.
+When all moves are used control is handed over to the next unit.
+
+## Initiative
+
+When a unit ends its turn the unit with the next highest initiative is picked.
+A unit may fail to take initiative if a d16 roll fails (initiative < d16). In such a case another unit may be chosen.
+
+If all units fail to take initiative or have used all their moves all moves are reset and the process is restarted.
+ ; updates a unit's status effects
+ ; inputs:
+ ; de: unit
+effects_unit_update:
+ ret
+
+ ; adds a new effect to a unit
+ ; if no effect slot is available
+ ; the new effect is dropped
+ ; inputs:
+ ; de: unit
+ ; a: effect type
+ ; b: effect dat
+effect_add:
+ ret
+
+ ; updates a single status effect
+ ; inputs:
+ ; de: unit
+ ; hl: effect
+effect_update:
+ ret
; finds a unit with a higher initiative value
; than the current one that has moves > 0 set
- ; if all unts have have 0 moves, set moves to
+ ; if all unts have have 0 moves, set moves to
; initial value and try again
+ ; when a unit has higher initiative it can still fail
+ ; to take the turn if it rolls a d16 and the roll is < initiative
; skips any ACT_T_NULL types
; inputs:
; gameplay_unit_current: unit that requested a change
; otherwise store new init value and hl
pop hl
push hl
+
+ ; this unit is better
+ ; but it can fail an initiative roll
+ push af
+ call roll_d16
+ ld d, a ; d = roll value
+ pop af ; a = init value
+ cp a, d
+ jr nc, @skip REL ; d < a
+
ld [unit_next_best_init], a
ld a, l
unit_demo_3:
st_def 0x00, unit_demo_1_init, st_unit_idle
act_def ACT_T_DEMO_1, 0, 4, 4, 0
- act_stat_def 1, 2, 3, 0, 0, 0, 0, 5
+ act_stat_def 1, 2, 3, 0, 0, 0, 4, 5
act_inventory_empty
act_equipment_empty
act_effects_empty