mxwow modules

This commit is contained in:
mikx
2025-03-24 23:53:45 -04:00
parent 93073b0be2
commit e87efbaf6e
99 changed files with 4909 additions and 814 deletions

View File

@@ -19,8 +19,7 @@ mxwow_honorable() : PlayerScript("mxwow_honorable") { }
void OnPlayerLogin(Player* player) override
{
if (!sConfigMgr->GetOption<bool>("MxWoW_Honorable.Enabled", true)) { return; }
ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00MxW Honorable |rmodule.");
}
void OnPlayerPVPKill(Player* player, Player* victim) {
@@ -41,7 +40,7 @@ mxwow_honorable() : PlayerScript("mxwow_honorable") { }
std::string pName = player->GetName();
uint32 pLevel = player->GetLevel();
uint32 piLevel = player->GetAverageItemLevelForDF();
float pLife = player->GetHealthPct();
float pLife = round(player->GetHealthPct());
bool pGrouped = player->GetGroup();
std::string vName = victim->GetName();
@@ -56,6 +55,7 @@ mxwow_honorable() : PlayerScript("mxwow_honorable") { }
else {
ss << "|cffabeeff[MxW][|cfffc0303PvP|cffabeeff][|cfffc0303" << mapName << "|cffabeeff] [" << GetPlayerFactionByRace(player) << "|cffabeeff][" << pLevel << "][" << GetPlayerColor(player) << pName << "|cffabeeff][iL" << piLevel << "][" << pLife << "%] |cfffc0303a tué|cffabeeff [" << GetPlayerFactionByRace(victim) << "|cffabeeff][" << vLevel << "][" << GetPlayerColor(victim) << vName << "|cffabeeff][iL" << viLevel << "].";
player->ModifyMoney(+int32(base));
ManageHonorableKill(player, victim);
}
sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, ss.str().c_str());
@@ -127,6 +127,43 @@ mxwow_honorable() : PlayerScript("mxwow_honorable") { }
}
}
void ManageHonorableKill(Player* player, Player* victim) {
uint32 base = sConfigMgr->GetOption<int>("MxWoW_Honorable.Kill.Copper", true);
uint32 killQty;
std::ostringstream ss;
std::ostringstream ssV;
uint32 kId = player->GetGUID().GetRawValue();
std::string kName = player->GetName();
uint32 kGuildId = 0;
std::string kGuildName = "";
uint32 vId = victim->GetGUID().GetRawValue();
std::string vName = victim->GetName();
uint32 vGuildId = 0;
std::string vGuildName = "";
uint32 kLevel = player->GetLevel();
uint32 vLevel = victim->GetLevel();
QueryResult queryPlayerHonorable = LoginDatabase.Query("SELECT * FROM mxw_honorable_kill WHERE kguid = {} AND vguid = {}", kId, vId);
if (queryPlayerHonorable) {
killQty = (*queryPlayerHonorable)[4].Get<int>();
killQty++;
if (player->GetGuild()) { kGuildId = player->GetGuildId(); kGuildName = player->GetGuildName(); }
if (victim->GetGuild()) { vGuildId = victim->GetGuildId(); vGuildName = victim->GetGuildName(); }
LoginDatabase.Execute("UPDATE mxw_honorable_kill SET kguildid='{}',vguildid='{}',killcount='{}',last_kill_klevel='{}',last_kill_vlevel='{}' WHERE kguid='{}' AND vguid='{}'", kGuildId, vGuildId, killQty, kLevel, vLevel, kId, vId);
ss << "|cffabeeff[MxW][|cfffc0303PvP|cffabeeff] Vous avez tué " << GetPlayerColor(victim) << vName << " |cffabeeffde façon honorable à |cfffc0303" << killQty << " |cffabeeffreprises. Ça vous rapporte "<< FormatMoney(base) << "g.";
ssV << "|cffabeeff[MxW][|cfffc0303PvP|cffabeeff] Vous avez été tué |cfffc0303" << killQty << " |cffabeefffois par " << GetPlayerColor(player) << vName << "|cffabeeffde.";
}
else {
if(player->GetGuild()){ kGuildId = player->GetGuildId(); kGuildName = player->GetGuildName(); }
if (victim->GetGuild()) { vGuildId = victim->GetGuildId(); vGuildName = victim->GetGuildName(); }
LoginDatabase.Execute("INSERT INTO mxw_honorable_kill (kguid, kguildid, vguid, vguildid, killcount, last_kill_klevel, last_kill_vlevel) VALUES ({}, {}, {}, {}, {}, {}, {})", kId, kGuildId, vId, vGuildId, 1, kLevel, vLevel);
ss << "|cffabeeff[MxW][|cfffc0303PvP|cffabeeff] Vous avez tué " << GetPlayerColor(victim) << vName << " |cffabeeffde façon honorable à |cfffc03031 |cffabeeffreprise. Ça vous rapporte " << FormatMoney(base) << "g.";
ssV << "|cffabeeff[MxW][|cfffc0303PvP|cffabeeff] Vous avez été tué |cfffc03031 |cffabeefffois par " << GetPlayerColor(player) << vName << "|cffabeeffde.";
}
ChatHandler(player->GetSession()).PSendSysMessage(ss.str().c_str());
ChatHandler(victim->GetSession()).PSendSysMessage(ssV.str().c_str());
}
void ManageDishonorableKill(Player* player, const Player* victim)
{
uint32 killQty;
@@ -136,18 +173,18 @@ mxwow_honorable() : PlayerScript("mxwow_honorable") { }
uint32 vId = victim->GetGUID().GetRawValue();
uint64 kCopper = GetCharCopper(kId);
uint32 loss;
QueryResult queryPlayerDishonorable = LoginDatabase.Query("SELECT * FROM mxw_dishonorable_penalty WHERE kguid = {} AND vguid = {}", kId, vId);
QueryResult queryPlayerDishonorable = LoginDatabase.Query("SELECT * FROM mxw_dishonorable_kill WHERE kguid = {} AND vguid = {}", kId, vId);
if (queryPlayerDishonorable)
{
killQty = (*queryPlayerDishonorable)[2].Get<int>();
killQty++;
loss = (kCopper * killQty) / 100;
LoginDatabase.Execute("UPDATE mxw_dishonorable_penalty SET killcount='{}' WHERE kguid='{}' AND vguid='{}'", killQty, kId, vId);
LoginDatabase.Execute("UPDATE mxw_dishonorable_kill SET killcount='{}' WHERE kguid='{}' AND vguid='{}'", killQty, kId, vId);
ss << "|cffabeeff[MxW] Vous avez tué "<< GetPlayerColor(victim) << vName << " |cffabeeffde façon déshonorable à |cfffc0303"<< killQty <<" |cffabeeffreprises. Vous subissez une perte de " << FormatMoney(loss) << "g";
}
else {
loss = (kCopper * 1) / 100;
LoginDatabase.Execute("INSERT INTO mxw_dishonorable_penalty (kguid, vguid, killcount) VALUES ({}, {}, {})", kId, vId, 1);
LoginDatabase.Execute("INSERT INTO mxw_dishonorable_kill (kguid, vguid, killcount) VALUES ({}, {}, {})", kId, vId, 1);
ss << "|cffabeeff[MxW] Vous avez tué " << GetPlayerColor(victim) << vName << " |cffabeeffde façon déshonorable à |cfffc03031 |cffabeeffreprise. Vous subissez une perte de " << FormatMoney(loss) << "g";
}
player->ModifyMoney(-int32(loss));