Timed CTF

Expand and mod your server.
Post Reply
User avatar
LouMan
Chief Sgt. of Cartography
Chief Sgt. of Cartography
Posts: 338
Joined: Mon Jan 31, 2005 3:05 am
Location: Michigan, USA

Timed CTF

Post by LouMan » Wed Jan 03, 2007 9:33 pm

timedctf plugin

Author: LouMan
Description: See below.
Min Version: Latest CVS 2.0 branch code (to compile), bzfs 2.0.8

** NOTE: the plugin is committed to CVS; can be obtained there.

Description:

It will start a timed capture the flag game in which a team must capture another team's flag in a configurable amount of time. If the time expires before the team captures a flag, all members of the team will be destroyed and the timer will restart for that team. If the team captures another team's flag before their time expires, their timer is reset and starts counting down again. All 4 teams have individual timers.

There are warning messages sent to individual teams as their time starts to expire:

A warning every minute (with time remaining) until the last minute.
A warning at 30 seconds before time expires.
A warning at 10 seconds before time expires.
(boom)

The plugin also monitors the balance of teams and will disable the timer if teams are uneven. To determine if teams are balanced or not, at least a 75% match is used. This means that even teams would be considered:

1 vs 1 (100%)
2 vs 2 (100%)
3 vs 3 (100%)
3 vs 4 (75%)
4 vs 4 (100%)
4 vs 5 (80%)
5 vs 5 (100%)
5 vs 6 (83%)
and so on.

If the teams are uneven, capture the flag is disabled; if a player tries to pick up a team flag, it will almost immediately be dropped.

The plugin is set up for all 4 teams (red, green, blue and purple) and will monitor/time all 4 teams. However, it is best suited to 2 team capture the flag type maps in that it only looks for the 75% match between any 2 team sizes. This means that it is possible (on a 4 team ctf map) to have teams considered to be even if:

1 vs 1 vs 3 vs 1
2 vs 2 vs 8 vs 1
and so on.

There are also informative messages when the status of the game changes, for example:

If a new player joins/parts that causes team imbalance, a message is sent stating that teams are uneven and timed ctf is disabled. If a new player joins/parts that balances teams out, a message is sent that timed ctf is enabled and how much time there is to capture a flag. And so on...

There are also standard CTF sounds used whenever significant events take place.

The plugin has the following commands available to administrators:

"ctfcaptime m" : this will change required capture time to m (1-120 minutes).
"ctfcaptimeoff" : this will disable timed CTF.
"ctfcaptimeon" : this will enable timed CTF.
"ctfcaptimestatus" : this will return the current status of functions and the current time limit.
"fairctfoff" : this will disable the fair ctf function.
"fairctfon" : this will enable the fair ctf function.

Note that the balance of teams will still be monitored when the ctf timer is off, and team flags will be dropped if teams are uneven (as described above). This allows this plugin to be utilized for fair, normal ctf play as well, if the ctf timer is turned off. If both functions (ctfcaptime and fairctf) are turned off, the plugin is effectively disabled. If the fair CTF function is disabled and the timed CTF function is enabled, the plugin will check for at least 2 teams present before allowing timed CTF to take place.

It will also allow the time limit to be passed to the plugin through the -loadplugin command line with bzfs. The format is as follows:

"-loadplugin <path>timedctf,m" where m is the timer value (in minutes) for timed ctf. For example,

"-loadplugin plugins/timedctf,7" would start the plugin with the timer set for 7 minutes. Again, the minimum is 1 minute and the maximum is 120 minutes. If no time is specified, the plugin defaults to 5 minutes.

Although I have tested this plugin extensively on a local level, there may be a bug or two that I am not aware of. Please notify me of any issues you may have with it and I will address them as quickly as possible.
Last edited by LouMan on Wed Jan 31, 2007 8:54 pm, edited 7 times in total.

User avatar
macsforme
General
General
Posts: 2033
Joined: Wed Mar 01, 2006 5:43 am

Post by macsforme » Wed Jan 03, 2007 10:55 pm

