Files
TCPlayerbotCore/src/scripts/examples/example_gossip_codebox.cpp
T

100 lines
3.2 KiB
C++
Raw Normal View History

2009-02-17 18:08:26 +01:00
/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2009-02-17 18:08:26 +01:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2009-02-17 18:08:26 +01:00
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
2009-10-17 15:51:44 -07:00
/* ScriptData
2009-02-17 18:08:26 +01:00
SDName: Example_Gossip_Codebox
SD%Complete: 100
SDComment: Show a codebox in gossip option
SDCategory: Script Examples
EndScriptData */
2009-10-17 15:51:44 -07:00
2010-01-19 11:36:05 +01:00
#include "ScriptedPch.h"
#include <cstring>
2009-10-17 15:51:44 -07:00
2009-10-17 07:42:48 -07:00
enum eEnums
2009-08-14 17:14:08 +02:00
{
SPELL_POLYMORPH = 12826,
SPELL_MARK_OF_THE_WILD = 26990,
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
SAY_NOT_INTERESTED = -1999922,
SAY_WRONG = -1999923,
SAY_CORRECT = -1999924
};
2009-10-17 15:51:44 -07:00
2009-02-17 18:08:26 +01:00
#define GOSSIP_ITEM_1 "A quiz: what's your name?"
#define GOSSIP_ITEM_2 "I'm not interested"
2009-10-17 15:51:44 -07:00
//This function is called when the player opens the gossip menubool
2009-08-14 00:39:07 +02:00
bool GossipHello_example_gossip_codebox(Player* pPlayer, Creature* pCreature)
{
2009-08-14 00:02:13 +02:00
pPlayer->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
2009-10-17 15:51:44 -07:00
2009-08-14 00:39:07 +02:00
pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());
2009-10-17 15:51:44 -07:00
return true;
}
2009-10-17 15:51:44 -07:00
//This function is called when the player clicks an option on the gossip menubool
2009-08-14 17:14:08 +02:00
bool GossipSelect_example_gossip_codebox(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
2009-08-14 17:14:08 +02:00
if (uiAction == GOSSIP_ACTION_INFO_DEF+2)
{
2009-08-14 00:39:07 +02:00
DoScriptText(SAY_NOT_INTERESTED, pCreature);
2009-08-14 00:02:13 +02:00
pPlayer->CLOSE_GOSSIP_MENU();
}
2009-10-17 15:51:44 -07:00
return true;
}
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
bool GossipSelectWithCode_example_gossip_codebox(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction, const char* sCode)
{
2009-08-14 17:14:08 +02:00
if (uiSender == GOSSIP_SENDER_MAIN)
{
2009-08-14 17:14:08 +02:00
switch (uiAction)
{
2009-08-14 17:14:08 +02:00
case GOSSIP_ACTION_INFO_DEF+1:
2009-08-14 00:02:13 +02:00
if (std::strcmp(sCode, pPlayer->GetName())!=0)
{
2009-08-14 00:39:07 +02:00
DoScriptText(SAY_WRONG, pCreature);
2009-08-14 17:14:08 +02:00
pCreature->CastSpell(pPlayer, SPELL_POLYMORPH, true);
}
else
{
2009-08-14 00:39:07 +02:00
DoScriptText(SAY_CORRECT, pCreature);
2009-08-14 17:14:08 +02:00
pCreature->CastSpell(pPlayer, SPELL_MARK_OF_THE_WILD, true);
}
2009-08-14 00:02:13 +02:00
pPlayer->CLOSE_GOSSIP_MENU();
2009-10-17 15:51:44 -07:00
return true;
}
}
2009-10-17 15:51:44 -07:00
return false;
}
2009-10-17 15:51:44 -07:00
2009-02-17 18:08:26 +01:00
void AddSC_example_gossip_codebox()
{
2009-08-14 17:14:08 +02:00
Script* newscript;
2009-10-17 15:51:44 -07:00
newscript = new Script;
2009-02-17 18:08:26 +01:00
newscript->Name = "example_gossip_codebox";
newscript->pGossipHello = &GossipHello_example_gossip_codebox;
newscript->pGossipSelect = &GossipSelect_example_gossip_codebox;
newscript->pGossipSelectWithCode = &GossipSelectWithCode_example_gossip_codebox;
newscript->RegisterSelf();
}