Scripts/Instances/Underbog: Rework Hungarfen (#26567)

This commit is contained in:
offl
2021-06-09 19:16:55 +03:00
committed by GitHub
parent 9e7cdb02d2
commit 3d0a081f8e
3 changed files with 134 additions and 128 deletions

View File

@@ -0,0 +1,20 @@
--
UPDATE `creature_template` SET `speed_walk` = 1, `scale` = 1 WHERE `entry` IN (17990,20189);
UPDATE `creature_template` SET `speed_walk` = 1, `speed_run` = 1.57143 WHERE `entry` = 20169;
DELETE FROM `creature_text` WHERE `CreatureID` = 17770;
INSERT INTO `creature_text` (`CreatureID`,`GroupID`,`ID`,`Text`,`Type`,`Language`,`Probability`,`Emote`,`Duration`,`Sound`,`BroadcastTextId`,`TextRange`,`comment`) VALUES
(17770,0,0,"Hungarfen roars in pain. ",16,0,100,15,0,0,16594,0,"Hungarfen EMOTE_ROARS");
DELETE FROM `spell_scripts` WHERE `id` = 34874;
INSERT INTO `spell_scripts` (`id`,`effIndex`,`delay`,`command`,`datalong`,`datalong2`,`dataint`,`x`,`y`,`z`,`o`,`Comment`) VALUES
(34874,0,0,18,0,0,0,0,0,0,0,"Despawn Underbog Mushrooms - On Effect Hit (Script Effect) - Target - Despawn");
DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 13 AND `SourceEntry` = 34874;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorType`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
(13,1,34874,0,0,31,0,3,17990,0,0,0,0,"","Group 0: Spell 'Despawn Underbog Mushrooms' (Effect 0) targets creature 'Underbog Mushroom'");
-- Needed to prevent spell hit everything including boss and mushrooms, temp solution
DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 13 AND `SourceEntry` = 34168;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorType`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
(13,1,34168,0,0,31,0,3,17990,0,0,0,0,"","Group 0: Spell 'Spore Cloud' (Effect 0) targets creature 'Underbog Mushroom'");

View File

@@ -15,166 +15,150 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
SDName: Boss_Hungarfen
SD%Complete: 95
SDComment: Need confirmation if spell data are same in both modes. Summons should have faster rate in heroic
SDCategory: Coilfang Resevoir, Underbog
EndScriptData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellAuras.h"
#include "the_underbog.h"
enum Spells
enum HungarfenTexts
{
SPELL_FOUL_SPORES = 31673,
SPELL_ACID_GEYSER = 38739,
SPELL_SPORE_CLOUD = 34168,
SPELL_PUTRID_MUSHROOM = 31690,
SPELL_GROW = 31698
EMOTE_ROARS = 0
};
class boss_hungarfen : public CreatureScript
enum HungarfenSpells
{
public:
boss_hungarfen() : CreatureScript("boss_hungarfen") { }
SPELL_FOUL_SPORES = 31673,
SPELL_SUMMON_UNDERBOG_MUSHROOM = 31692,
SPELL_PUTRID_MUSHROOM_PRIMER = 31693,
SPELL_DESPAWN_UNDERBOG_MUSHROOMS = 34874,
SPELL_ACID_GEYSER = 38739,
CreatureAI* GetAI(Creature* creature) const override
SPELL_SPORE_CLOUD = 34168,
SPELL_PUTRID_MUSHROOM = 31690,
SPELL_SHRINK = 31691,
SPELL_GROW = 31698
};
struct boss_hungarfen : public ScriptedAI
{
boss_hungarfen(Creature* creature) : ScriptedAI(creature), _roared(false) { }
void Reset() override
{
return GetTheUnderbogAI<boss_hungarfenAI>(creature);
_scheduler.CancelAll();
_roared = false;
me->SetReactState(REACT_AGGRESSIVE);
}
struct boss_hungarfenAI : public ScriptedAI
void JustEngagedWith(Unit* /*who*/) override
{
boss_hungarfenAI(Creature* creature) : ScriptedAI(creature)
_scheduler.Schedule(IsHeroic() ? 2500ms : 5s, [this](TaskContext task)
{
Initialize();
}
/// @todo cast here SPELL_PUTRID_MUSHROOM_PRIMER and do it in spell script
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
target->CastSpell(target, SPELL_SUMMON_UNDERBOG_MUSHROOM, true);
task.Repeat(IsHeroic() ? 2500ms : 10s);
});
void Initialize()
if (IsHeroic())
{
Root = false;
Mushroom_Timer = 5000; // 1 mushroom after 5s, then one per 10s. This should be different in heroic mode
AcidGeyser_Timer = 10000;
}
bool Root;
uint32 Mushroom_Timer;
uint32 AcidGeyser_Timer;
void Reset() override
{
Initialize();
}
void JustEngagedWith(Unit* /*who*/) override
{
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
if (!HealthAbovePct(20))
{
if (!Root)
{
DoCast(me, SPELL_FOUL_SPORES);
Root = true;
}
}
if (Mushroom_Timer <= diff)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
me->SummonCreature(17990, target->GetPositionX() + (rand32() % 8), target->GetPositionY() + (rand32() % 8), target->GetPositionZ(), float(rand32() % 5), TEMPSUMMON_TIMED_DESPAWN, 22s);
else
me->SummonCreature(17990, me->GetPositionX() + (rand32() % 8), me->GetPositionY() + (rand32() % 8), me->GetPositionZ(), float(rand32() % 5), TEMPSUMMON_TIMED_DESPAWN, 22s);
Mushroom_Timer = 10000;
} else Mushroom_Timer -= diff;
if (AcidGeyser_Timer <= diff)
_scheduler.Schedule(3s, 5s, [this](TaskContext task)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
DoCast(target, SPELL_ACID_GEYSER);
AcidGeyser_Timer = 10000 + rand32() % 7500;
} else AcidGeyser_Timer -= diff;
DoMeleeAttackIfReady();
task.Repeat(10s, 15s);
});
}
};
};
class npc_underbog_mushroom : public CreatureScript
{
public:
npc_underbog_mushroom() : CreatureScript("npc_underbog_mushroom") { }
CreatureAI* GetAI(Creature* creature) const override
{
return GetTheUnderbogAI<npc_underbog_mushroomAI>(creature);
}
struct npc_underbog_mushroomAI : public ScriptedAI
void EnterEvadeMode(EvadeReason why) override
{
npc_underbog_mushroomAI(Creature* creature) : ScriptedAI(creature)
DoCastSelf(SPELL_DESPAWN_UNDERBOG_MUSHROOMS, true);
ScriptedAI::EnterEvadeMode(why);
}
void JustDied(Unit* /*killer*/) override
{
DoCastSelf(SPELL_DESPAWN_UNDERBOG_MUSHROOMS, true);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
_scheduler.Update(diff, [this]
{
Initialize();
}
DoMeleeAttackIfReady();
});
void Initialize()
if (!HealthAbovePct(20) && !_roared)
{
Stop = false;
Grow_Timer = 0;
Shrink_Timer = 20000;
}
Talk(EMOTE_ROARS);
_roared = true;
me->SetReactState(REACT_PASSIVE);
bool Stop;
uint32 Grow_Timer;
uint32 Shrink_Timer;
void Reset() override
{
Initialize();
DoCast(me, SPELL_PUTRID_MUSHROOM, true);
DoCast(me, SPELL_SPORE_CLOUD, true);
}
void MoveInLineOfSight(Unit* /*who*/) override { }
void AttackStart(Unit* /*who*/) override { }
void JustEngagedWith(Unit* /*who*/) override { }
void UpdateAI(uint32 diff) override
{
if (Stop)
return;
if (Grow_Timer <= diff)
_scheduler.Schedule(2s, [this](TaskContext /*task*/)
{
DoCast(me, SPELL_GROW);
Grow_Timer = 3000;
} else Grow_Timer -= diff;
if (Shrink_Timer <= diff)
{
me->RemoveAurasDueToSpell(SPELL_GROW);
Stop = true;
} else Shrink_Timer -= diff;
DoCastSelf(SPELL_FOUL_SPORES);
me->SetReactState(REACT_AGGRESSIVE);
});
}
};
}
private:
TaskScheduler _scheduler;
bool _roared;
};
struct npc_underbog_mushroom : public ScriptedAI
{
npc_underbog_mushroom(Creature* creature) : ScriptedAI(creature) { }
void InitializeAI() override
{
_counter = RAND(8, 9, 10);
me->SetReactState(REACT_PASSIVE);
DoCastSelf(SPELL_SHRINK);
DoCastSelf(SPELL_PUTRID_MUSHROOM);
_scheduler.Schedule(1s, [this](TaskContext task)
{
DoCastSelf(SPELL_GROW);
// It's random(sniffs), makes them grow to different size. We need here count of stacks
// and not task repeat counter because first stack is applied not when task is repeated
Aura* growAura = me->GetAura(SPELL_GROW);
if (growAura && growAura->GetStackAmount() != _counter)
task.Repeat(2s);
else
{
task.Schedule(1s, [this](TaskContext task)
{
DoCastSelf(SPELL_SPORE_CLOUD);
task.Schedule(4s, [this](TaskContext /*task*/)
{
me->RemoveAurasDueToSpell(SPELL_GROW);
me->DespawnOrUnsummon(4s);
});
});
}
});
}
void UpdateAI(uint32 diff) override
{
_scheduler.Update(diff);
}
private:
TaskScheduler _scheduler;
uint32 _counter;
};
void AddSC_boss_hungarfen()
{
new boss_hungarfen();
new npc_underbog_mushroom();
RegisterTheUnderbogCreatureAI(boss_hungarfen);
RegisterTheUnderbogCreatureAI(npc_underbog_mushroom);
}

View File

@@ -28,4 +28,6 @@ inline AI* GetTheUnderbogAI(T* obj)
return GetInstanceAI<AI>(obj, TheUndebogScriptName);
}
#define RegisterTheUnderbogCreatureAI(ai_name) RegisterCreatureAIWithFactory(ai_name, GetTheUnderbogAI)
#endif // the_underbog_h__