source: abuse/branches/lol/data/lisp/jugger.lsp @ 737

Last change on this file since 737 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: 8.5 KB
Line 
1;; Copyright 1995 Crack dot Com,  All Rights reserved
2;; See licensing information for more details on usage rights
3
4(defun jug_ai ()
5  (if (<= (hp) 0)
6      (if (eq (state) dieing)
7          (if (not (next_picture))
8              (progn
9                (with_object (bg) (set_kills (+ (kills) 1)))
10                nil)
11              T)
12        (set_state dieing))
13    (if (activated)
14        (progn
15          (set_targetable T)
16          (push_char 35 40)
17          (select (aistate)
18                  (0 ;; prepare to walk toward player
19                   (if (eq stationary 0)
20                       (progn
21                         (set_state running)
22                         (go_state 1))
23                     (if (> (state_time) (aitype))
24                         (progn
25                           (set_state weapon_fire)
26                           (set_aistate 2)))))
27
28                  (1 ;; walk toward player
29                   (if (eq stationary 0)
30                       (progn
31                         (set_direction (toward))
32                         (let ((curx (x));; save position in case we fall off a cliff
33                               (cury (y)))
34                           (if (next_picture)
35                               (if (eq (current_frame) 8)
36                                   (play_sound JSTOMP_SND 127 (x) (y)))
37                             (progn
38                               (play_sound JSTOMP_SND 127 (x) (y))
39                               (set_state weapon_fire)
40                               (set_aistate 2)))
41                           (if (can_see (x) (y) (x) (+ (y) 5) nil)
42                               (progn
43                                 (set_x curx)
44                                 (set_y cury)
45                                 (try_move 0 10)))))
46                     (if (> (state_time) (aitype))
47                         (progn
48                           (set_state weapon_fire)
49                           (set_aistate 2)))))
50
51                  (2 ;; start fire
52                   (if (> (state_time) 3)
53                       (let ((myself (me))
54                             (xspeed (* throw_xvel (direction)))
55                             (yspeed throw_yvel))
56                         (with_object (add_object GRENADE (x) (- (y) 24) 1)
57                                      (progn
58                                        (user_fun myself)
59                                        (set_xvel xspeed)
60                                        (set_yvel yspeed)))
61                         (go_state 3))
62                     (next_picture)))
63                  (3 ;; wait for fire animation
64                   (if (next_picture) nil (set_aistate 0))))
65          T)
66      (progn (set_targetable nil)
67             T))))
68
69(defun jug_cons ()
70  (setq throw_xvel 13)
71  (setq throw_yvel -10)
72  (set_aitype 10))
73
74(defun explo_damage_cache (type)
75  (list (list EXPLODE6) nil))
76
77(def_char JUGGER
78  (range 200 0)
79  (funs (ai_fun     jug_ai)
80        (constructor jug_cons)
81        (get_cache_list_fun explo_damage_cache)
82        (damage_fun explo_damage))
83  (flags (hurtable T))
84  (abilities (start_hp    50)
85             (push_xrange 1))
86  (vars throw_xvel throw_yvel stationary)
87  (fields ("hp"            ai_health)
88          ("aitype"        jug_throw_spd)
89          ("throw_xvel"    jug_throw_xv)
90          ("throw_yvel"    jug_throw_yv)
91          ("stationary"    jug_stat)
92          ("aistate"       ai_state))
93
94  (states "art/jug.spe"
95          (stopped "robo0001.pcx")
96          (running (seq "rwlk" 1 13))
97          (weapon_fire (seq "robo" 1 10))
98          (dieing (seq "jugdie" 1 8))))
99
100;; AI for cleaner robot machine "ROB1"
101;; The robot waits for a sensor/switch/gate to turn it
102;; on before appearing
103(defun rob1_ai ()
104  (if (not (eq (fade_count) 0))             ;; appearing?
105      (set_fade_count (- (fade_count) 1)))  ;; fade in
106  (select (aistate)
107          (0 ;; wait for sensor to turn on
108           (if (eq rob_hiden 1)
109               (progn
110                 (set_targetable nil)       ;; can't lock into us while hiden
111                 (set_state rob_hiding))    ;; set invisible animation frame
112             (progn
113               (set_targetable T)           ;; can lock into us
114               (push_char 30 55)))          ;; push player away
115
116           (if (or (< (total_objects) 1)    ;; if not linked or link is on
117                   (not (eq (with_object (get_object 0) (aistate)) 0)))
118               (progn
119                 (if (eq rob_hiden 1)
120                     (set_fade_count 15))
121                 (set_aistate 1)))
122           T)
123          (1 ;; walk towards player
124           (push_char 30 55)                      ;; push her back
125           (next_picture)                         ;; go to next animation frame
126           (if (eq (mod (state_time) 6) 0)        ;; play sound every 6 ticks
127               (play_sound CLEANER_SND 127 (x) (y)))
128           (try_move 0 10)                        ;; see how far ahead we can move
129           (if (> (direction) 0)                  ;; moving right
130               (if (can_see (x) (y) (+ (x) (xvel) 23) (y) nil)   ;; can we see 23 pixels ahead?
131                     (set_x (+ (x) (xvel))))
132             (if (can_see (x) (y) (- (x) (xvel) 23) (y) nil)
133                   (set_x (- (x) (xvel)))))
134
135           (if (<= (hp) 0)                        ;; are we dead, if so blow up
136               (progn
137                 (add_object EXPLODE1 (+ (x) 5) (- (y) 10)     0)
138                 (add_object EXPLODE1 (+ (x) -5) (- (y) 15)    2)  ;; wait 2 frames before appearing
139                 (add_object EXPLODE1 (+ (x) 10) (- (y) 2)     1)
140                 (add_object EXPLODE1 (+ (x) -10) (- (y) 20)   3)
141                 (add_object EXPLODE1 (+ (x) 20) (- (y) 27)    4)
142                 (add_object EXPLODE1 (+ (x) -25) (- (y) 30)   2)
143                 (add_object EXPLODE1 (+ (x) 20) (- (y) 5)     4)
144                 (add_object EXPLODE1 (+ (x) -3) (- (y) 1)     5)
145                 (set_aistate 2)))
146           T)
147          (2 ;; dead, wait a few frames then return nil
148           (push_char 30 55)
149           (< (state_time) 3))))  ;; return nil (dead) if we've been in this state for 3 frames
150
151
152
153(defun explo_damage (amount from hitx hity push_xvel push_yvel)
154  (add_object EXPLODE6 (+ (x) (- 10 (random 20))) (- (y) (random 30))     0)
155  (damage_fun amount from hitx hity 0 0)
156  (if (eq 0 (hp))
157      (play_sound BLOWN_UP 127 (x) (y))))
158
159(defun rob_cons () (set_xvel 2))
160
161(def_char ROB1
162  (range 200 0)
163  (funs (ai_fun     rob1_ai)
164        (constructor rob_cons)
165        (get_cache_list_fun explo_damage_cache)
166        (damage_fun explo_damage))
167  (flags (hurtable T)
168         (can_block T))
169  (abilities (run_top_speed 4)
170             (start_hp      70)
171             (push_xrange   1))
172  (vars rob_hiden)
173  (fields ("xvel"         ai_xvel)
174          ("aitype"       rob_noturn)
175          ("rob_hiden"    rob_hide)
176          ("hp"           ai_health))
177  (states "art/rob1.spe"
178          (rob_hiding             "hiding")
179          (stopped (seq "clen" 1 10))))
180
181(defun who_ai ()
182  (if (eq (hp) 0)
183      nil
184    (progn
185      (set_xvel (+ (xvel) (* (+ (mod (state_time) 10) -4) (direction))))
186      (if (< (xvel) -15) (set_xvel -15))
187      (if (> (xvel) 15) (set_xvel 15))
188      (if (not (next_picture)) (set_state stopped))
189      (bounce_move '(progn
190                      (set_direction (- 0 (direction)))
191                      (set_state turn_around))
192                   '(progn
193                      (set_direction (- 0 (direction)))
194                      (set_state turn_around))
195                   nil nil nil)
196      T)))
197
198(defun who_cache (type) `((,STRAIT_ROCKET) nil))
199
200(def_char WHO
201  (range 200 100)
202  (funs (ai_fun flyer_ai)
203        (damage_fun  flyer_damage)
204        (get_cache_list_fun who_cache)
205        (constructor flyer_cons))
206
207  (flags (hurtable T))
208  (abilities (start_hp 20))
209  (vars fire_delay burst_delay burst_total burst_wait burst_left
210        max_xvel   max_yvel    smoke_time fire_time)
211  (fields ("fire_delay"   who_fdelay)
212          ("burst_delay"  who_bdelay)
213          ("burst_total"  who_btotal)
214          ("max_xvel"     who_mxv)
215          ("max_yvel"     who_myv)
216          ("hp"           ai_health)
217          ("aistate"      ai_state))
218
219  (states "art/rob2.spe"
220          (stopped (seq "wgo" 1 3))
221          (running (seq "wgo" 1 3))
222          (turn_around (seq "wtrn" 1 9))
223          (flinch_up  '("flinch" "flinch" "flinch"))
224          ))
225
226
227/*   --- not working
228(defun burst_fire (firex firey angle)
229  (if (> fire_time 0);; if we need to wait till next burst
230      (progn
231        (setq fire_time (- fire_time 1))
232        (if (eq fire_time 0)
233            (progn
234              (setq burst_left burst_total)
235              (setq burst_wait 0))))
236    (if (eq burst_wait 0)
237        (progn
238          (if (or (eq burst_left 1) (eq burst_left 0))
239              (setq fire_time fire_delay)
240            (setq burst_left (- burst_left 1)))
241          (setq burst_wait burst_delay)
242          (fire_object (me) (aitype) firex firey angle (bg)))
243      (setq burst_wait (- burst_wait 1)))))
244
245
246(defun wrob_cons ()
247  (setq fire_delay 4)
248  (setq burst_delay 1)
249  (setq max_xvel 10)
250  (setq max_yvel 5)
251  (set_aitype 0)
252  (setq burst_total 5))
253
254
255(defun wrob_ai ()
256  (if (eq (hp) 0)
257      nil
258    (progn
259      (select (aistate)
260              (0;; walk toward player
261               (if (or (> (distx) 120) (not (eq (direction) (toward))))
262                   (progn
263                     (move (toward) 0 0)
264                     (next_picture))
265                 (progn
266                   (set_state stopped)
267                   (set_aistate 1))))
268              (1;; stop and fire
269               (burst_fire  (+ (x) (* (direction) 28)) (- (y) 35)
270                            (if (> (direction) 0)
271                                (mod (- 375 (/ (* burst_left 30) burst_total)) 360)
272                              (+ 165 (/ (* burst_left 30) burst_total))))
273               (if (not (eq fire_time 0))
274                   (set_aistate 0))))
275      T)))
276
277
278
279
280(def_char WALK_ROB
281  (funs (ai_fun wrob_ai)
282        (constructor wrob_cons)
283        (damage_fun  guner_damage))
284  (abilities (run_top_speed 12))
285  (flags (hurtable T) (can_block T))
286  (range 300 100)
287  (vars fire_delay burst_delay burst_total burst_wait burst_left
288        max_xvel   max_yvel    smoke_time fire_time)
289  (fields ("fire_delay"   wrob_fdelay)
290          ("burst_delay"  wrob_bdelay)
291          ("burst_total"  wrob_btotal)
292          ("max_xvel"     wrob_mxv)
293          ("max_yvel"     wrob_myv)
294          ("hp"           ai_health)
295          ("aistate"      ai_state))
296
297  (states "art/rob2.spe"
298          (stopped "wwlk0001.pcx")
299          (running (seq "wwlk" 1 10))
300          (start_run_jump "wstart_jump")
301          (flinch_up      "wflinch")
302          (run_jump       "wwlk0009.pcx")
303          ))
304
305
306
307*/
Note: See TracBrowser for help on using the repository browser.