source: abuse/trunk/data/lisp/duong.lsp @ 614

Last change on this file since 614 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: 10.4 KB
Line 
1;; Copyright 1995 Crack dot Com,  All Rights reserved
2;; See licensing information for more details on usage rights
3
4
5(defun mine_ai ()
6  (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
7      (select (aistate)
8              (0 (if (touching_bg)
9                     (progn (set_state running)
10                            (if (eq (xvel) 1)
11                                (progn
12                                  (with_object (bg)
13                                               (make_view_solid (find_rgb 250 10 10)))
14                                  (hurt_radius (x) (y) 40 35 nil 20))
15                              (hurt_radius (x) (y) 40 25 nil 20))
16                            (go_state 1))
17                   (next_picture))
18                   T)
19              (1 (next_picture)))
20    T))
21
22
23
24
25(def_char CONC
26  (funs (ai_fun  mine_ai))
27  (fields  ("xvel" conc_flash))
28  (states "art/chars/mine.spe"
29          (running   (seq "mine" 1 8))
30          (stopped    '("mine0001.pcx" "mine_off"))))
31
32
33
34(defun air_mine_ai ()
35  (if (or (eq (total_objects) 0)                                 ;; turned on?
36          (not (eq (with_object (get_object 0) (aistate)) 0)))
37
38      (if (touching_bg)
39          (progn
40            (if (eq (xvel) 1)
41                (with_object (bg) (make_view_solid (find_rgb 250 10 10))))
42            (do_explo 40 25)
43            nil)
44        (progn (next_picture)
45               T))
46    T))
47
48(def_char CONC_AIR
49  (funs (ai_fun  air_mine_ai))
50  (fields  ("xvel" conc_flash))
51  (states "art/chars/mine.spe"
52          (stopped   (seq "amin" 1 2))))
53
54
55
56
57
58
59(defun bomb_cons ()
60  (setq blink_time 14))
61
62(defun bomb_ai ()
63  (select (aistate)
64          (0 ;; wait for a signal if connected, or wait for player touch
65           (if (activated)
66               (go_state 1)
67             T))
68
69          (1 ;; count down blink time until zero then blow up
70           (if (< blink_time 1)
71               (go_state 2)
72             (progn
73               (if (or (< blink_time 10)
74                       (and (< blink_time 18) (eq (mod blink_time 2) 0))
75                       (and (< blink_time 30) (eq (mod blink_time 3) 0))
76                       (and (< blink_time 50) (eq (mod blink_time 4) 0)))
77                   (progn
78                     (play_sound TICK_SND 127 (x) (y))
79                     (next_picture)))
80               (setq blink_time (- blink_time 1))
81               T)))
82
83          (2 ;; blow up
84           (let ((oldy (y)))
85             (set_y (- (y) (/ (picture_height) 2)))
86             (do_explo 40 (get_ability jump_yvel))
87             (if (> (get_ability jump_yvel) 100)
88                 (add_object EXPLODE1 (+ (x) (random 10)) (+ (+ (random 10) (y)) -20)     0))
89             (set_y oldy))
90           nil)))
91
92
93
94(def_char BOMB
95  (funs (ai_fun      bomb_ai)
96        (constructor bomb_cons))
97  (abilities (jump_yvel 30))
98  (range 150 150)
99  (vars blink_time)
100  (fields ("blink_time" bomb_blink))
101  (states "art/chars/mine.spe"
102          (stopped '("abomb0001.pcx" "abomb0002.pcx"))))
103
104(def_char BIG_BOMB
105  (funs (ai_fun      bomb_ai)
106        (constructor bomb_cons))
107  (abilities (jump_yvel 400))
108  (range 150 150)
109  (vars blink_time)
110  (fields ("blink_time" bomb_blink))
111  (states "art/chars/mine.spe"
112          (stopped '("abomb0001.pcx+" "abomb0002.pcx+"))))
113
114
115
116
117(defun block_ai ()
118  (if (<= (hp) 0)
119      (if (eq (state) dieing)
120          (next_picture)
121        (progn
122          (play_sound CRUMBLE_SND 127 (x) (y))
123          (set_state dieing)
124          T))
125    T))
126
127(def_char BLOCK
128                                        ;block has only 1 frame now will have block blowing up
129  (funs (ai_fun  block_ai))
130  (flags (can_block T)
131         (hurtable  T))
132  (abilities (start_hp 30))
133  (states "art/chars/block.spe"
134          (stopped       "block.pcx")
135          (dieing        (seq "bexplo" 1 7))))
136
137
138(defun trap_door_ai ()
139  (if (> (total_objects) 0)
140      (select (aistate)
141              (0 ;; wait for switch to go off
142               (if (not (eq (with_object (get_object 0) (aistate)) 0))
143                   (progn
144                     (set_state running)
145                     (go_state 1))))
146              (1 ;; wait for animation
147               (if (next_picture) T
148                 (progn
149                   (set_state blocking)
150                   (set_aistate 2))))
151              (2 ;; just stay here
152               T)))
153T)
154
155
156(defun strap_door_ai ()
157  (general_sdoor_ai nil))
158
159
160(def_char TRAP_DOOR2
161  (funs (ai_fun strap_door_ai))
162  (flags (can_block T))
163  (abilities (start_hp 30))
164  (states "art/chars/tdoor.spe"
165          (stopped        "tdor0001.pcx")
166          (running        (seq "tdor" 1 7))
167          (walking        (seq "tdor" 7 1))
168          (blocking       "tdor0007.pcx")))
169
170
171(def_char TRAP_DOOR3
172  (funs (ai_fun strap_door_ai))
173  (flags (can_block T))
174  (abilities (start_hp 30))
175  (states "art/chars/tdoor.spe"
176          (stopped        "cdor0001.pcx")
177          (running        (seq "cdor" 1 7))
178          (walking        (seq "cdor" 7 1))
179          (blocking       "cdor0007.pcx")))
180
181(defun lightin_ai ()
182  (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
183      (select (aistate)
184              (0  ;; delay
185               (if (< (state_time) (* (aitype) 2)) (set_state stopped)
186                 (progn
187                                        ;                (hurt_radius (x) (y) 40 30 nil 30)
188                   (set_state running)
189                   (play_sound ELECTRIC_SND 127 (x) (y))
190                   (go_state 1))))
191              (1  ;; next picture
192               (if (next_picture) T
193                 (set_aistate 0)))))
194T)
195
196(def_char LIGHTIN
197  (funs (ai_fun lightin_ai))
198  (flags (can_block T))
199  (fields  ("aitype" lightin_speed))
200  (states "art/chars/lightin.spe"
201          (running   (seq "lite" 1 9))
202          (stopped    "lite0001.pcx")))
203
204
205
206(defun lava_ai ()
207  (if (and (touching_bg) (eq (mod (state_time) 20) 0))
208      (do_damage 6 (bg)))
209
210  (select (aistate)
211          (0 (if (eq (random 100) 0)
212                 (progn
213                   (play_sound LAVA_SND 64 (x) (y))
214                   (set_aistate 1)))
215             (next_picture))
216          (1 (next_picture)
217             (if (eq (state_time) 5)
218                 (progn
219                   (hurt_radius (x) (y) 20 20 nil 10)
220                   (set_aistate 0)))))
221  T)
222
223
224(def_char LAVA
225  (funs (ai_fun lava_ai))
226  (states  "art/chars/lava.spe"
227           (stopped (seq "lava" 1 15))))
228
229
230;; XXX: Mac Abuse reimplements this in C++
231(defun tp2_ai ()
232  (if (> (total_objects) 0)
233      (select (aistate)
234              (0 ;; wait for player to activate
235               (if (and (touching_bg) (eq (total_objects) 1))
236                   (progn
237                     (if (with_object (bg) (pressing_action_key))
238                         (progn
239                           (link_object (bg))
240                           (set_state running)
241                           (play_sound TELEPORTER_SND 127 (x) (y))
242                           (set_aistate 1))))))
243              (1 ;; wait for animation
244               (if (next_picture)
245                   (let ((x (x))
246                         (y (- (y) 16))
247                         (fade (if (< (current_frame) 16) (current_frame) 15)))
248                     (with_object (get_object 1)
249                                  (progn
250                                    (set_x x)
251                                    (set_y y)
252                                    (user_fun SET_FADE_COUNT fade)
253                                    (setq is_teleporting 1)
254                                    )))
255
256                 (let ((x (with_object (get_object 0) (x)))
257                       (y (with_object (get_object 0) (- (y) 16))))
258                   (with_object (get_object 1)
259                                (progn
260                                  (set_x x)
261                                  (set_y y)
262                                  (setq is_teleporting 0)
263                                  (user_fun SET_FADE_COUNT 0)
264                                  ))
265                   (remove_object (get_object 1))
266                   (set_aistate 0))))))
267  T)
268
269
270
271(def_char TELE2
272  (funs  (ai_fun tp2_ai))
273  (flags (can_block  T))
274  (states "art/chars/teleport.spe"
275          (stopped "close")
276          (running (seq "elec" 1 15))))
277
278
279(defun bolder_ai ()
280  (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
281      (if (eq (hp) 0)
282          (progn
283            (play_sound P_EXPLODE_SND 127 (x) (y))
284            (add_object EXPLODE1 (+ (x) (random 5)) (+ (y) (random 5)) 0)
285            (add_object EXPLODE1 (+ (x) (random 5)) (+ (y) (random 5)) 2)
286            (add_object EXPLODE1 (- (x) (random 5)) (- (y) (random 5)) 1)
287            (add_object EXPLODE1 (- (x) (random 5)) (- (y) (random 5)) 2)
288            (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel -4) (set_yvel -8)))
289            (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel 4) (set_yvel -9)))
290            (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel 2) (set_yvel -5)))
291            (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel -3) (set_yvel -5)))
292            (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel -1) (set_yvel 2)))
293            (add_object EXP_LIGHT (x) (y) 100)
294            nil)
295        (progn
296          (next_picture)
297          (set_yvel (+ (yvel) 1))
298          (let ((old_yv  (yvel))
299                (old_xv  (xvel))
300                (old_x   (x))
301                (old_y   (y))
302                (status (float_tick)))
303
304            (let ((new_x (x))
305                  (new_y (y))
306                  (set_x old_x)
307                  (set_y old_y))
308              (platform_push (- new_x (x)) (- new_y (y)))
309              (set_x new_x)
310              (set_y new_y))
311            (hurt_radius (x) (y) 19 30 (me) 15)
312            (if (not (eq status T));; T means we did not hit anything
313                (let ((block_flags (car status)))
314                  (if (or (blocked_up block_flags) (blocked_down block_flags));; bounce up/down
315                      (progn
316                        (if (> (abs old_yv) 3)
317                            (play_sound SBALL_SND 127 (x) (y)))
318                        (set_xvel old_xv)
319                        (if (> old_yv 1)
320                            (set_yvel (- 2 old_yv))
321                          (set_yvel (- 0 old_yv))))
322                    (if (or (blocked_left block_flags) (blocked_right block_flags));; bounce left/right
323                        (progn
324                          (set_yvel old_yv)
325                          (set_xvel (- 0 old_xv))))))))
326          T))
327    T))
328
329
330(defun bolder_cons ()
331  (set_xvel -4)
332  (set_yvel 0))
333
334
335(defun bold_dam (amount from hitx hity push_xvel push_yvel)
336  (add_object EXPLODE3 (+ (x) (- 10 (random 20))) (- (y) (random 30)) 0)
337  (damage_fun amount from hitx hity (/ push_xvel 10) (/ push_yvel 2)))
338
339(def_char BOLDER
340  (funs  (ai_fun bolder_ai)
341         (damage_fun bold_dam)
342         (constructor bolder_cons))
343  (flags (can_block  T)
344         (add_front  T)
345         (hurtable   T))
346  (range 200 200)
347  (abilities (start_hp 40))
348  (fields ("xvel" ai_xvel)
349          ("yvel" ai_yvel)
350          ("hp"   ai_health)
351          )
352  (states "art/bold.spe"
353          (stopped '("bold0001.pcx" "bold0001.pcx" "bold0001.pcx"
354                    "bold0002.pcx" "bold0002.pcx" "bold0002.pcx"
355                    "bold0003.pcx" "bold0003.pcx" "bold0003.pcx"
356                    "bold0004.pcx" "bold0004.pcx" "bold0004.pcx"))))
357
358(defun bounce_move (left_stub right_stub up_stub down_stub nothing_stub)
359  (let ((old_yv  (yvel))
360        (old_xv  (xvel))
361        (status (float_tick)))
362    (if (not (eq status T)) ;; T means we did not hit anything
363        (let ((block_flags (car status)))
364          (if (blocked_up block_flags) ;; bounce up/down
365              (progn
366                (set_xvel old_xv)
367                (if (> old_yv 1)
368                    (set_yvel (- 2 old_yv))
369                  (set_yvel (- 0 old_yv)))
370                (eval up_stub))
371            (if (blocked_down block_flags)
372                (progn
373                  (set_xvel old_xv)
374                  (if (> old_yv 1)
375                      (set_yvel (- 2 old_yv))
376                    (set_yvel (- 0 old_yv)))
377                  (eval down_stub))
378              (if (blocked_left block_flags)
379                  (progn
380                    (set_yvel old_yv)
381                    (set_xvel (- 0 old_xv))
382                    (eval left_stub))
383                (if (blocked_right block_flags)
384                    (progn
385                      (set_yvel old_yv)
386                      (set_xvel (- 0 old_xv))
387                      (eval right_stub)))))))
388      (eval nothing_stub))))
389
390
391
392(defun small_rock_ai ()
393  (next_picture)
394  (set_yvel (+ (yvel) 1))
395  (bounce_move T T T
396               '(progn (add_object EXPLODE1 (+ (x) (random 10)) (- (+ (random 5) (y)) 10)     0)
397                 (add_object EXPLODE1 (- (x) (random 10)) (- (- (y) (random 5)) 10) 2)
398                 (play_sound P_EXPLODE_SND 127 (x) (y))
399                 (hurt_radius (x) (y) 40 15 (if (> (total_objects) 0)
400                                                (get_object 0)
401                                              nil) 20)
402                 nil) T))
403
404
405(def_char SMALL_BOLDER
406  (funs  (ai_fun small_rock_ai))
407
408  (flags (add_front  T)
409         (unlistable T))
410
411  (states "art/bold.spe"
412          (stopped "bsmall")))
413
414
415
416
417
418
419
Note: See TracBrowser for help on using the repository browser.