home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer 13 / 1995-12_Disc_13.iso / abuse / lisp / jugger.lsp < prev    next >
Lisp/Scheme  |  1995-08-31  |  8KB  |  296 lines

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licencing information for more details on usage rights
  3.  
  4. (defun jug_ai ()
  5.   (if (<= (hp) 0)
  6.       (if (eq (state) dieing)
  7.       (next_picture)
  8.     (set_state dieing))
  9.     (if (activated)
  10.     (progn       
  11.       (set_targetable T)
  12.       (push_char 35 40)
  13.       (select (aistate) 
  14.           (0 ;; prepare to walk toward player
  15.            (if (eq stationary 0)
  16.                (progn
  17.              (set_state running)
  18.              (go_state 1))
  19.              (if (> (state_time) (aitype))
  20.              (progn
  21.                (set_state weapon_fire)
  22.                (set_aistate 2)))))
  23.  
  24.           (1 ;; walk toward player
  25.            (if (eq stationary 0)
  26.                (progn
  27.              (set_direction (toward))
  28.              (let ((curx (x));; save position in case we fall off a cliff
  29.                    (cury (y)))             
  30.                (if (next_picture) 
  31.                    (if (eq (current_frame) 8)
  32.                    (play_sound JSTOMP_SND 127 (x) (y)))
  33.                  (progn
  34.                    (play_sound JSTOMP_SND 127 (x) (y))
  35.                    (set_state weapon_fire)
  36.                    (set_aistate 2)))
  37.                (if (can_see (x) (y) (x) (+ (y) 5) nil)
  38.                    (progn
  39.                  (set_x curx)
  40.                  (set_y cury)
  41.                  (try_move 0 10)))))
  42.              (if (> (state_time) (aitype))
  43.              (progn
  44.                (set_state weapon_fire)
  45.                (set_aistate 2)))))
  46.  
  47.           (2 ;; start fire
  48.            (if (> (state_time) 3)
  49.                (let ((myself (me))
  50.                  (xspeed (* throw_xvel (direction)))
  51.                  (yspeed throw_yvel))
  52.              (with_object (add_object GRENADE (x) (- (y) 24) 1) 
  53.                       (progn
  54.                     (user_fun myself)
  55.                     (set_xvel xspeed)
  56.                     (set_yvel yspeed)))
  57.              (go_state 3))
  58.              (next_picture)))
  59.           (3 ;; wait for fire animation
  60.            (if (next_picture) nil (set_aistate 0))))
  61.       T) 
  62.       (progn (set_targetable nil)
  63.          T))))
  64.        
  65. (defun jug_cons ()
  66.   (setq throw_xvel 13)
  67.   (setq throw_yvel -10)
  68.   (set_aitype 10))
  69.  
  70. (def_char JUGGER
  71.   (range 200 0)
  72.   (funs (ai_fun     jug_ai)
  73.     (constructor jug_cons)
  74.     (damage_fun explo_damage))
  75.   (flags (hurtable T))
  76.   (abilities (start_hp    50)
  77.          (push_xrange 1))
  78.   (vars throw_xvel throw_yvel stationary)
  79.   (fields ("hp" "hp")
  80.       ("aitype" "throw speed (0..255)")
  81.       ("throw_xvel" "throw xvel")
  82.       ("throw_yvel" "throw yvel")
  83.       ("stationary"   "stationary? (1=yes,0=no)")
  84.       ("aistate" "aistate"))
  85.  
  86.   (states "art/jug.spe" 
  87.       (stopped "robo0001.pcx")
  88.       (running (seq "rwlk" 1 13))
  89.       (weapon_fire (seq "robo" 1 10))
  90.       (dieing (seq "jugdie" 1 8))))
  91.  
  92. ;; AI for cleaner robot machine "ROB1"
  93. ;; The robot waits for a sensor/switch/gate to turn it
  94. ;; on before appearing
  95. (defun rob1_ai ()
  96.   (if (not (eq (fade_count) 0))             ;; appearing?
  97.       (set_fade_count (- (fade_count) 1)))  ;; fade in
  98.   (select (aistate)
  99.       (0 ;; wait for sensor to turn on
  100.        (if (eq rob_hiden 1)
  101.            (progn
  102.          (set_targetable nil)       ;; can't lock into us while hiden
  103.          (set_state rob_hiding))    ;; set invisible animation frame
  104.          (progn
  105.            (set_targetable T)           ;; can lock into us
  106.            (push_char 30 55)))          ;; push player away
  107.        
  108.        (if (or (< (total_objects) 1)    ;; if not linked or link is on
  109.            (not (eq (with_object (get_object 0) (aistate)) 0)))
  110.            (progn
  111.          (if (eq rob_hiden 1)
  112.              (set_fade_count 15))
  113.          (set_aistate 1)))
  114.        T)
  115.       (1 ;; walk towards player
  116.        (push_char 30 55)                      ;; push her back
  117.        (next_picture)                         ;; go to next animation frame
  118.        (if (eq (mod (state_time) 6) 0)        ;; play sound every 6 ticks
  119.            (play_sound CLEANER_SND 127 (x) (y)))
  120.        (try_move 0 10)                        ;; see how far ahead we can move
  121.        (if (> (direction) 0)                  ;; moving right
  122.            (if (can_see (x) (y) (+ (x) (xvel) 23) (y) nil)   ;; can we see 23 pixels ahead?
  123.              (set_x (+ (x) (xvel))))
  124.          (if (can_see (x) (y) (- (x) (xvel) 23) (y) nil)
  125.            (set_x (- (x) (xvel)))))
  126.  
  127.        (if (<= (hp) 0)                        ;; are we dead, if so blow up
  128.            (progn    
  129.          (add_object EXPLODE1 (+ (x) 5) (- (y) 10)     0)  
  130.          (add_object EXPLODE1 (+ (x) -5) (- (y) 15)    2)  ;; wait 2 frames before appearing
  131.          (add_object EXPLODE1 (+ (x) 10) (- (y) 2)     1)
  132.          (add_object EXPLODE1 (+ (x) -10) (- (y) 20)   3)
  133.          (add_object EXPLODE1 (+ (x) 20) (- (y) 27)    4)
  134.          (add_object EXPLODE1 (+ (x) -25) (- (y) 30)   2)
  135.          (add_object EXPLODE1 (+ (x) 20) (- (y) 5)     4)
  136.          (add_object EXPLODE1 (+ (x) -3) (- (y) 1)     5)
  137.          (set_aistate 2)))
  138.        T)
  139.       (2 ;; dead, wait a few frames then return nil
  140.        (push_char 30 55)
  141.        (< (state_time) 3))))  ;; return nil (dead) if we've been in this state for 3 frames
  142.       
  143.              
  144.  
  145. (defun explo_damage (amount from hitx hity push_xvel push_yvel)   
  146.   (add_object EXPLODE6 (+ (x) (- 10 (random 20))) (- (y) (random 30))     0)
  147.   (damage_fun amount from hitx hity 0 0)
  148.   (if (eq 0 (hp))
  149.       (play_sound BLOWN_UP 127 (x) (y))))
  150.  
  151. (defun rob_cons () (set_xvel 2))
  152.  
  153. (def_char ROB1
  154.   (range 200 0)
  155.   (funs (ai_fun     rob1_ai)
  156.     (constructor rob_cons)
  157.     (damage_fun explo_damage))
  158.   (flags (hurtable T)
  159.      (can_block T))
  160.   (abilities (run_top_speed 4)         
  161.          (start_hp      70)
  162.          (push_xrange   1))
  163.   (vars rob_hiden)
  164.   (fields ("xvel" "xvel")
  165.       ("aitype" "no turn around (1=on)")
  166.       ("rob_hiden"        "hiden start (1=hiden,0=visable)")
  167.       ("hp"     "health"))
  168.   (states "art/rob1.spe" 
  169.       (rob_hiding             "hiding")
  170.       (stopped (seq "clen" 1 10))))
  171.  
  172. (defun who_ai ()
  173.   (if (eq (hp) 0)
  174.       nil
  175.     (progn
  176.       (set_xvel (+ (xvel) (* (+ (mod (state_time) 10) -4) (direction))))
  177.       (if (< (xvel) -15) (set_xvel -15))
  178.       (if (> (xvel) 15) (set_xvel 15))
  179.       (if (not (next_picture)) (set_state stopped))
  180.       (bounce_move '(progn
  181.               (set_direction (- 0 (direction)))
  182.               (set_state turn_around))
  183.            '(progn
  184.               (set_direction (- 0 (direction)))
  185.               (set_state turn_around))
  186.            nil nil nil)
  187.       T)))
  188.   
  189.  
  190. (def_char WHO
  191.   (range 200 100)
  192.   (funs (ai_fun flyer_ai)
  193.     (damage_fun  flyer_damage)
  194.     (constructor flyer_cons))
  195.  
  196.   (flags (hurtable T))
  197.   (abilities (start_hp 20))
  198.   (vars fire_delay burst_delay burst_total burst_wait burst_left 
  199.     max_xvel   max_yvel    smoke_time fire_time)
  200.   (fields ("fire_delay" "fire_delay")
  201.       ("burst_delay" "burst_delay")
  202.       ("burst_total" "burst_total")
  203.       ("max_xvel"    "max_xvel")
  204.       ("max_yvel"    "max_yvel")
  205.       ("hp" "hp")
  206.       ("aistate" "aistate"))
  207.  
  208.   (states "art/rob2.spe" 
  209.       (stopped (seq "wgo" 1 3))
  210.       (running (seq "wgo" 1 3))
  211.       (turn_around (seq "wtrn" 1 9))
  212.       (flinch_up  '("flinch" "flinch" "flinch"))
  213.       ))
  214.  
  215.  
  216. /*   --- not working
  217. (defun burst_fire (firex firey angle)
  218.   (if (> fire_time 0);; if we need to wait till next burst
  219.       (progn
  220.     (setq fire_time (- fire_time 1))
  221.     (if (eq fire_time 0)
  222.         (progn 
  223.           (setq burst_left burst_total)
  224.           (setq burst_wait 0))))
  225.     (if (eq burst_wait 0)
  226.     (progn
  227.       (if (or (eq burst_left 1) (eq burst_left 0))
  228.           (setq fire_time fire_delay)
  229.         (setq burst_left (- burst_left 1)))
  230.       (setq burst_wait burst_delay)
  231.       (fire_object (me) (aitype) firex firey angle (bg)))
  232.       (setq burst_wait (- burst_wait 1)))))
  233.  
  234.  
  235. (defun wrob_cons ()      
  236.   (setq fire_delay 4)
  237.   (setq burst_delay 1)
  238.   (setq max_xvel 10)
  239.   (setq max_yvel 5)
  240.   (set_aitype 0)
  241.   (setq burst_total 5))
  242.  
  243.  
  244. (defun wrob_ai ()
  245.   (if (eq (hp) 0)
  246.       nil
  247.     (progn
  248.       (select (aistate)
  249.           (0;; walk toward player
  250.            (if (or (> (distx) 120) (not (eq (direction) (toward))))
  251.            (progn
  252.              (move (toward) 0 0)
  253.              (next_picture))
  254.          (progn
  255.            (set_state stopped)
  256.            (set_aistate 1))))
  257.           (1;; stop and fire
  258.            (burst_fire  (+ (x) (* (direction) 28)) (- (y) 35)              
  259.                 (if (> (direction) 0)
  260.                 (mod (- 375 (/ (* burst_left 30) burst_total)) 360)
  261.                   (+ 165 (/ (* burst_left 30) burst_total))))
  262.            (if (not (eq fire_time 0))
  263.            (set_aistate 0))))
  264.       T)))
  265.           
  266.     
  267.  
  268.  
  269. (def_char WALK_ROB
  270.   (funs (ai_fun wrob_ai)
  271.     (constructor wrob_cons)    
  272.     (damage_fun  guner_damage))
  273.   (abilities (run_top_speed 12))
  274.   (flags (hurtable T) (can_block T))
  275.   (range 300 100)
  276.   (vars fire_delay burst_delay burst_total burst_wait burst_left 
  277.     max_xvel   max_yvel    smoke_time fire_time)
  278.   (fields ("fire_delay" "fire_delay")
  279.       ("burst_delay" "burst_delay")
  280.       ("burst_total" "burst_total")
  281.       ("max_xvel"    "max_xvel")
  282.       ("max_yvel"    "max_yvel")
  283.       ("hp" "hp")
  284.       ("aistate" "aistate"))
  285.  
  286.   (states "art/rob2.spe" 
  287.       (stopped "wwlk0001.pcx")
  288.       (running (seq "wwlk" 1 10))
  289.       (start_run_jump "wstart_jump")
  290.       (flinch_up      "wflinch")
  291.       (run_jump       "wwlk0009.pcx")
  292.       ))
  293.  
  294.  
  295.  
  296. */