Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp (revision 18)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp (revision 28)
@@ -88,5 +88,5 @@
         Abuse_Bug_Timer = 10000 + rand()%7000;
         BugsTimer = 2000;
-        m_creature->clearUnitState(UNIT_STAT_STUNDED);
+        m_creature->clearUnitState(UNIT_STAT_STUNNED);
         DontYellWhenDead = false;
         EnrageTimer = 15*60000;
@@ -291,5 +291,5 @@
         DoResetThreat();
         DoCast(m_creature, SPELL_TWIN_TELEPORT_VISUAL);
-        m_creature->addUnitState(UNIT_STAT_STUNDED);
+        m_creature->addUnitState(UNIT_STAT_STUNNED);
         AfterTeleport = true;
         AfterTeleportTimer = 2000;
@@ -303,7 +303,7 @@
             if (!tspellcasted)
             {
-                m_creature->clearUnitState(UNIT_STAT_STUNDED);
+                m_creature->clearUnitState(UNIT_STAT_STUNNED);
                 DoCast(m_creature, SPELL_TWIN_TELEPORT);
-                m_creature->addUnitState(UNIT_STAT_STUNDED);
+                m_creature->addUnitState(UNIT_STAT_STUNNED);
             }
 
@@ -313,5 +313,5 @@
             {
                 AfterTeleport = false;
-                m_creature->clearUnitState(UNIT_STAT_STUNDED);
+                m_creature->clearUnitState(UNIT_STAT_STUNNED);
                 Unit *nearu = PickNearestPlayer();
                 //DoYell(nearu->GetName(), LANG_UNIVERSAL, 0);
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp (revision 18)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp (revision 28)
@@ -400,5 +400,5 @@
         }else EnfeebleResetTimer -= diff;
 
-        if(m_creature->hasUnitState(UNIT_STAT_STUNDED))     //While shifting to phase 2 malchezaar stuns himself
+        if(m_creature->hasUnitState(UNIT_STAT_STUNNED))     //While shifting to phase 2 malchezaar stuns himself
             return;
 
