For now this action always heals the player for 1 and skips the turn.
call ui_request_redraw
ldnull bc
ret
-
+
+ ; rests for a turn healing the unit
+ ; and skipping the turn
+ ; inputs:
+ ; de: actor
+unit_action_rest:
+ ld a, 1
+ call stat_heal_by
+ call ui_redraw_player
+ call ui_request_redraw
+ ldnull bc
+ ret
; default attack state
st_action_attack_init:
st_def 0x00, unit_action_attack, st_action_attack_direction_picked
st_action_attack_damage_actor:
st_def 0x00, unit_action_attack_damage_calc, st_action_attack_direction_picked
+
+ ; rest action skips a turn
+st_action_rest:
+ st_def 0x00, unit_action_rest, st_unit_delay_to_active_template
action_menu_action_table:
dw st_action_attack_init
dw st_action_attack_init
- dw st_action_attack_init
+ dw st_action_rest
action_menu_action_table_end:
#define ACTION_MENU_STR_TABLE_LEN (action_menu_str_table_end - action_menu_str_table) / 2
ld [hl], a ; write 0 hp
ld a, b ; a = damage dealt
ret
+
+ ; heals the actor by N
+ ; does not overheal
+ ; inputs:
+ ; de: actor
+ ; a: amount
+stat_heal_by:
+ ld b, a ; b = amount to heal by
+ ld hl, act_hp
+ add hl, de
+ ld a, [hl] ; a = current hp
+ add a, b ; a = new hp
+
+ push hl
+ push af
+ call stat_calc_hp_max
+ ld b, a ; b = max hp
+ pop af
+ pop hl
+
+ cp a, b
+ ; a > b? (max > new value)
+ jr nc, @overheal REL
+ ld [hl], a ; write new value
+ ret
+@overheal:
+ ; set to max
+ ld a, b
+ ld [hl], a ; write max into hp
+ ret
; calculates the real speed state
; inputs: