Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.73 KB | None | 0 0
  1.  
  2. diff --git a/src/game/Object.h b/src/game/Object.h
  3. index 68f68be..6e2bff7 100644
  4. --- a/src/game/Object.h
  5. +++ b/src/game/Object.h
  6. @@ -356,6 +356,9 @@ class MANGOS_DLL_SPEC Object
  7.  
  8. virtual bool HasQuest(uint32 /* quest_id */) const { return false; }
  9. virtual bool HasInvolvedQuest(uint32 /* quest_id */) const { return false; }
  10. +
  11. + //BountyHunter
  12. + Player* ToPlayer(){ if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player*>(this); else return NULL; }
  13. protected:
  14.  
  15. Object ( );
  16. diff --git a/src/game/Player.cpp b/src/game/Player.cpp
  17. index a03d970..90e80af 100644
  18. --- a/src/game/Player.cpp
  19. +++ b/src/game/Player.cpp
  20. @@ -1950,6 +1950,121 @@ void Player::RemoveFromWorld()
  21. Unit::RemoveFromWorld();
  22. }
  23.  
  24. +//BountyHunter
  25. +void Player::SendBountyKill(Player *killer, Player *bounty)
  26. +{
  27. + if(killer->GetObjectGuid() == bounty->GetObjectGuid())
  28. + return;
  29. +
  30. + QueryResult *result = CharacterDatabase.PQuery("SELECT * FROM bounties WHERE guid='%u'", bounty->GetObjectGuid());
  31. +
  32. + if(!result)
  33. + return;
  34. +
  35. + Field * fields = result->Fetch();
  36. + switch(fields[2].GetUInt64())
  37. + { //TODO BountyHunter prices
  38. + case 1:
  39. + killer->SetMoney(killer->GetMoney() + (10 * 10000));
  40. + break;
  41. + case 2:
  42. + killer->SetMoney(killer->GetMoney() + (20 * 10000));
  43. + break;
  44. + case 3:
  45. + killer->SetMoney(killer->GetMoney() + (30 * 10000));
  46. + break;
  47. + case 4:
  48. + killer->SetMoney(killer->GetMoney() + (40 * 10000));
  49. + break;
  50. + }
  51. +
  52. + CharacterDatabase.PExecute("DELETE FROM bounties WHERE guid='%u'", bounty->GetObjectGuid());
  53. + alertServer(bounty->GetName(), 2);
  54. +}
  55. +
  56. +bool Player::passChecks(Player * pPlayer, const char * name)
  57. +{
  58. + Player * pBounty = sObjectAccessor.FindPlayerByName(name);
  59. + WorldSession * m_session = pPlayer->GetSession();
  60. +
  61. + if(!pBounty)
  62. + {
  63. + m_session->SendNotification("The player is offline or doesn't exist!");
  64. + return false;
  65. + }
  66. +
  67. + QueryResult *result = CharacterDatabase.PQuery("SELECT * FROM bounties WHERE guid ='%u'", pBounty->GetObjectGuid());
  68. +
  69. + if(result)
  70. + {
  71. + m_session->SendNotification("This player already has a bounty on them!");
  72. + return false;
  73. + }
  74. +
  75. + if(pPlayer->GetObjectGuid() == pBounty->GetObjectGuid())
  76. + {
  77. + m_session->SendNotification("You cannot set a bounty on yourself!");
  78. + return false;
  79. + }
  80. + return true;
  81. +}
  82. +
  83. +void Player::alertServer(const char * name, int msg)
  84. +{
  85. + std::string message;
  86. + if(msg == 1)
  87. + {
  88. + message = "A bounty has been placed on ";
  89. + message += name;
  90. + message += ". Kill them immediately to collect the reward!";
  91. + }
  92. + else if(msg == 2)
  93. + {
  94. + message = "The bounty on ";
  95. + message += name;
  96. + message += " has been collected!";
  97. + }
  98. + sWorld.SendServerMessage(SERVER_MSG_RESTART_TIME, message.c_str(), 0);
  99. +}
  100. +
  101. +bool Player::hasGold(Player * Player, uint32 required)
  102. +{
  103. + uint32 currentmoney = Player->GetMoney();
  104. + uint32 requiredmoney = (required * 10000);
  105. + if(currentmoney < requiredmoney)
  106. + {
  107. + WorldSession *m_session = Player->GetSession();
  108. + m_session->SendNotification("You don't have enough gold!");
  109. + return false;
  110. + }
  111. + Player->SetMoney(currentmoney - requiredmoney);
  112. + return true;
  113. +}
  114. +
  115. +void Player::flagPlayer(const char * name, int number)
  116. +{
  117. + Player * pBounty = sObjectAccessor.FindPlayerByName(name);
  118. + pBounty->SetPvP(true);
  119. + pBounty->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
  120. +
  121. + if(number == 1)
  122. + {
  123. + CharacterDatabase.PExecute("INSERT INTO bounties VALUES('%u', '20', '1')", pBounty->GetObjectGuid());
  124. + }
  125. + if(number == 2)
  126. + {
  127. + CharacterDatabase.PExecute("INSERT INTO bounties VALUES('%u', '40', '2')", pBounty->GetObjectGuid());
  128. + }
  129. + if(number == 3)
  130. + {
  131. + CharacterDatabase.PExecute("INSERT INTO bounties VALUES('%u', '100', '3')", pBounty->GetObjectGuid());
  132. + }
  133. + if(number == 4)
  134. + {
  135. + CharacterDatabase.PExecute("INSERT INTO bounties VALUES('%u', '200', '4')", pBounty->GetObjectGuid());
  136. + }
  137. +}
  138. +
  139. void Player::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker )
  140. {
  141. float addRage;
  142. diff --git a/src/game/Player.h b/src/game/Player.h
  143. index d4ad9b2..f4e5f99 100644
  144. --- a/src/game/Player.h
  145. +++ b/src/game/Player.h
  146. @@ -1022,6 +1022,13 @@ class MANGOS_DLL_SPEC Player : public Unit
  147. void AddToWorld();
  148. void RemoveFromWorld();
  149.  
  150. + //BountyHunter
  151. + void SendBountyKill(Player *killer, Player *bounty);
  152. + void alertServer(const char * name, int msg);
  153. + void flagPlayer(const char * name, int number);
  154. + bool hasGold(Player * Player, uint32 required);
  155. + bool passChecks(Player *pPlayer, const char * name);
  156. +
  157. bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);
  158.  
  159. bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
  160. diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
  161. index 71e5685..bf3e23d 100644
  162. --- a/src/game/Unit.cpp
  163. +++ b/src/game/Unit.cpp
  164. @@ -672,6 +672,15 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
  165. {
  166. DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"DealDamage: victim just died");
  167.  
  168. + //BountHunter
  169. + if (pVictim->GetTypeId() == TYPEID_PLAYER && this->GetTypeId() == TYPEID_PLAYER)
  170. + {
  171. + Player *killer = ToPlayer();
  172. + Player *bounty = pVictim->ToPlayer();
  173. +
  174. + killer->SendBountyKill(killer, bounty);
  175. + }
  176. +
  177. // find player: owner of controlled `this` or `this` itself maybe
  178. // for loot will be sued only if group_tap==NULL
  179. Player *player_tap = GetCharmerOrOwnerPlayerOrPlayerItself();
  180. diff --git a/src/game/Unit.h b/src/game/Unit.h
  181. index 7e742e8..9cf977a 100644
  182. --- a/src/game/Unit.h
  183. +++ b/src/game/Unit.h
  184. @@ -1097,7 +1097,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
  185. {
  186. return m_floatValues[UNIT_FIELD_BOUNDINGRADIUS];
  187. }
  188. -
  189. +
  190. DiminishingLevels GetDiminishing(DiminishingGroup group);
  191. void IncrDiminishing(DiminishingGroup group);
  192. void ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster, DiminishingLevels Level, int32 limitduration, bool isReflected);
  193. diff --git a/src/game/World.cpp b/src/game/World.cpp
  194. index 5eb6e03..9825125 100644
  195. --- a/src/game/World.cpp
  196. +++ b/src/game/World.cpp
  197. @@ -1290,7 +1290,7 @@ void World::SetInitialWorldSettings()
  198.  
  199. sLog.outString( "Loading CreatureEventAI Scripts...");
  200. sEventAIMgr.LoadCreatureEventAI_Scripts();
  201. -
  202. +
  203. sLog.outString("Initializing Scripts...");
  204. switch(sScriptMgr.LoadScriptLibrary(MANGOS_SCRIPT_NAME))
  205. {
  206. @@ -1432,7 +1432,6 @@ void World::DetectDBCLang()
  207. sLog.outString("Using %s DBC Locale as default. All available DBC locales: %s",localeNames[m_defaultDbcLocale],availableLocalsStr.empty() ? "<none>" : availableLocalsStr.c_str());
  208. sLog.outString();
  209. }
  210. -
  211. /// Update the World !
  212. void World::Update(uint32 diff)
  213. {
  214. @@ -1565,7 +1564,7 @@ void World::Update(uint32 diff)
  215. sTerrainMgr.Update(diff);
  216. }
  217.  
  218. -/// Send a packet to all players (except self if mentioned)
  219. +// Send a packet to all players (except self if mentioned)
  220. void World::SendGlobalMessage(WorldPacket *packet, WorldSession *self, uint32 team)
  221. {
  222. SessionMap::const_iterator itr;
  223. diff --git a/src/game/World.h b/src/game/World.h
  224. index 840cf12..17fe997 100644
  225. --- a/src/game/World.h
  226. +++ b/src/game/World.h
  227. @@ -450,7 +450,7 @@ class World
  228. uint32 GetMaxQueuedSessionCount() const { return m_maxQueuedSessionCount; }
  229. uint32 GetMaxActiveSessionCount() const { return m_maxActiveSessionCount; }
  230. Player* FindPlayerInZone(uint32 zone);
  231. -
  232. +
  233. Weather* FindWeather(uint32 id) const;
  234. Weather* AddWeather(uint32 zone_id);
  235. void RemoveWeather(uint32 zone_id);
  236.  
  237.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement