This plug-in and code is granted under the terms of CC0-1.0 license.
Code: Select all
// tagGame.cpp
//
#include "bzfsAPI.h"
class tagGame : public bz_Plugin
{
public:
virtual const char* Name(){return "TagGame[0.0.1]";}
virtual void Init (const char* commandLine) {
bz_debugMessage(4,"TagGame loaded");
Register(bz_ePlayerDieEvent);
Register(bz_ePlayerSpawnEvent);
}
virtual void Event(bz_EventData *eventData ){
if (eventData->eventType == bz_ePlayerDieEvent) {
bz_PlayerDieEventData_V1* data = (bz_PlayerDieEventData_V1*)eventData;
bz_resetFlag(data->killerID);
if ((data->playerID != data->killerID) && (data->killerID != BZ_SERVER)) {
bz_sendTextMessage(BZ_SERVER,data->playerID,"TAG: You're it!");
bz_sendTextMessage(BZ_SERVER,data->killerID,"TAG: You're not it anymore!");
}
} else if (eventData->eventType == bz_ePlayerSpawnEvent) {
bz_PlayerSpawnEventData_V1* data = (bz_PlayerSpawnEventData_V1*)eventData;
bz_givePlayerFlag(data->playerID,"SR",0);
} else {
return;
}
}
virtual void Cleanup (void) {
bz_debugMessage(4,"TagGame unloaded");
Flush();
}
};
BZ_PLUGIN(tagGame)
Or even simply switch the death event to allowCap, check if it is a proper cap, deny the cap, reset the team flag, modify team(s) scores and play audio for flag capture. The result is a version of CTF without players dying on cap. (And you just need to remove the flag give on spawning.)
I hope to see some inspired to try to extend or modify this, as this basic form can be easily adapted to mostly any game mode.
-Zehra