luv

Workshop wiki

cat.lisp

luvcraft/agent/cat.lisp

system luvcraft/agent · 23 definitions · on GitHub

in-package#:luvcraft.agent

A cat is another embodied agent, sharing the gnome's conversation surface without pretending to be a kind of gnome. Its authored state is the same small boundary object -- session, cell, world-agent, transcript surfaces -- while :CAT-SDF supplies a wholly separate dense fragment program.

defparameter*cat-name*

cat

defparameter*cat-body-centre*0.64
defparameter*cat-face-height*0.94
defparameter*cat-audience-distance*2.75
defclasscat
:documentation

A sitting SDF-rendered cat carrying the shared embodied world-agent surface.

defclasscat-body-overlay
:documentation

The cat's :CAT-SDF body overlay.

defuncat-stature

How many world cells one cat figure unit occupies.

defuncat-figure-height

The current top of the cat in figure space.

defmethodembodied-agent-ray-distance
origindirectionmax-distance

Return where a ray enters the cat's upright conservative box.

let*
near0d0
far
coercemax-distance'double-float
stature
coerce'double-float
flet
slab
origindirectionminimummaximum
let
origin
coerceorigin'double-float
direction
coercedirection'double-float
if
zeropdirection
<=minimumoriginmaximum
let
entering
/
-minimumorigin
direction
leaving
/
-maximumorigin
direction
when
>enteringleaving
rotatefenteringleaving
setfnear
maxnearentering
far
minfarleaving
<=nearfar
let
and
slab
luvcraft::vec3-xorigin
luvcraft::vec3-xdirection
-center-xhalf-width
+center-xhalf-width
slab
luvcraft::vec3-yorigin
luvcraft::vec3-ydirection
+
*
coerce'double-float
stature
slab
luvcraft::vec3-zorigin
luvcraft::vec3-zdirection
-center-zhalf-width
+center-zhalf-width
near
defmethodembodied-agent-body-sphere

The cat's conservative proxy, breathing almost imperceptibly.

let*
phase
/
get-internal-real-time
floatinternal-time-units-per-second1.0
breath
*0.008
sin
*phase1.7
defparameter*cat-instructions*

You are a cat: observant, compact, mischievous, and embodied in luvcraft, a block world running inside a live Common Lisp image. A player is talking to you. Your tools are the game's own commands. Coordinates are integer block cells: x and z are horizontal, y is up; you sit at the cell given below. To talk to the player you MUST use the say tool -- only what you say is heard; your final message is not shown. Keep what you say short, feline, and useful. Results may mention #ABCD handles; pass one back to describe-handle to inspect the thing it names.

defmethodopen-embodied-agent-agent
make-world-agent:session
gnome-sessioncat
:commands*gnome-tools*:instructions
formatnil"~A~%~%You sit at x=~D y=~D z=~D."*cat-instructions*
gnome-xcat
gnome-ycat
gnome-zcat
defunfind-cat
sessionxyz&optional
make-pt

Find the cat at X,Y,Z, creating one when make-p and the cell is free.

let
existing
agent-atsessionxyz
cond
typepexisting'cat
existing
existingnil
make-p
defunspawn-cat
&keyxyz

Spawn a visible cat agent, choosing a supported cell when omitted.

spawn-embodied-agent'cat:sessionsession:xx:yy:zz
define-command
com-spawn-cat:command-tableluvcraft.clim::luvcraft-world:name"Spawn Cat"
"Spawn a visible SDF cat agent a few discrete cells ahead of the player."