User talk:Maikel: Difference between revisions
Line 10: | Line 10: | ||
The parkour goal can not be created through a Scenario.txt entry, since the checkpoints have to be created manually. Thus the obvious location to create the parkour goal is in the scenario script, an example of such a script is given here. | The parkour goal can not be created through a Scenario.txt entry, since the checkpoints have to be created manually. Thus the obvious location to create the parkour goal is in the scenario script, an example of such a script is given here. | ||
/*-- ''Parkour'' --*/ | |||
protected func Initialize() | protected func Initialize() | ||
{ | { | ||
Line 32: | Line 34: | ||
return; | return; | ||
} | |||
// ''Callback from parkour goal to the scenario script.'' | |||
protected func PlrHasRespawned(int plr, object cp) | |||
{ | |||
// ''Give the player a shovel when he respawns.'' | |||
var clonk = GetCrew(plr); | |||
clonk->CreateContents(Shovel); | |||
} | } | ||
Line 38: | Line 48: | ||
creates a start checkpoint at the global coordinates <nowiki>x</nowiki> and <nowiki>y</nowiki> and returns the checkpoint just created. After that 10 checkpoints are created ordered along the x direction at random height, for this the function | creates a start checkpoint at the global coordinates <nowiki>x</nowiki> and <nowiki>y</nowiki> and returns the checkpoint just created. After that 10 checkpoints are created ordered along the x direction at random height, for this the function | ||
public func AddCheckpoint(int x, int y, int mode) | public func AddCheckpoint(int x, int y, int mode) | ||
is used. This creates a checkpoint at the global coordinates <nowiki>x</nowiki> and <nowiki>y</nowiki> with the specified mode and returns the checkpoint just created. Checkpoint modes will be explained later, just note here that the checkpoints created in the example have to be passed in order and respawn the player at the latest passed checkpoint. In the last line the the parkour finish is created, also here only one finish should be created. | is used. This creates a checkpoint at the global coordinates <nowiki>x</nowiki> and <nowiki>y</nowiki> with the specified mode and returns the checkpoint just created. Checkpoint modes will be explained later, just note here that the checkpoints created in the example have to be passed in order and respawn the player at the latest passed checkpoint. In the last line the the parkour finish is created, also here only one finish should be created. The function | ||
public func SetFinishpoint(int x, int y) | |||
creates a finish checkpoint at the global coordinates <nowiki>x</nowiki> and <nowiki>y</nowiki> and returns the checkpoint just created. The parkour goal also provides a callback to the scenario script | |||
PlrHasRespawned(int plr, object cp) | |||
when the player is (re)spawned at a checkpoint. The player number and the checkpoint are passed as parameters. With this callback you can give the player necessary equipment to overcome the challenges provided. | |||
== Checkpoints == | == Checkpoints == |
Revision as of 17:55, 2 November 2010
Test for Tutorial: Creating a parkour
This tutorial provides a basis for scenario designers wanting to create a parkour. It explains the basics and some extended features of the parkour goal. Furthermore some elementary design issues for parkours will be addressed.
Parkour
A parkour is basically an extended race, players have to get from start to finish but have to pass checkpoints in between. The parkour goal gives the scenario designer options to adjust the path, thereby increasing the challenge for the players. Other features would be creating team parkours, where players need to split up and complete different paths to join forces later. On the player's side rounds get less frustrating since you would only have to redo parts of a parkour after having died, as you respawn at the latest passed checkpoint.
Scenario script
The parkour goal can not be created through a Scenario.txt entry, since the checkpoints have to be created manually. Thus the obvious location to create the parkour goal is in the scenario script, an example of such a script is given here.
/*-- Parkour --*/ protected func Initialize() { // First create the goal and store it. var goal = CreateObject(Goal_Parkour); // Place the start at the left of the map. goal->SetStartpoint(50, LandscapeHeight() / 2); // Place some checkpoints from left to right at random height in between. var cp_count = 10; for (var cp_num = 1; cp_num <= cp_count; cp_num++) { var x = cp_num * LandscapeWidth() / (cp_count + 1); var y = Random(LandscapeHeight()); var cp_mode = PARKOUR_CP_Check | PARKOUR_CP_Respawn | PARKOUR_CP_Ordered; goal->AddCheckpoint(x, y, cp_mode); } // Place the finish at the right of the map. goal->SetFinishPoint(LandscapeWidth() - 50, LandscapeHeight() / 2); return; } // Callback from parkour goal to the scenario script. protected func PlrHasRespawned(int plr, object cp) { // Give the player a shovel when he respawns. var clonk = GetCrew(plr); clonk->CreateContents(Shovel); }
This of course cries for an explanation. First note that for a static map, i.e. those created from a Map.bmp, you can look for decent places for your checkpoints and create them. For dynamic maps you need to let a script search a decent location, in this example script we do not worry about such issues. So in the first line the parkour goal is created and stored in goal, cause we need that later. The second line creates the parkour start, only create one start checkpoint. The function
public func SetStartpoint(int x, int y)
creates a start checkpoint at the global coordinates x and y and returns the checkpoint just created. After that 10 checkpoints are created ordered along the x direction at random height, for this the function
public func AddCheckpoint(int x, int y, int mode)
is used. This creates a checkpoint at the global coordinates x and y with the specified mode and returns the checkpoint just created. Checkpoint modes will be explained later, just note here that the checkpoints created in the example have to be passed in order and respawn the player at the latest passed checkpoint. In the last line the the parkour finish is created, also here only one finish should be created. The function
public func SetFinishpoint(int x, int y)
creates a finish checkpoint at the global coordinates x and y and returns the checkpoint just created. The parkour goal also provides a callback to the scenario script
PlrHasRespawned(int plr, object cp)
when the player is (re)spawned at a checkpoint. The player number and the checkpoint are passed as parameters. With this callback you can give the player necessary equipment to overcome the challenges provided.
Checkpoints
A checkpoint can have various modes, these can be assigned using a bit mask. The different modes are
PARKOUR_CP_Start PARKOUR_CP_Finish PARKOUR_CP_Check PARKOUR_CP_Respawn PARKOUR_CP_Ordered PARKOUR_CP_Team
Landscape
Dynamic vs. static.