ootw: c2: can now shoot friend (if going right)

This commit is contained in:
Vince Weaver 2019-08-20 13:49:27 -04:00
parent c216195c8e
commit 12c5b1921c
6 changed files with 128 additions and 15 deletions

View File

@ -96,7 +96,7 @@ done_recalc_walk_right_collision:
;=============================
;=============================
; far right limit is LEVEL_RIGHT
; any LOCKED or CLOSED doors stop things
; any LOCKED or CLOSED doors with SAME_Y to left of LEVEL_RIGHT
; any shield stops things
; our friend stops things
; any enemies stop things
@ -106,6 +106,9 @@ calc_gun_right_collision:
lda #$00
sta RIGHT_SHOOT_TARGET
;=====================================================================
; by default set it to left limit (which is often but not always a wall)
lda RIGHT_LIMIT
and #$7f
sta RIGHT_SHOOT_LIMIT
@ -123,8 +126,14 @@ calc_gun_right_doors:
ldy #0
calc_gun_right_door_loop:
lda PHYSICIST_X
; only if on same level
lda (DOOR_Y),Y
clc
adc #4
cmp PHYSICIST_Y
bne calc_gun_right_door_continue
lda PHYSICIST_X
cmp (DOOR_X),Y
bcs calc_gun_right_door_continue ; bge
@ -153,6 +162,86 @@ calc_gun_right_door_continue:
done_calc_gun_right_door_collision:
;==========================
; adjust for shield
calc_gun_right_shield:
lda SHIELD_OUT
beq done_calc_gun_right_shield_collision
ldx #0
calc_gun_right_shield_loop:
; FIXME: check for on same level?
lda shield_out,X
beq calc_gun_right_shield_continue
lda PHYSICIST_X
cmp shield_x,X
bcs calc_gun_right_shield_continue ; bge
; be sure closer than current max limit
lda RIGHT_SHOOT_LIMIT
cmp shield_x,X
bcc calc_gun_right_shield_continue ; blt
calc_gun_right_shield_there:
lda shield_x,X
sta RIGHT_SHOOT_LIMIT
txa ; set target if hit
ora #TARGET_SHIELD
sta RIGHT_SHOOT_TARGET
; can't early exit
calc_gun_right_shield_continue:
inx
cpx #MAX_SHIELDS
bne calc_gun_right_shield_loop
done_calc_gun_right_shield_collision:
;==========================
; adjust for friend
calc_gun_right_friend:
lda friend_room
cmp WHICH_ROOM
bne done_calc_gun_right_friend_collision
lda PHYSICIST_X
cmp friend_x
bcs calc_gun_right_friend_continue ; bge
; only if closer than previous found
lda RIGHT_SHOOT_LIMIT
cmp friend_x
bcc calc_gun_right_friend_continue ; blt
lda friend_state
cmp #F_DISINTEGRATING
beq calc_gun_right_friend_continue
calc_gun_right_friend_there:
; early exit
lda friend_x
sta RIGHT_SHOOT_LIMIT
; set target if hit
lda #TARGET_FRIEND
sta RIGHT_SHOOT_TARGET
calc_gun_right_friend_continue:
done_calc_gun_right_friend_collision:
;==========================
; adjust for alien
@ -172,12 +261,16 @@ calc_gun_right_alien_loop:
cmp alien_x,X
bcs calc_gun_right_alien_continue ; bge
; only if closer than previous found
lda RIGHT_SHOOT_LIMIT
cmp alien_x,X
bcc calc_gun_right_alien_continue ; blt
lda alien_state,X
cmp #A_DISINTEGRATING
beq calc_gun_right_alien_continue
calc_gun_right_alien_there:
; early exit
lda alien_x,X
sta RIGHT_SHOOT_LIMIT
@ -185,7 +278,7 @@ calc_gun_right_alien_there:
ora #TARGET_ALIEN
sta RIGHT_SHOOT_TARGET
jmp done_calc_gun_right_alien_collision
; can't early exit
calc_gun_right_alien_continue:
inx
@ -193,6 +286,8 @@ calc_gun_right_alien_continue:
bne calc_gun_right_alien_loop
done_calc_gun_right_alien_collision:
rts

16
ootw/dummy_friend.s Normal file
View File

@ -0,0 +1,16 @@
; Include on levels where there is no friend
F_STANDING = 0
F_WALKING = 1
F_RUNNING = 2
F_CROUCHING = 3
F_TURNING = 4
F_KEYPAD = 5
F_OPEN_VENT = 6
F_DISINTEGRATING= 7
friend_state:
friend_x:
friend_room:
.byte $ff

View File

@ -8,6 +8,11 @@ friend_gait: .byte 0
friend_direction: .byte 0
friend_ai_state: .byte 0
FAI_FOLLOWING = 0
FAI_RUNTO_PANEL = 1
FAI_OPENING_PANEL = 2
FAI_END_L2 = 3
F_STANDING = 0
F_WALKING = 1
F_RUNNING = 2
@ -17,14 +22,6 @@ F_KEYPAD = 5
F_OPEN_VENT = 6
F_DISINTEGRATING= 7
FAI_FOLLOWING = 0
FAI_RUNTO_PANEL = 1
FAI_OPENING_PANEL = 2
FAI_END_L2 = 3
fai_table_lo:
.byte <friend_ai_following ; 00
.byte <friend_ai_runto_panel ; 01
@ -80,6 +77,10 @@ friend_ai_runto_panel:
cmp #30
bcc ai_runto_panel_done
; hack, if running stop wrong place?
lda #31
sta friend_x
lda #FAI_OPENING_PANEL
sta friend_ai_state

View File

@ -843,9 +843,9 @@ not_teleporting_today:
bne not_picking_up_gun
; gun at 35,36,37
; so we should be at 32-39
; so we should be at 31-39
lda PHYSICIST_X
cmp #32
cmp #31
bcc not_picking_up_gun ; blt
lda #1

View File

@ -109,6 +109,7 @@ end_message:
.include "shield.s"
.include "blast.s"
.include "collision.s"
.include "dummy_friend.s"
.include "ootw_c4_action.s"

View File

@ -93,7 +93,7 @@ end_message:
.include "physicist.s"
.include "alien.s"
.include "dummy_friend.s"
.include "gun.s"
.include "laser.s"