source: abuse/trunk/data/addon/twist/f2ai.lsp @ 590

Last change on this file since 590 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: 6.1 KB
Line 
1(defun forceobj_ai ()
2  (if (<= (total_objects) 0)
3      nil
4     (progn
5        (let ((xfrc (xacel))
6              (yfrc (yacel)))
7        (try_move xfrc yfrc))
8          T)))
9
10
11(defun forceobj_cons ()
12  (set_xacel 0)
13  (set_yacel 10))
14
15
16(defun do_fire_explo (radius amount)
17      (play_sound GRENADE_SND 127 (x) (y))
18      (add_object EXPFIRE (+ (x) (random 10)) (+ (+ (random 10) (y)) -20)     0)
19      (if (not (frame_panic))
20          (progn
21            (add_object EXPFIRE (- (x) (random 10)) (+ (- (y) (random 10)) -20) 2)
22            (add_object EXP_LIGHT (x) (y) 100)))         ; add cool light if not too slow
23      (hurt_radius (x) (y) radius amount (if (> (total_objects) 0)
24                                             (get_object 0)
25                                           nil) 20)
26      nil)
27
28
29(defun do_light_explo (radius amount)
30      (play_sound GRENADE_SND 127 (x) (y))
31;;      (add_object EXPFIRE (+ (x) (random 10)) (+ (+ (random 10) (y)) -20)     0)
32      (if (not (frame_panic))
33          (progn
34;;          (add_object EXPFIRE (- (x) (random 10)) (+ (- (y) (random 10)) -20) 2)
35            (add_object EXP_LIGHT (x) (y) 100)))         ; add cool light if not too slow
36      (hurt_radius (x) (y) radius amount (if (> (total_objects) 0)
37                                             (get_object 0)
38                                           nil) 20)
39      nil)
40
41(defun gsensor_ai ()
42      (if (and (< (distx) (xvel)) (< (disty) (yvel)))
43           (progn
44                (let ((xgvty (xacel))
45                      (ygvty (yacel)))
46                        (with_object (bg) (try_move xgvty ygvty))))
47                T)
48           T)
49
50
51(defun gsensor_cons ()
52  (set_xvel 50)
53  (set_yvel 50)
54  (set_xacel 0)
55  (set_yacel -15))
56
57
58(defun gravity_sensor_draw ()
59  (if (edit_mode)
60      (progn
61        (draw)
62        (let ((x1 (- (x) (xvel)))
63              (y1 (- (y) (yvel)))
64              (x2 (+ (x) (xvel)))
65              (y2 (+ (y) (yvel)))
66              (c  (find_rgb 255 255 0)))
67          (draw_line x1 y1 x2 y1 c)
68          (draw_line x2 y1 x2 y2 c)
69          (draw_line x2 y2 x1 y2 c)
70          (draw_line x1 y2 x1 y1 c)))
71    nil))
72
73
74(defun hsensor_ai ()
75      (if (and (< (distx) (xvel)) (< (disty) (yvel)))
76           (progn
77                (select (aitype)
78                   (0   (let ((phlth (xacel))) (if (eq (mod (state_time) 10) 0) (do_damage phlth (bg)))))
79                   (1   (let ((phlth (xacel)) (hlthrad (/ (xvel) 2))) (hurt_radius (x) (y) hlthrad phlth nil 10)))
80                   (2   (let ((phlth (xacel)) (hlthrad (/ (xvel) 2))) (do_explo hlthrad phlth)))
81                        )
82                T)
83           T))
84
85
86(defun hsensor_cons ()
87  (set_xvel 50)
88  (set_yvel 50)
89  (set_aitype 0)
90  (set_aistate 0)
91  (set_xacel 10)
92  (set_yacel 0))
93
94
95(defun health_sensor_draw ()
96  (if (edit_mode)
97      (progn
98        (draw)
99        (let ((x1 (- (x) (xvel)))
100              (y1 (- (y) (yvel)))
101              (x2 (+ (x) (xvel)))
102              (y2 (+ (y) (yvel)))
103              (c  (find_rgb 255 0 255)))
104          (draw_line x1 y1 x2 y1 c)
105          (draw_line x2 y1 x2 y2 c)
106          (draw_line x2 y2 x1 y2 c)
107          (draw_line x1 y2 x1 y1 c)))
108    nil))
109
110
111(defun lsensor_ai ()
112      (if (and (< (distx) (xvel)) (< (disty) (yvel)))
113           (progn
114                (if (eq (aistate) 1) (request_end_game))
115                (if (eq (aitype) 1) (show_stats))
116                (request_level_load (concatenate 'string "levels/level" (digstr (xacel) 2)".spe"))
117           )
118                T)
119           T)
120
121
122(defun lsensor_cons ()
123  (set_xvel 50)
124  (set_yvel 50)
125  (set_xacel 1)
126  (set_yacel 1)
127  (set_aistate 0)
128  (set_aitype 1))
129
130
131(defun level_sensor_draw ()
132  (if (edit_mode)
133      (progn
134        (draw)
135        (let ((x1 (- (x) (xvel)))
136              (y1 (- (y) (yvel)))
137              (x2 (+ (x) (xvel)))
138              (y2 (+ (y) (yvel)))
139              (c  (find_rgb 255 128 0)))
140          (draw_line x1 y1 x2 y1 c)
141          (draw_line x2 y1 x2 y2 c)
142          (draw_line x2 y2 x1 y2 c)
143          (draw_line x1 y2 x1 y1 c)))
144    nil))
145
146(defun burst_fire (firex firey angle)
147  (if (> fire_time 0);; if we need to wait till next burst
148      (progn
149        (setq fire_time (- fire_time 1))
150        (if (eq fire_time 0)
151            (progn
152              (setq burst_left burst_total)
153              (setq burst_wait 0))))
154    (if (eq burst_wait 0)
155        (progn
156          (if (or (eq burst_left 1) (eq burst_left 0))
157              (setq fire_time fire_delay)
158            (setq burst_left (- burst_left 1)))
159          (setq burst_wait burst_delay)
160          (fire_object (me) (aitype) firex firey angle (bg)))
161      (setq burst_wait (- burst_wait 1)))))
162
163
164(defun wrob2_cons ()
165  (setq fire_delay 4)
166  (setq burst_delay 1)
167  (setq max_xvel 10)
168  (setq max_yvel 5)
169  (set_aitype 0)
170  (setq burst_total 5))
171
172
173(defun wrob2_ai ()
174  (if (eq (hp) 0)
175        (with_object (add_object WALK_ROBHEAD (x) (- (y) 24) 1)
176      nil)
177    (progn
178        (try_move 0 10)
179      (select (aistate)
180              (0;; walk toward player
181               (if (or (> (distx) 120) (not (eq (direction) (toward))))
182                   (progn
183                     (move (toward) 0 0)
184                     (next_picture))
185                 (progn
186                   (set_aistate 1))))
187              (1;; stop and fire
188               (burst_fire  (+ (x) (* (direction) 28)) (- (y) 35)
189                            (if (> (direction) 0)
190                                (mod (- 375 (/ (* burst_left 30) burst_total)) 360)
191                              (+ 165 (/ (* burst_left 30) burst_total))))
192               (if (not (eq fire_time 0))
193                   (set_aistate 0))))
194      T)))
195
196
197(defun telesensor_ai ()
198  (if (> (total_objects) 0)
199      (select (aistate)
200              (0 ;; wait for player to activate
201               (if (and (< (distx) (xvel)) (< (disty) (yvel)))
202                   (progn
203                (if (eq (aitype) 0)
204                         (progn
205                           (link_object (bg))
206                           (set_state running)
207                           (set_aistate 1))
208
209                     (if (with_object (bg) (pressing_action_key))
210                         (progn
211                           (link_object (bg))
212                           (set_state running)
213                           (set_aistate 1))
214                         )))) )
215              (1 ;; wait for animation
216               (if (next_picture)
217                   (let ((x (x))
218                         (y (- (y) 16))
219                         (fade (if (< (current_frame) 16) (current_frame) 15)))
220                     (with_object (get_object 1)
221                                  (progn
222                                    (set_x x)
223                                    (set_y y)
224                                    (user_fun SET_FADE_COUNT fade)
225                                    (setq is_teleporting 1)
226                                    )))
227
228                 (let ((x (with_object (get_object 0) (x)))
229                       (y (with_object (get_object 0) (- (y) 16))))
230                   (with_object (get_object 1)
231                                (progn
232                                  (set_x x)
233                                  (set_y y)
234                                  (setq is_teleporting 0)
235                                  (user_fun SET_FADE_COUNT 0)
236                                  ))
237                   (remove_object (get_object 1))
238                   (set_aistate 0))))))
239  T)
240
241
242(defun telesensor_cons ()
243  (set_xvel 50)
244  (set_yvel 50))
245
246
247(defun teleport_sensor_draw ()
248  (if (edit_mode)
249      (progn
250        (draw)
251        (let ((x1 (- (x) (xvel)))
252              (y1 (- (y) (yvel)))
253              (x2 (+ (x) (xvel)))
254              (y2 (+ (y) (yvel)))
255              (c  (find_rgb 128 255 0)))
256          (draw_line x1 y1 x2 y1 c)
257          (draw_line x2 y1 x2 y2 c)
258          (draw_line x2 y2 x1 y2 c)
259          (draw_line x1 y2 x1 y1 c)))
260    nil))
Note: See TracBrowser for help on using the repository browser.