Repository navigation
Expand file tree
/
Copy pathItemScript.cpp
More file actions
120 lines (110 loc) · 4.24 KB
/
Copy pathItemScript.cpp
File metadata and controls
120 lines (110 loc) · 4.24 KB
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
#include "HookMacros.h"
#include "ScriptMgr.h"
#include "Player.h"
#include "Spell.h"
class PythonItemScript : public ItemScript
{
public:
PythonItemScript() : ItemScript("PythonItemScript") {}
/**
* @brief Disable database binding requirement and suppress errors like:
* Script named '<PythonEntityScript>' is not assigned in the database.
*
* @todo should use AllItemScript instead?
*/
bool IsDatabaseBound() const override { return false; }
/**
* @brief Called when a player accepts a quest from the item
*
* @param player Contains information about the Player
* @param item Contains information about the Item
* @param quest Contains information about the Quest
* @return False if you want to continue, true if you want to disable
*/
bool OnQuestAccept(Player* player, Item* item, Quest const* quest) override
{
TRIGGER_ITEM_HOOK(ON_USE, item->GetEntry(), player, item, quest);
return false;
}
/**
* @brief Called when a player uses the item
*
* @param player Contains information about the Player
* @param item Contains information about the Item
* @param targets Contains information about the SpellCastTargets
* @return False if you want to continue, true if you want to disable
*/
bool OnUse(Player* player, Item* item, SpellCastTargets const& targets) override
{
TRIGGER_ITEM_HOOK(ON_USE, item->GetEntry(), player, item, targets);
return false;
}
/**
* @brief Called when the item is destroyed
*
* @param player Contains information about the Player
* @param item Contains information about the Item
* @return False if you want to continue, true if you want to disable
*/
bool OnRemove(Player* player, Item* item) override
{
TRIGGER_ITEM_HOOK(ON_USE, item->GetEntry(), player, item);
return false;
}
/**
* @brief Called before casting a combat spell from this item (chance on hit
* spells of item template, can be used to prevent cast if returning false)
*
* @param player Contains information about the Player
* @param victim Contains information about the victim Unit
* @param spellInfo Contains information about the SpellInfo
* @param item Contains information about the Item
* @return False if you want to continue, true if you want to disable
*/
bool OnCastItemCombatSpell(Player* player, Unit* victim, SpellInfo const* spellInfo, Item* item) override
{
TRIGGER_ITEM_HOOK(ON_USE, item->GetEntry(), player, victim, spellInfo, item);
return true;
}
/**
* @brief Called when the item expires (is destroyed)
*
* @param player Contains information about the Player
* @param proto Contains information about the ItemTemplate
* @return False if you want to continue, true if you want to disable
*/
bool OnExpire(Player* player, ItemTemplate const* proto) override
{
TRIGGER_ITEM_HOOK(ON_USE, proto->ItemId, player, proto);
return false;
}
/**
* @brief Called when a player selects an option in an item gossip window
*
* @param player Contains information about the Player
* @param item Contains information about the Item
* @param sender Contains information about the sender type
* @param action Contains information about the action id
*/
void OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action) override
{
TRIGGER_ITEM_HOOK(ON_USE, item->GetEntry(), player, item, sender, action);
}
/**
* @brief Called when a player selects an option in an item gossip window
*
* @param player Contains information about the Player
* @param item Contains information about the Item
* @param sender Contains information about the sender type
* @param action Contains information about the action id
* @param code Contains information about the code entered
*/
void OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, char const* code) override
{
TRIGGER_ITEM_HOOK(ON_USE, item->GetEntry(), player, item, sender, action, code);
}
};
void AddSC_PythonItemScripts()
{
new PythonItemScript();
}