Index: trunk/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp (revision 6)
+++ trunk/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp (revision 28)
@@ -17,5 +17,5 @@
 /* ScriptData
 SDName: Instance_Magisters_Terrace
-SD%Complete: 100
+SD%Complete: 60
 SDComment:  Designed only for Selin Fireheart
 SDCategory: Magister's Terrace
@@ -119,13 +119,22 @@
         switch(entry)
         {
-            case 24723:
-                SelinGUID = creature->GetGUID();
-                break;
-            case 24560:
-                DelrissaGUID = creature->GetGUID();
-                break;
-            case 24722:
-                FelCrystals.push_back(creature->GetGUID());
-                break;
+            case 24723: SelinGUID = creature->GetGUID(); break;
+            case 24560: DelrissaGUID = creature->GetGUID(); break;
+            case 24722: FelCrystals.push_back(creature->GetGUID()); break;
+        }
+    }
+
+    void OnObjectCreate(GameObject* go)
+    {
+        switch(go->GetEntry())
+        {
+            case 187896:  VexallusDoorGUID = go->GetGUID();       break;
+            //SunwellRaid Gate 02
+            case 187979:  SelinDoorGUID = go->GetGUID();          break;
+            //Assembly Chamber Door
+            case 188065:  SelinEncounterDoorGUID = go->GetGUID(); break;
+            case 187770:  DelrissaDoorGUID = go->GetGUID();       break;
+            case 188165:  KaelStatue[0] = go->GetGUID();          break;
+            case 188166:  KaelStatue[1] = go->GetGUID();          break;
         }
     }
@@ -165,17 +174,4 @@
         return 0;
     }
-
-    void OnObjectCreate(GameObject* go)
-    {
-        switch(go->GetEntry())
-        {
-            case 187896:  VexallusDoorGUID = go->GetGUID();       break;
-            case 187979:  SelinDoorGUID = go->GetGUID();          break;
-            case 188118:  SelinEncounterDoorGUID = go->GetGUID(); break;
-            case 187770:  DelrissaDoorGUID = go->GetGUID();       break;
-            case 188165:  KaelStatue[0] = go->GetGUID();          break;
-            case 188166:  KaelStatue[1] = go->GetGUID();          break;
-        }
-    }
 };
 
Index: trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp (revision 6)
+++ trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp (revision 28)
@@ -17,5 +17,5 @@
 /* ScriptData
 SDName: Boss_Selin_Fireheart
-SD%Complete: 99
+SD%Complete: 90
 SDComment: Heroic and Normal Support. Needs further testing.
 SDCategory: Magister's Terrace
@@ -74,5 +74,5 @@
             {
                 uint64 guid = pInstance->GetData64(DATA_FEL_CRYSTAL);
-                outstring_log("Selin: Adding Fel Crystal %u to list", guid);
+                debug_log("SD2: Selin: Adding Fel Crystal %u to list", guid);
                 Crystals.push_back(guid);
             }
@@ -117,7 +117,7 @@
 
             GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR));
-            if(Door)
-                Door->SetGoState(0);                        // Close the door. Open it only in JustDied.
-
+            if( Door )
+                Door->SetGoState(0);                        // Open the big encounter door. Close it in Aggro and open it only in JustDied(and here)
+                                                            // Small door opened after event are expected to be closed by default
             // Set Inst data for encounter
             pInstance->SetData(DATA_SELIN_EVENT, NOT_STARTED);
@@ -161,8 +161,9 @@
             }
         }
-        if(CrystalChosen)
+        if( CrystalChosen )
         {
             DoYell(SAY_ENERGY, LANG_UNIVERSAL, NULL);
             DoPlaySoundToSet(m_creature, SOUND_ENERGY);
+
             CrystalChosen->CastSpell(CrystalChosen, SPELL_FEL_CRYSTAL_COSMETIC, true);
 
@@ -186,5 +187,5 @@
             //Creature* pCrystal = ((Creature*)Unit::GetUnit(*m_creature, FelCrystals[i]));
             Creature* pCrystal = ((Creature*)Unit::GetUnit(*m_creature, *itr));
-            if(pCrystal && pCrystal->isAlive())
+            if( pCrystal && pCrystal->isAlive())
                 pCrystal->DealDamage(pCrystal, pCrystal->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
         }
@@ -195,4 +196,11 @@
         DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL);
         DoPlaySoundToSet(m_creature, SOUND_AGGRO);
+
+        if( pInstance )
+        {
+            GameObject* EncounterDoor = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR));
+            if( EncounterDoor )
+                EncounterDoor->SetGoState(1);               //Close the encounter door, open it in JustDied/Reset
+        }
     }
 
@@ -246,7 +254,12 @@
 
         pInstance->SetData(DATA_SELIN_EVENT, DONE);         // Encounter complete!
+
         GameObject* EncounterDoor = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR));
-        if(EncounterDoor)
-            EncounterDoor->SetGoState(1);                   // Open the door
+        if( EncounterDoor )
+            EncounterDoor->SetGoState(0);                   // Open the encounter door
+
+        GameObject* ContinueDoor = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_SELIN_DOOR));
+        if( ContinueDoor )
+            ContinueDoor->SetGoState(0);                    // Open the door leading further in
 
         ShatterRemainingCrystals();
@@ -303,21 +316,25 @@
         }else
         {
-            if(IsDraining)
-                if(EmpowerTimer < diff)
-            {
-                IsDraining = false;
-                DrainingCrystal = false;
-                DoYell(SAY_EMPOWERED, LANG_UNIVERSAL, NULL);
-                DoPlaySoundToSet(m_creature, SOUND_EMPOWERED);
-                Unit* CrystalChosen = Unit::GetUnit(*m_creature, CrystalGUID);
-                if(CrystalChosen && CrystalChosen->isAlive())
-                    // Use Deal Damage to kill it, not setDeathState.
-                    CrystalChosen->DealDamage(CrystalChosen, CrystalChosen->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
-
-                CrystalGUID = 0;
-
-                m_creature->GetMotionMaster()->Clear();
-                m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
-            }else EmpowerTimer -= diff;
+            if( IsDraining )
+            {
+                if( EmpowerTimer < diff )
+                {
+                    IsDraining = false;
+                    DrainingCrystal = false;
+
+                    DoYell(SAY_EMPOWERED, LANG_UNIVERSAL, NULL);
+                    DoPlaySoundToSet(m_creature, SOUND_EMPOWERED);
+
+                    Unit* CrystalChosen = Unit::GetUnit(*m_creature, CrystalGUID);
+                    if( CrystalChosen && CrystalChosen->isAlive() )
+                        // Use Deal Damage to kill it, not setDeathState.
+                        CrystalChosen->DealDamage(CrystalChosen, CrystalChosen->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
+
+                    CrystalGUID = 0;
+
+                    m_creature->GetMotionMaster()->Clear();
+                    m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
+                }else EmpowerTimer -= diff;
+            }
         }
 
Index: trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp (revision 6)
+++ trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp (revision 28)
@@ -1003,5 +1003,5 @@
             }else Freezing_Trap_Timer -= diff;
 
-            if(!m_creature->getVictim()->hasUnitState(UNIT_STAT_STUNDED | UNIT_STAT_ROOT | UNIT_STAT_CONFUSED | UNIT_STAT_DISTRACTED))
+            if(!m_creature->getVictim()->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_ROOT | UNIT_STAT_CONFUSED | UNIT_STAT_DISTRACTED))
                 DoMeleeAttackIfReady();
         }else
Index: trunk/src/bindings/scripts/ScriptMgr.cpp
===================================================================
--- trunk/src/bindings/scripts/ScriptMgr.cpp (revision 12)
+++ trunk/src/bindings/scripts/ScriptMgr.cpp (revision 28)
@@ -1,3 +1,3 @@
-/* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
+/* 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 */
@@ -5,8 +5,8 @@
 #include "precompiled.h"
 #include "Config/Config.h"
+#include "Database/DatabaseEnv.h"
+#include "Database/DBCStores.h"
+#include "ObjectMgr.h"
 #include "ProgressBar.h"
-#include "Database/DBCStores.h"
-#include "Database/DatabaseMysql.h"
-#include "ObjectMgr.h"
 #include "scripts/creature/mob_event_ai.h"
 
@@ -25,17 +25,17 @@
 Script *m_scripts[MAX_SCRIPTS];
 
-// Text Map for Event AI
-HM_NAMESPACE::hash_map<uint32, std::string> EventAI_Text_Map;
-
-// Script Text used as says / yells / text emotes / whispers in scripts.
-struct ScriptText
+DatabaseType TScriptDB;
+Config TScriptConfig;
+uint32 Locale;
+
+// String text additional data, used in TextMap
+struct StringTextData
 {
     uint32 SoundId;
     uint8  Type;
     uint32 Language;
-    std::string Text;
 };
 
-// Enums used by ScriptText::Type
+// Enums used by StringTextData::Type
 enum ChatType
 {
@@ -48,5 +48,9 @@
 };
 
-HM_NAMESPACE::hash_map<uint32, ScriptText> Script_TextMap;
+#define TEXT_SOURCE_RANGE   -100000                         //the amount of entries each text source has available
+
+// Text Maps
+HM_NAMESPACE::hash_map<uint32, std::string> EventAI_Text_Map;
+HM_NAMESPACE::hash_map<int32, StringTextData> TextMap;
 
 // Localized Text structure for storing locales (for EAI and SD2 scripts).
@@ -62,10 +66,9 @@
     std::string locale_8;
 };
+//*** End Global data ***
+
+//*** EventAI data ***
 HM_NAMESPACE::hash_map<uint32, Localized_Text> EventAI_LocalizedTextMap;
