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

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licencing information for more details on usage rights
  3.  
  4. ; draw function for characters only displayed during edit mode 
  5. ; such as start, etc.
  6. ; (defun dev_draw () (if (edit_mode) (draw) nil))       -- compiled C function --
  7.  
  8. (defun middle_draw ()
  9.   (let ((y (y)))
  10.     (set_y (+ (y) (/ (picture_height) 2)))
  11.     (draw)
  12.     (set_y y)))
  13.     
  14.  
  15.  
  16. (defun push_char (xamount yamount)
  17.   (let ((bgx (with_object (bg) (x)) (x))
  18.     (bgy (with_object (bg) (y)) (y)))
  19.     (if (and (<= bgy (y)) (< (disty) yamount) (< (distx) xamount))
  20.     (let ((amount (if (> bgx (x))
  21.               (- xamount (- bgx (x)))
  22.             (- (- (x) bgx) xamount))))
  23.       (with_object (bg) (try_move amount 0))))))
  24.  
  25.  
  26.  
  27. (defun do_nothing () (next_picture) T)
  28.  
  29. (defun lhold_ai ()
  30.   (if (> (total_objects) 0)
  31.       (progn
  32.     (set_x (with_object (get_object 0) (x)))
  33.     (set_y (with_object (get_object 0) (- (y) (/ (picture_height) 2) )))))
  34.   (if (eq (total_lights) 1)
  35.       (progn
  36.     (set_light_x (get_light 0) (x))
  37.     (set_light_y (get_light 0) (y)))
  38.     nil)
  39.   T)
  40.     
  41.  
  42.  
  43. (def_char LIGHTHOLD
  44.   (funs  (ai_fun   lhold_ai)
  45.      (draw_fun dev_draw))
  46.   (states "art/misc.spe"     
  47.       (stopped           "lhold")))
  48.  
  49.  
  50.  
  51. (def_char OBJ_MOVER 
  52.   (funs (ai_fun       mover_ai)
  53.     (constructor  mover_cons)
  54.     (draw_fun     dev_draw))
  55.   (range 300 40)
  56.   (fields ("aitype" "frames till arrival")
  57.        ("aistate" "current frame"))
  58.   (states "art/misc.spe" (stopped '("mover" "mover" ))))
  59.  
  60. /*    Compiled C       
  61. (defun mover_ai ()
  62.   (if (eq (total_objects) 2)
  63.       (let ((dest (get_object 0))
  64.         (mover (get_object 1)))
  65.     (if (< (aistate) 2)        ; transfer object to next mover          
  66.         (progn
  67.           (with_object dest 
  68.                (progn
  69.                  (link_object mover)
  70.                  (set_aistate (aitype))))
  71.           (remove_object mover))
  72.       (progn          
  73.         (set_aistate (- (aistate) 1))
  74.         (let ((newx (- (with_object dest (x)) (/ (* (- (with_object dest (x)) (x)) (aistate)) (aitype))))
  75.           (newy (- (with_object dest (y)) (/ (* (- (with_object dest (y)) (y)) (aistate)) (aitype)))))
  76.           (with_object mover 
  77.                (progn 
  78.                  (platform_push (- newx (x)) (- newy (y)))
  79.                  (set_x newx)
  80.                  (set_y newy)))))))
  81.     nil)
  82.   T)
  83. */
  84.  
  85. (defun mover_cons () (set_aitype 20))
  86.  
  87.  
  88. (defun respawn_ai ()
  89.   (let ((x (total_objects)))
  90.     (if (eq x 0)                           ; if not linked to anything return
  91.     T
  92.       (let ((last (get_object (- x 1))))   ; see if the last object has the same position as us
  93.     (if (and (eq (with_object last (x)) (x)) (eq (with_object last (y)) (y)))
  94.         (if (eq (aistate) 1)            
  95.         (if (eq (with_object last (fade_count)) 0)
  96.             (set_aistate 1)
  97.           (with_object last (set_fade_count (- (with_object last (fade_count)) 1))))
  98.           T)                          ; if so then return
  99.       (if (eq (aistate) 1)
  100.           (set_aistate 0)
  101.         (if (> (state_time) (xvel))
  102.         (let ((new (add_object (with_object (get_object (random x)) (otype)) (x) (y))))
  103.           (with_object new (set_fade_count 15))   ; make faded out so we can fade it in
  104.           (link_object new)
  105.           (set_aistate 1))
  106.           T))))))
  107.   T)
  108.  
  109. (defun respwan_cons () (set_xvel 50)) 
  110.  
  111.  
  112. (def_char RESPAWN 
  113.   (funs (ai_fun      respawn_ai)
  114.     (draw_fun    dev_draw)
  115.     (constructor respwan_cons))
  116.   (fields ("xvel" "frames to regenerate"))
  117.   (range 100 100)
  118.   (states "art/misc.spe"
  119.       (stopped           "respawn")))
  120.  
  121.  
  122.  
  123. (def_char MARKER
  124.   (funs (ai_fun   do_nothing)
  125.     (draw_fun dev_draw))
  126.   (states "art/misc.spe" (stopped "marker")))
  127.  
  128.  
  129. (def_char START
  130.   (funs (ai_fun   do_nothing)
  131.     (draw_fun dev_draw))
  132.   (range 0 0)
  133.   (states "art/misc.spe" (stopped "start_image")))
  134.  
  135.