A CTF Mapscript Tutorial


(Qualmi) #1

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


(Miki) #2

Little question,
what will this do : wm_setwinner -1
you’ll always have a winning team in ET, not?


(nUllSkillZ) #3

No.
Double objective maps might not have a winner.
If timelimit is hit and none of the teams has fullfilled all of their objectives the match is a draw.


(IndyJones) #4

still there is no solution to disable ‘objective taken’ sound?


(stealth6) #5

afaik no, the last idea was to override it with an empty sound (less then a second of nothing)


(Qualmi) #6

did you ever try to target your entity to a speaker ?

[QUOTE=Miki;227156]what will this do : wm_setwinner -1
you’ll always have a winning team in ET, not?[/QUOTE]

wm_setwinner -1 actually is a draw. but its not often used and kinda should be avoided. the ending screen will somehow be empty then, you immediately get the feeling that its unusual, and if players have that feeling they will blame it on the map real quick. thats at least my feeling.

[QUOTE=nUllSkillZ;227166]No.
Double objective maps might not have a winner.
If timelimit is hit and none of the teams has fullfilled all of their objectives the match is a draw.[/QUOTE]

in some of the maps you just might want to set a winner when the maptime expires. setting just a draw is not exactly why i set up this tutorial.


(stealth6) #7

you could just wait with the end of the game until the next cap is made or make something like in MW2
by that I mean wait with triggering the end game command

Trigger a massive hurt trigger that kills everybody in the game.
Then when they respawn the first team to touch the other teams flag wins.

Also a draw game isn’t that weird, then instead of saying axis or allied win, it just say DRAW

what’s the problem with that?


(Qualmi) #8

whuaaa…stretchs himself i am bored :slight_smile:

stealth: you have permission to abuse this thread for as many ideas as you have. may the force be with you.

greetz


(IndyJones) #9


i think it really kills the ctf spirit. a lot of times flag changes owner few times per minute, and that get u a lot of spam. replacing obj taken sound by null is possible, but then it applies to all maps… :frowning:


(Darkix) #10

Why did mickey mouse have to die? =[