From 4346882dbe5a9fa2b17fb316190b1737b4fa7229 Mon Sep 17 00:00:00 2001 From: Justin <224400640+DoubledaCoder@users.noreply.github.com> Date: Tue, 3 Feb 2026 17:45:57 +0800 Subject: [PATCH] feat: Killer Level Difference Update (#22) --- conf/mod_moneyforkills.conf.dist | 34 ++++++++++++++----- src/mod_moneyforkills.cpp | 56 +++++++++++++++++++------------- 2 files changed, 58 insertions(+), 32 deletions(-) diff --git a/conf/mod_moneyforkills.conf.dist b/conf/mod_moneyforkills.conf.dist index 8ca69b3..c9f685e 100644 --- a/conf/mod_moneyforkills.conf.dist +++ b/conf/mod_moneyforkills.conf.dist @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/src/mod_moneyforkills.cpp b/src/mod_moneyforkills.cpp index 1605557..67c1a62 100644 --- a/src/mod_moneyforkills.cpp +++ b/src/mod_moneyforkills.cpp @@ -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 +#include 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(MFKEnable, true)) { + //A coefficient to adjust the gold given for bounties const uint32 PVPMultiplier = sConfigMgr->GetOption(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(MFKKillerLevelDiffEnable, true)) + { + KillerLevelDiff = static_cast(VictimLevel) / static_cast(KillerLevel); + } + //Maximum percentage of victim gold which can be taken. Maximum allowable value is 100%. + const float MaxLootPercentage = std::min(1.0f,sConfigMgr->GetOption(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(MFKPVPCorpseLootPercent, 5)/100.0f)*KillerLevelDiff,MaxLootPercentage); + // Calculate the percentage of victim gold to be transferred + const uint32 VictimLoot = static_cast(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(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)