2020-02-02 23:33:07 +00:00
|
|
|
( T I C K )
|
2020-09-06 15:11:36 +00:00
|
|
|
defer cheat-tick
|
2020-02-02 23:33:07 +00:00
|
|
|
defer party
|
|
|
|
defer entities
|
2020-02-02 23:30:00 +00:00
|
|
|
var objects
|
2020-03-07 23:55:18 +00:00
|
|
|
var ticking-objects
|
|
|
|
var visible-objects
|
2020-02-02 23:30:00 +00:00
|
|
|
|
2020-04-02 23:11:01 +00:00
|
|
|
0 const rubber-on?
|
|
|
|
: rubber rubber-on? not ' rubber-on? redefine ;
|
|
|
|
: {tileent} rubber-on? if {duck} else {blank} then ;
|
|
|
|
: visible-objects@ rubber-on? if objects else visible-objects then @ ;
|
|
|
|
|
|
|
|
defer touchable-objects
|
|
|
|
' objects ' touchable-objects redefine
|
|
|
|
|
2020-02-02 23:30:00 +00:00
|
|
|
: obj-entity ( optr -- entity ) cell + @ ;
|
|
|
|
|
2020-02-02 23:33:07 +00:00
|
|
|
( P L A Y E R )
|
|
|
|
var player.state userword
|
|
|
|
var player.prevdir
|
|
|
|
|
|
|
|
1 const MOVING userword
|
|
|
|
2 const NOCLIP userword
|
2020-02-22 03:38:32 +00:00
|
|
|
4 const HASNEUT userword
|
2020-02-22 20:15:00 +00:00
|
|
|
8 const HASGORD userword
|
|
|
|
16 const ISPROG userword
|
2020-03-07 15:18:16 +00:00
|
|
|
32 const GORDSIT userword
|
2020-04-04 03:06:18 +00:00
|
|
|
64 const HASLIBB userword
|
2020-02-02 23:33:07 +00:00
|
|
|
|
|
|
|
: noclip player.state NOCLIP fnot! ; userword
|
|
|
|
|
2020-02-22 03:38:32 +00:00
|
|
|
var posessed-rexx
|
2020-02-18 01:43:14 +00:00
|
|
|
|
|
|
|
: isprog? player.state ISPROG f@ ;
|
2020-02-22 03:38:32 +00:00
|
|
|
: isneut? isprog? posessed-rexx @ not and ; userword
|
2020-02-18 01:43:14 +00:00
|
|
|
: isjaye? isprog? not ; userword
|
2020-02-22 03:38:32 +00:00
|
|
|
: isrexx? isprog? posessed-rexx @ and ; userword
|
2020-03-07 23:55:18 +00:00
|
|
|
: gord-follow? player.state HASGORD f@ ;
|
2020-04-04 03:06:18 +00:00
|
|
|
: haslibb? player.state HASLIBB f@ ;
|
2020-02-02 23:33:07 +00:00
|
|
|
|
|
|
|
: {jaye}
|
2020-02-02 23:30:00 +00:00
|
|
|
isjaye? player.state MOVING f@ and
|
2020-02-18 01:43:11 +00:00
|
|
|
if {jaye-walk} else {jaye-stand} then ;
|
2020-02-02 23:33:07 +00:00
|
|
|
|
2020-02-22 20:15:00 +00:00
|
|
|
: {gord}
|
2020-03-07 23:55:18 +00:00
|
|
|
gord-follow? if
|
2020-03-07 15:18:16 +00:00
|
|
|
isjaye? player.state MOVING f@ and player.state GORDSIT f@ or
|
2020-02-22 20:15:00 +00:00
|
|
|
if {gord-walk} else {gord-stand} then
|
2020-03-07 15:18:16 +00:00
|
|
|
else player.state GORDSIT f@ if {gord-sit} else {gord-floor} then then ;
|
2020-02-22 20:15:00 +00:00
|
|
|
|
2020-02-02 23:33:07 +00:00
|
|
|
: player.canmove? ( x y -- )
|
|
|
|
player.state NOCLIP f@ not if
|
|
|
|
isneut? if NEUTABLE else WALKABLE then mapflag?
|
|
|
|
else drop drop 1 then ;
|
|
|
|
|
2020-02-18 01:43:14 +00:00
|
|
|
14 9 N ' {jaye} defentity Jaye
|
2020-02-22 03:38:32 +00:00
|
|
|
17 5 N ' {neut} defentity Neut
|
2020-02-22 20:15:00 +00:00
|
|
|
-10 -10 N ' {gord} defentity Gord
|
2020-04-04 03:06:18 +00:00
|
|
|
-10 -10 N ' {libb} defentity Libb
|
2020-02-22 20:15:00 +00:00
|
|
|
|
2020-04-04 03:06:18 +00:00
|
|
|
: entity-present? entity>pos drop 0 >= ;
|
|
|
|
: gord-present? Gord entity-present? ;
|
2020-02-18 01:43:14 +00:00
|
|
|
|
2020-02-22 03:38:32 +00:00
|
|
|
: player
|
|
|
|
isrexx? if posessed-rexx @ else
|
|
|
|
isneut? if Neut else Jaye then then ;
|
2020-02-18 01:43:14 +00:00
|
|
|
|
|
|
|
: replace-entity-at ( x y 0 entity -- x y entity|0 b )
|
|
|
|
swap drop >r 2dup ( x y x y r:e )
|
|
|
|
r@ entity>pos world>tile 2= ( x y b r:e )
|
|
|
|
if <r else rdrop 0 then dup ;
|
2020-02-02 23:33:07 +00:00
|
|
|
|
2020-02-18 01:43:14 +00:00
|
|
|
: single-entity-at ( x y entity|0 entity -- x y entity|0 )
|
|
|
|
over not if replace-entity-at then drop ;
|
|
|
|
|
|
|
|
: entity-at ( x y -- entity|0 )
|
|
|
|
0 entities each replace-entity-at if break then more
|
2020-04-02 23:11:01 +00:00
|
|
|
dup not touchable-objects @ and if
|
|
|
|
touchable-objects @ links each
|
2020-02-18 01:43:14 +00:00
|
|
|
>r r@ obj-entity replace-entity-at if rdrop break else <r then
|
|
|
|
more
|
|
|
|
then
|
|
|
|
Neut single-entity-at
|
|
|
|
Jaye single-entity-at
|
|
|
|
>rot drop drop ;
|
2020-02-02 23:33:07 +00:00
|
|
|
|
2020-04-02 23:11:01 +00:00
|
|
|
: touchable-entity-at ( x y -- entity|0 )
|
|
|
|
2dup ENTITY mapflag? not if
|
|
|
|
' visible-objects ' touchable-objects redefine
|
|
|
|
entity-at
|
|
|
|
' objects ' touchable-objects redefine
|
|
|
|
else entity-at then ;
|
|
|
|
|
2020-02-02 23:33:07 +00:00
|
|
|
: sched-move-entity ( entity -- ) :| jobdata move-entity |; sched-with ;
|
|
|
|
: move-player
|
2020-04-02 23:11:01 +00:00
|
|
|
player entity>pos world>tile touchable-entity-at
|
2020-02-02 23:30:11 +00:00
|
|
|
dup if EVUNTOUCH entity>do else drop then
|
|
|
|
|
2020-02-02 23:29:49 +00:00
|
|
|
1 player.state MOVING f!
|
|
|
|
|
2020-02-18 01:43:14 +00:00
|
|
|
isjaye? if ( only jaye can have a party )
|
2020-02-02 23:33:07 +00:00
|
|
|
player.prevdir @ party each
|
|
|
|
dup player != if
|
|
|
|
dup entity.dir @ >r
|
|
|
|
dup >rot entity.dir !
|
|
|
|
sched-move-entity <r
|
|
|
|
else entity.dir @ player.prevdir ! then more drop
|
2020-02-02 23:29:49 +00:00
|
|
|
then
|
|
|
|
|
|
|
|
player move-entity
|
|
|
|
0 player.state MOVING f! ;
|
2020-02-02 23:33:07 +00:00
|
|
|
|
|
|
|
: out-of-bounds ( x y -- b )
|
|
|
|
2dup 0 < swap 0 < or >rot mapsize ( b x y w h )
|
|
|
|
<rot <= >rot ( b b x w )
|
|
|
|
>= or or ;
|
|
|
|
|
|
|
|
: leaving? ( x y dir -- b )
|
|
|
|
dup N = if drop swap drop 0 < else
|
|
|
|
dup W = if drop drop 0 < else
|
|
|
|
S = if swap drop mapsize swap drop >= else
|
|
|
|
drop mapsize drop >= then then then ;
|
|
|
|
|
2020-03-07 15:18:16 +00:00
|
|
|
defer touch-override ( x y -- b )
|
2020-02-02 23:33:07 +00:00
|
|
|
|
2020-02-18 01:43:14 +00:00
|
|
|
: rexx-touch ( x y -- b )
|
2020-04-19 02:12:57 +00:00
|
|
|
0 >r isrexx? if
|
|
|
|
2dup RUBBLE mapflag? if
|
|
|
|
tile 3 swap b! invalidate-map
|
|
|
|
sfx-garbage
|
|
|
|
else tile b@ REXX-POD = if
|
|
|
|
move-player
|
|
|
|
S posessed-rexx @ entity.dir !
|
|
|
|
posessed-rexx @ entity>pos Neut entity.pos!
|
|
|
|
0 posessed-rexx !
|
|
|
|
rdrop 1 >r
|
|
|
|
then then
|
|
|
|
else drop drop then <r ;
|
2020-03-07 15:18:16 +00:00
|
|
|
|
|
|
|
defer on-gord-sit
|
|
|
|
|
|
|
|
: do-gord-sit ( x y -- b )
|
2020-03-07 23:55:18 +00:00
|
|
|
isjaye? gord-follow? and if
|
2020-03-07 15:18:16 +00:00
|
|
|
tile b@ CHAIR = if
|
|
|
|
1 player.state GORDSIT f!
|
|
|
|
player.prevdir @ Gord entity.dir !
|
|
|
|
Gord move-entity
|
|
|
|
player entity.dir @ Gord entity.dir !
|
|
|
|
Gord move-entity
|
|
|
|
0 player.state HASGORD f!
|
|
|
|
on-gord-sit
|
|
|
|
1
|
|
|
|
else 0 then
|
|
|
|
else drop drop 0 then ;
|
|
|
|
|
|
|
|
: activate-dir ( x y dir -- )
|
2020-04-02 23:11:01 +00:00
|
|
|
dir>pos +pos touchable-entity-at EVTOUCH entity>do ;
|
2020-03-07 15:18:16 +00:00
|
|
|
|
|
|
|
: activate-gord
|
2020-04-04 03:06:18 +00:00
|
|
|
player.state GORDSIT f@ if
|
|
|
|
:| Gord entity>pos world>tile
|
|
|
|
2dup N activate-dir
|
|
|
|
2dup S activate-dir
|
|
|
|
2dup E activate-dir
|
|
|
|
W activate-dir |; sched
|
|
|
|
then ;
|
|
|
|
var hack-handled
|
|
|
|
: hacked 1 hack-handled ! ;
|
2020-04-04 17:27:40 +00:00
|
|
|
: hack-override? ( e -- e b )
|
|
|
|
dup EVHACK = if hacked drop EVNOP 1 else 0 then ;
|
|
|
|
|
2020-04-04 03:06:18 +00:00
|
|
|
: activate-libb
|
|
|
|
haslibb? if Libb entity-present? not if
|
|
|
|
:| 0 hack-handled !
|
|
|
|
Neut entity>pos world>tile touchable-entity-at EVHACK entity>do
|
|
|
|
hack-handled @ not if
|
|
|
|
libb say" don't think i can hack that."
|
|
|
|
then |; sched
|
|
|
|
then then ;
|
2020-02-02 23:33:07 +00:00
|
|
|
|
|
|
|
: touch-begin each 2dup more >rot drop drop ;
|
|
|
|
: touch-next dup if rdrop done then drop rswap ;
|
|
|
|
: touch-last ' done , ; immediate
|
|
|
|
: ;touch [ ' touch-last , ' [ , ] ; immediate
|
|
|
|
|
2020-04-04 03:06:18 +00:00
|
|
|
: neut-touch-libb ( x y -- b )
|
|
|
|
Libb entity>pos world>tile 2= isneut? and if
|
|
|
|
move-player
|
|
|
|
-100 -100 Libb entity.pos!
|
|
|
|
1
|
|
|
|
else 0 then ;
|
|
|
|
|
2020-02-02 23:33:07 +00:00
|
|
|
: check-player-touch ( x y -- b )
|
2020-04-04 03:06:18 +00:00
|
|
|
touch-begin neut-touch-libb
|
|
|
|
touch-next touchable-entity-at dup if EVTOUCH entity>do 1 then
|
2020-03-07 15:18:16 +00:00
|
|
|
touch-next touch-override
|
|
|
|
touch-next rexx-touch
|
|
|
|
touch-next do-gord-sit
|
2020-02-02 23:33:07 +00:00
|
|
|
touch-next out-of-bounds
|
|
|
|
touch-next player.canmove? not ;touch
|
|
|
|
|
|
|
|
: try-move-player
|
|
|
|
player entity-dst check-player-touch not if move-player then ;
|
|
|
|
|
|
|
|
: follow ( e -- )
|
2020-02-18 01:43:14 +00:00
|
|
|
Jaye entity>pos <rot entity.pos! NODIR player.prevdir ! ;
|
2020-02-02 23:33:07 +00:00
|
|
|
|
|
|
|
var q-level
|
2020-02-02 23:30:11 +00:00
|
|
|
: queue-level q-level ! ; userword
|
2020-02-02 23:33:07 +00:00
|
|
|
|
|
|
|
: player-tick
|
2020-03-07 23:55:18 +00:00
|
|
|
^SPACE key-pressed if player.state HASNEUT f@ if
|
2020-02-18 01:43:14 +00:00
|
|
|
player.state ISPROG fnot!
|
|
|
|
isprog? if prog-view else human-view then
|
2020-03-07 23:55:18 +00:00
|
|
|
then then
|
2020-04-04 03:06:18 +00:00
|
|
|
^Z key-pressed if
|
|
|
|
isprog? if activate-libb else activate-gord then
|
|
|
|
then
|
2020-02-02 23:33:07 +00:00
|
|
|
0 ^LEFT key-down if drop 1 W player entity.dir ! then
|
|
|
|
^RIGHT key-down if drop 1 E player entity.dir ! then
|
|
|
|
^UP key-down if drop 1 N player entity.dir ! then
|
|
|
|
^DOWN key-down if drop 1 S player entity.dir ! then
|
|
|
|
if ' try-move-player sched then ;
|
|
|
|
|
|
|
|
( S T U F F )
|
2020-03-07 15:18:16 +00:00
|
|
|
defer reset-level userword
|
2020-02-02 23:33:07 +00:00
|
|
|
|
2020-04-02 23:11:01 +00:00
|
|
|
67 const ^F9
|
|
|
|
|
2020-04-04 03:06:18 +00:00
|
|
|
: boss-tick
|
|
|
|
^F9 key-pressed if
|
|
|
|
ticks boss
|
|
|
|
unfuck invalidate-map reloadtiles reloadportraits
|
|
|
|
ticks!
|
|
|
|
then ;
|
|
|
|
|
2020-04-10 15:27:25 +00:00
|
|
|
: quit-game hide-footer LEV_QUIT queue-level ;
|
|
|
|
: quit-tick
|
|
|
|
^ESC key-pressed if :|
|
|
|
|
disk :|
|
|
|
|
s" Resume play" ' noop yield
|
|
|
|
s" Save and quit to title" :| savegame quit-game |; yield
|
|
|
|
s" Don't save and quit to title" ' quit-game yield
|
|
|
|
done |; choose
|
|
|
|
|; sched then ;
|
|
|
|
|
2020-02-02 23:33:07 +00:00
|
|
|
: mode-move
|
|
|
|
player-tick
|
2020-04-04 03:06:18 +00:00
|
|
|
boss-tick
|
2020-04-10 15:27:25 +00:00
|
|
|
quit-tick
|
2020-09-06 15:11:36 +00:00
|
|
|
cheat-tick
|
2020-03-07 15:18:16 +00:00
|
|
|
|
2020-03-07 23:55:18 +00:00
|
|
|
ticking-objects @ if
|
|
|
|
ticking-objects @ links
|
|
|
|
each dup obj-entity EVTICK entity>do more
|
|
|
|
then
|
|
|
|
|
2020-02-02 23:30:22 +00:00
|
|
|
DEV if tick-mapedit jiles then
|
2020-02-02 23:33:07 +00:00
|
|
|
tick-debounce
|
2020-03-07 15:18:16 +00:00
|
|
|
|
2020-02-02 23:33:07 +00:00
|
|
|
q-level @ dup if
|
|
|
|
0 q-level !
|
|
|
|
reset-level
|
2020-04-10 15:27:25 +00:00
|
|
|
dup LEV_QUIT = if
|
2020-04-20 22:33:13 +00:00
|
|
|
drop clear-pages title
|
2020-04-10 15:27:25 +00:00
|
|
|
else
|
|
|
|
loadlevel
|
|
|
|
party each follow more
|
|
|
|
then
|
2020-02-02 23:33:07 +00:00
|
|
|
else drop then ;
|
|
|
|
|
2020-04-04 03:06:18 +00:00
|
|
|
: mode-wait tick-debounce boss-tick ;
|
|
|
|
|
2020-02-02 23:33:07 +00:00
|
|
|
: draw-entity
|
|
|
|
>r r@ entity.x @ r@ entity.y @
|
|
|
|
r@ entity.dir @ <r entity>sprite
|
|
|
|
sprite-bob draw-sprite ;
|
|
|
|
|
|
|
|
var glitchlevel
|
2020-02-02 23:29:49 +00:00
|
|
|
var quaking
|
2020-02-02 23:33:07 +00:00
|
|
|
|
|
|
|
: full-draw
|
2020-02-02 23:29:49 +00:00
|
|
|
quaking @ not if
|
|
|
|
player entity.x @ 152 -
|
|
|
|
player entity.y @ 92 -
|
|
|
|
scroll
|
|
|
|
else
|
|
|
|
0 ticks 3 % 13 * 8 % scroll
|
|
|
|
then
|
2020-02-02 23:33:07 +00:00
|
|
|
|
2020-03-07 15:18:16 +00:00
|
|
|
party each dup Jaye != if draw-entity else drop then more
|
|
|
|
Jaye draw-entity
|
2020-02-18 01:43:14 +00:00
|
|
|
player.state HASNEUT f@ if Neut draw-entity then
|
2020-04-04 03:06:18 +00:00
|
|
|
Libb entity-present? if Libb draw-entity then
|
2020-03-07 23:55:18 +00:00
|
|
|
visible-objects@ if
|
|
|
|
visible-objects@ links each dup obj-entity draw-entity more
|
2020-02-02 23:30:00 +00:00
|
|
|
then
|
2020-02-02 23:33:07 +00:00
|
|
|
entities each draw-entity more
|
|
|
|
|
2020-02-02 23:30:22 +00:00
|
|
|
DEV if
|
2020-02-02 23:33:07 +00:00
|
|
|
mouseworldpos 4 draw-sprite
|
|
|
|
then
|
|
|
|
glitchlevel @ glitch
|
|
|
|
draw-screen
|
|
|
|
draw-footer ;
|
|
|
|
|
2020-02-02 23:30:00 +00:00
|
|
|
var defining-objects-head
|
|
|
|
var defining-objects-ptr
|
2020-03-07 23:55:18 +00:00
|
|
|
: objects: create here 0 , 0 , 0 ,
|
2020-02-02 23:30:00 +00:00
|
|
|
0 defining-objects-head !
|
|
|
|
defining-objects-ptr !
|
2020-03-07 23:55:18 +00:00
|
|
|
does>
|
|
|
|
dup @ objects !
|
|
|
|
dup cell + @ ticking-objects !
|
2020-04-02 23:11:01 +00:00
|
|
|
2 cells + @ visible-objects ! ;
|
2020-03-07 23:55:18 +00:00
|
|
|
|
|
|
|
: obj-link-head! ( index -- )
|
|
|
|
cells defining-objects-ptr @ + defining-objects-head @ swap ! ;
|
2020-02-02 23:30:00 +00:00
|
|
|
|
|
|
|
: link-object ( entity -- )
|
2020-03-07 23:55:18 +00:00
|
|
|
here defining-objects-head @ , swap , defining-objects-head !
|
|
|
|
0 obj-link-head! ;
|
|
|
|
|
|
|
|
: obj-ticking! 1 obj-link-head! ;
|
|
|
|
: obj-visible! 2 obj-link-head! ;
|
2020-02-02 23:30:00 +00:00
|
|
|
|
|
|
|
: entity>tile ( entity -- tile ) entity>pos world>tile tile ;
|
|
|
|
: entity>tile? ( entity expected - b ) swap entity>tile b@ = ;
|
2020-02-02 23:30:11 +00:00
|
|
|
: responder>tile? ( expected - b ) responder swap entity>tile? ;
|
2020-02-02 23:30:00 +00:00
|
|
|
|
|
|
|
: toggleval ( off on val -- off|on ) over = not if swap then drop ;
|
|
|
|
: toggletile ( entity off on -- )
|
|
|
|
<rot >r r@ entity>tile b@ toggleval <r entity>tile b! invalidate-map ;
|
|
|
|
|
|
|
|
: respondertile! ( tile -- ) responder entity>tile b! invalidate-map ;
|
|
|
|
|
2020-02-18 01:43:14 +00:00
|
|
|
: blankentity array here >r N ' {tileent} allotentity <r ;
|
2020-02-02 23:30:00 +00:00
|
|
|
|
2020-02-02 23:30:11 +00:00
|
|
|
: linked-entity responder entity.user @ execute ;
|
|
|
|
|
2020-03-07 23:55:18 +00:00
|
|
|
: timer>count ( e -- count ) entity.user cell + @ ; userword
|
|
|
|
: timer.start ( e -- p ) entity.user 2 cells + ; userword
|
|
|
|
: timer>donewaiting? ( e -- b )
|
|
|
|
dup timer>count swap timer.start @ still-waiting? not ; userword
|
|
|
|
|
2020-02-02 23:30:11 +00:00
|
|
|
: create-object blankentity dup link-object ;
|
|
|
|
: create-linked-object blankentity swap , dup link-object ;
|
2020-03-28 20:58:47 +00:00
|
|
|
: create-extra-linked-object blankentity swap , swap ,
|
|
|
|
dup link-object ;
|
2020-03-07 23:55:18 +00:00
|
|
|
: create-timed-object blankentity swap , swap , 0 ,
|
|
|
|
dup link-object obj-ticking! ;
|
|
|
|
|
2020-02-02 23:30:11 +00:00
|
|
|
: listener! ( entity listener ) swap ! ;
|
|
|
|
|
2020-02-26 03:12:40 +00:00
|
|
|
: handle-onoff ( ev on off -- )
|
|
|
|
<rot dup EVDEACT = if drop swap drop respondertile! else
|
|
|
|
dup EVACT = if drop drop respondertile! else
|
|
|
|
dup EVTOG = if drop responder >rot toggletile else
|
|
|
|
drop drop drop then then then ;
|
|
|
|
|
2020-02-02 23:30:11 +00:00
|
|
|
: entering-door? ( ev -- b )
|
2020-02-18 01:43:14 +00:00
|
|
|
EVTOUCH = isneut? not and DOOR-OPENED responder>tile? and ;
|
2020-02-02 23:30:00 +00:00
|
|
|
|
2020-02-02 23:30:11 +00:00
|
|
|
: door-listener ( ev -- )
|
|
|
|
dup entering-door? if move-player then
|
2020-04-18 20:53:11 +00:00
|
|
|
DOOR-CLOSED responder>tile? swap
|
|
|
|
DOOR-OPENED DOOR-CLOSED handle-onoff
|
|
|
|
DOOR-CLOSED responder>tile? != if
|
|
|
|
DOOR-CLOSED responder>tile? if sfx-doorclose else sfx-dooropen then
|
|
|
|
then ;
|
2020-02-02 23:30:11 +00:00
|
|
|
|
|
|
|
: door create-object ' door-listener listener! ;
|
|
|
|
|
|
|
|
: exitdoor create-linked-object
|
|
|
|
:| dup door-listener entering-door? if
|
2020-03-07 23:55:18 +00:00
|
|
|
gord-follow? not gord-present? and if
|
2020-02-22 20:15:00 +00:00
|
|
|
jaye say" I'm not leaving Gord behind."
|
2020-04-04 03:06:18 +00:00
|
|
|
else Libb entity-present? if
|
|
|
|
neut say" I SHOULD PROBABLY RETRIEVE\LIBB."
|
2020-02-22 20:15:00 +00:00
|
|
|
else
|
|
|
|
responder entity.user @ queue-level
|
2020-04-04 03:06:18 +00:00
|
|
|
then then
|
2020-02-02 23:30:11 +00:00
|
|
|
then |; listener! ;
|
|
|
|
|
2020-02-26 03:12:40 +00:00
|
|
|
: statechange? ( ev -- b )
|
|
|
|
dup EVACT = over EVDEACT = or swap EVTOG = or ;
|
|
|
|
|
|
|
|
: handle-link ( ev ontile -- )
|
|
|
|
swap statechange? if
|
|
|
|
responder>tile? if EVACT else EVDEACT then
|
|
|
|
linked-entity swap entity>do
|
|
|
|
else drop then ;
|
|
|
|
|
2020-03-07 23:55:18 +00:00
|
|
|
: handle-switch-touch ( ev -- )
|
|
|
|
dup EVTOUCH = isneut? and if move-player then
|
|
|
|
dup EVTOUCH = isrexx? not and if
|
|
|
|
responder EVTOG entity>do
|
|
|
|
isjaye? if wait-for-arrow-up then
|
|
|
|
then
|
|
|
|
dup SWITCH-ON SWITCH-OFF handle-onoff
|
|
|
|
SWITCH-ON handle-link ;
|
|
|
|
|
|
|
|
: switch create-linked-object ' handle-switch-touch listener! ;
|
|
|
|
|
|
|
|
: timedswitch create-timed-object
|
|
|
|
:| dup EVTICK = if SWITCH-ON responder>tile? if
|
|
|
|
drop responder timer>donewaiting? if
|
|
|
|
EVDEACT
|
|
|
|
else ret then
|
|
|
|
then then
|
|
|
|
dup EVTOUCH = over EVACT = or if SWITCH-ON responder>tile? if
|
|
|
|
dup EVTOUCH = isneut? and if move-player then
|
|
|
|
drop EVNOP
|
|
|
|
then then
|
|
|
|
dup handle-switch-touch
|
|
|
|
statechange? if SWITCH-ON responder>tile? if
|
|
|
|
ticks responder timer.start !
|
|
|
|
then then |; listener! ;
|
2020-02-02 23:30:00 +00:00
|
|
|
|
2020-02-26 03:12:40 +00:00
|
|
|
: computer-on? ( entity -- b ) COMP-ON entity>tile? ;
|
2020-04-04 03:06:18 +00:00
|
|
|
: switch-on? ( entity -- b ) SWITCH-ON entity>tile? ;
|
2020-02-26 03:12:40 +00:00
|
|
|
|
|
|
|
: handle-teleport ( ev -- )
|
|
|
|
EVTOUCH = isneut? and COMP-ON responder>tile? and if
|
|
|
|
linked-entity dup computer-on? if
|
|
|
|
entity>pos Neut entity.pos!
|
2020-04-18 20:53:11 +00:00
|
|
|
sfx-zoop
|
2020-02-26 03:12:40 +00:00
|
|
|
else drop then
|
|
|
|
then ;
|
|
|
|
|
|
|
|
|
2020-02-02 23:30:00 +00:00
|
|
|
: computer blankentity swap , dup link-object
|
|
|
|
:| dup EVTOUCH = isjaye? and if responder EVACT entity>do then
|
2020-02-02 23:30:11 +00:00
|
|
|
dup EVTOUCH = isneut? and COMP-ON responder>tile? and if move-player then
|
2020-04-04 03:06:18 +00:00
|
|
|
dup EVHACK = if hacked libb say" nothing interesting on this one." then
|
2020-04-19 02:12:57 +00:00
|
|
|
COMP-OFF responder>tile? swap
|
2020-02-02 23:30:00 +00:00
|
|
|
dup COMP-ON COMP-OFF handle-onoff
|
2020-04-19 02:12:57 +00:00
|
|
|
handle-teleport
|
|
|
|
COMP-OFF responder>tile? != if
|
|
|
|
COMP-OFF responder>tile? if sfx-termoff else sfx-termon then
|
|
|
|
then |; listener! ;
|
2020-02-02 23:30:11 +00:00
|
|
|
|
|
|
|
: scanner create-linked-object
|
|
|
|
:| dup EVTOUCH = isneut? and if
|
|
|
|
move-player
|
|
|
|
responder EVACT entity>do
|
|
|
|
then
|
2020-04-04 03:06:18 +00:00
|
|
|
dup EVHACK = if
|
2020-04-19 02:12:57 +00:00
|
|
|
sfx-libb
|
2020-04-04 03:06:18 +00:00
|
|
|
libb say" that's easy."
|
|
|
|
responder entity>pos Libb entity.pos!
|
|
|
|
hacked
|
|
|
|
then
|
|
|
|
dup EVUNTOUCH = isneut? and if
|
|
|
|
Libb entity>pos responder entity>pos 2= not if
|
|
|
|
responder EVDEACT entity>do
|
|
|
|
then
|
|
|
|
then
|
2020-02-02 23:30:11 +00:00
|
|
|
dup SCAN-ON SCAN-OFF handle-onoff
|
|
|
|
SCAN-ON handle-link |; listener! ;
|
|
|
|
|
2020-02-22 03:38:32 +00:00
|
|
|
: defrexx array here >r S ' {rexx} allotentity <r
|
2020-03-07 23:55:18 +00:00
|
|
|
dup link-object obj-visible!
|
2020-02-22 03:38:32 +00:00
|
|
|
:| EVTOUCH = isneut? and if
|
|
|
|
move-player
|
|
|
|
responder posessed-rexx !
|
|
|
|
-100 -100 Neut entity.pos!
|
2020-04-19 02:12:57 +00:00
|
|
|
sfx-rexx
|
2020-02-22 03:38:32 +00:00
|
|
|
then |; listener! ;
|
|
|
|
|
2020-02-17 02:36:02 +00:00
|
|
|
0 const unconnected
|
|
|
|
|
2020-02-02 23:30:11 +00:00
|
|
|
( usage: entity :noname [ ev -- ev ] ... chain-listener ;
|
|
|
|
ONLY works with :noname at top-level interpretation time - not :| |;
|
|
|
|
compiles a reference to the previous listener into the :noname func
|
|
|
|
and sets the listener of the entity on the stack to the new func )
|
2020-02-02 23:30:00 +00:00
|
|
|
|
2020-02-02 23:30:11 +00:00
|
|
|
: chain-listener ( entity xp -- ) swap dup @ , ! ; immediate
|
2020-02-18 01:43:11 +00:00
|
|
|
: cancel-ev ( ev -- EVNOP ) drop EVNOP ;
|
2020-02-02 23:30:00 +00:00
|
|
|
|
2020-02-26 03:12:40 +00:00
|
|
|
: with-gord Gord follow 1 player.state HASGORD f! ;
|
2020-04-04 03:06:18 +00:00
|
|
|
: with-libb 1 player.state HASLIBB f! ;
|
2020-02-26 03:12:40 +00:00
|
|
|
|
2020-02-22 20:15:00 +00:00
|
|
|
Gord :noname
|
2020-03-07 23:55:18 +00:00
|
|
|
dup EVTOUCH = isjaye? and gord-follow? not and if
|
2020-03-07 15:18:16 +00:00
|
|
|
player.state GORDSIT f@ if
|
|
|
|
1 player.state HASGORD f!
|
|
|
|
Gord player face
|
|
|
|
Gord move-entity
|
|
|
|
0 player.state GORDSIT f!
|
|
|
|
Gord follow
|
|
|
|
else move-player with-gord then
|
2020-02-22 20:15:00 +00:00
|
|
|
then chain-listener ;
|
|
|
|
|
2020-03-07 15:18:16 +00:00
|
|
|
Gord @ const gord-listener
|
|
|
|
: chain-gord-listener gord-listener execute ;
|
|
|
|
|
|
|
|
:noname
|
2020-04-19 02:12:57 +00:00
|
|
|
' norm-rexxinst ' rexxinst redefine
|
2020-04-10 23:16:52 +00:00
|
|
|
HASNEUT player.state !
|
|
|
|
human-view
|
2020-03-07 23:55:18 +00:00
|
|
|
0 objects ! 0 ticking-objects ! 0 visible-objects !
|
2020-03-07 15:18:16 +00:00
|
|
|
Gord gord-listener listener!
|
|
|
|
' noop ' on-gord-sit redefine
|
2020-03-07 23:55:18 +00:00
|
|
|
:| gord-follow? not gord-present? and if Gord yield then
|
2020-03-07 15:18:16 +00:00
|
|
|
done |; ' entities redefine
|
|
|
|
:| drop drop 0 |; ' touch-override redefine ; ' reset-level redefine
|
2020-02-26 03:12:40 +00:00
|
|
|
|
2020-02-02 23:33:07 +00:00
|
|
|
:noname
|
|
|
|
reset-level
|
2020-02-17 02:36:02 +00:00
|
|
|
' mode-move ' tick redefine
|
2020-02-02 23:33:07 +00:00
|
|
|
' full-draw ' draw redefine
|
2020-02-22 20:15:00 +00:00
|
|
|
:| Jaye yield
|
2020-03-07 23:55:18 +00:00
|
|
|
gord-follow? if Gord yield then
|
2020-02-22 20:15:00 +00:00
|
|
|
done |; ' party redefine
|
2020-04-04 03:06:18 +00:00
|
|
|
:| ' mode-wait ' tick redefine |; ' any-job-started redefine
|
2020-09-06 15:11:36 +00:00
|
|
|
:| hide-footer ' mode-move ' tick redefine |; ' all-jobs-complete redefine
|
2020-02-02 23:33:07 +00:00
|
|
|
; ' onload redefine
|