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

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

data: merge registered data into the main data directory.

File size: 25.9 KB
Line 
1;; Copyright 1995 Crack dot Com,  All Rights reserved
2;; See licensing information for more details on usage rights
3
4(setq bright_tint (def_tint "art/tints/cop/bright.spe"))  ;; used when the player fires a weapon
5(setq player_tints (make-array 8 :initial-contents (list
6                                                    0                                      ; 0 this is not used
7                                                    (def_tint "art/tints/cop/blue.spe")    ; 1 bright blue
8                                                    (def_tint "art/tints/cop/yellow.spe")  ; 2 yellow
9                                                    (def_tint "art/tints/cop/fire.spe")    ; 3 red-yellow
10                                                    (def_tint "art/tints/cop/olive.spe")   ; 4 green
11                                                    (def_tint "art/tints/cop/pinkish.spe") ; 5 pink
12                                                    (def_tint "art/tints/cop/darkblue.spe") ; 6 darkblue
13                                                    (def_tint "art/tints/cop/purple.spe")  ; 7 purple
14
15)))
16
17(setq player_text_color (make-array 8 :initial-contents (list
18                                                         43       ; 0 brown
19                                                         216      ; 1 blue
20                                                         76       ; 2 yellow
21                                                         82       ; 3 orange
22                                                         148      ; 4 green2
23                                                         90       ; 5 red
24                                                         231      ; 6 darkblue
25                                                         192)))   ; 7 purple
26
27(setq cop_dead_parts (make-array (* 4 3) :initial-contents
28                               ;       head           arm            leg
29                             '((CP_1  "4dha") (CP_2  "4daa") (CP_3  "4dba")     ; disapear
30                               (CP_4  "4dhf") (CP_5  "4daf") (CP_6  "4dbf")     ; flaming
31                               (CP_7  "4dae") (CP_8  "4dle") (CP_9  "4dbe")     ; electrical
32                               (CP_10 "4dhn") (CP_11 "4dan") (CP_12 "4dbn"))))  ; normal
33
34
35(do ((i 0 (setq i (+ i 1))))
36           ((>= i 12) nil)
37           (setq (aref cop_dead_parts i)
38                 (make_dead_part (car (aref cop_dead_parts i))
39                                 (car (cdr (aref cop_dead_parts i))) 4 "art/cop.spe" 'dead_cop_part_draw)))
40
41
42
43
44
45(setf fast_image (def_image "art/misc.spe" "fast_image"))
46(setf fly_image (def_image "art/misc.spe" "fly_image"))
47(setf sneaky_image (def_image "art/misc.spe" "sneaky_image"))
48(setf health_image (def_image "art/misc.spe" "b_check_image"))
49(setf shlamp_image (def_image "addon/aliens/aliens.spe" "slmp_img"))
50
51
52
53(defun give_player_health (amount)
54  (let ((h_amount  (select difficulty
55                           ('easy    amount)
56                           ('medium  (/ (* amount 3) 4))
57                           ('hard    (/ amount 2))
58                           ('extreme (/ amount 5))))
59        (h_max (if (eq special_power HEALTH_POWER)
60                   200
61                 100)))
62    (if (eq (hp) h_max)
63        nil
64      (progn
65        (if (<= (+ (hp) h_amount) h_max)
66            (add_hp h_amount)
67          (add_hp (- h_max (hp))))
68        (setq b_ramp (+ b_ramp (* h_amount 2)))
69
70        T)))
71)
72
73
74
75(defun pressing_action_key ()
76  (> (player_y_suggest) 0))
77
78
79; signals for user function
80(enum 'SET_SNEAKY_TIME
81      'SET_VISOR_TIME
82      'SET_FAST_TIME
83      'SET_FADE_COUNT
84)
85
86
87; states for cop
88(enum 'JUST_START
89      'NORMAL_PLAY)
90
91
92(enum 'NO_POWER
93      'FAST_POWER
94      'FLY_POWER
95      'SNEAKY_POWER
96      'HEALTH_POWER
97      'SHLAMP_POWER)
98
99; this is called by the engine when a level is loaded with no player_info in it
100; i.e. not for savegames
101; this function is called once for each player object
102(defun set_player_defaults ()
103  (set_ambient_light (me) 35)
104  (set_aistate 0)
105  (set_fade_count 0)
106  (setq in_climbing_area 0)
107  (setq disable_top_draw 0)
108  (setq just_hit 0)
109  (setq used_special_power 0)
110  (setq has_saved_this_level 0)
111  (setq r_ramp 0)
112  (setq g_ramp 0)
113  (setq b_ramp 0)
114  (setq is_teleporting 0)
115  (setq just_fired 0)
116  (setq has_compass 0)
117  (setq special_power NO_POWER))
118
119
120
121(defun cop_ufun (signal value)
122  (if (< (total_objects) 1)    ; make sure upper body is there
123      nil
124    (select signal
125            (SET_SNEAKY_TIME
126             (progn
127               (set_sneaky_time value)
128               (with_obj0 (set_sneaky_time value))))
129            (SET_VISOR_TIME (set_visor_time value))
130            (SET_FAST_TIME
131             (progn
132               (set_fast_time value)
133               (with_obj0 (set_fast_time value))))
134            (SET_FADE_COUNT (set_fade_count value)
135                            (with_obj0 (set_fade_count value)))
136
137            )))
138
139
140(defun cop_adjust_top (return)
141  (if (< (total_objects) 1)        ;; should be here
142      (let ((me (me)))
143        (link_object (add_object_after MGUN_TOP (x) (y)))
144        (with_obj0 (link_object me))
145        ))
146  return
147)
148
149(defun climb_off_handler ()
150  (if (next_picture)
151      (progn
152        (view_push_down 4)
153        0)
154    (progn
155      (set_y (- (y) 28))
156      (set_state stopped)
157      0)))
158
159(defun climb_handler (xm ym but)
160  (let ((yd in_climbing_area))
161    (setq in_climbing_area 0)
162    (if (eq (state) climb_off)
163        (climb_off_handler)
164      (if (eq (state) climbing)
165          (progn
166            (if (> ym 0)
167                (progn
168                  (if (eq (current_frame) 0) (set_current_frame 9)
169                    (set_current_frame (- (current_frame) 1)))
170                  (set_y (+ (y) 3)))
171              (if (< ym 0)
172                  (progn
173                    (if (< yd 32)
174                        (set_state climb_off)
175                      (progn
176                        (if (not (next_picture)) (set_state climbing))
177                        (set_y (- (y) 3)))))))
178            (if (not (eq xm 0))
179                (if (can_see (x) (- (y) 20) (x) (y) nil)
180                    (if (eq ym 0)
181                        (progn
182                          (set_state run_jump_fall)
183                          (set_gravity 1))
184                      (progn
185                        (set_state run_jump)
186                        (set_yvel (get_ability jump_yvel))
187                        (set_gravity 1)
188                        ))))
189
190            0)
191        (if (and (>= (yvel) 0) (or (> ym 0)
192                                   (and (< ym 0) (> yd 8))))
193            (progn
194              (set_state climbing)
195              (set_gravity 0)
196              (set_xvel 0)
197              (set_yvel 0)
198              (set_xacel 0)
199              (set_yacel 0)
200              0)
201          (progn
202            (next_picture)
203            (cop_adjust_top (mover xm ym but))))
204        ))))
205
206
207(defun undo_special_power (xm ym but)
208  (select special_power
209          (FAST_POWER   (setq used_special_power 0))
210          (SNEAKY_POWER (if (> used_special_power 0)
211                            (setq used_special_power (- used_special_power 1))))))
212
213(defun do_special_power (xm ym but)
214  (select special_power
215          (FLY_POWER
216           (add_object CLOUD (+ (+ (x) (* (direction) -10)) (random 5)) (+ (y) (random 5)))
217           (set_state run_jump)
218           (set_gravity 1)
219           (set_yacel 0)
220           (if (> (yvel) 0) (set_yvel (/ (yvel) 2)))
221           (set_yvel (- (yvel) 2))
222           (if (< ym 0)
223               (set_yvel (- (yvel) 1)))
224           )
225
226
227          (FAST_POWER
228           (setq used_special_power 1)
229           (setq last1_x (x))
230           (setq last1_y (y))
231           (if (> (total_objects) 0)
232               (with_obj0
233                            (if (> fire_delay1 0)
234                                (setq fire_delay1 (- fire_delay1 1)))))
235
236
237           (let ((in_area in_climbing_area)
238                 (old_yvel (yvel)))
239             (player_move xm ym but)
240             (setq in_climbing_area in_area)
241             (if (and (< ym 0) (eq old_yvel 0) (< (yvel) 0))
242                 (set_yvel (+ (yvel) (/ (yvel) 3))))
243
244             )
245
246           (setq last2_x (x))
247           (setq last2_y (y)))
248
249          (SNEAKY_POWER (if (<= used_special_power 15)
250                            (setq used_special_power (+ used_special_power 1))))
251          ))
252
253(defun player_move (xm ym but)
254  (if (eq in_climbing_area 0)
255      (progn
256        (if (eq (state) climbing)
257            (progn
258              (set_gravity 1)
259              (set_state run_jump_fall)))
260        (next_picture)
261        (cop_adjust_top (mover xm ym but)))
262    (climb_handler xm ym but)))
263
264/*(defun cop_mover (xm ym but)
265  (if (> (yvel) 10)
266      (progn
267        (set_yacel 0)
268        (set_yvel (- (yvel) 1))))  ;; terminal velocity
269  (select (aistate)
270          (JUST_START
271           (if (eq but 0)              ; wait till user lets go of button before moving
272               (progn
273                 (set_aistate NORMAL_PLAY)
274                 (mover xm ym but))
275             (cop_adjust_top (tick))))
276          (NORMAL_PLAY
277           (if (or (<= (hp) 0) (eq (state) dieing) (eq (state) dead))    ; are we dead?
278               (progn
279                 (if (not (eq (state) dead))
280                     (if (not (eq (state) dieing))
281                         (progn
282                           (set_state dieing)
283                           (set_xvel 0)
284                           (set_yvel 0)
285                           (set_xacel 0)
286                           (set_yacel 0))
287                       (if (not (next_picture))
288                           (set_state dead) nil))
289                   (if (not (eq but 0)) ; wait till dead and pressing but, then reset
290                       (progn
291                         (restart_player)
292                         (set_aistate JUST_START))
293                         (cop_adjust_top (tick))))
294                 0)
295
296             ; normal play code
297             (progn
298               ; check to see if player is firing
299               (if (equal (bit-and but 1) 1)
300                   (do_special_power xm ym but)
301                 (undo_special_power xm ym but))
302
303               (let ((ret (player_move xm ym but))
304                     (other (me)))
305                 (with_obj0
306                              (progn
307                                (set_x (with_object other (x)))
308                                (set_y (- (- (with_object other (y)) -29)
309                                          (with_object other (picture_height))))
310                                ))
311                 (if (and (equal (bit-and but 2) 2)
312                          (not (eq (state) dead)) (not (eq (state) dieing)))
313                     (let ((ammo (ammo_total (current_weapon_type))))
314                       (add_ammo (current_weapon_type) (with_obj0
315                                                                    (user_fun 'FIRE ammo)))
316                       nil))
317                 ret)
318               )))))
319
320)*/
321
322;;(defun normal_bottom_mover ()  ;; just runs around
323
324(defun dead_cop_part_draw ()
325  (if (eq (aitype) 0)
326      (draw)
327    (draw_tint (aref player_tints (aitype)))))
328
329(defun bottom_damage (amount from hitx hity push_xvel push_yvel)  ; transfer damage to lower half
330  (if (eq is_teleporting 1)
331      nil
332    (let ((amount (select difficulty;; reduce damage according to difficulty
333                          ('easy   (/ amount 2))
334                          ('medium (/ (* amount 3) 4))
335                          ('hard    amount)
336                          ('extreme (* amount 3))
337                          )))
338
339
340      (select (aistate)
341              (NORMAL_PLAY (if (and (not (eq (state) dieing)) (not (eq (state) dead)))
342                               (progn
343                                 (if (eq (random 2) 0)
344                                     (set_state flinch_up)
345                                   (set_state flinch_down))
346                                 (if (local_player)
347                                     (progn
348                                       (setq r_ramp (+ r_ramp (* amount 7)))
349                                       (setq g_ramp (- g_ramp (* amount 14)))
350                                       (setq b_ramp (- b_ramp (* amount 14)))
351                                       (if (> r_ramp 120) (setq r_ramp 120))
352                                       (if (< g_ramp 0) (setq g_ramp 0))
353                                       (if (< b_ramp 0) (setq b_ramp 0))))
354
355                                 (damage_fun amount from hitx hity (/ push_xvel 2) (/ push_yvel 2))
356                                 (if (eq (hp) 0)
357                                     (progn
358                                       (if (and (time_for_next_level) (nth current_net_level net_levels))
359                                           (progn
360                                             (show_kills)
361                                             (reset_kills)
362                                             (setq current_net_level (+ current_net_level 1))
363                                             (if (not (nth current_net_level net_levels))
364                                                 (setq current_net_level 0))
365
366                                             ;; save the level we are so joining clients know which one to load
367                                             (if (not (am_a_client))
368                                                 (open_file "config/cur_lev.lsp" "wb"
369                                                            (print `(setq current_net_level ,current_net_level))))
370
371                                             (request_level_load (nth current_net_level net_levels))))
372
373                                       (create_dead_parts cop_dead_parts (* (get_dead_part from) 3) (player_number))
374                                       (play_sound (aref PLAYER_DEATH (random 4)) 127 (x) (y)))
375                                   (if (> amount 8)
376                                       (play_sound (aref PLAYER_PAIN (random 4)) 127 (x) (y)))))))
377
378
379              )))
380  )
381
382(defun should_draw_top? (mode)
383  (select mode
384          (JUST_START T)
385          (NORMAL_PLAY T)))
386
387(defun change_mode (new_mode)
388  (setq disable_top_draw (if (should_draw_top? new_mode) 0 1))
389  (set_aistate new_mode))
390
391(defun draw_fast ()
392  (if  (local_player)
393      (put_image (- (view_x2) 20) (+ (view_y1) 5) fast_image))
394                       (if (eq used_special_power 1)
395                           (if (> (total_objects) 0)
396                               (let ((nowx (x))
397                                     (nowy (y))
398                                     (l2x last2_x)
399                                     (l2y last2_y)
400                                     (l1x last1_x)
401                                     (l1y last1_y)
402                                     (td (top_draw_state (state)))
403                                     (h   (picture_height)))
404
405                                 (set_x l2x)
406                                 (set_y l2y)
407                                 (draw_transparent 5 16)
408                                 (if td (with_obj0 (progn (set_x l2x)
409                                                                    (set_y (- (- l2y -29) h))
410                                                                    (draw_transparent 5 16))))
411                                 (set_x last1_x)
412                                 (set_y last1_y)
413                                 (draw_transparent 10 16)
414
415                                 (if td (with_obj0 (progn (set_x l1x)
416                                                                    (set_y (- (- l1y -29) h))
417                                                                    (draw_transparent 10 16)
418                                                                    (set_x nowx)
419                                                                    (set_y nowy)
420                                                                    )))
421
422                                 (set_x nowx)
423                                 (set_y nowy)))))
424
425(defun sneaky_draw (count num)
426  (print count)
427  (if (eq count 0)
428      (player_draw num)
429    (if (> count 15)
430        (draw_predator)
431      (draw_transparent count 16))))
432
433(defun player_draw (num)
434  (if (eq num 0)
435      (if (eq just_fired 1)           ;; if they just fired a weapon, draw them lite up.. use the bright tint
436          (progn
437            (draw_tint bright_tint)
438            (setq just_fired 0))      ;; ok to change this in the draw function only if it is not accessed anywhere else!
439        (draw)
440;       (draw_tint (aref player_tints (aitype)))
441        )
442    (if (eq just_fired 1)
443        (progn
444          (draw_double_tint (aref player_tints num) bright_tint)
445          (setq just_fired 0))      ;; ok to change this in the draw function only if it is not accessed anywhere else!
446      (draw_tint (aref player_tints num)))))
447
448/*(defun bottom_draw ()
449  (if (not (and (eq r_ramp 0)    ;; need to draw red palette
450                (eq g_ramp 0)
451                (eq b_ramp 0)))
452      (progn
453        (if (> r_ramp 7)
454            (setq r_ramp (- r_ramp 7))
455          (if (< r_ramp -7)
456              (setq r_ramp (+ r_ramp 7))
457            (setq r_ramp 0)))
458
459        (if (> g_ramp 7)
460            (setq g_ramp (- g_ramp 7))
461          (if (< g_ramp -7)
462              (setq g_ramp (+ g_ramp 7))
463            (setq g_ramp 0)))
464
465        (if (> b_ramp 7)
466            (setq b_ramp (- b_ramp 7))
467          (if (< b_ramp -7)
468              (setq b_ramp (+ b_ramp 7))
469            (setq b_ramp 0)))
470
471        (if (local_player)
472            (tint_palette r_ramp g_ramp b_ramp))))
473
474
475  (select (aistate)
476          (JUST_START (player_draw (player_number)))
477          (NORMAL_PLAY
478           (select special_power
479                   (NO_POWER (player_draw (player_number)))
480                   (HEALTH_POWER (player_draw (player_number))
481                                 (if (local_player)
482                                     (put_image (- (view_x2) 20) (+ (view_y1) 5) health_image)))
483                   (FAST_POWER (draw_fast) (player_draw (player_number)))
484                   (FLY_POWER   (player_draw (player_number))
485                                (if (local_player)
486                                    (put_image (- (view_x2) 20) (+ (view_y1) 5) fly_image)))
487                   (SNEAKY_POWER
488                    (if (local_player)
489                        (put_image (- (view_x2) 20) (+ (view_y1) 5) sneaky_image))
490                                 (sneaky_draw used_special_power (player_number)))
491                   (SHLAMP_POWER (player_draw (bottom_draw (player_number)))
492                    (if (local_player)
493                        (put_image (- (view_x2) 20) (+ (view_y1) 5) shlamp_image)))
494          ))))*/
495
496(defun frabs_bottom_draw()
497  (if (eq special_power SHLAMP_POWER)
498      (progn
499        (setq special_power NO_POWER)
500        (bottom_draw)
501        (setq special_power SHLAMP_POWER))
502      (bottom_draw)))
503
504(defun restart_player ()
505  (setq special_power 0)
506  (setq has_compass 0)
507  (if (and (local_player) (not (and (eq r_ramp 0)
508                                    (eq g_ramp 0)
509                                    (eq b_ramp 0))))
510      (progn
511        (setq r_ramp 0)
512        (setq g_ramp 0)
513        (setq b_ramp 0)
514        (tint_palette 0 0 0)))
515
516  (if (eq (total_players) 1)     ;; is this a single player game?
517      (request_level_load  (if (eq has_saved_this_level 0)
518                               (progn
519                                 (set_hp 100)
520                                 (level_name))
521                             (concatenate 'string "save" (digstr has_saved_this_level 4) ".spe")))
522    (reset_player)
523
524    ))
525
526
527
528(defun start_cache (type)
529  `((,DARNEL) nil))
530
531(def_char START
532  (funs (ai_fun   do_nothing)
533        (get_cache_list_fun start_cache)
534        (draw_fun dev_draw))
535  (range 0 0)
536  (states "art/misc.spe" (stopped "start_image")))
537
538
539(defun cop_cache (type)
540  `(() (,bright_tint)))
541
542(defun p_compass_draw (player)
543  (if player
544      (with_object player
545                   (if (or (not (eq special_power SNEAKY_POWER)) (local_player))
546                       (let ((spot (game_to_mouse (x) (y))))
547                         (draw_rect (- (first spot) 1)
548                                    (- (second spot) 1)
549                                    (+ (first spot) 1)
550                                    (+ (second spot) 1)
551                                    (aref player_text_color (player_number)))))
552                   (p_compass_draw (next_focus player)))))
553
554
555(defun compass_draw ()
556  (if (and (local_player) (eq (mod (game_tick) 2) 0))
557      (if (eq has_compass 1)
558          (p_compass_draw (first_focus))
559        (let ((spot (game_to_mouse (x) (y))))
560          (draw_rect (- (first spot) 1)
561                     (- (second spot) 1)
562                     (+ (first spot) 1)
563                     (+ (second spot) 1)
564                     (aref player_text_color (player_number)))))))
565
566
567(def_char DARNEL
568  (vars in_climbing_area
569        disable_top_draw
570        just_hit
571        ship_pan_x
572        special_power
573        used_special_power
574        last1_x last1_y
575        last2_x last2_y
576        has_saved_this_level
577        r_ramp g_ramp b_ramp
578        is_teleporting
579        just_fired
580        has_compass
581        )
582  (range 50 50)
583  (abilities (walk_top_speed    3)
584             (jump_yvel       -15)
585             (run_top_speed     9)
586             (jump_top_speed   10)
587             (jump_xvel         9)
588             (stop_accel        9)
589             (start_accel       8)
590             (start_hp        100)
591             (hamper_xrange    80)
592             (push_xrange       9))
593
594  (flags     (hurtable          T)
595             (unlistable        T))
596
597  (funs (move_fun           cop_mover)
598        (damage_fun         bottom_damage)
599        (draw_fun           frabs_bottom_draw)
600        (map_draw_fun       compass_draw)
601        (get_cache_list_fun cop_cache)
602        (user_fun           cop_ufun))
603
604  (states "art/cop.spe"
605          (stopped            (seq "stopped" 1 6))
606          (running            (seq "4wlk" 1 10))
607
608          (fast_running       (seq "4fst" 1 10))
609          (fly_running        (seq "4fly" 1 10))
610
611          (fast_stopped        (seq "bot2" 7 12))
612          (fly_stopped       (seq "bot2" 1 6))
613
614          (dead               "dead")
615
616          (start_run_jump     "jump_up")
617          (run_jump           "jump_up")
618          (run_jump_fall      "jump_down")
619          (end_run_jump       (seq "4jmp" 3 5))
620
621          (fly_start_run_jump     "4flj0002.pcx")
622          (fly_run_jump           "4flj0002.pcx")
623          (fly_run_jump_fall      "4flj0003.pcx")
624          (fly_end_run_jump       (seq "4flj" 4 6))
625
626          (fast_start_run_jump     "4fjp0002.pcx")
627          (fast_run_jump           "4fjp0002.pcx")
628          (fast_run_jump_fall      "4fjp0003.pcx")
629          (fast_end_run_jump       (seq "4fjp" 4 6))
630
631
632          (flinch_up           (rep "4flh0002.pcx" 4))
633          (flinch_down         (rep "4flh0003.pcx" 4))
634
635          (climbing             (seq "4lad" 1 10))
636          (climb_off            (seq "4off" 1 8))
637          (climb_on            (seq "4off" 8 1))
638          ))
639
640
641(defun clone_ai ()
642  (if (and (< (state_time) 200) (not (eq (state) dead)))
643      (progn
644        (select (direction)
645                (1 (if (blocked_right (move 1 0 0))
646                       (set_direction -1)
647                     nil))
648                (-1 (if (blocked_left (move -1 0 0))
649                        (set_direction 1)
650                      nil)))
651            (if (or (> (state_time) 185) (eq (state) dieing))
652                (set_fade_count (+ (fade_count) 1))
653              nil)
654            T)
655        nil))
656
657
658
659
660(defun top_draw_state (state)
661
662  (or (eq state stopped) (eq state running)
663                        (eq state run_jump) (eq state run_jump_fall)
664                        (eq state end_run_jump)))
665
666/*(defun top_draw ()
667  (if (> (total_objects) 0)
668      (let ((other  (get_object 0)))
669        (if (or (with_object other (morphing))
670                (eq (with_object other disable_top_draw) 1)
671                (not (top_draw_state (with_object other (state)))))
672            nil
673          (progn
674            (if (eq (with_object other special_power) SNEAKY_POWER)
675                (sneaky_draw (with_object other used_special_power)
676                             (with_object other (player_number)))
677              (let ((nowx (x))
678                    (nowy (y)))
679                (set_x (with_object other (if (> (direction) 0) (x) (+ (x) 2))))
680                (set_y (- (- (with_object other (y)) -29) (with_object other (picture_height))))
681                (player_draw  (with_object other (player_number)))
682                (set_x nowx)
683                (set_y nowy))
684              ))))))
685*/
686
687(defun ammo_type ()
688  (select (otype)
689          (GRENADE_TOP  2)
690          (MGUN_TOP     10)
691          (FIREBOMB_TOP 5)
692          (ROCKET_TOP   3)
693          (PGUN_TOP     4)
694          (LSABER_TOP   5)
695          (DFIRS_TOP    6)
696          ))
697
698(defun ammo_delay ()
699  0)
700
701
702(defun player_angle_suggestion ()
703  (atan2 (- (y) (player_pointer_y) 16)
704         (- (player_pointer_x) (x))))
705
706
707(defun player_fire_weapon (type target)
708  (let ((angle (with_obj0 (player_angle_suggestion))))
709
710    (let ((firex (+ (x) (* (cos angle) 17) (xvel)))
711          (firey (+ (- (y) (* (sin angle) 16) 20) (yvel))))
712      (if (can_see (x) (- (y) 16) firex firey nil)
713          (progn
714            (fire_object  (get_object 0) type firex firey angle target)
715            T)
716        nil))))
717
718/* (defun top_ai ()
719  (if (> (total_objects) 0)
720      (let ((myself (get_object 0)))
721
722        (set_state rotate)
723        (let ((angle (with_object myself
724                                            (if (> (direction) 0)
725                                                (player_angle_suggestion)
726                                              (if (> (player_angle_suggestion) 180)
727                                                  (- (player_angle_suggestion) 180)
728                                                (+ 180 (player_angle_suggestion)))))))
729          (setq point_angle angle)
730          (set_frame_angle 0 359 angle))
731        (if (not (eq fire_delay1 0))
732            (setq fire_delay1 (- fire_delay1 1)))
733        (if (eq (with_object myself (weapon_to_type (current_weapon_type))) (otype))
734            (select (aistate)
735                    (2                  ; start fire up
736                     (progn
737                       (set_state rotate_fire)
738                       (set_frame_angle 0 359 (with_object myself
739                                            (if (> (direction) 0)
740                                                (player_angle_suggestion)
741                                              (if (> (player_angle_suggestion) 180)
742                                                  (- (player_angle_suggestion) 180)
743                                              (+ 180 (player_angle_suggestion))))))
744                       ;; (set_state weapon_fire)
745;;                     (set_fire_delay1 3)
746
747;;                          (let ((otype (otype)))
748;;                            (with_object myself (add_ammo otype -1)))
749;;                          (with_object (add_object (ammo_type) (x) (- (y) 16) 1)
750;;                                       (user_fun myself))
751                          (set_aistate 3)))
752                    (1                  ; special power
753                     (progn (set_state weapon_fire_up)
754                            (let ((otype (otype)))
755                              (with_object myself (add_ammo weapon_type -1)))
756                            (with_object (add_object (ammo_type) (x) (- (y) 20) 2)
757                                         (user_fun myself))
758                            (set_aistate 3)))
759                    (3 (if (eq fire_delay1 0) ;; (user_fun 'RESET_FIRE_OK nil)
760                           (set_aistate 0)
761                         (progn
762                           (user_fun 'CONTINUE_FIRE nil)
763                           (setq fire_delay1 (- fire_delay1 1)))
764                         )))
765          (set_otype (with_object myself (weapon_to_type (current_weapon_type)))))))
766  (move 0 0 0)
767  T)
768
769;(defun top_damage (amount from hitx hity push_xvel push_yvel)  ; transfer damage to lower half
770;  (with_obj0 (damage_fun amount from hitx hity push_xvel push_yvel)))
771
772
773(defun laser_ufun (signal value)
774  (select signal
775          ('FIRE (if (eq (aistate) 0)  ;;  not already firing
776                     (if (> value 0)   ;; have ammo
777                         (progn
778                           (setq fire_delay1 3)
779                           (set_aistate 2)
780                           (if (player_fire_weapon (ammo_type) nil)
781                               -1
782                             0))
783                       (progn
784                         (setq fire_delay1 7)
785                         (set_aistate 2)
786                         (player_fire_weapon (ammo_type) nil)
787
788                         0))
789                   0))
790          ('RESET_FIRE_OK (>= (state_time) fire_delay1))))
791
792(defun top_ufun (signal value)
793  (select signal
794          ('FIRE (if (and (> value 0) (eq (aistate) 0))  ;; have ammo and not already firing
795                     (progn
796                       (setq fire_delay1 12)
797                       (set_aistate 2)
798                       (if (player_fire_weapon (ammo_type) nil)
799                           -1
800                         0))
801                   0))
802          ('RESET_FIRE_OK (>= (state_time) fire_delay1))))
803
804
805
806(defun plaser_ufun (signal value)
807  (select signal
808          ('FIRE (if (and (> value 0) (eq (aistate) 0))  ;; have ammo and not already firing
809                     (progn
810                       (setq fire_delay1 2)
811                       (set_aistate 2)
812                       (if (player_fire_weapon (ammo_type) nil)
813                           -1 0))
814                   0))
815
816          ('RESET_FIRE_OK (>= (state_time) fire_delay1))))
817
818
819
820(defun player_rocket_ufun (signal value)
821  (select signal
822          ('FIRE (if (and (> value 0) (eq (aistate) 0))  ;; have ammo and not already firing
823                     (progn
824                       (setq fire_delay1 12)
825                       (set_aistate 2)
826                       (if (player_fire_weapon (ammo_type)
827                                           (with_obj0 (find_object_in_area
828                                                                        (- (x) 160) (- (y) 160)
829                                                                        (+ (x) 160) (+ (y) 160)
830                                                                        bad_guy_list)))
831                           -1 0))
832                   0))
833          ('RESET_FIRE_OK (>= (state_time) fire_delay1)))) */
834
835
836
837
838(defun top_cache (type)
839  (list
840   (select type
841           (MGUN_TOP      (list SHOTGUN_BULLET))
842           (GRENADE_TOP   (list GRENADE))
843           (ROCKET_TOP    (list ROCKET))
844           (FIREBOMB_TOP  (list FIREBOMB))
845           (PGUN_TOP      (list PLASMAGUN_BULLET))
846           (LIGHT_SABER   (list LSABER_BULLET))
847           (DFRIS_TOP     (list DFRIS_BULLET))
848   nil)))
849
850
851(defun make_top_char (symbol base ufun dfun)
852  (eval (list 'def_char symbol
853              `(funs (ai_fun    top_ai)
854                     (get_cache_list_fun top_cache)
855                     (draw_fun  ,dfun)
856                     (user_fun  ,ufun))
857              '(flags (add_front  T)
858                      (is_weapon  T)
859                      (unlistable T))
860              '(vars point_angle fire_delay1 just_fired)
861              `(states "art/coptop.spe"
862                       (stopped        (seq ,base 1 24))))))
863
864
865
866(make_top_char 'MGUN_TOP     "4gma" 'laser_ufun         'top_draw)
867(make_top_char 'GRENADE_TOP  "4gre" 'top_ufun           'top_draw)
868(make_top_char 'ROCKET_TOP   "4gro" 'player_rocket_ufun 'top_draw)
869(make_top_char 'FIREBOMB_TOP "4gfi" 'top_ufun           'top_draw)
870
871
872
873
874(defun restart_ai ()
875  (if (eq (total_players) 1)       ;; only allow saving in single player games
876      (select (aistate)
877              (0 (next_picture)
878                 (if (and (touching_bg) (with_object (bg) (pressing_action_key)))
879                     (set_aistate 2)))
880              (1 (next_picture);; wait for save (actived state)
881                 (if (and (touching_bg) (with_object (bg) (pressing_action_key)))
882                     (set_aistate 2)))
883              (2 (set_state running)
884                 (set_aistate 3))
885              (3 (set_aistate 4))
886              (4
887               (let ((spot (get_save_slot)))
888                 (set_state stopped)
889                 (set_aistate 1)
890                 (if (not (eq spot 0));; did they escape ?
891                     (progn
892                       (show_help (concatenate 'string Station (num2str (xvel)) secured))
893                       (with_object (bg)
894                                    (progn
895                                      (let ((old_hp (hp)))
896                                        (if (not (eq difficulty 'extreme))
897                                            (set_hp 100));; save the player with 100 health, unless on extreme
898                                        (play_sound SAVE_SND 127 (x) (y))
899                                        (setq has_saved_this_level spot)
900                                        (save_game (concatenate 'string "save" (digstr spot 4) ".spe"))
901                                        (set_hp old_hp)
902                                        ))))))
903
904               )))
905  T)
906
907
908(def_char RESTART_POSITION
909  (funs (ai_fun restart_ai)
910        (reload_fun lower_reload))
911  (fields ("xvel"  restart_station))
912  (states "art/misc.spe"
913          (stopped (app (rep "console" 3) (rep "console2" 3)))
914          (running (rep "console_on" 2))))
915
916(defun next_level_ai ()
917  (if (and (touching_bg) (with_object (bg) (pressing_action_key)))
918      (if (eq (aistate) end_level)
919          (request_end_game)
920        (progn
921          (show_stats)
922          (request_level_load (concatenate 'string "levels/level" (digstr (aistate) 2) ".spe")))))
923  T)
924
925
926(def_char NEXT_LEVEL
927  (funs (ai_fun next_level_ai))
928  (flags (can_block T))
929  (fields ("aistate" next_level))
930  (states "art/misc.spe"
931          (stopped "end_port2")))
932
933(defun next_level_top_ai ()
934  (shift_rand_table 80)
935  (let ((oldy (y)))
936    (try_move 0 100)
937    (setq floor_yoff (- (y) oldy))
938    (set_y oldy))
939  T)
940
941(def_char NEXT_LEVEL_TOP
942  (funs (ai_fun next_level_top_ai))
943  (vars floor_yoff)
944  (draw_range 50 100)
945  (fields ("aistate" next_level))
946  (states "art/misc.spe"
947          (stopped "end_port1")))
948
949(defun tele_beam_ai ()
950  (next_picture)
951  (if (> (direction) 0)
952      (if (eq (fade_count) 12)
953          (progn
954            (play_sound APPEAR_SND 100 (x) (y))
955            (set_direction -1))
956        (set_fade_count (+ (fade_count) 1)))
957    (if (eq (fade_count) 5)
958        (progn
959          (play_sound APPEAR_SND 100 (x) (y))
960          (set_direction 1))
961      (set_fade_count (- (fade_count) 1)))))
962
963
964(def_char TELE_BEAM
965  (funs (ai_fun tele_beam_ai))
966  (states "art/chars/teleport.spe" (stopped (seq "beam" 1 5))))
967
968(def_char END_OF_S
969  (funs (ai_fun do_nothing))
970  (states "art/misc.spe" (stopped "eos")))
971
972
973(make_top_char 'PGUN_TOP     "4gza" 'plaser_ufun        'top_draw)
974(make_top_char 'LIGHT_SABER  "4gch" 'lsaber_ufun        'top_draw)
975(make_top_char 'DFRIS_TOP    "4gbo" 'top_ufun           'top_draw)
976(setq sell_screens '(("art/fore/endgame.spe" . "credit")))
977
978
979(setq end_level 22)
980
Note: See TracBrowser for help on using the repository browser.