source: abuse/branches/lol/data/lisp/teleport.lsp @ 737

Last change on this file since 737 was 589, checked in by Sam Hocevar, 12 years ago

data: remove exact duplicate Lisp files, merge all main space Lisp files,
and move most frabs addons to the main data directory.

File size: 2.4 KB
Line 
1;; Copyright 1995 Crack dot Com,  All Rights reserved
2;; See licensing 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)))))))
54T)
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"   tp_amb))
68  (states "art/door.spe" (stopped (seq "door" 1 5))))
69
70;; Teleporting door AI
71(defun tpdi_ai ()
72  (let ((player (bg)))
73       (if (has_object player)
74           (if (not (with_object player (pressing_action_key)))
75               (remove_object player))
76           (if (and (< (distx) 15)
77                    (< (disty) 20)
78                    (with_object player (pressing_action_key))
79                    (> (total_objects) 0))
80               (let ((otherx (with_object (get_object 0) (x)))
81                     (othery (with_object (get_object 0) (y))))
82                    (with_object (get_object 0) (link_object player))
83                    (with_object player
84                      (progn (set_x otherx) (set_y othery)))))))
85  T)
86
87(def_char TP_DOOR_INVIS
88  (range 0 0)
89  (funs (ai_fun tpdi_ai)
90        (draw_fun dev_draw))
91  (fields ("xvel" tp_amb))
92  (states "art/misc.spe" (stopped "clone_icon")))
93
Note: See TracBrowser for help on using the repository browser.