-HM_NAMESPACE::hash_map<uint32, Localized_Text> Script_LocalizedTextMap;
-
-//*** End Global data ***
-
-//*** EventAI data ***
+
 //Event AI structure. Used exclusivly by mob_event_ai.cpp (60 bytes each)
 std::list<EventAI_Event> EventAI_Event_List;
@@ -78,10 +81,5 @@
 
 uint32 EAI_ErrorLevel;
-
 //*** End EventAI data ***
-
-DatabaseMysql TScriptDB;
-Config TScriptConfig;
-uint32 Locale;
 
 void FillSpellSummary();
@@ -598,508 +596,585 @@
     //Get db string from file
     char const* dbstring = NULL;
-    if(!TScriptConfig.GetString("TScriptDatabaseInfo", &dbstring))
-        error_log("TSCR: Missing Trinity Script Database Info in configuration file");
-
-    //Initilize connection to DB
-    if(!dbstring || !TScriptDB.Initialize(dbstring))
-        error_db_log("TSCR: Unable to connect to Database");
+
+    if( !TScriptConfig.GetString("TScriptDatabaseInfo", &dbstring) )
+    {
+        error_log("TSCR: Missing Trinity Script database info from configuration file. Load database aborted.");
+        return;
+    }
+
+    //Initialize connection to DB
+    if( dbstring && TScriptDB.Initialize(dbstring) )
+        outstring_log("TSCR: TrinityScript database: %s",dbstring);
     else
     {
-        //***Preform all DB queries here***
-        QueryResult *result;
-
-        //Get Version information
-        result = TScriptDB.PQuery("SELECT `version`"
-            "FROM `script_db_version`");
-
-        if (result)
+        error_log("TSCR: Unable to connect to Database. Load database aborted.");
+        return;
+    }
+
+    //***Preform all DB queries here***
+    QueryResult *result;
+
+    //Get Version information
+    result = TScriptDB.PQuery("SELECT version FROM script_db_version");
+
+    if (result)
+    {
+        Field *fields = result->Fetch();
+        outstring_log("TSCR: Database version is: %s", fields[0].GetString());
+        outstring_log("");
+        delete result;
+
+    }else
+    {
+        error_log("TSCR: Missing `script_db_version` information.");
+        outstring_log("");
+    }
+
+    // Drop Existing Text Map, only done once and we are ready to add data from multiple sources.
+    TextMap.clear();
+
+    //TODO: Add load from eventai_texts here
+
+    // Load Script Text 
+    outstring_log("TSCR: Loading Script Texts...");
+    LoadMangosStrings(TScriptDB,"script_texts",TEXT_SOURCE_RANGE,(TEXT_SOURCE_RANGE*2)+1);
+
+    // Gather Additional data from Script Texts
+    result = TScriptDB.PQuery("SELECT entry, sound, type, language FROM script_texts");
+
+    outstring_log("TSCR: Loading Script Texts additional data...");
+    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();
+
+            if (i >= 0)
+            {
+                error_db_log("TSCR: Entry %i in table `script_texts` is not a negative value.",i);
+                continue;
+            }
+
+            if (i > TEXT_SOURCE_RANGE || i <= TEXT_SOURCE_RANGE*2)
+            {
+                error_db_log("TSCR: Entry %i in table `script_texts` is out of accepted entry range for table.",i);
+                continue;
+            }
+
+            if (temp.SoundId)
+            {
+                if (!GetSoundEntriesStore()->LookupEntry(temp.SoundId))
+                    error_db_log("TSCR: Entry %i in table `script_texts` has soundId %u but sound does not exist.",i,temp.SoundId);
+            }
+
+            if (!GetLanguageDescByID(temp.Language))
+                error_db_log("TSCR: Entry %i in table `script_texts` using Language %u but Language does not exist.",i,temp.Language);
+
+            if (temp.Type > CHAT_TYPE_BOSS_WHISPER)
+                error_db_log("TSCR: Entry %i in table `script_texts` has Type %u but this Chat Type does not exist.",i,temp.Type);
+
+            TextMap[i] = temp;
+            ++count;
+        } while (result->NextRow());
+
+        delete result;
+
+        outstring_log("");
+        outstring_log(">> TSCR: Loaded %u additional Script Texts data.", count);
+    }else
+    {
+        barGoLink bar(1);
+        bar.step();
+        outstring_log("");
+        outstring_log(">> Loaded 0 additional Script Texts data. DB table `script_texts` is empty.");
+    }
+
+    // Load Custom Text 
+    outstring_log("TSCR: Loading Custom Texts...");
+    LoadMangosStrings(TScriptDB,"custom_texts",TEXT_SOURCE_RANGE*2,(TEXT_SOURCE_RANGE*3)+1);
+
+    // Gather Additional data from Custom Texts
+    result = TScriptDB.PQuery("SELECT entry, sound, type, language FROM custom_texts");
+
+    outstring_log("TSCR: Loading Custom Texts additional data...");
+    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();
+
+            if (i >= 0)
+            {
+                error_db_log("TSCR: Entry %i in table `custom_texts` is not a negative value.",i);
+                continue;
+            }
+
+            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;
+            }
+
+            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);
+            }
+
+            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);
+
+            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);
+
+            TextMap[i] = temp;
+            ++count;
+        } while (result->NextRow());
+
+        delete result;
+
+        outstring_log("");
+        outstring_log(">> Loaded %u additional Custom Texts data.", count);
+    }else
+    {
+        barGoLink bar(1);
+        bar.step();
+        outstring_log("");
+        outstring_log(">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty.");
+    }
+
+    // Drop existing Event AI Localized Text hash map
+    EventAI_LocalizedTextMap.clear();
+
+    // Gather EventAI Localized Texts
+    result = TScriptDB.PQuery("SELECT id, locale_1, locale_2, locale_3, locale_4, locale_5, locale_6, locale_7, locale_8 "
+        "FROM eventai_localized_texts");
+
+    outstring_log("TSCR: Loading EventAI Localized Texts...");
+    if(result)
+    {
+        barGoLink bar(result->GetRowCount());
+        uint32 count = 0;
+
+        do
+        {
+            Localized_Text temp;
+            bar.step();
+
             Field *fields = result->Fetch();
-            outstring_log(" ");
-            outstring_log("TSCR: Database version is: %s", fields[0].GetString());
-            outstring_log(" ");
-            delete result;
-
-        }else error_db_log("TSCR: Missing script_db_version information.");
-
-        // Drop existing Event AI Localized Text hash map
-        EventAI_LocalizedTextMap.clear();
-
-        // Gather EventAI Localized Texts
-        result = TScriptDB.PQuery("SELECT `id`,`locale_1`,`locale_2`,`locale_3`,`locale_4`,`locale_5`,`locale_6`,`locale_7`,`locale_8`"
-            "FROM `eventai_localized_texts`");
-
-        if(result)
+
+            uint32 i = fields[0].GetInt32();
+
+            temp.locale_1 = fields[1].GetString();
+            temp.locale_2 = fields[2].GetString();
+            temp.locale_3 = fields[3].GetString();
+            temp.locale_4 = fields[4].GetString();
+            temp.locale_5 = fields[5].GetString();
+            temp.locale_6 = fields[6].GetString();
+            temp.locale_7 = fields[7].GetString();
+            temp.locale_8 = fields[8].GetString();
+
+            EventAI_LocalizedTextMap[i] = temp;
+            ++count;
+
+        }while(result->NextRow());
+
+        delete result;
+
+        outstring_log("");
+        outstring_log(">> Loaded %u EventAI Localized Texts", count);
+    }else
+    {
+        barGoLink bar(1);
+        bar.step();
+        outstring_log("");
+        outstring_log(">> Loaded 0 EventAI Localized Texts. DB table `eventai_localized_texts` is empty");
+    }
+
+    //Drop existing EventAI Text hash map
+    EventAI_Text_Map.clear();
+
+    //Gather EventAI Text Entries
+    result = TScriptDB.PQuery("SELECT id, text FROM eventai_texts");
+
+    outstring_log("TSCR: Loading EventAI_Texts...");
+    if (result)
+    {
+        barGoLink bar(result->GetRowCount());
+        uint32 Count = 0;
+
+        do
         {
-            outstring_log("TSCR: Loading EAI Localized Texts....");
-            barGoLink bar(result->GetRowCount());
-            uint32 count = 0;
-
-            do
+            bar.step();
+            Field *fields = result->Fetch();
+
+            uint32 i = fields[0].GetInt32();
+
+            std::string text = fields[1].GetString();
+
+            if (!strlen(text.c_str()))
+                error_db_log("TSCR: EventAI text %u is empty", i);
+
+            EventAI_Text_Map[i] = text;
+            ++Count;
+
+        }while (result->NextRow());
+
+        delete result;
+
+        outstring_log("");
+        outstring_log(">> Loaded %u EventAI texts", Count);
+    }else
+    {
+        barGoLink bar(1);
+        bar.step();
+        outstring_log("");
+        outstring_log(">> Loaded 0 EventAI texts. DB table `eventai_texts` is empty.");
+    }
+
+    //Gather event data
+    result = TScriptDB.PQuery("SELECT id, position_x, position_y, position_z, orientation, spawntimesecs FROM eventai_summons");
+
+    //Drop Existing EventSummon Map
+    EventAI_Summon_Map.clear();
+
+    outstring_log("TSCR: Loading EventAI_Summons...");
+    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.");
+    }
+
+    //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");
+
+    //Drop Existing EventAI List
+    EventAI_Event_List.clear();
+
+    outstring_log("TSCR: Loading EventAI_Scripts...");
+    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();
+            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();
+
+            //Report any errors in event
+            if (temp.event_type >= EVENT_T_END)
+                error_db_log("TSCR: Event %u has incorrect event type. Maybe DB requires updated version of SD2.", i);
+
+            //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)
             {
-                Localized_Text temp;
-                bar.step();
-                
-                Field *fields = result->Fetch();
-
-                uint32 i = fields[0].GetInt32();
-
-                temp.locale_1 = fields[1].GetString();
-                temp.locale_2 = fields[2].GetString();
-                temp.locale_3 = fields[3].GetString();
-                temp.locale_4 = fields[4].GetString();
-                temp.locale_5 = fields[5].GetString();
-                temp.locale_6 = fields[6].GetString();
-                temp.locale_7 = fields[7].GetString();
-                temp.locale_8 = fields[8].GetString();
-
-                EventAI_LocalizedTextMap[i] = temp;
-                ++count;
-
-            }while(result->NextRow());
-
-            delete result;
-
-            outstring_log("");
-            outstring_log("TSCR: Loaded %u EventAI Localized Texts", count);
-        }else outstring_log("TSCR: WARNING >> Loaded 0 EventAI Localized Texts. Database table `eventai_localized_texts` is empty");
-
-        // Drop Existing Script Localized Text Hash Map
-        Script_LocalizedTextMap.clear();
-
-        // Gather Script Localized Texts
-        result = TScriptDB.PQuery("SELECT `id`,`locale_1`,`locale_2`,`locale_3`,`locale_4`,`locale_5`,`locale_6`,`locale_7`,`locale_8`"
-            "FROM `script_localized_texts`");
-
-        if(result)
-        {
-            outstring_log("TSCR: Loading Script Localized Texts....");
-            barGoLink bar(result->GetRowCount());
-            uint32 count = 0;
-
-            do
+                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)
             {
-                Localized_Text temp;
-                bar.step();
-
-                Field *fields = result->Fetch();
-
-                uint32 i = fields[0].GetInt32();
-
-                temp.locale_1 = fields[1].GetString();
-                temp.locale_2 = fields[2].GetString();
-                temp.locale_3 = fields[3].GetString();
-                temp.locale_4 = fields[4].GetString();
-                temp.locale_5 = fields[5].GetString();
-                temp.locale_6 = fields[6].GetString();
-                temp.locale_7 = fields[7].GetString();
-                temp.locale_8 = fields[8].GetString();
-
-                Script_LocalizedTextMap[i] = temp;
-                ++count;
-
-            }while(result->NextRow());
-
-            delete result;
-
-            outstring_log("");
-            outstring_log("TSCR: Loaded %u Script Localized Texts", count);
-        }else outstring_log("TSCR: WARNING >> Loaded 0 Script Localized Texts. Database table `script_localized_texts` is empty");
-
-        //Drop existing EventAI Text hash map
-        EventAI_Text_Map.clear();
-
-        //Gather EventAI Text Entries
-        result = TScriptDB.PQuery("SELECT `id`,`text` FROM `eventai_texts`");
-
-        if (result)
-        {
-            outstring_log( "TSCR: Loading EventAI_Texts...");
-            barGoLink bar(result->GetRowCount());
-            uint32 Count = 0;
-
-            do
+                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;
+
+                case EVENT_T_RANGE:
+                case EVENT_T_OOC_LOS:
+                case EVENT_T_FRIENDLY_HP:
+                case EVENT_T_FRIENDLY_IS_CC:
+                case EVENT_T_FRIENDLY_MISSING_BUFF:
+                    {
+                        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;
+
+                case EVENT_T_AGGRO:
+                case EVENT_T_DEATH:
+                case EVENT_T_EVADE:
+                case EVENT_T_SPAWNED:
+                    {
+                        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;
+            }
+
+            for (uint32 j = 0; j < MAX_ACTIONS; j++)
             {
-                bar.step();
-                Field *fields = result->Fetch();
-
-                uint32 i = fields[0].GetInt32();
-
-                std::string text = fields[1].GetString();
-
-                if (!strlen(text.c_str()))
-                    error_db_log("TSCR: EventAI text %u is empty", i);
-
-                EventAI_Text_Map[i] = text;
-                ++Count;
-
-            }while (result->NextRow());
-
-            delete result;
-
-            outstring_log("");
-            outstring_log("TSCR: >> Loaded %u EventAI_Texts", Count);
-
-        }else outstring_log("TSCR: WARNING >> Loaded 0 EventAI_Texts. DB table `EventAI_Texts` is empty.");
-
-        //Gather event data
-        result = TScriptDB.PQuery("SELECT `id`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`"
-            "FROM `eventai_summons`");
-
-        //Drop Existing EventSummon Map
-        EventAI_Summon_Map.clear();
-
-        if (result)
-        {
-            outstring_log( "TSCR: Loading EventAI_Summons...");
-            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("TSCR: >> Loaded %u EventAI_Summons", Count);
-
-        }else outstring_log("TSCR: WARNING >> Loaded 0 EventAI_Summons. DB table `EventAI_Summons` is empty.");
-
-        //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`");
-
-        //Drop Existing EventAI List
-        EventAI_Event_List.clear();
-
-        if (result)
-        {
-            outstring_log( "TSCR: Loading EventAI_Scripts...");
-            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();
-                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();
-
-                //Report any errors in event
-                if (temp.event_type >= EVENT_T_END)
-                    error_db_log("TSCR: Event %u has incorrect event type. Maybe DB requires updated version of SD2.", i);
-
-                //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)
+                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)
                 {
-                    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:
+                    case ACTION_T_SAY:
+                    case ACTION_T_YELL:
+                    case ACTION_T_TEXTEMOTE:
+                        if (GetEventAIText(temp.action[j].param1) == DEFAULT_TEXT)
+                            error_db_log("TSCR: Event %u Action %u refrences missing Localized_Text entry", i, j+1);
+                        break;
+
+                    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;
+
+                    case ACTION_T_RANDOM_SAY:
+                    case ACTION_T_RANDOM_YELL:
+                    case ACTION_T_RANDOM_TEXTEMOTE:
+                        if ((temp.action[j].param1 != 0xffffffff && GetEventAIText(temp.action[j].param1) == DEFAULT_TEXT) ||
+                            (temp.action[j].param2 != 0xffffffff && GetEventAIText(temp.action[j].param2) == DEFAULT_TEXT) ||
+                            (temp.action[j].param3 != 0xffffffff && GetEventAIText(temp.action[j].param3) == DEFAULT_TEXT))
+                            error_db_log("TSCR: Event %u Action %u refrences missing Localized_Text entry", i, j+1);
+                        break;
+
+                    case ACTION_T_CAST:
                         {
-                            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;
-                            }
+                            if (!GetSpellStore()->LookupEntry(temp.action[j].param1))
+                                error_db_log("TSCR: Event %u Action %u uses non-existant SpellID %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;
 
-                    case EVENT_T_SPELLHIT:
+                    case ACTION_T_REMOVEAURASFROMSPELL:
                         {
-                            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);
+                            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;
 
-                    case EVENT_T_RANGE:
-                    case EVENT_T_OOC_LOS:
-                    case EVENT_T_FRIENDLY_HP:
-                    case EVENT_T_FRIENDLY_IS_CC:
-                    case EVENT_T_FRIENDLY_MISSING_BUFF:
+                    case ACTION_T_CASTCREATUREGO:
                         {
-                            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);
+                            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)
+                                error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1);
                         }
                         break;
 
