mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
Implement Rock Smash technique (#34)
This commit is contained in:
parent
424598bbf4
commit
16ba25346c
@ -124,6 +124,11 @@ DEF PLAYER_OBJECT EQU 0
|
||||
DEF MAPOBJECT_PALETTE_MASK EQU %11110000
|
||||
DEF MAPOBJECT_TYPE_MASK EQU %00001111
|
||||
|
||||
; special MAPOBJECT_EVENT_FLAG values
|
||||
DEF ALWAYS_HIDDEN EQU $ff00 ; anything between $ff00 and $fffe
|
||||
DEF ALWAYS_SHOWN EQU $ffff
|
||||
assert HIGH(ALWAYS_HIDDEN) == HIGH(ALWAYS_SHOWN)
|
||||
|
||||
; number of entries in MapObjectsBackups.
|
||||
; this sets a limit to the maximum number of different maps that can be reentered during a level.
|
||||
; map groups with more than NUM_MAP_OBJECTS_BACKUPS maps are only ok if no more than
|
||||
|
@ -144,7 +144,7 @@ DEF NUM_BGEVENTS EQU const_value
|
||||
const OBJECTTYPE_ITEMBALL
|
||||
const OBJECTTYPE_TRAINER
|
||||
const OBJECTTYPE_TALKER
|
||||
const OBJECTTYPE_4
|
||||
const OBJECTTYPE_ROCK
|
||||
const OBJECTTYPE_5
|
||||
const OBJECTTYPE_6
|
||||
DEF NUM_OBJECT_TYPES EQU const_value
|
||||
|
@ -3,8 +3,10 @@
|
||||
const TECHNIQUE_CUT_F
|
||||
const TECHNIQUE_FLASH_F
|
||||
const TECHNIQUE_SURF_F
|
||||
const TECHNIQUE_ROCK_SMASH_F
|
||||
DEF NUM_TECHNIQUES EQU const_value
|
||||
|
||||
DEF TECHNIQUE_CUT EQU 1 << TECHNIQUE_CUT_F
|
||||
DEF TECHNIQUE_FLASH EQU 1 << TECHNIQUE_FLASH_F
|
||||
DEF TECHNIQUE_SURF EQU 1 << TECHNIQUE_SURF_F
|
||||
DEF TECHNIQUE_CUT EQU 1 << TECHNIQUE_CUT_F
|
||||
DEF TECHNIQUE_FLASH EQU 1 << TECHNIQUE_FLASH_F
|
||||
DEF TECHNIQUE_SURF EQU 1 << TECHNIQUE_SURF_F
|
||||
DEF TECHNIQUE_ROCK_SMASH EQU 1 << TECHNIQUE_ROCK_SMASH_F
|
||||
|
@ -115,6 +115,7 @@ SpecialsPointers::
|
||||
add_special PrintDiploma
|
||||
add_special PrintGainCoins
|
||||
add_special PrintLoseCoins
|
||||
add_special SetObjectToRemainHidden
|
||||
|
||||
; Crystal only
|
||||
add_special Reset ; bank 0
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1110,7 +1110,7 @@ LoadMapStatus::
|
||||
ret
|
||||
|
||||
CallScript::
|
||||
; Call a script at a:hl.
|
||||
; Call a script at a:hl and return carry.
|
||||
|
||||
ld [wScriptBank], a
|
||||
ld a, l
|
||||
|
@ -26,6 +26,8 @@ DebugLevel2_Map1_MapEvents:
|
||||
def_bg_events
|
||||
|
||||
def_object_events
|
||||
object_event 6, 13, SPRITE_ROCK, SPRITEMOVEDATA_SMASHABLE_ROCK, 0, 0, -1, -1, 0, OBJECTTYPE_ROCK, 0, ObjectEvent, -1
|
||||
object_event 5, 12, SPRITE_ROCK, SPRITEMOVEDATA_SMASHABLE_ROCK, 0, 0, -1, -1, 0, OBJECTTYPE_ROCK, 0, ObjectEvent, -1
|
||||
|
||||
DebugLevel2_Map1_MapSpaces:
|
||||
space 6, 16, $0, 1 ; 0
|
||||
|
Loading…
Reference in New Issue
Block a user