aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Custom
diff options
context:
space:
mode:
authorazazel <none@none>2010-08-08 22:54:58 +0600
committerazazel <none@none>2010-08-08 22:54:58 +0600
commit590199d8e17405a0717eaf2e2d39f0d671b6f844 (patch)
tree36755767c89c4639c7cb0e2f31d8a99f53bb8cf5 /src/server/scripts/Custom
parent8a69e50d6aff8ea75100a1fb660deecf03b3ea07 (diff)
* Rename InstanceData to InstanceScript
* Rename *mgr to their new names in scripts project * Mass convert all the scripts (NEEDS THOROUGH TESTING, because it was done automatically) Please, report bugs on issue tracker. --HG-- branch : trunk rename : src/server/game/Instances/InstanceData.cpp => src/server/game/Instances/InstanceScript.cpp rename : src/server/game/Instances/InstanceData.h => src/server/game/Instances/InstanceScript.h
Diffstat (limited to 'src/server/scripts/Custom')
-rw-r--r--src/server/scripts/Custom/custom_example.cpp80
-rw-r--r--src/server/scripts/Custom/custom_gossip_codebox.cpp84
-rw-r--r--src/server/scripts/Custom/test.cpp93
3 files changed, 129 insertions, 128 deletions
diff --git a/src/server/scripts/Custom/custom_example.cpp b/src/server/scripts/Custom/custom_example.cpp
index d922dfed0aa..61b1f4e9229 100644
--- a/src/server/scripts/Custom/custom_example.cpp
+++ b/src/server/scripts/Custom/custom_example.cpp
@@ -211,11 +211,46 @@ struct TRINITY_DLL_DECL custom_exampleAI : public ScriptedAI
};
//This is the GetAI method used by all scripts that involve AI
-//It is called every time a new Creature using this script is created
-CreatureAI* GetAI_custom_example(Creature* pCreature)
+//It is called every time a new Creature using this script is created class custom_example : public CreatureScript
{
- return new custom_exampleAI (pCreature);
-}
+public:
+ custom_example() : CreatureScript("custom_example") { }
+
+ bool ReceiveEmote(Player* pPlayer, Creature* pCreature, uint32 emote)
+ {
+ pCreature->HandleEmoteCommand(emote);
+
+ if (emote == TEXTEMOTE_DANCE)
+ ((custom_exampleAI*)_Creature->AI())->DoSay(SAY_DANCE,LANG_UNIVERSAL,NULL);
+
+ if (emote == TEXTEMOTE_SALUTE)
+ ((custom_exampleAI*)_Creature->AI())->DoSay(SAY_SALUTE,LANG_UNIVERSAL,NULL);
+
+ return true;
+ }
+
+ bool GossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
+ {
+ if (uiSender == GOSSIP_SENDER_MAIN)
+ SendDefaultMenu(pPlayer, pCreature, uiAction);
+
+ return true;
+ }
+
+ bool GossipHello(Player* pPlayer, Creature* pCreature)
+ {
+ pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+ pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());
+
+ return true;
+ }
+
+ CreatureAI* GetAI(Creature* pCreature)
+ {
+ return new custom_exampleAI (pCreature);
+ }
+
+};
//This function is called when the player clicks an option on the gossip menu
void SendDefaultMenu_custom_example(Player* pPlayer, Creature* pCreature, uint32 uiAction)
@@ -230,36 +265,10 @@ void SendDefaultMenu_custom_example(Player* pPlayer, Creature* pCreature, uint32
}
//This function is called when the player clicks an option on the gossip menu
-bool GossipSelect_custom_example(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
-{
- if (uiSender == GOSSIP_SENDER_MAIN)
- SendDefaultMenu_custom_example(pPlayer, pCreature, uiAction);
-
- return true;
-}
//This function is called when the player opens the gossip menu
-bool GossipHello_custom_example(Player* pPlayer, Creature* pCreature)
-{
- pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
- pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());
-
- return true;
-}
//Our Recive emote function
-bool ReceiveEmote_custom_example(Player* pPlayer, Creature* pCreature, uint32 emote)
-{
- pCreature->HandleEmoteCommand(emote);
-
- if (emote == TEXTEMOTE_DANCE)
- ((custom_exampleAI*)_Creature->AI())->DoSay(SAY_DANCE,LANG_UNIVERSAL,NULL);
-
- if (emote == TEXTEMOTE_SALUTE)
- ((custom_exampleAI*)_Creature->AI())->DoSay(SAY_SALUTE,LANG_UNIVERSAL,NULL);
-
- return true;
-}
//This is the actual function called only once durring InitScripts()
//It must define all handled functions that are to be run in this script
@@ -267,14 +276,5 @@ bool ReceiveEmote_custom_example(Player* pPlayer, Creature* pCreature, uint32 em
//newscript->ReciveEmote = My_Emote_Function;
void AddSC_custom_example()
{
- Script *newscript;
-
- newscript = new Script;
- newscript->Name="custom_example";
- newscript->GetAI = &GetAI_custom_example;
- newscript->pGossipHello = &GossipHello_custom_example;
- newscript->pGossipSelect = &GossipSelect_custom_example;
- newscript->pReceiveEmote = &ReceiveEmote_custom_example;
- newscript->RegisterSelf();
+ new custom_example();
}
-
diff --git a/src/server/scripts/Custom/custom_gossip_codebox.cpp b/src/server/scripts/Custom/custom_gossip_codebox.cpp
index e7dd58f0a33..6b1dd91fabb 100644
--- a/src/server/scripts/Custom/custom_gossip_codebox.cpp
+++ b/src/server/scripts/Custom/custom_gossip_codebox.cpp
@@ -33,59 +33,59 @@ EndScriptData */
#define SAY_WRONG "Wrong!"
#define SAY_RIGHT "You're right, you are allowed to see my inner secrets."
-//This function is called when the player opens the gossip menubool
-bool GossipHello_custom_gossip_codebox(Player* pPlayer, Creature* pCreature)
+//This function is called when the player opens the gossip menubool class custom_gossip_codebox : public GameObjectScript
{
- pPlayer->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);
- pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
+public:
+ custom_gossip_codebox() : GameObjectScript("custom_gossip_codebox") { }
- pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());
- return true;
-}
-
-//This function is called when the player clicks an option on the gossip menubool
-bool GossipSelect_custom_gossip_codebox(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
-{
- if (uiAction == GOSSIP_ACTION_INFO_DEF+2)
+ bool GossipSelectWithCode(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction, const char* sCode)
{
- pCreature->Say(SAY_NOT_INTERESTED, LANG_UNIVERSAL, 0);
- pPlayer->CLOSE_GOSSIP_MENU();
+ if (uiSender == GOSSIP_SENDER_MAIN)
+ {
+ if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
+ {
+ if (std::strcmp(sCode, pPlayer->GetName())!=0)
+ {
+ pCreature->Say(SAY_WRONG, LANG_UNIVERSAL, 0);
+ pCreature->CastSpell(pPlayer, 12826, true);
+ }
+ else
+ {
+ pCreature->Say(SAY_RIGHT, LANG_UNIVERSAL, 0);
+ pCreature->CastSpell(pPlayer, 26990, true);
+ }
+ pPlayer->CLOSE_GOSSIP_MENU();
+ return true;
+ }
+ }
+ return false;
}
- return true;
-}
-bool GossipSelectWithCode_custom_gossip_codebox(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction, const char* sCode)
-{
- if (uiSender == GOSSIP_SENDER_MAIN)
+ bool GossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
- if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
+ if (uiAction == GOSSIP_ACTION_INFO_DEF+2)
{
- if (std::strcmp(sCode, pPlayer->GetName())!=0)
- {
- pCreature->Say(SAY_WRONG, LANG_UNIVERSAL, 0);
- pCreature->CastSpell(pPlayer, 12826, true);
- }
- else
- {
- pCreature->Say(SAY_RIGHT, LANG_UNIVERSAL, 0);
- pCreature->CastSpell(pPlayer, 26990, true);
- }
+ pCreature->Say(SAY_NOT_INTERESTED, LANG_UNIVERSAL, 0);
pPlayer->CLOSE_GOSSIP_MENU();
- return true;
}
+ return true;
+ }
+
+ bool GossipHello(Player* pPlayer, Creature* pCreature)
+ {
+ pPlayer->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);
+ pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
+
+ pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());
+ return true;
}
- return false;
-}
+
+};
+
+//This function is called when the player clicks an option on the gossip menubool
+
void AddSC_custom_gossip_codebox()
{
- Script *newscript;
-
- newscript = new Script;
- newscript->Name="custom_gossip_codebox";
- newscript->pGossipHello = &GossipHello_custom_gossip_codebox;
- newscript->pGossipSelect = &GossipSelect_custom_gossip_codebox;
- newscript->pGossipSelectWithCode = &GossipSelectWithCode_custom_gossip_codebox;
- newscript->RegisterSelf();
+ new custom_gossip_codebox();
}
-
diff --git a/src/server/scripts/Custom/test.cpp b/src/server/scripts/Custom/test.cpp
index 0e841d450ba..024b06fff0e 100644
--- a/src/server/scripts/Custom/test.cpp
+++ b/src/server/scripts/Custom/test.cpp
@@ -152,69 +152,70 @@ struct TRINITY_DLL_DECL npc_testAI : public npc_escortAI
}
}
};
-
-CreatureAI* GetAI_test(Creature* pCreature)
+ class test : public CreatureScript
{
- npc_testAI* testAI = new npc_testAI(pCreature);
-
- testAI->AddWaypoint(0, 1231, -4419, 23);
- testAI->AddWaypoint(1, 1198, -4440, 23, 0);
- testAI->AddWaypoint(2, 1208, -4392, 23);
- testAI->AddWaypoint(3, 1231, -4419, 23, 5000);
- testAI->AddWaypoint(4, 1208, -4392, 23, 5000);
+public:
+ test() : CreatureScript("test") { }
- return (CreatureAI*)testAI;
-}
+ bool GossipSelect_npc(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
+ {
+ if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
+ {
+ pPlayer->CLOSE_GOSSIP_MENU();
+ ((npc_escortAI*)(pCreature->AI()))->Start(true, true, pPlayer->GetGUID());
-bool GossipHello_npc_test(Player* pPlayer, Creature* pCreature)
-{
- pPlayer->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
- pCreature->prepareGossipMenu(pPlayer,0);
+ return true; // prevent Trinity core handling
+ }
- pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
- pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
+ if (uiAction == GOSSIP_ACTION_INFO_DEF+2)
+ {
+ pPlayer->CLOSE_GOSSIP_MENU();
+ ((npc_escortAI*)(pCreature->AI()))->Start(false, false, pPlayer->GetGUID());
- pCreature->sendPreparedGossip(pPlayer);
- return true;
-}
+ return true; // prevent Trinity core handling
+ }
-bool GossipSelect_npc_test(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
-{
- if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
- {
- pPlayer->CLOSE_GOSSIP_MENU();
- ((npc_escortAI*)(pCreature->AI()))->Start(true, true, pPlayer->GetGUID());
+ if (uiAction == GOSSIP_ACTION_INFO_DEF+3)
+ {
+ pPlayer->CLOSE_GOSSIP_MENU();
+ ((npc_escortAI*)(pCreature->AI()))->Start(false, false, pPlayer->GetGUID());
- return true; // prevent Trinity core handling
+ return true; // prevent Trinity core handling
+ }
+ return false;
}
- if (uiAction == GOSSIP_ACTION_INFO_DEF+2)
+ bool GossipHello_npc(Player* pPlayer, Creature* pCreature)
{
- pPlayer->CLOSE_GOSSIP_MENU();
- ((npc_escortAI*)(pCreature->AI()))->Start(false, false, pPlayer->GetGUID());
+ pPlayer->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
+ pCreature->prepareGossipMenu(pPlayer,0);
- return true; // prevent Trinity core handling
+ pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+ pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
+ pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
+
+ pCreature->sendPreparedGossip(pPlayer);
+ return true;
}
- if (uiAction == GOSSIP_ACTION_INFO_DEF+3)
+ CreatureAI* GetAI(Creature* pCreature)
{
- pPlayer->CLOSE_GOSSIP_MENU();
- ((npc_escortAI*)(pCreature->AI()))->Start(false, false, pPlayer->GetGUID());
+ npcAI* testAI = new npcAI(pCreature);
+
+ testAI->AddWaypoint(0, 1231, -4419, 23);
+ testAI->AddWaypoint(1, 1198, -4440, 23, 0);
+ testAI->AddWaypoint(2, 1208, -4392, 23);
+ testAI->AddWaypoint(3, 1231, -4419, 23, 5000);
+ testAI->AddWaypoint(4, 1208, -4392, 23, 5000);
- return true; // prevent Trinity core handling
+ return (CreatureAI*)testAI;
}
- return false;
-}
+
+};
+
+
void AddSC_test()
{
- Script *newscript;
- newscript = new Script;
- newscript->Name="test";
- newscript->GetAI = &GetAI_test;
- newscript->pGossipHello = &GossipHello_npc_test;
- newscript->pGossipSelect = &GossipSelect_npc_test;
- newscript->RegisterSelf();
+ new test();
}
-