Implement Rock Smash technique (#34)

This commit is contained in:
xCrystal
2023-12-28 19:53:34 +01:00
parent 424598bbf4
commit 16ba25346c
11 changed files with 131 additions and 16 deletions

View File

@@ -1358,7 +1358,7 @@ RockSmashScript:
playsound SFX_STRENGTH
earthquake 84
applymovementlasttalked MovementData_RockSmash
disappear -2
disappear LAST_TALKED
callasm RockMonEncounter
readmem wTempWildMonSpecies
@@ -1369,6 +1369,15 @@ RockSmashScript:
.done
end
RockSmashAutoScript::
special WaitSFX
playsound SFX_STRENGTH
earthquake 84
applymovementlasttalked MovementData_RockSmash
disappear LAST_TALKED
special SetObjectToRemainHidden
end
MovementData_RockSmash:
rock_smash 10
step_end

View File

@@ -360,6 +360,9 @@ PlayerEvents:
call DisableTileEvents ; preserves f
jr c, .ok
call CheckFacingTileEvent
jr c, .ok
call RunMemScript
jr c, .ok
@@ -637,6 +640,86 @@ SetMinTwoStepWildEncounterCooldown: ; unreferenced
ld [wWildEncounterCooldown], a
ret
CheckFacingTileEvent:
ldh a, [hCurBoardEvent]
cp BOARDEVENT_VIEW_MAP_MODE
jr z, .NoAction
call .TryObjectEvent
jr c, .Action
; fallthrough
.NoAction:
xor a
ret
.Action:
push af
farcall StopPlayerForEvent
pop af
scf
ret
.TryObjectEvent:
farcall CheckFacingObject
jr c, .IsObject
xor a
ret
.IsObject:
ldh a, [hObjectStructIndex]
call GetObjectStruct
ld hl, OBJECT_MAP_OBJECT_INDEX
add hl, bc
ld a, [hl]
ldh [hLastTalked], a
ldh a, [hLastTalked]
call GetMapObject
ld hl, MAPOBJECT_TYPE
add hl, bc
ld a, [hl]
and MAPOBJECT_TYPE_MASK
push bc
ld de, 3
ld hl, .ObjectEventTypeArray
call IsInArray
pop bc
jr nc, .nope
inc hl
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
.nope
xor a
ret
.ObjectEventTypeArray:
table_width 3, .ObjectEventTypeArray
dbw OBJECTTYPE_SCRIPT, .none
dbw OBJECTTYPE_ITEMBALL, .none
dbw OBJECTTYPE_TRAINER, .none
dbw OBJECTTYPE_TALKER, .none
dbw OBJECTTYPE_ROCK, .rock_smash
dbw OBJECTTYPE_5, .none
dbw OBJECTTYPE_6, .none
assert_table_length NUM_OBJECT_TYPES
db -1 ; end
.none
xor a
ret ; nc
.rock_smash
ld a, BANK(RockSmashAutoScript)
ld hl, RockSmashAutoScript
call CallScript
ret ; c
RunSceneScript:
ldh a, [hCurBoardEvent]
cp BOARDEVENT_VIEW_MAP_MODE
@@ -824,7 +907,7 @@ ObjectEventTypeArray:
dbw OBJECTTYPE_TRAINER, .trainer
; the remaining four are dummy events
dbw OBJECTTYPE_TALKER, .three
dbw OBJECTTYPE_4, .four
dbw OBJECTTYPE_ROCK, .four
dbw OBJECTTYPE_5, .five
dbw OBJECTTYPE_6, .six
assert_table_length NUM_OBJECT_TYPES

View File

@@ -2750,6 +2750,21 @@ ResetObject:
db SPRITEMOVEDATA_STANDING_LEFT
db SPRITEMOVEDATA_STANDING_RIGHT
; Used to make the last talked object remain hidden.
; This is done by setting its event flag to special value ALWAYS_HIDDEN.
; Otherwise when data is read from wMapObjectsBackups after entering the map,
; it would appear by default even if it had been made disappear.
SetObjectToRemainHidden:
ldh a, [hLastTalked]
call GetMapObject
ld hl, MAPOBJECT_EVENT_FLAG
add hl, bc
ld de, ALWAYS_HIDDEN
ld [hl], e
inc hl
ld [hl], d
ret
_UpdateActiveSpritesAfterOffset::
ld a, [wVramState]
bit 0, a

View File

@@ -41,10 +41,10 @@ CheckObjectFlag:
ld e, a
ld a, [hl]
ld d, a
cp -1
cp HIGH(ALWAYS_SHOWN) ; HIGH(ALWAYS_HIDDEN)
jr nz, .check
ld a, e
cp -1
cp LOW(ALWAYS_SHOWN)
jr z, .unmasked
jr .masked
.check

View File

@@ -1007,16 +1007,14 @@ ApplyEventActionAppearDisappear:
ld e, [hl]
inc hl
ld d, [hl]
ld a, -1
cp e
jr nz, .okay
ld a, HIGH(ALWAYS_SHOWN) ; HIGH(ALWAYS_HIDDEN)
cp d
jr nz, .okay
xor a
ret
.okay
jr z, .not_a_flag
call EventFlagAction
ret
.not_a_flag
xor a
ret
Script_follow:
call GetScriptByte