1 | (defun forceobj_ai ()
|
---|
2 | (if (<= (total_objects) 0)
|
---|
3 | nil
|
---|
4 | (progn
|
---|
5 | (let ((xfrc (xacel))
|
---|
6 | (yfrc (yacel)))
|
---|
7 | (try_move xfrc yfrc))
|
---|
8 | T)))
|
---|
9 |
|
---|
10 |
|
---|
11 | (defun forceobj_cons ()
|
---|
12 | (set_xacel 0)
|
---|
13 | (set_yacel 10))
|
---|
14 |
|
---|
15 |
|
---|
16 | (defun do_fire_explo (radius amount)
|
---|
17 | (play_sound GRENADE_SND 127 (x) (y))
|
---|
18 | (add_object EXPFIRE (+ (x) (random 10)) (+ (+ (random 10) (y)) -20) 0)
|
---|
19 | (if (not (frame_panic))
|
---|
20 | (progn
|
---|
21 | (add_object EXPFIRE (- (x) (random 10)) (+ (- (y) (random 10)) -20) 2)
|
---|
22 | (add_object EXP_LIGHT (x) (y) 100))) ; add cool light if not too slow
|
---|
23 | (hurt_radius (x) (y) radius amount (if (> (total_objects) 0)
|
---|
24 | (get_object 0)
|
---|
25 | nil) 20)
|
---|
26 | nil)
|
---|
27 |
|
---|
28 |
|
---|
29 | (defun do_light_explo (radius amount)
|
---|
30 | (play_sound GRENADE_SND 127 (x) (y))
|
---|
31 | ;; (add_object EXPFIRE (+ (x) (random 10)) (+ (+ (random 10) (y)) -20) 0)
|
---|
32 | (if (not (frame_panic))
|
---|
33 | (progn
|
---|
34 | ;; (add_object EXPFIRE (- (x) (random 10)) (+ (- (y) (random 10)) -20) 2)
|
---|
35 | (add_object EXP_LIGHT (x) (y) 100))) ; add cool light if not too slow
|
---|
36 | (hurt_radius (x) (y) radius amount (if (> (total_objects) 0)
|
---|
37 | (get_object 0)
|
---|
38 | nil) 20)
|
---|
39 | nil)
|
---|
40 |
|
---|
41 |
|
---|
42 | (defun msensor_ai ()
|
---|
43 | (if (and (< (distx) (xvel)) (< (disty) (yvel)))
|
---|
44 | (progn
|
---|
45 | (stop_song)
|
---|
46 | (select (aitype)
|
---|
47 | (0 (play_song "music/intro.hmi"))
|
---|
48 | (1 (play_song "music/abuse01.hmi"))
|
---|
49 | (2 (play_song "music/abuse02.hmi"))
|
---|
50 | (3 (play_song "music/abuse03.hmi"))
|
---|
51 | (4 (play_song "music/abuse04.hmi"))
|
---|
52 | (5 (play_song "music/abuse06.hmi"))
|
---|
53 | (6 (play_song "music/abuse08.hmi"))
|
---|
54 | (7 (play_song "music/abuse09.hmi"))
|
---|
55 | (8 (play_song "music/abuse11.hmi"))
|
---|
56 | (9 (play_song "music/abuse13.hmi"))
|
---|
57 | (10 (play_song "music/abuse15.hmi"))
|
---|
58 | (11 (play_song "music/abuse17.hmi")))
|
---|
59 | nil)
|
---|
60 | T))
|
---|
61 |
|
---|
62 | (defun msensor_cons ()
|
---|
63 | (set_xvel 50)
|
---|
64 | (set_yvel 50)
|
---|
65 | (set_xacel 0)
|
---|
66 | (set_yacel 0)
|
---|
67 | (add_hp -10))
|
---|
68 |
|
---|
69 |
|
---|
70 | (defun music_sensor_draw ()
|
---|
71 | (if (edit_mode)
|
---|
72 | (progn
|
---|
73 | (draw)
|
---|
74 | (let ((x1 (- (x) (xvel)))
|
---|
75 | (y1 (- (y) (yvel)))
|
---|
76 | (x2 (+ (x) (xvel)))
|
---|
77 | (y2 (+ (y) (yvel)))
|
---|
78 | (c (find_rgb 0 0 255)))
|
---|
79 | (draw_line x1 y1 x2 y1 c)
|
---|
80 | (draw_line x2 y1 x2 y2 c)
|
---|
81 | (draw_line x2 y2 x1 y2 c)
|
---|
82 | (draw_line x1 y2 x1 y1 c)))
|
---|
83 | nil))
|
---|
84 |
|
---|
85 |
|
---|
86 | (defun gsensor_ai ()
|
---|
87 | (if (and (< (distx) (xvel)) (< (disty) (yvel)))
|
---|
88 | (progn
|
---|
89 | (let ((xgvty (xacel))
|
---|
90 | (ygvty (yacel)))
|
---|
91 | (with_object (bg) (try_move xgvty ygvty))))
|
---|
92 | T)
|
---|
93 | T)
|
---|
94 |
|
---|
95 |
|
---|
96 | (defun gsensor_cons ()
|
---|
97 | (set_xvel 50)
|
---|
98 | (set_yvel 50)
|
---|
99 | (set_xacel 0)
|
---|
100 | (set_yacel -15))
|
---|
101 |
|
---|
102 |
|
---|
103 | (defun gravity_sensor_draw ()
|
---|
104 | (if (edit_mode)
|
---|
105 | (progn
|
---|
106 | (draw)
|
---|
107 | (let ((x1 (- (x) (xvel)))
|
---|
108 | (y1 (- (y) (yvel)))
|
---|
109 | (x2 (+ (x) (xvel)))
|
---|
110 | (y2 (+ (y) (yvel)))
|
---|
111 | (c (find_rgb 255 255 0)))
|
---|
112 | (draw_line x1 y1 x2 y1 c)
|
---|
113 | (draw_line x2 y1 x2 y2 c)
|
---|
114 | (draw_line x2 y2 x1 y2 c)
|
---|
115 | (draw_line x1 y2 x1 y1 c)))
|
---|
116 | nil))
|
---|
117 |
|
---|
118 |
|
---|
119 | (defun hsensor_ai ()
|
---|
120 | (if (and (< (distx) (xvel)) (< (disty) (yvel)))
|
---|
121 | (progn
|
---|
122 | (select (aitype)
|
---|
123 | (0 (let ((phlth (xacel))) (if (eq (mod (state_time) 10) 0) (do_damage phlth (bg)))))
|
---|
124 | (1 (let ((phlth (xacel)) (hlthrad (/ (xvel) 2))) (hurt_radius (x) (y) hlthrad phlth nil 10)))
|
---|
125 | (2 (let ((phlth (xacel)) (hlthrad (/ (xvel) 2))) (do_explo hlthrad phlth)))
|
---|
126 | )
|
---|
127 | T)
|
---|
128 | T))
|
---|
129 |
|
---|
130 |
|
---|
131 | (defun hsensor_cons ()
|
---|
132 | (set_xvel 50)
|
---|
133 | (set_yvel 50)
|
---|
134 | (set_aitype 0)
|
---|
135 | (set_aistate 0)
|
---|
136 | (set_xacel 10)
|
---|
137 | (set_yacel 0))
|
---|
138 |
|
---|
139 |
|
---|
140 | (defun health_sensor_draw ()
|
---|
141 | (if (edit_mode)
|
---|
142 | (progn
|
---|
143 | (draw)
|
---|
144 | (let ((x1 (- (x) (xvel)))
|
---|
145 | (y1 (- (y) (yvel)))
|
---|
146 | (x2 (+ (x) (xvel)))
|
---|
147 | (y2 (+ (y) (yvel)))
|
---|
148 | (c (find_rgb 255 0 255)))
|
---|
149 | (draw_line x1 y1 x2 y1 c)
|
---|
150 | (draw_line x2 y1 x2 y2 c)
|
---|
151 | (draw_line x2 y2 x1 y2 c)
|
---|
152 | (draw_line x1 y2 x1 y1 c)))
|
---|
153 | nil))
|
---|
154 |
|
---|
155 |
|
---|
156 | (defun lsensor_ai ()
|
---|
157 | (if (and (< (distx) (xvel)) (< (disty) (yvel)))
|
---|
158 | (progn
|
---|
159 | (if (eq (aistate) 1) (request_end_game))
|
---|
160 | (if (eq (aitype) 1) (show_stats))
|
---|
161 | (request_level_load (concatenate 'string "addon/twist/levels/l" (digstr (xacel) 2) "s" (digstr (yacel) 2) ".lvl"))
|
---|
162 | )
|
---|
163 | T)
|
---|
164 | T)
|
---|
165 |
|
---|
166 |
|
---|
167 | (defun lsensor_cons ()
|
---|
168 | (set_xvel 50)
|
---|
169 | (set_yvel 50)
|
---|
170 | (set_xacel 1)
|
---|
171 | (set_yacel 1)
|
---|
172 | (set_aistate 0)
|
---|
173 | (set_aitype 1))
|
---|
174 |
|
---|
175 |
|
---|
176 | (defun level_sensor_draw ()
|
---|
177 | (if (edit_mode)
|
---|
178 | (progn
|
---|
179 | (draw)
|
---|
180 | (let ((x1 (- (x) (xvel)))
|
---|
181 | (y1 (- (y) (yvel)))
|
---|
182 | (x2 (+ (x) (xvel)))
|
---|
183 | (y2 (+ (y) (yvel)))
|
---|
184 | (c (find_rgb 255 128 0)))
|
---|
185 | (draw_line x1 y1 x2 y1 c)
|
---|
186 | (draw_line x2 y1 x2 y2 c)
|
---|
187 | (draw_line x2 y2 x1 y2 c)
|
---|
188 | (draw_line x1 y2 x1 y1 c)))
|
---|
189 | nil))
|
---|
190 |
|
---|
191 |
|
---|
192 | ;; Cheats
|
---|
193 | ;;
|
---|
194 | ;; Add Health: Vitalize
|
---|
195 | ;; All Weapons: Arms
|
---|
196 | ;; Full Ammo: Reload
|
---|
197 | ;; Power Fast: Steroids
|
---|
198 | ;; Power Fly: Lift
|
---|
199 | ;; Power Sneaky:Mirage
|
---|
200 | ;; Power Health:Elixir
|
---|
201 | ;; Power Light: Visor
|
---|
202 | ;; End Game: Outcome
|
---|
203 | ;; To use cheat, type cheat code.
|
---|
204 | ;; Note: if you press any direction keys, you'll have to retype the whole thing.
|
---|
205 |
|
---|
206 | (defun csensor_ai ()
|
---|
207 | (progn (set_x (with_object (bg) (x))) (set_y (with_object (bg) (y))))
|
---|
208 |
|
---|
209 | (if (local_key_pressed up-key) (set_aistate 0))
|
---|
210 | (if (local_key_pressed down-key) (set_aistate 0))
|
---|
211 | (if (local_key_pressed left-key) (set_aistate 0))
|
---|
212 | (if (local_key_pressed right-key) (set_aistate 0))
|
---|
213 | (if (local_key_pressed weapon-left-key) (set_aistate 0))
|
---|
214 | (if (local_key_pressed weapon-right-key) (set_aistate 0))
|
---|
215 |
|
---|
216 | (if (eq (fourth (mouse_stat)) 1)
|
---|
217 | (progn
|
---|
218 | (select (aistate)
|
---|
219 | ;; First Letter
|
---|
220 | (0 (if (local_key_pressed key-v) (set_aistate 1))
|
---|
221 | (if (local_key_pressed key-a) (set_aistate 10))
|
---|
222 | (if (local_key_pressed key-r) (set_aistate 13))
|
---|
223 | (if (local_key_pressed key-s) (set_aistate 18))
|
---|
224 | (if (local_key_pressed key-l) (set_aistate 25))
|
---|
225 | (if (local_key_pressed key-m) (set_aistate 28))
|
---|
226 | (if (local_key_pressed key-e) (set_aistate 33))
|
---|
227 | (if (local_key_pressed key-o) (set_aistate 38)))
|
---|
228 | ;; Vitalize
|
---|
229 | (1 (if (local_key_pressed key-i) (set_aistate 2)))
|
---|
230 | (2 (if (local_key_pressed key-t) (set_aistate 3))
|
---|
231 | (if (local_key_pressed key-s) (set_aistate 8)))
|
---|
232 | (3 (if (local_key_pressed key-a) (set_aistate 4)))
|
---|
233 | (4 (if (local_key_pressed key-l) (set_aistate 5)))
|
---|
234 | (5 (if (local_key_pressed key-i) (set_aistate 6)))
|
---|
235 | (6 (if (local_key_pressed key-z) (set_aistate 44)))
|
---|
236 | (7 (if (local_key_pressed key-e) (set_aistate 44)))
|
---|
237 | ;; Visor
|
---|
238 | (8 (if (local_key_pressed key-o) (set_aistate 45)))
|
---|
239 | (9 (if (local_key_pressed key-r) (set_aistate 45)))
|
---|
240 | ;; Arms
|
---|
241 | (10 (if (local_key_pressed key-r) (set_aistate 11)))
|
---|
242 | (11 (if (local_key_pressed key-m) (set_aistate 46)))
|
---|
243 | (12 (if (local_key_pressed key-s) (set_aistate 46)))
|
---|
244 | ;; Reload
|
---|
245 | (13 (if (local_key_pressed key-e) (set_aistate 14)))
|
---|
246 | (14 (if (local_key_pressed key-l) (set_aistate 15)))
|
---|
247 | (15 (if (local_key_pressed key-o) (set_aistate 16)))
|
---|
248 | (16 (if (local_key_pressed key-a) (set_aistate 47)))
|
---|
249 | (17 (if (local_key_pressed key-d) (set_aistate 47)))
|
---|
250 | ;; Steroids
|
---|
251 | (18 (if (local_key_pressed key-t) (set_aistate 19)))
|
---|
252 | (19 (if (local_key_pressed key-e) (set_aistate 20)))
|
---|
253 | (20 (if (local_key_pressed key-r) (set_aistate 21)))
|
---|
254 | (21 (if (local_key_pressed key-o) (set_aistate 22)))
|
---|
255 | (22 (if (local_key_pressed key-i) (set_aistate 23)))
|
---|
256 | (23 (if (local_key_pressed key-d) (set_aistate 48)))
|
---|
257 | (24 (if (local_key_pressed key-s) (set_aistate 48)))
|
---|
258 | ;; Lift
|
---|
259 | (25 (if (local_key_pressed key-i) (set_aistate 26)))
|
---|
260 | (26 (if (local_key_pressed key-f) (set_aistate 49)))
|
---|
261 | (27 (if (local_key_pressed key-t) (set_aistate 49)))
|
---|
262 | ;; Mirage
|
---|
263 | (28 (if (local_key_pressed key-i) (set_aistate 29)))
|
---|
264 | (29 (if (local_key_pressed key-r) (set_aistate 30)))
|
---|
265 | (30 (if (local_key_pressed key-a) (set_aistate 31)))
|
---|
266 | (31 (if (local_key_pressed key-g) (set_aistate 50)))
|
---|
267 | (32 (if (local_key_pressed key-e) (set_aistate 50)))
|
---|
268 | ;; Elixir
|
---|
269 | (33 (if (local_key_pressed key-l) (set_aistate 34)))
|
---|
270 | (34 (if (local_key_pressed key-i) (set_aistate 35)))
|
---|
271 | (35 (if (local_key_pressed key-x) (set_aistate 36)))
|
---|
272 | (36 (if (local_key_pressed key-i) (set_aistate 51)))
|
---|
273 | (37 (if (local_key_pressed key-r) (set_aistate 51)))
|
---|
274 | ;; Outcome
|
---|
275 | (38 (if (local_key_pressed key-u) (set_aistate 39)))
|
---|
276 | (39 (if (local_key_pressed key-t) (set_aistate 40)))
|
---|
277 | (40 (if (local_key_pressed key-c) (set_aistate 41)))
|
---|
278 | (41 (if (local_key_pressed key-o) (set_aistate 42)))
|
---|
279 | (42 (if (local_key_pressed key-m) (set_aistate 52)))
|
---|
280 | (43 (if (local_key_pressed key-e) (set_aistate 52)))
|
---|
281 |
|
---|
282 | ;; Last Word
|
---|
283 | ;; Vitalize Activation
|
---|
284 | (44 (if (local_key_pressed key-e) (progn (with_object (bg) (give_player_health 20)) (set_aistate 0))))
|
---|
285 | ;; Visor Activation
|
---|
286 | (45 (if (local_key_pressed key-r) (progn (with_object (bg) (progn (setq special_power HEALTH_POWER))) (set_aistate 0))))
|
---|
287 | ;; Arms Activation
|
---|
288 | (46 (if (local_key_pressed key-s) (progn (with_object (bg) (progn (give_weapon 0)(give_weapon 1)(give_weapon 2)(give_weapon 3)(give_weapon 4)(give_weapon 5)(give_weapon 6)(give_weapon 7))) (set_aistate 0))))
|
---|
289 | ;; Reload Activation
|
---|
290 | (47 (if (local_key_pressed key-d) (progn (with_object (bg) (progn (add_ammo 0 999)(add_ammo 1 999)(add_ammo 2 999)(add_ammo 3 999)(add_ammo 4 999)(add_ammo 5 999)(add_ammo 6 999)(add_ammo 7 999))) (set_aistate 0))))
|
---|
291 | ;; Steroids Activation
|
---|
292 | (48 (if (local_key_pressed key-s) (progn (with_object (bg) (progn (setq special_power FAST_POWER))) (set_aistate 0))))
|
---|
293 | ;; Lift Activation
|
---|
294 | (49 (if (local_key_pressed key-t) (progn (with_object (bg) (progn (setq special_power FLY_POWER))) (set_aistate 0))))
|
---|
295 | ;; Mirage Activation
|
---|
296 | (50 (if (local_key_pressed key-e) (progn (with_object (bg) (progn (setq special_power SNEAKY_POWER))) (set_aistate 0))))
|
---|
297 | ;; Elixir Activation
|
---|
298 | (51 (if (local_key_pressed key-r) (progn (with_object (bg) (progn (setq special_power HEALTH_POWER))) (set_aistate 0))))
|
---|
299 | ;; Outcome Activation
|
---|
300 | (52 (if (local_key_pressed key-e) (progn (stop_song) (play_song "music/victory.hmi")(play_sound END_LEV_SND 127 (x) (y))(request_end_game))))
|
---|
301 | ) T) T))
|
---|
302 |
|
---|
303 |
|
---|
304 | (defun burst_fire (firex firey angle)
|
---|
305 | (if (> fire_time 0);; if we need to wait till next burst
|
---|
306 | (progn
|
---|
307 | (setq fire_time (- fire_time 1))
|
---|
308 | (if (eq fire_time 0)
|
---|
309 | (progn
|
---|
310 | (setq burst_left burst_total)
|
---|
311 | (setq burst_wait 0))))
|
---|
312 | (if (eq burst_wait 0)
|
---|
313 | (progn
|
---|
314 | (if (or (eq burst_left 1) (eq burst_left 0))
|
---|
315 | (setq fire_time fire_delay)
|
---|
316 | (setq burst_left (- burst_left 1)))
|
---|
317 | (setq burst_wait burst_delay)
|
---|
318 | (fire_object (me) (aitype) firex firey angle (bg)))
|
---|
319 | (setq burst_wait (- burst_wait 1)))))
|
---|
320 |
|
---|
321 |
|
---|
322 | (defun wrob_cons ()
|
---|
323 | (setq fire_delay 4)
|
---|
324 | (setq burst_delay 1)
|
---|
325 | (setq max_xvel 10)
|
---|
326 | (setq max_yvel 5)
|
---|
327 | (set_aitype 0)
|
---|
328 | (setq burst_total 5))
|
---|
329 |
|
---|
330 |
|
---|
331 | (defun wrob_ai ()
|
---|
332 | (if (eq (hp) 0)
|
---|
333 | (with_object (add_object WALK_ROBHEAD (x) (- (y) 24) 1)
|
---|
334 | nil)
|
---|
335 | (progn
|
---|
336 | (try_move 0 10)
|
---|
337 | (select (aistate)
|
---|
338 | (0;; walk toward player
|
---|
339 | (if (or (> (distx) 120) (not (eq (direction) (toward))))
|
---|
340 | (progn
|
---|
341 | (move (toward) 0 0)
|
---|
342 | (next_picture))
|
---|
343 | (progn
|
---|
344 | (set_state stopped)
|
---|
345 | (set_aistate 1))))
|
---|
346 | (1;; stop and fire
|
---|
347 | (burst_fire (+ (x) (* (direction) 28)) (- (y) 35)
|
---|
348 | (if (> (direction) 0)
|
---|
349 | (mod (- 375 (/ (* burst_left 30) burst_total)) 360)
|
---|
350 | (+ 165 (/ (* burst_left 30) burst_total))))
|
---|
351 | (if (not (eq fire_time 0))
|
---|
352 | (set_aistate 0))))
|
---|
353 | T)))
|
---|
354 |
|
---|
355 |
|
---|
356 | (defun telesensor_ai ()
|
---|
357 | (if (> (total_objects) 0)
|
---|
358 | (select (aistate)
|
---|
359 | (0 ;; wait for player to activate
|
---|
360 | (if (and (< (distx) (xvel)) (< (disty) (yvel)))
|
---|
361 | (progn
|
---|
362 | (if (eq (aitype) 0)
|
---|
363 | (progn
|
---|
364 | (link_object (bg))
|
---|
365 | (set_state running)
|
---|
366 | (set_aistate 1))
|
---|
367 |
|
---|
368 | (if (with_object (bg) (pressing_action_key))
|
---|
369 | (progn
|
---|
370 | (link_object (bg))
|
---|
371 | (set_state running)
|
---|
372 | (set_aistate 1))
|
---|
373 | )))) )
|
---|
374 | (1 ;; wait for animation
|
---|
375 | (if (next_picture)
|
---|
376 | (let ((x (x))
|
---|
377 | (y (- (y) 16))
|
---|
378 | (fade (if (< (current_frame) 16) (current_frame) 15)))
|
---|
379 | (with_object (get_object 1)
|
---|
380 | (progn
|
---|
381 | (set_x x)
|
---|
382 | (set_y y)
|
---|
383 | (user_fun SET_FADE_COUNT fade)
|
---|
384 | (setq is_teleporting 1)
|
---|
385 | )))
|
---|
386 |
|
---|
387 | (let ((x (with_object (get_object 0) (x)))
|
---|
388 | (y (with_object (get_object 0) (- (y) 16))))
|
---|
389 | (with_object (get_object 1)
|
---|
390 | (progn
|
---|
391 | (set_x x)
|
---|
392 | (set_y y)
|
---|
393 | (setq is_teleporting 0)
|
---|
394 | (user_fun SET_FADE_COUNT 0)
|
---|
395 | ))
|
---|
396 | (remove_object (get_object 1))
|
---|
397 | (set_aistate 0))))))
|
---|
398 | T)
|
---|
399 |
|
---|
400 |
|
---|
401 | (defun telesensor_cons ()
|
---|
402 | (set_xvel 50)
|
---|
403 | (set_yvel 50))
|
---|
404 |
|
---|
405 |
|
---|
406 | (defun teleport_sensor_draw ()
|
---|
407 | (if (edit_mode)
|
---|
408 | (progn
|
---|
409 | (draw)
|
---|
410 | (let ((x1 (- (x) (xvel)))
|
---|
411 | (y1 (- (y) (yvel)))
|
---|
412 | (x2 (+ (x) (xvel)))
|
---|
413 | (y2 (+ (y) (yvel)))
|
---|
414 | (c (find_rgb 128 255 0)))
|
---|
415 | (draw_line x1 y1 x2 y1 c)
|
---|
416 | (draw_line x2 y1 x2 y2 c)
|
---|
417 | (draw_line x2 y2 x1 y2 c)
|
---|
418 | (draw_line x1 y2 x1 y1 c)))
|
---|
419 | nil))
|
---|