fix(Scripts/Silverpine): Fix Fearleia not reseting and modernize Pyre… (#21159)
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
--
|
||||||
|
UPDATE `creature_template` SET `ScriptName` = 'npc_deathstalker_fearleia' WHERE `entry` = 2058;
|
||||||
@@ -161,136 +161,37 @@ static float PyrewoodSpawnPoints[3][4] =
|
|||||||
{-397.018219f, 1510.208740f, 18.868748f, 4.731330f},
|
{-397.018219f, 1510.208740f, 18.868748f, 4.731330f},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define WAIT_SECS 6000
|
struct npc_deathstalker_fearleia : public ScriptedAI
|
||||||
|
|
||||||
class pyrewood_ambush : public CreatureScript
|
|
||||||
{
|
{
|
||||||
public:
|
npc_deathstalker_fearleia(Creature* creature) : ScriptedAI(creature), _summons(me)
|
||||||
pyrewood_ambush() : CreatureScript("pyrewood_ambush") { }
|
|
||||||
|
|
||||||
bool OnQuestAccept(Player* player, Creature* creature, const Quest* quest) override
|
|
||||||
{
|
{
|
||||||
if (quest->GetQuestId() == QUEST_PYREWOOD_AMBUSH && !CAST_AI(pyrewood_ambush::pyrewood_ambushAI, creature->AI())->QuestInProgress)
|
_questInProgress = false;
|
||||||
{
|
|
||||||
CAST_AI(pyrewood_ambush::pyrewood_ambushAI, creature->AI())->QuestInProgress = true;
|
|
||||||
CAST_AI(pyrewood_ambush::pyrewood_ambushAI, creature->AI())->Phase = 0;
|
|
||||||
CAST_AI(pyrewood_ambush::pyrewood_ambushAI, creature->AI())->KillCount = 0;
|
|
||||||
CAST_AI(pyrewood_ambush::pyrewood_ambushAI, creature->AI())->PlayerGUID = player->GetGUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatureAI* GetAI(Creature* creature) const override
|
void Reset() override
|
||||||
{
|
{
|
||||||
return new pyrewood_ambushAI(creature);
|
if (!_questInProgress)
|
||||||
|
{
|
||||||
|
_playerGUID.Clear();
|
||||||
|
_summons.DespawnAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pyrewood_ambushAI : public ScriptedAI
|
void sQuestAccept(Player* player, Quest const* quest) override
|
||||||
{
|
{
|
||||||
pyrewood_ambushAI(Creature* creature) : ScriptedAI(creature), Summons(me)
|
if (quest->GetQuestId() == QUEST_PYREWOOD_AMBUSH && !_questInProgress)
|
||||||
{
|
{
|
||||||
QuestInProgress = false;
|
_questInProgress = true;
|
||||||
|
_playerGUID = player->GetGUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Phase;
|
Talk(NPCSAY_INIT, player);
|
||||||
int8 KillCount;
|
|
||||||
uint32 WaitTimer;
|
|
||||||
ObjectGuid PlayerGUID;
|
|
||||||
SummonList Summons;
|
|
||||||
|
|
||||||
bool QuestInProgress;
|
scheduler.Schedule(6s, [this](TaskContext context)
|
||||||
|
|
||||||
void Reset() override
|
|
||||||
{
|
{
|
||||||
WaitTimer = WAIT_SECS;
|
switch (context.GetRepeatCounter())
|
||||||
|
|
||||||
if (!QuestInProgress) //fix reset values (see UpdateVictim)
|
|
||||||
{
|
|
||||||
Phase = 0;
|
|
||||||
KillCount = 0;
|
|
||||||
PlayerGUID.Clear();
|
|
||||||
Summons.DespawnAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void JustEngagedWith(Unit* /*who*/) override { }
|
|
||||||
|
|
||||||
void JustSummoned(Creature* summoned) override
|
|
||||||
{
|
|
||||||
Summons.Summon(summoned);
|
|
||||||
++KillCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SummonedCreatureDespawn(Creature* summoned) override
|
|
||||||
{
|
|
||||||
Summons.Despawn(summoned);
|
|
||||||
--KillCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SummonCreatureWithRandomTarget(uint32 creatureId, int position)
|
|
||||||
{
|
|
||||||
if (Creature* summoned = me->SummonCreature(creatureId, PyrewoodSpawnPoints[position][0], PyrewoodSpawnPoints[position][1], PyrewoodSpawnPoints[position][2], PyrewoodSpawnPoints[position][3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000))
|
|
||||||
{
|
|
||||||
Unit* target = nullptr;
|
|
||||||
if (PlayerGUID)
|
|
||||||
if (Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID))
|
|
||||||
if (player->IsAlive() && RAND(0, 1))
|
|
||||||
target = player;
|
|
||||||
|
|
||||||
if (!target)
|
|
||||||
target = me;
|
|
||||||
|
|
||||||
summoned->SetFaction(FACTION_STORMWIND);
|
|
||||||
summoned->AddThreat(target, 32.0f);
|
|
||||||
summoned->AI()->AttackStart(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void JustDied(Unit* /*killer*/) override
|
|
||||||
{
|
|
||||||
if (PlayerGUID)
|
|
||||||
if (Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID))
|
|
||||||
if (player->GetQuestStatus(QUEST_PYREWOOD_AMBUSH) == QUEST_STATUS_INCOMPLETE)
|
|
||||||
player->FailQuest(QUEST_PYREWOOD_AMBUSH);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateAI(uint32 diff) override
|
|
||||||
{
|
|
||||||
//LOG_INFO("scripts", "DEBUG: p({}) k({}) d({}) W({})", Phase, KillCount, diff, WaitTimer);
|
|
||||||
|
|
||||||
if (!QuestInProgress)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (KillCount && Phase < 6)
|
|
||||||
{
|
|
||||||
if (!UpdateVictim()) //reset() on target Despawn...
|
|
||||||
return;
|
|
||||||
|
|
||||||
DoMeleeAttackIfReady();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Phase)
|
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (WaitTimer == WAIT_SECS)
|
|
||||||
{
|
|
||||||
if (PlayerGUID)
|
|
||||||
{
|
|
||||||
if (Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID))
|
|
||||||
{
|
|
||||||
me->AI()->Talk(NPCSAY_INIT, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (WaitTimer <= diff)
|
|
||||||
{
|
|
||||||
WaitTimer -= diff;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
SummonCreatureWithRandomTarget(2060, 1);
|
SummonCreatureWithRandomTarget(2060, 1);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@@ -309,21 +210,73 @@ public:
|
|||||||
SummonCreatureWithRandomTarget(2068, 2);
|
SummonCreatureWithRandomTarget(2068, 2);
|
||||||
break;
|
break;
|
||||||
case 5: //end
|
case 5: //end
|
||||||
if (PlayerGUID)
|
if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID))
|
||||||
{
|
{
|
||||||
if (Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID))
|
Talk(NPCSAY_END, player);
|
||||||
{
|
player->GroupEventHappens(QUEST_PYREWOOD_AMBUSH, me);
|
||||||
me->AI()->Talk(NPCSAY_END, player);
|
|
||||||
player->GroupEventHappens(QUEST_PYREWOOD_AMBUSH, me);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QuestInProgress = false;
|
_questInProgress = false;
|
||||||
Reset();
|
Reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++Phase; //prepare next phase
|
|
||||||
|
if (context.GetRepeatCounter() < 5)
|
||||||
|
context.Repeat();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void JustEngagedWith(Unit* /*who*/) override {}
|
||||||
|
|
||||||
|
void JustSummoned(Creature* summoned) override
|
||||||
|
{
|
||||||
|
_summons.Summon(summoned);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SummonedCreatureDespawn(Creature* summoned) override
|
||||||
|
{
|
||||||
|
_summons.Despawn(summoned);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SummonCreatureWithRandomTarget(uint32 creatureId, int position)
|
||||||
|
{
|
||||||
|
if (Creature* summoned = me->SummonCreature(creatureId, PyrewoodSpawnPoints[position][0], PyrewoodSpawnPoints[position][1], PyrewoodSpawnPoints[position][2], PyrewoodSpawnPoints[position][3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000))
|
||||||
|
{
|
||||||
|
Unit* target = nullptr;
|
||||||
|
if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID))
|
||||||
|
if (player->IsAlive() && RAND(0, 1))
|
||||||
|
target = player;
|
||||||
|
|
||||||
|
if (!target)
|
||||||
|
target = me;
|
||||||
|
|
||||||
|
summoned->SetFaction(FACTION_STORMWIND);
|
||||||
|
summoned->AddThreat(target, 32.0f);
|
||||||
|
summoned->AI()->AttackStart(target);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
void JustDied(Unit* /*killer*/) override
|
||||||
|
{
|
||||||
|
if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID))
|
||||||
|
if (player->GetQuestStatus(QUEST_PYREWOOD_AMBUSH) == QUEST_STATUS_INCOMPLETE)
|
||||||
|
player->FailQuest(QUEST_PYREWOOD_AMBUSH);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateAI(uint32 diff) override
|
||||||
|
{
|
||||||
|
if (_questInProgress && !_summons.IsAnyCreatureAlive())
|
||||||
|
scheduler.Update(diff);
|
||||||
|
|
||||||
|
if (!UpdateVictim())
|
||||||
|
return;
|
||||||
|
|
||||||
|
DoMeleeAttackIfReady();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ObjectGuid _playerGUID;
|
||||||
|
SummonList _summons;
|
||||||
|
bool _questInProgress;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -485,6 +438,6 @@ public:
|
|||||||
void AddSC_silverpine_forest()
|
void AddSC_silverpine_forest()
|
||||||
{
|
{
|
||||||
new npc_deathstalker_erland();
|
new npc_deathstalker_erland();
|
||||||
new pyrewood_ambush();
|
RegisterCreatureAI(npc_deathstalker_fearleia);
|
||||||
new npc_ravenclaw_apparition();
|
new npc_ravenclaw_apparition();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user