source: abuse/trunk/data-frabs/addon/twist/lisp/mario.lsp @ 582

Last change on this file since 582 was 582, checked in by Sam Hocevar, 10 years ago

data: remove \r and trailing spaces and tabs from all Lisp sources.

File size: 14.1 KB
Line 
1;; Copyright 1999 Profound Corp,  All Rights reserved
2;; See licensing information for more details on usage rights
3
4
5(defun yoshi_ai ()      ;; This is kinda amatuerish as this is my first attempt
6  (if (<= (hp) 0)       ;; in writing the code from scratch
7      (if (eq (state) dieing)
8          (next_picture)
9        (progn
10          (play_sound CRUMBLE_SND 127 (x) (y))
11          (set_state dieing)
12          T))
13    (progn
14        (try_move 0 10)
15        (next_picture)
16        (if (and (not (> (distx) 70)) (not (eq (state) stopped))) (set_state stopped))
17        (if (and (> (distx) 70) (eq (state) stopped)) (set_state running))
18        (if (or (eq (state) running) (not (eq (direction) (toward))))
19            (progn
20                (set_direction (toward))
21                (try_move (* (toward) 7) 0)
22                (next_picture)(next_picture)(next_picture)(next_picture)(next_picture)(next_picture)
23            ))
24        T) ))
25
26
27(defun mario_ai ()      ;; I think you know where i got this code from...
28  (if (<= (hp) 0)
29      (if (eq (state) dieing)
30          (next_picture)
31        (set_state dieing))
32    (if (activated)
33        (progn
34          (set_targetable T)
35          (push_char 35 40)
36          (select (aistate)
37                  (0 ;; prepare to walk toward player
38                   (if (eq stationary 0)
39                       (progn
40                         (set_state running)
41                         (go_state 1))
42                     (if (> (state_time) (aitype))
43                         (progn
44                           (set_state weapon_fire)
45                           (set_aistate 2)))))
46
47                  (1 ;; walk toward player
48                   (if (eq stationary 0)
49                       (progn
50                         (set_direction (toward))
51                         (let ((curx (x));; save position in case we fall off a cliff
52                               (cury (y)))
53                           (if (next_picture)
54                               (if (eq (current_frame) 99) ;; The sound wont play anyway
55                                   (play_sound JSTOMP_SND 127 (x) (y)));; bc there's 9 frames
56                             (progn                                     ;; only!
57                               (play_sound JSTOMP_SND 127 (x) (y))
58                               (set_state weapon_fire)
59                               (set_aistate 2)))
60                           (if (can_see (x) (y) (x) (+ (y) 5) nil)
61                               (progn
62                                 (set_x curx)
63                                 (set_y cury)
64                                 (try_move 0 10)))))
65                     (if (> (state_time) (aitype))
66                         (progn
67                           (set_state weapon_fire)
68                           (set_aistate 2)))))
69
70                  (2 ;; start fire
71                   (if (> (state_time) 10)
72                       (let ((myself (me))
73                             (xspeed (* throw_xvel (direction)))
74                             (yspeed throw_yvel))
75                         (with_object (add_object MARIO_FIREBALL (+ (x) (* (direction) 20)) (- (y) 5) 1)
76                                      (progn
77                                        (user_fun myself)
78                                        (set_xvel xspeed)
79                                        (set_yvel yspeed)))
80                         (go_state 3))
81                     (next_picture)))
82                  (3 ;; wait for fire animation
83                   (if (next_picture) nil (set_aistate 0))))
84          T)
85      (progn (set_targetable nil)
86             T))))
87
88(defun mario_cons ()
89  (setq throw_xvel 10)
90  (setq throw_yvel 5)
91  (set_aitype 0))
92
93
94(defun m_fireball_ai ()
95  (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
96      (if (eq (hp) 0)
97          (progn
98            (play_sound P_EXPLODE_SND 127 (x) (y))
99            (add_object EXPLODE3 (+ (x) (random 5)) (+ (y) (random 5)) 0)
100            (add_object EXPLODE2 (+ (x) (random 5)) (+ (y) (random 5)) 2)
101            (add_object EXPLODE3 (- (x) (random 5)) (- (y) (random 5)) 1)
102            (add_object EXPLODE2 (- (x) (random 5)) (- (y) (random 5)) 2)
103            (add_object EXP_LIGHT (x) (y) 100)
104            nil)
105        (progn
106          (next_picture)
107          (set_yvel (+ (yvel) 1))
108          (let ((old_yv  (yvel))
109                (old_xv  (xvel))
110                (old_x   (x))
111                (old_y   (y))
112                (status (float_tick)))
113
114            (let ((new_x (x))
115                  (new_y (y))
116                  (set_x old_x)
117                  (set_y old_y))
118              (platform_push (- new_x (x)) (- new_y (y)))
119              (set_x new_x)
120              (set_y new_y))
121            (hurt_radius (x) (y) 20 10 (me) 15)
122            (if (not (eq status T));; T means we did not hit anything
123                (let ((block_flags (car status)))
124                  (if (or (blocked_up block_flags) (blocked_down block_flags));; bounce up/down
125                      (progn
126                        (if (> (abs old_yv) 3)
127                            (play_sound SBALL_SND 127 (x) (y)))
128                        (set_xvel old_xv)
129                        (if (> old_yv 1)
130                            (set_yvel (- 2 old_yv))
131                          (set_yvel (- 0 old_yv))))
132                    (if (or (blocked_left block_flags) (blocked_right block_flags));; bounce left/right
133                        (progn
134                          (set_yvel old_yv)
135                          (set_xvel (- 0 old_xv))))))))
136          T))
137    T))
138
139
140
141(defun mqblock_ai ()
142        (set_fade_count (yacel))
143  (if (<= (hp) 0)
144      (if (eq (state) dieing)
145          (next_picture)
146        (progn
147          (play_sound CRUMBLE_SND 127 (x) (y))
148          (set_state dieing)
149        (with_object (add_object MARIO_BLOCKH (x) (y)) (progn (set_xvel 0) (set_yvel 0)))
150                (select (aitype)
151                  (1 (add_object MARIO_POWERCOIN (x) (- (y) 20)))
152                  (2 (add_object MARIO_POWERFLOW (x) (- (y) 20)))
153                  (3 (add_object MARIO_POWERTOAD (x) (- (y) 20)))
154                  (4 (add_object MARIO_POWERSTAR (x) (- (y) 20)))
155                )
156          T))
157    T))
158
159
160(defun mbblock_ai ()
161        (set_fade_count (yacel))
162  (if (<= (hp) 0)
163      (if (eq (state) dieing)
164          (next_picture)
165        (progn
166          (play_sound CRUMBLE_SND 127 (x) (y))
167          (set_state dieing)
168                (select (aitype)
169                  (1 (add_object MARIO_POWERCOIN (x) (y)))
170                  (2 (add_object MARIO_POWERFLOW (x) (y)))
171                  (3 (add_object MARIO_POWERTOAD (x) (y)))
172                  (4 (add_object MARIO_POWERSTAR (x) (y)))
173                )
174          T))
175    T))
176
177(defun mvenus_ai ()
178        (next_picture)
179  (if (<= (hp) 0)
180      (if (eq (state) dieing)
181          (next_picture)
182        (progn
183          (play_sound CRUMBLE_SND 127 (x) (y))
184          (set_state dieing)
185          T))
186    T))
187
188
189(defun mvenus_cons ()
190(set_current_frame 16))
191
192
193(defun memush_ai ()
194  (if (<= (hp) 0)
195      (if (eq (state) dieing)
196          (next_picture)
197        (progn
198          (play_sound CRUMBLE_SND 127 (x) (y))
199          (set_state dieing)
200          T))
201    (progn
202        (try_move 0 10)
203        (next_picture)
204        (if (and (eq (direction) 1) (blocked_right (move 1 0 0))) (set_direction -1))
205        (if (and (eq (direction) -1) (blocked_left (move -1 0 0))) (set_direction 1))
206        T) ))
207
208(defun mbill_ai ()
209  (if (eq (mod (game_tick) 40) 0)
210        (add_object MARIO_BULLET (x) (- (y) 18) ))
211  T)
212
213(defun mbullet_ai ()
214  (try_move (xvel) 0)
215)
216
217(defun mbullet_cons ()
218        (set_direction (toward))
219  (if (eq (direction) -1) (progn (set_x (- (x) 7)) (set_xvel -7)))
220  (if (eq (direction) 1) (progn (set_x (+ (x) 22)) (set_xvel 7)))
221)
222
223
224(defun mpowtoad_ai ()
225        (try_move 0 10)
226        (next_picture)
227        (if (touching_bg)
228           (progn
229        (with_object (bg) (give_player_health 20))
230             (play_sound HEALTH_UP_SND 127 (x) (y))
231             nil)
232          T))
233
234(defun mpowstar_ai ()
235        (try_move 0 10)
236        (next_picture)
237        (if (touching_bg)
238           (progn
239        (with_object (bg) (setq special_power FAST_POWER))
240             (play_sound HEALTH_UP_SND 127 (x) (y))
241             nil)
242          T))
243
244(defun mpowflow_ai ()
245        (try_move 0 10)
246        (next_picture)
247        (if (touching_bg)
248           (progn
249        (with_object (bg) (setq special_power HEALTH_POWER))
250             (play_sound HEALTH_UP_SND 127 (x) (y))
251             nil)
252          T))
253
254(defun mpowcoin_ai ()
255        (try_move 0 10)
256        (next_picture)
257        (if (touching_bg)
258           (progn
259        (with_object (bg) (give_player_health 4))
260             (play_sound HEALTH_UP_SND 127 (x) (y))
261             nil)
262          T))
263
264
265(def_char MARIO_YOSHI
266  (funs (ai_fun  yoshi_ai))
267  (flags (can_block T)
268         (hurtable  T))
269  (abilities (start_hp 200))
270  (states "addon/twist/art/mario.spe"
271          (stopped       '("ys0001.bmp" "ys0002.bmp" "ys0003.bmp" "ys0002.bmp" "ys0001.bmp"
272                           "ya0001.bmp" "ya0002.bmp" "ya0003.bmp" "ya0004.bmp" "ya0005.bmp"
273                           "ya0006.bmp" "ya0007.bmp" "ya0008.bmp" "ya0009.bmp" "ya0010.bmp"
274                           "ya0011.bmp" "ya0012.bmp"))
275          (running       (seqbmp "yr" 1 6))
276          (dieing        (seqbmp "yd" 1 20))))
277
278
279(def_char MARIO_MARIO
280  (range 200 0)
281  (funs (ai_fun     mario_ai)
282        (constructor mario_cons)
283        (draw_fun       gun_draw)
284        (get_cache_list_fun explo_damage_cache))
285  (flags (hurtable T))
286  (abilities (start_hp    100)
287             (push_xrange 1))
288  (vars throw_xvel throw_yvel stationary)
289  (fields ("hp"            ai_health)
290          ("aitype"        jug_throw_spd)
291          ("throw_xvel"    jug_throw_xv)
292          ("throw_yvel"    jug_throw_yv)
293          ("stationary"    jug_stat)
294          ("aistate"       ai_state))
295
296  (states "addon/twist/art/mario.spe"
297          (stopped "ms.bmp")
298          (running '("mr0001.bmp" "mr0002.bmp" "mr0003.bmp"
299                     "mr0001.bmp" "mr0002.bmp" "mr0003.bmp"
300                     "mr0001.bmp" "mr0002.bmp" "mr0003.bmp"))
301          (weapon_fire  '("ms.bmp" "mj.bmp" "ma.bmp" "ma.bmp" "ms.bmp"))
302          (dieing (seqbmp "md" 1 10))))
303
304
305(def_char MARIO_LUIGI
306  (range 200 0)
307  (funs (ai_fun     mario_ai)
308        (constructor mario_cons)
309        (draw_fun       gun_draw)
310        (get_cache_list_fun explo_damage_cache))
311  (flags (hurtable T))
312  (abilities (start_hp    100)
313             (push_xrange 1))
314  (vars throw_xvel throw_yvel stationary)
315  (fields ("hp"            ai_health)
316          ("aitype"        jug_throw_spd)
317          ("throw_xvel"    jug_throw_xv)
318          ("throw_yvel"    jug_throw_yv)
319          ("stationary"    jug_stat)
320          ("aistate"       ai_state))
321
322  (states "addon/twist/art/mario.spe"
323          (stopped "ls.bmp")
324          (running '("lr0001.bmp" "lr0002.bmp" "lr0003.bmp"
325                     "lr0001.bmp" "lr0002.bmp" "lr0003.bmp"
326                     "lr0001.bmp" "lr0002.bmp" "lr0003.bmp"))
327          (weapon_fire  '("ls.bmp" "lj.bmp" "la.bmp" "la.bmp" "ls.bmp"))
328          (dieing (seqbmp "ld" 1 10))))
329
330
331(def_char MARIO_FIREBALL
332  (funs  (ai_fun m_fireball_ai)
333         (damage_fun bold_dam)
334         (constructor bolder_cons))
335  (flags (can_block  T)
336         (add_front  T)
337         (hurtable   T)
338         (unlistable T))
339  (range 200 200)
340  (abilities (start_hp 1))
341  (fields ("xvel" ai_xvel)
342          ("yvel" ai_yvel)
343          ("hp"   ai_health)
344          )
345  (states "addon/twist/art/mario.spe"
346          (stopped (seqbmp "mf" 1 4))))
347
348
349(def_char MARIO_BLOCKQ
350  (funs (ai_fun  mqblock_ai))
351  (flags (can_block T)
352         (hurtable  T))
353  (abilities (start_hp 2))
354  (fields ("aitype" "Power 0=nil,1=cn,2=fl,3=td,4=st")
355          ("yacel" "Fade Count"))
356  (states "addon/twist/art/mario.spe"
357          (stopped       "b0012.bmp")
358          (dieing        (seqbmp "b" 12 1))))
359
360
361(def_char MARIO_BLOCKH
362  (funs (ai_fun  do_nothing)
363        (draw_fun lower_draw))
364  (flags (can_block T)
365         (hurtable  nil))
366  (states "addon/twist/art/mario.spe"
367          (stopped       "b0001.bmp")))
368
369
370(def_char MARIO_BLOCKB
371  (funs (ai_fun  mbblock_ai))
372  (flags (can_block T)
373         (hurtable  T))
374  (abilities (start_hp 2))
375  (fields ("aitype" "Power 0=nil,1=cn,2=fl,3=td,4=st")
376          ("yacel" "Fade Count"))
377  (states "addon/twist/art/mario.spe"
378          (stopped       "b20001.bmp")
379          (dieing        (seqbmp "b2" 1 10))))
380
381
382(def_char MARIO_PIPEUP
383  (funs (ai_fun  do_nothing))
384  (flags (can_block T))
385  (states "addon/twist/art/mario.spe"
386          (stopped       "pup.bmp")))
387
388
389(def_char MARIO_PIPEDOWN
390  (funs (ai_fun  do_nothing))
391  (flags (can_block T))
392  (states "addon/twist/art/mario.spe"
393          (stopped       "pdown.bmp")))
394
395
396(def_char MARIO_PIPELEFT
397  (funs (ai_fun  do_nothing))
398  (flags (can_block T))
399  (states "addon/twist/art/mario.spe"
400          (stopped       "pleft.bmp")))
401
402
403(def_char MARIO_PIPERIGHT
404  (funs (ai_fun  do_nothing))
405  (flags (can_block T))
406  (states "addon/twist/art/mario.spe"
407          (stopped       "pright.bmp")))
408
409
410(def_char MARIO_PIPEVERT
411  (funs (ai_fun  do_nothing))
412  (flags (can_block T))
413  (states "addon/twist/art/mario.spe"
414          (stopped       "pvert.bmp")))
415
416
417(def_char MARIO_PIPEHORI
418  (funs (ai_fun  do_nothing))
419  (flags (can_block T))
420  (states "addon/twist/art/mario.spe"
421          (stopped       "phori.bmp")))
422
423
424(def_char MARIO_PIPECROSS
425  (funs (ai_fun  do_nothing))
426  (flags (can_block T))
427  (states "addon/twist/art/mario.spe"
428          (stopped       "pcross.bmp")))
429
430
431(def_char MARIO_VENUS
432  (funs (ai_fun  mvenus_ai)
433        (constructor mvenus_cons))
434  (flags (can_block T)
435         (hurtable  T))
436  (abilities (start_hp 25))
437  (states "addon/twist/art/mario.spe"
438          (stopped       '("v0001.bmp" "v0001.bmp" "v0001.bmp" "v0001.bmp"
439                           "v0001.bmp" "v0001.bmp" "v0001.bmp" "v0001.bmp"
440                           "v0001.bmp" "v0001.bmp" "v0001.bmp" "v0001.bmp"
441                           "v0002.bmp" "v0003.bmp" "v0004.bmp" "v0005.bmp"
442                           "v0005.bmp" "v0005.bmp" "v0005.bmp" "v0005.bmp"
443                           "v0005.bmp" "v0005.bmp" "v0005.bmp" "v0005.bmp"
444                           "v0004.bmp" "v0003.bmp" "v0002.bmp" "v0001.bmp"))
445          (dieing        (seqbmp "vd" 1 10))
446          (risen         "v0005.bmp")))
447
448
449(def_char MARIO_ENEMYMUSH
450  (funs (ai_fun  memush_ai))
451  (flags (can_block T)
452         (hurtable  T))
453  (abilities (start_hp 20)
454             (run_top_speed 4))
455  (states "addon/twist/art/mario.spe"
456          (stopped       '("mush0001.bmp" "mush0002.bmp" "mush0003.bmp"))
457          (dieing        (seqbmp "mshd" 1 10))))
458
459
460(def_char MARIO_ENEMYTRTL
461  (funs (ai_fun  memush_ai))
462  (flags (can_block T)
463         (hurtable  T))
464  (abilities (start_hp 30)
465             (run_top_speed 2))
466  (states "addon/twist/art/mario.spe"
467          (stopped       (seq "trtl" 1 2))
468          (dieing        (seq "tdie" 1 10))))
469
470
471(def_char MARIO_BULLETBILL
472  (funs (ai_fun  mbill_ai))
473  (flags (can_block T)
474         (hurtable  nil))
475  (states "addon/twist/art/mario.spe"
476          (stopped       "bill")))
477
478(def_char MARIO_BULLET
479  (funs (ai_fun  mbullet_ai) (constructor mbullet_cons))
480  (flags (can_block T)
481         (hurtable  nil)
482         (unlistable T))
483  (states "addon/twist/art/mario.spe"
484          (stopped       "bullet")))
485
486
487(def_char MARIO_POWERTOAD
488  (funs (ai_fun mpowtoad_ai))
489  (range 0 0)
490  (states "addon/twist/art/mario.spe" (stopped "powtoad" )))
491
492(def_char MARIO_POWERSTAR
493  (funs (ai_fun mpowstar_ai))
494  (range 0 0)
495  (states "addon/twist/art/mario.spe" (stopped "powstar" )))
496
497(def_char MARIO_POWERFLOW
498  (funs (ai_fun mpowflow_ai))
499  (range 0 0)
500  (states "addon/twist/art/mario.spe" (stopped "powflow" )))
501
502(def_char MARIO_POWERCOIN
503  (funs (ai_fun mpowcoin_ai))
504  (range 0 0)
505  (states "addon/twist/art/mario.spe" (stopped (seq "coin" 1 4) )))
506
507(def_char MARIO_PROPCLDS
508  (funs (ai_fun do_nothing) (draw_fun lower_draw))
509  (range 0 0)
510  (states "addon/twist/art/mario.spe" (stopped "clouds")))
511
512(def_char MARIO_PROPBUSH
513  (funs (ai_fun do_nothing) (draw_fun lower_draw))
514  (range 0 0)
515  (states "addon/twist/art/mario.spe" (stopped "bushes")))
516
517(def_char MARIO_PROPHILL
518  (funs (ai_fun do_nothing) (draw_fun lower_draw))
519  (range 0 0)
520  (states "addon/twist/art/mario.spe" (stopped "hill")))
521
522(def_char MARIO_PROPHILL2
523  (funs (ai_fun do_nothing) (draw_fun lower_draw))
524  (range 0 0)
525  (states "addon/twist/art/mario.spe" (stopped "hillbig")))
526
527(def_char MARIO_PROPTREE2
528  (funs (ai_fun do_nothing) (draw_fun lower_draw))
529  (range 0 0)
530  (states "addon/twist/art/mario.spe" (stopped "treebig")))
531
532(def_char MARIO_PROPTREE
533  (funs (ai_fun do_nothing) (draw_fun lower_draw))
534  (range 0 0)
535  (states "addon/twist/art/mario.spe" (stopped "tree")))
536
537(def_char MARIO_PROPTREE
538  (funs (ai_fun do_nothing) (draw_fun lower_draw))
539  (range 0 0)
540  (states "addon/twist/art/mario.spe" (stopped "tree")))
541
542(def_char MARIO_PROPBRID
543  (funs (ai_fun do_nothing) (draw_fun lower_draw))
544  (flags (can_block T))
545  (range 0 0)
546  (states "addon/twist/art/mario.spe" (stopped "bridge")))
547
548(def_char MARIO_PROPPLAT
549  (funs (ai_fun do_nothing) (draw_fun lower_draw))
550  (flags (can_block T))
551  (range 0 0)
552  (states "addon/twist/art/mario.spe" (stopped "platform")))
553
Note: See TracBrowser for help on using the repository browser.