Alright guys while checking in the Requests section I've found that alot of people are looking for a Capture the flag script.
Well, I'm pretty sure this isn't exactly what your looking for but Its a pretty good start. If anyone knows the spell id for the Alliance warsong gulch spells that are casted on you when you get the flag please tell me
Well anyway here is the current script
#begin - begins the event, only usable by GM's
implemented a score system, once a faction gets 3 the score resets and the event is over til a GM begins it
added spell visual to the person who has the flag
Code:
#include "StdAfx.h"
#include "Setup.h"
#define ITEMID 38234//The object that is in your bag when you have the flag
#define FLAG_ID 28342//The Object to be clicked to take the flag
#define ALLYTURNINPOINT 26242//Alliance flag turn in object
#define HORDTURNINPOINT 26242//Horde flag turn in object
//Don't edit this
#define SPELL 23335
static bool IsHeld = false;
static int allyscore = 0;
static int hordescore = 0;
static bool isactive = false;
GameObject * flag;
static string begin = "#begin";
void PlayerChat(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
{
if(Message == begin)
{
if(pPlayer->GetSession()->HasGMPermissions())
{
isactive = true;
allyscore = 0;
hordescore = 0;
}
}
}
class FlagToCapture : public GameObjectAIScript
{
public:
FlagToCapture(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
static GameObjectAIScript *Create(GameObject * GO)
{
return new FlagToCapture(GO);
}
void OnSpawn()
{
flag = _gameobject;
_gameobject->invisible = false;
}
void OnActivate(Player * pPlayer)
{
if(isactive)
{
_gameobject->invisible = false;
if(IsHeld == false)
{
Item * item = objmgr.CreateItem(ITEMID,pPlayer);
pPlayer->GetItemInterface()->AddItemToFreeSlot(item);
IsHeld = true;
_gameobject->invisible = true;
pPlayer->AddAuraVisual(SPELL,1,true);
}
else
{
pPlayer->BroadcastMessage("The flag has already been picked up");
}
}
else
{
_gameobject->invisible = true;
}
}
};
class HordeObject : public GameObjectAIScript
{
public:
HordeObject(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
static GameObjectAIScript *Create(GameObject * GO)
{
return new HordeObject(GO);
}
void OnSpawn()
{
RegisterAIUpdateEvent(1);
}
void AIUpdate()
{
Player * plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords(_gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ());
if(_gameobject->CalcDistance( _gameobject, plr ) <= 2.0f) // You need to standing 2 meters from the actual center of the pink ring
{
if(plr->GetItemInterface()->GetItemCount(ITEMID) >= 1 && plr->GetTeam() == 0)
{
plr->GetItemInterface()->RemoveItemAmt(ITEMID,plr->GetItemInterface()->GetItemCount(ITEMID) && isactive);
IsHeld = false;
flag->invisible = false;
hordescore++;
if(hordescore == 3)
{
sWorld.SendWorldWideScreenText("The horde have won capture the flag");
sWorld.SendWorldText("score resetting");
allyscore = 0;
hordescore = 0;
isactive = false;
}
else
{
char * message;
sprintf(message,"%s has captured the flag for the horde",plr->GetName());
sWorld.SendWorldWideScreenText(message);
plr->RemoveAuraVisual(SPELL,1);
}
}
}
}
};
class AllyObject : public GameObjectAIScript
{
public:
AllyObject(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
static GameObjectAIScript *Create(GameObject * GO)
{
return new AllyObject(GO);
}
void OnSpawn()
{
RegisterAIUpdateEvent(1);
}
void AIUpdate()
{
Player * plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords(_gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ());
if(_gameobject->CalcDistance( _gameobject, plr ) <= 2.0f) // You need to standing 2 meters from the actual center of the pink ring
{
if(plr->GetItemInterface()->GetItemCount(ITEMID) >= 1 && plr->GetTeam() == 1 && isactive)
{
plr->GetItemInterface()->RemoveItemAmt(ITEMID,plr->GetItemInterface()->GetItemCount(ITEMID));
IsHeld = false;
flag->invisible = false;
allyscore++;
if(allyscore == 3)
{
sWorld.SendWorldWideScreenText("The alliance have won capture the flag");
sWorld.SendWorldText("score resetting");
allyscore = 0;
hordescore = 0;
isactive = false;
}
else
{
char * message;
sprintf(message,"%s has captured the flag for the alliance",plr->GetName());
sWorld.SendWorldWideScreenText(message);
plr->RemoveAuraVisual(SPELL,1);
}
}
}
}
};
void SetupCaptureTheFlag(ScriptMgr * mgr)
{
mgr->register_gameobject_script(FLAG_ID, &FlagToCapture::Create);
mgr->register_gameobject_script(ALLYTURNINPOINT, &AllyObject::Create);
mgr->register_gameobject_script(HORDTURNINPOINT, &HordeObject::Create);
mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &PlayerChat);
}
Without Spells -- Some errors in version with them
Code:
#include "StdAfx.h"
#include "Setup.h"
#define ITEMID 38234//The object that is in your bag when you have the flag
#define FLAG_ID 28342//The Object to be clicked to take the flag
#define ALLYTURNINPOINT 26242//Alliance flag turn in object
#define HORDTURNINPOINT 26242//Horde flag turn in object
//Don't edit this
#define SPELL 23335
static bool IsHeld = false;
static int allyscore = 0;
static int hordescore = 0;
static bool isactive = false;
GameObject * flag;
static string begin = "#begin";
void PlayerChat(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
{
if(Message == begin)
{
if(pPlayer->GetSession()->HasGMPermissions())
{
isactive = true;
allyscore = 0;
hordescore = 0;
}
}
}
class FlagToCapture : public GameObjectAIScript
{
public:
FlagToCapture(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
static GameObjectAIScript *Create(GameObject * GO)
{
return new FlagToCapture(GO);
}
void OnSpawn()
{
flag = _gameobject;
_gameobject->invisible = false;
}
void OnActivate(Player * pPlayer)
{
if(isactive)
{
_gameobject->invisible = false;
if(IsHeld == false)
{
Item * item = objmgr.CreateItem(ITEMID,pPlayer);
pPlayer->GetItemInterface()->AddItemToFreeSlot(item);
IsHeld = true;
_gameobject->invisible = true;
}
else
{
pPlayer->BroadcastMessage("The flag has already been picked up");
}
}
else
{
_gameobject->invisible = true;
}
}
};
class HordeObject : public GameObjectAIScript
{
public:
HordeObject(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
static GameObjectAIScript *Create(GameObject * GO)
{
return new HordeObject(GO);
}
void OnSpawn()
{
RegisterAIUpdateEvent(1);
}
void AIUpdate()
{
Player * plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords(_gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ());
if(_gameobject->CalcDistance( _gameobject, plr ) <= 2.0f) // You need to standing 2 meters from the actual center of the pink ring
{
if(plr->GetItemInterface()->GetItemCount(ITEMID) >= 1 && plr->GetTeam() == 0)
{
plr->GetItemInterface()->RemoveItemAmt(ITEMID,plr->GetItemInterface()->GetItemCount(ITEMID) && isactive);
IsHeld = false;
flag->invisible = false;
hordescore++;
if(hordescore == 3)
{
sWorld.SendWorldWideScreenText("The horde have won capture the flag");
sWorld.SendWorldText("score resetting");
allyscore = 0;
hordescore = 0;
isactive = false;
}
else
{
char * message;
sprintf(message,"%s has captured the flag for the horde",plr->GetName());
sWorld.SendWorldWideScreenText(message);
}
}
}
}
};
class AllyObject : public GameObjectAIScript
{
public:
AllyObject(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
static GameObjectAIScript *Create(GameObject * GO)
{
return new AllyObject(GO);
}
void OnSpawn()
{
RegisterAIUpdateEvent(1);
}
void AIUpdate()
{
Player * plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords(_gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ());
if(_gameobject->CalcDistance( _gameobject, plr ) <= 2.0f) // You need to standing 2 meters from the actual center of the pink ring
{
if(plr->GetItemInterface()->GetItemCount(ITEMID) >= 1 && plr->GetTeam() == 1 && isactive)
{
plr->GetItemInterface()->RemoveItemAmt(ITEMID,plr->GetItemInterface()->GetItemCount(ITEMID));
IsHeld = false;
flag->invisible = false;
allyscore++;
if(allyscore == 3)
{
sWorld.SendWorldWideScreenText("The alliance have won capture the flag");
sWorld.SendWorldText("score resetting");
allyscore = 0;
hordescore = 0;
isactive = false;
}
else
{
char * message;
sprintf(message,"%s has captured the flag for the alliance",plr->GetName());
sWorld.SendWorldWideScreenText(message);
}
}
}
}
};
void SetupCaptureTheFlag(ScriptMgr * mgr)
{
mgr->register_gameobject_script(FLAG_ID, &FlagToCapture::Create);
mgr->register_gameobject_script(ALLYTURNINPOINT, &AllyObject::Create);
mgr->register_gameobject_script(HORDTURNINPOINT, &HordeObject::Create);
mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &PlayerChat);
}
Just modify the definitions to what you want
and create your game objects (sorry that i don't have them, i don't have an updated DB will +Rep anyone to make them)