AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
npc_innkeeper Class Reference
Inheritance diagram for npc_innkeeper:
CreatureScript ScriptObject UpdatableScript< Creature >

Public Member Functions

 npc_innkeeper ()
 
bool OnGossipHello (Player *player, Creature *creature) override
 
bool OnGossipSelect (Player *player, Creature *creature, uint32, uint32 action) override
 
- Public Member Functions inherited from CreatureScript
bool IsDatabaseBound () const override
 
virtual bool OnGossipHello (Player *, Creature *)
 
virtual bool OnGossipSelect (Player *, Creature *, uint32, uint32)
 
virtual bool OnGossipSelectCode (Player *, Creature *, uint32, uint32, const char *)
 
virtual bool OnQuestAccept (Player *, Creature *, Quest const *)
 
virtual bool OnQuestSelect (Player *, Creature *, Quest const *)
 
virtual bool OnQuestComplete (Player *, Creature *, Quest const *)
 
virtual bool OnQuestReward (Player *, Creature *, Quest const *, uint32)
 
virtual uint32 GetDialogStatus (Player *, Creature *)
 
virtual CreatureAIGetAI (Creature *) const
 
virtual void OnFfaPvpStateUpdate (Creature *, bool)
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
- Public Member Functions inherited from UpdatableScript< Creature >
virtual void OnUpdate (Creature *, uint32)
 

Additional Inherited Members

- Protected Member Functions inherited from CreatureScript
 CreatureScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()=default
 
- Protected Member Functions inherited from UpdatableScript< Creature >
 UpdatableScript ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ npc_innkeeper()

npc_innkeeper::npc_innkeeper ( )
inline
34: CreatureScript("npc_innkeeper") { }
Definition: CreatureScript.h:25

Member Function Documentation

◆ OnGossipHello()

bool npc_innkeeper::OnGossipHello ( Player player,
Creature creature 
)
inlineoverridevirtual

Reimplemented from CreatureScript.

37 {
39 {
41 }
42
43 if (creature->IsQuestGiver())
44 {
45 player->PrepareQuestMenu(creature->GetGUID());
46 }
47
48 if (creature->IsVendor())
49 {
51 }
52
53 if (creature->IsInnkeeper())
54 {
56 }
57
58 player->TalkedToCreature(creature->GetEntry(), creature->GetGUID());
59 SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
60 return true;
61 }
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const guid)
Definition: ScriptedGossip.cpp:45
void AddGossipItemFor(Player *player, uint32 icon, std::string const &text, uint32 sender, uint32 action)
Definition: ScriptedGossip.cpp:28
@ GOSSIP_SENDER_MAIN
Definition: ScriptedGossip.h:70
@ GOSSIP_ACTION_INN
Definition: ScriptedGossip.h:62
@ GOSSIP_ACTION_TRADE
Definition: ScriptedGossip.h:56
@ GOSSIP_ACTION_INFO_DEF
Definition: ScriptedGossip.h:68
bool IsEventActive(uint16 event_id)
Definition: GameEventMgr.cpp:1924
constexpr auto SPELL_TRICKED_OR_TREATED
Definition: npc_innkeeper.cpp:26
constexpr auto HALLOWEEN_EVENTID
Definition: npc_innkeeper.cpp:27
constexpr auto GOSSIP_MENU
Definition: npc_innkeeper.cpp:28
constexpr auto GOSSIP_MENU_EVENT
Definition: npc_innkeeper.cpp:29
uint32 GetEntry() const
Definition: Object.h:109
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
void TalkedToCreature(uint32 entry, ObjectGuid guid)
Definition: PlayerQuest.cpp:2098
void PrepareQuestMenu(ObjectGuid guid)
Definition: PlayerQuest.cpp:39
uint32 GetGossipTextId(uint32 menuId, WorldObject *source)
Definition: PlayerGossip.cpp:403
bool IsInnkeeper() const
Definition: Unit.h:1673
bool IsQuestGiver() const
Definition: Unit.h:1667
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5636
bool IsVendor() const
Definition: Unit.h:1665

References AddGossipItemFor(), Object::GetEntry(), Player::GetGossipTextId(), Object::GetGUID(), GOSSIP_ACTION_INFO_DEF, GOSSIP_ACTION_INN, GOSSIP_ACTION_TRADE, GOSSIP_MENU, GOSSIP_MENU_EVENT, GOSSIP_SENDER_MAIN, HALLOWEEN_EVENTID, Unit::HasAura(), IsEventActive(), Unit::IsInnkeeper(), Unit::IsQuestGiver(), Unit::IsVendor(), Player::PrepareQuestMenu(), SendGossipMenuFor(), SPELL_TRICKED_OR_TREATED, and Player::TalkedToCreature().

◆ OnGossipSelect()

bool npc_innkeeper::OnGossipSelect ( Player player,
Creature creature,
uint32  ,
uint32  action 
)
inlineoverridevirtual

Reimplemented from CreatureScript.

64 {
65 ClearGossipMenuFor(player);
67 {
68 player->CastSpell(player, SPELL_TRICKED_OR_TREATED, true);
69 creature->CastSpell(player, roll_chance_i(50) ? SPELL_TRICK : SPELL_TREAT, true);
70
71 CloseGossipMenuFor(player);
72 return true;
73 }
74
75 CloseGossipMenuFor(player);
76
77 switch (action)
78 {
80 player->GetSession()->SendListInventory(creature->GetGUID());
81 break;
83 player->SetBindPoint(creature->GetGUID());
84 break;
85 }
86 return true;
87 }
bool roll_chance_i(int chance)
Definition: Random.h:59
void ClearGossipMenuFor(Player *player)
Definition: ScriptedGossip.cpp:22
void CloseGossipMenuFor(Player *player)
Definition: ScriptedGossip.cpp:56
constexpr auto SPELL_TREAT
Definition: npc_innkeeper.cpp:25
constexpr auto SPELL_TRICK
Definition: npc_innkeeper.cpp:24
WorldSession * GetSession() const
Definition: Player.h:1961
void SetBindPoint(ObjectGuid guid)
Definition: Player.cpp:8784
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1169
void SendListInventory(ObjectGuid guid, uint32 vendorEntry=0)
Definition: ItemHandler.cpp:1035

References Unit::CastSpell(), ClearGossipMenuFor(), CloseGossipMenuFor(), Object::GetGUID(), Player::GetSession(), GOSSIP_ACTION_INFO_DEF, GOSSIP_ACTION_INN, GOSSIP_ACTION_TRADE, HALLOWEEN_EVENTID, Unit::HasAura(), IsEventActive(), roll_chance_i(), WorldSession::SendListInventory(), Player::SetBindPoint(), SPELL_TREAT, SPELL_TRICK, and SPELL_TRICKED_OR_TREATED.