Advertisement
Rochet2

Untitled

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