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

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licencing information for more details on usage rights
  3.  
  4. (defun other_door_opening ()
  5.   (if (eq (total_objects) 0)
  6.       nil
  7.     (with_object (get_object 0)
  8.          (if (eq (otype) TP_DOOR)
  9.              (if (eq is_opening 0)             
  10.              (if (and (< (distx) 100) (< (disty) 80))
  11.                  T
  12.                nil)
  13.                T)
  14.            nil))))
  15.  
  16. (defun open_door ()
  17.  
  18.   (setq is_opening 1)
  19.   (if (eq (current_frame) 4)
  20.       (setq is_opening 0)
  21.     (progn
  22.       (if (eq (current_frame) 0)
  23.       (play_sound DOOR_UP 127 (x) (y)))
  24.       (next_picture))))
  25.  
  26. (defun close_door ()
  27.   (setq is_opening 0)
  28.   (if (eq (current_frame) 0)
  29.       nil
  30.     (progn
  31.       (if (eq (current_frame) 4)
  32.       (play_sound DOOR_DOWN 127 (x) (y)))
  33.       (set_current_frame (- (current_frame) 1)))))
  34.   
  35.  
  36. (defun tpd_ai ()     ;; teleporting door ai
  37.   (if (or (and (< (distx) 100) (< (disty) 80))
  38.       (other_door_opening))
  39.       (open_door)
  40.     (close_door))
  41.  
  42.   (let ((player (bg)))
  43.     (if (has_object player)
  44.     (if (not (with_object player (pressing_action_key)))
  45.         (remove_object player))
  46.       (if (and (< (distx) 20) (< (disty) 30) (with_object player (pressing_action_key))
  47.            (> (total_objects) 0))
  48.       (let ((otherx (with_object (get_object 0) (x)))
  49.         (othery (with_object (get_object 0) (y))))
  50.         (with_object (get_object 0) (link_object player))
  51.         (with_object player (progn 
  52.                   (set_x otherx) 
  53.                   (set_y othery)))))))
  54. T)
  55.  
  56.  
  57. (defun tp_door_cons () (set_xvel -1))
  58. (defun tp_door_draw () (set_ambient_light (bg) (xvel)) (draw))   
  59.  
  60. (def_char TP_DOOR
  61.   (range 0 0)
  62.   (vars is_opening)
  63.   (funs (ai_fun      tpd_ai)
  64.     (constructor tp_door_cons)
  65.     (reload_fun lower_reload)
  66.     (draw_fun   tp_door_draw))
  67.   (fields ("xvel" "ambient setting"))
  68.   (states "art/door.spe" (stopped (seq "door" 1 5))))
  69.  
  70.  
  71.