TrinityCore
Loading...
Searching...
No Matches
npc_innkeeper.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: Npc_Innkeeper
20SDAuthor: WarHead
21SD%Complete: 99%
22SDComment: Complete
23SDCategory: NPCs
24EndScriptData */
25
26#include "ScriptMgr.h"
27#include "ScriptedCreature.h"
28#include "ScriptedGossip.h"
29#include "GameEventMgr.h"
30#include "Player.h"
31#include "WorldSession.h"
32
34{
36 SPELL_TREAT = 24715
37};
38
39enum Npc
40{
43};
44
46{
47public:
48 npc_innkeeper() : CreatureScript("npc_innkeeper") { }
49
51 {
52 npc_innkeeperAI(Creature* creature) : ScriptedAI(creature) { }
53
73
74 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
75 {
76 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
77 ClearGossipMenuFor(player);
79 {
80 player->CastSpell(player, SPELL_TRICK_OR_TREATED, true);
81
82 if (urand(0, 1))
83 player->CastSpell(player, SPELL_TREAT, true);
84 else
85 {
86 uint32 trickspell = 0;
87 switch (urand(0, 13))
88 {
89 case 0: trickspell = 24753; break; // cannot cast, random 30sec
90 case 1: trickspell = 24713; break; // lepper gnome costume
91 case 2: trickspell = 24735; break; // male ghost costume
92 case 3: trickspell = 24736; break; // female ghostcostume
93 case 4: trickspell = 24710; break; // male ninja costume
94 case 5: trickspell = 24711; break; // female ninja costume
95 case 6: trickspell = 24708; break; // male pirate costume
96 case 7: trickspell = 24709; break; // female pirate costume
97 case 8: trickspell = 24723; break; // skeleton costume
98 case 9: trickspell = 24753; break; // Trick
99 case 10: trickspell = 24924; break; // Hallow's End Candy
100 case 11: trickspell = 24925; break; // Hallow's End Candy
101 case 12: trickspell = 24926; break; // Hallow's End Candy
102 case 13: trickspell = 24927; break; // Hallow's End Candy
103 }
104 player->CastSpell(player, trickspell, true);
105 }
106 CloseGossipMenuFor(player);
107 return true;
108 }
109
110 CloseGossipMenuFor(player);
111
112 switch (action)
113 {
114 case GOSSIP_ACTION_TRADE: player->GetSession()->SendListInventory(me->GetGUID()); break;
115 case GOSSIP_ACTION_INN: player->SetBindPoint(me->GetGUID()); break;
116 }
117 return true;
118 }
119 };
120
121 CreatureAI* GetAI(Creature* creature) const override
122 {
123 return new npc_innkeeperAI(creature);
124 }
125};
126
128{
129 new npc_innkeeper();
130}
uint32_t uint32
Definition Define.h:133
bool IsHolidayActive(HolidayIds id)
Spells
Definition PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const &guid)
void AddGossipItemFor(Player *player, GossipOptionIcon icon, std::string const &text, uint32 sender, uint32 action)
void ClearGossipMenuFor(Player *player)
void InitGossipMenuFor(Player *player, uint32 menuId)
void CloseGossipMenuFor(Player *player)
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_INN
@ GOSSIP_ACTION_TRADE
@ GOSSIP_ACTION_INFO_DEF
@ HOLIDAY_HALLOWS_END
Creature *const me
Definition CreatureAI.h:82
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 GetGossipOptionAction(uint32 selection) const
Definition GossipDef.h:269
void TalkedToCreature(uint32 entry, ObjectGuid guid)
Definition Player.cpp:16306
WorldSession * GetSession() const
Definition Player.h:1719
void PrepareQuestMenu(ObjectGuid guid)
Definition Player.cpp:14270
void SetBindPoint(ObjectGuid guid) const
Definition Player.cpp:9152
uint32 GetGossipTextId(uint32 menuId, WorldObject *source)
Definition Player.cpp:14233
PlayerMenu * PlayerTalkClass
Definition Player.h:1969
bool IsInnkeeper() const
Definition Unit.h:1109
bool IsQuestGiver() const
Definition Unit.h:1103
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4535
bool IsVendor() const
Definition Unit.h:1101
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
void SendListInventory(ObjectGuid guid)
CreatureAI * GetAI(Creature *creature) const override
void AddSC_npc_innkeeper()
@ SPELL_TREAT
@ SPELL_TRICK_OR_TREATED
@ NPC_GOSSIP_MENU_EVENT
@ NPC_GOSSIP_MENU
bool OnGossipHello(Player *player) override
npc_innkeeperAI(Creature *creature)
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override