Page 1 of 1

Plugin Idea: sharpshootingRewards

Posted: Tue Jul 10, 2007 5:38 am
by Tropican8
Camping is annoying. I always thought it would be nice to give people more incentive to take out tanks that have Laser or GM versus going for the little defenseless tank who just spawned.

Since 2.1x will allow the server to report individual scores back to clients, I thought a plugin that gives a point bonus for killing someone with a powerful superflag might be interesting.

Sound like a good idea?

Taking it one step further, perhaps such a thing could be integrated with playHistoryTracker. For example, sharpshootingRewards could give players extra points when they end someone else's killing spree.

It might also encourage beginners to seek out the better players and attempt to take them on, thus gaining experience.

Re: Plugin Idea: sharpshootingRewards

Posted: Tue Jul 10, 2007 8:57 am
by Enigma
Tropican8 wrote:Camping is annoying. I always thought it would be nice to give people more incentive to take out tanks that have Laser or GM versus going for the little defenseless tank who just spawned.

Since 2.1x will allow the server to report individual scores back to clients, I thought a plugin that gives a point bonus for killing someone with a powerful superflag might be interesting.

I think this will work. It compiles, but I can't test it because -solo doesn't work in 2.1.x.

Code: Select all

#include "bzfsAPI.h"
#include <string>

class DieHandler : public bz_EventHandler {

public:
  virtual void process(bz_EventData *eventData)
  {
    if(eventData->eventType != bz_ePlayerDieEvent)
      return;
    
    bz_PlayerDieEventData_V1 *eData = (bz_PlayerDieEventData_V1*)eventData;
    
    std::string flag = eData->flagKilledWith.c_str();    
    std::size_t i = 0;
    std::size_t flagPos = std::string::npos;
    
    while(i < 3) {
      flagPos = flag.find(superFlags[i]);
      
      if(flagPos != std::string::npos)
        break;
      
      ++i;
    }
    
    // If this is true, The player doesn't have one 
    // of the flags in superFlags[], so skip the rest
    if(flagPos == std::string::npos)
      return;
    
    
    // The player has one of the flags in superFlags
    // Update the score
    if((eData->killerTeam == eData->team) && 
       (eData->killerTeam != eRogueTeam) &&
       (eData->killerID != eData->playerID)) {
      
      //he tk'ed.  do something here
    } else {
      bz_BasePlayerRecord *killer = bz_getPlayerByIndex(eData->killerID);
      
      if(!killer) return;
      
      /* Not a TK.  Give the player a point. */
      bz_setPlayerWins(eData->killerID, killer->wins + 1);
      
      bz_freePlayerRecord(killer);

    }    
    
  }
  
private:
  static std::string superFlags[3];
};


std::string DieHandler::superFlags[3] = { "SW", "GM", "L" };
Apparently I like the idea. :D