diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 226fddc..99d736e 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -29,7 +29,7 @@ :strength 6 :constitution 12 :dexterity 19 :intelligence 14 :money 100 :game-admin T - :item '("Anaklusmos") + :item '("Anaklusmos" "Lightning bolt") :weapon "Lightning bolt"))) (add-player player) (play-game (player-name player)))) diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 226fddc..99d736e 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -29,7 +29,7 @@ :strength 6 :constitution 12 :dexterity 19 :intelligence 14 :money 100 :game-admin T - :item '("Anaklusmos") + :item '("Anaklusmos" "Lightning bolt") :weapon "Lightning bolt"))) (add-player player) (play-game (player-name player)))) diff --git a/lisp/game-objects.lisp b/lisp/game-objects.lisp index 1daf24e..3183153 100644 --- a/lisp/game-objects.lisp +++ b/lisp/game-objects.lisp @@ -19,6 +19,7 @@ (item NIL) (monster NIL) (npc NIL) + (spawns NIL) (dark NIL) (function "")) @@ -38,7 +39,7 @@ (strength 0) (dexterity 0) (aggression 0) - (spawn-probability 0) + (spawn 0) (item NIL) (weapon "") (armour-class 0)) @@ -47,7 +48,7 @@ (name "") (description "") (cost 0) - (weapon "no") + (weapon) (function NIL)) (defstruct weapon @@ -115,7 +116,14 @@ (setf (place-monster p) (objectify-name-list 'monster (place-monster p))) p)) - + +(defun spawn-monsters (place) + "Spawn monsters in this location" + (let ((p (if (stringp place) (get-game-object 'place place) place))) + (dolist (m (place-spawns p) p) + (let ((monster (get-game-object 'monster m))) + (when (< (random 100) (monster-spawn monster)) + (set-object-attribute p 'monster (copy-monster monster))))))) (let ((list-function (make-list-function 'place NIL))) (defun list-place-objects (object-type place) diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 226fddc..99d736e 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -29,7 +29,7 @@ :strength 6 :constitution 12 :dexterity 19 :intelligence 14 :money 100 :game-admin T - :item '("Anaklusmos") + :item '("Anaklusmos" "Lightning bolt") :weapon "Lightning bolt"))) (add-player player) (play-game (player-name player)))) diff --git a/lisp/game-objects.lisp b/lisp/game-objects.lisp index 1daf24e..3183153 100644 --- a/lisp/game-objects.lisp +++ b/lisp/game-objects.lisp @@ -19,6 +19,7 @@ (item NIL) (monster NIL) (npc NIL) + (spawns NIL) (dark NIL) (function "")) @@ -38,7 +39,7 @@ (strength 0) (dexterity 0) (aggression 0) - (spawn-probability 0) + (spawn 0) (item NIL) (weapon "") (armour-class 0)) @@ -47,7 +48,7 @@ (name "") (description "") (cost 0) - (weapon "no") + (weapon) (function NIL)) (defstruct weapon @@ -115,7 +116,14 @@ (setf (place-monster p) (objectify-name-list 'monster (place-monster p))) p)) - + +(defun spawn-monsters (place) + "Spawn monsters in this location" + (let ((p (if (stringp place) (get-game-object 'place place) place))) + (dolist (m (place-spawns p) p) + (let ((monster (get-game-object 'monster m))) + (when (< (random 100) (monster-spawn monster)) + (set-object-attribute p 'monster (copy-monster monster))))))) (let ((list-function (make-list-function 'place NIL))) (defun list-place-objects (object-type place) diff --git a/lisp/ui.lisp b/lisp/ui.lisp index d4d8720..f2699b1 100644 --- a/lisp/ui.lisp +++ b/lisp/ui.lisp @@ -214,6 +214,7 @@ (clear-screen) (debugging "~&~A is going to ~A." (player-name player) location) (change-player-location player location) + (spawn-monsters location) (add-player-experience player 1) (describe-place location (player-night-vision player))) @@ -352,7 +353,7 @@ (format t "~&You no longer have any weapon equipped.") (return-from equip)) (if (and (member new-weapon (player-item player) :test #'equalp) - (equalp (item-weapon (get-game-object 'item new-weapon)) "yes")) + (item-weapon (get-game-object 'item new-weapon))) (progn (setf (player-weapon player) new-weapon) (format t "~&You have equipped: ~A" new-weapon)) @@ -399,6 +400,8 @@ (format t "~&You hit! ~A points damage." damage) (when (> 1 (monster-health monster)) (let ((experience (round (average m-str m-dex)))) + (dolist (i (monster-item monster)) + (set-object-attribute place 'item i)) (remove-object-attribute place 'monster monster) (add-player-experience player experience)