-                    case EVENT_T_TIMER:
-                    case EVENT_T_TIMER_OOC:
+                    //2nd param target
+                    case ACTION_T_SUMMON_ID:
                         {
-                            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);
+                            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;
 
-                    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);
-                        }
+                    case ACTION_T_SUMMON:
+                    case ACTION_T_THREAT_SINGLE_PCT:
+                    case ACTION_T_QUEST_EVENT:
+                    case ACTION_T_SET_UNIT_FLAG:
+                    case ACTION_T_REMOVE_UNIT_FLAG:
+                    case ACTION_T_SET_INST_DATA64:
+                        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 EVENT_T_AGGRO:
-                    case EVENT_T_DEATH:
-                    case EVENT_T_EVADE:
-                    case EVENT_T_SPAWNED:
-                        {
-                            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;
-                            }
-                        }
+                    //3rd param target
+                    case ACTION_T_SET_UNIT_FIELD:
+                        if (temp.action[j].param3 >= TARGET_T_END)
+                            error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1);
                         break;
-                };
-
-                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)
-                    {
-                        case ACTION_T_SAY:
-                        case ACTION_T_YELL:
-                        case ACTION_T_TEXTEMOTE:
-                            if (GetEventAIText(temp.action[j].param1) == DEFAULT_TEXT)
-                                error_db_log("TSCR: Event %u Action %u refrences missing Localized_Text entry", i, j+1);
-                            break;
-
-                        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;
-
-                        case ACTION_T_RANDOM_SAY:
-                        case ACTION_T_RANDOM_YELL:
-                        case ACTION_T_RANDOM_TEXTEMOTE:
-                            if ((temp.action[j].param1 != 0xffffffff && GetEventAIText(temp.action[j].param1) == DEFAULT_TEXT) ||
-                                (temp.action[j].param2 != 0xffffffff && GetEventAIText(temp.action[j].param2) == DEFAULT_TEXT) ||
-                                (temp.action[j].param3 != 0xffffffff && GetEventAIText(temp.action[j].param3) == DEFAULT_TEXT))
-                                error_db_log("TSCR: Event %u Action %u refrences missing Localized_Text entry", i, j+1);
-                            break;
-
-                        case ACTION_T_CAST:
-                            {
-                                if (!GetSpellStore()->LookupEntry(temp.action[j].param1))
-                                    error_db_log("TSCR: Event %u Action %u uses non-existant SpellID %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;
-
-                        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;
-
-                        case ACTION_T_CASTCREATUREGO:
-                            {
-                                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)
-                                    error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1);
-                            }
-                            break;
-
-                        //2nd param target
-                        case ACTION_T_SUMMON_ID:
-                            {
-                                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;
-
-                        case ACTION_T_SUMMON:
-                        case ACTION_T_THREAT_SINGLE_PCT:
-                        case ACTION_T_QUEST_EVENT:
-                        case ACTION_T_SET_UNIT_FLAG:
-                        case ACTION_T_REMOVE_UNIT_FLAG:
-                        case ACTION_T_SET_INST_DATA64:
-                            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:
-                            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)
-                                error_db_log("TSCR: Event %u Action %u is incrementing phase by 0. Was this intended?", i, j+1);
-                            break;
-
-                        case ACTION_T_KILLED_MONSTER:
-                            if (temp.event_type != EVENT_T_DEATH)
-                                outstring_log("TSCR WARNING: Event %u Action %u calling ACTION_T_KILLED_MONSTER outside of EVENT_T_DEATH", i, j+1);
-                            break;
-
-                        case ACTION_T_SET_INST_DATA:
-                            if (temp.action[j].param2 > 3)
-                                error_db_log("TSCR: Event %u Action %u attempts to set instance data above encounter state 3. Custom case?", i, j+1);
-                            break;
-
-                        default:
-                            break;
-                    }
-
-                    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);
+
+                    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)
+                            error_db_log("TSCR: Event %u Action %u is incrementing phase by 0. Was this intended?", i, j+1);
+                        break;
+
+                    case ACTION_T_KILLED_MONSTER:
+                        if (temp.event_type != EVENT_T_DEATH)
+                            outstring_log("SD2 WARNING: Event %u Action %u calling ACTION_T_KILLED_MONSTER outside of EVENT_T_DEATH", i, j+1);
+                        break;
+
+                    case ACTION_T_SET_INST_DATA:
+                        if (temp.action[j].param2 > 3)
+                            error_db_log("TSCR: Event %u Action %u attempts to set instance data above encounter state 3. Custom case?", i, j+1);
+                        break;
+
+                    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
-                EventAI_Event_List.push_back(temp);
-                ++Count;
-
-            }while (result->NextRow());
-
-            delete result;
-            outstring_log("");
-            outstring_log("TSCR: >> Loaded %u EventAI_Events", Count);
-
-        }else outstring_log("TSCR: WARNING >> Loaded 0 EventAI_Scripts. DB table `EventAI_Scripts` is empty.");
-
-        // Gather Script Text 
-        result = TScriptDB.PQuery("SELECT `id`, `sound`, `type`, `language`, `text`"
-            "FROM `script_texts`;");
-
-        // Drop Existing Script Text Map
-        Script_TextMap.clear();
-
-        if(result)
-        {
-            outstring_log("TSCR: Loading Script Text...");
-            barGoLink bar(result->GetRowCount());
-            uint32 count = 0;
-
-            do
-            {
-                bar.step();
-                Field* fields = result->Fetch();
-                ScriptText temp;
-
-                uint32 i            = fields[0].GetInt32();
-                temp.SoundId        = fields[1].GetInt32();
-                temp.Type           = fields[2].GetInt32();
-                temp.Language       = fields[3].GetInt32();
-                temp.Text           = fields[4].GetString();
-
-                if (temp.SoundId)
-                {
-                    if (!GetSoundEntriesStore()->LookupEntry(temp.SoundId))
-                        error_db_log("TSCR: Id %u in table script_texts has soundid %u but sound does not exist.",i,temp.SoundId);
-                }
-
-                if(!strlen(temp.Text.c_str()))
-                    error_db_log("TSCR: Id %u in table script_texts has no text.", i);
-
-                Script_TextMap[i] = temp;
-                ++count;
-
-            }while(result->NextRow());
-
-            delete result;
-
-            outstring_log("");
-            outstring_log("TSCR: Loaded %u Script Texts", count);
-
-        }else outstring_log("TSCR WARNING >> Loaded 0 Script Texts. Database table `script_texts` is empty.");
-
-        //Free database thread and resources
-        TScriptDB.HaltDelayThread();
-
-        //***End DB queries***
+            }
+
+            //Add to list
+            EventAI_Event_List.push_back(temp);
+            ++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
-    uint8 Effects;    // set of enum SelectEffect 
+    uint8 Targets;                                          // set of enum SelectTarget
+    uint8 Effects;                                          // set of enum SelectEffect 
 }extern *SpellSummary;
 
