Pelf

pelf points patch

Mar 11th, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.85 KB | None | 0 0
  1. diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
  2. index 68c8aa7..c12c1dd 100644
  3. --- a/src/server/game/Entities/Player/Player.cpp
  4. +++ b/src/server/game/Entities/Player/Player.cpp
  5. @@ -22410,8 +22410,50 @@ bool Player::GetsRecruitAFriendBonus(bool forXP)
  6.      return recruitAFriend;
  7.  }
  8.  
  9. +void Player::RewardCurrencyAtKill(Unit* pVictim)
  10. +{
  11. +   if (!pVictim || pVictim->GetTypeId() == TYPEID_PLAYER)
  12. +        return;
  13. +
  14. +   if (!pVictim->ToCreature())
  15. +       return;
  16. +
  17. +   if (!pVictim->ToCreature()->GetCreatureInfo())
  18. +       return;
  19. +
  20. +    CurrencyOnKillEntry const* Curr = sObjectMgr->GetCurrencyOnKillEntry(pVictim->ToCreature()->GetCreatureInfo()->Entry);
  21. +
  22. +   if (!Curr)
  23. +       return;
  24. +
  25. +   if (Curr->currencyid1 && Curr->currencycount1)
  26. +        ModifyCurrency(Curr->currencyid1, Curr->currencycount1);
  27. +
  28. +    if (Curr->currencyid2 && Curr->currencycount2)
  29. +        ModifyCurrency(Curr->currencyid2, Curr->currencycount2);
  30. +
  31. +    if (Curr->currencyid3 && Curr->currencycount3)
  32. +        ModifyCurrency(Curr->currencyid3, Curr->currencycount3);
  33. +}
  34. +
  35.  bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
  36.  {
  37. +   //currency
  38. +   if (sMapStore.LookupEntry(GetMapId())->IsDungeon())
  39. +   {
  40. +       if (Group *pGroup = GetGroup())
  41. +       {
  42. +           for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
  43. +           {
  44. +               Player* pGroupGuy = itr->getSource();
  45. +               pGroupGuy->RewardCurrencyAtKill(pVictim);
  46. +           }              
  47. +       }
  48. +       else
  49. +           RewardCurrencyAtKill(pVictim);
  50. +
  51. +   }
  52. +
  53.      bool PvP = pVictim->isCharmedOwnedByPlayerOrPlayer();
  54.  
  55.      // prepare data for near group iteration (PvP and !PvP cases)
  56. diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
  57. index aeef13c..67781b3 100644
  58. --- a/src/server/game/Entities/Player/Player.h
  59. +++ b/src/server/game/Entities/Player/Player.h
  60. @@ -2031,6 +2031,7 @@ class Player : public Unit, public GridObject<Player>
  61.  
  62.          bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
  63.          bool IsAtRecruitAFriendDistance(WorldObject const* pOther) const;
  64. +       void RewardCurrencyAtKill(Unit* pVictim);
  65.          bool RewardPlayerAndGroupAtKill(Unit* pVictim);
  66.          void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource);
  67.          bool isHonorOrXPTarget(Unit* pVictim);
  68. diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
  69. index 0735dc1..be56994 100644
  70. --- a/src/server/game/Globals/ObjectMgr.cpp
  71. +++ b/src/server/game/Globals/ObjectMgr.cpp
  72. @@ -7359,6 +7359,79 @@ void ObjectMgr::LoadReputationRewardRate()
  73.      sLog->outString(">> Loaded %u reputation_reward_rate", count);
  74.  }
  75.  
  76. +void ObjectMgr::LoadCurrencyOnKill()
  77. +{
  78. +    uint32 oldMSTime = getMSTime();
  79. +
  80. +    mCurrOnKill.clear();
  81. +
  82. +    uint32 count = 0;
  83. +          
  84. +    QueryResult result = WorldDatabase.Query("SELECT `creature_id`, `CurrencyId1`,  `CurrencyId2`,  `CurrencyId3`, `CurrencyCount1`, `CurrencyCount2`, `CurrencyCount3` FROM `creature_currency`");
  85. +
  86. +    if (!result)
  87. +    {
  88. +        sLog->outErrorDb(">> Loaded 0 creature currency definitions. DB table `creature_currency` is empty.");
  89. +        sLog->outString();
  90. +        return;
  91. +    }
  92. +
  93. +    do
  94. +    {
  95. +        Field *fields = result->Fetch();
  96. +
  97. +        uint32 creature_id = fields[0].GetUInt32();
  98. +
  99. +       CurrencyOnKillEntry currOnKill;
  100. +        currOnKill.currencyid1          = fields[1].GetUInt32();
  101. +        currOnKill.currencyid2          = fields[2].GetUInt32();
  102. +        currOnKill.currencyid3          = fields[3].GetUInt32();
  103. +        currOnKill.currencycount1       = fields[4].GetInt32();
  104. +        currOnKill.currencycount2       = fields[5].GetInt32();
  105. +        currOnKill.currencycount3       = fields[6].GetInt32();
  106. +
  107. +        if (!GetCreatureTemplate(creature_id))
  108. +        {
  109. +            sLog->outErrorDb("Table `creature_creature` have data for not existed creature entry (%u), skipped", creature_id);
  110. +            continue;
  111. +        }
  112. +
  113. +        if (currOnKill.currencyid1)
  114. +        {
  115. +            if (!sCurrencyTypesStore.LookupEntry(currOnKill.currencyid1))
  116. +            {
  117. +                sLog->outErrorDb("CurrencyType (CurrencyTypes.dbc) %u does not exist but is used in `creature_currency`", currOnKill.currencyid1);
  118. +                continue;
  119. +            }
  120. +        }
  121. +
  122. +        if (currOnKill.currencyid2)
  123. +        {
  124. +            if (!sCurrencyTypesStore.LookupEntry(currOnKill.currencyid2))
  125. +            {
  126. +                sLog->outErrorDb("CurrencyType (CurrencyTypes.dbc) %u does not exist but is used in `creature_currency`", currOnKill.currencyid2);
  127. +                continue;
  128. +            }
  129. +        }
  130. +
  131. +        if (currOnKill.currencyid3)
  132. +        {
  133. +            if (!sCurrencyTypesStore.LookupEntry(currOnKill.currencyid3))
  134. +            {
  135. +                sLog->outErrorDb("CurrencyType (CurrencyTypes.dbc) %u does not exist but is used in `creature_currency`", currOnKill.currencyid3);
  136. +                continue;
  137. +            }
  138. +        }
  139. +
  140. +        mCurrOnKill[creature_id] = currOnKill;
  141. +
  142. +        ++count;
  143. +    } while (result->NextRow());
  144. +
  145. +    sLog->outString(">> Loaded %u creature currency definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
  146. +    sLog->outString();
  147. +}
  148. +
  149.  void ObjectMgr::LoadReputationOnKill()
  150.  {
  151.      // For reload case
  152. diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
  153. index 4271a9a..5d162e5 100644
  154. --- a/src/server/game/Globals/ObjectMgr.h
  155. +++ b/src/server/game/Globals/ObjectMgr.h
  156. @@ -446,6 +446,16 @@ struct ReputationOnKillEntry
  157.      bool team_dependent;
  158.  };
  159.  
  160. +struct CurrencyOnKillEntry
  161. +{
  162. +    uint32 currencyid1;
  163. +    uint32 currencyid2;
  164. +    uint32 currencyid3;
  165. +    int32 currencycount1;
  166. +    int32 currencycount2;
  167. +    int32 currencycount3;
  168. +};
  169. +
  170.  struct RepSpilloverTemplate
  171.  {
  172.      uint32 faction[MAX_SPILLOVER_FACTIONS];
  173. @@ -619,6 +629,7 @@ class ObjectMgr
  174.  
  175.          typedef UNORDERED_MAP<uint32, RepRewardRate > RepRewardRateMap;
  176.          typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
  177. +       typedef UNORDERED_MAP<uint32, CurrencyOnKillEntry> CurrOnKillMap;
  178.          typedef UNORDERED_MAP<uint32, RepSpilloverTemplate> RepSpilloverTemplateMap;
  179.  
  180.          typedef UNORDERED_MAP<uint32, PointOfInterest> PointOfInterestMap;
  181. @@ -783,6 +794,14 @@ class ObjectMgr
  182.              return NULL;
  183.          }
  184.  
  185. +       CurrencyOnKillEntry const* GetCurrencyOnKillEntry(uint32 id) const
  186. +       {
  187. +           CurrOnKillMap::const_iterator itr = mCurrOnKill.find(id);
  188. +           if (itr != mCurrOnKill.end())
  189. +               return &itr->second;
  190. +           return NULL;
  191. +       }
  192. +
  193.          ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const
  194.          {
  195.              RepOnKillMap::const_iterator itr = mRepOnKill.find(id);
  196. @@ -955,6 +974,7 @@ class ObjectMgr
  197.  
  198.          void LoadReputationRewardRate();
  199.          void LoadReputationOnKill();
  200. +       void LoadCurrencyOnKill();
  201.          void LoadReputationSpilloverTemplate();
  202.  
  203.          void LoadPointsOfInterest();
  204. @@ -1303,6 +1323,7 @@ class ObjectMgr
  205.  
  206.          RepRewardRateMap    m_RepRewardRateMap;
  207.          RepOnKillMap        mRepOnKill;
  208. +       CurrOnKillMap       mCurrOnKill;
  209.          RepSpilloverTemplateMap m_RepSpilloverTemplateMap;
  210.  
  211.          GossipMenusMap      m_mGossipMenusMap;
  212. diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
  213. index 822793e..0b75630 100644
  214. --- a/src/server/game/World/World.cpp
  215. +++ b/src/server/game/World/World.cpp
  216. @@ -1381,6 +1381,9 @@ void World::SetInitialWorldSettings()
  217.      sLog->outString("Loading Reputation Reward Rates...");
  218.      sObjectMgr->LoadReputationRewardRate();
  219.  
  220. +   sLog->outString("Loading Creature Currency OnKill Data...");
  221. +   sObjectMgr->LoadCurrencyOnKill();
  222. +
  223.      sLog->outString("Loading Creature Reputation OnKill Data...");
  224.      sObjectMgr->LoadReputationOnKill();
Advertisement
Add Comment
Please, Sign In to add comment