From: Lukas Krickl Date: Thu, 21 Aug 2025 17:17:15 +0000 (+0200) Subject: action: Added basic attack effect X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=98a7c406c5176060a37fef51292f839bfc294ea6;p=gbrg%2F.git action: Added basic attack effect For now it simply deletes the hit actor --- diff --git a/src/action.s b/src/action.s index 5634416..d8a9c8c 100644 --- a/src/action.s +++ b/src/action.s @@ -120,18 +120,16 @@ unit_action_pick_direction: ; should contain next state pop bc ret - - ; performs an attack - ; based on the units rt_action tmp value - ; inputs: - ; de: unit + + ; get the attack location + ; input: + ; de: actor ; returns: - ; bc: next action -unit_action_attack: - push de + ; bc: tile position +unit_attack_get_attack_tile: ; get location call unit_get_pos - + ld hl, act_rt_action_dat1 add hl, de ; hl = dat1 @@ -156,6 +154,18 @@ unit_action_attack: jr nz, @not_right REL inc c ; x++ @not_right: + ret + + ; performs an attack + ; based on the units rt_action tmp value + ; inputs: + ; de: unit + ; returns: + ; bc: next action +unit_action_attack: + push de + + call unit_attack_get_attack_tile ; draw a slash animation at that location @@ -202,8 +212,30 @@ unit_action_attack: @done: ; set animation timer and delay - ld bc, st_unit_delay_to_active_template + ld bc, st_action_attack_damage_actor ret + + ; performs damage calculations based on the attacked location + ; inputs: + ; de: unit + ; returns: + ; bc: new state +unit_action_attack_damage_calc: + ; TODO: do real damage calculation here + ; for now just delete the actor + + call unit_attack_get_attack_tile + call unit_find_at + + ; set type to NULL + ld de, act_type + add hl, de + ld a, ACT_T_NULL + ld [hl], a + + ldnull bc + ret + ; default attack state st_action_attack_init: @@ -212,3 +244,5 @@ st_action_attack_pick_direction: st_def 0x00, unit_action_attack_pick_direction, st_action_attack_pick_direction st_action_attack_direction_picked: 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_unit_delay_to_active_template