From: Lukas Krickl Date: Fri, 15 Aug 2025 07:08:23 +0000 (+0200) Subject: unit: Added stubs for attack state X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=d3cc3b5a40462a1b1b1adcff028691f65efe21fd;p=gbrg%2F.git unit: Added stubs for attack state --- diff --git a/src/player.s b/src/player.s index 92a10b5..cb13334 100644 --- a/src/player.s +++ b/src/player.s @@ -264,6 +264,15 @@ map_exit_relative_adjust: pop_all ret + + ; player attack state + ; inputs: + ; de: actor + ; returns: + ; bc: next state +unit_player_attack: + ldnull bc + ret #define player_draw unit_draw @@ -272,8 +281,11 @@ unit_player: act_def ACT_T_DEMO_1, 0, 2, 2, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 90, 1 - act_st_def NULL, NULL, st_unit_player_update, st_unit_idle + act_st_def st_unit_player_attack, NULL, st_unit_player_update, st_unit_idle act_def_meta player_draw, 0x8C, OAM_FPRIO, NULL st_unit_player_update: st_def 0x00, unit_player_update, st_unit_player_update + +st_unit_player_attack: + st_def 0x00, unit_player_attack, st_unit_player_attack diff --git a/src/unit.s b/src/unit.s index d3b8f48..3cf0112 100644 --- a/src/unit.s +++ b/src/unit.s @@ -658,6 +658,8 @@ unit_scroll_center: ; switches a unit to active state ; inputs: ; de: unit + ; returns: + ; bc: new state unit_switch_to_active: push de ld hl, act_rt_sub_tile @@ -675,6 +677,33 @@ unit_switch_to_active: ; bc = next active state ret + + ; switches a unit to attack state + ; inputs: + ; de: unit + ; returns: + ; bc: new state +unit_switch_to_attack: + ld hl, act_st_attack + add hl, de + ld a, [hl+] + ld c, a + ld a, [hl+] + ld b, a + ret + + ; forces the unit to enter attack state + ; inputs: + ; de: unit +unit_switch_to_attack_enter_combat: + push de + call unit_switch_to_attack + push bc ; de = new state + pop hl ; unit ptr (st header) + ld bc, st_size + call memcpy + + ret ; forces a unit into an active state ; inputs: @@ -694,6 +723,8 @@ unit_wake_up: ; sets moves to 0 ; inputs: ; de: unit + ; returns: + ; bc: new state unit_switch_to_idle: ld hl, act_st_idle add hl, de ; hl = st_idle ptr diff --git a/src/unit_cpu.s b/src/unit_cpu.s index f743617..88ee052 100644 --- a/src/unit_cpu.s +++ b/src/unit_cpu.s @@ -117,3 +117,11 @@ unit_cpu_random_move: ret + ; attack state for demo units + ; inputs: + ; de: actor ptr + ; returns: + ; bc: next state +unit_demo_1_cpu_update_attack: + ldnull bc + ret diff --git a/src/unit_demo.s b/src/unit_demo.s index e203d7e..95c0678 100644 --- a/src/unit_demo.s +++ b/src/unit_demo.s @@ -20,7 +20,7 @@ unit_demo_2: act_def ACT_T_DEMO_1, 0, 3, 3, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 32, 1 - act_st_def NULL, NULL, st_unit_demo_1_cpu_update_idle, st_unit_idle + act_st_def st_unit_demo_1_cpu_update_attack, NULL, st_unit_demo_1_cpu_update_idle, st_unit_idle act_def_meta unit_draw, 0x88, OAM_FPRIO, NULL unit_demo_warrior: @@ -28,7 +28,7 @@ unit_demo_warrior: act_def ACT_T_DEMO_1, 0, 9, 9, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 32, 1 - act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle + act_st_def st_unit_demo_1_cpu_update_attack, NULL, st_unit_demo_1_cpu_update, st_unit_idle act_def_meta unit_draw, 0x88, OAM_FPRIO, NULL unit_demo_mage: @@ -36,7 +36,7 @@ unit_demo_mage: act_def ACT_T_DEMO_1, 0, 9, 9, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 32, 1 - act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle + act_st_def st_unit_demo_1_cpu_update_attack, NULL, st_unit_demo_1_cpu_update, st_unit_idle act_def_meta unit_draw, 0x8C, OAM_FPRIO, NULL unit_demo_thief: @@ -44,7 +44,7 @@ unit_demo_thief: act_def ACT_T_DEMO_1, 0, 9, 9, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 32, 1 - act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle + act_st_def st_unit_demo_1_cpu_update_attack, NULL, st_unit_demo_1_cpu_update, st_unit_idle act_def_meta unit_draw, 0x90, OAM_FPRIO, NULL @@ -53,7 +53,7 @@ unit_demo_priest: act_def ACT_T_DEMO_1, 0, 9, 9, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 32, 1 - act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle + act_st_def st_unit_demo_1_cpu_update_attack, NULL, st_unit_demo_1_cpu_update, st_unit_idle act_def_meta unit_draw, 0x94, OAM_FPRIO, NULL @@ -62,3 +62,6 @@ st_unit_demo_1_cpu_update: st_unit_demo_1_cpu_update_idle: st_def 0x00, unit_demo_1_cpu_update_idle, st_unit_demo_1_cpu_update_idle + +st_unit_demo_1_cpu_update_attack: + st_def 0x00, unit_demo_1_cpu_update_attack, st_unit_demo_1_cpu_update_attack