Results 1 to 8 of 8

Code Utility: Level Link

  1. #1

    Code Utility: Level Link

    Building on the code I developed for the Babylon 5 mod's Area Capture game script, I've created a small set of scripts that will allow you to pass numerical information between the .level files and the game rules:

    http://www.moddb.com/mods/babylon-5-...d-2-level-link

    alternate link until Moddb clears the file:

    http://daedalus.f2s.com/HW2/HW2LevelLink_v1.zip

    This should open up a whole load of possibilities for customising maps to a much greater extent than is currently possible. For example you could create a script that takes values stored in the level file to create customised, scripted events on a per-level basis.

    Its pretty simple to use. The script consists of two parts, one which has to be loaded by the various level files and another part which has to be loaded in the relevant game rule.


    Inside Level Files:
    -------------------

    The scripts/scar/LevelLink/level.lua file is the level side of the link and should be imported at the start of the level file. To create the link, LinkOpen() should first be called in the deterministic section of the level file. LinkSet(sVarName, fValue) commands, following the LinkInit() command, can then be used to pass named values to the game rule. ie:

    Code:
    dofilepath("data:scripts/scar/LevelLink/level.lua")
    
    function DetermChunk()
    
    	linkOpen()
    	linkSet("youvarname1", yourvalue1)
    	linkSet("youvarname2", yourvalue2)
    	linkSet("youvarname3", yourvalue3)
    	linkSet("youvarname4", yourvalue4)
    
    	etc...
    
    end
    Inside Game rule:
    -----------------

    The scripts/scar/LevelLink/gamerule.lua is the game rule side of the link and should be imported at the start of the game rule file. LinkGet(sVarName, fValue) can then be used to recover the variables set in the level file via LinkSet(). Once all variables have been recovered, LinkClose() must be called to clean up sobgroups and objects used to pass the between data the level and game files. ie:

    Code:
    dofilepath("data:scripts/scar/LevelLink/gamerule.lua")
    
    function OnInit()
    
    	yourvar1 = LinkGet("yourvarname1")
    	yourvar2 = LinkGet("yourvarname2")
    	yourvar3 = LinkGet("yourvarname3")
    	yourvar4 = LinkGet("yourvarname4")
    	linkClose()
    
    	etc...
    
    end
    For those that are interested it works like so:

    The level script - A reference object and sobgroup are created. For each variable defined by the user in the level file, the variable's value is is encoded as a IEEE754 double (64-bit). A volume is created for each bit, with the volume either created surrounding the reference object or not depending on the value of each bit. The bits are named by the variable names set in the level file.

    The game rule script - when the user requests a variable the volumes associated with that variable's bits are checked to see if they contain the reference object. If they do the bit is 1 if not the bit is 0. The bits are then decoded back into a normal number and are then assigned to a normal lua variable. A cleanup routine removes the reference object and sobgroup.

    Give it a try, the possibilities are endless! For the Babylon 5 mod we intend to use this to allow map makers to provide customised hazards/events to maps such as groups of non-player/AI ships that guard areas of the map.
    Last edited by CnlPepper; 9th May 10 at 6:32 AM.


    HW2:B5TC Team Member (Effects and Game Scripting), HW2 Shader Designer, CFHodEd Maintainer, Nuclear Physicist

  2. #2
    groups of non-player/AI ships that guard areas of the map.
    Could you provide ready made scripts or gamerules such as this.

    I would like to have a few of these for my map pack.
    strange...as wonderfull as it may be,i'm still...up here... floating...and no one even seems to notice.

  3. #3
    Once I have the scripts in a nice form I'll release them.

    I intend to package up the area capture game type from the B5 mod at some point. I just need to clean up the award system to make it easier to write new awards. I might make a mini HW2 mod out of it.

  4. #4
    That sounds good to me.

    Don't know if you can do this through scripting,coding or both but I came up with this really cool idea.

    In the game we have the ability to Hyperspace from one point on a map to another.

    I would like to know if you can take this further by what I call HyperSwitching which is the ability to jump from one map to another.

    A HyperSwitching gamerule where the player can select a starting map and then select up to 5 more maps that the game rule would link.

    The player can then select on which maps the other CPU player would also start in.

    Now as the game progresses,you and the enemy can jump from one map to another conquering territory until you or the enemy defeat all forces on all maps.

  5. #5
    Member Ringleader's Avatar
    Join Date
    Nov 2007
    Location
    Metro-Atlanta Area
    This sounds really snazzy, and I hope other mods take notice of this development.
    "Sorry, you can not add yourself to your own buddy list."

  6. #6
    Hmm, that would be really hard to do. Remember that the camera doesn't follow along when your ships hyperspace. There would probably be no way to get the camera from one map to another.

    Plus, the game is hardcoded to only load one background, so there's another problem with the idea. Would be cool if it was possible though. You'd need another overview map to tell you which maps you had enemies in.
    Babylon 5: War Without End Official Site.

    "I keep telling you people that it's only a build animation, NOT a hyperspace animation." - Me, about the Babylon 5 mod hyperspace build animation.

  7. #7
    This sounds very interesting. I can see a lot of fun possiblities with this.

    If time allows, I'd love to experiment around with this!

    At any rate, gread work
    Path To Victory

    - I can count to 1024 on my fingers! -

  8. #8
    I've had a few people asking me in messages on various forums if I'm going to write a set of scripts to add "monsters" ie non player ships that, for example, guard regions of space. Yes, this is what I intend and the level link is a key part of that.

    Here is how it will work:

    1) a new race called "monsters" is added to the game

    2) to enable non player "hazards" to maps you need to give up one player slot on the map and that player slot must be set to the monsters race.

    3) when the monster script detects an AI player set as the monster race it initialises and reads the variable passed from code in the level files. The CPU control of the monster player is disabled (see CPU function descriptions on HW2 wiki).

    4) The monster scripts create and control the monster ships and other hazards based on the data passed from the level files.

    I intend to make the system easy to use. The present idea is to create a set of separate "controllers" to handle aspects of the monsters like ship spawning, defining patrol routes etc.. these will then be assigned to ships, sobgroups and volumes defined in the level file.

    Example scenarios:

    You could build a map where there are few resources near each player and a set of large clouds of salvage between the players. The larger resource field could be defended by a group of movers or a keeper which the players must either avoid (ie try and steal resources) or destroy.

    Another map could contain a few progenitor "artifacts" that when captured (by for example a player entering a set of volumes) trigger an autonomous fleet of monster ships to start attacking enemy ships. These artifacts would be defended by monster ships.

    I'll try and provide a range of controllers and also attempt to build a framework that makes it easy to add more features, much like the Area Capture gametype built into the Babylon 5 mod (I'm going to improve this and release it as a stand alone mod at some point).

    This will all take me some time, I'm very busy with life atm (restoring a house) once that is out of the way I should have something interesting to share.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •