User Tools

Site Tools


scripting:subgames

Scripted Subgames Overview

The 'Subgames' system provides your script with a set of functions that allows dynamic creation, monitoring and conclusion of multiplayer subgames.

The basic process is : - Create a Subgame and join players to it - Start the Subgame (perhaps moving players to a new location, starting timers, etc) - Update the game and wait for end-game criteria to be me - Finish the subgame (perhaps rewarding victorious players before returning them to their original location)

For fuller details of the Subgame script functions see the Subgame Scripting Reference Pages

Basic Subgame Example

A general overview of an implementation of a RC duel subgame. (The full script for this as used on Lovelace will be available in the script examples sections):

- Firstly - we'll choose an ID number for the subgame. If you've only got one subgame on the world, just using subgame 0 is fine, but if you want to have multiple games running simultaneously you'll need to allocate them different numbers. Might be good to set that up using a global variable so its easy to change later.. for this example we'll use global $kCrowDuelSubgameID = 0.

- Now we get the two players into the subgame together e.g.

	SubgameJoin( $kCrowDuelSubgameID, $player1 )
	SubgameJoin( $kCrowDuelSubgameID, $player2 )
(In this example, $player1 and $player2 are the player IDs for the two players who want to play in the subgame. There are various techniques we can use to collect the IDs of the players involved - e.g. Send out a global notification message and join the $gPlayerID of everyone who accepts the prompt.. or you could use the Subgame Duels system.)

- .. next we set up the RC game state ; setting the players spawn positions and lives, and locking the weapons

	*crowspawn $playerName1 176 75
	*crowspawn $playerName2 177 70

	*crowlives $playerName1 2
	*crowlives $playerName2 2

	*lockweapons $playerName1
	*lockweapons $playerName2

- When we're ready to start (again, the Subgame Duels system provides helpers for controlling this), we activate the scoreboard and trigger an event for both the players in the duel..

	SubgameActivateScoreboard( $kCrowDuelSubgameID, 0 )
	SubgameEventAll( $kCrowDuelSubgameID, "DuelStart", "" )

- We'll create the custom 'DuelStart' event to put the players in RC mode, get them players ready, unlock their weapons and set a timer for the end of the game, e.g:

Event( "Subgame", "DuelStart" )
{
	*gocrow %PLAYER%
	*centraltext %PLAYER% Ready up. Round starts in 10 seconds..
	Sleep( 70 )
	*countdown %PLAYER% 3 0
	Sleep( 30 )
	*onscreentimer %PLAYER%,0,180
	*unlockweapons %PLAYER%
	SubgameSetTimer( $kCrowDuelSubgameID, 0, 180, "CrowDuelEndTimer", 0 )
}

- While the players are duelling, the script listens in to “RobocrowKill” events, and tallies up the player scores using SubgameIncrementScore. Here we might also implement logic such as finishing the game if a player gets to a certain number of kills.

- When the 'CrowDuelEndTimer' expires (or some other winning criteria is met), we check the scores, award prizes and then finish off the subgame using SubgameReset( $kCrowDuelSubgameID )

scripting/subgames.txt · Last modified: 2023/04/05 11:59 by mit

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki