diff options
50 files changed, 752 insertions, 917 deletions
diff --git a/sql/updates/117_trinityscript.sql b/sql/updates/117_trinityscript.sql new file mode 100644 index 00000000000..0f0b9ecf7c2 --- /dev/null +++ b/sql/updates/117_trinityscript.sql @@ -0,0 +1,64 @@ +--
+-- NOTE: If you have temporary stored data in table `eventai_localized_texts` make sure to make backup of this before running this update!
+-- NOTE: If you have any texts in current eventai_texts and they are not using entries valid for *_texts table, you _will_ get error messages on startup.
+-- NOTE: Do not run this update twice, it may create bad data if you choose to do so.
+--
+
+-- drop obsolete table
+DROP TABLE eventai_localized_texts;
+
+-- alter and add fields in table `eventai_texts`
+ALTER TABLE eventai_texts CHANGE COLUMN `id` `entry` mediumint(8) NOT NULL;
+ALTER TABLE eventai_texts CHANGE COLUMN `text` `content_default` text NOT NULL AFTER `entry`;
+ALTER TABLE eventai_texts ADD COLUMN `content_loc1` text AFTER `content_default`;
+ALTER TABLE eventai_texts ADD COLUMN `content_loc2` text AFTER `content_loc1`;
+ALTER TABLE eventai_texts ADD COLUMN `content_loc3` text AFTER `content_loc2`;
+ALTER TABLE eventai_texts ADD COLUMN `content_loc4` text AFTER `content_loc3`;
+ALTER TABLE eventai_texts ADD COLUMN `content_loc5` text AFTER `content_loc4`;
+ALTER TABLE eventai_texts ADD COLUMN `content_loc6` text AFTER `content_loc5`;
+ALTER TABLE eventai_texts ADD COLUMN `content_loc7` text AFTER `content_loc6`;
+ALTER TABLE eventai_texts ADD COLUMN `content_loc8` text AFTER `content_loc7`;
+ALTER TABLE eventai_texts ADD COLUMN `sound` mediumint(8) unsigned NOT NULL default '0' AFTER `content_loc8`;
+ALTER TABLE eventai_texts ADD COLUMN `type` tinyint unsigned NOT NULL default '0' AFTER `sound`;
+ALTER TABLE eventai_texts ADD COLUMN `language` tinyint unsigned NOT NULL default '0' AFTER `type`;
+ALTER TABLE eventai_texts MODIFY COLUMN `comment` text;
+
+-- get our current action type, and update text type = yell
+UPDATE eventai_texts,eventai_scripts SET eventai_texts.type=1 WHERE eventai_scripts.action1_type IN (2,7) AND eventai_scripts.action1_param1=eventai_texts.entry;
+UPDATE eventai_texts,eventai_scripts SET eventai_texts.type=1 WHERE eventai_scripts.action2_type IN (2,7) AND eventai_scripts.action2_param1=eventai_texts.entry;
+UPDATE eventai_texts,eventai_scripts SET eventai_texts.type=1 WHERE eventai_scripts.action3_type IN (2,7) AND eventai_scripts.action3_param1=eventai_texts.entry;
+-- get our current action type, and update text type = textemote
+UPDATE eventai_texts,eventai_scripts SET eventai_texts.type=2 WHERE eventai_scripts.action1_type IN (3,8) AND eventai_scripts.action1_param1=eventai_texts.entry;
+UPDATE eventai_texts,eventai_scripts SET eventai_texts.type=2 WHERE eventai_scripts.action2_type IN (3,8) AND eventai_scripts.action2_param1=eventai_texts.entry;
+UPDATE eventai_texts,eventai_scripts SET eventai_texts.type=2 WHERE eventai_scripts.action3_type IN (3,8) AND eventai_scripts.action3_param1=eventai_texts.entry;
+
+-- update our scripts, for all action type 2, 3, 6, 7 & 8 to become 1
+UPDATE eventai_scripts SET action1_type=1 WHERE action1_type IN (2,3,6,7,8);
+UPDATE eventai_scripts SET action2_type=1 WHERE action2_type IN (2,3,6,7,8);
+UPDATE eventai_scripts SET action3_type=1 WHERE action3_type IN (2,3,6,7,8);
+
+-- was OOC, so at least one could be -1, set this to 0 (dev note: below will be bad, if run twice)
+UPDATE eventai_scripts SET action1_param2=0 WHERE action1_type=1 AND action1_param2=-1;
+UPDATE eventai_scripts SET action1_param3=0 WHERE action1_type=1 AND action1_param3=-1;
+UPDATE eventai_scripts SET action2_param2=0 WHERE action2_type=1 AND action2_param2=-1;
+UPDATE eventai_scripts SET action2_param3=0 WHERE action2_type=1 AND action2_param3=-1;
+UPDATE eventai_scripts SET action3_param2=0 WHERE action3_type=1 AND action3_param2=-1;
+UPDATE eventai_scripts SET action3_param3=0 WHERE action3_type=1 AND action3_param3=-1;
+
+-- expect all to be action type 1 now, continue convert to negative text entry
+UPDATE eventai_scripts SET action1_param1=(`action1_param1`) *-1 WHERE action1_type=1 AND action1_param1>0;
+UPDATE eventai_scripts SET action2_param1=(`action2_param1`) *-1 WHERE action2_type=1 AND action2_param1>0;
+UPDATE eventai_scripts SET action3_param1=(`action3_param1`) *-1 WHERE action3_type=1 AND action3_param1>0;
+
+UPDATE eventai_scripts SET action1_param2=(`action1_param2`) *-1 WHERE action1_type=1 AND action1_param2>0;
+UPDATE eventai_scripts SET action2_param2=(`action2_param2`) *-1 WHERE action2_type=1 AND action2_param2>0;
+UPDATE eventai_scripts SET action3_param2=(`action3_param2`) *-1 WHERE action3_type=1 AND action3_param2>0;
+
+UPDATE eventai_scripts SET action1_param3=(`action1_param3`) *-1 WHERE action1_type=1 AND action1_param3>0;
+UPDATE eventai_scripts SET action2_param3=(`action2_param3`) *-1 WHERE action2_type=1 AND action2_param3>0;
+UPDATE eventai_scripts SET action3_param3=(`action3_param3`) *-1 WHERE action3_type=1 AND action3_param3>0;
+
+-- now we have negative numbers in script, must make sure text entries have same entry as script
+UPDATE eventai_texts SET entry=(`entry`) *-1 WHERE entry>0;
+
+ALTER TABLE script_texts MODIFY COLUMN `sound` mediumint(8) unsigned NOT NULL default '0';
diff --git a/sql/world.sql b/sql/world.sql index 924ef20df97..1c59f43fb16 100644 --- a/sql/world.sql +++ b/sql/world.sql @@ -569,10 +569,10 @@ CREATE TABLE `custom_texts` ( `content_loc7` text, `content_loc8` text, `sound` mediumint(8) unsigned NOT NULL default '0', - `type` tinyint(3) unsigned NOT NULL default '0', - `language` tinyint(3) unsigned NOT NULL default '0', + `type` tinyint unsigned NOT NULL default '0', + `language` tinyint unsigned NOT NULL default '0', `comment` text, - PRIMARY KEY (`entry`) + PRIMARY KEY (`entry`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Custom Texts'; -- @@ -690,30 +690,30 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `eventai_scripts`; CREATE TABLE `eventai_scripts` ( - `id` int(11) unsigned NOT NULL auto_increment COMMENT 'Identifier', + `id` int(11) unsigned NOT NULL COMMENT 'Identifier' AUTO_INCREMENT, `creature_id` int(11) unsigned NOT NULL default '0' COMMENT 'Creature Template Identifier', `event_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Event Type', - `event_inverse_phase_mask` int(11) NOT NULL default '0' COMMENT 'Mask which phases this event will not trigger in', + `event_inverse_phase_mask` int(11) signed NOT NULL default '0' COMMENT 'Mask which phases this event will not trigger in', `event_chance` int(3) unsigned NOT NULL default '100', `event_flags` int(3) unsigned NOT NULL default '0', - `event_param1` int(11) NOT NULL default '0', - `event_param2` int(11) NOT NULL default '0', - `event_param3` int(11) NOT NULL default '0', - `event_param4` int(11) NOT NULL default '0', + `event_param1` int(11) signed NOT NULL default '0', + `event_param2` int(11) signed NOT NULL default '0', + `event_param3` int(11) signed NOT NULL default '0', + `event_param4` int(11) signed NOT NULL default '0', `action1_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Action Type', - `action1_param1` int(11) NOT NULL default '0', - `action1_param2` int(11) NOT NULL default '0', - `action1_param3` int(11) NOT NULL default '0', + `action1_param1` int(11) signed NOT NULL default '0', + `action1_param2` int(11) signed NOT NULL default '0', + `action1_param3` int(11) signed NOT NULL default '0', `action2_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Action Type', - `action2_param1` int(11) NOT NULL default '0', - `action2_param2` int(11) NOT NULL default '0', - `action2_param3` int(11) NOT NULL default '0', + `action2_param1` int(11) signed NOT NULL default '0', + `action2_param2` int(11) signed NOT NULL default '0', + `action2_param3` int(11) signed NOT NULL default '0', `action3_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Action Type', - `action3_param1` int(11) NOT NULL default '0', - `action3_param2` int(11) NOT NULL default '0', - `action3_param3` int(11) NOT NULL default '0', + `action3_param1` int(11) signed NOT NULL default '0', + `action3_param2` int(11) signed NOT NULL default '0', + `action3_param3` int(11) signed NOT NULL default '0', `comment` varchar(255) NOT NULL default '' COMMENT 'Event Comment', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='EventAI Scripts'; -- @@ -731,14 +731,14 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `eventai_summons`; CREATE TABLE `eventai_summons` ( - `id` int(11) unsigned NOT NULL auto_increment COMMENT 'Location Identifier', + `id` int(11) unsigned NOT NULL COMMENT 'Location Identifier' AUTO_INCREMENT, `position_x` float NOT NULL default '0', `position_y` float NOT NULL default '0', `position_z` float NOT NULL default '0', `orientation` float NOT NULL default '0', `spawntimesecs` int(11) unsigned NOT NULL default '120', `comment` varchar(255) NOT NULL default '' COMMENT 'Summon Comment', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='EventAI Summoning Locations'; -- @@ -756,11 +756,22 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `eventai_texts`; CREATE TABLE `eventai_texts` ( - `id` int(11) unsigned NOT NULL default '0' COMMENT 'Identifier', - `text` 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='Texts used in EventAI'; + `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'; -- -- Dumping data for table `eventai_texts` @@ -772,6 +783,38 @@ LOCK TABLES `eventai_texts` WRITE; UNLOCK TABLES; -- +-- Table structure for table `script_texts` +-- + +DROP TABLE IF EXISTS `script_texts`; +CREATE TABLE `script_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='Script Texts'; + +-- +-- Dumping data for table `script_texts` +-- + +LOCK TABLES `eventai_texts` WRITE; +/*!40000 ALTER TABLE `script_texts` DISABLE KEYS */; +/*!40000 ALTER TABLE `script_texts` ENABLE KEYS */; +UNLOCK TABLES; + +-- -- Table structure for table `exploration_basexp` -- diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp index 576581a249c..be711d82a7b 100644 --- a/src/bindings/scripts/ScriptMgr.cpp +++ b/src/bindings/scripts/ScriptMgr.cpp @@ -22,7 +22,6 @@ Script *m_scripts[MAX_SCRIPTS]; DatabaseType TScriptDB; Config TScriptConfig; -uint32 Locale; // String text additional data, used in TextMap struct StringTextData @@ -43,29 +42,15 @@ enum ChatType CHAT_TYPE_BOSS_WHISPER = 5, }; -#define TEXT_SOURCE_RANGE -100000 //the amount of entries each text source has available +#define TEXT_SOURCE_RANGE -1000000 //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). -struct Localized_Text -{ - std::string locale_1; - std::string locale_2; - std::string locale_3; - std::string locale_4; - std::string locale_5; - std::string locale_6; - std::string locale_7; - std::string locale_8; -}; + //*** End Global data *** //*** EventAI data *** -HM_NAMESPACE::hash_map<uint32, Localized_Text> EventAI_LocalizedTextMap; - //Event AI structure. Used exclusivly by mob_event_ai.cpp (60 bytes each) std::list<EventAI_Event> EventAI_Event_List; @@ -604,14 +589,14 @@ void LoadDatabase() //Get db string from file char const* dbstring = NULL; - if( !TScriptConfig.GetString("WorldDatabaseInfo", &dbstring) ) + if (!TScriptConfig.GetString("WorldDatabaseInfo", &dbstring) ) { error_log("TSCR: Missing world database info from configuration file. Load database aborted."); return; } //Initialize connection to DB - if( dbstring && TScriptDB.Initialize(dbstring) ) + if (dbstring && TScriptDB.Initialize(dbstring) ) outstring_log("TSCR: TrinityScript database: %s",dbstring); else { @@ -641,16 +626,14 @@ void LoadDatabase() // 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..."); - LoadTrinityStrings(TScriptDB,"script_texts",TEXT_SOURCE_RANGE,(TEXT_SOURCE_RANGE*2)+1); + // Load EventAI Text + outstring_log("TSCR: Loading EventAI Texts..."); + LoadTrinityStrings(TScriptDB,"eventai_texts",-1,1+(TEXT_SOURCE_RANGE)); - // Gather Additional data from Script Texts - result = TScriptDB.PQuery("SELECT entry, sound, type, language FROM script_texts"); + // Gather Additional data from EventAI Texts + result = TScriptDB.PQuery("SELECT entry, sound, type, language FROM eventai_texts"); - outstring_log("TSCR: Loading Script Texts additional data..."); + outstring_log("TSCR: Loading EventAI Texts additional data..."); if (result) { barGoLink bar(result->GetRowCount()); @@ -669,27 +652,27 @@ void LoadDatabase() if (i >= 0) { - error_db_log("TSCR: Entry %i in table `script_texts` is not a negative value.",i); + error_db_log("TSCR: Entry %i in table `eventai_texts` is not a negative value.",i); continue; } - if (i > TEXT_SOURCE_RANGE || i <= TEXT_SOURCE_RANGE*2) + if (i <= TEXT_SOURCE_RANGE) { - error_db_log("TSCR: Entry %i in table `script_texts` is out of accepted entry range for table.",i); + error_db_log("TSCR: Entry %i in table `eventai_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); + error_db_log("TSCR: Entry %i in table `eventai_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); + error_db_log("TSCR: Entry %i in table `eventai_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); + error_db_log("TSCR: Entry %i in table `eventai_texts` has Type %u but this Chat Type does not exist.",i,temp.Type); TextMap[i] = temp; ++count; @@ -698,23 +681,23 @@ void LoadDatabase() delete result; outstring_log(""); - outstring_log(">> TSCR: Loaded %u additional Script Texts data.", count); + outstring_log(">> TSCR: Loaded %u additional EventAI 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."); + outstring_log(">> Loaded 0 additional EventAI Texts data. DB table `eventai_texts` is empty."); } - // Load Custom Text - outstring_log("TSCR: Loading Custom Texts..."); - LoadTrinityStrings(TScriptDB,"custom_texts",TEXT_SOURCE_RANGE*2,(TEXT_SOURCE_RANGE*3)+1); + // Load Script Text + outstring_log("TSCR: Loading Script Texts..."); + LoadTrinityStrings(TScriptDB,"script_texts",TEXT_SOURCE_RANGE,1+(TEXT_SOURCE_RANGE*2)); - // Gather Additional data from Custom Texts - result = TScriptDB.PQuery("SELECT entry, sound, type, language FROM custom_texts"); + // Gather Additional data from Script Texts + result = TScriptDB.PQuery("SELECT entry, sound, type, language FROM script_texts"); - outstring_log("TSCR: Loading Custom Texts additional data..."); + outstring_log("TSCR: Loading Script Texts additional data..."); if (result) { barGoLink bar(result->GetRowCount()); @@ -733,27 +716,27 @@ void LoadDatabase() if (i >= 0) { - error_db_log("TSCR: Entry %i in table `custom_texts` is not a negative value.",i); + error_db_log("TSCR: Entry %i in table `script_texts` is not a negative value.",i); continue; } - if (i > TEXT_SOURCE_RANGE*2 || i <= TEXT_SOURCE_RANGE*3) + if (i > TEXT_SOURCE_RANGE || i <= TEXT_SOURCE_RANGE*2) { - error_db_log("TSCR: Entry %i in table `custom_texts` is out of accepted entry range for table.",i); + 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 `custom_texts` has soundId %u but sound does not exist.",i,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 `custom_texts` using Language %u but Language does not exist.",i,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 `custom_texts` has Type %u but this Chat Type does not exist.",i,temp.Type); + 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; @@ -762,111 +745,86 @@ void LoadDatabase() delete result; outstring_log(""); - outstring_log(">> Loaded %u additional Custom Texts data.", count); + outstring_log(">> TSCR: Loaded %u additional Script 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."); + outstring_log(">> Loaded 0 additional Script Texts data. DB table `script_texts` is empty."); } - // Drop existing Event AI Localized Text hash map - EventAI_LocalizedTextMap.clear(); + // Load Custom Text + outstring_log("TSCR: Loading Custom Texts..."); + LoadTrinityStrings(TScriptDB,"custom_texts",TEXT_SOURCE_RANGE*2,1+(TEXT_SOURCE_RANGE*3)); - // 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"); + // Gather Additional data from Custom Texts + result = TScriptDB.PQuery("SELECT entry, sound, type, language FROM custom_texts"); - outstring_log("TSCR: Loading EventAI Localized Texts..."); - if(result) + outstring_log("TSCR: Loading Custom Texts additional data..."); + if (result) { barGoLink bar(result->GetRowCount()); uint32 count = 0; do { - Localized_Text temp; bar.step(); + Field* fields = result->Fetch(); + StringTextData temp; - 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(">> 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; + int32 i = fields[0].GetInt32(); + temp.SoundId = fields[1].GetInt32(); + temp.Type = fields[2].GetInt32(); + temp.Language = fields[3].GetInt32(); - do - { - bar.step(); - Field *fields = result->Fetch(); + if (i >= 0) + { + error_db_log("TSCR: Entry %i in table `custom_texts` is not a negative value.",i); + continue; + } - uint32 i = fields[0].GetInt32(); + 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; + } - std::string text = fields[1].GetString(); + 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 (!strlen(text.c_str())) - error_db_log("TSCR: EventAI text %u is empty", i); + 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); - EventAI_Text_Map[i] = text; - ++Count; + 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); - }while (result->NextRow()); + TextMap[i] = temp; + ++count; + } while (result->NextRow()); delete result; outstring_log(""); - outstring_log(">> Loaded %u EventAI texts", Count); + outstring_log(">> Loaded %u additional Custom Texts data.", count); }else { barGoLink bar(1); bar.step(); outstring_log(""); - outstring_log(">> Loaded 0 EventAI texts. DB table `eventai_texts` is empty."); + outstring_log(">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty."); } - //Gather event data + //Gather additional data for EventAI 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..."); + outstring_log("TSCR: Loading EventAI Summons..."); if (result) { barGoLink bar(result->GetRowCount()); @@ -914,7 +872,7 @@ void LoadDatabase() //Drop Existing EventAI List EventAI_Event_List.clear(); - outstring_log("TSCR: Loading EventAI_Scripts..."); + outstring_log("TSCR: Loading EventAI scripts..."); if (result) { barGoLink bar(result->GetRowCount()); @@ -1054,11 +1012,30 @@ void LoadDatabase() //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); + 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); + } + } break; case ACTION_T_SOUND: @@ -1066,14 +1043,16 @@ void LoadDatabase() 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_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;*/ case ACTION_T_CAST: { @@ -1152,6 +1131,14 @@ void LoadDatabase() error_db_log("TSCR: Event %u Action %u attempts to set instance data above encounter state 3. Custom case?", i, j+1); break; + case ACTION_T_YELL: + case ACTION_T_TEXTEMOTE: + 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; + 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); @@ -1222,34 +1209,23 @@ void ScriptsInit() } else outstring_log("TSCR: Using configuration file %s",_TRINITY_SCRIPT_CONFIG); - //Locale - Locale = TScriptConfig.GetIntDefault("Locale", 0); - - if (Locale > 8) - { - Locale = 0; - error_log("TSCR: Locale set to invalid language id. Defaulting to 0."); - } - - 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; + 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(""); @@ -1794,88 +1770,7 @@ void ScriptsInit() } //********************************* -//*** Functions used internally *** - -const char* GetEventAILocalizedText(uint32 entry) -{ - if (entry == 0xffffffff) - error_log("TSCR: Entry = -1, GetEventAILocalizedText should not be called in this case."); - - const char* temp = NULL; - - HM_NAMESPACE::hash_map<uint32, Localized_Text>::iterator i = EventAI_LocalizedTextMap.find(entry); - - if (i == EventAI_LocalizedTextMap.end()) - { - error_log("TSCR: EventAI 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) -{ - if(entry == 0xffffffff) - error_log("TSCR: Entry = -1, GetEventAIText should not be called in this case."); - - const char* str = NULL; - - HM_NAMESPACE::hash_map<uint32, std::string>::iterator itr = EventAI_Text_Map.find(entry); - if(itr == EventAI_Text_Map.end()) - { - error_log("TSCR: Unable to find EventAI Text %u", entry); - return DEFAULT_TEXT; - } - - str = (*itr).second.c_str(); - - if(strlen(str)) - return str; - - if(strlen((*itr).second.c_str())) - return (*itr).second.c_str(); - - return DEFAULT_TEXT; -} +//*** Functions used globally *** void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target) { @@ -1887,7 +1782,7 @@ void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target) if (textEntry >= 0) { - error_log("TSCR: DoScriptText attempts to process entry %i, but entry must be negative.",textEntry); + 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); return; } @@ -1895,10 +1790,12 @@ void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target) if (i == TextMap.end()) { - error_log("TSCR: DoScriptText could not find text entry %i.",textEntry); + 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); return; } + debug_log("TSCR: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u",textEntry,(*i).second.SoundId,(*i).second.Type,(*i).second.Language); + if((*i).second.SoundId) { if( GetSoundEntriesStore()->LookupEntry((*i).second.SoundId) ) @@ -1938,14 +1835,17 @@ void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target) } } +//********************************* +//*** Functions used internally *** + Script* GetScriptByName(std::string Name) { - if(Name.empty()) + if (Name.empty()) return NULL; for(int i=0;i<MAX_SCRIPTS;i++) { - if( m_scripts[i] && m_scripts[i]->Name == Name ) + if (m_scripts[i] && m_scripts[i]->Name == Name) return m_scripts[i]; } return NULL; @@ -1958,7 +1858,7 @@ TRINITY_DLL_EXPORT bool GossipHello ( Player * player, Creature *_Creature ) { Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); - if(!tmpscript || !tmpscript->pGossipHello) return false; + if (!tmpscript || !tmpscript->pGossipHello) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pGossipHello(player,_Creature); @@ -1970,7 +1870,7 @@ bool GossipSelect( Player *player, Creature *_Creature, uint32 sender, uint32 ac debug_log("TSCR: Gossip selection, sender: %d, action: %d",sender, action); Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); - if(!tmpscript || !tmpscript->pGossipSelect) return false; + if (!tmpscript || !tmpscript->pGossipSelect) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pGossipSelect(player,_Creature,sender,action); @@ -1982,7 +1882,7 @@ bool GossipSelectWithCode( Player *player, Creature *_Creature, uint32 sender, u debug_log("TSCR: Gossip selection with code, sender: %d, action: %d",sender, action); Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); - if(!tmpscript || !tmpscript->pGossipSelectWithCode) return false; + if (!tmpscript || !tmpscript->pGossipSelectWithCode) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pGossipSelectWithCode(player,_Creature,sender,action,sCode); @@ -1992,7 +1892,7 @@ TRINITY_DLL_EXPORT bool QuestAccept( Player *player, Creature *_Creature, Quest const *_Quest ) { Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); - if(!tmpscript || !tmpscript->pQuestAccept) return false; + if (!tmpscript || !tmpscript->pQuestAccept) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pQuestAccept(player,_Creature,_Quest); @@ -2002,7 +1902,7 @@ TRINITY_DLL_EXPORT bool QuestSelect( Player *player, Creature *_Creature, Quest const *_Quest ) { Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); - if(!tmpscript || !tmpscript->pQuestSelect) return false; + if (!tmpscript || !tmpscript->pQuestSelect) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pQuestSelect(player,_Creature,_Quest); @@ -2012,7 +1912,7 @@ TRINITY_DLL_EXPORT bool QuestComplete( Player *player, Creature *_Creature, Quest const *_Quest ) { Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); - if(!tmpscript || !tmpscript->pQuestComplete) return false; + if (!tmpscript || !tmpscript->pQuestComplete) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pQuestComplete(player,_Creature,_Quest); @@ -2022,7 +1922,7 @@ TRINITY_DLL_EXPORT bool ChooseReward( Player *player, Creature *_Creature, Quest const *_Quest, uint32 opt ) { Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); - if(!tmpscript || !tmpscript->pChooseReward) return false; + if (!tmpscript || !tmpscript->pChooseReward) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pChooseReward(player,_Creature,_Quest,opt); @@ -2032,7 +1932,7 @@ TRINITY_DLL_EXPORT uint32 NPCDialogStatus( Player *player, Creature *_Creature ) { Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); - if(!tmpscript || !tmpscript->pNPCDialogStatus) return 100; + if (!tmpscript || !tmpscript->pNPCDialogStatus) return 100; player->PlayerTalkClass->ClearMenus(); return tmpscript->pNPCDialogStatus(player,_Creature); @@ -2052,7 +1952,7 @@ TRINITY_DLL_EXPORT bool ItemHello( Player *player, Item *_Item, Quest const *_Quest ) { Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName); - if(!tmpscript || !tmpscript->pItemHello) return false; + if (!tmpscript || !tmpscript->pItemHello) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pItemHello(player,_Item,_Quest); @@ -2062,7 +1962,7 @@ TRINITY_DLL_EXPORT bool ItemQuestAccept( Player *player, Item *_Item, Quest const *_Quest ) { Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName); - if(!tmpscript || !tmpscript->pItemQuestAccept) return false; + if (!tmpscript || !tmpscript->pItemQuestAccept) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pItemQuestAccept(player,_Item,_Quest); @@ -2072,7 +1972,7 @@ TRINITY_DLL_EXPORT bool GOHello( Player *player, GameObject *_GO ) { Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName); - if(!tmpscript || !tmpscript->pGOHello) return false; + if (!tmpscript || !tmpscript->pGOHello) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pGOHello(player,_GO); @@ -2082,7 +1982,7 @@ TRINITY_DLL_EXPORT bool GOQuestAccept( Player *player, GameObject *_GO, Quest const *_Quest ) { Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName); - if(!tmpscript || !tmpscript->pGOQuestAccept) return false; + if (!tmpscript || !tmpscript->pGOQuestAccept) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pGOQuestAccept(player,_GO,_Quest); @@ -2092,7 +1992,7 @@ TRINITY_DLL_EXPORT bool GOChooseReward( Player *player, GameObject *_GO, Quest const *_Quest, uint32 opt ) { Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName); - if(!tmpscript || !tmpscript->pGOChooseReward) return false; + if (!tmpscript || !tmpscript->pGOChooseReward) return false; player->PlayerTalkClass->ClearMenus(); return tmpscript->pGOChooseReward(player,_GO,_Quest,opt); @@ -2104,7 +2004,7 @@ bool AreaTrigger( Player *player, AreaTriggerEntry * atEntry) Script *tmpscript = NULL; tmpscript = GetScriptByName(GetAreaTriggerScriptNameById(atEntry->id)); - if(!tmpscript || !tmpscript->pAreaTrigger) return false; + if (!tmpscript || !tmpscript->pAreaTrigger) return false; return tmpscript->pAreaTrigger(player, atEntry); } @@ -2114,7 +2014,7 @@ CreatureAI* GetAI(Creature *_Creature) { Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); - if(!tmpscript || !tmpscript->GetAI) return NULL; + if (!tmpscript || !tmpscript->GetAI) return NULL; return tmpscript->GetAI(_Creature); } @@ -2122,7 +2022,7 @@ TRINITY_DLL_EXPORT bool ItemUse( Player *player, Item* _Item, SpellCastTargets const& targets) { Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName); - if(!tmpscript || !tmpscript->pItemUse) return false; + if (!tmpscript || !tmpscript->pItemUse) return false; return tmpscript->pItemUse(player,_Item,targets); } @@ -2131,7 +2031,7 @@ TRINITY_DLL_EXPORT bool ReceiveEmote( Player *player, Creature *_Creature, uint32 emote ) { Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); - if(!tmpscript || !tmpscript->pReceiveEmote) return false; + if (!tmpscript || !tmpscript->pReceiveEmote) return false; return tmpscript->pReceiveEmote(player, _Creature, emote); } @@ -2141,10 +2041,10 @@ InstanceData* CreateInstanceData(Map *map) { Script *tmpscript = NULL; - if(!map->IsDungeon()) return false; + if (!map->IsDungeon()) return false; tmpscript = GetScriptByName(((InstanceMap*)map)->GetScript()); - if(!tmpscript || !tmpscript->GetInstanceData) return false; + if (!tmpscript || !tmpscript->GetInstanceData) return false; return tmpscript->GetInstanceData(map); } diff --git a/src/bindings/scripts/ScriptMgr.h b/src/bindings/scripts/ScriptMgr.h index 1d275535081..c7a8cea1e0a 100644 --- a/src/bindings/scripts/ScriptMgr.h +++ b/src/bindings/scripts/ScriptMgr.h @@ -65,12 +65,6 @@ InstanceData* (*GetInstanceData)(Map*); extern int nrscripts; extern Script *m_scripts[MAX_SCRIPTS]; -// Localized Text function -const char* GetEventAILocalizedText(uint32 entry); - -//EventAI text function -const char* GetEventAIText(uint32 entry); // TODO: Locales - //Generic scripting text function void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target = NULL); diff --git a/src/bindings/scripts/docs/EventAI.txt b/src/bindings/scripts/docs/EventAI.txt index 1549fe74f1c..580f73ae75b 100644 --- a/src/bindings/scripts/docs/EventAI.txt +++ b/src/bindings/scripts/docs/EventAI.txt @@ -82,14 +82,14 @@ Params are always read from Param1, then Param2, then Param3. (# Internal Name Param usage Discription) 0 ACTION_T_NONE No Action Does Nothing -1 ACTION_T_SAY TextId Says Text -2 ACTION_T_YELL TextId Yells Text -3 ACTION_T_TEXTEMOTE TextId Text Emotes Text +1 ACTION_T_TEXT -TextId1, -TextId2, -TextId3 Displays the -TextId as defined. In case -TextId2 and optionally -TextId3, the output will be randomized. Type text are defined in the text table itself(say, yell, whisper, etc) along with other options for the text. All values are required to be negative. +2 ACTION_T_YELL UNUSED +3 ACTION_T_TEXTEMOTE UNUSED 4 ACTION_T_SOUND SoundId Plays Sound 5 ACTION_T_EMOTE EmoteId Does emote -6 ACTION_T_RANDOM_SAY TextId1, TextId2, TextId3 Says random text between 3 params* -7 ACTION_T_RANDOM_YELL TextId1, TextId2, TextId3 Yells random text between 3 params* -8 ACTION_T_RANDOM_TEXTEMOTE TextId1, TextId2, TextId3 Text Emotes random text between 3 params* +6 ACTION_T_RANDOM_SAY UNUSED +7 ACTION_T_RANDOM_YELL UNUSED +8 ACTION_T_RANDOM_TEXTEMOTE UNUSED 9 ACTION_T_RANDOM_SOUND SoundId1, SoundId2, SoundId3 Plays random sound between 3 params* 10 ACTION_T_RANDOM_EMOTE EmoteId1, EmoteId2, EmoteId3 Emotes random emote between 3 params 11 ACTION_T_CAST SpellId, Target, CastFlags Casts spell (param1) on target type (param2). Uses Cast Flags (specified below target types) @@ -311,26 +311,25 @@ Action Types ========================================= ----------------- -1 = ACTION_T_SAY: +1 = ACTION_T_TEXT: ----------------- -Parameter 1: The ID of the text that the NPC should SAY from the Localized_Texts Table. +Parameter 1: The entry of the text that the NPC should use from eventai_texts table. Optionally a entry from other tables can be used (such as custom_texts). + Entry are required to be negative and exist in a *_texts-table. The type text to be displayed are defined in the texts-table itself (Say, Yell, Whisper, Emote Text, Boss Whisper, Boss Emote) + Other options are also to be defined in the texts-table, such as a sound to be heard with the text and the language used in output (common, dwarvish, etc). + In case this entry has a localized version of the text, the localized text will be displayed in client that support this locale. -This action is pretty straightforward. When activated, the creature will SAY the specified text (Speech Bubble). +Parameter 2: Optional. TextId can be defined in addition. The same apply to this as explained above, however eventAI will randomize between the two. +Parameter 3: Optional, if Parameter 2 exist. In this case, eventAI will randomize between three. ------------------ 2 = ACTION_T_YELL: ------------------ -Parameter 1: The ID of the text that the NPC should YELL from the Localized_Texts Table. - -The creature will YELL the specified text (Red Speech Bubble). +UNUSED Can be reused to create new action type ----------------------- 3 = ACTION_T_TEXTEMOTE: ----------------------- -Parameter 1: The ID of the text that the NPC should TEXTEMOTE from the Localized_Texts Table. - -When activated, the creature will do a text emote using the specified text. A text emote is what you would regularly see by using the /em slash command. -NOTE: The text should be written with the assumption that the creature's name is the first word or words in the sentence (for example, "is doing a text emote" would appear as "XYZ is doing a text emote" for a creature named XYZ). +UNUSED Can be reused to create new action type ------------------- 4 = ACTION_T_SOUND: @@ -351,32 +350,17 @@ This is commonly used for NPC's who may perform a special action (Salute, Roar, ------------------------ 6 = ACTION_T_RANDOM_SAY: ------------------------ -Parameter 1: The ID of the text that the NPC should SAY from the Localized_Texts Table (Random Choice #1). -Parameter 2: The ID of the text that the NPC should SAY from the Localized_Texts Table (Random Choice #2). -Parameter 3: The ID of the text that the NPC should SAY from the Localized_Texts Table (Random Choice #3). - -Similar to the ACTION_T_SAY action, it will choose at random a text entry to SAY. This action will pick a random entry from the three. -NOTE: If you want any of the options if selected to do nothing you set that Param to -1 value. Then if selected it will do nothing. -NOTE: When using Random Select Actions, ALL The Actions using Random in a Single Event (Action 1,2,3) will select the SAME Random Choice when it expires. This can come in handy if you are doing a ACTION_T_RANDOM_YELL for Action1 and then the corresponding sounds for ACTION_T_RANDOM_SOUND in Action2. If it selects Random Choice #2 for the Yell it will Select Random Choice #2 for the sound so you can match them up as required. -This is commonly used for NPC's who have several different Aggro Say's and you would like one of them selected at random. +UNUSED Can be reused to create new action type ------------------------- 7 = ACTION_T_RANDOM_YELL: ------------------------- -Parameter 1: The ID of the text that the NPC should YELL from the Localized_Texts Table (Random Choice #1). -Parameter 2: The ID of the text that the NPC should YELL from the Localized_Texts Table (Random Choice #2). -Parameter 3: The ID of the text that the NPC should YELL from the Localized_Texts Table (Random Choice #3). - -Similar to the ACTION_T_YELL action, it will choose at random a text entry to YELL. +UNUSED Can be reused to create new action type ------------------------------ 8 = ACTION_T_RANDOM_TEXTEMOTE: ------------------------------ -Parameter 1: The ID of the text that the NPC should TEXTEMOTE from the Localized_Texts Table (Random Choice #1). -Parameter 2: The ID of the text that the NPC should TEXTEMOTE from the Localized_Texts Table (Random Choice #2). -Parameter 3: The ID of the text that the NPC should TEXTEMOTE from the Localized_Texts Table (Random Choice #3). - -Similar to the ACTION_T_TEXTEMOTE action, it will choose at random a text entry to TEXTEMOTE. +UNUSED Can be reused to create new action type -------------------------- 9 = ACTION_T_RANDOM_SOUND: @@ -699,4 +683,4 @@ Below is the list of current Event Flags that EventAI can handle. Event flags ar 6 64 7 128 EFLAG_DEBUG_ONLY Prevents events from occuring on Release builds of ScriptDev2. Useful for testing new features. -NOTE: You can add the numbers in the decimal column to combine flags.
\ No newline at end of file +NOTE: You can add the numbers in the decimal column to combine flags. diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index ee52817c114..0fdd25ebfe7 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -11,8 +11,8 @@ // Spell summary for ScriptedAI::SelectSpell 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 } *SpellSummary; bool ScriptedAI::IsVisible(Unit* who) const @@ -25,23 +25,41 @@ bool ScriptedAI::IsVisible(Unit* who) const void ScriptedAI::MoveInLineOfSight(Unit *who) { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + if (!m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature)) { if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) return; float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) { - DoStartAttackAndMovement(who); who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + AttackStart(who); + } + } +} - if (!InCombat) - { - InCombat = true; - Aggro(who); - } +void ScriptedAI::AttackStart(Unit* who, bool melee) +{ + if (!who) + return; + + if (m_creature->Attack(who, melee)) + { + m_creature->AddThreat(who, 0.0f); + m_creature->SetInCombatWith(who); + who->SetInCombatWith(m_creature); + + if (!InCombat) + { + InCombat = true; + Aggro(who); } + + if(melee) + DoStartMovement(who); + else + DoStartNoMovement(who); } } @@ -50,28 +68,31 @@ void ScriptedAI::AttackStart(Unit* who) if (!who) return; - if (who->isTargetableForAttack()) + if (m_creature->Attack(who, true)) { - //Begin attack - DoStartAttackAndMovement(who); + m_creature->AddThreat(who, 0.0f); + m_creature->SetInCombatWith(who); + who->SetInCombatWith(m_creature); if (!InCombat) { InCombat = true; Aggro(who); } + + DoStartMovement(who); } } void ScriptedAI::UpdateAI(const uint32 diff) { //Check if we have a current target - if( m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim()) + if (m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim()) { - if( m_creature->isAttackReady() ) + if (m_creature->isAttackReady() ) { //If we are within range melee the target - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) { m_creature->AttackerStateUpdate(m_creature->getVictim()); m_creature->resetAttackTimer(); @@ -88,7 +109,7 @@ void ScriptedAI::EnterEvadeMode() m_creature->CombatStop(); m_creature->LoadCreaturesAddon(); - if( m_creature->isAlive() ) + if (m_creature->isAlive()) m_creature->GetMotionMaster()->MoveTargetedHome(); m_creature->SetLootRecipient(NULL); @@ -103,37 +124,31 @@ void ScriptedAI::JustRespawned() Reset(); } -void ScriptedAI::DoStartAttackAndMovement(Unit* victim, float distance, float angle) +void ScriptedAI::DoStartMovement(Unit* victim, float distance, float angle) { if (!victim) return; - if ( m_creature->Attack(victim, true) ) - { - m_creature->GetMotionMaster()->MoveChase(victim, distance, angle); - m_creature->AddThreat(victim, 0.0f); - } + m_creature->GetMotionMaster()->MoveChase(victim, distance, angle); } -void ScriptedAI::DoStartAttackNoMovement(Unit* victim) +void ScriptedAI::DoStartNoMovement(Unit* victim) { if (!victim) return; - if ( m_creature->Attack(victim, true) ) - { - m_creature->AddThreat(victim, 0.0f); - } + m_creature->GetMotionMaster()->MoveIdle(); + m_creature->StopMoving(); } void ScriptedAI::DoMeleeAttackIfReady() { //Make sure our attack is ready and we aren't currently casting before checking distance - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) { //If we are within range melee the target - if( m_creature->IsWithinCombatDist(m_creature->getVictim(), ATTACK_DISTANCE)) + if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) { m_creature->AttackerStateUpdate(m_creature->getVictim()); m_creature->resetAttackTimer(); @@ -143,7 +158,7 @@ void ScriptedAI::DoMeleeAttackIfReady() void ScriptedAI::DoStopAttack() { - if( m_creature->getVictim() != NULL ) + if (m_creature->getVictim() != NULL) { m_creature->AttackStop(); } @@ -169,19 +184,19 @@ void ScriptedAI::DoCastSpell(Unit* who,SpellEntry const *spellInfo, bool trigger void ScriptedAI::DoSay(const char* text, uint32 language, Unit* target) { - if (target)m_creature->Say(text, language, target->GetGUID()); + if (target) m_creature->Say(text, language, target->GetGUID()); else m_creature->Say(text, language, 0); } void ScriptedAI::DoYell(const char* text, uint32 language, Unit* target) { - if (target)m_creature->Yell(text, language, target->GetGUID()); + if (target) m_creature->Yell(text, language, target->GetGUID()); else m_creature->Yell(text, language, 0); } void ScriptedAI::DoTextEmote(const char* text, Unit* target, bool IsBossEmote) { - if (target)m_creature->TextEmote(text, target->GetGUID(), IsBossEmote); + if (target) m_creature->TextEmote(text, target->GetGUID(), IsBossEmote); else m_creature->TextEmote(text, 0, IsBossEmote); } @@ -204,7 +219,10 @@ void ScriptedAI::DoPlaySoundToSet(Unit* unit, uint32 sound) return; } - unit->SendPlaySound(sound, false); + WorldPacket data(4); + data.SetOpcode(SMSG_PLAY_SOUND); + data << uint32(sound); + unit->SendMessageToSet(&data,false); } Creature* ScriptedAI::DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime) @@ -461,6 +479,7 @@ void ScriptedAI::DoZoneInCombat(Unit* pUnit) /*if (!pUnit->CanHaveThreatList() || pUnit->getThreatManager().isThreatListEmpty()) { error_log("SD2: DoZoneInCombat called for creature that either cannot have threat list or has empty threat list (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); + return; }*/ @@ -579,14 +598,8 @@ void Scripted_NoMovementAI::MoveInLineOfSight(Unit *who) float attackRadius = m_creature->GetAttackDistance(who); if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) { - DoStartAttackNoMovement(who); who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } + AttackStart(who); } } } @@ -596,15 +609,18 @@ void Scripted_NoMovementAI::AttackStart(Unit* who) if (!who) return; - if (who->isTargetableForAttack()) + if (m_creature->Attack(who, true)) { - //Begin attack - DoStartAttackNoMovement(who); + m_creature->AddThreat(who, 0.0f); + m_creature->SetInCombatWith(who); + who->SetInCombatWith(m_creature); if (!InCombat) { InCombat = true; Aggro(who); } + + DoStartNoMovement(who); } } diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h index 6b3d731d256..494ab101f08 100644 --- a/src/bindings/scripts/include/sc_creature.h +++ b/src/bindings/scripts/include/sc_creature.h @@ -25,6 +25,7 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI //Called at each attack of m_creature by any victim void AttackStart(Unit *); + void AttackStart(Unit *, bool melee); //Called at stoping attack by any attacker void EnterEvadeMode(); @@ -89,11 +90,11 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI //AI Helper Functions //************* - //Start attack of victim and go to him - void DoStartAttackAndMovement(Unit* victim, float distance = 0, float angle = 0); + //Start movement toward victim + void DoStartMovement(Unit* victim, float distance = 0, float angle = 0); - //Start attack on victim but do not move - void DoStartAttackNoMovement(Unit* victim); + //Start no movement on victim + void DoStartNoMovement(Unit* victim); //Do melee swing of current victim if in rnage and ready and not casting void DoMeleeAttackIfReady(); diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp index 4086430ae74..ca3361d9dd2 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -523,14 +523,59 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI { switch (type) { - case ACTION_T_SAY: - DoSay(GetEventAIText(param1), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); - break; - case ACTION_T_YELL: - DoYell(GetEventAIText(param1), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); - break; - case ACTION_T_TEXTEMOTE: - DoTextEmote(GetEventAIText(param1), pActionInvoker ? pActionInvoker : m_creature->getVictim()); + case ACTION_T_TEXT: + { + if (!param1) + return; + + uint32 temp = 0; + + if (param2 && param3) + { + switch( rand()%3 ) + { + case 0: temp = param1; break; + case 2: temp = param2; break; + case 3: temp = param3; break; + } + }else if ( param2 && urand(0,1) ) + { + temp = param2; + }else + { + temp = param1; + } + + if (temp) + { + Unit* target = NULL; + Unit* owner = NULL; + + if (pActionInvoker) + { + if (pActionInvoker->GetTypeId() == TYPEID_PLAYER) + target = pActionInvoker; + else if (owner = pActionInvoker->GetOwner()) + { + if (owner->GetTypeId() == TYPEID_PLAYER) + target = owner; + } + } + else if (target = m_creature->getVictim()) + { + if (target->GetTypeId() != TYPEID_PLAYER) + { + if (owner = target->GetOwner()) + { + if (owner->GetTypeId() == TYPEID_PLAYER) + target = owner; + } + } + } + + DoScriptText(temp, m_creature, target); + } + } break; case ACTION_T_SOUND: DoPlaySoundToSet(m_creature, param1); @@ -538,30 +583,6 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI case ACTION_T_EMOTE: m_creature->HandleEmoteCommand(param1); break; - case ACTION_T_RANDOM_SAY: - { - uint32 temp = GetRandActionParam(rnd, param1, param2, param3); - - if (temp != 0xffffffff) - DoSay(GetEventAIText(temp), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); - } - break; - case ACTION_T_RANDOM_YELL: - { - uint32 temp = GetRandActionParam(rnd, param1, param2, param3); - - if (temp != 0xffffffff) - DoYell(GetEventAIText(temp), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); - } - break; - case ACTION_T_RANDOM_TEXTEMOTE: - { - uint32 temp = GetRandActionParam(rnd, param1, param2, param3); - - if (temp != 0xffffffff) - DoTextEmote(GetEventAIText(temp), pActionInvoker ? pActionInvoker : m_creature->getVictim()); - } - break; case ACTION_T_RANDOM_SOUND: { uint32 temp = GetRandActionParam(rnd, param1, param2, param3); diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.h b/src/bindings/scripts/scripts/creature/mob_event_ai.h index b063df8b585..79300326bbc 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.h +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.h @@ -30,21 +30,21 @@ enum Event_Types EVENT_T_TARGET_MANA = 18, //ManaMax%, ManaMin%, RepeatMin, RepeatMax EVENT_T_QUEST_ACCEPT = 19, //QuestID EVENT_T_QUEST_COMPLETE = 20, // - + EVENT_T_END, }; enum Action_Types { ACTION_T_NONE = 0, //No action - ACTION_T_SAY = 1, //TextId - ACTION_T_YELL = 2, //TextId - ACTION_T_TEXTEMOTE = 3, //TextId + ACTION_T_TEXT = 1, //-TextId1, optionally -TextId2, optionally -TextId3(if -TextId2 exist). If more than just -TextId1 is defined, randomize. Negative values. + ACTION_T_YELL = 2, //UNUSED + ACTION_T_TEXTEMOTE = 3, //UNUSED ACTION_T_SOUND = 4, //SoundId ACTION_T_EMOTE = 5, //EmoteId - ACTION_T_RANDOM_SAY = 6, //TextId1, TextId2, TextId3 (-1 in any field means no output if randomed that field) - ACTION_T_RANDOM_YELL = 7, //TextId1, TextId2, TextId3 (-1 in any field means no output if randomed that field) - ACTION_T_RANDOM_TEXTEMOTE = 8, //TextId1, TextId2, TextId3 (-1 in any field means no output if randomed that field) + ACTION_T_RANDOM_SAY = 6, //UNUSED + ACTION_T_RANDOM_YELL = 7, //UNUSED + ACTION_T_RANDOM_TEXTEMOTE = 8, //UNUSED ACTION_T_RANDOM_SOUND = 9, //SoundId1, SoundId2, SoundId3 (-1 in any field means no output if randomed that field) ACTION_T_RANDOM_EMOTE = 10, //EmoteId1, EmoteId2, EmoteId3 (-1 in any field means no output if randomed that field) ACTION_T_CAST = 11, //SpellId, Target, CastFlags @@ -208,7 +208,7 @@ struct EventAI_CreatureError }; //Error prevention list -extern HM_NAMESPACE::hash_map<uint32, EventAI_CreatureError> EventAI_CreatureErrorPreventionList; +extern HM_NAMESPACE::hash_map<uint32, EventAI_CreatureError> EventAI_CreatureErrorPreventionList; //Defines #define EVENTAI_EMPTY_EVENTLIST "SD2: Eventlist for Creature %i is empty but creature is using Mob_EventAI. Preventing EventAI on this creature." diff --git a/src/bindings/scripts/scripts/guard/guards.cpp b/src/bindings/scripts/scripts/guard/guards.cpp index a6922be362d..be9c30ad0c5 100644 --- a/src/bindings/scripts/scripts/guard/guards.cpp +++ b/src/bindings/scripts/scripts/guard/guards.cpp @@ -529,7 +529,7 @@ struct TRINITY_DLL_DECL guard_contested : public guardAI DoCastSpell(who, spell); } } - DoStartAttackAndMovement(who); + DoStartMovement(who); } } } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp index 6be5a32ef2b..9eaa7023082 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp @@ -197,14 +197,8 @@ struct TRINITY_DLL_DECL boss_exarch_maladaarAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) { - DoStartAttackAndMovement(who); who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } + AttackStart(who); } } } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp index 71ad1e8ffc2..5b3ee392bba 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp @@ -101,14 +101,8 @@ struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) { - DoStartAttackAndMovement(who); who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } + AttackStart(who); } } } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp index 8c5f5157d25..63f527095c5 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp @@ -110,14 +110,8 @@ struct TRINITY_DLL_DECL boss_talon_king_ikissAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) { - DoStartAttackAndMovement(who); who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } + AttackStart(who); } } } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp index af8c2807a1e..bffb214e3c6 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp @@ -214,8 +214,7 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI if(who->HasStealthAura()) who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - DoStartAttackAndMovement(who); - Aggro(who); + AttackStart(who); } } else if (!Intro && m_creature->IsWithinLOSInMap(who)&& m_creature->IsWithinDistInMap(who, 100) ) //not sure about right radius diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp index 55456c86286..74b8c62e857 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp @@ -32,9 +32,9 @@ EndScriptData */ #define SPELL_RESONANCE 33657 #define SPELL_SHOCKWAVE 33686 -struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI +struct TRINITY_DLL_DECL boss_murmurAI : public Scripted_NoMovementAI { - boss_murmurAI(Creature *c) : ScriptedAI(c) {Reset();} + boss_murmurAI(Creature *c) : Scripted_NoMovementAI(c) {Reset();} uint32 SonicBoom_Timer; uint32 MurmursTouch_Timer; @@ -62,46 +62,6 @@ struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI void Aggro(Unit *who) { } - void AttackStart(Unit* who) - { - if (!who) - return; - - if (who->isTargetableForAttack()) - { - //Begin attack - DoStartAttackNoMovement(who); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } - } - } - - void MoveInLineOfSight(Unit* who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) - { - DoStartAttackNoMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } - } - } - } - void UpdateAI(const uint32 diff) { //Return since we have no target diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp index 505f73e7f21..e4bdfe21be5 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp @@ -441,19 +441,10 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI if(!who || Phase >= PHASE_TALK_SEQUENCE) return; - if (who->isTargetableForAttack()) - { - if(Phase == PHASE_FLIGHT || Phase == PHASE_DEMON) - m_creature->Attack(who, false); - else - DoStartAttackAndMovement(who); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } + if(Phase == PHASE_FLIGHT || Phase == PHASE_DEMON) + ScriptedAI::AttackStart(who, false); + else + ScriptedAI::AttackStart(who, true); } void MoveInLineOfSight(Unit *who) {} @@ -1510,26 +1501,17 @@ struct TRINITY_DLL_DECL boss_maievAI : public ScriptedAI if(!who || Timer[EVENT_MAIEV_STEALTH]) return; - if (who->isTargetableForAttack()) + if(Phase == PHASE_TALK_SEQUENCE) + ScriptedAI::AttackStart(who, false); + else if(Phase == PHASE_DEMON || Phase == PHASE_TRANSFORM_SEQUENCE ) { - if(Phase == PHASE_TALK_SEQUENCE) - m_creature->Attack(who, false); - else if(Phase == PHASE_DEMON || Phase == PHASE_TRANSFORM_SEQUENCE ) - { - GETUNIT(Illidan, IllidanGUID); - if(Illidan && m_creature->IsWithinDistInMap(Illidan, 25)) - BlinkToPlayer();//Do not let dread aura hurt her. - m_creature->Attack(who, false); - } - else - DoStartAttackAndMovement(who); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } + GETUNIT(Illidan, IllidanGUID); + if(Illidan && m_creature->IsWithinDistInMap(Illidan, 25)) + BlinkToPlayer();//Do not let dread aura hurt her. + ScriptedAI::AttackStart(who, false); } + else + ScriptedAI::AttackStart(who, true); } void EnterPhase(PhaseIllidan NextPhase)//This is in fact Illidan's phase. diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp index 590f1f71216..d0712ad6129 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp @@ -260,7 +260,7 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI if(!who || IsBanished) return; if(who->isTargetableForAttack() && who != m_creature) - DoStartAttackAndMovement(who); + DoStartMovement(who); } void MoveInLineOfSight(Unit* who) diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp index 5bcf7fe995e..c00b3c2f9a2 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp @@ -119,41 +119,39 @@ struct TRINITY_DLL_DECL boss_vaelAI : public ScriptedAI { //Speach if (DoingSpeach) - if (SpeachTimer < diff) { - switch (SpeachNum) + if (SpeachTimer < diff) { - case 0: - //16 seconds till next line - DoYell(SAY_LINE2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_LINE2); - SpeachTimer = 16000; - SpeachNum++; - break; - - case 1: - //This one is actually 16 seconds but we only go to 10 seconds because he starts attacking after he says "I must fight this!" - DoYell(SAY_LINE3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_LINE3); - SpeachTimer = 10000; - SpeachNum++; - break; - - case 2: - default: - m_creature->setFaction(103); - m_creature->SetHealth(int(m_creature->GetMaxHealth()*.3)); - if (PlayerGUID && Unit::GetUnit((*m_creature),PlayerGUID)) - { - DoStartAttackAndMovement(Unit::GetUnit((*m_creature),PlayerGUID)); - DoCast(m_creature,SPELL_ESSENCEOFTHERED); - } - - SpeachTimer = 0; - DoingSpeach = false; - break; - } - }else SpeachTimer -= diff; + switch (SpeachNum) + { + case 0: + //16 seconds till next line + DoYell(SAY_LINE2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_LINE2); + SpeachTimer = 16000; + SpeachNum++; + break; + case 1: + //This one is actually 16 seconds but we only go to 10 seconds because he starts attacking after he says "I must fight this!" + DoYell(SAY_LINE3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_LINE3); + SpeachTimer = 10000; + SpeachNum++; + break; + case 2: + m_creature->setFaction(103); + m_creature->SetHealth(int(m_creature->GetMaxHealth()*.3)); + if (PlayerGUID && Unit::GetUnit((*m_creature),PlayerGUID)) + { + AttackStart(Unit::GetUnit((*m_creature),PlayerGUID)); + DoCast(m_creature,SPELL_ESSENCEOFTHERED); + } + SpeachTimer = 0; + DoingSpeach = false; + break; + } + }else SpeachTimer -= diff; + } //Return since we have no target if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) diff --git a/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp b/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp index a7c35624830..02002f044b9 100644 --- a/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp +++ b/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp @@ -294,11 +294,8 @@ struct TRINITY_DLL_DECL npc_daranelleAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - //Begin melee attack if we are within range - DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + AttackStart(who); } } } diff --git a/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp b/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp index 4b5e491c1c1..5e834842bd7 100644 --- a/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp +++ b/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp @@ -56,14 +56,8 @@ struct TRINITY_DLL_DECL npc_ragged_johnAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) { - DoStartAttackAndMovement(who); who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } + AttackStart(who); } } } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp index 55cbde02e3a..d051c06d188 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp @@ -108,15 +108,8 @@ struct TRINITY_DLL_DECL boss_temporusAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - if (!InCombat) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + AttackStart(who); } } } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp index ba5bb5fea72..a4da476a408 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp @@ -197,12 +197,8 @@ struct TRINITY_DLL_DECL boss_fathomlord_karathressAI : public ScriptedAI if(target) { - DoStartAttackAndMovement(target); - + AttackStart(target); GetAdvisors(); - - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); } } @@ -294,7 +290,7 @@ struct TRINITY_DLL_DECL boss_fathomguard_sharkkisAI : public ScriptedAI if(target) { - DoStartAttackAndMovement(target); + AttackStart(target); } } @@ -375,7 +371,7 @@ struct TRINITY_DLL_DECL boss_fathomguard_tidalvessAI : public ScriptedAI if(target) { - DoStartAttackAndMovement(target); + AttackStart(target); } } @@ -453,7 +449,7 @@ struct TRINITY_DLL_DECL boss_fathomguard_caribdisAI : public ScriptedAI if(target) { - DoStartAttackAndMovement(target); + AttackStart(target); } } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp index 0264a45f63f..057c65cf86d 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp @@ -237,7 +237,7 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI { //Begin melee attack if we are within range if(Phase != 2) - DoStartAttackAndMovement(who); + DoStartMovement(who); StartEvent(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp index c2cea88c744..66f787d2ddc 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp @@ -351,10 +351,8 @@ struct TRINITY_DLL_DECL mob_water_globuleAI : public ScriptedAI if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) { //no attack radius check - it attacks the first target that moves in his los - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + AttackStart(who); } } diff --git a/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp b/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp index 09187f0d4c8..6421eedac22 100644 --- a/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp +++ b/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp @@ -188,7 +188,10 @@ struct TRINITY_DLL_DECL boss_high_king_maulgarAI : public ScriptedAI } - void Aggro(Unit *who) { StartEvent(who); } + void Aggro(Unit *who) + { + StartEvent(who); + } void GetCouncil() { @@ -224,11 +227,8 @@ struct TRINITY_DLL_DECL boss_high_king_maulgarAI : public ScriptedAI if(target) { - DoStartAttackAndMovement(target); - + AttackStart(target); GetCouncil(); - - DoPlaySoundToSet(m_creature, SOUND_AGGRO); } } @@ -283,8 +283,8 @@ struct TRINITY_DLL_DECL boss_high_king_maulgarAI : public ScriptedAI { Unit* target = NULL; target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - DoStartAttackAndMovement(target); + if (target) + AttackStart(target); DoCast(target, SPELL_BERSERKER_C); Charging_Timer = 20000; @@ -358,7 +358,7 @@ struct TRINITY_DLL_DECL boss_olm_the_summonerAI : public ScriptedAI if(target) { - DoStartAttackAndMovement(target); + AttackStart(target); } } @@ -465,7 +465,7 @@ struct TRINITY_DLL_DECL boss_kiggler_the_crazedAI : public ScriptedAI if(!InCombat) { - DoStartAttackAndMovement(who); + AttackStart(who); if(pInstance) { pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); @@ -485,7 +485,7 @@ struct TRINITY_DLL_DECL boss_kiggler_the_crazedAI : public ScriptedAI if(target) { - DoStartAttackAndMovement(target); + AttackStart(target); } } @@ -595,7 +595,7 @@ struct TRINITY_DLL_DECL boss_blindeye_the_seerAI : public ScriptedAI if(!InCombat) { - DoStartAttackAndMovement(who); + AttackStart(who); if(pInstance) { pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); @@ -615,7 +615,7 @@ struct TRINITY_DLL_DECL boss_blindeye_the_seerAI : public ScriptedAI if(target) { - DoStartAttackAndMovement(target); + AttackStart(target); } } @@ -709,7 +709,7 @@ struct TRINITY_DLL_DECL boss_krosh_firehandAI : public ScriptedAI if(!InCombat) { - DoStartAttackAndMovement(who); + AttackStart(who); if(pInstance) { pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); @@ -729,7 +729,7 @@ struct TRINITY_DLL_DECL boss_krosh_firehandAI : public ScriptedAI if(target) { - DoStartAttackAndMovement(target); + AttackStart(target); } } diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp index 0866ca826bc..e19dc74015d 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp @@ -54,9 +54,9 @@ EndScriptData */ #define SAY_WIPE "I am victorious!" #define SOUND_WIPE 10283 -struct TRINITY_DLL_DECL boss_omor_the_unscarredAI : public ScriptedAI +struct TRINITY_DLL_DECL boss_omor_the_unscarredAI : public Scripted_NoMovementAI { - boss_omor_the_unscarredAI(Creature *c) : ScriptedAI(c) {Reset();} + boss_omor_the_unscarredAI(Creature *c) : Scripted_NoMovementAI(c) {Reset();} uint32 OrbitalStrike_Timer; uint32 ShadowWhip_Timer; @@ -106,45 +106,6 @@ struct TRINITY_DLL_DECL boss_omor_the_unscarredAI : public ScriptedAI } } - void AttackStart(Unit* who) - { - if (!who) - return; - - if (who->isTargetableForAttack()) - { - DoStartAttackNoMovement(who); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } - } - } - - void MoveInLineOfSight(Unit* who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) - { - DoStartAttackNoMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } - } - } - } - void KilledUnit(Unit* victim) { if (rand()%2) diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp index 7b933f829be..e1115a397de 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp @@ -103,14 +103,8 @@ struct TRINITY_DLL_DECL boss_watchkeeper_gargolmarAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) { - DoStartAttackAndMovement(who); who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } + AttackStart(who); } else if (!HasTaunted && m_creature->IsWithinDistInMap(who, 60.0f)) { diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp index ecfe09ee287..d530a875804 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp @@ -193,16 +193,20 @@ struct TRINITY_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI if ( IsIntroEvent || !IsMainEvent ) return; - if( who->isTargetableForAttack() ) + if (m_creature->Attack(who, true)) { - if( Phase ) DoStartAttackNoMovement(who); - else DoStartAttackAndMovement(who); + m_creature->AddThreat(who, 0.0f); + m_creature->SetInCombatWith(who); + who->SetInCombatWith(m_creature); - if( !InCombat ) + if (!InCombat) { InCombat = true; Aggro(who); } + + if (Phase) DoStartNoMovement(who); + else DoStartMovement(who); } } @@ -230,16 +234,8 @@ struct TRINITY_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) { - if( Phase ) DoStartAttackNoMovement(who); - else DoStartAttackAndMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if( !InCombat ) - { - InCombat = true; - Aggro(who); - } + AttackStart(who); } } } diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp index d293ba7141c..06a47787fa0 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp @@ -16,7 +16,7 @@ /* ScriptData SDName: Boss_Moroes -SD%Complete: 100 +SD%Complete: 95 SDComment: SDCategory: Karazhan EndScriptData */ @@ -45,21 +45,20 @@ EndScriptData */ #define SAY_DEATH "How terribly clumsy of me..." #define SOUND_DEATH 9213 -#define SPELL_VANISH 24699 +#define SPELL_VANISH 29448 #define SPELL_GARROTE 37066 -#define SPELL_BLIND 34654 -#define SPELL_GOUGE 28456 -#define SPELL_ENRAGE 37023 +#define SPELL_BLIND 34694 +#define SPELL_GOUGE 29425 +#define SPELL_FRENZY 37023 -#define ORIENT 4.5784 #define POS_Z 81.73 -float Locations[4][2]= +float Locations[4][3]= { - {-10976.2793, -1878.1736}, - {-10979.7587, -1877.8706}, - {-10985.6650, -1877.2458}, - {-10989.1367, -1876.8309}, + {-10991.0, -1884.33, 0.614315}, + {-10989.4, -1885.88, 0.904913}, + {-10978.1, -1887.07, 2.035550}, + {-10975.9, -1885.81, 2.253890}, }; const uint32 Adds[6]= @@ -159,7 +158,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); DoPlaySoundToSet(m_creature, SOUND_DEATH); - if(pInstance) + if (pInstance) pInstance->SetData(DATA_MOROES_EVENT, DONE); DeSpawnAdds(); @@ -168,14 +167,13 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI uint8 CheckAdd(uint64 guid) { Unit* pUnit = Unit::GetUnit((*m_creature), guid); - if(pUnit) + if (pUnit) { - if(!pUnit->isAlive()) + if (!pUnit->isAlive()) return 1; // Exists but is dead else return 2; // Exists and is alive } - return 0; // Does not exist } @@ -183,7 +181,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI { Creature *pCreature = NULL; - if(FirstTime) + if (FirstTime) { std::vector<uint32> AddList; @@ -198,8 +196,8 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI { uint32 entry = *itr; - pCreature = m_creature->SummonCreature(entry, Locations[i][0], Locations[i][1], POS_Z, ORIENT, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); - if(pCreature) + pCreature = m_creature->SummonCreature(entry, Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); + if (pCreature) { AddGUID[i] = pCreature->GetGUID(); AddId[i] = entry; @@ -216,13 +214,13 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI switch(CheckAdd(AddGUID[i])) { case 0: - pCreature = m_creature->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, ORIENT, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); - if(pCreature) + pCreature = m_creature->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); + if (pCreature) AddGUID[i] = pCreature->GetGUID(); break; case 1: pCreature = ((Creature*)Unit::GetUnit((*m_creature), AddGUID[i])); - if(pCreature) + if (pCreature) { pCreature->Respawn(); pCreature->AI()->EnterEvadeMode(); @@ -230,7 +228,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI break; case 2: pCreature = ((Creature*)Unit::GetUnit((*m_creature), AddGUID[i])); - if(!pCreature->IsInEvadeMode()) + if (!pCreature->IsInEvadeMode()) pCreature->AI()->EnterEvadeMode(); break; } @@ -243,10 +241,10 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI for(uint8 i = 0; i < 4 ; ++i) { Unit* Temp = NULL; - if(AddGUID[i]) + if (AddGUID[i]) { Temp = Unit::GetUnit((*m_creature),AddGUID[i]); - if(Temp && Temp->isAlive()) + if (Temp && Temp->isAlive()) Temp->DealDamage(Temp, Temp->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); } } @@ -257,10 +255,10 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI for(uint8 i = 0; i < 4; ++i) { Unit* Temp = NULL; - if(AddGUID[i]) + if (AddGUID[i]) { Temp = Unit::GetUnit((*m_creature),AddGUID[i]); - if(Temp && Temp->isAlive()) + if (Temp && Temp->isAlive()) ((Creature*)Temp)->AI()->AttackStart(m_creature->getVictim()); else EnterEvadeMode(); @@ -278,100 +276,103 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI if(!Enrage && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30) { - DoCast(m_creature, SPELL_ENRAGE); + DoCast(m_creature, SPELL_FRENZY); Enrage = true; } - if(CheckAdds_Timer < diff) + if (CheckAdds_Timer < diff) { - for(uint8 i = 0; i < 4; ++i) + for (uint8 i = 0; i < 4; ++i) { Unit* Temp = NULL; - if(AddGUID[i]) + if (AddGUID[i]) { Temp = Unit::GetUnit((*m_creature),AddGUID[i]); - if(Temp && Temp->isAlive()) - if(!Temp->SelectHostilTarget() || !Temp->getVictim() ) + if (Temp && Temp->isAlive()) + if (!Temp->SelectHostilTarget() || !Temp->getVictim() ) ((Creature*)Temp)->AI()->AttackStart(m_creature->getVictim()); } } CheckAdds_Timer = 5000; }else CheckAdds_Timer -= diff; - //Cast Vanish, then Garrote random victim - if(Vanish_Timer < diff) - { - m_creature->setFaction(35); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - DoCast(m_creature, SPELL_VANISH); - InVanish = true; - Vanish_Timer = 30000; - Wait_Timer = 5000; - }else Vanish_Timer -= diff; - - if(InVanish) + if (!Enrage) { - if(Wait_Timer < diff) + //Cast Vanish, then Garrote random victim + if (Vanish_Timer < diff) + { + m_creature->setFaction(35); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + DoCast(m_creature, SPELL_VANISH); + InVanish = true; + Vanish_Timer = 30000; + Wait_Timer = 5000; + }else Vanish_Timer -= diff; + + if (InVanish) { - switch(rand()%2) + if (Wait_Timer < diff) { - case 0: - DoYell(SAY_SPECIAL_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SPECIAL_1); - break; - case 1: - DoYell(SAY_SPECIAL_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SPECIAL_2); - break; - } - - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - target->CastSpell(target, SPELL_GARROTE,true); - - m_creature->setFaction(16); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->AI()->AttackStart(m_creature->getVictim()); - InVanish = false; - }else Wait_Timer -= diff; - } + switch(rand()%2) + { + case 0: + DoYell(SAY_SPECIAL_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SPECIAL_1); + break; + case 1: + DoYell(SAY_SPECIAL_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SPECIAL_2); + break; + } + + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (target) + target->CastSpell(target, SPELL_GARROTE,true); + + m_creature->setFaction(16); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->AI()->AttackStart(m_creature->getVictim()); + InVanish = false; + }else Wait_Timer -= diff; + } - //Blind highest aggro, and attack second highest - if(Gouge_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_GOUGE); - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); - Gouge_Timer = 40000; - }else Gouge_Timer -= diff; + //Blind highest aggro, and attack second highest + if (Gouge_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_GOUGE); + if (m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); + Gouge_Timer = 40000; + }else Gouge_Timer -= diff; - if(Blind_Timer < diff) - { - Unit* target = NULL; - std::list<HostilReference*> t_list = m_creature->getThreatManager().getThreatList(); + if (Blind_Timer < diff) + { + Unit* target = NULL; + std::list<HostilReference*> t_list = m_creature->getThreatManager().getThreatList(); - if(t_list.empty()) - return; + if (t_list.empty()) + return; - std::vector<Unit*> target_list; - for(std::list<HostilReference*>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) - { - target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - if(target && target->GetDistance2d(m_creature) < 5) - target_list.push_back(target); - } - if(target_list.size()) - target = *(target_list.begin()+rand()%target_list.size()); + std::vector<Unit*> target_list; + for (std::list<HostilReference*>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + { + target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + if (target && target->GetDistance2d(m_creature) < 5) + target_list.push_back(target); + } + if (target_list.size()) + target = *(target_list.begin()+rand()%target_list.size()); - if(target) - DoCast(target, SPELL_BLIND); + if (target) + DoCast(target, SPELL_BLIND); - Blind_Timer = 40000; - }else Blind_Timer -= diff; + Blind_Timer = 40000; + }else Blind_Timer -= diff; + } - if(!InVanish) + if (!InVanish) DoMeleeAttackIfReady(); } }; diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp index 9f6341462a2..ddf6e9cb451 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp @@ -16,8 +16,8 @@ /* ScriptData SDName: Boss_Terestian_Illhoof -SD%Complete: 100 -SDComment: Complete! +SD%Complete: 95 +SDComment: Complete! Needs adjustments to use spell though. SDCategory: Karazhan EndScriptData */ @@ -31,6 +31,11 @@ EndScriptData */ #define SPELL_SACRIFICE 30115 // Teleports and adds the debuff #define SPELL_BERSERK 32965 // Increases attack speed by 75%. Periodically casts Shadow Bolt Volley. +#define SPELL_SUMMON_IMP 30066 // Summons Kil'rek + +#define SPELL_FIENDISH_PORTAL 30171 // Opens portal and summons Fiendish Portal, 2 sec cast +#define SPELL_FIENDISH_PORTAL_1 30179 // Opens portal and summons Fiendish Portal, instant cast + #define SPELL_FIREBOLT 18086 // Blasts a target for 150 Fire damage. #define SPELL_BROKEN_PACT 30065 // All damage taken increased by 25%. @@ -62,10 +67,6 @@ EndScriptData */ #define CREATURE_FIENDISHIMP 17267 #define CREATURE_PORTAL 17265 -#define SACRIFICE_X -11240.599 -#define SACRIFICE_Y -1694.2700 -#define SACRIFICE_Z 179.720007 - #define PORTAL_Z 179.434 float PortalLocations[2][2]= @@ -309,7 +310,7 @@ struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER) { DoCast(target, SPELL_SACRIFICE, true); - Creature* Chains = m_creature->SummonCreature(CREATURE_DEMONCHAINS, SACRIFICE_X, SACRIFICE_Y, SACRIFICE_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 21000); + Creature* Chains = m_creature->SummonCreature(CREATURE_DEMONCHAINS, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 21000); if(Chains) { ((mob_demon_chainAI*)Chains->AI())->SacrificeGUID = target->GetGUID(); diff --git a/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp b/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp index f99170d5ada..91dab811d00 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp @@ -1124,7 +1124,7 @@ struct TRINITY_DLL_DECL boss_romuloAI : public ScriptedAI if(Julianne && Julianne->getVictim()) { m_creature->AddThreat(Julianne->getVictim(), 1.0f); - DoStartAttackAndMovement(Julianne->getVictim()); + AttackStart(Julianne->getVictim()); } } } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp index 8561524af09..9217da40564 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp @@ -107,12 +107,6 @@ struct TRINITY_DLL_DECL boss_anubrekhanAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - //Begin melee attack if we are within range - DoStartAttackAndMovement(who); - if (!InCombat) { switch(rand()%3) @@ -131,6 +125,9 @@ struct TRINITY_DLL_DECL boss_anubrekhanAI : public ScriptedAI break; } } + + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + AttackStart(who); } else if (!HasTaunted && m_creature->IsWithinDistInMap(who, 60.0f)) { diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp index 5f5be2cd1de..abfa4598af1 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp @@ -97,10 +97,6 @@ struct TRINITY_DLL_DECL boss_faerlinaAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); //Say our dialog on initial aggro if (!InCombat) { @@ -124,6 +120,9 @@ struct TRINITY_DLL_DECL boss_faerlinaAI : public ScriptedAI break; } } + + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + AttackStart(who); } else if (!HasTaunted && m_creature->IsWithinDistInMap(who, 60.0f)) { diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp index 2675a6621d9..309d85936db 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp @@ -54,17 +54,14 @@ struct TRINITY_DLL_DECL boss_timmy_the_cruelAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - if (!HasYelled) { DoYell(SAY_SPAWN,LANG_UNIVERSAL,NULL); HasYelled = true; } - //Begin melee attack if we are within range - DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + AttackStart(who); } } } diff --git a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp index afaa014dd80..98c8b61586c 100644 --- a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp +++ b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp @@ -417,7 +417,7 @@ struct TRINITY_DLL_DECL boss_alythessAI : public ScriptedAI { if (!InCombat) { - DoStartAttackNoMovement(who); + DoStartNoMovement(who); Aggro(who); InCombat = true; } @@ -440,7 +440,7 @@ struct TRINITY_DLL_DECL boss_alythessAI : public ScriptedAI if (!InCombat) { - DoStartAttackNoMovement(who); + DoStartNoMovement(who); Aggro(who); InCombat = true; } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp index b8b296229aa..f80eb5c0a3f 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp @@ -123,39 +123,22 @@ struct TRINITY_DLL_DECL npc_millhouse_manastormAI : public ScriptedAI } } - void MoveInLineOfSight(Unit *who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackNoMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } - } - } - } - void AttackStart(Unit* who) { - if (who->isTargetableForAttack()) + if (m_creature->Attack(who, true)) { - DoStartAttackNoMovement(who); + m_creature->AddThreat(who, 0.0f); + m_creature->SetInCombatWith(who); + who->SetInCombatWith(m_creature); if (!InCombat) { InCombat = true; Aggro(who); } + + //TODO: Make it so he moves when target out of range + DoStartNoMovement(who); } } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp index 9c706566de4..1b66ed8811f 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp @@ -125,14 +125,8 @@ struct TRINITY_DLL_DECL boss_harbinger_skyrissAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) { - DoStartAttackAndMovement(who); who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } + AttackStart(who); } } } @@ -142,15 +136,19 @@ struct TRINITY_DLL_DECL boss_harbinger_skyrissAI : public ScriptedAI if( !Intro ) return; - if( who->isTargetableForAttack() ) + if (m_creature->Attack(who, true)) { - DoStartAttackAndMovement(who); + m_creature->AddThreat(who, 0.0f); + m_creature->SetInCombatWith(who); + who->SetInCombatWith(m_creature); - if( !InCombat ) + if (!InCombat) { InCombat = true; Aggro(who); } + + DoStartMovement(who); } } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp index 1fda311e173..0114fa1abcf 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp @@ -156,9 +156,9 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI { //Begin attack if(Phase1) - DoStartAttackNoMovement(who); + DoStartNoMovement(who); else - DoStartAttackAndMovement(who); + DoStartMovement(who); if(!InCombat) { diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp index a712b4bae6e..4081882d1c9 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp @@ -210,14 +210,8 @@ struct TRINITY_DLL_DECL advisorbase_ai : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) { - DoStartAttackAndMovement(who); who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - InCombat = true; - Aggro(who); - } + AttackStart(who); } } } @@ -227,16 +221,19 @@ struct TRINITY_DLL_DECL advisorbase_ai : public ScriptedAI if (!who || FakeDeath || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) return; - if (who->isTargetableForAttack()) + if (m_creature->Attack(who, true)) { - //Begin attack - DoStartAttackAndMovement(who); + m_creature->AddThreat(who, 0.0f); + m_creature->SetInCombatWith(who); + who->SetInCombatWith(m_creature); if (!InCombat) { InCombat = true; Aggro(who); } + + DoStartMovement(who); } } @@ -435,7 +432,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI target = SelectUnit(SELECT_TARGET_RANDOM, 0); if(target) { - DoStartAttackAndMovement(target); + AttackStart(target); } }else { @@ -506,10 +503,8 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if (Phase >= 4 && m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + AttackStart(who); } else if(who->isAlive()) { @@ -774,7 +769,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI target = SelectUnit(SELECT_TARGET_RANDOM, 0); if(target) { - DoStartAttackAndMovement(target); + AttackStart(target); } Phase_Timer = 30000; }else Phase_Timer -= diff; @@ -931,7 +926,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI DoCast(m_creature, SPELL_EXPLODE); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); Phase = 6; - DoStartAttackAndMovement(m_creature->getVictim()); + AttackStart(m_creature->getVictim()); m_creature->GetMotionMaster()->Clear(); m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); @@ -1037,7 +1032,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI InGravityLapse = false; GravityLapse_Timer = 60000; GravityLapse_Phase = 0; - DoStartAttackAndMovement(m_creature->getVictim()); + AttackStart(m_creature->getVictim()); m_creature->GetMotionMaster()->Clear(); m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); DoResetThreat(); @@ -1241,16 +1236,19 @@ struct TRINITY_DLL_DECL boss_grand_astromancer_capernianAI : public advisorbase_ if (!who || FakeDeath || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) return; - if (who->isTargetableForAttack()) + if (m_creature->Attack(who, true)) { - //Begin attack - DoStartAttackAndMovement(who, CAPERNIAN_DISTANCE, M_PI/2); + m_creature->AddThreat(who, 0.0f); + m_creature->SetInCombatWith(who); + who->SetInCombatWith(m_creature); if (!InCombat) { InCombat = true; Aggro(who); } + + DoStartMovement(who, CAPERNIAN_DISTANCE, M_PI/2); } } diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp index 220b05fb752..1dba25cd132 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp @@ -177,7 +177,7 @@ struct TRINITY_DLL_DECL boss_vemAI : public ScriptedAI { DoCast(target, SPELL_CHARGE); m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); - DoStartAttackAndMovement(target); + AttackStart(target); } Charge_Timer = 8000 + rand()%8000; diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp index e91b3f4d071..f57f1f3509c 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp @@ -80,7 +80,7 @@ struct TRINITY_DLL_DECL boss_sarturaAI : public ScriptedAI Unit* target = NULL; target = SelectUnit(SELECT_TARGET_RANDOM,1); if (target) - DoStartAttackAndMovement(target); + AttackStart(target); WhirlWindRandom_Timer = 3000 + rand()%4000; }else WhirlWindRandom_Timer -= diff; @@ -219,7 +219,7 @@ struct TRINITY_DLL_DECL mob_sartura_royal_guardAI : public ScriptedAI Unit* target = NULL; target = SelectUnit(SELECT_TARGET_RANDOM,1); if (target) - DoStartAttackAndMovement(target); + AttackStart(target); AggroReset = true; AggroReset_Timer = 2000 + rand()%3000; diff --git a/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp b/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp index c97f8284acb..7fe940268ec 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp @@ -276,7 +276,7 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI if(Phase == 2) m_creature->Attack(who, false); else - DoStartAttackAndMovement(who); + DoStartMovement(who); if (!InCombat) { @@ -680,4 +680,4 @@ void AddSC_boss_zuljin() newscript->Name="mob_zuljin_vortex"; newscript->GetAI = GetAI_feather_vortexAI; m_scripts[nrscripts++] = newscript; -}
\ No newline at end of file +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp index a82ecb0453a..e32538616f6 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp @@ -167,7 +167,7 @@ struct TRINITY_DLL_DECL boss_arlokkAI : public ScriptedAI m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35))); m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35))); m_creature->UpdateDamagePhysical(BASE_ATTACK); - DoStartAttackAndMovement(target); + AttackStart(target); //The Panther Model m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15215); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp index c2e9b616620..c882aa3ae6f 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp @@ -62,7 +62,7 @@ struct TRINITY_DLL_DECL boss_grilekAI : public ScriptedAI if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); if (target) - DoStartAttackAndMovement(target); + AttackStart(target); Avartar_Timer = 25000 + rand()%10000; }else Avartar_Timer -= diff; diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp index 2f62ef41856..86b6068cb3a 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp @@ -109,7 +109,7 @@ struct TRINITY_DLL_DECL boss_jeklikAI : public ScriptedAI m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); - DoStartAttackAndMovement(target); + AttackStart(target); } Charge_Timer = 15000 + rand()%15000; diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp index c9ba03a1d83..9781fae1f2d 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp @@ -142,7 +142,7 @@ struct TRINITY_DLL_DECL boss_mandokirAI : public ScriptedAI { DoCast(pUnit,SPELL_CHARGE); m_creature->SendMonsterMove(pUnit->GetPositionX(), pUnit->GetPositionY(), pUnit->GetPositionZ(), 0, true,1); - DoStartAttackAndMovement(pUnit); + AttackStart(pUnit); } } } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp index 6330e49dde6..de9a440ba38 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp @@ -165,10 +165,12 @@ struct TRINITY_DLL_DECL boss_marliAI : public ScriptedAI i=3; } if (target) + { DoCast(target, SPELL_CHARGE); - // m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); - // m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); - DoStartAttackAndMovement(target); + //m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + //m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); + AttackStart(target); + } Charge_Timer = 8000; }else Charge_Timer -= diff; diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp index 75b82ab9912..ada5cc6cdbc 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp @@ -121,7 +121,7 @@ struct TRINITY_DLL_DECL boss_renatakiAI : public ScriptedAI m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); if (target) - DoStartAttackAndMovement(target); + AttackStart(target); Aggro_Timer = 7000 + rand()%13000; }else Aggro_Timer -= diff; diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp index 26ecadadfd4..b1b44f9b94d 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp @@ -205,8 +205,8 @@ struct TRINITY_DLL_DECL boss_thekalAI : public ScriptedAI DoCast(target,SPELL_CHARGE); m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); - DoStartAttackAndMovement(target); DoResetThreat(); + AttackStart(target); Charge_Timer = 15000 + rand()%7000; }else Charge_Timer -= diff; diff --git a/src/bindings/scripts/sql/scripts_structure.sql b/src/bindings/scripts/sql/scripts_structure.sql index db46c42c948..dff8a54a806 100644 --- a/src/bindings/scripts/sql/scripts_structure.sql +++ b/src/bindings/scripts/sql/scripts_structure.sql @@ -1,78 +1,64 @@ +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 `eventai_scripts`; CREATE TABLE `eventai_scripts` ( -`id` int(11) unsigned NOT NULL COMMENT 'Identifier' AUTO_INCREMENT, -`creature_id` int(11) unsigned NOT NULL default '0' COMMENT 'Creature Template Identifier', - -`event_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Event Type', -`event_inverse_phase_mask` int(11) signed NOT NULL default '0' COMMENT 'Mask which phases this event will not trigger in', -`event_chance` int(3) unsigned NOT NULL default '100', -`event_flags` int(3) unsigned NOT NULL default '0', -`event_param1` int(11) signed NOT NULL default '0', -`event_param2` int(11) signed NOT NULL default '0', -`event_param3` int(11) signed NOT NULL default '0', -`event_param4` int(11) signed NOT NULL default '0', - -`action1_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Action Type', -`action1_param1` int(11) signed NOT NULL default '0', -`action1_param2` int(11) signed NOT NULL default '0', -`action1_param3` int(11) signed NOT NULL default '0', - -`action2_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Action Type', -`action2_param1` int(11) signed NOT NULL default '0', -`action2_param2` int(11) signed NOT NULL default '0', -`action2_param3` int(11) signed NOT NULL default '0', - -`action3_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Action Type', -`action3_param1` int(11) signed NOT NULL default '0', -`action3_param2` int(11) signed NOT NULL default '0', -`action3_param3` int(11) signed NOT NULL default '0', - -`comment` varchar(255) NOT NULL default '' COMMENT 'Event Comment', - - PRIMARY KEY (`id`) + `id` int(11) unsigned NOT NULL COMMENT 'Identifier' AUTO_INCREMENT, + `creature_id` int(11) unsigned NOT NULL default '0' COMMENT 'Creature Template Identifier', + `event_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Event Type', + `event_inverse_phase_mask` int(11) signed NOT NULL default '0' COMMENT 'Mask which phases this event will not trigger in', + `event_chance` int(3) unsigned NOT NULL default '100', + `event_flags` int(3) unsigned NOT NULL default '0', + `event_param1` int(11) signed NOT NULL default '0', + `event_param2` int(11) signed NOT NULL default '0', + `event_param3` int(11) signed NOT NULL default '0', + `event_param4` int(11) signed NOT NULL default '0', + `action1_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Action Type', + `action1_param1` int(11) signed NOT NULL default '0', + `action1_param2` int(11) signed NOT NULL default '0', + `action1_param3` int(11) signed NOT NULL default '0', + `action2_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Action Type', + `action2_param1` int(11) signed NOT NULL default '0', + `action2_param2` int(11) signed NOT NULL default '0', + `action2_param3` int(11) signed NOT NULL default '0', + `action3_type` tinyint(5) unsigned NOT NULL default '0' COMMENT 'Action Type', + `action3_param1` int(11) signed NOT NULL default '0', + `action3_param2` int(11) signed NOT NULL default '0', + `action3_param3` int(11) signed NOT NULL default '0', + `comment` varchar(255) NOT NULL default '' COMMENT 'Event Comment', + PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='EventAI Scripts'; -DROP TABLE IF EXISTS `eventai_texts`; -CREATE TABLE `eventai_texts` ( - -`id` int(11) unsigned NOT NULL default '0' COMMENT 'Identifier', -`text` varchar(255) character set utf8 NOT NULL default '', -`comment` varchar(255) character set utf8 NOT NULL default '' COMMENT 'Text Comment', - -PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Texts used in EventAI'; - -DROP TABLE IF EXISTS `eventai_localized_texts`; -CREATE TABLE `eventai_localized_texts` ( - -`id` int(11) unsigned NOT NULL COMMENT 'Identifier' AUTO_INCREMENT, -`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='EventAI Localized Text'; - DROP TABLE IF EXISTS `eventai_summons`; CREATE TABLE `eventai_summons` ( -`id` int(11) unsigned NOT NULL COMMENT 'Location Identifier' AUTO_INCREMENT, -`position_x` float NOT NULL default '0', -`position_y` float NOT NULL default '0', -`position_z` float NOT NULL default '0', -`orientation` float NOT NULL default '0', -`spawntimesecs` int(11) unsigned NOT NULL default '120', -`comment` varchar(255) NOT NULL default '' COMMENT 'Summon Comment', -PRIMARY KEY (`id`) + `id` int(11) unsigned NOT NULL COMMENT 'Location Identifier' AUTO_INCREMENT, + `position_x` float NOT NULL default '0', + `position_y` float NOT NULL default '0', + `position_z` float NOT NULL default '0', + `orientation` float NOT NULL default '0', + `spawntimesecs` int(11) unsigned NOT NULL default '120', + `comment` varchar(255) NOT NULL default '' COMMENT 'Summon Comment', + PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='EventAI Summoning Locations'; -DROP TABLE IF EXISTS `script_texts`; -CREATE TABLE `script_texts` ( +DROP TABLE IF EXISTS `eventai_texts`; +CREATE TABLE `eventai_texts` ( `entry` mediumint(8) NOT NULL, `content_default` text NOT NULL, `content_loc1` text, @@ -87,11 +73,11 @@ CREATE TABLE `script_texts` ( `type` tinyint unsigned NOT NULL default '0', `language` tinyint unsigned NOT NULL default '0', `comment` text, - PRIMARY KEY (`entry`) + PRIMARY KEY (`entry`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Script Texts'; -DROP TABLE IF EXISTS `custom_texts`; -CREATE TABLE `custom_texts` ( +DROP TABLE IF EXISTS `script_texts`; +CREATE TABLE `script_texts` ( `entry` mediumint(8) NOT NULL, `content_default` text NOT NULL, `content_loc1` text, @@ -107,9 +93,9 @@ CREATE TABLE `custom_texts` ( `language` tinyint unsigned NOT NULL default '0', `comment` text, PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Custom Texts'; +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Script Texts'; DROP TABLE IF EXISTS `script_db_version`; CREATE TABLE `script_db_version` ( -`version` varchar(255) NOT NULL default '' COMMENT 'Script Database version string' -) ENGINE=MyISAM DEFAULT CHARSET=utf8;
\ No newline at end of file + `version` varchar(255) NOT NULL default '' COMMENT 'Script Database version string' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; |