Update poltergeist enemies

This commit is contained in:
scawful
2024-01-25 19:24:28 -05:00
parent 9eb715e85b
commit 77eaebdc2b

View File

@@ -1,7 +1,5 @@
;==============================================================================
; Sprite Properties
;==============================================================================
!SPRID = $B6 ; The sprite ID you are overwriting (HEX)
!SPRID = $A4; The sprite ID you are overwriting (HEX)
!NbrTiles = 4 ; Number of tiles used in a frame
!Harmless = 00 ; 00 = Sprite is Harmful, 01 = Sprite is Harmless
!HVelocity = 00 ; Is your sprite going super fast? put 01 if it is
@@ -28,29 +26,28 @@
!ImperviousArrow = 00 ; 01 = Impervious to arrows
!ImpervSwordHammer = 00 ; 01 = Impervious to sword and hammer attacks
!Boss = 00 ; 00 = normal sprite, 01 = sprite is a boss
%Set_Sprite_Properties(Sprite_Poltergeist_Prep, Sprite_Poltergeist_Long);
%Set_Sprite_Properties(Sprite_Poltergeist_Prep, Sprite_Poltergeist_Long)
;==================================================================================================
; Sprite Long Hook for that sprite
; --------------------------------------------------------------------------------------------------
; This code can be left unchanged
; handle the draw code and if the sprite is active and should move or not
;==================================================================================================
Sprite_Poltergeist_Long:
{
PHB : PHK : PLB
JSR Sprite_Poltergeist_Draw ; Call the draw code
LDA $E0 : CMP #$F0 : BNE .onscreen
LDA.w SprMiscA, X : BEQ .SpriteIsNotActive
STZ.w SprState, X ; kill the sprite if offscreen and activated
.onscreen
JSL Sprite_CheckActive ; Check if game is not paused
BCC .SpriteIsNotActive ; Skip Main code is sprite is innactive
.onscreen
JSL Sprite_CheckActive ; Check if game is not paused
BCC .SpriteIsNotActive ; Skip Main code is sprite is innactive
JSR Sprite_Poltergeist_Main ; Call the main sprite code
.SpriteIsNotActive
PLB ; Get back the databank we stored previously
RTL ; Go back to original code
}
@@ -64,37 +61,48 @@ Sprite_Poltergeist_Long:
Sprite_Poltergeist_Prep:
{
PHB : PHK : PLB
; LDA #$00 : STA $0F60, X ; Persist
LDA #$02 : STA $0E40, X ;1 tile by default
LDA #$01 : STA.w SprAction, X ; by default it's a chair
LDA.w SprSubtype, X : CMP #$10 : BNE .notPictureFrame
STZ.w SprMiscA, X
STZ.w SprAction, X
JMP .done
.notPictureFrame
CMP #$11 : BNE .notAxe
LDA #$07 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X
LDA #$04 : STA $0E40, X
BRA .done
.notAxe
CMP #$12 : BNE .notKnife
LDA #15 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X
BRA .done
.notKnife
CMP #$13 : BNE .notFork
LDA #37 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X
BRA .done
.notFork
CMP #$14 : BNE .notBed
LDA #5 : STA.w SprFrame, X
LDA #$01 : STA.w SprAction, X
LDA #$06 : STA $0E40, X
BRA .done
.notBed
CMP #$15 : BNE .notDoor
LDA #36 : STA.w SprFrame, X
LDA #$01 : STA.w SprAction, X
@@ -102,27 +110,24 @@ Sprite_Poltergeist_Prep:
LDA.w SprY, X : SEC : SBC #$0C : STA.w SprY, X
LDA.w SprX, X : CLC : ADC #$08 : STA.w SprX, X
BRA .done
.notDoor
LDA.w SprSubtype, X : AND #$08 : BNE .secondset ;2nd set
LDA.w SprSubtype, X : CLC : ADC #23 : STA.w SprFrame, X
BRA .done
.secondset
LDA.w SprSubtype, X : AND #$07 : CLC : ADC #30 : STA.w SprFrame, X
LDA.w SprSubtype, X
.done
PLB
RTL
}
;==================================================================================================
; Sprite Main routines code
; --------------------------------------------------------------------------------------------------
; This is the main local code of your sprite
; This contains all the Subroutines of your sprites you can add more below
;==================================================================================================
; Subtype:
; 00:chair
; 01:lantern
@@ -155,54 +160,60 @@ Sprite_Poltergeist_Main:
dw Chair
dw Axe
dw SpawnerTester
}
PictureFrame:
{
JSL Sprite_CheckDamageToPlayer
REP #$20
JSR GetLinkDistance16bit : CMP #$0050 : BCS .notcloseenough
SEP #$20
LDA #$01 : STA.w SprMiscA, X
LDA #$02 : STA.w SprHeight, X
.notcloseenough
SEP #$20
LDA.w SprMiscA, X : BNE .chase
RTS
.chase
%PlayAnimation(0, 3, 6)
LDA #$0A
JSL Sprite_ApplySpeedTowardsPlayer
JSL Sprite_MoveLong
+
JSL Sprite_CheckDamageFromPlayer : BCC .noShatter
JMP Shatter
.noShatter
RTS
}
GetLinkDistance16bit:
{
LDA $0FD8 ; Sprite X
SEC : SBC $22 ; - Player X
BPL +
EOR #$FFFF : INC
+
STA $00 ; Distance X (ABS)
LDA $0FDA ; Sprite Y
SEC : SBC $20 ; - Player Y
BPL +
EOR #$FFFF : INC
+
; Add it back to X Distance
CLC : ADC $00 : STA $00 ; distance total X, Y (ABS)
@@ -213,13 +224,17 @@ Sprite_Poltergeist_Main:
{
JSL Sprite_CheckDamageToPlayer
REP #$20
JSR GetLinkDistance16bit : CMP #$0050 : BCS .notcloseenough
SEP #$20
LDA.w SprMiscA, X : BNE +
LDA #$01 : STA.w SprMiscA, X
+
.notcloseenough
SEP #$20
LDA.w SprMiscA, X : CMP #$01 : BNE +
; Prepare to raise in the air
LDA.b #$20 : STA.w SprTimerA, X
@@ -236,15 +251,17 @@ Sprite_Poltergeist_Main:
INC.w SprMiscA, X
RTS
.stillrising
; OPTIONAL DELAY THE INCREASING SPRHEIGHT WITH TIMER
LDA.w SprTimerC, X : BNE .optionalTimer
LDA #$02 : STA.w SprTimerC, X
INC.w SprHeight, X
.optionalTimer
RTS
.optionalTimer
RTS
+
CMP #$03 : BNE +
@@ -293,10 +310,13 @@ Sprite_Poltergeist_Main:
REP #$20
JSR GetLinkDistance16bit : CMP #$0050 : BCS .notcloseenough
SEP #$20
LDA.w SprMiscA, X : BNE +
LDA #$01 : STA.w SprMiscA, X
+
.notcloseenough
SEP #$20
LDA.w SprMiscA, X : CMP #$01 : BNE +
; Prepare to raise in the air
@@ -314,72 +334,90 @@ Sprite_Poltergeist_Main:
INC.w SprMiscA, X
RTS
.stillrising
; OPTIONAL DELAY THE INCREASING SPRHEIGHT WITH TIMER
LDA.w SprTimerC, X : BNE .optionalTimer
LDA #$02 : STA.w SprTimerC, X
INC.w SprHeight, X
.optionalTimer
RTS
.optionalTimer
RTS
+
CMP #$03 : BNE +
LDA.w SprSubtype, X
CMP #$11 : BNE .notAxe
LDA.w SprSubtype, X : CMP #$11 : BNE .notAxe
JSR PlayAxe
BRA .done
.notAxe
CMP #$12 : BNE .notKnife
JSR PlayKnife
BRA .done
.notKnife
JSR PlayFork
.notFork
.done
LDA.w SprTimerA, X : BNE .waitingdelay
JSL Sprite_MoveLong
JSL Sprite_CheckDamageToPlayer : BCC .noShatter
JMP Shatter
JSL Sprite_CheckDamageFromPlayer : BCC .noShatter
JMP Shatter
JSL Sprite_CheckTileCollision : BEQ .noShatter
JMP Shatter
.noShatter
RTS
+
RTS
.waitingdelay
LDA #$20
JSL Sprite_ApplySpeedTowardsPlayer
RTS
}
PlayAxe:
{
%PlayAnimation(7, 14, 6)
RTS
}
PlayFork:
{
%PlayAnimation(37, 44, 6)
RTS
}
PlayKnife:
{
%PlayAnimation(15, 22, 6)
RTS
}
SpawnerTester:
{
LDA.w SprTimerA, X : BEQ +
RTS
+
LDA #$FF : STA.w SprTimerA, X
LDA #$00
JSL Sprite_SpawnDynamically
@@ -394,37 +432,50 @@ Sprite_Poltergeist_Main:
STA.w SprMiscA, Y
STA.w SprAction, Y
BRA .done
.notPictureFrame
CMP #$11 : BNE .notAxe
LDA #$07 : STA.w SprFrame, Y
LDA #$02 : STA.w SprAction, Y
BRA .done
.notAxe
CMP #$12 : BNE .notKnife
LDA #15 : STA.w SprFrame, Y
LDA #$02 : STA.w SprAction, Y
BRA .done
.notKnife
CMP #$13 : BNE .notFork
LDA #37 : STA.w SprFrame, Y
LDA #$02 : STA.w SprAction, Y
BRA .done
.notFork
CMP #$14 : BNE .notBed
LDA #5 : STA.w SprFrame, Y
LDA #$01 : STA.w SprAction, Y
BRA .done
.notBed
CMP #$14 : BNE .notDoor
LDA #36 : STA.w SprFrame, Y
LDA #$01 : STA.w SprAction, Y
BRA .done
.notDoor
LDA.w SprSubtype, Y : AND #$08 : BNE .secondset ;2nd set
LDA.w SprSubtype, Y : CLC : ADC #23 : STA.w SprFrame, Y
BRA .done
.secondset
LDA.w SprSubtype, Y : AND #$07 : CLC : ADC #30 : STA.w SprFrame, Y
LDA.w SprSubtype, Y
@@ -432,16 +483,10 @@ Sprite_Poltergeist_Main:
RTS
}
}
;==================================================================================================
; Sprite Draw code
; --------------------------------------------------------------------------------------------------
; Draw the tiles on screen with the data provided by the sprite maker editor
;==================================================================================================
Sprite_Poltergeist_Draw:
{
LDA.w SprAction, X : CMP #$03 : BNE +
RTS
+
@@ -453,10 +498,10 @@ JSL Sprite_OAM_AllocateDeferToPlayer
LDA $0DC0, X : CLC : ADC $0D90, X : TAY;Animation Frame
LDA .start_index, Y : STA $06
PHX
LDX .nbr_of_tiles, Y ;amount of tiles -1
LDY.b #$00
.nextTile
PHX ; Save current Tile Index?
@@ -475,10 +520,11 @@ INY
LDA $02 : CLC : ADC .y_offsets, X : STA ($90), Y
CLC : ADC #$0010 : CMP.w #$0100
SEP #$20
BCC .on_screen_y
BCC .on_screen_y
LDA.b #$F0 : STA ($90), Y ;Put the sprite out of the way
STA $0E
.on_screen_y
PLX ; Pullback Animation Index Offset (without the *2 not 16bit anymore)
@@ -494,7 +540,6 @@ TYA : LSR #2 : TAY
LDA .sizes, X : ORA $0F : STA ($92), Y ; store size in oam buffer
PLY : INY
PLX : DEX : BPL .nextTile
PLX
@@ -502,17 +547,20 @@ LDA.w SprMiscA, X : BEQ .noshadow
JSL Sprite_DrawShadow
.noshadow
RTS
}
;==================================================================================================
; Sprite Draw Generated Data
; --------------------------------------------------------------------------------------------------
; This is where the generated Data for the sprite go
;==================================================================================================
.start_index
db $00, $02, $04, $06, $08, $09, $0F, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1F, $20, $22, $23, $25, $26, $28, $29, $2A, $2B, $2C, $2D, $2E, $2F, $30, $31, $33, $35, $37, $39, $3B, $3F, $41, $42, $44, $45, $47, $48, $4A
.nbr_of_tiles
db 1, 1, 1, 1, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 3, 1, 0, 1, 0, 1, 0, 1, 0
.x_offsets
dw -8, 8
dw -8, 8
@@ -559,6 +607,7 @@ dw 4, 4
dw 0
dw 0, 8
dw 0
.y_offsets
dw 0, 0
dw 0, 0
@@ -605,6 +654,7 @@ dw 0, 8
dw 0
dw 4, 4
dw 0
.chr
db $02, $02
db $00, $00
@@ -651,6 +701,7 @@ db $07, $17
db $28
db $3E, $3F
db $28
.properties
db $3D, $7D
db $3D, $7D
@@ -697,6 +748,7 @@ db $39, $39
db $39
db $39, $39
db $B9
.sizes
db $02, $02
db $02, $02