source: abuse-lib/trunk/lisp/flyer.lsp @ 96

Last change on this file since 96 was 46, checked in by Sam Hocevar, 15 years ago
  • Importing abuse-lib 2.00.
File size: 4.1 KB
Line 
1;; Copyright 1995 Crack dot Com,  All Rights reserved
2;; See licensing information for more details on usage rights
3
4
5(defun flyer_ai ()
6  (if (not (eq smoke_time 0))                 ;; if we just got hit, put out some smoke
7      (progn
8        (setq smoke_time (- smoke_time 1))
9        (if (eq (mod smoke_time 2) 0)
10            (add_object SMALL_DARK_CLOUD (x) (y)))))
11
12  (if (eq (aistate) 0)                        ;; wait for something to turn us on
13      (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
14          (if (next_picture) T
15            (progn
16              (set_targetable T)
17              (set_state running)
18              (set_aistate 1)))
19        (progn
20          (set_targetable nil)
21          (set_state stopped)
22          T))
23    (if (eq (hp) 0)                          ;; if dead, make an explosion
24        (progn
25          (add_object EXPLODE1 (+ (x) (random 10)) (+ (+ (random 10) (y)) -20)     0)
26          (add_object EXPLODE1 (- (x) (random 10)) (+ (- (y) (random 10)) -20)     2)
27          (add_object EXPLODE1 (x) (+ (- (y) (random 20)) -20)                     4)
28          nil)
29      (progn     
30        (if (eq (mod (state_time) 5) 0)      ;; make flyer noise every 5 ticks
31            (play_sound FLYER_SND 127 (x) (y)))
32        (if (> (with_object (bg) (x)) (x))   ;; start going right if player is to the right
33            (progn
34              (set_xvel (+ (xvel) 1))
35              (if (> (xvel) max_xvel) (set_xvel max_xvel))
36              (if (eq (direction) -1)
37                  (progn
38                    (set_direction 1)
39                    (set_state turn_around))))
40          (if (< (with_object (bg) (x)) (x))  ;; start going left if the player is to the left
41              (progn
42                (set_xvel (- (xvel) 1))
43                (if (< (xvel) (- 0 max_xvel)) (set_xvel (- 0 max_xvel)))
44                (if (eq (direction) 1)
45                    (progn
46                      (set_direction -1)
47                      (set_state turn_around))))))
48        (if (> (with_object (bg) (- (y) 70)) (y))
49            (if (> (yvel) max_yvel)
50                (set_yvel (- (yvel) 1))
51              (set_yvel (+ (yvel) 1)))
52
53          (if (< (with_object (bg) (- (y) 50)) (y))
54              (if (< (yvel) (- 0 max_yvel))
55                  (set_yvel (+ (yvel) 1))
56                (set_yvel (- (yvel) 1)))))
57
58        (if (eq (random 5) 0)                ;; add some randomness to the movement
59            (set_xvel (+ (xvel) 1))
60          (if (eq (random 5) 0)
61              (set_xvel (- (xvel) 1))))
62        (if (eq (random 5) 0)
63            (set_yvel (+ (yvel) 1))
64          (if (eq (random 5) 0)
65              (set_yvel (- (yvel) 1))))
66
67        (if (next_picture) T (set_state running))  ;; reset animation when done
68           
69        (bounce_move '(set_xvel (/ (xvel) 2)) '(set_xvel (/ (xvel) 2))
70                     '(set_yvel (/ (yvel) 2)) '(set_yvel (/ (yvel) 2)) nil)
71     
72        (if (> fire_time 0)              ;; if we need to wait till next burst
73            (progn
74              (setq fire_time (- fire_time 1))
75              (if (eq fire_time 0)
76                  (progn
77                    (setq burst_left burst_total)
78                    (setq burst_wait 0))))
79          (if (eq burst_wait 0)
80              (if (and (< (distx) 150) (eq (direction) (facing)))
81                  (let ((firex (+ (x) (* (direction) 10)) )
82                        (firey (y))
83                        (playerx (+ (with_object (bg) (x)) (with_object (bg) (* (xvel) 4))))
84                        (playery (+ (- (with_object (bg) (y)) 15) (with_object (bg) (* (yvel) 2)))))
85                    (if (and (can_see (x) (y) firex firey nil) (can_see firex firey playerx playery nil))
86                        (progn
87                          (let ((angle (atan2 (- firey playery)
88                                              (- playerx firex))))
89                            (if (or (eq burst_left 1) (eq burst_left 0))
90                                (setq fire_time fire_delay)
91                              (setq burst_left (- burst_left 1)))
92                            (setq burst_wait burst_delay)
93                            (fire_object (me) (aitype) firex firey angle (bg))
94                            )))))
95            (setq burst_wait (- burst_wait 1))))               
96        T))))
97
98
99
100(defun flyer_cons ()     
101  (setq fire_delay 20)
102  (setq burst_delay 3)
103  (setq max_xvel 10)
104  (setq max_yvel 5)
105  (set_aitype 9)
106  (setq burst_total 2))
107
108
109(defun flyer_damage (amount from hitx hity push_xvel push_yvel)
110  (if (and from (with_object from (and (> (total_objects) 0)
111                                       (with_object (get_object 0)
112                                                    (or (eq (otype) FLYER)
113                                                        (eq (otype) GREEN_FLYER))
114                                                        ))))
115      nil
116    (if (eq (state) stopped) nil
117      (progn
118        (setq smoke_time 30)
119        (set_yvel (- (yvel) 14))
120        (set_state flinch_up)
121        (damage_fun amount from hitx hity push_xvel push_yvel)))))
122
123
124(setq load_warn nil)
125(if (not (load "register/flyer.lsp"))
126    (progn
127      (setq FLYER WHO)
128      (setq GREEN_FLYER WHO)))
129(setq load_warn T)
130
131
132
133
134
135
136
137
138
Note: See TracBrowser for help on using the repository browser.