Paste number 96672: snippet of clon cl code

Paste number 96672: snippet of clon cl code
Pasted by: dto
When:1 year, 10 months ago
Share:Tweet this! | http://paste.lisp.org/+22LC
Channel:None
Paste contents:
Raw Source | XML | Display As
(defcell shocker 
  (tile :initform "shocker")
  (description :initform "Creeps about until catching sight of the player;
Then it fires and gives chase.")
  (team :initform :enemy)
  (color :initform :cyan)
  (waveform :initform :square)
  (hit-points :initform (make-stat :base 2 :min 0 :max 45))
  (movement-cost :initform (make-stat :base 10))
  (max-items :initform (make-stat :base 2))
  (speed :initform (make-stat :base 10 :min 0 :max 25))
  (strength :initform (make-stat :base 10))
  (defense :initform (make-stat :base 10))
  (hearing-range :initform 15)
  (energy :initform (make-stat :base 40 :min 0 :max 40 :unit :gj))
  (movement-cost :initform (make-stat :base 10))
  (max-items :initform (make-stat :base 2))
  (stepping :initform t)
  (direction :initform :north)
  (attacking-with :initform nil)
  (firing-with :initform :center-bay)
  (categories :initform '(:actor :obstacle  :target :container :light-source :vehicle :repairable))
  (equipment-slots :initform '(:left-bay :right-bay :center-bay :extension)))

(define-method loadout shocker ()
  [make-inventory self]
  [make-equipment self]
  [equip self [add-item self (clone =wave-cannon=)]])

(define-method hit shocker (&optional object)
  [die self])

(define-method run shocker ()
  (let ((cannon [equipment-slot self :center-bay]))
    (when cannon [recharge cannon]))
  (let ((dir [direction-to-player self])
	(dist [distance-to-player self]))
    (if (< dist 13)
	(if (> 9 dist)
	    (progn [fire self dir]
		   (xe2:percent-of-time 3 [move self dir]))
	    (if [obstacle-in-direction-p *world* <row> <column> dir]
		[move self (random-direction)]
		[move self dir]))
	(percent-of-time 3 [move self (random-direction)]))))

(define-method die shocker () 
  (dotimes (n 10)
    [drop self (clone =noise=)])
  (percent-of-time 12 [drop self (clone =health=)])
  [play-sample self "yelp"]
  [parent>>die self])  

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.