[8608] implement BattleGround Alterac Valley

sql won't be included - please look at your database
providers forum

also note, that creature_loot_template id 0
is used for the loot of dead players in this bg
(after a player died and you remove insignia from him..
he not only drops money - he drops some random items too)

further work must be done in better code for adjusting right
levels to creatures - maybe using something similar like it's
done in heroic instances

also quests and creatures needs some scripts in future

thanks to:
netsky - initial start of this patch
bogie - 2nd person writing on this patch
triply, kapatejib, vladimir - code review and suggestions
arrai - for his great tool and help
and all testers / code contributers - I won't write
down a list, else I would forget most probably one ^^
This commit is contained in:
balrok 2009-10-07 11:57:28 +02:00
parent ed5130c1c1
commit 45f6a474bf
20 changed files with 1795 additions and 139 deletions

View file

@ -80,6 +80,53 @@ namespace MaNGOS
va_list* i_args;
};
class BattleGroundYellBuilder
{
public:
BattleGroundYellBuilder(uint32 language, int32 textId, Creature const* source, va_list* args = NULL)
: i_language(language), i_textId(textId), i_source(source), i_args(args) {}
void operator()(WorldPacket& data, int32 loc_idx)
{
char const* text = objmgr.GetMangosString(i_textId,loc_idx);
if(i_args)
{
// we need copy va_list before use or original va_list will corrupted
va_list ap;
va_copy(ap,*i_args);
char str [2048];
vsnprintf(str,2048,text, ap );
va_end(ap);
do_helper(data,&str[0]);
}
else
do_helper(data,text);
}
private:
void do_helper(WorldPacket& data, char const* text)
{
//copyied from BuildMonsterChat
data << (uint8)CHAT_MSG_MONSTER_YELL;
data << (uint32)i_language;
data << (uint64)i_source->GetGUID();
data << (uint32)0; //2.1.0
data << (uint32)(strlen(i_source->GetName())+1);
data << i_source->GetName();
data << (uint64)0; //Unit Target - isn't important for bgs
data << (uint32)strlen(text)+1;
data << text;
data << (uint8)0; // ChatTag - for bgs allways 0?
}
uint32 i_language;
int32 i_textId;
Creature const* i_source;
va_list* i_args;
};
class BattleGround2ChatBuilder
{
public:
@ -113,6 +160,40 @@ namespace MaNGOS
int32 i_arg1;
int32 i_arg2;
};
class BattleGround2YellBuilder
{
public:
BattleGround2YellBuilder(uint32 language, int32 textId, Creature const* source, int32 arg1, int32 arg2)
: i_language(language), i_textId(textId), i_source(source), i_arg1(arg1), i_arg2(arg2) {}
void operator()(WorldPacket& data, int32 loc_idx)
{
char const* text = objmgr.GetMangosString(i_textId,loc_idx);
char const* arg1str = i_arg1 ? objmgr.GetMangosString(i_arg1,loc_idx) : "";
char const* arg2str = i_arg2 ? objmgr.GetMangosString(i_arg2,loc_idx) : "";
char str [2048];
snprintf(str,2048,text, arg1str, arg2str );
//copyied from BuildMonsterChat
data << (uint8)CHAT_MSG_MONSTER_YELL;
data << (uint32)i_language;
data << (uint64)i_source->GetGUID();
data << (uint32)0; //2.1.0
data << (uint32)(strlen(i_source->GetName())+1);
data << i_source->GetName();
data << (uint64)0; //Unit Target - isn't important for bgs
data << (uint32)strlen(str)+1;
data << str;
data << (uint8)0; // ChatTag - for bgs allways 0?
}
private:
uint32 i_language;
int32 i_textId;
Creature const* i_source;
int32 i_arg1;
int32 i_arg2;
};
} // namespace MaNGOS
template<class Do>
@ -664,6 +745,12 @@ void BattleGround::EndBattleGround(uint32 winner)
plr->ResurrectPlayer(1.0f);
plr->SpawnCorpseBones();
}
else
{
//needed cause else in av some creatures will kill the players at the end
plr->CombatStop();
plr->getHostilRefManager().deleteReferences();
}
//this line is obsolete - team is set ALWAYS
//if(!team) team = plr->GetTeam();
@ -1381,6 +1468,13 @@ void BattleGround::OnObjectDBLoad(Creature* creature)
SpawnBGCreature(creature->GetGUID(), RESPAWN_ONE_DAY);
}
uint64 BattleGround::GetSingleCreatureGuid(uint8 event1, uint8 event2)
{
BGCreatures::const_iterator itr = m_EventObjects[MAKE_PAIR32(event1, event2)].creatures.begin();
if (itr != m_EventObjects[MAKE_PAIR32(event1, event2)].creatures.end())
return *itr;
return 0;
}
void BattleGround::OnObjectDBLoad(GameObject* obj)
{
@ -1525,6 +1619,16 @@ void BattleGround::SendMessageToAll(int32 entry, ChatMsg type, Player const* sou
BroadcastWorker(bg_do);
}
void BattleGround::SendYellToAll(int32 entry, uint32 language, uint64 const& guid)
{
Creature* source = GetBgMap()->GetCreature(guid);
if(!source)
return;
MaNGOS::BattleGroundYellBuilder bg_builder(language, entry, source);
MaNGOS::LocalizedPacketDo<MaNGOS::BattleGroundYellBuilder> bg_do(bg_builder);
BroadcastWorker(bg_do);
}
void BattleGround::PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ...)
{
va_list ap;
@ -1544,6 +1648,16 @@ void BattleGround::SendMessage2ToAll(int32 entry, ChatMsg type, Player const* so
BroadcastWorker(bg_do);
}
void BattleGround::SendYell2ToAll(int32 entry, uint32 language, uint64 const& guid, int32 arg1, int32 arg2)
{
Creature* source = GetBgMap()->GetCreature(guid);
if(!source)
return;
MaNGOS::BattleGround2YellBuilder bg_builder(language, entry, source, arg1, arg2);
MaNGOS::LocalizedPacketDo<MaNGOS::BattleGround2YellBuilder> bg_do(bg_builder);
BroadcastWorker(bg_do);
}
void BattleGround::EndNow()
{
RemoveFromBGFreeSlotQueue();
@ -1604,8 +1718,6 @@ void BattleGround::HandleTriggerBuff(uint64 const& go_guid)
void BattleGround::HandleKillPlayer( Player *player, Player *killer )
{
//keep in mind that for arena this will have to be changed a bit
// add +1 deaths
UpdatePlayerScore(player, SCORE_DEATHS, 1);