mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
DB/Quest: Convert & update support for 'Pyrewood Ambush' to SAI
Closes #24833
This commit is contained in:
@@ -18,13 +18,12 @@
|
||||
/* ScriptData
|
||||
SDName: Silverpine_Forest
|
||||
SD%Complete: 100
|
||||
SDComment: Quest support: 435, 452
|
||||
SDComment: Quest support: 435
|
||||
SDCategory: Silverpine Forest
|
||||
EndScriptData */
|
||||
|
||||
/* ContentData
|
||||
npc_deathstalker_erland
|
||||
pyrewood_ambush
|
||||
EndContentData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
@@ -132,202 +131,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/*######
|
||||
## pyrewood_ambush
|
||||
#######*/
|
||||
|
||||
enum PyrewoodAmbush
|
||||
{
|
||||
SAY_PREPARE_TO_AMBUSH = 0,
|
||||
SAY_A_BLOW_TO_ARUGAL = 1,
|
||||
QUEST_PYREWOOD_AMBUSH = 452,
|
||||
COUNCILMAN_SMITHERS = 2060,
|
||||
COUNCILMAN_THATCHER = 2061,
|
||||
COUNCILMAN_HENDRICKS = 2062,
|
||||
COUNCILMAN_WILHELM = 2063,
|
||||
COUNCILMAN_HARTIN = 2064,
|
||||
COUNCILMAN_COOPER = 2065,
|
||||
COUNCILMAN_HIGARTH = 2066,
|
||||
COUNCILMAN_BRUNSWICK = 2067,
|
||||
LORD_MAYOR_MORRISON = 2068
|
||||
};
|
||||
|
||||
static float PyrewoodSpawnPoints[3][4] =
|
||||
{
|
||||
//pos_x pos_y pos_z orien
|
||||
//outside
|
||||
/*
|
||||
{-400.85f, 1513.64f, 18.67f, 0},
|
||||
{-397.32f, 1514.12f, 18.67f, 0},
|
||||
{-397.44f, 1511.09f, 18.67f, 0},
|
||||
*/
|
||||
//door
|
||||
{-396.17f, 1505.86f, 19.77f, 0},
|
||||
{-396.91f, 1505.77f, 19.77f, 0},
|
||||
{-397.94f, 1504.74f, 19.77f, 0},
|
||||
};
|
||||
|
||||
class pyrewood_ambush : public CreatureScript
|
||||
{
|
||||
public:
|
||||
pyrewood_ambush() : CreatureScript("pyrewood_ambush") { }
|
||||
|
||||
struct pyrewood_ambushAI : public ScriptedAI
|
||||
{
|
||||
pyrewood_ambushAI(Creature* creature) : ScriptedAI(creature), Summons(me)
|
||||
{
|
||||
Initialize();
|
||||
WaitTimer = 6 * IN_MILLISECONDS;
|
||||
QuestInProgress = false;
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
Phase = 0;
|
||||
KillCount = 0;
|
||||
PlayerGUID.Clear();
|
||||
}
|
||||
|
||||
uint32 Phase;
|
||||
int8 KillCount;
|
||||
uint32 WaitTimer;
|
||||
ObjectGuid PlayerGUID;
|
||||
SummonList Summons;
|
||||
|
||||
bool QuestInProgress;
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
WaitTimer = 6 * IN_MILLISECONDS;
|
||||
|
||||
if (!QuestInProgress) //fix reset values (see UpdateVictim)
|
||||
{
|
||||
Initialize();
|
||||
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_ENEMY);
|
||||
AddThreat(target, 32.0f, summoned);
|
||||
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
|
||||
{
|
||||
//TC_LOG_INFO("scripts", "DEBUG: p(%i) k(%i) d(%u) W(%i)", Phase, KillCount, diff, WaitTimer);
|
||||
|
||||
if (!QuestInProgress)
|
||||
return;
|
||||
|
||||
if (KillCount && Phase < 6)
|
||||
{
|
||||
if (!UpdateVictim()) //reset() on target Despawn...
|
||||
return;
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (Phase)
|
||||
{
|
||||
case 0:
|
||||
if (WaitTimer == 6 * IN_MILLISECONDS)
|
||||
if (Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID))
|
||||
Talk(SAY_PREPARE_TO_AMBUSH, player);
|
||||
|
||||
if (WaitTimer <= diff)
|
||||
{
|
||||
WaitTimer -= diff;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
SummonCreatureWithRandomTarget(COUNCILMAN_SMITHERS, 1);
|
||||
break;
|
||||
case 2:
|
||||
SummonCreatureWithRandomTarget(COUNCILMAN_THATCHER, 2);
|
||||
SummonCreatureWithRandomTarget(COUNCILMAN_HENDRICKS, 0);
|
||||
break;
|
||||
case 3:
|
||||
SummonCreatureWithRandomTarget(COUNCILMAN_WILHELM, 1);
|
||||
SummonCreatureWithRandomTarget(COUNCILMAN_HARTIN, 2);
|
||||
SummonCreatureWithRandomTarget(COUNCILMAN_COOPER, 0);
|
||||
break;
|
||||
case 4:
|
||||
SummonCreatureWithRandomTarget(COUNCILMAN_HIGARTH, 1);
|
||||
SummonCreatureWithRandomTarget(COUNCILMAN_BRUNSWICK, 0);
|
||||
SummonCreatureWithRandomTarget(LORD_MAYOR_MORRISON, 2);
|
||||
break;
|
||||
case 5: //end
|
||||
if (PlayerGUID)
|
||||
{
|
||||
if (Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID))
|
||||
{
|
||||
Talk(SAY_A_BLOW_TO_ARUGAL);
|
||||
player->GroupEventHappens(QUEST_PYREWOOD_AMBUSH, me);
|
||||
}
|
||||
}
|
||||
QuestInProgress = false;
|
||||
Reset();
|
||||
break;
|
||||
}
|
||||
++Phase; //prepare next phase
|
||||
}
|
||||
|
||||
void QuestAccept(Player* player, Quest const* quest) override
|
||||
{
|
||||
if (quest->GetQuestId() == QUEST_PYREWOOD_AMBUSH && !QuestInProgress)
|
||||
{
|
||||
QuestInProgress = true;
|
||||
Phase = 0;
|
||||
KillCount = 0;
|
||||
PlayerGUID = player->GetGUID();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return new pyrewood_ambushAI(creature);
|
||||
}
|
||||
};
|
||||
|
||||
/*######
|
||||
## AddSC
|
||||
######*/
|
||||
@@ -335,5 +138,4 @@ public:
|
||||
void AddSC_silverpine_forest()
|
||||
{
|
||||
new npc_deathstalker_erland();
|
||||
new pyrewood_ambush();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user