forked from Watcher187/UWoWScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathold_transmogrify
145 lines (127 loc) · 5.37 KB
/
old_transmogrify
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "ScriptPCH.h"
enum TransmogrifyActions {
ACTION_TRANSMOGRIFY_ADD_DISPLAY,
ACTION_TRANSMOGRIFY_REMOVE_DISPLAY,
ACTION_TRANSMOGRIFY_SUPPLYS,
ACTION_TRANSMOGRIFY_ADD_DISPLAY_TWO
};
class npc_transmogrify : public CreatureScript
{
public:
npc_transmogrify() : CreatureScript("npc_transmogrify") { }
bool OnGossipHello(Player* pPlayer, Creature* pCreature)
{
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "Make exchange! 4 PvP Tickets", GOSSIP_SENDER_MAIN, ACTION_TRANSMOGRIFY_ADD_DISPLAY);
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "Make exchange! 1 Transmogrifaction Tokens", GOSSIP_SENDER_MAIN, ACTION_TRANSMOGRIFY_ADD_DISPLAY_TWO);
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "Make item clean.", GOSSIP_SENDER_MAIN, ACTION_TRANSMOGRIFY_REMOVE_DISPLAY);
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "Transmogrify Supplys", GOSSIP_SENDER_MAIN, ACTION_TRANSMOGRIFY_SUPPLYS);
pPlayer->SEND_GOSSIP_MENU(51000, pCreature->GetGUID());
return true;
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
{
player->PlayerTalkClass->SendCloseGossip();
switch (action)
{
case ACTION_TRANSMOGRIFY_ADD_DISPLAY:
TransmogrifyItem(player, creature);
break;
case ACTION_TRANSMOGRIFY_ADD_DISPLAY_TWO:
TransmogrifyItemTwo(player, creature);
break;
case ACTION_TRANSMOGRIFY_REMOVE_DISPLAY:
ClearItem(player, creature);
break;
case ACTION_TRANSMOGRIFY_SUPPLYS:
pPlayer->GetSession()->SendListInventory(creature->GetGUID());
break;
}
return true;
}
void TransmogrifyItem(Player* player, Creature* creature)
{
ChatHandler handler(player);
Item *trItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, INVENTORY_SLOT_ITEM_START);
Item *displayItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, INVENTORY_SLOT_ITEM_START + 1);
if (!trItem || !displayItem)
{
handler.PSendSysMessage("Put item in the first and second slot!");
return;
}
if (!player->HasItemCount(19182, 4, true))
{
handler.PSendSysMessage("It costs 4 PvP Prize Tickets!");
return;
}
uint8 result = trItem->SetFakeDisplay(displayItem->GetTemplate()->ItemId);
switch (result)
{
case FAKE_ERR_CANT_FIND_ITEM:
handler.PSendSysMessage("Cant find item!");
break;
case FAKE_ERR_OK:
{
WorldPacket data;
data << uint8(INVENTORY_SLOT_BAG_0);
data << uint8(trItem->GetSlot());
player->GetSession()->HandleAutoEquipItemOpcode(data);
player->DestroyItemCount(19182, 4, true);
handler.PSendSysMessage("Item successfully transmogrified!!");
break;
}
}
}
void TransmogrifyItemTwo(Player* player, Creature* creature)
{
ChatHandler handler(player);
Item *trItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, INVENTORY_SLOT_ITEM_START);
Item *displayItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, INVENTORY_SLOT_ITEM_START + 1);
if (!trItem || !displayItem)
{
handler.PSendSysMessage("Put item in the first and second slot!");
return;
}
if (!player->HasItemCount(986504, 1, true))
{
handler.PSendSysMessage("It costs 1 Transmogrification Tokens!");
return;
}
uint8 result = trItem->SetFakeDisplay(displayItem->GetTemplate()->ItemId);
switch (result)
{
case FAKE_ERR_CANT_FIND_ITEM:
handler.PSendSysMessage("Cant find item!");
break;
case FAKE_ERR_OK:
{
WorldPacket data;
data << uint8(INVENTORY_SLOT_BAG_0);
data << uint8(trItem->GetSlot());
player->GetSession()->HandleAutoEquipItemOpcode(data);
player->DestroyItemCount(986504, 1, true);
handler.PSendSysMessage("Item successfully transmogrified!!");
break;
}
}
}
void ClearItem(Player *player, Creature* creature)
{
ChatHandler handler(player);
Item *trItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, INVENTORY_SLOT_ITEM_START);
if (!trItem)
{
handler.PSendSysMessage("Put item in the first slot!");
return;
}
trItem->RemoveFakeDisplay();
WorldPacket data;
data << uint8(INVENTORY_SLOT_BAG_0);
data << uint8(trItem->GetSlot());
player->GetSession()->HandleAutoEquipItemOpcode(data);
handler.PSendSysMessage("Item successfully cleared!!");
}
};
void AddSC_Transmogrification()
{
new npc_transmogrify;
}