|
@@ -438,12 +438,20 @@
|
438
|
438
|
(set-location floor x y map)
|
439
|
439
|
(setf (gethash (calc-location x y map) terrain) floor)))))))))
|
440
|
440
|
|
|
441
|
+(defun spawn-enemies (map player)
|
|
442
|
+ (loop for room in (crawler::rooms (game-map-dungeon map))
|
|
443
|
+ when (not (equal room (find-room (get-location player) map))) do
|
|
444
|
+ (with-slots ((x1 crawler::x1) (x2 crawler::x2) (y1 crawler::y1) (y2 crawler::y2)) room
|
|
445
|
+ (dotimes (times (random 3))
|
|
446
|
+ (let* ((location (nearest-open-tile (gethash (calc-location x1 y1 map) (game-map-terrain map)) map))
|
|
447
|
+ (enemy (make-instance 'enemy :location location)))
|
|
448
|
+ (when location
|
|
449
|
+ (setf (gethash location (game-map-mobiles map)) enemy)))))))
|
|
450
|
+
|
441
|
451
|
(defun initialize-map (map player)
|
442
|
452
|
(fill-map-from-crawler map player)
|
443
|
453
|
(setf (gethash (slot-value player 'location) (game-map-mobiles map)) player)
|
444
|
|
- (let* ((location (nearest-open-tile player map))
|
445
|
|
- (enemy (make-instance 'enemy :location location)))
|
446
|
|
- (setf (gethash location (game-map-mobiles map)) enemy))
|
|
454
|
+ (spawn-enemies map player)
|
447
|
455
|
map)
|
448
|
456
|
|
449
|
457
|
(defun get-neighbors (tile map layer &key (filter-fun #'identity))
|