Project SkyFire Core
SkyFire 5.4.8 server core API documentation
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
7SDName: Npc_Innkeeper
8SDAuthor: WarHead
9SD%Complete: 99%
10SDComment: Complete
11SDCategory: NPCs
12EndScriptData */
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
22{
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
36{
37public:
38 npc_innkeeper() : CreatureScript("npc_innkeeper") { }
39
40 bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
41 {
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())
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();
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
124{
125 new npc_innkeeper;
126}
127
@ LOCALE_deDE
Definition Common.h:142
@ LOCALE_esES
Definition Common.h:145
@ LOCALE_frFR
Definition Common.h:141
@ LOCALE_enUS
Definition Common.h:139
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
bool IsHolidayActive(HolidayIds id)
@ GOSSIP_ICON_CHAT
Definition GossipDef.h:46
@ GOSSIP_ICON_INTERACT_1
Definition GossipDef.h:50
@ GOSSIP_ICON_VENDOR
Definition GossipDef.h:47
#define GOSSIP_TEXT_BROWSE_GOODS
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_INN
@ GOSSIP_ACTION_TRADE
@ GOSSIP_ACTION_INFO_DEF
CreatureScript(const char *name)
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
#define LOCALE_TRICK_OR_TREAT_6
void AddSC_npc_innkeeper()
@ SPELL_TREAT
@ SPELL_TRICK_OR_TREATED
#define LOCALE_INNKEEPER_3
#define LOCALE_INNKEEPER_0
#define LOCALE_TRICK_OR_TREAT_3
#define LOCALE_TRICK_OR_TREAT_0
#define LOCALE_TRICK_OR_TREAT_2
@ SPELL_TREAT