home *** CD-ROM | disk | FTP | other *** search
/ Bila Vrana / BILA_VRANA.iso / 010A / ABUSE.ZIP / LISP / GUNS.LSP < prev    next >
Lisp/Scheme  |  1996-02-15  |  12KB  |  435 lines

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licensing information for more details on usage rights
  3.  
  4.  
  5. (setq gun_tints (make-array 11 :initial-contents (list 
  6.                           normal_tint
  7.                           (def_tint "art/tints/guns/orange.spe") ; orange
  8.                           (def_tint "art/tints/guns/green.spe")  ; grenade
  9.                           (def_tint "art/tints/guns/redish.spe") ; rocket
  10.                           (def_tint "art/tints/guns/blue.spe")   ; plasma
  11.                           normal_tint
  12.                           normal_tint
  13.                           normal_tint
  14.                           normal_tint
  15.                           normal_tint
  16.                           normal_tint)))
  17.  
  18.  
  19. (setq ai_ammo (make-array 9 :initial-contents (list MBULLET_ICON5 
  20.                         MBULLET_ICON5 
  21.                         GRENADE_ICON2
  22.                         ROCKET_ICON2 
  23.                         PLASMA_ICON20
  24.                         MBULLET_ICON5 
  25.                         MBULLET_ICON5 
  26.                         MBULLET_ICON5 
  27.                         MBULLET_ICON5)))
  28.  
  29. (defun aitype_to_ammo (aitype)
  30.   (aref ai_ammo aitype))
  31.  
  32.  
  33.  
  34. (defun fire_object (creator type x y angle target)
  35.   (select type
  36.  
  37.       (0 (with_object (add_object SHOTGUN_BULLET x y)
  38.                       (progn
  39.                     (play_sound ZAP_SND 127 (x) (y))
  40.                     (setq sgb_lifetime 6)
  41.                     (setq sgb_speed 15)
  42.                     (setq sgb_lastx (x))
  43.                     (setq sgb_lasty (y))
  44.                     (setq sgb_angle angle)
  45.                     (setq sgb_bright_color (find_rgb 255 255 200))
  46.                     (setq sgb_medium_color (find_rgb 150 150 0))
  47.                     (if creator 
  48.                         (progn
  49.                           (setq sgb_speed (+ sgb_speed (/ (xvel) 2)))
  50.                           (link_object creator)))
  51.                     (sgun_ai)
  52.                     )))
  53.       (1 (with_object (add_object SHOTGUN_BULLET x y)
  54.                       (progn
  55.                     (play_sound ZAP_SND 127 (x) (y))
  56.                     (setq sgb_lifetime 40)
  57.                     (setq sgb_speed 6)
  58.                     (setq sgb_lastx (x))
  59.                     (setq sgb_lasty (y))
  60.                     (setq sgb_angle angle)
  61.                     
  62.                     (setq sgb_bright_color (find_rgb 255 128 64))
  63.                     (setq sgb_medium_color (find_rgb 255 0 0))
  64.                     (if creator 
  65.                         (progn
  66.                           (setq sgb_speed (+ sgb_speed (/ (xvel) 2)))
  67.                           (link_object creator)))
  68.                     (sgun_ai)
  69.                     )))
  70.       (2 (with_object (add_object GRENADE x y)
  71.               (progn
  72.                 (play_sound GRENADE_THROW 127 x y)
  73.                 (set_course angle 20)
  74.                 (if creator    
  75.                 (progn
  76.                   (link_object creator)
  77.                   (set_xvel (+ (xvel) (with_object creator (xvel))))
  78.                   (set_yvel (+ (yvel) (with_object creator (yvel))))
  79.                   ))
  80.                 
  81.                 (set_frame_angle 0 359 angle)
  82.                 )))
  83.       (3 (with_object (add_object ROCKET x y)
  84.               (progn
  85.                 (play_sound ROCKET_LAUNCH_SND 127 x y)
  86.                 (set_aistate angle)
  87.                 (if creator    (link_object creator))
  88.  
  89.                 (if (and target   ;; don't link if not in line of site
  90.                      (can_see (x) (y) 
  91.                           (with_object target (x))
  92.                           (with_object target (y)) nil))
  93.                           (link_object target))
  94.  
  95.                 (set_frame_angle 0 359 angle)
  96.                 (setq speed 5)
  97.                 (if (and creator (with_object creator (isa_player)))
  98.                 (setq max_speed 14)
  99.                   (setq max_speed 10))
  100.                 (set_y (+ (y) (/ (picture_height) 2)))  ;; move down to match frame/pos
  101.                 )))
  102.  
  103.       (4 (with_object (add_object PLASMAGUN_BULLET x y)
  104.                       (progn
  105.                     (play_sound PLASMA_SND 127 (x) (y))
  106.                     (setq sgb_lastx (x))
  107.                     (setq sgb_lasty (y))
  108.                     (if creator 
  109.                           (link_object creator))
  110.                     (set_course angle 200)
  111.                     (let ((old_x (x))
  112.                           (old_y (y))
  113.                           (bx (bmove (if (> (total_objects) 0) (get_object 0) nil))))
  114.                       (if (not (eq bx T))
  115.                           (if (eq bx nil)
  116.                           (add_object EXPLODE5 (- (x) (random 5)) 
  117.                                   (- (y) (random 5)) 0)
  118.                         (progn
  119.                           (add_object EXPLODE3 (- (x) (random 5)) 
  120.                                   (- (y) (random 5)) 0)
  121.                           (do_damage 10 bx (* (cos sgb_angle) 20) 
  122.                                  (* (sin sgb_angle) 10)))))
  123.                       (setq sgb_lastx (x))
  124.                       (setq sgb_lasty (y))
  125.                       (set_x old_x)
  126.                       (set_y old_y))
  127.                     )))
  128.  
  129.  
  130.       (5 (with_object (add_object FIREBOMB x y)
  131.               (progn
  132.                 (play_sound FIREBOMB_SND 127 (x) (y))
  133.                 (set_course angle 20)
  134.                 (if creator    
  135.                 (progn
  136.                   (link_object creator)
  137.                   (set_yvel (+ (yvel) (with_object creator (yvel))))
  138.                   )))))
  139.  
  140.       (6 (with_object (add_object DFRIS_BULLET x y)
  141.                       (progn
  142.                     (play_sound ROCKET_LAUNCH_SND 127 x y)
  143.                     (set_course angle 25)
  144.                     (set_aistate angle)
  145.                     (if creator 
  146.                           (link_object creator))
  147.                     (dfris_ai)
  148.                     )))
  149.  
  150.       (7 (with_object (add_object LSABER_BULLET x y)
  151.                       (progn
  152.                     (play_sound LSABER_SND 127 (x) (y))
  153.                     (setq sgb_lastx (x))
  154.                     (setq sgb_lasty (y))
  155.                     (if creator 
  156.                           (link_object creator))
  157.                     (set_course angle 45)
  158.                     (let ((bx (bmove (if (> (total_objects) 0) (get_object 0) nil))))
  159.                       (if (not (eq bx T))
  160.                           (if (not (eq bx nil))
  161.                           (do_damage 30 bx (* (cos sgb_angle) 20) 
  162.                                  (* (sin sgb_angle) 10)))))
  163.                     )))
  164.                
  165.  
  166.       (9 (with_object (add_object STRAIT_ROCKET x y)
  167.                       (progn
  168.                     (play_sound MGUN_SND 127 (x) (y))
  169.                     (if creator 
  170.                           (link_object creator))
  171.                     (set_aistate angle)
  172.                     (set_frame_angle 0 359 angle)
  173.                     (play_sound GRENADE_THROW 127 (x) (y)))))
  174.  
  175.       (10 (with_object (add_object SHOTGUN_BULLET x y)
  176.                       (progn
  177.                     (play_sound ZAP_SND 127 (x) (y))
  178.                     (setq sgb_lifetime 6)
  179.                     (setq sgb_speed 15)
  180.                     (setq sgb_lastx (x))
  181.                     (setq sgb_lasty (y))
  182.                     (setq sgb_angle angle)
  183.                     (setq sgb_bright_color (find_rgb 255 0 0))
  184.                     (setq sgb_medium_color (find_rgb 150 0 0))
  185.                     (if creator 
  186.                         (progn
  187.                           (setq sgb_speed (+ sgb_speed (/ (xvel) 2)))
  188.                           (link_object creator)))
  189.                     (sgun_ai)
  190.                     )))
  191.  
  192.       ) 
  193. )
  194.  
  195.  
  196. (defun spray_fire ()
  197.   (fire_object (me) (aitype)
  198.            (+ (x) (* (cos spray.angle) 20))
  199.            (- (- (y) 21) (* (sin spray.angle) 22))
  200.            spray.angle
  201.            (bg)))
  202.  
  203.  
  204. (defun spray_gun_ai ()
  205.   (if (<= (hp) 0)
  206.       nil
  207.     (if (and (< (distx) 450) (< (disty) 400))
  208.     (progn
  209.       (select (aistate)
  210.           (0;; look at sensor
  211.            (if (activated)
  212.                (if (eq (state) stopped)
  213.                (progn
  214.                  (set_targetable T)
  215.                  (set_state spray.appear)
  216.                  (go_state 1))
  217.              (go_state 3))
  218.              (progn
  219.                (set_targetable nil)
  220.                (set_state stopped))))
  221.  
  222.  
  223.           (1;; unfold
  224.            (if (next_picture) T 
  225.              (progn (set_aistate 3)
  226.                 (set_state spray.aim)
  227.                 (setq spray.angle spray.start_angle)
  228.                 (set_frame_angle 0 359 spray.angle)
  229.                 )))
  230.  
  231.           (2;; fold up
  232.            (if (next_picture) T 
  233.              (progn (set_state stopped)
  234.                 (set_aistate 0))))
  235.  
  236.          
  237.           (3;; swivel down
  238.            (if (> (state_time) spray.fire_delay)
  239.                (progn
  240.              (set_aistate 3);; reset state time
  241.              (setq spray.angle (- spray.angle spray.angle_speed))
  242.              (if (<= spray.angle spray.start_angle)
  243.                  (progn
  244.                    (setq spray.angle spray.start_angle)
  245.                    (set_aistate 4)))
  246.              (set_frame_angle 0 359 spray.angle)
  247.              (spray_fire))))
  248.  
  249.           (4;; swivel up
  250.            (if (> (state_time) spray.fire_delay)
  251.                (progn
  252.              (set_aistate 4);; reset state time
  253.              (setq spray.angle (+ spray.angle spray.angle_speed))
  254.              (if (>= spray.angle spray.end_angle)
  255.                  (progn
  256.                    (setq spray.angle spray.end_angle)
  257.                    (set_aistate 0)))
  258.              (set_frame_angle 0 359 spray.angle)
  259.  
  260.              (spray_fire)))))
  261.       T)
  262.       (progn
  263.     (set_state stopped)
  264.     T))))
  265.         
  266.  
  267.           
  268.           
  269.     (defun spray_gun_cons () 
  270.       (setq spray.bullet_speed 20)
  271.       (setq spray.angle_speed  10)
  272.       (setq spray.start_angle  270)
  273.       (setq spray.end_angle    350)
  274.       (setq spray.fire_delay 4))
  275.  
  276. (def_char SPRAY_GUN
  277.   (funs (ai_fun       spray_gun_ai)
  278.     (damage_fun   guner_damage)
  279.     (draw_fun     gun_draw)
  280.     (constructor spray_gun_cons))
  281.  
  282.   (flags (can_block  T)
  283.      (hurtable   T))
  284.   (abilities (start_hp 20)
  285.          )
  286.   (vars spray.fire_delay
  287.     spray.bullet_speed
  288.     spray.start_angle
  289.     spray.end_angle
  290.     spray.angle_speed
  291.     spray.angle)     
  292.  
  293.   (fields ("hp"                 ai_health)
  294.       ("aitype"             ai_type)
  295.       ("spray.fire_delay"   spray_delay)
  296.       ("spray.start_angle"  spray_start)
  297.       ("spray.end_angle"    spray_end)
  298.       ("spray.angle_speed"  spray_speed)
  299.       ("spray.angle"        spray_cangle))
  300.  
  301.   (states "art/gun2.spe"
  302.       (stopped           "stopped")
  303.       (spray.aim         (seq "cspn" 1 24))
  304.       (spray.appear      '("csht0001.pcx" "csht0002.pcx"))
  305.       (spray.disappear   '("csht0002.pcx" "csht0001.pcx"))
  306.       ))
  307.  
  308. (defun gun_draw ()
  309.   (draw_tint (aref gun_tints (aitype))))
  310.  
  311.  
  312. (def_