You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-04-09 05:44:44 -07:00
Implement Surf technique, avoid facing-tile events when player has yet to STEP_TURN or while not in BOARDEVENT_HANDLE_BOARD [bugfix to previous two commits] (#34)
new tile permission SPACE_TILE added, which acts as WATER_TILE while on PLAYER_SURF or PLAYER_SURF_PIKA state, as LAND_TILE otherwise
This commit is contained in:
@@ -408,6 +408,16 @@ SurfFunction:
|
||||
ld a, $80
|
||||
ret
|
||||
|
||||
SurfAutoScript::
|
||||
readmem wSurfingPlayerState
|
||||
writevar VAR_MOVEMENT
|
||||
special UpdatePlayerSprite
|
||||
special PlayMapMusic
|
||||
; step into the water (slow_step DIR, step_end)
|
||||
special SurfStartStep
|
||||
applymovement PLAYER, wMovementBuffer
|
||||
end
|
||||
|
||||
SurfFromMenuScript:
|
||||
special UpdateTimePals
|
||||
|
||||
@@ -456,7 +466,7 @@ GetSurfType:
|
||||
ld a, PLAYER_SURF
|
||||
ret
|
||||
|
||||
CheckDirection:
|
||||
CheckDirection::
|
||||
; Return carry if a tile permission prevents you
|
||||
; from moving in the direction you're facing.
|
||||
|
||||
|
@@ -641,9 +641,23 @@ SetMinTwoStepWildEncounterCooldown: ; unreferenced
|
||||
ret
|
||||
|
||||
CheckFacingTileEvent:
|
||||
; no tile events if not in BOARDEVENT_HANDLE_BOARD (e.g. after player lands in space)
|
||||
ldh a, [hCurBoardEvent]
|
||||
cp BOARDEVENT_VIEW_MAP_MODE
|
||||
cp BOARDEVENT_HANDLE_BOARD
|
||||
jr nz, .NoAction
|
||||
|
||||
; no facing-tile events until player has turned to the walking direction.
|
||||
; if the player has to perform a STEP_TURN first, the facing tile is not the right one.
|
||||
ld a, [wWalkingDirection]
|
||||
cp STANDING
|
||||
jr z, .NoAction
|
||||
ld e, a
|
||||
ld a, [wPlayerDirection]
|
||||
rrca
|
||||
rrca
|
||||
maskbits NUM_DIRECTIONS
|
||||
cp e
|
||||
jr nz, .NoAction
|
||||
|
||||
call .TryObjectEvent
|
||||
jr c, .Action
|
||||
@@ -729,6 +743,33 @@ CheckFacingTileEvent:
|
||||
ret ; c
|
||||
|
||||
.TryTileCollisionEvent:
|
||||
call GetFacingTileCoord
|
||||
ld [wFacingTileID], a
|
||||
|
||||
;; Surf
|
||||
; Don't surf if already surfing.
|
||||
ld a, [wPlayerState]
|
||||
cp PLAYER_SURF_PIKA
|
||||
jr z, .next_event_1
|
||||
cp PLAYER_SURF
|
||||
jr z, .next_event_1
|
||||
|
||||
; Must be facing water.
|
||||
ld a, [wFacingTileID]
|
||||
call GetTileCollision
|
||||
cp WATER_TILE
|
||||
jr nz, .next_event_1
|
||||
|
||||
ld a, PLAYER_SURF
|
||||
ld [wSurfingPlayerState], a
|
||||
|
||||
ld a, BANK(SurfAutoScript)
|
||||
ld hl, SurfAutoScript
|
||||
call CallScript
|
||||
ret ; c
|
||||
|
||||
.next_event_1
|
||||
.no_event
|
||||
xor a
|
||||
ret ; nc
|
||||
|
||||
|
@@ -929,6 +929,8 @@ ENDM
|
||||
call GetTileCollision
|
||||
and a ; LAND_TILE
|
||||
ret z
|
||||
cp SPACE_TILE
|
||||
ret z
|
||||
scf
|
||||
ret
|
||||
|
||||
@@ -939,6 +941,10 @@ ENDM
|
||||
call GetTileCollision
|
||||
cp WATER_TILE
|
||||
jr z, .Water
|
||||
; because this is called during PLAYER_SURF or PLAYER_SURF_PIKA state,
|
||||
; SPACE_TILE is considered still water. Do not stop surfing on a space tile.
|
||||
cp SPACE_TILE
|
||||
jr z, .Water
|
||||
|
||||
; Can walk back onto land from water.
|
||||
and a ; LAND_TILE
|
||||
|
Reference in New Issue
Block a user