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

Last change on this file since 614 was 590, checked in by Sam Hocevar, 12 years ago

data: merge registered data into the main data directory.

File size: 5.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 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
126(def_char FLYER
127  (funs (ai_fun flyer_ai)
128        (damage_fun  flyer_damage)
129        (constructor flyer_cons))
130
131  (flags (hurtable T))
132  (abilities (start_hp 20))
133  (vars fire_delay burst_delay burst_total burst_wait burst_left
134        max_xvel   max_yvel    smoke_time fire_time)
135  (fields ("fire_delay"  who_fdelay)
136          ("burst_delay" who_bdelay)
137          ("burst_total" who_btotal)
138          ("max_xvel"    who_mxv)
139          ("max_yvel"    who_myv)
140          ("hp"          ai_health)
141          ("aitype"      ai_type)
142          ("aistate"     ai_state))
143
144  (range 200 200)
145  (states "art/flyer.spe"
146          (running (seq "ffly" 1 12))
147          (stopped (seq "unhurtable" 1 7))
148          (flinch_up  '("flinch" "flinch" "flinch"))
149          (turn_around (seq "ftrn" 1 6))))
150
151
152
153
154(def_char GREEN_FLYER
155  (funs (ai_fun flyer_ai)
156        (damage_fun  flyer_damage)
157        (constructor flyer_cons))
158
159  (flags (hurtable T))
160  (abilities (start_hp 20))
161  (vars fire_delay burst_delay burst_total burst_wait burst_left
162        max_xvel   max_yvel    smoke_time fire_time)
163  (fields ("fire_delay"   who_fdelay)
164          ("burst_delay"  who_bdelay)
165          ("burst_total"  who_btotal)
166          ("max_xvel"     who_mxv)
167          ("max_yvel"     who_myv)
168          ("hp"           ai_health)
169          ("aitype"       ai_type)
170          ("aistate"      ai_state))
171
172  (range 200 200)
173  (states "art/flyer.spe"
174          (running (seq "gspe" 1 7))
175          (stopped (seq "gdrp" 1 12))
176          (flinch_up  '("ghurt" "ghurt" "ghurt"))
177          (turn_around (seq "gspn" 1 7))))
178
Note: See TracBrowser for help on using the repository browser.