2004-10-16 00:15:31 +02:00
function initSession ( )
{
2004-11-15 18:34:51 +01:00
initCoord ( ) ;
2004-11-15 01:13:21 +01:00
initGroupPane ( ) ;
2004-11-15 22:07:02 +01:00
initResourcePool ( ) ;
2004-11-15 01:13:21 +01:00
}
// ====================================================================
2004-10-16 00:15:31 +02:00
function setPortrait ( objectName , portraitString )
{
// Use this function as a shortcut to change a portrait object to a different portrait image.
// Accepts an object and specifies its default, rollover (lit) and disabled (grey) sprites.
// Sprite Format: "ui_portrait_"portraitString"_64"
// Sprite Format: "ui_portrait_"portraitString"_64""-lit"
// Sprite Format: "ui_portrait_"portraitString"_64""-grey"
// Note: Make sure the file follows this naming convention or bad things could happen.
// Get GUI object
GUIObject = getGUIObjectByName ( objectName ) ;
// Set the three portraits.
GUIObject . sprite = "ui_portrait_" + portraitString + "_64" ;
2004-11-15 18:34:51 +01:00
// Note we need to use a special syntax here (object["param"] instead of object.param because dashes aren't actually in JS's variable-naming conventions.
2004-10-16 00:15:31 +02:00
GUIObject [ "sprite-over" ] = GUIObject . sprite + "-lit" ;
GUIObject [ "sprite-disabled" ] = GUIObject . sprite + "-grey" ;
}
// ====================================================================
function getObjectInfo ( )
{
// Updated each tick to extract entity information from selected unit(s).
if ( ! selection . length ) // If no entity selected,
{
// Hide Status Orb
getGUIObjectByName ( "session_status_orb" ) . hidden = true ;
// Hide Group Pane.
getGUIObjectByName ( "session_group_pane" ) . hidden = true ;
2004-11-12 00:54:41 +01:00
getGlobal ( ) . MultipleEntitiesSelected = 0 ;
2004-10-16 00:15:31 +02:00
}
else // If at least one entity selected,
{
// Store globals for entity information.
// strString = "" + selection[0].position;
// EntityPos = strString.substring(20,strString.length-3);
2004-11-15 18:34:51 +01:00
UpdateStatusOrb ( ) ;
2004-10-16 00:15:31 +02:00
// Check if a group of entities selected
if ( selection . length > 1 )
{
// If a group pane isn't already open, and we don't have the same set as last time,
// NOTE: This "if" is an optimisation because the game crawls if this set of processing occurs every frame.
// It's quite possible for the player to select another group of the same size and for it to not be recognised.
// Best solution would be to base this off a "new entities selected" instead of an on-tick.
2004-11-08 01:41:54 +01:00
if (
// getGUIObjectByName("session_group_pane").hidden == true ||
2004-11-15 01:13:21 +01:00
selection . length != getGlobal ( ) . MultipleEntitiesSelected )
2004-10-16 00:15:31 +02:00
{
2004-11-15 18:34:51 +01:00
UpdateGroupPane ( ) ;
2004-11-12 00:54:41 +01:00
getGlobal ( ) . MultipleEntitiesSelected = selection . length ;
2004-10-16 00:15:31 +02:00
}
}
else
{
2004-11-12 00:54:41 +01:00
getGlobal ( ) . MultipleEntitiesSelected = 0 ;
2004-10-16 00:15:31 +02:00
// Hide Group Pane.
getGUIObjectByName ( "session_group_pane" ) . hidden = true ;
}
}
}
// ====================================================================
function MakeUnit ( x , y , z , MakeUnitName )
{
// Spawn an entity at the given coordinates.
DudeSpawnPoint = new Vector3D ( x , y , z ) ;
new Entity ( getEntityTemplate ( MakeUnitName ) , DudeSpawnPoint , 1.0 ) ;
// writeConsole(MakeUnitName + " created at " + DudeSpawnPoint);
}
// ====================================================================
function selected ( )
{
// Returns how many units selected.
if ( selection . length > 0 )
return ( selection [ 0 ] ) ;
return ( null ) ;
}