home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 16 / PCGAMER16.bin / text / abuse.txt next >
Text File  |  1995-11-29  |  18KB  |  437 lines

  1. Abuse Levels and the Abuse Engine
  2.  
  3.  
  4. This document has been sabotaged by Ted at PC Gamer.
  5. All acknowlegments to the author, and, of course, to Ruari, the ant
  6. with attitude in Crack Dot Com's wunderfull game.
  7.  
  8. T O'Neill 29/11/95
  9.  
  10.  
  11. Note : these docs are far from finished, have not been edit for spelling/correctness,
  12. but I hope it's enough to get a few people started.  More docs/better will follow
  13. later, but I'm busy with net code right now....
  14.  
  15.             - Jonathan Clark
  16.  
  17.    
  18.   I would like to give a quick over-view of making games with the abuse engine.
  19.   First reasons why you might want to give it a try.
  20.   
  21.     - You can get the shareware version for free and develop at no cost.
  22.  
  23.     - Any code you write is portable and needs no compilation to run on
  24.         other systems.   Currently the engine has been ported to DOS, LINUX!,
  25.         and SGI.  Other UNIX ports are expected and Mac and WIN '95 are being 
  26.         considered.
  27.     - Network code which can be a big pain is already built in.  You can
  28.         make a simple working network game in a day or two.  The engine
  29.         currently supports IPX and TCPIP but will soon have support for modem
  30.         and other network drivers.
  31.     - If the game is fair Crack dot com will include it on their next data
  32.         pack CD and pay you according to it's quality,  but If it 'great' to
  33.         'cool' Crack will market and distribute it individually and pay you
  34.         a percentage of the profits.
  35.     - It's fun, why else?
  36.       
  37.   Getting started :
  38.   
  39.       Firstly you should get a copy of Satan Paint, a free program which
  40.     can be found at ftp.island.net (I think).  If you do not
  41.     have internet access then you are currently out of luck.  Satan Paint
  42.     was used in the making of Abuse mainly as a conversion utility, but
  43.     also has some features to assist in graphics creation.  There are
  44.     several data types the abuse engine supports, all outlined in spaint
  45.     docs. 
  46.  
  47.     Spaint is capable of creating all of these except WAV files and 
  48.     particle animations.
  49.     
  50.  
  51.       Images
  52.     spaint name : image
  53.         simple bitmaps with no other data.
  54.     loaded with (def_image "filename" "image_name")
  55.     displayed with (put_image screen_x screen_y image_id)
  56.     see also : image_width, image_height 
  57.  
  58.       Background tiles
  59.     spaint name : backtile
  60.     loaded with (load_tiles "filename")
  61.     all data items in filename with of type 'backtile' will be loaded
  62.         these tiles should be named with a number prefixing the name
  63.          i.e.  20 red brick
  64.         abuse takes the number and inserts the tile into an array at this offset.
  65.     (bg_tile x_map_location y_map_location) returns this number
  66.         (set_bg_tile x_loc y_loc value) sets this value
  67.  
  68.       Foreground tiles 
  69.     spaint name : foretile
  70.     loaded with (load_tiles "filename")
  71.     all data items in filename with of type 'foretile' will be loaded
  72.         these tiles should be named with a number prefixing the name
  73.          i.e.  25 my foretile
  74.     foretiles can have a 'frame' (as referred to in spaint) which blocks.
  75.     The player and other objects in the game will not be able to pass through
  76.         this area with calls like tick, move, bmove, & can_see.
  77.  
  78.       Character frames
  79.     spaint name : character (displayed as character2)
  80.     loaded with def_char (explained later)
  81.     characters frames have 
  82.            - x center of gravity     (spaint name xcfg)
  83.            - frame advancement       (spaint name advance)
  84.            - attack polygon          (spaint name attack)
  85.            - damage polygon.         (spaint name damage)
  86.  
  87.  
  88.       The x center of gravity
  89.         is used to for the object's X position in the game.  i.e. The
  90.         character's X position will correspond with the center of gravity
  91.         line. The character's Y position is always taken from then bottom
  92.         of the character.  Frame advancement indicates how many pixels
  93.         the character will move after the frame is played.  If the character's
  94.     direction>0
  95.         the character will move right according to the frame advancement,
  96.         and if the direction<0 then the character will move left.  The
  97.         attack polygon will incur damage on any other character's damage
  98.         polygon if the other character has the hurtable flags set in it's
  99.         character definition.  When damage occurs the character just hurt will
  100.         have it's damage_fun called (see def_char).
  101.  
  102.       Particle animation
  103.      can only be made with a particle animator that has not yet been released.
  104.      (perhaps some-day... it's not finished)
  105.      loaded with def_particle
  106.  
  107.       WAV files 
  108.     should be sampled at 11025 Hz mono.  We may add support for
  109.         stereo and variable sample speed later.
  110.     loaded with (def_sound "filename")
  111.     played with (play_sound sound_id volume x y)
  112.     The x & y are used for distance queuing and if we add stereo or
  113.         support for 3d sound cards these numbers will also be used.
  114.  
  115.       Palettes 
  116.     are simply the typical 768 bytes stored RGB RGB...  Spaint
  117.         will do this automatically save one with every file.
  118.     loaded with (load_palette "filename"), only one per game
  119.  
  120.     palettes can also be loaded as tints in abuse,  the abuse engine
  121.         takes each color of the new palette and finds the closest color
  122.         in the abuse palette to create a remapping filter.
  123.     loaded with (def_tint "filename")
  124.     see also : draw_tint, draw_double_tint
  125.  
  126.       Color filters 
  127.         5 bit RGB lookup tables.  This will be saved in
  128.         a file with spaint if the calc_filter command is executed before saving.
  129.     This filter is need to do effects like transparency and give the LISP 
  130.     programmer virtualized RGB access via (find_rgb r g b).
  131.         loaded with (load_color_filter "filename"),  if you use your own custom
  132.         palette you will need to calculate a new color filter with spaint.
  133.         One one color (and exactly one) color filter should be loaded per game.
  134.  
  135.  
  136.        
  137.  
  138.  
  139.  
  140. def_char reference
  141.   def_char is the most complicated function in abuse, and also the most used.
  142.   
  143.   here's a simple example of def_char
  144.   
  145.   (def_char CONC
  146.     (funs (ai_fun  mine_ai))
  147.     (fields  ("xvel" "flash [1=on]"))
  148.     (states "art/chars/mine.spe"
  149.         (running   (seq "mine" 1 8))
  150.             (stopped    '("mine0001.pcx" "mine_off"))))
  151.  
  152.  
  153.   The first parameter of def_char should be the symbol name of the object.
  154.   This name will be used by the level editor in the objects list.  This value of
  155.   this symbol will also be assigned a character_handle.
  156.  
  157.  
  158.   Lisp> (print CONC)
  159.   25
  160.  
  161.  
  162.   the next parameter to def_char is arbitrary, but it must be a list and the
  163.   first object in the list must be one of the following :
  164.  
  165.     funs, abilities,  flags, range, draw_range, fields, logo, vars, or states,
  166.  
  167.   
  168.   I. funs
  169.      Following funs should be a list o function types and function 
  170.   value pairs.  The following function types are currently defined :
  171.  
  172.     ai_fun - this is called with no parameter for every object for each 
  173.              game tick.  Order of object ai_fun execution goes from back to
  174.              front (as does order for draw_fun).
  175.              This function must return nil or non-nil.  Nil means *delete me*
  176.              and non-nil means keep going.  An object's ai_fun will not be executed
  177.              unless it is in range of a player view (see range).
  178.  
  179.  
  180.     move_fun - this is called for player object and has three parameters
  181.              (xv yv but) which indicate the status of the player's input
  182.              but is a bit mask of buttons and you should call bit-and to
  183.          see if a specific button is being pressed.
  184.  
  185.     constructor - this is called whenever an object is created for the
  186.              first time.  It is a good place to initialize object variable.
  187.              This is not called upon loading and object from disk.
  188.          no parameters are passed to the constructor.
  189.  
  190.     draw_fun - this is called when and object to displayed on screen.
  191.              it can call things like
  192.                 draw, draw_above, draw_line, draw_transparent, draw_tint,
  193.             draw_double_tint, draw_predator, scatter_line, ascatter_line,
  194.             put_image or even play_sound.
  195.          Since a draw_fun for an object may be executed on one computer in
  196.              a networked game and not on others, it is very important that it
  197.              does not change any variables or the state of the game at all.  i.e.
  198.              it can only do drawling stuff, but cannot create new characters, 
  199.          set global variables, or even do a (next_picture).
  200.  
  201.     next_state_fun - this is called when an object animation sequence ends
  202.              from within (next_picture), this function takes no parameters
  203.          and it's return is ignored.
  204.  
  205.  
  206.     user_fun - this function is not called by abuse but reserved for the user.
  207.              it can be used to achieve a minimal OOP system for objects.  This
  208.              function is invoked by (user_fun) and the number of parameters must
  209.          match your definition of this function.
  210.  
  211.  
  212.     reload_fun - this is called when an object is loaded from disk.
  213.              this can be used to correct general traits of a character.
  214.          this is the only place where (lower) and (raise) may be called.
  215.          If you created an object which you want always to be under all other    
  216.              characters, you should give it a reload_fun which calls (lower).
  217.          this function has no parameters and return is ignored.
  218.  
  219.  
  220.     get_cache_list_fun - this function is also called while a level is loading,
  221.          but the return must be in a specific format.  specifically this return
  222.          should be :
  223.               (list (list character_id1 character_id2) (list other_id1 other_id2))
  224.          the character_id list should be the id's of characters that are likely to
  225.          accessed within the level.  i.e. (CLOUD SPRAY_GUN)
  226.          The other_id's applies to any other data object which will be needed during
  227.          the level.  This includes sound effects, tints, images & particle animations.
  228.          
  229.            The game will load as much of these as it can before starting the level.
  230.          To improve game performance even more you should use the Cache profile options
  231.              from the edit menu in the game.
  232.  
  233.                 
  234.     type_change_fun - this function is called whenever the objects "aitype" variable
  235.              is changed.  This change can occur because a) (set_aitype) is called, or
  236.              b) it is edited by the level designer.  The b option allows a simple, but 
  237.          usefull interface between the object and the level editor since on all objects
  238.          pressing the keys 0..9, SHIFT 0..9 will change the objects aitype and thus
  239.          call type_change_fun if it exist.  This is how AMBIENT_SOUND works.
  240.  
  241.  
  242.     
  243.  
  244.  II. abilities
  245.     these are character type variables that can be accessed via 
  246.     (get_ability)
  247.  
  248.       start_hp - used to set an objects (hp) when it is first created
  249.  
  250.       walk_top_speed - looked at by the (move) function to determine how
  251.     far to move the character every frame.
  252.  
  253.       ** these are not useful or not used, but I'll list them for fun :) **
  254.       start_accel, stop_accel, jump_xvel, jump_yvel, run_top_speed, 
  255.       jump_top_speed, tint_color, push_xrange, 
  256.       example : (abilities (start_hp 200))
  257.  
  258.  
  259.   III. flags
  260.      all flags default to false, if a flag is not listed then it is assumed false
  261.  
  262.     
  263.      is_weapon - indicates this object should be allocated a spot on the status bar
  264.      hurtable - if an obect can be hurt by other objects
  265.      unlistable - if an object will appear in the object listing window.
  266.      add_front - when an object is created it will place in front of other object
  267.      unactive_shield - if object is hit by shotgun bullet and this flag is set and
  268.        the object is not actiavted, it will not be hurt.
  269.      example : (flags (unlistable T) (add_front T))
  270.  
  271.   
  272.   IV. range
  273.      (X_range Y_range)
  274.      specifies how far off-screen an object can be and still be processed.
  275.      example : (range 50 50)
  276.  
  277.     
  278.   V, draw_range
  279.      (X_range Y_range)
  280.      specifies how far off-screen an object can be and still be drawn.
  281.      example : (draw_range 50 50)
  282.  
  283.   VI. fields
  284.       following this should follow a list of (actual_name show_name)
  285.     where actual_name can be one of the following :
  286.                         "fade_dir",      
  287.                 "frame_dir",     
  288.                 "direction",     
  289.                 "gravity_on",    
  290.                 "fade_count",    
  291.                 "fade_max",      
  292.                 "active",        
  293.                 "flags",         
  294.                 "aitype",        
  295.                 "xvel",          
  296.                 "fxvel",         
  297.                 "yvel",          
  298.                 "fyvel",         
  299.                 "xacel",         
  300.                 "fxacel",        
  301.                 "yacel",         
  302.                 "fyacel",        
  303.                 "x",             
  304.                 "fx",            
  305.                 "y",             
  306.                 "fy",            
  307.                 "hp",            
  308.                 "mp",            
  309.                 "fmp",           
  310.                 "cur_frame",     
  311.                 "aistate",       
  312.                 "aistate_time",  
  313.                 "targetable"
  314.           or any of the variables declared in vars
  315.  
  316.         show_name can be any string and is what will be displayed
  317.         in the level editor under the ai window.
  318.     example : (fields ("hp" "health points")
  319.                       ("fade_count" "faded amount (0-15)"))
  320.  
  321.  
  322.   VII. vars
  323.       a list of variable names that get allocated to each object of this
  324.       type, these variables are also loaded and saved with each level.
  325.       The variables are restricted to integers however.
  326.          You may get some complaints from the compiler if different classes
  327.       have the same variable names.  To fix this reorder the compilitation
  328.       order of the objects or rename the variables.
  329.  
  330.       example : (var time1 time2)
  331.  
  332.  
  333.   VIII. states
  334.       An object is always in one animation state.  This section defines
  335.       the animation states for an object.  Each animation state listed
  336.       will be assigned a state number.  The first object of the state list
  337.       must be the file name where the animations are located.  Following
  338.       that should be a list of (state (frame_list)) pairs.
  339.  
  340.       example :
  341.         (states "art/cop.spe"
  342.             (stopped            (seq "stopped" 1 6))
  343.         (running            (seq "4wlk" 1 10)))
  344.  
  345.       The seq command creates a list of names such as 
  346.         "4wlk0001.pcx" "4wlk0002.pcx" ....
  347.  
  348.       The seq command is defined in lisp/common.lsp
  349.  
  350.       An object can set it's animation state with (set_state), and
  351.       once in a animation state it can change animation frames with
  352.       (next_picture) or access the current_frame variable directly with
  353.       (current_frame) and (set_current_frame).  An object can ask what
  354.       animation state it is in with (state).
  355.  
  356.       Every object must have a 'stopped' state defined.  This is the
  357.       state it will be placed in when it is first created.
  358.  
  359.       States need not use the seq command, but frames can be listed manually.
  360.  
  361.       example (states "art/cop.spe"
  362.                  (stopped   '("frame1" "frame2" "frame3" "frame4"))
  363.                  (running   '("rframe1" "rframe2" "rframe3" "rframe4")))
  364.  
  365.       A frame may be referenced from another file than the one listed after "states".
  366.  
  367.       example (states "art/cop.spe"
  368.              (stopped   '(  ("art/newfile.spe" . "frame1") "frame2" "frame3")))
  369.  
  370.       All animation frames of a character are automatically cached in when a level
  371.       containing the character is loaded or the character was refrenced via a get_cache_list
  372.       function.
  373.  
  374.  
  375. Ok. I've covered most of def_char, let's do an example of actually making a character for
  376.   abuse.  This example will show how to make a DIFFICULTY_SENSOR.  The difficulty sensor
  377.   turns on if the player is playing on a set difficulty.  In general object use the "aistate"
  378.   variable to indicate weither they are on or off.  aistate==0 means off, aistate<>0 means on.
  379.  
  380. ;; this addon must be loaded by other addons by
  381. ;; (if (not (load "addon/diffsens/diffsens.lsp"))
  382. ;;    (progn (print ("This package requires the diffsens addon"))    
  383. ;;           (quit)))
  384.  
  385. (def_char DIFFICULTY_SENSOR         ; name of objetc
  386.   (funs (ai_fun diff_sensor_ai)    ; name of function listed below
  387.     (draw_fun dev_draw))       ; dev_draw only draws when in edit mode
  388.                                       ; this makes the object invisible while playing
  389.  
  390.   ; this section provides the interface to the level editor    
  391.   (fields ("xvel"  "easy on?    (1=yes, 0=no)") ; recycle variables already defined
  392.       ("yvel"  "meduim on?  (1=yes, 0=no)")
  393.       ("xacel" "hard on?    (1=yes, 0=no)")
  394.       ("yacel" "extreme on? (1=yes, 0=no)"))
  395.  
  396.  
  397.   ; this section defines the "visible" part of the object
  398.   ; we define two states to aid the level designer in telling if the object is on or off
  399.   (states "addon/diffsens/diffsens.spe"  ; filename where state artwork is located
  400.      (stopped "off")                        ; we will use this as the off state
  401.      (on_state "on")))
  402.  
  403.  
  404. (defun diff_sensor_ai ()            ; no parameters to this function
  405.  
  406.   (set_state stopped)              ; set animation state to off
  407.   (set_aistate 0)                  ; set aistate to off
  408.  
  409.   (select difficulty               ; this is set by abuse
  410.       ('easy (if (eq (xvel) 1)
  411.              (progn
  412.                (set_aistate 1)           ; set aistate to on
  413.                (set_state on_state))))   ; set animation state to on
  414.       ('medium (if (eq (yvel) 1)
  415.                (progn
  416.              (set_aistate 1)
  417.              (set_state on_state))))
  418.       ('hard (if (eq (xacel) 1)
  419.              (progn
  420.                (set_aistate 1)
  421.                (set_state on_state))))
  422.       ('extreme (if (eq (yacel) 1)
  423.             (progn
  424.               (set_aistate 1)
  425.               (set_state on_state)))))
  426.  
  427.   T)    ; return true so that we are not deleted
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.      
  435.   
  436.  
  437.