For those of you who never played UT,
Domination is a game where two teams fight over control points (CP).
Every X seconds the game ticks, and each team gets points for each CP they control at that moment.
CODE
Code:
//------------------
// Title: Domination
// Desc: ???
// Author: Spidey
//------------------
#include "StdAfx.h"
#include "Setup.h"
#define DOM_TICK 30000;
//Every how many ms would we get points?
static uint32 dom_cp1 = -1; //control points
static uint32 dom_cp2 = -1;
static uint32 dom_cp3 = -1;
static uint32 dom_alliance = 0; //alliance points
static uint32 dom_horde = 0; //horde points
static bool dom_enabled = false;//is the game in progress?
static TimedEvent * te;
class DOMTick
{
public:
void Run();
};
void DOMTick::Run()
{
if(!dom_enabled)
return;
if(dom_cp1 == 0){
dom_alliance++;
} else if (dom_cp1 == 1){
dom_horde++;
}
if(dom_cp2 == 0){
dom_alliance++;
} else if (dom_cp2 == 1){
dom_horde++;
}
if(dom_cp3 == 0){
dom_alliance++;
} else if (dom_cp3 == 1){
dom_horde++;
}
char scr[1024];
sprintf(scr, "Domination ticked! Alliance: %u | Horde: %u. Next tick in 20 seconds!", dom_alliance, dom_horde);
sWorld.SendWorldWideScreenText(scr);
}
void DOMStart(){
dom_enabled = true;
dom_alliance = 0;
dom_horde = 0;
dom_cp1 = -1;
dom_cp2 = -1;
dom_cp3 = -1;
sWorld.SendWorldWideScreenText("Domination event started!");
}
void DOMEnd(){
dom_enabled = false;
char msg[1024];
//calculate score
if(dom_horde == dom_alliance){
//Tie!
sprintf(msg, "Domination event ended in a tie! Final score: %u", dom_horde);
} else if (dom_horde > dom_alliance){
//Hordies win
sprintf(msg, "Domination event ended: HORDE WINS! Horde %u : Alliance %u", dom_horde, dom_alliance);
} else {
//allies win
sprintf(msg, "Domination event ended: ALLIANCE WINS! Horde %u : Alliance %u", dom_horde, dom_alliance);
}
sWorld.SendWorldWideScreenText(msg);
}
class DOMStarter : public GameObjectAIScript
{
public:
DOMStarter(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
static GameObjectAIScript *Create(GameObject * GO) { return new DOMStarter(GO); }
void OnActivate(Player * pPlayer)
{
if(pPlayer->GetSession()->HasGMPermissions())
{
if(dom_enabled)
DOMEnd();
else
DOMStart();
} else {
pPlayer->BroadcastMessage("Can't touch this");
}
}
};
class CP1 : public GameObjectAIScript
{
public:
CP1(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
static GameObjectAIScript *Create(GameObject * GO) { return new CP1(GO); }
void OnActivate(Player * pPlayer)
{
if(dom_enabled)
{
dom_cp1 = pPlayer->GetTeam();
char msg[100];
sprintf("[%s]%s captured control point 1!", pPlayer->GetTeam() ? "Alliance" : "Horde", pPlayer->GetName();
sWorld.SendWorldWideScreenText(msg);
}
}
};
class CP2 : public GameObjectAIScript
{
public:
CP2(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
static GameObjectAIScript *Create(GameObject * GO) { return new CP2(GO); }
void OnActivate(Player * pPlayer)
{
if(dom_enabled)
{
dom_cp2 = pPlayer->GetTeam();
char msg[100];
sprintf("[%s]%s captured control point 2!", pPlayer->GetTeam() ? "Alliance" : "Horde", pPlayer->GetName();
sWorld.SendWorldWideScreenText(msg);
}
}
};
class CP3 : public GameObjectAIScript
{
public:
CP3(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
static GameObjectAIScript *Create(GameObject * GO) { return new CP3(GO); }
void OnActivate(Player * pPlayer)
{
if(dom_enabled)
{
dom_cp3 = pPlayer->GetTeam();
char msg[100];
sprintf("[%s]%s captured control point 3!", pPlayer->GetTeam() ? "Alliance" : "Horde", pPlayer->GetName();
sWorld.SendWorldWideScreenText(msg);
}
}
};
void SetupDomination(ScriptMgr *mgr){
DOMTick dt;
time_t ms = DOM_TICK;
te = TimedEvent::Allocate(&dt, new CallbackP0<DOMTick>(&dt, &DOMTick::Run), 1, ms, 0);
sWorld.event_AddEvent(te);
mgr->register_gameobject_script(92000 , &DOMStarter::Create);
mgr->register_gameobject_script(92001 , &CP1::Create);
mgr->register_gameobject_script(92002 , &CP2::Create);
mgr->register_gameobject_script(92003 , &CP3::Create);
sLog.outString("Domination script loaded.");
}
SQL:
CODE
Code:
INSERT INTO `gameobject_names` (`entry`,`Type`,`DisplayID`,`Name`) VALUES ('92000','10','6605','Domination Assistant');
INSERT INTO `gameobject_names` (`entry`,`Type`,`DisplayID`,`Name`) VALUES ('92001','3','1337','Control Point 1');
INSERT INTO `gameobject_names` (`entry`,`Type`,`DisplayID`,`Name`) VALUES ('92002','3','1337','Control Point 2');
INSERT INTO `gameobject_names` (`entry`,`Type`,`DisplayID`,`Name`) VALUES ('92003','3','1337','Control Point 3');
Credits to Ultra Spidey