From fbe3eaf2266039fe5469fd79c1cae92d278ead97 Mon Sep 17 00:00:00 2001 From: Emo Norfik Date: Sat, 7 Jan 2012 20:42:18 +0100 Subject: Scripts/Trial of the Crusader: Fix height position of Permafrost casted by Frost Sphere. It needs option "vmap.enableHeight = 1" to work properly. --- .../TrialOfTheCrusader/boss_anubarak_trial.cpp | 26 +++++++--------------- 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index e6678be3a2b..bc6145252d2 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -568,12 +568,11 @@ public: } bool m_bFall; - uint32 m_uiPermafrostTimer; + float x, y, z; void Reset() { m_bFall = false; - m_uiPermafrostTimer = 0; me->SetReactState(REACT_PASSIVE); me->SetFlying(true); me->SetDisplayId(25144); @@ -590,11 +589,13 @@ public: if (!m_bFall) { m_bFall = true; - me->SetFlying(false); me->GetMotionMaster()->MoveIdle(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); //At hit the ground - me->GetMotionMaster()->MoveFall(142.2f, 0); + me->GetPosition(x, y, z); + z = me->GetMap()->GetHeight(x, y, z, true, 50); + me->HandleEmoteCommand(EMOTE_ONESHOT_FLYDEATH); + me->GetMotionMaster()->MoveFall(z, 0); //me->FallGround(); //need correct vmap use (i believe it isn't working properly right now) } } @@ -607,24 +608,13 @@ public: switch (uiId) { case 0: - m_uiPermafrostTimer = IN_MILLISECONDS; - break; - } - } - - void UpdateAI(const uint32 uiDiff) - { - if (m_uiPermafrostTimer) - { - if (m_uiPermafrostTimer <= uiDiff) - { - m_uiPermafrostTimer = 0; me->RemoveAurasDueToSpell(SPELL_FROST_SPHERE); me->SetDisplayId(11686); - me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.0f); + me->Relocate(x, y, z, me->GetOrientation()); DoCast(SPELL_PERMAFROST_VISUAL); DoCast(SPELL_PERMAFROST); - } else m_uiPermafrostTimer -= uiDiff; + me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.0f); + break; } } }; -- cgit v1.2.3 From 138e5309e6fff172e56a08a8af844c2c1975eca4 Mon Sep 17 00:00:00 2001 From: Emo Norfik Date: Sat, 7 Jan 2012 21:18:27 +0100 Subject: Scripts/Halls of Lightning: Implement "Lightning Struck" achievement. --- .../HallsOfLightning/01_boss_general_bjarngrim.sql | 30 ++++++++++++ .../Ulduar/HallsOfLightning/boss_bjarngrim.cpp | 54 +++++++++++++++++++++- 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 sql/custom/Ulduar/HallsOfLightning/01_boss_general_bjarngrim.sql (limited to 'src/server/scripts/Northrend') diff --git a/sql/custom/Ulduar/HallsOfLightning/01_boss_general_bjarngrim.sql b/sql/custom/Ulduar/HallsOfLightning/01_boss_general_bjarngrim.sql new file mode 100644 index 00000000000..b4a77999612 --- /dev/null +++ b/sql/custom/Ulduar/HallsOfLightning/01_boss_general_bjarngrim.sql @@ -0,0 +1,30 @@ +-- HoL General Bjarngrim event Temporary Electrical Charge +-- Clear wrong aura +UPDATE `creature_addon` SET `auras`='' WHERE `guid` = 126981; + +-- add spell link for Temporary Electrical Charge +DELETE FROM `spell_linked_spell` WHERE `spell_trigger`='-52098' AND `spell_effect`='52092'; +INSERT INTO `spell_linked_spell` (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES +('-52098', '52092', '0', 'Charge Up - Temporary Electrical Charge'); + +-- Set 10 sec delay on platforms where boss gets Temporary Electrical Charge +UPDATE `waypoint_data` SET `delay`=10000 WHERE `id`=1269810 AND `point` IN (2, 5, 11, 14); + +-- Cast self Charge Up to get Temporary Electrical Charge +DELETE FROM `waypoint_scripts` WHERE `id`=12698101; +INSERT INTO `waypoint_scripts` (`id`, `delay`, `command`, `datalong`, `datalong2`, `dataint`, `x`, `y`, `z`, `o`, `guid`) VALUES +(12698101, 0, 14, 52092, 1, 0, 0, 0, 0, 0, 855), +(12698101, 2, 15, 52098, 1, 0, 0, 0, 0, 0, 856); +UPDATE `waypoint_data` SET `action`=12698101 WHERE `id`=1269810 AND `point` IN (5, 14); + +-- Remove aura Temporary Electrical Charge +DELETE FROM `waypoint_scripts` WHERE `id`=12698102; +INSERT INTO `waypoint_scripts` (`id`, `delay`, `command`, `datalong`, `datalong2`, `dataint`, `x`, `y`, `z`, `o`, `guid`) VALUES +(12698102, 0, 14, 52092, 1, 0, 0, 0, 0, 0, 857); +UPDATE `waypoint_data` SET `action`=12698102 WHERE `id`=1269810 AND `point` IN (2, 3, 4, 11, 12, 13); + +-- Lightning Struck achievement +DELETE FROM `disables` WHERE `sourceType`=4 AND `entry`=6835; +DELETE FROM `achievement_criteria_data` WHERE `type`=11 AND `criteria_id`=6835; +INSERT INTO `achievement_criteria_data` (`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES +(6835, 11, 0, 0, 'achievement_lightning_struck'); diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp index e96801f3ecb..0cf69eeb537 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp @@ -61,7 +61,7 @@ enum eEnums //OTHER SPELLS //SPELL_CHARGE_UP = 52098, // only used when starting walk from one platform to the other - //SPELL_TEMPORARY_ELECTRICAL_CHARGE = 52092, // triggered part of above + SPELL_TEMPORARY_ELECTRICAL_CHARGE = 52092, // triggered part of above NPC_STORMFORGED_LIEUTENANT = 29240, SPELL_ARC_WELD = 59085, @@ -77,6 +77,8 @@ enum eEnums STANCE_BATTLE = 2 }; +#define DATA_LIGHTNING_STRUCK 1834 + /*###### ## boss_bjarngrim ######*/ @@ -98,11 +100,14 @@ public: m_instance = creature->GetInstanceScript(); m_uiStance = STANCE_DEFENSIVE; memset(&m_auiStormforgedLieutenantGUID, 0, sizeof(m_auiStormforgedLieutenantGUID)); + canBuff = true; } InstanceScript* m_instance; bool m_bIsChangingStance; + bool achiLightningStruck; + bool canBuff; uint8 m_uiChargingStatus; uint8 m_uiStance; @@ -126,6 +131,11 @@ public: void Reset() { + if (canBuff) + if (!me->HasAura(SPELL_TEMPORARY_ELECTRICAL_CHARGE)) + me->AddAura(SPELL_TEMPORARY_ELECTRICAL_CHARGE, me); + + achiLightningStruck = false; m_bIsChangingStance = false; m_uiChargingStatus = 0; @@ -167,8 +177,21 @@ public: m_instance->SetData(TYPE_BJARNGRIM, NOT_STARTED); } + void EnterEvadeMode() + { + if (me->HasAura(SPELL_TEMPORARY_ELECTRICAL_CHARGE)) + canBuff = true; + else + canBuff = false; + + ScriptedAI::EnterEvadeMode(); + } + void EnterCombat(Unit* /*who*/) { + if (me->HasAura(SPELL_TEMPORARY_ELECTRICAL_CHARGE)) + achiLightningStruck = true; + DoScriptText(SAY_AGGRO, me); //must get both lieutenants here and make sure they are with him @@ -178,6 +201,14 @@ public: m_instance->SetData(TYPE_BJARNGRIM, IN_PROGRESS); } + uint32 GetData(uint32 type) + { + if (type == DATA_LIGHTNING_STRUCK) + return achiLightningStruck ? 1 : 0; + + return 0; + } + void KilledUnit(Unit* /*victim*/) { DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2, SAY_SLAY_3), me); @@ -211,7 +242,7 @@ public: void UpdateAI(const uint32 uiDiff) { //Return since we have no target - if (!UpdateVictim()) + if (!UpdateVictim()) return; // Change stance @@ -432,8 +463,27 @@ public: }; +class achievement_lightning_struck : public AchievementCriteriaScript +{ + public: + achievement_lightning_struck() : AchievementCriteriaScript("achievement_lightning_struck") { } + + bool OnCheck(Player* /*player*/, Unit* target) + { + if (!target) + return false; + + if (Creature* bjarngrim = target->ToCreature()) + if (bjarngrim->AI()->GetData(DATA_LIGHTNING_STRUCK)) + return true; + + return false; + } +}; + void AddSC_boss_bjarngrim() { new boss_bjarngrim(); new mob_stormforged_lieutenant(); + new achievement_lightning_struck(); } -- cgit v1.2.3 From c0bc5f6dcc44ba95bf0f75a7486e36b527462d1b Mon Sep 17 00:00:00 2001 From: Emo Norfik Date: Sun, 8 Jan 2012 17:22:31 +0100 Subject: Scripts/Halls of Lightning: Move criteria check for "Lightning Struck" achievement from criteria script to DB. Thx to Vincent-Michael for pointing this out. --- .../HallsOfLightning/02_boss_general_bjarngrim.sql | 5 ++++ .../Ulduar/HallsOfLightning/boss_bjarngrim.cpp | 34 ---------------------- 2 files changed, 5 insertions(+), 34 deletions(-) create mode 100644 sql/custom/Ulduar/HallsOfLightning/02_boss_general_bjarngrim.sql (limited to 'src/server/scripts/Northrend') diff --git a/sql/custom/Ulduar/HallsOfLightning/02_boss_general_bjarngrim.sql b/sql/custom/Ulduar/HallsOfLightning/02_boss_general_bjarngrim.sql new file mode 100644 index 00000000000..6cd1a367e81 --- /dev/null +++ b/sql/custom/Ulduar/HallsOfLightning/02_boss_general_bjarngrim.sql @@ -0,0 +1,5 @@ +-- Lightning Struck achievement move from criteria script to DB thx Vincent-Michael +DELETE FROM `achievement_criteria_data` WHERE `ScriptName`='achievement_lightning_struck'; +DELETE FROM `achievement_criteria_data` WHERE `type`=7 AND `criteria_id`=6835; +INSERT INTO `achievement_criteria_data` (`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES +(6835, 7, 52092, 0, ''); diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp index 0cf69eeb537..c6f72890d1f 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp @@ -77,8 +77,6 @@ enum eEnums STANCE_BATTLE = 2 }; -#define DATA_LIGHTNING_STRUCK 1834 - /*###### ## boss_bjarngrim ######*/ @@ -106,7 +104,6 @@ public: InstanceScript* m_instance; bool m_bIsChangingStance; - bool achiLightningStruck; bool canBuff; uint8 m_uiChargingStatus; @@ -135,7 +132,6 @@ public: if (!me->HasAura(SPELL_TEMPORARY_ELECTRICAL_CHARGE)) me->AddAura(SPELL_TEMPORARY_ELECTRICAL_CHARGE, me); - achiLightningStruck = false; m_bIsChangingStance = false; m_uiChargingStatus = 0; @@ -189,9 +185,6 @@ public: void EnterCombat(Unit* /*who*/) { - if (me->HasAura(SPELL_TEMPORARY_ELECTRICAL_CHARGE)) - achiLightningStruck = true; - DoScriptText(SAY_AGGRO, me); //must get both lieutenants here and make sure they are with him @@ -201,14 +194,6 @@ public: m_instance->SetData(TYPE_BJARNGRIM, IN_PROGRESS); } - uint32 GetData(uint32 type) - { - if (type == DATA_LIGHTNING_STRUCK) - return achiLightningStruck ? 1 : 0; - - return 0; - } - void KilledUnit(Unit* /*victim*/) { DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2, SAY_SLAY_3), me); @@ -463,27 +448,8 @@ public: }; -class achievement_lightning_struck : public AchievementCriteriaScript -{ - public: - achievement_lightning_struck() : AchievementCriteriaScript("achievement_lightning_struck") { } - - bool OnCheck(Player* /*player*/, Unit* target) - { - if (!target) - return false; - - if (Creature* bjarngrim = target->ToCreature()) - if (bjarngrim->AI()->GetData(DATA_LIGHTNING_STRUCK)) - return true; - - return false; - } -}; - void AddSC_boss_bjarngrim() { new boss_bjarngrim(); new mob_stormforged_lieutenant(); - new achievement_lightning_struck(); } -- cgit v1.2.3 From 6cb495048916a916804ebf8bde19e9619b12f897 Mon Sep 17 00:00:00 2001 From: Emo Norfik Date: Sun, 8 Jan 2012 23:07:31 +0000 Subject: Scripts/Utgarde Pinnacle: - Re-write Svala Sorrowgrave - Scripted achievement The Incredible Hulk. This script was writen basing on work and data: - Original TC script. - Albis fix for Arthas sounds and texts https://github.com/TrinityCore/TrinityCore/issues/4002 . - Ric event start fix. - Recorded encounters uploaded on YouTube. - Data found on ScriptDev2 forums. - Iov's custom SD2 repo and Svalas's script https://github.com/Iov/scriptdev2 . Also thx to: - ZxBiohazardZx for pointing how to fix looting problem when boss is killed when flying. - Aokromes for confirmig how many times event "Ritual of the Sword" is performed. - Mini event with Arthas. - Call Flames: timers of cast and time between "Ball of Flame" (48246) can be wrong (based on videos). - Ritual of the Sword works and is performed once at 50% hp but: a) Still need retail data for teleport position of Svala floating above player. b) Need fully fixed spell Ritual of the Sword (48276), the triggering of spell Ritual Strike - Trigger Missile (48331) part was hardcoded. - Spell Paralyze (48278) used by Ritual Channeler: fixed stacking and selection to ritual player only. - Achievement "The Incredible Hulk": works but often Scourge Hulk don't get initial dmg from spell Ritual Strike (spell 48277 Effect #1 Value: 6650 to 7350). - Looting problems when Svala was killed in air (require vmaps and option "vmap.enableHeight = 1" enabled in "worldserver.conf"). - Moved script_texts to creature_text. It require option "vmap.enableHeight = 1" to work properly. --- sql/updates/world/2011_01_08_16_world_misc.sql | 117 ++++ src/server/game/Spells/SpellMgr.cpp | 2 + .../UtgardeKeep/UtgardePinnacle/boss_svala.cpp | 775 ++++++++++++++------- .../UtgardePinnacle/instance_pinnacle.cpp | 9 +- .../UtgardeKeep/UtgardePinnacle/utgarde_pinnacle.h | 2 +- 5 files changed, 667 insertions(+), 238 deletions(-) create mode 100644 sql/updates/world/2011_01_08_16_world_misc.sql (limited to 'src/server/scripts/Northrend') diff --git a/sql/updates/world/2011_01_08_16_world_misc.sql b/sql/updates/world/2011_01_08_16_world_misc.sql new file mode 100644 index 00000000000..63cd81ff869 --- /dev/null +++ b/sql/updates/world/2011_01_08_16_world_misc.sql @@ -0,0 +1,117 @@ +/* Texts */ + +-- Move text used in Svala Sorrowgrave from script_texts to creature_text +-- Remove old script text for boss_svala.cpp +DELETE FROM `script_texts` WHERE `entry` BETWEEN -1575027 AND -1575015; + +DELETE FROM `creature_text` WHERE `entry` IN (26668,29281); +INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`language`,`probability`,`emote`,`duration`,`sound`,`comment`) VALUES +(26668,0,0, 'The sensation is... beyond my imagining. I am yours to command, my king.',14,0,0,0,0,13857, 'Svala Sorrowgrave SAY_DIALOG_WITH_ARTHAS_2'), +(26668,1,0, 'I will be happy to slaughter them in your name! Come, enemies of the Scourge! I will show you the might of the Lich King!',14,0,0,0,0,13858, 'Svala Sorrowgrave SAY_DIALOG_WITH_ARTHAS_3'), +(26668,2,0, 'I will vanquish your soul!',14,0,0,0,0,13842, 'Svala Sorrowgrave SAY_AGGRO'), +(26668,3,0, 'You were a fool to challenge the power of the Lich King!',14,0,0,0,0,13845, 'Svala Sorrowgrave SAY_SLAY_1'), +(26668,3,1, 'Your will is done, my king.',14,0,0,0,0,13847, 'Svala Sorrowgrave SAY_SLAY_2'), +(26668,3,2, 'Another soul for my master.',14,0,0,0,0,13848, 'Svala Sorrowgrave SAY_SLAY_3'), +(26668,4,0, 'Nooo! I did not come this far... to...',14,0,0,0,0,13855, 'Svala Sorrowgrave SAY_DEATH'), +(26668,5,0, 'Your death approaches.',14,0,0,0,0,13850, 'Svala Sorrowgrave SAY_SACRIFICE_1'), +(26668,5,1, 'Go now to my master.',14,0,0,0,0,13851, 'Svala Sorrowgrave SAY_SACRIFICE_2'), +(26668,5,2, 'Your end is inevitable.',14,0,0,0,0,13852, 'Svala Sorrowgrave SAY_SACRIFICE_3'), +(26668,5,3, 'Yor-guul mak!',14,0,0,0,0,13853, 'Svala Sorrowgrave SAY_SACRIFICE_4'), +(26668,5,4, 'Any last words?',14,0,0,0,0,13854, 'Svala Sorrowgrave SAY_SACRIFICE_5'), +(29281,0,0, 'My liege! I have done as you asked, and now beseech you for your blessing!',14,0,0,0,0,13856, 'Svala SAY_DIALOG_WITH_ARTHAS_1'); + +/* Templates */ + +UPDATE `creature_template` SET `unit_flags`=2 WHERE `entry` IN (29281, 30809); -- And this, fixes her flag so script can be started (credit to ric) +UPDATE `creature` SET `spawntimesecs`=86400 WHERE `id`=29281; -- Set Svala's spawn time +UPDATE `creature_template` SET `flags_extra`=`flags_extra`|1 WHERE `entry`=30809; -- Set flags_extra = 1 for Svala hero difficulty +UPDATE `creature_template` SET `InhabitType`=7, `flags_extra`=`flags_extra`|130 WHERE `entry`=30805; -- Set same data on heroic ver to triggers +UPDATE `creature_template` SET `InhabitType`=7, `flags_extra`=`flags_extra`|128 WHERE `entry`=30771; -- Set same data on heroic ver to triggers + +UPDATE `creature_template` SET `mechanic_immune_mask`=`mechanic_immune_mask` +|1 -- CHARM +|2 -- DISORIENTED +|4 -- DISARM +|8 -- DISTRACT +|16 -- FEAR +|32 -- GRIP +|64 -- ROOT +|128 -- PACIFY +|256 -- SILENCE +|512 -- SLEEP +|1024 -- SNARE +|2048 -- STUN +|4096 -- FREEZE +|8192 -- KNOCKOUT +|65536 -- POLYMORPH +|131072 -- BANISH +|524288 -- SHACKLE +|4194304 -- TURN +|8388608 -- HORROR +|67108864 -- DAZE +|536870912 -- SAPPED +WHERE `entry` IN (29281, 30809, 26668, 30810); + +-- Apply Image of Arthas Visual Effect +DELETE FROM `creature_template_addon` WHERE `entry`=29280; +INSERT INTO `creature_template_addon` (`entry`, `path_id`, `mount`, `bytes1`, `bytes2`, `emote`, `auras`) VALUES +(29280, 0, 0, 0, 1, 0, '54134'); + +-- Flame Brazier triggers deletion (will spawn them after activating event 17841 called by spell Call Flames 48258) +DELETE FROM `creature` WHERE `id`=27273 AND `map`=575; +DELETE FROM `creature_addon` WHERE `guid` IN (126121, 126122); + +/* Spells */ + +DELETE FROM `spell_target_position` WHERE `id` IN (48267,48276, 48271, 48274, 48275); +INSERT INTO `spell_target_position` (`id`, `target_map`, `target_position_x`, `target_position_y`, `target_position_z`, `target_orientation`) VALUES +(48267, 575, 296.632, -346.075, 90.5474, 4.60767), -- Svala Ritual - Player teleport position +(48276, 575, 296.651, -346.293, 108.5474, 1.58), -- Svala Ritual - Svala teleport position +(48271, 575, 296.42, -355.01, 90.94, 1.58), -- Summon Ritual Channeler positions +(48274, 575, 302.36, -352.01, 90.54, 2.20), -- Summon Ritual Channeler positions +(48275, 575, 291.39, -352.01, 90.54, 0.91); -- Summon Ritual Channeler positions + +DELETE FROM `conditions` WHERE `SourceEntry` IN (48331,48246,48277) AND `SourceTypeOrReferenceId`=13; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(13, 0, 48331, 0, 18, 1, 27327, 0, 0, '', NULL), -- Spell script target for flying sword +(13, 0, 48246, 0, 18, 1, 0, 0, 0, '', NULL), -- Spell script target for Flame Brazier's (on players only) +(13, 0, 48277, 0, 18, 1, 26555, 0, 0, '', NULL), -- Spell script target for Ritual Strike DMG -- Players +(13, 0, 48277, 0, 18, 1, 27327, 0, 0, '', NULL); -- Spell script target for Ritual Strike DMG -- Ritual Target + +/* Achivements */ + +-- The Incredible Hulk achievement 2043 +DELETE FROM `disables` WHERE `sourceType`=4 AND `entry`=7322; +DELETE FROM `achievement_criteria_data` WHERE `criteria_id`=7322 AND `type`=11; +INSERT INTO `achievement_criteria_data` (`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES +(7322, 11, 0, 0, 'achievement_incredible_hulk'); + +/* AI */ + +DELETE FROM `creature_ai_scripts` WHERE `creature_id`=26555; -- Scourge Hulk +UPDATE `creature_template` SET `AIName`='SmartAI' WHERE `entry`=27273; -- Flame Brazier + +-- Add Send Script Event (17841) summon 3 triggers +DELETE FROM `event_scripts` WHERE `id`=17841; +INSERT INTO `event_scripts` (`id`, `delay`, `command`, `datalong`, `datalong2`, `dataint`, `x`, `y`, `z`, `o`) VALUES +(17841, 0, 10, 27273, 10000, 0, 285.6, -357.5, 91.0833, 5.75959), +(17841, 3, 10, 27273, 10000, 0, 307, -357.5, 91.0833, 6.02139), +(17841, 6, 10, 27273, 10000, 0, 285.6, -357.5, 91.0833, 5.75959); + +-- SmartAI script Flame Brazier's cast Ball of Flame (48246) on random player +DELETE FROM `smart_scripts` WHERE `entryorguid`=27273 AND `source_type`=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`, `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 +(27273, 0, 0, 0, 1, 0, 100, 1, 100, 100, 100, 100, 11, 48246, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Flame Brazier - Ball of Flame'); + +/* Script names */ + +UPDATE `creature_template` SET `AIName`='', `ScriptName`='npc_scourge_hulk' WHERE `entry`=26555; +UPDATE `creature_template` SET `ScriptName`='' WHERE `entry`=26668; -- "boss_svala_sorrowgrave" script is now merged with "boss_svala" script +UPDATE `creature_template` SET `ScriptName`='npc_spectator' WHERE `entry`=26667; -- Spectators escape script +UPDATE `creature_template` SET `ScriptName`='npc_ritual_channeler' WHERE `entry`=27281; -- Change 'mob_ritual_channeler' to 'npc_ritual_channeler' + +-- Paralyze -- Filter targets -- cast only on sacrafacing target +DELETE FROM `spell_script_names` WHERE `spell_id`=48278; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(48278, 'spell_paralyze_pinnacle'); + diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index e57cbf4a390..f3d5697c672 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3041,6 +3041,7 @@ void SpellMgr::LoadDbcDataCorrections() case 42611: // Shoot case 61588: // Blazing Harpoon case 52479: // Gift of the Harvester + case 48246: // Ball of Flame spellInfo->MaxAffectedTargets = 1; break; case 41376: // Spite @@ -3383,6 +3384,7 @@ void SpellMgr::LoadDbcDataCorrections() spellInfo->AreaGroupId = 0; // originally, these require area 4522, which is... outside of Icecrown Citadel break; case 70602: // Corruption + case 48278: // Paralyze spellInfo->AttributesEx3 |= SPELL_ATTR3_STACK_FOR_DIFF_CASTERS; break; case 70715: // Column of Frost (visual marker) diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp index 01cd36266d0..7280c3d5b82 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp @@ -20,66 +20,93 @@ enum Spells { - SPELL_CALL_FLAMES = 48258, - SPELL_RITUAL_OF_THE_SWORD = 48276, //Effect #1 Teleport, Effect #2 Dummy + SPELL_SVALA_TRANSFORMING1 = 54140, + SPELL_SVALA_TRANSFORMING2 = 54205, + SPELL_TRANSFORMING_CHANNEL = 54142, + + SPELL_CALL_FLAMES = 48258, // caster effect only, triggers event 17841 SPELL_SINSTER_STRIKE = 15667, H_SPELL_SINSTER_STRIKE = 59409, - SPELL_SVALA_TRANSFORMING1 = 54140, - SPELL_SVALA_TRANSFORMING2 = 54205 + + SPELL_RITUAL_PREPARATION = 48267, + SPELL_RITUAL_OF_THE_SWORD = 48276, + SPELL_RITUAL_STRIKE_TRIGGER = 48331, // triggers 48277 & 59930, needs NPC_RITUAL_TARGET as spell_script_target + SPELL_RITUAL_DISARM = 54159, + SPELL_RITUAL_STRIKE_EFF_1 = 48277, + SPELL_RITUAL_STRIKE_EFF_2 = 59930, + + SPELL_SUMMONED_VIS = 64446, + SPELL_RITUAL_CHANNELER_1 = 48271, + SPELL_RITUAL_CHANNELER_2 = 48274, + SPELL_RITUAL_CHANNELER_3 = 48275, + + // Ritual Channeler spells + SPELL_PARALYZE = 48278, + SPELL_SHADOWS_IN_THE_DARK = 59407, + + // Scourge Hulk spells + SPELL_MIGHTY_BLOW = 48697, + SPELL_VOLATILE_INFECTION = 56785, + H_SPELL_VOLATILE_INFECTION = 59228 }; -//not in db + enum Yells { - SAY_DIALOG_WITH_ARTHAS_1 = -1575015, - SAY_DIALOG_WITH_ARTHAS_2 = -1575016, - SAY_DIALOG_WITH_ARTHAS_3 = -1575017, - SAY_AGGRO = -1575018, - SAY_SLAY_1 = -1575019, - SAY_SLAY_2 = -1575020, - SAY_SLAY_3 = -1575021, - SAY_DEATH = -1575022, - SAY_SACRIFICE_PLAYER_1 = -1575023, - SAY_SACRIFICE_PLAYER_2 = -1575024, - SAY_SACRIFICE_PLAYER_3 = -1575025, - SAY_SACRIFICE_PLAYER_4 = -1575026, - SAY_SACRIFICE_PLAYER_5 = -1575027, - SAY_DIALOG_OF_ARTHAS_1 = -1575028, - SAY_DIALOG_OF_ARTHAS_2 = -1575029 + // Svala + SAY_SVALA_INTRO_0 = 0, + + // Svala Sorrowgrave + SAY_SVALA_INTRO_1 = 0, + SAY_SVALA_INTRO_2 = 1, + SAY_AGGRO = 2, + SAY_SLAY = 3, + SAY_DEATH = 4, + SAY_SACRIFICE_PLAYER = 5, + + // Image of Arthas + SAY_DIALOG_OF_ARTHAS_1 = 0, + SAY_DIALOG_OF_ARTHAS_2 = 1 }; + enum Creatures { CREATURE_ARTHAS = 29280, // Image of Arthas CREATURE_SVALA_SORROWGRAVE = 26668, // Svala after transformation CREATURE_SVALA = 29281, // Svala before transformation - CREATURE_RITUAL_CHANNELER = 27281 + CREATURE_RITUAL_CHANNELER = 27281, + CREATURE_SPECTATOR = 26667, + CREATURE_RITUAL_TARGET = 27327, + CREATURE_FLAME_BRAZIER = 27273, + CREATURE_SCOURGE_HULK = 26555 }; -enum ChannelerSpells -{ - //ritual channeler's spells - SPELL_PARALYZE = 48278, - SPELL_SHADOWS_IN_THE_DARK = 59407 -}; -enum Misc + +enum Objects { - DATA_SVALA_DISPLAY_ID = 25944 + OBJECT_UTGARDE_MIRROR = 191745 }; -enum IntroPhase + +enum SvalaPhase { IDLE, INTRO, - FINISHED + NORMAL, + SACRIFICING, + SVALADEAD }; -enum CombatPhase + +#define DATA_INCREDIBLE_HULK 2043 + +static const float spectatorWP[2][3] = { - NORMAL, - SACRIFICING + {296.95f,-312.76f,86.36f}, + {297.69f,-275.81f,86.36f} }; static Position RitualChannelerPos[]= { - {296.42f, -355.01f, 90.94f, 0.0f}, - {302.36f, -352.01f, 90.54f, 0.0f}, - {291.39f, -350.89f, 90.54f, 0.0f} + {296.42f, -355.01f, 90.94f, 1.58f}, + {302.36f, -352.01f, 90.54f, 2.20f}, + {291.39f, -352.01f, 90.54f, 0.91f} }; static Position ArthasPos = { 295.81f, -366.16f, 92.57f, 1.58f }; static Position SvalaPos = { 296.632f, -346.075f, 90.6307f, 1.58f }; @@ -96,31 +123,96 @@ public: struct boss_svalaAI : public ScriptedAI { - boss_svalaAI(Creature* c) : ScriptedAI(c) + boss_svalaAI(Creature* creature) : ScriptedAI(creature), summons(creature) { - instance = c->GetInstanceScript(); + instance = creature->GetInstanceScript(); + Phase = IDLE; + + me->ApplySpellImmune(0, IMMUNITY_ID, SPELL_RITUAL_STRIKE_EFF_1, true); + me->ApplySpellImmune(0, IMMUNITY_ID, SPELL_RITUAL_STRIKE_EFF_2, true); } - uint32 uiIntroTimer; + InstanceScript* instance; + SummonList summons; + SvalaPhase Phase; + + Position pos; + float x, y, z; - uint8 uiIntroPhase; + uint32 introTimer; + uint8 introPhase; + uint8 sacrePhase; - IntroPhase Phase; + TempSummon* arthas; + uint64 arthasGUID; - TempSummon* pArthas; - uint64 uiArthasGUID; + uint32 sinsterStrikeTimer; + uint32 callFlamesTimer; + uint32 sacrificeTimer; - InstanceScript* instance; + bool sacrificed; void Reset() { - Phase = IDLE; - uiIntroTimer = 1 * IN_MILLISECONDS; - uiIntroPhase = 0; - uiArthasGUID = 0; + sacrificed = false; + SetCombatMovement(true); + + summons.DespawnAll(); + me->RemoveAllAuras(); + + if (Phase > INTRO) + { + me->SetFlying(true); + me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + } + + if (Phase > NORMAL) + Phase = NORMAL; + + introTimer = 1 * IN_MILLISECONDS; + introPhase = 0; + arthasGUID = 0; if (instance) + { instance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, NOT_STARTED); + instance->SetData64(DATA_SACRIFICED_PLAYER, 0); + } + } + + void JustReachedHome() + { + if (Phase > INTRO) + { + me->SetFlying(false); + me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + me->SetOrientation(1.58f); + me->SendMovementFlagUpdate(); + } + } + + void EnterCombat(Unit* /*who*/) + { + Talk(SAY_AGGRO); + + sinsterStrikeTimer = 7 * IN_MILLISECONDS; + callFlamesTimer = urand(10 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + + if (instance) + instance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, IN_PROGRESS); + } + + void JustSummoned(Creature* summon) + { + if (summon->GetEntry() == CREATURE_RITUAL_CHANNELER) + summon->CastSpell(summon, SPELL_SUMMONED_VIS, true); + + summons.Summon(summon); + } + + void SummonedCreatureDespawn(Creature* summon) + { + summons.Despawn(summon); } void MoveInLineOfSight(Unit* who) @@ -132,287 +224,500 @@ public: { Phase = INTRO; me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + if (GameObject* mirror = GetClosestGameObjectWithEntry(me, OBJECT_UTGARDE_MIRROR, 100.0f)) + mirror->SetGoState(GO_STATE_READY); - if (Creature* pArthas = me->SummonCreature(CREATURE_ARTHAS, ArthasPos, TEMPSUMMON_MANUAL_DESPAWN)) + if (Creature* arthas = me->SummonCreature(CREATURE_ARTHAS, ArthasPos, TEMPSUMMON_MANUAL_DESPAWN)) { - pArthas->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - uiArthasGUID = pArthas->GetGUID(); + arthas->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + arthasGUID = arthas->GetGUID(); } } } + + void KilledUnit(Unit* victim) + { + if (victim != me) + Talk(SAY_SLAY); + } + + void DamageTaken(Unit* attacker, uint32 &damage) + { + if (Phase == SVALADEAD) + { + if (attacker != me) + damage = 0; + return; + } - void AttackStart(Unit* /*who*/) {} + if (damage >= me->GetHealth()) + { + if (Phase == SACRIFICING) + SetEquipmentSlots(false, EQUIP_UNEQUIP, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); + + me->GetPosition(x, y, z); + z = me->GetMap()->GetHeight(x, y, z, true, 50); + + if (me->GetPositionZ() > z) + { + damage = 0; + Phase = SVALADEAD; + me->InterruptNonMeleeSpells(true); + me->RemoveAllAuras(); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetHealth(1); + + SetCombatMovement(false); + me->HandleEmoteCommand(EMOTE_ONESHOT_FLYDEATH); + me->GetMotionMaster()->MoveFall(z, 1); + } + } + } + + void MovementInform(uint32 motionType, uint32 pointId) + { + if (motionType != POINT_MOTION_TYPE) + return; + + if (pointId == 1) + { + me->Relocate(x, y, z, me->GetOrientation()); + me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + } + + void JustDied(Unit* killer) + { + summons.DespawnAll(); + + if (instance) + instance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, DONE); + + Talk(SAY_DEATH); + } + + void SpellHitTarget(Unit* target, const SpellInfo* spell) + { + if (spell->Id == SPELL_RITUAL_STRIKE_EFF_1 && Phase != NORMAL && Phase != SVALADEAD) + { + Phase = NORMAL; + SetCombatMovement(true); + + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 300, true)) + me->GetMotionMaster()->MoveChase(target); + } + } void UpdateAI(const uint32 diff) { - if (Phase != INTRO) + if (Phase == IDLE) + return; + + if (Phase == INTRO) + { + if (introTimer <= diff) + { + Creature* arthas = Unit::GetCreature(*me, arthasGUID); + if (!arthas) + return; + + switch (introPhase) + { + case 0: + Talk(SAY_SVALA_INTRO_0); + ++introPhase; + introTimer = 8100; + break; + case 1: + arthas->AI()->Talk(SAY_DIALOG_OF_ARTHAS_1); + ++introPhase; + introTimer = 10000; + break; + case 2: + arthas->CastSpell(me, SPELL_TRANSFORMING_CHANNEL, false); + me->SetFlying(true); + me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + pos.Relocate(me); + pos.m_positionZ += 8.0f; + me->GetMotionMaster()->MoveTakeoff(0, pos, 3.30078125f); + // spectators flee event + if (instance) + { + std::list lspectatorList; + GetCreatureListWithEntryInGrid(lspectatorList, me, CREATURE_SPECTATOR, 100.0f); + for(std::list::iterator itr = lspectatorList.begin(); itr != lspectatorList.end(); ++itr) + { + if ((*itr)->isAlive()) + { + (*itr)->SetStandState(UNIT_STAND_STATE_STAND); + (*itr)->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); + (*itr)->GetMotionMaster()->MovePoint(1, spectatorWP[0][0], spectatorWP[0][1], spectatorWP[0][2]); + } + } + } + ++introPhase; + introTimer = 4200; + break; + case 3: + me->CastSpell(me, SPELL_SVALA_TRANSFORMING1, false); + ++introPhase; + introTimer = 6200; + break; + case 4: + me->CastSpell(me, SPELL_SVALA_TRANSFORMING2, false); + arthas->InterruptNonMeleeSpells(true); + me->RemoveAllAuras(); + me->UpdateEntry(CREATURE_SVALA_SORROWGRAVE); + me->SetFacingToObject(arthas); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + ++introPhase; + introTimer = 3200; + break; + case 5: + Talk(SAY_SVALA_INTRO_1); + ++introPhase; + introTimer = 10000; + break; + case 6: + arthas->AI()->Talk(SAY_DIALOG_OF_ARTHAS_2); + ++introPhase; + introTimer = 7200; + break; + case 7: + Talk(SAY_SVALA_INTRO_2); + me->SetOrientation(1.58f); + me->SendMovementFlagUpdate(); + arthas->SetVisible(false); + ++introPhase; + introTimer = 13800; + break; + case 8: + me->SetFlying(false); + me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + me->SendMovementFlagUpdate(); + pos.Relocate(me); + pos.m_positionX = me->GetHomePosition().GetPositionX(); + pos.m_positionY = me->GetHomePosition().GetPositionY(); + pos.m_positionZ = 90.6065f; + me->GetMotionMaster()->MoveLand(0, pos, 6.247422f); + ++introPhase; + introTimer = 3000; + break; + case 9: + if (GameObject* mirror = GetClosestGameObjectWithEntry(me, OBJECT_UTGARDE_MIRROR, 100.0f)) + mirror->SetGoState(GO_STATE_ACTIVE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + arthas->DespawnOrUnsummon(); + arthasGUID = 0; + Phase = NORMAL; + break; + } + } else introTimer -= diff; + return; + } - if (uiIntroTimer <= diff) + if (Phase == NORMAL) { - Creature* pArthas = Unit::GetCreature(*me, uiArthasGUID); - if (!pArthas) + //Return since we have no target + if (!UpdateVictim()) return; - switch (uiIntroPhase) + if (me->IsWithinMeleeRange(me->getVictim()) && me->HasUnitMovementFlag(MOVEMENTFLAG_LEVITATING)) { - case 0: - DoScriptText(SAY_DIALOG_WITH_ARTHAS_1, me); - ++uiIntroPhase; - uiIntroTimer = 3500; - break; - case 1: - DoScriptText(SAY_DIALOG_OF_ARTHAS_1, pArthas); - ++uiIntroPhase; - uiIntroTimer = 3500; - break; - case 2: - DoScriptText(SAY_DIALOG_WITH_ARTHAS_2, me); - ++uiIntroPhase; - uiIntroTimer = 3500; - break; - case 3: - DoScriptText(SAY_DIALOG_OF_ARTHAS_2, pArthas); - ++uiIntroPhase; - uiIntroTimer = 3500; - break; - case 4: - DoScriptText(SAY_DIALOG_WITH_ARTHAS_3, me); - DoCast(me, SPELL_SVALA_TRANSFORMING1); - ++uiIntroPhase; - uiIntroTimer = 2800; - break; - case 5: - DoCast(me, SPELL_SVALA_TRANSFORMING2); - ++uiIntroPhase; - uiIntroTimer = 200; - break; - case 6: - if (me->SummonCreature(CREATURE_SVALA_SORROWGRAVE, SvalaPos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60*IN_MILLISECONDS)) + me->SetFlying(false); + me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + me->SendMovementFlagUpdate(); + } + + if (sinsterStrikeTimer <= diff) + { + DoCast(me->getVictim(), SPELL_SINSTER_STRIKE); + sinsterStrikeTimer = urand(5 * IN_MILLISECONDS, 9 * IN_MILLISECONDS); + } else sinsterStrikeTimer -= diff; + + if (callFlamesTimer <= diff) + { + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) + { + DoCast(target, SPELL_CALL_FLAMES); + callFlamesTimer = urand(10 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + } + } else callFlamesTimer -= diff; + + if (!sacrificed) + { + if (HealthBelowPct(50)) + { + if (Unit* sacrificeTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 80, true)) { - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetDisplayId(DATA_SVALA_DISPLAY_ID); - pArthas->DespawnOrUnsummon(); - uiArthasGUID = 0; - Phase = FINISHED; + if (instance) + instance->SetData64(DATA_SACRIFICED_PLAYER, sacrificeTarget->GetGUID()); + + Talk(SAY_SACRIFICE_PLAYER); + + DoCast(sacrificeTarget, SPELL_RITUAL_PREPARATION); + + SetCombatMovement(false); + me->SetFlying(true); + me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + + Phase = SACRIFICING; + sacrePhase = 0; + sacrificeTimer = 1 * IN_MILLISECONDS; + + DoCast(me, SPELL_RITUAL_OF_THE_SWORD); + sacrificed = true; } - else - Reset(); - break; + } } - } else uiIntroTimer -= diff; + + DoMeleeAttackIfReady(); + } + else //SACRIFICING + { + if (sacrificeTimer <= diff) + { + switch (sacrePhase) + { + case 0: + // spawn ritual channelers + if (instance) + { + DoCast(me, SPELL_RITUAL_CHANNELER_1, true); + DoCast(me, SPELL_RITUAL_CHANNELER_2, true); + DoCast(me, SPELL_RITUAL_CHANNELER_3, true); + } + ++sacrePhase; + sacrificeTimer = 2 * IN_MILLISECONDS; + break; + case 1: + me->StopMoving(); + me->GetMotionMaster()->MoveIdle(); + me->InterruptNonMeleeSpells(true); + DoCast(me, SPELL_RITUAL_STRIKE_TRIGGER, true); + ++sacrePhase; + sacrificeTimer = 200; + break; + case 2: + DoCast(me, SPELL_RITUAL_DISARM); + ++sacrePhase; + break; + case 3: + break; + } + } + else sacrificeTimer -= diff; + } } }; }; -class mob_ritual_channeler : public CreatureScript +class npc_ritual_channeler : public CreatureScript { public: - mob_ritual_channeler() : CreatureScript("mob_ritual_channeler") { } + npc_ritual_channeler() : CreatureScript("npc_ritual_channeler") { } CreatureAI* GetAI(Creature* creature) const { - return new mob_ritual_channelerAI(creature); + return new npc_ritual_channelerAI(creature); } - struct mob_ritual_channelerAI : public Scripted_NoMovementAI + struct npc_ritual_channelerAI : public Scripted_NoMovementAI { - mob_ritual_channelerAI(Creature* c) :Scripted_NoMovementAI(c) + npc_ritual_channelerAI(Creature* c) :Scripted_NoMovementAI(c) { instance = c->GetInstanceScript(); } InstanceScript* instance; + uint32 paralyzeTimer; void Reset() { - DoCast(me, SPELL_SHADOWS_IN_THE_DARK); - } - - // called by svala sorrowgrave to set guid of victim - void DoAction(const int32 /*action*/) - { + paralyzeTimer = 1600; if (instance) - if (Unit* victim = me->GetUnit(*me, instance->GetData64(DATA_SACRIFICED_PLAYER))) - DoCast(victim, SPELL_PARALYZE); + if (IsHeroic()) + DoCast(me, SPELL_SHADOWS_IN_THE_DARK); } - - void EnterCombat(Unit* /*who*/) + + void UpdateAI(const uint32 diff) { + if (me->HasUnitState(UNIT_STAT_CASTING)) + return; + + if (paralyzeTimer <= diff) + { + if (instance) + if (Unit* victim = me->GetUnit(*me, instance->GetData64(DATA_SACRIFICED_PLAYER))) + DoCast(victim, SPELL_PARALYZE, false); + + paralyzeTimer = 200; + } + else + paralyzeTimer -= diff; } }; - }; -class boss_svala_sorrowgrave : public CreatureScript +class npc_spectator : public CreatureScript { public: - boss_svala_sorrowgrave() : CreatureScript("boss_svala_sorrowgrave") { } + npc_spectator() : CreatureScript("npc_spectator") { } CreatureAI* GetAI(Creature* creature) const { - return new boss_svala_sorrowgraveAI(creature); + return new npc_spectatorAI(creature); } - struct boss_svala_sorrowgraveAI : public ScriptedAI + struct npc_spectatorAI : public ScriptedAI { - boss_svala_sorrowgraveAI(Creature* c) : ScriptedAI(c), summons(c) + npc_spectatorAI(Creature* c) : ScriptedAI(c) { } + + void Reset() { } + + void MovementInform(uint32 motionType, uint32 pointId) { - instance = c->GetInstanceScript(); + if (motionType == POINT_MOTION_TYPE) + { + if (pointId == 1) + me->GetMotionMaster()->MovePoint(2,spectatorWP[1][0],spectatorWP[1][1],spectatorWP[1][2]); + else if (pointId == 2) + me->DespawnOrUnsummon(1000); + } } + }; +}; - uint32 uiSinsterStrikeTimer; - uint32 uiCallFlamesTimer; - uint32 uiRitualOfSwordTimer; - uint32 uiSacrificeTimer; +class checkRitualTarget +{ + public: + explicit checkRitualTarget(Unit* _caster) : caster(_caster) { } - CombatPhase Phase; + bool operator() (Unit* unit) + { + if (InstanceScript* instance = caster->GetInstanceScript()) + if (instance->GetData64(DATA_SACRIFICED_PLAYER) == unit->GetGUID()) + return false; - SummonList summons; + return true; + } - bool bSacrificed; + private: + Unit* caster; +}; - InstanceScript* instance; +class spell_paralyze_pinnacle : public SpellScriptLoader +{ + public: + spell_paralyze_pinnacle() : SpellScriptLoader("spell_paralyze_pinnacle") { } - void Reset() + class spell_paralyze_pinnacle_SpellScript : public SpellScript { - uiSinsterStrikeTimer = 7 * IN_MILLISECONDS; - uiCallFlamesTimer = 10 * IN_MILLISECONDS; - uiRitualOfSwordTimer = 20 * IN_MILLISECONDS; - uiSacrificeTimer = 8 * IN_MILLISECONDS; - - bSacrificed = false; - - Phase = NORMAL; - - DoTeleportTo(296.632f, -346.075f, 90.6307f); - me->SetUnitMovementFlags(MOVEMENTFLAG_WALKING); + PrepareSpellScript(spell_paralyze_pinnacle_SpellScript); - summons.DespawnAll(); + void FilterTargets(std::list& unitList) + { + unitList.remove_if(checkRitualTarget(GetCaster())); + } - if (instance) + void Register() { - instance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, NOT_STARTED); - instance->SetData64(DATA_SACRIFICED_PLAYER, 0); + OnUnitTargetSelect += SpellUnitTargetFn(spell_paralyze_pinnacle_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); } - } + }; - void EnterCombat(Unit* /*who*/) + SpellScript* GetSpellScript() const { - DoScriptText(SAY_AGGRO, me); - - if (instance) - instance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, IN_PROGRESS); + return new spell_paralyze_pinnacle_SpellScript(); } +}; - void JustSummoned(Creature* summon) - { - summons.Summon(summon); - } +class npc_scourge_hulk : public CreatureScript +{ + public: + npc_scourge_hulk() : CreatureScript("npc_scourge_hulk") { } - void SummonedCreatureDespawn(Creature* summon) + struct npc_scourge_hulkAI : public ScriptedAI { - summons.Despawn(summon); - } + npc_scourge_hulkAI(Creature* creature) : ScriptedAI(creature) { } - void UpdateAI(const uint32 diff) - { - if (Phase == NORMAL) + uint32 mightyBlow; + uint32 volatileInfection; + + void Reset() + { + mightyBlow = urand(4000, 9000); + volatileInfection = urand(10000, 14000); + killedByRitualStrike = false; + } + + uint32 GetData(uint32 type) + { + return type == DATA_INCREDIBLE_HULK ? killedByRitualStrike : 0; + } + + void DamageTaken(Unit* attacker, uint32 &damage) + { + if (damage >= me->GetHealth() && attacker->GetEntry() == CREATURE_SVALA_SORROWGRAVE) + killedByRitualStrike = true; + } + + void UpdateAI(uint32 const diff) { - //Return since we have no target if (!UpdateVictim()) return; - if (uiSinsterStrikeTimer <= diff) - { - DoCast(me->getVictim(), SPELL_SINSTER_STRIKE); - uiSinsterStrikeTimer = urand(5 * IN_MILLISECONDS, 9 * IN_MILLISECONDS); - } else uiSinsterStrikeTimer -= diff; - - if (uiCallFlamesTimer <= diff) + if (mightyBlow <= diff) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - { - DoCast(target, SPELL_CALL_FLAMES); - uiCallFlamesTimer = urand(8 * IN_MILLISECONDS, 12 * IN_MILLISECONDS); - } - } else uiCallFlamesTimer -= diff; + if (Unit* victim = me->getVictim()) + if (!victim->HasUnitState(UNIT_STAT_STUNNED)) // Prevent knocking back a ritual player + DoCast(victim, SPELL_MIGHTY_BLOW); + mightyBlow = urand(12000, 17000); + } + else + mightyBlow -= diff; - if (!bSacrificed) + if (volatileInfection <= diff) { - if (uiRitualOfSwordTimer <= diff) - { - if (Unit* pSacrificeTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - { - DoScriptText(RAND(SAY_SACRIFICE_PLAYER_1, SAY_SACRIFICE_PLAYER_2, SAY_SACRIFICE_PLAYER_3, SAY_SACRIFICE_PLAYER_4, SAY_SACRIFICE_PLAYER_5), me); - DoCast(pSacrificeTarget, SPELL_RITUAL_OF_THE_SWORD); - //Spell doesn't teleport - DoTeleportPlayer(pSacrificeTarget, 296.632f, -346.075f, 90.63f, 4.6f); - me->SetUnitMovementFlags(MOVEMENTFLAG_CAN_FLY); - DoTeleportTo(296.632f, -346.075f, 120.85f); - Phase = SACRIFICING; - if (instance) - { - instance->SetData64(DATA_SACRIFICED_PLAYER, pSacrificeTarget->GetGUID()); - - for (uint8 i = 0; i < 3; ++i) - if (Creature* summon = me->SummonCreature(CREATURE_RITUAL_CHANNELER, RitualChannelerPos[i], TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000)) - summon->AI()->DoAction(0); - } - - bSacrificed = true; - } - } else uiRitualOfSwordTimer -= diff; + DoCastVictim(SPELL_VOLATILE_INFECTION); + volatileInfection = urand(13000, 17000); } + else + volatileInfection -= diff; DoMeleeAttackIfReady(); } - else //SACRIFICING - { - if (uiSacrificeTimer <= diff) - { - Unit* pSacrificeTarget = instance ? Unit::GetUnit(*me, instance->GetData64(DATA_SACRIFICED_PLAYER)) : NULL; - if (instance && !summons.empty() && pSacrificeTarget && pSacrificeTarget->isAlive()) - me->Kill(pSacrificeTarget, false); // durability damage? - - //go down - Phase = NORMAL; - pSacrificeTarget = NULL; - me->SetUnitMovementFlags(MOVEMENTFLAG_WALKING); - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - me->GetMotionMaster()->MoveChase(target); - uiSacrificeTimer = 8 * IN_MILLISECONDS; - } - else uiSacrificeTimer -= diff; - } - } + private: + bool killedByRitualStrike; + }; - void KilledUnit(Unit* /*victim*/) + CreatureAI* GetAI(Creature* creature) const { - DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2, SAY_SLAY_3), me); + return new npc_scourge_hulkAI(creature); } +}; - void JustDied(Unit* killer) - { - if (instance) - { - Creature* pSvala = Unit::GetCreature((*me), instance->GetData64(DATA_SVALA)); - if (pSvala && pSvala->isAlive()) - killer->Kill(pSvala); +class achievement_incredible_hulk : public AchievementCriteriaScript +{ + public: + achievement_incredible_hulk() : AchievementCriteriaScript("achievement_incredible_hulk") { } - instance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, DONE); - } - DoScriptText(SAY_DEATH, me); + bool OnCheck(Player* /*player*/, Unit* target) + { + return target && target->IsAIEnabled && target->GetAI()->GetData(DATA_INCREDIBLE_HULK); } - }; - }; void AddSC_boss_svala() { new boss_svala(); - new mob_ritual_channeler(); - new boss_svala_sorrowgrave(); + new npc_ritual_channeler(); + new npc_spectator(); + new spell_paralyze_pinnacle(); + new npc_scourge_hulk(); + new achievement_incredible_hulk(); } diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp index c5bc235da1f..cb596f284c5 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp @@ -170,8 +170,12 @@ public: void SetData64(uint32 type, uint64 data) { - if (type == DATA_SACRIFICED_PLAYER) - uiSacrificedPlayer = data; + switch (type) + { + case DATA_SACRIFICED_PLAYER: + uiSacrificedPlayer = data; + break; + } } uint32 GetData(uint32 type) @@ -201,6 +205,7 @@ public: case DATA_MOB_ORB: return uiPalehoofOrb; case DATA_SVALA: return uiSvala; case DATA_GORTOK_PALEHOOF_SPHERE: return uiGortokPalehoofSphere; + case DATA_SACRIFICED_PLAYER: return uiSacrificedPlayer; } return 0; diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/utgarde_pinnacle.h b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/utgarde_pinnacle.h index 7d10483ca1d..872314ee25e 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/utgarde_pinnacle.h +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/utgarde_pinnacle.h @@ -53,7 +53,7 @@ enum eCreatures MOB_MASSIVE_JORMUNGAR = 26685, MOB_FEROCIOUS_RHINO = 26686, MOB_SVALA = 29281, - MOB_PALEHOOF_ORB = 26688, + MOB_PALEHOOF_ORB = 26688 }; #endif -- cgit v1.2.3 From f850baeb30e2532d2fb52fbd49368f313b73fe04 Mon Sep 17 00:00:00 2001 From: kaelima Date: Mon, 9 Jan 2012 10:07:46 +0100 Subject: Script/Naxxramas: Fixed "A Spore Loser", texts and timers for Loatheb encounter. Creds to Warpten, thanks. --- ...12_01_09_00_world_achievement_criteria_data.sql | 5 + .../world/2012_01_09_00_world_creature_text.sql | 5 + .../2012_01_09_00_world_spell_script_names.sql | 3 + .../scripts/Northrend/Naxxramas/boss_loatheb.cpp | 204 ++++++++++++++++----- 4 files changed, 168 insertions(+), 49 deletions(-) create mode 100644 sql/updates/world/2012_01_09_00_world_achievement_criteria_data.sql create mode 100644 sql/updates/world/2012_01_09_00_world_creature_text.sql create mode 100644 sql/updates/world/2012_01_09_00_world_spell_script_names.sql (limited to 'src/server/scripts/Northrend') diff --git a/sql/updates/world/2012_01_09_00_world_achievement_criteria_data.sql b/sql/updates/world/2012_01_09_00_world_achievement_criteria_data.sql new file mode 100644 index 00000000000..6c2bcc86d03 --- /dev/null +++ b/sql/updates/world/2012_01_09_00_world_achievement_criteria_data.sql @@ -0,0 +1,5 @@ +DELETE FROM `disables` WHERE `sourceType`=4 AND `entry` IN (7612,7613); +DELETE FROM `achievement_criteria_data` WHERE `criteria_id` IN (7612,7613); +INSERT INTO `achievement_criteria_data` (`criteria_id`,`type`,`value1`,`value2`,`ScriptName`) VALUES +(7612,11,0,0, 'achievement_spore_loser'), +(7613,11,0,0, 'achievement_spore_loser'); diff --git a/sql/updates/world/2012_01_09_00_world_creature_text.sql b/sql/updates/world/2012_01_09_00_world_creature_text.sql new file mode 100644 index 00000000000..2a70be00b12 --- /dev/null +++ b/sql/updates/world/2012_01_09_00_world_creature_text.sql @@ -0,0 +1,5 @@ +DELETE FROM `creature_text` WHERE `entry`=16011; +INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`language`,`probability`,`emote`,`duration`,`sound`,`comment`) VALUES +(16011,0,0, 'An aura of necrotic energy blocks all healing!',41,0,100,0,0,0, 'Loatheb'), +(16011,1,0, 'The aura fades away, allowing for healing once more!',41,0,100,0,0,0, 'Loatheb'), +(16011,2,0, 'The aura''s power begins to wane!',41,0,100,0,0,0, 'Loatheb'); diff --git a/sql/updates/world/2012_01_09_00_world_spell_script_names.sql b/sql/updates/world/2012_01_09_00_world_spell_script_names.sql new file mode 100644 index 00000000000..7279fc54413 --- /dev/null +++ b/sql/updates/world/2012_01_09_00_world_spell_script_names.sql @@ -0,0 +1,3 @@ +DELETE FROM `spell_script_names` WHERE `spell_id`=59481; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(59481, 'spell_loatheb_necrotic_aura_warning'); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp index 4c2348d30c9..502c841540a 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp @@ -20,79 +20,185 @@ enum Spells { - SPELL_NECROTIC_AURA = 55593, - SPELL_SUMMON_SPORE = 29234, - SPELL_DEATHBLOOM = 29865, - H_SPELL_DEATHBLOOM = 55053, - SPELL_INEVITABLE_DOOM = 29204, - H_SPELL_INEVITABLE_DOOM = 55052 + SPELL_NECROTIC_AURA = 55593, + SPELL_WARN_NECROTIC_AURA = 59481, + SPELL_SUMMON_SPORE = 29234, + SPELL_DEATHBLOOM = 29865, + H_SPELL_DEATHBLOOM = 55053, + SPELL_INEVITABLE_DOOM = 29204, + H_SPELL_INEVITABLE_DOOM = 55052 +}; + +enum Texts +{ + SAY_NECROTIC_AURA_APPLIED = 0, + SAY_NECROTIC_AURA_REMOVED = 1, + SAY_NECROTIC_AURA_FADING = 2, }; enum Events { - EVENT_NONE, - EVENT_AURA, - EVENT_BLOOM, - EVENT_DOOM, + EVENT_NECROTIC_AURA = 1, + EVENT_DEATHBLOOM = 2, + EVENT_INEVITABLE_DOOM = 3, + EVENT_SPORE = 4, + EVENT_NECROTIC_AURA_FADING = 5, +}; + +enum Achievement +{ + DATA_ACHIEVEMENT_SPORE_LOSER = 21822183, }; class boss_loatheb : public CreatureScript { -public: - boss_loatheb() : CreatureScript("boss_loatheb") { } + public: + boss_loatheb() : CreatureScript("boss_loatheb") { } - CreatureAI* GetAI(Creature* creature) const - { - return new boss_loathebAI (creature); - } + struct boss_loathebAI : public BossAI + { + boss_loathebAI(Creature* creature) : BossAI(creature, BOSS_LOATHEB) + { + } - struct boss_loathebAI : public BossAI - { - boss_loathebAI(Creature* c) : BossAI(c, BOSS_LOATHEB) {} + void Reset() + { + _Reset(); + _doomCounter = 0; + _sporeLoserData = true; + } - void EnterCombat(Unit* /*who*/) - { - _EnterCombat(); - events.ScheduleEvent(EVENT_AURA, 10000); - events.ScheduleEvent(EVENT_BLOOM, 5000); - events.ScheduleEvent(EVENT_DOOM, 120000); - } + void EnterCombat(Unit* /*who*/) + { + _EnterCombat(); + events.ScheduleEvent(EVENT_NECROTIC_AURA, 17000); + events.ScheduleEvent(EVENT_DEATHBLOOM, 5000); + events.ScheduleEvent(EVENT_SPORE, IsHeroic() ? 18000 : 36000); + events.ScheduleEvent(EVENT_INEVITABLE_DOOM, 120000); + } - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - return; + void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) + { + _sporeLoserData = false; + } - events.Update(diff); + uint32 GetData(int32 id) + { + if (id != DATA_ACHIEVEMENT_SPORE_LOSER) + return 0; - while (uint32 eventId = events.ExecuteEvent()) + return uint32(_sporeLoserData); + } + + void UpdateAI(uint32 const diff) { - switch (eventId) + if (!UpdateVictim()) + return; + + events.Update(diff); + + while (uint32 eventId = events.ExecuteEvent()) { - case EVENT_AURA: - DoCastAOE(SPELL_NECROTIC_AURA); - events.ScheduleEvent(EVENT_AURA, 20000); - break; - case EVENT_BLOOM: - // TODO : Add missing text - DoCastAOE(SPELL_SUMMON_SPORE, true); - DoCastAOE(RAID_MODE(SPELL_DEATHBLOOM, H_SPELL_DEATHBLOOM)); - events.ScheduleEvent(EVENT_BLOOM, 30000); - break; - case EVENT_DOOM: - DoCastAOE(RAID_MODE(SPELL_INEVITABLE_DOOM, H_SPELL_INEVITABLE_DOOM)); - events.ScheduleEvent(EVENT_DOOM, events.GetTimer() < 5*60000 ? 30000 : 15000); - break; + switch (eventId) + { + case EVENT_NECROTIC_AURA: + DoCastAOE(SPELL_NECROTIC_AURA); + DoCast(me, SPELL_WARN_NECROTIC_AURA); + events.ScheduleEvent(EVENT_NECROTIC_AURA, 20000); + events.ScheduleEvent(EVENT_NECROTIC_AURA_FADING, 14000); + break; + case EVENT_DEATHBLOOM: + DoCastAOE(RAID_MODE(SPELL_DEATHBLOOM, H_SPELL_DEATHBLOOM)); + events.ScheduleEvent(EVENT_DEATHBLOOM, 30000); + break; + case EVENT_INEVITABLE_DOOM: + _doomCounter++; + DoCastAOE(RAID_MODE(SPELL_INEVITABLE_DOOM, H_SPELL_INEVITABLE_DOOM)); + events.ScheduleEvent(EVENT_INEVITABLE_DOOM, std::max(120000 - _doomCounter * 15000, 15000)); // needs to be confirmed + break; + case EVENT_SPORE: + DoCast(me, SPELL_SUMMON_SPORE, false); + events.ScheduleEvent(EVENT_SPORE, IsHeroic() ? 18000 : 36000); + break; + case EVENT_NECROTIC_AURA_FADING: + Talk(SAY_NECROTIC_AURA_FADING); + break; + default: + break; + } } + + DoMeleeAttackIfReady(); } - DoMeleeAttackIfReady(); + private: + bool _sporeLoserData; + uint8 _doomCounter; + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new boss_loathebAI(creature); + } +}; + +class achievement_spore_loser : public AchievementCriteriaScript +{ + public: + achievement_spore_loser() : AchievementCriteriaScript("achievement_spore_loser") { } + + bool OnCheck(Player* /*source*/, Unit* target) + { + return target && target->GetAI()->GetData(DATA_ACHIEVEMENT_SPORE_LOSER); } - }; +}; + +typedef boss_loatheb::boss_loathebAI LoathebAI; + +class spell_loatheb_necrotic_aura_warning : public SpellScriptLoader +{ + public: + spell_loatheb_necrotic_aura_warning() : SpellScriptLoader("spell_loatheb_necrotic_aura_warning") { } + + class spell_loatheb_necrotic_aura_warning_AuraScript : public AuraScript + { + PrepareAuraScript(spell_loatheb_necrotic_aura_warning_AuraScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellStore.LookupEntry(SPELL_WARN_NECROTIC_AURA)) + return false; + return true; + } + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetTarget()->IsAIEnabled) + CAST_AI(LoathebAI, GetTarget()->GetAI())->Talk(SAY_NECROTIC_AURA_APPLIED); + } + + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetTarget()->IsAIEnabled) + CAST_AI(LoathebAI, GetTarget()->GetAI())->Talk(SAY_NECROTIC_AURA_REMOVED); + } + + void Register() + { + AfterEffectApply += AuraEffectApplyFn(spell_loatheb_necrotic_aura_warning_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_loatheb_necrotic_aura_warning_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_loatheb_necrotic_aura_warning_AuraScript(); + } }; void AddSC_boss_loatheb() { new boss_loatheb(); + new achievement_spore_loser(); + new spell_loatheb_necrotic_aura_warning(); } -- cgit v1.2.3 From 2dc6cb15ed2b895311c2deb78daec9feabbf9d73 Mon Sep 17 00:00:00 2001 From: Emo Norfik Date: Mon, 9 Jan 2012 14:01:58 +0100 Subject: Scripts/Utgarde Pinnacle: - Fix spamming of spell Ball of Flame (48246). - Added missing text of Image of Arthas. - Code cleanup and code style. - Typo fix in sql naming in commit 6cb495048916a916804ebf8bde19e9619b12f897 --- sql/updates/world/2011_01_08_16_world_misc.sql | 117 --------------------- sql/updates/world/2012_01_08_16_world_misc.sql | 117 +++++++++++++++++++++ .../world/2012_01_09_01_world_creature_text.sql | 5 + .../world/2012_01_09_01_world_smart_scripts.sql | 2 + .../UtgardeKeep/UtgardePinnacle/boss_svala.cpp | 13 +-- 5 files changed, 127 insertions(+), 127 deletions(-) delete mode 100644 sql/updates/world/2011_01_08_16_world_misc.sql create mode 100644 sql/updates/world/2012_01_08_16_world_misc.sql create mode 100644 sql/updates/world/2012_01_09_01_world_creature_text.sql create mode 100644 sql/updates/world/2012_01_09_01_world_smart_scripts.sql (limited to 'src/server/scripts/Northrend') diff --git a/sql/updates/world/2011_01_08_16_world_misc.sql b/sql/updates/world/2011_01_08_16_world_misc.sql deleted file mode 100644 index 63cd81ff869..00000000000 --- a/sql/updates/world/2011_01_08_16_world_misc.sql +++ /dev/null @@ -1,117 +0,0 @@ -/* Texts */ - --- Move text used in Svala Sorrowgrave from script_texts to creature_text --- Remove old script text for boss_svala.cpp -DELETE FROM `script_texts` WHERE `entry` BETWEEN -1575027 AND -1575015; - -DELETE FROM `creature_text` WHERE `entry` IN (26668,29281); -INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`language`,`probability`,`emote`,`duration`,`sound`,`comment`) VALUES -(26668,0,0, 'The sensation is... beyond my imagining. I am yours to command, my king.',14,0,0,0,0,13857, 'Svala Sorrowgrave SAY_DIALOG_WITH_ARTHAS_2'), -(26668,1,0, 'I will be happy to slaughter them in your name! Come, enemies of the Scourge! I will show you the might of the Lich King!',14,0,0,0,0,13858, 'Svala Sorrowgrave SAY_DIALOG_WITH_ARTHAS_3'), -(26668,2,0, 'I will vanquish your soul!',14,0,0,0,0,13842, 'Svala Sorrowgrave SAY_AGGRO'), -(26668,3,0, 'You were a fool to challenge the power of the Lich King!',14,0,0,0,0,13845, 'Svala Sorrowgrave SAY_SLAY_1'), -(26668,3,1, 'Your will is done, my king.',14,0,0,0,0,13847, 'Svala Sorrowgrave SAY_SLAY_2'), -(26668,3,2, 'Another soul for my master.',14,0,0,0,0,13848, 'Svala Sorrowgrave SAY_SLAY_3'), -(26668,4,0, 'Nooo! I did not come this far... to...',14,0,0,0,0,13855, 'Svala Sorrowgrave SAY_DEATH'), -(26668,5,0, 'Your death approaches.',14,0,0,0,0,13850, 'Svala Sorrowgrave SAY_SACRIFICE_1'), -(26668,5,1, 'Go now to my master.',14,0,0,0,0,13851, 'Svala Sorrowgrave SAY_SACRIFICE_2'), -(26668,5,2, 'Your end is inevitable.',14,0,0,0,0,13852, 'Svala Sorrowgrave SAY_SACRIFICE_3'), -(26668,5,3, 'Yor-guul mak!',14,0,0,0,0,13853, 'Svala Sorrowgrave SAY_SACRIFICE_4'), -(26668,5,4, 'Any last words?',14,0,0,0,0,13854, 'Svala Sorrowgrave SAY_SACRIFICE_5'), -(29281,0,0, 'My liege! I have done as you asked, and now beseech you for your blessing!',14,0,0,0,0,13856, 'Svala SAY_DIALOG_WITH_ARTHAS_1'); - -/* Templates */ - -UPDATE `creature_template` SET `unit_flags`=2 WHERE `entry` IN (29281, 30809); -- And this, fixes her flag so script can be started (credit to ric) -UPDATE `creature` SET `spawntimesecs`=86400 WHERE `id`=29281; -- Set Svala's spawn time -UPDATE `creature_template` SET `flags_extra`=`flags_extra`|1 WHERE `entry`=30809; -- Set flags_extra = 1 for Svala hero difficulty -UPDATE `creature_template` SET `InhabitType`=7, `flags_extra`=`flags_extra`|130 WHERE `entry`=30805; -- Set same data on heroic ver to triggers -UPDATE `creature_template` SET `InhabitType`=7, `flags_extra`=`flags_extra`|128 WHERE `entry`=30771; -- Set same data on heroic ver to triggers - -UPDATE `creature_template` SET `mechanic_immune_mask`=`mechanic_immune_mask` -|1 -- CHARM -|2 -- DISORIENTED -|4 -- DISARM -|8 -- DISTRACT -|16 -- FEAR -|32 -- GRIP -|64 -- ROOT -|128 -- PACIFY -|256 -- SILENCE -|512 -- SLEEP -|1024 -- SNARE -|2048 -- STUN -|4096 -- FREEZE -|8192 -- KNOCKOUT -|65536 -- POLYMORPH -|131072 -- BANISH -|524288 -- SHACKLE -|4194304 -- TURN -|8388608 -- HORROR -|67108864 -- DAZE -|536870912 -- SAPPED -WHERE `entry` IN (29281, 30809, 26668, 30810); - --- Apply Image of Arthas Visual Effect -DELETE FROM `creature_template_addon` WHERE `entry`=29280; -INSERT INTO `creature_template_addon` (`entry`, `path_id`, `mount`, `bytes1`, `bytes2`, `emote`, `auras`) VALUES -(29280, 0, 0, 0, 1, 0, '54134'); - --- Flame Brazier triggers deletion (will spawn them after activating event 17841 called by spell Call Flames 48258) -DELETE FROM `creature` WHERE `id`=27273 AND `map`=575; -DELETE FROM `creature_addon` WHERE `guid` IN (126121, 126122); - -/* Spells */ - -DELETE FROM `spell_target_position` WHERE `id` IN (48267,48276, 48271, 48274, 48275); -INSERT INTO `spell_target_position` (`id`, `target_map`, `target_position_x`, `target_position_y`, `target_position_z`, `target_orientation`) VALUES -(48267, 575, 296.632, -346.075, 90.5474, 4.60767), -- Svala Ritual - Player teleport position -(48276, 575, 296.651, -346.293, 108.5474, 1.58), -- Svala Ritual - Svala teleport position -(48271, 575, 296.42, -355.01, 90.94, 1.58), -- Summon Ritual Channeler positions -(48274, 575, 302.36, -352.01, 90.54, 2.20), -- Summon Ritual Channeler positions -(48275, 575, 291.39, -352.01, 90.54, 0.91); -- Summon Ritual Channeler positions - -DELETE FROM `conditions` WHERE `SourceEntry` IN (48331,48246,48277) AND `SourceTypeOrReferenceId`=13; -INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES -(13, 0, 48331, 0, 18, 1, 27327, 0, 0, '', NULL), -- Spell script target for flying sword -(13, 0, 48246, 0, 18, 1, 0, 0, 0, '', NULL), -- Spell script target for Flame Brazier's (on players only) -(13, 0, 48277, 0, 18, 1, 26555, 0, 0, '', NULL), -- Spell script target for Ritual Strike DMG -- Players -(13, 0, 48277, 0, 18, 1, 27327, 0, 0, '', NULL); -- Spell script target for Ritual Strike DMG -- Ritual Target - -/* Achivements */ - --- The Incredible Hulk achievement 2043 -DELETE FROM `disables` WHERE `sourceType`=4 AND `entry`=7322; -DELETE FROM `achievement_criteria_data` WHERE `criteria_id`=7322 AND `type`=11; -INSERT INTO `achievement_criteria_data` (`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES -(7322, 11, 0, 0, 'achievement_incredible_hulk'); - -/* AI */ - -DELETE FROM `creature_ai_scripts` WHERE `creature_id`=26555; -- Scourge Hulk -UPDATE `creature_template` SET `AIName`='SmartAI' WHERE `entry`=27273; -- Flame Brazier - --- Add Send Script Event (17841) summon 3 triggers -DELETE FROM `event_scripts` WHERE `id`=17841; -INSERT INTO `event_scripts` (`id`, `delay`, `command`, `datalong`, `datalong2`, `dataint`, `x`, `y`, `z`, `o`) VALUES -(17841, 0, 10, 27273, 10000, 0, 285.6, -357.5, 91.0833, 5.75959), -(17841, 3, 10, 27273, 10000, 0, 307, -357.5, 91.0833, 6.02139), -(17841, 6, 10, 27273, 10000, 0, 285.6, -357.5, 91.0833, 5.75959); - --- SmartAI script Flame Brazier's cast Ball of Flame (48246) on random player -DELETE FROM `smart_scripts` WHERE `entryorguid`=27273 AND `source_type`=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`, `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 -(27273, 0, 0, 0, 1, 0, 100, 1, 100, 100, 100, 100, 11, 48246, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Flame Brazier - Ball of Flame'); - -/* Script names */ - -UPDATE `creature_template` SET `AIName`='', `ScriptName`='npc_scourge_hulk' WHERE `entry`=26555; -UPDATE `creature_template` SET `ScriptName`='' WHERE `entry`=26668; -- "boss_svala_sorrowgrave" script is now merged with "boss_svala" script -UPDATE `creature_template` SET `ScriptName`='npc_spectator' WHERE `entry`=26667; -- Spectators escape script -UPDATE `creature_template` SET `ScriptName`='npc_ritual_channeler' WHERE `entry`=27281; -- Change 'mob_ritual_channeler' to 'npc_ritual_channeler' - --- Paralyze -- Filter targets -- cast only on sacrafacing target -DELETE FROM `spell_script_names` WHERE `spell_id`=48278; -INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES -(48278, 'spell_paralyze_pinnacle'); - diff --git a/sql/updates/world/2012_01_08_16_world_misc.sql b/sql/updates/world/2012_01_08_16_world_misc.sql new file mode 100644 index 00000000000..63cd81ff869 --- /dev/null +++ b/sql/updates/world/2012_01_08_16_world_misc.sql @@ -0,0 +1,117 @@ +/* Texts */ + +-- Move text used in Svala Sorrowgrave from script_texts to creature_text +-- Remove old script text for boss_svala.cpp +DELETE FROM `script_texts` WHERE `entry` BETWEEN -1575027 AND -1575015; + +DELETE FROM `creature_text` WHERE `entry` IN (26668,29281); +INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`language`,`probability`,`emote`,`duration`,`sound`,`comment`) VALUES +(26668,0,0, 'The sensation is... beyond my imagining. I am yours to command, my king.',14,0,0,0,0,13857, 'Svala Sorrowgrave SAY_DIALOG_WITH_ARTHAS_2'), +(26668,1,0, 'I will be happy to slaughter them in your name! Come, enemies of the Scourge! I will show you the might of the Lich King!',14,0,0,0,0,13858, 'Svala Sorrowgrave SAY_DIALOG_WITH_ARTHAS_3'), +(26668,2,0, 'I will vanquish your soul!',14,0,0,0,0,13842, 'Svala Sorrowgrave SAY_AGGRO'), +(26668,3,0, 'You were a fool to challenge the power of the Lich King!',14,0,0,0,0,13845, 'Svala Sorrowgrave SAY_SLAY_1'), +(26668,3,1, 'Your will is done, my king.',14,0,0,0,0,13847, 'Svala Sorrowgrave SAY_SLAY_2'), +(26668,3,2, 'Another soul for my master.',14,0,0,0,0,13848, 'Svala Sorrowgrave SAY_SLAY_3'), +(26668,4,0, 'Nooo! I did not come this far... to...',14,0,0,0,0,13855, 'Svala Sorrowgrave SAY_DEATH'), +(26668,5,0, 'Your death approaches.',14,0,0,0,0,13850, 'Svala Sorrowgrave SAY_SACRIFICE_1'), +(26668,5,1, 'Go now to my master.',14,0,0,0,0,13851, 'Svala Sorrowgrave SAY_SACRIFICE_2'), +(26668,5,2, 'Your end is inevitable.',14,0,0,0,0,13852, 'Svala Sorrowgrave SAY_SACRIFICE_3'), +(26668,5,3, 'Yor-guul mak!',14,0,0,0,0,13853, 'Svala Sorrowgrave SAY_SACRIFICE_4'), +(26668,5,4, 'Any last words?',14,0,0,0,0,13854, 'Svala Sorrowgrave SAY_SACRIFICE_5'), +(29281,0,0, 'My liege! I have done as you asked, and now beseech you for your blessing!',14,0,0,0,0,13856, 'Svala SAY_DIALOG_WITH_ARTHAS_1'); + +/* Templates */ + +UPDATE `creature_template` SET `unit_flags`=2 WHERE `entry` IN (29281, 30809); -- And this, fixes her flag so script can be started (credit to ric) +UPDATE `creature` SET `spawntimesecs`=86400 WHERE `id`=29281; -- Set Svala's spawn time +UPDATE `creature_template` SET `flags_extra`=`flags_extra`|1 WHERE `entry`=30809; -- Set flags_extra = 1 for Svala hero difficulty +UPDATE `creature_template` SET `InhabitType`=7, `flags_extra`=`flags_extra`|130 WHERE `entry`=30805; -- Set same data on heroic ver to triggers +UPDATE `creature_template` SET `InhabitType`=7, `flags_extra`=`flags_extra`|128 WHERE `entry`=30771; -- Set same data on heroic ver to triggers + +UPDATE `creature_template` SET `mechanic_immune_mask`=`mechanic_immune_mask` +|1 -- CHARM +|2 -- DISORIENTED +|4 -- DISARM +|8 -- DISTRACT +|16 -- FEAR +|32 -- GRIP +|64 -- ROOT +|128 -- PACIFY +|256 -- SILENCE +|512 -- SLEEP +|1024 -- SNARE +|2048 -- STUN +|4096 -- FREEZE +|8192 -- KNOCKOUT +|65536 -- POLYMORPH +|131072 -- BANISH +|524288 -- SHACKLE +|4194304 -- TURN +|8388608 -- HORROR +|67108864 -- DAZE +|536870912 -- SAPPED +WHERE `entry` IN (29281, 30809, 26668, 30810); + +-- Apply Image of Arthas Visual Effect +DELETE FROM `creature_template_addon` WHERE `entry`=29280; +INSERT INTO `creature_template_addon` (`entry`, `path_id`, `mount`, `bytes1`, `bytes2`, `emote`, `auras`) VALUES +(29280, 0, 0, 0, 1, 0, '54134'); + +-- Flame Brazier triggers deletion (will spawn them after activating event 17841 called by spell Call Flames 48258) +DELETE FROM `creature` WHERE `id`=27273 AND `map`=575; +DELETE FROM `creature_addon` WHERE `guid` IN (126121, 126122); + +/* Spells */ + +DELETE FROM `spell_target_position` WHERE `id` IN (48267,48276, 48271, 48274, 48275); +INSERT INTO `spell_target_position` (`id`, `target_map`, `target_position_x`, `target_position_y`, `target_position_z`, `target_orientation`) VALUES +(48267, 575, 296.632, -346.075, 90.5474, 4.60767), -- Svala Ritual - Player teleport position +(48276, 575, 296.651, -346.293, 108.5474, 1.58), -- Svala Ritual - Svala teleport position +(48271, 575, 296.42, -355.01, 90.94, 1.58), -- Summon Ritual Channeler positions +(48274, 575, 302.36, -352.01, 90.54, 2.20), -- Summon Ritual Channeler positions +(48275, 575, 291.39, -352.01, 90.54, 0.91); -- Summon Ritual Channeler positions + +DELETE FROM `conditions` WHERE `SourceEntry` IN (48331,48246,48277) AND `SourceTypeOrReferenceId`=13; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(13, 0, 48331, 0, 18, 1, 27327, 0, 0, '', NULL), -- Spell script target for flying sword +(13, 0, 48246, 0, 18, 1, 0, 0, 0, '', NULL), -- Spell script target for Flame Brazier's (on players only) +(13, 0, 48277, 0, 18, 1, 26555, 0, 0, '', NULL), -- Spell script target for Ritual Strike DMG -- Players +(13, 0, 48277, 0, 18, 1, 27327, 0, 0, '', NULL); -- Spell script target for Ritual Strike DMG -- Ritual Target + +/* Achivements */ + +-- The Incredible Hulk achievement 2043 +DELETE FROM `disables` WHERE `sourceType`=4 AND `entry`=7322; +DELETE FROM `achievement_criteria_data` WHERE `criteria_id`=7322 AND `type`=11; +INSERT INTO `achievement_criteria_data` (`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES +(7322, 11, 0, 0, 'achievement_incredible_hulk'); + +/* AI */ + +DELETE FROM `creature_ai_scripts` WHERE `creature_id`=26555; -- Scourge Hulk +UPDATE `creature_template` SET `AIName`='SmartAI' WHERE `entry`=27273; -- Flame Brazier + +-- Add Send Script Event (17841) summon 3 triggers +DELETE FROM `event_scripts` WHERE `id`=17841; +INSERT INTO `event_scripts` (`id`, `delay`, `command`, `datalong`, `datalong2`, `dataint`, `x`, `y`, `z`, `o`) VALUES +(17841, 0, 10, 27273, 10000, 0, 285.6, -357.5, 91.0833, 5.75959), +(17841, 3, 10, 27273, 10000, 0, 307, -357.5, 91.0833, 6.02139), +(17841, 6, 10, 27273, 10000, 0, 285.6, -357.5, 91.0833, 5.75959); + +-- SmartAI script Flame Brazier's cast Ball of Flame (48246) on random player +DELETE FROM `smart_scripts` WHERE `entryorguid`=27273 AND `source_type`=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`, `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 +(27273, 0, 0, 0, 1, 0, 100, 1, 100, 100, 100, 100, 11, 48246, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Flame Brazier - Ball of Flame'); + +/* Script names */ + +UPDATE `creature_template` SET `AIName`='', `ScriptName`='npc_scourge_hulk' WHERE `entry`=26555; +UPDATE `creature_template` SET `ScriptName`='' WHERE `entry`=26668; -- "boss_svala_sorrowgrave" script is now merged with "boss_svala" script +UPDATE `creature_template` SET `ScriptName`='npc_spectator' WHERE `entry`=26667; -- Spectators escape script +UPDATE `creature_template` SET `ScriptName`='npc_ritual_channeler' WHERE `entry`=27281; -- Change 'mob_ritual_channeler' to 'npc_ritual_channeler' + +-- Paralyze -- Filter targets -- cast only on sacrafacing target +DELETE FROM `spell_script_names` WHERE `spell_id`=48278; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(48278, 'spell_paralyze_pinnacle'); + diff --git a/sql/updates/world/2012_01_09_01_world_creature_text.sql b/sql/updates/world/2012_01_09_01_world_creature_text.sql new file mode 100644 index 00000000000..d1ec26bd7f4 --- /dev/null +++ b/sql/updates/world/2012_01_09_01_world_creature_text.sql @@ -0,0 +1,5 @@ +-- Missing Image of Arthas say text +DELETE FROM `creature_text` WHERE `entry`=29280; +INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`language`,`probability`,`emote`,`duration`,`sound`,`comment`) VALUES +(29280,0,0, 'Your sacrifice is a testament to your obedience. Indeed you are worthy of this charge. Arise, and forever be known as Svala Sorrowgrave!',14,0,0,0,0,14732, 'Image of Arthas SAY_DIALOG_OF_ARTHAS_1'), +(29280,1,0, 'Your first test awaits you. Destroy our uninvited guests.',14,0,0,0,0,14733, 'Image of Arthas SAY_DIALOG_OF_ARTHAS_2'); diff --git a/sql/updates/world/2012_01_09_01_world_smart_scripts.sql b/sql/updates/world/2012_01_09_01_world_smart_scripts.sql new file mode 100644 index 00000000000..a7304fa6e6a --- /dev/null +++ b/sql/updates/world/2012_01_09_01_world_smart_scripts.sql @@ -0,0 +1,2 @@ +-- Fix spamming of spell Ball of Flame (48246) +UPDATE `smart_scripts` SET `event_type`=54, `event_param1`=0, `event_param2`=0, `event_param3`=0, `event_param4`=0 WHERE `entryorguid`=27273; diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp index 7280c3d5b82..9cab1de197c 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp @@ -102,14 +102,7 @@ static const float spectatorWP[2][3] = {297.69f,-275.81f,86.36f} }; -static Position RitualChannelerPos[]= -{ - {296.42f, -355.01f, 90.94f, 1.58f}, - {302.36f, -352.01f, 90.54f, 2.20f}, - {291.39f, -352.01f, 90.54f, 0.91f} -}; static Position ArthasPos = { 295.81f, -366.16f, 92.57f, 1.58f }; -static Position SvalaPos = { 296.632f, -346.075f, 90.6307f, 1.58f }; class boss_svala : public CreatureScript { @@ -527,9 +520,9 @@ public: struct npc_ritual_channelerAI : public Scripted_NoMovementAI { - npc_ritual_channelerAI(Creature* c) :Scripted_NoMovementAI(c) + npc_ritual_channelerAI(Creature* creature) :Scripted_NoMovementAI(creature) { - instance = c->GetInstanceScript(); + instance = creature->GetInstanceScript(); } InstanceScript* instance; @@ -574,7 +567,7 @@ public: struct npc_spectatorAI : public ScriptedAI { - npc_spectatorAI(Creature* c) : ScriptedAI(c) { } + npc_spectatorAI(Creature* creature) : ScriptedAI(creature) { } void Reset() { } -- cgit v1.2.3 From f7276a95de6bda0fbf4a446b9bb94373328506e2 Mon Sep 17 00:00:00 2001 From: Subv2112 Date: Mon, 9 Jan 2012 20:36:56 -0500 Subject: Scripts/Achievements: Fixed achievement Shocking! on 10-man and 25-man closes #4751 Signed-off-by: Subv2112 --- src/server/game/Spells/SpellEffects.cpp | 32 ------------ .../scripts/Northrend/Naxxramas/boss_thaddius.cpp | 59 ++++++++++++++++++++++ .../Northrend/Naxxramas/instance_naxxramas.cpp | 24 +++++++-- src/server/scripts/Northrend/Naxxramas/naxxramas.h | 2 + 4 files changed, 81 insertions(+), 36 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 40b3101cfd5..2c33488f76c 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -333,38 +333,6 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex) switch (m_spellInfo->Id) // better way to check unknown { - // Positive/Negative Charge - case 28062: - case 28085: - case 39090: - case 39093: - if (!m_triggeredByAuraSpell) - break; - if (unitTarget == m_caster) - { - uint8 count = 0; - for (std::list::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) - if (ihit->targetGUID != m_caster->GetGUID()) - if (Player* target = ObjectAccessor::GetPlayer(*m_caster, ihit->targetGUID)) - if (target->HasAura(m_triggeredByAuraSpell->Id)) - ++count; - if (count) - { - uint32 spellId = 0; - switch (m_spellInfo->Id) - { - case 28062: spellId = 29659; break; - case 28085: spellId = 29660; break; - case 39090: spellId = 39089; break; - case 39093: spellId = 39092; break; - } - m_caster->SetAuraStack(spellId, m_caster, count); - } - } - - if (unitTarget->HasAura(m_triggeredByAuraSpell->Id)) - damage = 0; - break; // Consumption case 28865: damage = (((InstanceMap*)m_caster->GetMap())->GetDifficulty() == REGULAR_DIFFICULTY ? 2750 : 4250); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp index b0138fb1a5e..24ef5fdcd3e 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp @@ -400,9 +400,68 @@ public: }; +class spell_thaddius_pos_neg_charge : public SpellScriptLoader +{ + public: + spell_thaddius_pos_neg_charge() : SpellScriptLoader("spell_thaddius_pos_neg_charge") { } + + class spell_thaddius_pos_neg_charge_SpellScript : public SpellScript + { + PrepareSpellScript(spell_thaddius_pos_neg_charge_SpellScript); + + void HandleTargets(std::list& targetList) + { + uint8 count = 0; + for (std::list::iterator ihit = targetList.begin(); ihit != targetList.end(); ++ihit) + if ((*ihit)->GetGUID() != GetCaster()->GetGUID()) + if (Player* target = (*ihit)->ToPlayer()) + if (target->HasAura(GetTriggeringSpell()->Id)) + ++count; + if (count) + { + uint32 spellId = 0; + switch (GetSpellInfo()->Id) + { + case 28062: spellId = 29659; break; + case 28085: spellId = 29660; break; + case 39090: spellId = 39089; break; + case 39093: spellId = 39092; break; + } + GetCaster()->SetAuraStack(spellId, GetCaster(), count); + } + } + + void HandleDamage(SpellEffIndex /*effIndex*/) + { + if (!GetTriggeringSpell()) + return; + + Unit* target = GetHitUnit(); + + if (target->HasAura(GetTriggeringSpell()->Id)) + SetHitDamage(0); + else + if (InstanceScript* instance = target->GetInstanceScript()) + instance->SetData(DATA_POLARITY_SWITCHED, 1); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_thaddius_pos_neg_charge_SpellScript::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + OnUnitTargetSelect += SpellUnitTargetFn(spell_thaddius_pos_neg_charge_SpellScript::HandleTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_thaddius_pos_neg_charge_SpellScript(); + } +}; + void AddSC_boss_thaddius() { new boss_thaddius(); new mob_stalagg(); new mob_feugen(); + new spell_thaddius_pos_neg_charge(); } diff --git a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp index 32cb279ce5f..9ae6f8d9776 100644 --- a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp +++ b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp @@ -148,6 +148,8 @@ public: time_t maxHorsemenDiedTime; uint32 playerDied; + + uint32 PolaritySwitch; void Initialize() { @@ -166,8 +168,10 @@ public: kelthuzadGUID = 0; kelthuzadTriggerGUID = 0; - playerDied = 0; - gothikDoorState = GO_STATE_ACTIVE; + playerDied = 0; + gothikDoorState = GO_STATE_ACTIVE; + + PolaritySwitch = 0; memset(portalsGUID, 0, sizeof(portalsGUID)); } @@ -311,6 +315,9 @@ public: case DATA_ABOMINATION_KILLED: AbominationCount = value; break; + case DATA_POLARITY_SWITCHED: + PolaritySwitch = value; + break; } } @@ -440,6 +447,13 @@ public: if (AreAllEncoutersDone() && !playerDied) return true; return false; + // Criteria for achievement 2178: Shocking! (10-man) + case 7604: + // Criteria for achievement 2179: Shocking! (25-man) + case 7605: + if (!PolaritySwitch) + return true; + return false; } return false; } @@ -447,14 +461,14 @@ public: std::string GetSaveData() { std::ostringstream saveStream; - saveStream << GetBossSaveData() << gothikDoorState << ' ' << playerDied; + saveStream << GetBossSaveData() << gothikDoorState << ' ' << playerDied << ' ' << PolaritySwitch; return saveStream.str(); } void Load(const char * data) { std::istringstream loadStream(LoadBossState(data)); - uint32 temp, buff, buff2; + uint32 temp, buff, buff2, buff3; for (uint32 i = 0; i < MAX_BOSS_NUMBER; ++i) loadStream >> temp; @@ -463,6 +477,8 @@ public: gothikDoorState = GOState(buff); loadStream >> buff2; playerDied = buff2; + loadStream >> buff3; + PolaritySwitch = buff3; } }; diff --git a/src/server/scripts/Northrend/Naxxramas/naxxramas.h b/src/server/scripts/Northrend/Naxxramas/naxxramas.h index 43393aff844..34d465c775d 100644 --- a/src/server/scripts/Northrend/Naxxramas/naxxramas.h +++ b/src/server/scripts/Northrend/Naxxramas/naxxramas.h @@ -49,6 +49,8 @@ enum Data DATA_HORSEMEN2, DATA_HORSEMEN3, DATA_ABOMINATION_KILLED, + + DATA_POLARITY_SWITCHED, }; enum Data64 -- cgit v1.2.3 From 233d8919528879a26b1aa03373fee590f2307c9d Mon Sep 17 00:00:00 2001 From: kaelima Date: Wed, 11 Jan 2012 17:21:03 +0100 Subject: Scripts/Achievements: - Move achievement Shocking! to appropriate boss script instead of instance script. - Split the polarity spellscript into two and move to proper boss file - Fixed a typo in Loatheb's spore achievement. --- ...12_01_11_01_world_achievement_criteria_data.sql | 4 + .../2012_01_11_01_world_spell_script_names.sql | 4 + src/server/game/Scripting/ScriptLoader.cpp | 2 + .../scripts/Northrend/Naxxramas/boss_loatheb.cpp | 2 +- .../scripts/Northrend/Naxxramas/boss_thaddius.cpp | 81 +++++++++++++++--- .../Northrend/Naxxramas/instance_naxxramas.cpp | 20 +---- src/server/scripts/Northrend/Naxxramas/naxxramas.h | 2 - src/server/scripts/Outland/CMakeLists.txt | 1 + .../Mechanar/boss_mechano_lord_capacitus.cpp | 99 ++++++++++++++++++++++ 9 files changed, 182 insertions(+), 33 deletions(-) create mode 100644 sql/updates/world/2012_01_11_01_world_achievement_criteria_data.sql create mode 100644 sql/updates/world/2012_01_11_01_world_spell_script_names.sql create mode 100644 src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp (limited to 'src/server/scripts/Northrend') diff --git a/sql/updates/world/2012_01_11_01_world_achievement_criteria_data.sql b/sql/updates/world/2012_01_11_01_world_achievement_criteria_data.sql new file mode 100644 index 00000000000..aa3ec94a5a8 --- /dev/null +++ b/sql/updates/world/2012_01_11_01_world_achievement_criteria_data.sql @@ -0,0 +1,4 @@ +DELETE FROM `achievement_criteria_data` WHERE `criteria_id` IN (7604, 7605) AND `type` IN (18,11); +INSERT INTO `achievement_criteria_data` (`criteria_id`,`type`,`value1`,`value2`,`ScriptName`) VALUES +(7604,11,0,0, 'achievement_polarity_switch'), +(7605,11,0,0, 'achievement_polarity_switch'); diff --git a/sql/updates/world/2012_01_11_01_world_spell_script_names.sql b/sql/updates/world/2012_01_11_01_world_spell_script_names.sql new file mode 100644 index 00000000000..4600f190c4e --- /dev/null +++ b/sql/updates/world/2012_01_11_01_world_spell_script_names.sql @@ -0,0 +1,4 @@ +DELETE FROM `spell_script_names` WHERE `spell_id` IN (39090, 39093); +INSERT INTO `spell_script_names`(`spell_id`,`ScriptName`) VALUES +(39090, 'spell_capacitus_polarity_shift'), +(39093, 'spell_capacitus_polarity_shift'); diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index 6322151e792..c46721db6cd 100755 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -570,6 +570,7 @@ void AddSC_the_eye(); void AddSC_boss_gatewatcher_iron_hand(); //TK The Mechanar void AddSC_boss_nethermancer_sepethrea(); void AddSC_boss_pathaleon_the_calculator(); +void AddSC_boss_mechano_lord_capacitus(); void AddSC_instance_mechanar(); void AddSC_blades_edge_mountains(); @@ -1030,6 +1031,7 @@ void AddOutlandScripts() AddSC_boss_gatewatcher_iron_hand(); //TK The Mechanar AddSC_boss_nethermancer_sepethrea(); AddSC_boss_pathaleon_the_calculator(); + AddSC_boss_mechano_lord_capacitus(); AddSC_instance_mechanar(); AddSC_blades_edge_mountains(); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp index 502c841540a..58d3a4240b2 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp @@ -82,7 +82,7 @@ class boss_loatheb : public CreatureScript _sporeLoserData = false; } - uint32 GetData(int32 id) + uint32 GetData(uint32 id) { if (id != DATA_ACHIEVEMENT_SPORE_LOSER) return 0; diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp index 24ef5fdcd3e..be9168c6fd4 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp @@ -83,7 +83,11 @@ enum ThaddiusSpells SPELL_BALL_LIGHTNING = 28299, SPELL_CHAIN_LIGHTNING = 28167, H_SPELL_CHAIN_LIGHTNING = 54531, - SPELL_BERSERK = 27680 + SPELL_BERSERK = 27680, + SPELL_POSITIVE_CHARGE = 28062, + SPELL_POSITIVE_CHARGE_STACK = 29659, + SPELL_NEGATIVE_CHARGE = 28085, + SPELL_NEGATIVE_CHARGE_STACK = 29660 }; enum Events @@ -94,6 +98,11 @@ enum Events EVENT_BERSERK, }; +enum Achievement +{ + DATA_POLARITY_SWITCH = 76047605, +}; + class boss_thaddius : public CreatureScript { public: @@ -135,6 +144,7 @@ public: bool checkStalaggAlive; bool checkFeugenAlive; + bool polaritySwitch; uint32 uiAddsTimer; void KilledUnit(Unit* /*victim*/) @@ -194,6 +204,20 @@ public: me->SetReactState(REACT_AGGRESSIVE); } + void SetData(uint32 id, uint32 data) + { + if (id == DATA_POLARITY_SWITCH) + polaritySwitch = data ? true : false; + } + + uint32 GetData(uint32 id) + { + if (id != DATA_POLARITY_SWITCH) + return 0; + + return uint32(polaritySwitch); + } + void UpdateAI(const uint32 diff) { if (checkFeugenAlive && checkStalaggAlive) @@ -409,6 +433,24 @@ class spell_thaddius_pos_neg_charge : public SpellScriptLoader { PrepareSpellScript(spell_thaddius_pos_neg_charge_SpellScript); + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE)) + return false; + if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE_STACK)) + return false; + if (!sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE)) + return false; + if (!sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE_STACK)) + return false; + return true; + } + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_UNIT; + } + void HandleTargets(std::list& targetList) { uint8 count = 0; @@ -417,16 +459,16 @@ class spell_thaddius_pos_neg_charge : public SpellScriptLoader if (Player* target = (*ihit)->ToPlayer()) if (target->HasAura(GetTriggeringSpell()->Id)) ++count; + if (count) { uint32 spellId = 0; - switch (GetSpellInfo()->Id) - { - case 28062: spellId = 29659; break; - case 28085: spellId = 29660; break; - case 39090: spellId = 39089; break; - case 39093: spellId = 39092; break; - } + + if (GetSpellInfo()->Id == SPELL_POSITIVE_CHARGE) + spellId = SPELL_POSITIVE_CHARGE_STACK; + else // if (GetSpellInfo()->Id == SPELL_NEGATIVE_CHARGE) + spellId = SPELL_NEGATIVE_CHARGE_STACK; + GetCaster()->SetAuraStack(spellId, GetCaster(), count); } } @@ -435,14 +477,17 @@ class spell_thaddius_pos_neg_charge : public SpellScriptLoader { if (!GetTriggeringSpell()) return; - + Unit* target = GetHitUnit(); - + Unit* caster = GetCaster(); + if (target->HasAura(GetTriggeringSpell()->Id)) SetHitDamage(0); else - if (InstanceScript* instance = target->GetInstanceScript()) - instance->SetData(DATA_POLARITY_SWITCHED, 1); + { + if (target->GetTypeId() == TYPEID_PLAYER && caster->IsAIEnabled) + caster->ToCreature()->AI()->SetData(DATA_POLARITY_SWITCH, 1); + } } void Register() @@ -458,10 +503,22 @@ class spell_thaddius_pos_neg_charge : public SpellScriptLoader } }; +class achievement_polarity_switch : public AchievementCriteriaScript +{ + public: + achievement_polarity_switch() : AchievementCriteriaScript("achievement_polarity_switch") { } + + bool OnCheck(Player* /*source*/, Unit* target) + { + return target && target->GetAI()->GetData(DATA_POLARITY_SWITCH); + } +}; + void AddSC_boss_thaddius() { new boss_thaddius(); new mob_stalagg(); new mob_feugen(); new spell_thaddius_pos_neg_charge(); + new achievement_polarity_switch(); } diff --git a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp index 9ae6f8d9776..c05d9a21850 100644 --- a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp +++ b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp @@ -148,8 +148,6 @@ public: time_t maxHorsemenDiedTime; uint32 playerDied; - - uint32 PolaritySwitch; void Initialize() { @@ -170,8 +168,6 @@ public: playerDied = 0; gothikDoorState = GO_STATE_ACTIVE; - - PolaritySwitch = 0; memset(portalsGUID, 0, sizeof(portalsGUID)); } @@ -315,9 +311,6 @@ public: case DATA_ABOMINATION_KILLED: AbominationCount = value; break; - case DATA_POLARITY_SWITCHED: - PolaritySwitch = value; - break; } } @@ -447,13 +440,6 @@ public: if (AreAllEncoutersDone() && !playerDied) return true; return false; - // Criteria for achievement 2178: Shocking! (10-man) - case 7604: - // Criteria for achievement 2179: Shocking! (25-man) - case 7605: - if (!PolaritySwitch) - return true; - return false; } return false; } @@ -461,14 +447,14 @@ public: std::string GetSaveData() { std::ostringstream saveStream; - saveStream << GetBossSaveData() << gothikDoorState << ' ' << playerDied << ' ' << PolaritySwitch; + saveStream << GetBossSaveData() << gothikDoorState << ' ' << playerDied; return saveStream.str(); } void Load(const char * data) { std::istringstream loadStream(LoadBossState(data)); - uint32 temp, buff, buff2, buff3; + uint32 temp, buff, buff2; for (uint32 i = 0; i < MAX_BOSS_NUMBER; ++i) loadStream >> temp; @@ -477,8 +463,6 @@ public: gothikDoorState = GOState(buff); loadStream >> buff2; playerDied = buff2; - loadStream >> buff3; - PolaritySwitch = buff3; } }; diff --git a/src/server/scripts/Northrend/Naxxramas/naxxramas.h b/src/server/scripts/Northrend/Naxxramas/naxxramas.h index 34d465c775d..43393aff844 100644 --- a/src/server/scripts/Northrend/Naxxramas/naxxramas.h +++ b/src/server/scripts/Northrend/Naxxramas/naxxramas.h @@ -49,8 +49,6 @@ enum Data DATA_HORSEMEN2, DATA_HORSEMEN3, DATA_ABOMINATION_KILLED, - - DATA_POLARITY_SWITCHED, }; enum Data64 diff --git a/src/server/scripts/Outland/CMakeLists.txt b/src/server/scripts/Outland/CMakeLists.txt index ffd9332c8aa..229f7de72ec 100644 --- a/src/server/scripts/Outland/CMakeLists.txt +++ b/src/server/scripts/Outland/CMakeLists.txt @@ -45,6 +45,7 @@ set(scripts_STAT_SRCS Outland/CoilfangReservoir/underbog/boss_hungarfen.cpp Outland/CoilfangReservoir/underbog/boss_the_black_stalker.cpp Outland/shattrath_city.cpp + Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp Outland/TempestKeep/Mechanar/boss_pathaleon_the_calculator.cpp Outland/TempestKeep/Mechanar/boss_nethermancer_sepethrea.cpp Outland/TempestKeep/Mechanar/mechanar.h diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp new file mode 100644 index 00000000000..070c107e61d --- /dev/null +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2008-2012 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +//! TODO - Boss not scripted, just ported required spellscript from core + +enum Spells +{ + SPELL_POSITIVE_CHARGE = 39090, + SPELL_POSITIVE_CHARGE_STACK = 39089, + SPELL_NEGATIVE_CHARGE = 39093, + SPELL_NEGATIVE_CHARGE_STACK = 39092 +}; + +class spell_capacitus_polarity_shift : public SpellScriptLoader +{ + public: + spell_capacitus_polarity_shift() : SpellScriptLoader("spell_capacitus_polarity_shift") { } + + class spell_capacitus_polarity_shift_SpellScript : public SpellScript + { + PrepareSpellScript(spell_capacitus_polarity_shift_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE)) + return false; + if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE_STACK)) + return false; + if (!sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE)) + return false; + if (!sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE_STACK)) + return false; + return true; + } + + void HandleTargets(std::list& targetList) + { + uint8 count = 0; + for (std::list::iterator ihit = targetList.begin(); ihit != targetList.end(); ++ihit) + if ((*ihit)->GetGUID() != GetCaster()->GetGUID()) + if (Player* target = (*ihit)->ToPlayer()) + if (target->HasAura(GetTriggeringSpell()->Id)) + ++count; + + if (count) + { + uint32 spellId = 0; + + if (GetSpellInfo()->Id == SPELL_POSITIVE_CHARGE) + spellId = SPELL_POSITIVE_CHARGE_STACK; + else // if (GetSpellInfo()->Id == SPELL_NEGATIVE_CHARGE) + spellId = SPELL_NEGATIVE_CHARGE_STACK; + + GetCaster()->SetAuraStack(spellId, GetCaster(), count); + } + } + + void HandleDamage(SpellEffIndex /*effIndex*/) + { + if (!GetTriggeringSpell()) + return; + + Unit* target = GetHitUnit(); + + if (target->HasAura(GetTriggeringSpell()->Id)) + SetHitDamage(0); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_capacitus_polarity_shift_SpellScript::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + OnUnitTargetSelect += SpellUnitTargetFn(spell_capacitus_polarity_shift_SpellScript::HandleTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_capacitus_polarity_shift_SpellScript(); + } +}; + +void AddSC_boss_mechano_lord_capacitus() +{ + new spell_capacitus_polarity_shift(); +} -- cgit v1.2.3 From 2293d2d7dfab3470c6d1fbdb84d7df691ac93240 Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Fri, 13 Jan 2012 16:43:49 +0100 Subject: Core/Movement: Prevent IdleMovementGenerator being put into MOTION_SLOT_IDLE and MOTION_SLOT_ACTIVE simultaneously --- src/server/game/Entities/Creature/Creature.cpp | 2 +- src/server/game/Entities/Creature/CreatureGroups.cpp | 2 +- src/server/game/Movement/MotionMaster.cpp | 9 ++++----- src/server/game/Movement/MotionMaster.h | 2 +- src/server/game/Server/Protocol/Handlers/PetHandler.cpp | 1 + src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp | 4 ++-- .../scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp | 3 ++- 7 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 3e06f9e73db..ff627f78ea0 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -715,7 +715,7 @@ void Creature::Motion_Initialize() i_motionMaster.Initialize(); } else if (m_formation->isFormed()) - i_motionMaster.MoveIdle(MOTION_SLOT_IDLE); //wait the order of leader + i_motionMaster.MoveIdle(); //wait the order of leader else i_motionMaster.Initialize(); } diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index 3a63c32fc1e..abf82dc5919 100755 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -203,7 +203,7 @@ void CreatureGroup::FormationReset(bool dismiss) if (dismiss) itr->first->GetMotionMaster()->Initialize(); else - itr->first->GetMotionMaster()->MoveIdle(MOTION_SLOT_IDLE); + itr->first->GetMotionMaster()->MoveIdle(); sLog->outDebug(LOG_FILTER_UNITS, "Set %s movement for member GUID: %u", dismiss ? "default" : "idle", itr->first->GetGUIDLow()); } } diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 51725c118ce..6660da146f0 100755 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -175,12 +175,11 @@ void MotionMaster::DelayedExpire() --i_top; } -void MotionMaster::MoveIdle(MovementSlot slot) +void MotionMaster::MoveIdle() { - //if (empty() || !isStatic(top())) - // push(&si_idleMovement); - if (!isStatic(Impl[slot])) - Mutate(&si_idleMovement, slot); + //! Should be preceded by MovementExpired or Clear if there's an overlying movementgenerator active + if (empty() || !isStatic(top())) + Mutate(&si_idleMovement, MOTION_SLOT_IDLE); } void MotionMaster::MoveRandom(float spawndist) diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index 64026ea7b80..a972c3b06ce 100755 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -142,7 +142,7 @@ class MotionMaster //: private std::stack DirectExpire(reset); } - void MoveIdle(MovementSlot slot = MOTION_SLOT_ACTIVE); + void MoveIdle(); void MoveTargetedHome(); void MoveRandom(float spawndist = 0.0f); void MoveFollow(Unit* target, float dist, float angle, MovementSlot slot = MOTION_SLOT_ACTIVE); diff --git a/src/server/game/Server/Protocol/Handlers/PetHandler.cpp b/src/server/game/Server/Protocol/Handlers/PetHandler.cpp index fc13ef802fd..68ce3153450 100755 --- a/src/server/game/Server/Protocol/Handlers/PetHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/PetHandler.cpp @@ -155,6 +155,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid case COMMAND_STAY: //flat=1792 //STAY pet->AttackStop(); pet->InterruptNonMeleeSpells(false); + pet->GetMotionMaster()->Clear(false); pet->GetMotionMaster()->MoveIdle(); charmInfo->SetCommandState(COMMAND_STAY); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 25610341a2f..46c1cf425ed 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -638,7 +638,7 @@ class npc_spinestalker : public CreatureScript float moveTime = me->GetExactDist(&SpinestalkerFlyPos) / (me->GetSpeed(MOVE_FLIGHT) * 0.001f); me->m_Events.AddEvent(new FrostwyrmLandEvent(*me, SpinestalkerLandPos), me->m_Events.CalculateTime(uint64(moveTime) + 250)); me->SetDefaultMovementType(IDLE_MOTION_TYPE); - me->GetMotionMaster()->MoveIdle(MOTION_SLOT_IDLE); + me->GetMotionMaster()->MoveIdle(); me->StopMoving(); me->GetMotionMaster()->MovePoint(POINT_FROSTWYRM_FLY_IN, SpinestalkerFlyPos); } @@ -753,7 +753,7 @@ class npc_rimefang : public CreatureScript float moveTime = me->GetExactDist(&RimefangFlyPos) / (me->GetSpeed(MOVE_FLIGHT) * 0.001f); me->m_Events.AddEvent(new FrostwyrmLandEvent(*me, RimefangLandPos), me->m_Events.CalculateTime(uint64(moveTime) + 250)); me->SetDefaultMovementType(IDLE_MOTION_TYPE); - me->GetMotionMaster()->MoveIdle(MOTION_SLOT_IDLE); + me->GetMotionMaster()->MoveIdle(); me->StopMoving(); me->GetMotionMaster()->MovePoint(POINT_FROSTWYRM_FLY_IN, RimefangFlyPos); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 1fbdb7f4677..f2657e5b2ef 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -1656,7 +1656,8 @@ class npc_strangulate_vehicle : public CreatureScript switch (eventId) { case EVENT_TELEPORT: - me->GetMotionMaster()->MoveIdle(MOTION_SLOT_ACTIVE); + me->GetMotionMaster()->Clear(false); + me->GetMotionMaster()->MoveIdle(); if (TempSummon* summ = me->ToTempSummon()) { if (Unit* summoner = summ->GetSummoner()) -- cgit v1.2.3 From d9a75b38281a080e01a50466175d8f94373a5386 Mon Sep 17 00:00:00 2001 From: zxbiohazardzx Date: Sat, 14 Jan 2012 09:40:00 +0100 Subject: Core/Scripts: remove obsolete scripts for Orsonn and Kodian related to #4788 --- src/server/scripts/Northrend/grizzly_hills.cpp | 107 ------------------------- 1 file changed, 107 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/Northrend/grizzly_hills.cpp b/src/server/scripts/Northrend/grizzly_hills.cpp index de0c6a909ad..9eb73463795 100644 --- a/src/server/scripts/Northrend/grizzly_hills.cpp +++ b/src/server/scripts/Northrend/grizzly_hills.cpp @@ -16,115 +16,9 @@ * with this program. If not, see . */ -/* ScriptData -SDName: Grizzly_Hills -SD%Complete: 80 -SDComment: Quest support: 12231, 12247 -SDCategory: Grizzly Hills -EndScriptData */ - -/* ContentData -npc_orsonn_and_kodian -EndContentData */ - #include "ScriptPCH.h" #include "ScriptedEscortAI.h" -#define GOSSIP_ITEM1 "You're free to go Orsonn, but first tell me what's wrong with the furbolg." -#define GOSSIP_ITEM2 "What happened then?" -#define GOSSIP_ITEM3 "Thank you, Son of Ursoc. I'll see what can be done." -#define GOSSIP_ITEM4 "Who was this stranger?" -#define GOSSIP_ITEM5 "Thank you, Kodian. I'll do what I can." - -enum eEnums -{ - GOSSIP_TEXTID_ORSONN1 = 12793, - GOSSIP_TEXTID_ORSONN2 = 12794, - GOSSIP_TEXTID_ORSONN3 = 12796, - - GOSSIP_TEXTID_KODIAN1 = 12797, - GOSSIP_TEXTID_KODIAN2 = 12798, - - NPC_ORSONN = 27274, - NPC_KODIAN = 27275, - - //trigger creatures - NPC_ORSONN_CREDIT = 27322, - NPC_KODIAN_CREDIT = 27321, - - QUEST_CHILDREN_OF_URSOC = 12247, - QUEST_THE_BEAR_GODS_OFFSPRING = 12231 -}; - -class npc_orsonn_and_kodian : public CreatureScript -{ -public: - npc_orsonn_and_kodian() : CreatureScript("npc_orsonn_and_kodian") { } - - bool OnGossipHello(Player* player, Creature* creature) - { - if (creature->isQuestGiver()) - player->PrepareQuestMenu(creature->GetGUID()); - - if (player->GetQuestStatus(QUEST_CHILDREN_OF_URSOC) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(QUEST_THE_BEAR_GODS_OFFSPRING) == QUEST_STATUS_INCOMPLETE) - { - switch (creature->GetEntry()) - { - case NPC_ORSONN: - if (!player->GetReqKillOrCastCurrentCount(QUEST_CHILDREN_OF_URSOC, NPC_ORSONN_CREDIT) || !player->GetReqKillOrCastCurrentCount(QUEST_THE_BEAR_GODS_OFFSPRING, NPC_ORSONN_CREDIT)) - { - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_ORSONN1, creature->GetGUID()); - return true; - } - break; - case NPC_KODIAN: - if (!player->GetReqKillOrCastCurrentCount(QUEST_CHILDREN_OF_URSOC, NPC_KODIAN_CREDIT) || !player->GetReqKillOrCastCurrentCount(QUEST_THE_BEAR_GODS_OFFSPRING, NPC_KODIAN_CREDIT)) - { - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_KODIAN1, creature->GetGUID()); - return true; - } - break; - } - } - - player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); - return true; - } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction) - { - player->PlayerTalkClass->ClearMenus(); - switch (uiAction) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_ORSONN2, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_ORSONN3, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->CLOSE_GOSSIP_MENU(); - player->TalkedToCreature(NPC_ORSONN_CREDIT, creature->GetGUID()); - break; - - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_KODIAN2, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->CLOSE_GOSSIP_MENU(); - player->TalkedToCreature(NPC_KODIAN_CREDIT, creature->GetGUID()); - break; - } - - return true; - } -}; - /*###### ## Quest 12027: Mr. Floppy's Perilous Adventure ######*/ @@ -801,7 +695,6 @@ public: void AddSC_grizzly_hills() { - new npc_orsonn_and_kodian; new npc_emily; new npc_mrfloppy; new npc_outhouse_bunny; -- cgit v1.2.3 From dbbac0bdaae4b6d8a0125999962c4a686092bd80 Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Sat, 14 Jan 2012 15:34:41 +0100 Subject: Core/Movement: Implement spline movement subsystem. Spline movement controls movements of server-side controlled units (monster movement, taxi movement, etc). Proper implementation of effects such as charge, jump, cyclic movement will rely on it. However, need improve our states system before. Technical changes: * Added linear, catmullrom and bezier3 splines which based on client's algorthims. They can be reused for proper transport position interpolation. * Precission increased. There are no more position desync issues since client's position calculation formulas used. * Now possible to move by paths with multiple points, send whole path to client. -- Original author of research and implementation: SilverIce. Massive kudos. Original port for Trinity (ref #4629) Chaplain and Venugh With the following incremental fixes during my review: - Restore flightmaster end grid pre-loading - Fix uninitialized Creature::m_path_id - Add missing trinity_string entries for .movegens command - Fix a bug in WaypointMovementGenerator that would trigger unexpected pausing at waypoints for various amounts of time Known issues: - Errors like WaypointMovementGenerator::LoadPath creature XXX (Entry: YYYYY GUID: ZZZZZZ) doesn't have waypoint path id: 0. This is caused by bad DB data. This commit didn't "break" it. Do not forget to re-run CMake before compiling. --- .../world/2011_01_14_03_world_trinity_string.sql | 6 + src/server/game/AI/CoreAI/GuardAI.cpp | 4 +- src/server/game/AI/CoreAI/PetAI.cpp | 9 +- src/server/game/AI/EventAI/CreatureEventAI.cpp | 5 +- src/server/game/AI/ScriptedAI/ScriptedCreature.cpp | 3 +- .../game/AI/ScriptedAI/ScriptedFollowerAI.cpp | 4 +- src/server/game/AI/SmartScripts/SmartScript.cpp | 6 +- src/server/game/CMakeLists.txt | 2 + src/server/game/Chat/Commands/Level3.cpp | 61 +-- src/server/game/Entities/Creature/Creature.cpp | 72 ++-- src/server/game/Entities/Creature/Creature.h | 4 +- .../game/Entities/Creature/CreatureGroups.cpp | 4 +- src/server/game/Entities/GameObject/GameObject.cpp | 2 +- src/server/game/Entities/Object/Object.cpp | 139 +++---- src/server/game/Entities/Object/Object.h | 3 + src/server/game/Entities/Player/Player.cpp | 38 +- src/server/game/Entities/Player/Player.h | 1 - src/server/game/Entities/Unit/Unit.cpp | 252 ++++--------- src/server/game/Entities/Unit/Unit.h | 126 ++----- src/server/game/Maps/Map.cpp | 18 + src/server/game/Maps/Map.h | 2 + src/server/game/Maps/MapManager.cpp | 1 - src/server/game/Miscellaneous/Language.h | 12 +- src/server/game/Movement/DestinationHolder.cpp | 20 - src/server/game/Movement/DestinationHolder.h | 65 ---- src/server/game/Movement/DestinationHolderImp.h | 215 ----------- src/server/game/Movement/MotionMaster.cpp | 160 ++++---- src/server/game/Movement/MotionMaster.h | 15 +- src/server/game/Movement/MovementGenerator.cpp | 1 - src/server/game/Movement/MovementGenerator.h | 2 - .../ConfusedMovementGenerator.cpp | 124 +++--- .../MovementGenerators/ConfusedMovementGenerator.h | 13 +- .../FleeingMovementGenerator.cpp | 123 +++--- .../MovementGenerators/FleeingMovementGenerator.h | 7 +- .../MovementGenerators/HomeMovementGenerator.cpp | 57 ++- .../MovementGenerators/HomeMovementGenerator.h | 12 +- .../MovementGenerators/PointMovementGenerator.cpp | 104 +++--- .../MovementGenerators/PointMovementGenerator.h | 30 +- .../MovementGenerators/RandomMovementGenerator.cpp | 188 ++++------ .../MovementGenerators/RandomMovementGenerator.h | 12 +- .../TargetedMovementGenerator.cpp | 357 ++++++++++-------- .../MovementGenerators/TargetedMovementGenerator.h | 92 +++-- .../WaypointMovementGenerator.cpp | 416 +++++++++------------ .../MovementGenerators/WaypointMovementGenerator.h | 90 +++-- src/server/game/Movement/Spline/MoveSpline.cpp | 316 ++++++++++++++++ src/server/game/Movement/Spline/MoveSpline.h | 127 +++++++ src/server/game/Movement/Spline/MoveSplineFlag.h | 143 +++++++ src/server/game/Movement/Spline/MoveSplineInit.cpp | 119 ++++++ src/server/game/Movement/Spline/MoveSplineInit.h | 170 +++++++++ .../game/Movement/Spline/MoveSplineInitArgs.h | 67 ++++ .../game/Movement/Spline/MovementPacketBuilder.cpp | 188 ++++++++++ .../game/Movement/Spline/MovementPacketBuilder.h | 37 ++ src/server/game/Movement/Spline/MovementTypedefs.h | 81 ++++ src/server/game/Movement/Spline/MovementUtil.cpp | 208 +++++++++++ src/server/game/Movement/Spline/Spline.cpp | 307 +++++++++++++++ src/server/game/Movement/Spline/Spline.h | 212 +++++++++++ src/server/game/Movement/Spline/SplineImpl.h | 97 +++++ src/server/game/Movement/Traveller.h | 152 -------- src/server/game/Scripting/MapScripts.cpp | 10 +- .../game/Server/Protocol/Handlers/TaxiHandler.cpp | 1 - src/server/game/Spells/Auras/SpellAuraEffects.cpp | 6 +- src/server/game/Spells/SpellEffects.cpp | 17 +- src/server/scripts/Commands/cs_npc.cpp | 5 +- .../EasternKingdoms/ScarletEnclave/chapter1.cpp | 2 +- .../EasternKingdoms/ZulAman/boss_akilzon.cpp | 2 +- src/server/scripts/EasternKingdoms/undercity.cpp | 4 +- .../TrialOfTheCrusader/boss_anubarak_trial.cpp | 6 +- .../FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp | 2 +- .../IcecrownCitadel/boss_blood_prince_council.cpp | 2 +- .../IcecrownCitadel/boss_deathbringer_saurfang.cpp | 4 +- .../IcecrownCitadel/boss_the_lich_king.cpp | 20 +- .../Northrend/IcecrownCitadel/icecrown_citadel.cpp | 2 +- .../Northrend/Nexus/EyeOfEternity/boss_malygos.cpp | 2 +- .../Ulduar/HallsOfLightning/boss_volkhan.cpp | 4 +- .../Ulduar/HallsOfStone/boss_krystallus.cpp | 2 +- .../Ulduar/Ulduar/boss_assembly_of_iron.cpp | 2 +- .../UtgardeKeep/UtgardePinnacle/boss_skadi.cpp | 2 +- .../UtgardeKeep/UtgardePinnacle/boss_svala.cpp | 27 +- .../ManaTombs/boss_nexusprince_shaffar.cpp | 2 +- .../scripts/Outland/BlackTemple/boss_illidan.cpp | 2 +- .../scripts/Outland/GruulsLair/boss_gruul.cpp | 2 +- .../Outland/TempestKeep/Eye/boss_kaelthas.cpp | 4 +- src/server/scripts/World/guards.cpp | 2 +- src/server/shared/Utilities/Timer.h | 2 +- 84 files changed, 3325 insertions(+), 1912 deletions(-) create mode 100644 sql/updates/world/2011_01_14_03_world_trinity_string.sql delete mode 100755 src/server/game/Movement/DestinationHolder.cpp delete mode 100755 src/server/game/Movement/DestinationHolder.h delete mode 100755 src/server/game/Movement/DestinationHolderImp.h create mode 100644 src/server/game/Movement/Spline/MoveSpline.cpp create mode 100644 src/server/game/Movement/Spline/MoveSpline.h create mode 100644 src/server/game/Movement/Spline/MoveSplineFlag.h create mode 100644 src/server/game/Movement/Spline/MoveSplineInit.cpp create mode 100644 src/server/game/Movement/Spline/MoveSplineInit.h create mode 100644 src/server/game/Movement/Spline/MoveSplineInitArgs.h create mode 100644 src/server/game/Movement/Spline/MovementPacketBuilder.cpp create mode 100644 src/server/game/Movement/Spline/MovementPacketBuilder.h create mode 100644 src/server/game/Movement/Spline/MovementTypedefs.h create mode 100644 src/server/game/Movement/Spline/MovementUtil.cpp create mode 100644 src/server/game/Movement/Spline/Spline.cpp create mode 100644 src/server/game/Movement/Spline/Spline.h create mode 100644 src/server/game/Movement/Spline/SplineImpl.h delete mode 100755 src/server/game/Movement/Traveller.h (limited to 'src/server/scripts/Northrend') diff --git a/sql/updates/world/2011_01_14_03_world_trinity_string.sql b/sql/updates/world/2011_01_14_03_world_trinity_string.sql new file mode 100644 index 00000000000..7dab007f774 --- /dev/null +++ b/sql/updates/world/2011_01_14_03_world_trinity_string.sql @@ -0,0 +1,6 @@ +DELETE FROM `trinity_string` WHERE `entry` IN(1139,1140,1141,1142); +INSERT INTO `trinity_string` (`entry`,`content_default`) VALUES +(1139,' Follow player %s (lowguid %u)'), +(1140,' Follow creature %s (lowguid %u)'), +(1141,' Follow '), +(1142,' Effect movement'); diff --git a/src/server/game/AI/CoreAI/GuardAI.cpp b/src/server/game/AI/CoreAI/GuardAI.cpp index 54061274408..b78fec7c142 100755 --- a/src/server/game/AI/CoreAI/GuardAI.cpp +++ b/src/server/game/AI/CoreAI/GuardAI.cpp @@ -115,8 +115,8 @@ void GuardAI::EnterEvadeMode() me->CombatStop(true); i_state = STATE_NORMAL; - // Remove TargetedMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + // Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) me->GetMotionMaster()->MoveTargetedHome(); } diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 60151e4865a..015e20415b1 100755 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -417,10 +417,9 @@ void PetAI::MovementInform(uint32 moveType, uint32 data) me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); } + break; } - break; - - case TARGETED_MOTION_TYPE: + case FOLLOW_MOTION_TYPE: { // If data is owner's GUIDLow then we've reached follow point, // otherwise we're probably chasing a creature @@ -430,11 +429,9 @@ void PetAI::MovementInform(uint32 moveType, uint32 data) me->GetCharmInfo()->SetIsReturning(false); me->GetCharmInfo()->SetIsFollowing(true); me->GetCharmInfo()->SetIsCommandAttack(false); - me->AddUnitState(UNIT_STAT_FOLLOW); } + break; } - break; - default: break; } diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index c7590ebb512..c507262bd3f 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -475,7 +475,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 //Melee current victim if flag not set if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM)) { - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) { m_AttackDistance = 0.0f; m_AttackAngle = 0.0f; @@ -483,7 +483,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 me->GetMotionMaster()->MoveChase(me->getVictim(), m_AttackDistance, m_AttackAngle); } } - } else { @@ -595,7 +594,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 me->ClearUnitState(UNIT_STAT_MELEE_ATTACKING); me->SendMeleeAttackStop(victim); } - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) me->GetMotionMaster()->MoveIdle(); } } diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index e3518cb6921..1b6fde6d132 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -298,7 +298,8 @@ void ScriptedAI::DoModifyThreatPercent(Unit* unit, int32 pct) void ScriptedAI::DoTeleportTo(float x, float y, float z, uint32 time) { me->Relocate(x, y, z); - me->SendMonsterMove(x, y, z, time); + float speed = me->GetDistance(x, y, z) / ((float)time * 0.001f); + me->MonsterMoveWithSpeed(x, y, z, speed); } void ScriptedAI::DoTeleportTo(const float position[4]) diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index 1e0b212dd45..53747d0c799 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -167,7 +167,7 @@ void FollowerAI::EnterEvadeMode() { sLog->outDebug(LOG_FILTER_TSCR, "TSCR: FollowerAI left combat, returning to CombatStartPosition."); - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) { float fPosX, fPosY, fPosZ; me->GetPosition(fPosX, fPosY, fPosZ); @@ -176,7 +176,7 @@ void FollowerAI::EnterEvadeMode() } else { - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) me->GetMotionMaster()->MoveTargetedHome(); } diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 9cea61c0d2b..4328eafc962 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1273,11 +1273,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); if (e.GetTargetType() == SMART_TARGET_SELF) - me->SetFacing(me->GetHomePosition().GetOrientation(), NULL); + me->SetFacingTo(me->GetHomePosition().GetOrientation()); else if (e.GetTargetType() == SMART_TARGET_POSITION) - me->SetFacing(e.target.o, NULL); + me->SetFacingTo(e.target.o); else if (targets && !targets->empty()) - me->SetFacing(0, (*targets->begin())); + me->SetFacingToObject(*targets->begin()); delete targets; break; diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt index 117a8f680ee..658e9a15cc8 100644 --- a/src/server/game/CMakeLists.txt +++ b/src/server/game/CMakeLists.txt @@ -102,6 +102,7 @@ set(game_STAT_SRCS include_directories( ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/dep/g3dlite/include ${CMAKE_SOURCE_DIR}/dep/mersennetwister ${CMAKE_SOURCE_DIR}/dep/SFMT ${CMAKE_SOURCE_DIR}/dep/zlib @@ -170,6 +171,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/Maps ${CMAKE_CURRENT_SOURCE_DIR}/Miscellaneous ${CMAKE_CURRENT_SOURCE_DIR}/Movement + ${CMAKE_CURRENT_SOURCE_DIR}/Movement/Spline ${CMAKE_CURRENT_SOURCE_DIR}/Movement/MovementGenerators ${CMAKE_CURRENT_SOURCE_DIR}/Movement/Waypoints ${CMAKE_CURRENT_SOURCE_DIR}/OutdoorPvP diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp index d23a429471f..cb3eb825354 100755 --- a/src/server/game/Chat/Commands/Level3.cpp +++ b/src/server/game/Chat/Commands/Level3.cpp @@ -3692,6 +3692,9 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/) PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUIDLow()); MotionMaster* mm = unit->GetMotionMaster(); + float x,y,z; + mm->GetDestination(x,y,z); + for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i) { MovementGenerator* mg = mm->GetMotionSlot(i); @@ -3707,48 +3710,55 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/) case WAYPOINT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_WAYPOINT); break; case ANIMAL_RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_ANIMAL_RANDOM); break; case CONFUSED_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_CONFUSED); break; - case TARGETED_MOTION_TYPE: + case CHASE_MOTION_TYPE: { + Unit* target = NULL; if (unit->GetTypeId() == TYPEID_PLAYER) - { - TargetedMovementGenerator const* mgen = static_cast const*>(mg); - Unit* target = mgen->GetTarget(); - if (target) - PSendSysMessage(LANG_MOVEGENS_TARGETED_PLAYER, target->GetName(), target->GetGUIDLow()); - else - SendSysMessage(LANG_MOVEGENS_TARGETED_NULL); - } + target = static_cast const*>(mg)->GetTarget(); else - { - TargetedMovementGenerator const* mgen = static_cast const*>(mg); - Unit* target = mgen->GetTarget(); - if (target) - PSendSysMessage(LANG_MOVEGENS_TARGETED_CREATURE, target->GetName(), target->GetGUIDLow()); - else - SendSysMessage(LANG_MOVEGENS_TARGETED_NULL); - } + target = static_cast const*>(mg)->GetTarget(); + + if (!target) + SendSysMessage(LANG_MOVEGENS_CHASE_NULL); + else if (target->GetTypeId() == TYPEID_PLAYER) + PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUIDLow()); + else + PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUIDLow()); break; } + case FOLLOW_MOTION_TYPE: + { + Unit* target = NULL; + if (unit->GetTypeId() == TYPEID_PLAYER) + target = static_cast const*>(mg)->GetTarget(); + else + target = static_cast const*>(mg)->GetTarget(); + + if (!target) + SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); + else if (target->GetTypeId() == TYPEID_PLAYER) + PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUIDLow()); + else + PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUIDLow()); + break; + } case HOME_MOTION_TYPE: + { if (unit->GetTypeId() == TYPEID_UNIT) - { - float x, y, z; - mg->GetDestination(x, y, z); PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z); - } else SendSysMessage(LANG_MOVEGENS_HOME_PLAYER); break; + } case FLIGHT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FLIGHT); break; case POINT_MOTION_TYPE: { - float x, y, z; - mg->GetDestination(x, y, z); PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z); break; } case FLEEING_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FEAR); break; case DISTRACT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_DISTRACT); break; + case EFFECT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_EFFECT); break; default: PSendSysMessage(LANG_MOVEGENS_UNKNOWN, mg->GetMovementGeneratorType()); break; @@ -4040,19 +4050,14 @@ bool ChatHandler::HandleComeToMeCommand(const char *args) if (!newFlagStr) return false; - uint32 newFlags = (uint32)strtoul(newFlagStr, NULL, 0); - Creature* caster = getSelectedCreature(); if (!caster) { - m_session->GetPlayer()->SetUnitMovementFlags(newFlags); SendSysMessage(LANG_SELECT_CREATURE); SetSentErrorMessage(true); return false; } - caster->SetUnitMovementFlags(newFlags); - Player* player = m_session->GetPlayer(); caster->GetMotionMaster()->MovePoint(0, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index ff627f78ea0..23865dd9e41 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -48,6 +48,8 @@ #include "Vehicle.h" #include "SpellAuraEffects.h" #include "Group.h" +#include "MoveSplineInit.h" +#include "MoveSpline.h" // apply implementation of the singletons TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const @@ -143,7 +145,7 @@ m_PlayerDamageReq(0), m_lootMoney(0), m_lootRecipient(0), m_lootRecipientGroup(0 m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0), m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), -m_creatureInfo(NULL), m_creatureData(NULL), m_formation(NULL) +m_creatureInfo(NULL), m_creatureData(NULL), m_formation(NULL), m_path_id(0) { m_regenTimer = CREATURE_REGEN_INTERVAL; m_valuesCount = UNIT_END; @@ -332,6 +334,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData* data SetSpeed(MOVE_FLIGHT, 1.0f); // using 1.0 rate SetFloatValue(OBJECT_FIELD_SCALE_X, cinfo->scale); + SetLevitate(canFly()); // checked at loading m_defaultMovementType = MovementGeneratorType(cinfo->MovementType); @@ -435,6 +438,17 @@ void Creature::Update(uint32 diff) m_vehicleKit->Reset(); } + if (IsInWater()) + { + if (canSwim()) + AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING); + } + else + { + if (canWalk()) + RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING); + } + switch (m_deathState) { case JUST_ALIVED: @@ -472,9 +486,7 @@ void Creature::Update(uint32 diff) } case CORPSE: { - m_Events.Update(diff); - _UpdateSpells(diff); - + Unit::Update(diff); // deathstate changed on spells update, prevent problems if (m_deathState != CORPSE) break; @@ -565,9 +577,6 @@ void Creature::Update(uint32 diff) m_regenTimer = CREATURE_REGEN_INTERVAL; break; } - case DEAD_FALLING: - GetMotionMaster()->UpdateMotion(diff); - break; default: break; } @@ -945,7 +954,8 @@ void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint3 m_startMove = getMSTime(); m_moveTime = time;*/ - SendMonsterMove(x, y, z, time); + float speed = GetDistance(x, y, z) / ((float)time * 0.001f); + MonsterMoveWithSpeed(x, y, z, speed); } Player* Creature::GetLootRecipient() const @@ -1507,8 +1517,8 @@ void Creature::setDeathState(DeathState s) if (m_formation && m_formation->getLeader() == this) m_formation->FormationReset(true); - if ((canFly() || IsFlying()) && FallGround()) - return; + if ((canFly() || IsFlying())) + i_motionMaster.MoveFall(); Unit::setDeathState(CORPSE); } @@ -1520,7 +1530,7 @@ void Creature::setDeathState(DeathState s) SetLootRecipient(NULL); ResetPlayerDamageReq(); CreatureTemplate const* cinfo = GetCreatureInfo(); - AddUnitMovementFlag(MOVEMENTFLAG_WALKING); + SetWalk(true); if (GetCreatureInfo()->InhabitType & INHABIT_AIR) AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING); if (GetCreatureInfo()->InhabitType & INHABIT_WATER) @@ -1536,24 +1546,6 @@ void Creature::setDeathState(DeathState s) } } -bool Creature::FallGround() -{ - // Let's abort after we called this function one time - if (getDeathState() == DEAD_FALLING) - return false; - - float x, y, z; - GetPosition(x, y, z); - // use larger distance for vmap height search than in most other cases - float ground_Z = GetMap()->GetHeight(x, y, z, true, MAX_FALL_DISTANCE); - if (fabs(ground_Z - z) < 0.1f) - return false; - - GetMotionMaster()->MoveFall(ground_Z, EVENT_FALL_GROUND); - Unit::setDeathState(DEAD_FALLING); - return true; -} - void Creature::Respawn(bool force) { DestroyForNearbyPlayers(); @@ -2415,3 +2407,25 @@ bool Creature::IsDungeonBoss() const CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry()); return cinfo && (cinfo->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS); } + +void Creature::SetWalk(bool enable) +{ + if (enable) + AddUnitMovementFlag(MOVEMENTFLAG_WALKING); + else + RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); + WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_WALK_MODE : SMSG_SPLINE_MOVE_SET_RUN_MODE, 9); + data.append(GetPackGUID()); + SendMessageToSet(&data, true); +} + +void Creature::SetLevitate(bool enable) +{ + if (enable) + AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + else + RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + WorldPacket data(enable ? SMSG_SPLINE_MOVE_GRAVITY_DISABLE : SMSG_SPLINE_MOVE_GRAVITY_ENABLE, 9); + data.append(GetPackGUID()); + SendMessageToSet(&data, true); +} diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index adad02653bf..05339f1da53 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -520,6 +520,9 @@ class Creature : public Unit, public GridObject, public MapCreature void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type); CreatureAI* AI() const { return (CreatureAI*)i_AI; } + void SetWalk(bool enable); + void SetLevitate(bool enable); + uint32 GetShieldBlockValue() const //dunno mob block value { return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20)); @@ -573,7 +576,6 @@ class Creature : public Unit, public GridObject, public MapCreature const char* GetNameForLocaleIdx(LocaleConstant locale_idx) const; void setDeathState(DeathState s); // override virtual Unit::setDeathState - bool FallGround(); bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false); } bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true); diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index abf82dc5919..f440fd497fc 100755 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -212,10 +212,12 @@ void CreatureGroup::FormationReset(bool dismiss) void CreatureGroup::LeaderMoveTo(float x, float y, float z) { + //! To do: This should probably get its own movement generator or use WaypointMovementGenerator. + //! If the leader's path is known, member's path can be plotted as well using formation offsets. if (!m_leader) return; - float pathangle = atan2(m_leader->GetPositionY() - y, m_leader->GetPositionX() - x); + float pathangle = atan2(m_leader->GetPositionY() - y, m_leader->GetPositionX() - x); for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 22f001d0224..fd094938da8 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1869,4 +1869,4 @@ void GameObject::SetLootState(LootState s) { m_lootState = s; AI()->OnStateChanged(s); -} \ No newline at end of file +} diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 3cd02d05a90..5c034f1a42a 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -45,6 +45,7 @@ #include "TemporarySummon.h" #include "Totem.h" #include "OutdoorPvPMgr.h" +#include "MovementPacketBuilder.h" uint32 GuidHigh2TypeId(uint32 guid_hi) { @@ -312,78 +313,17 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const *data << ((Unit*)this)->GetSpeed(MOVE_WALK); *data << ((Unit*)this)->GetSpeed(MOVE_RUN); - *data << ((Unit*)this)->GetSpeed(MOVE_SWIM_BACK); - *data << ((Unit*)this)->GetSpeed(MOVE_SWIM); *data << ((Unit*)this)->GetSpeed(MOVE_RUN_BACK); + *data << ((Unit*)this)->GetSpeed(MOVE_SWIM); + *data << ((Unit*)this)->GetSpeed(MOVE_SWIM_BACK); *data << ((Unit*)this)->GetSpeed(MOVE_FLIGHT); *data << ((Unit*)this)->GetSpeed(MOVE_FLIGHT_BACK); *data << ((Unit*)this)->GetSpeed(MOVE_TURN_RATE); *data << ((Unit*)this)->GetSpeed(MOVE_PITCH_RATE); - const Player* player = ToPlayer(); - // 0x08000000 - if (player && player->isInFlight()) - { - uint32 flags3 = SPLINEFLAG_GLIDE; - - *data << uint32(flags3); // splines flag? - - if (flags3 & 0x20000) // may be orientation - { - *data << (float)0; - } - else - { - if (flags3 & 0x8000) // probably x, y, z coords there - { - *data << (float)0; - *data << (float)0; - *data << (float)0; - } - - if (flags3 & 0x10000) // probably guid there - { - *data << uint64(0); - } - } - - FlightPathMovementGenerator *fmg = - (FlightPathMovementGenerator*)(player->GetMotionMaster()->top()); - TaxiPathNodeList const& path = fmg->GetPath(); - - float x, y, z; - player->GetPosition(x, y, z); - - uint32 inflighttime = uint32(path.GetPassedLength(fmg->GetCurrentNode(), x, y, z) * 32); - uint32 traveltime = uint32(path.GetTotalLength() * 32); - - *data << uint32(inflighttime); // passed move time? - *data << uint32(traveltime); // full move time? - *data << uint32(0); // ticks count? - - *data << float(0); // added in 3.1 - *data << float(0); // added in 3.1 - *data << float(0); // added in 3.1 - - *data << uint32(0); // added in 3.1 - - uint32 poscount = uint32(path.size()); - *data << uint32(poscount); // points count - - for (uint32 i = 0; i < poscount; ++i) - { - *data << float(path[i].x); - *data << float(path[i].y); - *data << float(path[i].z); - } - - *data << uint8(0); // added in 3.0.8 - - *data << float(path[poscount-1].x); - *data << float(path[poscount-1].y); - *data << float(path[poscount-1].z); - } + if (((Unit*)this)->m_movementInfo.GetMovementFlags() & MOVEMENTFLAG_SPLINE_ENABLED) + Movement::PacketBuilder::WriteCreate(*((Unit*)this)->movespline, *data); } else { @@ -487,7 +427,7 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const // 0x200 if (flags & UPDATEFLAG_ROTATION) { - *data << uint64(((GameObject*)this)->GetRotation()); + *data << int64(((GameObject*)this)->GetRotation()); } } @@ -1595,6 +1535,70 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const z = new_z+ 0.05f; // just to be sure that we are not a few pixel under the surface } +void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const +{ + switch (GetTypeId()) + { + case TYPEID_UNIT: + { + // non fly unit don't must be in air + // non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast + if (!((Creature const*)this)->canFly()) + { + bool canSwim = ((Creature const*)this)->canSwim(); + float ground_z = z; + float max_z = canSwim + ? GetBaseMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK)) + : ((ground_z = GetBaseMap()->GetHeight(x, y, z, true))); + if (max_z > INVALID_HEIGHT) + { + if (z > max_z) + z = max_z; + else if (z < ground_z) + z = ground_z; + } + } + else + { + float ground_z = GetBaseMap()->GetHeight(x, y, z, true); + if (z < ground_z) + z = ground_z; + } + break; + } + case TYPEID_PLAYER: + { + // for server controlled moves playr work same as creature (but it can always swim) + if (!((Player const*)this)->canFly()) + { + float ground_z = z; + float max_z = GetBaseMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK)); + if (max_z > INVALID_HEIGHT) + { + if (z > max_z) + z = max_z; + else if (z < ground_z) + z = ground_z; + } + } + else + { + float ground_z = GetBaseMap()->GetHeight(x, y, z, true); + if (z < ground_z) + z = ground_z; + } + break; + } + default: + { + float ground_z = GetBaseMap()->GetHeight(x, y, z, true); + if(ground_z > INVALID_HEIGHT) + z = ground_z; + break; + } + } +} + bool Position::IsPositionValid() const { return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation); @@ -2033,7 +2037,8 @@ void Unit::BuildHeartBeatMsg(WorldPacket* data) const void WorldObject::SendMessageToSet(WorldPacket* data, bool self) { - SendMessageToSetInRange(data, GetVisibilityRange(), self); + if (IsInWorld()) + SendMessageToSetInRange(data, GetVisibilityRange(), self); } void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*self*/) diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 3f78ec662e8..4cc298e4349 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -497,7 +497,9 @@ struct MovementInfo } uint32 GetMovementFlags() { return flags; } + void SetMovementFlags(uint32 flag) { flags = flag; } void AddMovementFlag(uint32 flag) { flags |= flag; } + void RemoveMovementFlag(uint32 flag) { flags &= ~flag; } bool HasMovementFlag(uint32 flag) const { return flags & flag; } uint16 GetExtraMovementFlags() { return flags2; } @@ -615,6 +617,7 @@ class WorldObject : public Object, public WorldLocation return (m_valuesCount > UNIT_FIELD_COMBATREACH) ? m_floatValues[UNIT_FIELD_COMBATREACH] : DEFAULT_WORLD_OBJECT_SIZE; } void UpdateGroundPositionZ(float x, float y, float &z) const; + void UpdateAllowedPositionZ(float x, float y, float &z) const; void GetRandomPoint(const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const; void GetRandomPoint(const Position &srcPos, float distance, Position &pos) const diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 7f7facfaff1..46f903ee71a 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -2101,6 +2101,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // reset movement flags at teleport, because player will continue move with these flags after teleport SetUnitMovementFlags(0); + DisableSpline(); if (m_transport) { @@ -5148,43 +5149,10 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) } } -/** - * FallMode = 0 implies that the player is dying, or already dead, and the proper death state will be set. - * = 1 simply causes the player to plummet towards the ground, and not suffer any damage. - * = 2 causes the player to plummet towards the ground, and causes falling damage, regardless - * of any auras that might of prevented fall damage. - */ -bool Player::FallGround(uint8 FallMode) -{ - // Let's abort after we called this function one time - if (getDeathState() == DEAD_FALLING && FallMode == 0) - return false; - - float x, y, z; - GetPosition(x, y, z); - float ground_Z = GetMap()->GetHeight(x, y, z); - float z_diff = 0.0f; - if ((z_diff = fabs(ground_Z - z)) < 0.1f) - return false; - - GetMotionMaster()->MoveFall(ground_Z, EVENT_FALL_GROUND); - - // Below formula for falling damage is from Player::HandleFall - if (FallMode == 2 && z_diff >= 14.57f) - { - uint32 damage = std::min(GetMaxHealth(), (uint32)((0.018f * z_diff - 0.2426f) * GetMaxHealth() * sWorld->getRate(RATE_DAMAGE_FALL))); - if (damage) - EnvironmentalDamage(DAMAGE_FALL, damage); - } - else if (FallMode == 0) - Unit::setDeathState(DEAD_FALLING); - return true; -} - void Player::KillPlayer() { if (IsFlying() && !GetTransport()) - FallGround(); + i_motionMaster.MoveFall(); SetMovement(MOVE_ROOT); @@ -21474,8 +21442,6 @@ void Player::SendInitialVisiblePackets(Unit* target) SendAurasForTarget(target); if (target->isAlive()) { - if (target->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE) - target->SendMonsterMoveWithSpeedToCurrentDestination(this); if (target->HasUnitState(UNIT_STAT_MELEE_ATTACKING) && target->getVictim()) target->SendMeleeAttackStart(target->getVictim()); } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 21c87a993dc..aa1d4e8185e 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1964,7 +1964,6 @@ class Player : public Unit, public GridObject Corpse* GetCorpse() const; void SpawnCorpseBones(); void CreateCorpse(); - bool FallGround(uint8 FallMode = 0); void KillPlayer(); uint32 GetResurrectionSpellId(); void ResurrectPlayer(float restore_percent, bool applySickness = false); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 2d6e8f1b724..63aa7771063 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -45,16 +45,16 @@ #include "InstanceSaveMgr.h" #include "GridNotifiersImpl.h" #include "CellImpl.h" -#include "Path.h" #include "CreatureGroups.h" #include "PetAI.h" #include "PassiveAI.h" -#include "Traveller.h" #include "TemporarySummon.h" #include "Vehicle.h" #include "Transport.h" #include "InstanceScript.h" #include "SpellInfo.h" +#include "MoveSplineInit.h" +#include "MoveSpline.h" #include @@ -62,9 +62,9 @@ float baseMoveSpeed[MAX_MOVE_TYPE] = { 2.5f, // MOVE_WALK 7.0f, // MOVE_RUN - 2.5f, // MOVE_RUN_BACK + 4.5f, // MOVE_RUN_BACK 4.722222f, // MOVE_SWIM - 4.5f, // MOVE_SWIM_BACK + 2.5f, // MOVE_SWIM_BACK 3.141594f, // MOVE_TURN_RATE 7.0f, // MOVE_FLIGHT 4.5f, // MOVE_FLIGHT_BACK @@ -73,9 +73,9 @@ float baseMoveSpeed[MAX_MOVE_TYPE] = float playerBaseMoveSpeed[MAX_MOVE_TYPE] = { 2.5f, // MOVE_WALK 7.0f, // MOVE_RUN - 2.5f, // MOVE_RUN_BACK + 4.5f, // MOVE_RUN_BACK 4.722222f, // MOVE_SWIM - 4.5f, // MOVE_SWIM_BACK + 2.5f, // MOVE_SWIM_BACK 3.141594f, // MOVE_TURN_RATE 7.0f, // MOVE_FLIGHT 4.5f, // MOVE_FLIGHT_BACK @@ -148,7 +148,7 @@ Unit::Unit(bool isWorldObject): WorldObject(isWorldObject), m_movedPlayer(NULL), m_lastSanctuaryTime(0), IsAIEnabled(false), NeedChangeAI(false), m_ControlledByPlayer(false), i_AI(NULL), i_disabledAI(NULL), m_procDeep(0), m_removedAurasCount(0), i_motionMaster(this), m_ThreatManager(this), m_vehicle(NULL), -m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), m_HostileRefManager(this) +m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), m_HostileRefManager(this), movespline(new Movement::MoveSpline()) { #ifdef _MSC_VER #pragma warning(default:4355) @@ -280,6 +280,7 @@ Unit::~Unit() delete m_charmInfo; delete m_vehicleKit; + delete movespline; ASSERT(!m_duringRemoveFromWorld); ASSERT(!m_attacking); @@ -346,6 +347,7 @@ void Unit::Update(uint32 p_time) ModifyAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, HealthAbovePct(75)); } + UpdateSplineMovement(p_time); i_motionMaster.UpdateMotion(p_time); } @@ -357,151 +359,46 @@ bool Unit::haveOffhandWeapon() const return m_canDualWield; } -void Unit::SendMonsterMoveWithSpeedToCurrentDestination(Player* player) +void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed) { - float x, y, z; - if (GetMotionMaster()->GetDestination(x, y, z)) - SendMonsterMoveWithSpeed(x, y, z, 0, player); -} - -void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime, Player* player) -{ - if (!transitTime) - { - if (GetTypeId() == TYPEID_PLAYER) - { - Traveller traveller(*(Player*)this); - transitTime = traveller.GetTotalTrevelTimeTo(x, y, z); - } - else - { - Traveller traveller(*ToCreature()); - transitTime = traveller.GetTotalTrevelTimeTo(x, y, z); - } - } - //float orientation = (float)atan2((double)dy, (double)dx); - SendMonsterMove(x, y, z, transitTime, player); + Movement::MoveSplineInit init(*this); + init.MoveTo(x,y,z); + init.SetVelocity(speed); + init.Launch(); } -void Unit::SetFacing(float ori, WorldObject* obj) +void Unit::UpdateSplineMovement(uint32 t_diff) { - SetOrientation(obj ? GetAngle(obj) : ori); - - WorldPacket data(SMSG_MONSTER_MOVE, (1+12+4+1+(obj ? 8 : 4)+4+4+4+12+GetPackGUID().size())); - data.append(GetPackGUID()); - data << uint8(0); // unk - data << GetPositionX() << GetPositionY() << GetPositionZ(); - data << getMSTime(); - if (obj) - { - data << uint8(SPLINETYPE_FACING_TARGET); - data << uint64(obj->GetGUID()); - } - else - { - data << uint8(SPLINETYPE_FACING_ANGLE); - data << ori; - } - data << uint32(SPLINEFLAG_NONE); - data << uint32(0); // move time 0 - data << uint32(1); // one point - data << GetPositionX() << GetPositionY() << GetPositionZ(); - SendMessageToSet(&data, true); -} - -void Unit::SendMonsterStop(bool on_death) -{ - WorldPacket data(SMSG_MONSTER_MOVE, (17 + GetPackGUID().size())); - data.append(GetPackGUID()); - data << uint8(0); // new in 3.1 - data << GetPositionX() << GetPositionY() << GetPositionZ(); - data << getMSTime(); - - if (on_death == true) - { - data << uint8(0); - data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? SPLINEFLAG_FLYING : SPLINEFLAG_WALKING); - data << uint32(0); // Time in between points - data << uint32(1); // 1 single waypoint - data << GetPositionX() << GetPositionY() << GetPositionZ(); - } - else - data << uint8(1); - - SendMessageToSet(&data, true); - - ClearUnitState(UNIT_STAT_MOVE); -} - -void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 Time, Player* player) -{ - WorldPacket data(SMSG_MONSTER_MOVE, 1+12+4+1+4+4+4+12+GetPackGUID().size()); - data.append(GetPackGUID()); - - data << uint8(0); // new in 3.1 - data << GetPositionX() << GetPositionY() << GetPositionZ(); - data << getMSTime(); - - data << uint8(0); - data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? SPLINEFLAG_FLYING : SPLINEFLAG_WALKING); - data << Time; // Time in between points - data << uint32(1); // 1 single waypoint - data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B - - if (player) - player->GetSession()->SendPacket(&data); - else - SendMessageToSet(&data, true); - - AddUnitState(UNIT_STAT_MOVE); -} + enum{ + POSITION_UPDATE_DELAY = 400, + }; -void Unit::SendMonsterMove(MonsterMoveData const& moveData, Player* player) -{ - WorldPacket data(SMSG_MONSTER_MOVE, GetPackGUID().size() + 1 + 12 + 4 + 1 + 4 + 8 + 4 + 4 + 12); - data.append(GetPackGUID()); + if (movespline->Finalized()) + return; - data << uint8(0); // new in 3.1 - data << GetPositionX() << GetPositionY() << GetPositionZ(); - data << getMSTime(); + movespline->updateState(t_diff); + bool arrived = movespline->Finalized(); - data << uint8(0); - data << moveData.SplineFlag; + if (arrived) + DisableSpline(); - if (moveData.SplineFlag & SPLINEFLAG_ANIMATIONTIER) + m_movesplineTimer.Update(t_diff); + if (m_movesplineTimer.Passed() || arrived) { - data << uint8(moveData.AnimationState); - data << uint32(0); - } + m_movesplineTimer.Reset(POSITION_UPDATE_DELAY); + Movement::Location loc = movespline->ComputePosition(); - data << moveData.Time; - - if (moveData.SplineFlag & SPLINEFLAG_TRAJECTORY) - { - data << moveData.SpeedZ; - data << uint32(0); // walk time after jump + if (GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->UpdatePosition(loc.x,loc.y,loc.z,loc.orientation); + else + GetMap()->CreatureRelocation((Creature*)this,loc.x,loc.y,loc.z,loc.orientation); } - - data << uint32(1); // waypoint count - data << moveData.DestLocation.GetPositionX(); - data << moveData.DestLocation.GetPositionY(); - data << moveData.DestLocation.GetPositionZ(); - - if (player) - player->GetSession()->SendPacket(&data); - else - SendMessageToSet(&data, true); } -void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 MoveFlags, uint32 time, float speedZ, Player* player) +void Unit::DisableSpline() { - MonsterMoveData data; - data.DestLocation.Relocate(NewPosX, NewPosY, NewPosZ); - data.SplineFlag = MoveFlags; - data.Time = time; - data.SpeedZ = speedZ; - - SendMonsterMove(data, player); + m_movementInfo.RemoveMovementFlag(MovementFlags(MOVEMENTFLAG_SPLINE_ENABLED|MOVEMENTFLAG_FORWARD)); + movespline->_Interrupt(); } void Unit::SendMonsterMoveExitVehicle(Position const* newPos) @@ -3106,17 +3003,6 @@ bool Unit::isInBackInMap(Unit const* target, float distance, float arc) const return IsWithinDistInMap(target, distance) && !HasInArc(2 * M_PI - arc, target); } -void Unit::SetFacingToObject(WorldObject* pObject) -{ - // update orientation at server - SetOrientation(GetAngle(pObject)); - - // and client - WorldPacket data; - BuildHeartBeatMsg(&data); - SendMessageToSet(&data, false); -} - bool Unit::isInAccessiblePlaceFor(Creature const* c) const { if (IsInWater()) @@ -12744,7 +12630,7 @@ void Unit::setDeathState(DeathState s) ClearDiminishings(); GetMotionMaster()->Clear(false); GetMotionMaster()->MoveIdle(); - SendMonsterStop(true); + StopMoving(); // without this when removing IncreaseMaxHealth aura player may stuck with 1 hp // do not why since in IncreaseMaxHealth currenthealth is checked SetHealth(0); @@ -13565,7 +13451,7 @@ void Unit::SetHealth(uint32 val) { if (getDeathState() == JUST_DIED) val = 0; - else if (GetTypeId() == TYPEID_PLAYER && (getDeathState() == DEAD || getDeathState() == DEAD_FALLING)) + else if (GetTypeId() == TYPEID_PLAYER && getDeathState() == DEAD) val = 1; else { @@ -14682,22 +14568,20 @@ void Unit::StopMoving() { ClearUnitState(UNIT_STAT_MOVING); - // send explicit stop packet - // rely on vmaps here because for example stormwind is in air - //float z = sMapMgr->GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); - //if (fabs(GetPositionZ() - z) < 2.0f) - // Relocate(GetPositionX(), GetPositionY(), z); - //Relocate(GetPositionX(), GetPositionY(), GetPositionZ()); + // not need send any packets if not in world + if (!IsInWorld()) + return; - if (!(GetUnitMovementFlags() & MOVEMENTFLAG_ONTRANSPORT)) - SendMonsterStop(); + Movement::MoveSplineInit init(*this); + init.SetFacing(GetOrientation()); + init.Launch(); } void Unit::SendMovementFlagUpdate() { WorldPacket data; BuildHeartBeatMsg(&data); - SendMessageToSet(&data, false); + SendMessageToSet(&data, true); } bool Unit::IsSitState() const @@ -17097,7 +16981,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) WorldPacket data2; BuildHeartBeatMsg(&data2); - SendMessageToSet(&data2, false); + SendMessageToSet(&data2, true); if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION)) if (((Minion*)vehicle->GetBase())->GetOwner() == this) @@ -17116,25 +17000,6 @@ void Unit::_ExitVehicle(Position const* exitPosition) void Unit::BuildMovementPacket(ByteBuffer *data) const { - switch (GetTypeId()) - { - case TYPEID_UNIT: - if (canFly()) - const_cast(this)->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); - break; - case TYPEID_PLAYER: - // remove unknown, unused etc flags for now - const_cast(this)->RemoveUnitMovementFlag(MOVEMENTFLAG_SPLINE_ENABLED); - if (isInFlight()) - { - WPAssert(const_cast(this)->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE); - const_cast(this)->AddUnitMovementFlag(MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_SPLINE_ENABLED); - } - break; - default: - break; - } - *data << uint32(GetUnitMovementFlags()); // movement flags *data << uint16(m_movementInfo.flags2); // 2.3.0 *data << uint32(getMSTime()); // time @@ -17198,13 +17063,13 @@ void Unit::SetFlying(bool apply) void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool casting /*= false*/) { + DisableSpline(); if (GetTypeId() == TYPEID_PLAYER) ToPlayer()->TeleportTo(GetMapId(), x, y, z, orientation, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0)); else { - // FIXME: this interrupts spell visual - DestroyForNearbyPlayers(); UpdatePosition(x, y, z, orientation, true); + SendMovementFlagUpdate(); } } @@ -17486,3 +17351,26 @@ bool CharmInfo::IsReturning() { return m_isReturning; } + +void Unit::SetInFront(Unit const* target) +{ + if (!HasUnitState(UNIT_STAT_CANNOT_TURN)) + SetOrientation(GetAngle(target)); +} + +void Unit::SetFacingTo(float ori) +{ + Movement::MoveSplineInit init(*this); + init.SetFacing(ori); + init.Launch(); +} + +void Unit::SetFacingToObject(WorldObject* pObject) +{ + // never face when already moving + if (!IsStopped()) + return; + + // TODO: figure out under what conditions creature will move towards object instead of facing it where it currently is. + SetFacingTo(GetAngle(pObject)); +} diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 5a6b34bc380..b64a2e210bc 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -465,7 +465,6 @@ enum DeathState CORPSE = 2, DEAD = 3, JUST_ALIVED = 4, - DEAD_FALLING= 5 }; enum UnitState @@ -493,13 +492,22 @@ enum UnitState UNIT_STAT_MOVE = 0x00100000, UNIT_STAT_ROTATING = 0x00200000, UNIT_STAT_EVADE = 0x00400000, + UNIT_STAT_ROAMING_MOVE = 0x00800000, + UNIT_STAT_CONFUSED_MOVE = 0x01000000, + UNIT_STAT_FLEEING_MOVE = 0x02000000, + UNIT_STAT_CHASE_MOVE = 0x04000000, + UNIT_STAT_FOLLOW_MOVE = 0x08000000, UNIT_STAT_UNATTACKABLE = (UNIT_STAT_IN_FLIGHT | UNIT_STAT_ONVEHICLE), - UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE), + //UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE), + // for real move using movegen check and stop (except unstoppable flight) + UNIT_STAT_MOVING = UNIT_STAT_ROAMING_MOVE | UNIT_STAT_CONFUSED_MOVE | UNIT_STAT_FLEEING_MOVE| UNIT_STAT_CHASE_MOVE | UNIT_STAT_FOLLOW_MOVE , UNIT_STAT_CONTROLLED = (UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING), UNIT_STAT_LOST_CONTROL = (UNIT_STAT_CONTROLLED | UNIT_STAT_JUMPING | UNIT_STAT_CHARGING), UNIT_STAT_SIGHTLESS = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_EVADE), UNIT_STAT_CANNOT_AUTOATTACK = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_CASTING), UNIT_STAT_CANNOT_TURN = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_ROTATING), + // stay by different reasons + UNIT_STAT_NOT_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED | UNIT_STAT_DISTRACTED, UNIT_STAT_ALL_STATE = 0xffffffff //(UNIT_STAT_STOPPED | UNIT_STAT_MOVING | UNIT_STAT_IN_COMBAT | UNIT_STAT_IN_FLIGHT) }; @@ -719,59 +727,18 @@ enum MovementFlags2 MOVEMENTFLAG2_UNK15 = 0x00004000, MOVEMENTFLAG2_UNK16 = 0x00008000, }; + enum SplineFlags { - SPLINEFLAG_NONE = 0x00000000, - SPLINEFLAG_FORWARD = 0x00000001, - SPLINEFLAG_BACKWARD = 0x00000002, - SPLINEFLAG_STRAFE_LEFT = 0x00000004, - SPLINEFLAG_STRAFE_RIGHT = 0x00000008, - SPLINEFLAG_LEFT = 0x00000010, - SPLINEFLAG_RIGHT = 0x00000020, - SPLINEFLAG_PITCH_UP = 0x00000040, - SPLINEFLAG_PITCH_DOWN = 0x00000080, - SPLINEFLAG_DONE = 0x00000100, - SPLINEFLAG_FALLING = 0x00000200, - SPLINEFLAG_NO_SPLINE = 0x00000400, - SPLINEFLAG_TRAJECTORY = 0x00000800, - SPLINEFLAG_WALKING = 0x00001000, - SPLINEFLAG_FLYING = 0x00002000, - SPLINEFLAG_KNOCKBACK = 0x00004000, - SPLINEFLAG_FINAL_POINT = 0x00008000, - SPLINEFLAG_FINAL_TARGET = 0x00010000, - SPLINEFLAG_FINAL_FACING = 0x00020000, - SPLINEFLAG_CATMULL_ROM = 0x00040000, - SPLINEFLAG_UNKNOWN20 = 0x00080000, - SPLINEFLAG_UNKNOWN21 = 0x00100000, - SPLINEFLAG_ANIMATIONTIER = 0x00200000, - SPLINEFLAG_UNKNOWN23 = 0x00400000, - SPLINEFLAG_TRANSPORT = 0x00800000, - SPLINEFLAG_EXIT_VEHICLE = 0x01000000, - SPLINEFLAG_UNKNOWN26 = 0x02000000, - SPLINEFLAG_UNKNOWN27 = 0x04000000, - SPLINEFLAG_UNKNOWN28 = 0x08000000, - SPLINEFLAG_UNKNOWN29 = 0x10000000, - SPLINEFLAG_ANIMATION = 0x20000000, - SPLINEFLAG_UNKNOWN31 = 0x40000000, - SPLINEFLAG_UNKNOWN32 = 0x80000000, - - SPLINEFLAG_GLIDE = SPLINEFLAG_WALKING | SPLINEFLAG_FLYING, -}; - -enum SplineMode -{ - SPLINEMODE_LINEAR = 0, - SPLINEMODE_CATMULL_ROM = 1, - SPLINEMODE_BEZIER3 = 2 + SPLINEFLAG_WALKMODE = 0x00001000, + SPLINEFLAG_FLYING = 0x00002000, + SPLINEFLAG_TRANSPORT = 0x00800000, + SPLINEFLAG_EXIT_VEHICLE = 0x01000000, }; enum SplineType { - SPLINETYPE_NORMAL = 0, - SPLINETYPE_STOP = 1, - SPLINETYPE_FACING_SPOT = 2, - SPLINETYPE_FACING_TARGET = 3, - SPLINETYPE_FACING_ANGLE = 4 + SPLINETYPE_FACING_ANGLE = 4, }; enum UnitTypeMask @@ -789,6 +756,10 @@ enum UnitTypeMask UNIT_MASK_ACCESSORY = 0x00000200, }; +namespace Movement{ + class MoveSpline; +} + enum DiminishingLevels { DIMINISHING_LEVEL_1 = 0, @@ -1628,20 +1599,18 @@ class Unit : public WorldObject void JumpTo(float speedXY, float speedZ, bool forward = true); void JumpTo(WorldObject* obj, float speedZ); - void SetFacing(float ori, WorldObject* obj = NULL); - void SendMonsterStop(bool on_death = false); - void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 Time, Player* player = NULL); - void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 MoveFlags, uint32 time, float speedZ, Player* player = NULL); - void SendMonsterMove(MonsterMoveData const& moveData, Player* receiver = NULL); + void MonsterMoveWithSpeed(float x, float y, float z, float speed); + //void SetFacing(float ori, WorldObject* obj = NULL); void SendMonsterMoveExitVehicle(Position const* newPos); //void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL); void SendMonsterMoveTransport(Unit* vehicleOwner); - void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL); - void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL); void SendMovementFlagUpdate(); + bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_LEVITATING);} + bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING);} - template - void SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end); + void SetInFront(Unit const* target); + void SetFacingTo(float ori); + void SetFacingToObject(WorldObject* pObject); void SendChangeCurrentVictimOpcode(HostileReference* pHostileReference); void SendClearThreatListOpcode(); @@ -1951,13 +1920,7 @@ class Unit : public WorldObject void SetBaseWeaponDamage(WeaponAttackType attType, WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; } bool isInFrontInMap(Unit const* target, float distance, float arc = M_PI) const; - void SetInFront(Unit const* target) - { - if (!HasUnitState(UNIT_STAT_CANNOT_TURN)) - SetOrientation(GetAngle(target)); - } bool isInBackInMap(Unit const* target, float distance, float arc = M_PI) const; - void SetFacingToObject(WorldObject* pObject); // Visibility system bool IsVisible() const { return (m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM) > SEC_PLAYER) ? false : true; } @@ -2232,6 +2195,9 @@ class Unit : public WorldObject SetUInt64Value(UNIT_FIELD_TARGET, 0); } + // Movement info + Movement::MoveSpline * movespline; + protected: explicit Unit (bool isWorldObject); @@ -2303,6 +2269,8 @@ class Unit : public WorldObject bool IsAlwaysVisibleFor(WorldObject const* seer) const; bool IsAlwaysDetectableFor(WorldObject const* seer) const; + + void DisableSpline(); private: bool IsTriggeredAtSpellProcEvent(Unit* pVictim, Aura* aura, SpellInfo const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const* & spellProcEvent); bool HandleDummyAuraProc(Unit* pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); @@ -2316,6 +2284,8 @@ class Unit : public WorldObject bool HandleAuraRaidProcFromChargeWithValue(AuraEffect* triggeredByAura); bool HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura); + void UpdateSplineMovement(uint32 t_diff); + // player or player's pet float GetCombatRatingReduction(CombatRating cr) const; uint32 GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const; @@ -2330,6 +2300,7 @@ class Unit : public WorldObject uint32 m_state; // Even derived shouldn't modify uint32 m_CombatTimer; uint32 m_lastManaUse; // msecs + TimeTrackerSmall m_movesplineTimer; Diminishing m_Diminishing; // Manage all Units that are threatened by us @@ -2382,31 +2353,4 @@ namespace Trinity const bool m_ascending; }; } - -template -inline void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end) -{ - uint32 traveltime = uint32(path.GetTotalLength(start, end) * 32); - uint32 pathSize = end - start; - WorldPacket data(SMSG_MONSTER_MOVE, (GetPackGUID().size()+1+4+4+4+4+1+4+4+4+pathSize*4*3)); - data.append(GetPackGUID()); - data << uint8(0); - data << GetPositionX(); - data << GetPositionY(); - data << GetPositionZ(); - data << uint32(getMSTime()); - data << uint8(0); - data << uint32(((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) || isInFlight()) ? (SPLINEFLAG_FLYING|SPLINEFLAG_WALKING) : SPLINEFLAG_WALKING); - data << uint32(traveltime); - data << uint32(pathSize); - - for (uint32 i = start; i < end; ++i) - { - data << float(path[i].x); - data << float(path[i].y); - data << float(path[i].z); - } - - SendMessageToSet(&data, true); -} #endif diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index b2f8e5608a7..df5ec540427 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -1539,6 +1539,24 @@ inline GridMap* Map::GetGrid(float x, float y) return GridMaps[gx][gy]; } +float Map::GetWaterOrGroundLevel(float x, float y, float z, float* ground /*= NULL*/, bool swim /*= false*/) const +{ + if (const_cast(this)->GetGrid(x, y)) + { + // we need ground level (including grid height version) for proper return water level in point + float ground_z = GetHeight(x, y, z, true, 50.0f); + if (ground) + *ground = ground_z; + + LiquidData liquid_status; + + ZLiquidStatus res = getLiquidStatus(x, y, ground_z, MAP_ALL_LIQUIDS, &liquid_status); + return res ? ( swim ? liquid_status.level - 2.0f : liquid_status.level) : ground_z; + } + + return VMAP_INVALID_HEIGHT_VALUE; +} + float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const { // find raw .map surface under Z coordinates diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 9f6b936541e..f3b45bd8f37 100755 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -424,6 +424,8 @@ class Map : public GridRefManager InstanceMap* ToInstanceMap(){ if (IsDungeon()) return reinterpret_cast(this); else return NULL; } const InstanceMap* ToInstanceMap() const { if (IsDungeon()) return (const InstanceMap*)((InstanceMap*)this); else return NULL; } + float GetWaterOrGroundLevel(float x, float y, float z, float* ground = NULL, bool swim = false) const; + private: void LoadMapAndVMap(int gx, int gy); void LoadVMap(int gx, int gy); diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index afb5aa5660f..0fb28008c1e 100755 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -25,7 +25,6 @@ #include "GridDefines.h" #include "MapInstanced.h" #include "InstanceScript.h" -#include "DestinationHolderImp.h" #include "Config.h" #include "World.h" #include "CellImpl.h" diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 66610adc1f0..e751dbf92fe 100755 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -492,9 +492,9 @@ enum TrinityStrings LANG_MOVEGENS_WAYPOINT = 529, LANG_MOVEGENS_ANIMAL_RANDOM = 530, LANG_MOVEGENS_CONFUSED = 531, - LANG_MOVEGENS_TARGETED_PLAYER = 532, - LANG_MOVEGENS_TARGETED_CREATURE = 533, - LANG_MOVEGENS_TARGETED_NULL = 534, + LANG_MOVEGENS_CHASE_PLAYER = 532, + LANG_MOVEGENS_CHASE_CREATURE = 533, + LANG_MOVEGENS_CHASE_NULL = 534, LANG_MOVEGENS_HOME_CREATURE = 535, LANG_MOVEGENS_HOME_PLAYER = 536, LANG_MOVEGENS_FLIGHT = 537, @@ -807,7 +807,11 @@ enum TrinityStrings LANG_CHAR_NOT_BANNED = 1136, LANG_DEV_ON = 1137, LANG_DEV_OFF = 1138, - // Room for more level 3 1139-1199 not used + LANG_MOVEGENS_FOLLOW_PLAYER = 1139, + LANG_MOVEGENS_FOLLOW_CREATURE = 1140, + LANG_MOVEGENS_FOLLOW_NULL = 1141, + LANG_MOVEGENS_EFFECT = 1142, + // Room for more level 3 1143-1199 not used // Debug commands LANG_CINEMATIC_NOT_EXIST = 1200, diff --git a/src/server/game/Movement/DestinationHolder.cpp b/src/server/game/Movement/DestinationHolder.cpp deleted file mode 100755 index 4b763112968..00000000000 --- a/src/server/game/Movement/DestinationHolder.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2008-2012 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "DestinationHolder.h" - diff --git a/src/server/game/Movement/DestinationHolder.h b/src/server/game/Movement/DestinationHolder.h deleted file mode 100755 index 5ae4ee88ce3..00000000000 --- a/src/server/game/Movement/DestinationHolder.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2008-2012 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef TRINITY_DESTINATION_HOLDER_H -#define TRINITY_DESTINATION_HOLDER_H - -#include "Define.h" -#include "Timer.h" - -class WorldObject; -class Map; - -#define TRAVELLER_UPDATE_INTERVAL 300 - -template -class DestinationHolder -{ - TimeTrackerSmall i_tracker; - uint32 i_totalTravelTime; - uint32 i_timeElapsed; - bool i_destSet; - float i_fromX, i_fromY, i_fromZ; - float i_destX, i_destY, i_destZ; - - public: - DestinationHolder() : i_tracker(TRAVELLER_UPDATE_INTERVAL), i_totalTravelTime(0), i_timeElapsed(0), - i_destSet(false), i_fromX(0), i_fromY(0), i_fromZ(0), i_destX(0), i_destY(0), i_destZ(0) {} - - uint32 SetDestination(TRAVELLER &traveller, float dest_x, float dest_y, float dest_z, bool sendMove = true); - void GetDestination(float &x, float &y, float &z) const { x = i_destX; y = i_destY; z = i_destZ; } - bool UpdateExpired(void) const { return i_tracker.Passed(); } - void ResetUpdate(uint32 t = TRAVELLER_UPDATE_INTERVAL) { i_tracker.Reset(t); } - uint32 GetTotalTravelTime(void) const { return i_totalTravelTime; } - void IncreaseTravelTime(uint32 increment) { i_totalTravelTime += increment; } - void ResetTravelTime() { i_totalTravelTime = 0; } - bool HasDestination(void) const { return i_destSet; } - float GetDestinationDiff(float x, float y, float z) const; - bool HasArrived(void) const { return (i_totalTravelTime == 0 || i_timeElapsed >= i_totalTravelTime); } - bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool micro_movement=false); - uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true); - void GetLocationNow(const Map* map, float &x, float &y, float &z, bool is3D = false) const; - void GetLocationNowNoMicroMovement(float &x, float &y, float &z) const; // For use without micro movement - float GetDistance3dFromDestSq(const WorldObject &obj) const; - - private: - void _findOffSetPoint(float x1, float y1, float x2, float y2, float offset, float &x, float &y); - -}; -#endif - diff --git a/src/server/game/Movement/DestinationHolderImp.h b/src/server/game/Movement/DestinationHolderImp.h deleted file mode 100755 index 4d6e6f0c741..00000000000 --- a/src/server/game/Movement/DestinationHolderImp.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (C) 2008-2012 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef TRINITY_DESTINATIONHOLDERIMP_H -#define TRINITY_DESTINATIONHOLDERIMP_H - -#include "MapManager.h" -#include "DestinationHolder.h" - -#include - -template -void -DestinationHolder::_findOffSetPoint(float x1, float y1, float x2, float y2, float offset, float &x, float &y) -{ - /* given the point (x1, y1) and (x2, y2).. need to find the point (x, y) on the same line - * such that the distance from (x, y) to (x2, y2) is offset. - * Let the distance of p1 to p2 = d.. then the ratio of offset/d = (x2-x)/(x2-x1) - * hence x = x2 - (offset/d)*(x2-x1) - * like wise offset/d = (y2-y)/(y2-y1); - */ - if (offset == 0) - { - x = x2; - y = y2; - } - else - { - double x_diff = double(x2 - x1); - double y_diff = double(y2 - y1); - double distance_d = (double)((x_diff*x_diff) + (y_diff * y_diff)); - if (distance_d == 0) - { - x = x2; - y = y2; - } - else - { - distance_d = ::sqrt(distance_d); // starting distance - double distance_ratio = (double)(distance_d - offset)/(double)distance_d; - // line above has revised formula which is more correct, I think - x = (float)(x1 + (distance_ratio*x_diff)); - y = (float)(y1 + (distance_ratio*y_diff)); - } - } -} - -template -uint32 -DestinationHolder::SetDestination(TRAVELLER &traveller, float dest_x, float dest_y, float dest_z, bool sendMove) -{ - i_destSet = true; - i_destX = dest_x; - i_destY = dest_y; - i_destZ = dest_z; - - return StartTravel(traveller, sendMove); -} - -template -uint32 -DestinationHolder::StartTravel(TRAVELLER &traveller, bool sendMove) -{ - if (!i_destSet) return 0; - - i_fromX = traveller.GetPositionX(); - i_fromY = traveller.GetPositionY(); - i_fromZ = traveller.GetPositionZ(); - - i_totalTravelTime = traveller.GetTotalTrevelTimeTo(i_destX, i_destY, i_destZ); - i_timeElapsed = 0; - if (sendMove) - traveller.MoveTo(i_destX, i_destY, i_destZ, i_totalTravelTime); - return i_totalTravelTime; -} - -template -bool -DestinationHolder::UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool micro_movement) -{ - i_timeElapsed += diff; - - // Update every TRAVELLER_UPDATE_INTERVAL - i_tracker.Update(diff); - if (!i_tracker.Passed()) - return false; - else - ResetUpdate(); - - if (!i_destSet) return true; - - float x, y, z; - if (!micro_movement) - GetLocationNowNoMicroMovement(x, y, z); - else - { - if (!traveller.GetTraveller().HasUnitState(UNIT_STAT_MOVING | UNIT_STAT_IN_FLIGHT)) - return true; - - if (traveller.GetTraveller().HasUnitState(UNIT_STAT_IN_FLIGHT)) - GetLocationNow(traveller.GetTraveller().GetBaseMap(), x, y, z, true); // Should reposition Object with right Coord, so I can bypass some Grid Relocation - else - GetLocationNow(traveller.GetTraveller().GetBaseMap(), x, y, z, false); - - // Change movement computation to micro movement based on last tick coords, this makes system work - // even on multiple floors zones without hugh vmaps usage ;) - - // Take care of underrun of uint32 - if (i_totalTravelTime >= i_timeElapsed) - i_totalTravelTime -= i_timeElapsed; // Consider only the remaining part - else - i_totalTravelTime = 0; - - i_timeElapsed = 0; - i_fromX = x; // and change origine - i_fromY = y; // then I take into account only micro movement - i_fromZ = z; - } - - if (traveller.GetTraveller().GetPositionX() != x || traveller.GetTraveller().GetPositionY() != y || traveller.GetTraveller().GetPositionZ() != z) - { - float ori = traveller.GetTraveller().GetAngle(x, y); - traveller.Relocation(x, y, z, ori); - } - - return true; -} - -template -void -DestinationHolder::GetLocationNow(const Map* map, float &x, float &y, float &z, bool is3D) const -{ - if (HasArrived()) - { - x = i_destX; - y = i_destY; - z = i_destZ; - } - else if (HasDestination()) - { - double percent_passed = (double)i_timeElapsed / (double)i_totalTravelTime; - const float distanceX = (float)((i_destX - i_fromX) * percent_passed); - const float distanceY = (float)((i_destY - i_fromY) * percent_passed); - const float distanceZ = (float)((i_destZ - i_fromZ) * percent_passed); - x = i_fromX + distanceX; - y = i_fromY + distanceY; - float z2 = i_fromZ + distanceZ; - // All that is not finished but previous code neither... Traveller need be able to swim. - if (is3D) - z = z2; - else - { - //That part is good for mob Walking on the floor. But the floor is not always what we thought. - z = map->GetHeight(x, y, i_fromZ, false); // Disable cave check - const float groundDist = sqrt(distanceX*distanceX + distanceY*distanceY); - const float zDist = fabs(i_fromZ - z) + 0.000001f; - const float slope = groundDist / zDist; - if (slope < 1.0f) // This prevents the ground returned by GetHeight to be used when in cave - z = z2; // a climb or jump of more than 45 is denied - } - } -} - -template -float -DestinationHolder::GetDistance3dFromDestSq(const WorldObject &obj) const -{ - float x, y, z; - obj.GetPosition(x, y, z); - return (i_destX-x)*(i_destX-x)+(i_destY-y)*(i_destY-y)+(i_destZ-z)*(i_destZ-z); -} - -template -float -DestinationHolder::GetDestinationDiff(float x, float y, float z) const -{ - return sqrt(((x-i_destX)*(x-i_destX)) + ((y-i_destY)*(y-i_destY)) + ((z-i_destZ)*(z-i_destZ))); -} - -template -void -DestinationHolder::GetLocationNowNoMicroMovement(float &x, float &y, float &z) const -{ - if (HasArrived()) - { - x = i_destX; - y = i_destY; - z = i_destZ; - } - else - { - double percent_passed = (double)i_timeElapsed / (double)i_totalTravelTime; - x = (float)(i_fromX + ((i_destX - i_fromX) * percent_passed)); - y = (float)(i_fromY + ((i_destY - i_fromY) * percent_passed)); - z = (float)(i_fromZ + ((i_destZ - i_fromZ) * percent_passed)); - } -} - -#endif - diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 6660da146f0..2656d882009 100755 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -19,7 +19,6 @@ #include "MotionMaster.h" #include "CreatureAISelector.h" #include "Creature.h" -#include "Traveller.h" #include "ConfusedMovementGenerator.h" #include "FleeingMovementGenerator.h" @@ -29,7 +28,8 @@ #include "TargetedMovementGenerator.h" #include "WaypointMovementGenerator.h" #include "RandomMovementGenerator.h" - +#include "MoveSpline.h" +#include "MoveSplineInit.h" #include inline bool isStatic(MovementGenerator *mv) @@ -193,16 +193,23 @@ void MotionMaster::MoveRandom(float spawndist) void MotionMaster::MoveTargetedHome() { - //if (i_owner->HasUnitState(UNIT_STAT_FLEEING)) - // return; - Clear(false); - if (i_owner->GetTypeId() == TYPEID_UNIT) + if (i_owner->GetTypeId()==TYPEID_UNIT && !((Creature*)i_owner)->GetCharmerOrOwnerGUID()) { sLog->outStaticDebug("Creature (Entry: %u GUID: %u) targeted home", i_owner->GetEntry(), i_owner->GetGUIDLow()); Mutate(new HomeMovementGenerator(), MOTION_SLOT_ACTIVE); } + else if (i_owner->GetTypeId()==TYPEID_UNIT && ((Creature*)i_owner)->GetCharmerOrOwnerGUID()) + { + sLog->outStaticDebug("Pet or controlled creature (Entry: %u GUID: %u) targeting home", i_owner->GetEntry(), i_owner->GetGUIDLow() ); + Unit *target = ((Creature*)i_owner)->GetCharmerOrOwner(); + if (target) + { + sLog->outStaticDebug("Following %s (GUID: %u)", target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : ((Creature*)target)->GetDBTableGUIDLow() ); + Mutate(new FollowMovementGenerator(*target,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE), MOTION_SLOT_ACTIVE); + } + } else { sLog->outError("Player (GUID: %u) attempt targeted home", i_owner->GetGUIDLow()); @@ -230,14 +237,14 @@ void MotionMaster::MoveChase(Unit* target, float dist, float angle) if (!target || target == i_owner || i_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE)) return; - i_owner->ClearUnitState(UNIT_STAT_FOLLOW); + //i_owner->ClearUnitState(UNIT_STAT_FOLLOW); if (i_owner->GetTypeId() == TYPEID_PLAYER) { sLog->outStaticDebug("Player (GUID: %u) chase to %s (GUID: %u)", i_owner->GetGUIDLow(), target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow()); - Mutate(new TargetedMovementGenerator(*target, dist, angle), MOTION_SLOT_ACTIVE); + Mutate(new ChaseMovementGenerator(*target,dist,angle), MOTION_SLOT_ACTIVE); } else { @@ -245,7 +252,7 @@ void MotionMaster::MoveChase(Unit* target, float dist, float angle) i_owner->GetEntry(), i_owner->GetGUIDLow(), target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow()); - Mutate(new TargetedMovementGenerator(*target, dist, angle), MOTION_SLOT_ACTIVE); + Mutate(new ChaseMovementGenerator(*target,dist,angle), MOTION_SLOT_ACTIVE); } } @@ -255,13 +262,13 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlo if (!target || target == i_owner || i_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE)) return; - i_owner->AddUnitState(UNIT_STAT_FOLLOW); + //i_owner->AddUnitState(UNIT_STAT_FOLLOW); if (i_owner->GetTypeId() == TYPEID_PLAYER) { sLog->outStaticDebug("Player (GUID: %u) follow to %s (GUID: %u)", i_owner->GetGUIDLow(), target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow()); - Mutate(new TargetedMovementGenerator(*target, dist, angle), slot); + Mutate(new FollowMovementGenerator(*target,dist,angle), slot); } else { @@ -269,7 +276,7 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlo i_owner->GetEntry(), i_owner->GetGUIDLow(), target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow()); - Mutate(new TargetedMovementGenerator(*target, dist, angle), slot); + Mutate(new FollowMovementGenerator(*target,dist,angle), slot); } } @@ -290,54 +297,32 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z) void MotionMaster::MoveLand(uint32 id, Position const& pos, float speed) { - if (i_owner->GetTypeId() != TYPEID_UNIT) - return; - - uint32 moveFlag = SPLINEFLAG_FLYING | SPLINEFLAG_ANIMATIONTIER; - uint32 moveTime = uint32(i_owner->GetExactDist(&pos) / speed) * IN_MILLISECONDS; - - // CHARGING state makes the unit use m_TempSpeed and JUMPING prevents sending movement packet in PointMovementGenerator - i_owner->AddUnitState(UNIT_STAT_CHARGING | UNIT_STAT_JUMPING); - i_owner->m_TempSpeed = speed; - float x, y, z; pos.GetPosition(x, y, z); - sLog->outStaticDebug("Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f)", i_owner->GetEntry(), id, x, y, z); - Mutate(new PointMovementGenerator(id, x, y, z), MOTION_SLOT_ACTIVE); - MonsterMoveData data; - data.DestLocation.Relocate(pos); - data.SplineFlag = moveFlag; - data.Time = moveTime; - data.AnimationState = ANIMATION_ON_GROUND; + sLog->outStaticDebug("Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f)", i_owner->GetEntry(), id, x, y, z); - i_owner->SendMonsterMove(data); + Movement::MoveSplineInit init(*i_owner); + init.MoveTo(x,y,z); + init.SetVelocity(speed); + init.SetAnimation(Movement::ToGround); + init.Launch(); + Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED); } void MotionMaster::MoveTakeoff(uint32 id, Position const& pos, float speed) { - if (i_owner->GetTypeId() != TYPEID_UNIT) - return; - - uint32 moveFlag = SPLINEFLAG_FLYING | SPLINEFLAG_ANIMATIONTIER; - uint32 moveTime = uint32(i_owner->GetExactDist(&pos) / speed) * IN_MILLISECONDS; - - // CHARGING state makes the unit use m_TempSpeed and JUMPING prevents sending movement packet in PointMovementGenerator - i_owner->AddUnitState(UNIT_STAT_CHARGING | UNIT_STAT_JUMPING); - i_owner->m_TempSpeed = speed; - float x, y, z; pos.GetPosition(x, y, z); - sLog->outStaticDebug("Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f)", i_owner->GetEntry(), id, x, y, z); - Mutate(new PointMovementGenerator(id, x, y, z), MOTION_SLOT_ACTIVE); - MonsterMoveData data; - data.DestLocation.Relocate(pos); - data.SplineFlag = moveFlag; - data.Time = moveTime; - data.AnimationState = ANIMATION_FLYING; + sLog->outStaticDebug("Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f)", i_owner->GetEntry(), id, x, y, z); - i_owner->SendMonsterMove(data); + Movement::MoveSplineInit init(*i_owner); + init.MoveTo(x,y,z); + init.SetVelocity(speed); + init.SetAnimation(Movement::ToFly); + init.Launch(); + Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED); } void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ) @@ -347,7 +332,9 @@ void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, floa return; float x, y, z; - float dist = speedXY * speedZ * 0.1f; + float moveTimeHalf = speedZ / Movement::gravity; + float dist = 2 * moveTimeHalf * speedXY; + i_owner->GetNearPoint(i_owner, x, y, z, i_owner->GetObjectSize(), dist, i_owner->GetAngle(srcX, srcY) + M_PI); MoveJump(x, y, z, speedXY, speedZ); } @@ -359,35 +346,48 @@ void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ) return; float x, y, z; - float dist = speedXY * speedZ * 0.1f; + + float moveTimeHalf = speedZ / Movement::gravity; + float dist = 2 * moveTimeHalf * speedXY; i_owner->GetClosePoint(x, y, z, i_owner->GetObjectSize(), dist, angle); MoveJump(x, y, z, speedXY, speedZ); } -void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ) +void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id) { - uint32 moveFlag = SPLINEFLAG_TRAJECTORY | SPLINEFLAG_WALKING; - uint32 time = uint32(speedZ * 100); + sLog->outStaticDebug("Unit (GUID: %u) jump to point (X: %f Y: %f Z: %f)", i_owner->GetGUIDLow(), x, y, z); - // Instantly interrupt non melee spells being casted - if (i_owner->IsNonMeleeSpellCasted(true)) - i_owner->InterruptNonMeleeSpells(true); + float moveTimeHalf = speedZ / Movement::gravity; + float max_height = -Movement::computeFallElevation(moveTimeHalf,false,-speedZ); - i_owner->AddUnitState(UNIT_STAT_CHARGING | UNIT_STAT_JUMPING); - i_owner->m_TempSpeed = speedXY; - if (i_owner->GetTypeId() == TYPEID_PLAYER) - { - sLog->outStaticDebug("Player (GUID: %u) jump to point (X: %f Y: %f Z: %f)", i_owner->GetGUIDLow(), x, y, z); - Mutate(new PointMovementGenerator(0, x, y, z), MOTION_SLOT_CONTROLLED); - } - else + Movement::MoveSplineInit init(*i_owner); + init.MoveTo(x,y,z); + init.SetParabolic(max_height,0); + init.SetVelocity(speedXY); + init.Launch(); + Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED); +} + +void MotionMaster::MoveFall() +{ + // use larger distance for vmap height search than in most other cases + float tz = i_owner->GetMap()->GetHeight(i_owner->GetPositionX(), i_owner->GetPositionY(), i_owner->GetPositionZ(), true, MAX_FALL_DISTANCE); + if (tz <= INVALID_HEIGHT) { - sLog->outStaticDebug("Creature (Entry: %u GUID: %u) jump to point (X: %f Y: %f Z: %f)", - i_owner->GetEntry(), i_owner->GetGUIDLow(), x, y, z); - Mutate(new PointMovementGenerator(0, x, y, z), MOTION_SLOT_CONTROLLED); + sLog->outStaticDebug("MotionMaster::MoveFall: unable retrive a proper height at map %u (x: %f, y: %f, z: %f).", + i_owner->GetMap()->GetId(), i_owner->GetPositionX(), i_owner->GetPositionX(), i_owner->GetPositionZ()); + return; } - i_owner->SendMonsterMove(x, y, z, moveFlag, time, speedZ); + // Abort too if the ground is very near + if (fabs(i_owner->GetPositionZ() - tz) < 0.1f) + return; + + Movement::MoveSplineInit init(*i_owner); + init.MoveTo(i_owner->GetPositionX(),i_owner->GetPositionY(),tz); + init.SetFall(); + init.Launch(); + Mutate(new EffectMovementGenerator(0), MOTION_SLOT_CONTROLLED); } void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id) @@ -395,29 +395,19 @@ void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id) if (Impl[MOTION_SLOT_CONTROLLED] && Impl[MOTION_SLOT_CONTROLLED]->GetMovementGeneratorType() != DISTRACT_MOTION_TYPE) return; - i_owner->AddUnitState(UNIT_STAT_CHARGING); - i_owner->m_TempSpeed = speed; if (i_owner->GetTypeId() == TYPEID_PLAYER) { sLog->outStaticDebug("Player (GUID: %u) charge point (X: %f Y: %f Z: %f)", i_owner->GetGUIDLow(), x, y, z); - Mutate(new PointMovementGenerator(id, x, y, z), MOTION_SLOT_CONTROLLED); + Mutate(new PointMovementGenerator(id, x, y, z, speed), MOTION_SLOT_CONTROLLED); } else { sLog->outStaticDebug("Creature (Entry: %u GUID: %u) charge point (X: %f Y: %f Z: %f)", i_owner->GetEntry(), i_owner->GetGUIDLow(), x, y, z); - Mutate(new PointMovementGenerator(id, x, y, z), MOTION_SLOT_CONTROLLED); + Mutate(new PointMovementGenerator(id, x, y, z, speed), MOTION_SLOT_CONTROLLED); } } -void MotionMaster::MoveFall(float z, uint32 id) -{ - i_owner->SetFlying(false); - i_owner->SendMovementFlagUpdate(); - //AddUnitMovementFlag(MOVEMENTFLAG_FALLING); - MoveCharge(i_owner->GetPositionX(), i_owner->GetPositionY(), z, SPEED_CHARGE, id); -} - void MotionMaster::MoveSeekAssistance(float x, float y, float z) { if (i_owner->GetTypeId() == TYPEID_PLAYER) @@ -561,7 +551,7 @@ void MotionMaster::MovePath(uint32 path_id, bool repeatable) //i_owner->GetTypeId() == TYPEID_PLAYER ? //Mutate(new WaypointMovementGenerator(path_id, repeatable)): - Mutate(new WaypointMovementGenerator(path_id, repeatable), MOTION_SLOT_IDLE); + Mutate(new WaypointMovementGenerator(path_id, repeatable), MOTION_SLOT_IDLE); sLog->outStaticDebug("%s (GUID: %u) start moving over path(Id:%u, repeatable: %s)", i_owner->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature", @@ -632,8 +622,12 @@ void MotionMaster::DelayedDelete(_Ty curr) bool MotionMaster::GetDestination(float &x, float &y, float &z) { - if (empty()) + if (i_owner->movespline->Finalized()) return false; - return top()->GetDestination(x, y, z); + const G3D::Vector3& dest = i_owner->movespline->FinalDestination(); + x = dest.x; + y = dest.y; + z = dest.z; + return true; } diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index a972c3b06ce..00f1701e591 100755 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -39,7 +39,7 @@ enum MovementGeneratorType MAX_DB_MOTION_TYPE = 3, // *** this and below motion types can't be set in DB. ANIMAL_RANDOM_MOTION_TYPE = MAX_DB_MOTION_TYPE, // AnimalRandomMovementGenerator.h CONFUSED_MOTION_TYPE = 4, // ConfusedMovementGenerator.h - TARGETED_MOTION_TYPE = 5, // TargetedMovementGenerator.h + CHASE_MOTION_TYPE = 5, // TargetedMovementGenerator.h HOME_MOTION_TYPE = 6, // HomeMovementGenerator.h FLIGHT_MOTION_TYPE = 7, // WaypointMovementGenerator.h POINT_MOTION_TYPE = 8, // PointMovementGenerator.h @@ -48,8 +48,10 @@ enum MovementGeneratorType ASSISTANCE_MOTION_TYPE= 11, // PointMovementGenerator.h (first part of flee for assistance) ASSISTANCE_DISTRACT_MOTION_TYPE = 12, // IdleMovementGenerator.h (second part of flee for assistance) TIMED_FLEEING_MOTION_TYPE = 13, // FleeingMovementGenerator.h (alt.second part of flee for assistance) - ROTATE_MOTION_TYPE = 14, - NULL_MOTION_TYPE = 15, + FOLLOW_MOTION_TYPE = 14, + ROTATE_MOTION_TYPE = 15, + EFFECT_MOTION_TYPE = 16, + NULL_MOTION_TYPE = 17, }; enum MovementSlot @@ -86,7 +88,6 @@ class MotionMaster //: private std::stack typedef std::vector<_Ty> ExpireList; int i_top; - bool empty() const { return (i_top < 0); } void pop() { Impl[i_top] = NULL; --i_top; } void push(_Ty _Val) { ++i_top; Impl[i_top] = _Val; } @@ -107,6 +108,7 @@ class MotionMaster //: private std::stack void Initialize(); void InitDefault(); + bool empty() const { return (i_top < 0); } int size() const { return i_top + 1; } _Ty top() const { return Impl[i_top]; } _Ty GetMotionSlot(int slot) const { return Impl[slot]; } @@ -158,10 +160,11 @@ class MotionMaster //: private std::stack void MoveTakeoff(uint32 id, Position const& pos, float speed); void MoveCharge(float x, float y, float z, float speed = SPEED_CHARGE, uint32 id = EVENT_CHARGE); - void MoveFall(float z, uint32 id = 0); void MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ); void MoveJumpTo(float angle, float speedXY, float speedZ); - void MoveJump(float x, float y, float z, float speedXY, float speedZ); + void MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id = 0); + void MoveFall(); + void MoveSeekAssistance(float x, float y, float z); void MoveSeekAssistanceDistract(uint32 timer); void MoveTaxiFlight(uint32 path, uint32 pathnode); diff --git a/src/server/game/Movement/MovementGenerator.cpp b/src/server/game/Movement/MovementGenerator.cpp index 103b8876959..73921ea86ff 100755 --- a/src/server/game/Movement/MovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerator.cpp @@ -21,4 +21,3 @@ MovementGenerator::~MovementGenerator() { } - diff --git a/src/server/game/Movement/MovementGenerator.h b/src/server/game/Movement/MovementGenerator.h index 06450d938ae..dd9ba32f337 100755 --- a/src/server/game/Movement/MovementGenerator.h +++ b/src/server/game/Movement/MovementGenerator.h @@ -43,8 +43,6 @@ class MovementGenerator virtual MovementGeneratorType GetMovementGeneratorType() = 0; virtual void unitSpeedChanged() { } - - virtual bool GetDestination(float& /*x*/, float& /*y*/, float& /*z*/) const { return false; } }; template diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp index bf5c8bafc49..ac09f2d403a 100755 --- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp @@ -18,10 +18,10 @@ #include "Creature.h" #include "MapManager.h" -#include "Opcodes.h" #include "ConfusedMovementGenerator.h" -#include "DestinationHolderImp.h" #include "VMapFactory.h" +#include "MoveSplineInit.h" +#include "MoveSpline.h" #ifdef MAP_BASED_RAND_GEN #define rand_norm() unit.rand_norm() @@ -31,8 +31,8 @@ template void ConfusedMovementGenerator::Initialize(T &unit) { - float const wanderDistance = 4; - float x, y, z; + const float wander_distance=4; + float x,y,z; x = unit.GetPositionX(); y = unit.GetPositionY(); z = unit.GetPositionZ(); @@ -44,52 +44,33 @@ void ConfusedMovementGenerator::Initialize(T &unit) bool is_water_ok, is_land_ok; _InitSpecific(unit, is_water_ok, is_land_ok); - for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx) + for (uint8 idx = 0; idx < MAX_CONF_WAYPOINTS + 1; ++idx) { - float wanderX = x + wanderDistance * (float)rand_norm() - wanderDistance/2; - float wanderY = y + wanderDistance * (float)rand_norm() - wanderDistance/2; - Trinity::NormalizeMapCoord(wanderX); - Trinity::NormalizeMapCoord(wanderY); + const float wanderX=wander_distance*(float)rand_norm() - wander_distance/2; + const float wanderY=wander_distance*(float)rand_norm() - wander_distance/2; - float new_z = map->GetHeight(wanderX, wanderY, z, true); - if (new_z > INVALID_HEIGHT && unit.IsWithinLOS(wanderX, wanderY, new_z)) - { - // Don't move in water if we're not already in - // Don't move on land if we're not already on it either - bool is_water_now = map->IsInWater(x, y, z); - bool is_water_next = map->IsInWater(wanderX, wanderY, new_z); - if ((is_water_now && !is_water_next && !is_land_ok) || (!is_water_now && is_water_next && !is_water_ok)) - { - i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx-1][0] : x; // Back to previous location - i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx-1][1] : y; - i_waypoints[idx][2] = idx > 0 ? i_waypoints[idx-1][2] : z; - continue; - } - - // Taken from FleeingMovementGenerator - if (!(new_z - z) || wanderDistance / fabs(new_z - z) > 1.0f) - { - i_waypoints[idx][0] = wanderX; - i_waypoints[idx][1] = wanderY; - i_waypoints[idx][2] = new_z; - continue; - } - } - else // Back to previous location + i_waypoints[idx][0] = x + wanderX; + i_waypoints[idx][1] = y + wanderY; + + // prevent invalid coordinates generation + Trinity::NormalizeMapCoord(i_waypoints[idx][0]); + Trinity::NormalizeMapCoord(i_waypoints[idx][1]); + + bool is_water = map->IsInWater(i_waypoints[idx][0],i_waypoints[idx][1],z); + // if generated wrong path just ignore + if ((is_water && !is_water_ok) || (!is_water && !is_land_ok)) { i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx-1][0] : x; i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx-1][1] : y; - i_waypoints[idx][2] = idx > 0 ? i_waypoints[idx-1][2] : z; - continue; } + + unit.UpdateAllowedPositionZ(i_waypoints[idx][0], i_waypoints[idx][1], z); + i_waypoints[idx][2] = z; } - unit.SetTarget(0); - unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); - unit.CastStop(); unit.StopMoving(); - unit.AddUnitMovementFlag(MOVEMENTFLAG_WALKING); // Should actually be splineflag - unit.AddUnitState(UNIT_STAT_CONFUSED); + unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); + unit.AddUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE); } template<> @@ -111,69 +92,70 @@ void ConfusedMovementGenerator::Reset(T &unit) { i_nextMove = 1; i_nextMoveTime.Reset(0); - i_destinationHolder.ResetUpdate(); unit.StopMoving(); + unit.AddUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE); } template -bool ConfusedMovementGenerator::Update(T &unit, const uint32 diff) +bool ConfusedMovementGenerator::Update(T &unit, const uint32 &diff) { - if (!&unit) - return true; - if (unit.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) return true; if (i_nextMoveTime.Passed()) { // currently moving, update location - Traveller traveller(unit); - if (i_destinationHolder.UpdateTraveller(traveller, diff)) + unit.AddUnitState(UNIT_STAT_CONFUSED_MOVE); + + if (unit.movespline->Finalized()) { - if (i_destinationHolder.HasArrived()) - { - // arrived, stop and wait a bit - unit.ClearUnitState(UNIT_STAT_MOVE); - - i_nextMove = urand(1, MAX_CONF_WAYPOINTS); - i_nextMoveTime.Reset(urand(100, 1000)); - } + i_nextMove = urand(1,MAX_CONF_WAYPOINTS); + i_nextMoveTime.Reset(urand(0, 1500-1)); // TODO: check the minimum reset time, should be probably higher } } else { // waiting for next move i_nextMoveTime.Update(diff); - if (i_nextMoveTime.Passed()) + if(i_nextMoveTime.Passed() ) { // start moving - ASSERT(i_nextMove <= MAX_CONF_WAYPOINTS); - const float x = i_waypoints[i_nextMove][0]; - const float y = i_waypoints[i_nextMove][1]; - const float z = i_waypoints[i_nextMove][2]; - Traveller traveller(unit); - i_destinationHolder.SetDestination(traveller, x, y, z); + unit.AddUnitState(UNIT_STAT_CONFUSED_MOVE); + + ASSERT( i_nextMove <= MAX_CONF_WAYPOINTS ); + float x = i_waypoints[i_nextMove][0]; + float y = i_waypoints[i_nextMove][1]; + float z = i_waypoints[i_nextMove][2]; + Movement::MoveSplineInit init(unit); + init.MoveTo(x, y, z); + init.SetWalk(true); + init.Launch(); } } + return true; } -template -void ConfusedMovementGenerator::Finalize(T &unit) +template<> +void ConfusedMovementGenerator::Finalize(Player &unit) { unit.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); - unit.ClearUnitState(UNIT_STAT_CONFUSED); + unit.ClearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE); +} - if (unit.GetTypeId() == TYPEID_UNIT && unit.getVictim()) +template<> +void ConfusedMovementGenerator::Finalize(Creature &unit) +{ + unit.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); + unit.ClearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE); + if (unit.getVictim()) unit.SetTarget(unit.getVictim()->GetGUID()); } template void ConfusedMovementGenerator::Initialize(Player &player); template void ConfusedMovementGenerator::Initialize(Creature &creature); -template void ConfusedMovementGenerator::Finalize(Player &player); -template void ConfusedMovementGenerator::Finalize(Creature &creature); template void ConfusedMovementGenerator::Reset(Player &player); template void ConfusedMovementGenerator::Reset(Creature &creature); -template bool ConfusedMovementGenerator::Update(Player &player, const uint32 diff); -template bool ConfusedMovementGenerator::Update(Creature &creature, const uint32 diff); +template bool ConfusedMovementGenerator::Update(Player &player, const uint32 &diff); +template bool ConfusedMovementGenerator::Update(Creature &creature, const uint32 &diff); diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.h b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.h index d3981ee2dcf..b9f96bb785d 100755 --- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.h @@ -20,8 +20,7 @@ #define TRINITY_CONFUSEDGENERATOR_H #include "MovementGenerator.h" -#include "DestinationHolder.h" -#include "Traveller.h" +#include "Timer.h" #define MAX_CONF_WAYPOINTS 24 @@ -35,21 +34,13 @@ class ConfusedMovementGenerator void Initialize(T &); void Finalize(T &); void Reset(T &); - bool Update(T &, const uint32); - - bool GetDestination(float &x, float &y, float &z) const - { - if (i_destinationHolder.HasArrived()) return false; - i_destinationHolder.GetDestination(x, y, z); - return true; - } + bool Update(T &, const uint32 &); MovementGeneratorType GetMovementGeneratorType() { return CONFUSED_MOTION_TYPE; } private: void _InitSpecific(T &, bool &, bool &); TimeTracker i_nextMoveTime; float i_waypoints[MAX_CONF_WAYPOINTS+1][3]; - DestinationHolder< Traveller > i_destinationHolder; uint32 i_nextMove; }; #endif diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp index d2b3fcee384..458e6f9a62c 100755 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp @@ -20,8 +20,9 @@ #include "CreatureAI.h" #include "MapManager.h" #include "FleeingMovementGenerator.h" -#include "DestinationHolderImp.h" #include "ObjectAccessor.h" +#include "MoveSplineInit.h" +#include "MoveSpline.h" #define MIN_QUIET_DISTANCE 28.0f #define MAX_QUIET_DISTANCE 43.0f @@ -43,25 +44,12 @@ FleeingMovementGenerator::_setTargetLocation(T &owner) if (!_getPoint(owner, x, y, z)) return; - owner.AddUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING); - Traveller traveller(owner); - i_destinationHolder.SetDestination(traveller, x, y, z); -} - -template<> -bool FleeingMovementGenerator::GetDestination(float &x, float &y, float &z) const -{ - if (i_destinationHolder.HasArrived()) - return false; + owner.AddUnitState(UNIT_STAT_FLEEING_MOVE); - i_destinationHolder.GetDestination(x, y, z); - return true; -} - -template<> -bool FleeingMovementGenerator::GetDestination(float & /*x*/, float & /*y*/, float & /*z*/) const -{ - return false; + Movement::MoveSplineInit init(owner); + init.MoveTo(x,y,z); + init.SetWalk(false); + init.Launch(); } template @@ -75,10 +63,10 @@ FleeingMovementGenerator::_getPoint(T &owner, float &x, float &y, float &z) y = owner.GetPositionY(); z = owner.GetPositionZ(); - float temp_x, temp_y, angle = 0; + float temp_x, temp_y, angle; const Map* _map = owner.GetBaseMap(); //primitive path-finding - for (uint8 i = 0; i < 18; ++i) + for(uint8 i = 0; i < 18; ++i) { if (i_only_forward && i > 2) break; @@ -143,11 +131,11 @@ FleeingMovementGenerator::_getPoint(T &owner, float &x, float &y, float &z) distance /= 4; break; case 15: - angle = i_cur_angle + static_cast(M_PI*3/4); + angle = i_cur_angle + static_cast(3*M_PI/4); distance /= 2; break; case 16: - angle = i_cur_angle - static_cast(M_PI*3/4); + angle = i_cur_angle - static_cast(3*M_PI/4); distance /= 2; break; case 17: @@ -161,9 +149,9 @@ FleeingMovementGenerator::_getPoint(T &owner, float &x, float &y, float &z) Trinity::NormalizeMapCoord(temp_y); if (owner.IsWithinLOS(temp_x, temp_y, z)) { - bool is_water_now = _map->IsInWater(x, y, z); + bool is_water_now = _map->IsInWater(x,y,z); - if (is_water_now && _map->IsInWater(temp_x, temp_y, z)) + if (is_water_now && _map->IsInWater(temp_x,temp_y,z)) { x = temp_x; y = temp_y; @@ -181,8 +169,8 @@ FleeingMovementGenerator::_getPoint(T &owner, float &x, float &y, float &z) if (!(new_z - z) || distance / fabs(new_z - z) > 1.0f) { - float new_z_left = _map->GetHeight(temp_x + (float)(cos(angle+M_PI/2)), temp_y + (float)(sin(angle+M_PI/2)), z, true); - float new_z_right = _map->GetHeight(temp_x + (float)(cos(angle-M_PI/2)), temp_y + (float)(sin(angle-M_PI/2)), z, true); + float new_z_left = _map->GetHeight(temp_x + 1.0f*cos(angle+static_cast(M_PI/2)),temp_y + 1.0f*sin(angle+static_cast(M_PI/2)),z,true); + float new_z_right = _map->GetHeight(temp_x + 1.0f*cos(angle-static_cast(M_PI/2)),temp_y + 1.0f*sin(angle-static_cast(M_PI/2)),z,true); if (fabs(new_z_left - new_z) < 1.2f && fabs(new_z_right - new_z) < 1.2f) { x = temp_x; @@ -194,7 +182,7 @@ FleeingMovementGenerator::_getPoint(T &owner, float &x, float &y, float &z) } } i_to_distance_from_caster = 0.0f; - i_nextCheckTime.Reset(urand(500, 1000)); + i_nextCheckTime.Reset( urand(500,1000) ); return false; } @@ -213,12 +201,12 @@ FleeingMovementGenerator::_setMoveData(T &owner) (i_last_distance_from_caster < i_to_distance_from_caster && cur_dist_xyz > i_to_distance_from_caster) || // if we reach bigger distance (cur_dist_xyz > MAX_QUIET_DISTANCE) || // if we are too far - (i_last_distance_from_caster > MIN_QUIET_DISTANCE && cur_dist_xyz < MIN_QUIET_DISTANCE)) + (i_last_distance_from_caster > MIN_QUIET_DISTANCE && cur_dist_xyz < MIN_QUIET_DISTANCE) ) // if we leave 'quiet zone' { // we are very far or too close, stopping i_to_distance_from_caster = 0.0f; - i_nextCheckTime.Reset(urand(500, 1000)); + i_nextCheckTime.Reset( urand(500,1000) ); return false; } else @@ -232,9 +220,7 @@ FleeingMovementGenerator::_setMoveData(T &owner) float cur_dist; float angle_to_caster; - Unit* fright = ObjectAccessor::GetUnit(owner, i_frightGUID); - - if (fright) + if (Unit* fright = ObjectAccessor::GetUnit(owner, i_frightGUID)) { cur_dist = fright->GetDistance(&owner); if (cur_dist < cur_dist_xyz) @@ -284,7 +270,7 @@ FleeingMovementGenerator::_setMoveData(T &owner) i_to_distance_from_caster = MIN_QUIET_DISTANCE + 2.5f + (float)rand_norm()*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE - 2.5f); } - int8 sign = rand_norm() > 0.5f ? 1 : -1; + int8 sign = (float)rand_norm() > 0.5f ? 1 : -1; i_cur_angle = sign*angle + angle_to_caster; // current distance @@ -300,14 +286,12 @@ FleeingMovementGenerator::Initialize(T &owner) if (!&owner) return; - _Init(owner); - owner.CastStop(); - owner.AddUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING); owner.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); - owner.SetTarget(0); - owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); + owner.AddUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); - if (Unit* fright = ObjectAccessor::GetUnit(owner, i_frightGUID)) + _Init(owner); + + if (Unit *fright = ObjectAccessor::GetUnit(owner, i_frightGUID)) { i_caster_x = fright->GetPositionX(); i_caster_y = fright->GetPositionY(); @@ -334,6 +318,7 @@ FleeingMovementGenerator::_Init(Creature &owner) if (!&owner) return; + //owner.SetTargetGuid(ObjectGuid()); is_water_ok = owner.canSwim(); is_land_ok = owner.canWalk(); } @@ -346,51 +331,44 @@ FleeingMovementGenerator::_Init(Player &) is_land_ok = true; } -template -void -FleeingMovementGenerator::Finalize(T &owner) +template<> +void FleeingMovementGenerator::Finalize(Player &owner) +{ + owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); + owner.ClearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); +} + +template<> +void FleeingMovementGenerator::Finalize(Creature &owner) { owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); - owner.ClearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING); - if (owner.GetTypeId() == TYPEID_UNIT && owner.getVictim()) + owner.ClearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); + if (owner.getVictim()) owner.SetTarget(owner.getVictim()->GetGUID()); } template -void -FleeingMovementGenerator::Reset(T &owner) +void FleeingMovementGenerator::Reset(T &owner) { Initialize(owner); } template bool -FleeingMovementGenerator::Update(T &owner, const uint32 time_diff) +FleeingMovementGenerator::Update(T &owner, const uint32 &time_diff) { if (!&owner || !owner.isAlive()) return false; if (owner.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED)) + { + owner.ClearUnitState(UNIT_STAT_FLEEING_MOVE); return true; - - Traveller traveller(owner); + } i_nextCheckTime.Update(time_diff); - - if ((owner.IsStopped() && !i_destinationHolder.HasArrived()) || !i_destinationHolder.HasDestination()) - { + if (i_nextCheckTime.Passed() && owner.movespline->Finalized()) _setTargetLocation(owner); - return true; - } - if (i_destinationHolder.UpdateTraveller(traveller, time_diff)) - { - i_destinationHolder.ResetUpdate(50); - if (i_nextCheckTime.Passed() && i_destinationHolder.HasArrived()) - { - _setTargetLocation(owner); - return true; - } - } return true; } @@ -402,17 +380,15 @@ template bool FleeingMovementGenerator::_getPoint(Player &, float &, flo template bool FleeingMovementGenerator::_getPoint(Creature &, float &, float &, float &); template void FleeingMovementGenerator::_setTargetLocation(Player &); template void FleeingMovementGenerator::_setTargetLocation(Creature &); -template void FleeingMovementGenerator::Finalize(Player &); -template void FleeingMovementGenerator::Finalize(Creature &); template void FleeingMovementGenerator::Reset(Player &); template void FleeingMovementGenerator::Reset(Creature &); -template bool FleeingMovementGenerator::Update(Player &, const uint32); -template bool FleeingMovementGenerator::Update(Creature &, const uint32); +template bool FleeingMovementGenerator::Update(Player &, const uint32 &); +template bool FleeingMovementGenerator::Update(Creature &, const uint32 &); void TimedFleeingMovementGenerator::Finalize(Unit &owner) { owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); - owner.ClearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING); + owner.ClearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); if (Unit* victim = owner.getVictim()) { if (owner.isAlive()) @@ -429,13 +405,20 @@ bool TimedFleeingMovementGenerator::Update(Unit & owner, const uint32 time_diff) return false; if (owner.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED)) + { + owner.ClearUnitState(UNIT_STAT_FLEEING_MOVE); return true; + } + + i_totalFleeTime.Update(time_diff); + if (i_totalFleeTime.Passed()) + return false; i_totalFleeTime.Update(time_diff); if (i_totalFleeTime.Passed()) return false; - // This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, const uint32) version + // This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, const uint32 &) version // This is done instead of casting Unit& to Creature& and call parent method, then we can use Unit directly return MovementGeneratorMedium< Creature, FleeingMovementGenerator >::Update(owner, time_diff); } diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h index 4d4631fe932..750db52bb5a 100755 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h @@ -20,8 +20,6 @@ #define TRINITY_FLEEINGMOVEMENTGENERATOR_H #include "MovementGenerator.h" -#include "DestinationHolder.h" -#include "Traveller.h" template class FleeingMovementGenerator @@ -33,8 +31,7 @@ class FleeingMovementGenerator void Initialize(T &); void Finalize(T &); void Reset(T &); - bool Update(T &, const uint32); - bool GetDestination(float &x, float &y, float &z) const; + bool Update(T &, const uint32 &); MovementGeneratorType GetMovementGeneratorType() { return FLEEING_MOTION_TYPE; } @@ -56,8 +53,6 @@ class FleeingMovementGenerator float i_cur_angle; uint64 i_frightGUID; TimeTracker i_nextCheckTime; - - DestinationHolder< Traveller > i_destinationHolder; }; class TimedFleeingMovementGenerator diff --git a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp index 16153dd6ccb..84997d6d1ae 100755 --- a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp @@ -19,22 +19,16 @@ #include "HomeMovementGenerator.h" #include "Creature.h" #include "CreatureAI.h" -#include "Traveller.h" -#include "DestinationHolderImp.h" #include "WorldPacket.h" +#include "MoveSplineInit.h" +#include "MoveSpline.h" void HomeMovementGenerator::Initialize(Creature & owner) { - owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); owner.AddUnitState(UNIT_STAT_EVADE); _setTargetLocation(owner); } -void HomeMovementGenerator::Finalize(Creature & owner) -{ - owner.ClearUnitState(UNIT_STAT_EVADE); -} - void HomeMovementGenerator::Reset(Creature &) { } @@ -47,42 +41,35 @@ void HomeMovementGenerator::_setTargetLocation(Creature & owner) if (owner.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) return; - float x, y, z; - owner.GetHomePosition(x, y, z, ori); + Movement::MoveSplineInit init(owner); + float x, y, z, o; + // at apply we can select more nice return points base at current movegen + //if (owner.GetMotionMaster()->empty() || !owner.GetMotionMaster()->top()->GetResetPosition(owner,x,y,z)) + //{ + owner.GetHomePosition(x, y, z, o); + init.SetFacing(o); + //} + init.MoveTo(x,y,z); + init.SetWalk(false); + init.Launch(); - CreatureTraveller traveller(owner); - - uint32 travel_time = i_destinationHolder.SetDestination(traveller, x, y, z); - modifyTravelTime(travel_time); - owner.ClearUnitState(uint32(UNIT_STAT_ALL_STATE & ~UNIT_STAT_EVADE)); + arrived = false; + owner.ClearUnitState(UNIT_STAT_ALL_STATE & ~UNIT_STAT_EVADE); } bool HomeMovementGenerator::Update(Creature &owner, const uint32 time_diff) { - CreatureTraveller traveller(owner); - i_destinationHolder.UpdateTraveller(traveller, time_diff); + arrived = owner.movespline->Finalized(); + return !arrived; +} - if (time_diff > i_travel_timer) +void HomeMovementGenerator::Finalize(Creature& owner) +{ + if (arrived) { - owner.AddUnitMovementFlag(MOVEMENTFLAG_WALKING); - - // restore orientation of not moving creature at returning to home - if (owner.GetDefaultMovementType() == IDLE_MOTION_TYPE) - { - //sLog->outDebug("Entering HomeMovement::GetDestination(z, y, z)"); - owner.SetOrientation(ori); - WorldPacket packet; - owner.BuildHeartBeatMsg(&packet); - owner.SendMessageToSet(&packet, false); - } - owner.ClearUnitState(UNIT_STAT_EVADE); + owner.SetWalk(true); owner.LoadCreaturesAddon(true); owner.AI()->JustReachedHome(); - return false; } - - i_travel_timer -= time_diff; - - return true; } diff --git a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h index ba34899dee5..c724edc91ff 100755 --- a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h @@ -20,8 +20,6 @@ #define TRINITY_HOMEMOVEMENTGENERATOR_H #include "MovementGenerator.h" -#include "DestinationHolder.h" -#include "Traveller.h" class Creature; @@ -34,24 +32,18 @@ class HomeMovementGenerator { public: - HomeMovementGenerator() {} + HomeMovementGenerator() : arrived(false) {} ~HomeMovementGenerator() {} void Initialize(Creature &); void Finalize(Creature &); void Reset(Creature &); bool Update(Creature &, const uint32); - void modifyTravelTime(uint32 travel_time) { i_travel_timer = travel_time; } MovementGeneratorType GetMovementGeneratorType() { return HOME_MOTION_TYPE; } - bool GetDestination(float& x, float& y, float& z) const { i_destinationHolder.GetDestination(x, y, z); return true; } - private: void _setTargetLocation(Creature &); - DestinationHolder< Traveller > i_destinationHolder; - - float ori; - uint32 i_travel_timer; + bool arrived; }; #endif diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp index af2207ae141..505615c07b8 100755 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp @@ -20,61 +20,59 @@ #include "Errors.h" #include "Creature.h" #include "CreatureAI.h" -#include "DestinationHolderImp.h" #include "World.h" +#include "MoveSplineInit.h" +#include "MoveSpline.h" //----- Point Movement Generator template void PointMovementGenerator::Initialize(T &unit) { - unit.StopMoving(); - Traveller traveller(unit); - // OLD: knockback effect has UNIT_STAT_JUMPING set, so if here we disable sentmonstermove there will be creature position sync problem between client and server - // NEW: reactivated this check - UNIT_STAT_JUMPING is only used in MoveJump, which sends its own packet - i_destinationHolder.SetDestination(traveller, i_x, i_y, i_z, /*true*/ !unit.HasUnitState(UNIT_STAT_JUMPING)); + if (!unit.IsStopped()) + unit.StopMoving(); + + unit.AddUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + Movement::MoveSplineInit init(unit); + init.MoveTo(i_x, i_y, i_z); + if (speed > 0.0f) + init.SetVelocity(speed); + init.Launch(); } template -bool PointMovementGenerator::Update(T &unit, const uint32 diff) +bool PointMovementGenerator::Update(T &unit, const uint32 &diff) { if (!&unit) return false; - if (unit.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED)) + if(unit.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED)) { - if (unit.HasUnitState(UNIT_STAT_CHARGING)) - return false; - else - return true; + unit.ClearUnitState(UNIT_STAT_ROAMING_MOVE); + return true; } - Traveller traveller(unit); - - i_destinationHolder.UpdateTraveller(traveller, diff); - - if (i_destinationHolder.HasArrived()) - { - unit.ClearUnitState(UNIT_STAT_MOVE); - arrived = true; - return false; - } - else if (!unit.HasUnitState(UNIT_STAT_MOVE) && !unit.HasUnitState(UNIT_STAT_JUMPING)) - { - i_destinationHolder.StartTravel(traveller); - } - - return true; + unit.AddUnitState(UNIT_STAT_ROAMING_MOVE); + return !unit.movespline->Finalized(); } template void PointMovementGenerator:: Finalize(T &unit) { - if (unit.HasUnitState(UNIT_STAT_CHARGING)) - unit.ClearUnitState(UNIT_STAT_CHARGING | UNIT_STAT_JUMPING); - if (arrived) // without this crash! + unit.ClearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + + if (unit.movespline->Finalized()) MovementInform(unit); } +template +void PointMovementGenerator::Reset(T &unit) +{ + if (!unit.IsStopped()) + unit.StopMoving(); + + unit.AddUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); +} + template void PointMovementGenerator::MovementInform(T & /*unit*/) { @@ -82,22 +80,23 @@ void PointMovementGenerator::MovementInform(T & /*unit*/) template <> void PointMovementGenerator::MovementInform(Creature &unit) { - if (id == EVENT_FALL_GROUND) - { - unit.setDeathState(JUST_DIED); - unit.SetFlying(true); - } - unit.AI()->MovementInform(POINT_MOTION_TYPE, id); + //if (id == EVENT_FALL_GROUND) + //{ + // unit.setDeathState(JUST_DIED); + // unit.SetFlying(true); + //} + if (unit.AI()) + unit.AI()->MovementInform(POINT_MOTION_TYPE, id); } template void PointMovementGenerator::Initialize(Player&); -template bool PointMovementGenerator::Update(Player &, const uint32 diff); -template void PointMovementGenerator::MovementInform(Player&); -template void PointMovementGenerator::Finalize(Player&); - template void PointMovementGenerator::Initialize(Creature&); -template bool PointMovementGenerator::Update(Creature&, const uint32 diff); +template void PointMovementGenerator::Finalize(Player&); template void PointMovementGenerator::Finalize(Creature&); +template void PointMovementGenerator::Reset(Player&); +template void PointMovementGenerator::Reset(Creature&); +template bool PointMovementGenerator::Update(Player &, const uint32 &); +template bool PointMovementGenerator::Update(Creature&, const uint32 &); void AssistanceMovementGenerator::Finalize(Unit &unit) { @@ -107,3 +106,24 @@ void AssistanceMovementGenerator::Finalize(Unit &unit) unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY)); } +bool EffectMovementGenerator::Update(Unit &unit, const uint32) +{ + return !unit.movespline->Finalized(); +} + +void EffectMovementGenerator::Finalize(Unit &unit) +{ + if (unit.GetTypeId() != TYPEID_UNIT) + return; + + if (((Creature&)unit).AI() && unit.movespline->Finalized()) + ((Creature&)unit).AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id); + // Need restore previous movement since we have no proper states system + //if (unit.isAlive() && !unit.HasUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_FLEEING)) + //{ + // if (Unit * victim = unit.getVictim()) + // unit.GetMotionMaster()->MoveChase(victim); + // else + // unit.GetMotionMaster()->Initialize(); + //} +} diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h index 2504f1a38e3..e47f3d93450 100755 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h @@ -20,8 +20,6 @@ #define TRINITY_POINTMOVEMENTGENERATOR_H #include "MovementGenerator.h" -#include "DestinationHolder.h" -#include "Traveller.h" #include "FollowerReference.h" template @@ -29,13 +27,13 @@ class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementGenerator > { public: - PointMovementGenerator(uint32 _id, float _x, float _y, float _z) : id(_id), - i_x(_x), i_y(_y), i_z(_z), i_nextMoveTime(0), arrived(false) {} + PointMovementGenerator(uint32 _id, float _x, float _y, float _z, float _speed = 0.0f) : id(_id), + i_x(_x), i_y(_y), i_z(_z), speed(_speed) {} void Initialize(T &); - void Finalize(T &unit); - void Reset(T &unit){unit.StopMoving();} - bool Update(T &, const uint32 diff); + void Finalize(T &); + void Reset(T &); + bool Update(T &, const uint32 &); void MovementInform(T &); @@ -45,9 +43,7 @@ class PointMovementGenerator private: uint32 id; float i_x, i_y, i_z; - TimeTracker i_nextMoveTime; - DestinationHolder< Traveller > i_destinationHolder; - bool arrived; + float speed; }; class AssistanceMovementGenerator @@ -61,5 +57,19 @@ class AssistanceMovementGenerator void Finalize(Unit &); }; +// Does almost nothing - just doesn't allows previous movegen interrupt current effect. +class EffectMovementGenerator : public MovementGenerator +{ + public: + explicit EffectMovementGenerator(uint32 Id) : m_Id(Id) {} + void Initialize(Unit &) {} + void Finalize(Unit &unit); + void Reset(Unit &) {} + bool Update(Unit &u, const uint32); + MovementGeneratorType GetMovementGeneratorType() { return EFFECT_MOTION_TYPE; } + private: + uint32 m_Id; +}; + #endif diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp index 981ec031cf9..0205b734058 100755 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp @@ -19,123 +19,103 @@ #include "Creature.h" #include "MapManager.h" #include "RandomMovementGenerator.h" -#include "Traveller.h" #include "ObjectAccessor.h" -#include "DestinationHolderImp.h" #include "Map.h" #include "Util.h" #include "CreatureGroups.h" +#include "MoveSplineInit.h" +#include "MoveSpline.h" #define RUNNING_CHANCE_RANDOMMV 20 //will be "1 / RUNNING_CHANCE_RANDOMMV" -template<> -bool -RandomMovementGenerator::GetDestination(float &x, float &y, float &z) const -{ - if (i_destinationHolder.HasArrived()) - return false; - - i_destinationHolder.GetDestination(x, y, z); - return true; -} - #ifdef MAP_BASED_RAND_GEN #define rand_norm() creature.rand_norm() #endif template<> -void -RandomMovementGenerator::_setRandomLocation(Creature &creature) +void RandomMovementGenerator::_setRandomLocation(Creature &creature) { - float X, Y, Z, nx, ny, nz, ori, dist; - - creature.GetHomePosition(X, Y, Z, ori); - + float respX, respY, respZ, respO, currZ, destX, destY, destZ, travelDistZ; + creature.GetHomePosition(respX, respY, respZ, respO); + currZ = creature.GetPositionZ(); Map const* map = creature.GetBaseMap(); // For 2D/3D system selection - //bool is_land_ok = creature.canWalk(); - //bool is_water_ok = creature.canSwim(); - bool is_air_ok = creature.canFly(); + //bool is_land_ok = creature.CanWalk(); // not used? + //bool is_water_ok = creature.CanSwim(); // not used? + bool is_air_ok = creature.canFly(); - for (uint32 i = 0; ; ++i) - { - const float angle = (float)rand_norm()*static_cast(M_PI*2); - const float range = (float)rand_norm()*wander_distance; - const float distanceX = range * cos(angle); - const float distanceY = range * sin(angle); + const float angle = float(rand_norm()) * static_cast(M_PI*2.0f); + const float range = float(rand_norm()) * wander_distance; + const float distanceX = range * cos(angle); + const float distanceY = range * sin(angle); - nx = X + distanceX; - ny = Y + distanceY; + destX = respX + distanceX; + destY = respY + distanceY; - // prevent invalid coordinates generation - Trinity::NormalizeMapCoord(nx); - Trinity::NormalizeMapCoord(ny); + // prevent invalid coordinates generation + Trinity::NormalizeMapCoord(destX); + Trinity::NormalizeMapCoord(destY); - dist = (nx - X)*(nx - X) + (ny - Y)*(ny - Y); + travelDistZ = distanceX*distanceX + distanceY*distanceY; - if (i == 5) - { - nz = Z; - break; - } + if (is_air_ok) // 3D system above ground and above water (flying mode) + { + // Limit height change + const float distanceZ = float(rand_norm()) * sqrtf(travelDistZ)/2.0f; + destZ = respZ + distanceZ; + float levelZ = map->GetWaterOrGroundLevel(destX, destY, destZ-2.0f); + + // Problem here, we must fly above the ground and water, not under. Let's try on next tick + if (levelZ >= destZ) + return; + } + //else if (is_water_ok) // 3D system under water and above ground (swimming mode) + else // 2D only + { + // 10.0 is the max that vmap high can check (MAX_CAN_FALL_DISTANCE) + travelDistZ = travelDistZ >= 100.0f ? 10.0f : sqrtf(travelDistZ); - if (is_air_ok) // 3D system above ground and above water (flying mode) - { - const float distanceZ = (float)(rand_norm()) * sqrtf(dist)/2; // Limit height change - nz = Z + distanceZ; - float tz = map->GetHeight(nx, ny, nz-2.0f, false); // Map check only, vmap needed here but need to alter vmaps checks for height. - float wz = map->GetWaterLevel(nx, ny); - if (tz >= nz || wz >= nz) - continue; // Problem here, we must fly above the ground and water, not under. Let's try on next tick - } - //else if (is_water_ok) // 3D system under water and above ground (swimming mode) - else // 2D only + // The fastest way to get an accurate result 90% of the time. + // Better result can be obtained like 99% accuracy with a ray light, but the cost is too high and the code is too long. + destZ = map->GetHeight(destX, destY, respZ+travelDistZ-2.0f, false); + + if (fabs(destZ - respZ) > travelDistZ) // Map check { - dist = dist >= 100.0f ? 10.0f : sqrtf(dist); // 10.0 is the max that vmap high can check (MAX_CAN_FALL_DISTANCE) + // Vmap Horizontal or above + destZ = map->GetHeight(destX, destY, respZ - 2.0f, true); - // The fastest way to get an accurate result 90% of the time. - // Better result can be obtained like 99% accuracy with a ray light, but the cost is too high and the code is too long. - nz = map->GetHeight(nx, ny, Z+dist-2.0f, false); // Map check - if (fabs(nz-Z)>dist) + if (fabs(destZ - respZ) > travelDistZ) { - nz = map->GetHeight(nx, ny, Z-2.0f, true); // Vmap Horizontal or above - if (fabs(nz-Z)>dist) - { - nz = map->GetHeight(nx, ny, Z+dist-2.0f, true); // Vmap Higher - if (fabs(nz-Z)>dist) - continue; // let's forget this bad coords where a z cannot be find and retry at next tick - } + // Vmap Higher + destZ = map->GetHeight(destX, destY, respZ+travelDistZ-2.0f, true); + + // let's forget this bad coords where a z cannot be find and retry at next tick + if (fabs(destZ - respZ) > travelDistZ) + return; } } - break; } - Traveller traveller(creature); - creature.SetOrientation(creature.GetAngle(nx, ny)); - i_destinationHolder.SetDestination(traveller, nx, ny, nz); - creature.AddUnitState(UNIT_STAT_ROAMING); if (is_air_ok) - { - i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); - } - //else if (is_water_ok) // Swimming mode to be done with more than this check + i_nextMoveTime.Reset(0); else - { - i_nextMoveTime.Reset(urand(500+i_destinationHolder.GetTotalTravelTime(), 5000+i_destinationHolder.GetTotalTravelTime())); - creature.AddUnitMovementFlag(MOVEMENTFLAG_WALKING); - } + i_nextMoveTime.Reset(urand(500, 10000)); + + creature.AddUnitState(UNIT_STAT_ROAMING_MOVE); + + Movement::MoveSplineInit init(creature); + init.MoveTo(destX, destY, destZ); + init.SetWalk(true); + init.Launch(); //Call for creature group update if (creature.GetFormation() && creature.GetFormation()->getLeader() == &creature) - { - creature.GetFormation()->LeaderMoveTo(nx, ny, nz); - } + creature.GetFormation()->LeaderMoveTo(destX, destY, destZ); } template<> -void -RandomMovementGenerator::Initialize(Creature &creature) +void RandomMovementGenerator::Initialize(Creature &creature) { if (!creature.isAlive()) return; @@ -143,8 +123,7 @@ RandomMovementGenerator::Initialize(Creature &creature) if (!wander_distance) wander_distance = creature.GetRespawnRadius(); - if (irand(0, RUNNING_CHANCE_RANDOMMV) > 0) - creature.AddUnitMovementFlag(MOVEMENTFLAG_WALKING); + creature.AddUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); _setRandomLocation(creature); } @@ -156,8 +135,11 @@ RandomMovementGenerator::Reset(Creature &creature) } template<> -void -RandomMovementGenerator::Finalize(Creature & /*creature*/){} +void RandomMovementGenerator::Finalize(Creature &creature) +{ + creature.ClearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + creature.SetWalk(false); +} template<> bool @@ -165,35 +147,29 @@ RandomMovementGenerator::Update(Creature &creature, const uint32 diff) { if (creature.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) { - i_nextMoveTime.Update(i_nextMoveTime.GetExpiry()); // Expire the timer - creature.ClearUnitState(UNIT_STAT_ROAMING); + i_nextMoveTime.Reset(0); // Expire the timer + creature.ClearUnitState(UNIT_STAT_ROAMING_MOVE); return true; } - i_nextMoveTime.Update(diff); - - if (i_destinationHolder.HasArrived() && !creature.IsStopped() && !creature.canFly()) - creature.ClearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_MOVE); - - if (!i_destinationHolder.HasArrived() && creature.IsStopped()) - creature.AddUnitState(UNIT_STAT_ROAMING); - - CreatureTraveller traveller(creature); - - if (i_destinationHolder.UpdateTraveller(traveller, diff, true)) + if (creature.movespline->Finalized()) { + i_nextMoveTime.Update(diff); if (i_nextMoveTime.Passed()) - { - if (irand(0, RUNNING_CHANCE_RANDOMMV) > 0) - creature.AddUnitMovementFlag(MOVEMENTFLAG_WALKING); _setRandomLocation(creature); - } - else if (creature.isPet() && creature.GetOwner() && !creature.IsWithinDist(creature.GetOwner(), PET_FOLLOW_DIST+2.5f)) - { - creature.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); - _setRandomLocation(creature); - } } return true; } +template<> +bool RandomMovementGenerator::GetResetPosition(Creature &creature, float& x, float& y, float& z) +{ + float radius; + creature.GetRespawnPosition(x, y, z, NULL, &radius); + + // use current if in range + if (creature.IsWithinDist2d(x,y,radius)) + creature.GetPosition(x,y,z); + + return true; +} diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h index 816e325f3b1..67161b6fc29 100755 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h @@ -20,15 +20,12 @@ #define TRINITY_RANDOMMOTIONGENERATOR_H #include "MovementGenerator.h" -#include "DestinationHolder.h" -#include "Traveller.h" template class RandomMovementGenerator : public MovementGeneratorMedium< T, RandomMovementGenerator > { public: - // Wander dist is related on db spawn dist. So what if we wanna set eandom movement on summoned creature?! RandomMovementGenerator(float spawn_dist = 0.0f) : i_nextMoveTime(0), wander_distance(spawn_dist) {} void _setRandomLocation(T &); @@ -36,18 +33,13 @@ class RandomMovementGenerator void Finalize(T &); void Reset(T &); bool Update(T &, const uint32); - bool GetDestination(float &x, float &y, float &z) const; - void UpdateMapPosition(uint32 mapid, float &x, float &y, float &z) - { - i_destinationHolder.GetLocationNow(mapid, x, y, z); - } + bool GetResetPosition(T&, float& x, float& y, float& z); MovementGeneratorType GetMovementGeneratorType() { return RANDOM_MOTION_TYPE; } private: TimeTrackerSmall i_nextMoveTime; - DestinationHolder< Traveller > i_destinationHolder; - float wander_distance; uint32 i_nextMove; + float wander_distance; }; #endif diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index e0ca5231000..bded2fd512c 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -21,106 +21,42 @@ #include "Errors.h" #include "Creature.h" #include "CreatureAI.h" -#include "DestinationHolderImp.h" #include "World.h" - -#define SMALL_ALPHA 0.05f +#include "MoveSplineInit.h" +#include "MoveSpline.h" #include -/* -struct StackCleaner -{ - Creature &i_creature; - StackCleaner(Creature &creature) : i_creature(creature) {} - void Done(void) { i_creature.StopMoving(); } - ~StackCleaner() - { - i_creature->Clear(); - } -}; -*/ -template -TargetedMovementGenerator::TargetedMovementGenerator(Unit &target, float offset, float angle) -: TargetedMovementGeneratorBase(target) -, i_offset(offset), i_angle(angle), i_recalculateTravel(false) -{ - target.GetPosition(i_targetX, i_targetY, i_targetZ); -} - -template -bool -TargetedMovementGenerator::_setTargetLocation(T &owner) +template +void TargetedMovementGeneratorMedium::_setTargetLocation(T &owner) { if (!i_target.isValid() || !i_target->IsInWorld()) - return false; + return; - if (owner.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) - return false; + if (owner.HasUnitState(UNIT_STAT_NOT_MOVE)) + return; float x, y, z; - Traveller traveller(owner); - if (i_destinationHolder.HasDestination()) + + if (i_offset && i_target->IsWithinDistInMap(&owner,2*i_offset)) { - if (i_destinationHolder.HasArrived()) - { - // prevent redundant micro-movement - if (!i_offset) - { - if (i_target->IsWithinMeleeRange(&owner)) - return false; - } - else if (!i_angle && !owner.HasUnitState(UNIT_STAT_FOLLOW)) - { - if (i_target->IsWithinDistInMap(&owner, i_offset)) - return false; - } - else - { - if (i_target->IsWithinDistInMap(&owner, i_offset + 1.0f)) - return false; - } - } - else - { - bool stop = false; - if (!i_offset) - { - if (i_target->IsWithinMeleeRange(&owner, 0)) - stop = true; - } - else if (!i_angle && !owner.HasUnitState(UNIT_STAT_FOLLOW)) - { - if (i_target->IsWithinDist(&owner, i_offset * 0.8f)) - stop = true; - } - - if (stop) - { - owner.GetPosition(x, y, z); - i_destinationHolder.SetDestination(traveller, x, y, z); - i_destinationHolder.StartTravel(traveller, false); - owner.StopMoving(); - return false; - } - } + if (!owner.movespline->Finalized()) + return; - if (i_target->GetExactDistSq(i_targetX, i_targetY, i_targetZ) < 0.01f) - return false; + owner.GetPosition(x, y, z); } - - if (!i_offset) + else if (!i_offset) { + if (i_target->IsWithinMeleeRange(&owner)) + return; + // to nearest random contact position i_target->GetRandomContactPoint(&owner, x, y, z, 0, MELEE_RANGE - 0.5f); } - else if (!i_angle && !owner.HasUnitState(UNIT_STAT_FOLLOW)) - { - // caster chase - i_target->GetContactPoint(&owner, x, y, z, i_offset * urand(80, 95) * 0.01f); - } else { + if (i_target->IsWithinDistInMap(&owner, i_offset + 1.0f)) + return; // to at i_offset distance from target and i_angle from target facing i_target->GetClosePoint(x, y, z, owner.GetObjectSize(), i_offset, i_angle); } @@ -137,55 +73,65 @@ TargetedMovementGenerator::_setTargetLocation(T &owner) ralf //We don't update Mob Movement, if the difference between New destination and last destination is < BothObjectSize - float bothObjectSize = i_target->GetObjectSize() + owner.GetObjectSize() + CONTACT_DISTANCE; - if (i_destinationHolder.HasDestination() && i_destinationHolder.GetDestinationDiff(x, y, z) < bothObjectSize) + float bothObjectSize = i_target->GetObjectBoundingRadius() + owner.GetObjectBoundingRadius() + CONTACT_DISTANCE; + if( i_destinationHolder.HasDestination() && i_destinationHolder.GetDestinationDiff(x,y,z) < bothObjectSize ) return; */ - i_destinationHolder.SetDestination(traveller, x, y, z); - owner.AddUnitState(UNIT_STAT_CHASE); - i_destinationHolder.StartTravel(traveller); - return true; + + + D::_addUnitStateMove(owner); + i_targetReached = false; + i_recalculateTravel = false; + + Movement::MoveSplineInit init(owner); + init.MoveTo(x,y,z); + init.SetWalk(((D*)this)->EnableWalking()); + init.Launch(); } -template -void -TargetedMovementGenerator::Initialize(T &owner) +template<> +void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float /*fDistance*/) { - if (owner.isInCombat()) - owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); + // nothing to do for Player +} - _setTargetLocation(owner); +template<> +void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float /*fDistance*/) +{ + // nothing to do for Player } -template -void -TargetedMovementGenerator::Finalize(T &owner) +template<> +void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float fDistance) { - owner.ClearUnitState(UNIT_STAT_CHASE); + i_offset = fDistance; + i_recalculateTravel = true; } -template -void -TargetedMovementGenerator::Reset(T &owner) +template<> +void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float fDistance) { - Initialize(owner); + i_offset = fDistance; + i_recalculateTravel = true; } -template -bool -TargetedMovementGenerator::Update(T &owner, const uint32 time_diff) +template +bool TargetedMovementGeneratorMedium::Update(T &owner, const uint32 & time_diff) { if (!i_target.isValid() || !i_target->IsInWorld()) return false; - if (!&owner || !owner.isAlive()) + if (!owner.isAlive()) return true; - if (owner.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_DISTRACTED)) + if (owner.HasUnitState(UNIT_STAT_NOT_MOVE)) + { + D::_clearUnitStateMove(owner); return true; + } // prevent movement while casting spells with cast time or channel time - if (owner.HasUnitState(UNIT_STAT_CASTING)) + if (owner.IsNonMeleeSpellCasted(false, false, true)) { if (!owner.IsStopped()) owner.StopMoving(); @@ -193,85 +139,170 @@ TargetedMovementGenerator::Update(T &owner, const uint32 time_diff) } // prevent crash after creature killed pet - if (!owner.HasUnitState(UNIT_STAT_FOLLOW) && owner.getVictim() != i_target.getTarget()) + if (static_cast(this)->_lostTarget(owner)) + { + D::_clearUnitStateMove(owner); return true; + } - Traveller traveller(owner); - - if (!i_destinationHolder.HasDestination()) - _setTargetLocation(owner); - else if (owner.IsStopped() && !i_destinationHolder.HasArrived()) + i_recheckDistance.Update(time_diff); + if (i_recheckDistance.Passed()) { - owner.AddUnitState(UNIT_STAT_CHASE); - i_destinationHolder.StartTravel(traveller); - return true; + i_recheckDistance.Reset(50); + //More distance let have better performance, less distance let have more sensitive reaction at target move. + float allowed_dist = i_target->GetObjectSize() + owner.GetObjectSize() + MELEE_RANGE - 0.5f; + float dist = (owner.movespline->FinalDestination() - G3D::Vector3(i_target->GetPositionX(),i_target->GetPositionY(),i_target->GetPositionZ())).squaredLength(); + if (dist >= allowed_dist * allowed_dist) + _setTargetLocation(owner); } - if (i_destinationHolder.UpdateTraveller(traveller, time_diff)) + if (owner.movespline->Finalized()) { - // put targeted movement generators on a higher priority - //if (owner.GetObjectSize()) - //i_destinationHolder.ResetUpdate(50); + static_cast(this)->MovementInform(owner); + if (i_angle == 0.f && !owner.HasInArc(0.01f, i_target.getTarget())) + owner.SetInFront(i_target.getTarget()); - // target moved - if (i_targetX != i_target->GetPositionX() || i_targetY != i_target->GetPositionY() - || i_targetZ != i_target->GetPositionZ()) + if (!i_targetReached) { - if (_setTargetLocation(owner) || !owner.HasUnitState(UNIT_STAT_FOLLOW)) - owner.SetInFront(i_target.getTarget()); - i_target->GetPosition(i_targetX, i_targetY, i_targetZ); + i_targetReached = true; + static_cast(this)->_reachTarget(owner); } + } + else + { + if (i_recalculateTravel) + _setTargetLocation(owner); + } + return true; +} - if ((owner.IsStopped() && !i_destinationHolder.HasArrived()) || i_recalculateTravel) - { - i_recalculateTravel = false; - //Angle update will take place into owner.StopMoving() - owner.SetInFront(i_target.getTarget()); +//-----------------------------------------------// +template +void ChaseMovementGenerator::_reachTarget(T &owner) +{ + if (owner.IsWithinMeleeRange(this->i_target.getTarget())) + owner.Attack(this->i_target.getTarget(),true); +} - owner.StopMoving(); - if (owner.IsWithinMeleeRange(i_target.getTarget()) && !owner.HasUnitState(UNIT_STAT_FOLLOW)) - owner.Attack(i_target.getTarget(), true); - } - } +template<> +void ChaseMovementGenerator::Initialize(Player &owner) +{ + owner.AddUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE); + _setTargetLocation(owner); +} - // Implemented for PetAI to handle resetting flags when pet owner reached - if (i_destinationHolder.HasArrived()) - MovementInform(owner); +template<> +void ChaseMovementGenerator::Initialize(Creature &owner) +{ + owner.SetWalk(false); + owner.AddUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE); + _setTargetLocation(owner); +} - return true; +template +void ChaseMovementGenerator::Finalize(T &owner) +{ + owner.ClearUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE); } template -Unit* -TargetedMovementGenerator::GetTarget() const +void ChaseMovementGenerator::Reset(T &owner) +{ + Initialize(owner); +} + +//-----------------------------------------------// +template<> +bool FollowMovementGenerator::EnableWalking() const +{ + return i_target.isValid() && i_target->IsWalking(); +} + +template<> +bool FollowMovementGenerator::EnableWalking() const { - return i_target.getTarget(); + return false; +} + +template<> +void FollowMovementGenerator::_updateSpeed(Player &/*u*/) +{ + // nothing to do for Player +} + +template<> +void FollowMovementGenerator::_updateSpeed(Creature &u) +{ + // pet only sync speed with owner + if (!((Creature&)u).isPet() || !i_target.isValid() || i_target->GetGUID() != u.GetOwnerGUID()) + return; + + u.UpdateSpeed(MOVE_RUN,true); + u.UpdateSpeed(MOVE_WALK,true); + u.UpdateSpeed(MOVE_SWIM,true); +} + +template<> +void FollowMovementGenerator::Initialize(Player &owner) +{ + owner.AddUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE); + _updateSpeed(owner); + _setTargetLocation(owner); +} + +template<> +void FollowMovementGenerator::Initialize(Creature &owner) +{ + owner.AddUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE); + _updateSpeed(owner); + _setTargetLocation(owner); } template -void TargetedMovementGenerator::MovementInform(T & /*unit*/) +void FollowMovementGenerator::Finalize(T &owner) { + owner.ClearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE); + _updateSpeed(owner); } -template <> void TargetedMovementGenerator::MovementInform(Creature &unit) +template +void FollowMovementGenerator::Reset(T &owner) +{ + Initialize(owner); +} + +template +void FollowMovementGenerator::MovementInform(T & /*unit*/) { - // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle - unit.AI()->MovementInform(TARGETED_MOTION_TYPE, i_target.getTarget()->GetGUIDLow()); } -template void TargetedMovementGenerator::MovementInform(Player&); // Not implemented for players -template TargetedMovementGenerator::TargetedMovementGenerator(Unit &target, float offset, float angle); -template TargetedMovementGenerator::TargetedMovementGenerator(Unit &target, float offset, float angle); -template bool TargetedMovementGenerator::_setTargetLocation(Player &); -template bool TargetedMovementGenerator::_setTargetLocation(Creature &); -template void TargetedMovementGenerator::Initialize(Player &); -template void TargetedMovementGenerator::Initialize(Creature &); -template void TargetedMovementGenerator::Finalize(Player &); -template void TargetedMovementGenerator::Finalize(Creature &); -template void TargetedMovementGenerator::Reset(Player &); -template void TargetedMovementGenerator::Reset(Creature &); -template bool TargetedMovementGenerator::Update(Player &, const uint32); -template bool TargetedMovementGenerator::Update(Creature &, const uint32); -template Unit* TargetedMovementGenerator::GetTarget() const; -template Unit* TargetedMovementGenerator::GetTarget() const; +template<> +void FollowMovementGenerator::MovementInform(Creature &unit) +{ + // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle + if (unit.AI()) + unit.AI()->MovementInform(FOLLOW_MOTION_TYPE, i_target.getTarget()->GetGUIDLow()); +} +//-----------------------------------------------// +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player &); +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player &); +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature &); +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature &); +template bool TargetedMovementGeneratorMedium >::Update(Player &, const uint32 &); +template bool TargetedMovementGeneratorMedium >::Update(Player &, const uint32 &); +template bool TargetedMovementGeneratorMedium >::Update(Creature &, const uint32 &); +template bool TargetedMovementGeneratorMedium >::Update(Creature &, const uint32 &); + +template void ChaseMovementGenerator::_reachTarget(Player &); +template void ChaseMovementGenerator::_reachTarget(Creature &); +template void ChaseMovementGenerator::Finalize(Player &); +template void ChaseMovementGenerator::Finalize(Creature &); +template void ChaseMovementGenerator::Reset(Player &); +template void ChaseMovementGenerator::Reset(Creature &); + +template void FollowMovementGenerator::Finalize(Player &); +template void FollowMovementGenerator::Finalize(Creature &); +template void FollowMovementGenerator::Reset(Player &); +template void FollowMovementGenerator::Reset(Creature &); +template void FollowMovementGenerator::MovementInform(Player &unit); diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h index edb4fca8fce..785d12ba6d2 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h @@ -20,9 +20,8 @@ #define TRINITY_TARGETEDMOVEMENTGENERATOR_H #include "MovementGenerator.h" -#include "DestinationHolder.h" -#include "Traveller.h" #include "FollowerReference.h" +#include "Timer.h" class TargetedMovementGeneratorBase { @@ -33,41 +32,84 @@ class TargetedMovementGeneratorBase FollowerReference i_target; }; +template +class TargetedMovementGeneratorMedium +: public MovementGeneratorMedium< T, D >, public TargetedMovementGeneratorBase +{ + protected: + TargetedMovementGeneratorMedium(Unit &target, float offset, float angle) : + TargetedMovementGeneratorBase(target), i_offset(offset), i_angle(angle), + i_recalculateTravel(false), i_targetReached(false), i_recheckDistance(0) + { + } + ~TargetedMovementGeneratorMedium() {} + + public: + bool Update(T &, const uint32 &); + Unit* GetTarget() const { return i_target.getTarget(); } + + void unitSpeedChanged() { i_recalculateTravel=true; } + void UpdateFinalDistance(float fDistance); + + protected: + void _setTargetLocation(T &); + + TimeTrackerSmall i_recheckDistance; + float i_offset; + float i_angle; + bool i_recalculateTravel : 1; + bool i_targetReached : 1; +}; + template -class TargetedMovementGenerator -: public MovementGeneratorMedium< T, TargetedMovementGenerator >, public TargetedMovementGeneratorBase +class ChaseMovementGenerator : public TargetedMovementGeneratorMedium > { public: - TargetedMovementGenerator(Unit &target, float offset = 0, float angle = 0); - ~TargetedMovementGenerator() {} + ChaseMovementGenerator(Unit &target) + : TargetedMovementGeneratorMedium >(target) {} + ChaseMovementGenerator(Unit &target, float offset, float angle) + : TargetedMovementGeneratorMedium >(target, offset, angle) {} + ~ChaseMovementGenerator() {} + + MovementGeneratorType GetMovementGeneratorType() { return CHASE_MOTION_TYPE; } void Initialize(T &); void Finalize(T &); void Reset(T &); - bool Update(T &, const uint32); - MovementGeneratorType GetMovementGeneratorType() { return TARGETED_MOTION_TYPE; } - - void MovementInform(T &); + void MovementInform(T &){} - Unit* GetTarget() const; + static void _clearUnitStateMove(T &u) { u.ClearUnitState(UNIT_STAT_CHASE_MOVE); } + static void _addUnitStateMove(T &u) { u.AddUnitState(UNIT_STAT_CHASE_MOVE); } + bool EnableWalking() const { return false;} + bool _lostTarget(T &u) const { return u.getVictim() != this->GetTarget(); } + void _reachTarget(T &); +}; - bool GetDestination(float &x, float &y, float &z) const - { - if (i_destinationHolder.HasArrived() || !i_destinationHolder.HasDestination()) return false; - i_destinationHolder.GetDestination(x, y, z); - return true; - } +template +class FollowMovementGenerator : public TargetedMovementGeneratorMedium > +{ + public: + FollowMovementGenerator(Unit &target) + : TargetedMovementGeneratorMedium >(target){} + FollowMovementGenerator(Unit &target, float offset, float angle) + : TargetedMovementGeneratorMedium >(target, offset, angle) {} + ~FollowMovementGenerator() {} - void unitSpeedChanged() { i_recalculateTravel=true; } - private: + MovementGeneratorType GetMovementGeneratorType() { return FOLLOW_MOTION_TYPE; } - bool _setTargetLocation(T &); + void Initialize(T &); + void Finalize(T &); + void Reset(T &); + void MovementInform(T &); - float i_offset; - float i_angle; - DestinationHolder< Traveller > i_destinationHolder; - bool i_recalculateTravel; - float i_targetX, i_targetY, i_targetZ; + static void _clearUnitStateMove(T &u) { u.ClearUnitState(UNIT_STAT_FOLLOW_MOVE); } + static void _addUnitStateMove(T &u) { u.AddUnitState(UNIT_STAT_FOLLOW_MOVE); } + bool EnableWalking() const; + bool _lostTarget(T &) const { return false; } + void _reachTarget(T &) {} + private: + void _updateSpeed(T &u); }; + #endif diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index f88ed249aca..ea858eaba84 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -17,222 +17,165 @@ */ //Basic headers #include "WaypointMovementGenerator.h" -#include "DestinationHolderImp.h" //Extended headers #include "ObjectMgr.h" #include "World.h" -#include "MapManager.h" // for flightmaster grid preloading +//Flightmaster grid preloading +#include "MapManager.h" //Creature-specific headers #include "Creature.h" #include "CreatureAI.h" #include "CreatureGroups.h" //Player-specific #include "Player.h" +#include "MoveSplineInit.h" +#include "MoveSpline.h" -template -void -WaypointMovementGenerator::Initialize(T & /*u*/){} - -template<> -void -WaypointMovementGenerator::Finalize(Creature & /*u*/){} +void WaypointMovementGenerator::LoadPath(Creature &creature) +{ + if (!path_id) + path_id = creature.GetWaypointPath(); -template<> -void -WaypointMovementGenerator::Finalize(Player & /*u*/){} + i_path = sWaypointMgr->GetPath(path_id); -template -void -WaypointMovementGenerator::MovementInform(T & /*unit*/){} + if (!i_path) + { + // No movement found for entry + sLog->outErrorDb("WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path id: %u", creature.GetName(), creature.GetEntry(), creature.GetGUIDLow(), path_id); + return; + } -template<> -void WaypointMovementGenerator::MovementInform(Creature &unit) -{ - unit.AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode); + StartMoveNow(creature); } -template<> -bool WaypointMovementGenerator::GetDestination(float &x, float &y, float &z) const +void WaypointMovementGenerator::Initialize(Creature &creature) { - if (i_destinationHolder.HasArrived()) - return false; - - i_destinationHolder.GetDestination(x, y, z); - return true; + LoadPath(creature); + creature.AddUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); } -template<> -bool WaypointMovementGenerator::GetDestination(float & /*x*/, float & /*y*/, float & /*z*/) const +void WaypointMovementGenerator::Finalize(Creature &creature) { - return false; + creature.ClearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + creature.SetWalk(false); } -template<> -void WaypointMovementGenerator::Reset(Creature & /*unit*/) +void WaypointMovementGenerator::Reset(Creature &creature) { - StopedByPlayer = true; - i_nextMoveTime.Reset(0); + creature.AddUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + StartMoveNow(creature); } -template<> -void WaypointMovementGenerator::Reset(Player & /*unit*/){} - -template<> -void WaypointMovementGenerator::InitTraveller(Creature &unit, const WaypointData &node) +void WaypointMovementGenerator::OnArrived(Creature& creature) { - node.run ? unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING): - unit.AddUnitMovementFlag(MOVEMENTFLAG_WALKING); + if (!i_path || i_path->empty()) + return; + if (m_isArrivalDone) + return; - unit.SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); - unit.SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + creature.ClearUnitState(UNIT_STAT_ROAMING_MOVE); + m_isArrivalDone = true; - // TODO: make this part of waypoint node, so that creature can walk when desired? - if (unit.canFly()) - unit.SetByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02); + if (i_path->at(i_currentNode)->event_id && urand(0, 99) < i_path->at(i_currentNode)->event_chance) + { + sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Creature movement start script %u at point %u for %u.", i_path->at(i_currentNode)->event_id, i_currentNode, creature.GetGUID()); + creature.GetMap()->ScriptsStart(sWaypointScripts, i_path->at(i_currentNode)->event_id, &creature, NULL/*, false*/); + } - unit.AddUnitState(UNIT_STAT_ROAMING); + // Inform script + MovementInform(creature); + Stop(i_path->at(i_currentNode)->delay); } -template<> -void -WaypointMovementGenerator::Initialize(Creature &u) +bool WaypointMovementGenerator::StartMove(Creature &creature) { - u.StopMoving(); - //i_currentNode = -1; // uint32, become 0 in the first update - //i_nextMoveTime.Reset(0); - StopedByPlayer = false; - if (!path_id) - path_id = u.GetWaypointPath(); - waypoints = sWaypointMgr->GetPath(path_id); - i_currentNode = 0; - if (waypoints && waypoints->size()) + if (!i_path || i_path->empty()) + return false; + if (Stopped()) + return true; + + const WaypointData *node = i_path->at(i_currentNode); + + if (m_isArrivalDone) { - node = waypoints->front(); - Traveller traveller(u); - InitTraveller(u, *node); - i_destinationHolder.SetDestination(traveller, node->x, node->y, node->z); - i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); - - //Call for creature group update - if (u.GetFormation() && u.GetFormation()->getLeader() == &u) - u.GetFormation()->LeaderMoveTo(node->x, node->y, node->z); + if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint + { + creature.SetHomePosition(node->x, node->y, node->z, creature.GetOrientation()); + creature.GetMotionMaster()->Initialize(); + return false; + } + + i_currentNode = (i_currentNode+1) % i_path->size(); } - else - node = NULL; -} -template<> -void WaypointMovementGenerator::InitTraveller(Player & /*unit*/, const WaypointData & /*node*/){} + m_isArrivalDone = false; -template -bool -WaypointMovementGenerator::Update(T & /*unit*/, const uint32 /*diff*/) -{ - return false; -} + creature.AddUnitState(UNIT_STAT_ROAMING_MOVE); + + Movement::MoveSplineInit init(creature); + init.MoveTo(node->x, node->y, node->z); -template<> -bool -WaypointMovementGenerator::Update(Creature &unit, const uint32 diff) -{ - if (!&unit) - return true; + if (node->orientation != 100 && node->delay != 0) + init.SetFacing(node->orientation); - if (!path_id) - return false; + init.SetWalk(!node->run); + init.Launch(); + + //Call for creature group update + if (creature.GetFormation() && creature.GetFormation()->getLeader() == &creature) + creature.GetFormation()->LeaderMoveTo(node->x, node->y, node->z); + + return true; +} +bool WaypointMovementGenerator::Update(Creature &creature, const uint32 &diff) +{ // Waypoint movement can be switched on/off // This is quite handy for escort quests and other stuff - if (unit.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) + if (creature.HasUnitState(UNIT_STAT_NOT_MOVE)) + { + creature.ClearUnitState(UNIT_STAT_ROAMING_MOVE); return true; - - // Clear the generator if the path doesn't exist - if (!waypoints || !waypoints->size()) + } + // prevent a crash at empty waypoint path. + if (!i_path || i_path->empty()) return false; - Traveller traveller(unit); - - i_nextMoveTime.Update(diff); - i_destinationHolder.UpdateTraveller(traveller, diff, true); - - if (i_nextMoveTime.GetExpiry() < TIMEDIFF_NEXT_WP) + if (Stopped()) { - if (unit.IsStopped()) - { - if (StopedByPlayer) - { - ASSERT(node); - InitTraveller(unit, *node); - i_destinationHolder.SetDestination(traveller, node->x, node->y, node->z); - i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); - StopedByPlayer = false; - return true; - } - - if (i_currentNode == waypoints->size() - 1) // If that's our last waypoint - { - if (repeating) // If the movement is repeating - i_currentNode = 0; // Start moving all over again - else - { - unit.SetHomePosition(node->x, node->y, node->z, unit.GetOrientation()); - unit.GetMotionMaster()->Initialize(); - return false; // Clear the waypoint movement - } - } - else - ++i_currentNode; - - node = waypoints->at(i_currentNode); - InitTraveller(unit, *node); - i_destinationHolder.SetDestination(traveller, node->x, node->y, node->z); - i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); - - //Call for creature group update - if (unit.GetFormation() && unit.GetFormation()->getLeader() == &unit) - unit.GetFormation()->LeaderMoveTo(node->x, node->y, node->z); - } - else - { - //Determine waittime - if (node->delay) - i_nextMoveTime.Reset(node->delay); - - //note: disable "start" for mtmap - if (node->event_id && urand(0, 99) < node->event_chance) - unit.GetMap()->ScriptsStart(sWaypointScripts, node->event_id, &unit, NULL/*, false*/); - - i_destinationHolder.ResetTravelTime(); - MovementInform(unit); - unit.UpdateWaypointID(i_currentNode); - unit.ClearUnitState(UNIT_STAT_ROAMING); - if (node->orientation) - { - unit.Relocate(node->x, node->y, node->z, node->orientation); - unit.SetFacing(node->orientation, NULL); - } - else - unit.Relocate(node->x, node->y, node->z); - } + if (CanMove(diff)) + return StartMove(creature); } - else + else { - if (unit.IsStopped() && !i_destinationHolder.HasArrived()) + if (creature.IsStopped()) + Stop(STOP_TIME_FOR_PLAYER); + else if (creature.movespline->Finalized()) { - if (!StopedByPlayer) - { - i_destinationHolder.IncreaseTravelTime(STOP_TIME_FOR_PLAYER); - i_nextMoveTime.Reset(STOP_TIME_FOR_PLAYER); - StopedByPlayer = true; - } - } + OnArrived(creature); + return StartMove(creature); + } } + return true; + } + +void WaypointMovementGenerator::MovementInform(Creature &creature) +{ + if (creature.AI()) + creature.AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode); +} + +bool WaypointMovementGenerator::GetResetPosition(Creature&, float& x, float& y, float& z) +{ + // prevent a crash at empty waypoint path. + if (!i_path || i_path->empty()) + return false; + + const WaypointData* node = i_path->at(i_currentNode); + x = node->x; y = node->y; z = node->z; return true; } -template void WaypointMovementGenerator::Initialize(Player &); -template bool WaypointMovementGenerator::Update(Player &, const uint32); -template void WaypointMovementGenerator::MovementInform(Player &); //----------------------------------------------------// @@ -253,71 +196,72 @@ uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const void FlightPathMovementGenerator::Initialize(Player &player) { - player.getHostileRefManager().setOnlineOfflineState(false); - player.AddUnitState(UNIT_STAT_IN_FLIGHT); - player.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); - Traveller traveller(player); - // do not send movement, it was sent already - i_destinationHolder.SetDestination(traveller, (*i_path)[i_currentNode].x, (*i_path)[i_currentNode].y, (*i_path)[i_currentNode].z, false); - // For preloading end grid + Reset(player); InitEndGridInfo(); - player.SendMonsterMoveByPath(GetPath(), GetCurrentNode(), GetPathAtMapEnd()); } void FlightPathMovementGenerator::Finalize(Player & player) { + // remove flag to prevent send object build movement packets for flight state and crash (movement generator already not at top of stack) player.ClearUnitState(UNIT_STAT_IN_FLIGHT); - float x = 0; - float y = 0; - float z = 0; - i_destinationHolder.GetLocationNow(player.GetBaseMap(), x, y, z); - player.UpdatePosition(x, y, z, player.GetOrientation()); + player.Dismount(); + player.RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); + if(player.m_taxi.empty()) + { + player.getHostileRefManager().setOnlineOfflineState(true); + if(player.pvpInfo.inHostileArea) + player.CastSpell(&player, 2479, true); + + // update z position to ground and orientation for landing point + // this prevent cheating with landing point at lags + // when client side flight end early in comparison server side + player.StopMoving(); + } +} + +#define PLAYER_FLIGHT_SPEED 32.0f + +void FlightPathMovementGenerator::Reset(Player & player) +{ + player.getHostileRefManager().setOnlineOfflineState(false); + player.AddUnitState(UNIT_STAT_IN_FLIGHT); + player.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); + + Movement::MoveSplineInit init(player); + uint32 end = GetPathAtMapEnd(); + for (uint32 i = GetCurrentNode(); i != end; ++i) + { + G3D::Vector3 vertice((*i_path)[i].x,(*i_path)[i].y,(*i_path)[i].z); + init.Path().push_back(vertice); + } + init.SetFirstPointId(GetCurrentNode()); + init.SetFly(); + init.SetVelocity(PLAYER_FLIGHT_SPEED); + init.Launch(); } bool FlightPathMovementGenerator::Update(Player &player, const uint32 diff) { - if (MovementInProgress()) + uint32 pointId = (uint32)player.movespline->currentPathIdx(); + if (pointId > i_currentNode) { - Traveller traveller(player); - if (i_destinationHolder.UpdateTraveller(traveller, diff)) + bool departureEvent = true; + do { - i_destinationHolder.ResetUpdate(FLIGHT_TRAVEL_UPDATE); - if (i_destinationHolder.HasArrived()) - { - DoEventIfAny(player, (*i_path)[i_currentNode], false); - - uint32 curMap = (*i_path)[i_currentNode].mapid; - ++i_currentNode; - if (MovementInProgress()) - { - DoEventIfAny(player, (*i_path)[i_currentNode], true); - - sLog->outStaticDebug("loading node %u for player %s", i_currentNode, player.GetName()); - if ((*i_path)[i_currentNode].mapid == curMap) - { - // do not send movement, it was sent already - i_destinationHolder.SetDestination(traveller, (*i_path)[i_currentNode].x, (*i_path)[i_currentNode].y, (*i_path)[i_currentNode].z, false); - } - - // check if it's time to preload the flightmaster grid at path end - if (i_currentNode == m_preloadTargetNode) - PreloadEndGrid(); - - return true; - } - //else HasArrived() - } - else - return true; + DoEventIfAny(player, (*i_path)[i_currentNode], departureEvent); + if (pointId == i_currentNode) + break; + if (i_currentNode == _preloadTargetNode) + PreloadEndGrid(); + i_currentNode += (uint32)departureEvent; + departureEvent = !departureEvent; } - else - return true; + while (true); } - // we have arrived at the end of the path - return false; + return i_currentNode < (i_path->size()-1); } void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport() @@ -336,42 +280,48 @@ void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport() } } +void FlightPathMovementGenerator::DoEventIfAny(Player& player, TaxiPathNodeEntry const& node, bool departure) +{ + if (uint32 eventid = departure ? node.departureEventID : node.arrivalEventID) + { + sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node.index, node.path, player.GetName()); + player.GetMap()->ScriptsStart(sEventScripts, eventid, &player, &player); + } +} + +bool FlightPathMovementGenerator::GetResetPosition(Player&, float& x, float& y, float& z) +{ + const TaxiPathNodeEntry& node = (*i_path)[i_currentNode]; + x = node.x; y = node.y; z = node.z; + return true; +} + void FlightPathMovementGenerator::InitEndGridInfo() { - // Storage to preload flightmaster grid at end of flight. For multi-stop flights, this will - // be reinitialized for each flightmaster at the end of each spline (or stop) in the flight. - - uint32 nodeCount = (*i_path).size(); // Get the number of nodes in the path. - m_endMapId = (*i_path)[nodeCount -1].mapid; // Get the map ID from the last node - m_preloadTargetNode = nodeCount - 3; // 2 nodes before the final node, we pre-load the grid - m_endGridX = (*i_path)[nodeCount -1].x; // Get the X position from the last node - m_endGridY = (*i_path)[nodeCount -1].y; // Get the Y position from the last node + /*! Storage to preload flightmaster grid at end of flight. For multi-stop flights, this will + be reinitialized for each flightmaster at the end of each spline (or stop) in the flight. */ + uint32 nodeCount = (*i_path).size(); //! Number of nodes in path. + _endMapId = (*i_path)[nodeCount - 1].mapid; //! MapId of last node + _preloadTargetNode = nodeCount - 3; + _endGridX = (*i_path)[nodeCount - 1].x; + _endGridY = (*i_path)[nodeCount - 1].y; } void FlightPathMovementGenerator::PreloadEndGrid() { // used to preload the final grid where the flightmaster is - Map* endMap = sMapMgr->FindBaseNonInstanceMap(m_endMapId); + Map* endMap = sMapMgr->FindBaseNonInstanceMap(_endMapId); // Load the grid if (endMap) { - sLog->outDetail("Preloading flightmaster at grid (%f, %f) for map %u", m_endGridX, m_endGridY, m_endMapId); - endMap->LoadGrid(m_endGridX, m_endGridY); + sLog->outDetail("Preloading rid (%f, %f) for map %u at node index %u/%u", _endGridX, _endGridY, _endMapId, _preloadTargetNode, (uint32)(i_path->size()-1)); + endMap->LoadGrid(_endGridX, _endGridY); } else sLog->outDetail("Unable to determine map to preload flightmaster grid"); } -void FlightPathMovementGenerator::DoEventIfAny(Player& player, TaxiPathNodeEntry const& node, bool departure) -{ - if (uint32 eventid = departure ? node.departureEventID : node.arrivalEventID) - { - sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node.index, node.path, player.GetName()); - player.GetMap()->ScriptsStart(sEventScripts, eventid, &player, &player); - } -} - // // Unique1's ASTAR Pathfinding Code... For future use & reference... diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h index 230630936ff..aa6d327db3b 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h @@ -26,10 +26,8 @@ */ #include "MovementGenerator.h" -#include "DestinationHolder.h" #include "WaypointManager.h" #include "Path.h" -#include "Traveller.h" #include "Player.h" @@ -44,49 +42,68 @@ template class PathMovementBase { public: - PathMovementBase() : i_currentNode(0) {} + PathMovementBase() : i_currentNode(0), i_path(NULL) {} virtual ~PathMovementBase() {}; - bool MovementInProgress(void) const { return i_currentNode < i_path->size(); } - + // template pattern, not defined .. override required void LoadPath(T &); - void ReloadPath(T &); uint32 GetCurrentNode() const { return i_currentNode; } - bool GetDestination(float& x, float& y, float& z) const { i_destinationHolder.GetDestination(x, y, z); return true; } - bool GetPosition(float& x, float& y, float& z) const { i_destinationHolder.GetLocationNowNoMicroMovement(x, y, z); return true; } - protected: - uint32 i_currentNode; - DestinationHolder< Traveller > i_destinationHolder; P i_path; + uint32 i_currentNode; }; template +class WaypointMovementGenerator; -class WaypointMovementGenerator - : public MovementGeneratorMedium< T, WaypointMovementGenerator >, public PathMovementBase +template<> +class WaypointMovementGenerator +: public MovementGeneratorMedium< Creature, WaypointMovementGenerator >, +public PathMovementBase { public: - WaypointMovementGenerator(uint32 _path_id = 0, bool _repeating = true) : - node(NULL), path_id(_path_id), i_nextMoveTime(0), repeating(_repeating), StopedByPlayer(false) {} - - void Initialize(T &); - void Finalize(T &); - void MovementInform(T &); - void InitTraveller(T &, const WaypointData &); - void GeneratePathId(T &); - void Reset(T &unit); - bool Update(T &, const uint32); - bool GetDestination(float &x, float &y, float &z) const; + WaypointMovementGenerator(uint32 _path_id = 0, bool _repeating = true) : i_nextMoveTime(0), path_id(_path_id), m_isArrivalDone(false), repeating(_repeating) {} + ~WaypointMovementGenerator() { i_path = NULL; } + void Initialize(Creature &); + void Finalize(Creature &); + void Reset(Creature &); + bool Update(Creature &, const uint32 &diff); + + void MovementInform(Creature &); + MovementGeneratorType GetMovementGeneratorType() { return WAYPOINT_MOTION_TYPE; } + // now path movement implmementation + void LoadPath(Creature &c); + + bool GetResetPosition(Creature&, float& x, float& y, float& z); + private: - WaypointData* node; - uint32 path_id; + + void Stop(int32 time) { i_nextMoveTime.Reset(time);} + + bool Stopped() { return !i_nextMoveTime.Passed();} + + bool CanMove(int32 diff) + { + i_nextMoveTime.Update(diff); + return i_nextMoveTime.Passed(); + } + + void OnArrived(Creature&); + bool StartMove(Creature&); + + void StartMoveNow(Creature& creature) + { + i_nextMoveTime.Reset(0); + StartMove(creature); + } + TimeTrackerSmall i_nextMoveTime; - WaypointPath const* waypoints; - bool repeating, StopedByPlayer; + bool m_isArrivalDone; + uint32 path_id; + bool repeating; }; /** FlightPathMovementGenerator generates movement of the player for the paths @@ -103,7 +120,7 @@ public PathMovementBase i_currentNode = startNode; } void Initialize(Player &); - void Reset(Player & /*u*/){}; + void Reset(Player &); void Finalize(Player &); bool Update(Player &, const uint32); MovementGeneratorType GetMovementGeneratorType() { return FLIGHT_MOTION_TYPE; } @@ -115,17 +132,16 @@ public PathMovementBase void SkipCurrentNode() { ++i_currentNode; } void DoEventIfAny(Player& player, TaxiPathNodeEntry const& node, bool departure); - bool GetDestination(float& x, float& y, float& z) const { return PathMovementBase::GetDestination(x, y, z); } + bool GetResetPosition(Player&, float& x, float& y, float& z); - void PreloadEndGrid(); void InitEndGridInfo(); + void PreloadEndGrid(); + private: - // storage for preloading the flightmaster grid at end - // before reaching final waypoint - uint32 m_endMapId; - uint32 m_preloadTargetNode; - float m_endGridX; - float m_endGridY; + float _endGridX; //! X coord of last node location + float _endGridY; //! Y coord of last node location + uint32 _endMapId; //! map Id of last node location + uint32 _preloadTargetNode; //! node index where preloading starts }; #endif diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp new file mode 100644 index 00000000000..4eaa6b57b36 --- /dev/null +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -0,0 +1,316 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "MoveSpline.h" +#include +#include "Log.h" + +namespace Movement{ + +extern float computeFallTime(float path_length, bool isSafeFall); +extern float computeFallElevation(float time_passed, bool isSafeFall, float start_velocy); +extern float computeFallElevation(float time_passed); + +Location MoveSpline::ComputePosition() const +{ + ASSERT(Initialized()); + + float u = 1.f; + int32 seg_time = spline.length(point_Idx,point_Idx+1); + if (seg_time > 0) + u = (time_passed - spline.length(point_Idx)) / (float)seg_time; + Location c; + c.orientation = initialOrientation; + spline.evaluate_percent(point_Idx, u, c); + + if (splineflags.animation) + ;// MoveSplineFlag::Animation disables falling or parabolic movement + else if (splineflags.parabolic) + computeParabolicElevation(c.z); + else if (splineflags.falling) + computeFallElevation(c.z); + + if (splineflags.done && splineflags.isFacing()) + { + if (splineflags.final_angle) + c.orientation = facing.angle; + else if (splineflags.final_point) + c.orientation = atan2(facing.f.y-c.y, facing.f.x-c.x); + //nothing to do for MoveSplineFlag::Final_Target flag + } + else + { + if (!splineflags.hasFlag(MoveSplineFlag::OrientationFixed|MoveSplineFlag::Falling)) + { + Vector3 hermite; + spline.evaluate_derivative(point_Idx,u,hermite); + c.orientation = atan2(hermite.y, hermite.x); + } + + if (splineflags.orientationInversed) + c.orientation = -c.orientation; + } + return c; +} + +void MoveSpline::computeParabolicElevation(float& el) const +{ + if (time_passed > effect_start_time) + { + float t_passedf = MSToSec(time_passed - effect_start_time); + float t_durationf = MSToSec(Duration() - effect_start_time); //client use not modified duration here + + // -a*x*x + bx + c: + //(dur * v3->z_acceleration * dt)/2 - (v3->z_acceleration * dt * dt)/2 + Z; + el += (t_durationf - t_passedf) * 0.5f * vertical_acceleration * t_passedf; + } +} + +void MoveSpline::computeFallElevation(float& el) const +{ + float z_now = spline.getPoint(spline.first()).z - Movement::computeFallElevation(MSToSec(time_passed)); + float final_z = FinalDestination().z; + if (z_now < final_z) + el = final_z; + else + el = z_now; +} + +inline uint32 computeDuration(float length, float velocity) +{ + return SecToMS(length / velocity); +} + +struct FallInitializer +{ + FallInitializer(float _start_elevation) : start_elevation(_start_elevation) {} + float start_elevation; + inline int32 operator()(Spline& s, int32 i) + { + return Movement::computeFallTime(start_elevation - s.getPoint(i+1).z,false) * 1000.f; + } +}; + +enum{ + minimal_duration = 1, +}; + +struct CommonInitializer +{ + CommonInitializer(float _velocity) : velocityInv(1000.f/_velocity), time(minimal_duration) {} + float velocityInv; + int32 time; + inline int32 operator()(Spline& s, int32 i) + { + time += (s.SegLength(i) * velocityInv); + return time; + } +}; + +void MoveSpline::init_spline(const MoveSplineInitArgs& args) +{ + const SplineBase::EvaluationMode modes[2] = {SplineBase::ModeLinear,SplineBase::ModeCatmullrom}; + if (args.flags.cyclic) + { + uint32 cyclic_point = 0; + // MoveSplineFlag::Enter_Cycle support dropped + //if (splineflags & SPLINEFLAG_ENTER_CYCLE) + //cyclic_point = 1; // shouldn't be modified, came from client + spline.init_cyclic_spline(&args.path[0], args.path.size(), modes[args.flags.isSmooth()], cyclic_point); + } + else + { + spline.init_spline(&args.path[0], args.path.size(), modes[args.flags.isSmooth()]); + } + + // init spline timestamps + if (splineflags.falling) + { + FallInitializer init(spline.getPoint(spline.first()).z); + spline.initLengths(init); + } + else + { + CommonInitializer init(args.velocity); + spline.initLengths(init); + } + + // TODO: what to do in such cases? problem is in input data (all points are at same coords) + if (spline.length() < minimal_duration) + { + sLog->outError("MoveSpline::init_spline: zero length spline, wrong input data?"); + spline.set_length(spline.last(), spline.isCyclic() ? 1000 : 1); + } + point_Idx = spline.first(); +} + +void MoveSpline::Initialize(const MoveSplineInitArgs& args) +{ + splineflags = args.flags; + facing = args.facing; + m_Id = args.splineId; + point_Idx_offset = args.path_Idx_offset; + initialOrientation = args.initialOrientation; + + time_passed = 0; + vertical_acceleration = 0.f; + effect_start_time = 0; + + init_spline(args); + + // init parabolic / animation + // spline initialized, duration known and i able to compute parabolic acceleration + if (args.flags & (MoveSplineFlag::Parabolic | MoveSplineFlag::Animation)) + { + effect_start_time = Duration() * args.time_perc; + if (args.flags.parabolic && effect_start_time < Duration()) + { + float f_duration = MSToSec(Duration() - effect_start_time); + vertical_acceleration = args.parabolic_amplitude * 8.f / (f_duration * f_duration); + } + } +} + +MoveSpline::MoveSpline() : m_Id(0), time_passed(0), + vertical_acceleration(0.f), effect_start_time(0), point_Idx(0), point_Idx_offset(0), initialOrientation(0.f) +{ + splineflags.done = true; +} + +/// ============================================================================================ + +bool MoveSplineInitArgs::Validate() const +{ +#define CHECK(exp) \ + if (!(exp))\ + {\ + sLog->outError("MoveSplineInitArgs::Validate: expression '%s' failed", #exp);\ + return false;\ + } + CHECK(path.size() > 1); + CHECK(velocity > 0.f); + CHECK(time_perc >= 0.f && time_perc <= 1.f); + //CHECK(_checkPathBounds()); + return true; +#undef CHECK +} + +// MONSTER_MOVE packet format limitation for not CatmullRom movement: +// each vertex offset packed into 11 bytes +bool MoveSplineInitArgs::_checkPathBounds() const +{ + if (!(flags & MoveSplineFlag::Mask_CatmullRom) && path.size() > 2) + { + enum{ + MAX_OFFSET = (1 << 11) / 2, + }; + Vector3 middle = (path.front()+path.back()) / 2; + Vector3 offset; + for (uint32 i = 1; i < path.size()-1; ++i) + { + offset = path[i] - middle; + if (fabs(offset.x) >= MAX_OFFSET || fabs(offset.y) >= MAX_OFFSET || fabs(offset.z) >= MAX_OFFSET) + { + sLog->outError("MoveSplineInitArgs::_checkPathBounds check failed"); + return false; + } + } + } + return true; +} + +/// ============================================================================================ + +MoveSpline::UpdateResult MoveSpline::_updateState(int32& ms_time_diff) +{ + if (Finalized()) + { + ms_time_diff = 0; + return Result_Arrived; + } + + UpdateResult result = Result_None; + + int32 minimal_diff = std::min(ms_time_diff, segment_time_elapsed()); + ASSERT(minimal_diff >= 0); + time_passed += minimal_diff; + ms_time_diff -= minimal_diff; + + if (time_passed >= next_timestamp()) + { + ++point_Idx; + if (point_Idx < spline.last()) + { + result = Result_NextSegment; + } + else + { + if (spline.isCyclic()) + { + point_Idx = spline.first(); + time_passed = time_passed % Duration(); + result = Result_NextSegment; + } + else + { + _Finalize(); + ms_time_diff = 0; + result = Result_Arrived; + } + } + } + + return result; +} + +std::string MoveSpline::ToString() const +{ + std::stringstream str; + str << "MoveSpline" << std::endl; + str << "spline Id: " << GetId() << std::endl; + str << "flags: " << splineflags.ToString() << std::endl; + if (splineflags.final_angle) + str << "facing angle: " << facing.angle; + else if (splineflags.final_target) + str << "facing target: " << facing.target; + else if(splineflags.final_point) + str << "facing point: " << facing.f.x << " " << facing.f.y << " " << facing.f.z; + str << std::endl; + str << "time passed: " << time_passed << std::endl; + str << "total time: " << Duration() << std::endl; + str << "spline point Id: " << point_Idx << std::endl; + str << "path point Id: " << currentPathIdx() << std::endl; + str << spline.ToString(); + return str.str(); +} + +void MoveSpline::_Finalize() +{ + splineflags.done = true; + point_Idx = spline.last() - 1; + time_passed = Duration(); +} + +int32 MoveSpline::currentPathIdx() const +{ + int32 point = point_Idx_offset + point_Idx - spline.first() + (int)Finalized(); + if (isCyclic()) + point = point % (spline.last()-spline.first()); + return point; +} +} diff --git a/src/server/game/Movement/Spline/MoveSpline.h b/src/server/game/Movement/Spline/MoveSpline.h new file mode 100644 index 00000000000..4b8dbcc8ee3 --- /dev/null +++ b/src/server/game/Movement/Spline/MoveSpline.h @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef TRINITYSERVER_MOVEPLINE_H +#define TRINITYSERVER_MOVEPLINE_H + +#include "Spline.h" +#include "MoveSplineInitArgs.h" + +namespace Movement +{ + struct Location : public Vector3 + { + Location() : orientation(0) {} + Location(float x, float y, float z, float o) : Vector3(x,y,z), orientation(o) {} + Location(const Vector3& v) : Vector3(v), orientation(0) {} + Location(const Vector3& v, float o) : Vector3(v), orientation(o) {} + + float orientation; + }; + + // MoveSpline represents smooth catmullrom or linear curve and point that moves belong it + // curve can be cyclic - in this case movement will be cyclic + // point can have vertical acceleration motion componemt(used in fall, parabolic movement) + class MoveSpline + { + public: + typedef Spline MySpline; + enum UpdateResult{ + Result_None = 0x01, + Result_Arrived = 0x02, + Result_NextCycle = 0x04, + Result_NextSegment = 0x08, + }; + #pragma region fields + friend class PacketBuilder; + protected: + MySpline spline; + + FacingInfo facing; + + uint32 m_Id; + + MoveSplineFlag splineflags; + + int32 time_passed; + // currently duration mods are unused, but its _currently_ + //float duration_mod; + //float duration_mod_next; + float vertical_acceleration; + float initialOrientation; + int32 effect_start_time; + int32 point_Idx; + int32 point_Idx_offset; + + void init_spline(const MoveSplineInitArgs& args); + protected: + + const MySpline::ControlArray& getPath() const { return spline.getPoints();} + void computeParabolicElevation(float& el) const; + void computeFallElevation(float& el) const; + + UpdateResult _updateState(int32& ms_time_diff); + int32 next_timestamp() const { return spline.length(point_Idx+1);} + int32 segment_time_elapsed() const { return next_timestamp()-time_passed;} + int32 Duration() const { return spline.length();} + int32 timeElapsed() const { return Duration() - time_passed;} + int32 timePassed() const { return time_passed;} + + public: + const MySpline& _Spline() const { return spline;} + int32 _currentSplineIdx() const { return point_Idx;} + void _Finalize(); + void _Interrupt() { splineflags.done = true;} + + #pragma endregion + public: + + void Initialize(const MoveSplineInitArgs&); + bool Initialized() const { return !spline.empty();} + + explicit MoveSpline(); + + template + void updateState(int32 difftime, UpdateHandler& handler) + { + ASSERT(Initialized()); + do + handler(_updateState(difftime)); + while(difftime > 0); + } + + void updateState(int32 difftime) + { + ASSERT(Initialized()); + do _updateState(difftime); + while(difftime > 0); + } + + Location ComputePosition() const; + + uint32 GetId() const { return m_Id;} + bool Finalized() const { return splineflags.done; } + bool isCyclic() const { return splineflags.cyclic;} + const Vector3 FinalDestination() const { return Initialized() ? spline.getPoint(spline.last()) : Vector3();} + const Vector3 CurrentDestination() const { return Initialized() ? spline.getPoint(point_Idx+1) : Vector3();} + int32 currentPathIdx() const; + + std::string ToString() const; + }; +} +#endif // TRINITYSERVER_MOVEPLINE_H diff --git a/src/server/game/Movement/Spline/MoveSplineFlag.h b/src/server/game/Movement/Spline/MoveSplineFlag.h new file mode 100644 index 00000000000..de91f63c30a --- /dev/null +++ b/src/server/game/Movement/Spline/MoveSplineFlag.h @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef TRINITYSERVER_MOVESPLINEFLAG_H +#define TRINITYSERVER_MOVESPLINEFLAG_H +#include "MovementTypedefs.h" + +#include + +namespace Movement +{ +#if defined( __GNUC__ ) +#pragma pack(1) +#else +#pragma pack(push,1) +#endif + + class MoveSplineFlag + { + public: + enum eFlags{ + None = 0x00000000, + // x00-xFF(first byte) used as animation Ids storage in pair with Animation flag + Done = 0x00000100, + Falling = 0x00000200, // Affects elevation computation, can't be combined with Parabolic flag + No_Spline = 0x00000400, + Parabolic = 0x00000800, // Affects elevation computation, can't be combined with Falling flag + Walkmode = 0x00001000, + Flying = 0x00002000, // Smooth movement(Catmullrom interpolation mode), flying animation + OrientationFixed = 0x00004000, // Model orientation fixed + Final_Point = 0x00008000, + Final_Target = 0x00010000, + Final_Angle = 0x00020000, + Catmullrom = 0x00040000, // Used Catmullrom interpolation mode + Cyclic = 0x00080000, // Movement by cycled spline + Enter_Cycle = 0x00100000, // Everytimes appears with cyclic flag in monster move packet, erases first spline vertex after first cycle done + Animation = 0x00200000, // Plays animation after some time passed + Frozen = 0x00400000, // Will never arrive + Unknown5 = 0x00800000, + Unknown6 = 0x01000000, + Unknown7 = 0x02000000, + Unknown8 = 0x04000000, + OrientationInversed = 0x08000000, + Unknown10 = 0x10000000, + Unknown11 = 0x20000000, + Unknown12 = 0x40000000, + Unknown13 = 0x80000000, + + // Masks + Mask_Final_Facing = Final_Point | Final_Target | Final_Angle, + // animation ids stored here, see AnimType enum, used with Animation flag + Mask_Animations = 0xFF, + // flags that shouldn't be appended into SMSG_MONSTER_MOVE\SMSG_MONSTER_MOVE_TRANSPORT packet, should be more probably + Mask_No_Monster_Move = Mask_Final_Facing | Mask_Animations | Done, + // CatmullRom interpolation mode used + Mask_CatmullRom = Flying | Catmullrom, + // Unused, not suported flags + Mask_Unused = No_Spline|Enter_Cycle|Frozen|Unknown5|Unknown6|Unknown7|Unknown8|Unknown10|Unknown11|Unknown12|Unknown13, + }; + + inline uint32& raw() { return (uint32&)*this;} + inline const uint32& raw() const { return (const uint32&)*this;} + + MoveSplineFlag() { raw() = 0; } + MoveSplineFlag(uint32 f) { raw() = f; } + MoveSplineFlag(const MoveSplineFlag& f) { raw() = f.raw(); } + + // Constant interface + + bool isSmooth() const { return raw() & Mask_CatmullRom;} + bool isLinear() const { return !isSmooth();} + bool isFacing() const { return raw() & Mask_Final_Facing;} + + uint8 getAnimationId() const { return animId;} + bool hasAllFlags(uint32 f) const { return (raw() & f) == f;} + bool hasFlag(uint32 f) const { return (raw() & f) != 0;} + uint32 operator & (uint32 f) const { return (raw() & f);} + uint32 operator | (uint32 f) const { return (raw() | f);} + std::string ToString() const; + + // Not constant interface + + void operator &= (uint32 f) { raw() &= f;} + void operator |= (uint32 f) { raw() |= f;} + + void EnableAnimation(uint8 anim) { raw() = raw() & ~(Mask_Animations|Falling|Parabolic) | Animation|anim;} + void EnableParabolic() { raw() = raw() & ~(Mask_Animations|Falling|Animation) | Parabolic;} + void EnableFalling() { raw() = raw() & ~(Mask_Animations|Parabolic|Animation) | Falling;} + void EnableFlying() { raw() = raw() & ~Catmullrom | Flying; } + void EnableCatmullRom() { raw() = raw() & ~Flying | Catmullrom; } + void EnableFacingPoint() { raw() = raw() & ~Mask_Final_Facing | Final_Point;} + void EnableFacingAngle() { raw() = raw() & ~Mask_Final_Facing | Final_Angle;} + void EnableFacingTarget() { raw() = raw() & ~Mask_Final_Facing | Final_Target;} + + uint8 animId : 8; + bool done : 1; + bool falling : 1; + bool no_spline : 1; + bool parabolic : 1; + bool walkmode : 1; + bool flying : 1; + bool orientationFixed : 1; + bool final_point : 1; + bool final_target : 1; + bool final_angle : 1; + bool catmullrom : 1; + bool cyclic : 1; + bool enter_cycle : 1; + bool animation : 1; + bool frozen : 1; + bool unknown5 : 1; + bool unknown6 : 1; + bool unknown7 : 1; + bool unknown8 : 1; + bool orientationInversed : 1; + bool unknown10 : 1; + bool unknown11 : 1; + bool unknown12 : 1; + bool unknown13 : 1; + }; +#if defined( __GNUC__ ) +#pragma pack() +#else +#pragma pack(pop) +#endif +} + +#endif // TRINITYSERVER_MOVESPLINEFLAG_H diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp new file mode 100644 index 00000000000..885ade57653 --- /dev/null +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "MoveSplineInit.h" +#include "MoveSpline.h" +#include "MovementPacketBuilder.h" +#include "Unit.h" + +namespace Movement +{ + UnitMoveType SelectSpeedType(uint32 moveFlags) + { + if (moveFlags & MOVEMENTFLAG_FLYING) + { + if ( moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.flight >= speed_obj.flight_back*/ ) + return MOVE_FLIGHT_BACK; + else + return MOVE_FLIGHT; + } + else if (moveFlags & MOVEMENTFLAG_SWIMMING) + { + if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.swim >= speed_obj.swim_back*/) + return MOVE_SWIM_BACK; + else + return MOVE_SWIM; + } + else if (moveFlags & MOVEMENTFLAG_WALKING) + { + //if ( speed_obj.run > speed_obj.walk ) + return MOVE_WALK; + } + else if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.run >= speed_obj.run_back*/) + return MOVE_RUN_BACK; + + return MOVE_RUN; + } + + void MoveSplineInit::Launch() + { + MoveSpline& move_spline = *unit.movespline; + + Location real_position(unit.GetPositionX(),unit.GetPositionY(),unit.GetPositionZ(),unit.GetOrientation()); + // there is a big chane that current position is unknown if current state is not finalized, need compute it + // this also allows calculate spline position and update map position in much greater intervals + if (!move_spline.Finalized()) + real_position = move_spline.ComputePosition(); + + if (args.path.empty()) + { + // should i do the things that user should do? + MoveTo(real_position); + } + + // corrent first vertex + args.path[0] = real_position; + args.initialOrientation = real_position.orientation; + + uint32 moveFlags = unit.m_movementInfo.GetMovementFlags(); + if (args.flags.walkmode) + moveFlags |= MOVEMENTFLAG_WALKING; + else + moveFlags &= ~MOVEMENTFLAG_WALKING; + + moveFlags |= (MOVEMENTFLAG_SPLINE_ENABLED|MOVEMENTFLAG_FORWARD); + + if (args.velocity == 0.f) + args.velocity = unit.GetSpeed(SelectSpeedType(moveFlags)); + + if (!args.Validate()) + return; + + if (moveFlags & MOVEMENTFLAG_ROOT) + moveFlags &= ~MOVEMENTFLAG_MASK_MOVING; + + unit.m_movementInfo.SetMovementFlags((MovementFlags)moveFlags); + move_spline.Initialize(args); + + WorldPacket data(SMSG_MONSTER_MOVE, 64); + data.append(unit.GetPackGUID()); + PacketBuilder::WriteMonsterMove(move_spline, data); + unit.SendMessageToSet(&data,true); + } + + MoveSplineInit::MoveSplineInit(Unit& m) : unit(m) + { + // mix existing state into new + args.flags.walkmode = unit.m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING); + args.flags.flying = unit.m_movementInfo.HasMovementFlag((MovementFlags)(MOVEMENTFLAG_FLYING|MOVEMENTFLAG_LEVITATING)); + } + + void MoveSplineInit::SetFacing(const Unit * target) + { + args.flags.EnableFacingTarget(); + target->GetUInt64Value(OBJECT_FIELD_GUID); + //args.facing.target = target->GetObjectGuid().GetRawValue(); + args.facing.target = target->GetUInt64Value(OBJECT_FIELD_GUID); + } + + void MoveSplineInit::SetFacing(float angle) + { + args.facing.angle = G3D::wrap(angle, 0.f, (float)G3D::twoPi()); + args.flags.EnableFacingAngle(); + } +} diff --git a/src/server/game/Movement/Spline/MoveSplineInit.h b/src/server/game/Movement/Spline/MoveSplineInit.h new file mode 100644 index 00000000000..7ef6cd7a120 --- /dev/null +++ b/src/server/game/Movement/Spline/MoveSplineInit.h @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef TRINITYSERVER_MOVESPLINEINIT_H +#define TRINITYSERVER_MOVESPLINEINIT_H + +#include "MoveSplineInitArgs.h" + +class Unit; + +namespace Movement +{ + enum AnimType + { + ToGround = 0, // 460 = ToGround, index of AnimationData.dbc + FlyToFly = 1, // 461 = FlyToFly? + ToFly = 2, // 458 = ToFly + FlyToGround = 3, // 463 = FlyToGround + }; + + /* Initializes and launches spline movement + */ + class MoveSplineInit + { + public: + + explicit MoveSplineInit(Unit& m); + + /* Final pass of initialization that launches spline movement. + */ + void Launch(); + + /* Adds movement by parabolic trajectory + * @param amplitude - the maximum height of parabola, value could be negative and positive + * @param start_time - delay between movement starting time and beginning to move by parabolic trajectory + * can't be combined with final animation + */ + void SetParabolic(float amplitude, float start_time); + /* Plays animation after movement done + * can't be combined with parabolic movement + */ + void SetAnimation(AnimType anim); + + /* Adds final facing animation + * sets unit's facing to specified point/angle after all path done + * you can have only one final facing: previous will be overriden + */ + void SetFacing(float angle); + void SetFacing(Vector3 const& point); + void SetFacing(const Unit * target); + + /* Initializes movement by path + * @param path - array of points, shouldn't be empty + * @param pointId - Id of fisrt point of the path. Example: when third path point will be done it will notify that pointId + 3 done + */ + void MovebyPath(const PointsArray& path, int32 pointId = 0); + + /* Initializes simple A to B mition, A is current unit's position, B is destination + */ + void MoveTo(const Vector3& destination); + void MoveTo(float x, float y, float z); + + /* Sets Id of fisrt point of the path. When N-th path point will be done ILisener will notify that pointId + N done + * Needed for waypoint movement where path splitten into parts + */ + void SetFirstPointId(int32 pointId) { args.path_Idx_offset = pointId; } + + /* Enables CatmullRom spline interpolation mode(makes path smooth) + * if not enabled linear spline mode will be choosen. Disabled by default + */ + void SetSmooth(); + /* Enables CatmullRom spline interpolation mode, enables flying animation. Disabled by default + */ + void SetFly(); + /* Enables walk mode. Disabled by default + */ + void SetWalk(bool enable); + /* Makes movement cyclic. Disabled by default + */ + void SetCyclic(); + /* Enables falling mode. Disabled by default + */ + void SetFall(); + /* Inverses unit model orientation. Disabled by default + */ + void SetOrientationInversed(); + /* Fixes unit's model rotation. Disabled by default + */ + void SetOrientationFixed(bool enable); + + /* Sets the velocity (in case you want to have custom movement velocity) + * if no set, speed will be selected based on unit's speeds and current movement mode + * Has no effect if falling mode enabled + * velocity shouldn't be negative + */ + void SetVelocity(float velocity); + + PointsArray& Path() { return args.path; } + + protected: + + MoveSplineInitArgs args; + Unit& unit; + }; + + inline void MoveSplineInit::SetFly() { args.flags.EnableFlying();} + inline void MoveSplineInit::SetWalk(bool enable) { args.flags.walkmode = enable;} + inline void MoveSplineInit::SetSmooth() { args.flags.EnableCatmullRom();} + inline void MoveSplineInit::SetCyclic() { args.flags.cyclic = true;} + inline void MoveSplineInit::SetFall() { args.flags.EnableFalling();} + inline void MoveSplineInit::SetVelocity(float vel){ args.velocity = vel;} + inline void MoveSplineInit::SetOrientationInversed() { args.flags.orientationInversed = true;} + inline void MoveSplineInit::SetOrientationFixed(bool enable) { args.flags.orientationFixed = enable;} + + inline void MoveSplineInit::MovebyPath(const PointsArray& controls, int32 path_offset) + { + args.path_Idx_offset = path_offset; + args.path.assign(controls.begin(),controls.end()); + } + + inline void MoveSplineInit::MoveTo(float x, float y, float z) + { + Vector3 v(x,y,z); + MoveTo(v); + } + + inline void MoveSplineInit::MoveTo(const Vector3& dest) + { + args.path_Idx_offset = 0; + args.path.resize(2); + args.path[1] = dest; + } + + inline void MoveSplineInit::SetParabolic(float amplitude, float time_shift) + { + args.time_perc = time_shift; + args.parabolic_amplitude = amplitude; + args.flags.EnableParabolic(); + } + + inline void MoveSplineInit::SetAnimation(AnimType anim) + { + args.time_perc = 0.f; + args.flags.EnableAnimation((uint8)anim); + } + + inline void MoveSplineInit::SetFacing(Vector3 const& spot) + { + args.facing.f.x = spot.x; + args.facing.f.y = spot.y; + args.facing.f.z = spot.z; + args.flags.EnableFacingPoint(); + } +} +#endif // TRINITYSERVER_MOVESPLINEINIT_H diff --git a/src/server/game/Movement/Spline/MoveSplineInitArgs.h b/src/server/game/Movement/Spline/MoveSplineInitArgs.h new file mode 100644 index 00000000000..26fbbdd0fcc --- /dev/null +++ b/src/server/game/Movement/Spline/MoveSplineInitArgs.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef TRINITYSERVER_MOVESPLINEINIT_ARGS_H +#define TRINITYSERVER_MOVESPLINEINIT_ARGS_H + +#include "MoveSplineFlag.h" +#include + +namespace Movement +{ + typedef std::vector PointsArray; + + union FacingInfo + { + struct{ + float x,y,z; + }f; + uint64 target; + float angle; + + FacingInfo(float o) : angle(o) {} + FacingInfo(uint64 t) : target(t) {} + FacingInfo() {} + }; + + struct MoveSplineInitArgs + { + MoveSplineInitArgs(size_t path_capacity = 16) : path_Idx_offset(0), + velocity(0.f), parabolic_amplitude(0.f), time_perc(0.f), splineId(0), initialOrientation(0.f) + { + path.reserve(path_capacity); + } + + PointsArray path; + FacingInfo facing; + MoveSplineFlag flags; + int32 path_Idx_offset; + float velocity; + float parabolic_amplitude; + float time_perc; + uint32 splineId; + float initialOrientation; + + /** Returns true to show that the arguments were configured correctly and MoveSpline initialization will succeed. */ + bool Validate() const; + private: + bool _checkPathBounds() const; + }; +} + +#endif // TRINITYSERVER_MOVESPLINEINIT_ARGS_H diff --git a/src/server/game/Movement/Spline/MovementPacketBuilder.cpp b/src/server/game/Movement/Spline/MovementPacketBuilder.cpp new file mode 100644 index 00000000000..73fdbf4c2f6 --- /dev/null +++ b/src/server/game/Movement/Spline/MovementPacketBuilder.cpp @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "MovementPacketBuilder.h" +#include "MoveSpline.h" +#include "WorldPacket.h" + +namespace Movement +{ + inline void operator << (ByteBuffer& b, const Vector3& v) + { + b << v.x << v.y << v.z; + } + + inline void operator >> (ByteBuffer& b, Vector3& v) + { + b >> v.x >> v.y >> v.z; + } + + enum MonsterMoveType + { + MonsterMoveNormal = 0, + MonsterMoveStop = 1, + MonsterMoveFacingSpot = 2, + MonsterMoveFacingTarget = 3, + MonsterMoveFacingAngle = 4 + }; + + void PacketBuilder::WriteCommonMonsterMovePart(const MoveSpline& move_spline, WorldPacket& data) + { + MoveSplineFlag splineflags = move_spline.splineflags; + /*if (mov.IsBoarded()) + { + data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT); + data << mov.GetTransport()->Owner.GetPackGUID(); + data << int8(mov.m_unused.transport_seat); + }*/ + + data << uint8(0); + data << move_spline.spline.getPoint(move_spline.spline.first()); + data << move_spline.GetId(); + + switch(splineflags & MoveSplineFlag::Mask_Final_Facing) + { + default: + data << uint8(MonsterMoveNormal); + break; + case MoveSplineFlag::Final_Target: + data << uint8(MonsterMoveFacingTarget); + data << move_spline.facing.target; + break; + case MoveSplineFlag::Final_Angle: + data << uint8(MonsterMoveFacingAngle); + data << move_spline.facing.angle; + break; + case MoveSplineFlag::Final_Point: + data << uint8(MonsterMoveFacingSpot); + data << move_spline.facing.f.x << move_spline.facing.f.y << move_spline.facing.f.z; + break; + } + + // add fake Enter_Cycle flag - needed for client-side cyclic movement (client will erase first spline vertex after first cycle done) + splineflags.enter_cycle = move_spline.isCyclic(); + data << uint32(splineflags & ~MoveSplineFlag::Mask_No_Monster_Move); + + if (splineflags.animation) + { + data << splineflags.getAnimationId(); + data << move_spline.effect_start_time; + } + + data << move_spline.Duration(); + + if (splineflags.parabolic) + { + data << move_spline.vertical_acceleration; + data << move_spline.effect_start_time; + } + } + + void WriteLinearPath(const Spline& spline, ByteBuffer& data) + { + uint32 last_idx = spline.getPointCount() - 3; + const Vector3 * real_path = &spline.getPoint(1); + + data << last_idx; + data << real_path[last_idx]; // destination + if (last_idx > 1) + { + Vector3 middle = (real_path[0] + real_path[last_idx]) / 2.f; + Vector3 offset; + // first and last points already appended + for(uint32 i = 1; i < last_idx; ++i) + { + offset = middle - real_path[i]; + data.appendPackXYZ(offset.x, offset.y, offset.z); + } + } + } + + void WriteCatmullRomPath(const Spline& spline, ByteBuffer& data) + { + uint32 count = spline.getPointCount() - 3; + data << count; + data.append(&spline.getPoint(2), count); + } + + void WriteCatmullRomCyclicPath(const Spline& spline, ByteBuffer& data) + { + uint32 count = spline.getPointCount() - 3; + data << uint32(count + 1); + data << spline.getPoint(1); // fake point, client will erase it from the spline after first cycle done + data.append(&spline.getPoint(1), count); + } + + void PacketBuilder::WriteMonsterMove(const MoveSpline& move_spline, WorldPacket& data) + { + WriteCommonMonsterMovePart(move_spline, data); + + const Spline& spline = move_spline.spline; + MoveSplineFlag splineflags = move_spline.splineflags; + if (splineflags & MoveSplineFlag::Mask_CatmullRom) + { + if (splineflags.cyclic) + WriteCatmullRomCyclicPath(spline, data); + else + WriteCatmullRomPath(spline, data); + } + else + WriteLinearPath(spline, data); + } + + void PacketBuilder::WriteCreate(const MoveSpline& move_spline, ByteBuffer& data) + { + //WriteClientStatus(mov,data); + //data.append(&mov.m_float_values[SpeedWalk], SpeedMaxCount); + //if (mov.SplineEnabled()) + { + MoveSplineFlag splineFlags = move_spline.splineflags; + + data << splineFlags.raw(); + + if (splineFlags.final_angle) + { + data << move_spline.facing.angle; + } + else if (splineFlags.final_target) + { + data << move_spline.facing.target; + } + else if(splineFlags.final_point) + { + data << move_spline.facing.f.x << move_spline.facing.f.y << move_spline.facing.f.z; + } + + data << move_spline.timePassed(); + data << move_spline.Duration(); + data << move_spline.GetId(); + + data << float(1.f); // splineInfo.duration_mod; added in 3.1 + data << float(1.f); // splineInfo.duration_mod_next; added in 3.1 + + data << move_spline.vertical_acceleration; // added in 3.1 + data << move_spline.effect_start_time; // added in 3.1 + + uint32 nodes = move_spline.getPath().size(); + data << nodes; + data.append(&move_spline.getPath()[0], nodes); + data << uint8(move_spline.spline.mode()); // added in 3.1 + data << (move_spline.isCyclic() ? Vector3::zero() : move_spline.FinalDestination()); + } + } +} diff --git a/src/server/game/Movement/Spline/MovementPacketBuilder.h b/src/server/game/Movement/Spline/MovementPacketBuilder.h new file mode 100644 index 00000000000..92a414e9b3b --- /dev/null +++ b/src/server/game/Movement/Spline/MovementPacketBuilder.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef TRINITYSERVER_PACKET_BUILDER_H +#define TRINITYSERVER_PACKET_BUILDER_H + +class ByteBuffer; +class WorldPacket; + +namespace Movement +{ + class MoveSpline; + class PacketBuilder + { + static void WriteCommonMonsterMovePart(const MoveSpline& mov, WorldPacket& data); + public: + + static void WriteMonsterMove(const MoveSpline& mov, WorldPacket& data); + static void WriteCreate(const MoveSpline& mov, ByteBuffer& data); + }; +} +#endif // TRINITYSERVER_PACKET_BUILDER_H diff --git a/src/server/game/Movement/Spline/MovementTypedefs.h b/src/server/game/Movement/Spline/MovementTypedefs.h new file mode 100644 index 00000000000..01c8a5b7e7b --- /dev/null +++ b/src/server/game/Movement/Spline/MovementTypedefs.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef TRINITYSERVER_TYPEDEFS_H +#define TRINITYSERVER_TYPEDEFS_H + +#include "Common.h" + +namespace G3D +{ + class Vector2; + class Vector3; + class Vector4; +} + +namespace Movement +{ + using G3D::Vector2; + using G3D::Vector3; + using G3D::Vector4; + + inline uint32 SecToMS(float sec) + { + return static_cast(sec * 1000.f); + } + + inline float MSToSec(uint32 ms) + { + return ms / 1000.f; + } + +#ifndef static_assert + #define CONCAT(x, y) CONCAT1 (x, y) + #define CONCAT1(x, y) x##y + #define static_assert(expr, msg) typedef char CONCAT(static_assert_failed_at_line_, __LINE__) [(expr) ? 1 : -1] +#endif + + template + class counter + { + public: + counter() { init();} + + void Increase() + { + if (m_counter == limit) + init(); + else + ++m_counter; + } + + T NewId() { Increase(); return m_counter;} + T getCurrent() const { return m_counter;} + + private: + void init() { m_counter = 0; } + T m_counter; + }; + + typedef counter UInt32Counter; + + extern double gravity; + extern float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity); +} + +#endif // TRINITYSERVER_TYPEDEFS_H diff --git a/src/server/game/Movement/Spline/MovementUtil.cpp b/src/server/game/Movement/Spline/MovementUtil.cpp new file mode 100644 index 00000000000..f0ed01c4676 --- /dev/null +++ b/src/server/game/Movement/Spline/MovementUtil.cpp @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "MoveSplineFlag.h" +#include +#include + +namespace Movement +{ + double gravity = 19.29110527038574; + + /// Velocity bounds that makes fall speed limited + float terminalVelocity = 60.148003f; + float terminalSavefallVelocity = 7.f; + + const float terminal_length = float(terminalVelocity * terminalVelocity) / (2.f * gravity); + const float terminal_savefall_length = (terminalSavefallVelocity * terminalSavefallVelocity) / (2.f * gravity); + const float terminalFallTime = float(terminalVelocity/gravity); // the time that needed to reach terminalVelocity + + float computeFallTime(float path_length, bool isSafeFall) + { + if (path_length < 0.f) + return 0.f; + + float time; + if ( isSafeFall ) + { + if (path_length >= terminal_savefall_length) + time = (path_length - terminal_savefall_length)/terminalSavefallVelocity + terminalSavefallVelocity/gravity; + else + time = sqrtf(2.f * path_length/gravity); + } + else + { + if (path_length >= terminal_length) + time = (path_length - terminal_length)/terminalVelocity + terminalFallTime; + else + time = sqrtf(2.f * path_length/gravity); + } + + return time; + } + + float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity) + { + float termVel; + float result; + + if ( isSafeFall ) + termVel = terminalSavefallVelocity; + else + termVel = terminalVelocity; + + if ( start_velocity > termVel ) + start_velocity = termVel; + + float terminal_time = terminalFallTime - start_velocity / gravity; // the time that needed to reach terminalVelocity + + if ( t_passed > terminal_time ) + { + result = terminalVelocity*(t_passed - terminal_time) + + start_velocity*terminal_time + gravity*terminal_time*terminal_time*0.5f; + } + else + result = t_passed * (start_velocity + t_passed * gravity * 0.5f); + + return result; + } + + float computeFallElevation(float t_passed) + { + float result; + + if (t_passed > terminalFallTime) + { + //result = terminalVelocity * (t_passed - terminal_time) + gravity*terminal_time*terminal_time*0.5f; + // simplified view: + result = terminalVelocity * (t_passed - terminalFallTime) + terminal_length; + } + else + result = t_passed * t_passed * gravity * 0.5f; + + return result; + } + + #define STR(x) #x + + const char * g_MovementFlag_names[]= + { + STR(Forward ),// 0x00000001, + STR(Backward ),// 0x00000002, + STR(Strafe_Left ),// 0x00000004, + STR(Strafe_Right ),// 0x00000008, + STR(Turn_Left ),// 0x00000010, + STR(Turn_Right ),// 0x00000020, + STR(Pitch_Up ),// 0x00000040, + STR(Pitch_Down ),// 0x00000080, + + STR(Walk ),// 0x00000100, // Walking + STR(Ontransport ),// 0x00000200, + STR(Levitation ),// 0x00000400, + STR(Root ),// 0x00000800, + STR(Falling ),// 0x00001000, + STR(Fallingfar ),// 0x00002000, + STR(Pendingstop ),// 0x00004000, + STR(PendingSTRafestop ),// 0x00008000, + STR(Pendingforward ),// 0x00010000, + STR(Pendingbackward ),// 0x00020000, + STR(PendingSTRafeleft ),// 0x00040000, + STR(PendingSTRaferight ),// 0x00080000, + STR(Pendingroot ),// 0x00100000, + STR(Swimming ),// 0x00200000, // Appears With Fly Flag Also + STR(Ascending ),// 0x00400000, // Swim Up Also + STR(Descending ),// 0x00800000, // Swim Down Also + STR(Can_Fly ),// 0x01000000, // Can Fly In 3.3? + STR(Flying ),// 0x02000000, // Actual Flying Mode + STR(Spline_Elevation ),// 0x04000000, // Used For Flight Paths + STR(Spline_Enabled ),// 0x08000000, // Used For Flight Paths + STR(Waterwalking ),// 0x10000000, // Prevent Unit From Falling Through Water + STR(Safe_Fall ),// 0x20000000, // Active Rogue Safe Fall Spell (Passive) + STR(Hover ),// 0x40000000 + STR(Unknown13 ),// 0x80000000 + STR(Unk1 ), + STR(Unk2 ), + STR(Unk3 ), + STR(Fullspeedturning ), + STR(Fullspeedpitching ), + STR(Allow_Pitching ), + STR(Unk4 ), + STR(Unk5 ), + STR(Unk6 ), + STR(Unk7 ), + STR(Interp_Move ), + STR(Interp_Turning ), + STR(Interp_Pitching ), + STR(Unk8 ), + STR(Unk9 ), + STR(Unk10 ), + }; + + const char * g_SplineFlag_names[32]= + { + STR(AnimBit1 ),// 0x00000001, + STR(AnimBit2 ),// 0x00000002, + STR(AnimBit3 ),// 0x00000004, + STR(AnimBit4 ),// 0x00000008, + STR(AnimBit5 ),// 0x00000010, + STR(AnimBit6 ),// 0x00000020, + STR(AnimBit7 ),// 0x00000040, + STR(AnimBit8 ),// 0x00000080, + STR(Done ),// 0x00000100, + STR(Falling ),// 0x00000200, // Not Compartible With Trajectory Movement + STR(No_Spline ),// 0x00000400, + STR(Trajectory ),// 0x00000800, // Not Compartible With Fall Movement + STR(Walkmode ),// 0x00001000, + STR(Flying ),// 0x00002000, // Smooth Movement(Catmullrom Interpolation Mode), Flying Animation + STR(Knockback ),// 0x00004000, // Model Orientation Fixed + STR(Final_Point ),// 0x00008000, + STR(Final_Target ),// 0x00010000, + STR(Final_Angle ),// 0x00020000, + STR(Catmullrom ),// 0x00040000, // Used Catmullrom Interpolation Mode + STR(Cyclic ),// 0x00080000, // Movement By Cycled Spline + STR(Enter_Cycle ),// 0x00100000, // Everytime Appears With Cyclic Flag In Monster Move Packet + STR(Animation ),// 0x00200000, // Animationid (0...3), Uint32 Time, Not Compartible With Trajectory And Fall Movement + STR(Unknown4 ),// 0x00400000, // Disables Movement By Path + STR(Unknown5 ),// 0x00800000, + STR(Unknown6 ),// 0x01000000, + STR(Unknown7 ),// 0x02000000, + STR(Unknown8 ),// 0x04000000, + STR(OrientationInversed ),// 0x08000000, // Appears With Runmode Flag, Nodes ),// 1, Handles Orientation + STR(Unknown10 ),// 0x10000000, + STR(Unknown11 ),// 0x20000000, + STR(Unknown12 ),// 0x40000000, + STR(Unknown13 ),// 0x80000000, + }; + + template + void print_flags(Flags t, const char* (&names)[N], std::string& str) + { + for (int i = 0; i < N; ++i) + { + if ((t & (Flags)(1 << i)) && names[i] != NULL) + str.append(" ").append(names[i]); + } + } + + std::string MoveSplineFlag::ToString() const + { + std::string str; + print_flags(raw(),g_SplineFlag_names,str); + return str; + } +} diff --git a/src/server/game/Movement/Spline/Spline.cpp b/src/server/game/Movement/Spline/Spline.cpp new file mode 100644 index 00000000000..14c1bd0c117 --- /dev/null +++ b/src/server/game/Movement/Spline/Spline.cpp @@ -0,0 +1,307 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Spline.h" +#include +#include + +namespace Movement{ + +SplineBase::EvaluationMethtod SplineBase::evaluators[SplineBase::ModesEnd] = +{ + &SplineBase::EvaluateLinear, + &SplineBase::EvaluateCatmullRom, + &SplineBase::EvaluateBezier3, + (EvaluationMethtod)&SplineBase::UninitializedSpline, +}; + +SplineBase::EvaluationMethtod SplineBase::derivative_evaluators[SplineBase::ModesEnd] = +{ + &SplineBase::EvaluateDerivativeLinear, + &SplineBase::EvaluateDerivativeCatmullRom, + &SplineBase::EvaluateDerivativeBezier3, + (EvaluationMethtod)&SplineBase::UninitializedSpline, +}; + +SplineBase::SegLenghtMethtod SplineBase::seglengths[SplineBase::ModesEnd] = +{ + &SplineBase::SegLengthLinear, + &SplineBase::SegLengthCatmullRom, + &SplineBase::SegLengthBezier3, + (SegLenghtMethtod)&SplineBase::UninitializedSpline, +}; + +SplineBase::InitMethtod SplineBase::initializers[SplineBase::ModesEnd] = +{ + //&SplineBase::InitLinear, + &SplineBase::InitCatmullRom, // we should use catmullrom initializer even for linear mode! (client's internal structure limitation) + &SplineBase::InitCatmullRom, + &SplineBase::InitBezier3, + (InitMethtod)&SplineBase::UninitializedSpline, +}; + +/////////// +#pragma region evaluation methtods + +using G3D::Matrix4; +static const Matrix4 s_catmullRomCoeffs( + -0.5f, 1.5f,-1.5f, 0.5f, + 1.f, -2.5f, 2.f, -0.5f, + -0.5f, 0.f, 0.5f, 0.f, + 0.f, 1.f, 0.f, 0.f); + +static const Matrix4 s_Bezier3Coeffs( + -1.f, 3.f, -3.f, 1.f, + 3.f, -6.f, 3.f, 0.f, + -3.f, 3.f, 0.f, 0.f, + 1.f, 0.f, 0.f, 0.f); + +/* classic view: +inline void C_Evaluate(const Vector3 *vertice, float t, const float (&matrix)[4][4], Vector3 &position) +{ + Vector3 tvec(t*t*t, t*t, t); + int i = 0; + double c; + double x = 0, y = 0, z = 0; + while ( i < 4 ) + { + c = matrix[0][i]*tvec.x + matrix[1][i]*tvec.y + matrix[2][i]*tvec.z + matrix[3][i]; + + x += c * vertice->x; + y += c * vertice->y; + z += c * vertice->z; + + ++i; + ++vertice; + } + + position.x = x; + position.y = y; + position.z = z; +}*/ + +inline void C_Evaluate(const Vector3 *vertice, float t, const Matrix4& matr, Vector3 &result) +{ + Vector4 tvec(t*t*t, t*t, t, 1.f); + Vector4 weights(tvec * matr); + + result = vertice[0] * weights[0] + vertice[1] * weights[1] + + vertice[2] * weights[2] + vertice[3] * weights[3]; +} + +inline void C_Evaluate_Derivative(const Vector3 *vertice, float t, const Matrix4& matr, Vector3 &result) +{ + Vector4 tvec(3.f*t*t, 2.f*t, 1.f, 0.f); + Vector4 weights(tvec * matr); + + result = vertice[0] * weights[0] + vertice[1] * weights[1] + + vertice[2] * weights[2] + vertice[3] * weights[3]; +} + +void SplineBase::EvaluateLinear(index_type index, float u, Vector3& result) const +{ + ASSERT(index >= index_lo && index < index_hi); + result = points[index] + (points[index+1] - points[index]) * u; +} + +void SplineBase::EvaluateCatmullRom( index_type index, float t, Vector3& result) const +{ + ASSERT(index >= index_lo && index < index_hi); + C_Evaluate(&points[index - 1], t, s_catmullRomCoeffs, result); +} + +void SplineBase::EvaluateBezier3(index_type index, float t, Vector3& result) const +{ + index *= 3u; + ASSERT(index >= index_lo && index < index_hi); + C_Evaluate(&points[index], t, s_Bezier3Coeffs, result); +} + +void SplineBase::EvaluateDerivativeLinear(index_type index, float, Vector3& result) const +{ + ASSERT(index >= index_lo && index < index_hi); + result = points[index+1] - points[index]; +} + +void SplineBase::EvaluateDerivativeCatmullRom(index_type index, float t, Vector3& result) const +{ + ASSERT(index >= index_lo && index < index_hi); + C_Evaluate_Derivative(&points[index - 1], t, s_catmullRomCoeffs, result); +} + +void SplineBase::EvaluateDerivativeBezier3(index_type index, float t, Vector3& result) const +{ + index *= 3u; + ASSERT(index >= index_lo && index < index_hi); + C_Evaluate_Derivative(&points[index], t, s_Bezier3Coeffs, result); +} + +float SplineBase::SegLengthLinear(index_type index) const +{ + ASSERT(index >= index_lo && index < index_hi); + return (points[index] - points[index+1]).length(); +} + +float SplineBase::SegLengthCatmullRom( index_type index ) const +{ + ASSERT(index >= index_lo && index < index_hi); + + Vector3 curPos, nextPos; + const Vector3 * p = &points[index - 1]; + curPos = nextPos = p[1]; + + index_type i = 1; + double length = 0; + while (i <= STEPS_PER_SEGMENT) + { + C_Evaluate(p, float(i) / float(STEPS_PER_SEGMENT), s_catmullRomCoeffs, nextPos); + length += (nextPos - curPos).length(); + curPos = nextPos; + ++i; + } + return length; +} + +float SplineBase::SegLengthBezier3(index_type index) const +{ + index *= 3u; + ASSERT(index >= index_lo && index < index_hi); + + Vector3 curPos, nextPos; + const Vector3 * p = &points[index]; + + C_Evaluate(p, 0.f, s_Bezier3Coeffs, nextPos); + curPos = nextPos; + + index_type i = 1; + double length = 0; + while (i <= STEPS_PER_SEGMENT) + { + C_Evaluate(p, float(i) / float(STEPS_PER_SEGMENT), s_Bezier3Coeffs, nextPos); + length += (nextPos - curPos).length(); + curPos = nextPos; + ++i; + } + return length; +} +#pragma endregion + +void SplineBase::init_spline(const Vector3 * controls, index_type count, EvaluationMode m) +{ + m_mode = m; + cyclic = false; + + (this->*initializers[m_mode])(controls, count, cyclic, 0); +} + +void SplineBase::init_cyclic_spline(const Vector3 * controls, index_type count, EvaluationMode m, index_type cyclic_point) +{ + m_mode = m; + cyclic = true; + + (this->*initializers[m_mode])(controls, count, cyclic, cyclic_point); +} + +void SplineBase::InitLinear(const Vector3* controls, index_type count, bool cyclic, index_type cyclic_point) +{ + ASSERT(count >= 2); + const int real_size = count + 1; + + points.resize(real_size); + + memcpy(&points[0],controls, sizeof(Vector3) * count); + + // first and last two indexes are space for special 'virtual points' + // these points are required for proper C_Evaluate and C_Evaluate_Derivative methtod work + if (cyclic) + points[count] = controls[cyclic_point]; + else + points[count] = controls[count-1]; + + index_lo = 0; + index_hi = cyclic ? count : (count - 1); +} + +void SplineBase::InitCatmullRom(const Vector3* controls, index_type count, bool cyclic, index_type cyclic_point) +{ + const int real_size = count + (cyclic ? (1+2) : (1+1)); + + points.resize(real_size); + + int lo_index = 1; + int high_index = lo_index + count - 1; + + memcpy(&points[lo_index],controls, sizeof(Vector3) * count); + + // first and last two indexes are space for special 'virtual points' + // these points are required for proper C_Evaluate and C_Evaluate_Derivative methtod work + if (cyclic) + { + if (cyclic_point == 0) + points[0] = controls[count-1]; + else + points[0] = controls[0].lerp(controls[1], -1); + + points[high_index+1] = controls[cyclic_point]; + points[high_index+2] = controls[cyclic_point+1]; + } + else + { + points[0] = controls[0].lerp(controls[1], -1); + points[high_index+1] = controls[count-1]; + } + + index_lo = lo_index; + index_hi = high_index + (cyclic ? 1 : 0); +} + +void SplineBase::InitBezier3(const Vector3* controls, index_type count, bool /*cyclic*/, index_type /*cyclic_point*/) +{ + index_type c = count / 3u * 3u; + index_type t = c / 3u; + + points.resize(c); + memcpy(&points[0],controls, sizeof(Vector3) * c); + + index_lo = 0; + index_hi = t-1; + //mov_assert(points.size() % 3 == 0); +} + +void SplineBase::clear() +{ + index_lo = 0; + index_hi = 0; + points.clear(); +} + +std::string SplineBase::ToString() const +{ + std::stringstream str; + const char * mode_str[ModesEnd] = {"Linear", "CatmullRom", "Bezier3", "Uninitialized"}; + + index_type count = this->points.size(); + str << "mode: " << mode_str[mode()] << std::endl; + str << "points count: " << count << std::endl; + for (index_type i = 0; i < count; ++i) + str << "point " << i << " : " << points[i].toString() << std::endl; + + return str.str(); +} + +} diff --git a/src/server/game/Movement/Spline/Spline.h b/src/server/game/Movement/Spline/Spline.h new file mode 100644 index 00000000000..28876b220d4 --- /dev/null +++ b/src/server/game/Movement/Spline/Spline.h @@ -0,0 +1,212 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef TRINITYSERVER_SPLINE_H +#define TRINITYSERVER_SPLINE_H + +#include "MovementTypedefs.h" +#include + +namespace Movement { + +class SplineBase +{ +public: + typedef int index_type; + typedef std::vector ControlArray; + + enum EvaluationMode + { + ModeLinear, + ModeCatmullrom, + ModeBezier3_Unused, + UninitializedMode, + ModesEnd + }; + + #pragma region fields +protected: + ControlArray points; + + index_type index_lo; + index_type index_hi; + + uint8 m_mode; + bool cyclic; + + enum{ + // could be modified, affects segment length evaluation precision + // lesser value saves more performance in cost of lover precision + // minimal value is 1 + // client's value is 20, blizzs use 2-3 steps to compute length + STEPS_PER_SEGMENT = 3, + }; + static_assert(STEPS_PER_SEGMENT > 0, "shouldn't be lesser than 1"); + +protected: + void EvaluateLinear(index_type, float, Vector3&) const; + void EvaluateCatmullRom(index_type, float, Vector3&) const; + void EvaluateBezier3(index_type, float, Vector3&) const; + typedef void (SplineBase::*EvaluationMethtod)(index_type,float,Vector3&) const; + static EvaluationMethtod evaluators[ModesEnd]; + + void EvaluateDerivativeLinear(index_type, float, Vector3&) const; + void EvaluateDerivativeCatmullRom(index_type, float, Vector3&) const; + void EvaluateDerivativeBezier3(index_type, float, Vector3&) const; + static EvaluationMethtod derivative_evaluators[ModesEnd]; + + float SegLengthLinear(index_type) const; + float SegLengthCatmullRom(index_type) const; + float SegLengthBezier3(index_type) const; + typedef float (SplineBase::*SegLenghtMethtod)(index_type) const; + static SegLenghtMethtod seglengths[ModesEnd]; + + void InitLinear(const Vector3*, index_type, bool, index_type); + void InitCatmullRom(const Vector3*, index_type, bool, index_type); + void InitBezier3(const Vector3*, index_type, bool, index_type); + typedef void (SplineBase::*InitMethtod)(const Vector3*, index_type, bool, index_type); + static InitMethtod initializers[ModesEnd]; + + void UninitializedSpline() const { ASSERT(false);} + + #pragma endregion +public: + + explicit SplineBase() : m_mode(UninitializedMode), index_lo(0), index_hi(0), cyclic(false) {} + + /** Caclulates the position for given segment Idx, and percent of segment length t + @param t - percent of segment length, assumes that t in range [0, 1] + @param Idx - spline segment index, should be in range [first, last) + */ + void evaluate_percent(index_type Idx, float u, Vector3& c) const {(this->*evaluators[m_mode])(Idx,u,c);} + + /** Caclulates derivation in index Idx, and percent of segment length t + @param Idx - spline segment index, should be in range [first, last) + @param t - percent of spline segment length, assumes that t in range [0, 1] + */ + void evaluate_derivative(index_type Idx, float u, Vector3& hermite) const {(this->*derivative_evaluators[m_mode])(Idx,u,hermite);} + + /** Bounds for spline indexes. All indexes should be in range [first, last). */ + index_type first() const { return index_lo;} + index_type last() const { return index_hi;} + + bool empty() const { return index_lo == index_hi;} + EvaluationMode mode() const { return (EvaluationMode)m_mode;} + bool isCyclic() const { return cyclic;} + + const ControlArray& getPoints() const { return points;} + index_type getPointCount() const { return points.size();} + const Vector3& getPoint(index_type i) const { return points[i];} + + /** Initializes spline. Don't call other methods while spline not initialized. */ + void init_spline(const Vector3 * controls, index_type count, EvaluationMode m); + void init_cyclic_spline(const Vector3 * controls, index_type count, EvaluationMode m, index_type cyclic_point); + + /** As i can see there are a lot of ways how spline can be initialized + would be no harm to have some custom initializers. */ + template inline void init_spline(Init& initializer) + { + initializer(m_mode,cyclic,points,index_lo,index_hi); + } + + void clear(); + + /** Calculates distance between [i; i+1] points, assumes that index i is in bounds. */ + float SegLength(index_type i) const { return (this->*seglengths[m_mode])(i);} + + std::string ToString() const; +}; + +template +class Spline : public SplineBase +{ +public: + typedef length_type LengthType; + typedef std::vector LengthArray; + #pragma region fields +protected: + + LengthArray lengths; + + index_type computeIndexInBounds(length_type length) const; + #pragma endregion +public: + + explicit Spline(){} + + /** Calculates the position for given t + @param t - percent of spline's length, assumes that t in range [0, 1]. */ + void evaluate_percent(float t, Vector3 & c) const; + + /** Calculates derivation for given t + @param t - percent of spline's length, assumes that t in range [0, 1]. */ + void evaluate_derivative(float t, Vector3& hermite) const; + + /** Calculates the position for given segment Idx, and percent of segment length t + @param t = partial_segment_length / whole_segment_length + @param Idx - spline segment index, should be in range [first, last). */ + void evaluate_percent(index_type Idx, float u, Vector3& c) const { SplineBase::evaluate_percent(Idx,u,c);} + + /** Caclulates derivation for index Idx, and percent of segment length t + @param Idx - spline segment index, should be in range [first, last) + @param t - percent of spline segment length, assumes that t in range [0, 1]. */ + void evaluate_derivative(index_type Idx, float u, Vector3& c) const { SplineBase::evaluate_derivative(Idx,u,c);} + + // Assumes that t in range [0, 1] + index_type computeIndexInBounds(float t) const; + void computeIndex(float t, index_type& out_idx, float& out_u) const; + + /** Initializes spline. Don't call other methods while spline not initialized. */ + void init_spline(const Vector3 * controls, index_type count, EvaluationMode m) { SplineBase::init_spline(controls,count,m);} + void init_cyclic_spline(const Vector3 * controls, index_type count, EvaluationMode m, index_type cyclic_point) { SplineBase::init_cyclic_spline(controls,count,m,cyclic_point);} + + /** Initializes lengths with SplineBase::SegLength method. */ + void initLengths(); + + /** Initializes lengths in some custom way + Note that value returned by cacher must be greater or equal to previous value. */ + template inline void initLengths(T& cacher) + { + index_type i = index_lo; + lengths.resize(index_hi+1); + length_type prev_length = 0, new_length = 0; + while(i < index_hi) + { + new_length = cacher(*this, i); + lengths[++i] = new_length; + + ASSERT(prev_length <= new_length); + prev_length = new_length; + } + } + + /** Returns length of the whole spline. */ + length_type length() const { return lengths[index_hi];} + /** Returns length between given nodes. */ + length_type length(index_type first, index_type last) const { return lengths[last]-lengths[first];} + length_type length(index_type Idx) const { return lengths[Idx];} + + void set_length(index_type i, length_type length) { lengths[i] = length;} + void clear(); +}; + +} + +#include "SplineImpl.h" + +#endif // TRINITYSERVER_SPLINE_H diff --git a/src/server/game/Movement/Spline/SplineImpl.h b/src/server/game/Movement/Spline/SplineImpl.h new file mode 100644 index 00000000000..eded2d8c903 --- /dev/null +++ b/src/server/game/Movement/Spline/SplineImpl.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +namespace Movement +{ +template void Spline::evaluate_percent( float t, Vector3 & c ) const +{ + index_type Index; + float u; + computeIndex(t, Index, u); + evaluate_percent(Index, u, c); +} + +template void Spline::evaluate_derivative(float t, Vector3& hermite) const +{ + index_type Index; + float u; + computeIndex(t, Index, u); + evaluate_derivative(Index, u, hermite); +} + +template SplineBase::index_type Spline::computeIndexInBounds(length_type length_) const +{ +// Temporary disabled: causes infinite loop with t = 1.f +/* + index_type hi = index_hi; + index_type lo = index_lo; + + index_type i = lo + (float)(hi - lo) * t; + + while ((lengths[i] > length) || (lengths[i + 1] <= length)) + { + if (lengths[i] > length) + hi = i - 1; // too big + else if (lengths[i + 1] <= length) + lo = i + 1; // too small + + i = (hi + lo) / 2; + }*/ + + index_type i = index_lo; + index_type N = index_hi; + while (i+1 < N && lengths[i+1] < length_) + ++i; + + return i; +} + +template void Spline::computeIndex(float t, index_type& index, float& u) const +{ + ASSERT(t >= 0.f && t <= 1.f); + length_type length_ = t * length(); + index = computeIndexInBounds(length_); + ASSERT(index < index_hi); + u = (length_ - length(index)) / (float)length(index, index+1); +} + +template SplineBase::index_type Spline::computeIndexInBounds( float t ) const +{ + ASSERT(t >= 0.f && t <= 1.f); + return computeIndexInBounds(t * length()); +} + +template void Spline::initLengths() +{ + index_type i = index_lo; + length_type length = 0; + lengths.resize(index_hi+1); + while(i < index_hi ) + { + length += SegLength(i); + lengths[++i] = length; + } +} + +template void Spline::clear() +{ + SplineBase::clear(); + lengths.clear(); +} + +} diff --git a/src/server/game/Movement/Traveller.h b/src/server/game/Movement/Traveller.h deleted file mode 100755 index 641278ee37a..00000000000 --- a/src/server/game/Movement/Traveller.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2008-2012 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef TRINITY_TRAVELLER_H -#define TRINITY_TRAVELLER_H - -#include "Creature.h" -#include "Player.h" -#include - -/** Traveller is a wrapper for units (creatures or players) that - * travel from point A to point B using the destination holder. - */ -#define PLAYER_FLIGHT_SPEED 32.0f - -template -struct Traveller -{ - T &i_traveller; - Traveller(T &t) : i_traveller(t) {} - Traveller(const Traveller &obj) : i_traveller(obj) {} - Traveller& operator=(const Traveller &obj) - { - this.i_traveller = obj.i_traveller; - return *this; - } - - operator T&(void) { return i_traveller; } - operator const T&(void) { return i_traveller; } - float GetPositionX() const { return i_traveller.GetPositionX(); } - float GetPositionY() const { return i_traveller.GetPositionY(); } - float GetPositionZ() const { return i_traveller.GetPositionZ(); } - T& GetTraveller(void) { return i_traveller; } - - float Speed(void) { ASSERT(false); return 0.0f; } - float GetMoveDestinationTo(float x, float y, float z); - uint32 GetTotalTrevelTimeTo(float x, float y, float z); - - void Relocation(float x, float y, float z, float orientation) {} - void Relocation(float x, float y, float z) { Relocation(x, y, z, i_traveller.GetOrientation()); } - void MoveTo(float x, float y, float z, uint32 t) {} -}; - -template -inline uint32 Traveller::GetTotalTrevelTimeTo(float x, float y, float z) -{ - float dist = GetMoveDestinationTo(x, y, z); - float speed = Speed(); - if (speed < 0.0f) - return 0xfffffffe; // almost infinity-unit should stop - else - speed *= 0.001f; // speed is in seconds so convert from second to millisecond - return static_cast(dist/speed); -} - -// specialization for creatures -template<> -inline float Traveller::Speed() -{ - if (i_traveller.HasUnitState(UNIT_STAT_CHARGING)) - return i_traveller.m_TempSpeed; - else if (i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_WALKING)) - return i_traveller.GetSpeed(MOVE_WALK); - else if (i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING)) - return i_traveller.GetSpeed(MOVE_FLIGHT); - else - return i_traveller.GetSpeed(MOVE_RUN); -} - -template<> -inline void Traveller::Relocation(float x, float y, float z, float orientation) -{ - i_traveller.UpdatePosition(x, y, z, orientation); -} - -template<> -inline float Traveller::GetMoveDestinationTo(float x, float y, float z) -{ - float dx = x - GetPositionX(); - float dy = y - GetPositionY(); - float dz = z - GetPositionZ(); - - //if (i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING)) - return sqrt((dx*dx) + (dy*dy) + (dz*dz)); - //else //Walking on the ground - // return sqrt((dx*dx) + (dy*dy)); -} - -template<> -inline void Traveller::MoveTo(float x, float y, float z, uint32 t) -{ - //i_traveller.AI_SendMoveToPacket(x, y, z, t, i_traveller.GetUnitMovementFlags(), 0); - i_traveller.SendMonsterMove(x, y, z, t); -} - -// specialization for players -template<> -inline float Traveller::Speed() -{ - if (i_traveller.HasUnitState(UNIT_STAT_CHARGING)) - return i_traveller.m_TempSpeed; - else if (i_traveller.isInFlight()) - return PLAYER_FLIGHT_SPEED; - else - return i_traveller.GetSpeed(i_traveller.m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING) ? MOVE_WALK : MOVE_RUN); -} - -template<> -inline float Traveller::GetMoveDestinationTo(float x, float y, float z) -{ - float dx = x - GetPositionX(); - float dy = y - GetPositionY(); - float dz = z - GetPositionZ(); - - //if (i_traveller.isInFlight()) - return sqrt((dx*dx) + (dy*dy) + (dz*dz)); - //else //Walking on the ground - // return sqrt((dx*dx) + (dy*dy)); -} - -template<> -inline void Traveller::Relocation(float x, float y, float z, float orientation) -{ - i_traveller.UpdatePosition(x, y, z, orientation); -} - -template<> -inline void Traveller::MoveTo(float x, float y, float z, uint32 t) -{ - //Only send MOVEMENTFLAG_WALKING, client has strange issues with other move flags - i_traveller.SendMonsterMove(x, y, z, t); -} - -typedef Traveller CreatureTraveller; -typedef Traveller PlayerTraveller; -#endif - diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index 71195538256..7757e1a1a35 100755 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -475,8 +475,14 @@ void Map::ScriptsProcess() // Source or target must be Creature. if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script)) { - cSource->SendMonsterMoveWithSpeed(step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ, step.script->MoveTo.TravelTime); - cSource->GetMap()->CreatureRelocation(cSource, step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ, 0); + Unit * unit = (Unit*)cSource; + if (step.script->MoveTo.TravelTime != 0) + { + float speed = unit->GetDistance(step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ) / ((float)step.script->MoveTo.TravelTime * 0.001f); + unit->MonsterMoveWithSpeed(step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ, speed); + } + else + unit->NearTeleportTo(step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ, unit->GetOrientation()); } break; diff --git a/src/server/game/Server/Protocol/Handlers/TaxiHandler.cpp b/src/server/game/Server/Protocol/Handlers/TaxiHandler.cpp index 81481bdef31..3533b153bd8 100755 --- a/src/server/game/Server/Protocol/Handlers/TaxiHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/TaxiHandler.cpp @@ -27,7 +27,6 @@ #include "UpdateMask.h" #include "Path.h" #include "WaypointMovementGenerator.h" -#include "DestinationHolderImp.h" void WorldSession::HandleTaxiNodeStatusQueryOpcode(WorldPacket & recv_data) { diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 1d3c657f50a..535253f4e13 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -4761,11 +4761,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool break; case 46361: // Reinforced Net if (caster) - { - float currentGroundLevel = target->GetBaseMap()->GetHeight(target->GetPositionX(), target->GetPositionY(), MAX_HEIGHT); - if (target->GetPositionZ() > currentGroundLevel) - target->GetMotionMaster()->MoveFall(currentGroundLevel); - } + target->GetMotionMaster()->MoveFall(); break; case 46699: // Requires No Ammo if (target->GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 2c33488f76c..eaf5f4e1d31 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -3363,22 +3363,11 @@ void Spell::EffectDistract(SpellEffIndex /*effIndex*/) if (unitTarget->HasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING)) return; - float angle = unitTarget->GetAngle(m_targets.GetDst()); + unitTarget->SetFacingTo(unitTarget->GetAngle(m_targets.GetDst())); + unitTarget->ClearUnitState(UNIT_STAT_MOVING); - if (unitTarget->GetTypeId() == TYPEID_PLAYER) - { - // For players just turn them - unitTarget->ToPlayer()->UpdatePosition(unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), angle, false); - unitTarget->ToPlayer()->SendTeleportAckPacket(); - } - else - { - // Set creature Distracted, Stop it, And turn it - unitTarget->SetOrientation(angle); - unitTarget->StopMoving(); + if (unitTarget->GetTypeId() == TYPEID_UNIT) unitTarget->GetMotionMaster()->MoveDistract(damage * IN_MILLISECONDS); - unitTarget->SendMovementFlagUpdate(); - } } void Spell::EffectPickPocket(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 54dac404f03..1b6a6c6fdcf 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -1036,15 +1036,14 @@ public: } if (/*creature->GetMotionMaster()->empty() ||*/ - creature->GetMotionMaster()->GetCurrentMovementGeneratorType () != TARGETED_MOTION_TYPE) + creature->GetMotionMaster()->GetCurrentMovementGeneratorType () != FOLLOW_MOTION_TYPE) { handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); handler->SetSentErrorMessage(true); return false; } - TargetedMovementGenerator const* mgen - = static_cast const*>((creature->GetMotionMaster()->top())); + FollowMovementGenerator const* mgen = static_cast const*>((creature->GetMotionMaster()->top())); if (mgen->GetTarget() != player) { diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index 999f3fda2e4..a7d1c3ad8ba 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -1009,7 +1009,7 @@ public: me->SetInFront(car); me->SendMovementFlagUpdate(); car->Relocate(car->GetPositionX(), car->GetPositionY(), me->GetPositionZ() + 1); - car->SendMonsterStop(); + car->StopMoving(); car->RemoveAura(SPELL_CART_DRAG); } me->MonsterSay(SAY_SCARLET_MINER2, LANG_UNIVERSAL, 0); diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp index d04d7af5c80..eee6b08d834 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp @@ -325,7 +325,7 @@ class boss_akilzon : public CreatureScript if (target) { target->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING); - target->SendMonsterMove(x, y, me->GetPositionZ()+15, 0); + target->MonsterMoveWithSpeed(x, y, me->GetPositionZ()+15, 0); } Unit* Cloud = me->SummonTrigger(x, y, me->GetPositionZ()+16, 0, 15000); if (Cloud) diff --git a/src/server/scripts/EasternKingdoms/undercity.cpp b/src/server/scripts/EasternKingdoms/undercity.cpp index f1c0fba2e29..fe9c40e6dbd 100644 --- a/src/server/scripts/EasternKingdoms/undercity.cpp +++ b/src/server/scripts/EasternKingdoms/undercity.cpp @@ -109,7 +109,7 @@ public: { if (Creature* target = Unit::GetCreature(*summoned, targetGUID)) { - target->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), me->GetPositionZ()+15.0f, 0); + target->MonsterMoveWithSpeed(target->GetPositionX(), target->GetPositionY(), me->GetPositionZ()+15.0f, 0); target->SetPosition(target->GetPositionX(), target->GetPositionY(), me->GetPositionZ()+15.0f, 0.0f); summoned->CastSpell(target, SPELL_RIBBON_OF_SOULS, false); } @@ -186,7 +186,7 @@ public: if (EventMove_Timer <= diff) { me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); - me->SendMonsterMoveWithSpeed(me->GetPositionX(), me->GetPositionY(), HIGHBORNE_LOC_Y_NEW, 5000); + me->MonsterMoveWithSpeed(me->GetPositionX(), me->GetPositionY(), HIGHBORNE_LOC_Y_NEW, me->GetDistance(me->GetPositionX(), me->GetPositionY(), HIGHBORNE_LOC_Y_NEW) / (5000 * 0.001f)); me->SetPosition(me->GetPositionX(), me->GetPositionY(), HIGHBORNE_LOC_Y_NEW, me->GetOrientation()); EventMove = false; } else EventMove_Timer -= diff; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index bc6145252d2..8e34a318d6c 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -592,11 +592,8 @@ public: me->GetMotionMaster()->MoveIdle(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); //At hit the ground - me->GetPosition(x, y, z); - z = me->GetMap()->GetHeight(x, y, z, true, 50); me->HandleEmoteCommand(EMOTE_ONESHOT_FLYDEATH); - me->GetMotionMaster()->MoveFall(z, 0); - //me->FallGround(); //need correct vmap use (i believe it isn't working properly right now) + me->GetMotionMaster()->MoveFall(); } } } @@ -610,7 +607,6 @@ public: case 0: me->RemoveAurasDueToSpell(SPELL_FROST_SPHERE); me->SetDisplayId(11686); - me->Relocate(x, y, z, me->GetOrientation()); DoCast(SPELL_PERMAFROST_VISUAL); DoCast(SPELL_PERMAFROST); me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.0f); diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp index bc06a92ef07..d444160b8f2 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp @@ -201,7 +201,7 @@ class mob_corrupted_soul_fragment : public CreatureScript void MovementInform(uint32 type, uint32 id) { - if (type != TARGETED_MOTION_TYPE) + if (type != CHASE_MOTION_TYPE) return; if (instance) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index 3b15bba5c5d..94a3da2672b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -1159,7 +1159,7 @@ class npc_ball_of_flame : public CreatureScript void MovementInform(uint32 type, uint32 id) { - if (type == TARGETED_MOTION_TYPE && id == GUID_LOPART(_chaseGUID) && _chaseGUID) + if (type == CHASE_MOTION_TYPE && id == GUID_LOPART(_chaseGUID) && _chaseGUID) { me->RemoveAurasDueToSpell(SPELL_BALL_OF_FLAMES_PERIODIC); DoCast(me, SPELL_FLAMES); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp index 8396b6e6c85..31b3786a360 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp @@ -608,7 +608,7 @@ class npc_high_overlord_saurfang_icc : public CreatureScript me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->SendMovementFlagUpdate(); me->Relocate(me->GetPositionX(), me->GetPositionY(), 539.2917f); - me->SendMonsterMove(me->GetPositionX(), me->GetPositionY(), 539.2917f, SPLINEFLAG_FALLING, 0, 0.0f); + me->MonsterMoveWithSpeed(me->GetPositionX(), me->GetPositionY(), 539.2917f, 0.0f); for (std::list::iterator itr = _guardList.begin(); itr != _guardList.end(); ++itr) (*itr)->AI()->DoAction(ACTION_DESPAWN); break; @@ -815,7 +815,7 @@ class npc_muradin_bronzebeard_icc : public CreatureScript me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->SendMovementFlagUpdate(); me->Relocate(me->GetPositionX(), me->GetPositionY(), 539.2917f); - me->SendMonsterMove(me->GetPositionX(), me->GetPositionY(), 539.2917f, SPLINEFLAG_FALLING, 0, 0.0f); + me->MonsterMoveWithSpeed(me->GetPositionX(), me->GetPositionY(), 539.2917f, 0.0f); for (std::list::iterator itr = _guardList.begin(); itr != _guardList.end(); ++itr) (*itr)->AI()->DoAction(ACTION_DESPAWN); break; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index f2657e5b2ef..5029dbcceee 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -508,7 +508,7 @@ class boss_the_lich_king : public CreatureScript if (fabs(ground_Z - z) < 0.1f) return; - me->GetMotionMaster()->MoveFall(ground_Z); + me->GetMotionMaster()->MoveFall(); } void EnterCombat(Unit* target) @@ -801,7 +801,7 @@ class boss_the_lich_king : public CreatureScript events.ScheduleEvent(EVENT_INTRO_TALK_1, 9000, 0, PHASE_INTRO); break; case POINT_CENTER_1: - me->SetFacing(0.0f); + me->SetFacingTo(0.0f); Talk(SAY_LK_REMORSELESS_WINTER); SendMusicToPlayers(MUSIC_SPECIAL); me->SetReactState(REACT_PASSIVE); @@ -818,7 +818,7 @@ class boss_the_lich_king : public CreatureScript events.ScheduleEvent(EVENT_SOUL_REAPER, 94000, 0, PHASE_TWO); break; case POINT_CENTER_2: - me->SetFacing(0.0f); + me->SetFacingTo(0.0f); Talk(SAY_LK_REMORSELESS_WINTER); SendMusicToPlayers(MUSIC_SPECIAL); me->SetReactState(REACT_PASSIVE); @@ -1047,14 +1047,14 @@ class boss_the_lich_king : public CreatureScript break; case EVENT_OUTRO_TALK_3: if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HIGHLORD_TIRION_FORDRING))) - me->SetFacing(0.0f, tirion); + me->SetFacingToObject(tirion); Talk(SAY_LK_OUTRO_3); break; case EVENT_OUTRO_MOVE_CENTER: me->GetMotionMaster()->MovePoint(POINT_LK_OUTRO_1, CenterPosition); break; case EVENT_OUTRO_TALK_4: - me->SetFacing(0.01745329f); + me->SetFacingTo(0.01745329f); Talk(SAY_LK_OUTRO_4); break; case EVENT_OUTRO_RAISE_DEAD: @@ -1070,7 +1070,7 @@ class boss_the_lich_king : public CreatureScript case EVENT_OUTRO_TALK_6: Talk(SAY_LK_OUTRO_6); if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HIGHLORD_TIRION_FORDRING))) - tirion->SetFacing(0.0f, me); + tirion->SetFacingToObject(me); me->ClearUnitState(UNIT_STAT_CASTING); DoCastAOE(SPELL_SUMMON_BROKEN_FROSTMOURNE_3); SetEquipmentSlots(false, EQUIP_UNEQUIP); @@ -1222,7 +1222,7 @@ class npc_tirion_fordring_tft : public CreatureScript void SpellHit(Unit* /*caster*/, SpellInfo const* spell) { if (spell->Id == SPELL_ICE_LOCK) - me->SetFacing(3.085098f); + me->SetFacingTo(3.085098f); else if (spell->Id == SPELL_BROKEN_FROSTMOURNE_KNOCK) SetEquipmentSlots(true); // remove glow on ashbringer } @@ -1285,7 +1285,7 @@ class npc_tirion_fordring_tft : public CreatureScript SetEquipmentSlots(false, EQUIP_ASHBRINGER_GLOWING); if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) { - me->SetFacing(0.0f, lichKing); + me->SetFacingToObject(lichKing); lichKing->AI()->DoAction(ACTION_PLAY_MUSIC); } break; @@ -1621,7 +1621,7 @@ class npc_strangulate_vehicle : public CreatureScript void IsSummonedBy(Unit* summoner) { - me->SetFacing(0.0f, summoner); + me->SetFacingToObject(summoner); DoCast(summoner, SPELL_HARVEST_SOUL_VEHICLE); _events.Reset(); _events.ScheduleEvent(EVENT_MOVE_TO_LICH_KING, 2000); @@ -1789,7 +1789,7 @@ class npc_terenas_menethil : public CreatureScript _events.Reset(); _events.SetPhase(PHASE_OUTRO); if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) - me->SetFacing(0.0f, lichKing); + me->SetFacingToObject(lichKing); _events.ScheduleEvent(EVENT_OUTRO_TERENAS_TALK_1, 2000, 0, PHASE_OUTRO); _events.ScheduleEvent(EVENT_OUTRO_TERENAS_TALK_2, 14000, 0, PHASE_OUTRO); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index ab3046806db..6bd8f3cba7d 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -1264,7 +1264,7 @@ struct npc_argent_captainAI : public ScriptedAI void EnterEvadeMode() { // not yet following - if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_IDLE) != TARGETED_MOTION_TYPE || IsUndead) + if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_IDLE) != CHASE_MOTION_TYPE || IsUndead) { ScriptedAI::EnterEvadeMode(); return; diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 8e995a9b260..052fa3ba4a5 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -838,7 +838,7 @@ public: return; } - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) me->GetMotionMaster()->MoveFollow(malygos, 0.0f, 0.0f); } } diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp index 194c2a36862..1fc724c8b6c 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp @@ -243,7 +243,7 @@ public: { if (m_uiPause_Timer <= uiDiff) { - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) if (me->getVictim()) me->GetMotionMaster()->MoveChase(me->getVictim()); @@ -421,7 +421,7 @@ public: // me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); //Set in DB if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(false); - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) me->GetMotionMaster()->MovementExpired(); m_bIsFrozen = true; } diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp index 4ee71367b55..d1aba800094 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp @@ -174,7 +174,7 @@ public: bIsSlam = false; //and correct movement, if not already - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) { if (me->getVictim()) me->GetMotionMaster()->MoveChase(me->getVictim()); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp index 68435fffb1b..2c7532fcf70 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp @@ -634,7 +634,7 @@ class boss_stormcaller_brundir : public CreatureScript // Prevent to have Brundir somewhere in the air when he die in Air phase if (me->GetPositionZ() > FLOOR_Z) - me->GetMotionMaster()->MoveFall(FLOOR_Z); + me->GetMotionMaster()->MoveFall(); } void KilledUnit(Unit* /*who*/) diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp index 1bedd7e19e9..d5cd79b25f1 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp @@ -288,7 +288,7 @@ public: me->Dismount(); if (Creature* pGrauf = me->SummonCreature(CREATURE_GRAUF, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3*IN_MILLISECONDS)) { - pGrauf->GetMotionMaster()->MoveFall(0); + pGrauf->GetMotionMaster()->MoveFall(); pGrauf->HandleEmoteCommand(EMOTE_ONESHOT_FLYDEATH); } me->GetMotionMaster()->MoveJump(Location[4].GetPositionX(), Location[4].GetPositionY(), Location[4].GetPositionZ(), 5.0f, 10.0f); diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp index 9cab1de197c..436336ec5b8 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp @@ -249,22 +249,16 @@ public: if (Phase == SACRIFICING) SetEquipmentSlots(false, EQUIP_UNEQUIP, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); - me->GetPosition(x, y, z); - z = me->GetMap()->GetHeight(x, y, z, true, 50); + damage = 0; + Phase = SVALADEAD; + me->InterruptNonMeleeSpells(true); + me->RemoveAllAuras(); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetHealth(1); - if (me->GetPositionZ() > z) - { - damage = 0; - Phase = SVALADEAD; - me->InterruptNonMeleeSpells(true); - me->RemoveAllAuras(); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->SetHealth(1); - - SetCombatMovement(false); - me->HandleEmoteCommand(EMOTE_ONESHOT_FLYDEATH); - me->GetMotionMaster()->MoveFall(z, 1); - } + SetCombatMovement(false); + me->HandleEmoteCommand(EMOTE_ONESHOT_FLYDEATH); + me->GetMotionMaster()->MoveFall(); } } @@ -274,10 +268,7 @@ public: return; if (pointId == 1) - { - me->Relocate(x, y, z, me->GetOrientation()); me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } } void JustDied(Unit* killer) diff --git a/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_nexusprince_shaffar.cpp b/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_nexusprince_shaffar.cpp index 81211b6e3d9..aa63f1adf18 100644 --- a/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_nexusprince_shaffar.cpp +++ b/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_nexusprince_shaffar.cpp @@ -187,7 +187,7 @@ public: //expire movement, will prevent from running right back to victim after cast //(but should MoveChase be used again at a certain time or should he not move?) - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) me->GetMotionMaster()->MovementExpired(); DoCast(me, SPELL_BLINK); diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index b23b7bcd1ac..c17b6d5baf3 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -1982,7 +1982,7 @@ void boss_illidan_stormrage::boss_illidan_stormrageAI::HandleTalkSequence() Akama->GetMotionMaster()->Clear(false); // Akama->GetMotionMaster()->MoveIdle(); Akama->SetPosition(x, y, z, 0.0f); - Akama->SendMonsterMove(x, y, z, 0, MOVEMENTFLAG_NONE, 0); // Illidan must not die until Akama arrives. + Akama->MonsterMoveWithSpeed(x, y, z, 0); // Illidan must not die until Akama arrives. Akama->GetMotionMaster()->MoveChase(me); } diff --git a/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp b/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp index 33196b1213a..b7604c41794 100644 --- a/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp +++ b/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp @@ -151,7 +151,7 @@ public: m_bPerformingGroundSlam = false; //and correct movement, if not already - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) { if (me->getVictim()) me->GetMotionMaster()->MoveChase(me->getVictim()); diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 974d81ef914..a45576f8884 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -820,7 +820,7 @@ class boss_kaelthas : public CreatureScript me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); me->SetPosition(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); - me->SendMonsterMove(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0, 0, 0); + me->MonsterMoveWithSpeed(afGravityPos[0], afGravityPos[1], afGravityPos[2], 1); me->InterruptNonMeleeSpells(false); DoCast(me, SPELL_FULLPOWER); @@ -887,7 +887,7 @@ class boss_kaelthas : public CreatureScript me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); me->SetPosition(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); - me->SendMonsterMove(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0, MOVEMENTFLAG_NONE, 0); + me->MonsterMoveWithSpeed(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); // 1) Kael'thas will portal the whole raid right into his body for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) diff --git a/src/server/scripts/World/guards.cpp b/src/server/scripts/World/guards.cpp index d562542a7d7..9bc511931b9 100644 --- a/src/server/scripts/World/guards.cpp +++ b/src/server/scripts/World/guards.cpp @@ -179,7 +179,7 @@ public: globalCooldown = GENERIC_CREATURE_COOLDOWN; } //If no spells available and we arn't moving run to target - else if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE) + else if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) { //Cancel our current spell and then mutate new movement generator me->InterruptNonMeleeSpells(false); diff --git a/src/server/shared/Utilities/Timer.h b/src/server/shared/Utilities/Timer.h index 4dae8ac30d2..4d3f02f6688 100755 --- a/src/server/shared/Utilities/Timer.h +++ b/src/server/shared/Utilities/Timer.h @@ -133,7 +133,7 @@ struct TimeTrackerSmall { public: - TimeTrackerSmall(uint32 expiry) + TimeTrackerSmall(uint32 expiry = 0) : i_expiryTime(expiry) { } -- cgit v1.2.3 From b02666213c4c69bb0ea1a237e746f994284184ec Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Sun, 15 Jan 2012 15:26:00 +0100 Subject: Scripts/Misc: Fix some MovementInform handler filters after recent motionmaster changes Also correct year of SQL in dbbac0bdaae --- .../world/2011_01_14_03_world_trinity_string.sql | 6 ------ .../world/2012_01_14_03_world_trinity_string.sql | 6 ++++++ src/server/game/Movement/MotionMaster.cpp | 4 ++-- src/server/game/Movement/MotionMaster.h | 2 +- .../Northrend/IcecrownCitadel/boss_sindragosa.cpp | 2 +- .../UtgardeKeep/UtgardePinnacle/boss_svala.cpp | 18 ++++++++++++------ 6 files changed, 22 insertions(+), 16 deletions(-) delete mode 100644 sql/updates/world/2011_01_14_03_world_trinity_string.sql create mode 100644 sql/updates/world/2012_01_14_03_world_trinity_string.sql (limited to 'src/server/scripts/Northrend') diff --git a/sql/updates/world/2011_01_14_03_world_trinity_string.sql b/sql/updates/world/2011_01_14_03_world_trinity_string.sql deleted file mode 100644 index 7dab007f774..00000000000 --- a/sql/updates/world/2011_01_14_03_world_trinity_string.sql +++ /dev/null @@ -1,6 +0,0 @@ -DELETE FROM `trinity_string` WHERE `entry` IN(1139,1140,1141,1142); -INSERT INTO `trinity_string` (`entry`,`content_default`) VALUES -(1139,' Follow player %s (lowguid %u)'), -(1140,' Follow creature %s (lowguid %u)'), -(1141,' Follow '), -(1142,' Effect movement'); diff --git a/sql/updates/world/2012_01_14_03_world_trinity_string.sql b/sql/updates/world/2012_01_14_03_world_trinity_string.sql new file mode 100644 index 00000000000..7dab007f774 --- /dev/null +++ b/sql/updates/world/2012_01_14_03_world_trinity_string.sql @@ -0,0 +1,6 @@ +DELETE FROM `trinity_string` WHERE `entry` IN(1139,1140,1141,1142); +INSERT INTO `trinity_string` (`entry`,`content_default`) VALUES +(1139,' Follow player %s (lowguid %u)'), +(1140,' Follow creature %s (lowguid %u)'), +(1141,' Follow '), +(1142,' Effect movement'); diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 2656d882009..c17f5096748 100755 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -368,7 +368,7 @@ void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float spee Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED); } -void MotionMaster::MoveFall() +void MotionMaster::MoveFall(uint32 id/*=0*/) { // use larger distance for vmap height search than in most other cases float tz = i_owner->GetMap()->GetHeight(i_owner->GetPositionX(), i_owner->GetPositionY(), i_owner->GetPositionZ(), true, MAX_FALL_DISTANCE); @@ -387,7 +387,7 @@ void MotionMaster::MoveFall() init.MoveTo(i_owner->GetPositionX(),i_owner->GetPositionY(),tz); init.SetFall(); init.Launch(); - Mutate(new EffectMovementGenerator(0), MOTION_SLOT_CONTROLLED); + Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED); } void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id) diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index 00f1701e591..a5bd0861b04 100755 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -163,7 +163,7 @@ class MotionMaster //: private std::stack void MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ); void MoveJumpTo(float angle, float speedXY, float speedZ); void MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id = 0); - void MoveFall(); + void MoveFall(uint32 id = 0); void MoveSeekAssistance(float x, float y, float z); void MoveSeekAssistanceDistract(uint32 timer); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 46c1cf425ed..11100e6297e 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -268,7 +268,7 @@ class boss_sindragosa : public CreatureScript void MovementInform(uint32 type, uint32 point) { - if (type != POINT_MOTION_TYPE) + if (type != POINT_MOTION_TYPE && type != EFFECT_MOTION_TYPE) return; switch (point) diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp index 436336ec5b8..542243293de 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp @@ -94,6 +94,11 @@ enum SvalaPhase SVALADEAD }; +enum SvalaPoint +{ + POINT_FALL_GROUND = 1, +}; + #define DATA_INCREDIBLE_HULK 2043 static const float spectatorWP[2][3] = @@ -258,16 +263,16 @@ public: SetCombatMovement(false); me->HandleEmoteCommand(EMOTE_ONESHOT_FLYDEATH); - me->GetMotionMaster()->MoveFall(); + me->GetMotionMaster()->MoveFall(POINT_FALL_GROUND); } } void MovementInform(uint32 motionType, uint32 pointId) { - if (motionType != POINT_MOTION_TYPE) + if (motionType != EFFECT_MOTION_TYPE) return; - if (pointId == 1) + if (pointId == POINT_FALL_GROUND) me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); } @@ -288,7 +293,7 @@ public: Phase = NORMAL; SetCombatMovement(true); - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 300, true)) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 300.0f, true)) me->GetMotionMaster()->MoveChase(target); } } @@ -330,7 +335,7 @@ public: { std::list lspectatorList; GetCreatureListWithEntryInGrid(lspectatorList, me, CREATURE_SPECTATOR, 100.0f); - for(std::list::iterator itr = lspectatorList.begin(); itr != lspectatorList.end(); ++itr) + for (std::list::iterator itr = lspectatorList.begin(); itr != lspectatorList.end(); ++itr) { if ((*itr)->isAlive()) { @@ -397,7 +402,8 @@ public: Phase = NORMAL; break; } - } else introTimer -= diff; + } + else introTimer -= diff; return; } -- cgit v1.2.3 From f10e41ee416d723cfae0b8791307a87e029708a6 Mon Sep 17 00:00:00 2001 From: kaelima Date: Sun, 15 Jan 2012 20:37:25 +0100 Subject: Scripts/Trial of the Crusader: Fix crash in MovementInform for Frost Sphere in Anub'arak encounter. Thanks Vincent-Michael! Fixes #4834 --- .../EasternKingdoms/Karazhan/boss_nightbane.cpp | 2 +- .../TrialOfTheCrusader/boss_anubarak_trial.cpp | 105 +++++++++++---------- 2 files changed, 56 insertions(+), 51 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp index ecb909480c5..728446aa833 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp @@ -186,7 +186,7 @@ public: void MovementInform(uint32 type, uint32 id) { if (type != POINT_MOTION_TYPE) - return; + return; if (Intro) { diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index 8e34a318d6c..d3d92375d39 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -122,6 +122,11 @@ const Position SphereSpawn[6] = { 706.6383f, 161.5266f, 155.6701f, 0 }, }; +enum MovementPoints +{ + POINT_FALL_GROUND = 1 +}; + class boss_anubarak_trial : public CreatureScript { public: @@ -553,68 +558,68 @@ public: class mob_frost_sphere : public CreatureScript { -public: - mob_frost_sphere() : CreatureScript("mob_frost_sphere") { } + public: + mob_frost_sphere() : CreatureScript("mob_frost_sphere") { } - CreatureAI* GetAI(Creature* creature) const - { - return new mob_frost_sphereAI(creature); - }; - - struct mob_frost_sphereAI : public ScriptedAI - { - mob_frost_sphereAI(Creature* creature) : ScriptedAI(creature) + struct mob_frost_sphereAI : public ScriptedAI { - } - - bool m_bFall; - float x, y, z; + mob_frost_sphereAI(Creature* creature) : ScriptedAI(creature) + { + } - void Reset() - { - m_bFall = false; - me->SetReactState(REACT_PASSIVE); - me->SetFlying(true); - me->SetDisplayId(25144); - me->SetSpeed(MOVE_RUN, 0.5f, false); - me->GetMotionMaster()->MoveRandom(20.0f); - DoCast(SPELL_FROST_SPHERE); - } + void Reset() + { + _isFalling = false; + me->SetReactState(REACT_PASSIVE); + me->SetFlying(true); + me->SetDisplayId(me->GetCreatureInfo()->Modelid2); + me->SetSpeed(MOVE_RUN, 0.5f, false); + me->GetMotionMaster()->MoveRandom(20.0f); + DoCast(SPELL_FROST_SPHERE); + } - void DamageTaken(Unit* /*who*/, uint32& uiDamage) - { - if (me->GetHealth() < uiDamage) + void DamageTaken(Unit* /*who*/, uint32& damage) { - uiDamage = 0; - if (!m_bFall) + if (me->GetHealth() <= damage) { - m_bFall = true; - me->GetMotionMaster()->MoveIdle(); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //At hit the ground - me->HandleEmoteCommand(EMOTE_ONESHOT_FLYDEATH); - me->GetMotionMaster()->MoveFall(); + damage = 0; + if (!_isFalling) + { + _isFalling = true; + me->GetMotionMaster()->MoveIdle(); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + //At hit the ground + me->HandleEmoteCommand(EMOTE_ONESHOT_FLYDEATH); + me->GetMotionMaster()->MoveFall(POINT_FALL_GROUND); + } } } - } - - void MovementInform(uint32 uiType, uint32 uiId) - { - if (uiType != POINT_MOTION_TYPE) return; - switch (uiId) + void MovementInform(uint32 type, uint32 pointId) { - case 0: - me->RemoveAurasDueToSpell(SPELL_FROST_SPHERE); - me->SetDisplayId(11686); - DoCast(SPELL_PERMAFROST_VISUAL); - DoCast(SPELL_PERMAFROST); - me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.0f); - break; + if (type != EFFECT_MOTION_TYPE) + return; + + switch (pointId) + { + case POINT_FALL_GROUND: + me->RemoveAurasDueToSpell(SPELL_FROST_SPHERE); + me->SetDisplayId(me->GetCreatureInfo()->Modelid1); + DoCast(SPELL_PERMAFROST_VISUAL); + DoCast(SPELL_PERMAFROST); + me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.0f); + break; + } } - } - }; + private: + bool _isFalling; + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new mob_frost_sphereAI(creature); + }; }; class mob_anubarak_spike : public CreatureScript -- cgit v1.2.3 From 4bdc5353735a7ec73c23e11f824adb378eea3adf Mon Sep 17 00:00:00 2001 From: Souler Date: Tue, 17 Jan 2012 12:55:54 +0100 Subject: Script/Quest: Solve some related problems with "An Audience With The Arcanist" and "A Meeting With The Magister" --- sql/updates/world/2012_01_17_00_world_misc.sql | 27 +++++++++ src/server/scripts/Northrend/dalaran.cpp | 13 ++++- src/server/scripts/Spells/spell_generic.cpp | 80 +++++++++++++++++++++++++- 3 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 sql/updates/world/2012_01_17_00_world_misc.sql (limited to 'src/server/scripts/Northrend') diff --git a/sql/updates/world/2012_01_17_00_world_misc.sql b/sql/updates/world/2012_01_17_00_world_misc.sql new file mode 100644 index 00000000000..300d239bd43 --- /dev/null +++ b/sql/updates/world/2012_01_17_00_world_misc.sql @@ -0,0 +1,27 @@ +DELETE FROM `spell_script_names` WHERE `spell_id` IN (69672,69673); +INSERT INTO `spell_script_names`(`spell_id`,`ScriptName`) VALUES +(69672,'spell_gen_sunreaver_disguise'), +(69673,'spell_gen_silver_covenant_disguise'); + +-- Update spells used on script. Now they are always casting the female spell, +-- since the spell script is fixed we should cast now the correct spell. +UPDATE `smart_scripts` SET `action_param1`=69672 WHERE `entryorguid`=36669 AND `action_type`=11 AND `action_param1`=70973; +UPDATE `smart_scripts` SET `action_param1`=69673 WHERE `entryorguid`=36670 AND `action_type`=11 AND `action_param1`=70971; +-- Set correct gossip menus ids for renewing the disguise +UPDATE `smart_scripts` SET `event_param1`=10858 WHERE `entryorguid`=36669 AND `event_param1`=10857; +UPDATE `smart_scripts` SET `event_param1`=10857 WHERE `entryorguid`=36670 AND `event_param1`=10858; + +-- Gossip options were crossed. They should offer to cast the oposing faction disguise,instead of his own faction disguise. +UPDATE `gossip_menu_option` SET `option_text`="Would you renew my Covenant disguise?" WHERE `menu_id`=10857 AND `id`=1; +UPDATE `gossip_menu_option` SET `option_text`="Would you renew my Sunreaver disguise?" WHERE `menu_id`=10858 AND `id`=1; + +-- Correct quest ids on conditios for showing the renew disguise option. +-- Also add a check for male disguise aura. +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup` IN (10857,10858) AND `SourceEntry`=1; +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES +(15,10858,1,0,11,70973,0,0,0,'',NULL), +(15,10858,1,0,11,70974,0,0,0,'',NULL), +(15,10858,1,0,9,20439,0,0,0,'',NULL), +(15,10857,1,0,11,70971,0,0,0,'',NULL), +(15,10857,1,0,11,70972,0,0,0,'',NULL), +(15,10857,1,0,9,24451,0,0,0,'',NULL); diff --git a/src/server/scripts/Northrend/dalaran.cpp b/src/server/scripts/Northrend/dalaran.cpp index 57007a93fa7..cd3cbf29d0d 100644 --- a/src/server/scripts/Northrend/dalaran.cpp +++ b/src/server/scripts/Northrend/dalaran.cpp @@ -32,7 +32,12 @@ Script Data End */ enum Spells { SPELL_TRESPASSER_A = 54028, - SPELL_TRESPASSER_H = 54029 + SPELL_TRESPASSER_H = 54029, + + SPELL_SUNREAVER_DISGUISE_FEMALE = 70973, + SPELL_SUNREAVER_DISGUISE_MALE = 70974, + SPELL_SILVER_COVENANT_DISGUISE_FEMALE = 70971, + SPELL_SILVER_COVENANT_DISGUISE_MALE = 70972, }; enum NPCs // All outdoor guards are within 35.0f of these NPCs @@ -71,8 +76,10 @@ public: Player* player = who->GetCharmerOrOwnerPlayerOrPlayerItself(); - // If player has Disguise aura for quest A Meeting With The Magister or An Audience With The Arcanist, do not teleport it away but let it pass - if (!player || player->isGameMaster() || player->IsBeingTeleported() || player->HasAura(70973) || player->HasAura(70971)) + if (!player || player->isGameMaster() || player->IsBeingTeleported() || + // If player has Disguise aura for quest A Meeting With The Magister or An Audience With The Arcanist, do not teleport it away but let it pass + player->HasAura(SPELL_SUNREAVER_DISGUISE_FEMALE) || player->HasAura(SPELL_SUNREAVER_DISGUISE_MALE) || + player->HasAura(SPELL_SILVER_COVENANT_DISGUISE_FEMALE) || player->HasAura(SPELL_SILVER_COVENANT_DISGUISE_MALE)) return; switch (me->GetEntry()) diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 38e5771ccca..bb3e63af8e4 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -1471,6 +1471,82 @@ class spell_gen_luck_of_the_draw : public SpellScriptLoader } }; +enum DalaranDisguiseSpells +{ + SPELL_SUNREAVER_DISGUISE_TRIGGER = 69672, + SPELL_SUNREAVER_DISGUISE_FEMALE = 70973, + SPELL_SUNREAVER_DISGUISE_MALE = 70974, + + SPELL_SILVER_COVENANT_DISGUISE_TRIGGER = 69673, + SPELL_SILVER_COVENANT_DISGUISE_FEMALE = 70971, + SPELL_SILVER_COVENANT_DISGUISE_MALE = 70972, +}; + +class spell_gen_dalaran_disguise : public SpellScriptLoader +{ + public: + spell_gen_dalaran_disguise(const char* name) : SpellScriptLoader(name) {} + + class spell_gen_dalaran_disguise_SpellScript : public SpellScript + { + PrepareSpellScript(spell_gen_dalaran_disguise_SpellScript); + bool Validate(SpellInfo const* spellEntry) + { + switch (spellEntry->Id) + { + case SPELL_SUNREAVER_DISGUISE_TRIGGER: + if (!sSpellMgr->GetSpellInfo(SPELL_SUNREAVER_DISGUISE_FEMALE)) + return false; + if (!sSpellMgr->GetSpellInfo(SPELL_SUNREAVER_DISGUISE_MALE)) + return false; + break; + case SPELL_SILVER_COVENANT_DISGUISE_TRIGGER: + if (!sSpellMgr->GetSpellInfo(SPELL_SILVER_COVENANT_DISGUISE_FEMALE)) + return false; + if (!sSpellMgr->GetSpellInfo(SPELL_SILVER_COVENANT_DISGUISE_MALE)) + return false; + break; + } + return true; + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + + if (Player* player = GetHitPlayer()) + { + uint8 gender = player->getGender(); + + uint32 spellId = GetSpellInfo()->Id; + + switch (spellId) + { + case SPELL_SUNREAVER_DISGUISE_TRIGGER: + spellId = gender ? SPELL_SUNREAVER_DISGUISE_FEMALE : SPELL_SUNREAVER_DISGUISE_MALE; + break; + case SPELL_SILVER_COVENANT_DISGUISE_TRIGGER: + spellId = gender ? SPELL_SILVER_COVENANT_DISGUISE_FEMALE : SPELL_SILVER_COVENANT_DISGUISE_MALE; + break; + default: + break; + } + + GetCaster()->CastSpell(player, spellId, true); + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_gen_dalaran_disguise_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_gen_dalaran_disguise_SpellScript(); + } +}; + void AddSC_generic_spell_scripts() { new spell_gen_absorb0_hitlimit1(); @@ -1504,4 +1580,6 @@ void AddSC_generic_spell_scripts() new spell_gen_oracle_wolvar_reputation(); new spell_gen_damage_reduction_aura(); new spell_gen_luck_of_the_draw(); -} + new spell_gen_dalaran_disguise("spell_gen_sunreaver_disguise"); + new spell_gen_dalaran_disguise("spell_gen_silver_covenant_disguise"); +} \ No newline at end of file -- cgit v1.2.3 From f02d91309495eb467fbd8ece26ce09e5f0f3cd0f Mon Sep 17 00:00:00 2001 From: Manuel Carrasco Date: Thu, 19 Jan 2012 21:09:13 -0300 Subject: Scripts/FoS: * Fixed Bronjahm teleport. * Soulstorm Channel (Visual) will be correctly cast at wip. * Adjusted Magic Bane timer. --- .../Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp index d444160b8f2..a0d6f04f44c 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp @@ -67,6 +67,7 @@ class boss_bronjahm : public CreatureScript { boss_bronjahmAI(Creature* creature) : BossAI(creature, DATA_BRONJAHM) { + DoCast(me, SPELL_SOULSTORM_CHANNEL, true); } void InitializeAI() @@ -82,14 +83,17 @@ class boss_bronjahm : public CreatureScript events.Reset(); events.SetPhase(PHASE_1); events.ScheduleEvent(EVENT_SHADOW_BOLT, 2000); - events.ScheduleEvent(EVENT_MAGIC_BANE, urand(8000, 15000)); + events.ScheduleEvent(EVENT_MAGIC_BANE, urand(8000, 20000)); events.ScheduleEvent(EVENT_CORRUPT_SOUL, urand(25000, 35000), 0, PHASE_1); - me->CastSpell(me, SPELL_SOULSTORM_CHANNEL, true); - instance->SetBossState(DATA_BRONJAHM, NOT_STARTED); } + void JustReachedHome() + { + DoCast(me, SPELL_SOULSTORM_CHANNEL, true); + } + void EnterCombat(Unit* /*who*/) { DoScriptText(SAY_AGGRO, me); @@ -118,7 +122,7 @@ class boss_bronjahm : public CreatureScript events.SetPhase(PHASE_2); DoCast(me, SPELL_TELEPORT); events.ScheduleEvent(EVENT_FEAR, urand(12000, 16000), 0, PHASE_2); - events.ScheduleEvent(EVENT_SOULSTORM, 700, 0, PHASE_2); + events.ScheduleEvent(EVENT_SOULSTORM, 100, 0, PHASE_2); } } @@ -147,7 +151,7 @@ class boss_bronjahm : public CreatureScript { case EVENT_MAGIC_BANE: DoCastVictim(SPELL_MAGIC_S_BANE); - events.ScheduleEvent(EVENT_MAGIC_BANE, urand(8000, 15000)); + events.ScheduleEvent(EVENT_MAGIC_BANE, urand(8000, 20000)); break; case EVENT_SHADOW_BOLT: if (!me->IsWithinMeleeRange(me->getVictim())) -- cgit v1.2.3 From 53c48c774a007e2a4d60bf8e9a6ba90065645600 Mon Sep 17 00:00:00 2001 From: Manuel Carrasco Date: Fri, 20 Jan 2012 01:55:55 -0300 Subject: Scripts/UK: Adjusted Ingvar the Plunderer's spell timers (Shadow Axe is still missing), sniffs have been used as source. --- .../UtgardeKeep/boss_ingvar_the_plunderer.cpp | 135 +++++++++++---------- 1 file changed, 74 insertions(+), 61 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp index ea84502c16d..c2b1699bf5b 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp @@ -45,16 +45,32 @@ enum Creatures MOB_INGVAR_UNDEAD = 23980, }; +enum Events +{ + EVENT_CLEAVE = 1, + EVENT_SMASH, + EVENT_STAGGERING_ROAR, + EVENT_ENRAGE, + + EVENT_DARK_SMASH, + EVENT_DREADFUL_ROAR, + EVENT_WOE_STRIKE, + EVENT_SHADOW_AXE +}; + +enum Phases +{ + PHASE_HUMAN = 1, + PHASE_UNDEAD, +}; + enum Spells { //Ingvar Spells human form SPELL_CLEAVE = 42724, SPELL_SMASH = 42669, - H_SPELL_SMASH = 59706, SPELL_STAGGERING_ROAR = 42708, - H_SPELL_STAGGERING_ROAR = 59708, SPELL_ENRAGE = 42705, - H_SPELL_ENRAGE = 59707, SPELL_INGVAR_FEIGN_DEATH = 42795, SPELL_SUMMON_BANSHEE = 42912, @@ -63,9 +79,7 @@ enum Spells //Ingvar Spells undead form SPELL_DARK_SMASH = 42723, SPELL_DREADFUL_ROAR = 42729, - H_SPELL_DREADFUL_ROAR = 59734, SPELL_WOE_STRIKE = 42730, - H_SPELL_WOE_STRIKE = 59735, ENTRY_THROW_TARGET = 23996, SPELL_SHADOW_AXE_SUMMON = 42749 @@ -110,10 +124,18 @@ public: me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); me->SetStandState(UNIT_STAND_STATE_STAND); - uiCleaveTimer = 2000; - uiSmashTimer = 5000; - uiEnrageTimer = 10000; - uiRoarTimer = 15000; + events.Reset(); + events.SetPhase(PHASE_HUMAN); + + events.ScheduleEvent(EVENT_CLEAVE, urand(6,12)*IN_MILLISECONDS, 0, PHASE_HUMAN); + events.ScheduleEvent(EVENT_STAGGERING_ROAR, urand(18,21)*IN_MILLISECONDS, 0, PHASE_HUMAN); + events.ScheduleEvent(EVENT_ENRAGE, urand(7,14)*IN_MILLISECONDS, 0, PHASE_HUMAN); + events.ScheduleEvent(EVENT_SMASH, urand(12,17)*IN_MILLISECONDS, 0, PHASE_HUMAN); + + events.ScheduleEvent(EVENT_DARK_SMASH, urand(14,22)*IN_MILLISECONDS, 0, PHASE_UNDEAD); + events.ScheduleEvent(EVENT_DREADFUL_ROAR, urand(18,21)*IN_MILLISECONDS, 0, PHASE_UNDEAD); + events.ScheduleEvent(EVENT_WOE_STRIKE, urand(10,14)*IN_MILLISECONDS, 0, PHASE_UNDEAD); + events.ScheduleEvent(EVENT_SHADOW_AXE, 30*IN_MILLISECONDS, 0, PHASE_UNDEAD); uiSpawnResTimer = 3000; @@ -138,6 +160,7 @@ public: bEventInProgress = true; bIsUndead = true; + events.SetPhase(PHASE_UNDEAD); DoScriptText(YELL_DEAD_1, me); } @@ -208,70 +231,60 @@ public: return; } - if (uiCleaveTimer <= diff) - { - if (!me->HasUnitState(UNIT_STAT_CASTING)) - { - if (bIsUndead) - DoCast(me->getVictim(), SPELL_WOE_STRIKE); - else - DoCast(me->getVictim(), SPELL_CLEAVE); - uiCleaveTimer = rand()%5000 + 2000; - } - } else uiCleaveTimer -= diff; + events.Update(diff); - if (uiSmashTimer <= diff) - { - if (!me->HasUnitState(UNIT_STAT_CASTING)) - { - if (bIsUndead) - DoCast(me->getVictim(), SPELL_DARK_SMASH); - else - DoCast(me->getVictim(), SPELL_SMASH); - uiSmashTimer = 10000; - } - } else uiSmashTimer -= diff; + if (me->HasUnitState(UNIT_STAT_CASTING)) + return; - if (!bIsUndead) + while (uint32 eventId = events.ExecuteEvent()) { - if (uiEnrageTimer <= diff) + switch (eventId) { - DoCast(me, SPELL_ENRAGE); - uiEnrageTimer = 10000; - } else uiEnrageTimer -= diff; - } else // In Undead form used to summon weapon - { - if (uiEnrageTimer <= diff) - { - if (!me->HasUnitState(UNIT_STAT_CASTING)) - { - // Spawn target for Axe - Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); - if (target) + // PHASE ONE + case EVENT_CLEAVE: + DoCastVictim(SPELL_CLEAVE); + events.ScheduleEvent(EVENT_CLEAVE, urand(6,12)*IN_MILLISECONDS, 0, PHASE_HUMAN); + break; + case EVENT_STAGGERING_ROAR: + DoCast(me, SPELL_STAGGERING_ROAR); + events.ScheduleEvent(EVENT_STAGGERING_ROAR, urand(18,21)*IN_MILLISECONDS, 0, PHASE_HUMAN); + break; + case EVENT_ENRAGE: + DoCast(me, SPELL_ENRAGE); + events.ScheduleEvent(EVENT_ENRAGE, urand(7,14)*IN_MILLISECONDS, 0, PHASE_HUMAN); + break; + case EVENT_SMASH: + DoCastVictim(SPELL_SMASH); + events.ScheduleEvent(EVENT_SMASH, urand(12,17)*IN_MILLISECONDS, 0, PHASE_HUMAN); + break; + // PHASE TWO + case EVENT_DARK_SMASH: + DoCastVictim(SPELL_DARK_SMASH); + events.ScheduleEvent(EVENT_DARK_SMASH, urand(14,22)*IN_MILLISECONDS, 0, PHASE_UNDEAD); + break; + case EVENT_DREADFUL_ROAR: + DoCast(me, SPELL_DREADFUL_ROAR); + events.ScheduleEvent(EVENT_DREADFUL_ROAR, urand(18,21)*IN_MILLISECONDS, 0, PHASE_UNDEAD); + break; + case EVENT_WOE_STRIKE: + DoCastVictim(SPELL_WOE_STRIKE); + events.ScheduleEvent(EVENT_WOE_STRIKE, urand(10,14)*IN_MILLISECONDS, 0, PHASE_UNDEAD); + break; + case EVENT_SHADOW_AXE: + if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1)) { me->SummonCreature(ENTRY_THROW_TARGET, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 2000); - DoCast(me, SPELL_SHADOW_AXE_SUMMON); } - uiEnrageTimer = 30000; - } - } else uiEnrageTimer -= diff; - } - - if (uiRoarTimer <= diff) - { - if (!me->HasUnitState(UNIT_STAT_CASTING)) - { - if (bIsUndead) - DoCast(me, SPELL_DREADFUL_ROAR); - else - DoCast(me, SPELL_STAGGERING_ROAR); - uiRoarTimer = 10000; + events.ScheduleEvent(EVENT_SHADOW_AXE, 30*IN_MILLISECONDS, 0, PHASE_UNDEAD); + break; } - } else uiRoarTimer -= diff; + } DoMeleeAttackIfReady(); } + private: + EventMap events; }; }; -- cgit v1.2.3 From e336c6ff57d751d4e395eb6c0bad3c9066765199 Mon Sep 17 00:00:00 2001 From: Manuel Carrasco Date: Fri, 20 Jan 2012 02:28:09 -0300 Subject: Scripts/FoS: Fixed visual bug when Devourer of Souls casts Wailing Souls. fixed #1692 --- .../Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp index 8180a686e0e..fb39019fb84 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp @@ -306,6 +306,7 @@ class boss_devourer_of_souls : public CreatureScript if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) { me->SetOrientation(me->GetAngle(target)); + me->SendMovementFlagUpdate(); DoCast(me, SPELL_WAILING_SOULS_BEAM); } @@ -332,6 +333,7 @@ class boss_devourer_of_souls : public CreatureScript case EVENT_WAILING_SOULS_TICK: beamAngle += beamAngleDiff; me->SetOrientation(beamAngle); + me->SendMovementFlagUpdate(); me->StopMoving(); DoCast(me, SPELL_WAILING_SOULS); -- cgit v1.2.3 From 19f8cc26b9cae894469263125fdb5342fe7a264d Mon Sep 17 00:00:00 2001 From: Manuel Carrasco Date: Fri, 20 Jan 2012 13:08:41 -0300 Subject: Scripts/UK: Removed unused variables, thanks to Vincent-Michael. --- .../UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp index c2b1699bf5b..1ab95c53500 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp @@ -18,7 +18,7 @@ /* ScriptData SDName: Boss_Ingvar_The_Plunderer SD%Complete: 95 -SDComment: Some Problems with Annhylde Movement, Blizzlike Timers +SDComment: Some Problems with Annhylde Movement, Blizzlike Timers (just shadow axe summon needs a new timer) SDCategory: Udgarde Keep EndScriptData */ @@ -97,9 +97,9 @@ public: struct boss_ingvar_the_plundererAI : public ScriptedAI { - boss_ingvar_the_plundererAI(Creature* c) : ScriptedAI(c) + boss_ingvar_the_plundererAI(Creature* creature) : ScriptedAI(creature) { - instance = c->GetInstanceScript(); + instance = creature->GetInstanceScript(); } InstanceScript* instance; @@ -107,10 +107,6 @@ public: bool bIsUndead; bool bEventInProgress; - uint32 uiCleaveTimer; - uint32 uiSmashTimer; - uint32 uiEnrageTimer; - uint32 uiRoarTimer; uint32 uiSpawnResTimer; void Reset() -- cgit v1.2.3 From 40c6e7bcdbff46f355af5b43bbf5ca0fd86e6777 Mon Sep 17 00:00:00 2001 From: Manuel Carrasco Date: Mon, 23 Jan 2012 20:03:06 -0300 Subject: Scripts/UK: Re-written Prince Keleseth script. * Corrected spawns amount, only 4 Skeletons must be spawned not 5. * Adjusted timers, now they are blizzlike. * This also includes skeleton resurrection timer. * Removed hacky code that was replacing spells (they are casted now). * Implemented "On The Rocks" achievement. Thanks to Subv for help. --- .../2012_01_23_01_world_creature_script_names.sql | 2 + sql/updates/world/2012_01_23_02_world_disables.sql | 1 + ...12_01_23_03_world_achievement_criteria_data.sql | 3 + .../world/2012_01_23_04_world_creature_text.sql | 9 + .../2012_01_23_05_world_spell_script_names.sql | 3 + .../UtgardeKeep/UtgardeKeep/boss_keleseth.cpp | 434 ++++++++++----------- 6 files changed, 223 insertions(+), 229 deletions(-) create mode 100644 sql/updates/world/2012_01_23_01_world_creature_script_names.sql create mode 100644 sql/updates/world/2012_01_23_02_world_disables.sql create mode 100644 sql/updates/world/2012_01_23_03_world_achievement_criteria_data.sql create mode 100644 sql/updates/world/2012_01_23_04_world_creature_text.sql create mode 100644 sql/updates/world/2012_01_23_05_world_spell_script_names.sql (limited to 'src/server/scripts/Northrend') diff --git a/sql/updates/world/2012_01_23_01_world_creature_script_names.sql b/sql/updates/world/2012_01_23_01_world_creature_script_names.sql new file mode 100644 index 00000000000..d7c2b22725e --- /dev/null +++ b/sql/updates/world/2012_01_23_01_world_creature_script_names.sql @@ -0,0 +1,2 @@ +UPDATE `creature_template` SET `ScriptName`='npc_frost_tomb' WHERE `entry`=23965; +UPDATE `creature_template` SET `ScriptName`='npc_vrykul_skeleton' WHERE `entry`=23970; diff --git a/sql/updates/world/2012_01_23_02_world_disables.sql b/sql/updates/world/2012_01_23_02_world_disables.sql new file mode 100644 index 00000000000..0a1be704dac --- /dev/null +++ b/sql/updates/world/2012_01_23_02_world_disables.sql @@ -0,0 +1 @@ +DELETE FROM `disables` WHERE `entry`=7231 AND `sourceType`=4; diff --git a/sql/updates/world/2012_01_23_03_world_achievement_criteria_data.sql b/sql/updates/world/2012_01_23_03_world_achievement_criteria_data.sql new file mode 100644 index 00000000000..4d1f4536455 --- /dev/null +++ b/sql/updates/world/2012_01_23_03_world_achievement_criteria_data.sql @@ -0,0 +1,3 @@ +DELETE FROM `achievement_criteria_data` WHERE `criteria_id`=7231; +INSERT INTO `achievement_criteria_data` (`criteria_id`, `type`, `ScriptName`) VALUES +(7231,11,'achievement_on_the_rocks'); diff --git a/sql/updates/world/2012_01_23_04_world_creature_text.sql b/sql/updates/world/2012_01_23_04_world_creature_text.sql new file mode 100644 index 00000000000..f505a86b16c --- /dev/null +++ b/sql/updates/world/2012_01_23_04_world_creature_text.sql @@ -0,0 +1,9 @@ +DELETE FROM `script_texts` WHERE `entry` IN (-1574000,-1574001,-1574002,-1574003,-1574004); + +DELETE FROM `creature_text` WHERE `entry`=23953; +INSERT INTO `creature_text` (`entry`, `groupid`, `text`, `sound`, `emote`, `type`) VALUES +(23953,1,'Your blood is mine!',13221,7,14), +(23953,2,'Aranal, ledel! Their fate shall be yours!',13224,0,14), +(23953,3,'Not so fast.',13222,0,14), +(23953,4,'%s casts Frost Tomb on $n.',0,0,41), +(23953,5,'I join... the night.',13225,0,14); diff --git a/sql/updates/world/2012_01_23_05_world_spell_script_names.sql b/sql/updates/world/2012_01_23_05_world_spell_script_names.sql new file mode 100644 index 00000000000..6f3b4907e5b --- /dev/null +++ b/sql/updates/world/2012_01_23_05_world_spell_script_names.sql @@ -0,0 +1,3 @@ +DELETE FROM `spell_script_names` WHERE `spell_id`=48400; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(48400,'spell_frost_tomb'); diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp index dc93917f2e5..639d1852c15 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp @@ -17,354 +17,330 @@ /* ScriptData SDName: Boss_Prince_Keleseth -SD%Complete: 90 -SDComment: Needs Prince Movements, Needs adjustments to blizzlike timers, Needs Shadowbolt castbar, Needs right Ressurect Visual, Needs Some Heroic Spells +SD%Complete: 100 +SDComment: SDCategory: Utgarde Keep EndScriptData */ #include "ScriptPCH.h" #include "utgarde_keep.h" -enum eEnums +enum KelsethEncounter { - ACHIEVEMENT_ON_THE_ROCKS = 1919, - SPELL_SHADOWBOLT = 43667, - SPELL_SHADOWBOLT_HEROIC = 59389, SPELL_FROST_TOMB = 48400, + SPELL_FROST_TOMB_STUN = 42672, SPELL_FROST_TOMB_SUMMON = 42714, + + SPELL_SHADOW_FISSURE = 50657, + SPELL_FULL_HEAL = 17683, SPELL_DECREPIFY = 42702, - SPELL_SCOURGE_RESSURRECTION = 42704, - CREATURE_FROSTTOMB = 23965, - CREATURE_SKELETON = 23970, - - SAY_AGGRO = -1574000, - SAY_FROST_TOMB = -1574001, - SAY_SKELETONS = -1574002, - SAY_KILL = -1574003, - SAY_DEATH = -1574004 + SPELL_BONE_ARMOR = 59386, + + NPC_FROSTTOMB = 23965, + NPC_SKELETON = 23970, + + SAY_START_COMBAT = 1, + SAY_SUMMON_SKELETONS, + SAY_FROST_TOMB, + SAY_FROST_TOMB_EMOTE, + SAY_DEATH, + + EVENT_SHADOWBOLT = 1, + EVENT_FROST_TOMB, + EVENT_SUMMON_SKELETONS, + + EVENT_DECREPIFY, + EVENT_FULL_HEAL, + EVENT_SHADOW_FISSURE, + EVENT_RESURRECT, + + DATA_ON_THE_ROCKS }; #define SKELETONSPAWN_Z 42.8668f -float SkeletonSpawnPoint[5][5]= +const float SkeletonSpawnPoint[1][2] = { {156.2559f, 259.2093f}, - {156.2559f, 259.2093f}, - {156.2559f, 259.2093f}, - {156.2559f, 259.2093f}, - {156.2559f, 259.2093f}, }; -float AttackLoc[3]={197.636f, 194.046f, 40.8164f}; +float AttackLoc[3]= {197.636f, 194.046f, 40.8164f}; -bool ShatterFrostTomb; // needed for achievement: On The Rocks(1919) - -class mob_frost_tomb : public CreatureScript +class npc_frost_tomb : public CreatureScript { public: - mob_frost_tomb() : CreatureScript("mob_frost_tomb") { } + npc_frost_tomb() : CreatureScript("npc_frost_tomb") {} CreatureAI* GetAI(Creature* creature) const { - return new mob_frost_tombAI(creature); + return new npc_frost_tombAI(creature); } - struct mob_frost_tombAI : public ScriptedAI + struct npc_frost_tombAI : public ScriptedAI { - mob_frost_tombAI(Creature* c) : ScriptedAI(c) + npc_frost_tombAI(Creature* creature) : ScriptedAI(creature) { - FrostTombGUID = 0; - } - - uint64 FrostTombGUID; + if (me->isSummon()) + if (Unit* summon = me->ToTempSummon()->GetSummoner()) + DoCast(summon, SPELL_FROST_TOMB, true); - void SetPrisoner(Unit* uPrisoner) - { - FrostTombGUID = uPrisoner->GetGUID(); + instance = creature->GetInstanceScript(); } - void Reset(){ FrostTombGUID = 0; } - void EnterCombat(Unit* /*who*/) {} - void AttackStart(Unit* /*who*/) {} - void MoveInLineOfSight(Unit* /*who*/) {} + void UpdateAI(const uint32 /*diff*/) {} - void JustDied(Unit* killer) + void JustDied(Unit* /*killer*/) { - if (killer->GetGUID() != me->GetGUID()) - ShatterFrostTomb = true; - - if (FrostTombGUID) - { - Unit* FrostTomb = Unit::GetUnit((*me), FrostTombGUID); - if (FrostTomb) - FrostTomb->RemoveAurasDueToSpell(SPELL_FROST_TOMB); - } + if (instance) + if (Unit* boss = me->GetUnit(*me, instance->GetData64(DATA_PRINCEKELESETH))) + if (boss->ToCreature() && boss->ToCreature()->AI()) + boss->ToCreature()->AI()->SetData(DATA_ON_THE_ROCKS, false); } - void UpdateAI(const uint32 /*diff*/) - { - Unit* temp = Unit::GetUnit((*me), FrostTombGUID); - if ((temp && temp->isAlive() && !temp->HasAura(SPELL_FROST_TOMB)) || !temp) - me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } + private: + InstanceScript* instance; }; - }; class boss_keleseth : public CreatureScript { public: - boss_keleseth() : CreatureScript("boss_keleseth") { } + boss_keleseth() : CreatureScript("boss_keleseth") {} CreatureAI* GetAI(Creature* creature) const { return new boss_kelesethAI (creature); } - struct boss_kelesethAI : public ScriptedAI + struct boss_kelesethAI : public BossAI { - boss_kelesethAI(Creature* c) : ScriptedAI(c) + boss_kelesethAI(Creature* creature) : BossAI(creature, DATA_PRINCEKELESETH_EVENT) { - instance = c->GetInstanceScript(); + creature->SetReactState(REACT_DEFENSIVE); } - InstanceScript* instance; - - uint32 FrostTombTimer; - uint32 SummonSkeletonsTimer; - uint32 RespawnSkeletonsTimer; - uint32 ShadowboltTimer; - uint64 SkeletonGUID[5]; - bool Skeletons; - bool RespawnSkeletons; - void Reset() { - ShadowboltTimer = 0; - Skeletons = false; + instance->SetData(DATA_PRINCEKELESETH_EVENT, NOT_STARTED); - ShatterFrostTomb = false; + events.Reset(); + events.ScheduleEvent(EVENT_SHADOWBOLT, urand(2,3)*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FROST_TOMB, urand(14,19)*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SUMMON_SKELETONS, 6*IN_MILLISECONDS); - ResetTimer(); + summons.DespawnAll(); - if (instance) - instance->SetData(DATA_PRINCEKELESETH_EVENT, NOT_STARTED); + onTheRocks = true; } - void KilledUnit(Unit* victim) + void EnterCombat(Unit* /*who*/) { - if (victim == me) - return; - - DoScriptText(SAY_KILL, me); + me->SetInCombatWithZone(); + instance->SetData(DATA_PRINCEKELESETH_EVENT, IN_PROGRESS); + Talk(SAY_START_COMBAT); } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); - - if (IsHeroic() && !ShatterFrostTomb) - { - AchievementEntry const* AchievOnTheRocks = GetAchievementStore()->LookupEntry(ACHIEVEMENT_ON_THE_ROCKS); - if (AchievOnTheRocks) - { - Map* map = me->GetMap(); - if (map && map->IsDungeon()) - { - Map::PlayerList const &players = map->GetPlayers(); - for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) - itr->getSource()->CompletedAchievement(AchievOnTheRocks); - } - } - } - - if (instance) - instance->SetData(DATA_PRINCEKELESETH_EVENT, DONE); + instance->SetData(DATA_PRINCEKELESETH_EVENT, DONE); + summons.DespawnAll(); + Talk(SAY_DEATH); } - void EnterCombat(Unit* /*who*/) + void SetData(uint32 data, uint32 value) { - DoScriptText(SAY_AGGRO, me); - DoZoneInCombat(); - - if (instance) - instance->SetData(DATA_PRINCEKELESETH_EVENT, IN_PROGRESS); + if (data == DATA_ON_THE_ROCKS) + onTheRocks = value; } - void ResetTimer(uint32 inc = 0) + uint32 GetData(uint32 data) { - SummonSkeletonsTimer = 5000 + inc; - FrostTombTimer = 28000 + inc; + if (data == DATA_ON_THE_ROCKS) + return onTheRocks; + + return 0; } - void UpdateAI(const uint32 diff) + void ExecuteEvent(uint32 const eventId) { - if (!UpdateVictim()) - return; - - if (ShadowboltTimer <= diff) + switch (eventId) { - Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 0); - if (target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER) - me->CastSpell(target, DUNGEON_MODE(SPELL_SHADOWBOLT, SPELL_SHADOWBOLT_HEROIC), true); - ShadowboltTimer = 10000; - } else ShadowboltTimer -= diff; - - if (!Skeletons) - { - if ((SummonSkeletonsTimer <= diff)) - { - Creature* Skeleton; - DoScriptText(SAY_SKELETONS, me); - for (uint8 i = 0; i < 5; ++i) + case EVENT_SUMMON_SKELETONS: + Talk(SAY_SUMMON_SKELETONS); + SummonSkeletons(); + break; + case EVENT_SHADOWBOLT: + DoCastVictim(SPELL_SHADOWBOLT); + events.ScheduleEvent(EVENT_SHADOWBOLT, urand(2,3)*IN_MILLISECONDS); + break; + case EVENT_FROST_TOMB: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true, -SPELL_FROST_TOMB)) { - Skeleton = me->SummonCreature(CREATURE_SKELETON, SkeletonSpawnPoint[i][0], SkeletonSpawnPoint[i][1], SKELETONSPAWN_Z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000); - if (Skeleton) - { - Skeleton->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); - Skeleton->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()); - Skeleton->AddThreat(me->getVictim(), 0.0f); - DoZoneInCombat(Skeleton); - } - } - Skeletons = true; - } else SummonSkeletonsTimer -= diff; - } + Talk(SAY_FROST_TOMB); + Talk(SAY_FROST_TOMB_EMOTE, target->GetGUID()); - if (FrostTombTimer <= diff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - if (target->isAlive()) - { - //DoCast(target, SPELL_FROST_TOMB_SUMMON, true); - if (Creature* pChains = me->SummonCreature(CREATURE_FROSTTOMB, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 20000)) - { - CAST_AI(mob_frost_tomb::mob_frost_tombAI, pChains->AI())->SetPrisoner(target); - pChains->CastSpell(target, SPELL_FROST_TOMB, true); - - DoScriptText(SAY_FROST_TOMB, me); - } + DoCast(target, SPELL_FROST_TOMB_STUN, true); + // checked from sniffs - the player casts the spell + target->CastSpell(target, SPELL_FROST_TOMB_SUMMON, true); } - FrostTombTimer = 15000; - } else FrostTombTimer -= diff; + events.ScheduleEvent(EVENT_FROST_TOMB, urand(14,19)*IN_MILLISECONDS); + break; + } + } - DoMeleeAttackIfReady(); + void SummonSkeletons() + { + // I could not found any spell casted for this + for (uint8 i = 0; i < 4; ++i) + me->SummonCreature(NPC_SKELETON, SkeletonSpawnPoint[0][0], SkeletonSpawnPoint[0][1], SKELETONSPAWN_Z, 0); } + private: + bool onTheRocks; }; - }; -class mob_vrykul_skeleton : public CreatureScript +class npc_vrykul_skeleton : public CreatureScript { public: - mob_vrykul_skeleton() : CreatureScript("mob_vrykul_skeleton") { } + npc_vrykul_skeleton() : CreatureScript("npc_vrykul_skeleton") {} CreatureAI* GetAI(Creature* creature) const { - return new mob_vrykul_skeletonAI (creature); + return new npc_vrykul_skeletonAI (creature); } - struct mob_vrykul_skeletonAI : public ScriptedAI + struct npc_vrykul_skeletonAI : public ScriptedAI { - mob_vrykul_skeletonAI(Creature* c) : ScriptedAI(c) - { - instance = c->GetInstanceScript(); - } - - InstanceScript* instance; - uint32 Respawn_Time; - uint64 Target_Guid; - uint32 Decrepify_Timer; - - bool isDead; + npc_vrykul_skeletonAI(Creature* creature) : ScriptedAI(creature) {} void Reset() { - Respawn_Time = 12000; - Decrepify_Timer = urand(10000, 20000); - isDead = false; + events.Reset(); + events.ScheduleEvent(EVENT_DECREPIFY, urand(4,6)*IN_MILLISECONDS); + + DoCast(SPELL_BONE_ARMOR); } - void EnterCombat(Unit* /*who*/){} - void DamageTaken(Unit* done_by, uint32 &damage) + void DamageTaken(Unit* /*done_by*/, uint32 &damage) { - if (done_by->GetGUID() == me->GetGUID()) - return; - if (damage >= me->GetHealth()) { - PretendToDie(); damage = 0; - } - } - void PretendToDie() - { - isDead = true; - me->InterruptNonMeleeSpells(true); - me->RemoveAllAuras(); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->GetMotionMaster()->MovementExpired(false); - me->GetMotionMaster()->MoveIdle(); - me->SetStandState(UNIT_STAND_STATE_DEAD); - }; + // There are some issues with pets + // they will still attack. I would say it is a PetAI bug + if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) + { + // from sniffs + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetFlag(UNIT_FIELD_BYTES_1, UNIT_STAND_STATE_DEAD); - void Resurrect() - { - isDead = false; - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->SetStandState(UNIT_STAND_STATE_STAND); - DoCast(me, SPELL_SCOURGE_RESSURRECTION, true); + events.Reset(); + events.ScheduleEvent(EVENT_RESURRECT, urand(18,22)*IN_MILLISECONDS); - if (me->getVictim()) - { - me->GetMotionMaster()->MoveChase(me->getVictim()); - me->AI()->AttackStart(me->getVictim()); + me->GetMotionMaster()->MovementExpired(false); + me->GetMotionMaster()->MoveIdle(); + } } - else - me->GetMotionMaster()->Initialize(); - }; + } void UpdateAI(const uint32 diff) { - if (instance && instance->GetData(DATA_PRINCEKELESETH_EVENT) == IN_PROGRESS) + if (!UpdateVictim()) + return; + + events.Update(diff); + + if (me->HasUnitState(UNIT_STAT_CASTING)) + return; + + while (uint32 eventId = events.ExecuteEvent()) { - if (isDead) + switch (eventId) { - if (Respawn_Time <= diff) - { - Resurrect(); - Respawn_Time = 12000; - } else Respawn_Time -= diff; + case EVENT_DECREPIFY: + DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, -SPELL_DECREPIFY), SPELL_DECREPIFY); + events.ScheduleEvent(EVENT_DECREPIFY, urand(1,5)*IN_MILLISECONDS); + break; + case EVENT_RESURRECT: + events.ScheduleEvent(EVENT_FULL_HEAL, 1*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SHADOW_FISSURE, 1*IN_MILLISECONDS); + break; + case EVENT_FULL_HEAL: + DoCast(me, SPELL_FULL_HEAL, true); + break; + case EVENT_SHADOW_FISSURE: + DoCast(me, SPELL_SHADOW_FISSURE, true); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->RemoveFlag(UNIT_FIELD_BYTES_1, UNIT_STAND_STATE_DEAD); + me->GetMotionMaster()->MoveChase(me->getVictim()); + events.ScheduleEvent(EVENT_DECREPIFY, urand(4,6)*IN_MILLISECONDS); + break; } - else - { - if (!UpdateVictim()) - return; + } - if (Decrepify_Timer <= diff) - { - DoCast(me->getVictim(), SPELL_DECREPIFY); - Decrepify_Timer = 30000; - } else Decrepify_Timer -= diff; + if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) + DoMeleeAttackIfReady(); + } - DoMeleeAttackIfReady(); - } - }else + private: + EventMap events; + }; +}; + +class spell_frost_tomb : public SpellScriptLoader +{ + public: + spell_frost_tomb() : SpellScriptLoader("spell_frost_tomb") {} + + class spell_frost_tomb_AuraScript : public AuraScript + { + PrepareAuraScript(spell_frost_tomb_AuraScript); + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - if (me->isAlive()) - me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEATH) + if (Unit* caster = GetCaster()) + if (caster->ToCreature() && caster->isAlive()) + caster->ToCreature()->DespawnOrUnsummon(); } + void Register() + { + AfterEffectRemove += AuraEffectRemoveFn(spell_frost_tomb_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_frost_tomb_AuraScript(); } - }; +}; + +class achievement_on_the_rocks : public AchievementCriteriaScript +{ + public: + achievement_on_the_rocks() : AchievementCriteriaScript("achievement_on_the_rocks") {} + + bool OnCheck(Player* source, Unit* target) + { + if (!source->GetMap()->IsHeroic()) + return false; + + if (Creature* boss = target->ToCreature()) + if (boss->AI()) + return boss->AI()->GetData(DATA_ON_THE_ROCKS); + + return false; + } }; void AddSC_boss_keleseth() { new boss_keleseth(); - new mob_frost_tomb(); - new mob_vrykul_skeleton(); + new npc_frost_tomb(); + new npc_vrykul_skeleton(); + new spell_frost_tomb(); + new achievement_on_the_rocks(); } -- cgit v1.2.3 From e6d5b21778762fec1ae21d3ce093102373cc8ec5 Mon Sep 17 00:00:00 2001 From: click Date: Tue, 24 Jan 2012 00:24:39 +0100 Subject: Core: Fix non-PCH build and remove a few warnings. --- src/server/game/AI/CoreAI/GameObjectAI.h | 2 +- src/server/game/Entities/Player/Player.cpp | 2 +- src/server/game/Entities/Player/Player.h | 2 +- .../game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp | 1 + .../game/Movement/MovementGenerators/PointMovementGenerator.cpp | 1 + .../game/Movement/MovementGenerators/TargetedMovementGenerator.cpp | 1 + .../game/Movement/MovementGenerators/TargetedMovementGenerator.h | 1 + src/server/scripts/Commands/cs_reload.cpp | 2 +- .../scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp | 6 +++--- .../Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp | 3 +++ src/server/shared/Cryptography/HMACSHA1.cpp | 1 + 11 files changed, 15 insertions(+), 7 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/game/AI/CoreAI/GameObjectAI.h b/src/server/game/AI/CoreAI/GameObjectAI.h index bfdd887de3e..b9d385ba675 100644 --- a/src/server/game/AI/CoreAI/GameObjectAI.h +++ b/src/server/game/AI/CoreAI/GameObjectAI.h @@ -50,7 +50,7 @@ class GameObjectAI virtual void Destroyed(Player* /*player*/, uint32 /*eventId*/) {} virtual void SetData(uint32 /*id*/, uint32 /*value*/) {} virtual void OnGameEvent(bool /*start*/, uint16 /*eventId*/) {} - virtual void OnStateChanged(uint32 state, Unit* unit) { } + virtual void OnStateChanged(uint32 /*state*/, Unit* /*unit*/) { } }; class NullGameObjectAI : public GameObjectAI diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 00fbab8ceb3..44186dad95c 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -305,7 +305,7 @@ bool TradeData::HasItem(uint64 itemGuid) const return false; } -TradeSlots const TradeData::GetTradeSlotForItem(uint64 itemGuid) +TradeSlots TradeData::GetTradeSlotForItem(uint64 itemGuid) const { for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i) if (m_items[i] == itemGuid) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index fccd380bd29..c39d29db12a 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1003,7 +1003,7 @@ class TradeData Item* GetItem(TradeSlots slot) const; bool HasItem(uint64 itemGuid) const; - TradeSlots const GetTradeSlotForItem(uint64 itemGuid); + TradeSlots GetTradeSlotForItem(uint64 itemGuid) const; void SetItem(TradeSlots slot, Item* item); uint32 GetSpell() const { return m_spell; } diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp index ac09f2d403a..94608d85420 100755 --- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp @@ -22,6 +22,7 @@ #include "VMapFactory.h" #include "MoveSplineInit.h" #include "MoveSpline.h" +#include "Player.h" #ifdef MAP_BASED_RAND_GEN #define rand_norm() unit.rand_norm() diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp index 505615c07b8..88465017dc2 100755 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp @@ -23,6 +23,7 @@ #include "World.h" #include "MoveSplineInit.h" #include "MoveSpline.h" +#include "Player.h" //----- Point Movement Generator template diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index b03e13f91f4..0d2982ab6b7 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -24,6 +24,7 @@ #include "World.h" #include "MoveSplineInit.h" #include "MoveSpline.h" +#include "Player.h" #include diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h index 982f7fc875c..696c99e1460 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h @@ -22,6 +22,7 @@ #include "MovementGenerator.h" #include "FollowerReference.h" #include "Timer.h" +#include "Unit.h" class TargetedMovementGeneratorBase { diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index 35b590fe404..363f7645f6f 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -992,7 +992,7 @@ public: return true; } - static bool HandleReloadWpCommand(ChatHandler* handler, const char* args) + static bool HandleReloadWpCommand(ChatHandler* /*handler*/, const char* args) { if (*args != 'a') sLog->outString("Re-Loading Waypoints data from 'waypoints_data'"); diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp index 542243293de..5c1ec15030c 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp @@ -276,7 +276,7 @@ public: me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); } - void JustDied(Unit* killer) + void JustDied(Unit* /*killer*/) { summons.DespawnAll(); @@ -285,8 +285,8 @@ public: Talk(SAY_DEATH); } - - void SpellHitTarget(Unit* target, const SpellInfo* spell) + + void SpellHitTarget(Unit* /*target*/, const SpellInfo* spell) { if (spell->Id == SPELL_RITUAL_STRIKE_EFF_1 && Phase != NORMAL && Phase != SVALADEAD) { diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp index 070c107e61d..ed818fb13be 100644 --- a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp @@ -17,6 +17,9 @@ //! TODO - Boss not scripted, just ported required spellscript from core +#include "ScriptMgr.h" +#include "SpellScript.h" + enum Spells { SPELL_POSITIVE_CHARGE = 39090, diff --git a/src/server/shared/Cryptography/HMACSHA1.cpp b/src/server/shared/Cryptography/HMACSHA1.cpp index 3f21aa4582d..447d0b58efc 100755 --- a/src/server/shared/Cryptography/HMACSHA1.cpp +++ b/src/server/shared/Cryptography/HMACSHA1.cpp @@ -18,6 +18,7 @@ #include "HMACSHA1.h" #include "BigNumber.h" +#include "Common.h" HmacHash::HmacHash(uint32 len, uint8 *seed) { -- cgit v1.2.3 From 78ede251b05c4e9a4fa6c21dfd0bc65892d3788a Mon Sep 17 00:00:00 2001 From: Manuel Carrasco Date: Mon, 23 Jan 2012 23:15:57 -0300 Subject: Scripts/UK: Improvements to my last commit. Thanks to Vincent-Michael --- .../world/2012_01_23_06_world_achievement_criteria_data.sql | 3 +++ sql/updates/world/2012_01_23_07_world_creature_text.sql | 5 +++++ .../Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp | 13 +++---------- 3 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 sql/updates/world/2012_01_23_06_world_achievement_criteria_data.sql create mode 100644 sql/updates/world/2012_01_23_07_world_creature_text.sql (limited to 'src/server/scripts/Northrend') diff --git a/sql/updates/world/2012_01_23_06_world_achievement_criteria_data.sql b/sql/updates/world/2012_01_23_06_world_achievement_criteria_data.sql new file mode 100644 index 00000000000..33899c3f512 --- /dev/null +++ b/sql/updates/world/2012_01_23_06_world_achievement_criteria_data.sql @@ -0,0 +1,3 @@ +DELETE FROM `achievement_criteria_data` WHERE `criteria_id`=7231 AND `type`=12; +INSERT INTO `achievement_criteria_data` (`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES +(7231,12,1,0,''); diff --git a/sql/updates/world/2012_01_23_07_world_creature_text.sql b/sql/updates/world/2012_01_23_07_world_creature_text.sql new file mode 100644 index 00000000000..90ac11e363c --- /dev/null +++ b/sql/updates/world/2012_01_23_07_world_creature_text.sql @@ -0,0 +1,5 @@ +UPDATE `creature_text` SET `comment`='Prince Keleseth - SAY_DEATH' WHERE `groupid`=5 AND `entry`=23953; +UPDATE `creature_text` SET `comment`='Prince Keleseth - SAY_FROST_TOMB_EMOTE' WHERE `groupid`=4 AND `entry`=23953; +UPDATE `creature_text` SET `comment`='Prince Keleseth - SAY_FROST_TOMB' WHERE `groupid`=3 AND `entry`=23953; +UPDATE `creature_text` SET `comment`='Prince Keleseth - SAY_SUMMON_SKELETONS' WHERE `groupid`=2 AND `entry`=23953; +UPDATE `creature_text` SET `comment`='Prince Keleseth - SAY_START_COMBAT' WHERE `groupid`=1 AND `entry`=23953; diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp index 639d1852c15..ea54fc16095 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp @@ -60,7 +60,7 @@ enum KelsethEncounter #define SKELETONSPAWN_Z 42.8668f -const float SkeletonSpawnPoint[1][2] = +float const SkeletonSpawnPoint[1][2] = { {156.2559f, 259.2093f}, }; @@ -323,16 +323,9 @@ class achievement_on_the_rocks : public AchievementCriteriaScript public: achievement_on_the_rocks() : AchievementCriteriaScript("achievement_on_the_rocks") {} - bool OnCheck(Player* source, Unit* target) + bool OnCheck(Player* /*source*/, Unit* target) { - if (!source->GetMap()->IsHeroic()) - return false; - - if (Creature* boss = target->ToCreature()) - if (boss->AI()) - return boss->AI()->GetData(DATA_ON_THE_ROCKS); - - return false; + return target && target->IsAIEnabled && target->GetAI()->GetData(DATA_ON_THE_ROCKS); } }; -- cgit v1.2.3 From e552b1744c28fb80b90eb29246682787974f0f6e Mon Sep 17 00:00:00 2001 From: Souler Date: Tue, 24 Jan 2012 15:12:47 +0100 Subject: DB/Conditions: Convert Dame Evniki Kapsalis script into conditions DB/SAI: Convert Priestess Alorah and Grimmin scripts into SmartAI --- sql/updates/world/2012_01_24_00_world_misc.sql | 18 +++++ src/server/scripts/Northrend/icecrown.cpp | 93 -------------------------- 2 files changed, 18 insertions(+), 93 deletions(-) create mode 100644 sql/updates/world/2012_01_24_00_world_misc.sql (limited to 'src/server/scripts/Northrend') diff --git a/sql/updates/world/2012_01_24_00_world_misc.sql b/sql/updates/world/2012_01_24_00_world_misc.sql new file mode 100644 index 00000000000..b66a0bd91ca --- /dev/null +++ b/sql/updates/world/2012_01_24_00_world_misc.sql @@ -0,0 +1,18 @@ +-- Make Dame Evniki Kapsalis show vendor gossip option only to players with Crusader title +UPDATE `creature_template` SET `AIName` = 'SmartAI',`ScriptName` = '' WHERE `entry` = 34885; +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=10598; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`ErrorTextId`,`ScriptName`,`COMMENT`) VALUES +(15,10598,0,0,17,2816,0,0,0,'',"Evniki Kapsalis should only sell to Crusaders"), +(15,10598,0,1,17,2817,0,0,0,'',"Evniki Kapsalis should only sell to Crusaders"); + +SET @SPELL_CHAIN = 68341; +SET @NPC_FJOLA_LIGHTBANE = 36065; +SET @NPC_EYDIS_DARKBANE = 36066; +SET @NPC_PRIESTESS_ALORAH = 36101; +SET @NPC_PRIEST_GRIMMIN = 36102; + +UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE `entry` IN(@NPC_PRIESTESS_ALORAH,@NPC_PRIEST_GRIMMIN); +DELETE FROM `smart_scripts` WHERE (`entryorguid` IN(@NPC_PRIESTESS_ALORAH,@NPC_PRIEST_GRIMMIN) AND `source_type`=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`,`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 +(@NPC_PRIESTESS_ALORAH,0,0,0,1,0,100,1,100,100,0,0,11,@SPELL_CHAIN,0,0,0,0,0,19,@NPC_EYDIS_DARKBANE,0,0,0,0,0,0,'Priestess Alorah - Cast chain on Eydis Darkbane'), +(@NPC_PRIEST_GRIMMIN,0,0,0,1,0,100,1,100,100,0,0,11,@SPELL_CHAIN,0,0,0,0,0,19,@NPC_FJOLA_LIGHTBANE,0,0,0,0,0,0,'Priestess Grimmin - Cast chain on Fjola Lightbane'); \ No newline at end of file diff --git a/src/server/scripts/Northrend/icecrown.cpp b/src/server/scripts/Northrend/icecrown.cpp index 28384455616..91522503d65 100644 --- a/src/server/scripts/Northrend/icecrown.cpp +++ b/src/server/scripts/Northrend/icecrown.cpp @@ -114,38 +114,6 @@ public: } }; -/*###### -## npc_dame_evniki_kapsalis -######*/ - -enum eDameEnvikiKapsalis -{ - TITLE_CRUSADER = 123 -}; - -class npc_dame_evniki_kapsalis : public CreatureScript -{ -public: - npc_dame_evniki_kapsalis() : CreatureScript("npc_dame_evniki_kapsalis") { } - - bool OnGossipHello(Player* player, Creature* creature) - { - if (player->HasTitle(TITLE_CRUSADER)) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - - player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); - return true; - } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction) - { - player->PlayerTalkClass->ClearMenus(); - if (uiAction == GOSSIP_ACTION_TRADE) - player->GetSession()->SendListInventory(creature->GetGUID()); - return true; - } -}; - /*###### ## npc_squire_david ######*/ @@ -275,65 +243,6 @@ public: } }; -/*###### -## npc_alorah_and_grimmin -######*/ - -enum ealorah_and_grimmin -{ - SPELL_CHAIN = 68341, - NPC_FJOLA_LIGHTBANE = 36065, - NPC_EYDIS_DARKBANE = 36066, - NPC_PRIESTESS_ALORAH = 36101, - NPC_PRIEST_GRIMMIN = 36102 -}; - -class npc_alorah_and_grimmin : public CreatureScript -{ -public: - npc_alorah_and_grimmin() : CreatureScript("npc_alorah_and_grimmin") { } - - struct npc_alorah_and_grimminAI : public ScriptedAI - { - npc_alorah_and_grimminAI(Creature* creature) : ScriptedAI(creature) {} - - bool uiCast; - - void Reset() - { - uiCast = false; - } - - void UpdateAI(const uint32 /*uiDiff*/) - { - if (uiCast) - return; - uiCast = true; - Creature* target = NULL; - - switch (me->GetEntry()) - { - case NPC_PRIESTESS_ALORAH: - target = me->FindNearestCreature(NPC_EYDIS_DARKBANE, 10.0f); - break; - case NPC_PRIEST_GRIMMIN: - target = me->FindNearestCreature(NPC_FJOLA_LIGHTBANE, 10.0f); - break; - } - if (target) - DoCast(target, SPELL_CHAIN); - - if (!UpdateVictim()) - return; - } - }; - - CreatureAI* GetAI(Creature* creature) const - { - return new npc_alorah_and_grimminAI(creature); - } -}; - /*###### ## npc_guardian_pavilion ######*/ @@ -429,10 +338,8 @@ public: void AddSC_icecrown() { new npc_arete; - new npc_dame_evniki_kapsalis; new npc_squire_david; new npc_argent_valiant; - new npc_alorah_and_grimmin; new npc_guardian_pavilion; new npc_vereth_the_cunning; } -- cgit v1.2.3 From 83c85a2f07cfdc10ee90f5cb2744057efc4a3262 Mon Sep 17 00:00:00 2001 From: Shocker Date: Fri, 27 Jan 2012 02:24:48 +0200 Subject: Scripts/Utgarde Keep: Fix possible crsah in Ingvar code --- .../Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp index 1ab95c53500..d2133a78bc9 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp @@ -391,7 +391,8 @@ public: ingvar->RemoveAurasDueToSpell(SPELL_SCOURG_RESURRECTION_DUMMY); if (boss_ingvar_the_plunderer::boss_ingvar_the_plundererAI* pAI = CAST_AI(boss_ingvar_the_plunderer::boss_ingvar_the_plundererAI, ingvar->AI())) - pAI->StartZombiePhase(); + if (ingvar->getVictim()) + pAI->StartZombiePhase(); me->GetMotionMaster()->MovePoint(2, x+1, y, z+30); ++uiResurectPhase; -- cgit v1.2.3 From ac40323ea0036dbb2643d4a9f21e5b4c2e8bfbee Mon Sep 17 00:00:00 2001 From: Manuel Carrasco Date: Fri, 27 Jan 2012 13:07:40 -0300 Subject: Scripts/UK: Fixed crash. A better way must be implemented if there is any. --- src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp index ea54fc16095..94a133c78a6 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp @@ -302,7 +302,7 @@ class spell_frost_tomb : public SpellScriptLoader if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEATH) if (Unit* caster = GetCaster()) if (caster->ToCreature() && caster->isAlive()) - caster->ToCreature()->DespawnOrUnsummon(); + caster->ToCreature()->DespawnOrUnsummon(1000); } void Register() -- cgit v1.2.3 From fa384665af344d79824bc454d6bdd75d25977ba0 Mon Sep 17 00:00:00 2001 From: LiMCrosS Date: Sat, 28 Jan 2012 19:27:52 -0200 Subject: ICC/Sindragosa: POINT_FROSTWYRM_LAND now is EFFECT_MOTION_TYPE --- src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 11100e6297e..3d3eaa1cc87 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -646,7 +646,7 @@ class npc_spinestalker : public CreatureScript void MovementInform(uint32 type, uint32 point) { - if (type != POINT_MOTION_TYPE || point != POINT_FROSTWYRM_LAND) + if (type != EFFECT_MOTION_TYPE || point != POINT_FROSTWYRM_LAND) return; me->setActive(false); @@ -761,7 +761,7 @@ class npc_rimefang : public CreatureScript void MovementInform(uint32 type, uint32 point) { - if (type != POINT_MOTION_TYPE || point != POINT_FROSTWYRM_LAND) + if (type != EFFECT_MOTION_TYPE || point != POINT_FROSTWYRM_LAND) return; me->setActive(false); -- cgit v1.2.3 From 5ceae46302b1b601927b50f3ea973941cd8938d0 Mon Sep 17 00:00:00 2001 From: Nay Date: Sun, 29 Jan 2012 01:48:36 +0000 Subject: Core/Scripts: Rename pAI to ai --- .../CullingOfStratholme/culling_of_stratholme.cpp | 40 +++++++++++----------- .../UtgardeKeep/boss_ingvar_the_plunderer.cpp | 6 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp index ad0a36da84e..6cdb794bf5e 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp @@ -234,53 +234,53 @@ public: bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) { player->PlayerTalkClass->ClearMenus(); - npc_arthasAI* pAI = CAST_AI(npc_arthas::npc_arthasAI, creature->AI()); + npc_arthasAI* ai = CAST_AI(npc_arthas::npc_arthasAI, creature->AI()); - if (!pAI) + if (!ai) return false; switch (action) { case GOSSIP_ACTION_INFO_DEF: - pAI->Start(true, true, player->GetGUID(), 0, false, false); - pAI->SetDespawnAtEnd(false); - pAI->bStepping = false; - pAI->uiStep = 1; + ai->Start(true, true, player->GetGUID(), 0, false, false); + ai->SetDespawnAtEnd(false); + ai->bStepping = false; + ai->uiStep = 1; break; case GOSSIP_ACTION_INFO_DEF+1: - pAI->bStepping = true; - pAI->uiStep = 24; + ai->bStepping = true; + ai->uiStep = 24; break; case GOSSIP_ACTION_INFO_DEF+2: - pAI->SetHoldState(false); - pAI->bStepping = false; - pAI->uiStep = 61; + ai->SetHoldState(false); + ai->bStepping = false; + ai->uiStep = 61; break; case GOSSIP_ACTION_INFO_DEF+3: - pAI->SetHoldState(false); + ai->SetHoldState(false); break; case GOSSIP_ACTION_INFO_DEF+4: - pAI->bStepping = true; - pAI->uiStep = 84; + ai->bStepping = true; + ai->uiStep = 84; break; case GOSSIP_ACTION_INFO_DEF+5: - pAI->bStepping = true; - pAI->uiStep = 85; + ai->bStepping = true; + ai->uiStep = 85; break; } player->CLOSE_GOSSIP_MENU(); - pAI->SetDespawnAtFar(true); + ai->SetDespawnAtFar(true); creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); return true; } bool OnGossipHello(Player* player, Creature* creature) { - npc_arthasAI* pAI = CAST_AI(npc_arthas::npc_arthasAI, creature->AI()); + npc_arthasAI* ai = CAST_AI(npc_arthas::npc_arthasAI, creature->AI()); - if (pAI && pAI->bStepping == false) + if (ai && ai->bStepping == false) { - switch (pAI->uiGossipStep) + switch (ai->uiGossipStep) { case 0: //This one is a workaround since the very beggining of the script is wrong. { diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp index d2133a78bc9..0c59097a9ec 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp @@ -390,9 +390,9 @@ public: { ingvar->RemoveAurasDueToSpell(SPELL_SCOURG_RESURRECTION_DUMMY); - if (boss_ingvar_the_plunderer::boss_ingvar_the_plundererAI* pAI = CAST_AI(boss_ingvar_the_plunderer::boss_ingvar_the_plundererAI, ingvar->AI())) - if (ingvar->getVictim()) - pAI->StartZombiePhase(); + if (ingvar->getVictim()) + if (boss_ingvar_the_plunderer::boss_ingvar_the_plundererAI* ai = CAST_AI(boss_ingvar_the_plunderer::boss_ingvar_the_plundererAI, ingvar->AI())) + ai->StartZombiePhase(); me->GetMotionMaster()->MovePoint(2, x+1, y, z+30); ++uiResurectPhase; -- cgit v1.2.3 From 83e0486e59ddf17ef8abc83b57ff459f8b9e1e9c Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 30 Jan 2012 12:31:59 +0100 Subject: Scripts/Icecrown Citadel: Professor Putricide will now remove Mutated Plague from players when dying --- .../world/2012_01_30_01_world_conditions.sql | 3 +++ .../2012_01_30_01_world_spell_script_names.sql | 3 +++ .../IcecrownCitadel/boss_professor_putricide.cpp | 31 ++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 sql/updates/world/2012_01_30_01_world_conditions.sql create mode 100644 sql/updates/world/2012_01_30_01_world_spell_script_names.sql (limited to 'src/server/scripts/Northrend') diff --git a/sql/updates/world/2012_01_30_01_world_conditions.sql b/sql/updates/world/2012_01_30_01_world_conditions.sql new file mode 100644 index 00000000000..bcaf0af435a --- /dev/null +++ b/sql/updates/world/2012_01_30_01_world_conditions.sql @@ -0,0 +1,3 @@ +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceEntry`=72618; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES +(13,0,72618,0,0,18,1,0,0,0, '', 'Mutated Plague Clear - target players'); diff --git a/sql/updates/world/2012_01_30_01_world_spell_script_names.sql b/sql/updates/world/2012_01_30_01_world_spell_script_names.sql new file mode 100644 index 00000000000..6e4b10094e5 --- /dev/null +++ b/sql/updates/world/2012_01_30_01_world_spell_script_names.sql @@ -0,0 +1,3 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_putricide_clear_mutated_plague'; +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(72618,'spell_putricide_clear_mutated_plague'); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index 0d3640504c1..cf22338995b 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -75,6 +75,7 @@ enum Spells SPELL_PLAGUE_SICKNESS = 70953, SPELL_UNBOUND_PLAGUE_PROTECTION = 70955, SPELL_MUTATED_PLAGUE = 72451, + SPELL_MUTATED_PLAGUE_CLEAR = 72618, // Slime Puddle SPELL_GROW_STACKER = 70345, @@ -244,6 +245,7 @@ class boss_professor_putricide : public CreatureScript { _JustDied(); Talk(SAY_DEATH); + DoCast(SPELL_MUTATED_PLAGUE_CLEAR); } void JustSummoned(Creature* summon) @@ -1427,6 +1429,34 @@ class spell_putricide_regurgitated_ooze : public SpellScriptLoader } }; +class spell_putricide_clear_mutated_plague : public SpellScriptLoader +{ + public: + spell_putricide_clear_mutated_plague() : SpellScriptLoader("spell_putricide_clear_mutated_plague") { } + + class spell_putricide_clear_mutated_plague_SpellScript : public SpellScript + { + PrepareSpellScript(spell_putricide_clear_mutated_plague_SpellScript); + + void HandleScript(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + uint32 auraId = sSpellMgr->GetSpellIdForDifficulty(uint32(GetEffectValue()), GetCaster()); + GetHitUnit()->RemoveAurasDueToSpell(auraId); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_putricide_clear_mutated_plague_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_putricide_clear_mutated_plague_SpellScript(); + } +}; + // Stinky and Precious spell, it's here because its used for both (Festergut and Rotface "pets") class spell_stinky_precious_decimate : public SpellScriptLoader { @@ -1478,5 +1508,6 @@ void AddSC_boss_professor_putricide() new spell_putricide_mutated_transformation(); new spell_putricide_mutated_transformation_dmg(); new spell_putricide_regurgitated_ooze(); + new spell_putricide_clear_mutated_plague(); new spell_stinky_precious_decimate(); } -- cgit v1.2.3