Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
#include "SpellScript.h"

#define NPC_WOLF 49871

#define BROTHER_PAXTON_SPELL_RENEW 93094
#define NPC_PAXTON 951
class npc_stormwind_infantry : public CreatureScript
{
public:
Expand All @@ -66,6 +67,19 @@ class npc_stormwind_infantry : public CreatureScript
wolfTarget = ObjectGuid::Empty;
me->SetSheath(SHEATH_STATE_MELEE);
waitTime = urand(0, 2000);

me->GetScheduler().Schedule(Seconds(urand(20, 30)), [this](TaskContext task)
{
Creature* paxton = me->FindNearestCreature(NPC_PAXTON, 10.0f, true);

if (paxton)
{
Talk(0);
paxton->SetFacingToObject(me);
paxton->CastSpell(me, BROTHER_PAXTON_SPELL_RENEW, true);
}
task.Repeat(Seconds(urand(20, 30)));
});
}

void DamageTaken(Unit* doneBy, uint32& damage) override
Expand Down Expand Up @@ -172,19 +186,23 @@ class npc_stormwind_injured_soldier : public CreatureScript

_clicker = Clicker;
Player* player = _clicker->ToPlayer();
ObjectGuid playerGUID = player->GetGUID();

if (player->HasItemCount(PAXTON_PRAYER_BOOK, 1, false))
{
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
me->CastSpell(me, SPELL_HEAL_VISUAL, true);
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
me->SetStandState(UNIT_STAND_STATE_STAND);

me->GetScheduler().Schedule(Milliseconds(1000), [this](TaskContext /*task*/)
me->GetScheduler().Schedule(Milliseconds(1000), [this, playerGUID](TaskContext /*task*/)
{
if (_clicker)
me->SetFacingToObject(_clicker);

me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
if (Player* player = ObjectAccessor::GetPlayer(*me, playerGUID))
{
me->SetFacingToObject(player);
me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
Talk(0);
}
});

me->GetScheduler().Schedule(Milliseconds(3000), [this](TaskContext /*task*/)
Expand All @@ -198,15 +216,15 @@ class npc_stormwind_injured_soldier : public CreatureScript
{
npc_escortAI::MoveInLineOfSight(who);

if (me->GetStandState() == UNIT_STAND_STATE_STAND)
return;

if (!who || !who->IsPlayer())
return;

Player* player = who->ToPlayer();

if (!player)
return;

if (player->HasItemCount(PAXTON_PRAYER_BOOK, 1, false))
if (player && player->HasItemCount(PAXTON_PRAYER_BOOK, 1, false))
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
else
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
Expand Down
Loading