Merge pull request #172 from Day36512/master

Fixed Zombie eating and decimate
This commit is contained in:
ZhengPeiRu21
2023-08-21 12:19:06 -06:00
committed by GitHub
3 changed files with 107 additions and 64 deletions

View File

@@ -0,0 +1,4 @@
DELETE FROM `creature_template_spell` WHERE `CreatureID`=351084 AND `Index`=0;
INSERT INTO `creature_template_spell` (`CreatureID`, `Index`, `Spell`, `VerifiedBuild`) VALUES (351084, 0, 29060, 0);
DELETE FROM `creature_template_spell` WHERE `CreatureID`=351084 AND `Index`=1;
INSERT INTO `creature_template_spell` (`CreatureID`, `Index`, `Spell`, `VerifiedBuild`) VALUES (351084, 1, 29061, 0);

View File

@@ -196,6 +196,23 @@ public:
case EVENT_DECIMATE: case EVENT_DECIMATE:
Talk(EMOTE_DECIMATE); Talk(EMOTE_DECIMATE);
me->CastSpell(me, SPELL_DECIMATE, false); me->CastSpell(me, SPELL_DECIMATE, false);
// Apply Decimate effect to zombies
{
std::list<Creature*> zombies;
me->GetCreatureListWithEntryInGrid(zombies, NPC_ZOMBIE_CHOW, 150.0f);
for (Creature* zombie : zombies)
{
if (zombie->IsAlive())
{
int32 reduceHp = int32(zombie->GetMaxHealth() * 0.05f);
if (zombie->GetHealth() > reduceHp)
zombie->SetHealth(reduceHp); // Reduce HP to 5%
zombie->SetWalk(true); // Set to walk
zombie->GetMotionMaster()->MoveFollow(me, 0.0f, 0.0f, MOTION_SLOT_CONTROLLED); // Move to boss
zombie->SetReactState(REACT_PASSIVE); // Set to passive
}
}
}
events.RepeatEvent(105000); events.RepeatEvent(105000);
break; break;
case EVENT_SUMMON_ZOMBIE: case EVENT_SUMMON_ZOMBIE:
@@ -212,12 +229,16 @@ public:
} }
case EVENT_CAN_EAT_ZOMBIE: case EVENT_CAN_EAT_ZOMBIE:
events.RepeatEvent(1000); events.RepeatEvent(1000);
if (me->GetVictim()->GetEntry() == NPC_ZOMBIE_CHOW && me->IsWithinMeleeRange(me->GetVictim())) if (me->GetVictim() && me->GetVictim()->GetEntry() == NPC_ZOMBIE_CHOW && me->IsWithinMeleeRange(me->GetVictim()))
{ {
me->CastCustomSpell(SPELL_CHOW_SEARCHER, SPELLVALUE_RADIUS_MOD, 20000, me, true); if (me->GetVictim()->GetHealth() > 0) // Check if the zombie is alive
{
me->ModifyHealth(int32(me->GetMaxHealth() * 0.05f)); // Heal for 5% of max health
Talk(EMOTE_DEVOURS_ALL); Talk(EMOTE_DEVOURS_ALL);
Unit::DealDamage(me, me->GetVictim(), me->GetVictim()->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); // Kill the zombie
return; // leave it to skip DoMeleeAttackIfReady return; // leave it to skip DoMeleeAttackIfReady
} }
}
break; break;
} }
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
@@ -269,5 +290,5 @@ public:
void AddSC_boss_gluth_40() void AddSC_boss_gluth_40()
{ {
new boss_gluth_40(); new boss_gluth_40();
// new spell_gluth_decimate(); new spell_gluth_decimate();
} }

View File

@@ -116,6 +116,7 @@ enum Yells
SAY_EVADE = 5 SAY_EVADE = 5
}; };
class boss_onyxia_40 : public CreatureScript class boss_onyxia_40 : public CreatureScript
{ {
public: public:
@@ -209,11 +210,8 @@ public:
void JustSummoned(Creature* summon) override void JustSummoned(Creature* summon) override
{ {
if (summon->GetEntry() != NPC_ONYXIAN_WHELP && summon->GetEntry() != NPC_ONYXIAN_LAIR_GUARD) if (summon->GetEntry() == NPC_ONYXIAN_WHELP || summon->GetEntry() == NPC_ONYXIAN_LAIR_GUARD)
{ {
return;
}
if (Unit* target = summon->SelectNearestTarget(300.0f)) if (Unit* target = summon->SelectNearestTarget(300.0f))
{ {
summon->AI()->AttackStart(target); summon->AI()->AttackStart(target);
@@ -222,6 +220,7 @@ public:
summons.Summon(summon); summons.Summon(summon);
} }
}
void MovementInform(uint32 type, uint32 id) override void MovementInform(uint32 type, uint32 id) override
{ {
@@ -275,11 +274,29 @@ public:
whelpSpamTimer -= diff; whelpSpamTimer -= diff;
if (whelpSpamTimer <= 0) if (whelpSpamTimer <= 0)
{ {
float angle = rand_norm() * 2 * M_PI; // Coordinates for the cave mouths
float dist = rand_norm() * 4.0f; float caveMouths[2][3] = {
me->CastSpell(-33.18f + cos(angle) * dist, -258.80f + sin(angle) * dist, -89.0f, SPELL_SUMMON_WHELP, true); {-31.71, -170.55, -89.72},
me->CastSpell(-32.535f + cos(angle) * dist, -170.190f + sin(angle) * dist, -89.0f, SPELL_SUMMON_WHELP, true); {-32.086, -258.55, -89.72},
whelpCount += 2; };
// Randomly select one of the cave mouths for spawning
uint8 selectedCave = urand(0, 1);
// Summon a whelp at the selected cave mouth
Creature* whelp = me->SummonCreature(NPC_ONYXIAN_WHELP, caveMouths[selectedCave][0], caveMouths[selectedCave][1], caveMouths[selectedCave][2], 0);
if (whelp)
{
// Find the nearest player and attack
if (Unit* target = whelp->SelectNearestTarget(300.0f))
{
whelp->AI()->AttackStart(target);
}
}
// Increment the whelp count and reset the timer
whelpCount += 1;
whelpSpamTimer += 600; whelpSpamTimer += 600;
} }
} }
@@ -292,6 +309,7 @@ public:
} }
} }
bool CheckInRoom() override bool CheckInRoom() override
{ {
if (me->GetDistance2d(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY()) > 95.0f) if (me->GetDistance2d(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY()) > 95.0f)