source: abuse-lib/trunk/lisp/common.lsp @ 72

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