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

Last change on this file since 102 was 102, checked in by Sam Hocevar, 11 years ago
File size: 3.7 KB
Line 
1;; Copyright 1995 Crack dot Com,  All Rights reserved
2;; See licensing information for more details on usage rights
3
4; draw function for characters only displayed during edit mode
5; such as start, etc.
6; (defun dev_draw () (if (edit_mode) (draw) nil))       -- compiled C function --
7
8/* written in C
9(defun middle_draw ()
10  (let ((y (y)))
11    (set_y (+ (y) (/ (picture_height) 2)))
12    (draw)
13    (set_y y)))
14       
15
16
17(defun push_char (xamount yamount)
18  (let ((bgx (with_object (bg) (x)) (x))
19        (bgy (with_object (bg) (y)) (y)))
20    (if (and (<= bgy (y)) (< (disty) yamount) (< (distx) xamount))
21        (let ((amount (if (> bgx (x))
22                          (- xamount (- bgx (x)))
23                        (- (- (x) bgx) xamount))))
24          (with_object (bg) (try_move amount 0))))))
25
26*/
27
28(defun push_char (xamount yamount)
29  (let ((bgx (with_object (bg) (x)) (x))
30        (bgy (with_object (bg) (y)) (y)))
31    (if (and (<= bgy (y)) (< (disty) yamount) (< (distx) xamount))
32        (let ((amount (if (> bgx (x))
33                          (- xamount (- bgx (x)))
34                        (- (- (x) bgx) xamount))))
35          (with_object (bg) (try_move amount 0))))))
36
37
38
39(defun do_nothing () (next_picture) T)
40
41(defun lhold_ai ()
42  (if (> (total_objects) 0)
43      (progn
44        (set_x (with_object (get_object 0) (x)))
45        (set_y (with_object (get_object 0) (- (y) (/ (picture_height) 2) )))))
46  (if (eq (total_lights) 1)
47      (progn
48        (set_light_x (get_light 0) (x))
49        (set_light_y (get_light 0) (y)))
50    nil)
51  T)
52   
53
54
55(def_char LIGHTHOLD
56  (funs  (ai_fun   lhold_ai)
57         (draw_fun dev_draw))
58  (states "art/misc.spe"         
59          (stopped           "lhold")))
60
61
62
63(def_char OBJ_MOVER
64  (funs (ai_fun       mover_ai)
65        (constructor  mover_cons)
66        (draw_fun     dev_draw))
67  (range 300 40)
68  (fields ("aitype" obj_frames)
69           ("aistate" obj_frame))
70  (states "art/misc.spe" (stopped '("mover" "mover" ))))
71
72/*    Compiled C           
73(defun mover_ai ()
74  (if (eq (total_objects) 2)
75      (let ((dest (get_object 0))
76            (mover (get_object 1)))
77        (if (< (aistate) 2)             ; transfer object to next mover       
78            (progn
79              (with_object dest
80                           (progn
81                             (link_object mover)
82                             (set_aistate (aitype))))
83              (remove_object mover))
84          (progn             
85            (set_aistate (- (aistate) 1))
86            (let ((newx (- (with_object dest (x)) (/ (* (- (with_object dest (x)) (x)) (aistate)) (aitype))))
87                  (newy (- (with_object dest (y)) (/ (* (- (with_object dest (y)) (y)) (aistate)) (aitype)))))
88              (with_object mover
89                           (progn
90                             (platform_push (- newx (x)) (- newy (y)))
91                             (set_x newx)
92                             (set_y newy)))))))
93    nil)
94  T)
95*/
96
97(defun mover_cons () (set_aitype 20))
98
99
100/*  // compiled C
101(defun respawn_ai ()
102  (let ((x (total_objects)))
103    (if (eq x 0)                           ; if not linked to anything return
104        T
105      (let ((last (get_object (- x 1))))   ; see if the last object has the same position as us
106        (if (and (eq (with_object last (x)) (x)) (eq (with_object last (y)) (y)))
107            (if (eq (aistate) 1)                       
108                (if (eq (with_object last (fade_count)) 0)
109                    (set_aistate 1)
110                  (with_object last (set_fade_count (- (with_object last (fade_count)) 1))))
111              T)                          ; if so then return
112          (if (eq (aistate) 1)
113              (set_aistate 0)
114            (if (> (state_time) (xvel))
115                (let ((new (add_object (with_object (get_object (random x)) (otype)) (x) (y))))
116                  (with_object new (set_fade_count 15))   ; make faded out so we can fade it in
117                  (link_object new)
118                  (set_aistate 1))
119              T))))))
120  T)
121*/
122
123
124(defun respwan_cons () (set_xvel 50))
125
126
127(def_char RESPAWN
128  (funs (ai_fun      respawn_ai)
129        (draw_fun    dev_draw) 
130        (constructor respwan_cons))
131;  (flags (unlistable T))
132  (fields ("xvel" respawn_reg))
133  (range 100 100)
134  (states "art/misc.spe"
135          (stopped           "respawn")))
136
137
138
139(def_char MARKER
140  (funs (ai_fun   do_nothing)
141        (draw_fun dev_draw))
142  (states "art/misc.spe" (stopped "marker")))
143
Note: See TracBrowser for help on using the repository browser.