Scripts/Examples: Remove outdated example scripts

Remove outdated misleading example scripts not following anymore current TC codestyle and standards. Please refer to the wiki or forum for up to date examples and documentation.
This commit is contained in:
jackpoz
2014-09-21 22:42:50 +02:00
parent 6e27841382
commit 84efd8b92b
10 changed files with 0 additions and 1332 deletions

View File

@@ -18,13 +18,6 @@
#include "ScriptLoader.h"
#include "World.h"
//examples
void AddSC_example_creature();
void AddSC_example_escort();
void AddSC_example_gossip_codebox();
void AddSC_example_misc();
void AddSC_example_commandscript();
// spells
void AddSC_deathknight_spell_scripts();
void AddSC_druid_spell_scripts();
@@ -39,7 +32,6 @@ void AddSC_warlock_spell_scripts();
void AddSC_warrior_spell_scripts();
void AddSC_quest_spell_scripts();
void AddSC_item_spell_scripts();
void AddSC_example_spell_scripts();
void AddSC_holiday_spell_scripts();
void AddSC_SmartScripts();
@@ -700,7 +692,6 @@ void AddSC_action_ip_logger();
void AddScripts()
{
AddExampleScripts();
AddSpellScripts();
AddSC_SmartScripts();
AddCommandScripts();
@@ -718,15 +709,6 @@ void AddScripts()
#endif
}
void AddExampleScripts()
{
AddSC_example_creature();
AddSC_example_escort();
AddSC_example_gossip_codebox();
AddSC_example_misc();
AddSC_example_commandscript();
}
void AddSpellScripts()
{
AddSC_deathknight_spell_scripts();
@@ -742,7 +724,6 @@ void AddSpellScripts()
AddSC_warrior_spell_scripts();
AddSC_quest_spell_scripts();
AddSC_item_spell_scripts();
AddSC_example_spell_scripts();
AddSC_holiday_spell_scripts();
}

View File

@@ -19,7 +19,6 @@
#define SC_SCRIPTLOADER_H
void AddScripts();
void AddExampleScripts();
void AddSpellScripts();
void AddCommandScripts();
void AddWorldScripts();

View File

