honeylisp/game/level5.fnl

94 lines
3.5 KiB
Plaintext
Raw Normal View History

2021-01-24 16:32:49 +00:00
(local {: deflevel : say : itile : controlstate : tilelist} (require :game.defs))
2020-12-12 16:55:22 +00:00
(local {: ev} (require :game.entity))
2020-12-17 03:59:55 +00:00
(local tile (require :game.tiles))
2021-02-05 02:15:27 +00:00
(local {: notes} (require :game.boop))
2020-12-17 03:59:55 +00:00
(local {: walkable : neutable : debris : sittable} tile.flag-to-bit)
(local level (deflevel "game/map5.json" :level5))
2020-12-12 16:55:22 +00:00
(local vm level.vm)
2021-02-05 02:15:27 +00:00
(vm:word :snd-dropgarbage (notes [:a1] 0x02 0xf0))
2021-01-24 16:32:49 +00:00
(vm.code:append :debristiles)
(each [itile tiledef (ipairs tilelist)]
(when tiledef.flags.debris
(vm.code:append [:db (tile.encode-itile itile)])))
(vm:word :randomgarbage :rnd 0x03 :& :lit :debristiles :+ :bget)
2020-12-15 04:14:35 +00:00
(vm:var :doortimer 0)
(vm:word :start-doortimer 0x10 :doortimer :set)
2020-12-15 04:14:35 +00:00
(vm:word :doortimer-tick
:doortimer :get (vm:when
:doortimer :get 1 :- :dup :doortimer :set
:not (vm:when
:lit :timedswitch ev.deact :entity>do)))
(vm:word :do-timedswitch
; only gord is physically able to touch it
:dup ev.touch := (vm:when :start-doortimer :drop ev.act) :switch)
2020-12-17 03:59:55 +00:00
(vm:var :is-garbagerexx vm.false)
(vm:var :garbagerexx-yx 0x0710)
(vm:var :garbagerexx-introduced vm.false)
2020-12-17 03:59:55 +00:00
(vm:word :garbagerexx ; ev --
:is-rexx? :swap :rexx :is-rexx? := :not (vm:when
:is-rexx? (vm:if [
:garbagerexx-yx :get :get-responder :get := (vm:when
vm.true :is-garbagerexx :set
:garbagerexx-introduced :get :not (vm:when
(say :rexx "BO@oSSsS...,? htgz")
(say :rexx "I DON'T F3EL SO GOp0%foo)OD...>?qw" "idontfeelsogood")
vm.true :garbagerexx-introduced :set
))
2020-12-17 03:59:55 +00:00
] [
:is-garbagerexx :get (vm:when
:get-responder :get :garbagerexx-yx :set
vm.false :is-garbagerexx :set)
])))
(vm:word :not-picking-up? ; yxdest -- f
debris :flag-at? :not)
(vm:word :can-drop-rubble? ; yxdest -- f
:itile-at (itile :t-floor) :=
:rexx-yx :get :itile-at (itile :t-floor) := :&)
(vm:word :move-garbagerexx ; yx -- f
(vm:if-and [[:is-rexx?] [:is-garbagerexx :get]]
[:dup 0xff :& 0x0d := (vm:if [
(say :rexx "PARITYe#ERPORr(sbaitso" " tellmeabout" " your problems") :drop vm.true :ret
2020-12-17 03:59:55 +00:00
] [
(vm:if-and [[:dup :not-picking-up?] [:dup :can-drop-rubble?]]
2021-02-05 02:15:27 +00:00
[:rexx-yx :get :randomgarbage :update-itile :snd-dropgarbage])
2020-12-17 03:59:55 +00:00
])])
:move-noop)
2020-12-18 02:42:09 +00:00
(vm:word :move ; dir -- dir
:dup :player-yx :get :yx+ :move-player-to 0x300 :snooze)
(vm:word :explode ; dir --
2021-01-22 03:54:21 +00:00
:player-yx :get :yx+ :randomgarbage :update-itile :snd-explode)
2020-12-18 02:42:09 +00:00
(vm:word :explodingdoor
:dup :door
(vm:if-and [[ev.touch :=] [:is-jaye?] [:player-yx :get :get-responder :get :=] [:garbagerexx-yx :get :lit :south-rexx :get :=] [:gord-yx :get 0x812 :=]]
[:rexx-yx :get
:garbagerexx-yx :get :dup (itile :t-rexxstop) :update-itile :rexx-yx :set
controlstate.rexx :controlstate :bset
0x00ff :move :move :move
(say :rexx "DAAAISYY" " DAAAAAIIISYYYY" "d a i s y") :hide-footer
2020-12-18 02:42:09 +00:00
:move :drop 0xff00 :move
(say :rexx "GIVE ME" " .,#YOUR ANSWEibmER" " %$DOO00OOooo@'bell\"") :hide-footer
2020-12-18 02:42:09 +00:00
:move :drop
(say :rexx "UH OH") :hide-footer
0xff00 :explode 0x0100 :explode 0x00ff :explode 0x0001 :explode 0 :explode
0xffff :garbagerexx-yx :set
controlstate.jaye :controlstate :bset
:rexx-yx :set]))
(vm:var :healthyrexx-introduced vm.false)
(vm:word :healthyrexx ; ev --
(vm:if-and [[:is-neut?] [:dup ev.touch :=] [:healthyrexx-introduced :get :not]]
[(say :neut "REXX UNIT" "PERFORM FULL DIAGNOSTIC SCAN")
(say :rexx "I'M IN TIP-TOP SHAPE, BOSS!")
(say :neut "ACTIVATING RELIEF SUBROUTINE")
vm.true :healthyrexx-introduced :set]) :rexx)
2020-12-12 16:55:22 +00:00
level