Laser_sight_check: ; BC = XY of the enemy. D = direction (must be unchanged). Direction to face in E (or 0 if not) LD E, $00 LD A, L AND $f0 ADD $09 LD L, A LD A, $00 CP (HL) RET Z ; straight line + distance <= 4 LD A, $mem_bunny_predicted_x CP B JR Z, =.vertical_distance_check LD A, $mem_bunny_predicted_y CP C RET NZ .horizontal_distance_check: LD A, $mem_bunny_predicted_x CP B JR C, =.left .right: SUB $05 CP B RET NC LD E, $enum_direction_right RET .left: ADD $04 CP B RET C LD E, $enum_direction_left RET .vertical_distance_check: LD A, $mem_bunny_predicted_y CP C JR C, =.up .down: SUB $05 CP C RET NC LD E, $enum_direction_down RET .up: ADD $04 CP C RET C LD E, $enum_direction_up RET Laser_Prepare_Attack: LD A, D AND $f0 SWAP A LD D, A LD A, E DEC A DEC D XOR D INC D CP $00 JR Z, =.attack BIT 1, A JR NZ, =.attack LD D, E LD A, D SWAP A AND $70 OR D LD D, A RET .attack: LD A, E SWAP A AND $70 OR E LD D, A LD A, L AND $f0 ADD $07 LD L, A SET 2, (HL) RET Apply_Prepared_Laser_Enemy_Attack: ; Entity (whatever alignment) in HL Direction to face in E. Result in BC (XY), Direction in D LD A, $mem_moving_animation_step CP $0f RET NZ LD A, L AND $f0 ADD $07 LD L, A BIT 2, (HL) RES 2, (HL) RET Z CALL =Laser_sight_check LD A, D AND $70 SWAP A CP E RET NZ PUSH DE PUSH BC LD A, E DEC A AND $03 SWAP A SLA A SLA A OR $03 ; Laser_Animation LD D, A LD A, C ADD B LD B, A LD A, $mem_bunny_x LD C, A LD A, $mem_bunny_y ADD C SUB B .ABS SWAP A LD E, A POP BC LD A, D LD D, $10 CALL =Try_Launch_Animation .SET_SOUND_EFFECT =_sound_effect_Laser LD A, $enum_animation_wait_mode LD $mem_requested_mode, A LD $mem_current_mode, A CALL =Update_VBlank_Handler LD A, E SUB $f LD E, A LD A, $mem_animation_wait_frames CP E JR NC, =.skip_animation_wait_frames_update LD A, E LD $mem_animation_wait_frames, A .skip_animation_wait_frames_update: LD A, $mem_animation_wait_frames POP DE LD A, $mem_bunny_health SUB $01 JR C, =.health_underflow_fix DAA LD $mem_bunny_health, A JR =.Skip_health_underflow_fix .health_underflow_fix: LD A, $00 LD $mem_bunny_health, A .Skip_health_underflow_fix: ; Mana LD A, L AND $f0 ADD $09 LD L, A DEC (HL) RET