Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
example_gossip_codebox.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: Example_Gossip_Codebox
8
SD%Complete: 100
9
SDComment: Show a codebox in gossip option
10
SDCategory: Script Examples
11
EndScriptData */
12
13
#include "
ScriptMgr.h
"
14
#include "
ScriptedCreature.h
"
15
#include "
ScriptedGossip.h
"
16
#include "
Player.h
"
17
#include <cstring>
18
19
enum
Yells
20
{
21
// These texts must be added to the creature texts of the npc for which the script is assigned.
22
SAY_NOT_INTERESTED
= 0,
// "Normal select, guess you're not interested."
23
SAY_WRONG
= 1,
// "Wrong!"
24
SAY_CORRECT
= 2
// "You're right, you are allowed to see my inner secrets."
25
};
26
27
enum
Spells
28
{
29
SPELL_POLYMORPH
= 12826,
30
SPELL_MARK_OF_THE_WILD
= 26990
31
};
32
33
#define GOSSIP_ITEM_1 "A quiz: what's your name?"
34
#define GOSSIP_ITEM_2 "I'm not interested"
35
36
class
example_gossip_codebox
:
public
CreatureScript
37
{
38
public
:
39
example_gossip_codebox
() :
CreatureScript
(
"example_gossip_codebox"
) { }
40
41
bool
OnGossipHello
(
Player
* player,
Creature
* creature)
OVERRIDE
42
{
43
player->ADD_GOSSIP_ITEM_EXTENDED(0,
GOSSIP_ITEM_1
,
GOSSIP_SENDER_MAIN
,
GOSSIP_ACTION_INFO_DEF
+1,
""
, 0,
true
);
44
player->ADD_GOSSIP_ITEM(
GOSSIP_ICON_CHAT
,
GOSSIP_ITEM_2
,
GOSSIP_SENDER_MAIN
,
GOSSIP_ACTION_INFO_DEF
+2);
45
46
player->PlayerTalkClass->SendGossipMenu(907, creature->GetGUID());
47
48
return
true
;
49
}
50
51
bool
OnGossipSelect
(
Player
* player,
Creature
* creature,
uint32
/*sender*/
,
uint32
action)
OVERRIDE
52
{
53
player->PlayerTalkClass->ClearMenus();
54
if
(action ==
GOSSIP_ACTION_INFO_DEF
+2)
55
{
56
//Read comment in enum
57
creature->AI()->Talk(
SAY_NOT_INTERESTED
);
58
player->CLOSE_GOSSIP_MENU();
59
}
60
61
return
true
;
62
}
63
64
bool
OnGossipSelectCode
(
Player
* player,
Creature
* creature,
uint32
sender,
uint32
action,
char
const
* code)
OVERRIDE
65
{
66
player->PlayerTalkClass->ClearMenus();
67
if
(sender ==
GOSSIP_SENDER_MAIN
)
68
{
69
switch
(action)
70
{
71
case
GOSSIP_ACTION_INFO_DEF
+1:
72
if
(player->GetName() != code)
73
{
74
//Read comment in enum
75
creature->AI()->Talk(
SAY_WRONG
);
76
creature->CastSpell(player,
SPELL_POLYMORPH
,
true
);
77
}
78
else
79
{
80
//Read comment in enum
81
creature->AI()->Talk(
SAY_CORRECT
);
82
creature->CastSpell(player,
SPELL_MARK_OF_THE_WILD
,
true
);
83
}
84
player->CLOSE_GOSSIP_MENU();
85
86
return
true
;
87
}
88
}
89
90
return
false
;
91
}
92
};
93
94
void
AddSC_example_gossip_codebox
()
95
{
96
new
example_gossip_codebox
();
97
}
Spells
Spells
Definition
BattlegroundIC.h:645
uint32
std::uint32_t uint32
Definition
Define.h:77
OVERRIDE
#define OVERRIDE
Definition
Define.h:60
GOSSIP_ICON_CHAT
@ GOSSIP_ICON_CHAT
Definition
GossipDef.h:46
Player.h
ScriptMgr.h
ScriptedCreature.h
ScriptedGossip.h
GOSSIP_SENDER_MAIN
@ GOSSIP_SENDER_MAIN
Definition
ScriptedGossip.h:58
GOSSIP_ACTION_INFO_DEF
@ GOSSIP_ACTION_INFO_DEF
Definition
ScriptedGossip.h:56
SPELL_POLYMORPH
@ SPELL_POLYMORPH
Definition
boss_priestess_delrissa.cpp:734
Creature
Definition
Creature.h:427
CreatureScript::CreatureScript
CreatureScript(const char *name)
Definition
ScriptMgr.cpp:1436
Player
Definition
Player.h:1289
example_gossip_codebox
Definition
example_gossip_codebox.cpp:37
example_gossip_codebox::example_gossip_codebox
example_gossip_codebox()
Definition
example_gossip_codebox.cpp:39
example_gossip_codebox::OnGossipSelect
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
Definition
example_gossip_codebox.cpp:51
example_gossip_codebox::OnGossipHello
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
Definition
example_gossip_codebox.cpp:41
example_gossip_codebox::OnGossipSelectCode
bool OnGossipSelectCode(Player *player, Creature *creature, uint32 sender, uint32 action, char const *code) OVERRIDE
Definition
example_gossip_codebox.cpp:64
GOSSIP_ITEM_2
#define GOSSIP_ITEM_2
Definition
example_gossip_codebox.cpp:34
SAY_WRONG
@ SAY_WRONG
Definition
example_gossip_codebox.cpp:23
SAY_CORRECT
@ SAY_CORRECT
Definition
example_gossip_codebox.cpp:24
SAY_NOT_INTERESTED
@ SAY_NOT_INTERESTED
Definition
example_gossip_codebox.cpp:22
GOSSIP_ITEM_1
#define GOSSIP_ITEM_1
Definition
example_gossip_codebox.cpp:33
SPELL_MARK_OF_THE_WILD
@ SPELL_MARK_OF_THE_WILD
Definition
example_gossip_codebox.cpp:30
SPELL_POLYMORPH
@ SPELL_POLYMORPH
Definition
example_gossip_codebox.cpp:29
AddSC_example_gossip_codebox
void AddSC_example_gossip_codebox()
Definition
example_gossip_codebox.cpp:94
Yells
Definition
boss_illidan.cpp:256
src
server
scripts
Examples
example_gossip_codebox.cpp
Generated on
for Project SkyFire Core by
1.17.0