Project SkyFire Core
SkyFire 5.4.8 server core API documentation
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
7SDName: Example_Gossip_Codebox
8SD%Complete: 100
9SDComment: Show a codebox in gossip option
10SDCategory: Script Examples
11EndScriptData */
12
13#include "ScriptMgr.h"
14#include "ScriptedCreature.h"
15#include "ScriptedGossip.h"
16#include "Player.h"
17#include <cstring>
18
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
32
33#define GOSSIP_ITEM_1 "A quiz: what's your name?"
34#define GOSSIP_ITEM_2 "I'm not interested"
35
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);
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 {
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
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ GOSSIP_ICON_CHAT
Definition GossipDef.h:46
@ GOSSIP_SENDER_MAIN
@ 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
bool OnGossipSelectCode(Player *player, Creature *creature, uint32 sender, uint32 action, char const *code) OVERRIDE
#define GOSSIP_ITEM_2
#define GOSSIP_ITEM_1
@ SPELL_MARK_OF_THE_WILD
void AddSC_example_gossip_codebox()