These script commands can be entered directly into a sector's properties and run as a single command. They can also be used within blocks of C code for advanced scripting.
If you are unsure about what all this means then read this first.
void SC_SetSectorTexture( int SectorId, char *TextureName); Sets the texture of a sector on the map. SectorId is the sector's ID number to change, TextureName is the filename of the texture (with no path). Holding a mouse over a sector (while in Sector Mode) will display that sector's ID number. Example |
char *SC_GetSectorTexture( int SectorId); Return's the specified sector's texture name as a string. Example |
void SC_SetSectorHidden( int inSectorId, int value); Sets a sector's hidden flag. When a sector is hidden it effectively does not exist within the game. inSectorId is the ID number of the sector to change, value can be 1 for hidden or 0 for not hidden. Examples |
void SC_SetSectorTriggerEnabled( int SectorId, int value); Once a sector trigger is used it is disabled by default (so it won't run again). Using this function a sector's trigger can be re-enabled (or disabled for that matter). Notes Example // re-enable this trigger for next time |
int SC_GetSectorTriggerEnabled( int SectorId); Gets the status of a sector's event trigger. Example |
void SC_OpenDoor( int SectorId); Opens a door sector just
as if the player had walked into it. This is really handy for as
it allows objects on waypoints to open doors. If you attempt to
run this on a non-door sector then it will abort automatically. |
void SC_SetSectorDamage( int SectorId, int damage); Sets a sectors damage (acid). Example |
int SC_GetSectorDamage( int SectorId); Gets a sectors damage (acid). Return Values Example |
void SC_SetSectorDamageInterval( int SectorId, int DamageInterval); Sets a sector's damage interval (acid). 100=1 second and 50=0.5 seconds and so on. Example |
int SC_GetSectorDamageInterval( int SectorId); Gets a sectors damage interval. Return Values Example |
int SC_AddObject( char *ObjectName, int PosX, int PosY, int
angle, int AiType, int side, char *OverrideName, int moving, int
MultiplayerRespawn, int locked) Adds a new game object and returns the new object's ID. Parameters Return Values Example |
int SC_BindObjectToWaypoint( int ObjectId, int WaypointId); Binds a game object to a waypoint. ObjectId is the ID of the game object, WaypointId is the ID of the map waypoint.
Return Values Example |
int SC_BindObjectToWaypointSoft( int ObjectId, int WaypointId); This function works in exactly the same way as SC_BindObjectToWaypoint (above) except that the object is soft bound. Soft bound objects are released (unbound) from their waypoints if they get stuck. |
void SC_SetObjectHidden(int ObjectId, int value); Sets an object's hidden flag. When an object is hidden it effectively does not exist within the game. ObjectId is the ID number of the object to change, value can be 1 for hidden or 0 for not hidden. Examples |
int SC_GetObjectHidden( int ObjectId); Gets the hidden status of an object. Return Values Example |
void SC_ShowObjectTeleport(int ObjectId); This function shows an object in a similar way to using SC_SetObjectHidden(???,0); except that the object appears to teleport (plays directional teleport sound and applies teleport damage to the landing area). Note that you do not need to call SC_SetObjectHidden(??,0); as well as this function. Example |
int SC_GetObjectSide( int ObjectId); Gets the side number for the specified object. See SC_SetObjectSide below for an explanation of sides. |
void SC_SetObjectSide(int ObjectId,int value); Sets the side number of an individual object. ObjectId is the id of the object to change, value is the side value to set. See base\game.ini for a list of side numbers, these are generally as follows: 0 = Neutral Example |
void SC_GetObjectCoords( int ObjectId, int *x, int *y); Gets the map coordinates for the specified object. ObjectId is the ID of the object, x and y are 2 integer pointers that will be populated with the object's coordinates when this function is called. Example |
void SC_SetObjectCoords( int ObjectId, int x, int y); Sets the map coordinates of an object. ObjectId is the ID of the object to set, x and y are the new coordinates. Note that map coordinates are shown in the Map Editor status bar when moving the mouse over the terrain window. Example |
int SC_GetObjectAngle( int ObjectId); Returns the angle of the specified object. ObjectId is the ID of the object, the angle value is returned by this function. Note that angles range from 0 to 255 with 64 representing a right angle etc. Example Return Value |
void SC_SetObjectAngle( int ObjectId, int angle); Sets the angle of the specified object. ObjectId is the object to affect, angle is the new angle. Note that angles range from 0 to 255 with 64 representing a right angle etc. Example |
int SC_GetObjectHits( int ObjectId); Gets the number of hits an object has. An object's hits value (or current health). ObjectId is the ID of the object, the hits value is returned by this function. Example Return Value |
void SC_SetObjectHits( int ObjectId, int value); Set's an objects hits (health). ObjectId is the ID of the object to affect, value is the new hits value. Example |
int SC_GetObjectIndestructible( int ObjectId); Returns the value of an object's indestructible flag. Returns 1 if the object is indestructible, else 0. Example Return Value |
void SC_SetObjectIndestructible( int ObjectId, int value); Sets an object's indestructible flag, set value to 1 to make an object indestructible or 0 or destructible. Note that making predefined indestructible objects (like drain covers) destructible may cause problems as their hits are set to -1. However this is fine for objects which were set as indestructible earlier in a script. Example |
int SC_GetObjectSpeed( int ObjectId); Gets an object's current speed. Example |
void SC_SetObjectSpeed( int ObjectId, int speed); Set's an object's current speed. Example |
int SC_GetObjectMaxSpeed( int ObjectId); Returns an object ID's max speed value. Example Return Value |
void SC_SetObjectMaxSpeed( int ObjectId, int value); By default each game object's max speed is inherited from its "speed" value in the Object Editor. This function allows this value to be set on a per game object basis. Therefore a particular game object can move faster or slower than its normal speed. Set value to the desired value. Example |
int SC_GetObjectDefaultMaxSpeed( int ObjectId); Returns the
default max speed of an object. This is handy if you want to reset
an object's speed after previously changing it. ObjectId is the ID
of the object. ...or to set the default speed in a single line... SC_SetObjectMaxSpeed( 10, SC_GetObjectDefaultMaxSpeed(10) ); |
int SC_GetObjectAiType( int ObjectId); Gets an object ID's AI type. Return values are either AI_NONE, AI_ROAMING, AI_GUARDING or AI_IDLE. If the object is not found then AI_NONE is returned. Example Return Value |
void SC_SetObjectAiType( int ObjectId, int value); Sets an object ID's terrain type. ObjectId is the id of the object, value can be AI_NONE, AI_ROAMING, AI_GUARDING or AI_IDLE (these are defined as constants). Example |
int SC_GetObjectLocked( int ObjectId); Gets the locked status of a vehicle (locked vehicles can not be entered by the player), ObjectId is the ID of the object to check. Example |
void SC_SetObjectLocked( int ObjectId, int value); Sets the locked status of a vehicle (locked vehicles can not be entered by the player), ObjectId is the ID of the object to check, value is the "locked" flag (1 = locked, 0 = unlocked); Notes Example |
int SC_GetObjectActive( int
ObjectId); Gets the active status of an object. By default objects become active when they are first drawn. Non active objects do not attack, are not targeted and are not displayed on the minimap. Return Values Example |
void SetObjectActive( int ObjectId, int value); Sets the active status of an object. Object ID is the object to affect, value is either 1 or 0 (active or not active). Notes Example |
int SC_GetObjectNoTarget( int ObjectId); Gets the an object's "NoTarget" value. While NoTarget is set to 1 the object will not be attacked, the default is 0. |
void SC_SetObjectNoTarget( int ObjectId, int value); Sets and object's "NoTarget" value. While NoTarget is set to 1 the object will not be attacked, the default is 0. |
int SC_DoesObjectExist( int ObjectId); Determines whether an object exists (destroyed objects do not exist). Return Values Example |
void SC_PutObjectOnHorse( int RiderObjectId, int HorseObjectId); Attaches an object to another object. The "rider" object will sit on top of the "horse" object. If the horse object has weapons then those will be used instead of the rider's weapons. Notes If another object is already riding the "horse" object then they will be killed! Example |
void SC_KickObjectOffHorse( int RiderObjectId); Detaches and object from a ride on object. If the "rider" object is not riding an object then nothing will happen. Example |
void SC_ObjectHoot( int ObjectId); Makes the specified object bleep their horn. This is not appropriate for non vehicle objects! |
char *SC_GetObjectTypeNameForNumber( int ObjectTypeNumber); Gets an object type name from a type number. Notes Example void MyCode() |
int SC_GetObjectTypeNumberForName( char *ObjectFilename); Gets an object type number for an object filename. Notes Example void MyCode() |
void SC_SetObjectFollow( int ObjectId, int ObjectToFollowId); Tells an object to follow (or stop following) another object. This function is self explanatory. Pass ObjectToFollowId as -1 to tell an object to stop following another object. |
void SC_ResetObjectRespawnCoords( int ObjectId); Resets an object's respawn coordinates to its current location. This is handy if you have moved an object and want to respawn from the new location rather than its placement coordinates. This only applies to multiplayer respawning objects (generally vehicles in multiplayer). |
int SC_AddSprite( char *SpriteName, int PosX, int PosY, int
angle, int side); Adds a new sprite to the map at the specified x and y coordinates. SpriteName = the sprite filename (i.e. "objects\\car11_Still.spr") Return Values Example |
void SC_SetSpriteHidden( int SpriteId, int value); Sets the hidden flag value of a map sprite (set 1 for hidden, 0 for not hidden). Example |
int SC_GetSpriteHidden( int SpriteId); Gets the hidden flag value of a map sprite. Example |
void SC_PlayerGetInVehicle( int ObjectId); Puts the player "inside" the specified game object. The object must be an empty vehicle otherwise this function may fail. The real player object will be hidden accordingly (this function deals with everything). Example |
void SC_PlayerGetOutOfVehicle( int PlaceInCentre); Exits the player from the current vehicle. If the player is not in a vehicle then this will fail. Set PlaceInCentre to 1 to put the player in the centre of the vehicle (handy if you are hiding the vehicle in the same code block). Set PlaceInCentre to 0 to allow Meteor to find a suitable place nearby to put the player. Be warned that if no place can be found then this function may fail (using a value of 1 does not have this pitfall). Example |
int SC_IsPlayerInVehicle(); If the player is in a vehicle then this function returns 1, else it returns 0. Example |
int SC_SetPlayerObjectId( int ObjectId); Changes the player object to the specified "ObjectId". Notes
Examples Change to another object on the map Change object type only (add a new object on the fly) // bind the player to the new sheep object (the
old player is hidden automatically)
|
int SC_GetPlayerObjectId(); Returns the object ID of the player. Note that if the player is in a vehicle then the vehicle's ID will be returned so be careful. Example |
void SC_SetPlayerInteractionEnabled( int value); Disables or enables player interaction. When interaction is enabled the "E" key works. Use this function to control whether or not the "E" key can be used. Notes Parameters Example |
int SC_GetPlayerInteractionEnabled(); Gets the current player interaction value. Return Values Example |
void SC_MessageBox( char *MessageText, ...); Shows a message dialog box during the game. MessageText is the text to display in double quotes. The ",..." (for people who know a bit of C) means that you can pass a "printf" style formatted string. Examples |
void SC_GameMessage( char *MessageText, ...); Like SC_MessageBox except that the message appears in a hint on the screen without interrupting the game. The message is also echoed to the game console. Example |
void SC_ConsoleMessage( char *MessageText, ...); Like SC_MessageBox and SC_GameMessage except that the message appears in the corner of the screen. The message is also echoed to game console. Example |
int SC_StringInputBox( char * string, int MaxLen,
char *caption, ...); Shows a string input box and returns the string entered. Parameters Example Return Value |
int SC_ConfirmBox( char *caption, ...); Shows a yes/no dialog and returns the choice selected by the user. Parameters Return Value |
int SC_CreateToolbar( int ToolbarNumber, char *title, int x, int
y, int docked, int LocalOnly); Creates a new toolbar. Toolbars can be placed anywhere on the game screen and can contain any number of buttons. A script trigger can be placed behind each button. Toolbars are visible until they are destroyed using SC_DestroyToolbar. Up to 5 toolbars may be used at any one time. These are accessed by a toolbar number ranging from 0 to 4 (not 1 to 5). Parameters Return Values Notes Example |
void SC_DestroyToolbar( int ToolbarNumber, int LocalOnly); Destroys the specified toolbar and stops its being drawn. Parameters Notes Example |
void SC_AddToolbarButton( int ToolbarNumber, char *caption, char
*ImageFilename, char *TriggerText, int LocalOnly); Adds a new button or separator to the end of a toolbar. Parameters Notes Examples (add buttons) Example (add seperator) |
void SC_PlaySound( char *EffectName); Plays the specified effect name. The effect name is the relative path of a wave file from the "base\soundfx" directory with no numbers on the end, for example "world\\thunder" (it is important to use \\ and not \ in paths). Example Note that birds1.wav, birds2.wav and birds3.wav will actually create a single sound effect called "birds". Whenever this effect is played Meteor will pick a random sample from the 3 wav files. |
int SC_GetSoundNumberForName( char *EffectName); Gets a number for the specified sound effect, this is required if you cant to use SC_PlayDirectionalSoundNumber. Parameters Return Values Example |
void SC_PlayDirectionalNumber( int SoundNumber, int x, int y,
char *InstanceId); Plays a sound from the given map coordinates, also supports looping. Parameters Looping Non looping Example void MyCode() Looping Example #include "meteor2" #define FLAG_ALARM_SOUND 0 // use the first static flag void OnMapStart() // call this a lot! |
void SC_PlayMusic( char *inMusicFilename); Stops the current music (if playing) and plays a music track (looping). The inMusicFilename can be the filename of a music file in the "music" folder (looks in mod folder first) or a full path to a music file elsewhere (not much use if you are deploying your map). Supported file formats are MP3, IT, S3M, XM and MOD. Examples |
void SC_Music_SeekToStart(); Starts playing the current track from the beginning. Example |
void AUD_StopMusic(); Stops and unloads the current playing music track. Example |
Not yet implemented void AUD_Music_MoveBackwards(); Moves back 5 seconds. Example |
Not yet implemented void AUD_Music_MoveForwards(); Moves Forward 5 seconds. Example |
void SC_TogglePauseMusic(); Pauses or resumes the current music. Example |
void SC_GiveItem(char *ItemName,int amount); Gives or takes away a specified amount of a certain item from the player. Examples Notes |
int SC_GetItemCount(char *ItemName); Gets the amount the player has of an inventory item. Example Notes |
void SC_ResetAllItems( int LocalItemsOnly); Resets the player's items. If LocalItemsOnly is set to 0 this will totally wipe out the player's items as if they were starting a new game. This is suitable for using at the beginning of some missions. Be careful with this as taking items away can lead to bad feeling and a loss of interest (due to a lack of game progression). If LocalItemsOnly is set to 1 only level specific items (like keys and god mode etc) will be reset. Example |
void SC_ShowPda(); Shows the in-game Personal Messages viewer. By default the newest (top) message is displayed in the right hand panel. Example |
void SC_AddPdaMessage( char *subject, char *message); Adds a message to the Personal Messages list, subject is the message subject and message is the message body. Meteor will automatically wrap the message to the window. Example |
int SC_LoadPdaMessage( char *SectionName, int ShowPda); Like SC_AddPdaMessage except the message text is loaded from the map's briefing file. SectionName is the name of the section in the briefing file (don't
add the [] braces!). Note that the subject is included in the briefing file. Read this for more information about briefing files. Example |
void SC_RemovePdaMessage( char *subject); Removes a single PDA message. Example |
void SC_ClearAllPdaMessages(); Empties the entire Personal Messages list. Example |
SC_EndCurrentLevel(); Ends the current mission and progresses to the next level. Example |
void SC_Wait( int hunds); Pauses script execution and wait for hunds/100 sec before proceeding. Example |
void SC_SetSideId(int SideNumber, int SideId); Sets a side's SideId. Sides with the same SideId will not attack each other. SideNumber is the number of the side (see table below). SideId is the SideId value to set. You should refer to base\game.ini for side numbers. Generally
these are as follows: Side Ids are generally as follows: By default the Enemy, GNV and ROD sides have the same SideId value (2) meaning that they are allies. Example Notes |
void SC_RunMap( char *filename); Runs a map with no "Mission Completed" message and without changing the music or mission number. The filename parameter is the map's filename, no path information is required and the the .map map extension may be omitted. Note that if you are running a mod then Meteor will look in the mod\maps folder before looking in base\maps. Example |
int SC_Random( int lower, int upper); Returns a random number, the lower and upper parameters represent the range of the number to be returned. Example Notes |
void SC_PassToConsole( char *string); Passes the string "string" to the game console. Examples Notes |
void SC_PlayMovieClip( char *filename, char *SoundName); Plays an animated gif animation from the "base\clips\" folder. filename is the filename of the animation (i.e. "intro.gif"), SoundName is the name of the sound to play (i.e. "world\\thunder"). If no sound is required then enter the SoundName as NULL. Examples |
void SC_AddExplosion( int x, int y, int w, int h, int damage, int
OwnerObjectId); Adds an explosion at the specified coordinates. An explosion applies damage to the rectangular area defined by x, y, w, h. Parameters Example |
Utility functions are designed to make complex tasks available via a single function. As well as making script code more simple, utility functions also allow these tasks to be entered directly into a map sector's script trigger.
void SC_OpenForcefield( int SectorId); This is a very quick way to open a forcefield. Normally opening a forcefield would involve drawing a passable sector underneath the forcefield and hiding the forcefield sector. This function removes the need for that process (it converts your sector for you), it basically does the following:
SectorId is the id of the sector to change. Example |
void SC_CloseForcefield( int SectorId, char *ForcefieldTextureName) Like SC_OpenForcefield except this takes flat passable sector and turns it into a forcefield. The texture name for the actual forcefield needs to be specified. Be careful with this function, especially on multiplayer maps. |
The following standard C functions are also available. Click on the function names below to view the respective MSDN "help" pages.
Event triggers are functions which run automatically when a certain type of event occurs within the game. The most simple example of an event trigger is the "OnMapStart" function which is called automatically when starting a new map.
It is important to understand that triggers are placed in a script as functions (not calls to functions). In basic terms you need to write a function with the correct name (see examples below), the code within the function can be anything that you like.
Don't forget to export your events
using "export EventName_123;" at the top of your script.
If your event triggers fail to run then this is the most likely cause!
void OnMapStart() This function will be called when the map is first run, it is called just before play begins. Name Rules Example |
void OnObjectHurt_???() This function is called when object ID ??? gets hurt, this will not be called when healing an object. Name Rules Parameters Example (runs when object ID 10 is hurt) |
void OnObjectDie_???() This function is called when object ID ??? dies. Name Rules Parameters Example (runs when object ID 10 gets killed) |
void OnWaypointReached_???(int ObjectId) This function is called when an object reaches a specified waypoint. Name Rules Parameters Notes Example |
void OnEnterVehicle_???() This function is called when the player enters the specified vehicle. Name Rules Parameters Notes Examples void OnEnterVehicle_10() |
void OnExitVehicle_???() This function is called when the player exits the specified vehicle. Name Rules Parameters Example void OnExitVehicle_10() |
void OnObjectTypeEnter( int ObjectId, int ObjectTypeNumber) This function is called whenever the player gets in a vehicle. It contains the ID and type number of the object just entered. You may make use of either or both of these values. Parameters Comments Example void OnObjectTypeEnter( int ObjectId, int ObjectTypeNumber) Or you could do things the other way around but this could require more function calls (slower in most cases)... void OnObjectTypeEnter( int ObjectId, int ObjectTypeNumber)
if( ObjectTypeNumber == ChinookTypeNumber) See base\maps\examples\Test_ObjectEvents.map for a working example using the first method. |
void OnObjectTypeExit( int ObjectId, int ObjectTypeNumber) This function is exactly like OnObjectTypeEnter expect it is called when the player exits the vehicle. Comments |
void OnObjectLaserTrip_???( int ObstructingObjectId) This function is called when an object's fixed laser beam is broken by another object. Name Rules Parameters |
int StaticFlags[100] There are issues with scripts containing internal static or global variables. This array of 100 integers can be written to and/or read by your script however you feel fit. The values that you assign will not change for the duration of the map. Examples Notes |
int UseMiniMap This variable represents the status of the minimap. This variable is connected directly to an in-game variable so changes to its value have immediate effect and its current value is "real". 0 = Minimap is off |
int MapWidth int MapHeight These values contain the map's dimensions in pixels, you should NOT change these values as it will cause the computer to become unstable. |
int TimeLimit This the remaining mission time limit in seconds, set to -1 for no time limit. |
int GameType This variable represents the game type. Do not change this variables value under any circumstances. The values used by this variable are defined as the following constants... GT_NONE |
Page last updated 09 September 2004
Copyright (C) 2004 by James
Bunting
www.jbgames.com