Author: allejo
Description: After every cap this plugin will reset all flags excluding team flags in order to keep flags evenly spread out and prevents a user from using the same flag too much.
Min Version: Tested on 2.4.0
Notes:
* This plugin only resets flags after each cap. This means this plugin will NOT reset flags in a FFA, KOTH, or Rabbit Hunt game.
* This plugin only works correctly if there is one team flag for every team, if a map has more than one team flag for each team (such as an HTF) this plugin will not work.
License: BSD
This plugin is on GitHub. Read further documentation and/or report any issues to GitHub.
Download
flagResetOnCap 2.0
flagResetOnCap 2.0
flagResetOnCap 2.0
Last edited by allejo on Sat Feb 18, 2012 10:15 pm, edited 10 times in total.
Re: flagResetOnCap 1.0
Great job! Glad you finally got it worked out.
The only thing I would recommend doing is making it auto-detect the number of teams so you dont have to put it in manually each time.
The only thing I think that would help you with that would be Bz_getTeamPlayerLimit which would still need a little manipulating to get it to work.
Good luck and nice work
The only thing I would recommend doing is making it auto-detect the number of teams so you dont have to put it in manually each time.
The only thing I think that would help you with that would be Bz_getTeamPlayerLimit which would still need a little manipulating to get it to work.
Good luck and nice work
flagResetOnCap 1.0 (Parameter Based)
If you would like the plugin to have a parameter to state the number of teams playing in the CTF game use this source file.
How to load:
How to load:
Code: Select all
In a conf file add: -loadplugin /path/to/flagResetOnCap.so,<number of teams playing CTF(excluding rogue if any)>
In the game type: /loadplugin /path/to/flagResetOnCap.so,<number of teams playing CTF(excluding rogue if any)>
- Attachments
-
- flagResetOnCap.cpp
- v1.0 Parameter based
- (2.03 KiB) Downloaded 182 times
Re: flagResetOnCap 1.0
Thanksmrapplecomputer1 wrote:Great job! Glad you finally got it worked out.
Done, the bz_getTeamPlayerLimit was used but not how most people would think. flagResetOnCap v1.1 automatically detects the number of teams playing but if you still like to use a parameter download flagResetOnCap v1.0, which is located right above this post.mrapplecomputer1 wrote:The only thing I would recommend doing is making it auto-detect the number of teams so you dont have to put it in manually each time.
The only thing I think that would help you with that would be Bz_getTeamPlayerLimit which would still need a little manipulating to get it to work.
Good luck and nice work
Re: flagResetOnCap 1.1
For some reason I felt like cleaning up your code. There are a few guidelines you should be aware of: 1) Generally, you should only use variables if they are going to be used more than once in your code. 2) Do not Repeat Yourself (DRY). You should try to remove all repeat code.
Note that C++ treats any non-zero integer as true in boolean expressions. The getNumTeams() function uses this fact.
All the code is here: http://pastebin.com/u6Y9hT1b
Note that C++ treats any non-zero integer as true in boolean expressions. The getNumTeams() function uses this fact.
Code: Select all
#define TOTAL_CTF_TEAMS 4
unsigned int getNumTeams()
{
return TOTAL_CTF_TEAMS - (!bz_getTeamPlayerLimit(eRedTeam) +
!bz_getTeamPlayerLimit(eGreenTeam) +
!bz_getTeamPlayerLimit(eBlueTeam) +
!bz_getTeamPlayerLimit(ePurpleTeam));
}
void ONCAPHandler::process ( bz_EventData *eventData )
{
for(int i = getNumTeams(); i < bz_getNumFlags(); i++)
bz_resetFlag(i);
}
Re: flagResetOnCap 1.1
Thank you Enigma for cleaning up my code. Small little update to the plugin. The plugin will only reset unused flags on cap.
Re: flagResetOnCap 2.0
Plugin updated to BZFlag 2.4. See first post