@@ -1120,4 +1195,6 @@
 void ScriptsInit()
 {
+    bool CanLoadDB = true;
+
     //Trinity Script startup
     outstring_log(" _____     _       _ _         ____            _       _");
@@ -1132,7 +1209,9 @@
     //Get configuration file
     if (!TScriptConfig.SetSource(_TRINITY_SCRIPT_CONFIG))
-        error_log("TSCR: Unable to open configuration file, Database will be unaccessible");
-    else outstring_log("TSCR: Using configuration file %s", _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);
 
     //Check config file version
@@ -1150,31 +1229,34 @@
 
     outstring_log("TSCR: Using locale %u", Locale);
+
+    EAI_ErrorLevel = TScriptConfig.GetIntDefault("EAIErrorLevel", 1);
+
+    switch (EAI_ErrorLevel)
+    {
+    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;
+    }
+
     outstring_log("");
 
-    EAI_ErrorLevel = TScriptConfig.GetIntDefault("EAIErrorLevel", 1);
-
-    switch (EAI_ErrorLevel)
-    {
-        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;
-    }
+    //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("");
-
-    //Load database (must be called after TScriptConfig.SetSource)
-    LoadDatabase();
 
     nrscripts = 0;
@@ -1756,57 +1838,4 @@
 }
 
