diff options
-rw-r--r-- | sql/FULL/world_scripts_full.sql | 3 | ||||
-rw-r--r-- | sql/FULL/world_spell_full.sql | 5 | ||||
-rw-r--r-- | sql/updates/5175_world_scripts_dk.sql | 10 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/the_scarlet_enclave.cpp | 53 | ||||
-rw-r--r-- | src/game/Unit.cpp | 15 | ||||
-rw-r--r-- | src/game/UnitAI.cpp | 5 | ||||
-rw-r--r-- | src/game/UnitAI.h | 2 |
7 files changed, 89 insertions, 4 deletions
diff --git a/sql/FULL/world_scripts_full.sql b/sql/FULL/world_scripts_full.sql index b26a1c83536..0c22ae65a8c 100644 --- a/sql/FULL/world_scripts_full.sql +++ b/sql/FULL/world_scripts_full.sql @@ -117,6 +117,9 @@ UPDATE `creature_template` SET `ScriptName`='npc_scarlet_miner' WHERE (`entry`=' UPDATE `creature_template` SET `ScriptName`='npc_crusade_persuaded' WHERE `entry` IN (28939,28940,28610); UPDATE `creature_template` SET `ScriptName`='mob_scarlet_courier' WHERE `entry`='29076'; +update creature_template set scriptname="mob_anti_air" where entry in (29102,29103,29104); + + /* */ /* ZONE */ diff --git a/sql/FULL/world_spell_full.sql b/sql/FULL/world_spell_full.sql index f7bd1efbccd..11380f04afd 100644 --- a/sql/FULL/world_spell_full.sql +++ b/sql/FULL/world_spell_full.sql @@ -1984,7 +1984,8 @@ INSERT INTO `spell_script_target` (`entry`, `type`, `targetEntry`) VALUES (52479, 1, 28822), (52576, 1, 28834), -- Electro-magnetic Pulse (52576, 1, 28886), -(53110, 1, 28940); -- Devour Humanoid +(53110, 1, 29102), +(53110, 1, 29103); -- Devour Humanoid -- Eye of Acherus DELETE FROM `spell_target_position` WHERE `id`=51852; @@ -2039,6 +2040,8 @@ UPDATE `quest_template` SET `PrevQuestId`=12751 WHERE `entry`=12754; update spell_area set quest_end = 12756 where spell=53081; +update creature_template set spell1=53117 where entry=29104; +update creature_template set spell1=53348,killcredit1=29150 where entry IN (29102,29103); -- -------- -- NAXXARAMAS diff --git a/sql/updates/5175_world_scripts_dk.sql b/sql/updates/5175_world_scripts_dk.sql new file mode 100644 index 00000000000..33f62d77f31 --- /dev/null +++ b/sql/updates/5175_world_scripts_dk.sql @@ -0,0 +1,10 @@ +update creature_template set spell1=53117 where entry=29104; +update creature_template set spell1=53348,killcredit1=29150 where entry IN (29102,29103); +update creature_template set scriptname="mob_anti_air" where entry in (29102,29103,29104); + + +DELETE FROM `spell_script_target` WHERE entry IN +(53110); +INSERT INTO `spell_script_target` (`entry`, `type`, `targetEntry`) VALUES +(53110, 1, 29102), +(53110, 1, 29103); -- Devour Humanoid diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/the_scarlet_enclave.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/the_scarlet_enclave.cpp index 0bc4966dc33..cfbc9bc0597 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/the_scarlet_enclave.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/the_scarlet_enclave.cpp @@ -100,6 +100,54 @@ CreatureAI* GetAI_npc_valkyr_battle_maiden(Creature* pCreature) return new npc_valkyr_battle_maidenAI (pCreature); } +struct TRINITY_DLL_DECL mob_anti_airAI : public ScriptedAI +{ + mob_anti_airAI(Creature *c) : ScriptedAI(c) + { + assert(me->m_spells[0]); + range = DoGetSpellMaxRange(me->m_spells[0]); + } + + float range; + + void MoveInLineOfSight(Unit *who) + { + if(!me->getVictim() && me->canAttack(who) + && me->IsWithinCombatRange(who, range) + && me->IsWithinLOSInMap(who)) + AttackStart(who); + } + + void AttackStart(Unit *who) + { + if(who->IsFlying() || !me->IsWithinMeleeRange(who)) + { + if(me->Attack(who, false)) + me->GetMotionMaster()->MoveIdle(); + } + else if(me->Attack(who, true)) + me->GetMotionMaster()->MoveChase(who); + } + + void UpdateAI(const uint32 diff) + { + if(!UpdateVictim()) + return; + + if(me->getVictim()->IsFlying() || !me->IsWithinMeleeRange(me->getVictim())) + { + if(!DoSpellAttackIfReady(me->m_spells[0])) + EnterEvadeMode(); + } + else + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_anti_air(Creature* pCreature) +{ + return new mob_anti_airAI (pCreature); +} void AddSC_the_scarlet_enclave() { @@ -109,4 +157,9 @@ void AddSC_the_scarlet_enclave() newscript->Name="npc_valkyr_battle_maiden"; newscript->GetAI = &GetAI_npc_valkyr_battle_maiden; newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="mob_anti_air"; + newscript->GetAI = &GetAI_mob_anti_air; + newscript->RegisterSelf(); } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 8053944f9ea..64fdc7d845d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8152,10 +8152,19 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) if (m_attacking == victim) { // switch to melee attack from ranged/magic - if( meleeAttack && !hasUnitState(UNIT_STAT_MELEE_ATTACKING) ) + if(meleeAttack) { - addUnitState(UNIT_STAT_MELEE_ATTACKING); - SendMeleeAttackStart(victim); + if(!hasUnitState(UNIT_STAT_MELEE_ATTACKING)) + { + addUnitState(UNIT_STAT_MELEE_ATTACKING); + SendMeleeAttackStart(victim); + return true; + } + } + else if(hasUnitState(UNIT_STAT_MELEE_ATTACKING)) + { + clearUnitState(UNIT_STAT_MELEE_ATTACKING); + SendMeleeAttackStop(victim); return true; } return false; diff --git a/src/game/UnitAI.cpp b/src/game/UnitAI.cpp index a41ad894097..0f00cd356f2 100644 --- a/src/game/UnitAI.cpp +++ b/src/game/UnitAI.cpp @@ -223,6 +223,11 @@ void UnitAI::SelectTargetList(std::list<Unit*> &targetList, uint32 num, SelectAg } } +float UnitAI::DoGetSpellMaxRange(uint32 spellId, bool positive) +{ + return GetSpellMaxRange(spellId, positive); +} + void UnitAI::DoCast(uint32 spellId) { Unit *target = NULL; diff --git a/src/game/UnitAI.h b/src/game/UnitAI.h index 784a453e970..a9afbb61b11 100644 --- a/src/game/UnitAI.h +++ b/src/game/UnitAI.h @@ -69,6 +69,8 @@ class TRINITY_DLL_SPEC UnitAI void DoCast(Unit* victim, uint32 spellId, bool triggered = false); void DoCastAOE(uint32 spellId, bool triggered = false); + float DoGetSpellMaxRange(uint32 spellId, bool positive = false); + void DoMeleeAttackIfReady(); bool DoSpellAttackIfReady(uint32 spell); |