fix(DB/SAI): Shay Leafrunner (#16454)

* fix(DB/SAI): Wandering-Shay-Quest

* fix(DB/SAI): Wandering-Shay-Quest

* Update rev_1685747385631953200.sql

* Update rev_1685747385631953200.sql

---------

Co-authored-by: dario strani <xspid@lastrevenge.ddns.net>
This commit is contained in:
The GhostRider
2023-06-26 03:43:59 +01:00
committed by GitHub
parent 65ebbec8b6
commit 3186edc568
2 changed files with 41 additions and 224 deletions

View File

@@ -0,0 +1,41 @@
-- Shay Leafrunner - On Quest - Wandering Shay --
UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE (`entry` = 7774);
DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 7774);
INSERT INTO `smart_scripts` VALUES
(7774, 0, 0, 0, 19, 0, 100, 0, 2845, 0, 0, 0, 0, 80, 777400, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Quest \'Wandering Shay\' Taken - Run Script'),
(7774, 0, 1, 0, 8, 0, 100, 0, 11402, 0, 0, 0, 0, 80, 777401, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Spellhit \'Shay`s Bell\' - Run Script'),
(7774, 0, 2, 0, 75, 0, 100, 0, 0, 7765, 7, 10000, 0, 80, 777402, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Distance To Creature - Run Script'),
(7774, 0, 3, 0, 6, 0, 100, 0, 0, 0, 0, 0, 0, 80, 777403, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Just Died - Run Script'),
(7774, 0, 4, 0, 38, 0, 100, 0, 1, 1, 0, 0, 0, 67, 61, 30000, 35000, 60000, 65000, 100, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Data Set 1 1 - Create Timed Event'),
(7774, 0, 5, 6, 59, 0, 100, 0, 61, 0, 0, 0, 0, 73, 38, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Timed Event 61 Triggered - Trigger Timed Event 38'),
(7774, 0, 6, 7, 61, 0, 100, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Timed Event 61 Triggered - Stop Follow '),
(7774, 0, 7, 8, 61, 0, 100, 0, 0, 0, 0, 0, 0, 89, 15, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Data Set 1 1 - Start Random Movement'),
(7774, 0, 8, 9, 61, 0, 100, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Data Set 1 1 - Say Line 2'),
(7774, 0, 9, 0, 61, 0, 100, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Data Set 1 1 - Say Line 3'),
(7774, 0, 10, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 74, 61, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Respawn - Remove Timed Event 61'),
(7774, 0, 11, 0, 6, 0, 100, 0, 0, 0, 0, 0, 0, 6, 2845, 0, 0, 0, 0, 0, 18, 10, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Just Died - Fail Quest \'Wandering Shay\''),
(7774, 0, 12, 0, 75, 0, 100, 1, 0, 7765, 10, 5000, 0, 1, 0, 0, 0, 0, 0, 0, 11, 7765, 10, 1, 0, 0, 0, 0, 0, 'Shay Leafrunner - On Distance To Creature - Say Line 0');
DELETE FROM `smart_scripts` WHERE (`source_type` = 9 AND `entryorguid` = 777400);
INSERT INTO `smart_scripts` VALUES
(777400, 9, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 19, 768, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - Actionlist - Remove Flags Immune To Players & Immune To NPC\'s'),
(777400, 9, 1, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 29, 2, 3, 7765, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - Actionlist - Start Follow Invoker'),
(777400, 9, 2, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - Actionlist - Say Line 0'),
(777400, 9, 3, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 45, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - Actionlist - Set Data 1 1');
DELETE FROM `smart_scripts` WHERE (`source_type` = 9 AND `entryorguid` = 777401);
INSERT INTO `smart_scripts` VALUES
(777401, 9, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 29, 2, 3, 7765, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - Actionlist - Start Follow Invoker'),
(777401, 9, 1, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - Actionlist - Say Line 1');
DELETE FROM `smart_scripts` WHERE (`source_type` = 9 AND `entryorguid` = 777402);
INSERT INTO `smart_scripts` VALUES
(777402, 9, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 15, 2845, 0, 0, 0, 0, 0, 18, 10, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - Actionlist - Quest Credit \'Wandering Shay\''),
(777402, 9, 1, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - Actionlist - Say Line 4');
DELETE FROM `smart_scripts` WHERE (`source_type` = 9 AND `entryorguid` = 777403);
INSERT INTO `smart_scripts` VALUES
(777403, 9, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 6, 2845, 0, 0, 0, 0, 0, 18, 10, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - Actionlist - Fail Quest \'Wandering Shay\''),
(777403, 9, 1, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 18, 768, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - Actionlist - Set Flags Immune To Players & Immune To NPC\'s'),
(777403, 9, 2, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 74, 61, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shay Leafrunner - Actionlist - Remove Timed Event 61');

View File

@@ -66,231 +66,7 @@ public:
}
};
enum WanderingShay
{
QUEST_WANDERING_SHAY = 2845,
SPELL_SHAY_BELL = 11402,
NPC_ROCKBITER = 7765,
TALK_0 = 0,
TALK_1 = 1,
TALK_2 = 2,
TALK_3 = 3,
TALK_4 = 4,
EVENT_WANDERING_START = 1,
EVENT_WANDERING_TALK = 2,
EVENT_WANDERING_RANDOM = 3,
EVENT_FINAL_TALK = 4,
EVENT_CHECK_FOLLOWER = 5
};
class npc_shay_leafrunner : public CreatureScript
{
public:
npc_shay_leafrunner() : CreatureScript("npc_shay_leafrunner") {}
struct npc_shay_leafrunnerAI : public ScriptedAI
{
npc_shay_leafrunnerAI(Creature* creature) : ScriptedAI(creature) {}
void InitializeAI() override
{
me->SetNpcFlag(UNIT_NPC_FLAG_QUESTGIVER);
me->SetImmuneToAll(true);
me->RestoreFaction();
_events.Reset();
_playerGUID.Clear();
_rockbiterGUID.Clear();
}
void JustRespawned() override
{
InitializeAI();
me->SetHomePosition(me->GetPosition());
}
void MoveInLineOfSight(Unit* target) override
{
if (!_playerGUID || target->GetEntry() != NPC_ROCKBITER || !me->IsInRange(target, 0.f, 10.f))
{
if (!me->IsInCombat() && !me->GetVictim())
{
if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID))
{
if (Unit* victim = player->GetVictim())
{
if (me->CanStartAttack(victim))
{
AttackStart(victim);
}
}
}
}
return;
}
_rockbiterGUID = target->GetGUID();
Talk(TALK_4, target);
me->SetControlled(true, UNIT_STATE_ROOT);
if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID))
{
player->GroupEventHappens(QUEST_WANDERING_SHAY, me);
}
_events.CancelEvent(EVENT_WANDERING_START);
_events.ScheduleEvent(EVENT_FINAL_TALK, 5s);
}
void EnterEvadeMode(EvadeReason why) override
{
_EnterEvadeMode(why);
if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID))
{
me->GetMotionMaster()->MoveFollow(player, 3.f, M_PI);
}
}
void FailQuest(Player* player, bool despawn)
{
if (player)
{
player->FailQuest(QUEST_WANDERING_SHAY);
if (Group* group = player->GetGroup())
{
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
{
if (Player* member = groupRef->GetSource())
{
if (member->GetGUID() != player->GetGUID())
{
member->FailQuest(QUEST_WANDERING_SHAY);
}
}
}
}
}
if (despawn)
{
me->DespawnOrUnsummon(1);
}
}
void JustDied(Unit* /*killer*/) override
{
if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID))
{
FailQuest(player, false);
}
}
void sQuestAccept(Player* player, Quest const* quest) override
{
if (quest->GetQuestId() == QUEST_WANDERING_SHAY)
{
_playerGUID = player->GetGUID();
Talk(TALK_0, player);
me->RemoveNpcFlag(UNIT_NPC_FLAG_QUESTGIVER);
me->SetImmuneToAll(false);
me->SetFaction(FACTION_ESCORT_N_NEUTRAL_ACTIVE);
me->GetMotionMaster()->MoveFollow(player, 3.f, M_PI);
_events.ScheduleEvent(EVENT_WANDERING_START, 40s, 70s);
_events.ScheduleEvent(EVENT_CHECK_FOLLOWER, 30s);
}
}
void SpellHit(Unit* caster, SpellInfo const* spellInfo) override
{
if (spellInfo->Id == SPELL_SHAY_BELL)
{
_playerGUID = caster->GetGUID();
Talk(TALK_1, caster);
me->GetMotionMaster()->MoveIdle();
me->GetMotionMaster()->MoveFollow(caster, 3.f, M_PI);
}
}
void UpdateAI(uint32 diff) override
{
if (UpdateVictim())
{
DoMeleeAttackIfReady();
return;
}
_events.Update(diff);
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_WANDERING_START:
{
Position pos = me->GetFirstCollisionPosition(15.f, rand_norm() * static_cast<float>(2 * M_PI));
me->GetMotionMaster()->MovePoint(0, pos);
Talk(TALK_2);
_events.ScheduleEvent(EVENT_WANDERING_START, 60s, 70s);
_events.ScheduleEvent(EVENT_WANDERING_TALK, 3s);
_events.ScheduleEvent(EVENT_WANDERING_RANDOM, 8s);
break;
}
case EVENT_WANDERING_TALK:
Talk(TALK_3);
break;
case EVENT_WANDERING_RANDOM:
me->SetHomePosition(me->GetPosition());
me->GetMotionMaster()->MoveRandom(15.f);
break;
case EVENT_FINAL_TALK:
if (Creature* robckbiter = ObjectAccessor::GetCreature(*me, _rockbiterGUID))
{
robckbiter->AI()->Talk(TALK_0, me);
}
me->DespawnOrUnsummon(10 * IN_MILLISECONDS);
break;
case EVENT_CHECK_FOLLOWER:
{
Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID);
if (!player || !player->IsAlive() || !me->IsInRange(player, 0.f, 50.f))
{
FailQuest(player, true);
}
break;
}
default:
break;
}
}
}
private:
ObjectGuid _playerGUID;
ObjectGuid _rockbiterGUID;
EventMap _events;
};
CreatureAI* GetAI(Creature* creature) const override
{
return new npc_shay_leafrunnerAI(creature);
}
};
void AddSC_feralas()
{
new spell_gordunni_trap();
new npc_shay_leafrunner();
}