update village dog behavior, make liftable

This commit is contained in:
scawful
2024-05-27 17:10:13 -04:00
parent a5d964271c
commit 026d8c593f

View File

@@ -46,7 +46,6 @@ Sprite_VillageDog_Long:
RTL ; Go back to original code
}
Sprite_VillageDog_Prep:
{
PHB : PHK : PLB
@@ -55,6 +54,14 @@ Sprite_VillageDog_Prep:
RTL
}
HandleTossedDog:
{
LDA.w SprHeight, X : BEQ .on_ground
DEC.w SprHeight, X
.on_ground
RTS
}
Sprite_VillageDog_Main:
{
LDA.w SprAction, X ; Load the SprAction
@@ -67,22 +74,25 @@ Sprite_VillageDog_Main:
dw Dog_MoveRightTowardsLink ; 04
dw Dog_WagTailLeft ; 05
dw Dog_WagTailRight ; 06
dw Dog_RandomMovement ; 07
; 0
Dog_Handler:
{
%PlayAnimation(8,8,8) ; Sitting
JSR HandleTossedDog
LDA $0309 : AND #$03 : BNE .lifting
LDA #$20 : STA.w SprTimerD, X
JSL Sprite_IsToRightOfPlayer : TYA : BEQ .walk_right
%GotoAction(1)
JMP .lifting
JSL Sprite_IsToRightOfPlayer ; Check if sprite is to the right of player
TYA : BEQ .WalkRight ; If so, go to LookLeft
%GotoAction(3)
RTS
.WalkRight
%GotoAction(4)
.walk_right
%GotoAction(2)
.lifting
JSL Sprite_CheckIfLifted
JSL Sprite_Move
RTS
}
@@ -90,7 +100,7 @@ Sprite_VillageDog_Main:
Dog_LookLeftAtLink:
{
%PlayAnimation(9,9,8)
JSR HandleTossedDog
LDA.w SprTimerD, X : BNE +
; Load the timer for the run
LDA #$60 : STA.w SprTimerD, X
@@ -103,7 +113,7 @@ Sprite_VillageDog_Main:
Dog_LookRightAtLink:
{
%PlayAnimation(10,10,8)
JSR HandleTossedDog
LDA.w SprTimerD, X : BNE +
; Load the timer for the run
LDA #$60 : STA.w SprTimerD, X
@@ -116,12 +126,9 @@ Sprite_VillageDog_Main:
Dog_MoveLeftTowardsLink:
{
%PlayAnimation(2,4,6)
JSR CheckForSwitchToRandomMovement
JSL Sprite_DirectionToFacePlayer
JSR HandleTossedDog
; Check if the dog is near link, then wag the tail
LDA $0E : CMP.b #$00A0 : BCS +
CLC
LDA $0F : CMP.b #$00A0 : BCS +
JSR CheckIfPlayerIsNearby : BCC +
%GotoAction(5)
+
@@ -129,12 +136,13 @@ Sprite_VillageDog_Main:
JSL Sprite_CheckTileCollision
LDA $0E70, X : BEQ .no_collision
%GotoAction(0)
.no_collision
.no_collision
LDA.b #$0A ; Speed
JSL Sprite_ApplySpeedTowardsPlayer
STZ $06 : STZ $07
JSL Sprite_MoveLong
JSL Sprite_CheckIfLifted
LDA.w SprTimerD, X : BNE +
@@ -147,13 +155,8 @@ Sprite_VillageDog_Main:
Dog_MoveRightTowardsLink:
{
%PlayAnimation(5,7,6)
JSR CheckForSwitchToRandomMovement
JSL Sprite_DirectionToFacePlayer
; Check if the dog is near link, then wag the tail
LDA $0E : CMP.b #$00A0 : BCS +
CLC
LDA $0F : CMP.b #$00A0 : BCS +
JSR HandleTossedDog
JSR CheckIfPlayerIsNearby : BCC +
%GotoAction(6)
+
@@ -161,11 +164,14 @@ Sprite_VillageDog_Main:
JSL Sprite_CheckTileCollision
LDA $0E70, X : BEQ .no_collision
%GotoAction(0)
.no_collision
.no_collision
LDA.b #$0A ; Speed
JSL Sprite_ApplySpeedTowardsPlayer
STZ $06 : STZ $07
JSL Sprite_MoveLong
JSL Sprite_CheckIfLifted
LDA.w SprTimerD, X : BNE ++
%GotoAction(0)
++
@@ -177,6 +183,8 @@ Sprite_VillageDog_Main:
{
%PlayAnimation(0,1, 8)
JSR ShowMessageIfMinish
JSL Sprite_CheckIfLifted
JSR HandleTossedDog
LDA.w SprTimerD, X : BNE +
%GotoAction(0)
+
@@ -188,45 +196,33 @@ Sprite_VillageDog_Main:
{
%PlayAnimation(11,12,8)
JSR ShowMessageIfMinish
JSL Sprite_CheckIfLifted
JSR HandleTossedDog
LDA.w SprTimerD, X : BNE +
%GotoAction(0)
+
RTS
}
; 07
Dog_RandomMovement:
{
%PlayAnimation(2,4,6)
LDA.w SprTimerD, X : BNE +
; Load the timer for the run
LDA #$60 : STA.w SprTimerD, X
JSL GetRandomInt
AND.b #$03
BEQ .move_left
BNE .move_right
.move_left
%GotoAction(3)
RTS
.move_right
%GotoAction(4)
RTS
+
RTS
}
}
CheckForSwitchToRandomMovement:
CheckIfPlayerIsNearby:
{
; LDA.w SprTimerD, X : BNE +
; LDA #$60 : STA.w SprTimerD, X
; %GotoAction(7)
; +
RTS
REP #$20
LDA $22 : CLC : ADC #$0012 : CMP $0FD8 : BCC .left
LDA $22 : SEC : SBC #$0012 : CMP $0FD8 : BCS .right
LDA $20 : CLC : ADC #$001A : CMP $0FDA : BCC .up
LDA $20 : SEC : SBC #$001A : CMP $0FDA : BCS .down
SEP #$21 : RTS ; Return with carry set
.left
.right
.up
.down
SEP #$20
CLC : RTS ; Return with carry cleared
}