@@ -20,8 +20,6 @@ include(Spells/CMakeLists.txt)
include(Commands/CMakeLists.txt)
include(Examples/CMakeLists.txt)
set(scripts_STAT_SRCS
${scripts_STAT_SRCS}
../game/AI/ScriptedAI/ScriptedEscortAI.cpp

View File

@@ -1,21 +0,0 @@
# Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
set(scripts_STAT_SRCS
${scripts_STAT_SRCS}
Examples/example_misc.cpp
Examples/example_gossip_codebox.cpp
Examples/example_escort.cpp
Examples/example_creature.cpp
Examples/example_spell.cpp
Examples/example_commandscript.cpp
)
message(" -> Prepared: Examples")

View File

@@ -1,60 +0,0 @@
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
* 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 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, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
Name: Example_Commandscript
%Complete: 100
Comment: Short custom scripting example
Category: Script Examples
EndScriptData */
#include "ScriptMgr.h"
#include "Chat.h"
// **** This script is designed as an example for others to build on ****
// **** Please modify whatever you'd like to as this script is only for developement ****
// **** Script Info* ***
// This script's primary purpose is to show just how much you can really do with commandscripts
class example_commandscript : public CommandScript
{
public:
example_commandscript() : CommandScript("example_commandscript") { }
static bool HandleHelloWorldCommand(ChatHandler* handler, const char* /*args*/)
{
handler->PSendSysMessage("Hello World");
return true;
}
ChatCommand* GetCommands() const override
{
static ChatCommand HelloWorldCommandTable[] =
{
{ "hello", SEC_PLAYER, true, &HandleHelloWorldCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
return HelloWorldCommandTable;
}
};
void AddSC_example_commandscript()
{
new example_commandscript();
}

View File

@@ -1,298 +0,0 @@
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
* 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 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, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
SDName: Example_Creature
SD%Complete: 100
SDComment: Short custom scripting example
SDCategory: Script Examples
EndScriptData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "Player.h"
// **** This script is designed as an example for others to build on ****
// **** Please modify whatever you'd like to as this script is only for developement ****
// **** Script Info* ***
// This script is written in a way that it can be used for both friendly and hostile monsters
// Its primary purpose is to show just how much you can really do with scripts
// I recommend trying it out on both an agressive NPC and on friendly npc
// **** Quick Info* ***
// Functions with Handled Function marked above them are functions that are called automatically by the core
// Functions that are marked Custom Function are functions I've created to simplify code
enum Yells
{
//List of text id's. The text is stored in database, also in a localized version
//(if translation not exist for the textId, default english text will be used)
//Not required to define in this way, but simplify if changes are needed.
//These texts must be added to the creature texts of the npc for which the script is assigned.
SAY_AGGRO = 0, // "Let the games begin."
SAY_RANDOM = 1, // "I see endless suffering. I see torment. I see rage. I see everything.",
// "Muahahahaha",
// "These mortal infedels my lord, they have invaded your sanctum and seek to steal your secrets.",
// "You are already dead.",
// "Where to go? What to do? So many choices that all end in pain, end in death."
SAY_BERSERK = 2, // "$N, I sentance you to death!"
SAY_PHASE = 3, // "The suffering has just begun!"
SAY_DANCE = 4, // "I always thought I was a good dancer."
SAY_SALUTE = 5, // "Move out Soldier!"
SAY_EVADE = 6 // "Help $N! I'm under attack!"
};
enum Spells
{
// List of spells.
// Not required to define them in this way, but will make it easier to maintain in case spellId change
SPELL_BUFF = 25661,
SPELL_ONE = 12555,
SPELL_ONE_ALT = 24099,
SPELL_TWO = 10017,
SPELL_THREE = 26027,
SPELL_FRENZY = 23537,
SPELL_BERSERK = 32965,
};
enum Factions
{
// any other constants
FACTION_WORGEN = 24
};
//List of gossip item texts. Items will appear in the gossip window.
#define GOSSIP_ITEM "I'm looking for a fight"
class example_creature : public CreatureScript
{
public:
example_creature()
: CreatureScript("example_creature")
{
}
struct example_creatureAI : public ScriptedAI
{
// *** HANDLED FUNCTION ***
//This is the constructor, called only once when the Creature is first created
example_creatureAI(Creature* creature) : ScriptedAI(creature) { }
// *** CUSTOM VARIABLES ****
//These variables are for use only by this individual script.
//Nothing else will ever call them but us.
uint32 m_uiSayTimer; // Timer for random chat
uint32 m_uiRebuffTimer; // Timer for rebuffing
uint32 m_uiSpell1Timer; // Timer for spell 1 when in combat
uint32 m_uiSpell2Timer; // Timer for spell 1 when in combat
uint32 m_uiSpell3Timer; // Timer for spell 1 when in combat
uint32 m_uiBeserkTimer; // Timer until we go into Beserk (enraged) mode
uint32 m_uiPhase; // The current battle phase we are in
uint32 m_uiPhaseTimer; // Timer until phase transition
// *** HANDLED FUNCTION ***
//This is called after spawn and whenever the core decides we need to evade
void Reset() override
{
m_uiPhase = 1; // Start in phase 1
m_uiPhaseTimer = 60000; // 60 seconds
m_uiSpell1Timer = 5000; // 5 seconds
m_uiSpell2Timer = urand(10000, 20000); // between 10 and 20 seconds
m_uiSpell3Timer = 19000; // 19 seconds
m_uiBeserkTimer = 120000; // 2 minutes
me->RestoreFaction();
}
// *** HANDLED FUNCTION ***
// Enter Combat called once per combat
void EnterCombat(Unit* who) override
{
//Say some stuff
Talk(SAY_AGGRO, who);
}
// *** HANDLED FUNCTION ***
// Attack Start is called when victim change (including at start of combat)
// By default, attack who and start movement toward the victim.
//void AttackStart(Unit* who) override
//{
// ScriptedAI::AttackStart(who);
//}
// *** HANDLED FUNCTION ***
// Called when going out of combat. Reset is called just after.
void EnterEvadeMode() override
{
Talk(SAY_EVADE);
}
// *** HANDLED FUNCTION ***
//Our Receive emote function
void ReceiveEmote(Player* /*player*/, uint32 uiTextEmote) override
{
me->HandleEmoteCommand(uiTextEmote);
switch (uiTextEmote)
{
case TEXT_EMOTE_DANCE:
Talk(SAY_DANCE);
break;
case TEXT_EMOTE_SALUTE:
Talk(SAY_SALUTE);
break;
}
}
// *** HANDLED FUNCTION ***
//Update AI is called Every single map update (roughly once every 50ms if a player is within the grid)
void UpdateAI(uint32 uiDiff) override
{
//Out of combat timers
if (!me->GetVictim())
{
//Random Say timer
if (m_uiSayTimer <= uiDiff)
{
//Random switch between 5 outcomes
Talk(SAY_RANDOM);
m_uiSayTimer = 45000; //Say something agian in 45 seconds
}
else
m_uiSayTimer -= uiDiff;
//Rebuff timer
if (m_uiRebuffTimer <= uiDiff)
{
DoCast(me, SPELL_BUFF);
m_uiRebuffTimer = 900000; //Rebuff agian in 15 minutes
}
else
m_uiRebuffTimer -= uiDiff;
}
//Return since we have no target
if (!UpdateVictim())
return;
//Spell 1 timer
if (m_uiSpell1Timer <= uiDiff)
{
//Cast spell one on our current target.
if (rand32() % 50 > 10)
DoCastVictim(SPELL_ONE_ALT);
else if (me->IsWithinDist(me->GetVictim(), 25.0f))
DoCastVictim(SPELL_ONE);
m_uiSpell1Timer = 5000;
}
else
m_uiSpell1Timer -= uiDiff;
//Spell 2 timer
if (m_uiSpell2Timer <= uiDiff)
{
//Cast spell two on our current target.
DoCastVictim(SPELL_TWO);
m_uiSpell2Timer = 37000;
}
else
m_uiSpell2Timer -= uiDiff;
//Beserk timer
if (m_uiPhase > 1)
{
//Spell 3 timer
if (m_uiSpell3Timer <= uiDiff)
{
//Cast spell one on our current target.
DoCastVictim(SPELL_THREE);
m_uiSpell3Timer = 19000;
}
else
m_uiSpell3Timer -= uiDiff;
if (m_uiBeserkTimer <= uiDiff)
{
//Say our line then cast uber death spell
Talk(SAY_BERSERK, me->GetVictim());
DoCastVictim(SPELL_BERSERK);
//Cast our beserk spell agian in 12 seconds if we didn't kill everyone
m_uiBeserkTimer = 12000;
}
else
m_uiBeserkTimer -= uiDiff;
}
else if (m_uiPhase == 1) //Phase timer
{
if (m_uiPhaseTimer <= uiDiff)
{
//Go to next phase
++m_uiPhase;
Talk(SAY_PHASE);
DoCast(me, SPELL_FRENZY);
}
else
m_uiPhaseTimer -= uiDiff;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* creature) const override
{
return new example_creatureAI(creature);
}
bool OnGossipHello(Player* player, Creature* creature) override
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
player->SEND_GOSSIP_MENU(907, creature->GetGUID());
return true;
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
{
player->PlayerTalkClass->ClearMenus();
if (action == GOSSIP_ACTION_INFO_DEF+1)
{
player->CLOSE_GOSSIP_MENU();
//Set our faction to hostile towards all
creature->setFaction(FACTION_WORGEN);
creature->AI()->AttackStart(player);
}
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
void AddSC_example_creature()
{
new example_creature();
}

View File

@@ -1,244 +0,0 @@
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
* 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 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, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
SDName: Example_Escort
SD%Complete: 100
SDComment: Script used for testing escortAI
SDCategory: Script Examples
EndScriptData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "ScriptedEscortAI.h"
#include "Player.h"
#include "CreatureTextMgr.h"
enum Yells
{
SAY_AGGRO1 = 0,
SAY_AGGRO2 = 1,
SAY_WP_1 = 2,
SAY_WP_2 = 3,
SAY_WP_3 = 4,
SAY_WP_4 = 5,
SAY_DEATH_1 = 6,
SAY_DEATH_2 = 7,
SAY_DEATH_3 = 8,
SAY_SPELL = 9,
SAY_RAND_1 = 10,
SAY_RAND_2 = 11
};
enum Spells
{
SPELL_DEATH_COIL = 33130,
SPELL_ELIXIR_OF_FORTITUDE = 3593,
SPELL_BLUE_FIREWORK = 11540
};
enum Creatures
{
NPC_FELBOAR = 21878
};
#define GOSSIP_ITEM_1 "Click to Test Escort(Attack, Run)"
#define GOSSIP_ITEM_2 "Click to Test Escort(NoAttack, Walk)"
#define GOSSIP_ITEM_3 "Click to Test Escort(NoAttack, Run)"
class example_escort : public CreatureScript
{
public:
example_escort()
: CreatureScript("example_escort")
{
}
struct example_escortAI : public npc_escortAI
{
// CreatureAI functions
example_escortAI(Creature* creature) : npc_escortAI(creature) { }
uint32 m_uiDeathCoilTimer;
uint32 m_uiChatTimer;
void JustSummoned(Creature* summoned) override
{
summoned->AI()->AttackStart(me);
}
// Pure Virtual Functions (Have to be implemented)
void WaypointReached(uint32 waypointId) override
{
switch (waypointId)
{
case 1:
Talk(SAY_WP_1);
break;
case 3:
Talk(SAY_WP_2);
me->SummonCreature(NPC_FELBOAR, me->GetPositionX()+5.0f, me->GetPositionY()+7.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000);
break;
case 4:
if (Player* player = GetPlayerForEscort())
{
//pTmpPlayer is the target of the text
Talk(SAY_WP_3, player);
//pTmpPlayer is the source of the text
sCreatureTextMgr->SendChat(me, SAY_WP_4, NULL, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, player);
}
break;
}
}
void EnterCombat(Unit* /*who*/) override
{
if (HasEscortState(STATE_ESCORT_ESCORTING))
{
if (Player* player = GetPlayerForEscort())
Talk(SAY_AGGRO1, player);
}
else
Talk(SAY_AGGRO2);
}
void Reset() override
{
m_uiDeathCoilTimer = 4000;
m_uiChatTimer = 4000;
}
void JustDied(Unit* killer) override
{
if (HasEscortState(STATE_ESCORT_ESCORTING))
{
if (Player* player = GetPlayerForEscort())
{
// not a likely case, code here for the sake of example
if (killer == me)
Talk(SAY_DEATH_1, player);
else
Talk(SAY_DEATH_2, player);
}
}
else
Talk(SAY_DEATH_3);
}
void UpdateAI(uint32 uiDiff) override
{
//Must update npc_escortAI
npc_escortAI::UpdateAI(uiDiff);
//Combat check
if (me->GetVictim())
{
if (m_uiDeathCoilTimer <= uiDiff)
{
Talk(SAY_SPELL);
DoCastVictim(SPELL_DEATH_COIL, false);
m_uiDeathCoilTimer = 4000;
}
else
m_uiDeathCoilTimer -= uiDiff;
}
else
{
//Out of combat but being escorted
if (HasEscortState(STATE_ESCORT_ESCORTING))
{
if (m_uiChatTimer <= uiDiff)
{
if (me->HasAura(SPELL_ELIXIR_OF_FORTITUDE))
{
Talk(SAY_RAND_1);
DoCast(me, SPELL_BLUE_FIREWORK, false);
}
else
{
Talk(SAY_RAND_2);
DoCast(me, SPELL_ELIXIR_OF_FORTITUDE, false);
}
m_uiChatTimer = 12000;
}
else
m_uiChatTimer -= uiDiff;
}
}
}
};
CreatureAI* GetAI(Creature* creature) const override
{
return new example_escortAI(creature);
}
bool OnGossipHello(Player* player, Creature* creature) override
{
player->TalkedToCreature(creature->GetEntry(), creature->GetGUID());
player->PrepareGossipMenu(creature, 0);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
player->SendPreparedGossip(creature);
return true;
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
{
player->PlayerTalkClass->ClearMenus();
npc_escortAI* pEscortAI = CAST_AI(example_escort::example_escortAI, creature->AI());
switch (action)
{
case GOSSIP_ACTION_INFO_DEF+1:
player->CLOSE_GOSSIP_MENU();
if (pEscortAI)
pEscortAI->Start(true, true, player->GetGUID());
break;
case GOSSIP_ACTION_INFO_DEF+2:
player->CLOSE_GOSSIP_MENU();
if (pEscortAI)
pEscortAI->Start(false, false, player->GetGUID());
break;
case GOSSIP_ACTION_INFO_DEF+3:
player->CLOSE_GOSSIP_MENU();
if (pEscortAI)
pEscortAI->Start(false, true, player->GetGUID());
break;
default:
return false; // nothing defined -> trinity core handling
}
return true; // no default handling -> prevent trinity core handling
}
};
void AddSC_example_escort()
{
new example_escort();
}

View File

@@ -1,114 +0,0 @@
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
* 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 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, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
SDName: Example_Gossip_Codebox
SD%Complete: 100
SDComment: Show a codebox in gossip option
SDCategory: Script Examples
EndScriptData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "Player.h"
#include <cstring>
enum Yells
{
// These texts must be added to the creature texts of the npc for which the script is assigned.
SAY_NOT_INTERESTED = 0, // "Normal select, guess you're not interested."
SAY_WRONG = 1, // "Wrong!"
SAY_CORRECT = 2 // "You're right, you are allowed to see my inner secrets."
};
enum Spells
{
SPELL_POLYMORPH = 12826,
SPELL_MARK_OF_THE_WILD = 26990
};
#define GOSSIP_ITEM_1 "A quiz: what's your name?"
#define GOSSIP_ITEM_2 "I'm not interested"
class example_gossip_codebox : public CreatureScript
{
public:
example_gossip_codebox()
: CreatureScript("example_gossip_codebox")
{
}
bool OnGossipHello(Player* player, Creature* creature) override
{
player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
player->PlayerTalkClass->SendGossipMenu(907, creature->GetGUID());
return true;
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
{
player->PlayerTalkClass->ClearMenus();
if (action == GOSSIP_ACTION_INFO_DEF+2)
{
//Read comment in enum
creature->AI()->Talk(SAY_NOT_INTERESTED);
player->CLOSE_GOSSIP_MENU();
}
return true;
}
bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code) override
{
player->PlayerTalkClass->ClearMenus();
if (sender == GOSSIP_SENDER_MAIN)
{
switch (action)
{
case GOSSIP_ACTION_INFO_DEF+1:
if (player->GetName() != code)
{
//Read comment in enum
creature->AI()->Talk(SAY_WRONG);
creature->CastSpell(player, SPELL_POLYMORPH, true);
}
else
{
//Read comment in enum
creature->AI()->Talk(SAY_CORRECT);
creature->CastSpell(player, SPELL_MARK_OF_THE_WILD, true);
}
player->CLOSE_GOSSIP_MENU();
return true;
}
}
return false;
}
};
void AddSC_example_gossip_codebox()
{
new example_gossip_codebox();
}

View File

@@ -1,82 +0,0 @@
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
* 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 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, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
SDName: Example_Misc
SD%Complete: 100
SDComment: Item, Areatrigger and other small code examples
SDCategory: Script Examples
EndScriptData */
#include "ScriptMgr.h"
#include "Player.h"
class AT_example_areatrigger : public AreaTriggerScript
{
public:
AT_example_areatrigger()
: AreaTriggerScript("example_areatrigger")
{
}
bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/) override
{
player->Kill(player);
return true;
}
};
class ItemUse_example_item : public ItemScript
{
public:
ItemUse_example_item()
: ItemScript("example_item")
{
}
bool OnUse(Player* /*player*/, Item* /*item*/, SpellCastTargets const& /*targets*/) override
{
sScriptMgr->LoadDatabase();
return true;
}
};
class GOHello_example_go_teleporter : public GameObjectScript
{
public:
GOHello_example_go_teleporter()
: GameObjectScript("example_go_teleporter")
{
}
bool OnGossipHello(Player* player, GameObject* /*go*/) override
{
player->TeleportTo(0, 1807.07f, 336.105f, 70.3975f, 0.0f);
return false;
}
};
void AddSC_example_misc()
{
new AT_example_areatrigger();
new ItemUse_example_item();
new GOHello_example_go_teleporter();
}

View File

@@ -1,491 +0,0 @@
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
*
* 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 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, see <http://www.gnu.org/licenses/>.
*/
/*
* An example of a spell script file
* to bind a script to spell you have to add entry for it in `spell_script_names`
* where `spell_id` is id of the spell to bind
* and `ScriptName` is the name of a script assigned on registration
*/
#include "ScriptMgr.h"
#include "SpellAuras.h"
#include "SpellAuraEffects.h"
#include "SpellScript.h"
#include "Player.h"
enum Spells
{
SPELL_TRIGGERED = 18282
};
class spell_ex_5581 : public SpellScriptLoader
{
public:
spell_ex_5581() : SpellScriptLoader("spell_ex_5581") { }
class spell_ex_5581SpellScript : public SpellScript
{
// initialize script, this macro does compile time check for type of the function - prevents possible issues
// if you have assigned wrong type of function to a hook you'll receive type conversion error during build
// this line is required, otherwise you'll get XXXHandlerFunction - identifier not found errors
PrepareSpellScript(spell_ex_5581SpellScript);
std::string localVariable;
char* localVariable2;
// function called on server startup
// checks if script has data required for it to work
bool Validate(SpellInfo const* /*spellInfo*/) override
{
// check if spellid 70522 exists in dbc, we will trigger it later
if (!sSpellMgr->GetSpellInfo(SPELL_TRIGGERED))
return false;
return true;
}
// function called just after script is added to spell
// we initialize local variables if needed
bool Load() override
{
localVariable = "we're using local variable";
localVariable2 = new char();
return true;
// return false - script will be immediately removed from the spell
// for example - we don't want this script to be executed on a creature
// if (GetCaster()->GetTypeID() != TYPEID_PLAYER)
// return false;
}
// function called just before script delete
// we free allocated memory
void Unload() override
{
delete localVariable2;
}
void HandleBeforeCast()
{
// this hook is executed before anything about casting the spell is done
// after this hook is executed all the machinery starts
TC_LOG_INFO("misc", "Caster just finished preparing the spell (cast bar has expired)");
}
void HandleOnCast()
{
// cast is validated and spell targets are selected at this moment
// this is a last place when the spell can be safely interrupted
TC_LOG_INFO("misc", "Spell is about to do take reagents, power, launch missile, do visuals and instant spell effects");
}
void HandleAfterCast()
{
TC_LOG_INFO("misc", "All immediate Actions for the spell are finished now");
// this is a safe for triggering additional effects for a spell without interfering
// with visuals or with other effects of the spell
//GetCaster()->CastSpell(target, SPELL_TRIGGERED, true);
}
SpellCastResult CheckRequirement()
{
// in this hook you can add additional requirements for spell caster (and throw a client error if reqs're not passed)
// in this case we're disallowing to select non-player as a target of the spell
//if (!GetExplTargetUnit() || GetExplTargetUnit()->ToPlayer())
//return SPELL_FAILED_BAD_TARGETS;
return SPELL_CAST_OK;
}
void HandleDummyLaunch(SpellEffIndex /*effIndex*/)
{
TC_LOG_INFO("misc", "Spell %u with SPELL_EFFECT_DUMMY is just launched!", GetSpellInfo()->Id);
}
void HandleDummyLaunchTarget(SpellEffIndex /*effIndex*/)
{
ObjectGuid targetGUID;
if (Unit* unitTarget = GetHitUnit())
targetGUID = unitTarget->GetGUID();
// we're handling SPELL_EFFECT_DUMMY in effIndex 0 here
TC_LOG_INFO("misc", "Spell %u with SPELL_EFFECT_DUMMY is just launched at it's target: " UI64FMTD "!", GetSpellInfo()->Id, targetGUID.GetRawValue());
}
void HandleDummyHit(SpellEffIndex /*effIndex*/)
{
TC_LOG_INFO("misc", "Spell %u with SPELL_EFFECT_DUMMY has hit!", GetSpellInfo()->Id);
}
void HandleDummyHitTarget(SpellEffIndex /*effIndex*/)
{
TC_LOG_INFO("misc", "SPELL_EFFECT_DUMMY is hits it's target!");
// make caster cast a spell on a unit target of effect
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target, SPELL_TRIGGERED, true);
}
void HandleBeforeHit()
{
TC_LOG_INFO("misc", "Spell is about to hit target!");
}
void HandleOnHit()
{
TC_LOG_INFO("misc", "Spell just hit target!");
}
void HandleAfterHit()
{
TC_LOG_INFO("misc", "Spell just finished hitting target!");
}
void FilterTargets(std::list<Unit*>& /*targetList*/)
{
// usually you want this call for Area Target spells
TC_LOG_INFO("misc", "Spell is about to add targets from targetList to final targets!");
}
// register functions used in spell script - names of these functions do not matter
void Register() override
{
// we're registering our functions here
BeforeCast += SpellCastFn(spell_ex_5581SpellScript::HandleBeforeCast);
OnCast += SpellCastFn(spell_ex_5581SpellScript::HandleOnCast);
AfterCast += SpellCastFn(spell_ex_5581SpellScript::HandleAfterCast);
OnCheckCast += SpellCheckCastFn(spell_ex_5581SpellScript::CheckRequirement);
// function HandleDummy will be called when spell is launched, independant from targets selected for spell, just before default effect 0 launch handler
OnEffectLaunch += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyLaunch, EFFECT_0, SPELL_EFFECT_DUMMY);
// function HandleDummy will be called when spell is launched at target, just before default effect 0 launch at target handler
OnEffectLaunchTarget += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyLaunchTarget, EFFECT_0, SPELL_EFFECT_DUMMY);
// function HandleDummy will be called when spell hits it's destination, independant from targets selected for spell, just before default effect 0 hit handler
OnEffectHit += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyHit, EFFECT_0, SPELL_EFFECT_DUMMY);
// function HandleDummy will be called when unit is hit by spell, just before default effect 0 hit target handler
OnEffectHitTarget += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyHitTarget, EFFECT_0, SPELL_EFFECT_DUMMY);
// this will prompt an error on startup because effect 0 of spell 49375 is set to SPELL_EFFECT_DUMMY, not SPELL_EFFECT_APPLY_AURA
//OnEffectHitTarget += SpellEffectFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
// this will make HandleDummy function to be called on first != 0 effect of spell 49375
//OnEffectHitTarget += SpellEffectFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_FIRST_FOUND, SPELL_EFFECT_ANY);
// this will make HandleDummy function to be called on all != 0 effect of spell 49375
//OnEffectHitTarget += SpellEffectFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_ALL, SPELL_EFFECT_ANY);
// bind handler to BeforeHit event of the spell
BeforeHit += SpellHitFn(spell_ex_5581SpellScript::HandleBeforeHit);
// bind handler to OnHit event of the spell
OnHit += SpellHitFn(spell_ex_5581SpellScript::HandleOnHit);
// bind handler to AfterHit event of the spell
AfterHit += SpellHitFn(spell_ex_5581SpellScript::HandleAfterHit);
// bind handler to OnUnitTargetSelect event of the spell
//OnUnitTargetSelect += SpellUnitTargetFn(spell_ex_5581SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_CASTER);
}
};
// function which creates SpellScript
SpellScript* GetSpellScript() const override
{
return new spell_ex_5581SpellScript();
}
};
class spell_ex_66244 : public SpellScriptLoader
{
public:
spell_ex_66244() : SpellScriptLoader("spell_ex_66244") { }
class spell_ex_66244AuraScript : public AuraScript
{
PrepareAuraScript(spell_ex_66244AuraScript);
// function called on server startup
// checks if script has data required for it to work
bool Validate(SpellInfo const* /*spellInfo*/) override
{
// check if spellid exists in dbc, we will trigger it later
if (!sSpellMgr->GetSpellInfo(SPELL_TRIGGERED))
return false;
return true;
}
// function called in aura constructor
// we initialize local variables if needed
bool Load() override
{
// do not load script if aura is cast by player or caster not avalible
if (Unit* caster = GetCaster())
if (caster->GetTypeId() == TYPEID_PLAYER)
return true;
return false;
}
void HandleOnEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
TC_LOG_INFO("misc", "Aura Effect is about to be applied on target!");
// this hook allows you to prevent execution of AuraEffect handler, or to replace it with your own handler
//PreventDefaultAction();
}
void HandleOnEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
TC_LOG_INFO("misc", "Aura Effect is about to be removed from target!");
// this hook allows you to prevent execution of AuraEffect handler, or to replace it with your own handler
//PreventDefaultAction();
}
void HandleAfterEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
TC_LOG_INFO("misc", "Aura Effect has just been applied on target!");
Unit* target = GetTarget();
// cast spell on target on aura apply
target->CastSpell(target, SPELL_TRIGGERED, true);
}
void HandleAfterEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
TC_LOG_INFO("misc", "Aura Effect has just been just removed from target!");
Unit* target = GetTarget();
Unit* caster = GetCaster();
// caster may be not avalible (logged out for example)
if (!caster)
return;
// cast spell on caster on aura remove
target->CastSpell(caster, SPELL_TRIGGERED, true);
}
void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
{
TC_LOG_INFO("misc", "Perioidic Aura Effect is does a tick on target!");
Unit* target = GetTarget();
// aura targets damage self on tick
target->DealDamage(target, 100);
}
void HandleEffectPeriodicUpdate(AuraEffect* aurEff)
{
TC_LOG_INFO("misc", "Perioidic Aura Effect is now updated!");
// we're doubling aura amount every tick
aurEff->ChangeAmount(aurEff->GetAmount() * 2);
}
void HandleEffectCalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated)
{
TC_LOG_INFO("misc", "Amount of Aura Effect is being calculated now!");
// we're setting amount to 100
amount = 100;
// amount will be never recalculated due to applying passive aura
canBeRecalculated = false;
}
void HandleEffectCalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude)
{
TC_LOG_INFO("misc", "Periodic data of Aura Effect is being calculated now!");
// we're setting aura to be periodic and tick every 10 seconds
isPeriodic = true;
amplitude = 2 * IN_MILLISECONDS;
}
void HandleEffectCalcSpellMod(AuraEffect const* /*aurEff*/, SpellModifier*& spellMod)
{
TC_LOG_INFO("misc", "SpellMod data of Aura Effect is being calculated now!");
// we don't want spellmod for example
if (spellMod)
{
delete spellMod;
spellMod = NULL;
}
/*
// alternative: we want spellmod for spell which doesn't have it
if (!spellMod)
{
spellMod = new SpellModifier(GetAura());
spellMod->op = SPELLMOD_DOT;
spellMod->type = SPELLMOD_PCT;
spellMod->spellId = GetId();
spellMod->mask[1] = 0x00002000;
}
*/
}
// function registering
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_ex_66244AuraScript::HandleOnEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_ex_66244AuraScript::HandleOnEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
// AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK - makes handler to be called when aura is reapplied on target
AfterEffectApply += AuraEffectApplyFn(spell_ex_66244AuraScript::HandleAfterEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
AfterEffectRemove += AuraEffectRemoveFn(spell_ex_66244AuraScript::HandleAfterEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_ex_66244AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_DUMMY);
OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_ex_66244AuraScript::HandleEffectPeriodicUpdate, EFFECT_0, SPELL_AURA_DUMMY);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ex_66244AuraScript::HandleEffectCalcAmount, EFFECT_0, SPELL_AURA_DUMMY);
DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_ex_66244AuraScript::HandleEffectCalcPeriodic, EFFECT_0, SPELL_AURA_DUMMY);
DoEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_ex_66244AuraScript::HandleEffectCalcSpellMod, EFFECT_0, SPELL_AURA_DUMMY);
/*OnApply += AuraEffectApplyFn();
OnRemove += AuraEffectRemoveFn();
DoCheckAreaTarget += AuraCheckAreaTargetFn();*/
}
/*
void OnApply()
{
}
void OnRemove()
{
}
bool DoCheckAreaTarget(Unit* proposedTarget)
{
}*/
};
// function which creates AuraScript
AuraScript* GetAuraScript() const override
{
return new spell_ex_66244AuraScript();
}
};
// example usage of OnEffectManaShield and AfterEffectManaShield hooks
// see spell_ex_absorb_aura, these hooks work the same as OnEffectAbsorb and AfterEffectAbsorb
// example usage of OnEffectAbsorb and AfterEffectAbsorb hooks
class spell_ex_absorb_aura : public SpellScriptLoader
{
public:
spell_ex_absorb_aura() : SpellScriptLoader("spell_ex_absorb_aura") { }
class spell_ex_absorb_auraAuraScript : public AuraScript
{
PrepareAuraScript(spell_ex_absorb_auraAuraScript);
void HandleOnEffectAbsorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
TC_LOG_INFO("misc", "Our aura is now absorbing damage done to us!");
// absorb whole damage done to us
absorbAmount = dmgInfo.GetDamage();
}
void HandleAfterEffectAbsorb(AuraEffect* /*aurEff*/, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount)
{
TC_LOG_INFO("misc", "Our aura has absorbed %u damage!", absorbAmount);
}
// function registering
void Register() override
{
OnEffectAbsorb += AuraEffectAbsorbFn(spell_ex_absorb_auraAuraScript::HandleOnEffectAbsorb, EFFECT_0);
AfterEffectAbsorb += AuraEffectAbsorbFn(spell_ex_absorb_auraAuraScript::HandleAfterEffectAbsorb, EFFECT_0);
}
};
// function which creates AuraScript
AuraScript* GetAuraScript() const override
{
return new spell_ex_absorb_auraAuraScript();
}
};
class spell_ex_463 : public SpellScriptLoader
{
public:
spell_ex_463() : SpellScriptLoader("spell_ex_463") { }
class spell_ex_463AuraScript : public AuraScript
{
PrepareAuraScript(spell_ex_463AuraScript);
bool CheckAreaTarget(Unit* target)
{
TC_LOG_INFO("misc", "Area aura checks if unit is a valid target for it!");
// in our script we allow only players to be affected
return target->GetTypeId() == TYPEID_PLAYER;
}
void Register() override
{
DoCheckAreaTarget += AuraCheckAreaTargetFn(spell_ex_463AuraScript::CheckAreaTarget);
}
};
// function which creates AuraScript
AuraScript* GetAuraScript() const override
{
return new spell_ex_463AuraScript();
}
};
// this function has to be added to function set in ScriptLoader.cpp
void AddSC_example_spell_scripts()
{
new spell_ex_5581;
new spell_ex_66244;
new spell_ex_absorb_aura;
new spell_ex_463;
}
/* empty script for copypasting
class spell_ex : public SpellScriptLoader
{
public:
spell_ex() : SpellScriptLoader("spell_ex") { }
class spell_ex_SpellScript : public SpellScript
{
PrepareSpellScript(spell_ex_SpellScript);
//bool Validate(SpellInfo const* spellEntry){return true;} override
//bool Load(){return true;}
//void Unload(){ }
//void Function(SpellEffIndex effIndex) //OnEffect += SpellEffectFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_EFFECT_ANY);
//void Function() //OnHit += SpellEffectFn(spell_ex_SpellScript::Function);
void Register() override
{
}
};
SpellScript* GetSpellScript() const override
{
return new spell_ex_SpellScript();
}
};
*/
/* empty script for copypasting
class spell_ex : public SpellScriptLoader
{
public:
spell_ex() : SpellScriptLoader("spell_ex") { }
class spell_ex_AuraScript : public AuraScript
{
PrepareAuraScript(spell_ex)
//bool Validate(SpellInfo const* spellEntry){return true;} override
//bool Load(){return true;}
//void Unload(){ }
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff, AuraEffectHandleModes mode) //OnEffectApply += AuraEffectApplyFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL);
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff, AuraEffectHandleModes mode) //OnEffectRemove += AuraEffectRemoveFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL);
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff) //OnEffectPeriodic += AuraEffectPeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
//void spell_ex_SpellScript::Function(AuraEffect* aurEff) //OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) //DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff, bool& isPeriodic, int32& amplitude) //OnEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff, SpellModifier*& spellMod) //OnEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
void Register() override
{
}
};
AuraScript* GetAuraScript() const override
{
return new spell_ex_AuraScript();
}
};
*/