home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Today (BR) Volume 2 #6 / CDRTV2N6.iso / games / abuse / disk2.dat / LISP / DUONG.LSP < prev    next >
Lisp/Scheme  |  1996-02-15  |  11KB  |  419 lines

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licensing information for more details on usage rights
  3.        
  4.  
  5. (defun mine_ai ()
  6.   (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
  7.       (select (aistate)
  8.           (0 (if (touching_bg)
  9.              (progn (set_state running)
  10.                 (if (eq (xvel) 1)
  11.                 (progn
  12.                   (with_object (bg)
  13.                            (make_view_solid (find_rgb 250 10 10)))
  14.                   (hurt_radius (x) (y) 40 35 nil 20))
  15.                   (hurt_radius (x) (y) 40 25 nil 20))
  16.                 (go_state 1))
  17.            (next_picture))
  18.            T)
  19.           (1 (next_picture)))
  20.     T))
  21.  
  22.  
  23.  
  24.  
  25. (def_char CONC
  26.   (funs (ai_fun  mine_ai))
  27.   (fields  ("xvel" conc_flash))
  28.   (states "art/chars/mine.spe"
  29.       (running   (seq "mine" 1 8))
  30.       (stopped    '("mine0001.pcx" "mine_off"))))
  31.  
  32.  
  33.  
  34. (defun air_mine_ai ()
  35.   (if (or (eq (total_objects) 0)                                 ;; turned on?
  36.       (not (eq (with_object (get_object 0) (aistate)) 0)))
  37.  
  38.       (if (touching_bg)
  39.       (progn
  40.         (if (eq (xvel) 1)
  41.         (with_object (bg) (make_view_solid (find_rgb 250 10 10))))
  42.         (do_explo 40 25)
  43.         nil)
  44.     (progn (next_picture)
  45.            T))
  46.     T))
  47.  
  48. (def_char CONC_AIR
  49.   (funs (ai_fun  air_mine_ai))
  50.   (fields  ("xvel" conc_flash))
  51.   (states "art/chars/mine.spe"
  52.       (stopped   (seq "amin" 1 2))))
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. (defun bomb_cons ()
  60.   (setq blink_time 14))
  61.  
  62. (defun bomb_ai ()
  63.   (select (aistate)
  64.       (0 ;; wait for a signal if connected, or wait for player touch
  65.        (if (activated)
  66.            (go_state 1)
  67.          T))
  68.  
  69.       (1 ;; count down blink time until zero then blow up
  70.        (if (< blink_time 1)
  71.            (go_state 2)
  72.          (progn
  73.            (if (or (< blink_time 10)
  74.                (and (< blink_time 18) (eq (mod blink_time 2) 0))
  75.                (and (< blink_time 30) (eq (mod blink_time 3) 0))
  76.                (and (< blink_time 50) (eq (mod blink_time 4) 0)))
  77.            (progn
  78.              (play_sound TICK_SND 127 (x) (y))
  79.              (next_picture)))
  80.            (setq blink_time (- blink_time 1))
  81.            T)))
  82.  
  83.       (2 ;; blow up
  84.        (let ((oldy (y)))
  85.          (set_y (- (y) (/ (picture_height) 2)))
  86.          (do_explo 40 (get_ability jump_yvel))
  87.          (if (> (get_ability jump_yvel) 100)
  88.          (add_object EXPLODE1 (+ (x) (random 10)) (+ (+ (random 10) (y)) -20)     0))
  89.          (set_y oldy))
  90.        nil)))
  91.   
  92.       
  93.                  
  94. (def_char BOMB
  95.   (funs (ai_fun      bomb_ai)
  96.     (constructor bomb_cons))
  97.   (abilities (jump_yvel 30))
  98.   (range 150 150)
  99.   (vars blink_time)
  100.   (fields ("blink_time" bomb_blink))
  101.   (states "art/chars/mine.spe"
  102.       (stopped '("abomb0001.pcx" "abomb0002.pcx"))))
  103.  
  104. (def_char BIG_BOMB
  105.   (funs (ai_fun      bomb_ai)
  106.     (constructor bomb_cons))
  107.   (abilities (jump_yvel 400))
  108.   (range 150 150)
  109.   (vars blink_time)
  110.   (fields ("blink_time" bomb_blink))
  111.   (states "art/chars/mine.spe"
  112.       (stopped '("abomb0001.pcx+" "abomb0002.pcx+"))))
  113.       
  114.  
  115.  
  116.  
  117. (defun block_ai ()
  118.   (if (<= (hp) 0)
  119.       (if (eq (state) dieing)
  120.       (next_picture)
  121.     (progn
  122.       (play_sound CRUMBLE_SND 127 (x) (y))
  123.       (set_state dieing)
  124.       T))
  125.     T))
  126.  
  127. (def_char BLOCK
  128.                     ;block has only 1 frame now will have block blowing up
  129.   (funs (ai_fun  block_ai))
  130.   (flags (can_block T)
  131.      (hurtable  T))
  132.   (abilities (start_hp 30))
  133.   (states "art/chars/block.spe"
  134.       (stopped       "block.pcx")
  135.       (dieing        (seq "bexplo" 1 7))))
  136.  
  137.  
  138. (defun trap_door_ai ()
  139.   (if (> (total_objects) 0)
  140.       (select (aistate)
  141.           (0 ;; wait for switch to go off
  142.            (if (not (eq (with_object (get_object 0) (aistate)) 0))
  143.            (progn 
  144.              (set_state running)
  145.              (go_state 1))))
  146.           (1 ;; wait for animation
  147.            (if (next_picture) T
  148.          (progn
  149.            (set_state blocking)
  150.            (set_aistate 2))))
  151.           (2 ;; just stay here 
  152.            T)))
  153. T)
  154.       
  155.  
  156. (defun strap_door_ai ()
  157.   (general_sdoor_ai nil))
  158.  
  159.  
  160. (def_char TRAP_DOOR2
  161.   (funs (ai_fun strap_door_ai))
  162.   (flags (can_block T))
  163.   (abilities (start_hp 30))
  164.   (states "art/chars/tdoor.spe"
  165.       (stopped        "tdor0001.pcx")
  166.       (running        (seq "tdor" 1 7))
  167.       (walking        (seq "tdor" 7 1))
  168.       (blocking       "tdor0007.pcx")))
  169.  
  170.  
  171. (def_char TRAP_DOOR3
  172.   (funs (ai_fun strap_door_ai))
  173.   (flags (can_block T))
  174.   (abilities (start_hp 30))
  175.   (states "art/chars/tdoor.spe"
  176.           (stopped        "cdor0001.pcx")
  177.           (running        (seq "cdor" 1 7))
  178.           (walking        (seq "cdor" 7 1))
  179.           (blocking       "cdor0007.pcx")))
  180.  
  181. (defun lightin_ai ()
  182.   (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
  183.       (select (aistate)
  184.           (0  ;; delay
  185.            (if (< (state_time) (* (aitype) 2)) (set_state stopped)
  186.          (progn
  187.                     ;         (hurt_radius (x) (y) 40 30 nil 30)
  188.            (set_state running)
  189.            (play_sound ELECTRIC_SND 127 (x) (y))
  190.            (go_state 1))))
  191.           (1  ;; next picture
  192.            (if (next_picture) T
  193.          (set_aistate 0)))))
  194. T)
  195.  
  196. (def_char LIGHTIN
  197.   (funs (ai_fun lightin_ai))
  198.   (flags (can_block T))
  199.   (fields  ("aitype" lightin_speed))
  200.   (states "art/chars/lightin.spe"
  201.       (running   (seq "lite" 1 9))
  202.       (stopped    "lite0001.pcx")))
  203.       
  204.  
  205.  
  206. (defun lava_ai ()
  207.   (if (and (touching_bg) (eq (mod (state_time) 20) 0))
  208.       (do_damage 6 (bg)))
  209.  
  210.   (select (aistate)
  211.       (0 (if (eq (random 100) 0)
  212.          (progn
  213.            (play_sound LAVA_SND 64 (x) (y))
  214.            (set_aistate 1)))
  215.          (next_picture))
  216.       (1 (next_picture)
  217.          (if (eq (state_time) 5)
  218.          (progn
  219.            (hurt_radius (x) (y) 20 20 nil 10)
  220.            (set_aistate 0)))))
  221.   T)
  222.  
  223.  
  224. (def_char LAVA
  225.   (funs (ai_fun lava_ai))
  226.   (states  "art/chars/lava.spe"
  227.        (stopped (seq "lava" 1 15))))
  228.  
  229.  
  230. (defun tp2_ai ()
  231.   (if (> (total_objects) 0)
  232.       (select (aistate)
  233.           (0 ;; wait for player to activate
  234.            (if (and (touching_bg) (eq (total_objects) 1))
  235.            (progn
  236.              (if (with_object (bg) (pressing_action_key))
  237.              (progn
  238.                (link_object (bg))
  239.                (set_state running)
  240.                (play_sound TELEPORTER_SND 127 (x) (y))
  241.                (set_aistate 1))))))
  242.           (1 ;; wait for animation
  243.            (if (next_picture)
  244.            (let ((x (x))
  245.              (y (- (y) 16))
  246.              (fade (if (< (current_frame) 16) (current_frame) 15)))
  247.              (with_object (get_object 1) 
  248.                   (progn
  249.                     (set_x x) 
  250.                     (set_y y) 
  251.                     (user_fun SET_FADE_COUNT fade)
  252.                     (setq is_teleporting 1)
  253.                     )))
  254.                   
  255.          (let ((x (with_object (get_object 0) (x)))
  256.                (y (with_object (get_object 0) (- (y) 16))))           
  257.            (with_object (get_object 1)
  258.                 (progn 
  259.                   (set_x x)
  260.                   (set_y y)
  261.                   (setq is_teleporting 0)
  262.                   (user_fun SET_FADE_COUNT 0)
  263.                   ))
  264.            (remove_object (get_object 1))
  265.            (set_aistate 0))))))
  266.   T)
  267.          
  268.                
  269.  
  270. (def_char TELE2
  271.   (funs  (ai_fun tp2_ai))
  272.   (flags (can_block  T))
  273.   (states "art/chars/teleport.spe"
  274.       (stopped "close")
  275.       (running (seq "elec" 1 15))))
  276.      
  277.  
  278. (defun bolder_ai ()
  279.   (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
  280.       (if (eq (hp) 0)
  281.       (progn
  282.         (play_sound P_EXPLODE_SND 127 (x) (y))
  283.         (add_object EXPLODE1 (+ (x) (random 5)) (+ (y) (random 5)) 0)
  284.         (add_object EXPLODE1 (+ (x) (random 5)) (+ (y) (random 5)) 2)
  285.         (add_object EXPLODE1 (- (x) (random 5)) (- (y) (random 5)) 1)
  286.         (add_object EXPLODE1 (- (x) (random 5)) (- (y) (random 5)) 2)
  287.         (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel -4) (set_yvel -8)))
  288.         (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel 4) (set_yvel -9)))
  289.         (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel 2) (set_yvel -5)))
  290.         (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel -3) (set_yvel -5)))
  291.         (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel -1) (set_yvel 2)))
  292.         (add_object EXP_LIGHT (x) (y) 100)
  293.         nil)
  294.     (progn
  295.       (next_picture)
  296.       (set_yvel (+ (yvel) 1))      
  297.       (let ((old_yv  (yvel))
  298.         (old_xv  (xvel))
  299.         (old_x   (x))
  300.         (old_y   (y))
  301.         (status (float_tick)))
  302.  
  303.         (let ((new_x (x))
  304.           (new_y (y))
  305.           (set_x old_x)
  306.           (set_y old_y))
  307.           (platform_push (- new_x (x)) (- new_y (y)))
  308.           (set_x new_x)
  309.           (set_y new_y))
  310.         (hurt_radius (x) (y) 19 30 (me) 15)
  311.         (if (not (eq status T));; T means we did not hit anything    
  312.         (let ((block_flags (car status)))
  313.           (if (or (blocked_up block_flags) (blocked_down block_flags));; bounce up/down
  314.               (progn
  315.             (if (> (abs old_yv) 3)
  316.                 (play_sound SBALL_SND 127 (x) (y)))
  317.             (set_xvel old_xv)
  318.             (if (> old_yv 1)
  319.                 (set_yvel (- 2 old_yv))
  320.               (set_yvel (- 0 old_yv))))
  321.             (if (or (blocked_left block_flags) (blocked_right block_flags));; bounce left/right
  322.             (progn
  323.               (set_yvel old_yv)
  324.               (set_xvel (- 0 old_xv))))))))
  325.       T))
  326.     T))
  327.   
  328.  
  329. (defun bolder_cons ()
  330.   (set_xvel -4)
  331.   (set_yvel 0))
  332.  
  333.  
  334. (defun bold_dam (amount from hitx hity push_xvel push_yvel) 
  335.   (add_object EXPLODE3 (+ (x) (- 10 (random 20))) (- (y) (random 30)) 0)
  336.   (damage_fun amount from hitx hity (/ push_xvel 10) (/ push_yvel 2)))
  337.  
  338. (def_char BOLDER
  339.   (funs  (ai_fun bolder_ai)
  340.      (damage_fun bold_dam)
  341.      (constructor bolder_cons))
  342.   (flags (can_block  T)
  343.      (add_front  T)
  344.      (hurtable   T))
  345.   (range 200 200)
  346.   (abilities (start_hp 40))
  347.   (fields ("xvel" ai_xvel)      
  348.       ("yvel" ai_yvel)
  349.       ("hp"   ai_health)
  350.       )
  351.   (states "art/bold.spe"
  352.       (stopped '("bold0001.pcx" "bold0001.pcx" "bold0001.pcx" 
  353.             "bold0002.pcx" "bold0002.pcx" "bold0002.pcx"
  354.             "bold0003.pcx" "bold0003.pcx" "bold0003.pcx"
  355.             "bold0004.pcx" "bold0004.pcx" "bold0004.pcx"))))
  356.  
  357. (defun bounce_move (left_stub right_stub up_stub down_stub nothing_stub)
  358.   (let ((old_yv  (yvel))
  359.     (old_xv  (xvel))
  360.     (status (float_tick)))
  361.     (if (not (eq status T)) ;; T means we did not hit anything    
  362.     (let ((block_flags (car status)))            
  363.       (if (blocked_up block_flags) ;; bounce up/down
  364.           (progn
  365.         (set_xvel old_xv)
  366.         (if (> old_yv 1)
  367.             (set_yvel (- 2 old_yv))
  368.           (set_yvel (- 0 old_yv)))
  369.         (eval up_stub))
  370.         (if (blocked_down block_flags)
  371.         (progn
  372.           (set_xvel old_xv)
  373.           (if (> old_yv 1)
  374.               (set_yvel (- 2 old_yv))
  375.             (set_yvel (- 0 old_yv)))
  376.           (eval down_stub))
  377.           (if (blocked_left block_flags)
  378.           (progn
  379.             (set_yvel old_yv)
  380.             (set_xvel (- 0 old_xv))
  381.             (eval left_stub))
  382.         (if (blocked_right block_flags)
  383.             (progn
  384.               (set_yvel old_yv)
  385.               (set_xvel (- 0 old_xv))
  386.               (eval right_stub)))))))
  387.       (eval nothing_stub))))
  388.           
  389.  
  390.  
  391. (defun small_rock_ai ()
  392.   (next_picture)
  393.   (set_yvel (+ (yvel) 1))
  394.   (bounce_move T T T            
  395.            '(progn (add_object EXPLODE1 (+ (x) (random 10)) (- (+ (random 5) (y)) 10)     0)               
  396.          (add_object EXPLODE1 (- (x) (random 10)) (- (- (y) (random 5)) 10) 2)
  397.          (play_sound P_EXPLODE_SND 127 (x) (y))
  398.          (hurt_radius (x) (y) 40 15 (if (> (total_objects) 0)
  399.                         (get_object 0)
  400.                           nil) 20)
  401.          nil) T))
  402.   
  403.  
  404. (def_char SMALL_BOLDER
  405.   (funs  (ai_fun small_rock_ai))
  406.  
  407.   (flags (add_front  T)
  408.      (unlistable T))
  409.     
  410.   (states "art/bold.spe"
  411.       (stopped "bsmall")))
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.