diff --git a/apps/codestyle/codestyle-cpp.py b/apps/codestyle/codestyle-cpp.py index 77ff3f376..7b0dea93f 100644 --- a/apps/codestyle/codestyle-cpp.py +++ b/apps/codestyle/codestyle-cpp.py @@ -223,7 +223,7 @@ def misc_codestyle_check(file: io, file_path: str) -> None: # used to check for "if/else (...) {" "} else" ignores "if/else (...) {...}" "#define ... if/else (...) {" ifelse_curlyregex = r"^[^#define].*\s+(if|else)(\s*\(.*\))?\s*{[^}]*$|}\s*else(\s*{[^}]*$)" # used to catch double semicolons ";;" ignores "(;;)" - double_semiregex = r"[^(];;[^)]" + double_semiregex = r"(? None: print( f"Curly brackets are not allowed to be leading or trailing if/else statements. Place it on a new line: {file_path} at line {line_number}") check_failed = True - if re.match(double_semiregex, line): + if re.search(double_semiregex, line): print( f"Double semicolon (;;) found in {file_path} at line {line_number}") check_failed = True diff --git a/apps/codestyle/codestyle-sql.py b/apps/codestyle/codestyle-sql.py index 662f0962c..79f13241f 100644 --- a/apps/codestyle/codestyle-sql.py +++ b/apps/codestyle/codestyle-sql.py @@ -206,18 +206,38 @@ def backtick_check(file: io, file_path: str) -> None: global error_handler, results file.seek(0) check_failed = False + + # Find SQL clauses pattern = re.compile( - r'\b(SELECT|FROM|JOIN|WHERE|GROUP BY|ORDER BY|DELETE FROM|UPDATE|INSERT INTO|SET)\s+([^;]+)', - re.IGNORECASE) + r'\b(SELECT|FROM|JOIN|WHERE|GROUP BY|ORDER BY|DELETE FROM|UPDATE|INSERT INTO|SET|REPLACE|REPLACE INTO)\s+(.*?)(?=;$|(?=\b(?:WHERE|SET|VALUES)\b)|$)', + re.IGNORECASE | re.DOTALL + ) + + + # Make sure to ignore values enclosed in single- and doublequotes + quote_pattern = re.compile(r"'(?:\\'|[^'])*'|\"(?:\\\"|[^\"])*\"") for line_number, line in enumerate(file, start=1): - matches = pattern.findall(line) + # Ignore comments + if line.startswith('--'): + continue + + # Sanitize single- and doublequotes to prevent false positives + sanitized_line = quote_pattern.sub('', line) + matches = pattern.findall(sanitized_line) + for clause, content in matches: - words = re.findall(r'\b[a-zA-Z_][a-zA-Z0-9_]*\b', content) + # Find all words and exclude @variables + words = re.findall(r'\b(? 2025_02_05_00 +-- +DELETE FROM `spell_script_names` WHERE `spell_id` IN (45370, 45367); +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(45370, 'spell_gen_translocate_down'), +(45367, 'spell_gen_translocate_up'); + +UPDATE `conditions` SET `ConditionValue2` = 187428, `Comment` = 'Translocation (Up)' WHERE `SourceEntry` = 45368 AND `SourceTypeOrReferenceId` = 13; +UPDATE `conditions` SET `ConditionValue2` = 187431, `Comment` = 'Translocation (Down)' WHERE `SourceEntry` = 45371 AND `SourceTypeOrReferenceId` = 13; diff --git a/data/sql/updates/db_world/2025_02_05_01.sql b/data/sql/updates/db_world/2025_02_05_01.sql new file mode 100644 index 000000000..dc22d80fe --- /dev/null +++ b/data/sql/updates/db_world/2025_02_05_01.sql @@ -0,0 +1,70 @@ +-- DB update 2025_02_05_00 -> 2025_02_05_01 + +-- Trapdoor Crawler +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 28221; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 28221); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(28221, 0, 0, 0, 1, 0, 100, 0, 20000, 30000, 20000, 30000, 0, 0, 11, 50981, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Trapdoor Crawler - Out of Combat - Cast \'Burrow\''), +(28221, 0, 1, 0, 23, 0, 100, 0, 50981, 1, 40000, 50000, 0, 0, 28, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Trapdoor Crawler - On Aura \'Burrow\' - Remove Aura \'null\''), +(28221, 0, 2, 0, 4, 0, 100, 0, 0, 0, 0, 0, 0, 0, 28, 50981, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Trapdoor Crawler - On Aggro - Remove Aura \'Burrow\''), +(28221, 0, 3, 0, 0, 0, 100, 0, 2000, 5000, 4000, 8000, 0, 0, 11, 11918, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Trapdoor Crawler - In Combat - Cast \'Poison\''); + +-- Thornvine Creeper +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 23874; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 23874); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(23874, 0, 0, 0, 1, 0, 100, 0, 4000, 6000, 4000, 6000, 0, 0, 11, 33907, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Thornvine Creeper - Out of Combat - Cast \'Thorns\''), +(23874, 0, 1, 0, 0, 0, 100, 0, 4000, 6000, 12000, 16000, 0, 0, 11, 31287, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Thornvine Creeper - In Combat - Cast \'Entangling Roots\''); + +-- Keeper Witherleaf +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 24638; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 24638); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(24638, 0, 0, 0, 0, 0, 100, 0, 4000, 12000, 4000, 12000, 0, 0, 11, 43619, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Keeper Witherleaf - In Combat - Cast \'Wrath\''); + +-- Runic War Golem +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 26347; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 26347); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(26347, 0, 0, 0, 0, 0, 100, 0, 8000, 12000, 20000, 30000, 0, 0, 11, 52702, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Runic War Golem - In Combat - Cast \'Rune Punch\''); + +-- Icetouched Earthrager +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 29436; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 29436); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(29436, 0, 0, 0, 0, 0, 100, 0, 4000, 8000, 12000, 24000, 0, 0, 11, 55216, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Icetouched Earthrager - In Combat - Cast \'Avalanche\''); + +-- Tukemuth +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 32400; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 32400); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(32400, 0, 0, 0, 9, 0, 100, 0, 0, 0, 9000, 13000, 0, 5, 11, 50410, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Tukemuth - Within 0-5 Range - Cast \'Tusk Strike\''), +(32400, 0, 1, 0, 0, 0, 100, 0, 9000, 17000, 15000, 22000, 0, 0, 11, 57066, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Tukemuth - In Combat - Cast \'Trample\''); + +-- Wandering Shadow +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 30842; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 30842); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(30842, 0, 0, 0, 0, 0, 100, 0, 4000, 8000, 12000, 24000, 0, 0, 11, 38240, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Wandering Shadow - In Combat - Cast \'Chilling Touch\''), +(30842, 0, 1, 0, 0, 0, 50, 0, 25000, 30000, 25000, 30000, 0, 0, 11, 18267, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Wandering Shadow - In Combat - Cast \'Curse of Weakness\''); + +-- Shadow Revenant +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 30872; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 30872); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(30872, 0, 0, 0, 0, 0, 100, 0, 4000, 8000, 12000, 20000, 0, 0, 11, 51131, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Shadow Revenant - In Combat - Cast \'Strangulate\''); + +-- Iron Rune Sentinel +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 24316; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 24316); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(24316, 0, 0, 0, 0, 0, 100, 0, 8000, 12000, 14000, 22000, 0, 0, 11, 48416, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Iron Rune Sentinel - In Combat - Cast \'Rune Detonation\''); diff --git a/data/sql/updates/db_world/2025_02_06_00.sql b/data/sql/updates/db_world/2025_02_06_00.sql new file mode 100644 index 000000000..b55abf37d --- /dev/null +++ b/data/sql/updates/db_world/2025_02_06_00.sql @@ -0,0 +1,3 @@ +-- DB update 2025_02_05_01 -> 2025_02_06_00 +-- +UPDATE `creature_template` SET `flags_extra` = `flags_extra`|2147483648 WHERE `entry` = 24850; diff --git a/data/sql/updates/db_world/2025_02_06_01.sql b/data/sql/updates/db_world/2025_02_06_01.sql new file mode 100644 index 000000000..0722f14c6 --- /dev/null +++ b/data/sql/updates/db_world/2025_02_06_01.sql @@ -0,0 +1,3 @@ +-- DB update 2025_02_06_00 -> 2025_02_06_01 +-- +UPDATE `creature_text` SET `Language` = 0 WHERE `CreatureID` = 24882 AND `GroupId`= 3 AND `ID` = 0; diff --git a/data/sql/updates/db_world/2025_02_06_02.sql b/data/sql/updates/db_world/2025_02_06_02.sql new file mode 100644 index 000000000..7632cb0ce --- /dev/null +++ b/data/sql/updates/db_world/2025_02_06_02.sql @@ -0,0 +1,5 @@ +-- DB update 2025_02_06_01 -> 2025_02_06_02 +-- Fix quest 11343 so that quest credit spell is cast on caster, not player +UPDATE `smart_scripts` +SET `target_type` = 1 +WHERE `entryorguid` = 2431400 AND `action_type` = 11 AND `action_param1` = 43458; diff --git a/data/sql/updates/db_world/2025_02_06_03.sql b/data/sql/updates/db_world/2025_02_06_03.sql new file mode 100644 index 000000000..07c7e05b9 --- /dev/null +++ b/data/sql/updates/db_world/2025_02_06_03.sql @@ -0,0 +1,15 @@ +-- DB update 2025_02_06_02 -> 2025_02_06_03 + +SET @LOOTTHISTLEBOAR := 1985; -- Skinning loot template for Thistle Boar +SET @LOOTSCORPIDWORKER := 3124; -- Skinning loot template for Scorpid Worker +SET @LIGHTLEATHER := 2318; -- Light Leather +SET @RUINEDSCRAPS := 2934; -- Ruined Leather Scraps + +-- Setting skinloot as 0 for creature that should not be skinnable +UPDATE `creature_template` SET `skinloot` = 0 WHERE `entry` IN (1984, 1985, 2032, 3124); + +-- Removing now unused skinning loot template to keep the DB cleaned up +DELETE FROM `skinning_loot_template` WHERE `entry` = @LOOTTHISTLEBOAR AND `item` = @LIGHTLEATHER; +DELETE FROM `skinning_loot_template` WHERE `entry` = @LOOTTHISTLEBOAR AND `item` = @RUINEDSCRAPS; +DELETE FROM `skinning_loot_template` WHERE `entry` = @LOOTSCORPIDWORKER AND `item` = @LIGHTLEATHER; +DELETE FROM `skinning_loot_template` WHERE `entry` = @LOOTSCORPIDWORKER AND `item` = @RUINEDSCRAPS; diff --git a/data/sql/updates/db_world/2025_02_06_04.sql b/data/sql/updates/db_world/2025_02_06_04.sql new file mode 100644 index 000000000..b5082eb96 --- /dev/null +++ b/data/sql/updates/db_world/2025_02_06_04.sql @@ -0,0 +1,4 @@ +-- DB update 2025_02_06_03 -> 2025_02_06_04 +-- Update gold drop rate with min 437 and max 3869 like picture +-- I suspect realistically ~200 ~4000 +UPDATE `creature_template` SET `mingold` = 437, `maxgold` = 3869 WHERE `entry` IN (18853, 19453, 18852, 18857, 19779, 18855, 19643); diff --git a/data/sql/updates/db_world/2025_02_07_00.sql b/data/sql/updates/db_world/2025_02_07_00.sql new file mode 100644 index 000000000..959c141cb --- /dev/null +++ b/data/sql/updates/db_world/2025_02_07_00.sql @@ -0,0 +1,3 @@ +-- DB update 2025_02_06_04 -> 2025_02_07_00 +-- +UPDATE `creature_addon` SET `mount` = 20675 WHERE `guid` = 94387; diff --git a/data/sql/updates/db_world/2025_02_07_01.sql b/data/sql/updates/db_world/2025_02_07_01.sql new file mode 100644 index 000000000..b509f9978 --- /dev/null +++ b/data/sql/updates/db_world/2025_02_07_01.sql @@ -0,0 +1,4 @@ +-- DB update 2025_02_07_00 -> 2025_02_07_01 + +-- Thornvine Creeper skinloot +UPDATE `creature_template` SET `skinloot` = 80007 WHERE (`entry` = 23874); diff --git a/data/sql/updates/db_world/2025_02_07_02.sql b/data/sql/updates/db_world/2025_02_07_02.sql new file mode 100644 index 000000000..c79a2f33a --- /dev/null +++ b/data/sql/updates/db_world/2025_02_07_02.sql @@ -0,0 +1,2 @@ +-- DB update 2025_02_07_01 -> 2025_02_07_02 +UPDATE `creature_template` SET `skinloot` = 80103 WHERE `entry` = 24316; diff --git a/data/sql/updates/db_world/2025_02_07_03.sql b/data/sql/updates/db_world/2025_02_07_03.sql new file mode 100644 index 000000000..1ed135df9 --- /dev/null +++ b/data/sql/updates/db_world/2025_02_07_03.sql @@ -0,0 +1,3 @@ +-- DB update 2025_02_07_02 -> 2025_02_07_03 +-- Setting the 'CREATURE_FLAG_EXTRA_CIVILIAN' flag +UPDATE `creature_template` SET `flags_extra` = `flags_extra` | 2 WHERE `entry` = 27064; diff --git a/data/sql/updates/db_world/2025_02_07_04.sql b/data/sql/updates/db_world/2025_02_07_04.sql new file mode 100644 index 000000000..f954db55b --- /dev/null +++ b/data/sql/updates/db_world/2025_02_07_04.sql @@ -0,0 +1,3 @@ +-- DB update 2025_02_07_03 -> 2025_02_07_04 +-- Failed Incursion requirement removed from Lost in Action +UPDATE `quest_template_addon` SET `PrevQuestID` = 0 WHERE (`ID` = 9738); diff --git a/data/sql/updates/db_world/2025_02_09_00.sql b/data/sql/updates/db_world/2025_02_09_00.sql new file mode 100644 index 000000000..eedfb57af --- /dev/null +++ b/data/sql/updates/db_world/2025_02_09_00.sql @@ -0,0 +1,31 @@ +-- DB update 2025_02_07_04 -> 2025_02_09_00 +-- Kaylaan smart ai +SET @ENTRY := 20780; +UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE `entry` = @ENTRY; +DELETE FROM `smart_scripts` WHERE `source_type` = 0 AND `entryOrGuid` = @ENTRY; +DELETE FROM `smart_scripts` WHERE `source_type` = 9 AND `entryOrGuid` IN (@ENTRY * 100); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(@ENTRY, 0, 0, 0, 1, 0, 100, 0, 0, 0, 74000, 105000, 0, 0, 80, @ENTRY * 100, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Kaylaan - Out of Combat - Run Script'), +(@ENTRY * 100, 9, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Kaylaan - Actionlist - Say Line 0'), +(@ENTRY * 100, 9, 1, 0, 0, 0, 100, 0, 2000, 2000, 0, 0, 0, 0, 11, 35746, 0, 0, 0, 0, 0, 19, 20922, 10, 0, 0, 0, 0, 0, 'Kaylaan - Actionlist - Cast \'Resurrection\''), +(@ENTRY * 100, 9, 2, 0, 0, 0, 100, 0, 8000, 8000, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Kaylaan - Actionlist - Say Line 1'); + +-- Add creature spawn +SET @CGUID := 425; +DELETE FROM `creature` WHERE `id1` = 20922 AND `guid` = @CGUID; +INSERT INTO `creature` (`guid`, `id1`, `id2`, `id3`, `map`, `zoneId`, `areaId`, `spawnMask`, `phaseMask`, `equipment_id`, `position_x`, `position_y`, `position_z`, `orientation`, `spawntimesecs`, `wander_distance`, `currentwaypoint`, `curhealth`, `curmana`, `MovementType`, `npcflag`, `unit_flags`, `dynamicflags`, `ScriptName`, `VerifiedBuild`) VALUES +(@CGUID, 20922, 0, 0, 530, 3523, 3852, 1, 1, 0, 4034.83203125, 3545.646728515625, 121.47908782958984, 2.670353651046753, 120, 0, 0, 6986, 0, 0, 0, 0, 0, '', 58629); + +-- aura 29266 Permanent Feign Death +DELETE FROM `creature_addon` WHERE (`guid` IN (@CGUID)); +INSERT INTO `creature_addon` (`guid`, `path_id`, `mount`, `bytes1`, `bytes2`, `emote`, `visibilityDistanceType`, `auras`) VALUES +(@CGUID, 0, 0, 0, 1, 0, 0, '29266'); + +-- add creature_text +DELETE FROM `creature_text` WHERE `CreatureID` = 20780; +INSERT INTO `creature_text` (`CreatureID`, `GroupID`, `ID`, `Text`, `Type`, `Language`, `Probability`, `Emote`, `Duration`, `Sound`, `BroadcastTextId`, `TextRange`, `comment`) VALUES +(20780, 0, 1, 'Light! Do not fail me!', 12, 0, 100, 274, 0, 0, 18385, 0, 'Kaylaan'), +(20780, 0, 2, 'Do not die on me, vindicator!', 12, 0, 100, 0, 0, 0, 18386, 0, 'Kaylaan'), +(20780, 0, 3, 'Kael\'thas and the Legion... just what we needed!', 12, 0, 100, 0, 0, 0, 18387, 0, 'Kaylaan'), +(20780, 1, 0, 'It is hopeless... I\'ve done all I can.', 12, 0, 100, 274, 0, 0, 18594, 0, 'Kaylaan'), +(20780, 1, 1, 'I\'ve failed. The Light has abandoned me.', 12, 0, 100, 274, 0, 0, 18595, 0, 'Kaylaan'); diff --git a/data/sql/updates/db_world/2025_02_09_01.sql b/data/sql/updates/db_world/2025_02_09_01.sql new file mode 100644 index 000000000..fc3b723cd --- /dev/null +++ b/data/sql/updates/db_world/2025_02_09_01.sql @@ -0,0 +1,19 @@ +-- DB update 2025_02_09_00 -> 2025_02_09_01 +-- +SET +@sunwellnone = 116, +@sunwellfirst = 117, +@sunwellsecond = 118, +@sunwellall = 119; + +-- Vindicator Moorba +-- move menuID entries and conditions from 51004 to 9293 `creature_template.gossip_menu_id` +UPDATE `gossip_menu` SET `MenuID` = 9293 WHERE `MenuID` = 51004 AND `TextID` IN (12602, 12603, 12605); +UPDATE `conditions` SET `SourceGroup` = 9293 WHERE `SourceGroup` = 51004 AND `SourceEntry` IN (12602, 12603, 12605) AND `ConditionTypeOrReference` = 12 AND `ConditionValue1` IN (@sunwellnone, @sunwellfirst, @sunwellsecond); + +DELETE FROM `conditions` WHERE `ConditionTypeOrReference` = 12 AND `ConditionValue1` IN (@sunwellall) AND `SourceGroup` IN (9307, 9293) AND `SourceEntry` IN (12623, 12604); +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +-- Exarch Nasuun (Shattrath) +(14, 9307, 12623, 0, 0, 12, 0, @sunwellall, 0, 0, 0, 0, 0, '', 'Show gossip text if the event ''SWP - All Gates Open'' is active'), +-- Vindicator Moorba (SWP) +(14, 9293, 12604, 0, 0, 12, 0, @sunwellall, 0, 0, 0, 0, 0, '', 'Show gossip text if the event ''SWP - All Gates Open'' is active'); diff --git a/data/sql/updates/db_world/2025_02_09_02.sql b/data/sql/updates/db_world/2025_02_09_02.sql new file mode 100644 index 000000000..3b3b668c4 --- /dev/null +++ b/data/sql/updates/db_world/2025_02_09_02.sql @@ -0,0 +1,10 @@ +-- DB update 2025_02_09_01 -> 2025_02_09_02 + +-- Theremis +UPDATE `creature_template_movement` SET `Flight` = 1, `Ground` = 2 WHERE (`CreatureId` = 25976); + +-- Shattered Sun Archmage +UPDATE `creature_template_movement` SET `Flight` = 1, `Ground` = 2 WHERE (`CreatureId` = 25170); + +-- Yrma +UPDATE `creature_template_movement` SET `Flight` = 1, `Ground` = 2 WHERE (`CreatureId` = 25977); diff --git a/data/sql/updates/db_world/2025_02_09_03.sql b/data/sql/updates/db_world/2025_02_09_03.sql new file mode 100644 index 000000000..ba396a05c --- /dev/null +++ b/data/sql/updates/db_world/2025_02_09_03.sql @@ -0,0 +1,2 @@ +-- DB update 2025_02_09_02 -> 2025_02_09_03 +UPDATE `creature_template` SET `speed_run` = 0.42857 WHERE `entry` = 25543; diff --git a/data/sql/updates/db_world/2025_02_09_04.sql b/data/sql/updates/db_world/2025_02_09_04.sql new file mode 100644 index 000000000..da6d8656c --- /dev/null +++ b/data/sql/updates/db_world/2025_02_09_04.sql @@ -0,0 +1,32 @@ +-- DB update 2025_02_09_03 -> 2025_02_09_04 +-- +UPDATE `creature_template_movement` SET `Flight` = 2 WHERE `CreatureId` = 25038; + +DELETE FROM `creature` WHERE `id1` = 25038; + +-- Pathing for Entry: 25038 +SET @NPC := 25038; +SET @PATH := @NPC * 10; +DELETE FROM `waypoint_data` WHERE `id`=@PATH; +INSERT INTO `waypoint_data` (`id`,`point`,`position_x`,`position_y`,`position_z`,`orientation`,`delay`,`move_type`,`action`,`action_chance`,`wpguid`) VALUES +(@PATH,1,1469.8419,617.6385,43.109043,0,0,2,0,100,0), +(@PATH,2,1457.057,601.483,45.94235,0,0,2,0,100,0), +(@PATH,3,1441.8115,579.3153,47.886784,0,0,2,0,100,0), +(@PATH,4,1436.9575,553.7235,48.136852,0,0,2,0,100,0), +(@PATH,5,1445.1992,530.0166,47.609146,0,0,2,0,100,0), +(@PATH,6,1466.5448,511.74057,46.942425,0,0,2,0,100,0), +(@PATH,7,1495.123,512.1063,47.056377,0,0,2,0,100,0), +(@PATH,8,1508.4324,531.7451,46.67483,0,0,2,0,100,0), +(@PATH,9,1511.3053,556.9556,46.87133,0,0,2,0,100,0), +(@PATH,10,1507.6771,580.32935,47.010162,0,0,2,0,100,0), +(@PATH,11,1497.4128,601.9794,47.37127,0,0,0,2,100,0), +(@PATH,12,1479.3727,624.20746,47.287914,0,0,2,0,100,0), +(@PATH,13,1467.832,637.91895,46.565674,0,0,2,0,100,0), +(@PATH,14,1449.8766,658.87976,46.037872,0,0,2,0,100,0), +(@PATH,15,1442.1505,681.62445,45.26012,0,0,2,0,100,0), +(@PATH,16,1438.8881,713.9516,44.95452,0,0,2,0,100,0), +(@PATH,17,1452.2178,737.73157,44.23236,0,0,2,0,100,0), +(@PATH,18,1476.1324,743.0824,43.843422,0,0,2,0,100,0), +(@PATH,19,1498.3573,726.6184,43.843445,0,0,2,0,100,0), +(@PATH,20,1503.4194,693.78595,44.26011,0,0,2,0,100,0), +(@PATH,21,1496.3456,664.36005,43.037888,0,0,2,0,100,0); diff --git a/data/sql/updates/db_world/2025_02_10_00.sql b/data/sql/updates/db_world/2025_02_10_00.sql new file mode 100644 index 000000000..66cb0b7d2 --- /dev/null +++ b/data/sql/updates/db_world/2025_02_10_00.sql @@ -0,0 +1,8 @@ +-- DB update 2025_02_09_04 -> 2025_02_10_00 +-- +DELETE FROM `spell_custom_attr` WHERE `spell_id`=46305; +INSERT INTO `spell_custom_attr` (`spell_id`, `attributes`) VALUES (46305, 4194304); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 25948) AND (`source_type` = 0) AND (`id` IN (0)); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(25948, 0, 0, 0, 6, 0, 100, 0, 0, 0, 0, 0, 0, 0, 11, 46305, 2, 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 'Doomfire Shard - On Just Died - Cast \'Avenging Rage\''); diff --git a/data/sql/updates/db_world/2025_02_10_01.sql b/data/sql/updates/db_world/2025_02_10_01.sql new file mode 100644 index 000000000..551c28143 --- /dev/null +++ b/data/sql/updates/db_world/2025_02_10_01.sql @@ -0,0 +1,29 @@ +-- DB update 2025_02_10_00 -> 2025_02_10_01 + +-- Remove flag IMMUNE_TO_NPC. Add Flag PET_IN_COMBAT (Sniffed Values) +UPDATE `creature_template` SET `unit_flags`=`unit_flags`& ~512 WHERE (`entry` = 24938); +UPDATE `creature_template` SET `unit_flags`=`unit_flags`|2048 WHERE (`entry` = 24938); + +-- Change Temp movement +UPDATE `creature_template_movement` SET `Rooted` = `Rooted`|1 WHERE (`CreatureId` = 24938); + +-- Dawnblade Hawkrider SmartAI +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 25063; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 25063); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(25063, 0, 0, 0, 25, 0, 100, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Dawnblade Hawkrider - On Reset - Set Reactstate Passive'), +(25063, 0, 1, 0, 60, 0, 100, 0, 3000, 6500, 3000, 6500, 0, 0, 11, 45189, 2, 0, 1, 0, 0, 9, 24938, 5, 40, 0, 0, 0, 0, 0, 'Dawnblade Hawkrider - On Update - Cast \'Dawnblade Attack\''); + +-- Shattered Sun Marksman SmartAI +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 24938; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 24938); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(24938, 0, 0, 0, 1, 0, 100, 1, 1000, 1000, 1000, 1000, 0, 0, 21, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Sun Marksman - Out of Combat - Disable Combat Movement (No Repeat)'), +(24938, 0, 1, 0, 60, 0, 100, 0, 4500, 8000, 4500, 8000, 0, 0, 11, 74414, 0, 0, 1, 0, 0, 9, 25063, 0, 40, 0, 0, 0, 0, 0, 'Shattered Sun Marksman - On Update - Cast \'Shoot\''), +(24938, 0, 2, 0, 10, 0, 100, 1, 0, 70, 4500, 8000, 0, 0, 11, 74414, 0, 0, 0, 0, 0, 9, 25192, 0, 50, 0, 0, 0, 0, 0, 'Shattered Sun Marksman - Within 0-70 Range Out of Combat LoS - Cast \'Shoot\' (No Repeat)'), +(24938, 0, 3, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 0, 88, 2493810, 2493813, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Sun Marksman - On Respawn - Run Random Script'), +(24938, 0, 4, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 0, 88, 2493820, 2493823, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Sun Marksman - On Respawn - Run Random Script'), +(24938, 0, 5, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 0, 88, 2493830, 2493833, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Sun Marksman - On Respawn - Run Random Script'), +(24938, 0, 6, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 0, 88, 2493840, 2493843, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Sun Marksman - On Respawn - Run Random Script'); diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp index d42ce67a2..5bb8b3f41 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp @@ -267,6 +267,8 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_ALL_GAME_EVENT_CONDITION_SAVE, "DELETE FROM game_event_condition_save WHERE eventEntry = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GAME_EVENT_CONDITION_SAVE, "DELETE FROM game_event_condition_save WHERE eventEntry = ? AND condition_id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_GAME_EVENT_CONDITION_SAVE, "INSERT INTO game_event_condition_save (eventEntry, condition_id, done) VALUES (?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_GAME_EVENT_CONDITION_SAVE_DATA, "SELECT eventEntry, condition_id, done FROM game_event_condition_save", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_GAME_EVENT_SAVE_DATA, "SELECT eventEntry, state, next_start FROM game_event_save", CONNECTION_SYNCH); // Petitions PrepareStatement(CHAR_DEL_ALL_PETITION_SIGNATURES, "DELETE FROM petition_sign WHERE playerguid = ?", CONNECTION_ASYNC); diff --git a/src/server/database/Database/Implementation/CharacterDatabase.h b/src/server/database/Database/Implementation/CharacterDatabase.h index b7c428e1c..6f8ac783e 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.h +++ b/src/server/database/Database/Implementation/CharacterDatabase.h @@ -218,6 +218,8 @@ enum CharacterDatabaseStatements : uint32 CHAR_DEL_ALL_GAME_EVENT_CONDITION_SAVE, CHAR_DEL_GAME_EVENT_CONDITION_SAVE, CHAR_INS_GAME_EVENT_CONDITION_SAVE, + CHAR_SEL_GAME_EVENT_CONDITION_SAVE_DATA, + CHAR_SEL_GAME_EVENT_SAVE_DATA, CHAR_INS_ARENA_TEAM, CHAR_INS_ARENA_TEAM_MEMBER, diff --git a/src/server/database/Database/Implementation/WorldDatabase.cpp b/src/server/database/Database/Implementation/WorldDatabase.cpp index d6081c983..f216c9583 100644 --- a/src/server/database/Database/Implementation/WorldDatabase.cpp +++ b/src/server/database/Database/Implementation/WorldDatabase.cpp @@ -84,6 +84,21 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? AND (phaseMask & ?) <> 0 ORDER BY order_", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_CREATURE_NEAREST, "SELECT guid, id1, id2, id3, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? AND (phaseMask & ?) <> 0 ORDER BY order_", CONNECTION_SYNCH); PrepareStatement(WORLD_INS_CREATURE, "INSERT INTO creature (guid, id1, id2, id3, map, spawnMask, phaseMask, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, dynamicflags) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(WORLD_SEL_GAME_EVENTS, "SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, holidayStage, description, world_event, announce FROM game_event", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_PREREQUISITE_DATA, "SELECT eventEntry, prerequisite_event FROM game_event_prerequisite", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_CREATURE_DATA, "SELECT guid, eventEntry FROM game_event_creature", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_GAMEOBJECT_DATA, "SELECT guid, eventEntry FROM game_event_gameobject", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_MODEL_EQUIPMENT_DATA, "SELECT creature.guid, creature.id1, creature.id2, creature.id3, game_event_model_equip.eventEntry, game_event_model_equip.modelid, game_event_model_equip.equipment_id FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_QUEST_DATA, "SELECT id, quest, eventEntry FROM game_event_creature_quest", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_GAMEOBJECT_QUEST_DATA, "SELECT id, quest, eventEntry FROM game_event_gameobject_quest", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_QUEST_CONDITION_DATA, "SELECT quest, eventEntry, condition_id, num FROM game_event_quest_condition", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_CONDITION_DATA, "SELECT eventEntry, condition_id, req_num, max_world_state_field, done_world_state_field FROM game_event_condition", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_NPC_FLAGS, "SELECT guid, eventEntry, npcflag FROM game_event_npcflag", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_QUEST_SEASONAL_RELATIONS, "SELECT questId, eventEntry FROM game_event_seasonal_questrelation", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_BATTLEGROUND_DATA, "SELECT eventEntry, bgflag FROM game_event_battleground_holiday", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_POOL_DATA, "SELECT pool_template.entry, game_event_pool.eventEntry FROM pool_template JOIN game_event_pool ON pool_template.entry = game_event_pool.pool_entry", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_ARENA_SEASON, "SELECT eventEntry FROM game_event_arena_seasons WHERE season = ?", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_HOLIDAY_DATES, "SELECT id, date_id, date_value, holiday_duration FROM holiday_dates", CONNECTION_SYNCH); PrepareStatement(WORLD_DEL_GAME_EVENT_CREATURE, "DELETE FROM game_event_creature WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP, "DELETE FROM game_event_model_equip WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_SEL_GAME_EVENT_NPC_VENDOR, "SELECT eventEntry, guid, item, maxcount, incrtime, ExtendedCost FROM game_event_npc_vendor ORDER BY guid, slot ASC", CONNECTION_SYNCH); diff --git a/src/server/database/Database/Implementation/WorldDatabase.h b/src/server/database/Database/Implementation/WorldDatabase.h index 049766725..016791ccd 100644 --- a/src/server/database/Database/Implementation/WorldDatabase.h +++ b/src/server/database/Database/Implementation/WorldDatabase.h @@ -90,6 +90,21 @@ enum WorldDatabaseStatements : uint32 WORLD_SEL_CREATURE_NEAREST, WORLD_SEL_GAMEOBJECT_TARGET, WORLD_INS_CREATURE, + WORLD_SEL_GAME_EVENTS, + WORLD_SEL_GAME_EVENT_PREREQUISITE_DATA, + WORLD_SEL_GAME_EVENT_CREATURE_DATA, + WORLD_SEL_GAME_EVENT_GAMEOBJECT_DATA, + WORLD_SEL_GAME_EVENT_MODEL_EQUIPMENT_DATA, + WORLD_SEL_GAME_EVENT_QUEST_DATA, + WORLD_SEL_GAME_EVENT_GAMEOBJECT_QUEST_DATA, + WORLD_SEL_GAME_EVENT_QUEST_CONDITION_DATA, + WORLD_SEL_GAME_EVENT_CONDITION_DATA, + WORLD_SEL_GAME_EVENT_NPC_FLAGS, + WORLD_SEL_GAME_EVENT_QUEST_SEASONAL_RELATIONS, + WORLD_SEL_GAME_EVENT_BATTLEGROUND_DATA, + WORLD_SEL_GAME_EVENT_POOL_DATA, + WORLD_SEL_GAME_EVENT_ARENA_SEASON, + WORLD_SEL_GAME_EVENT_HOLIDAY_DATES, WORLD_DEL_GAME_EVENT_CREATURE, WORLD_DEL_GAME_EVENT_MODEL_EQUIP, WORLD_SEL_GAME_EVENT_NPC_VENDOR, diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index fe609ea1f..ae10a9f9d 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -806,7 +806,10 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl return nullptr; } - creature->SetFaction(BattlefieldFactions[teamId]); + // no need to set faction for neutral team + if (teamId == TEAM_ALLIANCE || teamId == TEAM_HORDE) + creature->SetFaction(BattlefieldFactions[teamId]); + creature->SetHomePosition(x, y, z, o); // force using DB speeds -- do we really need this? diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 96c2d3847..bc83a2361 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -525,7 +525,7 @@ bool Creature::InitEntry(uint32 Entry, const CreatureData* data) SetFloatValue(UNIT_FIELD_HOVERHEIGHT, cinfo->HoverHeight); - SetCanDualWield(cinfo->flags_extra & CREATURE_FLAG_EXTRA_USE_OFFHAND_ATTACK); + SetCanDualWield(cinfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_USE_OFFHAND_ATTACK)); // checked at loading m_defaultMovementType = MovementGeneratorType(cinfo->MovementType); @@ -556,7 +556,7 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele uint32 npcflag, unit_flags, dynamicflags; ObjectMgr::ChooseCreatureFlags(cInfo, npcflag, unit_flags, dynamicflags, data); - if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_WORLDEVENT) + if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_WORLDEVENT)) ReplaceAllNpcFlags(NPCFlags(npcflag | sGameEventMgr->GetNPCFlag(this))); else ReplaceAllNpcFlags(NPCFlags(npcflag)); @@ -571,7 +571,7 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele ReplaceAllDynamicFlags(dynamicflags); - SetCanDualWield(cInfo->flags_extra & CREATURE_FLAG_EXTRA_USE_OFFHAND_ATTACK); + SetCanDualWield(cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_USE_OFFHAND_ATTACK)); SetAttackTime(BASE_ATTACK, cInfo->BaseAttackTime); SetAttackTime(OFF_ATTACK, cInfo->BaseAttackTime); @@ -637,7 +637,7 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele InitializeReactState(); - if (!IsPet() && cInfo->flags_extra & CREATURE_FLAG_EXTRA_NO_TAUNT) + if (!IsPet() && cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_TAUNT)) { ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true); @@ -1200,7 +1200,7 @@ bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, u LastUsedScriptID = GetScriptId(); - if (IsSpiritHealer() || IsSpiritGuide() || (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GHOST_VISIBILITY)) + if (IsSpiritHealer() || IsSpiritGuide() || HasFlagsExtra(CREATURE_FLAG_EXTRA_GHOST_VISIBILITY)) { m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST); m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST); @@ -1213,7 +1213,7 @@ bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, u if (Entry == VISUAL_WAYPOINT) SetVisible(false); - if (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_IGNORE_PATHFINDING) + if (HasFlagsExtra(CREATURE_FLAG_EXTRA_IGNORE_PATHFINDING)) AddUnitState(UNIT_STATE_IGNORE_PATHFINDING); return true; @@ -2175,12 +2175,8 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds forceRespawnTimer) RemoveCorpse(true); if (forceRespawnTimer > Seconds::zero()) - { if (GetMap()) - { GetMap()->ScheduleCreatureRespawn(GetGUID(), forceRespawnTimer); - } - } } void Creature::DespawnOrUnsummon(Milliseconds msTimeToDespawn /*= 0*/, Seconds forcedRespawnTimer) @@ -2203,7 +2199,7 @@ void Creature::DespawnOnEvade(Seconds respawnDelay) if (TempSummon* whoSummon = ToTempSummon()) { - LOG_WARN("entities.unit", "DespawnOnEvade called on a temporary summon."); + GetMap()->ScheduleCreatureRespawn(GetGUID(), respawnDelay, GetHomePosition()); whoSummon->UnSummon(); return; } @@ -3184,8 +3180,7 @@ bool Creature::IsDungeonBoss() const if (GetOwnerGUID().IsPlayer()) return false; - CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry()); - return cinfo && (cinfo->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS); + return HasFlagsExtra(CREATURE_FLAG_EXTRA_DUNGEON_BOSS); } bool Creature::IsImmuneToKnockback() const @@ -3193,8 +3188,7 @@ bool Creature::IsImmuneToKnockback() const if (GetOwnerGUID().IsPlayer()) return false; - CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry()); - return cinfo && (cinfo->flags_extra & CREATURE_FLAG_EXTRA_IMMUNITY_KNOCKBACK); + return HasFlagsExtra(CREATURE_FLAG_EXTRA_IMMUNITY_KNOCKBACK); } bool Creature::HasWeapon(WeaponAttackType type) const @@ -3464,7 +3458,7 @@ void Creature::UpdateMovementFlags() return; // Creatures with CREATURE_FLAG_EXTRA_NO_MOVE_FLAGS_UPDATE should control MovementFlags in your own scripts - if (info->flags_extra & CREATURE_FLAG_EXTRA_NO_MOVE_FLAGS_UPDATE) + if (info->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_MOVE_FLAGS_UPDATE)) return; float ground = GetFloorZ(); @@ -3820,7 +3814,7 @@ void Creature::ModifyThreatPercentTemp(Unit* victim, int32 percent, Milliseconds bool Creature::IsDamageEnoughForLootingAndReward() const { - return (m_creatureInfo->flags_extra & CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ) || (_playerDamageReq == 0 && _damagedByPlayer); + return m_creatureInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ) || (_playerDamageReq == 0 && _damagedByPlayer); } void Creature::LowerPlayerDamageReq(uint32 unDamage, bool damagedByPlayer /*= true*/) diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 2642b7d08..6b861f17e 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -70,10 +70,11 @@ public: void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } void SetCorpseRemoveTime(uint32 delay); [[nodiscard]] uint32 GetCorpseDelay() const { return m_corpseDelay; } + [[nodiscard]] bool HasFlagsExtra(uint32 flag) const { return GetCreatureTemplate()->HasFlagsExtra(flag); } [[nodiscard]] bool IsRacialLeader() const { return GetCreatureTemplate()->RacialLeader; } - [[nodiscard]] bool IsCivilian() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; } - [[nodiscard]] bool IsTrigger() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; } - [[nodiscard]] bool IsGuard() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; } + [[nodiscard]] bool IsCivilian() const { return HasFlagsExtra(CREATURE_FLAG_EXTRA_CIVILIAN); } + [[nodiscard]] bool IsTrigger() const { return HasFlagsExtra(CREATURE_FLAG_EXTRA_TRIGGER); } + [[nodiscard]] bool IsGuard() const { return HasFlagsExtra(CREATURE_FLAG_EXTRA_GUARD); } CreatureMovementData const& GetMovementTemplate() const; [[nodiscard]] bool CanWalk() const { return GetMovementTemplate().IsGroundAllowed(); } [[nodiscard]] bool CanSwim() const override; @@ -127,7 +128,7 @@ public: [[nodiscard]] bool IsDungeonBoss() const; [[nodiscard]] bool IsImmuneToKnockback() const; - [[nodiscard]] bool IsAvoidingAOE() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_AVOID_AOE; } + [[nodiscard]] bool IsAvoidingAOE() const { return HasFlagsExtra(CREATURE_FLAG_EXTRA_AVOID_AOE); } uint8 getLevelForTarget(WorldObject const* target) const override; // overwrite Unit::getLevelForTarget for boss level support @@ -272,7 +273,7 @@ public: bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; } bool CanAssistTo(Unit const* u, Unit const* enemy, bool checkfaction = true) const; bool _IsTargetAcceptable(Unit const* target) const; - [[nodiscard]] bool CanIgnoreFeignDeath() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_IGNORE_FEIGN_DEATH) != 0; } + [[nodiscard]] bool CanIgnoreFeignDeath() const { return HasFlagsExtra(CREATURE_FLAG_EXTRA_IGNORE_FEIGN_DEATH); } // pussywizard: Updated at faction change, disable move in line of sight if actual faction is not hostile to anyone void UpdateMoveInLineOfSightState(); diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index 28b923d1e..a0c044a5d 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -310,13 +310,9 @@ void TempSummon::UnSummon(uint32 msTime) if (WorldObject* owner = GetSummoner()) { if (owner->IsCreature() && owner->ToCreature()->IsAIEnabled) - { owner->ToCreature()->AI()->SummonedCreatureDespawn(this); - } else if (owner->IsGameObject() && owner->ToGameObject()->AI()) - { owner->ToGameObject()->AI()->SummonedCreatureDespawn(this); - } } AddObjectToRemoveList(); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 5a97ed8d1..1a0dbd402 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -12721,17 +12721,11 @@ bool Player::isHonorOrXPTarget(Unit* victim) const // Victim level less gray level if (v_level <= k_grey) - { return false; - } if (victim->IsCreature()) - { - if (victim->IsTotem() || victim->IsCritter() || victim->IsPet() || (victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP)) - { + if (victim->IsTotem() || victim->IsCritter() || victim->IsPet() || victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_XP)) return false; - } - } return true; } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 3bf1e4aad..35aece6e6 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1375,7 +1375,7 @@ public: [[nodiscard]] Player* GetTrader() const { return m_trade ? m_trade->GetTrader() : nullptr; } [[nodiscard]] TradeData* GetTradeData() const { return m_trade; } - void TradeCancel(bool sendback); + void TradeCancel(bool sendback, TradeStatus status = TRADE_STATUS_TRADE_CANCELED); CinematicMgr* GetCinematicMgr() const { return _cinematicMgr; } diff --git a/src/server/game/Entities/Player/PlayerStorage.cpp b/src/server/game/Entities/Player/PlayerStorage.cpp index 0080963b6..4b3a28cc3 100644 --- a/src/server/game/Entities/Player/PlayerStorage.cpp +++ b/src/server/game/Entities/Player/PlayerStorage.cpp @@ -4085,7 +4085,7 @@ void Player::SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, GetSession()->SendPacket(&data); } -void Player::TradeCancel(bool sendback) +void Player::TradeCancel(bool sendback, TradeStatus status /*= TRADE_STATUS_TRADE_CANCELED*/) { if (m_trade) { @@ -4093,9 +4093,9 @@ void Player::TradeCancel(bool sendback) // send yellow "Trade canceled" message to both traders if (sendback) - GetSession()->SendCancelTrade(); + GetSession()->SendCancelTrade(status); - trader->GetSession()->SendCancelTrade(); + trader->GetSession()->SendCancelTrade(status); // cleanup delete m_trade; @@ -6066,7 +6066,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint3 GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList(); for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr) { - if (uint32(events[*itr].holiday_id) == proto->HolidayId) + if (uint32(events[*itr].HolidayId) == proto->HolidayId) { remove = false; break; @@ -6724,7 +6724,7 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, target_map, this)) { - GetSession()->SendAreaTriggerMessage("{}", GetSession()->GetAcoreString(LANG_INSTANCE_CLOSED)); + GetSession()->SendAreaTriggerMessage(LANG_INSTANCE_CLOSED); return false; } @@ -6862,11 +6862,11 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map { ObjectMgr::GetLocaleString(il->Name, loc_idx, name); } - GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_LEVEL_MINREQUIRED_AND_ITEM), ar->levelMin, name.c_str()); + GetSession()->SendAreaTriggerMessage(LANG_LEVEL_MINREQUIRED_AND_ITEM, ar->levelMin, name); } else if (LevelMin) { - GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_LEVEL_MINREQUIRED), LevelMin); + GetSession()->SendAreaTriggerMessage(LANG_LEVEL_MINREQUIRED, LevelMin); } else if (ilvlRequirementNotMet) { @@ -6924,11 +6924,11 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map if (LevelMin) { - GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_LEVEL_MINREQUIRED), LevelMin); + GetSession()->SendAreaTriggerMessage(LANG_LEVEL_MINREQUIRED, LevelMin); } else if (LevelMax) { - GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_ACCESS_REQUIREMENT_MAX_LEVEL), LevelMax); + GetSession()->SendAreaTriggerMessage(LANG_ACCESS_REQUIREMENT_MAX_LEVEL, LevelMax); } else if (mapDiff->hasErrorMessage && !errorAlreadyPrinted) { diff --git a/src/server/game/Entities/Player/PlayerUpdates.cpp b/src/server/game/Entities/Player/PlayerUpdates.cpp index efc83f329..862113798 100644 --- a/src/server/game/Entities/Player/PlayerUpdates.cpp +++ b/src/server/game/Entities/Player/PlayerUpdates.cpp @@ -980,9 +980,7 @@ void Player::UpdateWeaponSkill(Unit* victim, WeaponAttackType attType, Item* ite if (GetShapeshiftForm() == FORM_TREE) return; // use weapon but not skill up - if (victim->IsCreature() && - (victim->ToCreature()->GetCreatureTemplate()->flags_extra & - CREATURE_FLAG_EXTRA_NO_SKILL_GAINS)) + if (victim->IsCreature() && victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_SKILL_GAINS)) return; uint32 weapon_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_WEAPON); @@ -1168,7 +1166,7 @@ bool Player::UpdatePosition(float x, float y, float z, float orientation, SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION); if (GetTrader() && !IsWithinDistInMap(GetTrader(), INTERACTION_DISTANCE)) - GetSession()->SendCancelTrade(); + GetSession()->SendCancelTrade(TRADE_STATUS_TRADE_CANCELED); CheckAreaExploreAndOutdoor(); diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index c76c79865..1ab462f70 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -582,7 +582,22 @@ void MotionTransport::DelayedTeleportTransport() float destX, destY, destZ, destO; obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO); TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o); - if (!obj->ToPlayer()->TeleportTo(newMapId, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT)) + + Player* player = obj->ToPlayer(); + // Vehicle passengers are dropped in the middle of nowhere, so lets try to eject them, add to the transport and teleport + // this needs to be revisited to properly restore vehicles with passengers after transport teleportation + if (player->IsVehicle()) + if (Vehicle* vehicleKit = player->GetVehicleKit()) + for (SeatMap::iterator itr = vehicleKit->Seats.begin(); itr != vehicleKit->Seats.end(); ++itr) + if (Player* passenger = ObjectAccessor::GetPlayer(*player, itr->second.Passenger.Guid)) + { + passenger->ExitVehicle(); + AddPassenger(passenger, true); + if (!passenger->TeleportTo(newMapId, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT)) + _passengers.erase(passenger); + } + + if (!player->TeleportTo(newMapId, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT)) _passengers.erase(obj); } break; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 48b593294..c2501d1e5 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2856,7 +2856,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy //LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: attack came from behind and victim was a player."); } // Xinef: do not allow to dodge with CREATURE_FLAG_EXTRA_NO_DODGE flag - else if (victim->IsPlayer() || !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_DODGE)) + else if (victim->IsPlayer() || !(victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_DODGE))) { // Reduce dodge chance by attacker expertise rating if (IsPlayer()) @@ -2898,7 +2898,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy else parry_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25; - if (victim->IsPlayer() || !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY)) + if (victim->IsPlayer() || !(victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_PARRY))) { tmp = parry_chance; @@ -2915,7 +2915,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy } } - if (victim->IsPlayer() || !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK)) + if (victim->IsPlayer() || !(victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_BLOCK))) { tmp = block_chance; @@ -2957,7 +2957,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy if (getLevelForTarget(victim) >= victim->getLevelForTarget(this) + 4 && // can be from by creature (if can) or from controlled player that considered as creature !IsControlledByPlayer() && - !(IsCreature() && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSHING_BLOWS)) + !(IsCreature() && ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_CRUSHING_BLOWS))) { // when their weapon skill is 15 or more above victim's defense skill tmp = victimDefenseSkill; @@ -2984,10 +2984,8 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy if (tmp > 0 && roll < (sum += tmp)) { LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: CRIT <{}, {})", sum - tmp, sum); - if (IsCreature() && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT)) - { + if (IsCreature() && (ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_CRIT))) LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: CRIT DISABLED)"); - } else return MELEE_HIT_CRIT; } @@ -3122,7 +3120,7 @@ bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttac { // Check creatures flags_extra for disable block if (victim->IsCreature() && - victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK) + victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_BLOCK)) return false; float blockChance = victim->GetUnitBlockChance(); @@ -10453,10 +10451,9 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) creature->SendAIReaction(AI_REACTION_HOSTILE); /// @todo: Implement aggro range, detection range and assistance range templates - if (!(creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_DONT_CALL_ASSISTANCE)) - { + if (!(creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_DONT_CALL_ASSISTANCE))) creature->CallAssistance(); - } + creature->SetAssistanceTimer(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_PERIOD)); SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); @@ -15144,7 +15141,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration, Unit const* source = casterOwner ? casterOwner : caster; if ((target->IsPlayer() - || target->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH) + || target->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_ALL_DIMINISH)) && source->IsPlayer()) duration = limitduration; } @@ -15153,7 +15150,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration, if (group == DIMINISHING_TAUNT) { - if (IsCreature() && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_OBEYS_TAUNT_DIMINISHING_RETURNS)) + if (IsCreature() && (ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_OBEYS_TAUNT_DIMINISHING_RETURNS))) { DiminishingLevels diminish = Level; switch (diminish) @@ -15180,7 +15177,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration, // Some diminishings applies to mobs too (for example, Stun) else if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && ((targetOwner ? (targetOwner->IsPlayer()) : (IsPlayer())) - || (IsCreature() && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))) + || (IsCreature() && ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_ALL_DIMINISH)))) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL) { DiminishingLevels diminish = Level; @@ -18057,7 +18054,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp if (instanceMap->IsDungeon() && player) if (instanceMap->IsRaidOrHeroicDungeon()) - if (creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) + if (creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND)) instanceMap->ToInstanceMap()->PermBindAllPlayers(); } } @@ -20997,16 +20994,12 @@ void Unit::PatchValuesUpdate(ByteBuffer& valuesUpdateBuf, BuildValuesCachePosPoi break; } - if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) + if (cinfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_TRIGGER)) { if (target->IsGameMaster() && target->GetSession()->IsGMAccount()) - { displayId = cinfo->GetFirstVisibleModel()->CreatureDisplayID; - } else - { displayId = cinfo->GetFirstInvisibleModel()->CreatureDisplayID; - } } } diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index 1927e4ee4..ce529ff24 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -42,16 +42,16 @@ GameEventMgr* GameEventMgr::instance() bool GameEventMgr::CheckOneGameEvent(uint16 entry) const { - switch (mGameEvent[entry].state) + switch (_gameEvent[entry].State) { default: case GAMEEVENT_NORMAL: { time_t currenttime = GameTime::GetGameTime().count(); // Get the event information - return mGameEvent[entry].start < currenttime - && currenttime < mGameEvent[entry].end - && (currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE) < mGameEvent[entry].length * MINUTE; + return _gameEvent[entry].Start < currenttime + && currenttime < _gameEvent[entry].End + && (currenttime - _gameEvent[entry].Start) % (_gameEvent[entry].Occurence * MINUTE) < _gameEvent[entry].Length * MINUTE; } // if the state is conditions or nextphase, then the event should be active case GAMEEVENT_WORLD_CONDITIONS: @@ -65,15 +65,15 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry) const case GAMEEVENT_WORLD_INACTIVE: { time_t currenttime = GameTime::GetGameTime().count(); - for (std::set::const_iterator itr = mGameEvent[entry].prerequisite_events.begin(); itr != mGameEvent[entry].prerequisite_events.end(); ++itr) + for (std::set::const_iterator itr = _gameEvent[entry].PrerequisiteEvents.begin(); itr != _gameEvent[entry].PrerequisiteEvents.end(); ++itr) { - if ((mGameEvent[*itr].state != GAMEEVENT_WORLD_NEXTPHASE && mGameEvent[*itr].state != GAMEEVENT_WORLD_FINISHED) || // if prereq not in nextphase or finished state, then can't start this one - mGameEvent[*itr].nextstart > currenttime) // if not in nextphase state for long enough, can't start this one + if ((_gameEvent[*itr].State != GAMEEVENT_WORLD_NEXTPHASE && _gameEvent[*itr].State != GAMEEVENT_WORLD_FINISHED) || // if prereq not in nextphase or finished state, then can't start this one + _gameEvent[*itr].NextStart > currenttime) // if not in nextphase state for long enough, can't start this one return false; } // all prerequisite events are met // but if there are no prerequisites, this can be only activated through gm command - return !(mGameEvent[entry].prerequisite_events.empty()); + return !(_gameEvent[entry].PrerequisiteEvents.empty()); } } } @@ -83,161 +83,160 @@ uint32 GameEventMgr::NextCheck(uint16 entry) const time_t currenttime = GameTime::GetGameTime().count(); // for NEXTPHASE state world events, return the delay to start the next event, so the followup event will be checked correctly - if ((mGameEvent[entry].state == GAMEEVENT_WORLD_NEXTPHASE || mGameEvent[entry].state == GAMEEVENT_WORLD_FINISHED) && mGameEvent[entry].nextstart >= currenttime) - return uint32(mGameEvent[entry].nextstart - currenttime); + if ((_gameEvent[entry].State == GAMEEVENT_WORLD_NEXTPHASE || _gameEvent[entry].State == GAMEEVENT_WORLD_FINISHED) && _gameEvent[entry].NextStart >= currenttime) + return uint32(_gameEvent[entry].NextStart - currenttime); // for CONDITIONS state world events, return the length of the wait period, so if the conditions are met, this check will be called again to set the timer as NEXTPHASE event - if (mGameEvent[entry].state == GAMEEVENT_WORLD_CONDITIONS) + if (_gameEvent[entry].State == GAMEEVENT_WORLD_CONDITIONS) { - if (mGameEvent[entry].length) - return mGameEvent[entry].length * 60; + if (_gameEvent[entry].Length) + return _gameEvent[entry].Length * 60; else return max_ge_check_delay; } // outdated event: we return max - if (currenttime > mGameEvent[entry].end) + if (currenttime > _gameEvent[entry].End) return max_ge_check_delay; // never started event, we return delay before start - if (mGameEvent[entry].start > currenttime) - return uint32(mGameEvent[entry].start - currenttime); + if (_gameEvent[entry].Start > currenttime) + return uint32(_gameEvent[entry].Start - currenttime); uint32 delay; // in event, we return the end of it - if ((((currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * 60)) < (mGameEvent[entry].length * 60))) + if ((((currenttime - _gameEvent[entry].Start) % (_gameEvent[entry].Occurence * 60)) < (_gameEvent[entry].Length * 60))) // we return the delay before it ends - delay = (mGameEvent[entry].length * MINUTE) - ((currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE)); + delay = (_gameEvent[entry].Length * MINUTE) - ((currenttime - _gameEvent[entry].Start) % (_gameEvent[entry].Occurence * MINUTE)); else // not in window, we return the delay before next start - delay = (mGameEvent[entry].occurence * MINUTE) - ((currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE)); + delay = (_gameEvent[entry].Occurence * MINUTE) - ((currenttime - _gameEvent[entry].Start) % (_gameEvent[entry].Occurence * MINUTE)); // In case the end is before next check - if (mGameEvent[entry].end < time_t(currenttime + delay)) - return uint32(mGameEvent[entry].end - currenttime); + if (_gameEvent[entry].End < time_t(currenttime + delay)) + return uint32(_gameEvent[entry].End - currenttime); else return delay; } -void GameEventMgr::StartInternalEvent(uint16 event_id) +void GameEventMgr::StartInternalEvent(uint16 eventId) { - if (event_id < 1 || event_id >= mGameEvent.size()) + if (eventId < 1 || eventId >= _gameEvent.size()) return; - if (!mGameEvent[event_id].isValid()) + if (!_gameEvent[eventId].isValid()) return; - if (m_ActiveEvents.find(event_id) != m_ActiveEvents.end()) + if (_activeEvents.find(eventId) != _activeEvents.end()) return; - StartEvent(event_id); + StartEvent(eventId); } -bool GameEventMgr::StartEvent(uint16 event_id, bool overwrite) +bool GameEventMgr::StartEvent(uint16 eventId, bool overwrite) { - if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_GAME_EVENT, event_id, nullptr) && !overwrite) - { + if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_GAME_EVENT, eventId, nullptr) && !overwrite) return false; - } - GameEventData& data = mGameEvent[event_id]; - if (data.state == GAMEEVENT_NORMAL || data.state == GAMEEVENT_INTERNAL) + GameEventData& data = _gameEvent[eventId]; + if (data.State == GAMEEVENT_NORMAL || data.State == GAMEEVENT_INTERNAL) { - AddActiveEvent(event_id); - ApplyNewEvent(event_id); + AddActiveEvent(eventId); + ApplyNewEvent(eventId); if (overwrite) { - mGameEvent[event_id].start = GameTime::GetGameTime().count(); - if (data.end <= data.start) - data.end = data.start + data.length; + _gameEvent[eventId].Start = GameTime::GetGameTime().count(); + if (data.End <= data.Start) + data.End = data.Start + data.Length; } - if (IsActiveEvent(event_id)) - sScriptMgr->OnGameEventStart(event_id); + if (IsActiveEvent(eventId)) + sScriptMgr->OnGameEventStart(eventId); // When event is started, set its worldstate to current time - auto itr = _gameEventSeasonalQuestsMap.find(event_id); + auto itr = _gameEventSeasonalQuestsMap.find(eventId); if (itr != _gameEventSeasonalQuestsMap.end() && !itr->second.empty()) { - sWorld->setWorldState(event_id, GameTime::GetGameTime().count()); + sWorld->setWorldState(eventId, GameTime::GetGameTime().count()); } return false; } else { - if (data.state == GAMEEVENT_WORLD_INACTIVE) + if (data.State == GAMEEVENT_WORLD_INACTIVE) // set to conditions phase - data.state = GAMEEVENT_WORLD_CONDITIONS; + data.State = GAMEEVENT_WORLD_CONDITIONS; // add to active events - AddActiveEvent(event_id); + AddActiveEvent(eventId); // add spawns - ApplyNewEvent(event_id); + ApplyNewEvent(eventId); // check if can go to next state - bool conditions_met = CheckOneGameEventConditions(event_id); + bool conditions_met = CheckOneGameEventConditions(eventId); // save to db - SaveWorldEventStateToDB(event_id); + SaveWorldEventStateToDB(eventId); // force game event update to set the update timer if conditions were met from a command // this update is needed to possibly start events dependent on the started one // or to scedule another update where the next event will be started if (overwrite && conditions_met) sWorld->ForceGameEventUpdate(); - if (IsActiveEvent(event_id)) - sScriptMgr->OnGameEventStart(event_id); + if (IsActiveEvent(eventId)) + sScriptMgr->OnGameEventStart(eventId); return conditions_met; } } -void GameEventMgr::StopEvent(uint16 event_id, bool overwrite) +void GameEventMgr::StopEvent(uint16 eventId, bool overwrite) { - GameEventData& data = mGameEvent[event_id]; - bool serverwide_evt = data.state != GAMEEVENT_NORMAL && data.state != GAMEEVENT_INTERNAL; + GameEventData& data = _gameEvent[eventId]; + bool serverwide_evt = data.State != GAMEEVENT_NORMAL && data.State != GAMEEVENT_INTERNAL; - RemoveActiveEvent(event_id); - UnApplyEvent(event_id); + RemoveActiveEvent(eventId); + UnApplyEvent(eventId); // When event is stopped, clean up its worldstate - sWorld->setWorldState(event_id, 0); + sWorld->setWorldState(eventId, 0); if (overwrite && !serverwide_evt) { - data.start = GameTime::GetGameTime().count() - data.length * MINUTE; - if (data.end <= data.start) - data.end = data.start + data.length; + data.Start = GameTime::GetGameTime().count() - data.Length * MINUTE; + if (data.End <= data.Start) + data.End = data.Start + data.Length; } else if (serverwide_evt) { // if finished world event, then only gm command can stop it - if (overwrite || data.state != GAMEEVENT_WORLD_FINISHED) + if (overwrite || data.State != GAMEEVENT_WORLD_FINISHED) { // reset conditions - data.nextstart = 0; - data.state = GAMEEVENT_WORLD_INACTIVE; + data.NextStart = 0; + data.State = GAMEEVENT_WORLD_INACTIVE; GameEventConditionMap::iterator itr; - for (itr = data.conditions.begin(); itr != data.conditions.end(); ++itr) - itr->second.done = 0; + for (itr = data.Conditions.begin(); itr != data.Conditions.end(); ++itr) + itr->second.Done = 0; CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ALL_GAME_EVENT_CONDITION_SAVE); - stmt->SetData(0, uint8(event_id)); + stmt->SetData(0, uint8(eventId)); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GAME_EVENT_SAVE); - stmt->SetData(0, uint8(event_id)); + stmt->SetData(0, uint8(eventId)); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); } } - if (!IsActiveEvent(event_id)) - sScriptMgr->OnGameEventStop(event_id); + if (!IsActiveEvent(eventId)) + sScriptMgr->OnGameEventStop(eventId); } void GameEventMgr::LoadEventVendors() { + LOG_INFO("server.loading", "Loading Game Event Vendor Additions Data..."); uint32 oldMSTime = getMSTime(); WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_NPC_VENDOR); PreparedQueryResult result = WorldDatabase.Query(stmt); @@ -258,7 +257,7 @@ void GameEventMgr::LoadEventVendors() uint8 eventId = fields[0].Get(); ObjectGuid::LowType guid = fields[1].Get(); - if (eventId >= mGameEventVendors.size()) + if (eventId >= _gameEventVendors.size()) { LOG_ERROR("sql.sql", "Table `game_event_npc_vendor` has invalid eventEntry ({}) for GUID ({}), skipped.", eventId, guid); continue; @@ -268,24 +267,24 @@ void GameEventMgr::LoadEventVendors() if (processedEvents.find(eventId) == processedEvents.end()) { // Remove vendor items from in-memory data - for (auto& entry : mGameEventVendors[eventId]) + for (auto& entry : _gameEventVendors[eventId]) { - sObjectMgr->RemoveVendorItem(entry.entry, entry.item, false); + sObjectMgr->RemoveVendorItem(entry.Entry, entry.Item, false); } - mGameEventVendors[eventId].clear(); + _gameEventVendors[eventId].clear(); processedEvents.insert(eventId); } - NPCVendorList& vendors = mGameEventVendors[eventId]; + NPCVendorList& vendors = _gameEventVendors[eventId]; NPCVendorEntry newEntry; - newEntry.item = fields[2].Get(); - newEntry.maxcount = fields[3].Get(); - newEntry.incrtime = fields[4].Get(); + newEntry.Item = fields[2].Get(); + newEntry.MaxCount = fields[3].Get(); + newEntry.Incrtime = fields[4].Get(); newEntry.ExtendedCost = fields[5].Get(); // Get the event NPC flag for validity check uint32 event_npc_flag = 0; - NPCFlagList& flist = mGameEventNPCFlags[eventId]; + NPCFlagList& flist = _gameEventNPCFlags[eventId]; for (NPCFlagList::const_iterator itr = flist.begin(); itr != flist.end(); ++itr) { if (itr->first == guid) @@ -296,21 +295,21 @@ void GameEventMgr::LoadEventVendors() } // Get creature entry - newEntry.entry = 0; + newEntry.Entry = 0; if (CreatureData const* data = sObjectMgr->GetCreatureData(guid)) - newEntry.entry = data->id1; + newEntry.Entry = data->id1; // Validate vendor item - if (!sObjectMgr->IsVendorItemValid(newEntry.entry, newEntry.item, newEntry.maxcount, newEntry.incrtime, newEntry.ExtendedCost, nullptr, nullptr, event_npc_flag)) + if (!sObjectMgr->IsVendorItemValid(newEntry.Entry, newEntry.Item, newEntry.MaxCount, newEntry.Incrtime, newEntry.ExtendedCost, nullptr, nullptr, event_npc_flag)) { LOG_ERROR("sql.sql", "Table `game_event_npc_vendor` has invalid item ({}) for guid ({}) for event ({}), skipped.", - newEntry.item, newEntry.entry, eventId); + newEntry.Item, newEntry.Entry, eventId); continue; } // Add the item to the vendor if event is active if (IsEventActive(eventId)) - sObjectMgr->AddVendorItem(newEntry.entry, newEntry.item, newEntry.maxcount, newEntry.incrtime, newEntry.ExtendedCost, false); + sObjectMgr->AddVendorItem(newEntry.Entry, newEntry.Item, newEntry.MaxCount, newEntry.Incrtime, newEntry.ExtendedCost, false); vendors.push_back(newEntry); @@ -322,716 +321,757 @@ void GameEventMgr::LoadEventVendors() } -void GameEventMgr::LoadFromDB() +void GameEventMgr::LoadEvents() { + LOG_INFO("server.loading", "Loading Game Events..."); + uint32 oldMSTime = getMSTime(); + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENTS); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - // 1 2 3 4 5 6 7 8 9 10 - QueryResult result = WorldDatabase.Query("SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, holidayStage, description, world_event, announce FROM game_event"); - if (!result) + _gameEvent.clear(); + LOG_WARN("server.loading", ">> Loaded 0 game events. DB table `game_event` is empty."); + LOG_INFO("server.loading", " "); + return; + } + + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + uint8 eventId = fields[0].Get(); + if (eventId == 0) { - mGameEvent.clear(); - LOG_WARN("server.loading", ">> Loaded 0 game events. DB table `game_event` is empty."); - LOG_INFO("server.loading", " "); - return; + LOG_ERROR("sql.sql", "`game_event` game event entry 0 is reserved and can't be used."); + continue; } + GameEventData& pGameEvent = _gameEvent[eventId]; + pGameEvent.EventId = fields[0].Get(); + uint64 starttime = fields[1].Get(); + pGameEvent.Start = time_t(starttime); + uint64 endtime = fields[2].Get(); + if (fields[2].IsNull()) + endtime = GameTime::GetGameTime().count() + 63072000; // add 2 years to current date + pGameEvent.End = time_t(endtime); + pGameEvent.Occurence = fields[3].Get(); + pGameEvent.Length = fields[4].Get(); + pGameEvent.HolidayId = HolidayIds(fields[5].Get()); + pGameEvent.HolidayStage = fields[6].Get(); + pGameEvent.Description = fields[7].Get(); + pGameEvent.State = (GameEventState)(fields[8].Get()); + pGameEvent.Announce = fields[9].Get(); + pGameEvent.NextStart = 0; + + ++count; + + if (pGameEvent.Length == 0 && pGameEvent.State == GAMEEVENT_NORMAL) // length>0 is validity check + { + LOG_ERROR("sql.sql", "`game_event` game event id ({}) isn't a world event and has length = 0, thus it can't be used.", eventId); + continue; + } + + if (pGameEvent.HolidayId != HOLIDAY_NONE) + { + if (!sHolidaysStore.LookupEntry(pGameEvent.HolidayId)) + { + LOG_ERROR("sql.sql", "`game_event` game event id ({}) have not existed holiday id {}.", eventId, pGameEvent.HolidayId); + pGameEvent.HolidayId = HOLIDAY_NONE; + } + + SetHolidayEventTime(pGameEvent); + } + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); +} + +void GameEventMgr::LoadEventSaveData() +{ + uint32 oldMSTime = getMSTime(); + LOG_INFO("server.loading", "Loading Game Event Saves Data..."); + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GAME_EVENT_SAVE_DATA); + PreparedQueryResult result = CharacterDatabase.Query(stmt); + + if (!result) + { + LOG_WARN("server.loading", ">> Loaded 0 Game Event Saves In Game Events. DB Table `game_event_save` Is Empty."); + LOG_INFO("server.loading", " "); + } + else + { uint32 count = 0; do { Field* fields = result->Fetch(); - uint8 event_id = fields[0].Get(); - if (event_id == 0) + uint8 eventId = fields[0].Get(); + + if (eventId >= _gameEvent.size()) { - LOG_ERROR("sql.sql", "`game_event` game event entry 0 is reserved and can't be used."); + LOG_ERROR("sql.sql", "`game_event_save` game event entry ({}) is out of range compared to max event entry in `game_event`", eventId); continue; } - GameEventData& pGameEvent = mGameEvent[event_id]; - pGameEvent.eventId = fields[0].Get(); - uint64 starttime = fields[1].Get(); - pGameEvent.start = time_t(starttime); - uint64 endtime = fields[2].Get(); - if (fields[2].IsNull()) - endtime = GameTime::GetGameTime().count() + 63072000; // add 2 years to current date - pGameEvent.end = time_t(endtime); - pGameEvent.occurence = fields[3].Get(); - pGameEvent.length = fields[4].Get(); - pGameEvent.holiday_id = HolidayIds(fields[5].Get()); - - pGameEvent.holidayStage = fields[6].Get(); - pGameEvent.description = fields[7].Get(); - pGameEvent.state = (GameEventState)(fields[8].Get()); - pGameEvent.announce = fields[9].Get(); - pGameEvent.nextstart = 0; + if (_gameEvent[eventId].State != GAMEEVENT_NORMAL && _gameEvent[eventId].State != GAMEEVENT_INTERNAL) + { + _gameEvent[eventId].State = (GameEventState)(fields[1].Get()); + _gameEvent[eventId].NextStart = time_t(fields[2].Get()); + } + else + { + LOG_ERROR("sql.sql", "game_event_save includes event save for non-worldevent id {}", eventId); + continue; + } ++count; + } while (result->NextRow()); - if (pGameEvent.length == 0 && pGameEvent.state == GAMEEVENT_NORMAL) // length>0 is validity check + LOG_INFO("server.loading", ">> Loaded {} Game Event Saves In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadEventPrerequisiteData() +{ + LOG_INFO("server.loading", "Loading Game Event Prerequisite Data..."); + + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_PREREQUISITE_DATA); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) + { + LOG_WARN("server.loading", ">> Loaded 0 Game Rvent Prerequisites in Game Events. DB Table `game_event_prerequisite` Is Empty."); + LOG_INFO("server.loading", " "); + } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + uint16 eventId = fields[0].Get(); + + if (eventId >= _gameEvent.size()) { - LOG_ERROR("sql.sql", "`game_event` game event id ({}) isn't a world event and has length = 0, thus it can't be used.", event_id); + LOG_ERROR("sql.sql", "`game_event_prerequisite` game event id ({}) is out of range compared to max event id in `game_event`", eventId); continue; } - if (pGameEvent.holiday_id != HOLIDAY_NONE) + if (_gameEvent[eventId].State != GAMEEVENT_NORMAL && _gameEvent[eventId].State != GAMEEVENT_INTERNAL) { - if (!sHolidaysStore.LookupEntry(pGameEvent.holiday_id)) + uint16 prerequisite_event = fields[1].Get(); + if (prerequisite_event >= _gameEvent.size()) { - LOG_ERROR("sql.sql", "`game_event` game event id ({}) have not existed holiday id {}.", event_id, pGameEvent.holiday_id); - pGameEvent.holiday_id = HOLIDAY_NONE; + LOG_ERROR("sql.sql", "`game_event_prerequisite` game event prerequisite id ({}) is out of range compared to max event id in `game_event`", prerequisite_event); + continue; } - - SetHolidayEventTime(pGameEvent); + _gameEvent[eventId].PrerequisiteEvents.insert(prerequisite_event); } + else + { + LOG_ERROR("sql.sql", "game_event_prerequisiste includes event entry for non-worldevent id {}", eventId); + continue; + } + + ++count; } while (result->NextRow()); - LOG_INFO("server.loading", ">> Loaded {} Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", ">> Loaded {} game event prerequisites in Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); LOG_INFO("server.loading", " "); } +} - LOG_INFO("server.loading", "Loading Game Event Saves Data..."); - { - uint32 oldMSTime = getMSTime(); - - // 0 1 2 - QueryResult result = CharacterDatabase.Query("SELECT eventEntry, state, next_start FROM game_event_save"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 Game Event Saves In Game Events. DB Table `game_event_save` Is Empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - uint8 event_id = fields[0].Get(); - - if (event_id >= mGameEvent.size()) - { - LOG_ERROR("sql.sql", "`game_event_save` game event entry ({}) is out of range compared to max event entry in `game_event`", event_id); - continue; - } - - if (mGameEvent[event_id].state != GAMEEVENT_NORMAL && mGameEvent[event_id].state != GAMEEVENT_INTERNAL) - { - mGameEvent[event_id].state = (GameEventState)(fields[1].Get()); - mGameEvent[event_id].nextstart = time_t(fields[2].Get()); - } - else - { - LOG_ERROR("sql.sql", "game_event_save includes event save for non-worldevent id {}", event_id); - continue; - } - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Game Event Saves In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } - } - - LOG_INFO("server.loading", "Loading Game Event Prerequisite Data..."); - { - uint32 oldMSTime = getMSTime(); - - // 0 1 - QueryResult result = WorldDatabase.Query("SELECT eventEntry, prerequisite_event FROM game_event_prerequisite"); - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 Game Rvent Prerequisites in Game Events. DB Table `game_event_prerequisite` Is Empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - uint16 event_id = fields[0].Get(); - - if (event_id >= mGameEvent.size()) - { - LOG_ERROR("sql.sql", "`game_event_prerequisite` game event id ({}) is out of range compared to max event id in `game_event`", event_id); - continue; - } - - if (mGameEvent[event_id].state != GAMEEVENT_NORMAL && mGameEvent[event_id].state != GAMEEVENT_INTERNAL) - { - uint16 prerequisite_event = fields[1].Get(); - if (prerequisite_event >= mGameEvent.size()) - { - LOG_ERROR("sql.sql", "`game_event_prerequisite` game event prerequisite id ({}) is out of range compared to max event id in `game_event`", prerequisite_event); - continue; - } - mGameEvent[event_id].prerequisite_events.insert(prerequisite_event); - } - else - { - LOG_ERROR("sql.sql", "game_event_prerequisiste includes event entry for non-worldevent id {}", event_id); - continue; - } - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} game event prerequisites in Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } - } - +void GameEventMgr::LoadEventCreatureData() +{ LOG_INFO("server.loading", "Loading Game Event Creature Data..."); + + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_CREATURE_DATA); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 - QueryResult result = WorldDatabase.Query("SELECT guid, eventEntry FROM game_event_creature"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 creatures in game events. DB table `game_event_creature` is empty"); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - ObjectGuid::LowType guid = fields[0].Get(); - int16 event_id = fields[1].Get(); - - CreatureData const* data = sObjectMgr->GetCreatureData(guid); - if (!data) - { - LOG_ERROR("sql.sql", "`game_event_creature` contains creature (GUID: {}) not found in `creature` table.", guid); - continue; - } - - int32 internal_event_id = mGameEvent.size() + event_id - 1; - - if (internal_event_id < 0 || internal_event_id >= int32(mGameEventCreatureGuids.size())) - { - LOG_ERROR("sql.sql", "`game_event_creature` game event id ({}) is out of range compared to max event id in `game_event`", event_id); - continue; - } - - GuidLowList& crelist = mGameEventCreatureGuids[internal_event_id]; - crelist.push_back(guid); - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Creatures In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_WARN("server.loading", ">> Loaded 0 creatures in game events. DB table `game_event_creature` is empty"); + LOG_INFO("server.loading", " "); } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + ObjectGuid::LowType guid = fields[0].Get(); + int16 eventId = fields[1].Get(); + + CreatureData const* data = sObjectMgr->GetCreatureData(guid); + if (!data) + { + LOG_ERROR("sql.sql", "`game_event_creature` contains creature (GUID: {}) not found in `creature` table.", guid); + continue; + } + + int32 internal_event_id = _gameEvent.size() + eventId - 1; + + if (internal_event_id < 0 || internal_event_id >= int32(GameEventCreatureGuids.size())) + { + LOG_ERROR("sql.sql", "`game_event_creature` game event id ({}) is out of range compared to max event id in `game_event`", eventId); + continue; + } + + GuidLowList& crelist = GameEventCreatureGuids[internal_event_id]; + crelist.push_back(guid); + + ++count; + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Creatures In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadEventGameObjectData() +{ LOG_INFO("server.loading", "Loading Game Event GO Data..."); + + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_GAMEOBJECT_DATA); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 - QueryResult result = WorldDatabase.Query("SELECT guid, eventEntry FROM game_event_gameobject"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 gameobjects in game events. DB table `game_event_gameobject` is empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - ObjectGuid::LowType guid = fields[0].Get(); - int16 event_id = fields[1].Get(); - - int32 internal_event_id = mGameEvent.size() + event_id - 1; - - GameObjectData const* data = sObjectMgr->GetGameObjectData(guid); - if (!data) - { - LOG_ERROR("sql.sql", "`game_event_gameobject` contains gameobject (GUID: {}) not found in `gameobject` table.", guid); - continue; - } - - if (internal_event_id < 0 || internal_event_id >= int32(mGameEventGameobjectGuids.size())) - { - LOG_ERROR("sql.sql", "`game_event_gameobject` game event id ({}) is out of range compared to max event id in `game_event`", event_id); - continue; - } - - GuidLowList& golist = mGameEventGameobjectGuids[internal_event_id]; - golist.push_back(guid); - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Gameobjects In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_WARN("server.loading", ">> Loaded 0 gameobjects in game events. DB table `game_event_gameobject` is empty."); + LOG_INFO("server.loading", " "); } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + ObjectGuid::LowType guid = fields[0].Get(); + int16 eventId = fields[1].Get(); + + int32 internal_event_id = _gameEvent.size() + eventId - 1; + + GameObjectData const* data = sObjectMgr->GetGameObjectData(guid); + if (!data) + { + LOG_ERROR("sql.sql", "`game_event_gameobject` contains gameobject (GUID: {}) not found in `gameobject` table.", guid); + continue; + } + + if (internal_event_id < 0 || internal_event_id >= int32(GameEventGameobjectGuids.size())) + { + LOG_ERROR("sql.sql", "`game_event_gameobject` game event id ({}) is out of range compared to max event id in `game_event`", eventId); + continue; + } + + GuidLowList& golist = GameEventGameobjectGuids[internal_event_id]; + golist.push_back(guid); + + ++count; + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Gameobjects In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadEventModelEquipmentChangeData() +{ LOG_INFO("server.loading", "Loading Game Event Model/Equipment Change Data..."); + + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_MODEL_EQUIPMENT_DATA); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 2 3 4 5 6 - QueryResult result = WorldDatabase.Query("SELECT creature.guid, creature.id1, creature.id2, creature.id3, game_event_model_equip.eventEntry, game_event_model_equip.modelid, game_event_model_equip.equipment_id " - "FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid"); - - if (!result) + LOG_WARN("server.loading", ">> Loaded 0 Model/Equipment Changes In Game Events. DB Table `game_event_model_equip` Is Empty."); + LOG_INFO("server.loading", " "); + } + else + { + uint32 count = 0; + do { - LOG_WARN("server.loading", ">> Loaded 0 Model/Equipment Changes In Game Events. DB Table `game_event_model_equip` Is Empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do + Field* fields = result->Fetch(); + + ObjectGuid::LowType guid = fields[0].Get(); + uint32 entry = fields[1].Get(); + uint32 entry2 = fields[2].Get(); + uint32 entry3 = fields[3].Get(); + uint16 eventId = fields[4].Get(); + + if (eventId >= _gameEventModelEquip.size()) { - Field* fields = result->Fetch(); + LOG_ERROR("sql.sql", "`game_event_model_equip` game event id ({}) is out of range compared to max event id in `game_event`", eventId); + continue; + } - ObjectGuid::LowType guid = fields[0].Get(); - uint32 entry = fields[1].Get(); - uint32 entry2 = fields[2].Get(); - uint32 entry3 = fields[3].Get(); - uint16 event_id = fields[4].Get(); + ModelEquipList& equiplist = _gameEventModelEquip[eventId]; + ModelEquip newModelEquipSet; + newModelEquipSet.ModelId = fields[5].Get(); + newModelEquipSet.EquipmentId = fields[6].Get(); + newModelEquipSet.EquipementIdPrev = 0; + newModelEquipSet.ModelIdPrev = 0; - if (event_id >= mGameEventModelEquip.size()) + if (newModelEquipSet.EquipmentId > 0) + { + int8 equipId = static_cast(newModelEquipSet.EquipmentId); + if ((!sObjectMgr->GetEquipmentInfo(entry, equipId)) || (entry2 && !sObjectMgr->GetEquipmentInfo(entry2, equipId)) || (entry3 && !sObjectMgr->GetEquipmentInfo(entry3, equipId))) { - LOG_ERROR("sql.sql", "`game_event_model_equip` game event id ({}) is out of range compared to max event id in `game_event`", event_id); + LOG_ERROR("sql.sql", "Table `game_event_model_equip` have creature (Guid: {}) with equipment_id {} not found in table `creature_equip_template`, set to no equipment.", + guid, newModelEquipSet.EquipmentId); continue; } + } - ModelEquipList& equiplist = mGameEventModelEquip[event_id]; - ModelEquip newModelEquipSet; - newModelEquipSet.modelid = fields[5].Get(); - newModelEquipSet.equipment_id = fields[6].Get(); - newModelEquipSet.equipement_id_prev = 0; - newModelEquipSet.modelid_prev = 0; + equiplist.push_back(std::pair(guid, newModelEquipSet)); - if (newModelEquipSet.equipment_id > 0) - { - int8 equipId = static_cast(newModelEquipSet.equipment_id); - if ((!sObjectMgr->GetEquipmentInfo(entry, equipId)) || (entry2 && !sObjectMgr->GetEquipmentInfo(entry2, equipId)) || (entry3 && !sObjectMgr->GetEquipmentInfo(entry3, equipId))) - { - LOG_ERROR("sql.sql", "Table `game_event_model_equip` have creature (Guid: {}) with equipment_id {} not found in table `creature_equip_template`, set to no equipment.", - guid, newModelEquipSet.equipment_id); - continue; - } - } + ++count; + } while (result->NextRow()); - equiplist.push_back(std::pair(guid, newModelEquipSet)); - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Model/Equipment Changes In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_INFO("server.loading", ">> Loaded {} Model/Equipment Changes In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); } +} +void GameEventMgr::LoadEventQuestData() +{ LOG_INFO("server.loading", "Loading Game Event Quest Data..."); + + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_QUEST_DATA); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 2 - QueryResult result = WorldDatabase.Query("SELECT id, quest, eventEntry FROM game_event_creature_quest"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 Quests Additions In Game Events. DB Table `game_event_creature_quest` Is Empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - uint32 id = fields[0].Get(); - uint32 quest = fields[1].Get(); - uint16 event_id = fields[2].Get(); - - if (event_id >= mGameEventCreatureQuests.size()) - { - LOG_ERROR("sql.sql", "`game_event_creature_quest` game event id ({}) is out of range compared to max event id in `game_event`", event_id); - continue; - } - - QuestRelList& questlist = mGameEventCreatureQuests[event_id]; - questlist.push_back(QuestRelation(id, quest)); - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Quests Additions In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_WARN("server.loading", ">> Loaded 0 Quests Additions In Game Events. DB Table `game_event_creature_quest` Is Empty."); + LOG_INFO("server.loading", " "); } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + uint32 quest = fields[1].Get(); + uint16 eventId = fields[2].Get(); + + if (eventId >= _gameEventCreatureQuests.size()) + { + LOG_ERROR("sql.sql", "`game_event_creature_quest` game event id ({}) is out of range compared to max event id in `game_event`", eventId); + continue; + } + + QuestRelList& questlist = _gameEventCreatureQuests[eventId]; + questlist.push_back(QuestRelation(id, quest)); + + ++count; + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Quests Additions In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadEventGameObjectQuestData() +{ LOG_INFO("server.loading", "Loading Game Event GO Quest Data..."); + + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_GAMEOBJECT_QUEST_DATA); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 2 - QueryResult result = WorldDatabase.Query("SELECT id, quest, eventEntry FROM game_event_gameobject_quest"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 go Quests Additions In Game Events. DB Table `game_event_gameobject_quest` Is Empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - uint32 id = fields[0].Get(); - uint32 quest = fields[1].Get(); - uint16 event_id = fields[2].Get(); - - if (event_id >= mGameEventGameObjectQuests.size()) - { - LOG_ERROR("sql.sql", "`game_event_gameobject_quest` game event id ({}) is out of range compared to max event id in `game_event`", event_id); - continue; - } - - QuestRelList& questlist = mGameEventGameObjectQuests[event_id]; - questlist.push_back(QuestRelation(id, quest)); - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Quests Additions In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_WARN("server.loading", ">> Loaded 0 go Quests Additions In Game Events. DB Table `game_event_gameobject_quest` Is Empty."); + LOG_INFO("server.loading", " "); } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + uint32 quest = fields[1].Get(); + uint16 eventId = fields[2].Get(); + + if (eventId >= _gameEventGameObjectQuests.size()) + { + LOG_ERROR("sql.sql", "`game_event_gameobject_quest` game event id ({}) is out of range compared to max event id in `game_event`", eventId); + continue; + } + + QuestRelList& questlist = _gameEventGameObjectQuests[eventId]; + questlist.push_back(QuestRelation(id, quest)); + + ++count; + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Quests Additions In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadEventQuestConditionData() +{ LOG_INFO("server.loading", "Loading Game Event Quest Condition Data..."); + + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_QUEST_CONDITION_DATA); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 2 3 - QueryResult result = WorldDatabase.Query("SELECT quest, eventEntry, condition_id, num FROM game_event_quest_condition"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 quest event Conditions In Game Events. DB Table `game_event_quest_condition` Is Empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - uint32 quest = fields[0].Get(); - uint16 event_id = fields[1].Get(); - uint32 condition = fields[2].Get(); - float num = fields[3].Get(); - - if (event_id >= mGameEvent.size()) - { - LOG_ERROR("sql.sql", "`game_event_quest_condition` game event id ({}) is out of range compared to max event id in `game_event`", event_id); - continue; - } - - mQuestToEventConditions[quest].event_id = event_id; - mQuestToEventConditions[quest].condition = condition; - mQuestToEventConditions[quest].num = num; - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} quest event conditions in Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_WARN("server.loading", ">> Loaded 0 quest event Conditions In Game Events. DB Table `game_event_quest_condition` Is Empty."); + LOG_INFO("server.loading", " "); } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + uint32 quest = fields[0].Get(); + uint16 eventId = fields[1].Get(); + uint32 condition = fields[2].Get(); + float num = fields[3].Get(); + + if (eventId >= _gameEvent.size()) + { + LOG_ERROR("sql.sql", "`game_event_quest_condition` game event id ({}) is out of range compared to max event id in `game_event`", eventId); + continue; + } + + _questToEventConditions[quest].EventId = eventId; + _questToEventConditions[quest].Condition = condition; + _questToEventConditions[quest].Num = num; + + ++count; + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} quest event conditions in Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadEventConditionData() +{ LOG_INFO("server.loading", "Loading Game Event Condition Data..."); + + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_CONDITION_DATA); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 2 3 4 - QueryResult result = WorldDatabase.Query("SELECT eventEntry, condition_id, req_num, max_world_state_field, done_world_state_field FROM game_event_condition"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 Conditions In Game Events. DB table `game_event_condition` Is Empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - uint16 event_id = fields[0].Get(); - uint32 condition = fields[1].Get(); - - if (event_id >= mGameEvent.size()) - { - LOG_ERROR("sql.sql", "`game_event_condition` game event id ({}) is out of range compared to max event id in `game_event`", event_id); - continue; - } - - mGameEvent[event_id].conditions[condition].reqNum = fields[2].Get(); - mGameEvent[event_id].conditions[condition].done = 0; - mGameEvent[event_id].conditions[condition].max_world_state = fields[3].Get(); - mGameEvent[event_id].conditions[condition].done_world_state = fields[4].Get(); - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} conditions in Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_WARN("server.loading", ">> Loaded 0 Conditions In Game Events. DB table `game_event_condition` Is Empty."); + LOG_INFO("server.loading", " "); } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + uint16 eventId = fields[0].Get(); + uint32 condition = fields[1].Get(); + + if (eventId >= _gameEvent.size()) + { + LOG_ERROR("sql.sql", "`game_event_condition` game event id ({}) is out of range compared to max event id in `game_event`", eventId); + continue; + } + + _gameEvent[eventId].Conditions[condition].ReqNum = fields[2].Get(); + _gameEvent[eventId].Conditions[condition].Done = 0; + _gameEvent[eventId].Conditions[condition].MaxWorldState = fields[3].Get(); + _gameEvent[eventId].Conditions[condition].DoneWorldState = fields[4].Get(); + + ++count; + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} conditions in Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadEventConditionSaveData() +{ LOG_INFO("server.loading", "Loading Game Event Condition Save Data..."); + + uint32 oldMSTime = getMSTime(); + + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GAME_EVENT_CONDITION_SAVE_DATA); + PreparedQueryResult result = CharacterDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 2 - QueryResult result = CharacterDatabase.Query("SELECT eventEntry, condition_id, done FROM game_event_condition_save"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 Condition Saves In Game Events. DB Table `game_event_condition_save` Is Empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - uint16 event_id = fields[0].Get(); - uint32 condition = fields[1].Get(); - - if (event_id >= mGameEvent.size()) - { - LOG_ERROR("sql.sql", "`game_event_condition_save` game event id ({}) is out of range compared to max event id in `game_event`", event_id); - continue; - } - - GameEventConditionMap::iterator itr = mGameEvent[event_id].conditions.find(condition); - if (itr != mGameEvent[event_id].conditions.end()) - { - itr->second.done = fields[2].Get(); - } - else - { - LOG_ERROR("sql.sql", "game_event_condition_save contains not present condition evt id {} cond id {}", event_id, condition); - continue; - } - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Condition Saves In Game Events In {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_WARN("server.loading", ">> Loaded 0 Condition Saves In Game Events. DB Table `game_event_condition_save` Is Empty."); + LOG_INFO("server.loading", " "); } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + uint16 eventId = fields[0].Get(); + uint32 condition = fields[1].Get(); + + if (eventId >= _gameEvent.size()) + { + LOG_ERROR("sql.sql", "`game_event_condition_save` game event id ({}) is out of range compared to max event id in `game_event`", eventId); + continue; + } + + GameEventConditionMap::iterator itr = _gameEvent[eventId].Conditions.find(condition); + if (itr != _gameEvent[eventId].Conditions.end()) + { + itr->second.Done = fields[2].Get(); + } + else + { + LOG_ERROR("sql.sql", "game_event_condition_save contains not present condition evt id {} cond id {}", eventId, condition); + continue; + } + + ++count; + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Condition Saves In Game Events In {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadEventNPCFlags() +{ LOG_INFO("server.loading", "Loading Game Event NPCflag Data..."); + + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement * stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_NPC_FLAGS); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 2 - QueryResult result = WorldDatabase.Query("SELECT guid, eventEntry, npcflag FROM game_event_npcflag"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 Npcflags In Game Events. DB Table `game_event_npcflag` Is Empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - ObjectGuid::LowType guid = fields[0].Get(); - uint16 event_id = fields[1].Get(); - uint32 npcflag = fields[2].Get(); - - if (event_id >= mGameEvent.size()) - { - LOG_ERROR("sql.sql", "`game_event_npcflag` game event id ({}) is out of range compared to max event id in `game_event`", event_id); - continue; - } - - mGameEventNPCFlags[event_id].push_back(GuidNPCFlagPair(guid, npcflag)); - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Npcflags In Game Events In {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_WARN("server.loading", ">> Loaded 0 Npcflags In Game Events. DB Table `game_event_npcflag` Is Empty."); + LOG_INFO("server.loading", " "); } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + ObjectGuid::LowType guid = fields[0].Get(); + uint16 eventId = fields[1].Get(); + uint32 npcflag = fields[2].Get(); + + if (eventId >= _gameEvent.size()) + { + LOG_ERROR("sql.sql", "`game_event_npcflag` game event id ({}) is out of range compared to max event id in `game_event`", eventId); + continue; + } + + _gameEventNPCFlags[eventId].push_back(GuidNPCFlagPair(guid, npcflag)); + + ++count; + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Npcflags In Game Events In {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadEventSeasonalQuestRelations() +{ LOG_INFO("server.loading", "Loading Game Event Seasonal Quest Relations..."); + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_QUEST_SEASONAL_RELATIONS); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 - QueryResult result = WorldDatabase.Query("SELECT questId, eventEntry FROM game_event_seasonal_questrelation"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 Seasonal Quests Additions In Game Events. DB Table `game_event_seasonal_questrelation` Is Empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - uint32 questId = fields[0].Get(); - uint32 eventEntry = fields[1].Get(); /// @todo: Change to uint8 - - Quest* questTemplate = const_cast(sObjectMgr->GetQuestTemplate(questId)); - - if (!questTemplate) - { - LOG_ERROR("sql.sql", "`game_event_seasonal_questrelation` quest id ({}) does not exist in `quest_template`", questId); - continue; - } - - if (eventEntry >= mGameEvent.size()) - { - LOG_ERROR("sql.sql", "`game_event_seasonal_questrelation` event id ({}) is out of range compared to max event in `game_event`", eventEntry); - continue; - } - - questTemplate->SetEventIdForQuest((uint16)eventEntry); - _gameEventSeasonalQuestsMap[eventEntry].push_back(questId); - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Quests Additions In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_WARN("server.loading", ">> Loaded 0 Seasonal Quests Additions In Game Events. DB Table `game_event_seasonal_questrelation` Is Empty."); + LOG_INFO("server.loading", " "); } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); - LOG_INFO("server.loading", "Loading Game Event Vendor Additions Data..."); - LoadEventVendors(); + uint32 questId = fields[0].Get(); + uint32 eventEntry = fields[1].Get(); /// @todo: Change to uint8 + Quest* questTemplate = const_cast(sObjectMgr->GetQuestTemplate(questId)); + + if (!questTemplate) + { + LOG_ERROR("sql.sql", "`game_event_seasonal_questrelation` quest id ({}) does not exist in `quest_template`", questId); + continue; + } + + if (eventEntry >= _gameEvent.size()) + { + LOG_ERROR("sql.sql", "`game_event_seasonal_questrelation` event id ({}) is out of range compared to max event in `game_event`", eventEntry); + continue; + } + + questTemplate->SetEventIdForQuest((uint16)eventEntry); + _gameEventSeasonalQuestsMap[eventEntry].push_back(questId); + ++count; + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Quests Additions In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadEventBattlegroundData() +{ LOG_INFO("server.loading", "Loading Game Event Battleground Data..."); + + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_BATTLEGROUND_DATA); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 - QueryResult result = WorldDatabase.Query("SELECT eventEntry, bgflag FROM game_event_battleground_holiday"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 Battleground Holidays In Game Events. DB table `game_event_battleground_holiday` is empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - uint16 event_id = fields[0].Get(); - - if (event_id >= mGameEvent.size()) - { - LOG_ERROR("sql.sql", "`game_event_battleground_holiday` game event id ({}) is out of range compared to max event id in `game_event`", event_id); - continue; - } - - mGameEventBattlegroundHolidays[event_id] = fields[1].Get(); - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Battleground Holidays In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_WARN("server.loading", ">> Loaded 0 Battleground Holidays In Game Events. DB table `game_event_battleground_holiday` is empty."); + LOG_INFO("server.loading", " "); } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + uint16 eventId = fields[0].Get(); + + if (eventId >= _gameEvent.size()) + { + LOG_ERROR("sql.sql", "`game_event_battleground_holiday` game event id ({}) is out of range compared to max event id in `game_event`", eventId); + continue; + } + + _gameEventBattlegroundHolidays[eventId] = fields[1].Get(); + + ++count; + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Battleground Holidays In Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadEventPoolData() +{ LOG_INFO("server.loading", "Loading Game Event Pool Data..."); + + uint32 oldMSTime = getMSTime(); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_POOL_DATA); + PreparedQueryResult result = WorldDatabase.Query(stmt); + + if (!result) { - uint32 oldMSTime = getMSTime(); - - // 0 1 - QueryResult result = WorldDatabase.Query("SELECT pool_template.entry, game_event_pool.eventEntry FROM pool_template" - " JOIN game_event_pool ON pool_template.entry = game_event_pool.pool_entry"); - - if (!result) - { - LOG_WARN("server.loading", ">> Loaded 0 Pools For Game Events. DB Table `game_event_pool` Is Empty."); - LOG_INFO("server.loading", " "); - } - else - { - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - - uint32 entry = fields[0].Get(); - int16 event_id = fields[1].Get(); - - int32 internal_event_id = mGameEvent.size() + event_id - 1; - - if (internal_event_id < 0 || internal_event_id >= int32(mGameEventPoolIds.size())) - { - LOG_ERROR("sql.sql", "`game_event_pool` game event id ({}) is out of range compared to max event id in `game_event`", event_id); - continue; - } - - if (!sPoolMgr->CheckPool(entry)) - { - LOG_ERROR("sql.sql", "Pool Id ({}) has all creatures or gameobjects with explicit chance sum <>100 and no equal chance defined. The pool system cannot pick one to spawn.", entry); - continue; - } - - IdList& poollist = mGameEventPoolIds[internal_event_id]; - poollist.push_back(entry); - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Pools For Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_WARN("server.loading", ">> Loaded 0 Pools For Game Events. DB Table `game_event_pool` Is Empty."); + LOG_INFO("server.loading", " "); } + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + uint32 entry = fields[0].Get(); + int16 eventId = fields[1].Get(); + + int32 internal_event_id = _gameEvent.size() + eventId - 1; + + if (internal_event_id < 0 || internal_event_id >= int32(_gameEventPoolIds.size())) + { + LOG_ERROR("sql.sql", "`game_event_pool` game event id ({}) is out of range compared to max event id in `game_event`", eventId); + continue; + } + + if (!sPoolMgr->CheckPool(entry)) + { + LOG_ERROR("sql.sql", "Pool Id ({}) has all creatures or gameobjects with explicit chance sum <>100 and no equal chance defined. The pool system cannot pick one to spawn.", entry); + continue; + } + + IdList& poollist = _gameEventPoolIds[internal_event_id]; + poollist.push_back(entry); + + ++count; + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Pools For Game Events in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } +} + +void GameEventMgr::LoadFromDB() +{ + // The order of these functions matter. Do not change + LoadEvents(); + LoadEventSaveData(); + LoadEventPrerequisiteData(); + LoadEventCreatureData(); + LoadEventGameObjectData(); + LoadEventModelEquipmentChangeData(); + LoadEventQuestData(); + LoadEventGameObjectQuestData(); + LoadEventQuestConditionData(); + LoadEventConditionData(); + LoadEventConditionSaveData(); + LoadEventNPCFlags(); + LoadEventSeasonalQuestRelations(); + LoadEventVendors(); + LoadEventBattlegroundData(); + LoadEventPoolData(); } void GameEventMgr::LoadHolidayDates() { uint32 oldMSTime = getMSTime(); - // 0 1 2 3 - QueryResult result = WorldDatabase.Query("SELECT id, date_id, date_value, holiday_duration FROM holiday_dates"); + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_HOLIDAY_DATES); + PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) { @@ -1063,10 +1103,10 @@ void GameEventMgr::LoadHolidayDates() if (uint32 duration = fields[3].Get()) entry->Duration[0] = duration; - auto itr = std::lower_bound(modifiedHolidays.begin(), modifiedHolidays.end(), entry->Id); - if (itr == modifiedHolidays.end() || *itr != entry->Id) + auto itr = std::lower_bound(ModifiedHolidays.begin(), ModifiedHolidays.end(), entry->Id); + if (itr == ModifiedHolidays.end() || *itr != entry->Id) { - modifiedHolidays.insert(itr, entry->Id); + ModifiedHolidays.insert(itr, entry->Id); } ++count; @@ -1080,9 +1120,9 @@ uint32 GameEventMgr::GetNPCFlag(Creature* cr) uint32 mask = 0; ObjectGuid::LowType spawnId = cr->GetSpawnId(); - for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) + for (ActiveEvents::iterator e_itr = _activeEvents.begin(); e_itr != _activeEvents.end(); ++e_itr) { - for (NPCFlagList::iterator itr = mGameEventNPCFlags[*e_itr].begin(); itr != mGameEventNPCFlags[*e_itr].end(); ++ itr) + for (NPCFlagList::iterator itr = _gameEventNPCFlags[*e_itr].begin(); itr != _gameEventNPCFlags[*e_itr].end(); ++ itr) if (itr->first == spawnId) mask |= itr->second; } @@ -1102,31 +1142,34 @@ void GameEventMgr::Initialize() // Id starts with 1 and vector with 0, thus increment maxEventId++; - mGameEvent.resize(maxEventId); - mGameEventCreatureGuids.resize(maxEventId * 2 - 1); - mGameEventGameobjectGuids.resize(maxEventId * 2 - 1); - mGameEventCreatureQuests.resize(maxEventId); - mGameEventGameObjectQuests.resize(maxEventId); - mGameEventVendors.resize(maxEventId); - mGameEventBattlegroundHolidays.resize(maxEventId, 0); - mGameEventPoolIds.resize(maxEventId * 2 - 1); - mGameEventNPCFlags.resize(maxEventId); - mGameEventModelEquip.resize(maxEventId); + _gameEvent.resize(maxEventId); + GameEventCreatureGuids.resize(maxEventId * 2 - 1); + GameEventGameobjectGuids.resize(maxEventId * 2 - 1); + _gameEventCreatureQuests.resize(maxEventId); + _gameEventGameObjectQuests.resize(maxEventId); + _gameEventVendors.resize(maxEventId); + _gameEventBattlegroundHolidays.resize(maxEventId, 0); + _gameEventPoolIds.resize(maxEventId * 2 - 1); + _gameEventNPCFlags.resize(maxEventId); + _gameEventModelEquip.resize(maxEventId); } } uint32 GameEventMgr::StartSystem() // return the next event delay in ms { - m_ActiveEvents.clear(); + _activeEvents.clear(); uint32 delay = Update(); - isSystemInit = true; + _isSystemInit = true; return delay; } void GameEventMgr::StartArenaSeason() { uint8 season = sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID); - QueryResult result = WorldDatabase.Query("SELECT eventEntry FROM game_event_arena_seasons WHERE season = '{}'", season); + + WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAME_EVENT_ARENA_SEASON); + stmt->SetData(0, season); + PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) { @@ -1137,7 +1180,7 @@ void GameEventMgr::StartArenaSeason() Field* fields = result->Fetch(); uint16 eventId = fields[0].Get(); - if (eventId >= mGameEvent.size()) + if (eventId >= _gameEvent.size()) { LOG_ERROR("gameevent", "EventEntry {} for ArenaSeason ({}) does not exists", eventId, season); return; @@ -1154,7 +1197,7 @@ uint32 GameEventMgr::Update() // return the next e uint32 nextEventDelay = max_ge_check_delay; // 1 day uint32 calcDelay; std::set activate, deactivate; - for (uint16 itr = 1; itr < mGameEvent.size(); ++itr) + for (uint16 itr = 1; itr < _gameEvent.size(); ++itr) { // must do the activating first, and after that the deactivating // so first queue it @@ -1165,11 +1208,11 @@ uint32 GameEventMgr::Update() // return the next e if (CheckOneGameEvent(itr)) { // if the world event is in NEXTPHASE state, and the time has passed to finish this event, then do so - if (mGameEvent[itr].state == GAMEEVENT_WORLD_NEXTPHASE && mGameEvent[itr].nextstart <= currenttime) + if (_gameEvent[itr].State == GAMEEVENT_WORLD_NEXTPHASE && _gameEvent[itr].NextStart <= currenttime) { // set this event to finished, null the nextstart time - mGameEvent[itr].state = GAMEEVENT_WORLD_FINISHED; - mGameEvent[itr].nextstart = 0; + _gameEvent[itr].State = GAMEEVENT_WORLD_FINISHED; + _gameEvent[itr].NextStart = 0; // save the state of this gameevent SaveWorldEventStateToDB(itr); // queue for deactivation @@ -1178,7 +1221,7 @@ uint32 GameEventMgr::Update() // return the next e // go to next event, this no longer needs an event update timer continue; } - else if (mGameEvent[itr].state == GAMEEVENT_WORLD_CONDITIONS && CheckOneGameEventConditions(itr)) + else if (_gameEvent[itr].State == GAMEEVENT_WORLD_CONDITIONS && CheckOneGameEventConditions(itr)) // changed, save to DB the gameevent state, will be updated in next update cycle SaveWorldEventStateToDB(itr); @@ -1194,12 +1237,12 @@ uint32 GameEventMgr::Update() // return the next e if (IsActiveEvent(itr)) { // Xinef: do not deactivate internal events on whim - if (mGameEvent[itr].state != GAMEEVENT_INTERNAL) + if (_gameEvent[itr].State != GAMEEVENT_INTERNAL) deactivate.insert(itr); } else { - if (!isSystemInit) + if (!_isSystemInit) { int16 event_nid = (-1) * (itr); // spawn all negative ones for this event @@ -1227,71 +1270,71 @@ uint32 GameEventMgr::Update() // return the next e return (nextEventDelay + 1) * IN_MILLISECONDS; // Add 1 second to be sure event has started/stopped at next call } -void GameEventMgr::UnApplyEvent(uint16 event_id) +void GameEventMgr::UnApplyEvent(uint16 eventId) { - LOG_DEBUG("gameevent", "GameEvent {} \"{}\" removed.", event_id, mGameEvent[event_id].description); + LOG_DEBUG("gameevent", "GameEvent {} \"{}\" removed.", eventId, _gameEvent[eventId].Description); //! Run SAI scripts with SMART_EVENT_GAME_EVENT_END - RunSmartAIScripts(event_id, false); + RunSmartAIScripts(eventId, false); // un-spawn positive event tagged objects - GameEventUnspawn(event_id); + GameEventUnspawn(eventId); // spawn negative event tagget objects - int16 event_nid = (-1) * event_id; - GameEventSpawn(event_nid); + int16 numEventId = (-1) * eventId; + GameEventSpawn(numEventId); // restore equipment or model - ChangeEquipOrModel(event_id, false); + ChangeEquipOrModel(eventId, false); // Remove quests that are events only to non event npc - UpdateEventQuests(event_id, false); - UpdateWorldStates(event_id, false); + UpdateEventQuests(eventId, false); + UpdateWorldStates(eventId, false); // update npcflags in this event - UpdateEventNPCFlags(event_id); + UpdateEventNPCFlags(eventId); // remove vendor items - UpdateEventNPCVendor(event_id, false); + UpdateEventNPCVendor(eventId, false); // update bg holiday UpdateBattlegroundSettings(); } -void GameEventMgr::ApplyNewEvent(uint16 event_id) +void GameEventMgr::ApplyNewEvent(uint16 eventId) { - uint8 announce = mGameEvent[event_id].announce; + uint8 announce = _gameEvent[eventId].Announce; if (announce == 1 || (announce == 2 && sWorld->getIntConfig(CONFIG_EVENT_ANNOUNCE))) - ChatHandler(nullptr).SendWorldText(LANG_EVENTMESSAGE, mGameEvent[event_id].description); + ChatHandler(nullptr).SendWorldText(LANG_EVENTMESSAGE, _gameEvent[eventId].Description); - LOG_DEBUG("gameevent", "GameEvent {} \"{}\" started.", event_id, mGameEvent[event_id].description); + LOG_DEBUG("gameevent", "GameEvent {} \"{}\" started.", eventId, _gameEvent[eventId].Description); // spawn positive event tagget objects - GameEventSpawn(event_id); + GameEventSpawn(eventId); // un-spawn negative event tagged objects - int16 event_nid = (-1) * event_id; - GameEventUnspawn(event_nid); + int16 numEventId = (-1) * eventId; + GameEventUnspawn(numEventId); // Change equipement or model - ChangeEquipOrModel(event_id, true); + ChangeEquipOrModel(eventId, true); // Add quests that are events only to non event npc - UpdateEventQuests(event_id, true); - UpdateWorldStates(event_id, true); + UpdateEventQuests(eventId, true); + UpdateWorldStates(eventId, true); // update npcflags in this event - UpdateEventNPCFlags(event_id); + UpdateEventNPCFlags(eventId); // add vendor items - UpdateEventNPCVendor(event_id, true); + UpdateEventNPCVendor(eventId, true); // update bg holiday UpdateBattlegroundSettings(); //! Run SAI scripts with SMART_EVENT_GAME_EVENT_START - RunSmartAIScripts(event_id, true); + RunSmartAIScripts(eventId, true); // If event's worldstate is 0, it means the event hasn't been started yet. In that case, reset seasonal quests. // When event ends (if it expires or if it's stopped via commands) worldstate will be set to 0 again, ready for another seasonal quest reset. - if (sWorld->getWorldState(event_id) == 0) + if (sWorld->getWorldState(eventId) == 0) { - sWorld->ResetEventSeasonalQuests(event_id); + sWorld->ResetEventSeasonalQuests(eventId); } } -void GameEventMgr::UpdateEventNPCFlags(uint16 event_id) +void GameEventMgr::UpdateEventNPCFlags(uint16 eventId) { std::unordered_map> creaturesByMap; // go through the creatures whose npcflags are changed in the event - for (NPCFlagList::iterator itr = mGameEventNPCFlags[event_id].begin(); itr != mGameEventNPCFlags[event_id].end(); ++itr) + for (NPCFlagList::iterator itr = _gameEventNPCFlags[eventId].begin(); itr != _gameEventNPCFlags[eventId].end(); ++itr) { // get the creature data from the low guid to get the entry, to be able to find out the whole guid if (CreatureData const* data = sObjectMgr->GetCreatureData(itr->first)) @@ -1324,34 +1367,34 @@ void GameEventMgr::UpdateEventNPCFlags(uint16 event_id) void GameEventMgr::UpdateBattlegroundSettings() { uint32 mask = 0; - for (ActiveEvents::const_iterator itr = m_ActiveEvents.begin(); itr != m_ActiveEvents.end(); ++itr) - mask |= mGameEventBattlegroundHolidays[*itr]; + for (ActiveEvents::const_iterator itr = _activeEvents.begin(); itr != _activeEvents.end(); ++itr) + mask |= _gameEventBattlegroundHolidays[*itr]; sBattlegroundMgr->SetHolidayWeekends(mask); } -void GameEventMgr::UpdateEventNPCVendor(uint16 event_id, bool activate) +void GameEventMgr::UpdateEventNPCVendor(uint16 eventId, bool activate) { - for (NPCVendorList::iterator itr = mGameEventVendors[event_id].begin(); itr != mGameEventVendors[event_id].end(); ++itr) + for (NPCVendorList::iterator itr = _gameEventVendors[eventId].begin(); itr != _gameEventVendors[eventId].end(); ++itr) { if (activate) - sObjectMgr->AddVendorItem(itr->entry, itr->item, itr->maxcount, itr->incrtime, itr->ExtendedCost, false); + sObjectMgr->AddVendorItem(itr->Entry, itr->Item, itr->MaxCount, itr->Incrtime, itr->ExtendedCost, false); else - sObjectMgr->RemoveVendorItem(itr->entry, itr->item, false); + sObjectMgr->RemoveVendorItem(itr->Entry, itr->Item, false); } } -void GameEventMgr::GameEventSpawn(int16 event_id) +void GameEventMgr::GameEventSpawn(int16 eventId) { - int32 internal_event_id = mGameEvent.size() + event_id - 1; + int32 internal_event_id = _gameEvent.size() + eventId - 1; - if (internal_event_id < 0 || internal_event_id >= int32(mGameEventCreatureGuids.size())) + if (internal_event_id < 0 || internal_event_id >= int32(GameEventCreatureGuids.size())) { LOG_ERROR("gameevent", "GameEventMgr::GameEventSpawn attempt access to out of range mGameEventCreatureGuids element {} (size: {})", - internal_event_id, mGameEventCreatureGuids.size()); + internal_event_id, GameEventCreatureGuids.size()); return; } - for (GuidLowList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr) + for (GuidLowList::iterator itr = GameEventCreatureGuids[internal_event_id].begin(); itr != GameEventCreatureGuids[internal_event_id].end(); ++itr) { // Add to correct cell if (CreatureData const* data = sObjectMgr->GetCreatureData(*itr)) @@ -1370,14 +1413,14 @@ void GameEventMgr::GameEventSpawn(int16 event_id) } } - if (internal_event_id >= int32(mGameEventGameobjectGuids.size())) + if (internal_event_id >= int32(GameEventGameobjectGuids.size())) { LOG_ERROR("gameevent", "GameEventMgr::GameEventSpawn attempt access to out of range mGameEventGameobjectGuids element {} (size: {})", - internal_event_id, mGameEventGameobjectGuids.size()); + internal_event_id, GameEventGameobjectGuids.size()); return; } - for (GuidLowList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr) + for (GuidLowList::iterator itr = GameEventGameobjectGuids[internal_event_id].begin(); itr != GameEventGameobjectGuids[internal_event_id].end(); ++itr) { // Add to correct cell if (GameObjectData const* data = sObjectMgr->GetGameObjectData(*itr)) @@ -1402,32 +1445,32 @@ void GameEventMgr::GameEventSpawn(int16 event_id) } } - if (internal_event_id >= int32(mGameEventPoolIds.size())) + if (internal_event_id >= int32(_gameEventPoolIds.size())) { - LOG_ERROR("gameevent", "GameEventMgr::GameEventSpawn attempt access to out of range mGameEventPoolIds element {} (size: {})", - internal_event_id, mGameEventPoolIds.size()); + LOG_ERROR("gameevent", "GameEventMgr::GameEventSpawn attempt access to out of range _gameEventPoolIds element {} (size: {})", + internal_event_id, _gameEventPoolIds.size()); return; } - for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin(); itr != mGameEventPoolIds[internal_event_id].end(); ++itr) + for (IdList::iterator itr = _gameEventPoolIds[internal_event_id].begin(); itr != _gameEventPoolIds[internal_event_id].end(); ++itr) sPoolMgr->SpawnPool(*itr); } -void GameEventMgr::GameEventUnspawn(int16 event_id) +void GameEventMgr::GameEventUnspawn(int16 eventId) { - int32 internal_event_id = mGameEvent.size() + event_id - 1; + int32 internal_event_id = _gameEvent.size() + eventId - 1; - if (internal_event_id < 0 || internal_event_id >= int32(mGameEventCreatureGuids.size())) + if (internal_event_id < 0 || internal_event_id >= int32(GameEventCreatureGuids.size())) { - LOG_ERROR("gameevent", "GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventCreatureGuids element {} (size: {})", - internal_event_id, mGameEventCreatureGuids.size()); + LOG_ERROR("gameevent", "GameEventMgr::GameEventUnspawn attempt access to out of range GameEventCreatureGuids element {} (size: {})", + internal_event_id, GameEventCreatureGuids.size()); return; } - for (GuidLowList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr) + for (GuidLowList::iterator itr = GameEventCreatureGuids[internal_event_id].begin(); itr != GameEventCreatureGuids[internal_event_id].end(); ++itr) { // check if it's needed by another event, if so, don't remove - if (event_id > 0 && hasCreatureActiveEventExcept(*itr, event_id)) + if (eventId > 0 && HasCreatureActiveEventExcept(*itr, eventId)) continue; // Remove the creature from grid @@ -1448,17 +1491,17 @@ void GameEventMgr::GameEventUnspawn(int16 event_id) } } - if (internal_event_id >= int32(mGameEventGameobjectGuids.size())) + if (internal_event_id >= int32(GameEventGameobjectGuids.size())) { - LOG_ERROR("gameevent", "GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventGameobjectGuids element {} (size: {})", - internal_event_id, mGameEventGameobjectGuids.size()); + LOG_ERROR("gameevent", "GameEventMgr::GameEventUnspawn attempt access to out of range GameEventGameobjectGuids element {} (size: {})", + internal_event_id, GameEventGameobjectGuids.size()); return; } - for (GuidLowList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr) + for (GuidLowList::iterator itr = GameEventGameobjectGuids[internal_event_id].begin(); itr != GameEventGameobjectGuids[internal_event_id].end(); ++itr) { // check if it's needed by another event, if so, don't remove - if (event_id > 0 && hasGameObjectActiveEventExcept(*itr, event_id)) + if (eventId > 0 && HasGameObjectActiveEventExcept(*itr, eventId)) continue; // Remove the gameobject from grid if (GameObjectData const* data = sObjectMgr->GetGameObjectData(*itr)) @@ -1477,21 +1520,21 @@ void GameEventMgr::GameEventUnspawn(int16 event_id) }); } } - if (internal_event_id >= int32(mGameEventPoolIds.size())) + if (internal_event_id >= int32(_gameEventPoolIds.size())) { - LOG_ERROR("gameevent", "GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventPoolIds element {} (size: {})", internal_event_id, mGameEventPoolIds.size()); + LOG_ERROR("gameevent", "GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventPoolIds element {} (size: {})", internal_event_id, _gameEventPoolIds.size()); return; } - for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin(); itr != mGameEventPoolIds[internal_event_id].end(); ++itr) + for (IdList::iterator itr = _gameEventPoolIds[internal_event_id].begin(); itr != _gameEventPoolIds[internal_event_id].end(); ++itr) { sPoolMgr->DespawnPool(*itr); } } -void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate) +void GameEventMgr::ChangeEquipOrModel(int16 eventId, bool activate) { - for (ModelEquipList::iterator itr = mGameEventModelEquip[event_id].begin(); itr != mGameEventModelEquip[event_id].end(); ++itr) + for (ModelEquipList::iterator itr = _gameEventModelEquip[eventId].begin(); itr != _gameEventModelEquip[eventId].end(); ++itr) { // Remove the creature from grid CreatureData const* data = sObjectMgr->GetCreatureData(itr->first); @@ -1507,22 +1550,22 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate) Creature* creature = itr2->second; if (activate) { - itr->second.equipement_id_prev = creature->GetCurrentEquipmentId(); - itr->second.modelid_prev = creature->GetDisplayId(); - creature->LoadEquipment(itr->second.equipment_id, true); - if (itr->second.modelid > 0 && itr->second.modelid_prev != itr->second.modelid && sObjectMgr->GetCreatureModelInfo(itr->second.modelid)) + itr->second.EquipementIdPrev = creature->GetCurrentEquipmentId(); + itr->second.ModelIdPrev = creature->GetDisplayId(); + creature->LoadEquipment(itr->second.EquipmentId, true); + if (itr->second.ModelId > 0 && itr->second.ModelIdPrev != itr->second.ModelId && sObjectMgr->GetCreatureModelInfo(itr->second.ModelId)) { - creature->SetDisplayId(itr->second.modelid); - creature->SetNativeDisplayId(itr->second.modelid); + creature->SetDisplayId(itr->second.ModelId); + creature->SetNativeDisplayId(itr->second.ModelId); } } else { - creature->LoadEquipment(itr->second.equipement_id_prev, true); - if (itr->second.modelid_prev > 0 && itr->second.modelid_prev != itr->second.modelid && sObjectMgr->GetCreatureModelInfo(itr->second.modelid_prev)) + creature->LoadEquipment(itr->second.EquipementIdPrev, true); + if (itr->second.ModelIdPrev > 0 && itr->second.ModelIdPrev != itr->second.ModelId && sObjectMgr->GetCreatureModelInfo(itr->second.ModelIdPrev)) { - creature->SetDisplayId(itr->second.modelid_prev); - creature->SetNativeDisplayId(itr->second.modelid_prev); + creature->SetDisplayId(itr->second.ModelIdPrev); + creature->SetNativeDisplayId(itr->second.ModelIdPrev); } } } @@ -1533,26 +1576,26 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate) CreatureData& data2 = sObjectMgr->NewOrExistCreatureData(itr->first); if (activate) { - itr->second.modelid_prev = data2.displayid; - itr->second.equipement_id_prev = data2.equipmentId; - data2.displayid = itr->second.modelid; - data2.equipmentId = itr->second.equipment_id; + itr->second.ModelIdPrev = data2.displayid; + itr->second.EquipementIdPrev = data2.equipmentId; + data2.displayid = itr->second.ModelId; + data2.equipmentId = itr->second.EquipmentId; } else { - data2.displayid = itr->second.modelid_prev; - data2.equipmentId = itr->second.equipement_id_prev; + data2.displayid = itr->second.ModelIdPrev; + data2.equipmentId = itr->second.EquipementIdPrev; } } } -bool GameEventMgr::hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id) +bool GameEventMgr::HasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 eventId) { - for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) + for (ActiveEvents::iterator e_itr = _activeEvents.begin(); e_itr != _activeEvents.end(); ++e_itr) { - if ((*e_itr) != event_id) - for (QuestRelList::iterator itr = mGameEventCreatureQuests[*e_itr].begin(); - itr != mGameEventCreatureQuests[*e_itr].end(); + if ((*e_itr) != eventId) + for (QuestRelList::iterator itr = _gameEventCreatureQuests[*e_itr].begin(); + itr != _gameEventCreatureQuests[*e_itr].end(); ++ itr) if (itr->second == quest_id) return true; @@ -1560,41 +1603,41 @@ bool GameEventMgr::hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 eve return false; } -bool GameEventMgr::hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id) +bool GameEventMgr::HasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 eventId) { - for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) + for (ActiveEvents::iterator e_itr = _activeEvents.begin(); e_itr != _activeEvents.end(); ++e_itr) { - if ((*e_itr) != event_id) - for (QuestRelList::iterator itr = mGameEventGameObjectQuests[*e_itr].begin(); - itr != mGameEventGameObjectQuests[*e_itr].end(); + if ((*e_itr) != eventId) + for (QuestRelList::iterator itr = _gameEventGameObjectQuests[*e_itr].begin(); + itr != _gameEventGameObjectQuests[*e_itr].end(); ++ itr) if (itr->second == quest_id) return true; } return false; } -bool GameEventMgr::hasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 event_id) +bool GameEventMgr::HasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 eventId) { - for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) + for (ActiveEvents::iterator e_itr = _activeEvents.begin(); e_itr != _activeEvents.end(); ++e_itr) { - if ((*e_itr) != event_id) + if ((*e_itr) != eventId) { - int32 internal_event_id = mGameEvent.size() + (*e_itr) - 1; - for (GuidLowList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++ itr) + int32 internal_event_id = _gameEvent.size() + (*e_itr) - 1; + for (GuidLowList::iterator itr = GameEventCreatureGuids[internal_event_id].begin(); itr != GameEventCreatureGuids[internal_event_id].end(); ++ itr) if (*itr == creature_guid) return true; } } return false; } -bool GameEventMgr::hasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 event_id) +bool GameEventMgr::HasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 eventId) { - for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) + for (ActiveEvents::iterator e_itr = _activeEvents.begin(); e_itr != _activeEvents.end(); ++e_itr) { - if ((*e_itr) != event_id) + if ((*e_itr) != eventId) { - int32 internal_event_id = mGameEvent.size() + (*e_itr) - 1; - for (GuidLowList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++ itr) + int32 internal_event_id = _gameEvent.size() + (*e_itr) - 1; + for (GuidLowList::iterator itr = GameEventGameobjectGuids[internal_event_id].begin(); itr != GameEventGameobjectGuids[internal_event_id].end(); ++ itr) if (*itr == go_guid) return true; } @@ -1602,17 +1645,17 @@ bool GameEventMgr::hasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, u return false; } -void GameEventMgr::UpdateEventQuests(uint16 event_id, bool activate) +void GameEventMgr::UpdateEventQuests(uint16 eventId, bool activate) { QuestRelList::iterator itr; - for (itr = mGameEventCreatureQuests[event_id].begin(); itr != mGameEventCreatureQuests[event_id].end(); ++itr) + for (itr = _gameEventCreatureQuests[eventId].begin(); itr != _gameEventCreatureQuests[eventId].end(); ++itr) { QuestRelations* CreatureQuestMap = sObjectMgr->GetCreatureQuestRelationMap(); if (activate) // Add the pair(id, quest) to the multimap CreatureQuestMap->insert(QuestRelations::value_type(itr->first, itr->second)); else { - if (!hasCreatureQuestActiveEventExcept(itr->second, event_id)) + if (!HasCreatureQuestActiveEventExcept(itr->second, eventId)) { // Remove the pair(id, quest) from the multimap QuestRelations::iterator qitr = CreatureQuestMap->find(itr->first); @@ -1630,14 +1673,14 @@ void GameEventMgr::UpdateEventQuests(uint16 event_id, bool activate) } } } - for (itr = mGameEventGameObjectQuests[event_id].begin(); itr != mGameEventGameObjectQuests[event_id].end(); ++itr) + for (itr = _gameEventGameObjectQuests[eventId].begin(); itr != _gameEventGameObjectQuests[eventId].end(); ++itr) { QuestRelations* GameObjectQuestMap = sObjectMgr->GetGOQuestRelationMap(); if (activate) // Add the pair(id, quest) to the multimap GameObjectQuestMap->insert(QuestRelations::value_type(itr->first, itr->second)); else { - if (!hasGameObjectQuestActiveEventExcept(itr->second, event_id)) + if (!HasGameObjectQuestActiveEventExcept(itr->second, eventId)) { // Remove the pair(id, quest) from the multimap QuestRelations::iterator qitr = GameObjectQuestMap->find(itr->first); @@ -1657,12 +1700,12 @@ void GameEventMgr::UpdateEventQuests(uint16 event_id, bool activate) } } -void GameEventMgr::UpdateWorldStates(uint16 event_id, bool Activate) +void GameEventMgr::UpdateWorldStates(uint16 eventId, bool Activate) { - GameEventData const& event = mGameEvent[event_id]; - if (event.holiday_id != HOLIDAY_NONE) + GameEventData const& event = _gameEvent[eventId]; + if (event.HolidayId != HOLIDAY_NONE) { - BattlegroundTypeId bgTypeId = BattlegroundMgr::WeekendHolidayIdToBGType(event.holiday_id); + BattlegroundTypeId bgTypeId = BattlegroundMgr::WeekendHolidayIdToBGType(event.HolidayId); if (bgTypeId != BATTLEGROUND_TYPE_NONE) { BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId); @@ -1677,57 +1720,57 @@ void GameEventMgr::UpdateWorldStates(uint16 event_id, bool Activate) } } -GameEventMgr::GameEventMgr() : isSystemInit(false) +GameEventMgr::GameEventMgr() : _isSystemInit(false) { } void GameEventMgr::HandleQuestComplete(uint32 quest_id) { // translate the quest to event and condition - QuestIdToEventConditionMap::iterator itr = mQuestToEventConditions.find(quest_id); + QuestIdToEventConditionMap::iterator itr = _questToEventConditions.find(quest_id); // quest is registered - if (itr != mQuestToEventConditions.end()) + if (itr != _questToEventConditions.end()) { - uint16 event_id = itr->second.event_id; - uint32 condition = itr->second.condition; - float num = itr->second.num; + uint16 eventId = itr->second.EventId; + uint32 condition = itr->second.Condition; + float num = itr->second.Num; // the event is not active, so return, don't increase condition finishes - if (!IsActiveEvent(event_id)) + if (!IsActiveEvent(eventId)) return; // not in correct phase, return - if (mGameEvent[event_id].state != GAMEEVENT_WORLD_CONDITIONS) + if (_gameEvent[eventId].State != GAMEEVENT_WORLD_CONDITIONS) return; - GameEventConditionMap::iterator citr = mGameEvent[event_id].conditions.find(condition); + GameEventConditionMap::iterator citr = _gameEvent[eventId].Conditions.find(condition); // condition is registered - if (citr != mGameEvent[event_id].conditions.end()) + if (citr != _gameEvent[eventId].Conditions.end()) { // increase the done count, only if less then the req - if (citr->second.done < citr->second.reqNum) + if (citr->second.Done < citr->second.ReqNum) { - citr->second.done += num; + citr->second.Done += num; // check max limit - if (citr->second.done > citr->second.reqNum) - citr->second.done = citr->second.reqNum; + if (citr->second.Done > citr->second.ReqNum) + citr->second.Done = citr->second.ReqNum; // save the change to db CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GAME_EVENT_CONDITION_SAVE); - stmt->SetData(0, uint8(event_id)); + stmt->SetData(0, uint8(eventId)); stmt->SetData(1, condition); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GAME_EVENT_CONDITION_SAVE); - stmt->SetData(0, uint8(event_id)); + stmt->SetData(0, uint8(eventId)); stmt->SetData(1, condition); - stmt->SetData(2, citr->second.done); + stmt->SetData(2, citr->second.Done); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); // check if all conditions are met, if so, update the event state - if (CheckOneGameEventConditions(event_id)) + if (CheckOneGameEventConditions(eventId)) { // changed, save to DB the gameevent state - SaveWorldEventStateToDB(event_id); + SaveWorldEventStateToDB(eventId); // force update events to set timer sWorld->ForceGameEventUpdate(); } @@ -1736,48 +1779,48 @@ void GameEventMgr::HandleQuestComplete(uint32 quest_id) } } -bool GameEventMgr::CheckOneGameEventConditions(uint16 event_id) +bool GameEventMgr::CheckOneGameEventConditions(uint16 eventId) { - for (GameEventConditionMap::const_iterator itr = mGameEvent[event_id].conditions.begin(); itr != mGameEvent[event_id].conditions.end(); ++itr) - if (itr->second.done < itr->second.reqNum) + for (GameEventConditionMap::const_iterator itr = _gameEvent[eventId].Conditions.begin(); itr != _gameEvent[eventId].Conditions.end(); ++itr) + if (itr->second.Done < itr->second.ReqNum) // return false if a condition doesn't match return false; // set the phase - mGameEvent[event_id].state = GAMEEVENT_WORLD_NEXTPHASE; + _gameEvent[eventId].State = GAMEEVENT_WORLD_NEXTPHASE; // set the followup events' start time - if (!mGameEvent[event_id].nextstart) + if (!_gameEvent[eventId].NextStart) { time_t currenttime = GameTime::GetGameTime().count(); - mGameEvent[event_id].nextstart = currenttime + mGameEvent[event_id].length * 60; + _gameEvent[eventId].NextStart = currenttime + _gameEvent[eventId].Length * 60; } return true; } -void GameEventMgr::SaveWorldEventStateToDB(uint16 event_id) +void GameEventMgr::SaveWorldEventStateToDB(uint16 eventId) { CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GAME_EVENT_SAVE); - stmt->SetData(0, uint8(event_id)); + stmt->SetData(0, uint8(eventId)); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GAME_EVENT_SAVE); - stmt->SetData(0, uint8(event_id)); - stmt->SetData(1, mGameEvent[event_id].state); - stmt->SetData(2, mGameEvent[event_id].nextstart ? uint32(mGameEvent[event_id].nextstart) : 0); + stmt->SetData(0, uint8(eventId)); + stmt->SetData(1, _gameEvent[eventId].State); + stmt->SetData(2, _gameEvent[eventId].NextStart ? uint32(_gameEvent[eventId].NextStart) : 0); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); } -void GameEventMgr::SendWorldStateUpdate(Player* player, uint16 event_id) +void GameEventMgr::SendWorldStateUpdate(Player* player, uint16 eventId) { GameEventConditionMap::const_iterator itr; - for (itr = mGameEvent[event_id].conditions.begin(); itr != mGameEvent[event_id].conditions.end(); ++itr) + for (itr = _gameEvent[eventId].Conditions.begin(); itr != _gameEvent[eventId].Conditions.end(); ++itr) { - if (itr->second.done_world_state) - player->SendUpdateWorldState(itr->second.done_world_state, (uint32)(itr->second.done)); - if (itr->second.max_world_state) - player->SendUpdateWorldState(itr->second.max_world_state, (uint32)(itr->second.reqNum)); + if (itr->second.DoneWorldState) + player->SendUpdateWorldState(itr->second.DoneWorldState, (uint32)(itr->second.Done)); + if (itr->second.MaxWorldState) + player->SendUpdateWorldState(itr->second.MaxWorldState, (uint32)(itr->second.ReqNum)); } } @@ -1808,13 +1851,13 @@ private: bool _activate; }; -void GameEventMgr::RunSmartAIScripts(uint16 event_id, bool activate) +void GameEventMgr::RunSmartAIScripts(uint16 eventId, bool activate) { //! Iterate over every supported source type (creature and gameobject) //! Not entirely sure how this will affect units in non-loaded grids. - sMapMgr->DoForAllMaps([event_id, activate](Map* map) + sMapMgr->DoForAllMaps([eventId, activate](Map* map) { - GameEventAIHookWorker worker(event_id, activate); + GameEventAIHookWorker worker(eventId, activate); TypeContainerVisitor visitor(worker); visitor.Visit(map->GetObjectsStore()); }); @@ -1822,19 +1865,19 @@ void GameEventMgr::RunSmartAIScripts(uint16 event_id, bool activate) void GameEventMgr::SetHolidayEventTime(GameEventData& event) { - if (!event.holidayStage) // Ignore holiday + if (!event.HolidayStage) // Ignore holiday return; - const HolidaysEntry* holiday = sHolidaysStore.LookupEntry(event.holiday_id); + HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(event.HolidayId); if (!holiday->Date[0] || !holiday->Duration[0]) // Invalid definitions { - LOG_ERROR("sql.sql", "Missing date or duration for holiday {}.", event.holiday_id); + LOG_ERROR("sql.sql", "Missing date or duration for holiday {}.", event.HolidayId); return; } - uint8 stageIndex = event.holidayStage - 1; - event.length = holiday->Duration[stageIndex] * HOUR / MINUTE; + uint8 stageIndex = event.HolidayStage - 1; + event.Length = holiday->Duration[stageIndex] * HOUR / MINUTE; time_t stageOffset = 0; for (uint8 i = 0; i < stageIndex; ++i) @@ -1845,10 +1888,10 @@ void GameEventMgr::SetHolidayEventTime(GameEventData& event) switch (holiday->CalendarFilterType) { case -1: // Yearly - event.occurence = YEAR / MINUTE; // Not all too useful + event.Occurence = YEAR / MINUTE; // Not all too useful break; case 0: // Weekly - event.occurence = WEEK / MINUTE; + event.Occurence = WEEK / MINUTE; break; case 1: // Defined dates only (Darkmoon Faire) break; @@ -1858,10 +1901,10 @@ void GameEventMgr::SetHolidayEventTime(GameEventData& event) if (holiday->Looping) { - event.occurence = 0; + event.Occurence = 0; for (uint8 i = 0; i < MAX_HOLIDAY_DURATIONS && holiday->Duration[i]; ++i) { - event.occurence += holiday->Duration[i] * HOUR / MINUTE; + event.Occurence += holiday->Duration[i] * HOUR / MINUTE; } } @@ -1893,9 +1936,9 @@ void GameEventMgr::SetHolidayEventTime(GameEventData& event) // try to get next start time (skip past dates) time_t startTime = mktime(&timeInfo); - if (curTime < startTime + event.length * MINUTE) + if (curTime < startTime + event.Length * MINUTE) { - event.start = startTime + stageOffset; + event.Start = startTime + stageOffset; break; } else if (singleDate) @@ -1904,7 +1947,7 @@ void GameEventMgr::SetHolidayEventTime(GameEventData& event) int year = tmCopy.tm_year; // This year tmCopy = timeInfo; tmCopy.tm_year = year; - event.start = mktime(&tmCopy) + stageOffset; + event.Start = mktime(&tmCopy) + stageOffset; break; } else @@ -1921,9 +1964,9 @@ uint32 GameEventMgr::GetHolidayEventId(uint32 holidayId) const for (auto const& eventEntry : events) { - if (eventEntry.holiday_id == holidayId) + if (eventEntry.HolidayId == holidayId) { - return eventEntry.eventId; + return eventEntry.EventId; } } @@ -1939,14 +1982,14 @@ bool IsHolidayActive(HolidayIds id) GameEventMgr::ActiveEvents const& ae = sGameEventMgr->GetActiveEventList(); for (GameEventMgr::ActiveEvents::const_iterator itr = ae.begin(); itr != ae.end(); ++itr) - if (events[*itr].holiday_id == id) + if (events[*itr].HolidayId == id) return true; return false; } -bool IsEventActive(uint16 event_id) +bool IsEventActive(uint16 eventId) { GameEventMgr::ActiveEvents const& ae = sGameEventMgr->GetActiveEventList(); - return ae.find(event_id) != ae.end(); + return ae.find(eventId) != ae.end(); } diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h index b997efe06..390849269 100644 --- a/src/server/game/Events/GameEventMgr.h +++ b/src/server/game/Events/GameEventMgr.h @@ -38,17 +38,17 @@ enum GameEventState struct GameEventFinishCondition { - float reqNum; // required number // use float, since some events use percent - float done; // done number - uint32 max_world_state; // max resource count world state update id - uint32 done_world_state; // done resource count world state update id + float ReqNum; // required number // use float, since some events use percent + float Done; // done number + uint32 MaxWorldState; // max resource count world state update id + uint32 DoneWorldState; // done resource count world state update id }; struct GameEventQuestToEventConditionNum { - uint16 event_id; - uint32 condition; - float num; + uint16 EventId; + uint32 Condition; + float Num; }; typedef std::map GameEventConditionMap; @@ -56,37 +56,37 @@ typedef std::map GameEventCon struct GameEventData { GameEventData() = default; - uint32 eventId; - time_t start{1}; // occurs after this time - time_t end{0}; // occurs before this time - time_t nextstart{0}; // after this time the follow-up events count this phase completed - uint32 occurence{0}; // time between end and start - uint32 length{0}; // length of the event (minutes) after finishing all conditions - HolidayIds holiday_id{HOLIDAY_NONE}; - uint8 holidayStage; - GameEventState state{GAMEEVENT_NORMAL}; // state of the game event, these are saved into the game_event table on change! - GameEventConditionMap conditions; // conditions to finish - std::set prerequisite_events; // events that must be completed before starting this event - std::string description; - uint8 announce; // if 0 dont announce, if 1 announce, if 2 take config value + uint32 EventId; + time_t Start{1}; // occurs after this time + time_t End{0}; // occurs before this time + time_t NextStart{0}; // after this time the follow-up events count this phase completed + uint32 Occurence{0}; // time between end and start + uint32 Length{0}; // length of the event (minutes) after finishing all conditions + HolidayIds HolidayId{HOLIDAY_NONE}; + uint8 HolidayStage; + GameEventState State{GAMEEVENT_NORMAL}; // state of the game event, these are saved into the game_event table on change! + GameEventConditionMap Conditions; // conditions to finish + std::set PrerequisiteEvents; // events that must be completed before starting this event + std::string Description; + uint8 Announce; // if 0 dont announce, if 1 announce, if 2 take config value - [[nodiscard]] bool isValid() const { return length > 0 || state > GAMEEVENT_NORMAL; } + [[nodiscard]] bool isValid() const { return Length > 0 || State > GAMEEVENT_NORMAL; } }; struct ModelEquip { - uint32 modelid; - uint32 modelid_prev; - uint8 equipment_id; - uint8 equipement_id_prev; + uint32 ModelId; + uint32 ModelIdPrev; + uint8 EquipmentId; + uint8 EquipementIdPrev; }; struct NPCVendorEntry { - uint32 entry; // creature entry - uint32 item; // item id - int32 maxcount; // 0 for infinite - uint32 incrtime; // time for restore items amount if maxcount != 0 + uint32 Entry; // creature entry + uint32 Item; // item id + int32 MaxCount; // 0 for infinite + uint32 Incrtime; // time for restore items amount if maxcount != 0 uint32 ExtendedCost; }; @@ -105,46 +105,62 @@ public: typedef std::set ActiveEvents; typedef std::vector GameEventDataMap; - [[nodiscard]] ActiveEvents const& GetActiveEventList() const { return m_ActiveEvents; } - [[nodiscard]] GameEventDataMap const& GetEventMap() const { return mGameEvent; } + [[nodiscard]] ActiveEvents const& GetActiveEventList() const { return _activeEvents; } + [[nodiscard]] GameEventDataMap const& GetEventMap() const { return _gameEvent; } [[nodiscard]] bool CheckOneGameEvent(uint16 entry) const; [[nodiscard]] uint32 NextCheck(uint16 entry) const; void LoadFromDB(); void LoadHolidayDates(); uint32 Update(); - bool IsActiveEvent(uint16 event_id) { return (m_ActiveEvents.find(event_id) != m_ActiveEvents.end()); } + bool IsActiveEvent(uint16 eventId) { return (_activeEvents.find(eventId) != _activeEvents.end()); } uint32 StartSystem(); void Initialize(); void StartArenaSeason(); - void StartInternalEvent(uint16 event_id); - bool StartEvent(uint16 event_id, bool overwrite = false); - void StopEvent(uint16 event_id, bool overwrite = false); - void HandleQuestComplete(uint32 quest_id); // called on world event type quest completions + void StartInternalEvent(uint16 eventId); + bool StartEvent(uint16 eventId, bool overwrite = false); + void StopEvent(uint16 eventId, bool overwrite = false); + void HandleQuestComplete(uint32 questId); // called on world event type quest completions uint32 GetNPCFlag(Creature* cr); // Load the game event npc vendor table from the DB void LoadEventVendors(); [[nodiscard]] uint32 GetHolidayEventId(uint32 holidayId) const; private: - void SendWorldStateUpdate(Player* player, uint16 event_id); - void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); } - void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); } - void ApplyNewEvent(uint16 event_id); - void UnApplyEvent(uint16 event_id); - void GameEventSpawn(int16 event_id); - void GameEventUnspawn(int16 event_id); - void ChangeEquipOrModel(int16 event_id, bool activate); - void UpdateEventQuests(uint16 event_id, bool activate); - void UpdateWorldStates(uint16 event_id, bool Activate); - void UpdateEventNPCFlags(uint16 event_id); - void UpdateEventNPCVendor(uint16 event_id, bool activate); + void LoadEvents(); + void LoadEventSaveData(); + void LoadEventPrerequisiteData(); + void LoadEventCreatureData(); + void LoadEventGameObjectData(); + void LoadEventModelEquipmentChangeData(); + void LoadEventQuestData(); + void LoadEventGameObjectQuestData(); + void LoadEventQuestConditionData(); + void LoadEventConditionData(); + void LoadEventConditionSaveData(); + void LoadEventNPCFlags(); + void LoadEventSeasonalQuestRelations(); + void LoadEventBattlegroundData(); + void LoadEventPoolData(); + + void SendWorldStateUpdate(Player* player, uint16 eventId); + void AddActiveEvent(uint16 eventId) { _activeEvents.insert(eventId); } + void RemoveActiveEvent(uint16 eventId) { _activeEvents.erase(eventId); } + void ApplyNewEvent(uint16 eventId); + void UnApplyEvent(uint16 eventId); + void GameEventSpawn(int16 eventId); + void GameEventUnspawn(int16 eventId); + void ChangeEquipOrModel(int16 eventId, bool activate); + void UpdateEventQuests(uint16 eventId, bool activate); + void UpdateWorldStates(uint16 eventId, bool Activate); + void UpdateEventNPCFlags(uint16 eventId); + void UpdateEventNPCVendor(uint16 eventId, bool activate); void UpdateBattlegroundSettings(); - void RunSmartAIScripts(uint16 event_id, bool activate); //! Runs SMART_EVENT_GAME_EVENT_START/_END SAI - bool CheckOneGameEventConditions(uint16 event_id); - void SaveWorldEventStateToDB(uint16 event_id); - bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id); - bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id); - bool hasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 event_id); - bool hasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 event_id); + void RunSmartAIScripts(uint16 eventId, bool activate); //! Runs SMART_EVENT_GAME_EVENT_START/_END SAI + bool CheckOneGameEventConditions(uint16 eventId); + void SaveWorldEventStateToDB(uint16 eventId); + bool HasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 eventId); + bool HasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 eventId); + bool HasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 eventId); + bool HasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 eventId); void SetHolidayEventTime(GameEventData& event); typedef std::list GuidLowList; @@ -165,29 +181,27 @@ private: typedef std::vector GameEventNPCFlagMap; typedef std::vector GameEventBitmask; typedef std::unordered_map> GameEventSeasonalQuestsMap; - GameEventQuestMap mGameEventCreatureQuests; - GameEventQuestMap mGameEventGameObjectQuests; - GameEventNPCVendorMap mGameEventVendors; - GameEventModelEquipMap mGameEventModelEquip; - //GameEventGuidMap mGameEventCreatureGuids; - //GameEventGuidMap mGameEventGameobjectGuids; - GameEventIdMap mGameEventPoolIds; - GameEventDataMap mGameEvent; - GameEventBitmask mGameEventBattlegroundHolidays; - QuestIdToEventConditionMap mQuestToEventConditions; - GameEventNPCFlagMap mGameEventNPCFlags; - ActiveEvents m_ActiveEvents; - bool isSystemInit; + GameEventQuestMap _gameEventCreatureQuests; + GameEventQuestMap _gameEventGameObjectQuests; + GameEventNPCVendorMap _gameEventVendors; + GameEventModelEquipMap _gameEventModelEquip; + GameEventIdMap _gameEventPoolIds; + GameEventDataMap _gameEvent; + GameEventBitmask _gameEventBattlegroundHolidays; + QuestIdToEventConditionMap _questToEventConditions; + GameEventNPCFlagMap _gameEventNPCFlags; + ActiveEvents _activeEvents; + bool _isSystemInit; GameEventSeasonalQuestsMap _gameEventSeasonalQuestsMap; public: - GameEventGuidMap mGameEventCreatureGuids; - GameEventGuidMap mGameEventGameobjectGuids; - std::vector modifiedHolidays; + GameEventGuidMap GameEventCreatureGuids; + GameEventGuidMap GameEventGameobjectGuids; + std::vector ModifiedHolidays; }; #define sGameEventMgr GameEventMgr::instance() bool IsHolidayActive(HolidayIds id); -bool IsEventActive(uint16 event_id); +bool IsEventActive(uint16 eventId); #endif diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 208a5ccbf..aa39808ce 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1651,7 +1651,7 @@ CreatureModel const* ObjectMgr::ChooseDisplayId(CreatureTemplate const* cinfo, C if (CreatureModel const* model = cinfo->GetModelWithDisplayId(data->displayid)) return model; - if (!(cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)) + if (!cinfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_TRIGGER)) if (CreatureModel const* model = cinfo->GetRandomValidModel()) return model; @@ -2233,7 +2233,7 @@ void ObjectMgr::LoadCreatures() data.equipmentId = 0; } } - if ((cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) || (data.id2 && cInfo2->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) || (data.id3 && cInfo3->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)) + if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND) || (data.id2 && cInfo2->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND)) || (data.id3 && cInfo3->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND))) { if (!mapEntry->IsDungeon()) LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with a `creature_template`.`flags_extra` in one or more entries including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.", diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 4ee34697d..53cccbf4e 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -153,8 +153,8 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) data.append(dataBuffer); /// @todo: Fix this, how we do know how many and what holidays to send? - data << uint32(sGameEventMgr->modifiedHolidays.size()); - for (uint32 entry : sGameEventMgr->modifiedHolidays) + data << uint32(sGameEventMgr->ModifiedHolidays.size()); + for (uint32 entry : sGameEventMgr->ModifiedHolidays) { HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(entry); diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 610ef3da2..fa2f17e62 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -743,7 +743,7 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData) return; } - if ((creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_SELL_VENDOR) != 0) + if (creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_SELL_VENDOR)) { _player->SendSellError(SELL_ERR_CANT_SELL_TO_THIS_MERCHANT, creature, itemguid, 0); return; diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp index 1de3e182e..3197e0982 100644 --- a/src/server/game/Handlers/TradeHandler.cpp +++ b/src/server/game/Handlers/TradeHandler.cpp @@ -70,14 +70,12 @@ void WorldSession::SendTradeStatus(TradeStatus status) void WorldSession::HandleIgnoreTradeOpcode(WorldPacket& /*recvPacket*/) { - LOG_DEBUG("network", "WORLD: Ignore Trade {}", _player->GetGUID().ToString()); - // recvPacket.print_storage(); + _player->TradeCancel(true, TRADE_STATUS_IGNORE_YOU); } void WorldSession::HandleBusyTradeOpcode(WorldPacket& /*recvPacket*/) { - LOG_DEBUG("network", "WORLD: Busy Trade {}", _player->GetGUID().ToString()); - // recvPacket.print_storage(); + _player->TradeCancel(true, TRADE_STATUS_BUSY); } void WorldSession::SendUpdateTrade(bool trader_data /*= true*/) @@ -526,12 +524,12 @@ void WorldSession::HandleBeginTradeOpcode(WorldPacket& /*recvPacket*/) SendTradeStatus(TRADE_STATUS_OPEN_WINDOW); } -void WorldSession::SendCancelTrade() +void WorldSession::SendCancelTrade(TradeStatus status) { if (PlayerRecentlyLoggedOut() || PlayerLogout()) return; - SendTradeStatus(TRADE_STATUS_TRADE_CANCELED); + SendTradeStatus(status); } void WorldSession::HandleCancelTradeOpcode(WorldPacket& /*recvPacket*/) @@ -620,12 +618,6 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) return; } - if (pOther->GetSocial()->HasIgnore(GetPlayer()->GetGUID())) - { - SendTradeStatus(TRADE_STATUS_IGNORE_YOU); - return; - } - if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_TRADE) && pOther->GetTeamId() != _player->GetTeamId()) { SendTradeStatus(TRADE_STATUS_WRONG_FACTION); diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 9371aeccb..90e70694c 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3724,14 +3724,14 @@ void Map::RemoveOldCorpses() } } -void Map::ScheduleCreatureRespawn(ObjectGuid creatureGuid, Milliseconds respawnTimer) +void Map::ScheduleCreatureRespawn(ObjectGuid creatureGuid, Milliseconds respawnTimer, Position pos) { - _creatureRespawnScheduler.Schedule(respawnTimer, [this, creatureGuid](TaskContext) + _creatureRespawnScheduler.Schedule(respawnTimer, [this, creatureGuid, pos](TaskContext) { if (Creature* creature = GetCreature(creatureGuid)) - { creature->Respawn(); - } + else + SummonCreature(creatureGuid.GetEntry(), pos); }); } diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index e753d841f..e6e10c26d 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -596,7 +596,7 @@ public: TaskScheduler _creatureRespawnScheduler; - void ScheduleCreatureRespawn(ObjectGuid /*creatureGuid*/, Milliseconds /*respawnTimer*/); + void ScheduleCreatureRespawn(ObjectGuid /*creatureGuid*/, Milliseconds /*respawnTimer*/, Position pos = Position()); void LoadCorpseData(); void DeleteCorpseData(); diff --git a/src/server/game/Maps/MapMgr.cpp b/src/server/game/Maps/MapMgr.cpp index 423f5ac5d..3a52e5fe3 100644 --- a/src/server/game/Maps/MapMgr.cpp +++ b/src/server/game/Maps/MapMgr.cpp @@ -167,7 +167,7 @@ Map::EnterState MapMgr::PlayerCannotEnter(uint32 mapid, Player* player, bool log { // probably there must be special opcode, because client has this string constant in GlobalStrings.lua /// @todo: this is not a good place to send the message - player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetAcoreString(LANG_INSTANCE_RAID_GROUP_ONLY), mapName); + player->GetSession()->SendAreaTriggerMessage(LANG_INSTANCE_RAID_GROUP_ONLY, mapName); LOG_DEBUG("maps", "MAP: Player '{}' must be in a raid group to enter instance '{}'", player->GetName(), mapName); return Map::CANNOT_ENTER_NOT_IN_RAID; } diff --git a/src/server/game/Miscellaneous/Formulas.cpp b/src/server/game/Miscellaneous/Formulas.cpp index 0924db641..00237c578 100644 --- a/src/server/game/Miscellaneous/Formulas.cpp +++ b/src/server/game/Miscellaneous/Formulas.cpp @@ -74,7 +74,7 @@ uint32 Acore::XP::Gain(Player* player, Unit* unit, bool isBattleGround /*= false uint32 gain = 0; if (!creature || (!creature->IsTotem() && !creature->IsPet() && !creature->IsCritter() && - !(creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP))) + !creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_XP))) { float xpMod = 1.0f; diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index ebccbc0fe..e2b73bef7 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -372,7 +372,7 @@ public: void SendAreaTriggerMessage(std::string_view str); template - void SendAreaTriggerMessage(std::string fmt, Args&&... args) + void SendAreaTriggerMessage(char const* fmt, Args&&... args) { if (!m_playerLoading) SendAreaTriggerMessage(Acore::StringFormat(fmt, std::forward(args)...)); @@ -466,7 +466,7 @@ public: void SendTradeStatus(TradeStatus status); void SendUpdateTrade(bool trader_data = true); - void SendCancelTrade(); + void SendCancelTrade(TradeStatus status); void SendPetitionQueryOpcode(ObjectGuid petitionguid); diff --git a/src/server/game/Spells/SpellInfoCorrections.cpp b/src/server/game/Spells/SpellInfoCorrections.cpp index dccf4ca4f..c59c4fdf8 100644 --- a/src/server/game/Spells/SpellInfoCorrections.cpp +++ b/src/server/game/Spells/SpellInfoCorrections.cpp @@ -3107,6 +3107,7 @@ void SpellMgr::LoadSpellInfoCorrections() // Tail Smash (Sindragosa) ApplySpellFix({ 71077 }, [](SpellInfo* spellInfo) { + spellInfo->AttributesEx2 |= SPELL_ATTR2_IGNORE_LINE_OF_SIGHT; spellInfo->Effects[EFFECT_0].TargetA = SpellImplicitTargetInfo(TARGET_DEST_CASTER_BACK); spellInfo->Effects[EFFECT_0].TargetB = SpellImplicitTargetInfo(TARGET_UNIT_DEST_AREA_ENEMY); spellInfo->Effects[EFFECT_1].TargetA = SpellImplicitTargetInfo(TARGET_DEST_CASTER_BACK); diff --git a/src/server/game/World/WorldState.cpp b/src/server/game/World/WorldState.cpp index a17ac7a11..2d7d56b55 100644 --- a/src/server/game/World/WorldState.cpp +++ b/src/server/game/World/WorldState.cpp @@ -881,9 +881,9 @@ std::string WorldState::GetSunsReachPrintout() } }; output += "Sunwell Plateau Gate Phase " + std::to_string(m_sunsReachData.m_gate) + " (" + formatGatePhase(m_sunsReachData.m_gate) + ")" + ":\n"; - output += " 0. Gate 1 (Agamath): " + std::string(m_sunsReachData.m_gate >= SUNWELL_AGAMATH_GATE1_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_sunsReachReclamationCounters[COUNTER_AGAMATH_THE_FIRST_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_ALL_GATES_CLOSED)) + "%)\n"; - output += " 1. Gate 2 (Rohendor): " + std::string(m_sunsReachData.m_gate >= SUNWELL_ROHENDOR_GATE2_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_sunsReachReclamationCounters[COUNTER_ROHENDOR_THE_SECOND_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_AGAMATH_GATE1_OPEN)) + "%)\n"; - output += " 2. Gate 3 (Archonisus): " + std::string(m_sunsReachData.m_gate >= SUNWELL_ARCHONISUS_GATE3_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_sunsReachReclamationCounters[COUNTER_ARCHONISUS_THE_FINAL_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_ROHENDOR_GATE2_OPEN)) + "%)\n"; + output += " 0. Gate 1 (Agamath): " + std::string(m_sunsReachData.m_gate >= SUNWELL_AGAMATH_GATE1_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_gateCounters[COUNTER_AGAMATH_THE_FIRST_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_ALL_GATES_CLOSED)) + "%)\n"; + output += " 1. Gate 2 (Rohendor): " + std::string(m_sunsReachData.m_gate >= SUNWELL_ROHENDOR_GATE2_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_gateCounters[COUNTER_ROHENDOR_THE_SECOND_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_AGAMATH_GATE1_OPEN)) + "%)\n"; + output += " 2. Gate 3 (Archonisus): " + std::string(m_sunsReachData.m_gate >= SUNWELL_ARCHONISUS_GATE3_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_gateCounters[COUNTER_ARCHONISUS_THE_FINAL_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_ROHENDOR_GATE2_OPEN)) + "%)\n"; return output; } diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp index d8cfdde57..b73b067ef 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -68,9 +68,9 @@ public: GameEventData const& eventData = events[eventId]; if (handler->GetSession()) - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, eventId, eventId, eventData.description, active); + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, eventId, eventId, eventData.Description, active); else - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, eventId, eventData.description, active); + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, eventId, eventData.Description, active); ++counter; } @@ -104,17 +104,17 @@ public: bool active = activeEvents.find(eventId) != activeEvents.end(); std::string activeStr = active ? handler->GetAcoreString(LANG_ACTIVE) : ""; - std::string startTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.start)); - std::string endTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.end)); + std::string startTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.Start)); + std::string endTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.End)); uint32 delay = sGameEventMgr->NextCheck(eventId); time_t nextTime = GameTime::GetGameTime().count() + delay; - std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? Acore::Time::TimeToTimestampStr(Seconds(nextTime)) : "-"; + std::string nextStr = nextTime >= eventData.Start && nextTime < eventData.End ? Acore::Time::TimeToTimestampStr(Seconds(nextTime)) : "-"; - std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE, true); - std::string lengthStr = secsToTimeString(eventData.length * MINUTE, true); + std::string occurenceStr = secsToTimeString(eventData.Occurence * MINUTE, true); + std::string lengthStr = secsToTimeString(eventData.Length * MINUTE, true); - handler->PSendSysMessage(LANG_EVENT_INFO, uint16(eventId), eventData.description, activeStr, + handler->PSendSysMessage(LANG_EVENT_INFO, uint16(eventId), eventData.Description, activeStr, startTimeStr, endTimeStr, occurenceStr, lengthStr, nextStr); @@ -141,11 +141,11 @@ public: GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList(); if (activeEvents.find(eventId) != activeEvents.end()) { - handler->SendErrorMessage(LANG_EVENT_ALREADY_ACTIVE, uint16(eventId), eventData.description); + handler->SendErrorMessage(LANG_EVENT_ALREADY_ACTIVE, uint16(eventId), eventData.Description); return false; } - handler->PSendSysMessage(LANG_EVENT_STARTED, uint16(eventId), eventData.description); + handler->PSendSysMessage(LANG_EVENT_STARTED, uint16(eventId), eventData.Description); sGameEventMgr->StartEvent(eventId, true); return true; } @@ -171,11 +171,11 @@ public: if (activeEvents.find(eventId) == activeEvents.end()) { - handler->SendErrorMessage(LANG_EVENT_NOT_ACTIVE, uint16(eventId), eventData.description); + handler->SendErrorMessage(LANG_EVENT_NOT_ACTIVE, uint16(eventId), eventData.Description); return false; } - handler->PSendSysMessage(LANG_EVENT_STOPPED, uint16(eventId), eventData.description); + handler->PSendSysMessage(LANG_EVENT_STOPPED, uint16(eventId), eventData.Description); sGameEventMgr->StopEvent(eventId, true); return true; } diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 27ba9f67d..5cc26cb0c 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -269,17 +269,13 @@ public: static bool HandleLookupEventCommand(ChatHandler* handler, Tail namePart) { if (namePart.empty()) - { return false; - } std::wstring wNamePart; // converting string that we try to find to lower case if (!Utf8toWStr(namePart, wNamePart)) - { return false; - } wstrToLower(wNamePart); @@ -294,11 +290,9 @@ public: { GameEventData const& eventData = events[id]; - std::string descr = eventData.description; + std::string descr = eventData.Description; if (descr.empty()) - { continue; - } if (Utf8FitTo(descr, wNamePart)) { @@ -311,25 +305,17 @@ public: std::string active = activeEvents.find(id) != activeEvents.end() ? handler->GetAcoreString(LANG_ACTIVE) : ""; if (handler->GetSession()) - { - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.description, active); - } + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.Description, active); else - { - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.description, active); - } + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.Description, active); if (!found) - { found = true; - } } } if (!found) - { handler->SendSysMessage(LANG_NOEVENTFOUND); - } return true; } diff --git a/src/server/scripts/Commands/cs_worldstate.cpp b/src/server/scripts/Commands/cs_worldstate.cpp index 7c1887b1c..40b37d6c5 100644 --- a/src/server/scripts/Commands/cs_worldstate.cpp +++ b/src/server/scripts/Commands/cs_worldstate.cpp @@ -83,7 +83,7 @@ public: handler->PSendSysMessage("Invalid subphase, see \".worldstate sunsreach subphase\" for usage"); return false; } - sWorldState->HandleSunsReachSubPhaseTransition(subphase);; + sWorldState->HandleSunsReachSubPhaseTransition(subphase); handler->PSendSysMessage(sWorldState->GetSunsReachPrintout()); return true; } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp index 6f464d7d1..abd2df2d8 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp @@ -354,9 +354,8 @@ struct npc_madrigosa : public NullCreatureAI } break; case EVENT_SPAWN_FELMYST: + DoCastAOE(SPELL_SUMMON_FELBLAZE, true); me->DespawnOrUnsummon(1); - if (Creature* felmyst = instance->GetCreature(DATA_FELMYST)) - felmyst->AI()->DoAction(ACTION_START_EVENT); break; } } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp index 4d57ab7fb..f8ead6557 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp @@ -100,30 +100,30 @@ private: struct boss_felmyst : public BossAI { - boss_felmyst(Creature* creature) : BossAI(creature, DATA_FELMYST) - { - bool appear = instance->GetBossState(DATA_BRUTALLUS) == DONE; - creature->SetVisible(appear); - creature->SetStandState(UNIT_STAND_STATE_SLEEP); - creature->SetReactState(REACT_PASSIVE); - } + boss_felmyst(Creature* creature) : BossAI(creature, DATA_FELMYST) { } - void DoAction(int32 param) override + void InitializeAI() override { - if (param == ACTION_START_EVENT) + me->SetReactState(REACT_PASSIVE); + + if (instance->GetBossState(DATA_FELMYST) == TO_BE_DECIDED) { - me->SetVisible(true); - me->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE); + me->SetStandState(UNIT_STAND_STATE_SLEEP); + me->SetImmuneToPC(true); StartIntro(); } + else + { + me->SetCanFly(true); + me->SetDisableGravity(true); + me->SendMovementFlagUpdate(); + me->GetMotionMaster()->MovePath(me->GetEntry() * 10, true); + } } void Reset() override { BossAI::Reset(); - me->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE); - me->SetReactState(REACT_PASSIVE); - me->SetDisableGravity(false); me->m_Events.KillAllEvents(false); instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_FOG_OF_CORRUPTION_CHARM); } @@ -131,10 +131,18 @@ struct boss_felmyst : public BossAI void JustEngagedWith(Unit* who) override { BossAI::JustEngagedWith(who); - me->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE); + me->CastSpell(me, SPELL_NOXIOUS_FUMES, true); + me->m_Events.AddEventAtOffset([&] { + Talk(YELL_BERSERK); + DoCastSelf(SPELL_BERSERK, true); + }, 10min); - if (!scheduler.IsGroupScheduled(GROUP_START_INTRO)) - StartIntro(); + me->GetMotionMaster()->Clear(); + + Position landPos = who->GetPosition(); + me->m_Events.AddEventAtOffset([&, landPos] { + me->GetMotionMaster()->MovePoint(POINT_GROUND, landPos, false, true); + }, 2s); } void KilledUnit(Unit* victim) override @@ -146,6 +154,7 @@ struct boss_felmyst : public BossAI void JustDied(Unit* killer) override { BossAI::JustDied(killer); + me->m_Events.KillAllEvents(false); Talk(YELL_DEATH); instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_FOG_OF_CORRUPTION_CHARM); @@ -161,8 +170,10 @@ struct boss_felmyst : public BossAI if (point == POINT_GROUND) { me->HandleEmoteCommand(EMOTE_ONESHOT_LAND); + me->SetCanFly(false); me->SetDisableGravity(false); me->SendMovementFlagUpdate(); + SetInvincibility(false); me->m_Events.AddEventAtOffset([&] { me->SetReactState(REACT_AGGRESSIVE); @@ -171,7 +182,7 @@ struct boss_felmyst : public BossAI me->SetTarget(me->GetVictim()->GetGUID()); me->ResumeChasingVictim(); - }, 1s); + }, 2s); ScheduleTimedEvent(7500ms, [&] { DoCastVictim(SPELL_CLEAVE); @@ -238,6 +249,7 @@ struct boss_felmyst : public BossAI me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); me->SetDisableGravity(true); me->SendMovementFlagUpdate(); + SetInvincibility(true); me->m_Events.AddEventAtOffset([&] { me->GetMotionMaster()->MovePoint(POINT_AIR, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 15.0f, false, true); @@ -304,30 +316,16 @@ struct boss_felmyst : public BossAI me->m_Events.AddEventAtOffset([&] { Talk(YELL_BIRTH); + me->SetCanFly(true); me->SetDisableGravity(true); - me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); me->SendMovementFlagUpdate(); + me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); }, 7s); me->m_Events.AddEventAtOffset([&] { - me->GetMotionMaster()->MovePoint(POINT_AIR, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 10.0f, false, true); + me->SetImmuneToPC(false); + me->GetMotionMaster()->MovePath(me->GetEntry() * 10, true); }, 8500ms); - - me->m_Events.AddEventAtOffset([&] { - me->SetInCombatWithZone(); - me->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE); - me->CastSpell(me, SPELL_NOXIOUS_FUMES, true); - me->GetMotionMaster()->MovePoint(POINT_MISC, 1472.18f, 603.38f, 34.0f, false, true); - - me->m_Events.AddEventAtOffset([&] { - me->GetMotionMaster()->MovePoint(POINT_GROUND, me->GetPositionX(), me->GetPositionY(), me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()), false, true); - }, 3s); - - me->m_Events.AddEventAtOffset([&] { - Talk(YELL_BERSERK); - DoCastSelf(SPELL_BERSERK, true); - }, 10min); - }, 10500ms); }); } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index abb1b321c..35c71b297 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -106,12 +106,6 @@ struct boss_kalecgos : public BossAI return true; } - void JustReachedHome() override - { - BossAI::JustReachedHome(); - me->SetVisible(true); - } - void Reset() override { BossAI::Reset(); @@ -175,7 +169,6 @@ struct boss_kalecgos : public BossAI }, 4s); me->m_Events.AddEventAtOffset([&] { - me->SetVisible(false); EnterEvadeMode(); }, 9s); @@ -251,10 +244,11 @@ struct boss_kalecgos : public BossAI DoCastAOE(SPELL_SPECTRAL_BLAST); }, 15s, 25s); - me->m_Events.AddEventAtOffset([&] { + scheduler.Schedule(16s, [this](TaskContext) + { me->SummonCreature(NPC_KALEC, 1702.21f, 931.7f, -74.56f, 5.07f, TEMPSUMMON_MANUAL_DESPAWN); me->SummonCreature(NPC_SATHROVARR, 1704.62f, 927.78f, -73.9f, 2.0f, TEMPSUMMON_MANUAL_DESPAWN); - }, 16s); + }); me->SetStandState(UNIT_STAND_STATE_STAND); Talk(SAY_EVIL_AGGRO); @@ -282,10 +276,7 @@ enum Kalec struct boss_kalec : public ScriptedAI { - boss_kalec(Creature* creature) : ScriptedAI(creature) - { - SetInvincibility(true); - } + boss_kalec(Creature* creature) : ScriptedAI(creature) { } void Reset() override { diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp index a37aa61c4..03c85d228 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp @@ -89,6 +89,18 @@ public: LoadSummonData(summonData); } + void Load(char const* data) override + { + InstanceScript::Load(data); + + scheduler.Schedule(3s, [this](TaskContext /*context*/) + { + if (IsBossDone(DATA_BRUTALLUS) && !IsBossDone(DATA_FELMYST)) + if (Creature* madrigosa = GetCreature(DATA_MADRIGOSA)) + madrigosa->CastSpell((Unit*)nullptr, SPELL_SUMMON_FELBLAZE, true); + }); + } + void OnPlayerEnter(Player* player) override { instance->LoadGrid(1477.94f, 643.22f); diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/sunwell_plateau.h b/src/server/scripts/EasternKingdoms/SunwellPlateau/sunwell_plateau.h index 83f8705a4..9db46986d 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/sunwell_plateau.h +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/sunwell_plateau.h @@ -106,6 +106,11 @@ enum GameObjectIds GO_ORB_OF_THE_BLUE_DRAGONFLIGHT4 = 188116 }; +enum SpellIds +{ + SPELL_SUMMON_FELBLAZE = 45069 // Felblaze? Summons Felmyst +}; + template inline AI* GetSunwellPlateauAI(T* obj) { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 263b636d4..08932e308 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -1114,10 +1114,9 @@ public: return !_caster->IsWithinLOSInMap(unit); // for players and pets check only dynamic los (ice block gameobjects) - float ox, oy, oz; - _caster->GetPosition(ox, oy, oz); - DynamicMapTree const& dTree = unit->GetMap()->GetDynamicMapTree(); - return !dTree.isInLineOfSight(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ() + 2.f, ox, oy, oz + 2.f, unit->GetPhaseMask(), VMAP::ModelIgnoreFlags::Nothing); + if (unit->IsUnit() && unit->ToUnit()->HasUnitState(UNIT_STATE_MELEE_ATTACKING) && unit->ToUnit()->IsWithinMeleeRange(_caster)) + return false; + return !_caster->IsWithinLOSInMap(unit, VMAP::ModelIgnoreFlags::Nothing, LINEOFSIGHT_CHECK_GOBJECT_M2, 0, _caster->GetCombatReach() * 0.7); } private: diff --git a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp index 2887192b6..f2640d9c5 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp @@ -1161,17 +1161,6 @@ public: { IsSindragosaIntroDone = true; HandleDropAttempt(); - if (instance->IsHeroic()) - { - if (HeroicAttempts) - { - Events.ScheduleEvent(EVENT_RESPAWN_SINDRAGOSA, 30s); - } - } - else - { - Events.ScheduleEvent(EVENT_RESPAWN_SINDRAGOSA, 30s); - } } if (state == DONE && !instance->IsHeroic() && LichKingHeroicAvailable) { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp index dd8e7ae95..a987a7c82 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp @@ -369,6 +369,9 @@ public: break; case NPC_ALGALON: m_uiAlgalonGUID = creature->GetGUID(); + + if (!m_algalonTimer) + creature->DespawnOrUnsummon(); break; case NPC_HARPOON_FIRE_STATE: { @@ -811,17 +814,6 @@ public: go->EnableCollision(false); } - if (data == FAIL) - { - scheduler.Schedule(5s, [this](TaskContext) - { - if (m_algalonTimer && (m_algalonTimer <= 60 || m_algalonTimer == TIMER_ALGALON_TO_SUMMON)) - { - instance->SummonCreature(NPC_ALGALON, AlgalonLandPos); - } - }); - } - break; // Achievement diff --git a/src/server/scripts/Northrend/zone_dalaran.cpp b/src/server/scripts/Northrend/zone_dalaran.cpp index 6d2d5aeac..cc217eada 100644 --- a/src/server/scripts/Northrend/zone_dalaran.cpp +++ b/src/server/scripts/Northrend/zone_dalaran.cpp @@ -444,7 +444,9 @@ public: void MoveInLineOfSight(Unit* who) override { - if (!who || !who->IsInWorld() || who->GetZoneId() != 4395) + // 4395 Dalaran + // 4569 Sewer Exit Pipe + if (!who || !who->IsInWorld()|| who->GetZoneId() != 4395 || who->GetAreaId() == 4569) return; if (!me->IsWithinDist(who, 5.0f, false)) diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index a790ef65c..40b21e2a7 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -5400,6 +5400,38 @@ class spell_gen_proc_on_victim : public AuraScript } }; +enum TranslocateSpells +{ + SPELL_TRANSLOCATION_DOWN = 45368, + SPELL_TRANSLOCATION_UP = 45371 +}; + +class spell_gen_translocate : public SpellScript +{ + PrepareSpellScript(spell_gen_translocate); + +public: + spell_gen_translocate(uint32 spellId) : SpellScript(), _spellId(spellId) {} + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ _spellId }); + } + + void HandleScript() + { + GetCaster()->CastSpell(GetCaster(), _spellId); + } + + void Register() override + { + AfterCast += SpellCastFn(spell_gen_translocate::HandleScript); + } + +private: + uint32 _spellId; +}; + void AddSC_generic_spell_scripts() { RegisterSpellScript(spell_silithyst); @@ -5560,4 +5592,6 @@ void AddSC_generic_spell_scripts() RegisterSpellScript(spell_gen_set_health); RegisterSpellScript(spell_pet_spellhit_expertise_spellpen_scaling); RegisterSpellScript(spell_gen_proc_on_victim); + RegisterSpellScriptWithArgs(spell_gen_translocate, "spell_gen_translocate_down", SPELL_TRANSLOCATION_DOWN); + RegisterSpellScriptWithArgs(spell_gen_translocate, "spell_gen_translocate_up", SPELL_TRANSLOCATION_UP); }