source: abuse/trunk/data-abuse/lisp/people.lsp @ 586

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

data: remove \r and trailing spaces and tabs from all Lisp sources.

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