From bc1a69caa390db728889e78ed0da5c800f6a44ac Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Tue, 21 Apr 2020 13:34:23 +0200 Subject: [PATCH] Core/Spells: fixed Guild Battle Standard buff effects --- .../world/4.3.4/2020_04_21_01_world.sql | 63 ++++++++++ src/server/scripts/Spells/spell_generic.cpp | 113 ++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 sql/updates/world/4.3.4/2020_04_21_01_world.sql diff --git a/sql/updates/world/4.3.4/2020_04_21_01_world.sql b/sql/updates/world/4.3.4/2020_04_21_01_world.sql new file mode 100644 index 00000000000..687f7ed9355 --- /dev/null +++ b/sql/updates/world/4.3.4/2020_04_21_01_world.sql @@ -0,0 +1,63 @@ +UPDATE `creature_template` SET `unit_flags`= 0x8 | 0x100 | 0x200 WHERE `entry` IN (48115, 48633, 48634, 48636, 48637, 48638); +DELETE FROM `creature_template_movement` WHERE `CreatureId` IN (48115, 48633, 48634, 48636, 48637, 48638); +INSERT INTO `creature_template_movement` (`CreatureId`, `Ground`, `Swim`, `Flight`, `Rooted`, `Random`) VALUES +(48115, 0, 0, 1, 1, 0), +(48633, 0, 0, 1, 1, 0), +(48634, 0, 0, 1, 1, 0), +(48636, 0, 0, 1, 1, 0), +(48637, 0, 0, 1, 1, 0), +(48638, 0, 0, 1, 1, 0); + +DELETE FROM `creature_template_addon` WHERE `entry` IN (48115, 48633, 48634, 48636, 48637, 48638); +INSERT INTO `creature_template_addon` (`entry`, `bytes2`, `auras`) VALUES +(48115, 1, '89481'), +(48633, 1, '89481'), +(48634, 1, '89481'), +(48636, 1, '89481'), +(48637, 1, '89481'), +(48638, 1, '89481'); + +DELETE FROM `spell_script_names` WHERE `ScriptName` IN +('spell_gen_guild_battle_standard', +'spell_gen_guild_battle_standard_buff'); + +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(89481, 'spell_gen_guild_battle_standard'), +(90216, 'spell_gen_guild_battle_standard_buff'), +(90708, 'spell_gen_guild_battle_standard_buff'); + +SET @ENTRY := 48115; +UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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 +(@ENTRY, 0, 0, 0, 60, 0, 100, 1, 1, 1, 0, 0, 11, 23235, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ""); + +SET @ENTRY := 48633; +UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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 +(@ENTRY, 0, 0, 0, 60, 0, 100, 1, 1, 1, 0, 0, 11, 23235, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ""); + +SET @ENTRY := 48634; +UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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 +(@ENTRY, 0, 0, 0, 60, 0, 100, 1, 1, 1, 0, 0, 11, 23235, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ""); + +SET @ENTRY := 48636; +UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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 +(@ENTRY, 0, 0, 0, 60, 0, 100, 1, 1, 1, 0, 0, 11, 23235, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ""); + +SET @ENTRY := 48637; +UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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 +(@ENTRY, 0, 0, 0, 60, 0, 100, 1, 1, 1, 0, 0, 11, 23235, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ""); + +SET @ENTRY := 48638; +UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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 +(@ENTRY, 0, 0, 0, 60, 0, 100, 1, 1, 1, 0, 0, 11, 23235, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ""); diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 06eef63177b..a71d0147570 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -5155,6 +5155,117 @@ class spell_gen_sunflower_dnd : public AuraScript } }; +enum GuildBattleStandard +{ + // Spells + SPELL_GUILD_BATTLE_STANDARD_ALLIANCE = 90216, + SPELL_GUILD_BATTLE_STANDARD_HORDE = 90708, + + // Creatures + NPC_GUILD_BATTLE_STANDARD_ALLIANCE_1 = 48115, + NPC_GUILD_BATTLE_STANDARD_ALLIANCE_2 = 48633, + NPC_GUILD_BATTLE_STANDARD_ALLIANCE_3 = 48634, + NPC_GUILD_BATTLE_STANDARD_HORDE_1 = 48636, + NPC_GUILD_BATTLE_STANDARD_HORDE_2 = 48637, + NPC_GUILD_BATTLE_STANDARD_HORDE_3 = 48638 +}; + +// 89481 - Guild Battle Standard +class spell_gen_guild_battle_standard : public AuraScript +{ + PrepareAuraScript(spell_gen_guild_battle_standard); + + bool Load() override + { + return GetCaster()->IsCreature(); + } + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo( + { + SPELL_GUILD_BATTLE_STANDARD_ALLIANCE, + SPELL_GUILD_BATTLE_STANDARD_HORDE + }); + } + + void HandlePeriodic(AuraEffect const* aurEff) + { + int32 bp = 0; + uint32 spellId = 0; + + Unit* target = GetTarget(); + switch (target->GetEntry()) + { + case NPC_GUILD_BATTLE_STANDARD_ALLIANCE_1: + bp = 5; + spellId = SPELL_GUILD_BATTLE_STANDARD_ALLIANCE; + break; + case NPC_GUILD_BATTLE_STANDARD_ALLIANCE_2: + bp = 10; + spellId = SPELL_GUILD_BATTLE_STANDARD_ALLIANCE; + break; + case NPC_GUILD_BATTLE_STANDARD_ALLIANCE_3: + bp = 15; + spellId = SPELL_GUILD_BATTLE_STANDARD_ALLIANCE; + break; + case NPC_GUILD_BATTLE_STANDARD_HORDE_1: + bp = 5; + spellId = SPELL_GUILD_BATTLE_STANDARD_HORDE; + break; + case NPC_GUILD_BATTLE_STANDARD_HORDE_2: + bp = 10; + spellId = SPELL_GUILD_BATTLE_STANDARD_HORDE; + break; + case NPC_GUILD_BATTLE_STANDARD_HORDE_3: + bp = 15; + spellId = SPELL_GUILD_BATTLE_STANDARD_HORDE; + break; + default: + break; + } + + if (spellId) + target->CastCustomSpell(target, spellId, &bp, &bp, &bp, true, nullptr, aurEff); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_guild_battle_standard::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } +}; + +// 90216 - Guild Battle Standard +// 90708 - Guild Battle Standard +class spell_gen_guild_battle_standard_buff : public SpellScript +{ + PrepareSpellScript(spell_gen_guild_battle_standard_buff); + + bool Load() override + { + return GetCaster()->IsSummon(); + } + + void FilterTargets(std::list& targets) + { + TempSummon* summon = GetCaster()->ToTempSummon(); + Unit* summoner = summon->GetSummoner(); + if (Player* player = summoner->ToPlayer()) + { + uint32 guildId = player->GetGuildId(); + targets.remove_if([guildId](WorldObject* target)->bool + { + return !target->IsPlayer() || target->ToPlayer()->GetGuildId() != guildId; + }); + } + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_gen_guild_battle_standard_buff::FilterTargets, EFFECT_ALL, TARGET_UNIT_SRC_AREA_ALLY); + } +}; + void AddSC_generic_spell_scripts() { new spell_gen_absorb0_hitlimit1(); @@ -5278,4 +5389,6 @@ void AddSC_generic_spell_scripts() RegisterSpellScript(spell_gen_launch_quest); RegisterSpellScript(spell_gen_charmed_unit_spell_cooldown); RegisterAuraScript(spell_gen_sunflower_dnd); + RegisterAuraScript(spell_gen_guild_battle_standard); + RegisterSpellScript(spell_gen_guild_battle_standard_buff); }