Level Script File
The scripting language integrated into Stuntman Evolution is named Lua. For specifics about the language and documenation on virtually everything about the language visit:
Lua Language Documentation
In addition to Lua, Stuntman Evolution adds a number of game to the language so that the script can control the game. Those commands are described here:
Custom Commands
Play(song filename) This command will play the specified music file if of a .IT and .XM file format from the Custom directory or within the included songs with the game. Example:
Play("2morro.xm") The following music files are included with the game:
2morro.xm menu.it mr_archl.it silence.it holosyn2.xm gor.xm LoadSound(filename,index) This command will load a .WAV file from the custom directory. Choose an index value between 1 and 29.
PlaySound(index) Play a sound from memory. Example:
PlaySound(2) The following indexes are already included in the game:
1: blip 3: blip2 4: scifielec 5: scifielec2 6: swoosh 7: radiosound 8: splash 9: lightning 10: bulldoze To play a sound loaded with the LoadSound command add 10 from the index:
LoadSound("test.wav",1) PlaySound(11) PopMenu(index,title,item1,item2,item3...) This command will pop a menu to the screen. Each item is indexed incrementally starting with the index number provided (must be between 1 & 999). Then when the user selects the menu item it will call the script function ProcessMenu(index) so that you can do something with the selection. Example
PopMenu(1,"Menu","Items","Spells","Skills") You can do multiple PopMenu command and each successive PopMenu command will add a tab nicely to the menu.
EndLevel(result) This command will end the custom level. Result=1 for success. Result=2 for failure. Example:
EndLevel(1) // player completed the level successfully TopText(text,time,r,g,b) This command will show small text along the top of the screen. The test will stay on the screen for time/100 seconds and it'll be of the color RGB where r, g, and b are values between 0 and 255.
TopText("Test Text",200,255,0,0) BottomText(text,time,r,g,b) This command will show small text along the bottom of the screen. The test will stay on the screen for time/100 seconds and it'll be of the color RGB where r, g, and b are values between 0 and 255.
BottomText("Test Text",200,255,0,0) ClearTile(x,y) This command will clear the contents of a tile.
DeleteTileItem(x,y,type,index) This command will delete a specific item from a tile. To get an idea of what type & index values to use. Use the in-game level editor to drop an item on the map. Then hover over the item to see it's type & index values.
PutPlayerInShip(ship) This command will put the player into a ship. This should only be called during the BeginGame function. Example:
PutPlayerInShip(4) // put the player in the personal vehicle The following ship values are valid:
1: hovercraft 2: Bulldozer 3: RocketElite 4: Personal Vehicle 5: Turbocraft 6: Cruiser 7: Cargo Hauler AddShip(x,y,ship) This command adds a ship at a specific location. Each level should only have one ship of each type. Ship types are shown above.
SetPlayerPosition(x,y,z) This command will set the player to a specific location on the map x & y are in tile coordinates and z is in pixels. Example:
SetPlayerPosition(5,5,50) GetPlayerPosition() Use this command to get your player's location on the map. Example:
x,y=GetPlayerPosition() LoadSpriteFile(filename) Use this command to load additional sprites for your level. This command isn't really necessary because your sprites will be loaded automatically if your sprite file is the same name as your level. Your sprites will be of type 2 and index values starting at 50 and going up. GetHeight(x,y) This command will get the height of the center of a tile. Example:
h=GetHeight(x,y) Get(x,y) This command will get the height of the four corners of the tile. Example:
h1,h2,h3,h4=Get(x,y) GetVersion This command will return the version of Stuntman Evolution that's executing. Example:
version=GetVersion() ScreenShake(value) This command will shake the screen by the number of pixels specified in value.
PutHeight(x,y,h) This command will set the tile height of a tile. Example:
PutHeight(4,4,6) Put(x,y,h1,h2,h3,h4) This command will set the tile height of the four corners of a tile individually. Example:
Put(4,4,6,7,6,7) GetTerra(x,y) This gets the tile type of a tile. Example:
type=GetTerra(x,y) Valid Types:
0: Grass 1: Rock 2: Dirt 3: Sand 4: Water PutTerra(x,y,type) This sets the type of the tile. Example:
PutTerra(4,4,3) //make the tile at 4,4 set to type sand SetHeight(h) This command will set the percentage of the screen black. This is cool for level openings or a letterbox style. Example:
SetHeight(100) //== Hide Entire Game Window FadeHeight(0) //== Fade to Game Window FadeHeight(h) This command will fade to a given percentage of the screen black. This is cool for level openings or a letterbox style. Example:
SetHeight(50) //== Hide Entire Game Window FadeHeight(70) //== Fade to Game Window Title(text) This command will print the text in the upper right with a cursor and typed look. The text will persist for a few seconds. Example:
Title("This is my level!\n\nCool!") OverlayImage(filename,time) This command will load a BMP, PNG, GIF of name filename (without extention) and show it on the screen for time/100 seconds. Example:
OverlayImage("opening",300) GetMapSize() This command will return the size of the map. Example:
w,h=GetMapSize() Radio(text) This command will print the text in the radio style box along the bottom of the screen. The text will persist for a approximately 5 seconds. Example:
Radio("Back to base!") RadioClear() This command will clear all pending radio messages as they tend to que up if multiple are sent in rapid succession.
LockCameraAt(x,y,speed) This will lock the view at a specific location on the map. You must call the LockCameraOn fuction to bring the view back to the player. The speed value is 0 for instant,1 for fast scroll, and 2 for slow scroll.
LockCameraOn(player) This command will lock the camera back onto the player. Useful after a LockCameraAt command. The only valid value for player is 0.
AddHiddenItem(x,y) This command will add a hidden item object to the map at x,y.
AddObject(x,y,type,index) This command will add an object at location x,y of type & index. To get an idea of what type and index values to use, add an item using the level editor and hover over it to see it's type and value.
AddObjectComplex(x,y,type,index,xoffset,yoffset) This command will add an object at location x,y of type & index. This command is just like the AddObject command except that the xoffset & yoffset values allow you to adjust the objects location from the center of the tile by any number of pixels.
AddTileComplex(x,y,type,index,xoffset,yoffset,height) This command will add an object at location x,y of type & index. This command is just like the AddObjectComplex function except that it also alows you to specify the height of the object.
AddFlatObject(x,y,index,height) This command is useful for adding bridges & tunnels at specific locations because you can specify the height. Use an index of 0 or 1 for the two types of bridges/tunnels.
AddLandArea(x1,y1,x2,y2) & SetLandOwnership(land index, owner) These two commands can be used to set a location on the map that the player is allowed to bulldoze and adjust the height of. For example, lets say we wanted the player to be able to bulldoze the upper left corner of the map:
AddLandArea(0,0,5,5) SetLandOwnership(0,0) SetObjectiveTick(speed) This command will set the tick speed. Once the tick speed is set it will call the script function ObjectiveTick() at speed/100 times per second.
SetWaypoint(x,y) This command allows you to set a waypoint so that you can have an arrow along the bottom of the screen pointing to your objective.
ClearWaypoint() This will clear the waypoint set by SetWaypoint.
AddMapPoint(x,y) This command will add a point to the map and it will overlay along the bottom of the screen. Useful for objectives. You can add up to 50 points at a time.
ClearMap() This will clear the map overlay of all it's points.
RemoveMapPoint(x,y) This allows you to remove a single point from the map.
IsObject(x,y,type,index) This command will return 1 if an object of type & value is at location x,y otherwise it will return a 0.
PlayerVehicle() This command will return what vehicle your player is currently in. Example:
ship=PlayerVehicle()
Custom Level Functions
Stuntman Evolution expects several functions to be defined in the custom level script. You'll need to define the following functions in your level script:
BeginLevel, InGameMenu, ShipAction, GameTick, LocationChange, Jump, GapSelected, BoardShip, AcceptObjective, Sign, HiddenItem, PointOfInterest, ShipAvailable, ObjectiveTick, LevelProgress.
And Some optional functions depending on your level: ProcessMenu, HitWaypoint, ObjectiveItem.
Now I'm going to describe all the functions and their purpose in detail. Unless you plan on changing the functionality of the standard game mechanics you can just cut & paste these functions from the Tic-Tac-Toe example and edit as necessary.
BeginLevel() This function is called right when the level begins. Use it to set the player location, start background music, set and global variables you might need, add items to the map, add vehicles to the map, etc.
ShipAction(ship) This function is called whenever the player presses the action button. It passed the ship type as a variable for your convenience.
GameTick(tick) This function is called once per second. Use it for whatever you'd like.
LocationChange(x,y) This function is called whenever the player moves into the next tile on the map. The function is usually not needed, but can be used for anything.
Jump(takeoffx,takeoffy,landx,landy) This function is called whenever the player jumps from one location to another. It's normally used to calculate when the player hits a gap. You don't usually need to modify this function.
GapSelected(gap) This function is called when the player selects a gap from the Gap List. Usually used to show gaps to the player.
BoardShip(ship) This function is called whenever the player boards a vehicle.
AcceptObjective(x,y) This function is called whenever the player accepts an objective.
Sign(x,y) This function is called when the player is near a sign. Simply return what the sign says. See Tic Tac Toe example.
HiddenItem(x,y) This function is called when the player finds a hidden package.
PointOfInterest(x,y) This function is called when the player finds a point of interest.
ShipAvailable(index) This function is called when the player is using a telepad to determine what ships are available.
ObjectiveTick() This function is required if the level uses the SetObjectiveTick command and is called N times per second -- set by the SetObjectiveTick command.
LevelProgress() This function is called when the player selects the level progess menu item and returns all the objective info to the game.
ProcessMenu(index) This optional function is required if the level uses the PopMenu() command.
HitWaypoint(x,y) This optional function is called when the player hits a waypoint. This is required if the level uses the addwaypoint command.
ObjectiveItem(x,y) This function is called if the player moves over an Objective and presses the B button.
InGameMenu() This function is called when the player presses the back button which brings up the game menus. This function can be used to pop up additional tabs into the game menu.
In addition to these functions you can create your own for use within these functions.
Hopefully this gives you enough information to create the levels you've thought up. If you can't figure something out, ask for details on the forums.
|