[102] | 1 | ;; Copyright 1995 Crack dot Com, All Rights reserved |
---|
| 2 | ;; See licensing information for more details on usage rights |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | (defun flyer_ai () |
---|
| 6 | (if (not (eq smoke_time 0)) ;; if we just got hit, put out some smoke |
---|
| 7 | (progn |
---|
| 8 | (setq smoke_time (- smoke_time 1)) |
---|
| 9 | (if (eq (mod smoke_time 2) 0) |
---|
| 10 | (add_object SMALL_DARK_CLOUD (x) (y))))) |
---|
| 11 | |
---|
| 12 | (if (eq (aistate) 0) ;; wait for something to turn us on |
---|
| 13 | (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0))) |
---|
| 14 | (if (next_picture) T |
---|
| 15 | (progn |
---|
| 16 | (set_targetable T) |
---|
| 17 | (set_state running) |
---|
| 18 | (set_aistate 1))) |
---|
| 19 | (progn |
---|
| 20 | (set_targetable nil) |
---|
| 21 | (set_state stopped) |
---|
| 22 | T)) |
---|
| 23 | (if (eq (hp) 0) ;; if dead, make an explosion |
---|
| 24 | (progn |
---|
| 25 | (add_object EXPLODE1 (+ (x) (random 10)) (+ (+ (random 10) (y)) -20) 0) |
---|
| 26 | (add_object EXPLODE1 (- (x) (random 10)) (+ (- (y) (random 10)) -20) 2) |
---|
| 27 | (add_object EXPLODE1 (x) (+ (- (y) (random 20)) -20) 4) |
---|
| 28 | (with_object (bg) (set_kills (+ (kills) 1))) |
---|
| 29 | nil) |
---|
| 30 | (progn |
---|
| 31 | (if (eq (mod (state_time) 5) 0) ;; make flyer noise every 5 ticks |
---|
| 32 | (play_sound FLYER_SND 127 (x) (y))) |
---|
| 33 | (if (> (with_object (bg) (x)) (x)) ;; start going right if player is to the right |
---|
| 34 | (progn |
---|
| 35 | (set_xvel (+ (xvel) 1)) |
---|
| 36 | (if (> (xvel) max_xvel) (set_xvel max_xvel)) |
---|
| 37 | (if (eq (direction) -1) |
---|
| 38 | (progn |
---|
| 39 | (set_direction 1) |
---|
| 40 | (set_state turn_around)))) |
---|
| 41 | (if (< (with_object (bg) (x)) (x)) ;; start going left if the player is to the left |
---|
| 42 | (progn |
---|
| 43 | (set_xvel (- (xvel) 1)) |
---|
| 44 | (if (< (xvel) (- 0 max_xvel)) (set_xvel (- 0 max_xvel))) |
---|
| 45 | (if (eq (direction) 1) |
---|
| 46 | (progn |
---|
| 47 | (set_direction -1) |
---|
| 48 | (set_state turn_around)))))) |
---|
| 49 | (if (> (with_object (bg) (- (y) 70)) (y)) |
---|
| 50 | (if (> (yvel) max_yvel) |
---|
| 51 | (set_yvel (- (yvel) 1)) |
---|
| 52 | (set_yvel (+ (yvel) 1))) |
---|
| 53 | |
---|
| 54 | (if (< (with_object (bg) (- (y) 50)) (y)) |
---|
| 55 | (if (< (yvel) (- 0 max_yvel)) |
---|
| 56 | (set_yvel (+ (yvel) 1)) |
---|
| 57 | (set_yvel (- (yvel) 1))))) |
---|
| 58 | |
---|
| 59 | (if (eq (random 5) 0) ;; add some randomness to the movement |
---|
| 60 | (set_xvel (+ (xvel) 1)) |
---|
| 61 | (if (eq (random 5) 0) |
---|
| 62 | (set_xvel (- (xvel) 1)))) |
---|
| 63 | (if (eq (random 5) 0) |
---|
| 64 | (set_yvel (+ (yvel) 1)) |
---|
| 65 | (if (eq (random 5) 0) |
---|
| 66 | (set_yvel (- (yvel) 1)))) |
---|
| 67 | |
---|
| 68 | (if (next_picture) T (set_state running)) ;; reset animation when done |
---|
| 69 | |
---|
| 70 | (bounce_move '(set_xvel (/ (xvel) 2)) '(set_xvel (/ (xvel) 2)) |
---|
| 71 | '(set_yvel (/ (yvel) 2)) '(set_yvel (/ (yvel) 2)) nil) |
---|
| 72 | |
---|
| 73 | (if (> fire_time 0) ;; if we need to wait till next burst |
---|
| 74 | (progn |
---|
| 75 | (setq fire_time (- fire_time 1)) |
---|
| 76 | (if (eq fire_time 0) |
---|
| 77 | (progn |
---|
| 78 | (setq burst_left burst_total) |
---|
| 79 | (setq burst_wait 0)))) |
---|
| 80 | (if (eq burst_wait 0) |
---|
| 81 | (if (and (< (distx) 150) (eq (direction) (facing))) |
---|
| 82 | (let ((firex (+ (x) (* (direction) 10)) ) |
---|
| 83 | (firey (y)) |
---|
| 84 | (playerx (+ (with_object (bg) (x)) (with_object (bg) (* (xvel) 4)))) |
---|
| 85 | (playery (+ (- (with_object (bg) (y)) 15) (with_object (bg) (* (yvel) 2))))) |
---|
| 86 | (if (and (can_see (x) (y) firex firey nil) (can_see firex firey playerx playery nil)) |
---|
| 87 | (progn |
---|
| 88 | (let ((angle (atan2 (- firey playery) |
---|
| 89 | (- playerx firex)))) |
---|
| 90 | (if (or (eq burst_left 1) (eq burst_left 0)) |
---|
| 91 | (setq fire_time fire_delay) |
---|
| 92 | (setq burst_left (- burst_left 1))) |
---|
| 93 | (setq burst_wait burst_delay) |
---|
| 94 | (fire_object (me) (aitype) firex firey angle (bg)) |
---|
| 95 | ))))) |
---|
| 96 | (setq burst_wait (- burst_wait 1)))) |
---|
| 97 | T)))) |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | (defun flyer_cons () |
---|
| 102 | (setq fire_delay 20) |
---|
| 103 | (setq burst_delay 3) |
---|
| 104 | (setq max_xvel 10) |
---|
| 105 | (setq max_yvel 5) |
---|
| 106 | (set_aitype 9) |
---|
| 107 | (setq burst_total 2)) |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | (defun flyer_damage (amount from hitx hity push_xvel push_yvel) |
---|
| 111 | (if (and from (with_object from (and (> (total_objects) 0) |
---|
| 112 | (with_object (get_object 0) |
---|
| 113 | (or (eq (otype) FLYER) |
---|
| 114 | (eq (otype) GREEN_FLYER)) |
---|
| 115 | )))) |
---|
| 116 | nil |
---|
| 117 | (if (eq (state) stopped) nil |
---|
| 118 | (progn |
---|
| 119 | (setq smoke_time 30) |
---|
| 120 | (set_yvel (- (yvel) 14)) |
---|
| 121 | (set_state flinch_up) |
---|
| 122 | (damage_fun amount from hitx hity push_xvel push_yvel))))) |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | (setq load_warn nil) |
---|
| 126 | (if (not (load "register/flyer.lsp")) |
---|
| 127 | (progn |
---|
| 128 | (setq FLYER WHO) |
---|
| 129 | (setq GREEN_FLYER WHO))) |
---|
| 130 | (setq load_warn T) |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | |
---|
| 139 | |
---|