2010-08-07 16:38:22 +02:00
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2010 Trinity <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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
2009-10-17 15:51:44 -07:00
2010-06-07 16:21:52 -06:00
#include "ScriptPCH.h"
2010-06-08 17:01:03 -06:00
#include "Config.h"
#include "DatabaseEnv.h"
2009-03-27 09:58:20 -06:00
#include "DBCStores.h"
2008-10-11 14:16:25 -05:00
#include "ObjectMgr.h"
#include "ProgressBar.h"
2010-01-19 11:36:05 +01:00
#include "ScriptLoader.h"
#include "ScriptSystem.h"
2010-08-06 19:23:43 +02:00
// Utility macros to refer to the script registry.
#define SCR_REG_MAP(T) ScriptRegistry<T>::ScriptMap
2010-08-07 15:26:24 +02:00
#define SCR_REG_ITR(T) ScriptRegistry<T>::ScriptMapIterator
2010-08-06 19:23:43 +02:00
#define SCR_REG_LST(T) ScriptRegistry<T>::ScriptPointerList
// Utility macros for looping over scripts.
#define FOR_SCRIPTS(T,C,E) \
if (SCR_REG_LST(T).empty()) \
return; \
2010-08-07 15:26:24 +02:00
for (SCR_REG_ITR(T) C = SCR_REG_LST(T).begin(); \
2010-08-06 19:23:43 +02:00
C != SCR_REG_LST(T).end(); ++C)
#define FOR_SCRIPTS_RET(T,C,E,R) \
if (SCR_REG_LST(T).empty()) \
return R; \
2010-08-07 15:26:24 +02:00
for (SCR_REG_ITR(T) C = SCR_REG_LST(T).begin(); \
2010-08-06 19:23:43 +02:00
C != SCR_REG_LST(T).end(); ++C)
#define FOREACH_SCRIPT(T) \
FOR_SCRIPTS(T, itr, end) \
itr->second
// Utility macros for finding specific scripts.
#define GET_SCRIPT(T,I,V) \
T* V = ScriptRegistry<T>::GetScriptById(I); \
if (!V) \
return;
#define GET_SCRIPT_RET(T,I,V,R) \
T* V = ScriptRegistry<T>::GetScriptById(I); \
if (!V) \
return R;
2009-10-17 15:51:44 -07:00
2009-08-16 19:38:18 +02:00
void DoScriptText ( int32 iTextEntry , WorldObject * pSource , Unit * pTarget )
2008-10-11 14:16:25 -05:00
{
if ( ! pSource )
{
2010-06-22 02:53:04 +02:00
sLog . outError ( "TSCR: DoScriptText entry %i, invalid Source pointer." , iTextEntry );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-08-16 19:38:18 +02:00
if ( iTextEntry >= 0 )
2008-10-11 14:16:25 -05:00
{
2010-06-22 02:53:04 +02:00
sLog . outError ( "TSCR: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative." , pSource -> GetEntry (), pSource -> GetTypeId (), pSource -> GetGUIDLow (), iTextEntry );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
const StringTextData * pData = sScriptSystemMgr . GetTextData ( iTextEntry );
2009-10-17 15:51:44 -07:00
2009-08-16 19:38:18 +02:00
if ( ! pData )
2008-10-11 14:16:25 -05:00
{
2010-06-22 02:53:04 +02:00
sLog . outError ( "TSCR: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i." , pSource -> GetEntry (), pSource -> GetTypeId (), pSource -> GetGUIDLow (), iTextEntry );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-06-22 02:53:04 +02:00
sLog . outDebug ( "TSCR: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u" , iTextEntry , pData -> uiSoundId , pData -> uiType , pData -> uiLanguage , pData -> uiEmote );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( pData -> uiSoundId )
2008-10-11 14:16:25 -05:00
{
2010-04-07 19:14:10 +02:00
if ( GetSoundEntriesStore () -> LookupEntry ( pData -> uiSoundId ))
2009-08-16 19:38:18 +02:00
pSource -> SendPlaySound ( pData -> uiSoundId , false );
2008-10-11 14:16:25 -05:00
else
2010-06-22 02:53:04 +02:00
sLog . outError ( "TSCR: DoScriptText entry %i tried to process invalid sound id %u." , iTextEntry , pData -> uiSoundId );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( pData -> uiEmote )
2009-02-09 08:16:34 -05:00
{
if ( pSource -> GetTypeId () == TYPEID_UNIT || pSource -> GetTypeId () == TYPEID_PLAYER )
2009-08-16 19:38:18 +02:00
(( Unit * ) pSource ) -> HandleEmoteCommand ( pData -> uiEmote );
2009-02-09 08:16:34 -05:00
else
2010-06-22 02:53:04 +02:00
sLog . outError ( "TSCR: DoScriptText entry %i tried to process emote for invalid TypeId (%u)." , iTextEntry , pSource -> GetTypeId ());
2009-02-09 08:16:34 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
switch ( pData -> uiType )
2008-10-11 14:16:25 -05:00
{
case CHAT_TYPE_SAY :
2009-08-16 19:38:18 +02:00
pSource -> MonsterSay ( iTextEntry , pData -> uiLanguage , pTarget ? pTarget -> GetGUID () : 0 );
2008-10-11 14:16:25 -05:00
break ;
case CHAT_TYPE_YELL :
2009-08-16 19:38:18 +02:00
pSource -> MonsterYell ( iTextEntry , pData -> uiLanguage , pTarget ? pTarget -> GetGUID () : 0 );
2008-10-11 14:16:25 -05:00
break ;
case CHAT_TYPE_TEXT_EMOTE :
2009-08-16 19:38:18 +02:00
pSource -> MonsterTextEmote ( iTextEntry , pTarget ? pTarget -> GetGUID () : 0 );
2008-10-11 14:16:25 -05:00
break ;
case CHAT_TYPE_BOSS_EMOTE :
2009-08-16 19:38:18 +02:00
pSource -> MonsterTextEmote ( iTextEntry , pTarget ? pTarget -> GetGUID () : 0 , true );
2008-10-11 14:16:25 -05:00
break ;
case CHAT_TYPE_WHISPER :
2010-08-06 19:23:43 +02:00
{
if ( pTarget && pTarget -> GetTypeId () == TYPEID_PLAYER )
pSource -> MonsterWhisper ( iTextEntry , pTarget -> GetGUID ());
else
sLog . outError ( "TSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER)." , iTextEntry );
2009-10-27 22:09:45 -07:00
break ;
2010-08-06 19:23:43 +02:00
}
2008-10-11 14:16:25 -05:00
case CHAT_TYPE_BOSS_WHISPER :
2010-08-06 19:23:43 +02:00
{
if ( pTarget && pTarget -> GetTypeId () == TYPEID_PLAYER )
pSource -> MonsterWhisper ( iTextEntry , pTarget -> GetGUID (), true );
else
sLog . outError ( "TSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER)." , iTextEntry );
2009-10-27 22:09:45 -07:00
break ;
2010-08-06 19:23:43 +02:00
}
2009-04-03 16:54:20 -06:00
case CHAT_TYPE_ZONE_YELL :
2009-08-16 19:38:18 +02:00
pSource -> MonsterYellToZone ( iTextEntry , pData -> uiLanguage , pTarget ? pTarget -> GetGUID () : 0 );
2009-04-03 16:54:20 -06:00
break ;
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
ScriptMgr :: ScriptMgr ()
2010-08-09 16:07:03 -05:00
: _scriptCount ( 0 )
2010-08-06 19:23:43 +02:00
{
}
ScriptMgr ::~ ScriptMgr ()
{
#define SCR_CLEAR(T) \
FOR_SCRIPTS(T, itr, end) \
delete itr->second; \
SCR_REG_LST(T).clear();
// Clear scripts for every script type.
2010-08-24 00:10:49 +02:00
SCR_CLEAR ( SpellScriptLoader );
2010-08-06 19:23:43 +02:00
SCR_CLEAR ( ServerScript );
SCR_CLEAR ( WorldScript );
SCR_CLEAR ( FormulaScript );
SCR_CLEAR ( WorldMapScript );
SCR_CLEAR ( InstanceMapScript );
SCR_CLEAR ( BattlegroundMapScript );
SCR_CLEAR ( ItemScript );
SCR_CLEAR ( CreatureScript );
SCR_CLEAR ( GameObjectScript );
SCR_CLEAR ( AreaTriggerScript );
SCR_CLEAR ( BattlegroundScript );
SCR_CLEAR ( OutdoorPvPScript );
SCR_CLEAR ( CommandScript );
SCR_CLEAR ( WeatherScript );
SCR_CLEAR ( AuctionHouseScript );
SCR_CLEAR ( ConditionScript );
SCR_CLEAR ( VehicleScript );
SCR_CLEAR ( DynamicObjectScript );
SCR_CLEAR ( TransportScript );
2010-08-07 17:58:45 +02:00
SCR_CLEAR ( AchievementCriteriaScript );
2010-08-14 12:44:54 -07:00
SCR_CLEAR ( PlayerScript );
SCR_CLEAR ( GuildScript );
2010-08-06 19:23:43 +02:00
#undef SCR_CLEAR
}
void ScriptMgr :: Initialize ()
2008-11-03 08:14:21 -06:00
{
2010-08-06 19:23:43 +02:00
LoadDatabase ();
sLog . outString ( "Loading C++ scripts" );
barGoLink bar ( 1 );
bar . step ();
sLog . outString ( "" );
FillSpellSummary ();
AddScripts ();
sLog . outString ( ">> Loaded %u C++ scripts" , GetScriptCount ());
}
void ScriptMgr :: LoadDatabase ()
{
sScriptSystemMgr . LoadVersion ();
sScriptSystemMgr . LoadScriptTexts ();
sScriptSystemMgr . LoadScriptTextsCustom ();
sScriptSystemMgr . LoadScriptWaypoints ();
}
struct TSpellSummary
{
uint8 Targets ; // set of enum SelectTarget
uint8 Effects ; // set of enum SelectEffect
} * SpellSummary ;
void ScriptMgr :: FillSpellSummary ()
{
SpellSummary = new TSpellSummary [ GetSpellStore () -> GetNumRows ()];
SpellEntry const * pTempSpell ;
for ( uint32 i = 0 ; i < GetSpellStore () -> GetNumRows (); ++ i )
2010-05-14 20:07:45 +02:00
{
2010-08-06 19:23:43 +02:00
SpellSummary [ i ]. Effects = 0 ;
SpellSummary [ i ]. Targets = 0 ;
pTempSpell = GetSpellStore () -> LookupEntry ( i );
//This spell doesn't exist
if ( ! pTempSpell )
continue ;
for ( uint32 j = 0 ; j < 3 ; ++ j )
2010-05-14 20:07:45 +02:00
{
2010-08-06 19:23:43 +02:00
//Spell targets self
if ( pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_CASTER )
SpellSummary [ i ]. Targets |= 1 << ( SELECT_TARGET_SELF - 1 );
//Spell targets a single enemy
if ( pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_TARGET_ENEMY ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_DST_TARGET_ENEMY )
SpellSummary [ i ]. Targets |= 1 << ( SELECT_TARGET_SINGLE_ENEMY - 1 );
//Spell targets AoE at enemy
if ( pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_AREA_ENEMY_SRC ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_AREA_ENEMY_DST ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_SRC_CASTER ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_DEST_DYNOBJ_ENEMY )
SpellSummary [ i ]. Targets |= 1 << ( SELECT_TARGET_AOE_ENEMY - 1 );
//Spell targets an enemy
if ( pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_TARGET_ENEMY ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_DST_TARGET_ENEMY ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_AREA_ENEMY_SRC ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_AREA_ENEMY_DST ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_SRC_CASTER ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_DEST_DYNOBJ_ENEMY )
SpellSummary [ i ]. Targets |= 1 << ( SELECT_TARGET_ANY_ENEMY - 1 );
//Spell targets a single friend(or self)
if ( pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_CASTER ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_TARGET_ALLY ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_TARGET_PARTY )
SpellSummary [ i ]. Targets |= 1 << ( SELECT_TARGET_SINGLE_FRIEND - 1 );
//Spell targets aoe friends
if ( pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_PARTY_CASTER ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_PARTY_TARGET ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_SRC_CASTER )
SpellSummary [ i ]. Targets |= 1 << ( SELECT_TARGET_AOE_FRIEND - 1 );
//Spell targets any friend(or self)
if ( pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_CASTER ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_TARGET_ALLY ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_TARGET_PARTY ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_PARTY_CASTER ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_UNIT_PARTY_TARGET ||
pTempSpell -> EffectImplicitTargetA [ j ] == TARGET_SRC_CASTER )
SpellSummary [ i ]. Targets |= 1 << ( SELECT_TARGET_ANY_FRIEND - 1 );
//Make sure that this spell includes a damage effect
if ( pTempSpell -> Effect [ j ] == SPELL_EFFECT_SCHOOL_DAMAGE ||
pTempSpell -> Effect [ j ] == SPELL_EFFECT_INSTAKILL ||
pTempSpell -> Effect [ j ] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE ||
pTempSpell -> Effect [ j ] == SPELL_EFFECT_HEALTH_LEECH )
SpellSummary [ i ]. Effects |= 1 << ( SELECT_EFFECT_DAMAGE - 1 );
//Make sure that this spell includes a healing effect (or an apply aura with a periodic heal)
if ( pTempSpell -> Effect [ j ] == SPELL_EFFECT_HEAL ||
pTempSpell -> Effect [ j ] == SPELL_EFFECT_HEAL_MAX_HEALTH ||
pTempSpell -> Effect [ j ] == SPELL_EFFECT_HEAL_MECHANICAL ||
( pTempSpell -> Effect [ j ] == SPELL_EFFECT_APPLY_AURA && pTempSpell -> EffectApplyAuraName [ j ] == 8 ))
SpellSummary [ i ]. Effects |= 1 << ( SELECT_EFFECT_HEALING - 1 );
//Make sure that this spell applies an aura
if ( pTempSpell -> Effect [ j ] == SPELL_EFFECT_APPLY_AURA )
SpellSummary [ i ]. Effects |= 1 << ( SELECT_EFFECT_AURA - 1 );
2010-05-14 20:07:45 +02:00
}
}
2010-08-06 19:23:43 +02:00
}
2010-05-14 20:07:45 +02:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: CreateSpellScripts ( uint32 spell_id , std :: list < SpellScript *> & script_vector )
{
2010-08-08 05:25:45 +02:00
SpellScriptsBounds bounds = sObjectMgr . GetSpellScriptsBounds ( spell_id );
2010-08-06 19:23:43 +02:00
for ( SpellScriptsMap :: iterator itr = bounds . first ; itr != bounds . second ; ++ itr )
2008-10-11 14:16:25 -05:00
{
2010-08-24 00:10:49 +02:00
SpellScriptLoader * tmpscript = ScriptRegistry < SpellScriptLoader >:: GetScriptById ( itr -> second );
2010-08-06 19:23:43 +02:00
if ( ! tmpscript )
continue ;
2010-05-13 14:15:11 +02:00
2010-08-06 19:23:43 +02:00
SpellScript * script = tmpscript -> GetSpellScript ();
if ( ! script )
continue ;
script_vector . push_back ( script );
}
}
2010-08-24 00:10:49 +02:00
void ScriptMgr :: CreateAuraScripts ( uint32 spell_id , std :: list < AuraScript *> & script_vector )
2010-08-06 19:23:43 +02:00
{
2010-08-08 05:25:45 +02:00
SpellScriptsBounds bounds = sObjectMgr . GetSpellScriptsBounds ( spell_id );
2010-08-06 19:23:43 +02:00
for ( SpellScriptsMap :: iterator itr = bounds . first ; itr != bounds . second ; ++ itr )
{
2010-08-24 00:10:49 +02:00
SpellScriptLoader * tmpscript = ScriptRegistry < SpellScriptLoader >:: GetScriptById ( itr -> second );
2010-08-06 19:23:43 +02:00
if ( ! tmpscript )
continue ;
2010-08-24 00:10:49 +02:00
AuraScript * script = tmpscript -> GetAuraScript ();
2010-08-06 19:23:43 +02:00
if ( ! script )
continue ;
2010-08-24 00:10:49 +02:00
script_vector . push_back ( script );
}
}
void ScriptMgr :: CreateSpellScriptLoaders ( uint32 spell_id , std :: vector < std :: pair < SpellScriptLoader * , SpellScriptsMap :: iterator > > & script_vector )
{
SpellScriptsBounds bounds = sObjectMgr . GetSpellScriptsBounds ( spell_id );
script_vector . reserve ( std :: distance ( bounds . first , bounds . second ));
for ( SpellScriptsMap :: iterator itr = bounds . first ; itr != bounds . second ; ++ itr )
{
SpellScriptLoader * tmpscript = ScriptRegistry < SpellScriptLoader >:: GetScriptById ( itr -> second );
if ( ! tmpscript )
continue ;
script_vector . push_back ( std :: make_pair ( tmpscript , itr ));
2009-02-20 14:14:16 +01:00
}
2010-08-06 19:23:43 +02:00
}
void ScriptMgr :: OnNetworkStart ()
{
FOREACH_SCRIPT ( ServerScript ) -> OnNetworkStart ();
}
void ScriptMgr :: OnNetworkStop ()
{
FOREACH_SCRIPT ( ServerScript ) -> OnNetworkStop ();
}
void ScriptMgr :: OnSocketOpen ( WorldSocket * socket )
{
ASSERT ( socket );
FOREACH_SCRIPT ( ServerScript ) -> OnSocketOpen ( socket );
}
void ScriptMgr :: OnSocketClose ( WorldSocket * socket , bool wasNew )
{
ASSERT ( socket );
FOREACH_SCRIPT ( ServerScript ) -> OnSocketClose ( socket , wasNew );
}
2010-08-07 17:58:45 +02:00
void ScriptMgr :: OnPacketReceive ( WorldSocket * socket , WorldPacket packet )
2010-08-06 19:23:43 +02:00
{
ASSERT ( socket );
FOREACH_SCRIPT ( ServerScript ) -> OnPacketReceive ( socket , packet );
}
2010-08-07 17:58:45 +02:00
void ScriptMgr :: OnPacketSend ( WorldSocket * socket , WorldPacket packet )
2010-08-06 19:23:43 +02:00
{
ASSERT ( socket );
FOREACH_SCRIPT ( ServerScript ) -> OnPacketSend ( socket , packet );
}
2010-08-07 17:58:45 +02:00
void ScriptMgr :: OnUnknownPacketReceive ( WorldSocket * socket , WorldPacket packet )
2010-08-06 19:23:43 +02:00
{
ASSERT ( socket );
FOREACH_SCRIPT ( ServerScript ) -> OnUnknownPacketReceive ( socket , packet );
}
void ScriptMgr :: OnOpenStateChange ( bool open )
{
FOREACH_SCRIPT ( WorldScript ) -> OnOpenStateChange ( open );
}
void ScriptMgr :: OnConfigLoad ( bool reload )
{
FOREACH_SCRIPT ( WorldScript ) -> OnConfigLoad ( reload );
}
void ScriptMgr :: OnMotdChange ( std :: string & newMotd )
{
FOREACH_SCRIPT ( WorldScript ) -> OnMotdChange ( newMotd );
}
2010-08-07 13:07:18 +02:00
void ScriptMgr :: OnShutdownInitiate ( ShutdownExitCode code , ShutdownMask mask )
2010-08-06 19:23:43 +02:00
{
2010-08-07 13:07:18 +02:00
FOREACH_SCRIPT ( WorldScript ) -> OnShutdownInitiate ( code , mask );
2010-08-06 19:23:43 +02:00
}
void ScriptMgr :: OnShutdownCancel ()
{
FOREACH_SCRIPT ( WorldScript ) -> OnShutdownCancel ();
}
void ScriptMgr :: OnWorldUpdate ( uint32 diff )
{
FOREACH_SCRIPT ( WorldScript ) -> OnUpdate ( NULL , diff );
}
void ScriptMgr :: OnHonorCalculation ( float & honor , uint8 level , uint32 count )
{
FOREACH_SCRIPT ( FormulaScript ) -> OnHonorCalculation ( honor , level , count );
}
void ScriptMgr :: OnHonorCalculation ( uint32 & honor , uint8 level , uint32 count )
{
FOREACH_SCRIPT ( FormulaScript ) -> OnHonorCalculation ( honor , level , count );
}
2010-08-07 13:07:18 +02:00
void ScriptMgr :: OnGrayLevelCalculation ( uint8 & grayLevel , uint8 playerLevel )
2010-08-06 19:23:43 +02:00
{
2010-08-07 13:07:18 +02:00
FOREACH_SCRIPT ( FormulaScript ) -> OnGrayLevelCalculation ( grayLevel , playerLevel );
2010-08-06 19:23:43 +02:00
}
2010-08-07 13:07:18 +02:00
void ScriptMgr :: OnColorCodeCalculation ( XPColorChar & color , uint8 playerLevel , uint8 mobLevel )
2010-08-06 19:23:43 +02:00
{
2010-08-07 13:07:18 +02:00
FOREACH_SCRIPT ( FormulaScript ) -> OnColorCodeCalculation ( color , playerLevel , mobLevel );
2010-08-06 19:23:43 +02:00
}
2010-08-07 13:07:18 +02:00
void ScriptMgr :: OnZeroDifferenceCalculation ( uint8 & diff , uint8 playerLevel )
2010-08-06 19:23:43 +02:00
{
2010-08-07 13:07:18 +02:00
FOREACH_SCRIPT ( FormulaScript ) -> OnZeroDifferenceCalculation ( diff , playerLevel );
2010-08-06 19:23:43 +02:00
}
2010-08-07 13:07:18 +02:00
void ScriptMgr :: OnBaseGainCalculation ( uint32 & gain , uint8 playerLevel , uint8 mobLevel , ContentLevels content )
2010-08-06 19:23:43 +02:00
{
2010-08-07 13:07:18 +02:00
FOREACH_SCRIPT ( FormulaScript ) -> OnBaseGainCalculation ( gain , playerLevel , mobLevel , content );
2010-08-06 19:23:43 +02:00
}
2010-08-07 13:07:18 +02:00
void ScriptMgr :: OnGainCalculation ( uint32 & gain , Player * player , Unit * unit )
2010-08-06 19:23:43 +02:00
{
ASSERT ( player );
ASSERT ( unit );
2010-08-07 13:07:18 +02:00
FOREACH_SCRIPT ( FormulaScript ) -> OnGainCalculation ( gain , player , unit );
2010-08-06 19:23:43 +02:00
}
2010-08-07 13:07:18 +02:00
void ScriptMgr :: OnGroupRateCalculation ( float & rate , uint32 count , bool isRaid )
2010-08-06 19:23:43 +02:00
{
2010-08-07 13:07:18 +02:00
FOREACH_SCRIPT ( FormulaScript ) -> OnGroupRateCalculation ( rate , count , isRaid );
2010-08-06 19:23:43 +02:00
}
#define SCR_MAP_BGN(M,V,I,E,C,T) \
if (V->GetEntry()->T()) \
{ \
FOR_SCRIPTS(M, I, E) \
{ \
MapEntry const* C = I->second->GetEntry(); \
if (!C) \
continue; \
if (entry->MapID == V->GetId()) \
{
#define SCR_MAP_END \
2010-08-09 11:07:23 +02:00
return; \
2010-08-06 19:23:43 +02:00
} \
} \
2009-02-20 14:14:16 +01:00
}
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnCreateMap ( Map * map )
{
ASSERT ( map );
SCR_MAP_BGN ( WorldMapScript , map , itr , end , entry , IsContinent );
itr -> second -> OnCreate ( map );
SCR_MAP_END ;
SCR_MAP_BGN ( InstanceMapScript , map , itr , end , entry , IsDungeon );
itr -> second -> OnCreate (( InstanceMap * ) map );
SCR_MAP_END ;
2010-08-08 04:37:24 +02:00
SCR_MAP_BGN ( BattlegroundMapScript , map , itr , end , entry , IsBattleground );
itr -> second -> OnCreate (( BattlegroundMap * ) map );
2010-08-06 19:23:43 +02:00
SCR_MAP_END ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnDestroyMap ( Map * map )
2009-09-13 00:01:35 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( map );
SCR_MAP_BGN ( WorldMapScript , map , itr , end , entry , IsContinent );
itr -> second -> OnDestroy ( map );
SCR_MAP_END ;
SCR_MAP_BGN ( InstanceMapScript , map , itr , end , entry , IsDungeon );
itr -> second -> OnDestroy (( InstanceMap * ) map );
SCR_MAP_END ;
2010-08-08 04:37:24 +02:00
SCR_MAP_BGN ( BattlegroundMapScript , map , itr , end , entry , IsBattleground );
itr -> second -> OnDestroy (( BattlegroundMap * ) map );
2010-08-06 19:23:43 +02:00
SCR_MAP_END ;
2009-09-13 00:01:35 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-07 13:07:18 +02:00
void ScriptMgr :: OnLoadGridMap ( Map * map , GridMap * gmap , uint32 gx , uint32 gy )
2009-09-13 00:01:35 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( map );
2010-08-07 17:58:45 +02:00
ASSERT ( gmap );
2010-08-06 19:23:43 +02:00
SCR_MAP_BGN ( WorldMapScript , map , itr , end , entry , IsContinent );
2010-08-07 13:07:18 +02:00
itr -> second -> OnLoadGridMap ( map , gmap , gx , gy );
2010-08-06 19:23:43 +02:00
SCR_MAP_END ;
SCR_MAP_BGN ( InstanceMapScript , map , itr , end , entry , IsDungeon );
2010-08-07 13:07:18 +02:00
itr -> second -> OnLoadGridMap (( InstanceMap * ) map , gmap , gx , gy );
2010-08-06 19:23:43 +02:00
SCR_MAP_END ;
2010-08-08 04:37:24 +02:00
SCR_MAP_BGN ( BattlegroundMapScript , map , itr , end , entry , IsBattleground );
itr -> second -> OnLoadGridMap (( BattlegroundMap * ) map , gmap , gx , gy );
2010-08-06 19:23:43 +02:00
SCR_MAP_END ;
2009-09-13 00:01:35 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-07 13:07:18 +02:00
void ScriptMgr :: OnUnloadGridMap ( Map * map , GridMap * gmap , uint32 gx , uint32 gy )
2009-09-13 00:01:35 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( map );
2010-08-07 17:58:45 +02:00
ASSERT ( gmap );
2010-08-06 19:23:43 +02:00
SCR_MAP_BGN ( WorldMapScript , map , itr , end , entry , IsContinent );
2010-08-07 13:07:18 +02:00
itr -> second -> OnUnloadGridMap ( map , gmap , gx , gy );
2010-08-06 19:23:43 +02:00
SCR_MAP_END ;
SCR_MAP_BGN ( InstanceMapScript , map , itr , end , entry , IsDungeon );
2010-08-07 13:07:18 +02:00
itr -> second -> OnUnloadGridMap (( InstanceMap * ) map , gmap , gx , gy );
2010-08-06 19:23:43 +02:00
SCR_MAP_END ;
2010-08-08 04:37:24 +02:00
SCR_MAP_BGN ( BattlegroundMapScript , map , itr , end , entry , IsBattleground );
itr -> second -> OnUnloadGridMap (( BattlegroundMap * ) map , gmap , gx , gy );
2010-08-06 19:23:43 +02:00
SCR_MAP_END ;
2009-09-13 00:01:35 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-07 13:07:18 +02:00
void ScriptMgr :: OnPlayerEnterMap ( Map * map , Player * player )
2009-09-23 20:19:21 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( map );
ASSERT ( player );
SCR_MAP_BGN ( WorldMapScript , map , itr , end , entry , IsContinent );
itr -> second -> OnPlayerEnter ( map , player );
SCR_MAP_END ;
SCR_MAP_BGN ( InstanceMapScript , map , itr , end , entry , IsDungeon );
itr -> second -> OnPlayerEnter (( InstanceMap * ) map , player );
SCR_MAP_END ;
2010-08-08 04:37:24 +02:00
SCR_MAP_BGN ( BattlegroundMapScript , map , itr , end , entry , IsBattleground );
itr -> second -> OnPlayerEnter (( BattlegroundMap * ) map , player );
2010-08-06 19:23:43 +02:00
SCR_MAP_END ;
2009-09-23 20:19:21 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-07 13:07:18 +02:00
void ScriptMgr :: OnPlayerLeaveMap ( Map * map , Player * player )
2009-09-23 20:19:21 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( map );
ASSERT ( player );
SCR_MAP_BGN ( WorldMapScript , map , itr , end , entry , IsContinent );
itr -> second -> OnPlayerLeave ( map , player );
SCR_MAP_END ;
SCR_MAP_BGN ( InstanceMapScript , map , itr , end , entry , IsDungeon );
itr -> second -> OnPlayerLeave (( InstanceMap * ) map , player );
SCR_MAP_END ;
2010-08-08 04:37:24 +02:00
SCR_MAP_BGN ( BattlegroundMapScript , map , itr , end , entry , IsBattleground );
itr -> second -> OnPlayerLeave (( BattlegroundMap * ) map , player );
2010-08-06 19:23:43 +02:00
SCR_MAP_END ;
2009-09-23 20:19:21 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnMapUpdate ( Map * map , uint32 diff )
2009-09-23 20:19:21 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( map );
SCR_MAP_BGN ( WorldMapScript , map , itr , end , entry , IsContinent );
itr -> second -> OnUpdate ( map , diff );
SCR_MAP_END ;
SCR_MAP_BGN ( InstanceMapScript , map , itr , end , entry , IsDungeon );
itr -> second -> OnUpdate (( InstanceMap * ) map , diff );
SCR_MAP_END ;
2010-08-08 04:37:24 +02:00
SCR_MAP_BGN ( BattlegroundMapScript , map , itr , end , entry , IsBattleground );
itr -> second -> OnUpdate (( BattlegroundMap * ) map , diff );
2010-08-06 19:23:43 +02:00
SCR_MAP_END ;
2009-09-23 20:19:21 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
#undef SCR_MAP_BGN
#undef SCR_MAP_END
2010-08-08 22:54:58 +06:00
InstanceScript * ScriptMgr :: CreateInstanceData ( InstanceMap * map )
2009-09-23 20:19:21 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( map );
GET_SCRIPT_RET ( InstanceMapScript , map -> GetScriptId (), tmpscript , NULL );
2010-08-08 22:54:58 +06:00
return tmpscript -> GetInstanceScript ( map );
2009-09-23 20:19:21 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnDummyEffect ( Unit * caster , uint32 spellId , SpellEffIndex effIndex , Item * target )
2009-09-23 20:19:21 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( caster );
ASSERT ( target );
2010-08-07 15:26:24 +02:00
GET_SCRIPT_RET ( ItemScript , target -> GetScriptId (), tmpscript , false );
2010-08-06 19:23:43 +02:00
return tmpscript -> OnDummyEffect ( caster , spellId , effIndex , target );
2009-09-23 20:19:21 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnQuestAccept ( Player * player , Item * item , Quest const * quest )
2009-09-23 20:19:21 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( item );
ASSERT ( quest );
2010-08-07 15:26:24 +02:00
GET_SCRIPT_RET ( ItemScript , item -> GetScriptId (), tmpscript , false );
2010-08-06 19:23:43 +02:00
player -> PlayerTalkClass -> ClearMenus ();
return tmpscript -> OnQuestAccept ( player , item , quest );
2009-09-23 20:19:21 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnItemUse ( Player * player , Item * item , SpellCastTargets const & targets )
2009-09-23 20:19:21 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( item );
2010-08-07 15:26:24 +02:00
GET_SCRIPT_RET ( ItemScript , item -> GetScriptId (), tmpscript , false );
2010-08-06 19:23:43 +02:00
return tmpscript -> OnUse ( player , item , targets );
2009-09-23 20:19:21 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnItemExpire ( Player * player , ItemPrototype const * proto )
2009-09-23 20:19:21 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( proto );
GET_SCRIPT_RET ( ItemScript , proto -> ScriptId , tmpscript , false );
return tmpscript -> OnExpire ( player , proto );
2009-09-23 20:19:21 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnDummyEffect ( Unit * caster , uint32 spellId , SpellEffIndex effIndex , Creature * target )
2009-09-23 20:19:21 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( caster );
ASSERT ( target );
GET_SCRIPT_RET ( CreatureScript , target -> GetScriptId (), tmpscript , false );
return tmpscript -> OnDummyEffect ( caster , spellId , effIndex , target );
2009-09-23 20:19:21 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnGossipHello ( Player * player , Creature * creature )
2009-09-23 20:19:21 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( creature );
GET_SCRIPT_RET ( CreatureScript , creature -> GetScriptId (), tmpscript , false );
player -> PlayerTalkClass -> ClearMenus ();
return tmpscript -> OnGossipHello ( player , creature );
2009-09-23 20:19:21 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnGossipSelect ( Player * player , Creature * creature , uint32 sender , uint32 action )
2009-09-23 20:19:21 -07:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( creature );
GET_SCRIPT_RET ( CreatureScript , creature -> GetScriptId (), tmpscript , false );
return tmpscript -> OnGossipSelect ( player , creature , sender , action );
2009-09-23 20:19:21 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnGossipSelectCode ( Player * player , Creature * creature , uint32 sender , uint32 action , const char * code )
2008-11-20 16:16:57 -06:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( creature );
ASSERT ( code );
GET_SCRIPT_RET ( CreatureScript , creature -> GetScriptId (), tmpscript , false );
return tmpscript -> OnGossipSelectCode ( player , creature , sender , action , code );
2008-11-20 16:16:57 -06:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnQuestAccept ( Player * player , Creature * creature , Quest const * quest )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( creature );
ASSERT ( quest );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT_RET ( CreatureScript , creature -> GetScriptId (), tmpscript , false );
player -> PlayerTalkClass -> ClearMenus ();
return tmpscript -> OnQuestAccept ( player , creature , quest );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnQuestSelect ( Player * player , Creature * creature , Quest const * quest )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( creature );
ASSERT ( quest );
GET_SCRIPT_RET ( CreatureScript , creature -> GetScriptId (), tmpscript , false );
player -> PlayerTalkClass -> ClearMenus ();
return tmpscript -> OnQuestSelect ( player , creature , quest );
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnQuestComplete ( Player * player , Creature * creature , Quest const * quest )
{
ASSERT ( player );
ASSERT ( creature );
ASSERT ( quest );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT_RET ( CreatureScript , creature -> GetScriptId (), tmpscript , false );
player -> PlayerTalkClass -> ClearMenus ();
return tmpscript -> OnQuestComplete ( player , creature , quest );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnQuestReward ( Player * player , Creature * creature , Quest const * quest , uint32 opt )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( creature );
ASSERT ( quest );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT_RET ( CreatureScript , creature -> GetScriptId (), tmpscript , false );
player -> PlayerTalkClass -> ClearMenus ();
return tmpscript -> OnQuestReward ( player , creature , quest , opt );
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
uint32 ScriptMgr :: GetDialogStatus ( Player * player , Creature * creature )
{
ASSERT ( player );
ASSERT ( creature );
// TODO: 100 is a funny magic number to have hanging around here...
GET_SCRIPT_RET ( CreatureScript , creature -> GetScriptId (), tmpscript , 100 );
player -> PlayerTalkClass -> ClearMenus ();
2010-08-07 13:07:18 +02:00
return tmpscript -> GetDialogStatus ( player , creature );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
CreatureAI * ScriptMgr :: GetCreatureAI ( Creature * creature )
2009-03-30 16:57:17 +02:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( creature );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT_RET ( CreatureScript , creature -> GetScriptId (), tmpscript , NULL );
2010-08-07 13:07:18 +02:00
return tmpscript -> GetAI ( creature );
2010-08-06 19:23:43 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnCreatureUpdate ( Creature * creature , uint32 diff )
{
ASSERT ( creature );
GET_SCRIPT ( CreatureScript , creature -> GetScriptId (), tmpscript );
tmpscript -> OnUpdate ( creature , diff );
2009-03-30 16:57:17 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnGossipHello ( Player * player , GameObject * go )
2009-03-30 16:57:17 +02:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( go );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT_RET ( GameObjectScript , go -> GetScriptId (), tmpscript , false );
player -> PlayerTalkClass -> ClearMenus ();
return tmpscript -> OnGossipHello ( player , go );
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnGossipSelect ( Player * player , GameObject * go , uint32 sender , uint32 action )
{
ASSERT ( player );
ASSERT ( go );
GET_SCRIPT_RET ( GameObjectScript , go -> GetScriptId (), tmpscript , false );
return tmpscript -> OnGossipSelect ( player , go , sender , action );
2009-03-30 16:57:17 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnGossipSelectCode ( Player * player , GameObject * go , uint32 sender , uint32 action , const char * code )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( go );
ASSERT ( code );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT_RET ( GameObjectScript , go -> GetScriptId (), tmpscript , false );
return tmpscript -> OnGossipSelectCode ( player , go , sender , action , code );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnQuestAccept ( Player * player , GameObject * go , Quest const * quest )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( go );
ASSERT ( quest );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT_RET ( GameObjectScript , go -> GetScriptId (), tmpscript , false );
player -> PlayerTalkClass -> ClearMenus ();
return tmpscript -> OnQuestAccept ( player , go , quest );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnQuestReward ( Player * player , GameObject * go , Quest const * quest , uint32 opt )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( go );
ASSERT ( quest );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT_RET ( GameObjectScript , go -> GetScriptId (), tmpscript , false );
player -> PlayerTalkClass -> ClearMenus ();
return tmpscript -> OnQuestReward ( player , go , quest , opt );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
uint32 ScriptMgr :: GetDialogStatus ( Player * player , GameObject * go )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( go );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
// TODO: 100 is a funny magic number to have hanging around here...
GET_SCRIPT_RET ( GameObjectScript , go -> GetScriptId (), tmpscript , 100 );
player -> PlayerTalkClass -> ClearMenus ();
2010-08-07 13:07:18 +02:00
return tmpscript -> GetDialogStatus ( player , go );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnGameObjectDestroyed ( Player * player , GameObject * go , uint32 eventId )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( go );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT ( GameObjectScript , go -> GetScriptId (), tmpscript );
tmpscript -> OnDestroyed ( player , go , eventId );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnGameObjectUpdate ( GameObject * go , uint32 diff )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( go );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT ( GameObjectScript , go -> GetScriptId (), tmpscript );
tmpscript -> OnUpdate ( go , diff );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnDummyEffect ( Unit * caster , uint32 spellId , SpellEffIndex effIndex , GameObject * target )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( caster );
ASSERT ( target );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT_RET ( GameObjectScript , target -> GetScriptId (), tmpscript , false );
return tmpscript -> OnDummyEffect ( caster , spellId , effIndex , target );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-07 13:07:18 +02:00
bool ScriptMgr :: OnAreaTrigger ( Player * player , AreaTriggerEntry const * trigger )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( player );
ASSERT ( trigger );
2010-08-26 16:22:59 +06:00
GET_SCRIPT_RET ( AreaTriggerScript , GetAreaTriggerScriptId ( trigger -> id ), tmpscript , false );
2010-08-06 19:23:43 +02:00
return tmpscript -> OnTrigger ( player , trigger );
}
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
Battleground * ScriptMgr :: CreateBattleground ( BattlegroundTypeId typeId )
2010-08-06 19:23:43 +02:00
{
// TODO: Implement script-side battlegrounds.
ASSERT ( false );
return NULL ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
OutdoorPvP * ScriptMgr :: CreateOutdoorPvP ( OutdoorPvPData const * data )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( data );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT_RET ( OutdoorPvPScript , data -> ScriptId , tmpscript , NULL );
2010-08-07 13:07:18 +02:00
return tmpscript -> GetOutdoorPvP ();
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
std :: vector < ChatCommand *> ScriptMgr :: GetChatCommands ()
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
std :: vector < ChatCommand *> table ;
FOR_SCRIPTS_RET ( CommandScript , itr , end , table )
2010-08-07 13:07:18 +02:00
table . push_back ( itr -> second -> GetCommands ());
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
return table ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnWeatherChange ( Weather * weather , WeatherState state , float grade )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( weather );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
GET_SCRIPT ( WeatherScript , weather -> GetScriptId (), tmpscript );
tmpscript -> OnChange ( weather , state , grade );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnWeatherUpdate ( Weather * weather , uint32 diff )
2010-06-03 14:29:04 +02:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( weather );
GET_SCRIPT ( WeatherScript , weather -> GetScriptId (), tmpscript );
tmpscript -> OnUpdate ( weather , diff );
2010-06-03 14:29:04 +02:00
}
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnAuctionAdd ( AuctionHouseObject * ah , AuctionEntry * entry )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( ah );
ASSERT ( entry );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
FOREACH_SCRIPT ( AuctionHouseScript ) -> OnAuctionAdd ( ah , entry );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 21:49:39 -07:00
void ScriptMgr :: OnAuctionRemove ( AuctionHouseObject * ah , AuctionEntry * entry )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( ah );
ASSERT ( entry );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
FOREACH_SCRIPT ( AuctionHouseScript ) -> OnAuctionRemove ( ah , entry );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnAuctionSuccessful ( AuctionHouseObject * ah , AuctionEntry * entry )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( ah );
ASSERT ( entry );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
FOREACH_SCRIPT ( AuctionHouseScript ) -> OnAuctionSuccessful ( ah , entry );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnAuctionExpire ( AuctionHouseObject * ah , AuctionEntry * entry )
2009-08-04 01:44:14 +02:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( ah );
ASSERT ( entry );
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
FOREACH_SCRIPT ( AuctionHouseScript ) -> OnAuctionExpire ( ah , entry );
2009-08-04 01:44:14 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
bool ScriptMgr :: OnConditionCheck ( Condition * condition , Player * player , Unit * targetOverride )
2008-10-11 14:16:25 -05:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( condition );
ASSERT ( player );
2010-08-07 17:58:45 +02:00
// targetOverride can be NULL.
2010-08-06 19:23:43 +02:00
GET_SCRIPT_RET ( ConditionScript , condition -> mScriptId , tmpscript , true );
return tmpscript -> OnConditionCheck ( condition , player , targetOverride );
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnInstall ( Vehicle * veh )
{
ASSERT ( veh );
2010-08-07 15:26:24 +02:00
ASSERT ( veh -> GetBase () -> GetTypeId () == TYPEID_UNIT );
2009-10-17 15:51:44 -07:00
2010-08-07 15:26:24 +02:00
GET_SCRIPT ( VehicleScript , veh -> GetBase () -> ToCreature () -> GetScriptId (), tmpscript );
tmpscript -> OnInstall ( veh );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnUninstall ( Vehicle * veh )
2009-03-13 20:34:36 -06:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( veh );
2010-08-07 15:26:24 +02:00
ASSERT ( veh -> GetBase () -> GetTypeId () == TYPEID_UNIT );
2009-10-17 15:51:44 -07:00
2010-08-07 15:26:24 +02:00
GET_SCRIPT ( VehicleScript , veh -> GetBase () -> ToCreature () -> GetScriptId (), tmpscript );
tmpscript -> OnUninstall ( veh );
2010-08-06 19:23:43 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnDie ( Vehicle * veh )
{
ASSERT ( veh );
2010-08-07 15:26:24 +02:00
ASSERT ( veh -> GetBase () -> GetTypeId () == TYPEID_UNIT );
2010-08-06 19:23:43 +02:00
2010-08-07 15:26:24 +02:00
GET_SCRIPT ( VehicleScript , veh -> GetBase () -> ToCreature () -> GetScriptId (), tmpscript );
tmpscript -> OnDie ( veh );
2009-03-13 20:34:36 -06:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnReset ( Vehicle * veh )
2009-03-13 20:34:36 -06:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( veh );
2010-08-07 15:26:24 +02:00
ASSERT ( veh -> GetBase () -> GetTypeId () == TYPEID_UNIT );
2010-08-06 19:23:43 +02:00
2010-08-07 15:26:24 +02:00
GET_SCRIPT ( VehicleScript , veh -> GetBase () -> ToCreature () -> GetScriptId (), tmpscript );
tmpscript -> OnReset ( veh );
2010-08-06 19:23:43 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnInstallAccessory ( Vehicle * veh , Creature * accessory )
{
ASSERT ( veh );
2010-08-07 15:26:24 +02:00
ASSERT ( veh -> GetBase () -> GetTypeId () == TYPEID_UNIT );
2010-08-06 19:23:43 +02:00
ASSERT ( accessory );
2009-10-17 15:51:44 -07:00
2010-08-07 15:26:24 +02:00
GET_SCRIPT ( VehicleScript , veh -> GetBase () -> ToCreature () -> GetScriptId (), tmpscript );
tmpscript -> OnInstallAccessory ( veh , accessory );
2009-03-13 20:34:36 -06:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnAddPassenger ( Vehicle * veh , Unit * passenger , int8 seatId )
2009-03-13 20:34:36 -06:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( veh );
2010-08-07 15:26:24 +02:00
ASSERT ( veh -> GetBase () -> GetTypeId () == TYPEID_UNIT );
2010-08-06 19:23:43 +02:00
ASSERT ( passenger );
2009-10-17 15:51:44 -07:00
2010-08-07 15:26:24 +02:00
GET_SCRIPT ( VehicleScript , veh -> GetBase () -> ToCreature () -> GetScriptId (), tmpscript );
tmpscript -> OnAddPassenger ( veh , passenger , seatId );
2010-08-06 19:23:43 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnRemovePassenger ( Vehicle * veh , Unit * passenger )
{
ASSERT ( veh );
2010-08-07 15:26:24 +02:00
ASSERT ( veh -> GetBase () -> GetTypeId () == TYPEID_UNIT );
2010-08-06 19:23:43 +02:00
ASSERT ( passenger );
2010-08-07 15:26:24 +02:00
GET_SCRIPT ( VehicleScript , veh -> GetBase () -> ToCreature () -> GetScriptId (), tmpscript );
tmpscript -> OnRemovePassenger ( veh , passenger );
2009-03-13 20:34:36 -06:00
}
2009-04-03 16:54:20 -06:00
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnDynamicObjectUpdate ( DynamicObject * dynobj , uint32 diff )
2010-07-24 22:41:42 +02:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( dynobj );
FOR_SCRIPTS ( DynamicObjectScript , itr , end )
itr -> second -> OnUpdate ( dynobj , diff );
2010-07-24 22:41:42 +02:00
}
2010-08-06 19:23:43 +02:00
void ScriptMgr :: OnAddPassenger ( Transport * transport , Player * player )
2010-07-24 22:41:42 +02:00
{
2010-08-06 19:23:43 +02:00
ASSERT ( transport );
ASSERT ( player );
GET_SCRIPT ( TransportScript , transport -> GetScriptId (), tmpscript );
tmpscript -> OnAddPassenger ( transport , player );
}
void ScriptMgr :: OnAddCreaturePassenger ( Transport * transport , Creature * creature )
{
ASSERT ( transport );
ASSERT ( creature );
GET_SCRIPT ( TransportScript , transport -> GetScriptId (), tmpscript );
tmpscript -> OnAddCreaturePassenger ( transport , creature );
}
void ScriptMgr :: OnRemovePassenger ( Transport * transport , Player * player )
{
ASSERT ( transport );
ASSERT ( player );
GET_SCRIPT ( TransportScript , transport -> GetScriptId (), tmpscript );
tmpscript -> OnRemovePassenger ( transport , player );
}
void ScriptMgr :: OnTransportUpdate ( Transport * transport , uint32 diff )
{
ASSERT ( transport );
GET_SCRIPT ( TransportScript , transport -> GetScriptId (), tmpscript );
tmpscript -> OnUpdate ( transport , diff );
}
2010-08-07 14:17:32 +02:00
void ScriptMgr :: OnRelocate ( Transport * transport , uint32 mapId , float x , float y , float z )
{
GET_SCRIPT ( TransportScript , transport -> GetScriptId (), tmpscript );
tmpscript -> OnRelocate ( transport , mapId , x , y , z );
}
2010-08-07 14:30:10 +02:00
void ScriptMgr :: OnStartup ()
{
FOREACH_SCRIPT ( WorldScript ) -> OnStartup ();
}
void ScriptMgr :: OnShutdown ()
{
FOREACH_SCRIPT ( WorldScript ) -> OnShutdown ();
}
2010-08-07 16:48:34 +02:00
bool ScriptMgr :: OnCriteriaCheck ( AchievementCriteriaData const * data , Player * source , Unit * target )
{
ASSERT ( source );
2010-08-07 17:58:45 +02:00
// target can be NULL.
2010-08-07 16:48:34 +02:00
GET_SCRIPT_RET ( AchievementCriteriaScript , data -> ScriptId , tmpscript , false );
return tmpscript -> OnCheck ( source , target );
}
2010-08-11 19:52:58 -07:00
void ScriptMgr :: OnPVPKill ( Player * killer , Player * killed )
{
FOREACH_SCRIPT ( PlayerScript ) -> OnPVPKill ( killer , killed );
}
void ScriptMgr :: OnCreatureKill ( Player * killer , Creature * killed )
{
FOREACH_SCRIPT ( PlayerScript ) -> OnCreatureKill ( killer , killed );
}
void ScriptMgr :: OnPlayerKilledByCreature ( Creature * killer , Player * killed )
{
FOREACH_SCRIPT ( PlayerScript ) -> OnPlayerKilledByCreature ( killer , killed );
}
void ScriptMgr :: OnPlayerLevelChanged ( Player * player , uint8 newLevel )
{
FOREACH_SCRIPT ( PlayerScript ) -> OnLevelChanged ( player , newLevel );
}
void ScriptMgr :: OnPlayerFreeTalentPointsChanged ( Player * player , uint32 points )
{
FOREACH_SCRIPT ( PlayerScript ) -> OnFreeTalentPointsChanged ( player , points );
}
void ScriptMgr :: OnPlayerTalentsReset ( Player * player , bool no_cost )
{
FOREACH_SCRIPT ( PlayerScript ) -> OnTalentsReset ( player , no_cost );
}
2010-08-11 22:53:31 -07:00
void ScriptMgr :: OnPlayerMoneyChanged ( Player * player , int32 & amount )
{
FOREACH_SCRIPT ( PlayerScript ) -> OnMoneyChanged ( player , amount );
}
void ScriptMgr :: OnGivePlayerXP ( Player * player , uint32 & amount , Unit * victim )
{
FOREACH_SCRIPT ( PlayerScript ) -> OnGiveXP ( player , amount , victim );
}
void ScriptMgr :: OnPlayerReputationChange ( Player * player , uint32 factionID , int32 & standing , bool incremental )
{
FOREACH_SCRIPT ( PlayerScript ) -> OnReputationChange ( player , factionID , standing , incremental );
}
2010-08-12 22:33:45 +06:00
void ScriptMgr :: OnPlayerChat ( Player * player , uint32 type , uint32 lang , std :: string msg , void * param )
2010-08-11 22:53:31 -07:00
{
2010-08-12 22:33:45 +06:00
FOREACH_SCRIPT ( PlayerScript ) -> OnChat ( player , type , lang , msg , param );
2010-08-11 22:53:31 -07:00
}
2010-08-12 22:33:45 +06:00
void ScriptMgr :: OnPlayerEmote ( Player * player , uint32 emote )
2010-08-11 22:53:31 -07:00
{
2010-08-12 22:33:45 +06:00
FOREACH_SCRIPT ( PlayerScript ) -> OnEmote ( player , emote );
2010-08-11 22:53:31 -07:00
}
2010-08-12 22:33:45 +06:00
void ScriptMgr :: OnPlayerTextEmote ( Player * player , uint32 text_emote , uint32 emoteNum , uint64 guid )
2010-08-11 22:53:31 -07:00
{
2010-08-12 22:33:45 +06:00
FOREACH_SCRIPT ( PlayerScript ) -> OnTextEmote ( player , text_emote , emoteNum , guid );
2010-08-11 22:53:31 -07:00
}
2010-08-14 12:17:05 -07:00
void ScriptMgr :: OnGuildAddMember ( Guild * guild , Player * player , uint32 & plRank )
{
FOREACH_SCRIPT ( GuildScript ) -> OnAddMember ( guild , player , plRank );
}
void ScriptMgr :: OnGuildRemoveMember ( Guild * guild , Player * player , bool isDisbanding , bool isKicked )
{
FOREACH_SCRIPT ( GuildScript ) -> OnRemoveMember ( guild , player , isDisbanding , isKicked );
}
void ScriptMgr :: OnGuildMOTDChanged ( Guild * guild , std :: string newMotd )
{
FOREACH_SCRIPT ( GuildScript ) -> OnMOTDChanged ( guild , newMotd );
}
void ScriptMgr :: OnGuildInfoChanged ( Guild * guild , std :: string newGInfo )
{
FOREACH_SCRIPT ( GuildScript ) -> OnGInfoChanged ( guild , newGInfo );
}
void ScriptMgr :: OnGuildDisband ( Guild * guild )
{
FOREACH_SCRIPT ( GuildScript ) -> OnDisband ( guild );
}
2010-08-24 00:10:49 +02:00
SpellScriptLoader :: SpellScriptLoader ( const char * name )
2010-08-09 19:53:21 +02:00
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
2010-08-24 00:10:49 +02:00
ScriptMgr :: ScriptRegistry < SpellScriptLoader >:: AddScript ( this );
2010-08-06 19:23:43 +02:00
}
2010-08-09 19:53:21 +02:00
ServerScript :: ServerScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < ServerScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
WorldScript :: WorldScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < WorldScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
FormulaScript :: FormulaScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < FormulaScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
WorldMapScript :: WorldMapScript ( const char * name , uint32 mapId )
: ScriptObject ( name ), MapScript < Map > ( mapId )
2010-08-06 19:23:43 +02:00
{
2010-08-09 19:53:21 +02:00
if ( GetEntry () && ! GetEntry () -> IsContinent ())
sLog . outError ( "WorldMapScript for map %u is invalid." , mapId );
2010-08-06 19:23:43 +02:00
ScriptMgr :: ScriptRegistry < WorldMapScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
InstanceMapScript :: InstanceMapScript ( const char * name , uint32 mapId )
2010-08-09 16:07:03 -05:00
: ScriptObject ( name ), MapScript < InstanceMap > ( mapId )
2010-08-06 19:23:43 +02:00
{
2010-08-09 19:53:21 +02:00
if ( GetEntry () && ! GetEntry () -> IsDungeon ())
sLog . outError ( "InstanceMapScript for map %u is invalid." , mapId );
2010-08-06 19:23:43 +02:00
ScriptMgr :: ScriptRegistry < InstanceMapScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
BattlegroundMapScript :: BattlegroundMapScript ( const char * name , uint32 mapId )
: ScriptObject ( name ), MapScript < BattlegroundMap > ( mapId )
2010-08-06 19:23:43 +02:00
{
2010-08-09 19:53:21 +02:00
if ( GetEntry () && ! GetEntry () -> IsBattleground ())
sLog . outError ( "BattlegroundMapScript for map %u is invalid." , mapId );
2010-08-06 19:23:43 +02:00
2010-08-09 19:53:21 +02:00
ScriptMgr :: ScriptRegistry < BattlegroundMapScript >:: AddScript ( this );
2010-08-06 19:23:43 +02:00
}
2010-08-09 19:53:21 +02:00
ItemScript :: ItemScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < ItemScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
CreatureScript :: CreatureScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < CreatureScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
GameObjectScript :: GameObjectScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < GameObjectScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
AreaTriggerScript :: AreaTriggerScript ( const char * name )
: ScriptObject ( name )
{
ScriptMgr :: ScriptRegistry < AreaTriggerScript >:: AddScript ( this );
}
BattlegroundScript :: BattlegroundScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < BattlegroundScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
OutdoorPvPScript :: OutdoorPvPScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < OutdoorPvPScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
CommandScript :: CommandScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < CommandScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
WeatherScript :: WeatherScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < WeatherScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
AuctionHouseScript :: AuctionHouseScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < AuctionHouseScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
ConditionScript :: ConditionScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < ConditionScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
VehicleScript :: VehicleScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < VehicleScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
DynamicObjectScript :: DynamicObjectScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < DynamicObjectScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
TransportScript :: TransportScript ( const char * name )
: ScriptObject ( name )
2010-08-06 19:23:43 +02:00
{
ScriptMgr :: ScriptRegistry < TransportScript >:: AddScript ( this );
}
2010-08-09 19:53:21 +02:00
AchievementCriteriaScript :: AchievementCriteriaScript ( const char * name )
: ScriptObject ( name )
2010-08-07 16:48:34 +02:00
{
ScriptMgr :: ScriptRegistry < AchievementCriteriaScript >:: AddScript ( this );
}
2010-08-11 19:52:58 -07:00
PlayerScript :: PlayerScript ( const char * name )
: ScriptObject ( name )
{
ScriptMgr :: ScriptRegistry < PlayerScript >:: AddScript ( this );
}
2010-08-14 12:42:05 -07:00
GuildScript :: GuildScript ( const char * name )
: ScriptObject ( name )
{
ScriptMgr :: ScriptRegistry < GuildScript >:: AddScript ( this );
}
2010-08-06 19:23:43 +02:00
// Instantiate static members of ScriptMgr::ScriptRegistry.
template < class TScript > std :: map < uint32 , TScript *> ScriptMgr :: ScriptRegistry < TScript >:: ScriptPointerList ;
2010-08-09 16:07:03 -05:00
template < class TScript > uint32 ScriptMgr :: ScriptRegistry < TScript >:: _scriptIdCounter = 0 ;
2010-08-06 19:23:43 +02:00
// Specialize for each script type class like so:
2010-08-24 00:10:49 +02:00
template class ScriptMgr :: ScriptRegistry < SpellScriptLoader > ;
2010-08-06 19:23:43 +02:00
template class ScriptMgr :: ScriptRegistry < ServerScript > ;
template class ScriptMgr :: ScriptRegistry < WorldScript > ;
template class ScriptMgr :: ScriptRegistry < FormulaScript > ;
template class ScriptMgr :: ScriptRegistry < WorldMapScript > ;
template class ScriptMgr :: ScriptRegistry < InstanceMapScript > ;
template class ScriptMgr :: ScriptRegistry < BattlegroundMapScript > ;
template class ScriptMgr :: ScriptRegistry < ItemScript > ;
template class ScriptMgr :: ScriptRegistry < CreatureScript > ;
template class ScriptMgr :: ScriptRegistry < GameObjectScript > ;
template class ScriptMgr :: ScriptRegistry < AreaTriggerScript > ;
template class ScriptMgr :: ScriptRegistry < BattlegroundScript > ;
template class ScriptMgr :: ScriptRegistry < OutdoorPvPScript > ;
template class ScriptMgr :: ScriptRegistry < CommandScript > ;
template class ScriptMgr :: ScriptRegistry < WeatherScript > ;
template class ScriptMgr :: ScriptRegistry < AuctionHouseScript > ;
template class ScriptMgr :: ScriptRegistry < ConditionScript > ;
template class ScriptMgr :: ScriptRegistry < VehicleScript > ;
template class ScriptMgr :: ScriptRegistry < DynamicObjectScript > ;
template class ScriptMgr :: ScriptRegistry < TransportScript > ;
2010-08-07 16:48:34 +02:00
template class ScriptMgr :: ScriptRegistry < AchievementCriteriaScript > ;
2010-08-06 19:23:43 +02:00
// Undefine utility macros.
#undef GET_SCRIPT_RET
#undef GET_SCRIPT
#undef FOREACH_SCRIPT
#undef FOR_SCRIPTS_RET
#undef FOR_SCRIPTS
#undef SCR_REG_LST
2010-08-07 15:26:24 +02:00
#undef SCR_REG_ITR
2010-08-06 19:23:43 +02:00
#undef SCR_REG_MAP