Send feedback to feedback@q3f.com
Visit #q3f on IRC: irc.be.quakenet.org, east.gamesnet.net or irc.enterthegame.com


Q3F News Sites
PlanetQ3F

PlanetFortress Germany

Q3F.SE

Q3F.Fr

AusFortress

Custom Levels
Leakspot.net

Q3F Server Sites
RailBait

CannonFodder

Tutorial 02: Advanced CTF
In the first CTF flag tutorial you learned how to define teams, spawn flags and create capture points. You can think of this as the bare bones of CTF - its workable but not very interesting. You can do a lot more with some careful planning. In this tutorial I'll show you how to implement multiple teams and resupply packs.

Firstly whenever you do the ents on a more advanced map its important to be absolutely sure of what you're trying to achieve. Things can get very confusing if you just charge in without preparation. Personally I like to make a quick list of my goals to refer back to:

1) Implement four teams (red,blue,green,yellow)
2) Spawn four flags
3) Player must not be able to carry multiple flags
4) Player must be able to cap and be rewarded 10 team points
5) Capturing a teams flag will close a defense door leading to that area.

The last point is where things get complex - I'll explain more below.

1)
--
Open the entity editor and select worldspawn. Add a map message and declare the teams:

Next create info_player_starts for each team. It is customary to have AT LEAST one per team member. Given the current limits on the Q3A engine that will probably mean 5 per team - but to be on the safe side 8-12 is preferable.

2)
--
Next we need to spawn our flags. This is done very much like in normal CTF, except we need to add the following line:

This is for the red flag - change the teams for each of the other flags. Your flag should now look something like this:

{
"light" "150"
"_color" "1.000000 0.392157 0.392157"
"wait" "60"
"carried_flaginfo" "%N is carrying the ^4blue ^* flag!"
"inactive_flaginfo" "The ^4blue ^* flag is at base."
"active_flaginfo" "The ^4blue ^* flag has been dropped in the field!"
"flags" "showcarry,revealspy"
"active_all_message" "The ^4blue ^*flag was dropped in the field!"
"inactive_all_message" "The ^4blue ^*flag returned to base!"
"classname" "func_goalitem"
"allowteams" "red,green,yellow"
"groupname" "blueflag"
"carried_all_message" "%N nabbed the ^4blue ^*flag!"
"carried_message" "~You got the ^4blue ^*flag! Run for it!"
"model" "models/flags/b_flag.md3"
"origin" "0 0 0"
"carried_all_sound" "sound/misc/q3f_alarm.wav"
"carried_sound" "sound/misc/q3f_alarm.wav"
}

3)
--
As it stands the player can carry multiple flags. This would be fine if the game demanded it (such as in q3f_crossfire) but is not what we want in this case. We will use the 'notholding' key to sort this. Because the logic on 'notholding' is AND rather than OR a line like:

'notholding' 'greenflag,redflag,blueflag'

will not work - you would need to be not holding all three, rather than just one.
The solution is to tell each flag not just what it is, but also what it isn't:

This may seem a little obscure, but we can now use the notholding key:

Now if the activator is holding a flag they can't pick up another. Our final flag therefore looks like this:

{
"light" "150"
"_color" "1.000000 0.392157 0.392157"
"wait" "60"
"notholding" "notblueflag"
"carried_flaginfo" "%N is carrying the ^4blue ^* flag!"
"inactive_flaginfo" "The ^4blue ^* flag is at base."
"active_flaginfo" "The ^4blue ^* flag has been dropped in the field!"
"flags" "showcarry,revealspy"
"active_all_message" "The ^4blue ^*flag was dropped in the field!"
"inactive_all_message" "The ^4blue ^*flag returned to base!"
"classname" "func_goalitem"
"allowteams" "red,green,yellow"
"groupname" "blueflag,notredflag,notgreenflag,notyellowflag"
"carried_all_message" "%N nabbed the ^4blue ^*flag!"
"carried_message" "~You got the ^4blue ^*flag! Run for it!"
"model" "models/flags/b_flag.md3"
"origin" "0 0 0"
"carried_all_sound" "sound/misc/q3f_alarm.wav"
"carried_sound" "sound/misc/q3f_alarm.wav"
}

You can copy this flag straight into your map file if you wish.

4)
--
We'll borrow the capture ent from the normal CTF tutorial.

{
"classname" "func_goalinfo"
"origin" "0 0 0"
"holding " "blueflag"
"teamscore" "10"
"active_team_sound" "sound/teamplay/flagcap_red.wav"
"active_all_message" "~%N CAPTURED the ^4blue ^*flag!"
"active_sound" "sound/teamplay/flagcap_red.wav"
"activetarget" "blueflag=~inactive"
}

This will allow capture of the blue flag, but not any of the others. Assuming this was the green base we couldn't use a 'holding' 'notgreenflag'. Although it would activate fine there is no way to cleanly return the flag - "activetarget" "notgreenflag=~inactive" would return all the non green flags - not what we want at all. The solution is slightly long winded, but works fine. Simply make two more copies of this capture point and adjust one to 'redflag' and the other to 'yellowflag', then stack all 3 on your capture point:

Repeat this in each base for a total of 12 capture points. There you have it - a four team CTF map.

The last thing I'll show you is resupply packs. These are normally placed in or near the re-spawn rooms so your team can tool up before going into battle. You'll a func_goalinfo:

{
"classname" "func_goalinfo"
"allowteams" "red"     // don't want any of those nasty blues using our ammo...
"flags" "hideactive"    // hide for 'wait' seconds, visual clue to show it can't be used
"active_all_sound" "sound/misc/am_pkup.wav"    // play this sound when used
"give" "health=+100,armor=+100,ammo_shells=+100,
        ammo_bullets=+100,ammo_rockets=+100,ammo_cells=+100,
        gren1=+2,gren2=+1,ammo_medikit=+100"     // restock as required
"model" "models/objects/backpack/backpack.md3"     // display this model
"wait" "4"     // can be used once per 'wait' seconds
}

Spread these around your base as needed and adjust the 'give' to give the appropriate amounts of ammo.

- by Steve 'MrChumble' Batham


Site design ©1999, 2000, 2001, 2002 RR2DO2.
Q3F ©1999, 2000, 2001, 2002 Q3F. For legal info click here.