Tag Game Template - Try to expand into a full fledged game mode

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
User avatar
Zehra
Private First Class
Private First Class
Posts: 921
Joined: Sun Oct 18, 2015 3:36 pm
Location: Within the BZFS API and Beyond it
Contact:

Tag Game Template - Try to expand into a full fledged game mode

Post by Zehra »

A from scratch implementation of "Tag! your it!!!" plug-in.

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)

This done within 40 lines of code and creates a very simple game mode. It can be extended or adapted into a minimalist version of Zombies, HumansVsZombies or even Rabbit Hunt/Chase.

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
Those who are critical of me, I'll likely be the same of them. ~Zehra
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra

See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.

Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
Post Reply