diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index aa325f6..3f7e00e 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -228,4 +228,5 @@ health 10 strength 1 dexterity 1 - item "Hunny" \ No newline at end of file + item "Hunny" + death-msg "The Heffalump runs away." ;TODO \ No newline at end of file diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index aa325f6..3f7e00e 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -228,4 +228,5 @@ health 10 strength 1 dexterity 1 - item "Hunny" \ No newline at end of file + item "Hunny" + death-msg "The Heffalump runs away." ;TODO \ No newline at end of file diff --git a/lisp/game-objects.lisp b/lisp/game-objects.lisp index 16ac5f0..8b276b9 100644 --- a/lisp/game-objects.lisp +++ b/lisp/game-objects.lisp @@ -19,21 +19,17 @@ (monster NIL) (npc NIL) (spawns NIL) - ;(entry-hook NIL) - ;(exit-hook NIL) - ;; XXX Get rid of the following? (If hooks are available) + (entry-hook "") + (exit-hook "") (requires "")) ;Can be an ability or an item - -;;; WORK IN PROGRESS >>> - (defstruct npc (name "") (description "") (says "") (sells NIL) - (quest "")) - ;(interaction-hook NIL)) + (quest "") + (interaction-hook "")) (defstruct monster (name "") @@ -45,9 +41,9 @@ (spawn 0) (item NIL) (weapon "") - (armour-class 0)) - ;(attack-hook NIL) - ;(meet-hook NIL)) + (armour-class 0) + (attack-hook "") + (death-msg "")) (defstruct item ;; XXX Items containing items? diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index aa325f6..3f7e00e 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -228,4 +228,5 @@ health 10 strength 1 dexterity 1 - item "Hunny" \ No newline at end of file + item "Hunny" + death-msg "The Heffalump runs away." ;TODO \ No newline at end of file diff --git a/lisp/game-objects.lisp b/lisp/game-objects.lisp index 16ac5f0..8b276b9 100644 --- a/lisp/game-objects.lisp +++ b/lisp/game-objects.lisp @@ -19,21 +19,17 @@ (monster NIL) (npc NIL) (spawns NIL) - ;(entry-hook NIL) - ;(exit-hook NIL) - ;; XXX Get rid of the following? (If hooks are available) + (entry-hook "") + (exit-hook "") (requires "")) ;Can be an ability or an item - -;;; WORK IN PROGRESS >>> - (defstruct npc (name "") (description "") (says "") (sells NIL) - (quest "")) - ;(interaction-hook NIL)) + (quest "") + (interaction-hook "")) (defstruct monster (name "") @@ -45,9 +41,9 @@ (spawn 0) (item NIL) (weapon "") - (armour-class 0)) - ;(attack-hook NIL) - ;(meet-hook NIL)) + (armour-class 0) + (attack-hook "") + (death-msg "")) (defstruct item ;; XXX Items containing items? diff --git a/lisp/ui.lisp b/lisp/ui.lisp index 018acdb..992ea75 100644 --- a/lisp/ui.lisp +++ b/lisp/ui.lisp @@ -12,6 +12,7 @@ ;; TODO Out-source all game logic to other modules ;; (This module should be purely UI) +;; Yeah, probably not going to happen ;-) (defun play-game () @@ -166,10 +167,14 @@ (format t "~&You cannot enter this place unless you have: ~A" req) (return-from goto)))) ;; Change places + (let ((hook (place-exit-hook (get-game-object 'place location)))) ;exit hook + (unless (zerop (length hook)) (funcall (read-from-string hook) player))) (clear-screen) (debugging "~&~A is going to ~A." (player-name player) location) (change-player-location player location) (spawn-monsters location) + (let ((hook (place-entry-hook (get-game-object 'place location)))) ;entry hook + (unless (zerop (length hook)) (funcall (read-from-string hook) player))) (add-player-experience player 1) (describe-place location)) @@ -193,7 +198,6 @@ (defun talk (player &optional npc-name) "Talk to the desired NPC" - ;; TODO Add interactive facility (unless npc-name (format t "~&Please specify an NPC to talk to!") (return-from talk)) @@ -209,6 +213,10 @@ (format t "~&~A is not here!" npc-name) (return-from talk)) (format t "~&~A: ~A" (string-upcase npc-name) (npc-says npc)) + ;; Interaction hook + (let ((hook (npc-interaction-hook npc))) + (unless (zerop (length hook)) + (funcall (read-from-string hook) player))) ;; Trade with the NPC (when (and (npc-sells npc) (y-or-n-p "Trade with ~A?" npc-name)) @@ -348,14 +356,20 @@ (m-str (monster-strength monster)) (m-dex (monster-dexterity monster)) (m-ac (monster-armour-class monster)) - (m-weapon (get-game-object 'weapon (monster-weapon monster))) + (m-weapon (if (not (equalp (monster-weapon monster) "")) ;lbyl + (get-game-object 'weapon (monster-weapon monster)) + (make-weapon :name "Fists" :damage 0))) (p-str (player-strength player)) (p-dex (player-dexterity player)) (p-ac (player-armour-class player)) (p-weapon (if (not (equalp (player-weapon player) "")) ;lbyl (get-game-object 'weapon (player-weapon player)) (make-weapon :name "Fists" :damage 0))) + (monster-hook (monster-attack-hook monster)) (damage 0)) + ;; Call the monster's attack hook + (unless (zerop (length monster-hook)) + (funcall (read-from-string monster-hook) player)) ;; Print information about the combattants (format t "~&Health ~A: ~A Health ~A: ~A" (player-name player) (player-health player) opponent (monster-health monster)) @@ -374,8 +388,10 @@ (remove-object-attribute place 'monster monster) (add-player-experience player experience) - (format t "~&You killed the monster! ") - (format t "~A points experience." experience)))) + (if (monster-death-msg monster) + (format t "~&~A" (monster-death-msg monster)) + (format t "~&You killed the monster!")) + (format t "~&~A points experience." experience)))) ((minusp damage) (change-player-health player damage) (format t "~&You missed. Your opponent hit! ")