Sdyess
2019-06-11 17:07:42 -05:00
parent e71c6062bc
commit ef1d9a4d20
2 changed files with 146 additions and 93 deletions

View File

@@ -17,34 +17,46 @@ MFK.Announce = 1
# Enable announcements to notify the server of a world boss kill # Enable announcements to notify the server of a world boss kill
# Default 1 # Default 1
MFK.WorldBossAnnounce = 1 MFK.Announce.World.WorldBoss = 1
# Enable player suicide announcements # It is recommended to only enable world suicide announcements if group and guild are both disabled and vice versa
# as it can become spammy in some situations. Having all 3 enabled would display 3 messages for some people.
# Enable player suicide announcements to display to the world
# Default 1 # Default 1
MFK.SuicideAnnounce = 1 MFK.Announce.World.Suicide = 1
# Enable player suicide announcements to display to their guild
# Default 0
MFK.Announce.Guild.Suicide = 0
# Enable player suicide announcements to display to their party
# Default 0
MFK.Announce.Group.Suicide = 0
# Enable PvP announcements # Enable PvP announcements
# Default 1 # Default 1
MFK.PvPAnnounce = 1 MFK.Announce.World.PvP = 1
# Enable Group announcements for killing a dungeon boss # Enable Group announcements for killing a dungeon boss
# Default 1 # Default 1
MFK.DungeonBossAnnounce = 1 MFK.Announce.Group.DungeonBoss = 1
# Only allow the player with the killing blow to claim the bounty? # Only allow the player with the killing blow to claim the bounty?
# Default: 0 (All players receive the bounty) # Default: 0 (All players receive the bounty)
MFK.KillingBlowOnly = 0 MFK.Bounty.KillingBlowOnly = 0
# Award bounty to party members far away from the group? # Award bounty to party members far away from the group?
# Default: 0 (Only award players near the group) # Default: 0 (Only award players near the group)
MFK.MoneyForNothing = 0 MFK.Bounty.MoneyForNothing = 0
# How much gold does a Player take from the victim's corpse on a PVP kill? # How much gold does a Player take from the victim's corpse on a PVP kill?
# Setting this to 0 will disable player gold stealing.
# Default: 5 (5% of the victim's gold) # Default: 5 (5% of the victim's gold)
MFK.PVP.CorpseLootPercent = 5 MFK.PVP.CorpseLootPercent = 5
@@ -62,7 +74,7 @@ MFK.PVP.CorpseLootPercent = 5
# NOTE: There are many dungeon bosses per dungeon, so set accordingly! # NOTE: There are many dungeon bosses per dungeon, so set accordingly!
# NOTE: A value of 0 will disable the payment type # NOTE: A value of 0 will disable the payment type
MFK.Kill.Multiplier = 100 MFK.Bounty.Kill.Multiplier = 100
MFK.PVP.Multiplier = 200 MFK.PVP.Kill.Multiplier = 200
MFK.DungeonBoss.Multiplier = 25 MFK.Bounty.DungeonBoss.Multiplier = 25
MFK.WorldBoss.Multiplier = 200 MFK.Bounty.WorldBoss.Multiplier = 200

View File

