Go
High Level Design
What does go provide?
- The game world
- Physics
- Interactions
- Weapons
- Collisions
- Mission Loading / editing
- Graphics - Nicely drawn representations of the game world
- Boats
- Explosions
- Weapon Effects
- Water
- Sky
- Architectural Glue
- The eva system
- common global memory for storing / accessing information
- ghosted for client/server networking
- python / c++ integration
Second - What does YOU need to know?
Behavior networks in cat must integrate within the game world, and do this they must go through the eva system.
Behavior Network : public nAspect {
///called every tick (~frame)
public void Tick( float time, float dtime ) {
//read from variables
vector3 pos = position.GetV();
//do processing
float ds = pos.x / pos.z;
//write to variables
desiredSpeed.SetF(ds);
}
var position;
var desiredSpeed;
}
Knowing where to put the python scripts seems like an obvious one, as knowing the basics of what files are used seems useful
EVA
Entity - Some game entity - stores / manages variables
An entity is just a storage class for containing variables
Variable - some piece of information
- int
- float
- string
- vector3
- quaternion
- reference to another entity
Variable functions
For each type are associated get/set functions along with create functions from script
get[i,f,s,v,q,ref] -> get the value (GetS('favoritedish') returns this entities favorite dish
in script the get is shortened to just g[i,f,s,v,q,ref]
similarily for set,s
script also allows c[i,f,s,v,q,ref] which means create and set this variable, in c-code this should be done by using the 'var' class.
GetType() allows you to figure out the type of a variable
var
var wraps a smart pointer to a variable with a bunch of nice functions, used by aspects to simplify things.
Aspect
Some code attached to an entity
An aspect can be anything from a physics model to a complicated AI
The core purpose of an aspect is too reads from and writes to variables, doing appropriate processing inbetween
For example the nPhysics var reads in from the force / torque variables, and writes out changes to the position / velocity.
EVA
TNL can ghost entities and variables over, expanding it to ghost aspects could be done if needed as well.
Subtrees can be cloned / copied, but generally not moved / renamed.
They can also be written to and read from files (tcl files), but for serious save loading custom xml writers / readers are usually used (better readability / maintainability).
Python
Go well supports c++ and tcl, with python under development.
Python actually integrates very easily, the major problem being the wxPython mainloop problem.
This will be solved soon, and then python will be fully integrated.
Creating the files
Python has a predefined directory / package structure which has been combined into go.
Under abra/code/scripts are the different modules, to create say (exec) create a new directory named exec and put a __init__.py file in there.
At the end of lagoon/go.py add
import exec
This will load that package, running the __init__ file, generally the __init__ imports exec.go, which then loads everything up you want running
Interacting with EVA
At the top of your code put
from npython import *
from common.defs import *
The first gives you nebula functions (access to eva), the second is my growing list of convenient python functions for this stuff.
Functions to know
sel(path) - make path (relative / absolute) the currently selected object
call(function, args) - call a c function exported from the selected object
- call('getcmds') will return a list of all the commands this entity excepts
- call('gf', 'mass') will return the mass of a selected entity
- call('sv', 'pos', 15, 0, 25) will set the position
new(class, path) - create a new object in the eva tree
genEnt(type,side,label) - create a new entity
ndir() - return all the objects in my current directory
Files in GO
XML Files
Xml files are used to save information about the map, the mission, entities, and all kinds of other useful things.
Most of these should be fairly obvious (the benefit of using xml).
Map Files
These missions describe the static universe, the map show in the background
<MAP> Open Water <DESCRIPTION> continued refusal to believe in global warning + blaming everything on el nino combines with constant pollution to melt the entirety of the worlds ice caps, flooding the majority of the worlds population centers, this map takes place over Washington D.C. </DESCRIPTION> <TERRAIN> water </TERRAIN>
<HEIGHTMAP> flat </HEIGHTMAP> <DETAIL> waterDetail </DETAIL> <SKYBOX> sunset </SKYBOX> <DETAILSIZE>64 </DETAILSIZE> <ERROR> 5 </ERROR> <MAXHEIGHT> 10 </MAXHEIGHT> <LATTOP> 40 </LATTOP> <LATBOTTOM> 38.5 </LATBOTTOM> <LNGLEFT> 130.0 </LNGLEFT> <LNGRIGHT> 115.0 </LNGRIGHT> <WORLDSIZE> 50000 </WORLDSIZE> <CAMERAPOS> 22486 16 22372 </CAMERAPOS>
<CAMERAROT> -0.0026 0.7709 -0.0031 0.6369 </CAMERAROT> <ENVMAP> 1 </ENVMAP> </MAP>
Note - the existence of the envmap tag tells the terrain renderer to draw the sky reflected off the terrain, a nice touch for water terrains.
Technically it needs a spherical texture however, and this is only one piece of a skybox, so its not a perfect matching.
Mission Files
This files describe a particular mission, which is essentially a configuration of entities
<MISSION> Fixed Platform <BRIEF> A destroyer defends an oil platform against 2 groups of attackers </BRIEF> <DESCRIPTION> Angered by their enemies repeated premature proclomations of victory, terrorists from derka-derka stan send two groups of cigar boats to destroy the brand new and ultra overpriced oil platform 'Gilded John'. Nearby to oversee repairs is the destroyer 'le magnifique' which must help defend the oil platform from the onslaught. </DESCRIPTION> <ENTITIES> <ENT type="ddg51" side="blue"> Le Magnifique <var name="pos" type="vector3" x="22400" y="0" z="22400"/> </ENT> <ENT type="oilplatform" side="blue"> Gilded John <var name="pos" type="vector3" x="22500" y="0" z="22500"/> </ENT> <ENT type="cigarboat" side="red"> Alpha1 <var name="pos" type="vector3" x="22000" y="0" z="23000"/> </ENT> <ENT type="cigarboat" side="red"> Alpha2 <var name="pos" type="vector3" x="22013" y="0" z="23025"/> </ENT> <ENT type="cigarboat" side="red"> Alpha3 <var name="pos" type="vector3" x="22025" y="0" z="23007"/> </ENT> <ENT type="cigarboat" side="red"> Alpha4 <var name="pos" type="vector3" x="22043" y="0" z="23025"/> </ENT> <ENT type="cigarboat" side="red"> Beta1 <var name="pos" type="vector3" x="23000" y="0" z="22000"/> </ENT> <ENT type="cigarboat" side="red"> Beta2 <var name="pos" type="vector3" x="23013" y="0" z="22025"/> </ENT> <ENT type="cigarboat" side="red"> Beta3 <var name="pos" type="vector3" x="23025" y="0" z="22007"/> </ENT> <ENT type="cigarboat" side="red"> Beta4 <var name="pos" type="vector3" x="23043" y="0" z="22025"/> </ENT> </ENTITIES> </MISSION>
Entity Definition Files
Any xml file within a loaded project will have entityDefinitions parsed out of it - These describe entities which can be added to the game world.
<entityDefinitions> <entityDefinition>ddg51 <standardVis/> <var name="priority" type="int" value="5"/> <var name="hp" type="float" value="10.0"/> <var name="pos" type="vector3" x="10" y="25" z="45"/> <aspect>nphysics</aspect> <var name="mass" type="float" value="1000.0"/> <var name="inertia" type="float" value="1000.0"/> </entityDefinition> </entityDefinitions>
StandardVis tells it to draw it the conventional way, load a meh contained in 'ddg51.xml', use the texture 'ddg51.bmp' and the standard shader to render it
Obj Files
Obj's represent the 3d objects drawn in the world, they contain information about an objects shape, how it reflects light, and how to wrap a texture around it
Texture Files
Bmp files, these contain textures to be drawn on top of objects.
They must be square, and the dimensions must be powers of 2 (64x64,128x128,1024x1024)
Generally 128x128 or 256x256 is sufficient.
For alpha files they must be black and white and atleast 64x64.
|