Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
npc_innkeeper.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
/* ScriptData
7
SDName: Npc_Innkeeper
8
SDAuthor: WarHead
9
SD%Complete: 99%
10
SDComment: Complete
11
SDCategory: NPCs
12
EndScriptData */
13
14
#include "
ScriptMgr.h
"
15
#include "
ScriptedCreature.h
"
16
#include "
ScriptedGossip.h
"
17
#include "
GameEventMgr.h
"
18
#include "
Player.h
"
19
#include "
WorldSession.h
"
20
21
enum
Spells
22
{
23
SPELL_TRICK_OR_TREATED
= 24755,
24
SPELL_TREAT
= 24715
25
};
26
27
#define LOCALE_TRICK_OR_TREAT_0 "Trick or Treat!"
28
#define LOCALE_TRICK_OR_TREAT_2 "Des bonbons ou des blagues!"
29
#define LOCALE_TRICK_OR_TREAT_3 "Süßes oder Saures!"
30
#define LOCALE_TRICK_OR_TREAT_6 "¡Truco o trato!"
31
32
#define LOCALE_INNKEEPER_0 "Make this inn my home."
33
#define LOCALE_INNKEEPER_3 "Ich möchte dieses Gasthaus zu meinem Heimatort machen."
34
35
class
npc_innkeeper
:
public
CreatureScript
36
{
37
public
:
38
npc_innkeeper
() :
CreatureScript
(
"npc_innkeeper"
) { }
39
40
bool
OnGossipHello
(
Player
* player,
Creature
* creature)
OVERRIDE
41
{
42
if
(
IsHolidayActive
(
HolidayIds::HOLIDAY_HALLOWS_END
) && !player->HasAura(
SPELL_TRICK_OR_TREATED
))
43
{
44
const
char
* localizedEntry;
45
switch
(player->GetSession()->GetSessionDbcLocale())
46
{
47
case
LOCALE_frFR
: localizedEntry =
LOCALE_TRICK_OR_TREAT_2
;
break
;
48
case
LOCALE_deDE
: localizedEntry =
LOCALE_TRICK_OR_TREAT_3
;
break
;
49
case
LOCALE_esES
: localizedEntry =
LOCALE_TRICK_OR_TREAT_6
;
break
;
50
case
LOCALE_enUS
:
default
: localizedEntry =
LOCALE_TRICK_OR_TREAT_0
;
51
}
52
player->ADD_GOSSIP_ITEM(
GOSSIP_ICON_CHAT
, localizedEntry,
GOSSIP_SENDER_MAIN
,
GOSSIP_ACTION_INFO_DEF
+ 1);
53
}
54
55
if
(creature->IsQuestGiver())
56
player->PrepareQuestMenu(creature->GetGUID());
57
58
if
(creature->IsVendor())
59
player->ADD_GOSSIP_ITEM(
GOSSIP_ICON_VENDOR
,
GOSSIP_TEXT_BROWSE_GOODS
,
GOSSIP_SENDER_MAIN
,
GOSSIP_ACTION_TRADE
);
60
61
if
(creature->IsInnkeeper())
62
{
63
const
char
* localizedEntry;
64
switch
(player->GetSession()->GetSessionDbcLocale())
65
{
66
case
LOCALE_deDE
: localizedEntry =
LOCALE_INNKEEPER_3
;
break
;
67
case
LOCALE_enUS
:
default
: localizedEntry =
LOCALE_INNKEEPER_0
;
68
}
69
player->ADD_GOSSIP_ITEM(
GOSSIP_ICON_INTERACT_1
, localizedEntry,
GOSSIP_SENDER_MAIN
,
GOSSIP_ACTION_INN
);
70
}
71
72
player->TalkedToCreature(creature->GetEntry(), creature->GetGUID());
73
player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
74
return
true
;
75
}
76
77
bool
OnGossipSelect
(
Player
* player,
Creature
* creature,
uint32
/*sender*/
,
uint32
action)
OVERRIDE
78
{
79
player->PlayerTalkClass->ClearMenus();
80
if
(action ==
GOSSIP_ACTION_INFO_DEF
+ 1 &&
IsHolidayActive
(
HolidayIds::HOLIDAY_HALLOWS_END
) && !player->HasAura(
SPELL_TRICK_OR_TREATED
))
81
{
82
player->CastSpell(player,
SPELL_TRICK_OR_TREATED
,
true
);
83
84
if
(std::rand() % 1)
85
player->CastSpell(player,
SPELL_TREAT
,
true
);
86
else
87
{
88
uint32
trickspell = 0;
89
switch
(std::rand() % 13)
90
{
91
case
0: trickspell = 24753;
break
;
// cannot cast, random 30sec
92
case
1: trickspell = 24713;
break
;
// lepper gnome costume
93
case
2: trickspell = 24735;
break
;
// male ghost costume
94
case
3: trickspell = 24736;
break
;
// female ghostcostume
95
case
4: trickspell = 24710;
break
;
// male ninja costume
96
case
5: trickspell = 24711;
break
;
// female ninja costume
97
case
6: trickspell = 24708;
break
;
// male pirate costume
98
case
7: trickspell = 24709;
break
;
// female pirate costume
99
case
8: trickspell = 24723;
break
;
// skeleton costume
100
case
9: trickspell = 24753;
break
;
// Trick
101
case
10: trickspell = 24924;
break
;
// Hallow's End Candy
102
case
11: trickspell = 24925;
break
;
// Hallow's End Candy
103
case
12: trickspell = 24926;
break
;
// Hallow's End Candy
104
case
13: trickspell = 24927;
break
;
// Hallow's End Candy
105
}
106
player->CastSpell(player, trickspell,
true
);
107
}
108
player->CLOSE_GOSSIP_MENU();
109
return
true
;
110
}
111
112
player->CLOSE_GOSSIP_MENU();
113
114
switch
(action)
115
{
116
case
GOSSIP_ACTION_TRADE
: player->GetSession()->SendListInventory(creature->GetGUID());
break
;
117
case
GOSSIP_ACTION_INN
: player->SetBindPoint(creature->GetGUID());
break
;
118
}
119
return
true
;
120
}
121
};
122
123
void
AddSC_npc_innkeeper
()
124
{
125
new
npc_innkeeper
;
126
}
127
Spells
Spells
Definition
BattlegroundIC.h:645
LOCALE_deDE
@ LOCALE_deDE
Definition
Common.h:142
LOCALE_esES
@ LOCALE_esES
Definition
Common.h:145
LOCALE_frFR
@ LOCALE_frFR
Definition
Common.h:141
LOCALE_enUS
@ LOCALE_enUS
Definition
Common.h:139
uint32
std::uint32_t uint32
Definition
Define.h:77
OVERRIDE
#define OVERRIDE
Definition
Define.h:60
IsHolidayActive
bool IsHolidayActive(HolidayIds id)
Definition
GameEventMgr.cpp:1597
GameEventMgr.h
GOSSIP_ICON_CHAT
@ GOSSIP_ICON_CHAT
Definition
GossipDef.h:46
GOSSIP_ICON_INTERACT_1
@ GOSSIP_ICON_INTERACT_1
Definition
GossipDef.h:50
GOSSIP_ICON_VENDOR
@ GOSSIP_ICON_VENDOR
Definition
GossipDef.h:47
Player.h
ScriptMgr.h
ScriptedCreature.h
ScriptedGossip.h
GOSSIP_TEXT_BROWSE_GOODS
#define GOSSIP_TEXT_BROWSE_GOODS
Definition
ScriptedGossip.h:13
GOSSIP_SENDER_MAIN
@ GOSSIP_SENDER_MAIN
Definition
ScriptedGossip.h:58
GOSSIP_ACTION_INN
@ GOSSIP_ACTION_INN
Definition
ScriptedGossip.h:50
GOSSIP_ACTION_TRADE
@ GOSSIP_ACTION_TRADE
Definition
ScriptedGossip.h:44
GOSSIP_ACTION_INFO_DEF
@ GOSSIP_ACTION_INFO_DEF
Definition
ScriptedGossip.h:56
HolidayIds::HOLIDAY_HALLOWS_END
@ HOLIDAY_HALLOWS_END
Definition
SharedDefines.h:3239
WorldSession.h
Creature
Definition
Creature.h:427
CreatureScript::CreatureScript
CreatureScript(const char *name)
Definition
ScriptMgr.cpp:1436
Player
Definition
Player.h:1289
npc_innkeeper
Definition
npc_innkeeper.cpp:36
npc_innkeeper::npc_innkeeper
npc_innkeeper()
Definition
npc_innkeeper.cpp:38
npc_innkeeper::OnGossipSelect
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
Definition
npc_innkeeper.cpp:77
npc_innkeeper::OnGossipHello
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
Definition
npc_innkeeper.cpp:40
LOCALE_TRICK_OR_TREAT_6
#define LOCALE_TRICK_OR_TREAT_6
Definition
npc_innkeeper.cpp:30
AddSC_npc_innkeeper
void AddSC_npc_innkeeper()
Definition
npc_innkeeper.cpp:123
SPELL_TREAT
@ SPELL_TREAT
Definition
npc_innkeeper.cpp:24
SPELL_TRICK_OR_TREATED
@ SPELL_TRICK_OR_TREATED
Definition
npc_innkeeper.cpp:23
LOCALE_INNKEEPER_3
#define LOCALE_INNKEEPER_3
Definition
npc_innkeeper.cpp:33
LOCALE_INNKEEPER_0
#define LOCALE_INNKEEPER_0
Definition
npc_innkeeper.cpp:32
LOCALE_TRICK_OR_TREAT_3
#define LOCALE_TRICK_OR_TREAT_3
Definition
npc_innkeeper.cpp:29
LOCALE_TRICK_OR_TREAT_0
#define LOCALE_TRICK_OR_TREAT_0
Definition
npc_innkeeper.cpp:27
LOCALE_TRICK_OR_TREAT_2
#define LOCALE_TRICK_OR_TREAT_2
Definition
npc_innkeeper.cpp:28
SPELL_TREAT
@ SPELL_TREAT
Definition
spell_holiday.cpp:184
src
server
scripts
World
npc_innkeeper.cpp
Generated on
for Project SkyFire Core by
1.17.0