TrinityCore
Loading...
Searching...
No Matches
deadmines.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/* ScriptData
19SDName: Deadmines
20SD%Complete: 0
21SDComment: Placeholder
22SDCategory: Deadmines
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "deadmines.h"
27#include "GameObject.h"
28#include "InstanceScript.h"
29#include "Item.h"
30#include "Player.h"
31#include "ScriptedCreature.h"
32#include "Spell.h"
33#include "WorldSession.h"
34
35/*#####
36# item_Defias_Gunpowder
37#####*/
38
40{
41public:
42 item_defias_gunpowder() : ItemScript("item_defias_gunpowder") { }
43
44 bool OnUse(Player* player, Item* item, SpellCastTargets const& targets) override
45 {
46 InstanceScript* instance = player->GetInstanceScript();
47
48 if (!instance)
49 {
50 player->GetSession()->SendNotification("Instance script not initialized");
51 return true;
52 }
53
54 if (instance->GetData(EVENT_STATE) != CANNON_NOT_USED)
55 return false;
56
57 if (targets.GetGOTarget() && targets.GetGOTarget()->GetEntry() == GO_DEFIAS_CANNON)
59
60 player->DestroyItemCount(item->GetEntry(), 1, true);
61 return true;
62 }
63};
64
66{
68}
Definition Item.h:62
uint32 GetEntry() const
Definition Object.h:81
WorldSession * GetSession() const
Definition Player.h:1719
uint32 DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check=false)
Definition Player.cpp:12209
GameObject * GetGOTarget() const
Definition Spell.cpp:255
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
void SendNotification(const char *format,...) ATTR_PRINTF(2
virtual uint32 GetData(uint32) const
Definition ZoneScript.h:55
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:56
bool OnUse(Player *player, Item *item, SpellCastTargets const &targets) override
Definition deadmines.cpp:44
void AddSC_deadmines()
Definition deadmines.cpp:65
@ GO_DEFIAS_CANNON
Definition deadmines.h:64
@ EVENT_STATE
Definition deadmines.h:50
@ CANNON_NOT_USED
Definition deadmines.h:30
@ CANNON_GUNPOWDER_USED
Definition deadmines.h:31