@@ -72,6 +72,10 @@ reward range of the group and an option to only reward the player that got the k
#include "Config.h" #include "Config.h"
#include "Group.h" #include "Group.h"
#include "ScriptMgr.h"
#include "Chat.h"
#include "Player.h"
#include "Guild.h"
enum KillType enum KillType
{ {
@@ -79,9 +83,26 @@ enum KillType
KILLTYPE_PVP, KILLTYPE_PVP,
KILLTYPE_DUNGEONBOSS, KILLTYPE_DUNGEONBOSS,
KILLTYPE_WORLDBOSS, KILLTYPE_WORLDBOSS,
KILLTYPE_MOB KILLTYPE_MOB,
KILLTYPE_SUICIDE
}; };
static constexpr const char* MFKEnable = "MFK.Enable";
static constexpr const char* MFKAnnounce = "MFK.Announce";
static constexpr const char* MFKAnnounceWorldBoss = "MFK.Announce.World.WorldBoss";
static constexpr const char* MFKAnnounceDungeonBoss = "MFK.Announce.Group.DungeonBoss";
static constexpr const char* MFKAnnounceWorldSuicide = "MFK.Announce.World.Suicide";
static constexpr const char* MFKAnnounceGuildSuicide = "MFK.Announce.Guild.Suicide";
static constexpr const char* MFKAnnounceGroupSuicide = "MFK.Announce.Group.Suicide";
static constexpr const char* MFKAnnouncePvP = "MFK.Announce.World.PvP";
static constexpr const char* MFKBountyKillingBlow = "MFK.Bounty.KillingBlowOnly";
static constexpr const char* MFKBountyMoneyForNothing = "MFK.Bounty.MoneyForNothing";
static constexpr const char* MFKPVPCorpseLootPercent = "MFK.PVP.CorpseLootPercent";
static constexpr const char* MFKBountyKillMult = "MFK.Bounty.Kill.Multiplier";
static constexpr const char* MFKPVPKillMult = "MFK.PVP.Kill.Multiplier";
static constexpr const char* MFKBountyKillDBMult = "MFK.Bounty.DungeonBoss.Multiplier";
static constexpr const char* MFKBountyKillWBMult = "MFK.Bounty.WorldBoss.Multiplier";
class MoneyForKills : public PlayerScript class MoneyForKills : public PlayerScript
{ {
public: public:
@@ -89,9 +110,9 @@ public:
// Announce Module // Announce Module
void OnLogin(Player *player) { void OnLogin(Player *player) {
if (sConfigMgr->GetBoolDefault("MFK.Enable", true)) if (sConfigMgr->GetBoolDefault(MFKEnable, true))
{ {
if (sConfigMgr->GetBoolDefault("MFK.Announce", true)) if (sConfigMgr->GetBoolDefault(MFKAnnounce, true))
{ {
ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00MoneyForKills |rmodule."); ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00MoneyForKills |rmodule.");
} }
@@ -102,9 +123,10 @@ public:
void OnPVPKill(Player* killer, Player* victim) void OnPVPKill(Player* killer, Player* victim)
{ {
// If enabled... // If enabled...
if (sConfigMgr->GetBoolDefault("MFK.Enable", true)) if (sConfigMgr->GetBoolDefault(MFKEnable, true))
{ {
const uint32 PVPMultiplier = sConfigMgr->GetIntDefault("MFK.PVP.Multiplier", 0); const uint32 PVPMultiplier = sConfigMgr->GetIntDefault(MFKPVPKillMult, 0);
const uint32 VictimLevel = victim->getLevel();
// If enabled... // If enabled...
if (PVPMultiplier > 0) if (PVPMultiplier > 0)
@@ -112,30 +134,24 @@ public:
// No reward for killing yourself // No reward for killing yourself
if (killer->GetGUID() == victim->GetGUID()) if (killer->GetGUID() == victim->GetGUID())
{ {
if (sConfigMgr->GetBoolDefault("MFK.SuicideAnnounce", true)) Notify(killer, victim, nullptr, KILLTYPE_SUICIDE, 0);
{
// Inform the world
std::string message = "|cff676767[ |cffFFFF00World |cff676767]|r:|cff4CFF00 ";
message.append(killer->GetName());
message.append(" met an untimely demise!");
sWorld->SendServerMessage(SERVER_MSG_STRING, message.c_str());
}
return; return;
} }
// Calculate the amount of gold to give to the victor
const uint32 PVPCorpseLootPercent = sConfigMgr->GetIntDefault("MFK.PVP.CorpseLootPercent", 5);
const uint32 VictimLevel = victim->getLevel();
const int VictimLoot = (victim->GetMoney() * PVPCorpseLootPercent) / 100;
const int BountyAmount = ((VictimLevel * PVPMultiplier) / 3); const int BountyAmount = ((VictimLevel * PVPMultiplier) / 3);
// Pay the player the additional PVP bounty // Pay the player the additional PVP bounty
killer->ModifyMoney(BountyAmount); killer->ModifyMoney(BountyAmount);
// Inform the player of the bounty amount
Notify(killer, victim, nullptr, KILLTYPE_PVP, BountyAmount);
}
// Calculate the amount of gold to give to the victor
const uint32 PVPCorpseLootPercent = sConfigMgr->GetIntDefault(MFKPVPCorpseLootPercent, 5);
const int VictimLoot = (victim->GetMoney() * PVPCorpseLootPercent) / 100;
// Rifle the victim's corpse for loot // Rifle the victim's corpse for loot
if (victim->GetMoney() >= 10000) if (victim->GetMoney() >= 10000 && VictimLoot > 0)
{ {
// Player loots a percentage of the victim's gold // Player loots a percentage of the victim's gold
killer->ModifyMoney(VictimLoot); killer->ModifyMoney(VictimLoot);
@@ -145,68 +161,60 @@ public:
Notify(killer, victim, nullptr, KILLTYPE_LOOT, VictimLoot); Notify(killer, victim, nullptr, KILLTYPE_LOOT, VictimLoot);
} }
// Inform the player of the bounty amount
Notify(killer, victim, nullptr, KILLTYPE_PVP, BountyAmount);
return; return;
} }
} }
}
// Creature Kill Reward // Creature Kill Reward
void OnCreatureKill(Player* player, Creature* killed) void OnCreatureKill(Player* player, Creature* killed)
{ {
// If enabled... // If enabled...
if (sConfigMgr->GetBoolDefault("MFK.Enable", true)) if (sConfigMgr->GetBoolDefault(MFKEnable, true))
{ {
// Get the creature level // Get the creature level
const uint32 CreatureLevel = killed->getLevel(); const uint32 CreatureLevel = killed->getLevel();
uint32 BossMultiplier = 0;
uint32 KillMultiplier = 0;
KillType CreatureType;
// What did the player kill? if (killed->IsDungeonBoss()) {
if (killed->IsDungeonBoss() || killed->isWorldBoss()) BossMultiplier = sConfigMgr->GetIntDefault(MFKBountyKillDBMult, 0);
{ CreatureType = KILLTYPE_DUNGEONBOSS;
uint32 BossMultiplier; }
else if (killed->isWorldBoss()) {
// Dungeon Boss or World Boss multiplier? BossMultiplier = sConfigMgr->GetIntDefault(MFKBountyKillWBMult, 0);
if (killed->IsDungeonBoss()) CreatureType = KILLTYPE_WORLDBOSS;
{
BossMultiplier = sConfigMgr->GetIntDefault("MFK.DungeonBoss.Multiplier", 0);
} }
else else
{ {
BossMultiplier = sConfigMgr->GetIntDefault("MFK.WorldBoss.Multiplier", 0); KillMultiplier = sConfigMgr->GetIntDefault(MFKBountyKillMult, 0);
CreatureType = KILLTYPE_MOB;
} }
// If enabled...
if (BossMultiplier > 0) if (BossMultiplier > 0)
{ {
// Reward based on creature level // Reward based on creature level
const int BountyAmount = ((CreatureLevel * BossMultiplier) * 100); const int BountyAmount = ((CreatureLevel * BossMultiplier) * 100);
if (killed->IsDungeonBoss()) if (CreatureType == KILLTYPE_WORLDBOSS)
{ {
// Pay the bounty amount Notify(player, nullptr, killed, KILLTYPE_WORLDBOSS, BountyAmount);
CreatureBounty(player, killed, KILLTYPE_DUNGEONBOSS, BountyAmount); CreatureBounty(player, killed, KILLTYPE_MOB, BountyAmount);
} }
else else
{ {
// Pay the bounty amount CreatureBounty(player, killed, CreatureType, BountyAmount);
CreatureBounty(player, killed, KILLTYPE_WORLDBOSS, BountyAmount); }
} }
}
}
else
{
const uint32 KillMultiplier = sConfigMgr->GetIntDefault("MFK.Kill.Multiplier", 0);
// If enabled...
if (KillMultiplier > 0) if (KillMultiplier > 0)
{ {
// Reward based on creature level // Reward based on creature level
const int BountyAmount = ((CreatureLevel * KillMultiplier) / 3); const int BountyAmount = ((CreatureLevel * KillMultiplier) / 3);
// Pay the bounty amount // Pay the bounty amount
CreatureBounty(player, killed, KILLTYPE_MOB, BountyAmount); CreatureBounty(player, killed, CreatureType, BountyAmount);
}
} }
} }
} }
@@ -215,9 +223,7 @@ public:
void CreatureBounty(Player* player, Creature* killed, KillType kType, int bounty) void CreatureBounty(Player* player, Creature* killed, KillType kType, int bounty)
{ {
Group* group = player->GetGroup(); Group* group = player->GetGroup();
Group::MemberSlotList const &members = group->GetMemberSlots(); const uint32 KillingBlowOnly = sConfigMgr->GetIntDefault(MFKBountyKillingBlow, 0);
const uint32 KillingBlowOnly = sConfigMgr->GetIntDefault("MFK.KillingBlowOnly", 0);
const uint32 MoneyForNothing = sConfigMgr->GetIntDefault("MFK.MoneyForNothing", 0);
// Determine who receives the bounty // Determine who receives the bounty
if (!group || KillingBlowOnly == 1) if (!group || KillingBlowOnly == 1)
@@ -230,10 +236,12 @@ public:
} }
else else
{ {
const uint32 MoneyForNothing = sConfigMgr->GetIntDefault(MFKBountyMoneyForNothing, 0);
Group::MemberSlotList const& members = group->GetMemberSlots();
// Pay the group (OnCreatureKill only rewards the player that got the killing blow) // Pay the group (OnCreatureKill only rewards the player that got the killing blow)
for (Group::MemberSlotList::const_iterator itr = members.begin(); itr != members.end(); ++itr) for (auto itr = members.begin(); itr != members.end(); ++itr)
{ {
Group::MemberSlot const &slot = *itr;
Player* playerInGroup = ObjectAccessor::FindPlayer((*itr).guid); Player* playerInGroup = ObjectAccessor::FindPlayer((*itr).guid);
// Pay each player in the group // Pay each player in the group
@@ -285,7 +293,7 @@ public:
ChatHandler(killer->GetSession()).SendSysMessage(rewardMsg.c_str()); ChatHandler(killer->GetSession()).SendSysMessage(rewardMsg.c_str());
break; break;
case KILLTYPE_PVP: case KILLTYPE_PVP:
if (sConfigMgr->GetBoolDefault("MFK.PvPAnnounce", true)) if (sConfigMgr->GetBoolDefault(MFKAnnouncePvP, true))
{ {
rewardMsg.append("|cff676767[ |cffFFFF00World |cff676767]|r:|cff4CFF00 ").append(killer->GetName()).append(" |cffFF0000has slain "); rewardMsg.append("|cff676767[ |cffFFFF00World |cff676767]|r:|cff4CFF00 ").append(killer->GetName()).append(" |cffFF0000has slain ");
rewardMsg.append(victim->GetName()).append(" earning a bounty of").append(rewardVal).append("."); rewardMsg.append(victim->GetName()).append(" earning a bounty of").append(rewardVal).append(".");
@@ -293,7 +301,7 @@ public:
} }
break; break;
case KILLTYPE_DUNGEONBOSS: case KILLTYPE_DUNGEONBOSS:
if (sConfigMgr->GetBoolDefault("MFK.DungeonBossAnnounce", true)) if (sConfigMgr->GetBoolDefault(MFKAnnounceDungeonBoss, true))
{ {
rewardMsg.append("|cffFF8000Your group has defeated |cffFF0000").append(killed->GetName()).append("|cffFF8000."); rewardMsg.append("|cffFF8000Your group has defeated |cffFF0000").append(killed->GetName()).append("|cffFF8000.");
ChatHandler(killer->GetSession()).SendSysMessage(rewardMsg.c_str()); ChatHandler(killer->GetSession()).SendSysMessage(rewardMsg.c_str());
@@ -301,7 +309,7 @@ public:
} }
break; break;
case KILLTYPE_WORLDBOSS: case KILLTYPE_WORLDBOSS:
if (sConfigMgr->GetBoolDefault("MFK.WorldBossAnnounce", true)) if (sConfigMgr->GetBoolDefault(MFKAnnounceWorldBoss, true))
{ {
rewardMsg.append("|cffFF0000[ |cffFFFF00World |cffFF0000]|r:|cff4CFF00 ").append(killer->GetName()); rewardMsg.append("|cffFF0000[ |cffFFFF00World |cffFF0000]|r:|cff4CFF00 ").append(killer->GetName());
rewardMsg.append("'s|r group triumphed victoriously over |CFF18BE00[").append(killed->GetName()).append("]|r !"); rewardMsg.append("'s|r group triumphed victoriously over |CFF18BE00[").append(killed->GetName()).append("]|r !");
@@ -311,12 +319,45 @@ public:
break; break;
case KILLTYPE_MOB: case KILLTYPE_MOB:
break; break;
case KILLTYPE_SUICIDE:
std::string message = "|cff4CFF00 ";
message.append(killer->GetName());
message.append(" met an untimely demise!");
if (sConfigMgr->GetBoolDefault(MFKAnnounceWorldSuicide, true))
sWorld->SendServerMessage(SERVER_MSG_STRING, message.c_str());
if (sConfigMgr->GetBoolDefault(MFKAnnounceGuildSuicide, false))
{
Guild* guild = killer->GetGuild();
if (guild)
guild->BroadcastToGuild(killer->GetSession(), false, message, LANG_UNIVERSAL);
} }
if (kType != KILLTYPE_LOOT)
if (sConfigMgr->GetBoolDefault(MFKAnnounceGroupSuicide, false))
{
Group* group = killer->GetGroup();
if (group)
{
Group::MemberSlotList const& members = group->GetMemberSlots();
// Pay the group (OnCreatureKill only rewards the player that got the killing blow)
for (auto itr = members.begin(); itr != members.end(); ++itr)
{
Player* playerInGroup = ObjectAccessor::FindPlayer((*itr).guid);
if (playerInGroup)
ChatHandler(playerInGroup->GetSession()).SendSysMessage(message.c_str());
}
}
}
}
if (kType != KILLTYPE_LOOT && kType != KILLTYPE_WORLDBOSS && kType != KILLTYPE_SUICIDE)
{ {
rewardMsg.clear(); rewardMsg.clear();
rewardMsg.append(" You receive a bounty of"); rewardMsg.append("You receive a bounty of");
rewardMsg.append(rewardVal); rewardMsg.append(rewardVal);
rewardMsg.append(" for the kill."); rewardMsg.append(" for the kill.");
ChatHandler(killer->GetSession()).SendSysMessage(rewardMsg.c_str()); ChatHandler(killer->GetSession()).SendSysMessage(rewardMsg.c_str());