-const char* GetScriptLocalizedText(uint32 entry)
-{   
-    const char* temp = NULL;
-
-    HM_NAMESPACE::hash_map<uint32, Localized_Text>::iterator i = Script_LocalizedTextMap.find(entry);
-
-    if (i == Script_LocalizedTextMap.end())
-    {
-        error_log("TSCR: Script Localized Text %u not found", entry);
-        return DEFAULT_TEXT;
-    }
-
-    switch (Locale)
-    {
-        case 1:
-            temp =  (*i).second.locale_1.c_str();
-            break;
-
-        case 2:
-            temp =  (*i).second.locale_2.c_str();
-            break;
-
-        case 3:
-            temp =  (*i).second.locale_3.c_str();
-            break;
-
-        case 4:
-            temp =  (*i).second.locale_4.c_str();
-            break;
-
-        case 5:
-            temp =  (*i).second.locale_5.c_str();
-            break;
-
-        case 6:
-            temp =  (*i).second.locale_6.c_str();
-            break;
-
-        case 7:
-            temp =  (*i).second.locale_7.c_str();
-            break;
-
-        case 8:
-            temp =  (*i).second.locale_8.c_str();
-            break;
-    };
-
-    if (strlen(temp))
-        return temp;
-
-    return DEFAULT_TEXT;
-}
-
 const char* GetEventAIText(uint32 entry)
 {
@@ -1834,28 +1863,34 @@
 }
 
