Page 1 of 1

flagResetOnCap 2.0

Posted: Sun Dec 20, 2009 5:57 am
by allejo
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

Re: flagResetOnCap 1.0

Posted: Sun Dec 20, 2009 2:02 pm
by mrapple
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 :)

flagResetOnCap 1.0 (Parameter Based)

Posted: Sun Dec 20, 2009 5:14 pm
by allejo
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:

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)>

Re: flagResetOnCap 1.0

Posted: Sun Dec 20, 2009 5:18 pm
by allejo
mrapplecomputer1 wrote:Great job! Glad you finally got it worked out.
Thanks :D
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 :)
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. :D

Re: flagResetOnCap 1.1

Posted: Mon May 17, 2010 1:20 am
by Enigma
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.

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);
}
All the code is here: http://pastebin.com/u6Y9hT1b

Re: flagResetOnCap 1.1

Posted: Sun Oct 10, 2010 11:26 pm
by allejo
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

Posted: Tue Jun 21, 2011 3:53 am
by allejo
Plugin updated to BZFlag 2.4. See first post