Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
- index 68c8aa7..c12c1dd 100644
- --- a/src/server/game/Entities/Player/Player.cpp
- +++ b/src/server/game/Entities/Player/Player.cpp
- @@ -22410,8 +22410,50 @@ bool Player::GetsRecruitAFriendBonus(bool forXP)
- return recruitAFriend;
- }
- +void Player::RewardCurrencyAtKill(Unit* pVictim)
- +{
- + if (!pVictim || pVictim->GetTypeId() == TYPEID_PLAYER)
- + return;
- +
- + if (!pVictim->ToCreature())
- + return;
- +
- + if (!pVictim->ToCreature()->GetCreatureInfo())
- + return;
- +
- + CurrencyOnKillEntry const* Curr = sObjectMgr->GetCurrencyOnKillEntry(pVictim->ToCreature()->GetCreatureInfo()->Entry);
- +
- + if (!Curr)
- + return;
- +
- + if (Curr->currencyid1 && Curr->currencycount1)
- + ModifyCurrency(Curr->currencyid1, Curr->currencycount1);
- +
- + if (Curr->currencyid2 && Curr->currencycount2)
- + ModifyCurrency(Curr->currencyid2, Curr->currencycount2);
- +
- + if (Curr->currencyid3 && Curr->currencycount3)
- + ModifyCurrency(Curr->currencyid3, Curr->currencycount3);
- +}
- +
- bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
- {
- + //currency
- + if (sMapStore.LookupEntry(GetMapId())->IsDungeon())
- + {
- + if (Group *pGroup = GetGroup())
- + {
- + for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
- + {
- + Player* pGroupGuy = itr->getSource();
- + pGroupGuy->RewardCurrencyAtKill(pVictim);
- + }
- + }
- + else
- + RewardCurrencyAtKill(pVictim);
- +
- + }
- +
- bool PvP = pVictim->isCharmedOwnedByPlayerOrPlayer();
- // prepare data for near group iteration (PvP and !PvP cases)
- diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
- index aeef13c..67781b3 100644
- --- a/src/server/game/Entities/Player/Player.h
- +++ b/src/server/game/Entities/Player/Player.h
- @@ -2031,6 +2031,7 @@ class Player : public Unit, public GridObject<Player>
- bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
- bool IsAtRecruitAFriendDistance(WorldObject const* pOther) const;
- + void RewardCurrencyAtKill(Unit* pVictim);
- bool RewardPlayerAndGroupAtKill(Unit* pVictim);
- void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource);
- bool isHonorOrXPTarget(Unit* pVictim);
- diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
- index 0735dc1..be56994 100644
- --- a/src/server/game/Globals/ObjectMgr.cpp
- +++ b/src/server/game/Globals/ObjectMgr.cpp
- @@ -7359,6 +7359,79 @@ void ObjectMgr::LoadReputationRewardRate()
- sLog->outString(">> Loaded %u reputation_reward_rate", count);
- }
- +void ObjectMgr::LoadCurrencyOnKill()
- +{
- + uint32 oldMSTime = getMSTime();
- +
- + mCurrOnKill.clear();
- +
- + uint32 count = 0;
- +
- + QueryResult result = WorldDatabase.Query("SELECT `creature_id`, `CurrencyId1`, `CurrencyId2`, `CurrencyId3`, `CurrencyCount1`, `CurrencyCount2`, `CurrencyCount3` FROM `creature_currency`");
- +
- + if (!result)
- + {
- + sLog->outErrorDb(">> Loaded 0 creature currency definitions. DB table `creature_currency` is empty.");
- + sLog->outString();
- + return;
- + }
- +
- + do
- + {
- + Field *fields = result->Fetch();
- +
- + uint32 creature_id = fields[0].GetUInt32();
- +
- + CurrencyOnKillEntry currOnKill;
- + currOnKill.currencyid1 = fields[1].GetUInt32();
- + currOnKill.currencyid2 = fields[2].GetUInt32();
- + currOnKill.currencyid3 = fields[3].GetUInt32();
- + currOnKill.currencycount1 = fields[4].GetInt32();
- + currOnKill.currencycount2 = fields[5].GetInt32();
- + currOnKill.currencycount3 = fields[6].GetInt32();
- +
- + if (!GetCreatureTemplate(creature_id))
- + {
- + sLog->outErrorDb("Table `creature_creature` have data for not existed creature entry (%u), skipped", creature_id);
- + continue;
- + }
- +
- + if (currOnKill.currencyid1)
- + {
- + if (!sCurrencyTypesStore.LookupEntry(currOnKill.currencyid1))
- + {
- + sLog->outErrorDb("CurrencyType (CurrencyTypes.dbc) %u does not exist but is used in `creature_currency`", currOnKill.currencyid1);
- + continue;
- + }
- + }
- +
- + if (currOnKill.currencyid2)
- + {
- + if (!sCurrencyTypesStore.LookupEntry(currOnKill.currencyid2))
- + {
- + sLog->outErrorDb("CurrencyType (CurrencyTypes.dbc) %u does not exist but is used in `creature_currency`", currOnKill.currencyid2);
- + continue;
- + }
- + }
- +
- + if (currOnKill.currencyid3)
- + {
- + if (!sCurrencyTypesStore.LookupEntry(currOnKill.currencyid3))
- + {
- + sLog->outErrorDb("CurrencyType (CurrencyTypes.dbc) %u does not exist but is used in `creature_currency`", currOnKill.currencyid3);
- + continue;
- + }
- + }
- +
- + mCurrOnKill[creature_id] = currOnKill;
- +
- + ++count;
- + } while (result->NextRow());
- +
- + sLog->outString(">> Loaded %u creature currency definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
- + sLog->outString();
- +}
- +
- void ObjectMgr::LoadReputationOnKill()
- {
- // For reload case
- diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
- index 4271a9a..5d162e5 100644
- --- a/src/server/game/Globals/ObjectMgr.h
- +++ b/src/server/game/Globals/ObjectMgr.h
- @@ -446,6 +446,16 @@ struct ReputationOnKillEntry
- bool team_dependent;
- };
- +struct CurrencyOnKillEntry
- +{
- + uint32 currencyid1;
- + uint32 currencyid2;
- + uint32 currencyid3;
- + int32 currencycount1;
- + int32 currencycount2;
- + int32 currencycount3;
- +};
- +
- struct RepSpilloverTemplate
- {
- uint32 faction[MAX_SPILLOVER_FACTIONS];
- @@ -619,6 +629,7 @@ class ObjectMgr
- typedef UNORDERED_MAP<uint32, RepRewardRate > RepRewardRateMap;
- typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
- + typedef UNORDERED_MAP<uint32, CurrencyOnKillEntry> CurrOnKillMap;
- typedef UNORDERED_MAP<uint32, RepSpilloverTemplate> RepSpilloverTemplateMap;
- typedef UNORDERED_MAP<uint32, PointOfInterest> PointOfInterestMap;
- @@ -783,6 +794,14 @@ class ObjectMgr
- return NULL;
- }
- + CurrencyOnKillEntry const* GetCurrencyOnKillEntry(uint32 id) const
- + {
- + CurrOnKillMap::const_iterator itr = mCurrOnKill.find(id);
- + if (itr != mCurrOnKill.end())
- + return &itr->second;
- + return NULL;
- + }
- +
- ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const
- {
- RepOnKillMap::const_iterator itr = mRepOnKill.find(id);
- @@ -955,6 +974,7 @@ class ObjectMgr
- void LoadReputationRewardRate();
- void LoadReputationOnKill();
- + void LoadCurrencyOnKill();
- void LoadReputationSpilloverTemplate();
- void LoadPointsOfInterest();
- @@ -1303,6 +1323,7 @@ class ObjectMgr
- RepRewardRateMap m_RepRewardRateMap;
- RepOnKillMap mRepOnKill;
- + CurrOnKillMap mCurrOnKill;
- RepSpilloverTemplateMap m_RepSpilloverTemplateMap;
- GossipMenusMap m_mGossipMenusMap;
- diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
- index 822793e..0b75630 100644
- --- a/src/server/game/World/World.cpp
- +++ b/src/server/game/World/World.cpp
- @@ -1381,6 +1381,9 @@ void World::SetInitialWorldSettings()
- sLog->outString("Loading Reputation Reward Rates...");
- sObjectMgr->LoadReputationRewardRate();
- + sLog->outString("Loading Creature Currency OnKill Data...");
- + sObjectMgr->LoadCurrencyOnKill();
- +
- sLog->outString("Loading Creature Reputation OnKill Data...");
- sObjectMgr->LoadReputationOnKill();
Advertisement
Add Comment
Please, Sign In to add comment