-
Notifications
You must be signed in to change notification settings - Fork 87
/
NPC_Tools.cpp
101 lines (85 loc) · 3.56 KB
/
NPC_Tools.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
93
94
95
96
97
98
99
100
101
#include "ScriptMgr.h"
#include "ScriptedGossip.h"
#include "Player.h"
#include "Creature.h"
#include "SpellHistory.h"
#include "Chat.h"
#define DEFAULT_MESSAGE 907
class NPC_Tools : public CreatureScript
{
public:
NPC_Tools() : CreatureScript("NPC_Tools") { }
bool OnGossipHello(Player *player, Creature *creature)
{
AddGossipItemFor(player, GOSSIP_ICON_TRAINER, "Restore HP and MP", GOSSIP_SENDER_MAIN, 1);
AddGossipItemFor(player, GOSSIP_ICON_TRAINER, "Reset Instances", GOSSIP_SENDER_MAIN, 2);
AddGossipItemFor(player, GOSSIP_ICON_TRAINER, "Reset Cooldowns", GOSSIP_SENDER_MAIN, 3);
AddGossipItemFor(player, GOSSIP_ICON_TRAINER, "Reset Combat", GOSSIP_SENDER_MAIN, 4);
AddGossipItemFor(player, GOSSIP_ICON_TRAINER, "Remove Sickness", GOSSIP_SENDER_MAIN, 5);
AddGossipItemFor(player, GOSSIP_ICON_TRAINER, "Repair Items", GOSSIP_SENDER_MAIN, 6);
SendGossipMenuFor(player, DEFAULT_MESSAGE, creature->GetGUID());
return true;
}
bool OnGossipSelect(Player *player, Creature *creature, uint32 sender, uint32 action)
{
player->PlayerTalkClass->ClearMenus();
switch (action)
{
case 1: // Restore HP and MP
if (player->IsInCombat())
{
ChatHandler(player->GetSession()).PSendSysMessage("Failure! You are in combat.");
CloseGossipMenuFor(player);
return false;
}
if (player->getPowerType() == POWER_MANA)
player->SetPower(POWER_MANA, player->GetMaxPower(POWER_MANA));
player->SetHealth(player->GetMaxHealth());
ChatHandler(player->GetSession()).PSendSysMessage("Success! HP and MP restored.");
CloseGossipMenuFor(player);
break;
case 2: // Reset Instances
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
Player::BoundInstancesMap &binds = player->GetBoundInstances(Difficulty(i));
for (Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();)
player->UnbindInstance(itr, Difficulty(i));
}
ChatHandler(player->GetSession()).PSendSysMessage("Success! Instances reseted.");
CloseGossipMenuFor(player);
break;
case 3: // Reset Cooldowns
if (player->IsInCombat())
{
ChatHandler(player->GetSession()).PSendSysMessage("Failure! You are in combat.");
CloseGossipMenuFor(player);
return false;
}
player->GetSpellHistory()->ResetAllCooldowns();
ChatHandler(player->GetSession()).PSendSysMessage("Success! Cooldowns reseted.");
CloseGossipMenuFor(player);
break;
case 4: // Reset Combat
player->CombatStop();
ChatHandler(player->GetSession()).PSendSysMessage("Success! Combat reseted.");
CloseGossipMenuFor(player);
break;
case 5: // Remove Sickness
if (player->HasAura(15007))
player->RemoveAura(15007);
ChatHandler(player->GetSession()).PSendSysMessage("Success! Sickness removed.");
CloseGossipMenuFor(player);
break;
case 6: // Repair Items
player->DurabilityRepairAll(false, 0, false);
ChatHandler(player->GetSession()).PSendSysMessage("Success! Items repaired.");
CloseGossipMenuFor(player);
break;
}
return true;
}
};
void AddSC_NPC_Tools()
{
new NPC_Tools();
}