source: abuse/trunk/data/lisp/common.lsp @ 589

Last change on this file since 589 was 589, checked in by Sam Hocevar, 10 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: 3.4 KB
Line 
1;; Copyright 1995 Crack dot Com,  All Rights reserved
2;; See licensing 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;; XXX: Mac Abuse reimplements this in C++
9(defun middle_draw ()
10  (let ((y (y)))
11    (set_y (+ (y) (/ (picture_height) 2)))
12    (draw)
13    (set_y y)))
14
15(defun push_char (xamount yamount)
16  (let ((bgx (with_object (bg) (x)) (x))
17        (bgy (with_object (bg) (y)) (y)))
18    (if (and (<= bgy (y)) (< (disty) yamount) (< (distx) xamount))
19        (let ((amount (if (> bgx (x))
20                          (- xamount (- bgx (x)))
21                        (- (- (x) bgx) xamount))))
22          (with_object (bg) (try_move amount 0))))))
23
24
25
26(defun do_nothing () (next_picture) T)
27
28(defun lhold_ai ()
29  (if (> (total_objects) 0)
30      (progn
31        (set_x (with_object (get_object 0) (x)))
32        (set_y (with_object (get_object 0) (- (y) (/ (picture_height) 2) )))))
33  (if (eq (total_lights) 1)
34      (progn
35        (set_light_x (get_light 0) (x))
36        (set_light_y (get_light 0) (y)))
37    nil)
38  T)
39
40
41
42(def_char LIGHTHOLD
43  (funs  (ai_fun   lhold_ai)
44         (draw_fun dev_draw))
45  (states "art/misc.spe"
46          (stopped           "lhold")))
47
48
49
50(def_char OBJ_MOVER
51  (funs (ai_fun       mover_ai)
52        (constructor  mover_cons)
53        (draw_fun     dev_draw))
54  (range 300 40)
55  (fields ("aitype" obj_frames)
56           ("aistate" obj_frame))
57  (states "art/misc.spe" (stopped '("mover" "mover" ))))
58
59/*    Compiled C
60(defun mover_ai ()
61  (if (eq (total_objects) 2)
62      (let ((dest (get_object 0))
63            (mover (get_object 1)))
64        (if (< (aistate) 2)             ; transfer object to next mover
65            (progn
66              (with_object dest
67                           (progn
68                             (link_object mover)
69                             (set_aistate (aitype))))
70              (remove_object mover))
71          (progn
72            (set_aistate (- (aistate) 1))
73            (let ((newx (- (with_object dest (x)) (/ (* (- (with_object dest (x)) (x)) (aistate)) (aitype))))
74                  (newy (- (with_object dest (y)) (/ (* (- (with_object dest (y)) (y)) (aistate)) (aitype)))))
75              (with_object mover
76                           (progn
77                             (platform_push (- newx (x)) (- newy (y)))
78                             (set_x newx)
79                             (set_y newy)))))))
80    nil)
81  T)
82*/
83
84(defun mover_cons () (set_aitype 20))
85
86
87/*  // compiled C
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
110
111(defun respwan_cons () (set_xvel 50))
112
113
114(def_char RESPAWN
115  (funs (ai_fun      respawn_ai)
116        (draw_fun    dev_draw)
117        (constructor respwan_cons))
118;  (flags (unlistable T))
119  (fields ("xvel" respawn_reg))
120  (range 100 100)
121  (states "art/misc.spe"
122          (stopped           "respawn")))
123
124
125
126(def_char MARKER
127  (funs (ai_fun   do_nothing)
128        (draw_fun dev_draw))
129  (states "art/misc.spe" (stopped "marker")))
130
Note: See TracBrowser for help on using the repository browser.