home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer 13 / 1995-12_Disc_13.iso / abuse / lisp / flyer.lsp < prev    next >
Lisp/Scheme  |  1995-08-31  |  4KB  |  138 lines

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licencing information for more details on usage rights
  3.  
  4.  
  5. (defun flyer_ai ()
  6.   (if (not (eq smoke_time 0))                 ;; if we just got hit, put out some smoke
  7.       (progn
  8.     (setq smoke_time (- smoke_time 1))
  9.     (if (eq (mod smoke_time 2) 0)
  10.         (add_object SMALL_DARK_CLOUD (x) (y)))))
  11.  
  12.   (if (eq (aistate) 0)                        ;; wait for something to turn us on (women maybe?)
  13.       (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
  14.       (if (next_picture) T
  15.         (progn
  16.           (set_targetable T)
  17.           (set_state running)
  18.           (set_aistate 1)))
  19.     (progn
  20.       (set_targetable nil)
  21.       (set_state stopped)
  22.       T))
  23.     (if (eq (hp) 0)                          ;; if dead, make an explosion
  24.     (progn
  25.       (add_object EXPLODE1 (+ (x) (random 10)) (+ (+ (random 10) (y)) -20)     0)
  26.       (add_object EXPLODE1 (- (x) (random 10)) (+ (- (y) (random 10)) -20)     2)
  27.       (add_object EXPLODE1 (x) (+ (- (y) (random 20)) -20)                     4)
  28.       nil)
  29.       (progn      
  30.     (if (eq (mod (state_time) 5) 0)      ;; make flyer noise every 5 ticks
  31.         (play_sound FLYER_SND 127 (x) (y)))
  32.     (if (> (with_object (bg) (x)) (x))   ;; start going right if player is to the right
  33.         (progn
  34.           (set_xvel (+ (xvel) 1))
  35.           (if (> (xvel) max_xvel) (set_xvel max_xvel))
  36.           (if (eq (direction) -1)
  37.           (progn
  38.             (set_direction 1)
  39.             (set_state turn_around))))
  40.       (if (< (with_object (bg) (x)) (x))  ;; start going left if the player is to the left
  41.           (progn
  42.         (set_xvel (- (xvel) 1))
  43.         (if (< (xvel) (- 0 max_xvel)) (set_xvel (- 0 max_xvel)))
  44.         (if (eq (direction) 1)
  45.             (progn
  46.               (set_direction -1)
  47.               (set_state turn_around))))))
  48.     (if (> (with_object (bg) (- (y) 70)) (y))
  49.         (if (> (yvel) max_yvel)
  50.         (set_yvel (- (yvel) 1))
  51.           (set_yvel (+ (yvel) 1)))
  52.  
  53.       (if (< (with_object (bg) (- (y) 50)) (y))
  54.           (if (< (yvel) (- 0 max_yvel))
  55.           (set_yvel (+ (yvel) 1))
  56.         (set_yvel (- (yvel) 1)))))
  57.  
  58.     (if (eq (random 5) 0)                ;; add some randomness to the movement
  59.         (set_xvel (+ (xvel) 1))
  60.       (if (eq (random 5) 0)
  61.           (set_xvel (- (xvel) 1))))
  62.     (if (eq (random 5) 0)
  63.         (set_yvel (+ (yvel) 1))
  64.       (if (eq (random 5) 0)
  65.           (set_yvel (- (yvel) 1))))
  66.  
  67.     (if (next_picture) T (set_state running))  ;; reset animation when done
  68.         
  69.     (bounce_move '(set_xvel (/ (xvel) 2)) '(set_xvel (/ (xvel) 2))
  70.              '(set_yvel (/ (yvel) 2)) '(set_yvel (/ (yvel) 2)) nil)
  71.       
  72.     (if (> fire_time 0)              ;; if we need to wait till next burst
  73.         (progn
  74.           (setq fire_time (- fire_time 1))
  75.           (if (eq fire_time 0)
  76.           (progn 
  77.             (setq burst_left burst_total)
  78.             (setq burst_wait 0))))
  79.       (if (eq burst_wait 0)
  80.           (if (and (< (distx) 150) (eq (direction) (facing)))
  81.           (let ((firex (+ (x) (* (direction) 10)) )
  82.             (firey (y))
  83.             (playerx (+ (with_object (bg) (x)) (with_object (bg) (* (xvel) 4))))
  84.             (playery (+ (- (with_object (bg) (y)) 15) (with_object (bg) (* (yvel) 2)))))
  85.             (if (and (can_see (x) (y) firex firey nil) (can_see firex firey playerx playery nil))
  86.             (progn
  87.               (let ((angle (atan2 (- firey playery)
  88.                           (- playerx firex))))
  89.                 (if (or (eq burst_left 1) (eq burst_left 0))
  90.                 (setq fire_time fire_delay)
  91.                   (setq burst_left (- burst_left 1)))
  92.                 (setq burst_wait burst_delay)
  93.                 (fire_object (me) (aitype) firex firey angle (bg)))))))
  94.         (setq burst_wait (- burst_wait 1))))        
  95.     T))))
  96.  
  97.  
  98.  
  99. (defun flyer_cons ()      
  100.   (setq fire_delay 20)
  101.   (setq burst_delay 3)
  102.   (setq max_xvel 10)
  103.   (setq max_yvel 5)
  104.   (set_aitype 9)
  105.   (setq burst_total 2))
  106.  
  107.  
  108. (defun flyer_damage (amount from hitx hity push_xvel push_yvel)
  109.   (if (and from (with_object from (and (> (total_objects) 0) 
  110.                        (with_object (get_object 0) 
  111.                             (or (eq (otype) FLYER)
  112.                             (eq (otype) GREEN_FLYER))
  113.                             ))))
  114.       nil
  115.     (if (eq (state) stopped) nil
  116.       (progn
  117.     (setq smoke_time 30)
  118.     (set_yvel (- (yvel) 14))
  119.     (set_state flinch_up)
  120.     (damage_fun amount from hitx hity push_xvel push_yvel)))))
  121.  
  122.  
  123. (setq load_warn nil)
  124. (if (not (load "register/flyer.lsp"))
  125.     (progn
  126.       (setq FLYER WHO)
  127.       (setq GREEN_FLYER WHO)))
  128. (setq load_warn T)
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.