189 lines
7.6 KiB
C++
189 lines
7.6 KiB
C++
//// MxWoW Official Module
|
|
//// Boss Kill
|
|
//// Dev: mikx
|
|
//// Git: https://mxgit.ovh/MxWoW/mod_mxwow_bosskill
|
|
|
|
#include "Configuration/Config.h"
|
|
#include "ScriptMgr.h"
|
|
#include "Player.h"
|
|
#include "Chat.h"
|
|
#include <WorldSessionMgr.h>
|
|
|
|
class mxwow_bosskill : public PlayerScript
|
|
{
|
|
|
|
public:
|
|
|
|
mxwow_bosskill() : PlayerScript("mxwow_bosskill") {}
|
|
|
|
void OnPlayerLogin(Player* player) override
|
|
{
|
|
|
|
}
|
|
|
|
void OnPlayerCreatureKill(Player* player, Creature* boss) {
|
|
std::string contentDifficulty;
|
|
std::string contentDifName;
|
|
std::string mType;
|
|
std::ostringstream ss;
|
|
std::ostringstream line00;
|
|
std::ostringstream line01;
|
|
std::ostringstream line02;
|
|
std::ostringstream line03;
|
|
std::string bName;
|
|
std::string bKillMsg;
|
|
Map* map;
|
|
std::string pName;
|
|
uint32 piLevel;
|
|
std::string pMapName;
|
|
float pLife;
|
|
bool pGrouped;
|
|
if (boss->isWorldBoss() || boss->IsDungeonBoss()) {
|
|
if (boss->isWorldBoss()) { mType = "Raid"; }
|
|
else { mType = "Donjon"; }
|
|
uint32 contentDifId;
|
|
bName = boss->GetName();
|
|
map = player->GetMap();
|
|
piLevel = player->GetAverageItemLevelForDF();
|
|
pMapName = map->GetMapName();
|
|
pGrouped = player->GetGroup();
|
|
pLife = player->GetHealthPct();
|
|
int RandIndex = rand() % 8;
|
|
if (player->GetMap()->IsHeroic()) {
|
|
contentDifficulty = "|cffff0000";
|
|
contentDifName = "|cffff0000Heroic";
|
|
contentDifId = 1;
|
|
}
|
|
else {
|
|
contentDifficulty = "|cff00ff00";
|
|
contentDifName = "|cff00ff00Normal";
|
|
contentDifId = 0;
|
|
}
|
|
|
|
if (!pGrouped) {
|
|
KillManager(player, boss, map);
|
|
//ss << "|cffabeeff[MxW] [" << GetPlayerColor(player) << pName << "|cffabeeff][iL"<< piLevel <<"][" << pLife << "%] a tué [|cffff1100" << bName << "|cffabeeff][" << contentDifficulty << pMapName << "|cffabeeff]";
|
|
/*pName = p->GetName();
|
|
line00 << "|cffabeeff[MxW][" << mType << "]";
|
|
line01 << "|cffabeeff[" << contentDifficulty << "" << pMapName << "|cffabeeff][" << contentDifName << "|cffabeeff]";
|
|
line02 << "|cffabeeff[" << GetPlayerColor(player) << pName << "|cffabeeff][iL" << piLevel << "][" << pLife << "%]";
|
|
line03 << "|cffabeeff[|cffff1100" << bName << "|cffabeeff] " << GenKillMessage(RandIndex) << ".";
|
|
sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, line00.str().c_str());
|
|
sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, line01.str().c_str());
|
|
sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, line02.str().c_str());
|
|
sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, line03.str().c_str());
|
|
ChatHandler(p->GetSession()).PSendSysMessage(ss.str().c_str());*/
|
|
}
|
|
else {
|
|
Group* group = player->GetGroup();
|
|
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
|
|
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
|
|
{
|
|
Player* p = ObjectAccessor::FindPlayer(itr->guid);
|
|
KillManager(p, boss, map);
|
|
/*pName = p->GetName();
|
|
line00 << "|cffabeeff[MxW][" << mType << "]";
|
|
line01 << "|cffabeeff[" << contentDifficulty << "" << pMapName << "|cffabeeff][" << contentDifName << "|cffabeeff]";
|
|
line02 << "|cffabeeff[" << GetPlayerColor(player) << pName << "|cffabeeff][iL" << piLevel << "][" << pLife << "%]";
|
|
line03 << "|cffabeeff[|cffff1100" << bName << "|cffabeeff] " << GenKillMessage(RandIndex) << ".";
|
|
sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, line00.str().c_str());
|
|
sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, line01.str().c_str());
|
|
sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, line02.str().c_str());
|
|
sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, line03.str().c_str());
|
|
ChatHandler(p->GetSession()).PSendSysMessage(ss.str().c_str());*/
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void KillManager(Player* player, Creature* boss, Map* map) {
|
|
uint32 aId = player->GetSession()->GetAccountId();
|
|
uint32 pId = player->GetGUID().GetRawValue();
|
|
uint32 mapId = map->GetId();
|
|
uint32 cId = boss->GetCreatureTemplate()->Entry;
|
|
uint32 contentDifId;
|
|
if (player->GetMap()->IsHeroic()) {
|
|
contentDifId = 1;
|
|
}
|
|
else {
|
|
contentDifId = 0;
|
|
}
|
|
QueryResult queryBossKill = LoginDatabase.Query("SELECT * FROM mxw_boss_kill WHERE accountid = {} AND charid = {} AND creatureid = {} AND instanceid = {} AND difficulty = {}", aId, pId, cId, mapId, contentDifId);
|
|
if (queryBossKill) {
|
|
uint32 killCount = (*queryBossKill)[5].Get<uint32>();
|
|
killCount++;
|
|
LoginDatabase.Execute("UPDATE mxw_boss_kill SET killcount = {} WHERE accountid = {} AND charid = {} AND creatureid = {} AND instanceid = {} AND difficulty = {}", killCount, aId, pId, cId, mapId, contentDifId);
|
|
}
|
|
else {
|
|
LoginDatabase.Execute("INSERT INTO mxw_boss_kill (accountid,charid,creatureid,instanceid,difficulty,killcount) VALUES ({}, {}, {}, {}, {}, {})", aId, pId, cId, mapId, contentDifId, 1);
|
|
}
|
|
|
|
QueryResult queryInstanceKill = LoginDatabase.Query("SELECT * FROM mxw_boss_instance WHERE instanceid = {} AND difficulty = {} AND bossid = {}", mapId, contentDifId, cId);
|
|
if (queryInstanceKill) {
|
|
uint32 killCount = (*queryInstanceKill)[3].Get<uint32>();
|
|
killCount++;
|
|
LoginDatabase.Execute("UPDATE mxw_boss_instance SET killcount = {} WHERE instanceid = {} AND difficulty = {} AND bossid = {} ", killCount, mapId, contentDifId, cId);
|
|
}
|
|
else {
|
|
LoginDatabase.Execute("INSERT INTO mxw_boss_instance (instanceid,difficulty,bossid,killcount) VALUES ({}, {}, {}, {})", mapId, contentDifId, cId, 1);
|
|
}
|
|
}
|
|
|
|
std::string GenKillMessage(const int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
return "est mort";
|
|
case 1:
|
|
return "est tombé";
|
|
case 2:
|
|
return "n'est plus";
|
|
case 3:
|
|
return "à rendu l'âme";
|
|
case 4:
|
|
return "ne faisait pas le poid";
|
|
case 5:
|
|
return "en a eu pour son compte";
|
|
case 6:
|
|
return "n'était pas à la hauteur";
|
|
case 7:
|
|
return "ne fera pas de vieux os";
|
|
}
|
|
}
|
|
|
|
std::string GetPlayerColor(const Player* p)
|
|
{
|
|
switch (p->getClass())
|
|
{
|
|
case CLASS_ROGUE:
|
|
return "|cffFFF468";
|
|
case CLASS_DEATH_KNIGHT:
|
|
return "|cffC41E3A";
|
|
case CLASS_WARRIOR:
|
|
return "|cffC69B6D";
|
|
case CLASS_PRIEST:
|
|
return "|cffFFFFFF";
|
|
case CLASS_MAGE:
|
|
return "|cff3FC7EB";
|
|
case CLASS_PALADIN:
|
|
return "|cffF48CBA";
|
|
case CLASS_HUNTER:
|
|
return "|cffAAD372";
|
|
case CLASS_DRUID:
|
|
return "|cffFF7C0A";
|
|
case CLASS_SHAMAN:
|
|
return "|cff0070DD";
|
|
case CLASS_WARLOCK:
|
|
return "|cff8788EE";
|
|
default:
|
|
return "n/d";
|
|
}
|
|
}
|
|
};
|
|
|
|
void AddMxWoWBossKillScripts()
|
|
{
|
|
new mxwow_bosskill();
|
|
}
|