Scripts/Tanaris: move Aquementas to SAI & improve related event (#20464)

* Script/Tanaris: move Aquementas to SAI and improve related event

Closes #11668

(cherry picked from commit 8888e6d96d)
This commit is contained in:
Wyreth
2017-11-02 05:36:27 +01:00
committed by funjoker
parent 28a4a3bc46
commit 0c6447f94c
2 changed files with 45 additions and 121 deletions

View File

@@ -35,127 +35,6 @@ EndContentData */
#include "ScriptedFollowerAI.h"
#include "ScriptedGossip.h"
/*######
## npc_aquementas
######*/
enum Aquementas
{
AGGRO_YELL_AQUE = 0,
SPELL_AQUA_JET = 13586,
SPELL_FROST_SHOCK = 15089,
ITEM_BOOK_OF_AQUOR = 11169,
ITEM_SILVERY_CLAWS = 11172,
ITEM_IRONTREE_HEART = 11173,
ITEM_SILVER_TOTEM = 11522
};
class npc_aquementas : public CreatureScript
{
public:
npc_aquementas() : CreatureScript("npc_aquementas") { }
CreatureAI* GetAI(Creature* creature) const override
{
return new npc_aquementasAI (creature);
}
struct npc_aquementasAI : public ScriptedAI
{
npc_aquementasAI(Creature* creature) : ScriptedAI(creature)
{
Initialize();
}
void Initialize()
{
SendItemTimer = 0;
SwitchFactionTimer = 10000;
isFriendly = true;
AquaJetTimer = 5000;
FrostShockTimer = 1000;
}
uint32 SendItemTimer;
uint32 SwitchFactionTimer;
bool isFriendly;
uint32 FrostShockTimer;
uint32 AquaJetTimer;
void Reset() override
{
Initialize();
me->SetFaction(FACTION_FRIENDLY);
}
void SendItem(Unit* receiver)
{
Player* player = receiver->ToPlayer();
if (player && player->HasItemCount(ITEM_BOOK_OF_AQUOR, 1, false) &&
player->HasItemCount(ITEM_SILVERY_CLAWS, 11, false) &&
player->HasItemCount(ITEM_IRONTREE_HEART, 1, false) &&
!player->HasItemCount(ITEM_SILVER_TOTEM, 1, true))
{
ItemPosCountVec dest;
uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 11522, 1, nullptr);
if (msg == EQUIP_ERR_OK)
player->StoreNewItem(dest, ITEM_SILVER_TOTEM, true);
}
}
void EnterCombat(Unit* who) override
{
Talk(AGGRO_YELL_AQUE, who);
}
void UpdateAI(uint32 diff) override
{
if (isFriendly)
{
if (SwitchFactionTimer <= diff)
{
me->SetFaction(FACTION_ELEMENTAL);
isFriendly = false;
} else SwitchFactionTimer -= diff;
}
if (!UpdateVictim())
return;
if (!isFriendly)
{
if (SendItemTimer <= diff)
{
if (me->GetVictim() && me->EnsureVictim()->GetTypeId() == TYPEID_PLAYER)
SendItem(me->GetVictim());
SendItemTimer = 5000;
} else SendItemTimer -= diff;
}
if (FrostShockTimer <= diff)
{
DoCastVictim(SPELL_FROST_SHOCK);
FrostShockTimer = 15000;
} else FrostShockTimer -= diff;
if (AquaJetTimer <= diff)
{
DoCast(me, SPELL_AQUA_JET);
AquaJetTimer = 15000;
} else AquaJetTimer -= diff;
DoMeleeAttackIfReady();
}
};
};
/*######
## npc_custodian_of_time
######*/