1 | ;; Copyright 1995 Crack dot Com, All Rights reserved |
---|
2 | ;; See licensing information for more details on usage rights |
---|
3 | |
---|
4 | (defun switch_dim_ai () |
---|
5 | (general_dim_ai '(if (> (total_objects) 0) |
---|
6 | (not (eq (with_object (get_object 0) (aistate)) 0)) |
---|
7 | nil) |
---|
8 | '(if (> (total_objects) 0) |
---|
9 | (eq (with_object (get_object 0) (aistate)) 0) |
---|
10 | nil))) |
---|
11 | |
---|
12 | |
---|
13 | (defun dim_ai () |
---|
14 | (general_dim_ai '(and (< (distx) (aitype)) (< (disty) 50)) '(> (distx) (xacel)))) |
---|
15 | |
---|
16 | (defun get_light_value () |
---|
17 | (if (> (total_lights) 0) |
---|
18 | (light_r2 (get_light 0)) |
---|
19 | (ambient_light (bg)))) |
---|
20 | |
---|
21 | (defun set_light_value (x) |
---|
22 | (if (> (total_lights) 0) |
---|
23 | (set_light_r2 (get_light 0) x) |
---|
24 | (set_ambient_light (bg) x))) |
---|
25 | |
---|
26 | (defun general_dim_ai (activation_condition deactivation_condition) |
---|
27 | (select (aistate) |
---|
28 | (0 (if (eval activation_condition) |
---|
29 | (progn |
---|
30 | (if (< (* (xvel) (direction)) 0) |
---|
31 | (if (eq (yacel) 0) ;; play sound effect? |
---|
32 | (play_sound FADEON_SND 127 (x) (y)))) |
---|
33 | (go_state 1)) |
---|
34 | T)) |
---|
35 | (1 (if (> (state_time) (yvel)) |
---|
36 | (go_state 2) |
---|
37 | (set_light_value (- (get_light_value) (* (xvel) (direction)))))) |
---|
38 | (2 (progn |
---|
39 | (if (> (total_objects) 0) |
---|
40 | (with_object (get_object 0) (set_aistate 1)) |
---|
41 | nil) |
---|
42 | (set_aistate 3) |
---|
43 | T)) |
---|
44 | (3 (if (eval deactivation_condition) |
---|
45 | (progn |
---|
46 | (if (> (* (xvel) (direction)) 0) |
---|
47 | (if (eq (yacel) 0) ;; play sound effect? |
---|
48 | (play_sound FADEON_SND 127 (x) (y)))) |
---|
49 | (go_state 4)) |
---|
50 | T)) |
---|
51 | (4 (if (> (state_time) (yvel)) |
---|
52 | (go_state 5) |
---|
53 | (set_light_value (+ (get_light_value) (* (xvel) (direction)))))) |
---|
54 | (5 (progn |
---|
55 | (if (> (total_objects) 0) |
---|
56 | (with_object (get_object 0) (set_aistate 4)) |
---|
57 | nil) |
---|
58 | (set_aistate 0) |
---|
59 | T)) |
---|
60 | ) |
---|
61 | T) |
---|
62 | |
---|
63 | (defun dim_cons () (set_xvel 20) (set_yvel 5)) |
---|
64 | |
---|
65 | |
---|
66 | (def_char DIMMER |
---|
67 | (funs (ai_fun dim_ai) |
---|
68 | (draw_fun dev_draw) |
---|
69 | (constructor dim_cons)) |
---|
70 | (flags (unlistable T)) |
---|
71 | (fields ("aistate" ai_state) |
---|
72 | ("xvel" dimmer_step_amount) |
---|
73 | ("yvel" dimmer_steps) |
---|
74 | ("aitype" dimmer_dist) |
---|
75 | ("xacel" dimmer_dedist) |
---|
76 | ("yacel" dimmer_silent)) |
---|
77 | (states "art/misc.spe" |
---|
78 | (stopped "dim"))) |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | (def_char SWITCH_DIMMER |
---|
83 | (funs (ai_fun switch_dim_ai) |
---|
84 | (draw_fun dev_draw) |
---|
85 | (constructor dim_cons)) |
---|
86 | (fields ("aistate" ai_state) |
---|
87 | ("xvel" dimmer_step_amount) |
---|
88 | ("yvel" dimmer_steps) |
---|
89 | ("yacel" dimmer_silent)) |
---|
90 | (states "art/misc.spe" (stopped "dim"))) |
---|
91 | |
---|