VERY cool idea, although I personally think that the timed ctf functionality should be distinct from the no-unfair-capping funcitonality (and should be in different plugins... there's already the FairCTF plugin).

User avatar
LouMan
Chief Sgt. of Cartography
Chief Sgt. of Cartography
Posts: 338
Joined: Mon Jan 31, 2005 3:05 am
Location: Michigan, USA

Post by LouMan » Wed Jan 03, 2007 11:24 pm

I thought that the fair ctf was essential to timed ctf, so I wrote it such that you cannot have timed ctf without fair ctf. It automatically switches off/on timed ctf based on team fairness. I thought that having both functionalities in the same plugin would be more convenient.

Again, it is best suited to two team ctf matches, even though it can support all four teams.

User avatar
macsforme
General
General
Posts: 2033
Joined: Wed Mar 01, 2006 5:43 am

Post by macsforme » Thu Jan 04, 2007 12:53 am

I can't get it to compile right... something about the bz_ePlayerUpdateEvent?

Code: Select all

const@xxxxx:~/src/timedctf$ g++ -shared -I /home/xxxxx/bzflag/include -o timedctftest.so timedctf.orig.cpp 
timedctf.orig.cpp: In function 'int bz_Load(const char*)':
timedctf.orig.cpp:52: error: 'bz_ePlayerUpdateEvent' was not declared in this scope
timedctf.orig.cpp: In function 'int bz_Unload()':
timedctf.orig.cpp:68: error: 'bz_ePlayerUpdateEvent' was not declared in this scope
timedctf.orig.cpp: In member function 'virtual void PlayerUpdates::process(bz_EventData*)':
timedctf.orig.cpp:461: error: 'bz_ePlayerUpdateEvent' was not declared in this scope
timedctf.orig.cpp:468: error: 'bz_PlayerUpdateEventData' was not declared in this scope
timedctf.orig.cpp:468: error: expected primary-expression before ')' token
timedctf.orig.cpp:468: error: expected `)' before 'eventData'
timedctf.orig.cpp:469: error: 'bz_getPlayerFlag' was not declared in this scope
You do have a valid point about how even teams and the timer go hand-in-hand... perhaps the timedctf plugin should just use the evenness calculation to turn itself on and off instead of disabling ctf? Interesting.

User avatar
LouMan
Chief Sgt. of Cartography
Chief Sgt. of Cartography
Posts: 338
Joined: Mon Jan 31, 2005 3:05 am
Location: Michigan, USA

Post by LouMan » Thu Jan 04, 2007 2:17 am

It might be that the bz_ePlayerUpdateEvent & bz_GetPlayerFlag are fairly new additions to the API (I think that JeffM2501 added them for the flagStay plugin not so long ago). If you are able, download the latest BZFlag 2.0 branch code and try again. I will change the version requirement above to this level - sorry.

User avatar
macsforme
General
General
Posts: 2033
Joined: Wed Mar 01, 2006 5:43 am

Post by macsforme » Mon Jan 08, 2007 12:21 am

Nice plugin... I'e had it running for several days at my server @ gnudux.homelinux.net:5170. I have a few suggestions:

1. Allow explicit capture time assignment with something like "/ctfcaptime 10" (for ten minutes).
2. Allow capture time assignment on plugin load with with "/loadplugin timedctf.so,10" for ten minutes. This will allow server owners to configure the capture time in their conf file.
3. Add feature that would allow admins to disable the plugin with a command like "/ctfcaptimeoff", or something like that. I've had admins want to turn it off temporarily, and telling them to run "/unloadplugin /path/to/plugin.so" is kind of confusing to the non-techie types. ;-)

User avatar
LouMan
Chief Sgt. of Cartography
Chief Sgt. of Cartography
Posts: 338
Joined: Mon Jan 31, 2005 3:05 am
Location: Michigan, USA

Post by LouMan » Mon Jan 08, 2007 12:50 am

Thanks for the feedback :)

#3: Already done and should work (see original post); /ctfcaptimeoff will disable timer, but fair ctf will still work. Did you mean fair CTF too?

#2: I am already looking into this - should have something soon.

#1: Ditto.

:) Thanks again!

User avatar
macsforme
General
General
Posts: 2033
Joined: Wed Mar 01, 2006 5:43 am

Post by macsforme » Mon Jan 08, 2007 5:42 am

LouMan wrote:#3: Already done and should work (see original post); /ctfcaptimeoff will disable timer, but fair ctf will still work. Did you mean fair CTF too?
Oh duh, lol. Should've looked more closely. :-(

No, I just completely missed it. ;-)

User avatar
Zelgadis
Private First Class
Private First Class
Posts: 638
Joined: Sat Jul 02, 2005 2:31 pm
Location: European Union

Post by Zelgadis » Mon Jan 08, 2007 9:05 am

yeah great! :)
Want to improve your skill? Join the http://guleague.org!

User avatar
LouMan
Chief Sgt. of Cartography
Chief Sgt. of Cartography
Posts: 338
Joined: Mon Jan 31, 2005 3:05 am
Location: Michigan, USA

Post by LouMan » Mon Jan 08, 2007 9:50 pm

I am nearly complete with the updates - just need to test them a little more. I have added an explicit command for ctfcaptime (and removed the ctfcaptime+, ctfcaptime-, etc. commands), made it possible to assign ctfcaptime on plugin load and made new commands for "ctfcaptimeon", "fairctfon" and "fairctfoff". I had to modify the code a bit to accomodate the ability to turn the fair ctf function off (e.g. no timed ctf with one team and fair ctf off, etc.)

Look for a version 2 of this plugin in the next few days, after I have tested it a bit. I will include a detailed description of the updated plugin's functionality when it is complete.

User avatar
LouMan
Chief Sgt. of Cartography
Chief Sgt. of Cartography
Posts: 338
Joined: Mon Jan 31, 2005 3:05 am
Location: Michigan, USA

Post by LouMan » Tue Jan 09, 2007 2:44 am

I have updated the original post with version 2.0 of the timedctf plugin - see above for description :)

User avatar
LouMan
Chief Sgt. of Cartography
Chief Sgt. of Cartography
Posts: 338
Joined: Mon Jan 31, 2005 3:05 am
Location: Michigan, USA

Post by LouMan » Tue Jan 23, 2007 12:47 am

Upgraded plugin to version 2.1: added local sounds for when time runs out (standard CTF sounds).

Post Reply