Advertisement
Hamar

asd

Jun 25th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.96 KB | None | 0 0
  1. /*
  2.  *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
  3.  *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
  4.  *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
  5.  *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
  6.  *       EmuDevs - (http://emudevs.com)
  7. */
  8.  
  9. enum Misc
  10. {
  11.     BOUNTY_AMOUNT_GOLD = 100000
  12. };
  13.  
  14. struct BountyInfo
  15. {
  16.     std::string name;
  17.     std::string bounty;
  18.     uint64 hunted;
  19.     uint64 hunter;
  20.     uint32 gold;
  21. };
  22.  
  23. std::map<uint64, BountyInfo> Bounty;
  24.  
  25. void DoSendMessageToWorld(int msg, std::string name, std::string playerName)
  26. {
  27.     std::ostringstream ss;
  28.     if (msg == 1)
  29.     {
  30.         ss << "|cffFF0000A Bounty has been placed on "
  31.             << name.c_str()
  32.             << "'s head!|r";
  33.     }
  34.     else if (msg == 2)
  35.     {
  36.         ss << "|cffFFA500Increased the price on "
  37.             << name.c_str()
  38.             << "'s head!|r";
  39.     }
  40.     else if (msg == 3)
  41.     {
  42.         ss << "|cffFF0000 "
  43.             << playerName.c_str()
  44.             << " has killed "
  45.             << name.c_str()
  46.             << ", a bounty target!";
  47.     }
  48.     sWorld->SendGlobalText(ss.str().c_str(), NULL);
  49. }
  50.  
  51. class npc_b_hunter : public CreatureScript
  52. {
  53. public:
  54.     npc_b_hunter() : CreatureScript("npc_bounty_hunter") { }
  55.  
  56.     bool OnGossipHello(Player * player, Creature * creature)
  57.     {
  58.         player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_BATTLE, "I would like to place a bounty. [10g]", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);
  59.         if(!Bounty.empty())
  60.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Show Bounty List", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  61.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Nevermind..", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);
  62.         player->SEND_GOSSIP_MENU(1, creature->GetGUID());
  63.         return true;
  64.     }
  65.  
  66.     bool OnGossipSelect(Player * player, Creature * creature, uint32 /* sender */, uint32 actions)
  67.     {
  68.         player->PlayerTalkClass->ClearMenus();
  69.  
  70.         if (actions == GOSSIP_ACTION_INFO_DEF+2)
  71.         {
  72.             for(std::map<uint64, BountyInfo>::const_iterator i = Bounty.begin(); i != Bounty.end(); ++i)
  73.                 ChatHandler(player->GetSession()).PSendSysMessage("Current Bounties: \n Name: %s, Money: %u, Bounty: %s", i->second.name.c_str(), i->second.gold, i->second.bounty.c_str());
  74.             player->PlayerTalkClass->SendCloseGossip();
  75.                 }
  76.         else
  77.             player->CLOSE_GOSSIP_MENU();
  78.         return true;
  79.     }
  80.  
  81.     bool OnGossipSelectCode(Player* player, Creature* creature, uint32 /* sender */, uint32 action, const char* code)
  82.     {
  83.         player->PlayerTalkClass->ClearMenus();
  84.  
  85.         std::string name = code;
  86.         Player * hunted = NULL;
  87.        
  88.         if(!name.empty())
  89.             hunted = sObjectAccessor->FindPlayerByName(name.c_str());
  90.  
  91.         switch(action)
  92.         {
  93.             case GOSSIP_ACTION_INFO_DEF+1:
  94.             {
  95.                      
  96.                 for(std::map<uint64, BountyInfo>::const_iterator i = Bounty.begin(); i != Bounty.end(); ++i)
  97.                 {
  98.                     if(i->second.bounty == player->GetName())
  99.                     {
  100.                         player->GetSession()->SendNotification("You have already placed a bounty!");
  101.                         player->CLOSE_GOSSIP_MENU();
  102.                         return false;
  103.                     }
  104.  
  105.                     if(i->second.hunted == player->GetGUID())
  106.                     {
  107.                         player->GetSession()->SendNotification("You cannot place a bounty if you're being hunted!");
  108.                         player->CLOSE_GOSSIP_MENU();
  109.                         return false;
  110.                     }
  111.  
  112.                     if(i->second.hunted == hunted->GetGUID())
  113.                     {
  114.                         Bounty[i->second.hunter].gold += BOUNTY_AMOUNT_GOLD;
  115.                         ChatHandler(player->GetSession()).PSendSysMessage("A hunter already made his mark on %s! So, the price for this bounty went up!", i->second.name.c_str());
  116.                         DoSendMessageToWorld(2, i->second.name, "");
  117.                         player->CLOSE_GOSSIP_MENU();
  118.                         return false;
  119.                     }
  120.                  }
  121.  
  122.                  if(player->GetMoney() >= BOUNTY_AMOUNT_GOLD)
  123.                  {
  124.                      player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_BATTLE, "I would like to place a bounty. [10g]", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);
  125.                      player->ModifyMoney(-BOUNTY_AMOUNT_GOLD);
  126.                  }
  127.                  else
  128.                  {
  129.                      player->GetSession()->SendNotification("You don't have enough gold!");
  130.                      player->CLOSE_GOSSIP_MENU();
  131.                      return false;
  132.                  }
  133.  
  134.                  if(name == player->GetName())
  135.                  {
  136.                      player->GetSession()->SendNotification("You cannot place a bounty on yourself!");
  137.                      player->CLOSE_GOSSIP_MENU();
  138.                      return false;
  139.                  }
  140.  
  141.                  if(!hunted)
  142.                  {
  143.                      player->GetSession()->SendNotification("Player %s is not online.", name.c_str());
  144.                      player->CLOSE_GOSSIP_MENU();
  145.                      return false;
  146.                  }
  147.                  Bounty[hunted->GetGUID()].hunted = hunted->GetGUID();
  148.                  Bounty[hunted->GetGUID()].hunter = player->GetGUID();
  149.                  Bounty[hunted->GetGUID()].gold = BOUNTY_AMOUNT_GOLD;
  150.                  Bounty[hunted->GetGUID()].name = name.c_str();
  151.                  Bounty[hunted->GetGUID()].bounty = player->GetName();
  152.                  ChatHandler(player->GetSession()).PSendSysMessage("|cffFF0000Bounty was placed on %s!|r", name.c_str());
  153.                  player->Whisper("I placed a Bounty on you!", LANG_UNIVERSAL, hunted->GetGUID());
  154.                  DoSendMessageToWorld(1, name.c_str(), "");
  155.                  player->CLOSE_GOSSIP_MENU();
  156.             }break;
  157.         }
  158.         return true;
  159.     }
  160. };
  161.  
  162. class bounty_kills : public PlayerScript
  163. {
  164. public:
  165.     bounty_kills() : PlayerScript("bounty_kills") { }
  166.  
  167.     void OnPVPKill(Player * killer, Player * victim)
  168.     {
  169.         if(killer->GetGUID() == victim->GetGUID())
  170.             return;
  171.  
  172.         for(std::map<uint64, BountyInfo>::const_iterator i = Bounty.begin(); i != Bounty.end(); ++i)
  173.         {
  174.             if(i->second.hunted == victim->GetGUID())
  175.             {
  176.                 killer->ModifyMoney(Bounty[victim->GetGUID()].gold);
  177.                 ChatHandler(killer->GetSession()).PSendSysMessage("Added %u gold for your kill!", Bounty[victim->GetGUID()].gold);
  178.                 Bounty.erase(victim->GetGUID());
  179.                 DoSendMessageToWorld(3, victim->GetName(), killer->GetName());
  180.             }
  181.         }
  182.     }
  183. };
  184.  
  185. void AddSC_bounties_hunters()
  186. {
  187.     new npc_b_hunter;
  188.     new bounty_kills;
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement