source: abuse/trunk/data/addon/aliens/alichars.lsp @ 634

Last change on this file since 634 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: 25.2 KB
Line 
1;; Copyright 1995 Crack dot Com,  All Rights reserved
2;; See licensing information for more details on usage rights
3;;
4;; Copyright 1997 Mike Moss (tfirestorm@aol.com),  All Rights reserved
5;; See readme for more details on usage rights
6
7;; Face Hugger
8
9(defun no_fall_move (xm ym but)
10  (move xm ym but)
11  (if (not (eq (gravity) 0))         ;; if we are in the air don't check for no fall
12      (move xm ym but)
13    (let ((oldx (x))
14          (oldy (y))
15          (ret (move xm ym but)))
16      (if (try_move 0 5)
17          (progn
18            (set_x oldx)
19            (set_y oldy)
20            (set_xacel 0)
21            (set_state stopped)
22            (set_xv 0)
23            (set_gravity 0)
24            0))
25        ret)))
26
27(defun will_fall_if_jump ()
28  (let ((dist (* (abs (get_ability jump_yvel)) (get_ability jump_xvel)))
29        (oldx (x))
30        (oldy (y))
31        )
32    (if (> (direction) 0)
33        (set_x (+ (x) dist))
34      (set_x (- (x) dist)))
35    (if (try_move 0 5)
36        (progn
37          (set_x oldx)
38          (set_y oldy)
39          T)
40      (progn
41        (set_x oldx)
42          (set_y oldy)
43        nil))))
44
45
46(defun alien_wait_time ()
47  (select difficulty
48          ('easy    6)
49          ('medium  4)
50          ('hard    2)
51          ('extreme 1)))
52
53(defun not_ali_congestion ()
54  (if (> (direction) 0)
55      (if (find_object_in_area (+ (x) 23) (- (y) 20) (+ (x) 30) (+ (y) 20) (list ALIEN_DRONE ALIEN_WARRIOR FACE_HUGGER))
56          nil
57        T)
58    (if (find_object_in_area (- (x) 30) (+ (y) 20) (- (x) 23) (+ (y) 20) (list ALIEN_DRONE ALIEN_WARRIOR FACE_HUGGER))
59        nil
60      T)))
61
62
63(defun roof_above () (not (can_see (x) (y) (x) (- (y) 120) nil)))
64
65(defun ali_dodge ()
66  (if (eq need_to_dodge 1)
67      (progn
68        (setq need_to_dodge 0)
69        (if (eq (random 2) 1)
70            (progn
71              (set_state stopped)
72              (go_state 6))         ;; jump at player
73            (progn
74              (set_yvel -12)  ;; long jump
75              (set_xvel (* (direction) 20))
76              (set_aistate 6)))
77        T
78    nil)))
79
80(defun alscream_check ()
81  (if (can_see (x) (y) (with_object (bg) (x)) (with_object (bg) (y)) nil)
82      (progn
83        (if (or (eq no_see_time 0) (> no_see_time 20))
84          (play_sound ALSCREAM_SND 127 (x) (y)))
85        (setq no_see_time 1))
86    (setq no_see_time (+ no_see_time 1))))
87
88(defun al_char_draw ()
89        (draw)
90        (if (edit_mode)
91          (progn
92          (draw_line (x) (- (y) 9) (+ (x) 9) (- (y) 9) (find_rgb 255 0 0))
93          (draw_line (+ (x) 9) (- (y) 9) (+ (x) 9) (y) (find_rgb 255 0 0))
94          (draw_line (+ (x) 9) (y) (x) (y) (find_rgb 255 0 0))
95          (draw_line (x) (y) (x) (- (y) 9) (find_rgb 255 0 0)))))
96
97(defun fh_ai ()
98        (if (not (eq (aistate) 20))
99           (if (not (eq (aistate) 0))
100        (push_char 30 10)))
101      (if (or (eq (state) flinch_up) (eq (state) flinch_down))
102          (progn (next_picture) T)
103        (progn
104
105          (select (aistate)
106                  (0   (if (eq hide_flag 0)
107                           (set_aistate 15)
108                         (set_aistate 1)))
109
110                (15 ;; hiding
111                   (set_state hiding)
112                   (if (if (eq (total_objects) 0);; no sensor, wait for guy
113                           (and (< (distx) 130) (< (y) (with_object (bg) (y))))
114                         (not (eq (with_object (get_object 0) (aistate)) 0)))
115                       (progn
116                         (set_state fall_start)                  (set_direction (toward))
117                         (set_aistate 1))))
118
119                  (1 ;; falling down
120                   (set_state falling)
121                   (alscream_check)
122                   (if (blocked_down (move 0 0 0))
123                       (progn
124                         (set_state landing)
125                         (play_sound ALAND_SND 127 (x) (y))
126                         (set_aistate 9))))
127
128                  (9 ;; landing / turn around (general finish animation state)
129                   (if (next_picture) T
130                     (if (try_move 0 2)
131                         (progn
132                           (set_gravity 1)
133                           (set_aistate 1))
134                       (progn (set_state stopped)
135                              (go_state 2)))))  ;; running
136
137                  (2 ;; running
138                   (alscream_check)
139                   (if (eq (random 20) 0) (setq need_to_dodge 1))
140                   (if (not (ali_dodge))
141                     (if (eq (facing) (toward))
142                         (progn
143                           (next_picture)
144                             (if (and (< (distx) 100) (> (distx) 10) (eq (random 5) 0))
145                                 (set_aistate 4)  ;; wait for pounce
146
147                               (if (and (> (distx) 140)
148                                        (not_ali_congestion)
149                                        (not (will_fall_if_jump)))
150                                   (set_aistate 6)
151
152                                 (if (> (direction) 0)
153                                     (if (and (not_ali_congestion) (blocked_right (no_fall_move 1 0 0)))
154                                         (set_direction -1))
155                                   (if (and (not_ali_congestion) (blocked_left (no_fall_move -1 0 0)))
156                                       (set_direction 1))))))
157                           (progn
158                             (set_direction (toward))
159                             (set_state turn_around)
160                             (set_aistate 9)))))
161
162                  (4 ;; wait for pounce
163                   (if (ali_dodge) T
164                     (progn
165                       (set_state pounce_wait)
166                       (move 0 0 0)
167                       (if (> (state_time) (alien_wait_time))
168                           (progn
169                             (play_sound ALSLASH_SND 127 (x) (y))
170                             (set_state stopped)
171                             (go_state 6))))))
172
173                  (6 ;; jump
174                   (setq need_to_dodge 0)
175                   (if (blocked_down (move (direction) -1 0))
176                       (progn
177                         (set_aistate 2))))
178                  )))
179   (if (eq (aistate) 20)
180        (progn nil)
181        (progn   T)))
182
183(defun ali_damage (amount from hitx hity push_xvel push_yvel)
184
185  (if (not (or (eq (state) dead)
186           (with_object from (or (eq (otype) FACE_HUGGER) (or (eq (otype) ALIEN_DRONE) (or (eq (otype) ALIEN_WARRIOR) (eq (otype) ALI_QUE)))))))
187      (if (not (eq (aistate) 15))
188          (progn
189            (if (eq (random 2) 0)
190                (set_state flinch_up)
191              (set_state flinch_down))
192            (damage_fun amount from hitx hity push_xvel push_yvel)
193            (play_sound ALPAIN_SND 127 (x) (y))
194            (setq need_to_dodge 1)
195            (if (<= (hp) 0)
196                (progn
197                  (play_sound (aref AL_DEATH (random 4)) 127 (x) (y))
198                  (set_state dead)
199                  (set_aistate 20)
200                        (if (eq (with_object (me) (otype)) ALIEN_DRONE)
201                           (add_object DYING_AD (x) (y))
202                           (if (eq (with_object (me) (otype)) ALIEN_WARRIOR)
203                                (add_object DYING_AW (x) (y))
204                                (if (eq (with_object (me) (otype)) ALI_QUE)
205                                     (add_object DYING_AQ (x) (y))
206                                     (if (eq (with_object (me) (otype)) FACE_HUGGER)
207                                        (add_object DYING_FH (x) (y))))))
208                  ))))))
209
210(defun fh_cons ()
211  (set_hp 15)
212  (set_state hiding)
213  (setq no_see_time 300))
214
215(def_char FACE_HUGGER
216  (vars need_to_dodge
217        no_see_time
218        hide_flag)
219  (fields
220          ("hide_flag"    "hidden? 0-Yes 1-No")
221          ("fade_count"   "fade")
222          ("aitype"       "aitype")
223          ("hp"           "health")
224          ("aistate"      "aistate"))
225  (range 250 200)
226  (draw_range 40 40)
227  (funs (ai_fun         fh_ai)
228        (draw_fun       al_char_draw)
229        (constructor    fh_cons)
230        (damage_fun             ali_damage))
231
232  (abilities (run_top_speed   9)
233             (start_hp       20)
234             (stop_acel      14)
235             (start_acel     10)
236             (jump_yvel      -4)
237             (jump_xvel      14)
238             (push_xrange     1)
239             (jump_top_speed 15))
240
241  (flags (hurtable  T)
242         (force_health T))
243
244  (states "addon/aliens/aliens.spe"
245          (stopped              "fhwk0001.pcx")
246          (fall_start   "fhattack.pcx")
247          (falling              "fhattack.pcx")
248          (running              (seq "fhwk" 1 4))
249          (landing              "fhattack.pcx")
250          (pounce_wait  "fhwk0002.pcx")
251          (turn_around  (seq "fhtn" 1 3))
252          (run_jump             "fhattack.pcx")
253          (run_jump_fall        "fhattack.pcx")
254          (start_run_jump "fhattack.pcx")
255          (flinch_up    "fhhit.pcx")
256          (flinch_down  "fhattack.pcx")
257          (hiding         "hidden")
258          ))
259
260(defun fh_egg_ai ()
261   (try_move 0 10)
262   (progn
263        (if (eq (aistate) 0)
264         (if (if (eq (total_objects) 0)
265              (and (< (distx) 70) (< (disty) 70))
266              (with_object (get_object 0) (not (eq (aistate) 0))))
267              (set_aistate 1))
268        (select (current_frame)
269            (12 (set_current_frame 13)
270                (with_object (add_object_after FACE_HUGGER (+ (x) (* (toward) 20)) (y))
271                            (progn
272                              (set_aitype 0)
273                              (set_direction (toward))
274                              (set_state run_jump)
275                              (set_aistate 6)))
276               )
277            (0 (next_picture)
278                 (play_sound EGGH_SND 127 (x) (y)))
279            (1 (next_picture))
280            (2 (next_picture))
281            (3 (next_picture))
282            (4 (next_picture))
283            (5 (next_picture))
284            (6 (next_picture))
285            (7 (next_picture))
286            (8 (next_picture))
287            (9 (next_picture))
288            (10 (next_picture))
289            (11 (next_picture))
290        )))
291  T)
292
293
294(def_char FACE_HUGGER_EGG
295  (funs (ai_fun fh_egg_ai))
296  (range 250 0)
297  (states "addon/aliens/aliens.spe"
298          (stopped              (seq "eggh" 0 13))))
299
300(defun dying_ai ()
301        (try_move 0 10)
302        (next_picture))
303
304(def_char DYING_FH
305  (flags (unlistable T))
306  (funs (ai_fun dying_ai))
307  (states "addon/aliens/aliens.spe"
308         (stopped (seq "fhdi" 2 11))))
309
310(def_char FACE_HUGGER_EGG_HATCHED
311  (funs (ai_fun fh_d_egg_ai))
312        (states "addon/aliens/aliens.spe"
313         (stopped "eggh0013.pcx")))
314
315(def_char FACE_HUGGER_EGG_UNHATCHED
316  (funs (ai_fun fh_d_egg_ai))
317        (states "addon/aliens/aliens.spe"
318         (stopped "eggunh.pcx")))
319
320(defun fh_d_egg_ai ()
321        (progn
322        (try_move 0 10)
323        (lower)))
324
325(def_char FACE_HUGGER_JAR_DEAD
326  (funs (ai_fun d_fh_jar_ai))
327        (states "addon/aliens/aliens.spe"
328         (stopped "afhj0001.pcx")))
329
330(defun d_fh_jar_ai ()
331        (progn
332        (lower)))
333
334(def_char FACE_HUGGER_JAR_ALIVE
335   (funs (ai_fun a_fh_jar_ai)
336        (damage_fun             jar_damage))
337   (flags (hurtable  T))
338   (states "addon/aliens/aliens.spe"
339         (stopped (seq "afhj" 1 2))
340         (escaped "fhjexplo.pcx")))
341
342(defun jar_damage ()
343        (if (eq (aistate) 0)
344           (progn
345           (play_sound JBRK_SND 127 (x) (y))
346           (set_aistate 1)
347           (set_state escaped)
348                )))
349
350(defun a_fh_jar_ai ()
351  (if (eq (aistate) 0)
352        (progn
353           (lower)
354           (if (and (eq (current_frame) 0) (eq (random 20) 0))
355                (progn
356                (next_picture))
357                (progn
358                (set_current_frame 0)))
359        )
360        (if (eq (aistate) 1)
361            (progn
362                (add_object EXPLODE1 (x) (- (y) 10))
363               (with_object (add_object_after FACE_HUGGER (x) (y))
364                            (progn
365                              (set_aitype 0)
366                              (set_direction (toward))
367                              (set_yvel 2)
368                              (set_state falling)
369                              (set_aistate 1)))
370                (set_aistate 2)
371        )))
372  T)
373
374;; Alien Drone
375
376(defun ad_dodge ()
377  (if (eq need_to_dodge 1)
378      (progn
379        (setq need_to_dodge 0)
380        (if (eq (random 2) 1)
381            (progn
382              (set_state stopped)
383              (go_state 6))         ;; jump at player
384          (if (roof_above)
385              (progn
386                (set_yvel -17)  ;; jump up
387                (set_xvel 0)
388                (go_state 12))
389            (progn
390              (set_yvel -12)  ;; long jump
391              (set_xvel (* (direction) 20))
392              (set_aistate 6))))
393        T
394    nil)))
395
396(defun can_hit_player ()
397  (let ((firex (+ (x) (* (direction) 15)) )
398        (firey (- (y) 15))
399        (playerx (with_object (bg) (x)))
400        (playery (- (with_object (bg) (y)) 15)))
401    (can_see firex firey playerx playery nil)))
402
403(defun ali_fire_at_player ()
404  (let ((firex (+ (x) (* (direction) 15)) )
405        (firey (- (y) 15))
406        (playerx (+ (with_object (bg) (x)) (with_object (bg) (* (xvel) 8))))
407        (playery (+ (- (with_object (bg) (y)) 15) (with_object (bg) (* (yvel) 2)))))
408
409    (if (and (can_see (x) (y) firex firey nil) (can_see firex firey playerx playery nil))
410        (progn
411          (let ((angle (atan2 (- firey playery)
412                              (- playerx firex))))
413            (fire_object (me) 50 firex firey angle (bg))
414            (set_state weapon_fire))
415
416          ))))
417
418(defun fire_object (creator type x y angle target)
419  (select type
420          (0 (with_object (add_object SHOTGUN_BULLET x y)
421                                      (progn
422                                        (play_sound ZAP_SND 127 (x) (y))
423                                        (setq sgb_lifetime 6)
424                                        (setq sgb_speed 15)
425                                        (setq sgb_lastx (x))
426                                        (setq sgb_lasty (y))
427                                        (setq sgb_angle angle)
428                                        (setq sgb_bright_color (find_rgb 255 255 200))
429                                        (setq sgb_medium_color (find_rgb 150 150 0))
430                                        (if creator
431                                            (progn
432                                              (setq sgb_speed (+ sgb_speed (/ (xvel) 2)))
433                                              (link_object creator)))
434                                        (sgun_ai)
435                                        )))
436          (1 (with_object (add_object SHOTGUN_BULLET x y)
437                                      (progn
438                                        (play_sound ZAP_SND 127 (x) (y))
439                                        (setq sgb_lifetime 40)
440                                        (setq sgb_speed 6)
441                                        (setq sgb_lastx (x))
442                                        (setq sgb_lasty (y))
443                                        (setq sgb_angle angle)
444
445                                        (setq sgb_bright_color (find_rgb 255 128 64))
446                                        (setq sgb_medium_color (find_rgb 255 0 0))
447                                        (if creator
448                                            (progn
449                                              (setq sgb_speed (+ sgb_speed (/ (xvel) 2)))
450                                              (link_object creator)))
451                                        (sgun_ai)
452                                        )))
453          (2 (with_object (add_object GRENADE x y)
454                          (progn
455                            (play_sound GRENADE_THROW 127 x y)
456                            (set_course angle 20)
457                            (if creator
458                                (progn
459                                  (link_object creator)
460                                  (set_xvel (+ (xvel) (with_object creator (xvel))))
461                                  (set_yvel (+ (yvel) (with_object creator (yvel))))
462                                  ))
463
464                            (set_frame_angle 0 359 angle)
465                            )))
466          (3 (with_object (add_object ROCKET x y)
467                          (progn
468                            (play_sound ROCKET_LAUNCH_SND 127 x y)
469                            (set_aistate angle)
470                            (if creator (link_object creator))
471
472                            (if (and target   ;; don't link if not in line of site
473                                     (can_see (x) (y)
474                                              (with_object target (x))
475                                              (with_object target (y)) nil))
476                                              (link_object target))
477
478                            (set_frame_angle 0 359 angle)
479                            (setq speed 5)
480                            (if (and creator (with_object creator (isa_player)))
481                                (setq max_speed 14)
482                              (setq max_speed 10))
483                            (set_y (+ (y) (/ (picture_height) 2)))  ;; move down to match frame/pos
484                            )))
485
486          (4 (with_object (add_object PLASMAGUN_BULLET x y)
487                                      (progn
488                                        (play_sound PLASMA_SND 127 (x) (y))
489                                        (setq sgb_lastx (x))
490                                        (setq sgb_lasty (y))
491                                        (if creator
492                                              (link_object creator))
493                                        (set_course angle 200)
494                                        (let ((old_x (x))
495                                              (old_y (y))
496                                              (bx (bmove (if (> (total_objects) 0) (get_object 0) nil))))
497                                          (if (not (eq bx T))
498                                              (if (eq bx nil)
499                                                  (add_object EXPLODE5 (- (x) (random 5))
500                                                              (- (y) (random 5)) 0)
501                                                (progn
502                                                  (add_object EXPLODE3 (- (x) (random 5))
503                                                              (- (y) (random 5)) 0)
504                                                  (do_damage 10 bx (* (cos sgb_angle) 20)
505                                                             (* (sin sgb_angle) 10)))))
506                                          (setq sgb_lastx (x))
507                                          (setq sgb_lasty (y))
508                                          (set_x old_x)
509                                          (set_y old_y))
510                                        )))
511
512
513          (5 (with_object (add_object FIREBOMB x y)
514                          (progn
515                            (play_sound FIREBOMB_SND 127 (x) (y))
516                            (set_course angle 20)
517                            (if creator
518                                (progn
519                                  (link_object creator)
520                                  (set_yvel (+ (yvel) (with_object creator (yvel))))
521                                  )))))
522
523          (6 (with_object (add_object DFRIS_BULLET x y)
524                                      (progn
525                                        (play_sound ROCKET_LAUNCH_SND 127 x y)
526                                        (set_course angle 25)
527                                        (set_aistate angle)
528                                        (if creator
529                                              (link_object creator))
530                                        (dfris_ai)
531                                        )))
532
533          (7 (with_object (add_object LSABER_BULLET x y)
534                                      (progn
535                                        (play_sound LSABER_SND 127 (x) (y))
536                                        (setq sgb_lastx (x))
537                                        (setq sgb_lasty (y))
538                                        (if creator
539                                              (link_object creator))
540                                        (set_course angle 45)
541                                        (let ((bx (bmove (if (> (total_objects) 0) (get_object 0) nil))))
542                                          (if (not (eq bx T))
543                                              (if (not (eq bx nil))
544                                                  (do_damage 30 bx (* (cos sgb_angle) 20)
545                                                             (* (sin sgb_angle) 10)))))
546                                        )))
547
548
549          (9 (with_object (add_object STRAIT_ROCKET x y)
550                                      (progn
551                                        (play_sound MGUN_SND 127 (x) (y))
552                                        (if creator
553                                              (link_object creator))
554                                        (set_aistate angle)
555                                        (set_frame_angle 0 359 angle)
556                                        (play_sound GRENADE_THROW 127 (x) (y)))))
557
558          (10 (with_object (add_object SHOTGUN_BULLET x y)
559                                      (progn
560                                        (play_sound ZAP_SND 127 (x) (y))
561                                        (setq sgb_lifetime 6)
562                                        (setq sgb_speed 15)
563                                        (setq sgb_lastx (x))
564                                        (setq sgb_lasty (y))
565                                        (setq sgb_angle angle)
566                                        (setq sgb_bright_color (find_rgb 255 0 0))
567                                        (setq sgb_medium_color (find_rgb 150 0 0))
568                                        (if creator
569                                            (progn
570                                              (setq sgb_speed (+ sgb_speed (/ (xvel) 2)))
571                                              (link_object creator)))
572                                        (sgun_ai)
573                                        )))
574
575          (50 (with_object (add_object SHOTGUN_BULLET x y)
576                                      (progn
577                                        (play_sound ALSLASH_SND 127 (x) (y))
578                                        (setq sgb_lifetime 6)
579                                        (setq sgb_speed 15)
580                                        (setq sgb_lastx (x))
581                                        (setq sgb_lasty (y))
582                                        (setq sgb_angle angle)
583                                        (setq sgb_bright_color (find_rgb 170 210 50))
584                                        (setq sgb_medium_color (find_rgb 120 180 70))
585                                        (if creator
586                                            (progn
587                                              (setq sgb_speed (+ sgb_speed (/ (xvel) 2)))
588                                              (link_object creator)))
589                                        (sgun_ai)
590                                        )))
591          ))
592
593(defun ad_ai ()
594        (if (not (eq (aistate) 20))
595           (if (not (eq (aistate) 0))
596        (push_char 30 20)))
597      (if (or (eq (state) flinch_up) (eq (state) flinch_down))
598          (progn (next_picture) T)
599        (progn
600
601          (select (aistate)
602                  (0   (if (eq hide_flag 0)
603                           (set_aistate 15)
604                         (set_aistate 1)))
605
606                (15 ;; hiding
607                   (set_state hiding)
608                   (if (eq (random 200) 0)
609                             (play_sound ALTAUNT_SND 127 (x) (y)))
610                   (if (if (eq (total_objects) 0);; no sensor, wait for guy
611                           (and (< (distx) 130) (< (y) (with_object (bg) (y))))
612                         (not (eq (with_object (get_object 0) (aistate)) 0)))
613                       (progn
614                         (set_state fall_start)                  (set_direction (toward))
615                         (set_aistate 1))))
616
617                  (1 ;; falling down
618                   (set_state falling)
619                   (alscream_check)
620                   (if (blocked_down (move 0 0 0))
621                       (progn
622                         (set_state landing)
623                         (play_sound ALAND_SND 127 (x) (y))
624                         (set_aistate 9))))
625
626                  (9 ;; landing / turn around (general finish animation state)
627                   (if (next_picture) T
628                     (if (try_move 0 2)
629                         (progn
630                           (set_gravity 1)
631                           (set_aistate 1))
632                       (progn (set_state stopped)
633                              (go_state 2)))))  ;; running
634
635                  (2 ;; running
636                   (alscream_check)
637                   (if (eq (random 20) 0) (setq need_to_dodge 1))
638                   (if (not (ad_dodge))
639                     (if (eq (facing) (toward))
640                         (progn
641                           (next_picture)
642                           (if (and (eq (random 15) 0) (< (distx) 180) (< (disty) 100) (can_hit_player))
643                               (progn
644                                 (set_state weapon_fire)
645                                 (set_aistate 8))  ;; fire at player
646                             (if (and (< (distx) 100) (> (distx) 10) (eq (random 5) 0))
647                                 (set_aistate 4)  ;; wait for pounce
648
649                               (if (and (> (distx) 140)
650                                        (not_ali_congestion)
651                                        (not (will_fall_if_jump)))
652                                   (set_aistate 6)
653
654                                 (if (> (direction) 0)
655                                     (if (and (not_ali_congestion) (blocked_right (no_fall_move 1 0 0)))
656                                         (set_direction -1))
657                                   (if (and (not_ali_congestion) (blocked_left (no_fall_move -1 0 0)))
658                                       (set_direction 1)))))))
659                           (progn
660                             (set_direction (toward))
661                             (set_state turn_around)
662                             (set_aistate 9)))))
663
664                  (4 ;; wait for pounce
665                   (if (ad_dodge) T
666                     (progn
667                       (set_state pounce_wait)
668                       (move 0 0 0)
669                       (if (> (state_time) (alien_wait_time))
670                           (progn
671                             (play_sound ALSLASH_SND 127 (x) (y))
672                             (set_state stopped)
673                             (go_state 6))))))
674
675                  (6 ;; jump
676                   (setq need_to_dodge 0)
677                   (if (blocked_down (move (direction) -1 0))
678                       (progn
679                         (set_aistate 2))))
680
681                  (8 ;; fire at player
682                   (if (ad_dodge) T
683                     (if (eq (state) fire_wait)
684                         (if (next_picture)
685                             T
686                           (progn
687                             (ali_fire_at_player)
688                             (set_state stopped)
689                             (set_aistate 2)))
690                       (set_state fire_wait))))
691
692                  (12 ;; jump to roof
693                   (setq need_to_dodge 0)
694                   (set_state jump_up)
695                   (set_yvel (+ (yvel) 1))
696                   (set_xacel 0)
697                   (let ((top (- (y) 21))
698                         (old_yvel (yvel))
699                         (new_top (+ (- (y) 21) (yvel))))
700                     (let ((y2 (car (cdr (see_dist (x) top (x) new_top)))))
701                       (try_move 0 (- y2 top) nil)
702                       (if (not (eq y2 new_top))
703                           (if (> old_yvel 0)
704                             (progn
705                               (set_state stopped)
706                               (set_aistate 2))
707                           (progn
708                             (set_state top_walk)
709                             (set_aistate 13)))))))
710
711                  (13 ;; roof walking
712                   (alscream_check)
713                   (if (or (and (< (y) (with_object (bg) (y)))
714                                (< (distx) 10) (eq (random 8) 0))
715                           (eq need_to_dodge 1))  ;; shooting at us, fall down
716                       (progn
717                         (set_gravity 1)
718                         (set_state run_jump)
719                         (go_state 6))
720                     (progn
721                       (if (not (eq (facing) (toward)))        ;; run toward player
722                           (set_direction (- 0 (direction))))
723                       (if (and (< (distx) 120) (eq (random 15) 0))
724                           (progn
725                             (set_state ceil_fire)
726                             (go_state 14))
727                         (let ((xspeed (if (> (direction) 0) (get_ability run_top_speed)
728                                         (- 0 (get_ability run_top_speed)))))
729                           (if (and (can_see (x) (- (y) 21) (+ (x) xspeed) (- (y) 21) nil)
730                                    (not (can_see (+ (x) xspeed) (- (y) 21)
731                                                  (+ (x) xspeed) (- (y) 22) nil)))
732                               (progn
733                                 (set_x (+ (x) xspeed))
734                                 (if (not (next_picture))
735                                     (set_state top_walk)))
736                             (set_aistate 1)))))))
737
738                  (14 ;; cieling shoot
739                   (if (next_picture)
740                       T
741                     (progn
742                       (ali_fire_at_player)
743                       (set_state top_walk)
744                       (set_aistate 13))))
745                  )))
746   (if (eq (aistate) 20)
747        (progn nil)
748        (progn   T)))
749
750(defun ad_cons ()
751  (set_hp 35)
752  (set_state hiding)
753  (setq no_see_time 300))
754
755(def_char ALIEN_DRONE
756  (vars need_to_dodge
757        no_see_time
758        hide_flag)
759  (fields
760          ("hide_flag"    "hidden? 0-Yes 1-No")
761          ("fade_count"   "fade")
762          ("aitype"       "aitype")
763          ("hp"           "health")
764          ("aistate"      "aistate"))
765  (range 250 200)
766  (draw_range 40 40)
767  (funs (ai_fun     ad_ai)
768        (draw_fun       al_char_draw)
769        (constructor ad_cons)
770        (damage_fun ali_damage))
771
772  (abilities (run_top_speed   7)
773             (start_hp       20)
774             (stop_acel      12)
775             (start_acel     9)
776             (jump_yvel      -4)
777             (jump_xvel      16)
778             (push_xrange     2)
779             (jump_top_speed 16))
780
781  (flags (hurtable  T)
782         (force_health T))
783
784  (states "addon/aliens/aliens.spe"
785          (fall_start   "adrjf")
786          (falling              "adrjf")
787          (stopped              "adpouncew")
788          (running              (seq "adrn" 1 4))
789          (landing              "adrjf")
790          (pounce_wait  "adpouncew")
791          (turn_around  (seq "adtn" 1 3))
792          (run_jump     "adjump")
793          (run_jump_fall        "adrjf")
794          (start_run_jump "adsrj")
795          (top_walk     (seq "adcr" 1 4))
796          (flinch_up    "adsrj")
797          (flinch_down  "adrjf")
798          (jump_up        "adjump")
799          (hiding         "hidden")
800          (dead           "hidden")
801          (fire_wait    "adjump")
802          (ceil_fire    "adcr0004.pcx")
803          (weapon_fire  "adsrj")
804        ))
805
806(def_char DYING_AD
807  (flags (unlistable T))
808  (funs (ai_fun dying_ai))
809  (states "addon/aliens/aliens.spe"
810         (stopped (seq "addi" 1 10))))
811
812
813;; Alien Warrior
814
815(defun aw_ai ()
816        (if (not (eq (aistate) 20))
817           (if (not (eq (aistate) 0))
818        (push_char 30 20)))
819      (if (or (eq (state) flinch_up) (eq (state) flinch_down))
820          (progn (next_picture) T)
821        (progn
822
823          (select (aistate)
824                  (0   (if (eq hide_flag 0)
825                           (set_aistate 15)
826                         (set_aistate 1)))
827
828                (15 ;; hiding
829                   (set_state hiding)
830                   (if (and (< (distx) 200) (eq (random 50) 50))
831                             (play_sound ALTAUNT_SND 127 (x) (y)))
832                   (if (if (eq (total_objects) 0);; no sensor, wait for guy
833                           (and (< (distx) 130) (< (y) (with_object (bg) (y))))
834                         (not (eq (with_object (get_object 0) (aistate)) 0)))
835                       (progn
836                         (set_state fall_start)                  (set_direction (toward))
837                         (set_aistate 1))))
838
839                  (1 ;; falling down
840                   (set_state falling)
841                   (alscream_check)
842                   (if (blocked_down (move 0 0 0))
843                       (progn
844                         (set_state landing)
845                         (play_sound ALAND_SND 127 (x) (y))
846                         (set_aistate 9))))
847
848                  (9 ;; landing / turn around (general finish animation state)
849                   (if (next_picture) T
850                     (if (try_move 0 2)
851                         (progn
852                           (set_gravity 1)
853                           (set_aistate 1))
854                       (progn (set_state stopped)
855                              (go_state 2)))))  ;; running
856
857                  (2 ;; running
858                   (alscream_check)
859                   (if (eq (random 20) 0) (setq need_to_dodge 1))
860                   (if (not (ali_dodge))
861                     (if (eq (facing) (toward))
862                         (progn
863                           (next_picture)
864                           (if (and (eq (random 25) 0) (< (distx) 180) (< (disty) 100) (can_hit_player))
865                               (progn
866                                 (set_state weapon_fire)
867                                 (set_aistate 8))  ;; fire at player
868                             (if (and (< (distx) 100) (> (distx) 10) (eq (random 5) 0))
869                                 (set_aistate 4)  ;; wait for pounce
870
871                               (if (and (> (distx) 140)
872                                        (not_ali_congestion)
873                                        (not (will_fall_if_jump)))
874                                   (set_aistate 6)
875
876                                 (if (> (direction) 0)
877                                     (if (and (not_ali_congestion) (blocked_right (no_fall_move 1 0 0)))
878                                         (set_direction -1))
879                                   (if (and (not_ali_congestion) (blocked_left (no_fall_move -1 0 0)))
880                                       (set_direction 1)))))))
881                           (progn
882                             (set_direction (toward))
883                             (set_state turn_around)
884                             (set_aistate 9)))))
885
886                  (4 ;; wait for pounce
887                   (if (ali_dodge) T
888                     (progn
889                       (set_state pounce_wait)
890                       (move 0 0 0)
891                       (if (> (state_time) (alien_wait_time))
892                           (progn
893                             (play_sound ALSLASH_SND 127 (x) (y))
894                             (set_state stopped)
895                             (go_state 6))))))
896
897                  (6 ;; jump
898                   (setq need_to_dodge 0)
899                   (if (blocked_down (move (direction) -1 0))
900                       (progn
901                         (set_aistate 2))))
902
903                  (8 ;; fire at player
904                   (if (ad_dodge) T
905                     (if (eq (state) fire_wait)
906                         (if (next_picture)
907                             T
908                           (progn
909                             (ali_fire_at_player)
910                             (set_state stopped)
911                             (set_aistate 2)))
912                       (set_state fire_wait))))
913                  )))
914   (if (eq (aistate) 20)
915        (progn nil)
916        (progn   T)))
917
918(defun aw_cons ()
919  (set_hp 80)
920  (set_state hiding)
921  (setq no_see_time 300))
922
923(def_char ALIEN_WARRIOR
924  (vars need_to_dodge
925        no_see_time
926        hide_flag)
927  (fields
928          ("hide_flag"    "hidden? 0-Yes 1-No")
929          ("fade_count"   "fade")
930          ("aitype"       "aitype")
931          ("hp"           "health")
932          ("aistate"      "aistate"))
933  (range 250 200)
934  (draw_range 40 40)
935  (funs (ai_fun     aw_ai)
936        (draw_fun       al_char_draw)
937        (constructor aw_cons)
938        (damage_fun ali_damage))
939
940  (abilities (run_top_speed   5)
941             (start_hp       20)
942             (stop_acel      11)
943             (start_acel     8)
944             (jump_yvel      -2)
945             (jump_xvel      8)
946             (push_xrange     2)
947             (jump_top_speed 12))
948
949  (flags (hurtable  T)
950         (force_health T))
951
952  (states "addon/aliens/aliens.spe"
953          (fall_start   "awrjf")
954          (falling              "awrjf")
955          (stopped              "awrn0001.pcx")
956          (running              (seq "awrn" 1 4))
957          (landing              "awrjf")
958          (pounce_wait  "awpouncew")
959          (turn_around  (seq "awtn" 1 3))
960          (run_jump             "awjump")
961          (run_jump_fall        "awrjf")
962          (start_run_jump "awsrj")
963          (flinch_up    "awsrj")
964          (flinch_down  "awrjf")
965          (jump_up        "awjump")
966          (hiding         "hidden")
967          (dead           "hidden")
968          (fire_wait    "awjump")
969          (weapon_fire  "awsrj")
970        ))
971
972(def_char DYING_AW
973  (flags (unlistable T))
974  (funs (ai_fun dying_ai))
975  (states "addon/aliens/aliens.spe"
976         (stopped (seq "awdi" 1 10))))
977
978;; Old Alien speed settings, modified 6/28/00
979;;  (abilities (run_top_speed   15)
980             ;; (start_hp       20)
981             ;; (stop_acel      20)
982             ;; (start_acel     20)
983             ;; (jump_yvel      -4)
984             ;; (jump_xvel      20)
985             ;; (push_xrange     1)
986             ;; (jump_top_speed 20))
Note: See TracBrowser for help on using the repository browser.