Advertisement
Parranoia

Blood Money NPC

Oct 11th, 2012
3,103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 18.43 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2.  
  3. // Set USE_TOKEN to 1 if you want to have it use tokens in place of gold
  4. #define USE_TOKEN   0
  5. #define TOKEN_ID    29434
  6.  
  7. struct BloodMoneyInfo
  8. {
  9.     uint64 guid;
  10.     uint32 amount;
  11.     bool accepted;
  12. };
  13.  
  14. typedef std::list<BloodMoneyInfo> BloodMoneyList;
  15. typedef std::map<uint64, BloodMoneyList> BloodMoney;
  16. static BloodMoney m_bloodMoney;
  17.  
  18. bool HasBloodMoneyChallenger(uint64 playerGUID)
  19. {
  20.     return m_bloodMoney.find(playerGUID) != m_bloodMoney.end();
  21. }
  22.  
  23. bool HasBloodMoneyChallenger(uint64 targetGUID, uint64 playerGUID)
  24. {
  25.     if (!HasBloodMoneyChallenger(targetGUID))
  26.         return false;
  27.     BloodMoneyList bml = m_bloodMoney[targetGUID];
  28.     for (BloodMoneyList::const_iterator itr = bml.begin(); itr != bml.end(); ++itr)
  29.         if (itr->guid == playerGUID)
  30.             return true;
  31.     return false;
  32. }
  33.  
  34. void AddBloodMoneyEntry(uint64 targetGUID, uint64 playerGUID, uint32 amount)
  35. {
  36.     BloodMoneyInfo bmi;
  37.     bmi.guid = playerGUID;
  38.     bmi.amount = amount;
  39.     bmi.accepted = false;
  40.     m_bloodMoney[targetGUID].push_back(bmi);
  41. }
  42.  
  43. void RemoveBloodMoneyEntry(uint64 targetGUID, uint64 playerGUID)
  44. {
  45.     if (!HasBloodMoneyChallenger(targetGUID, playerGUID))
  46.         return;
  47.     BloodMoneyList &list = m_bloodMoney[targetGUID];
  48.         BloodMoneyList::iterator itr;
  49.         for (itr = list.begin(); itr != list.end(); ++itr)
  50.             if (itr->guid == playerGUID)
  51.                     break;
  52.         list.erase(itr);
  53. }
  54.  
  55. void SetChallengeAccepted(uint64 targetGUID, uint64 playerGUID)
  56. {
  57.     if (!HasBloodMoneyChallenger(targetGUID, playerGUID))
  58.         return;
  59.     BloodMoneyList &list = m_bloodMoney[targetGUID];
  60.     BloodMoneyList::iterator itr;
  61.     for (itr = list.begin(); itr != list.end(); ++itr)
  62.     {
  63.         if (itr->guid == playerGUID)
  64.         {
  65.             itr->accepted = true;
  66.             break;
  67.         }
  68.     }
  69. }
  70.  
  71. class npc_blood_money : public CreatureScript
  72. {
  73.     public :
  74.         npc_blood_money() : CreatureScript("npc_blood_money") {}
  75.  
  76.     bool OnGossipHello(Player * player, Creature * creature)
  77.     {
  78.         player->PlayerTalkClass->ClearMenus();
  79.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Challenge a Player", 11, 1000);   
  80.         if (HasBloodMoneyChallenger(player->GetGUID()))
  81.         {
  82.             BloodMoneyList list = m_bloodMoney[player->GetGUID()];
  83.             for (BloodMoneyList::const_iterator itr = list.begin(); itr != list.end(); ++itr)
  84.             {
  85.                 char msg[50];
  86.  
  87.                 if (Player* plr = Player::GetPlayer(*player, itr->guid))
  88.                 {
  89.                     if (USE_TOKEN)
  90.                     {
  91.                         sprintf(msg, "Accept %s's Challenge of %u tokens", plr->GetName().c_str(), itr->amount);
  92.                         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, msg, GOSSIP_SENDER_MAIN, itr->guid);
  93.                         sprintf(msg, "Decline %s's Challenge of %u tokens", plr->GetName().c_str(), itr->amount);
  94.                         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, msg, GOSSIP_SENDER_INFO, itr->guid);
  95.                     }
  96.                     else
  97.                     {
  98.                         sprintf(msg, "Accept %s's Challenge of %ug", plr->GetName().c_str(), itr->amount/10000);
  99.                         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, msg, GOSSIP_SENDER_MAIN, itr->guid);
  100.                         sprintf(msg, "Decline %s's Challenge of %ug", plr->GetName().c_str(), itr->amount/10000);
  101.                         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, msg, GOSSIP_SENDER_INFO, itr->guid);
  102.                     }
  103.                    
  104.                 }
  105.             }
  106.         }
  107.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Nevermind", GOSSIP_SENDER_MAIN, 1);
  108.        
  109.         player->SEND_GOSSIP_MENU(80025, creature->GetGUID());
  110.  
  111.         return true;
  112.     }
  113.  
  114.     bool OnGossipSelect(Player * player, Creature * creature, uint32 uiSender, uint32 uiAction)
  115.     {
  116.         player->PlayerTalkClass->ClearMenus();
  117.         if (uiAction == 1)
  118.         {
  119.             player->CLOSE_GOSSIP_MENU();
  120.             return true;
  121.         }
  122.         switch(uiSender)
  123.         {
  124.             case GOSSIP_SENDER_MAIN:
  125.                 if (Player* target = Player::GetPlayer(*player, uiAction))
  126.                 {
  127.                     SetChallengeAccepted(player->GetGUID(), target->GetGUID());
  128.                     char msg[60];
  129.                     sprintf(msg, "%s has accepted your challenge!", player->GetName().c_str());
  130.                     creature->MonsterWhisper(msg, target->GetGUID(), true);
  131.                     player->CLOSE_GOSSIP_MENU();
  132.                 }
  133.                 break;
  134.             case GOSSIP_SENDER_INFO:
  135.                 if (Player* target = Player::GetPlayer(*player, uiAction))
  136.                 {
  137.                     char msg[60];
  138.                     sprintf(msg, "%s has declined your challenge!", player->GetName().c_str());
  139.                     creature->MonsterWhisper(msg, target->GetGUID(), true);
  140.                     RemoveBloodMoneyEntry(player->GetGUID(), uiAction);
  141.                     OnGossipHello(player, creature);
  142.                 }
  143.                 break;
  144.             case 11:
  145.                 if (USE_TOKEN)
  146.                 {
  147.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 5 tokens", GOSSIP_SENDER_MAIN, 5, "", 0, true);
  148.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 10 tokens", GOSSIP_SENDER_MAIN, 10, "", 0, true);
  149.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 15 tokens", GOSSIP_SENDER_MAIN, 15, "", 0, true);
  150.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 25 tokens", GOSSIP_SENDER_MAIN, 25, "", 0, true);
  151.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 50 tokens", GOSSIP_SENDER_MAIN, 50, "", 0, true);
  152.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 100 tokens", GOSSIP_SENDER_MAIN, 100, "", 0, true);
  153.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 150 tokens", GOSSIP_SENDER_MAIN, 150, "", 0, true);
  154.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 200 tokens", GOSSIP_SENDER_MAIN, 200, "", 0, true);
  155.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 250 tokens", GOSSIP_SENDER_MAIN, 250, "", 0, true);
  156.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 500 tokens", GOSSIP_SENDER_MAIN, 500, "", 0, true);
  157.                 }
  158.                 else
  159.                 {
  160.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 5g", GOSSIP_SENDER_MAIN, 5, "", 0, true);
  161.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 10g", GOSSIP_SENDER_MAIN, 10, "", 0, true);
  162.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 15g", GOSSIP_SENDER_MAIN, 15, "", 0, true);
  163.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 25g", GOSSIP_SENDER_MAIN, 25, "", 0, true);
  164.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 50g", GOSSIP_SENDER_MAIN, 50, "", 0, true);
  165.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 100g", GOSSIP_SENDER_MAIN, 100, "", 0, true);
  166.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 150g", GOSSIP_SENDER_MAIN, 150, "", 0, true);
  167.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 200g", GOSSIP_SENDER_MAIN, 200, "", 0, true);
  168.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 250g", GOSSIP_SENDER_MAIN, 250, "", 0, true);
  169.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "Bet 500g", GOSSIP_SENDER_MAIN, 500, "", 0, true);
  170.                 }
  171.                
  172.                 player->SEND_GOSSIP_MENU(80025, creature->GetGUID());
  173.                 break;
  174.         }
  175.         return true;
  176.     }
  177.  
  178.     bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code)
  179.     {
  180.         if (player->GetName().c_str() == code)
  181.         {
  182.             ChatHandler(player->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFNow why would you want to challenge yourself?");
  183.             return false;
  184.         }
  185.         if (uint64 targetGUID = sObjectMgr->GetPlayerGUIDByName(code))
  186.         {
  187.             if (Player* target = Player::GetPlayer(*player, targetGUID))
  188.             {
  189.                 if (target->GetGUID() == player->GetGUID())
  190.                 {
  191.                     ChatHandler(player->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFNow why would you want to challenge yourself?");
  192.                     return false;
  193.                 }
  194.                 if (target->GetZoneId() == player->GetZoneId())
  195.                 {
  196.                     if (USE_TOKEN)
  197.                     {
  198.                         if (target->GetItemCount(TOKEN_ID) < action)
  199.                         {
  200.                             ChatHandler(player->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFThat player does not have enough tokens to make the bet!");
  201.                             player->CLOSE_GOSSIP_MENU();
  202.                             return false;
  203.                         }
  204.                         if (player->GetItemCount(TOKEN_ID) < action)
  205.                         {
  206.                             ChatHandler(player->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou do not have enough tokens to make the bet!");
  207.                             player->CLOSE_GOSSIP_MENU();
  208.                             return false;
  209.                         }
  210.                        
  211.                         bool found = false;
  212.                         if (HasBloodMoneyChallenger(player->GetGUID()))
  213.                         {
  214.                             BloodMoneyList list = m_bloodMoney[player->GetGUID()];
  215.                             for (BloodMoneyList::const_iterator itr = list.begin(); itr != list.end(); ++itr)
  216.                                 if (itr->guid == target->GetGUID())
  217.                                     found = true;
  218.                         }
  219.                         if (!found)
  220.                         {
  221.                             if (!HasBloodMoneyChallenger(target->GetGUID(), player->GetGUID()))
  222.                             {
  223.                                 AddBloodMoneyEntry(target->GetGUID(), player->GetGUID(), action);
  224.                                 char msg[60];
  225.                                 sprintf(msg, "%s has requested a Blood Money duel with you!", player->GetName().c_str());
  226.                                 creature->MonsterWhisper(msg, target->GetGUID(), true);
  227.                             }
  228.                             else
  229.                                 ChatHandler(target->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou cannot request a duel with the same person!");
  230.                         }
  231.                         else
  232.                             ChatHandler(player->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou cannot request a duel with somebody that has challenged you!");
  233.                         player->CLOSE_GOSSIP_MENU();
  234.                         return true;
  235.                     }
  236.                     else
  237.                     {
  238.                         uint32 money = action*10000;
  239.                         if (target->GetMoney() < money)
  240.                         {
  241.                             ChatHandler(player->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFThat player does not have enough money to make the bet!");
  242.                             player->CLOSE_GOSSIP_MENU();
  243.                             return false;
  244.                         }
  245.                         if (player->GetMoney() < money)
  246.                         {
  247.                             ChatHandler(player->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou do not have enough money to make the bet!");
  248.                             player->CLOSE_GOSSIP_MENU();
  249.                             return false;
  250.                         }
  251.  
  252.                         bool found = false;
  253.                         if (HasBloodMoneyChallenger(player->GetGUID()))
  254.                         {
  255.                             BloodMoneyList list = m_bloodMoney[player->GetGUID()];
  256.                             for (BloodMoneyList::const_iterator itr = list.begin(); itr != list.end(); ++itr)
  257.                                 if (itr->guid == target->GetGUID())
  258.                                     found = true;
  259.                         }
  260.                         if (!found)
  261.                         {
  262.                             if (!HasBloodMoneyChallenger(target->GetGUID(), player->GetGUID()))
  263.                             {
  264.                                 AddBloodMoneyEntry(target->GetGUID(), player->GetGUID(), money);
  265.                                 char msg[60];
  266.                                 sprintf(msg, "%s has requested a Blood Money duel with you!", player->GetName().c_str());
  267.                                 creature->MonsterWhisper(msg, target->GetGUID(), true);
  268.                             }
  269.                             else
  270.                                 ChatHandler(target->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou cannot request a duel with the same person!");
  271.                         }
  272.                         else
  273.                             ChatHandler(player->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou cannot request a duel with somebody that has challenged you!");
  274.                         player->CLOSE_GOSSIP_MENU();
  275.                         return true;
  276.                     }
  277.                    
  278.                 }
  279.                 else
  280.                 {
  281.                     ChatHandler(player->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFThat player is not in your zone!");
  282.                     player->CLOSE_GOSSIP_MENU();
  283.                     return false;
  284.                 }
  285.             }
  286.             else
  287.             {
  288.                 ChatHandler(player->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFThat player was not found!");
  289.                 player->CLOSE_GOSSIP_MENU();
  290.                 return false;
  291.             }
  292.         }
  293.         else
  294.         {
  295.             ChatHandler(player->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFThat player was not found!");
  296.             player->CLOSE_GOSSIP_MENU();
  297.             return false;
  298.         }
  299.         player->CLOSE_GOSSIP_MENU();
  300.         return true;
  301.     }
  302.  
  303. };
  304.  
  305. class BloodMoneyReward : public PlayerScript
  306. {
  307.  public:
  308.      BloodMoneyReward() : PlayerScript("BloodMoneyReward") {}
  309.      
  310.     void OnDuelEnd(Player* winner, Player* loser, DuelCompleteType type)
  311.     {
  312.         if (type != DUEL_WON)
  313.                     return;
  314.         if (HasBloodMoneyChallenger(winner->GetGUID()) || HasBloodMoneyChallenger(loser->GetGUID()))
  315.         {            
  316.             BloodMoneyList list1 = m_bloodMoney[winner->GetGUID()];
  317.             BloodMoneyList list2 = m_bloodMoney[loser->GetGUID()];
  318.  
  319.             BloodMoneyList::const_iterator itr;
  320.             for (itr = list1.begin(); itr != list1.end(); ++itr)
  321.             {
  322.                 if (itr->guid == loser->GetGUID() && itr->accepted)
  323.                 {
  324.                     if (USE_TOKEN)
  325.                     {
  326.                         if (winner->GetItemCount(TOKEN_ID) < itr->amount)
  327.                         {
  328.                             winner->AddAura(15007, winner);     // Apply Rez sickness for possible cheating
  329.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou have gained Resurrection Sickness for possibly trying to abuse the system.");
  330.                             ChatHandler(loser->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYour opponent tried to cheat you. Don't worry you did not lose any tokens because of this.");
  331.                             RemoveBloodMoneyEntry(winner->GetGUID(), itr->guid);
  332.                             return;
  333.                         }
  334.                         if (loser->GetItemCount(TOKEN_ID) >= itr->amount)
  335.                         {
  336.                             winner->AddItem(TOKEN_ID, itr->amount);
  337.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFCongratulations on winning %u tokens!", itr->amount);
  338.                             Item* item = loser->GetItemByEntry(TOKEN_ID);
  339.                             loser->DestroyItemCount(TOKEN_ID, itr->amount, true);
  340.                             RemoveBloodMoneyEntry(winner->GetGUID(), itr->guid);
  341.                         }
  342.                         else
  343.                         {
  344.                             loser->AddAura(15007, loser);       // Apply Rez sickness for possible cheating
  345.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYour opponent tried to cheat you. He did not have enough tokens to pay off the bet.");
  346.                             ChatHandler(loser->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou have gained Resurrection Sickness for possibly trying to abuse the system.");
  347.                             RemoveBloodMoneyEntry(winner->GetGUID(), itr->guid);
  348.                         }
  349.                         return;
  350.                     }
  351.                     else
  352.                     {
  353.                         if (winner->GetMoney() < itr->amount)
  354.                         {
  355.                             winner->AddAura(15007, winner);     // Apply Rez sickness for possible cheating
  356.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou have gained Resurrection Sickness for possibly trying to abuse the system.");
  357.                             ChatHandler(loser->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYour opponent tried to cheat you. Don't worry you did not lose any money because of this.");
  358.                             RemoveBloodMoneyEntry(winner->GetGUID(), itr->guid);
  359.                             return;
  360.                         }
  361.                         if (loser->GetMoney() >= itr->amount)
  362.                         {
  363.                             winner->ModifyMoney(itr->amount);
  364.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFCongratulations on winning %ug!", itr->amount/10000);
  365.                             loser->ModifyMoney(-(int32)(itr->amount));
  366.                             RemoveBloodMoneyEntry(winner->GetGUID(), itr->guid);
  367.                         }
  368.                         else
  369.                         {
  370.                             loser->AddAura(15007, loser);       // Apply Rez sickness for possible cheating
  371.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYour opponent tried to cheat you. He did not have enough money to pay off the bet.");
  372.                             ChatHandler(loser->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou have gained Resurrection Sickness for possibly trying to abuse the system.");
  373.                             RemoveBloodMoneyEntry(winner->GetGUID(), itr->guid);
  374.                         }
  375.                         return;
  376.                     }
  377.                 }
  378.             }
  379.             for (itr = list2.begin(); itr != list2.end(); ++itr)
  380.             {
  381.                 if (itr->guid == winner->GetGUID() && itr->accepted)
  382.                 {
  383.                     if (USE_TOKEN)
  384.                     {
  385.                         if (winner->GetItemCount(TOKEN_ID) < itr->amount)
  386.                         {
  387.                             winner->AddAura(15007, winner);     // Apply Rez sickness for possible cheating
  388.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou have gained Resurrection Sickness for possibly trying to abuse the system.");
  389.                             ChatHandler(loser->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYour opponent tried to cheat you. Don't worry you did not lose any tokens because of this.");
  390.                             RemoveBloodMoneyEntry(loser->GetGUID(), itr->guid);
  391.                             return;
  392.                         }
  393.                         if (loser->GetItemCount(TOKEN_ID) >= itr->amount)
  394.                         {
  395.                             winner->AddItem(TOKEN_ID, itr->amount);
  396.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFCongratulations on winning %u tokens!", itr->amount);
  397.                             Item* item = loser->GetItemByEntry(TOKEN_ID);
  398.                             loser->DestroyItemCount(TOKEN_ID, itr->amount, true);
  399.                             RemoveBloodMoneyEntry(loser->GetGUID(), itr->guid);
  400.                         }
  401.                         else
  402.                         {
  403.                             loser->AddAura(15007, loser);       // Apply Rez sickness for possible cheating
  404.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYour opponent tried to cheat you. He did not have enough tokens to pay off the bet.");
  405.                             ChatHandler(loser->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou have gained Resurrection Sickness for possibly trying to abuse the system.");
  406.                             RemoveBloodMoneyEntry(loser->GetGUID(), itr->guid);
  407.                         }
  408.                         return;
  409.                     }
  410.                     else
  411.                     {
  412.                         if (winner->GetMoney() < itr->amount)
  413.                         {
  414.                             winner->AddAura(15007, winner);     // Apply Rez sickness for possible cheating
  415.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou have gained Resurrection Sickness for possibly trying to abuse the system.");
  416.                             ChatHandler(loser->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYour opponent tried to cheat you. Don't worry you did not lose any money because of this.");
  417.                             RemoveBloodMoneyEntry(loser->GetGUID(), itr->guid);
  418.                             return;
  419.                         }
  420.                         if (loser->GetMoney() >= itr->amount)
  421.                         {
  422.                             winner->ModifyMoney(itr->amount);
  423.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFCongratulations on winning %ug!", itr->amount/10000);
  424.                             loser->ModifyMoney(-(int32)(itr->amount));
  425.                             RemoveBloodMoneyEntry(loser->GetGUID(), itr->guid);
  426.                         }
  427.                         else
  428.                         {
  429.                             loser->AddAura(15007, loser);       // Apply Rez sickness for possible cheating
  430.                             ChatHandler(winner->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYour opponent tried to cheat you. He did not have enough money to pay off the bet.");
  431.                             ChatHandler(loser->GetSession()).PSendSysMessage("|cff800C0C[Blood Money] |cffFFFFFFYou have gained Resurrection Sickness for possibly trying to abuse the system.");
  432.                             RemoveBloodMoneyEntry(loser->GetGUID(), itr->guid);
  433.                         }
  434.                         return;
  435.                     }
  436.                 }
  437.             }
  438.  
  439.          }
  440.      }
  441. };
  442.  
  443. void AddSC_npc_blood_money()
  444. {
  445.     new BloodMoneyReward();
  446.     new npc_blood_money();
  447. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement