Skip to content

Commit

Permalink
foo
Browse files Browse the repository at this point in the history
  • Loading branch information
David O'Toole committed Dec 11, 2009
1 parent 92edc32 commit 2264291
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 13 deletions.
6 changes: 6 additions & 0 deletions cells.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,12 @@ Return ITEM if successful, nil otherwise."
[delete-from-world cell]
[add-item self cell])))

(define-method use cell (user)
"Return non-nil if cell is used up and should disappear."
(declare (ignore user))
(prog1 nil
[say self "Nothing happens."]))

(define-method resolve cell (reference &optional category)
"Accept a REFERENCE to a cell, and try to get the real cell.
The REFERENCE may be an object, one of the `*compass-directions*', an
Expand Down
Binary file modified forest/forest.fasl
Binary file not shown.
58 changes: 45 additions & 13 deletions forest/forest.lisp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; forest.lisp --- forest exploration stories
;;; forest.lisp --- forest exploration story

;; Copyright (C) 2009 David O'Toole

Expand Down Expand Up @@ -51,9 +51,9 @@
:fireflies 100
:graveyards 8
:ruins 10
:tree-grain 0.8
:tree-density 40
:water-grain 0.6
:tree-grain 0.5
:tree-density 30
:water-grain 0.2
:water-density 90
:water-cutoff 0.2))

Expand Down Expand Up @@ -366,12 +366,12 @@
(name :initform "Player")
(dead :initform nil)
(hit-points :initform (make-stat :base 30 :min 0 :max 30))
(rations :initform (make-stat :base 5 :min 0 :max 20))
(hunger :initform (make-stat :base 0 :min 0 :max 1000))
(hunger-damage-clock :initform 0)
(hearing-range :initform 1000)
(firing-with :initform :left-hand)
(arrows :initform (make-stat :base 40 :min 0 :max 40))
(rations :initform (make-stat :base 5 :min 0 :max 20))
(speed :initform (make-stat :base 10 :min 0 :max 10))
(strength :initform (make-stat :base 15 :min 0 :max 50))
(defense :initform (make-stat :base 15 :min 0 :max 50))
Expand All @@ -383,6 +383,16 @@
(stepping :initform t)
(categories :initform '(:actor :player :obstacle :target)))

(define-method use-item player (n)
(assert (integerp n))
(let ((object [item-at self n]))
(if object
(if [in-category object :equipment]
[equip self n]
(when [use object self]
[remove-item self object]))
[say self "There is nothing to use there."])))

(define-method enter player ()
(let ((gateway [category-at-p *world* <row> <column> :gateway]))
(if (null gateway)
Expand Down Expand Up @@ -592,16 +602,23 @@

(defcell herb
(tile :initform "herb")
(categories :initform '(:equipment :item))
(categories :initform '(:item))
(equip-for :initform '(:right-hand :left-hand)))

(define-method step herb (stepper)
(when [is-player stepper]
[say self "You found a healing herb."]
[take stepper :direction :here :category :item]))

(define-method use herb (user)
(when (and user (has-field :hit-points user))
(prog1 t
[stat-effect user :hit-points 10]
[say self "You consume the healing herb and quickly feel better."])))

(defcell body
(tile :initform "body"))
(tile :initform "body")
(categories :initform '(:exclusive)))

(define-method step body (stepper)
(when [is-player stepper]
Expand Down Expand Up @@ -742,7 +759,8 @@
(trace-rectangle #'drop-floor (1+ row) (1+ column) (- height 2) (- width 2) :fill))
(dotimes (n (random 3))
(percent-of-time 70
[drop-cell self (clone =body=) (+ 1 row (random (- height 1))) (+ 1 column (random (- width 1)))])))))
[drop-cell self (clone =body=) (+ 1 row (random (- height 1))) (+ 1 column (random (- width 1)))
:exclusive t :probe t])))))

(define-method generate forest (&key (height *forest-height*)
(width *forest-width*)
Expand Down Expand Up @@ -892,6 +910,11 @@
("L" (:control) "fire :east .")
("J" (:control) "fire :south .")
;;
("1" nil "use-item 0 .")
("2" nil "use-item 1 .")
("1" (:control) "drop-item 0 .")
("2" (:control) "drop-item 1 .")
;;
("ESCAPE" nil "restart .")
("RETURN" nil "enter .")
;;
Expand Down Expand Up @@ -954,8 +977,8 @@
[print self " "])
[print self "EMPTY "])))

(define-method print-inventory-slot status (slot-number)
[print self (format nil "[~D]: " slot-number)]
(define-method print-inventory-slot status (slot-number &key show-as)
[print self (format nil "[~D]: " (or show-as slot-number))]
(let ((item [item-at <character> slot-number]))
(if item
(clon:with-field-values (name tile) item
Expand Down Expand Up @@ -986,8 +1009,8 @@

[newline self]
[print self " Inventory: "]
[print-inventory-slot self 0]
[print-inventory-slot self 1]
[print-inventory-slot self 0 :show-as 1]
[print-inventory-slot self 1 :show-as 2]
[newline self]))

;;; Main program.
Expand All @@ -1003,6 +1026,7 @@
(let* ((prompt (clone =room-prompt=))
(universe (clone =universe=))
(narrator (clone =narrator=))
(quickhelp (clone =formatter=))
(player (clone =player=))
(status (clone =status=))
(viewport (clone =viewport=)))
Expand All @@ -1021,6 +1045,14 @@
[move narrator :x 0 :y (- *room-window-height* 80)]
[set-verbosity narrator 0]
;;
[resize quickhelp :height 85 :width 250]
[move quickhelp :y (- *room-window-height* 100) :x (- *room-window-width* 250)]
(let ((text (find-resource-object "quickhelp-message")))
(dolist (line text)
(dolist (string line)
(funcall #'send nil :print-formatted-string quickhelp string))
[newline quickhelp]))
;;
[play universe
:address (generate-forest-address 1)
:player player
Expand All @@ -1036,6 +1068,6 @@
[adjust viewport]
[loadout player]
;;
(xe2:install-widgets prompt viewport narrator status)))
(xe2:install-widgets prompt viewport narrator status quickhelp)))

(init-forest)
4 changes: 4 additions & 0 deletions forest/forest.org
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
** TODO map
** TODO don't generate bodies in walls
** TODO fix arrow behavior
** TODO record music/chant vox samples for monastery approach
** TODO fix being able to travel easily thru water, fix too much water
** TODO FIX joystick button handling
** TODO arduous journey overworld travel / food
Expand Down
2 changes: 2 additions & 0 deletions forest/forest.pak
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
(:name "gravestone" :type :image :file "gravestone.png")
(:name "wooden-bow" :type :image :file "wooden-bow.png")

(:name "quickhelp-message" :type :formatted-text :file "quickhelp.text")

(:name "player" :type :image :file "player.png")
(:name "passage-gateway" :type :image :file "mountain.png")
(:name "herb" :type :image :file "herb.png")
Expand Down
Binary file added forest/monks.wav
Binary file not shown.
Binary file added forest/mountain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forest/sanctuary-map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forest/tundra-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forest/tundra-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forest/tundra-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forest/tundra-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forest/tundra-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forest/tundra-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2264291

Please sign in to comment.