A CTF Mapscript Tutorial
In ET we often have maps where there are accums storing the score for each team. Most of the times, if a certain team has reached a specific amount of score, the map ends, doing this in the mapscript by simply triggering the endgame block depending on a limit reached.
But what if the maptime expires and there is still no winner. We would have two accums storing the score for each team and now ? How can we compare them ? And how can we set the winner, when we cant figure out which accum stores a higher value ?
So comparing two different kinds of accums in the ET Mapscripting language is impossible. But what we can do is create an additional accum doing the job.
This works like this:
- when allies score we add +1 to our accum
- when axis score we add -1 to our accum
- when the maptime expires and noone reached the neccessary amount of captures we look at our third accum and trigger three different kind of blocks. Inside those we will use conditions like…
[ul]
[li]accum n abort_if_less_than 0
[/li][li]accum n abort_if_greater_than 0
[/li][li]accum n abort_if_equal 0
[/li][/ul]
…to actually parse the winner or let it be draw. Here is how it is meant:
game_manager
{
spawn
{
wait 200
accum 0 set 0 //allies score
accum 1 set 0 //axis score
accum 2 set 0 //additional accum
wm_setwinner 0 //important to set a winner here to make trigger timelimit_hit available
}
trigger score_al
{
accum 0 inc 1
accum 2 inc 1
accum 0 abort_if_not_equal 3
wm_setwinner 1
wm_endround
}
trigger score_ax
{
accum 1 inc 1
accum 2 inc -1
accum 1 abort_if_not_equal 3
wm_setwinner 0
wm_endround
}
//this gets called when the maptime expires
trigger timelimit_hit
{
trigger self win_al
trigger self win_ax
trigger self win_draw
}
trigger win_al
{
accum 2 abort_if_less_than 0
accum 2 abort_if_equal 0
wm_setwinner 1
wm_endround
}
trigger win_ax
{
accum 2 abort_if_greater_than 0
accum 2 abort_if_equal 0
wm_setwinner 0
wm_endround
}
trigger win_draw
{
accum 2 abort_if_not_equal 0
wm_setwinner -1
wm_endround
}
}
score_al //we assume this is a CTF entity
{
spawn
{
}
trigger captured
{
trigger game_manager score_al
}
}
score_ax
{
spawn
{
}
trigger captured
{
trigger game_manager score_ax
}
}
This also can be done with globalaccums, i decided for locals here. Just focus on accum 2 and what its doing. When the maptime expires the timelimit_hit block gets executed and does all the work.
Source: Splash Damage Forums.
Compressed by Qualmi


