source: abuse-mac/trunk/lisp/doors.lsp @ 102

Last change on this file since 102 was 102, checked in by Sam Hocevar, 11 years ago
File size: 5.6 KB
Line 
1;; Copyright 1995 Crack dot Com,  All Rights reserved
2;; See licensing information for more details on usage rights
3
4(defun general_door_ai (push?)
5  (select (aistate)
6          (0 (if (> (total_objects) 0)             ; are we linked to a key?
7                 (progn
8                   (set_state blocking)              ; don't let play pass
9                   (if push?
10                       (push_char (+ (picture_width) 8) (picture_height)))
11                   )
12               (if (touching_bg)                   ; found key, wait till touching to open
13                   (progn (set_state running)      ; start opening animation
14                          (play_sound SWISH 70 (x) (y))
15                          (go_state 1))
16                 nil)))
17          (1 (if (not (next_picture))              ; wait till open animation finishes
18                 (progn
19                   (set_state stopped)             ; set opened animation
20                   (go_state 2))))             
21
22          (2 (if (> (total_objects) 0)             ; wait till level editor links us to a key
23                 (progn
24                   (set_state blocking)
25                   (go_state 0))
26               (next_picture))))
27  T)
28
29(defun sdoor_ai ()
30  (general_sdoor_ai T))
31
32(defun general_sdoor_ai (push?)
33  (select (aistate)
34          (0 ;          closed, wait for signal
35           (if (> (total_objects) 0)
36               (if (not (eq (with_object (get_object 0) (aistate)) 0))
37                   (progn (set_state running)
38                          (play_sound SWISH 70 (x) (y))
39                          (go_state 1))
40                 (progn
41                   (set_state stopped)
42                   (if push?
43                       (push_char (+ (picture_width) 8) (picture_height)))))))
44
45          (1 ;          opening
46           (if (next_picture) nil
47             (progn
48               (set_state blocking)
49               (set_aistate 2))))
50          (2 (if (> (total_objects) 0)
51                 (if (eq (with_object (get_object 0) (aistate)) 0)
52                   (progn (set_state walking)
53                          (play_sound SWISH 70 (x) (y))
54                          (go_state 3)))))
55          (3 ;         closing
56           (if (next_picture) nil
57             (progn
58               (set_state stopped)
59               (set_aistate 0))))
60          )
61 
62
63T)
64
65
66(def_char SWITCH_DOOR
67  (funs (ai_fun sdoor_ai)
68        (reload_fun lower_reload))
69  (flags (can_block T))
70  (range 250 60)
71  (draw_range 30 50)
72  (abilities (push_xrange 1))
73  (states "art/chars/door.spe"
74          (stopped "door0006.pcx")
75          (running (seq "door" 6 1))
76          (walking (seq "door" 1 6))
77          (blocking "door0001.pcx")))
78
79(defun ff_push (who xamount)
80  (if who
81      (progn
82        (let ((bgx (with_object who (x)) (x))
83              (bgy (with_object who (y)) (y)))
84          (if (and (>= bgy (y)) (<= bgy (+ end_y 20))
85                   (< (abs (- bgx (x))) xamount))           
86              (let ((amount (if (> bgx (x))
87                                (- xamount (- bgx (x)))
88                              (- (- (x) bgx) xamount))))
89                (with_object who (try_move amount 0)))))
90        (ff_push (next_focus who) xamount))))
91
92
93(defun ff_ai ()
94
95  (shift_rand_table (random 80))
96  (if (activated)
97      (let ((nowx (x))
98            (nowy (y)))
99
100        (if (eq (mod (game_tick) 4) 0)
101            (play_sound FF_SND 127 (x) (y)))
102        (try_move 0 (+ (y) 200))    ;; find the floor
103        (setq end_y (y))            ;; save the position
104        (set_x nowx)
105        (set_y nowy)
106        (ff_push (first_focus) 35)))
107  T)
108       
109
110(defun ff_draw ()
111  (if (edit_mode) (draw))
112  (if (activated)
113      (progn
114        (ascatter_line (x) (y) (x) end_y (find_rgb 151 139 151) (find_rgb 75 69 75)    3)
115        (ascatter_line (x) (y) (x) end_y (find_rgb 139 147 191) (find_rgb 69 73 95)    2)
116        (ascatter_line (x) (y) (x) end_y (find_rgb 39  55  71)  (find_rgb 19 27 35)    2)
117        (ascatter_line (x) (y) (x) end_y (find_rgb 39  55  71)  (find_rgb 20 26 35)    2))))
118
119
120
121(def_char FORCE_FIELD
122  (funs (ai_fun ff_ai)
123        (draw_fun ff_draw))
124  (range 10 500)
125  (vars end_y)
126  (states "art/misc.spe"
127          (stopped "force_field")))
128       
129
130(defun hwall_ai ()
131  (if (or (eq (hp) 0)
132          (and (eq (total_objects) 1)
133               (with_object (get_object 0) (not (eq (aistate) 0)))))
134      (progn
135        (add_object EXPLODE1 (+ (x) 15) (- (y) 7)   0)
136        (play_sound HWALL_SND 127 (x) (y))
137        (hurt_radius (+ (x) (* 15 (direction))) (- (y) 7) 50 60 (bg) 20)
138        nil)
139    T))
140
141(defun big_wall_ai ()
142  (if (or (eq (hp) 0)
143          (and (eq (total_objects) 1)
144               (with_object (get_object 0) (not (eq (aistate) 0)))))
145      (progn
146        (add_object EXPLODE1 (- (x) 15) (- (y) 7)   0)
147        (add_object EXPLODE1 (+ (x) 15) (- (y) 22)  0)
148        (add_object EXPLODE1 (+ (x) (random 5)) (+ (+ (random 5) (y)) -20)     0)
149        (play_sound HWALL_SND 127 (x) (y))
150        (hurt_radius (x) (- (y) 15) 110 120 (bg) 20)
151        nil)
152    T))
153
154
155(defun hwall_damage (amount from hitx hity push_xvel push_yvel)
156  (if (activated)
157      (progn
158        (damage_fun amount from hitx hity push_xvel push_yvel)
159        (let ((max_hp (get_ability start_hp)))
160          (if (and (not (eq (hp) 0)) (not (> (hp) max_hp)))
161              (set_current_frame (/ (* (total_frames) (- max_hp (hp))) max_hp)))))))
162
163(defun hwall_reload ()    ;; we changed this , make sure this is reflected in all of the levels
164  (if (eq (hp) 60)
165      (set_hp 25)))
166
167     
168(defun make_hidden_wall_char (name start end ai)
169  (eval `(def_char ,name
170           (funs (ai_fun ,ai)
171                 (reload_fun  hwall_reload)
172                 (damage_fun hwall_damage))
173           (abilities (start_hp 25))
174           (draw_range 80 80)
175           (flags (can_block T)
176                  (unactive_shield T)
177                  (hurtable T))
178           (states "art/chars/sect.spe"
179                   (stopped (seq "sect" ,start ,end))))))     ; damn lisp is cool
180
181
182
183
184(make_hidden_wall_char 'HIDDEN_WALL1 1 3 'hwall_ai)
185(make_hidden_wall_char 'HIDDEN_WALL2 4 6 'hwall_ai)
186(make_hidden_wall_char 'HIDDEN_WALL3 7 9 'hwall_ai)
187(make_hidden_wall_char 'HIDDEN_WALL4 10 12 'hwall_ai)
188(make_hidden_wall_char 'HIDDEN_WALL5 13 15 'hwall_ai)
189
190(make_hidden_wall_char 'HIDDEN_WALL_2x2 16 18 'big_wall_ai)
191(make_hidden_wall_char 'HIDDEN_WALL_3WAL 19 21 'big_wall_ai)
192(make_hidden_wall_char 'HIDDEN_WALL_3FLR 22 24 'big_wall_ai)
193(make_hidden_wall_char 'HIDDEN_WALL_3TOP 25 27 'big_wall_ai)
194
195(make_hidden_wall_char 'HIDDEN_WALL_AFLR 28 30 'big_wall_ai)
196
197(make_hidden_wall_char 'HIDDEN_RAMP1 31 33 'hwall_ai)
198(make_hidden_wall_char 'HIDDEN_RAMP2 34 36 'hwall_ai)
199
200
201
202
203
Note: See TracBrowser for help on using the repository browser.