Skip to content

Commit

Permalink
Rug-behaviour only triggers once
Browse files Browse the repository at this point in the history
This prevents weirdness if a player gets the rug, drops it, then
gets it again.
  • Loading branch information
skx committed Apr 26, 2021
1 parent 0ccd899 commit 830b5fb
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions game.z80
Original file line number Diff line number Diff line change
Expand Up @@ -1126,13 +1126,32 @@ get_found_it_take:
inc hl
ld (hl),255

; HACK - Was the item being taken the rug?
;
; HACK - We don't have a notion of a take-handler
; so we can't show the trapdoor when the rug
; is taken.
;
; Hardwire that behaviour here, even though that
; is horrid.
;
; The alternative would have been to give some kind of
; "rug covers other objects" property to the rug.
;
ld de, tmp_buffer+1
ld hl, item_7_name
ld b, 3 ; strlen("RUG")
call CompareStringsWithLength
jp nz, not_taken_rug

; Taking the rug should only trigger this behaviour
; once - store state in `RUG_TAKEN` and ensure it
; doesn't get triggered more than once.
ld hl, RUG_TAKEN
ld a,(hl)
cp 0
jr nz, not_taken_rug
inc (hl)

; show a message telling the user about the trapdoor.
ld de, rug_taken_msg
call show_msg
Expand Down Expand Up @@ -1902,7 +1921,8 @@ PLAYER_WON:
db 0
MAGIC_LOCATION
db 0

RUG_TAKEN:
db 0

;********************************************************************
; String Area
Expand Down

0 comments on commit 830b5fb

Please sign in to comment.