2008-10-11 14:16:25 -05:00
/* Copyright (C) 2006 - 2008 TrinityScript <https://scriptdev2.svn.sourceforge.net/>
* This program is free software licensed under GPL version 2
* Please see the included DOCS/LICENSE.TXT for more information */
# include "precompiled.h"
# include "Config/Config.h"
# include "Database/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"
# include "scripts/creature/mob_event_ai.h"
# define _FULLVERSION "TrinityScript"
# ifndef _TRINITY_SCRIPT_CONFIG
2008-10-12 17:35:16 -05:00
# define _TRINITY_SCRIPT_CONFIG "trinitycore.conf"
# endif _TRINITY_SCRIPT_CONFIG
2008-10-11 14:16:25 -05:00
2008-11-20 16:16:57 -06:00
int num_sc_scripts ;
2008-10-11 14:16:25 -05:00
Script * m_scripts [ MAX_SCRIPTS ] ;
DatabaseType TScriptDB ;
Config TScriptConfig ;
// String text additional data, used in TextMap
struct StringTextData
{
uint32 SoundId ;
uint8 Type ;
uint32 Language ;
2009-02-09 08:16:34 -05:00
uint32 Emote ;
2008-10-11 14:16:25 -05:00
} ;
// Enums used by StringTextData::Type
enum ChatType
{
CHAT_TYPE_SAY = 0 ,
CHAT_TYPE_YELL = 1 ,
CHAT_TYPE_TEXT_EMOTE = 2 ,
CHAT_TYPE_BOSS_EMOTE = 3 ,
CHAT_TYPE_WHISPER = 4 ,
CHAT_TYPE_BOSS_WHISPER = 5 ,
} ;
2008-10-25 11:40:10 -05:00
# define TEXT_SOURCE_RANGE -1000000 //the amount of entries each text source has available
2008-10-11 14:16:25 -05:00
// Text Maps
2008-11-10 06:53:00 -06:00
UNORDERED_MAP < int32 , StringTextData > TextMap ;
2008-10-11 14:16:25 -05:00
2009-03-22 23:11:55 +01:00
// Waypoint lists
std : : list < PointMovement > PointMovementList ;
2008-10-11 14:16:25 -05:00
//Event AI structure. Used exclusivly by mob_event_ai.cpp (60 bytes each)
2009-03-23 15:22:24 -06:00
UNORDERED_MAP < uint32 , std : : vector < EventAI_Event > > EventAI_Event_Map ;
2008-10-11 14:16:25 -05:00
//Event AI summon structure. Used exclusivly by mob_event_ai.cpp.
2008-11-10 06:53:00 -06:00
UNORDERED_MAP < uint32 , EventAI_Summon > EventAI_Summon_Map ;
2008-10-11 14:16:25 -05:00
uint32 EAI_ErrorLevel ;
void FillSpellSummary ( ) ;
2009-02-05 15:38:24 -06:00
void LoadOverridenSQLData ( ) ;
void LoadOverridenDBCData ( ) ;
2008-10-11 14:16:25 -05:00
// -- Scripts to be added --
// -- Areatrigger --
extern void AddSC_areatrigger_scripts ( ) ;
// -- Boss --
extern void AddSC_boss_emeriss ( ) ;
extern void AddSC_boss_taerar ( ) ;
extern void AddSC_boss_ysondre ( ) ;
// -- Creature --
extern void AddSC_mob_event ( ) ;
extern void AddSC_generic_creature ( ) ;
// -- Custom --
2009-02-17 18:08:26 +01:00
// -- Examples --
extern void AddSC_example_creature ( ) ;
extern void AddSC_example_escort ( ) ;
extern void AddSC_example_gossip_codebox ( ) ;
extern void AddSC_example_misc ( ) ;
2008-10-11 14:16:25 -05:00
// -- GO --
extern void AddSC_go_scripts ( ) ;
// -- Guard --
extern void AddSC_guards ( ) ;
// -- Honor --
// -- Item --
extern void AddSC_item_scripts ( ) ;
// -- NPC --
extern void AddSC_npc_professions ( ) ;
extern void AddSC_npcs_special ( ) ;
// -- Servers --
//--------------------
//------ ZONE --------
//Alterac Mountains
extern void AddSC_alterac_mountains ( ) ;
//Arathi Highlands
2008-12-27 21:29:09 +01:00
extern void AddSC_arathi_highlands ( ) ;
2008-10-11 14:16:25 -05:00
//Ashenvale Forest
2008-12-13 19:56:53 +01:00
extern void AddSC_ashenvale ( ) ;
2008-10-11 14:16:25 -05:00
//Aunchindoun
//--Auchenai Crypts
extern void AddSC_boss_exarch_maladaar ( ) ;
2008-12-30 01:50:43 +01:00
extern void AddSC_boss_shirrak_the_dead_watcher ( ) ;
2008-10-11 14:16:25 -05:00
//--Mana Tombs
extern void AddSC_boss_nexusprince_shaffar ( ) ;
extern void AddSC_boss_pandemonius ( ) ;
//--Sekketh Halls
extern void AddSC_boss_darkweaver_syth ( ) ;
extern void AddSC_boss_talon_king_ikiss ( ) ;
extern void AddSC_instance_sethekk_halls ( ) ;
//--Shadow Labyrinth
extern void AddSC_boss_ambassador_hellmaw ( ) ;
extern void AddSC_boss_blackheart_the_inciter ( ) ;
extern void AddSC_boss_grandmaster_vorpil ( ) ;
extern void AddSC_boss_murmur ( ) ;
extern void AddSC_instance_shadow_labyrinth ( ) ;
//Azshara
extern void AddSC_boss_azuregos ( ) ;
extern void AddSC_azshara ( ) ;
//Azuremyst Isle
extern void AddSC_azuremyst_isle ( ) ;
//Badlands
//Barrens
extern void AddSC_the_barrens ( ) ;
//Black Temple
extern void AddSC_black_temple ( ) ;
extern void AddSC_boss_illidan ( ) ;
extern void AddSC_boss_shade_of_akama ( ) ;
extern void AddSC_boss_supremus ( ) ;
extern void AddSC_boss_gurtogg_bloodboil ( ) ;
extern void AddSC_boss_mother_shahraz ( ) ;
extern void AddSC_boss_reliquary_of_souls ( ) ;
extern void AddSC_boss_teron_gorefiend ( ) ;
extern void AddSC_boss_najentus ( ) ;
extern void AddSC_boss_illidari_council ( ) ;
extern void AddSC_instance_black_temple ( ) ;
//Blackfathom Depths
//Blackrock Depths
extern void AddSC_blackrock_depths ( ) ;
extern void AddSC_boss_ambassador_flamelash ( ) ;
extern void AddSC_boss_anubshiah ( ) ;
extern void AddSC_boss_draganthaurissan ( ) ;
extern void AddSC_boss_general_angerforge ( ) ;
extern void AddSC_boss_gorosh_the_dervish ( ) ;
extern void AddSC_boss_grizzle ( ) ;
extern void AddSC_boss_high_interrogator_gerstahn ( ) ;
extern void AddSC_boss_magmus ( ) ;
extern void AddSC_boss_moira_bronzebeard ( ) ;
2009-01-18 19:48:01 +01:00
extern void AddSC_boss_tomb_of_seven ( ) ;
extern void AddSC_instance_blackrock_depths ( ) ;
2008-10-11 14:16:25 -05:00
//Blackrock Spire
extern void AddSC_boss_drakkisath ( ) ;
extern void AddSC_boss_halycon ( ) ;
extern void AddSC_boss_highlordomokk ( ) ;
extern void AddSC_boss_mothersmolderweb ( ) ;
extern void AddSC_boss_overlordwyrmthalak ( ) ;
extern void AddSC_boss_shadowvosh ( ) ;
extern void AddSC_boss_thebeast ( ) ;
extern void AddSC_boss_warmastervoone ( ) ;
extern void AddSC_boss_quatermasterzigris ( ) ;
extern void AddSC_boss_pyroguard_emberseer ( ) ;
extern void AddSC_boss_gyth ( ) ;
extern void AddSC_boss_rend_blackhand ( ) ;
//Blackwing lair
extern void AddSC_boss_razorgore ( ) ;
extern void AddSC_boss_vael ( ) ;
extern void AddSC_boss_broodlord ( ) ;
extern void AddSC_boss_firemaw ( ) ;
extern void AddSC_boss_ebonroc ( ) ;
extern void AddSC_boss_flamegor ( ) ;
extern void AddSC_boss_chromaggus ( ) ;
extern void AddSC_boss_nefarian ( ) ;
extern void AddSC_boss_victor_nefarius ( ) ;
//Blade's Edge Mountains
extern void AddSC_blades_edge_mountains ( ) ;
//Blasted lands
extern void AddSC_boss_kruul ( ) ;
extern void AddSC_blasted_lands ( ) ;
//Bloodmyst Isle
extern void AddSC_bloodmyst_isle ( ) ;
2009-02-05 10:46:43 +01:00
//Borean Tundra
extern void AddSC_borean_tundra ( ) ;
2008-10-11 14:16:25 -05:00
//Burning steppes
extern void AddSC_burning_steppes ( ) ;
//Caverns of Time
//--Battle for Mt. Hyjal
extern void AddSC_hyjal ( ) ;
extern void AddSC_boss_archimonde ( ) ;
extern void AddSC_instance_mount_hyjal ( ) ;
//--Old Hillsbrad
extern void AddSC_boss_captain_skarloc ( ) ;
extern void AddSC_boss_epoch_hunter ( ) ;
extern void AddSC_boss_lieutenant_drake ( ) ;
extern void AddSC_instance_old_hillsbrad ( ) ;
extern void AddSC_old_hillsbrad ( ) ;
//--The Dark Portal
extern void AddSC_boss_aeonus ( ) ;
extern void AddSC_boss_chrono_lord_deja ( ) ;
extern void AddSC_boss_temporus ( ) ;
2008-12-15 18:54:16 +01:00
extern void AddSC_dark_portal ( ) ;
extern void AddSC_instance_dark_portal ( ) ;
2008-10-11 14:16:25 -05:00
//Coilfang Resevoir
//--Serpent Shrine Cavern
extern void AddSC_boss_fathomlord_karathress ( ) ;
extern void AddSC_boss_hydross_the_unstable ( ) ;
extern void AddSC_boss_lady_vashj ( ) ;
extern void AddSC_boss_leotheras_the_blind ( ) ;
extern void AddSC_boss_morogrim_tidewalker ( ) ;
extern void AddSC_instance_serpentshrine_cavern ( ) ;
2008-11-07 10:03:34 -06:00
extern void AddSC_boss_the_lurker_below ( ) ;
2008-10-11 14:16:25 -05:00
//--Slave Pens
//--Steam Vault
extern void AddSC_boss_hydromancer_thespia ( ) ;
extern void AddSC_boss_mekgineer_steamrigger ( ) ;
extern void AddSC_boss_warlord_kalithresh ( ) ;
extern void AddSC_instance_steam_vault ( ) ;
//--Underbog
extern void AddSC_boss_hungarfen ( ) ;
2009-02-08 11:43:53 +01:00
extern void AddSC_boss_the_black_stalker ( ) ;
2008-10-11 14:16:25 -05:00
//Darkshore
//Darnassus
//Deadmines
2008-12-01 18:32:00 -06:00
extern void AddSC_instance_deadmines ( ) ;
2008-10-11 14:16:25 -05:00
//Deadwind pass
//Desolace
//Dire Maul
//Dun Morogh
extern void AddSC_dun_morogh ( ) ;
//Durotar
//Duskwood
//Dustwallow marsh
extern void AddSC_dustwallow_marsh ( ) ;
//Eversong Woods
extern void AddSC_eversong_woods ( ) ;
//Exodar
//Eastern Plaguelands
extern void AddSC_eastern_plaguelands ( ) ;
//Elwynn Forest
extern void AddSC_elwynn_forest ( ) ;
//Felwood
extern void AddSC_felwood ( ) ;
//Feralas
extern void AddSC_feralas ( ) ;
//Ghostlands
extern void AddSC_ghostlands ( ) ;
//Gnomeregan
//Gruul's Lair
extern void AddSC_boss_gruul ( ) ;
extern void AddSC_boss_high_king_maulgar ( ) ;
extern void AddSC_instance_gruuls_lair ( ) ;
//Hellfire Citadel
//--Blood Furnace
extern void AddSC_boss_broggok ( ) ;
extern void AddSC_boss_kelidan_the_breaker ( ) ;
extern void AddSC_boss_the_maker ( ) ;
2009-01-21 17:27:28 +01:00
extern void AddSC_instance_blood_furnace ( ) ;
2008-10-11 14:16:25 -05:00
//--Magtheridon's Lair
extern void AddSC_boss_magtheridon ( ) ;
extern void AddSC_instance_magtheridons_lair ( ) ;
//--Shattered Halls
extern void AddSC_boss_grand_warlock_nethekurse ( ) ;
extern void AddSC_boss_warbringer_omrogg ( ) ;
2008-11-26 19:14:03 +01:00
extern void AddSC_boss_warchief_kargath_bladefist ( ) ;
2008-10-11 14:16:25 -05:00
extern void AddSC_instance_shattered_halls ( ) ;
//--Ramparts
extern void AddSC_boss_watchkeeper_gargolmar ( ) ;
extern void AddSC_boss_omor_the_unscarred ( ) ;
2009-01-23 20:34:30 +01:00
extern void AddSC_boss_vazruden_the_herald ( ) ;
2008-10-11 14:16:25 -05:00
//Hellfire Peninsula
extern void AddSC_boss_doomlordkazzak ( ) ;
extern void AddSC_hellfire_peninsula ( ) ;
//Hillsbrad Foothills
//Hinterlands
//Ironforge
extern void AddSC_ironforge ( ) ;
//Isle of Quel'Danas
extern void AddSC_isle_of_queldanas ( ) ;
//Karazhan
extern void AddSC_boss_attumen ( ) ;
extern void AddSC_boss_curator ( ) ;
extern void AddSC_boss_maiden_of_virtue ( ) ;
extern void AddSC_boss_shade_of_aran ( ) ;
extern void AddSC_boss_malchezaar ( ) ;
extern void AddSC_boss_terestian_illhoof ( ) ;
extern void AddSC_boss_moroes ( ) ;
extern void AddSC_bosses_opera ( ) ;
extern void AddSC_instance_karazhan ( ) ;
extern void AddSC_karazhan ( ) ;
2009-01-02 15:20:51 +01:00
extern void AddSC_boss_nightbane ( ) ;
2008-10-11 14:16:25 -05:00
//Loch Modan
extern void AddSC_loch_modan ( ) ;
//Lower Blackrock Spire
// Magister's Terrace
extern void AddSC_boss_felblood_kaelthas ( ) ;
extern void AddSC_boss_selin_fireheart ( ) ;
extern void AddSC_boss_vexallus ( ) ;
extern void AddSC_boss_priestess_delrissa ( ) ;
extern void AddSC_instance_magisters_terrace ( ) ;
//Maraudon
extern void AddSC_boss_celebras_the_cursed ( ) ;
extern void AddSC_boss_landslide ( ) ;
extern void AddSC_boss_noxxion ( ) ;
extern void AddSC_boss_ptheradras ( ) ;
//Molten core
extern void AddSC_boss_lucifron ( ) ;
extern void AddSC_boss_magmadar ( ) ;
extern void AddSC_boss_gehennas ( ) ;
extern void AddSC_boss_garr ( ) ;
extern void AddSC_boss_baron_geddon ( ) ;
extern void AddSC_boss_shazzrah ( ) ;
extern void AddSC_boss_golemagg ( ) ;
extern void AddSC_boss_sulfuron ( ) ;
extern void AddSC_boss_majordomo ( ) ;
extern void AddSC_boss_ragnaros ( ) ;
extern void AddSC_instance_molten_core ( ) ;
extern void AddSC_molten_core ( ) ;
//Moonglade
extern void AddSC_moonglade ( ) ;
//Mulgore
extern void AddSC_mulgore ( ) ;
//Nagrand
extern void AddSC_nagrand ( ) ;
//Naxxramas
extern void AddSC_boss_anubrekhan ( ) ;
extern void AddSC_boss_maexxna ( ) ;
extern void AddSC_boss_patchwerk ( ) ;
extern void AddSC_boss_razuvious ( ) ;
extern void AddSC_boss_kelthuzad ( ) ;
extern void AddSC_boss_loatheb ( ) ;
extern void AddSC_boss_noth ( ) ;
extern void AddSC_boss_gluth ( ) ;
extern void AddSC_boss_sapphiron ( ) ;
2009-01-02 22:24:07 +01:00
extern void AddSC_boss_four_horsemen ( ) ;
extern void AddSC_boss_faerlina ( ) ;
2008-10-11 14:16:25 -05:00
//Netherstorm
extern void AddSC_netherstorm ( ) ;
//Onyxia's Lair
extern void AddSC_boss_onyxia ( ) ;
//Orgrimmar
extern void AddSC_orgrimmar ( ) ;
//Ragefire Chasm
//Razorfen Downs
extern void AddSC_boss_amnennar_the_coldbringer ( ) ;
2008-12-27 22:46:01 +01:00
//Razorfen Kraul
extern void AddSC_razorfen_kraul ( ) ;
2008-10-11 14:16:25 -05:00
//Redridge Mountains
//Ruins of Ahn'Qiraj
//Scarlet Monastery
extern void AddSC_boss_arcanist_doan ( ) ;
extern void AddSC_boss_azshir_the_sleepless ( ) ;
extern void AddSC_boss_bloodmage_thalnos ( ) ;
2008-12-08 17:30:52 -06:00
extern void AddSC_boss_headless_horseman ( ) ;
2008-10-11 14:16:25 -05:00
extern void AddSC_boss_herod ( ) ;
extern void AddSC_boss_high_inquisitor_fairbanks ( ) ;
extern void AddSC_boss_houndmaster_loksey ( ) ;
extern void AddSC_boss_interrogator_vishas ( ) ;
extern void AddSC_boss_scorn ( ) ;
2008-12-08 17:30:52 -06:00
extern void AddSC_instance_scarlet_monastery ( ) ;
2008-12-13 19:56:53 +01:00
extern void AddSC_boss_mograine_and_whitemane ( ) ;
2008-10-11 14:16:25 -05:00
//Scholomance
extern void AddSC_boss_darkmaster_gandling ( ) ;
extern void AddSC_boss_death_knight_darkreaver ( ) ;
extern void AddSC_boss_theolenkrastinov ( ) ;
extern void AddSC_boss_illuciabarov ( ) ;
extern void AddSC_boss_instructormalicia ( ) ;
extern void AddSC_boss_jandicebarov ( ) ;
extern void AddSC_boss_kormok ( ) ;
extern void AddSC_boss_lordalexeibarov ( ) ;
extern void AddSC_boss_lorekeeperpolkelt ( ) ;
extern void AddSC_boss_rasfrost ( ) ;
extern void AddSC_boss_theravenian ( ) ;
extern void AddSC_boss_vectus ( ) ;
extern void AddSC_instance_scholomance ( ) ;
//Searing gorge
extern void AddSC_searing_gorge ( ) ;
//Shadowfang keep
extern void AddSC_shadowfang_keep ( ) ;
extern void AddSC_instance_shadowfang_keep ( ) ;
//Shadowmoon Valley
extern void AddSC_boss_doomwalker ( ) ;
extern void AddSC_shadowmoon_valley ( ) ;
//Shattrath
extern void AddSC_shattrath_city ( ) ;
//Silithus
extern void AddSC_silithus ( ) ;
//Silvermoon
extern void AddSC_silvermoon_city ( ) ;
//Silverpine forest
extern void AddSC_silverpine_forest ( ) ;
//Stockade
//Stonetalon mountains
extern void AddSC_stonetalon_mountains ( ) ;
//Stormwind City
extern void AddSC_stormwind_city ( ) ;
//Stranglethorn Vale
extern void AddSC_stranglethorn_vale ( ) ;
//Stratholme
extern void AddSC_boss_magistrate_barthilas ( ) ;
extern void AddSC_boss_maleki_the_pallid ( ) ;
extern void AddSC_boss_nerubenkan ( ) ;
extern void AddSC_boss_cannon_master_willey ( ) ;
extern void AddSC_boss_baroness_anastari ( ) ;
extern void AddSC_boss_ramstein_the_gorger ( ) ;
extern void AddSC_boss_timmy_the_cruel ( ) ;
extern void AddSC_boss_postmaster_malown ( ) ;
extern void AddSC_boss_baron_rivendare ( ) ;
extern void AddSC_boss_dathrohan_balnazzar ( ) ;
extern void AddSC_boss_order_of_silver_hand ( ) ;
extern void AddSC_instance_stratholme ( ) ;
extern void AddSC_stratholme ( ) ;
//Sunken Temple
2008-10-20 14:02:13 -05:00
//Sunwell Plateau
extern void AddSC_instance_sunwell_plateau ( ) ;
extern void AddSC_boss_kalecgos ( ) ;
extern void AddSC_boss_brutallus ( ) ;
extern void AddSC_boss_felmyst ( ) ;
extern void AddSC_boss_eredar_twins ( ) ;
2008-10-11 14:16:25 -05:00
//Tanaris
extern void AddSC_tanaris ( ) ;
//Teldrassil
//Tempest Keep
//--Arcatraz
extern void AddSC_arcatraz ( ) ;
extern void AddSC_boss_harbinger_skyriss ( ) ;
extern void AddSC_instance_arcatraz ( ) ;
//--Botanica
extern void AddSC_boss_high_botanist_freywinn ( ) ;
extern void AddSC_boss_laj ( ) ;
extern void AddSC_boss_warp_splinter ( ) ;
//--The Eye
2008-10-20 14:02:13 -05:00
extern void AddSC_boss_alar ( ) ;
2008-10-11 14:16:25 -05:00
extern void AddSC_boss_kaelthas ( ) ;
extern void AddSC_boss_void_reaver ( ) ;
extern void AddSC_boss_high_astromancer_solarian ( ) ;
extern void AddSC_instance_the_eye ( ) ;
extern void AddSC_the_eye ( ) ;
//--The Mechanar
extern void AddSC_boss_gatewatcher_iron_hand ( ) ;
extern void AddSC_boss_nethermancer_sepethrea ( ) ;
2008-11-13 17:12:54 -06:00
extern void AddSC_boss_pathaleon_the_calculator ( ) ;
extern void AddSC_instance_mechanar ( ) ;
2008-10-11 14:16:25 -05:00
//Temple of ahn'qiraj
extern void AddSC_boss_cthun ( ) ;
extern void AddSC_boss_fankriss ( ) ;
extern void AddSC_boss_huhuran ( ) ;
extern void AddSC_bug_trio ( ) ;
extern void AddSC_boss_sartura ( ) ;
extern void AddSC_boss_skeram ( ) ;
extern void AddSC_boss_twinemperors ( ) ;
extern void AddSC_mob_anubisath_sentinel ( ) ;
extern void AddSC_instance_temple_of_ahnqiraj ( ) ;
//Terokkar Forest
extern void AddSC_terokkar_forest ( ) ;
//Thousand Needles
2009-01-04 17:11:24 +01:00
extern void AddSC_thousand_needles ( ) ;
2008-10-11 14:16:25 -05:00
//Thunder Bluff
extern void AddSC_thunder_bluff ( ) ;
//Tirisfal Glades
extern void AddSC_tirisfal_glades ( ) ;
//Uldaman
2008-12-08 16:57:49 -06:00
extern void AddSC_boss_archaedas ( ) ;
2008-10-11 14:16:25 -05:00
extern void AddSC_boss_ironaya ( ) ;
extern void AddSC_uldaman ( ) ;
2008-12-08 16:57:49 -06:00
extern void AddSC_instance_uldaman ( ) ;
2008-10-11 14:16:25 -05:00
//Undercity
extern void AddSC_undercity ( ) ;
//Un'Goro Crater
2009-01-09 19:55:26 +01:00
extern void AddSC_ungoro_crater ( ) ;
2008-10-11 14:16:25 -05:00
//Upper blackrock spire
2009-02-11 00:57:39 +01:00
//Utgarde Keep
extern void AddSC_boss_keleseth ( ) ;
2009-02-28 22:39:05 +01:00
extern void AddSC_boss_skarvald_dalronn ( ) ;
2009-03-08 00:13:03 +01:00
extern void AddSC_boss_ingvar_the_plunderer ( ) ;
2009-02-11 13:13:43 +01:00
extern void AddSC_instance_utgarde_keep ( ) ;
2009-02-11 00:57:39 +01:00
2008-10-11 14:16:25 -05:00
//Wailing caverns
//Western plaguelands
extern void AddSC_western_plaguelands ( ) ;
//Westfall
2008-11-04 15:37:18 -06:00
extern void AddSC_westfall ( ) ;
2008-10-11 14:16:25 -05:00
//Wetlands
//Winterspring
extern void AddSC_winterspring ( ) ;
//Zangarmarsh
extern void AddSC_zangarmarsh ( ) ;
//Zul'Farrak
2008-12-15 18:54:16 +01:00
extern void AddSC_zulfarrak ( ) ;
2008-10-11 14:16:25 -05:00
//Zul'Gurub
extern void AddSC_boss_jeklik ( ) ;
extern void AddSC_boss_venoxis ( ) ;
extern void AddSC_boss_marli ( ) ;
extern void AddSC_boss_mandokir ( ) ;
extern void AddSC_boss_gahzranka ( ) ;
extern void AddSC_boss_thekal ( ) ;
extern void AddSC_boss_arlokk ( ) ;
extern void AddSC_boss_jindo ( ) ;
extern void AddSC_boss_hakkar ( ) ;
extern void AddSC_boss_grilek ( ) ;
extern void AddSC_boss_hazzarah ( ) ;
extern void AddSC_boss_renataki ( ) ;
extern void AddSC_boss_wushoolay ( ) ;
extern void AddSC_instance_zulgurub ( ) ;
2008-10-17 21:44:37 -05:00
2008-10-11 14:16:25 -05:00
//Zul'Aman
2008-10-17 21:44:37 -05:00
extern void AddSC_boss_akilzon ( ) ;
extern void AddSC_boss_halazzi ( ) ;
extern void AddSC_boss_hex_lord_malacrass ( ) ;
2008-10-11 14:16:25 -05:00
extern void AddSC_boss_janalai ( ) ;
extern void AddSC_boss_nalorakk ( ) ;
2008-10-17 21:44:37 -05:00
extern void AddSC_boss_zuljin ( ) ;
2008-10-11 14:16:25 -05:00
extern void AddSC_instance_zulaman ( ) ;
extern void AddSC_zulaman ( ) ;
// -------------------
void LoadDatabase ( )
{
//Get db string from file
2009-03-18 20:32:17 -06:00
std : : string dbstring = TScriptConfig . GetStringDefault ( " WorldDatabaseInfo " , " " ) ;
2008-10-11 14:16:25 -05:00
2009-03-18 20:46:39 +01:00
if ( dbstring . empty ( ) )
2008-10-11 14:16:25 -05:00
{
2008-10-12 17:35:16 -05:00
error_log ( " TSCR: Missing world database info from configuration file. Load database aborted. " ) ;
2008-10-11 14:16:25 -05:00
return ;
}
//Initialize connection to DB
2009-03-18 20:46:39 +01:00
if ( ! dbstring . empty ( ) & & TScriptDB . Initialize ( dbstring . c_str ( ) ) )
outstring_log ( " TSCR: TrinityScript database: %s " , dbstring . c_str ( ) ) ;
2008-10-11 14:16:25 -05:00
else
{
error_log ( " TSCR: Unable to connect to Database. Load database aborted. " ) ;
return ;
}
//***Preform all DB queries here***
QueryResult * result ;
//Get Version information
2009-01-19 17:38:03 +01:00
result = TScriptDB . PQuery ( " SELECT script_version FROM version LIMIT 1 " ) ;
2008-10-11 14:16:25 -05:00
if ( result )
{
Field * fields = result - > Fetch ( ) ;
outstring_log ( " TSCR: Database version is: %s " , fields [ 0 ] . GetString ( ) ) ;
outstring_log ( " " ) ;
delete result ;
} else
{
2009-01-19 17:38:03 +01:00
error_log ( " TSCR: Missing `version.script_version` information. " ) ;
2008-10-11 14:16:25 -05:00
outstring_log ( " " ) ;
}
// Drop Existing Text Map, only done once and we are ready to add data from multiple sources.
TextMap . clear ( ) ;
2009-02-04 10:33:18 -06:00
// Load EventAI Text
2008-10-25 11:40:10 -05:00
outstring_log ( " TSCR: Loading EventAI Texts... " ) ;
LoadTrinityStrings ( TScriptDB , " eventai_texts " , - 1 , 1 + ( TEXT_SOURCE_RANGE ) ) ;
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
// Gather Additional data from EventAI Texts
2009-02-17 18:08:26 +01:00
result = TScriptDB . PQuery ( " SELECT entry, sound, type, language, emote FROM eventai_texts " ) ;
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
outstring_log ( " TSCR: Loading EventAI Texts additional data... " ) ;
2008-10-11 14:16:25 -05:00
if ( result )
{
barGoLink bar ( result - > GetRowCount ( ) ) ;
uint32 count = 0 ;
do
{
bar . step ( ) ;
Field * fields = result - > Fetch ( ) ;
StringTextData temp ;
int32 i = fields [ 0 ] . GetInt32 ( ) ;
temp . SoundId = fields [ 1 ] . GetInt32 ( ) ;
temp . Type = fields [ 2 ] . GetInt32 ( ) ;
temp . Language = fields [ 3 ] . GetInt32 ( ) ;
2009-02-17 18:08:26 +01:00
temp . Emote = fields [ 4 ] . GetInt32 ( ) ;
2008-10-11 14:16:25 -05:00
if ( i > = 0 )
{
2008-10-25 11:40:10 -05:00
error_db_log ( " TSCR: Entry %i in table `eventai_texts` is not a negative value. " , i ) ;
2008-10-11 14:16:25 -05:00
continue ;
}
2008-10-25 11:40:10 -05:00
if ( i < = TEXT_SOURCE_RANGE )
2008-10-11 14:16:25 -05:00
{
2008-10-25 11:40:10 -05:00
error_db_log ( " TSCR: Entry %i in table `eventai_texts` is out of accepted entry range for table. " , i ) ;
2008-10-11 14:16:25 -05:00
continue ;
}
if ( temp . SoundId )
{
if ( ! GetSoundEntriesStore ( ) - > LookupEntry ( temp . SoundId ) )
2008-10-25 11:40:10 -05:00
error_db_log ( " TSCR: Entry %i in table `eventai_texts` has soundId %u but sound does not exist. " , i , temp . SoundId ) ;
2008-10-11 14:16:25 -05:00
}
if ( ! GetLanguageDescByID ( temp . Language ) )
2008-10-25 11:40:10 -05:00
error_db_log ( " TSCR: Entry %i in table `eventai_texts` using Language %u but Language does not exist. " , i , temp . Language ) ;
2008-10-11 14:16:25 -05:00
if ( temp . Type > CHAT_TYPE_BOSS_WHISPER )
2008-10-25 11:40:10 -05:00
error_db_log ( " TSCR: Entry %i in table `eventai_texts` has Type %u but this Chat Type does not exist. " , i , temp . Type ) ;
2008-10-11 14:16:25 -05:00
TextMap [ i ] = temp ;
+ + count ;
} while ( result - > NextRow ( ) ) ;
delete result ;
outstring_log ( " " ) ;
2008-10-25 11:40:10 -05:00
outstring_log ( " >> TSCR: Loaded %u additional EventAI Texts data. " , count ) ;
2008-10-11 14:16:25 -05:00
} else
{
barGoLink bar ( 1 ) ;
bar . step ( ) ;
outstring_log ( " " ) ;
2008-10-25 11:40:10 -05:00
outstring_log ( " >> Loaded 0 additional EventAI Texts data. DB table `eventai_texts` is empty. " ) ;
2008-10-11 14:16:25 -05:00
}
2009-02-04 10:33:18 -06:00
// Load Script Text
2008-10-25 11:40:10 -05:00
outstring_log ( " TSCR: Loading Script Texts... " ) ;
LoadTrinityStrings ( TScriptDB , " script_texts " , TEXT_SOURCE_RANGE , 1 + ( TEXT_SOURCE_RANGE * 2 ) ) ;
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
// Gather Additional data from Script Texts
2008-12-31 12:22:16 -06:00
result = TScriptDB . PQuery ( " SELECT entry, sound, type, language, emote FROM script_texts " ) ;
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
outstring_log ( " TSCR: Loading Script Texts additional data... " ) ;
2008-10-11 14:16:25 -05:00
if ( result )
{
barGoLink bar ( result - > GetRowCount ( ) ) ;
uint32 count = 0 ;
do
{
bar . step ( ) ;
Field * fields = result - > Fetch ( ) ;
StringTextData temp ;
int32 i = fields [ 0 ] . GetInt32 ( ) ;
temp . SoundId = fields [ 1 ] . GetInt32 ( ) ;
temp . Type = fields [ 2 ] . GetInt32 ( ) ;
temp . Language = fields [ 3 ] . GetInt32 ( ) ;
2009-02-09 08:16:34 -05:00
temp . Emote = fields [ 4 ] . GetInt32 ( ) ;
2008-10-11 14:16:25 -05:00
if ( i > = 0 )
{
2008-10-25 11:40:10 -05:00
error_db_log ( " TSCR: Entry %i in table `script_texts` is not a negative value. " , i ) ;
2008-10-11 14:16:25 -05:00
continue ;
}
2008-10-25 11:40:10 -05:00
if ( i > TEXT_SOURCE_RANGE | | i < = TEXT_SOURCE_RANGE * 2 )
2008-10-11 14:16:25 -05:00
{
2008-10-25 11:40:10 -05:00
error_db_log ( " TSCR: Entry %i in table `script_texts` is out of accepted entry range for table. " , i ) ;
2008-10-11 14:16:25 -05:00
continue ;
}
if ( temp . SoundId )
{
if ( ! GetSoundEntriesStore ( ) - > LookupEntry ( temp . SoundId ) )
2008-10-25 11:40:10 -05:00
error_db_log ( " TSCR: Entry %i in table `script_texts` has soundId %u but sound does not exist. " , i , temp . SoundId ) ;
2008-10-11 14:16:25 -05:00
}
if ( ! GetLanguageDescByID ( temp . Language ) )
2008-10-25 11:40:10 -05:00
error_db_log ( " TSCR: Entry %i in table `script_texts` using Language %u but Language does not exist. " , i , temp . Language ) ;
2008-10-11 14:16:25 -05:00
if ( temp . Type > CHAT_TYPE_BOSS_WHISPER )
2008-10-25 11:40:10 -05:00
error_db_log ( " TSCR: Entry %i in table `script_texts` has Type %u but this Chat Type does not exist. " , i , temp . Type ) ;
2008-10-11 14:16:25 -05:00
TextMap [ i ] = temp ;
+ + count ;
} while ( result - > NextRow ( ) ) ;
delete result ;
outstring_log ( " " ) ;
2008-10-25 11:40:10 -05:00
outstring_log ( " >> TSCR: Loaded %u additional Script Texts data. " , count ) ;
2008-10-11 14:16:25 -05:00
} else
{
barGoLink bar ( 1 ) ;
bar . step ( ) ;
outstring_log ( " " ) ;
2008-10-25 11:40:10 -05:00
outstring_log ( " >> Loaded 0 additional Script Texts data. DB table `script_texts` is empty. " ) ;
2008-10-11 14:16:25 -05:00
}
2009-02-04 10:33:18 -06:00
// Load Custom Text
2008-10-25 11:40:10 -05:00
outstring_log ( " TSCR: Loading Custom Texts... " ) ;
LoadTrinityStrings ( TScriptDB , " custom_texts " , TEXT_SOURCE_RANGE * 2 , 1 + ( TEXT_SOURCE_RANGE * 3 ) ) ;
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
// Gather Additional data from Custom Texts
2008-12-31 12:33:54 +01:00
result = TScriptDB . PQuery ( " SELECT entry, sound, type, language, emote FROM custom_texts " ) ;
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
outstring_log ( " TSCR: Loading Custom Texts additional data... " ) ;
if ( result )
2008-10-11 14:16:25 -05:00
{
barGoLink bar ( result - > GetRowCount ( ) ) ;
uint32 count = 0 ;
do
{
bar . step ( ) ;
2008-10-25 11:40:10 -05:00
Field * fields = result - > Fetch ( ) ;
StringTextData temp ;
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
int32 i = fields [ 0 ] . GetInt32 ( ) ;
temp . SoundId = fields [ 1 ] . GetInt32 ( ) ;
temp . Type = fields [ 2 ] . GetInt32 ( ) ;
temp . Language = fields [ 3 ] . GetInt32 ( ) ;
2009-02-09 08:16:34 -05:00
temp . Emote = fields [ 4 ] . GetInt32 ( ) ;
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
if ( i > = 0 )
{
error_db_log ( " TSCR: Entry %i in table `custom_texts` is not a negative value. " , i ) ;
continue ;
}
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
if ( i > TEXT_SOURCE_RANGE * 2 | | i < = TEXT_SOURCE_RANGE * 3 )
{
error_db_log ( " TSCR: Entry %i in table `custom_texts` is out of accepted entry range for table. " , i ) ;
continue ;
}
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
if ( temp . SoundId )
{
if ( ! GetSoundEntriesStore ( ) - > LookupEntry ( temp . SoundId ) )
error_db_log ( " TSCR: Entry %i in table `custom_texts` has soundId %u but sound does not exist. " , i , temp . SoundId ) ;
}
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
if ( ! GetLanguageDescByID ( temp . Language ) )
error_db_log ( " TSCR: Entry %i in table `custom_texts` using Language %u but Language does not exist. " , i , temp . Language ) ;
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
if ( temp . Type > CHAT_TYPE_BOSS_WHISPER )
error_db_log ( " TSCR: Entry %i in table `custom_texts` has Type %u but this Chat Type does not exist. " , i , temp . Type ) ;
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
TextMap [ i ] = temp ;
+ + count ;
} while ( result - > NextRow ( ) ) ;
2008-10-11 14:16:25 -05:00
delete result ;
outstring_log ( " " ) ;
2008-10-25 11:40:10 -05:00
outstring_log ( " >> Loaded %u additional Custom Texts data. " , count ) ;
2008-10-11 14:16:25 -05:00
} else
{
barGoLink bar ( 1 ) ;
bar . step ( ) ;
outstring_log ( " " ) ;
2008-10-25 11:40:10 -05:00
outstring_log ( " >> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty. " ) ;
2008-10-11 14:16:25 -05:00
}
2009-03-23 15:22:24 -06:00
2009-03-22 23:11:55 +01:00
// Drop Existing Waypoint list
PointMovementList . clear ( ) ;
uint64 uiCreatureCount = 0 ;
// Load Waypoints
result = TScriptDB . PQuery ( " SELECT COUNT(entry) FROM script_waypoint GROUP BY entry " ) ;
if ( result )
{
uiCreatureCount = result - > GetRowCount ( ) ;
delete result ;
}
outstring_log ( " SD2: Loading Script Waypoints for %u creature(s)... " , uiCreatureCount ) ;
result = TScriptDB . PQuery ( " SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid " ) ;
if ( result )
{
barGoLink bar ( result - > GetRowCount ( ) ) ;
uint32 uiNodeCount = 0 ;
do
{
bar . step ( ) ;
Field * pFields = result - > Fetch ( ) ;
PointMovement pTemp ;
pTemp . m_uiCreatureEntry = pFields [ 0 ] . GetUInt32 ( ) ;
pTemp . m_uiPointId = pFields [ 1 ] . GetUInt32 ( ) ;
pTemp . m_fX = pFields [ 2 ] . GetFloat ( ) ;
pTemp . m_fY = pFields [ 3 ] . GetFloat ( ) ;
pTemp . m_fZ = pFields [ 4 ] . GetFloat ( ) ;
pTemp . m_uiWaitTime = pFields [ 5 ] . GetUInt32 ( ) ;
CreatureInfo const * pCInfo = GetCreatureTemplateStore ( pTemp . m_uiCreatureEntry ) ;
if ( ! pCInfo )
{
error_db_log ( " SD2: DB table script_waypoint has waypoint for non-existant creature entry %u " , pTemp . m_uiCreatureEntry ) ;
continue ;
}
if ( ! pCInfo - > ScriptID )
error_db_log ( " SD2: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless. " , pTemp . m_uiCreatureEntry ) ;
PointMovementList . push_back ( pTemp ) ;
+ + uiNodeCount ;
} while ( result - > NextRow ( ) ) ;
delete result ;
outstring_log ( " " ) ;
outstring_log ( " >> Loaded %u Script Waypoint nodes. " , uiNodeCount ) ;
}
else
{
barGoLink bar ( 1 ) ;
bar . step ( ) ;
outstring_log ( " " ) ;
outstring_log ( " >> Loaded 0 Script Waypoints. DB table `script_waypoint` is empty. " ) ;
}
2008-10-11 14:16:25 -05:00
2008-10-25 11:40:10 -05:00
//Gather additional data for EventAI
2008-10-11 14:16:25 -05:00
result = TScriptDB . PQuery ( " SELECT id, position_x, position_y, position_z, orientation, spawntimesecs FROM eventai_summons " ) ;
//Drop Existing EventSummon Map
EventAI_Summon_Map . clear ( ) ;
2008-10-25 11:40:10 -05:00
outstring_log ( " TSCR: Loading EventAI Summons... " ) ;
2008-10-11 14:16:25 -05:00
if ( result )
{
barGoLink bar ( result - > GetRowCount ( ) ) ;
uint32 Count = 0 ;
do
{
bar . step ( ) ;
Field * fields = result - > Fetch ( ) ;
EventAI_Summon temp ;
uint32 i = fields [ 0 ] . GetUInt32 ( ) ;
temp . position_x = fields [ 1 ] . GetFloat ( ) ;
temp . position_y = fields [ 2 ] . GetFloat ( ) ;
temp . position_z = fields [ 3 ] . GetFloat ( ) ;
temp . orientation = fields [ 4 ] . GetFloat ( ) ;
temp . SpawnTimeSecs = fields [ 5 ] . GetUInt32 ( ) ;
//Add to map
EventAI_Summon_Map [ i ] = temp ;
+ + Count ;
} while ( result - > NextRow ( ) ) ;
delete result ;
outstring_log ( " " ) ;
outstring_log ( " >> Loaded %u EventAI summon definitions " , Count ) ;
} else
{
barGoLink bar ( 1 ) ;
bar . step ( ) ;
outstring_log ( " " ) ;
outstring_log ( " >> Loaded 0 EventAI Summon definitions. DB table `eventai_summons` is empty. " ) ;
}
2009-03-21 19:33:10 +01:00
//Drop Existing EventAI List
2009-03-23 15:22:24 -06:00
EventAI_Event_Map . clear ( ) ;
2009-03-21 19:33:10 +01:00
uint64 uiEAICreatureCount = 0 ;
result = TScriptDB . PQuery ( " SELECT COUNT(creature_id) FROM eventai_scripts GROUP BY creature_id " ) ;
if ( result )
{
uiEAICreatureCount = result - > GetRowCount ( ) ;
delete result ;
}
2009-03-22 23:11:55 +01:00
outstring_log ( " SD2: Loading EventAI scripts for %u creature(s)... " , uiEAICreatureCount ) ;
2009-03-21 19:33:10 +01:00
2008-10-11 14:16:25 -05:00
//Gather event data
result = TScriptDB . PQuery ( " SELECT id, creature_id, event_type, event_inverse_phase_mask, event_chance, event_flags, "
" event_param1, event_param2, event_param3, event_param4, "
" action1_type, action1_param1, action1_param2, action1_param3, "
" action2_type, action2_param1, action2_param2, action2_param3, "
" action3_type, action3_param1, action3_param2, action3_param3 "
" FROM eventai_scripts " ) ;
2009-03-21 19:33:10 +01:00
outstring_log ( " SD2: Loading EventAI scripts for %u creature(s)... " , uiEAICreatureCount ) ;
2008-10-11 14:16:25 -05:00
if ( result )
{
barGoLink bar ( result - > GetRowCount ( ) ) ;
uint32 Count = 0 ;
do
{
bar . step ( ) ;
Field * fields = result - > Fetch ( ) ;
EventAI_Event temp ;
temp . event_id = fields [ 0 ] . GetUInt32 ( ) ;
uint32 i = temp . event_id ;
temp . creature_id = fields [ 1 ] . GetUInt32 ( ) ;
2009-03-23 15:22:24 -06:00
uint32 creature_id = temp . creature_id ;
2008-10-11 14:16:25 -05:00
temp . event_type = fields [ 2 ] . GetUInt16 ( ) ;
temp . event_inverse_phase_mask = fields [ 3 ] . GetUInt32 ( ) ;
temp . event_chance = fields [ 4 ] . GetUInt8 ( ) ;
temp . event_flags = fields [ 5 ] . GetUInt8 ( ) ;
temp . event_param1 = fields [ 6 ] . GetUInt32 ( ) ;
temp . event_param2 = fields [ 7 ] . GetUInt32 ( ) ;
temp . event_param3 = fields [ 8 ] . GetUInt32 ( ) ;
temp . event_param4 = fields [ 9 ] . GetUInt32 ( ) ;
2009-02-20 14:14:16 +01:00
//Creature does not exist in database
if ( ! GetCreatureTemplateStore ( temp . creature_id ) )
2009-03-21 19:33:10 +01:00
{
2009-03-13 17:14:02 -06:00
error_db_log ( " TSCR: Event %u has script for non-existing creature. " , i ) ;
2009-03-21 19:33:10 +01:00
continue ;
}
2009-02-20 14:14:16 +01:00
2008-10-11 14:16:25 -05:00
//Report any errors in event
if ( temp . event_type > = EVENT_T_END )
2009-03-21 19:33:10 +01:00
{
2008-10-11 14:16:25 -05:00
error_db_log ( " TSCR: Event %u has incorrect event type. Maybe DB requires updated version of SD2. " , i ) ;
2009-03-21 19:33:10 +01:00
continue ;
}
2008-10-11 14:16:25 -05:00
//No chance of this event occuring
if ( temp . event_chance = = 0 )
error_db_log ( " TSCR: Event %u has 0 percent chance. Event will never trigger! " , i ) ;
//Chance above 100, force it to be 100
if ( temp . event_chance > 100 )
{
error_db_log ( " TSCR: Creature %u are using event %u with more than 100 percent chance. Adjusting to 100 percent. " , temp . creature_id , i ) ;
temp . event_chance = 100 ;
}
//Individual event checks
switch ( temp . event_type )
{
case EVENT_T_HP :
case EVENT_T_MANA :
case EVENT_T_TARGET_HP :
{
if ( temp . event_param2 > 100 )
error_db_log ( " TSCR: Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! " , temp . creature_id , i ) ;
if ( temp . event_param1 < = temp . event_param2 )
error_db_log ( " TSCR: Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! " , temp . creature_id , i ) ;
if ( temp . event_flags & EFLAG_REPEATABLE & & ! temp . event_param3 & & ! temp . event_param4 )
{
error_db_log ( " TSCR: Creature %u has param3 and param4=0 (RepeatMin/RepeatMax) but cannot be repeatable without timers. Removing EFLAG_REPEATABLE for event %u. " , temp . creature_id , i ) ;
temp . event_flags & = ~ EFLAG_REPEATABLE ;
}
}
break ;
case EVENT_T_SPELLHIT :
{
if ( temp . event_param1 )
{
SpellEntry const * pSpell = GetSpellStore ( ) - > LookupEntry ( temp . event_param1 ) ;
if ( ! pSpell )
{
error_db_log ( " TSCR: Creature %u has non-existant SpellID(%u) defined in event %u. " , temp . creature_id , temp . event_param1 , i ) ;
continue ;
}
if ( temp . event_param2_s ! = - 1 & & temp . event_param2 ! = pSpell - > SchoolMask )
error_db_log ( " TSCR: Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger. " , temp . creature_id , temp . event_param1 , i ) ;
}
//TODO: fix this system with SPELL_SCHOOL_MASK. Current complicate things, using int32(-1) instead of just 0
//SPELL_SCHOOL_MASK_NONE = 0 and does not exist, thus it can not ever trigger or be used in SpellHit()
if ( temp . event_param2_s ! = - 1 & & temp . event_param2_s > SPELL_SCHOOL_MASK_ALL )
error_db_log ( " TSCR: Creature %u is using invalid SpellSchoolMask(%u) defined in event %u. " , temp . creature_id , temp . event_param2 , i ) ;
if ( temp . event_param4 < temp . event_param3 )
error_db_log ( " TSCR: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat. " , temp . creature_id , i ) ;
}
break ;
2009-03-23 15:22:24 -06:00
2009-03-21 07:56:52 +01:00
case EVENT_T_OOC_LOS :
{
2009-03-23 15:22:24 -06:00
if ( temp . event_param2 > VISIBLE_RANGE | | temp . event_param2 < = 0 )
{
error_db_log ( " SD2: Creature %u are using event(%u), but param2 (MaxAllowedRange=%u) are not within allowed range. " , temp . creature_id , i , temp . event_param2 ) ;
temp . event_param2 = VISIBLE_RANGE ;
}
if ( temp . event_param3 = = 0 & & temp . event_param4 = = 0 & & temp . event_flags & EFLAG_REPEATABLE )
{
error_db_log ( " SD2: Creature %u are using event(%u) with EFLAG_REPEATABLE, but param3(RepeatMin) and param4(RepeatMax) are 0. Repeatable disabled. " , temp . creature_id , i ) ;
temp . event_flags & = ~ EFLAG_REPEATABLE ;
}
if ( temp . event_param4 < temp . event_param3 )
error_db_log ( " SD2: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat. " , temp . creature_id , i ) ;
2009-03-21 07:56:52 +01:00
}
2009-03-23 15:22:24 -06:00
break ;
2008-10-11 14:16:25 -05:00
2009-03-23 15:22:24 -06:00
case EVENT_T_RANGE :
2008-10-11 14:16:25 -05:00
case EVENT_T_FRIENDLY_HP :
case EVENT_T_FRIENDLY_IS_CC :
2009-03-21 19:33:10 +01:00
{
if ( temp . event_param4 < temp . event_param3 )
error_db_log ( " SD2: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat. " , temp . creature_id , i ) ;
}
break ;
2009-03-23 15:22:24 -06:00
2008-10-11 14:16:25 -05:00
case EVENT_T_FRIENDLY_MISSING_BUFF :
{
2009-03-21 19:33:10 +01:00
if ( ! GetSpellStore ( ) - > LookupEntry ( temp . event_param1 ) )
{
error_db_log ( " SD2: Creature %u has non-existant SpellID(%u) defined in event %u. " , temp . creature_id , temp . event_param1 , i ) ;
continue ;
}
2008-10-11 14:16:25 -05:00
if ( temp . event_param4 < temp . event_param3 )
error_db_log ( " TSCR: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat. " , temp . creature_id , i ) ;
}
break ;
case EVENT_T_TIMER :
case EVENT_T_TIMER_OOC :
{
if ( temp . event_param2 < temp . event_param1 )
error_db_log ( " TSCR: Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat. " , temp . creature_id , i ) ;
if ( temp . event_param4 < temp . event_param3 )
error_db_log ( " TSCR: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat. " , temp . creature_id , i ) ;
}
break ;
case EVENT_T_KILL :
case EVENT_T_TARGET_CASTING :
{
if ( temp . event_param2 < temp . event_param1 )
error_db_log ( " TSCR: Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat. " , temp . creature_id , i ) ;
}
break ;
2009-03-21 19:33:10 +01:00
case EVENT_T_SUMMONED_UNIT :
{
if ( ! GetCreatureTemplateStore ( temp . event_param1 ) )
{
error_db_log ( " SD2: Creature %u has non-existant creature entry (%u) defined in event %u. " , temp . creature_id , temp . event_param1 , i ) ;
continue ;
}
}
break ;
2008-10-11 14:16:25 -05:00
case EVENT_T_AGGRO :
case EVENT_T_DEATH :
case EVENT_T_EVADE :
2009-03-23 15:22:24 -06:00
case EVENT_T_SPAWNED :
2009-02-20 14:14:16 +01:00
case EVENT_T_REACHED_HOME :
2008-10-11 14:16:25 -05:00
{
if ( temp . event_flags & EFLAG_REPEATABLE )
{
error_db_log ( " TSCR: Creature %u has EFLAG_REPEATABLE set. Event can never be repeatable. Removing flag for event %u. " , temp . creature_id , i ) ;
temp . event_flags & = ~ EFLAG_REPEATABLE ;
}
}
break ;
2009-03-21 19:33:10 +01:00
case EVENT_T_RECEIVE_EMOTE :
{
//no good way to check for valid textEmote (enum TextEmotes)
switch ( temp . event_param2 )
{
case CONDITION_AURA :
if ( ! GetSpellStore ( ) - > LookupEntry ( temp . event_param3 ) )
{
error_db_log ( " SD2: Creature %u using event %u: param3 (CondValue1: %u) are not valid. " , temp . creature_id , i , temp . event_param3 ) ;
continue ;
}
break ;
case CONDITION_TEAM :
if ( temp . event_param3 ! = HORDE | | temp . event_param3 ! = ALLIANCE )
{
error_db_log ( " SD2: Creature %u using event %u: param3 (CondValue1: %u) are not valid. " , temp . creature_id , i , temp . event_param3 ) ;
continue ;
}
break ;
case CONDITION_QUESTREWARDED :
case CONDITION_QUESTTAKEN :
if ( ! GetQuestTemplateStore ( temp . event_param3 ) )
{
error_db_log ( " SD2: Creature %u using event %u: param3 (CondValue1: %u) are not valid. " , temp . creature_id , i , temp . event_param3 ) ;
continue ;
}
break ;
case CONDITION_ACTIVE_EVENT :
if ( temp . event_param3 ! =
( HOLIDAY_FIREWORKS_SPECTACULAR | HOLIDAY_FEAST_OF_WINTER_VEIL | HOLIDAY_NOBLEGARDEN |
HOLIDAY_CHILDRENS_WEEK | HOLIDAY_CALL_TO_ARMS_AV | HOLIDAY_CALL_TO_ARMS_WG |
HOLIDAY_CALL_TO_ARMS_AB | HOLIDAY_FISHING_EXTRAVAGANZA | HOLIDAY_HARVEST_FESTIVAL |
HOLIDAY_HALLOWS_END | HOLIDAY_LUNAR_FESTIVAL | HOLIDAY_LOVE_IS_IN_THE_AIR |
HOLIDAY_FIRE_FESTIVAL | HOLIDAY_CALL_TO_ARMS_ES | HOLIDAY_BREWFEST |
HOLIDAY_DARKMOON_FAIRE_ELWYNN | HOLIDAY_DARKMOON_FAIRE_THUNDER | HOLIDAY_DARKMOON_FAIRE_SHATTRATH |
HOLIDAY_CALL_TO_ARMS_SA | HOLIDAY_WOTLK_LAUNCH ) )
{
error_db_log ( " SD2: Creature %u using event %u: param3 (CondValue1: %u) are not valid. " , temp . creature_id , i , temp . event_param3 ) ;
continue ;
}
break ;
case CONDITION_REPUTATION_RANK :
if ( ! temp . event_param3 )
{
error_db_log ( " SD2: Creature %u using event %u: param3 (CondValue1: %u) are missing. " , temp . creature_id , i , temp . event_param3 ) ;
continue ;
}
if ( temp . event_param4 > REP_EXALTED )
{
error_db_log ( " SD2: Creature %u using event %u: param4 (CondValue2: %u) are not valid. " , temp . creature_id , i , temp . event_param4 ) ;
continue ;
}
break ;
case CONDITION_ITEM :
case CONDITION_ITEM_EQUIPPED :
case CONDITION_SKILL :
if ( ! temp . event_param3 )
{
error_db_log ( " SD2: Creature %u using event %u: param3 (CondValue1: %u) are missing. " , temp . creature_id , i , temp . event_param3 ) ;
continue ;
}
if ( ! temp . event_param4 )
{
error_db_log ( " SD2: Creature %u using event %u: param4 (CondValue2: %u) are missing. " , temp . creature_id , i , temp . event_param4 ) ;
continue ;
}
break ;
case CONDITION_ZONEID :
if ( ! temp . event_param3 )
{
error_db_log ( " SD2: Creature %u using event %u: param3 (CondValue1: %u) are missing. " , temp . creature_id , i , temp . event_param3 ) ;
continue ;
}
break ;
case CONDITION_NONE :
2009-03-23 15:22:24 -06:00
break ;
2009-03-21 19:33:10 +01:00
default :
{
error_db_log ( " SD2: Creature %u using event %u: param2 (Condition: %u) are not valid/not implemented for script. " , temp . creature_id , i , temp . event_param3 ) ;
continue ;
}
}
if ( ! ( temp . event_flags & EFLAG_REPEATABLE ) )
{
error_db_log ( " SD2: Creature %u using event %u: EFLAG_REPEATABLE not set. Event must always be repeatable. Flag applied. " , temp . creature_id , i ) ;
temp . event_flags | = EFLAG_REPEATABLE ;
}
}
break ;
case EVENT_T_QUEST_ACCEPT :
case EVENT_T_QUEST_COMPLETE :
{
error_db_log ( " SD2: Creature %u using not implemented event (%u) in event %u. " , temp . creature_id , temp . event_id , i ) ;
continue ;
}
break ;
2008-10-11 14:16:25 -05:00
}
for ( uint32 j = 0 ; j < MAX_ACTIONS ; j + + )
{
temp . action [ j ] . type = fields [ 10 + ( j * 4 ) ] . GetUInt16 ( ) ;
temp . action [ j ] . param1 = fields [ 11 + ( j * 4 ) ] . GetUInt32 ( ) ;
temp . action [ j ] . param2 = fields [ 12 + ( j * 4 ) ] . GetUInt32 ( ) ;
temp . action [ j ] . param3 = fields [ 13 + ( j * 4 ) ] . GetUInt32 ( ) ;
//Report any errors in actions
switch ( temp . action [ j ] . type )
{
2008-10-25 11:40:10 -05:00
case ACTION_T_TEXT :
{
if ( temp . action [ j ] . param1_s < 0 )
{
if ( TextMap . find ( temp . action [ j ] . param1_s ) = = TextMap . end ( ) )
error_db_log ( " TSCR: Event %u Action %u param1 refrences non-existing entry in texts table. " , i , j + 1 ) ;
}
if ( temp . action [ j ] . param2_s < 0 )
{
if ( TextMap . find ( temp . action [ j ] . param2_s ) = = TextMap . end ( ) )
error_db_log ( " TSCR: Event %u Action %u param2 refrences non-existing entry in texts table. " , i , j + 1 ) ;
if ( ! temp . action [ j ] . param1_s )
error_db_log ( " TSCR: Event %u Action %u has param2, but param1 is not set. Required for randomized text. " , i , j + 1 ) ;
}
if ( temp . action [ j ] . param3_s < 0 )
{
if ( TextMap . find ( temp . action [ j ] . param3_s ) = = TextMap . end ( ) )
error_db_log ( " TSCR: Event %u Action %u param3 refrences non-existing entry in texts table. " , i , j + 1 ) ;
if ( ! temp . action [ j ] . param1_s | | ! temp . action [ j ] . param2_s )
error_db_log ( " TSCR: Event %u Action %u has param3, but param1 and/or param2 is not set. Required for randomized text. " , i , j + 1 ) ;
}
}
2008-10-11 14:16:25 -05:00
break ;
2009-02-20 14:14:16 +01:00
case ACTION_T_SET_FACTION :
if ( temp . action [ j ] . param1 ! = 0 & & ! GetFactionStore ( ) - > LookupEntry ( temp . action [ j ] . param1 ) )
{
error_db_log ( " TSCR: Event %u Action %u uses non-existant FactionId %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
temp . action [ j ] . param1 = 0 ;
}
break ;
case ACTION_T_MORPH_TO_ENTRY_OR_MODEL :
if ( temp . action [ j ] . param1 ! = 0 | | temp . action [ j ] . param2 ! = 0 )
{
if ( temp . action [ j ] . param1 & & ! GetCreatureTemplateStore ( temp . action [ j ] . param1 ) )
{
error_db_log ( " TSCR: Event %u Action %u uses non-existant Creature entry %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
temp . action [ j ] . param1 = 0 ;
}
2008-10-11 14:16:25 -05:00
2009-02-20 14:14:16 +01:00
if ( temp . action [ j ] . param2 & & ! GetCreatureDisplayStore ( ) - > LookupEntry ( temp . action [ j ] . param2 ) )
{
error_db_log ( " TSCR: Event %u Action %u uses non-existant ModelId %u. " , i , j + 1 , temp . action [ j ] . param2 ) ;
temp . action [ j ] . param2 = 0 ;
}
}
break ;
2008-10-11 14:16:25 -05:00
case ACTION_T_SOUND :
if ( ! GetSoundEntriesStore ( ) - > LookupEntry ( temp . action [ j ] . param1 ) )
error_db_log ( " TSCR: Event %u Action %u uses non-existant SoundID %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
break ;
2008-10-25 11:40:10 -05:00
/*case ACTION_T_RANDOM_SOUND:
{
if(!GetSoundEntriesStore()->LookupEntry(temp.action[j].param1))
error_db_log("TSCR: Event %u Action %u param1 uses non-existant SoundID %u.", i, j+1, temp.action[j].param1);
if(!GetSoundEntriesStore()->LookupEntry(temp.action[j].param2))
error_db_log("TSCR: Event %u Action %u param2 uses non-existant SoundID %u.", i, j+1, temp.action[j].param2);
if(!GetSoundEntriesStore()->LookupEntry(temp.action[j].param3))
error_db_log("TSCR: Event %u Action %u param3 uses non-existant SoundID %u.", i, j+1, temp.action[j].param3);
}
break;*/
2008-10-11 14:16:25 -05:00
case ACTION_T_CAST :
{
2009-02-20 14:14:16 +01:00
const SpellEntry * spell = GetSpellStore ( ) - > LookupEntry ( temp . action [ j ] . param1 ) ;
if ( ! spell )
2009-03-13 17:14:02 -06:00
error_db_log ( " SD2: Event %u Action %u uses non-existant SpellID %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
2009-02-20 14:14:16 +01:00
else
{
if ( spell - > RecoveryTime > 0 & & temp . event_flags & EFLAG_REPEATABLE )
{
//output as debug for now, also because there's no general rule all spells have RecoveryTime
if ( temp . event_param3 < spell - > RecoveryTime )
debug_log ( " TSCR: Event %u Action %u uses SpellID %u but cooldown is longer(%u) than minumum defined in event param3(%u). " , i , j + 1 , temp . action [ j ] . param1 , spell - > RecoveryTime , temp . event_param3 ) ;
}
}
2008-10-11 14:16:25 -05:00
if ( temp . action [ j ] . param2 > = TARGET_T_END )
error_db_log ( " TSCR: Event %u Action %u uses incorrect Target type " , i , j + 1 ) ;
}
break ;
case ACTION_T_REMOVEAURASFROMSPELL :
{
if ( ! GetSpellStore ( ) - > LookupEntry ( temp . action [ j ] . param2 ) )
error_db_log ( " TSCR: Event %u Action %u uses non-existant SpellID %u. " , i , j + 1 , temp . action [ j ] . param2 ) ;
if ( temp . action [ j ] . param1 > = TARGET_T_END )
error_db_log ( " TSCR: Event %u Action %u uses incorrect Target type " , i , j + 1 ) ;
}
break ;
2009-02-20 14:14:16 +01:00
case ACTION_T_QUEST_EVENT :
{
if ( Quest const * qid = GetQuestTemplateStore ( temp . action [ j ] . param1 ) )
{
if ( ! qid - > HasFlag ( QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT ) )
error_db_log ( " TSCR: Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect. " , i , j + 1 , temp . action [ j ] . param1 ) ;
}
else
error_db_log ( " TSCR: Event %u Action %u uses non-existant Quest entry %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
2008-10-11 14:16:25 -05:00
2009-02-20 14:14:16 +01:00
if ( temp . action [ j ] . param2 > = TARGET_T_END )
error_db_log ( " TSCR: Event %u Action %u uses incorrect Target type " , i , j + 1 ) ;
}
break ;
case ACTION_T_QUEST_EVENT_ALL :
{
if ( Quest const * qid = GetQuestTemplateStore ( temp . action [ j ] . param1 ) )
{
if ( ! qid - > HasFlag ( QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT ) )
error_db_log ( " TSCR: Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect. " , i , j + 1 , temp . action [ j ] . param1 ) ;
}
else
error_db_log ( " TSCR: Event %u Action %u uses non-existant Quest entry %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
}
break ;
2008-10-11 14:16:25 -05:00
case ACTION_T_CASTCREATUREGO :
{
2009-02-20 14:14:16 +01:00
if ( ! GetCreatureTemplateStore ( temp . action [ j ] . param1 ) )
error_db_log ( " TSCR: Event %u Action %u uses non-existant creature entry %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
2008-10-11 14:16:25 -05:00
if ( ! GetSpellStore ( ) - > LookupEntry ( temp . action [ j ] . param2 ) )
error_db_log ( " TSCR: Event %u Action %u uses non-existant SpellID %u. " , i , j + 1 , temp . action [ j ] . param2 ) ;
if ( temp . action [ j ] . param3 > = TARGET_T_END )
2009-03-13 17:14:02 -06:00
error_db_log ( " SD2: Event %u Action %u uses incorrect Target type " , i , j + 1 ) ;
2008-10-11 14:16:25 -05:00
}
break ;
2009-02-20 14:14:16 +01:00
case ACTION_T_CASTCREATUREGO_ALL :
{
if ( ! GetQuestTemplateStore ( temp . action [ j ] . param1 ) )
error_db_log ( " TSCR: Event %u Action %u uses non-existant Quest entry %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
if ( ! GetSpellStore ( ) - > LookupEntry ( temp . action [ j ] . param2 ) )
error_db_log ( " TSCR: Event %u Action %u uses non-existant SpellID %u. " , i , j + 1 , temp . action [ j ] . param2 ) ;
}
break ;
2008-10-11 14:16:25 -05:00
//2nd param target
case ACTION_T_SUMMON_ID :
{
2009-02-20 14:14:16 +01:00
if ( ! GetCreatureTemplateStore ( temp . action [ j ] . param1 ) )
error_db_log ( " TSCR: Event %u Action %u uses non-existant creature entry %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
2008-10-11 14:16:25 -05:00
if ( EventAI_Summon_Map . find ( temp . action [ j ] . param3 ) = = EventAI_Summon_Map . end ( ) )
error_db_log ( " TSCR: Event %u Action %u summons missing EventAI_Summon %u " , i , j + 1 , temp . action [ j ] . param3 ) ;
if ( temp . action [ j ] . param2 > = TARGET_T_END )
error_db_log ( " TSCR: Event %u Action %u uses incorrect Target type " , i , j + 1 ) ;
}
break ;
2009-02-20 14:14:16 +01:00
case ACTION_T_KILLED_MONSTER :
{
if ( ! GetCreatureTemplateStore ( temp . action [ j ] . param1 ) )
error_db_log ( " TSCR: Event %u Action %u uses non-existant creature entry %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
2008-10-11 14:16:25 -05:00
2009-02-20 14:14:16 +01:00
if ( temp . action [ j ] . param2 > = TARGET_T_END )
error_db_log ( " TSCR: Event %u Action %u uses incorrect Target type " , i , j + 1 ) ;
}
break ;
2008-10-11 14:16:25 -05:00
case ACTION_T_SUMMON :
2009-02-20 14:14:16 +01:00
{
if ( ! GetCreatureTemplateStore ( temp . action [ j ] . param1 ) )
error_db_log ( " TSCR: Event %u Action %u uses non-existant creature entry %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
if ( temp . action [ j ] . param2 > = TARGET_T_END )
error_db_log ( " TSCR: Event %u Action %u uses incorrect Target type " , i , j + 1 ) ;
}
break ;
2008-10-11 14:16:25 -05:00
case ACTION_T_THREAT_SINGLE_PCT :
case ACTION_T_SET_UNIT_FLAG :
case ACTION_T_REMOVE_UNIT_FLAG :
if ( temp . action [ j ] . param2 > = TARGET_T_END )
error_db_log ( " TSCR: Event %u Action %u uses incorrect Target type " , i , j + 1 ) ;
break ;
//3rd param target
case ACTION_T_SET_UNIT_FIELD :
2009-02-17 18:08:26 +01:00
if ( temp . action [ j ] . param1 < OBJECT_END | | temp . action [ j ] . param1 > = UNIT_END )
error_db_log ( " TSCR: Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use. " , i , j + 1 ) ;
2008-10-11 14:16:25 -05:00
if ( temp . action [ j ] . param3 > = TARGET_T_END )
error_db_log ( " TSCR: Event %u Action %u uses incorrect Target type " , i , j + 1 ) ;
break ;
case ACTION_T_SET_PHASE :
if ( temp . action [ j ] . param1 > 31 )
error_db_log ( " TSCR: Event %u Action %u attempts to set phase > 31. Phase mask cannot be used past phase 31. " , i , j + 1 ) ;
break ;
case ACTION_T_INC_PHASE :
if ( ! temp . action [ j ] . param1 )
2009-03-13 17:14:02 -06:00
error_db_log ( " SD2: Event %u Action %u is incrementing phase by 0. Was this intended? " , i , j + 1 ) ;
2008-10-11 14:16:25 -05:00
break ;
case ACTION_T_SET_INST_DATA :
2009-02-20 14:14:16 +01:00
{
if ( ! ( temp . event_flags & EFLAG_NORMAL ) & & ! ( temp . event_flags & EFLAG_HEROIC ) )
error_db_log ( " TSCR: Event %u Action %u. Cannot set instance data without event flags (normal/heroic). " , i , j + 1 ) ;
if ( temp . action [ j ] . param2 > SPECIAL )
error_db_log ( " TSCR: Event %u Action %u attempts to set instance data above encounter state 4. Custom case? " , i , j + 1 ) ;
}
2008-10-11 14:16:25 -05:00
break ;
2009-02-20 14:14:16 +01:00
case ACTION_T_SET_INST_DATA64 :
{
if ( ! ( temp . event_flags & EFLAG_NORMAL ) & & ! ( temp . event_flags & EFLAG_HEROIC ) )
error_db_log ( " TSCR: Event %u Action %u. Cannot set instance data without event flags (normal/heroic). " , i , j + 1 ) ;
2008-10-11 14:16:25 -05:00
2009-02-20 14:14:16 +01:00
if ( temp . action [ j ] . param2 > = TARGET_T_END )
error_db_log ( " TSCR: Event %u Action %u uses incorrect Target type " , i , j + 1 ) ;
}
break ;
case ACTION_T_UPDATE_TEMPLATE :
{
if ( ! GetCreatureTemplateStore ( temp . action [ j ] . param1 ) )
error_db_log ( " TSCR: Event %u Action %u uses non-existant creature entry %u. " , i , j + 1 , temp . action [ j ] . param1 ) ;
}
break ;
2008-10-25 11:40:10 -05:00
case ACTION_T_RANDOM_SAY :
case ACTION_T_RANDOM_YELL :
case ACTION_T_RANDOM_TEXTEMOTE :
error_db_log ( " TSCR: Event %u Action %u currently unused ACTION type. Did you forget to update database? " , i , j + 1 ) ;
break ;
2008-10-11 14:16:25 -05:00
default :
if ( temp . action [ j ] . type > = ACTION_T_END )
error_db_log ( " TSCR: Event %u Action %u has incorrect action type. Maybe DB requires updated version of SD2. " , i , j + 1 ) ;
break ;
}
}
//Add to list
2009-03-23 15:22:24 -06:00
EventAI_Event_Map [ creature_id ] . push_back ( temp ) ;
2008-10-11 14:16:25 -05:00
+ + Count ;
} while ( result - > NextRow ( ) ) ;
delete result ;
outstring_log ( " " ) ;
outstring_log ( " >> Loaded %u EventAI scripts " , Count ) ;
} else
{
barGoLink bar ( 1 ) ;
bar . step ( ) ;
outstring_log ( " " ) ;
outstring_log ( " >> Loaded 0 EventAI scripts. DB table `eventai_scripts` is empty. " ) ;
}
//Free database thread and resources
TScriptDB . HaltDelayThread ( ) ;
}
struct TSpellSummary {
uint8 Targets ; // set of enum SelectTarget
2009-02-04 10:33:18 -06:00
uint8 Effects ; // set of enum SelectEffect
2008-10-11 14:16:25 -05:00
} extern * SpellSummary ;
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
void ScriptsFree ( )
2008-11-20 16:16:57 -06:00
{
2008-10-11 14:16:25 -05:00
// Free Spell Summary
delete [ ] SpellSummary ;
// Free resources before library unload
2009-02-20 14:14:16 +01:00
for ( int i = 0 ; i < MAX_SCRIPTS ; i + + )
2008-10-11 14:16:25 -05:00
delete m_scripts [ i ] ;
2008-11-20 16:16:57 -06:00
num_sc_scripts = 0 ;
2008-10-11 14:16:25 -05:00
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
void ScriptsInit ( )
{
bool CanLoadDB = true ;
//Trinity Script startup
outstring_log ( " _____ _ _ _ ____ _ _ " ) ;
outstring_log ( " |_ _| __(_)_ __ (_) |_ _ _/ ___| ___ _ __(_)_ __ | |_ " ) ;
outstring_log ( " | || '__| | '_ \\ | | __| | | \\ ___ \\ / __| \' __| | \' _ \\ | __| " ) ;
outstring_log ( " | || | | | | | | | |_| |_| |___) | (__| | | | |_) | |_ " ) ;
outstring_log ( " |_||_| |_|_| |_|_| \\ __| \\ __, |____/ \\ ___|_| |_| .__/ \\ __| " ) ;
outstring_log ( " |___/ |_| " ) ;
outstring_log ( " Trinity Script initializing %s " , _FULLVERSION ) ;
outstring_log ( " " ) ;
//Get configuration file
if ( ! TScriptConfig . SetSource ( _TRINITY_SCRIPT_CONFIG ) )
{
CanLoadDB = false ;
error_log ( " TSCR: Unable to open configuration file. Database will be unaccessible. Configuration values will use default. " ) ;
}
else outstring_log ( " TSCR: Using configuration file %s " , _TRINITY_SCRIPT_CONFIG ) ;
EAI_ErrorLevel = TScriptConfig . GetIntDefault ( " EAIErrorLevel " , 1 ) ;
switch ( EAI_ErrorLevel )
{
2008-10-25 11:40:10 -05:00
case 0 :
outstring_log ( " TSCR: EventAI Error Reporting level set to 0 (Startup Errors only) " ) ;
break ;
case 1 :
outstring_log ( " TSCR: EventAI Error Reporting level set to 1 (Startup errors and Runtime event errors) " ) ;
break ;
case 2 :
outstring_log ( " TSCR: EventAI Error Reporting level set to 2 (Startup errors, Runtime event errors, and Creation errors) " ) ;
break ;
default :
outstring_log ( " TSCR: Unknown EventAI Error Reporting level. Defaulting to 1 (Startup errors and Runtime event errors) " ) ;
EAI_ErrorLevel = 1 ;
break ;
2008-10-11 14:16:25 -05:00
}
outstring_log ( " " ) ;
//Load database (must be called after TScriptConfig.SetSource). In case it failed, no need to even try load.
if ( CanLoadDB )
LoadDatabase ( ) ;
outstring_log ( " TSCR: Loading C++ scripts " ) ;
barGoLink bar ( 1 ) ;
bar . step ( ) ;
outstring_log ( " " ) ;
for ( int i = 0 ; i < MAX_SCRIPTS ; i + + )
m_scripts [ i ] = NULL ;
FillSpellSummary ( ) ;
// -- Scripts to be added --
// -- Areatrigger --
AddSC_areatrigger_scripts ( ) ;
// -- Boss --
AddSC_boss_emeriss ( ) ;
AddSC_boss_taerar ( ) ;
AddSC_boss_ysondre ( ) ;
// -- Creature --
AddSC_mob_event ( ) ;
AddSC_generic_creature ( ) ;
// -- Custom --
2009-02-17 18:08:26 +01:00
// -- Examples --
AddSC_example_creature ( ) ;
AddSC_example_escort ( ) ;
AddSC_example_gossip_codebox ( ) ;
AddSC_example_misc ( ) ;
2008-10-11 14:16:25 -05:00
// -- GO --
AddSC_go_scripts ( ) ;
// -- Guard --
AddSC_guards ( ) ;
// -- Honor --
// -- Item --
AddSC_item_scripts ( ) ;
// -- NPC --
AddSC_npc_professions ( ) ;
AddSC_npcs_special ( ) ;
// -- Servers --
//--------------------
//------ ZONE --------
//Alterac Mountains
AddSC_alterac_mountains ( ) ;
//Arathi Highlands
2009-02-09 08:16:34 -05:00
AddSC_arathi_highlands ( ) ;
2008-12-27 21:29:09 +01:00
2008-10-11 14:16:25 -05:00
//Ashenvale Forest
2009-02-09 08:16:34 -05:00
AddSC_ashenvale ( ) ;
2008-12-13 19:56:53 +01:00
2008-10-11 14:16:25 -05:00
//Aunchindoun
//--Auchenai Crypts
AddSC_boss_exarch_maladaar ( ) ;
2009-02-09 08:16:34 -05:00
AddSC_boss_shirrak_the_dead_watcher ( ) ;
2008-10-11 14:16:25 -05:00
//--Mana Tombs
AddSC_boss_nexusprince_shaffar ( ) ;
AddSC_boss_pandemonius ( ) ;
//--Sekketh Halls
AddSC_boss_darkweaver_syth ( ) ;
AddSC_boss_talon_king_ikiss ( ) ;
AddSC_instance_sethekk_halls ( ) ;
//--Shadow Labyrinth
AddSC_boss_ambassador_hellmaw ( ) ;
AddSC_boss_blackheart_the_inciter ( ) ;
AddSC_boss_grandmaster_vorpil ( ) ;
AddSC_boss_murmur ( ) ;
AddSC_instance_shadow_labyrinth ( ) ;
//Azshara
AddSC_boss_azuregos ( ) ;
AddSC_azshara ( ) ;
//Azuremyst Isle
AddSC_azuremyst_isle ( ) ;
//Badlands
//Barrens
AddSC_the_barrens ( ) ;
//Black Temple
AddSC_black_temple ( ) ;
AddSC_boss_illidan ( ) ;
AddSC_boss_shade_of_akama ( ) ;
AddSC_boss_supremus ( ) ;
AddSC_boss_gurtogg_bloodboil ( ) ;
AddSC_boss_mother_shahraz ( ) ;
AddSC_boss_reliquary_of_souls ( ) ;
AddSC_boss_teron_gorefiend ( ) ;
AddSC_boss_najentus ( ) ;
AddSC_boss_illidari_council ( ) ;
AddSC_instance_black_temple ( ) ;
//Blackfathom Depths
//Blackrock Depths
AddSC_blackrock_depths ( ) ;
2009-02-09 08:16:34 -05:00
AddSC_boss_ambassador_flamelash ( ) ;
AddSC_boss_anubshiah ( ) ;
AddSC_boss_draganthaurissan ( ) ;
AddSC_boss_general_angerforge ( ) ;
AddSC_boss_gorosh_the_dervish ( ) ;
AddSC_boss_grizzle ( ) ;
AddSC_boss_high_interrogator_gerstahn ( ) ;
AddSC_boss_magmus ( ) ;
AddSC_boss_moira_bronzebeard ( ) ;
AddSC_boss_tomb_of_seven ( ) ;
AddSC_instance_blackrock_depths ( ) ;
2008-10-11 14:16:25 -05:00
//Blackrock Spire
AddSC_boss_drakkisath ( ) ;
AddSC_boss_halycon ( ) ;
AddSC_boss_highlordomokk ( ) ;
AddSC_boss_mothersmolderweb ( ) ;
AddSC_boss_overlordwyrmthalak ( ) ;
AddSC_boss_shadowvosh ( ) ;
AddSC_boss_thebeast ( ) ;
AddSC_boss_warmastervoone ( ) ;
AddSC_boss_quatermasterzigris ( ) ;
AddSC_boss_pyroguard_emberseer ( ) ;
AddSC_boss_gyth ( ) ;
AddSC_boss_rend_blackhand ( ) ;
//Blackwing lair
AddSC_boss_razorgore ( ) ;
AddSC_boss_vael ( ) ;
AddSC_boss_broodlord ( ) ;
AddSC_boss_firemaw ( ) ;
AddSC_boss_ebonroc ( ) ;
AddSC_boss_flamegor ( ) ;
AddSC_boss_chromaggus ( ) ;
AddSC_boss_nefarian ( ) ;
AddSC_boss_victor_nefarius ( ) ;
//Blade's Edge Mountains
AddSC_blades_edge_mountains ( ) ;
//Blasted lands
AddSC_boss_kruul ( ) ;
AddSC_blasted_lands ( ) ;
//Bloodmyst Isle
AddSC_bloodmyst_isle ( ) ;
2009-02-05 10:46:43 +01:00
//Borean Tundra
AddSC_borean_tundra ( ) ;
2008-10-11 14:16:25 -05:00
//Burning steppes
AddSC_burning_steppes ( ) ;
//Caverns of Time
//--Battle for Mt. Hyjal
AddSC_hyjal ( ) ;
AddSC_boss_archimonde ( ) ;
AddSC_instance_mount_hyjal ( ) ;
//--Old Hillsbrad
AddSC_boss_captain_skarloc ( ) ;
AddSC_boss_epoch_hunter ( ) ;
AddSC_boss_lieutenant_drake ( ) ;
AddSC_instance_old_hillsbrad ( ) ;
AddSC_old_hillsbrad ( ) ;
//--The Dark Portal
AddSC_boss_aeonus ( ) ;
AddSC_boss_chrono_lord_deja ( ) ;
AddSC_boss_temporus ( ) ;
2009-02-09 08:16:34 -05:00
AddSC_dark_portal ( ) ;
AddSC_instance_dark_portal ( ) ;
2008-10-11 14:16:25 -05:00
//Coilfang Resevoir
//--Serpent Shrine Cavern
AddSC_boss_fathomlord_karathress ( ) ;
AddSC_boss_hydross_the_unstable ( ) ;
AddSC_boss_lady_vashj ( ) ;
AddSC_boss_leotheras_the_blind ( ) ;
AddSC_boss_morogrim_tidewalker ( ) ;
AddSC_instance_serpentshrine_cavern ( ) ;
2009-02-09 08:16:34 -05:00
AddSC_boss_the_lurker_below ( ) ;
2008-10-11 14:16:25 -05:00
//--Slave Pens
//--Steam Vault
AddSC_boss_hydromancer_thespia ( ) ;
AddSC_boss_mekgineer_steamrigger ( ) ;
AddSC_boss_warlord_kalithresh ( ) ;
AddSC_instance_steam_vault ( ) ;
//--Underbog
AddSC_boss_hungarfen ( ) ;
2009-02-08 11:43:53 +01:00
AddSC_boss_the_black_stalker ( ) ;
2008-10-11 14:16:25 -05:00
//Darkshore
//Darnassus
//Deadmines
2008-12-01 18:32:00 -06:00
AddSC_instance_deadmines ( ) ;
2008-10-11 14:16:25 -05:00
//Deadwind pass
//Desolace
//Dire Maul
//Dun Morogh
AddSC_dun_morogh ( ) ;
//Durotar
//Duskwood
//Dustwallow marsh
AddSC_dustwallow_marsh ( ) ;
//Eversong Woods
AddSC_eversong_woods ( ) ;
//Exodar
//Eastern Plaguelands
AddSC_eastern_plaguelands ( ) ;
//Elwynn Forest
AddSC_elwynn_forest ( ) ;
//Felwood
AddSC_felwood ( ) ;
//Feralas
AddSC_feralas ( ) ;
//Ghostlands
AddSC_ghostlands ( ) ;
//Gnomeregan
//Gruul's Lair
AddSC_boss_gruul ( ) ;
AddSC_boss_high_king_maulgar ( ) ;
AddSC_instance_gruuls_lair ( ) ;
//Hellfire Citadel
//--Blood Furnace
AddSC_boss_broggok ( ) ;
AddSC_boss_kelidan_the_breaker ( ) ;
AddSC_boss_the_maker ( ) ;
2009-02-09 08:16:34 -05:00
AddSC_instance_blood_furnace ( ) ;
2008-10-11 14:16:25 -05:00
//--Magtheridon's Lair
AddSC_boss_magtheridon ( ) ;
AddSC_instance_magtheridons_lair ( ) ;
//--Shattered Halls
AddSC_boss_grand_warlock_nethekurse ( ) ;
AddSC_boss_warbringer_omrogg ( ) ;
2008-11-26 19:14:03 +01:00
AddSC_boss_warchief_kargath_bladefist ( ) ;
2008-10-11 14:16:25 -05:00
AddSC_instance_shattered_halls ( ) ;
//--Ramparts
AddSC_boss_watchkeeper_gargolmar ( ) ;
AddSC_boss_omor_the_unscarred ( ) ;
2009-01-23 20:34:30 +01:00
AddSC_boss_vazruden_the_herald ( ) ;
2008-10-11 14:16:25 -05:00
//Hellfire Peninsula
AddSC_boss_doomlordkazzak ( ) ;
AddSC_hellfire_peninsula ( ) ;
//Hillsbrad Foothills
//Hinterlands
//Ironforge
AddSC_ironforge ( ) ;
//Isle of Quel'Danas
AddSC_isle_of_queldanas ( ) ;
//Karazhan
AddSC_boss_attumen ( ) ;
AddSC_boss_curator ( ) ;
AddSC_boss_maiden_of_virtue ( ) ;
AddSC_boss_shade_of_aran ( ) ;
AddSC_boss_malchezaar ( ) ;
AddSC_boss_terestian_illhoof ( ) ;
AddSC_boss_moroes ( ) ;
AddSC_bosses_opera ( ) ;
AddSC_instance_karazhan ( ) ;
AddSC_karazhan ( ) ;
2009-02-09 08:16:34 -05:00
AddSC_boss_nightbane ( ) ;
2008-10-11 14:16:25 -05:00
//Loch Modan
AddSC_loch_modan ( ) ;
//Lower Blackrock Spire
// Magister's Terrace
AddSC_boss_felblood_kaelthas ( ) ;
AddSC_boss_selin_fireheart ( ) ;
AddSC_boss_vexallus ( ) ;
AddSC_boss_priestess_delrissa ( ) ;
AddSC_instance_magisters_terrace ( ) ;
//Maraudon
AddSC_boss_celebras_the_cursed ( ) ;
AddSC_boss_landslide ( ) ;
AddSC_boss_noxxion ( ) ;
AddSC_boss_ptheradras ( ) ;
//Molten core
AddSC_boss_lucifron ( ) ;
AddSC_boss_magmadar ( ) ;
AddSC_boss_gehennas ( ) ;
AddSC_boss_garr ( ) ;
AddSC_boss_baron_geddon ( ) ;
AddSC_boss_shazzrah ( ) ;
AddSC_boss_golemagg ( ) ;
AddSC_boss_sulfuron ( ) ;
AddSC_boss_majordomo ( ) ;
AddSC_boss_ragnaros ( ) ;
AddSC_instance_molten_core ( ) ;
AddSC_molten_core ( ) ;
//Moonglade
AddSC_moonglade ( ) ;
//Mulgore
AddSC_mulgore ( ) ;
//Nagrand
AddSC_nagrand ( ) ;
//Naxxramas
AddSC_boss_anubrekhan ( ) ;
2009-03-08 00:13:03 +01:00
AddSC_boss_faerlina ( ) ;
2008-10-11 14:16:25 -05:00
AddSC_boss_maexxna ( ) ;
AddSC_boss_patchwerk ( ) ;
AddSC_boss_razuvious ( ) ;
2009-02-20 14:14:16 +01:00
AddSC_boss_kelthuzad ( ) ;
2008-10-11 14:16:25 -05:00
AddSC_boss_loatheb ( ) ;
AddSC_boss_noth ( ) ;
AddSC_boss_gluth ( ) ;
AddSC_boss_sapphiron ( ) ;
2009-02-09 08:16:34 -05:00
AddSC_boss_four_horsemen ( ) ;
2008-10-11 14:16:25 -05:00
//Netherstorm
AddSC_netherstorm ( ) ;
//Onyxia's Lair
AddSC_boss_onyxia ( ) ;
//Orgrimmar
AddSC_orgrimmar ( ) ;
//Ragefire Chasm
//Razorfen Downs
AddSC_boss_amnennar_the_coldbringer ( ) ;
2009-02-09 08:16:34 -05:00
//Razorfen Kraul
AddSC_razorfen_kraul ( ) ;
2008-12-27 22:46:01 +01:00
2008-10-11 14:16:25 -05:00
//Redridge Mountains
//Ruins of Ahn'Qiraj
//Scarlet Monastery
AddSC_boss_arcanist_doan ( ) ;
AddSC_boss_azshir_the_sleepless ( ) ;
AddSC_boss_bloodmage_thalnos ( ) ;
2009-02-09 08:16:34 -05:00
AddSC_boss_headless_horseman ( ) ;
2008-10-11 14:16:25 -05:00
AddSC_boss_herod ( ) ;
AddSC_boss_high_inquisitor_fairbanks ( ) ;
AddSC_boss_houndmaster_loksey ( ) ;
AddSC_boss_interrogator_vishas ( ) ;
AddSC_boss_scorn ( ) ;
2009-02-09 08:16:34 -05:00
AddSC_instance_scarlet_monastery ( ) ;
AddSC_boss_mograine_and_whitemane ( ) ;
2008-10-11 14:16:25 -05:00
//Scholomance
AddSC_boss_darkmaster_gandling ( ) ;
AddSC_boss_death_knight_darkreaver ( ) ;
AddSC_boss_theolenkrastinov ( ) ;
AddSC_boss_illuciabarov ( ) ;
AddSC_boss_instructormalicia ( ) ;
AddSC_boss_jandicebarov ( ) ;
AddSC_boss_kormok ( ) ;
AddSC_boss_lordalexeibarov ( ) ;
AddSC_boss_lorekeeperpolkelt ( ) ;
AddSC_boss_rasfrost ( ) ;
AddSC_boss_theravenian ( ) ;
AddSC_boss_vectus ( ) ;
AddSC_instance_scholomance ( ) ;
//Searing gorge
AddSC_searing_gorge ( ) ;
//Shadowfang keep
AddSC_shadowfang_keep ( ) ;
AddSC_instance_shadowfang_keep ( ) ;
//Shadowmoon Valley
AddSC_boss_doomwalker ( ) ;
AddSC_shadowmoon_valley ( ) ;
//Shattrath
AddSC_shattrath_city ( ) ;
//Silithus
AddSC_silithus ( ) ;
//Silvermoon
AddSC_silvermoon_city ( ) ;
//Silverpine forest
AddSC_silverpine_forest ( ) ;
//Stockade
//Stonetalon mountains
AddSC_stonetalon_mountains ( ) ;
//Stormwind City
AddSC_stormwind_city ( ) ;
//Stranglethorn Vale
AddSC_stranglethorn_vale ( ) ;
//Stratholme
AddSC_boss_magistrate_barthilas ( ) ;
AddSC_boss_maleki_the_pallid ( ) ;
AddSC_boss_nerubenkan ( ) ;
AddSC_boss_cannon_master_willey ( ) ;
AddSC_boss_baroness_anastari ( ) ;
AddSC_boss_ramstein_the_gorger ( ) ;
AddSC_boss_timmy_the_cruel ( ) ;
AddSC_boss_postmaster_malown ( ) ;
AddSC_boss_baron_rivendare ( ) ;
AddSC_boss_dathrohan_balnazzar ( ) ;
AddSC_boss_order_of_silver_hand ( ) ;
AddSC_instance_stratholme ( ) ;
AddSC_stratholme ( ) ;
//Sunken Temple
2009-02-09 08:16:34 -05:00
//Sunwell Plateau
2008-10-20 14:02:13 -05:00
AddSC_instance_sunwell_plateau ( ) ;
AddSC_boss_kalecgos ( ) ;
2009-02-09 08:16:34 -05:00
AddSC_boss_brutallus ( ) ;
2008-10-20 14:02:13 -05:00
AddSC_boss_felmyst ( ) ;
AddSC_boss_eredar_twins ( ) ;
2008-10-11 14:16:25 -05:00
//Tanaris
AddSC_tanaris ( ) ;
//Teldrassil
//Tempest Keep
//--Arcatraz
AddSC_arcatraz ( ) ;
AddSC_boss_harbinger_skyriss ( ) ;
AddSC_instance_arcatraz ( ) ;
//--Botanica
AddSC_boss_high_botanist_freywinn ( ) ;
AddSC_boss_laj ( ) ;
AddSC_boss_warp_splinter ( ) ;
//--The Eye
2008-10-20 14:02:13 -05:00
AddSC_boss_alar ( ) ;
2008-10-11 14:16:25 -05:00
AddSC_boss_kaelthas ( ) ;
AddSC_boss_void_reaver ( ) ;
AddSC_boss_high_astromancer_solarian ( ) ;
AddSC_instance_the_eye ( ) ;
AddSC_the_eye ( ) ;
//--The Mechanar
AddSC_boss_gatewatcher_iron_hand ( ) ;
AddSC_boss_nethermancer_sepethrea ( ) ;
2008-11-13 17:12:54 -06:00
AddSC_boss_pathaleon_the_calculator ( ) ;
AddSC_instance_mechanar ( ) ;
2008-10-11 14:16:25 -05:00
//Temple of ahn'qiraj
AddSC_boss_cthun ( ) ;
AddSC_boss_fankriss ( ) ;
AddSC_boss_huhuran ( ) ;
AddSC_bug_trio ( ) ;
AddSC_boss_sartura ( ) ;
AddSC_boss_skeram ( ) ;
AddSC_boss_twinemperors ( ) ;
AddSC_mob_anubisath_sentinel ( ) ;
AddSC_instance_temple_of_ahnqiraj ( ) ;
//Terokkar Forest
AddSC_terokkar_forest ( ) ;
//Thousand Needles
2009-02-09 08:16:34 -05:00
AddSC_thousand_needles ( ) ;
2009-01-04 17:11:24 +01:00
2008-10-11 14:16:25 -05:00
//Thunder Bluff
AddSC_thunder_bluff ( ) ;
//Tirisfal Glades
AddSC_tirisfal_glades ( ) ;
//Uldaman
2008-12-08 16:57:49 -06:00
AddSC_boss_archaedas ( ) ;
2008-10-11 14:16:25 -05:00
AddSC_boss_ironaya ( ) ;
AddSC_uldaman ( ) ;
2008-12-08 16:57:49 -06:00
AddSC_instance_uldaman ( ) ;
2008-10-11 14:16:25 -05:00
//Undercity
AddSC_undercity ( ) ;
//Un'Goro Crater
2009-02-09 08:16:34 -05:00
AddSC_ungoro_crater ( ) ;
2009-01-09 19:55:26 +01:00
2008-10-11 14:16:25 -05:00
//Upper blackrock spire
2009-02-11 00:57:39 +01:00
//Utgarde Keep
AddSC_boss_keleseth ( ) ;
2009-02-28 22:39:05 +01:00
AddSC_boss_skarvald_dalronn ( ) ;
2009-03-08 00:13:03 +01:00
AddSC_boss_ingvar_the_plunderer ( ) ;
2009-02-11 13:13:43 +01:00
AddSC_instance_utgarde_keep ( ) ;
2009-02-28 22:39:05 +01:00
2008-10-11 14:16:25 -05:00
//Wailing caverns
//Western plaguelands
AddSC_western_plaguelands ( ) ;
//Westfall
2008-11-04 15:37:18 -06:00
AddSC_westfall ( ) ;
2008-10-11 14:16:25 -05:00
//Wetlands
//Winterspring
AddSC_winterspring ( ) ;
//Zangarmarsh
AddSC_zangarmarsh ( ) ;
//Zul'Farrak
2009-02-09 08:16:34 -05:00
AddSC_zulfarrak ( ) ;
2008-12-15 18:54:16 +01:00
2008-10-11 14:16:25 -05:00
//Zul'Gurub
AddSC_boss_jeklik ( ) ;
AddSC_boss_venoxis ( ) ;
AddSC_boss_marli ( ) ;
AddSC_boss_mandokir ( ) ;
AddSC_boss_gahzranka ( ) ;
AddSC_boss_thekal ( ) ;
AddSC_boss_arlokk ( ) ;
AddSC_boss_jindo ( ) ;
AddSC_boss_hakkar ( ) ;
AddSC_boss_grilek ( ) ;
AddSC_boss_hazzarah ( ) ;
AddSC_boss_renataki ( ) ;
AddSC_boss_wushoolay ( ) ;
AddSC_instance_zulgurub ( ) ;
//Zul'Aman
2008-10-17 21:44:37 -05:00
AddSC_boss_akilzon ( ) ;
2009-02-09 08:16:34 -05:00
AddSC_boss_halazzi ( ) ;
AddSC_boss_hex_lord_malacrass ( ) ;
AddSC_boss_janalai ( ) ;
AddSC_boss_nalorakk ( ) ;
AddSC_boss_zuljin ( ) ;
AddSC_instance_zulaman ( ) ;
AddSC_zulaman ( ) ;
2008-10-11 14:16:25 -05:00
// -------------------
2009-02-09 08:16:34 -05:00
outstring_log ( " >> Loaded %i C++ Scripts. " , num_sc_scripts ) ;
2009-02-05 15:38:24 -06:00
outstring_log ( " >> Load Overriden SQL Data. " ) ;
LoadOverridenSQLData ( ) ;
outstring_log ( " >> Load Overriden DBC Data. " ) ;
LoadOverridenDBCData ( ) ;
2008-10-11 14:16:25 -05:00
}
//*********************************
2008-10-25 11:40:10 -05:00
//*** Functions used globally ***
2008-10-11 14:16:25 -05:00
void DoScriptText ( int32 textEntry , WorldObject * pSource , Unit * target )
{
if ( ! pSource )
{
error_log ( " TSCR: DoScriptText entry %i, invalid Source pointer. " , textEntry ) ;
return ;
}
if ( textEntry > = 0 )
{
2008-10-25 11:40:10 -05:00
error_log ( " 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 ( ) , textEntry ) ;
2008-10-11 14:16:25 -05:00
return ;
}
2008-11-10 06:53:00 -06:00
UNORDERED_MAP < int32 , StringTextData > : : iterator i = TextMap . find ( textEntry ) ;
2008-10-11 14:16:25 -05:00
if ( i = = TextMap . end ( ) )
{
2008-10-25 11:40:10 -05:00
error_log ( " TSCR: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i. " , pSource - > GetEntry ( ) , pSource - > GetTypeId ( ) , pSource - > GetGUIDLow ( ) , textEntry ) ;
2008-10-11 14:16:25 -05:00
return ;
}
2008-12-31 12:33:54 +01:00
debug_log ( " TSCR: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u " , textEntry , ( * i ) . second . SoundId , ( * i ) . second . Type , ( * i ) . second . Language , ( * i ) . second . Emote ) ;
2008-10-25 11:40:10 -05:00
2008-10-11 14:16:25 -05:00
if ( ( * i ) . second . SoundId )
{
if ( GetSoundEntriesStore ( ) - > LookupEntry ( ( * i ) . second . SoundId ) )
{
pSource - > SendPlaySound ( ( * i ) . second . SoundId , false ) ;
}
else
error_log ( " TSCR: DoScriptText entry %i tried to process invalid sound id %u. " , textEntry , ( * i ) . second . SoundId ) ;
}
2009-02-09 08:16:34 -05:00
if ( ( * i ) . second . Emote )
{
if ( pSource - > GetTypeId ( ) = = TYPEID_UNIT | | pSource - > GetTypeId ( ) = = TYPEID_PLAYER )
{
( ( Unit * ) pSource ) - > HandleEmoteCommand ( ( * i ) . second . Emote ) ;
}
else
error_log ( " TSCR: DoScriptText entry %i tried to process emote for invalid TypeId (%u). " , textEntry , pSource - > GetTypeId ( ) ) ;
}
2008-12-31 12:33:54 +01:00
2008-10-11 14:16:25 -05:00
switch ( ( * i ) . second . Type )
{
case CHAT_TYPE_SAY :
pSource - > MonsterSay ( textEntry , ( * i ) . second . Language , target ? target - > GetGUID ( ) : 0 ) ;
break ;
case CHAT_TYPE_YELL :
pSource - > MonsterYell ( textEntry , ( * i ) . second . Language , target ? target - > GetGUID ( ) : 0 ) ;
break ;
case CHAT_TYPE_TEXT_EMOTE :
pSource - > MonsterTextEmote ( textEntry , target ? target - > GetGUID ( ) : 0 ) ;
break ;
case CHAT_TYPE_BOSS_EMOTE :
pSource - > MonsterTextEmote ( textEntry , target ? target - > GetGUID ( ) : 0 , true ) ;
break ;
case CHAT_TYPE_WHISPER :
{
if ( target & & target - > GetTypeId ( ) = = TYPEID_PLAYER )
pSource - > MonsterWhisper ( textEntry , target - > GetGUID ( ) ) ;
else error_log ( " TSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER). " , textEntry ) ;
} break ;
case CHAT_TYPE_BOSS_WHISPER :
{
if ( target & & target - > GetTypeId ( ) = = TYPEID_PLAYER )
pSource - > MonsterWhisper ( textEntry , target - > GetGUID ( ) , true ) ;
else error_log ( " TSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER). " , textEntry ) ;
} break ;
}
}
2008-10-25 11:40:10 -05:00
//*********************************
//*** Functions used internally ***
2008-11-20 16:16:57 -06:00
void Script : : RegisterSelf ( )
2008-11-03 08:14:21 -06:00
{
2008-11-20 16:16:57 -06:00
int id = GetScriptId ( Name . c_str ( ) ) ;
if ( id ! = 0 )
2008-10-11 14:16:25 -05:00
{
2008-11-20 16:16:57 -06:00
m_scripts [ id ] = this ;
+ + num_sc_scripts ;
2009-02-20 14:14:16 +01:00
}
else
{
debug_log ( " TSCR: RegisterSelf, but script named %s does not have ScriptName assigned in database. " , ( this ) - > Name . c_str ( ) ) ;
delete this ;
}
2008-10-11 14:16:25 -05:00
}
//********************************
//*** Functions to be Exported ***
2008-11-20 16:16:57 -06:00
TRINITY_DLL_EXPORT
char const * ScriptsVersion ( )
{
2009-02-09 08:16:34 -05:00
return " Default Trinity scripting library " ;
2008-11-20 16:16:57 -06:00
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool GossipHello ( Player * player , Creature * _Creature )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Creature - > GetScriptId ( ) ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pGossipHello ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pGossipHello ( player , _Creature ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool GossipSelect ( Player * player , Creature * _Creature , uint32 sender , uint32 action )
{
debug_log ( " TSCR: Gossip selection, sender: %d, action: %d " , sender , action ) ;
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Creature - > GetScriptId ( ) ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pGossipSelect ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pGossipSelect ( player , _Creature , sender , action ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool GossipSelectWithCode ( Player * player , Creature * _Creature , uint32 sender , uint32 action , const char * sCode )
{
debug_log ( " TSCR: Gossip selection with code, sender: %d, action: %d " , sender , action ) ;
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Creature - > GetScriptId ( ) ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pGossipSelectWithCode ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pGossipSelectWithCode ( player , _Creature , sender , action , sCode ) ;
}
2009-03-30 16:57:17 +02:00
TRINITY_DLL_EXPORT
bool GOSelect ( Player * player , GameObject * _GO , uint32 sender , uint32 action )
{
debug_log ( " TSCR: Gossip selection, sender: %d, action: %d " , sender , action ) ;
Script * tmpscript = m_scripts [ _GO - > GetGOInfo ( ) - > ScriptId ] ;
if ( ! tmpscript | | ! tmpscript - > pGOSelect ) return false ;
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pGOSelect ( player , _GO , sender , action ) ;
}
TRINITY_DLL_EXPORT
bool GOSelectWithCode ( Player * player , GameObject * _GO , uint32 sender , uint32 action , const char * sCode )
{
debug_log ( " TSCR: Gossip selection, sender: %d, action: %d " , sender , action ) ;
Script * tmpscript = m_scripts [ _GO - > GetGOInfo ( ) - > ScriptId ] ;
if ( ! tmpscript | | ! tmpscript - > pGOSelectWithCode ) return false ;
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pGOSelectWithCode ( player , _GO , sender , action , sCode ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool QuestAccept ( Player * player , Creature * _Creature , Quest const * _Quest )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Creature - > GetScriptId ( ) ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pQuestAccept ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pQuestAccept ( player , _Creature , _Quest ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool QuestSelect ( Player * player , Creature * _Creature , Quest const * _Quest )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Creature - > GetScriptId ( ) ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pQuestSelect ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pQuestSelect ( player , _Creature , _Quest ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool QuestComplete ( Player * player , Creature * _Creature , Quest const * _Quest )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Creature - > GetScriptId ( ) ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pQuestComplete ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pQuestComplete ( player , _Creature , _Quest ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool ChooseReward ( Player * player , Creature * _Creature , Quest const * _Quest , uint32 opt )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Creature - > GetScriptId ( ) ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pChooseReward ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pChooseReward ( player , _Creature , _Quest , opt ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
uint32 NPCDialogStatus ( Player * player , Creature * _Creature )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Creature - > GetScriptId ( ) ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pNPCDialogStatus ) return 100 ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pNPCDialogStatus ( player , _Creature ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
uint32 GODialogStatus ( Player * player , GameObject * _GO )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _GO - > GetGOInfo ( ) - > ScriptId ] ;
if ( ! tmpscript | | ! tmpscript - > pGODialogStatus ) return 100 ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pGODialogStatus ( player , _GO ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool ItemHello ( Player * player , Item * _Item , Quest const * _Quest )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Item - > GetProto ( ) - > ScriptId ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pItemHello ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pItemHello ( player , _Item , _Quest ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool ItemQuestAccept ( Player * player , Item * _Item , Quest const * _Quest )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Item - > GetProto ( ) - > ScriptId ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pItemQuestAccept ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pItemQuestAccept ( player , _Item , _Quest ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool GOHello ( Player * player , GameObject * _GO )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _GO - > GetGOInfo ( ) - > ScriptId ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pGOHello ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pGOHello ( player , _GO ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool GOQuestAccept ( Player * player , GameObject * _GO , Quest const * _Quest )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _GO - > GetGOInfo ( ) - > ScriptId ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pGOQuestAccept ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pGOQuestAccept ( player , _GO , _Quest ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool GOChooseReward ( Player * player , GameObject * _GO , Quest const * _Quest , uint32 opt )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _GO - > GetGOInfo ( ) - > ScriptId ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pGOChooseReward ) return false ;
2008-10-11 14:16:25 -05:00
player - > PlayerTalkClass - > ClearMenus ( ) ;
return tmpscript - > pGOChooseReward ( player , _GO , _Quest , opt ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool AreaTrigger ( Player * player , AreaTriggerEntry * atEntry )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ GetAreaTriggerScriptId ( atEntry - > id ) ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pAreaTrigger ) return false ;
2008-10-11 14:16:25 -05:00
return tmpscript - > pAreaTrigger ( player , atEntry ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
CreatureAI * GetAI ( Creature * _Creature )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Creature - > GetScriptId ( ) ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > GetAI ) return NULL ;
2008-11-20 16:16:57 -06:00
2008-10-11 14:16:25 -05:00
return tmpscript - > GetAI ( _Creature ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool ItemUse ( Player * player , Item * _Item , SpellCastTargets const & targets )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Item - > GetProto ( ) - > ScriptId ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pItemUse ) return false ;
2008-10-11 14:16:25 -05:00
return tmpscript - > pItemUse ( player , _Item , targets ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
bool ReceiveEmote ( Player * player , Creature * _Creature , uint32 emote )
{
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ _Creature - > GetScriptId ( ) ] ;
2008-10-25 11:40:10 -05:00
if ( ! tmpscript | | ! tmpscript - > pReceiveEmote ) return false ;
2008-10-11 14:16:25 -05:00
return tmpscript - > pReceiveEmote ( player , _Creature , emote ) ;
}
2008-10-14 11:57:03 -05:00
TRINITY_DLL_EXPORT
2008-10-11 14:16:25 -05:00
InstanceData * CreateInstanceData ( Map * map )
{
2008-11-20 16:16:57 -06:00
if ( ! map - > IsDungeon ( ) ) return NULL ;
2008-10-11 14:16:25 -05:00
2008-11-20 16:16:57 -06:00
Script * tmpscript = m_scripts [ ( ( InstanceMap * ) map ) - > GetScriptId ( ) ] ;
if ( ! tmpscript | | ! tmpscript - > GetInstanceData ) return NULL ;
2008-10-11 14:16:25 -05:00
return tmpscript - > GetInstanceData ( map ) ;
}
2009-02-17 20:07:49 -06:00
2009-03-13 20:34:36 -06:00
TRINITY_DLL_EXPORT
bool EffectDummyGameObj ( Unit * caster , uint32 spellId , uint32 effIndex , GameObject * gameObjTarget )
{
Script * tmpscript = m_scripts [ gameObjTarget - > GetGOInfo ( ) - > ScriptId ] ;
if ( ! tmpscript | | ! tmpscript - > pEffectDummyGameObj ) return false ;
return tmpscript - > pEffectDummyGameObj ( caster , spellId , effIndex , gameObjTarget ) ;
}
TRINITY_DLL_EXPORT
bool EffectDummyCreature ( Unit * caster , uint32 spellId , uint32 effIndex , Creature * crTarget )
{
Script * tmpscript = m_scripts [ crTarget - > GetScriptId ( ) ] ;
if ( ! tmpscript | | ! tmpscript - > pEffectDummyCreature ) return false ;
return tmpscript - > pEffectDummyCreature ( caster , spellId , effIndex , crTarget ) ;
}
TRINITY_DLL_EXPORT
bool EffectDummyItem ( Unit * caster , uint32 spellId , uint32 effIndex , Item * itemTarget )
{
Script * tmpscript = m_scripts [ itemTarget - > GetProto ( ) - > ScriptId ] ;
if ( ! tmpscript | | ! tmpscript - > pEffectDummyItem ) return false ;
return tmpscript - > pEffectDummyItem ( caster , spellId , effIndex , itemTarget ) ;
}