source: abuse/trunk/data/lisp/gates.lsp @ 671

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

data: move original Abuse files to our main data directory and move
the Bong addon for Abuse Mac in there, too.

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(defun delay_ai ()
5  (if (> (xvel) 0)
6      (progn
7        (set_xvel (- (xvel) 1))
8        (if (eq (xvel) 0)
9            (if (eq (state) stopped)
10                (progn
11                  (set_aistate 1)
12                  (set_state on_state))
13              (progn
14                (set_state stopped)
15                (set_aistate 0)))))
16    (if (> (total_objects) 0)
17        (if (eq (eq (aistate) 0) (eq (with_obj0 (aistate)) 0))
18          T
19        (set_xvel delay_time))))
20T)
21
22(def_char GATE_DELAY
23  (funs (ai_fun delay_ai)
24        (draw_fun dev_draw))
25  (vars delay_time)
26  (fields ("delay_time" gate_delay_time)
27          ("aistate"    ai_state)
28          )
29  (states "art/misc.spe"
30          (stopped "0_delay")
31          (on_state "1_delay")))
32
33
34(def_char GATE_OR
35  (funs (ai_fun or_ai)
36        (draw_fun dev_draw))
37  (states "art/misc.spe"
38          (stopped "0_or_gate")
39          (on_state "1_or_gate")))
40
41(def_char GATE_AND
42  (funs (ai_fun and_ai)
43        (draw_fun dev_draw))
44  (states "art/misc.spe"
45          (stopped "0_and_gate")
46          (on_state "1_and_gate")))
47
48
49(def_char GATE_NOT
50  (funs (ai_fun not_ai)
51        (draw_fun dev_draw))
52  (states "art/misc.spe"
53          (stopped "0_not_gate")
54          (on_state "1_not_gate")))
55
56
57(def_char GATE_XOR
58  (funs (ai_fun xor_ai)
59        (draw_fun dev_draw))
60  (states "art/misc.spe"
61          (stopped "0_xor_gate")
62          (on_state "1_xor_gate")))
63
64
65(def_char GATE_PULSE
66  (funs (ai_fun pulse_ai)
67        (draw_fun dev_draw))
68  (vars time_left pulse_speed)
69  (fields ("pulse_speed" gate_pulse_speed))
70  (states "art/misc.spe"
71          (stopped "0_pulse")
72          (on_state "1_pulse")))
73
74
75(def_char INDICATOR
76  (funs (ai_fun indicator_ai))
77  (states "art/misc.spe"
78          (stopped "0_indicator")
79          (on_state "1_indicator")))
80
81(defun indicator_ai ()
82  (if (> (total_objects) 0)
83      (if (eq (with_obj0 (aistate)) 0)
84          (progn
85            (set_state stopped)
86            (set_aistate 0))
87        (progn
88          (set_state on_state)
89          (set_aistate 1)))) T)
90
91(defun xor_check (last_object stat)
92  (if (< last_object 0)
93      stat
94    (if (eq (with_object (get_object last_object) (aistate)) 0)
95        (xor_check (- last_object 1) stat)
96      (xor_check (- last_object 1) (not stat)))))
97
98(defun xor_ai ()
99  (if (xor_check (- (total_objects) 1) nil)
100      (progn
101        (set_state on_state)
102        (set_aistate 1))
103    (progn
104      (set_state stopped)
105      (set_aistate 0))) T)
106
107(defun or_check (last_object)
108  (if (< last_object 0)
109      nil
110    (if (eq (with_object (get_object last_object) (aistate)) 0)
111        (or_check (- last_object 1))
112      T)))
113
114(defun or_ai ()
115  (if (or_check (- (total_objects) 1))
116      (progn
117        (set_state on_state)
118        (set_aistate 1))
119    (progn
120      (set_state stopped)
121      (set_aistate 0))) T)
122
123
124(defun and_check (last_object)
125  (if (< last_object 0)
126      T
127    (if (eq (with_object (get_object last_object) (aistate)) 0)
128        nil
129      (and_check (- last_object 1)))))
130
131
132(defun and_ai ()
133  (if (and_check (- (total_objects) 1))
134      (progn
135        (set_state on_state)
136        (set_aistate 1))
137    (progn
138      (set_state stopped)
139      (set_aistate 0))) T)
140
141
142(defun not_ai ()
143  (if (> (total_objects) 0)
144      (if (eq (with_obj0 (aistate)) 0)
145          (progn
146            (set_state on_state)
147            (set_aistate 1))
148        (progn
149          (set_state stopped)
150          (set_aistate 0)))) T)
151
152(defun pulse_ai ()
153  (if (> (total_objects) 0)
154      (if (not (eq (with_obj0 (aistate)) 0))
155          (if (eq time_left 0)
156              (if (eq (aistate) 0)
157                  (progn
158                    (setq time_left pulse_speed)
159                    (set_state on_state)
160                    (set_aistate 1))
161                (progn
162                  (set_state stopped)
163                  (set_aistate 0)))
164            (setq time_left (- time_left 1)))))
165  T)
166
Note: See TracBrowser for help on using the repository browser.