Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum Misc
- {
- BOUNTY_AMOUNT_GOLD = 100000
- };
- struct BountyInfo
- {
- std::string name;
- std::string bounty;
- uint64 hunted;
- uint64 hunter;
- uint32 gold;
- };
- typedef std::map<uint64, BountyInfo> bountyMap;
- bountyMap Bounty;
- void DoSendMessageToWorld(int msg, std::string name, std::string playerName)
- {
- std::ostringstream ss;
- switch (msg)
- {
- case 1:
- {
- ss << "|cffFF0000A Bounty has been placed on "
- << name
- << "'s head!|r";
- } break;
- case 2:
- {
- ss << "|cffFFA500Increased the price on "
- << name
- << "'s head!|r";
- } break;
- case 3:
- {
- ss << "|cffFF0000 "
- << playerName
- << " has killed "
- << name
- << ", a bounty target!";
- } break;
- default:
- return;
- }
- sWorld->SendServerMessage(SERVER_MSG_STRING, ss.str().c_str());
- }
- 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)
- {
- ChatHandler(player->GetSession()).PSendSysMessage("Current Bounties:");
- for(bountyMap::const_iterator i = Bounty.begin(); i != Bounty.end(); ++i)
- ChatHandler(player->GetSession()).PSendSysMessage("Name: %s, Money: %u, Bounty: %s", i->second.name.c_str(), i->second.gold, i->second.bounty.c_str());
- }
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- bool OnGossipSelectCode(Player* player, Creature* creature, uint32 /* sender */, uint32 action, const char* code)
- {
- player->PlayerTalkClass->ClearMenus();
- Player * hunted = NULL;
- if(code && strlen(code) > 0)
- hunted = sObjectAccessor->FindPlayerByName(code);
- if(!hunted)
- {
- player->GetSession()->SendNotification("Player \"%s\" is not online", code);
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- if(action == GOSSIP_ACTION_INFO_DEF+1)
- {
- if(player->GetMoney() < BOUNTY_AMOUNT_GOLD)
- {
- player->GetSession()->SendNotification("You don't have enough gold!");
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- if(hunted->GetGUID() == player->GetGUID())
- {
- player->GetSession()->SendNotification("You cannot place a bounty on yourself!");
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- for(bountyMap::iterator i = Bounty.begin(); i != Bounty.end(); ++i)
- {
- if(i->second.hunter == player->GetGUID())
- {
- player->GetSession()->SendNotification("You have already placed a bounty!");
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- if(i->second.hunted == player->GetGUID())
- {
- player->GetSession()->SendNotification("You cannot place a bounty if you're being hunted!");
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- if(i->second.hunted == hunted->GetGUID())
- {
- i->second.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 true;
- }
- }
- player->ModifyMoney(-BOUNTY_AMOUNT_GOLD);
- Bounty[hunted->GetGUID()].hunted = hunted->GetGUID();
- Bounty[hunted->GetGUID()].hunter = player->GetGUID();
- Bounty[hunted->GetGUID()].gold = BOUNTY_AMOUNT_GOLD;
- Bounty[hunted->GetGUID()].name = hunted->GetName();
- Bounty[hunted->GetGUID()].bounty = player->GetName();
- ChatHandler(player->GetSession()).PSendSysMessage("|cffFF0000Bounty was placed on %s!|r", hunted->GetName().c_str());
- player->Whisper("I placed a Bounty on you!", LANG_UNIVERSAL, hunted->GetGUID());
- DoSendMessageToWorld(1, hunted->GetName().c_str(), "");
- }
- player->CLOSE_GOSSIP_MENU();
- 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;
- bountyMap::const_iterator it = Bounty.find(victim->GetGUID());
- if(it == Bounty.end())
- return;
- killer->ModifyMoney(it->second.gold);
- ChatHandler(killer->GetSession()).PSendSysMessage("Added %u gold for your kill!", it->second.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