; sets the RF_ACTOR flag at target_y/x
; unsets RF_ACTOR at [bc] and [bc+1]
; preserves registers
-actor_tile_update_flag:
+actor_tile_update_rf_flags:
push_all
; first unset existing flags
+ ; add +8 to positions to center on tile
+
inc bc ; bc = y pos
ld a, [bc]
+ sub a, ANIM_MOVE_TILE_SIZE / 2 ; -8 to be in center
ld d, a ; d = y pos
inc bc ; bc = x pos
ld a, [bc]
+ sub a, ANIM_MOVE_TILE_SIZE / 2 ; -8 to be in center
ld e, a ; e = x pos
call room_get_flag_ptr
; then set the new position's flag
ld a, [anim_target_y]
+ sub a, ANIM_MOVE_TILE_SIZE / 2 ; -8 to be in center
ld d, a ; d = y pos
ld a, [anim_target_x]
+ sub a, ANIM_MOVE_TILE_SIZE / 2 ; -8 to be in center
ld e, a ; e = x pos
call room_get_flag_ptr
; check anim collision
call actor_anim_verify
; set flags on z
- call z, actor_tile_update_flag
+ call z, actor_tile_update_rf_flags
turn_finish
@no_door_hit:
+
+ ld a, h ; restore original a for next check
+ and a, RF_ACTOR
+ jr z, @no_enemy_hit REL
+
+ ; TODO add enemy hit logic
+
+@no_enemy_hit:
+
ld a, h ; restore original a for next check
- and a, RF_WALL
+ and a, RF_WALL | RF_ACTOR
pop hl
jr z, @no_collision REL
; clear anim memory
call anim_clear
@no_collision:
+
@skip_input:
; hl should be player_y here