SHOW:
|
|
- or go back to the newest paste.
1 | - | /* |
1 | + | |
2 | - | *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗ |
2 | + | |
3 | - | *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣ |
3 | + | |
4 | - | *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║ |
4 | + | |
5 | - | *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝ |
5 | + | |
6 | - | * EmuDevs - (http://emudevs.com) |
6 | + | |
7 | - | */ |
7 | + | |
8 | - | |
8 | + | |
9 | std::string name; | |
10 | std::string bounty; | |
11 | uint64 hunted; | |
12 | uint64 hunter; | |
13 | - | |
13 | + | |
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 | - | |
22 | + | switch (msg) |
23 | - | std::map<uint64, BountyInfo> Bounty; |
23 | + | |
24 | - | |
24 | + | case 1: |
25 | { | |
26 | ss << "|cffFF0000A Bounty has been placed on " | |
27 | << name | |
28 | - | if (msg == 1) |
28 | + | << "'s head!|r"; |
29 | } break; | |
30 | - | ss << "|cffFF0000A Bounty has been placed on " |
30 | + | case 2: |
31 | - | << name.c_str() |
31 | + | |
32 | - | << "'s head!|r"; |
32 | + | ss << "|cffFFA500Increased the price on " |
33 | << name | |
34 | - | else if (msg == 2) |
34 | + | << "'s head!|r"; |
35 | } break; | |
36 | - | ss << "|cffFFA500Increased the price on " |
36 | + | case 3: |
37 | - | << name.c_str() |
37 | + | |
38 | - | << "'s head!|r"; |
38 | + | ss << "|cffFF0000 " |
39 | << playerName | |
40 | - | else if (msg == 3) |
40 | + | << " has killed " |
41 | << name | |
42 | - | ss << "|cffFF0000 " |
42 | + | << ", a bounty target!"; |
43 | - | << playerName.c_str() |
43 | + | } break; |
44 | - | << " has killed " |
44 | + | default: |
45 | - | << name.c_str() |
45 | + | return; |
46 | - | << ", a bounty target!"; |
46 | + | |
47 | sWorld->SendServerMessage(SERVER_MSG_STRING, ss.str().c_str()); | |
48 | - | sWorld->SendGlobalText(ss.str().c_str(), NULL); |
48 | + | |
49 | ||
50 | - | |
50 | + | |
51 | { | |
52 | public: | |
53 | npc_b_hunter() : CreatureScript("npc_bounty_hunter") { } | |
54 | ||
55 | - | |
55 | + | |
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 | - | |
65 | + | |
66 | { | |
67 | player->PlayerTalkClass->ClearMenus(); | |
68 | ||
69 | - | |
69 | + | |
70 | { | |
71 | ChatHandler(player->GetSession()).PSendSysMessage("Current Bounties:"); | |
72 | - | for(std::map<uint64, BountyInfo>::const_iterator i = Bounty.begin(); i != Bounty.end(); ++i) |
72 | + | for(bountyMap::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()); |
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 | - | player->PlayerTalkClass->SendCloseGossip(); |
74 | + | |
75 | player->CLOSE_GOSSIP_MENU(); | |
76 | - | else |
76 | + | |
77 | } | |
78 | ||
79 | bool OnGossipSelectCode(Player* player, Creature* creature, uint32 /* sender */, uint32 action, const char* code) | |
80 | - | |
80 | + | |
81 | player->PlayerTalkClass->ClearMenus(); | |
82 | ||
83 | Player * hunted = NULL; | |
84 | - | |
84 | + | if(code && strlen(code) > 0) |
85 | - | std::string name = code; |
85 | + | hunted = sObjectAccessor->FindPlayerByName(code); |
86 | if(!hunted) | |
87 | - | |
87 | + | |
88 | - | if(!name.empty()) |
88 | + | player->GetSession()->SendNotification("Player \"%s\" is not online", code); |
89 | - | hunted = sObjectAccessor->FindPlayerByName(name.c_str()); |
89 | + | |
90 | - | |
90 | + | return true; |
91 | - | switch(action) |
91 | + | |
92 | ||
93 | - | case GOSSIP_ACTION_INFO_DEF+1: |
93 | + | if(action == GOSSIP_ACTION_INFO_DEF+1) |
94 | { | |
95 | - | |
95 | + | if(player->GetMoney() < BOUNTY_AMOUNT_GOLD) |
96 | - | for(std::map<uint64, BountyInfo>::const_iterator i = Bounty.begin(); i != Bounty.end(); ++i) |
96 | + | |
97 | player->GetSession()->SendNotification("You don't have enough gold!"); | |
98 | - | if(i->second.bounty == player->GetName()) |
98 | + | player->CLOSE_GOSSIP_MENU(); |
99 | - | { |
99 | + | return true; |
100 | - | player->GetSession()->SendNotification("You have already placed a bounty!"); |
100 | + | |
101 | - | player->CLOSE_GOSSIP_MENU(); |
101 | + | |
102 | - | return false; |
102 | + | if(hunted->GetGUID() == player->GetGUID()) |
103 | - | } |
103 | + | |
104 | - | |
104 | + | player->GetSession()->SendNotification("You cannot place a bounty on yourself!"); |
105 | - | if(i->second.hunted == player->GetGUID()) |
105 | + | player->CLOSE_GOSSIP_MENU(); |
106 | - | { |
106 | + | return true; |
107 | - | player->GetSession()->SendNotification("You cannot place a bounty if you're being hunted!"); |
107 | + | |
108 | - | player->CLOSE_GOSSIP_MENU(); |
108 | + | |
109 | - | return false; |
109 | + | for(bountyMap::iterator i = Bounty.begin(); i != Bounty.end(); ++i) |
110 | - | } |
110 | + | |
111 | - | |
111 | + | if(i->second.hunter == player->GetGUID()) |
112 | - | if(i->second.hunted == hunted->GetGUID()) |
112 | + | |
113 | - | { |
113 | + | player->GetSession()->SendNotification("You have already placed a bounty!"); |
114 | - | Bounty[i->second.hunter].gold += BOUNTY_AMOUNT_GOLD; |
114 | + | player->CLOSE_GOSSIP_MENU(); |
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()); |
115 | + | return true; |
116 | - | DoSendMessageToWorld(2, i->second.name, ""); |
116 | + | |
117 | - | player->CLOSE_GOSSIP_MENU(); |
117 | + | |
118 | - | return false; |
118 | + | if(i->second.hunted == player->GetGUID()) |
119 | - | } |
119 | + | |
120 | - | } |
120 | + | player->GetSession()->SendNotification("You cannot place a bounty if you're being hunted!"); |
121 | - | |
121 | + | player->CLOSE_GOSSIP_MENU(); |
122 | - | if(player->GetMoney() >= BOUNTY_AMOUNT_GOLD) |
122 | + | return true; |
123 | - | { |
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); |
124 | + | |
125 | - | player->ModifyMoney(-BOUNTY_AMOUNT_GOLD); |
125 | + | if(i->second.hunted == hunted->GetGUID()) |
126 | - | } |
126 | + | |
127 | - | else |
127 | + | i->second.gold += BOUNTY_AMOUNT_GOLD; |
128 | - | { |
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 | - | player->GetSession()->SendNotification("You don't have enough gold!"); |
129 | + | DoSendMessageToWorld(2, i->second.name, ""); |
130 | - | player->CLOSE_GOSSIP_MENU(); |
130 | + | player->CLOSE_GOSSIP_MENU(); |
131 | - | return false; |
131 | + | return true; |
132 | - | } |
132 | + | |
133 | - | |
133 | + | |
134 | - | if(name == player->GetName()) |
134 | + | |
135 | - | { |
135 | + | player->ModifyMoney(-BOUNTY_AMOUNT_GOLD); |
136 | - | player->GetSession()->SendNotification("You cannot place a bounty on yourself!"); |
136 | + | Bounty[hunted->GetGUID()].hunted = hunted->GetGUID(); |
137 | - | player->CLOSE_GOSSIP_MENU(); |
137 | + | Bounty[hunted->GetGUID()].hunter = player->GetGUID(); |
138 | - | return false; |
138 | + | Bounty[hunted->GetGUID()].gold = BOUNTY_AMOUNT_GOLD; |
139 | - | } |
139 | + | Bounty[hunted->GetGUID()].name = hunted->GetName(); |
140 | - | |
140 | + | Bounty[hunted->GetGUID()].bounty = player->GetName(); |
141 | - | if(!hunted) |
141 | + | ChatHandler(player->GetSession()).PSendSysMessage("|cffFF0000Bounty was placed on %s!|r", hunted->GetName().c_str()); |
142 | - | { |
142 | + | player->Whisper("I placed a Bounty on you!", LANG_UNIVERSAL, hunted->GetGUID()); |
143 | - | player->GetSession()->SendNotification("Player %s is not online.", name.c_str()); |
143 | + | DoSendMessageToWorld(1, hunted->GetName().c_str(), ""); |
144 | - | player->CLOSE_GOSSIP_MENU(); |
144 | + | |
145 | - | return false; |
145 | + | player->CLOSE_GOSSIP_MENU(); |
146 | - | } |
146 | + | |
147 | - | Bounty[hunted->GetGUID()].hunted = hunted->GetGUID(); |
147 | + | |
148 | - | Bounty[hunted->GetGUID()].hunter = player->GetGUID(); |
148 | + | |
149 | - | Bounty[hunted->GetGUID()].gold = BOUNTY_AMOUNT_GOLD; |
149 | + | |
150 | - | Bounty[hunted->GetGUID()].name = name.c_str(); |
150 | + | |
151 | - | Bounty[hunted->GetGUID()].bounty = player->GetName(); |
151 | + | |
152 | - | ChatHandler(player->GetSession()).PSendSysMessage("|cffFF0000Bounty was placed on %s!|r", name.c_str()); |
152 | + | |
153 | - | player->Whisper("I placed a Bounty on you!", LANG_UNIVERSAL, hunted->GetGUID()); |
153 | + | |
154 | - | DoSendMessageToWorld(1, name.c_str(), ""); |
154 | + | |
155 | - | player->CLOSE_GOSSIP_MENU(); |
155 | + | |
156 | - | }break; |
156 | + | |
157 | if(killer->GetGUID() == victim->GetGUID()) | |
158 | return; | |
159 | ||
160 | bountyMap::const_iterator it = Bounty.find(victim->GetGUID()); | |
161 | - | |
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 | - | |
166 | + | Bounty.erase(victim->GetGUID()); |
167 | DoSendMessageToWorld(3, victim->GetName(), killer->GetName()); | |
168 | } | |
169 | }; | |
170 | ||
171 | - | |
171 | + | |
172 | - | for(std::map<uint64, BountyInfo>::const_iterator i = Bounty.begin(); i != Bounty.end(); ++i) |
172 | + | |
173 | new npc_b_hunter; | |
174 | - | if(i->second.hunted == victim->GetGUID()) |
174 | + | |
175 | } |