-void ProcessScriptText(uint32 id, WorldObject* pSource, Unit* target)
+void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target)
 {
     if (!pSource)
     {
-        error_log("TSCR: ProcessScriptText invalid Source pointer.");
+        error_log("TSCR: DoScriptText entry %i, invalid Source pointer.",textEntry);
         return;
     }
 
-    HM_NAMESPACE::hash_map<uint32, ScriptText>::iterator i = Script_TextMap.find(id);
-
-    if (i == Script_TextMap.end())
-    {
-        error_log("TSCR: ProcessScriptText could not find id %u.",id);
+    if (textEntry >= 0)
+    {
+        error_log("TSCR: DoScriptText attempts to process entry %i, but entry must be negative.",textEntry);
         return;
     }
 
+    HM_NAMESPACE::hash_map<int32, StringTextData>::iterator i = TextMap.find(textEntry);
+
+    if (i == TextMap.end())
+    {
+        error_log("TSCR: DoScriptText could not find text entry %i.",textEntry);
+        return;
+    }
+
     if((*i).second.SoundId)
     {
-        if(GetSoundEntriesStore()->LookupEntry((*i).second.SoundId))
+        if( GetSoundEntriesStore()->LookupEntry((*i).second.SoundId) )
         {
             pSource->SendPlaySound((*i).second.SoundId, false);
         }
         else
-            error_log("TSCR: ProcessScriptText id %u tried to process invalid soundid %u.",id,(*i).second.SoundId);
+            error_log("TSCR: DoScriptText entry %i tried to process invalid sound id %u.",textEntry,(*i).second.SoundId);
     }
 
@@ -1863,31 +1898,26 @@
     {
         case CHAT_TYPE_SAY:
-            pSource->MonsterSay((*i).second.Text.c_str(), (*i).second.Language, target ? target->GetGUID() : 0);
+            pSource->MonsterSay(textEntry, (*i).second.Language, target ? target->GetGUID() : 0);
             break;
-
         case CHAT_TYPE_YELL:
-            pSource->MonsterYell((*i).second.Text.c_str(), (*i).second.Language, target ? target->GetGUID() : 0);
+            pSource->MonsterYell(textEntry, (*i).second.Language, target ? target->GetGUID() : 0);
             break;
-
         case CHAT_TYPE_TEXT_EMOTE:
-            pSource->MonsterTextEmote((*i).second.Text.c_str(), target ? target->GetGUID() : 0);
+            pSource->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0);
             break;
-
         case CHAT_TYPE_BOSS_EMOTE:
-            pSource->MonsterTextEmote((*i).second.Text.c_str(), target ? target->GetGUID() : 0, true);
+            pSource->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0, true);
             break;
-
         case CHAT_TYPE_WHISPER:
             {
                 if (target && target->GetTypeId() == TYPEID_PLAYER)
-                    pSource->MonsterWhisper((*i).second.Text.c_str(), target->GetGUID());
-                else error_log("TSCR: ProcessScriptText id %u cannot whisper without target unit (TYPEID_PLAYER).", id);
+                    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((*i).second.Text.c_str(), target->GetGUID(), true);
-                else error_log("TSCR: ProcessScriptText id %u cannot whisper without target unit (TYPEID_PLAYER).", id);
+                    pSource->MonsterWhisper(textEntry, target->GetGUID(), true);
+                else error_log("TSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry);
             }break;
     }
Index: trunk/src/bindings/scripts/sql/scriptdev2_structure.sql
===================================================================
--- trunk/src/bindings/scripts/sql/scriptdev2_structure.sql (revision 5)
+++ trunk/src/bindings/scripts/sql/scriptdev2_structure.sql (revision 28)
@@ -74,29 +74,39 @@
 DROP TABLE IF EXISTS `script_texts`;
 CREATE TABLE `script_texts` (
-`id` int(11) unsigned NOT NULL auto_increment COMMENT 'Identifier',
-`sound` int(11) unsigned NOT NULL default '0',
-`type` int(11) unsigned NOT NULL default '0',
-`language` int(11) unsigned NOT NULL default '0',
-`text` varchar(255) NOT NULL default '',
-`comment` varchar(255) NOT NULL default '',
-PRIMARY KEY  (`id`)
+  `entry` mediumint(8) NOT NULL,
+  `content_default` text NOT NULL,
+  `content_loc1` text,
+  `content_loc2` text,
+  `content_loc3` text,
+  `content_loc4` text,
+  `content_loc5` text,
+  `content_loc6` text,
+  `content_loc7` text,
+  `content_loc8` text,
+  `sound` mediumint(8) unsigned NOT NULL default '0',
+  `type` tinyint unsigned NOT NULL default '0',
+  `language` tinyint unsigned NOT NULL default '0',
+  `comment` text,
+  PRIMARY KEY  (`entry`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Script Texts';
 
-
-DROP TABLE IF EXISTS `script_localized_texts`;
-CREATE TABLE `script_localized_texts` (
-`id` int(11) unsigned NOT NULL auto_increment COMMENT 'Identifier',
-`locale_1` varchar(255) NOT NULL default '',
-`locale_2` varchar(255) NOT NULL default '',
-`locale_3` varchar(255) NOT NULL default '',
-`locale_4` varchar(255) NOT NULL default '',
-`locale_5` varchar(255) NOT NULL default '',
-`locale_6` varchar(255) NOT NULL default '',
-`locale_7` varchar(255) NOT NULL default '',
-`locale_8` varchar(255) NOT NULL default '',
-`comment` varchar(255) NOT NULL default '' COMMENT 'Text Comment',
-PRIMARY KEY  (`id`)            
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Localized Script Text';
-
+DROP TABLE IF EXISTS `custom_texts`;
+CREATE TABLE `custom_texts` (
+  `entry` mediumint(8) NOT NULL,
+  `content_default` text NOT NULL,
+  `content_loc1` text,
+  `content_loc2` text,
+  `content_loc3` text,
+  `content_loc4` text,
+  `content_loc5` text,
+  `content_loc6` text,
+  `content_loc7` text,
+  `content_loc8` text,
+  `sound` mediumint(8) unsigned NOT NULL default '0',
+  `type` tinyint unsigned NOT NULL default '0',
+  `language` tinyint unsigned NOT NULL default '0',
+  `comment` text,
+  PRIMARY KEY  (`entry`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Custom Texts';
 
 DROP TABLE IF EXISTS `script_db_version`;
Index: trunk/src/bindings/scripts/ScriptMgr.h
===================================================================
--- trunk/src/bindings/scripts/ScriptMgr.h (revision 5)
+++ trunk/src/bindings/scripts/ScriptMgr.h (revision 28)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2006 - 2008 ScriptDev2 <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 */
+ * This program is free software licensed under GPL version 2
+ * Please see the included DOCS/LICENSE.TXT for more information */
 
 #ifndef SCRIPTMGR_H
@@ -22,12 +22,8 @@
 class WorldObject;
 
-#define MAX_SCRIPTS     1000            //72 bytes each (approx 71kb)
+#define MAX_SCRIPTS         1000                            //72 bytes each (approx 71kb)
+#define VISIBLE_RANGE       (166.0f)                        //MAX visible range (size of grid)
+#define DEFAULT_TEXT        "<Trinity Script Text Entry Missing!>"
 
-//MAX visible range (size of grid)
-#define VISIBLE_RANGE   (166.0f)
-
-#define DEFAULT_TEXT    "<Trinity Script Text Entry Missing!>"
-
-//
 struct Script
 {
@@ -41,5 +37,5 @@
 std::string Name;
 
-// -- Quest/gossip Methods to be scripted --
+// Quest/gossip Methods to be scripted
 bool (*pGossipHello         )(Player*, Creature*);
 bool (*pQuestAccept         )(Player*, Creature*, Quest const* );
@@ -62,5 +58,4 @@
 CreatureAI* (*GetAI)(Creature*);
 InstanceData* (*GetInstanceData)(Map*);
-// -----------------------------------------
 };
 
@@ -70,11 +65,10 @@
 // Localized Text function
 const char* GetEventAILocalizedText(uint32 entry);
-const char* GetScriptLocalizedText(uint32 entry);
 
 //EventAI text function
-const char* GetEventAIText(uint32 entry); // TODO: Locales
+const char* GetEventAIText(uint32 entry);                   // TODO: Locales
 
-// Script Text function
-void ProcessScriptText(uint32 id, WorldObject* pSource, Unit* target = NULL); // TODO: Locales
+//Generic scripting text function
+void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target = NULL);
 
 #if COMPILER == COMPILER_GNU
