Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
- *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
- *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
- *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
- * EmuDevs - (http://emudevs.com)
- */
- enum Misc
- {
- BOUNTY_AMOUNT_GOLD = 100000
- };
- struct BountyInfo
- {
- std::string name;
- std::string bounty;
- uint64 hunted;
- uint64 hunter;
- uint32 gold;
- };
- std::map<uint64, BountyInfo> Bounty;
- void DoSendMessageToWorld(int msg, std::string name, std::string playerName)
- {
- std::ostringstream ss;
- if (msg == 1)
- {
- ss << "|cffFF0000A Bounty has been placed on "
- << name.c_str()
- << "'s head!|r";
- }
- else if (msg == 2)
- {
- ss << "|cffFFA500Increased the price on "
- << name.c_str()
- << "'s head!|r";
- }
- else if (msg == 3)
- {
- ss << "|cffFF0000 "
- << playerName.c_str()
- << " has killed "
- << name.c_str()
- << ", a bounty target!";
- }
- sWorld->SendGlobalText(ss.str().c_str(), NULL);
- }
- class npc_b_hunter : public CreatureScript
- {
- public:
- npc_b_hunter() : CreatureScript("npc_bounty_hunter") { }
- bool OnGossipHello(Player * player, Creature * creature)
- {
- 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);
- if(!Bounty.empty())
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Show Bounty List", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Nevermind..", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);
- player->SEND_GOSSIP_MENU(1, creature->GetGUID());
- return true;
- }
- bool OnGossipSelect(Player * player, Creature * creature, uint32 /* sender */, uint32 actions)
- {
- player->PlayerTalkClass->ClearMenus();
- if (actions == GOSSIP_ACTION_INFO_DEF+2)
- {
- for(std::map<uint64, BountyInfo>::const_iterator i = Bounty.begin(); i != Bounty.end(); ++i)
- 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());
- player->PlayerTalkClass->SendCloseGossip();
- }
- else
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- bool OnGossipSelectCode(Player* player, Creature* creature, uint32 /* sender */, uint32 action, const char* code)
- {
- player->PlayerTalkClass->ClearMenus();
- std::string name = code;
- Player * hunted = NULL;
- if(!name.empty())
- hunted = sObjectAccessor->FindPlayerByName(name.c_str());
- switch(action)
- {
- case GOSSIP_ACTION_INFO_DEF+1:
- {
- for(std::map<uint64, BountyInfo>::const_iterator i = Bounty.begin(); i != Bounty.end(); ++i)
- {
- if(i->second.bounty == player->GetName())
- {
- player->GetSession()->SendNotification("You have already placed a bounty!");
- player->CLOSE_GOSSIP_MENU();
- return false;
- }
- if(i->second.hunted == player->GetGUID())
- {
- player->GetSession()->SendNotification("You cannot place a bounty if you're being hunted!");
- player->CLOSE_GOSSIP_MENU();
- return false;
- }
- if(i->second.hunted == hunted->GetGUID())
- {
- Bounty[i->second.hunter].gold += BOUNTY_AMOUNT_GOLD;
- 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());
- DoSendMessageToWorld(2, i->second.name, "");
- player->CLOSE_GOSSIP_MENU();
- return false;
- }
- }
- if(player->GetMoney() >= BOUNTY_AMOUNT_GOLD)
- {
- 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);
- player->ModifyMoney(-BOUNTY_AMOUNT_GOLD);
- }
- else
- {
- player->GetSession()->SendNotification("You don't have enough gold!");
- player->CLOSE_GOSSIP_MENU();
- return false;
- }
- if(name == player->GetName())
- {
- player->GetSession()->SendNotification("You cannot place a bounty on yourself!");
- player->CLOSE_GOSSIP_MENU();
- return false;
- }
- if(!hunted)
- {
- player->GetSession()->SendNotification("Player %s is not online.", name.c_str());
- player->CLOSE_GOSSIP_MENU();
- return false;
- }
- Bounty[hunted->GetGUID()].hunted = hunted->GetGUID();
- Bounty[hunted->GetGUID()].hunter = player->GetGUID();
- Bounty[hunted->GetGUID()].gold = BOUNTY_AMOUNT_GOLD;
- Bounty[hunted->GetGUID()].name = name.c_str();
- Bounty[hunted->GetGUID()].bounty = player->GetName();
- ChatHandler(player->GetSession()).PSendSysMessage("|cffFF0000Bounty was placed on %s!|r", name.c_str());
- player->Whisper("I placed a Bounty on you!", LANG_UNIVERSAL, hunted->GetGUID());
- DoSendMessageToWorld(1, name.c_str(), "");
- player->CLOSE_GOSSIP_MENU();
- }break;
- }
- return true;
- }
- };
- class bounty_kills : public PlayerScript
- {
- public:
- bounty_kills() : PlayerScript("bounty_kills") { }
- void OnPVPKill(Player * killer, Player * victim)
- {
- if(killer->GetGUID() == victim->GetGUID())
- return;
- for(std::map<uint64, BountyInfo>::const_iterator i = Bounty.begin(); i != Bounty.end(); ++i)
- {
- if(i->second.hunted == victim->GetGUID())
- {
- killer->ModifyMoney(Bounty[victim->GetGUID()].gold);
- ChatHandler(killer->GetSession()).PSendSysMessage("Added %u gold for your kill!", Bounty[victim->GetGUID()].gold);
- Bounty.erase(victim->GetGUID());
- DoSendMessageToWorld(3, victim->GetName(), killer->GetName());
- }
- }
- }
- };
- void AddSC_bounties_hunters()
- {
- new npc_b_hunter;
- new bounty_kills;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement