-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathvendor_general.cpp
92 lines (78 loc) · 2.98 KB
/
vendor_general.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "ScriptPCH.h"
#include <cstring>
#include "CustomVendor.h" // upravte si cestu
class vendor_multi : public CreatureScript
{
public:
vendor_multi()
: CreatureScript("vendor_multi")
{
}
bool OnGossipHello(Player* player, Creature* creature)
{
IterateCategory(player, creature);
return true;
}
void IterateCategory(Player* player, Creature* creature, int category = 0)
{
player->PlayerTalkClass->ClearMenus();
player->currentVendorEntry = -1;
VendorEntry *current = current = CustomVendorMgr.GetParent(category);
VendorEntryList *result;
if(category == 0)
result = CustomVendorMgr.GetBaseItemsForEntry(creature->GetEntry());
else
result = CustomVendorMgr.GetItemsForEntry(creature->GetEntry(), category);
VendorEntryList::iterator i;
int x = 0;
for (i = result->begin(); i != result->end(); ++i)
{
VendorEntry *vendorEntry = *i;
int icon = GOSSIP_ICON_CHAT;
if(CustomVendorMgr.GetNext(creature->GetEntry(), vendorEntry->next) < 0)
icon = GOSSIP_ICON_MONEY_BAG;
player->ADD_GOSSIP_ITEM(icon, vendorEntry->desc, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2+vendorEntry->next);
x++;
if(x == 5)
{
player->PlayerTalkClass->SendGossipMenu(11102, creature->GetGUID());
x = 0;
}
}
if(current)
{
if(current->group != 0)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "<< back", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2+current->id);
else
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "<< back", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
x++;
}
if(x != 0)
player->PlayerTalkClass->SendGossipMenu(11102, creature->GetGUID());
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
{
if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
{
IterateCategory(player, creature);
}
else if (uiAction > GOSSIP_ACTION_INFO_DEF+1)
{
int id = uiAction-GOSSIP_ACTION_INFO_DEF-2;
int next = CustomVendorMgr.GetNext(creature->GetEntry(), id);
if(next < 0)
{
next = (-1) * next;
player->currentVendorEntry = next;
player->GetSession()->SendListInventory(creature->GetGUID(), next);
}
else
IterateCategory(player, creature, id);
}
return true;
}
};
void AddSC_vendor_multi()
{
new vendor_multi();
}