feat: Killer Level Difference Update (#22)

This commit is contained in:
Justin
2026-02-03 17:45:57 +08:00
committed by GitHub
parent efe60fa32f
commit 4346882dbe
2 changed files with 58 additions and 32 deletions

View File

@@ -10,7 +10,7 @@
MFK.Enable = 1
# Announce the module when the player logs in?
# Default: 1
# Default: 0
MFK.Announce = 0
@@ -22,9 +22,9 @@ MFK.Announce.World.WorldBoss = 1
# 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 0
MFK.Announce.World.Suicide = 1
MFK.Announce.World.Suicide = 0
# Enable player suicide announcements to display to their guild
# Default 0
@@ -36,14 +36,14 @@ MFK.Announce.Guild.Suicide = 0
MFK.Announce.Group.Suicide = 0
# Enable PvP announcements
# Default 1
# Default 0
MFK.Announce.World.PvP = 1
MFK.Announce.World.PvP = 0
# Enable Group announcements for killing a dungeon boss
# Default 1
# Default 0
MFK.Announce.Group.DungeonBoss = 1
MFK.Announce.Group.DungeonBoss = 0
# Only allow the player with the killing blow to claim the bounty?
# Default: 0 (All players receive the bounty)
@@ -76,5 +76,21 @@ MFK.PVP.CorpseLootPercent = 5
MFK.Bounty.Kill.Multiplier = 10
MFK.PVP.Kill.Multiplier = 20
MFK.Bounty.DungeonBoss.Multiplier = 25
MFK.Bounty.WorldBoss.Multiplier = 20
MFK.Bounty.DungeonBoss.Multip lier = 25
MFK.Bounty.WorldBoss.Multiplier = 20
# Provide bonus or penalty multiplier to the amount taken based on proportional level difference
# Calculation is KillerLevelDiff = VictimLevel / KillerLevel
# Level 80 kills a level 40 the KillerLevelDiff = 0.5 i.e. CorpseLootPercent is reduced to 2.5%
# Level 40 kills a level 80 the KillerLevelDiff = 2 i.e. CorpseLootPercent is increased to 10%
# This has been set so no value can go over 100%.
# Default: 1 for enable
MFK.Killer.Level.Diff.Enable = 1
# Maximum Lootable value is the maximum percentage of a player's gold that can be taken in a single kill
# This is to ensure that even with bonuses, the killerleveldiff does not lead to efficient gold farming.
# Value should be a decimal between 0 and 1 and this has been set so no value can go over 100%
# Default = 0.5
MFK.Max.Gold.Threshold = 0.5

View File

@@ -80,6 +80,8 @@ reward range of the group and an option to only reward the player that got the k
#include "Player.h"
#include "Guild.h"
#include "WorldSessionMgr.h"
#include <algorithm>
#include <cmath>
enum KillType
{
@@ -106,6 +108,8 @@ 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";
static constexpr const char* MFKKillerLevelDiffEnable = "MFK.Killer.Level.Diff.Enable";
static constexpr const char* MFKMaxGoldThreshold = "MFK.Max.Gold.Threshold";
class MoneyForKills : public PlayerScript
{
@@ -129,9 +133,33 @@ public:
// If enabled...
if (sConfigMgr->GetOption<bool>(MFKEnable, true))
{
//A coefficient to adjust the gold given for bounties
const uint32 PVPMultiplier = sConfigMgr->GetOption<uint32>(MFKPVPKillMult, 0);
const uint32 VictimLevel = victim->GetLevel();
const uint32 VictimLevel = victim->GetLevel();
const uint32 KillerLevel = killer->GetLevel();
//Gold of the victim before calculation
const uint32 VictimGold = victim->GetMoney();
//Scales the reward depending on the proportional difference in level if enabled
float KillerLevelDiff = 1.0f;
//adding an enable system to choose the multiplier applied
if (sConfigMgr->GetOption<bool>(MFKKillerLevelDiffEnable, true))
{
KillerLevelDiff = static_cast<float>(VictimLevel) / static_cast<float>(KillerLevel);
}
//Maximum percentage of victim gold which can be taken. Maximum allowable value is 100%.
const float MaxLootPercentage = std::min(1.0f,sConfigMgr->GetOption<float>(MFKMaxGoldThreshold, 1.0f));
// Calculate the percentage of gold to transfer from victim to killer. Maximum alloable is whatever was set in MaxLootPercentage.
const float PVPCorpseLootPercent = std::min((sConfigMgr->GetOption<uint32>(MFKPVPCorpseLootPercent, 5)/100.0f)*KillerLevelDiff,MaxLootPercentage);
// Calculate the percentage of victim gold to be transferred
const uint32 VictimLoot = static_cast<uint32>(VictimGold * PVPCorpseLootPercent);
//only notify if a value is being transferred
if (VictimLoot > 0){
// Rifle the victim's corpse for loot
killer->ModifyMoney(VictimLoot);
victim->ModifyMoney(-VictimLoot);
// Inform the player of the corpse loot
Notify(killer, victim, nullptr, KILLTYPE_LOOT, VictimLoot);
}
// If enabled...
if (PVPMultiplier > 0)
{
@@ -141,33 +169,15 @@ public:
Notify(killer, victim, nullptr, KILLTYPE_SUICIDE, 0);
return;
}
const int BountyAmount = ((VictimLevel * PVPMultiplier) / 3);
//Added in the KillerLevelDiff so bounties are not awarded for farming low level players.
const int BountyAmount = ((VictimLevel * PVPMultiplier * KillerLevelDiff) / 3);
// Pay the player the additional PVP bounty
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->GetOption<uint32>(MFKPVPCorpseLootPercent, 5);
const int VictimLoot = (victim->GetMoney() * PVPCorpseLootPercent) / 100;
// Rifle the victim's corpse for loot
if (victim->GetMoney() >= 10000 && VictimLoot > 0)
{
// Player loots a percentage of the victim's gold
killer->ModifyMoney(VictimLoot);
victim->ModifyMoney(-VictimLoot);
// Inform the player of the corpse loot
Notify(killer, victim, nullptr, KILLTYPE_LOOT, VictimLoot);
}
return;
}
}
}}
// Creature Kill Reward
void OnPlayerCreatureKill(Player* player, Creature* killed)