refactor(Core/Scripts): restyle scripts lib with astyle (#3467)

This commit is contained in:
Kargatum
2020-10-11 15:35:34 +07:00
committed by GitHub
parent 4cca286a4d
commit 5e20b46812
538 changed files with 92888 additions and 91297 deletions

View File

@@ -31,259 +31,259 @@ enum DeathKnightSpells
class npc_pet_dk_ebon_gargoyle : public CreatureScript
{
public:
npc_pet_dk_ebon_gargoyle() : CreatureScript("npc_pet_dk_ebon_gargoyle") { }
public:
npc_pet_dk_ebon_gargoyle() : CreatureScript("npc_pet_dk_ebon_gargoyle") { }
struct npc_pet_dk_ebon_gargoyleAI : ScriptedAI
struct npc_pet_dk_ebon_gargoyleAI : ScriptedAI
{
npc_pet_dk_ebon_gargoyleAI(Creature* creature) : ScriptedAI(creature)
{
npc_pet_dk_ebon_gargoyleAI(Creature* creature) : ScriptedAI(creature)
{
_despawnTimer = 36000; // 30 secs + 4 fly out + 2 initial attack timer
_despawning = false;
_initialSelection = true;
_targetGUID = 0;
}
void MovementInform(uint32 type, uint32 point)
{
if (type == POINT_MOTION_TYPE && point == 1)
{
me->SetCanFly(false);
me->SetDisableGravity(false);
}
}
void InitializeAI()
{
ScriptedAI::InitializeAI();
Unit* owner = me->GetOwner();
if (!owner)
return;
// Xinef: Night of the Dead avoidance
if (Aura *aur = me->GetAura(SPELL_DK_NIGHT_OF_THE_DEAD))
if (Unit* owner = me->GetOwner())
if (AuraEffect *aurEff = owner->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2718, 0))
if (aur->GetEffect(0))
aur->GetEffect(0)->SetAmount(-aurEff->GetSpellInfo()->Effects[EFFECT_2].CalcValue());
float tz = me->GetMap()->GetHeight(me->GetPhaseMask(), me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), true, MAX_FALL_DISTANCE);
me->GetMotionMaster()->MoveCharge(me->GetPositionX(), me->GetPositionY(), tz, 7.0f, 1);
me->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
me->SetCanFly(true);
me->SetDisableGravity(true);
_selectionTimer = 2000;
_initialCastTimer = 0;
}
void MySelectNextTarget()
{
Unit* owner = me->GetOwner();
if (owner && owner->GetTypeId() == TYPEID_PLAYER && (!me->GetVictim() || me->GetVictim()->IsImmunedToSpell(sSpellMgr->GetSpellInfo(51963)) || !me->IsValidAttackTarget(me->GetVictim()) || !owner->CanSeeOrDetect(me->GetVictim())))
{
Unit* selection = owner->ToPlayer()->GetSelectedUnit();
if (selection && selection != me->GetVictim() && me->IsValidAttackTarget(selection))
{
me->GetMotionMaster()->Clear(false);
SetGazeOn(selection);
}
else if (!me->GetVictim() || !owner->CanSeeOrDetect(me->GetVictim()))
{
me->CombatStop(true);
me->GetMotionMaster()->Clear(false);
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, 0.0f);
RemoveTargetAura();
}
}
}
void AttackStart(Unit* who)
{
RemoveTargetAura();
_targetGUID = who->GetGUID();
me->AddAura(SPELL_DK_SUMMON_GARGOYLE_1, who);
ScriptedAI::AttackStart(who);
}
void RemoveTargetAura()
{
if (Unit* target = ObjectAccessor::GetUnit(*me, _targetGUID))
target->RemoveAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetGUID());
}
void Reset()
{
_selectionTimer = 0;
me->SetReactState(REACT_PASSIVE);
MySelectNextTarget();
}
// Fly away when dismissed
void FlyAway()
{
RemoveTargetAura();
// Stop Fighting
me->CombatStop(true);
me->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE, true);
// Sanctuary
me->CastSpell(me, SPELL_DK_SANCTUARY, true);
me->SetReactState(REACT_PASSIVE);
me->SetSpeed(MOVE_FLIGHT, 1.0f, true);
me->SetSpeed(MOVE_RUN, 1.0f, true);
float x = me->GetPositionX() + 20 * cos(me->GetOrientation());
float y = me->GetPositionY() + 20 * sin(me->GetOrientation());
float z = me->GetPositionZ() + 40;
me->DisableSpline();
me->GetMotionMaster()->Clear(false);
me->GetMotionMaster()->MoveCharge(x, y, z, 7.0f, 1);
me->SetCanFly(true);
me->SetDisableGravity(true);
_despawning = true;
}
void UpdateAI(uint32 diff)
{
if (_initialSelection)
{
_initialSelection = false;
// Find victim of Summon Gargoyle spell
std::list<Unit*> targets;
acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 50);
acore::UnitListSearcher<acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
me->VisitNearbyObject(50, searcher);
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
if ((*iter)->GetAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID()))
{
(*iter)->RemoveAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID());
SetGazeOn(*iter);
_targetGUID = (*iter)->GetGUID();
break;
}
}
if (_despawnTimer > 4000)
{
_despawnTimer -= diff;
if (!UpdateVictimWithGaze())
{
MySelectNextTarget();
return;
}
_initialCastTimer += diff;
_selectionTimer += diff;
if (_selectionTimer >= 1000)
{
MySelectNextTarget();
_selectionTimer = 0;
}
if (_initialCastTimer >= 2000 && !me->HasUnitState(UNIT_STATE_CASTING | UNIT_STATE_LOST_CONTROL) && me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) == NULL_MOTION_TYPE)
me->CastSpell(me->GetVictim(), 51963, false);
}
else
{
if (!_despawning)
FlyAway();
if (_despawnTimer > diff)
_despawnTimer -= diff;
else
me->DespawnOrUnsummon();
}
}
private:
uint64 _targetGUID;
uint32 _despawnTimer;
uint32 _selectionTimer;
uint32 _initialCastTimer;
bool _despawning;
bool _initialSelection;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_dk_ebon_gargoyleAI(creature);
_despawnTimer = 36000; // 30 secs + 4 fly out + 2 initial attack timer
_despawning = false;
_initialSelection = true;
_targetGUID = 0;
}
void MovementInform(uint32 type, uint32 point)
{
if (type == POINT_MOTION_TYPE && point == 1)
{
me->SetCanFly(false);
me->SetDisableGravity(false);
}
}
void InitializeAI()
{
ScriptedAI::InitializeAI();
Unit* owner = me->GetOwner();
if (!owner)
return;
// Xinef: Night of the Dead avoidance
if (Aura* aur = me->GetAura(SPELL_DK_NIGHT_OF_THE_DEAD))
if (Unit* owner = me->GetOwner())
if (AuraEffect* aurEff = owner->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2718, 0))
if (aur->GetEffect(0))
aur->GetEffect(0)->SetAmount(-aurEff->GetSpellInfo()->Effects[EFFECT_2].CalcValue());
float tz = me->GetMap()->GetHeight(me->GetPhaseMask(), me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), true, MAX_FALL_DISTANCE);
me->GetMotionMaster()->MoveCharge(me->GetPositionX(), me->GetPositionY(), tz, 7.0f, 1);
me->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
me->SetCanFly(true);
me->SetDisableGravity(true);
_selectionTimer = 2000;
_initialCastTimer = 0;
}
void MySelectNextTarget()
{
Unit* owner = me->GetOwner();
if (owner && owner->GetTypeId() == TYPEID_PLAYER && (!me->GetVictim() || me->GetVictim()->IsImmunedToSpell(sSpellMgr->GetSpellInfo(51963)) || !me->IsValidAttackTarget(me->GetVictim()) || !owner->CanSeeOrDetect(me->GetVictim())))
{
Unit* selection = owner->ToPlayer()->GetSelectedUnit();
if (selection && selection != me->GetVictim() && me->IsValidAttackTarget(selection))
{
me->GetMotionMaster()->Clear(false);
SetGazeOn(selection);
}
else if (!me->GetVictim() || !owner->CanSeeOrDetect(me->GetVictim()))
{
me->CombatStop(true);
me->GetMotionMaster()->Clear(false);
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, 0.0f);
RemoveTargetAura();
}
}
}
void AttackStart(Unit* who)
{
RemoveTargetAura();
_targetGUID = who->GetGUID();
me->AddAura(SPELL_DK_SUMMON_GARGOYLE_1, who);
ScriptedAI::AttackStart(who);
}
void RemoveTargetAura()
{
if (Unit* target = ObjectAccessor::GetUnit(*me, _targetGUID))
target->RemoveAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetGUID());
}
void Reset()
{
_selectionTimer = 0;
me->SetReactState(REACT_PASSIVE);
MySelectNextTarget();
}
// Fly away when dismissed
void FlyAway()
{
RemoveTargetAura();
// Stop Fighting
me->CombatStop(true);
me->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE, true);
// Sanctuary
me->CastSpell(me, SPELL_DK_SANCTUARY, true);
me->SetReactState(REACT_PASSIVE);
me->SetSpeed(MOVE_FLIGHT, 1.0f, true);
me->SetSpeed(MOVE_RUN, 1.0f, true);
float x = me->GetPositionX() + 20 * cos(me->GetOrientation());
float y = me->GetPositionY() + 20 * sin(me->GetOrientation());
float z = me->GetPositionZ() + 40;
me->DisableSpline();
me->GetMotionMaster()->Clear(false);
me->GetMotionMaster()->MoveCharge(x, y, z, 7.0f, 1);
me->SetCanFly(true);
me->SetDisableGravity(true);
_despawning = true;
}
void UpdateAI(uint32 diff)
{
if (_initialSelection)
{
_initialSelection = false;
// Find victim of Summon Gargoyle spell
std::list<Unit*> targets;
acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 50);
acore::UnitListSearcher<acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
me->VisitNearbyObject(50, searcher);
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
if ((*iter)->GetAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID()))
{
(*iter)->RemoveAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID());
SetGazeOn(*iter);
_targetGUID = (*iter)->GetGUID();
break;
}
}
if (_despawnTimer > 4000)
{
_despawnTimer -= diff;
if (!UpdateVictimWithGaze())
{
MySelectNextTarget();
return;
}
_initialCastTimer += diff;
_selectionTimer += diff;
if (_selectionTimer >= 1000)
{
MySelectNextTarget();
_selectionTimer = 0;
}
if (_initialCastTimer >= 2000 && !me->HasUnitState(UNIT_STATE_CASTING | UNIT_STATE_LOST_CONTROL) && me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) == NULL_MOTION_TYPE)
me->CastSpell(me->GetVictim(), 51963, false);
}
else
{
if (!_despawning)
FlyAway();
if (_despawnTimer > diff)
_despawnTimer -= diff;
else
me->DespawnOrUnsummon();
}
}
private:
uint64 _targetGUID;
uint32 _despawnTimer;
uint32 _selectionTimer;
uint32 _initialCastTimer;
bool _despawning;
bool _initialSelection;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_dk_ebon_gargoyleAI(creature);
}
};
class npc_pet_dk_ghoul : public CreatureScript
{
public:
npc_pet_dk_ghoul() : CreatureScript("npc_pet_dk_ghoul") { }
public:
npc_pet_dk_ghoul() : CreatureScript("npc_pet_dk_ghoul") { }
struct npc_pet_dk_ghoulAI : public CombatAI
struct npc_pet_dk_ghoulAI : public CombatAI
{
npc_pet_dk_ghoulAI(Creature* c) : CombatAI(c) { }
void JustDied(Unit* /*who*/)
{
npc_pet_dk_ghoulAI(Creature *c) : CombatAI(c) { }
void JustDied(Unit * /*who*/)
{
if (me->IsGuardian() || me->IsSummon())
me->ToTempSummon()->UnSummon();
}
};
CreatureAI* GetAI(Creature* pCreature) const
{
return new npc_pet_dk_ghoulAI (pCreature);
if (me->IsGuardian() || me->IsSummon())
me->ToTempSummon()->UnSummon();
}
};
CreatureAI* GetAI(Creature* pCreature) const
{
return new npc_pet_dk_ghoulAI (pCreature);
}
};
class npc_pet_dk_army_of_the_dead : public CreatureScript
{
public:
npc_pet_dk_army_of_the_dead() : CreatureScript("npc_pet_dk_army_of_the_dead") { }
public:
npc_pet_dk_army_of_the_dead() : CreatureScript("npc_pet_dk_army_of_the_dead") { }
struct npc_pet_dk_army_of_the_deadAI : public CombatAI
struct npc_pet_dk_army_of_the_deadAI : public CombatAI
{
npc_pet_dk_army_of_the_deadAI(Creature* creature) : CombatAI(creature) { }
void InitializeAI()
{
npc_pet_dk_army_of_the_deadAI(Creature* creature) : CombatAI(creature) { }
CombatAI::InitializeAI();
((Minion*)me)->SetFollowAngle(rand_norm() * 2 * M_PI);
void InitializeAI()
{
CombatAI::InitializeAI();
((Minion*)me)->SetFollowAngle(rand_norm()*2*M_PI);
// Heroism / Bloodlust immunity
me->ApplySpellImmune(0, IMMUNITY_ID, 32182, true);
me->ApplySpellImmune(0, IMMUNITY_ID, 2825, true);
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_dk_army_of_the_deadAI (creature);
// Heroism / Bloodlust immunity
me->ApplySpellImmune(0, IMMUNITY_ID, 32182, true);
me->ApplySpellImmune(0, IMMUNITY_ID, 2825, true);
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_dk_army_of_the_deadAI (creature);
}
};
class npc_pet_dk_dancing_rune_weapon : public CreatureScript
{
public:
npc_pet_dk_dancing_rune_weapon() : CreatureScript("npc_pet_dk_dancing_rune_weapon") { }
public:
npc_pet_dk_dancing_rune_weapon() : CreatureScript("npc_pet_dk_dancing_rune_weapon") { }
struct npc_pet_dk_dancing_rune_weaponAI : public NullCreatureAI
struct npc_pet_dk_dancing_rune_weaponAI : public NullCreatureAI
{
npc_pet_dk_dancing_rune_weaponAI(Creature* creature) : NullCreatureAI(creature) { }
void InitializeAI()
{
npc_pet_dk_dancing_rune_weaponAI(Creature* creature) : NullCreatureAI(creature) { }
// Xinef: Hit / Expertise scaling
me->AddAura(61017, me);
if (Unit* owner = me->GetOwner())
me->GetMotionMaster()->MoveFollow(owner, 0.01f, me->GetFollowAngle(), MOTION_SLOT_CONTROLLED);
void InitializeAI()
{
// Xinef: Hit / Expertise scaling
me->AddAura(61017, me);
if (Unit* owner = me->GetOwner())
me->GetMotionMaster()->MoveFollow(owner, 0.01f, me->GetFollowAngle(), MOTION_SLOT_CONTROLLED);
NullCreatureAI::InitializeAI();
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_dk_dancing_rune_weaponAI (creature);
NullCreatureAI::InitializeAI();
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_dk_dancing_rune_weaponAI (creature);
}
};
void AddSC_deathknight_pet_scripts()

View File

@@ -30,55 +30,55 @@ enum Mojo
class npc_pet_gen_mojo : public CreatureScript
{
public:
npc_pet_gen_mojo() : CreatureScript("npc_pet_gen_mojo") { }
public:
npc_pet_gen_mojo() : CreatureScript("npc_pet_gen_mojo") { }
struct npc_pet_gen_mojoAI : public ScriptedAI
struct npc_pet_gen_mojoAI : public ScriptedAI
{
npc_pet_gen_mojoAI(Creature* creature) : ScriptedAI(creature) { }
void Reset()
{
npc_pet_gen_mojoAI(Creature* creature) : ScriptedAI(creature) { }
_victimGUID = 0;
void Reset()
{
_victimGUID = 0;
if (Unit* owner = me->GetOwner())
me->GetMotionMaster()->MoveFollow(owner, 0.0f, 0.0f);
}
void EnterCombat(Unit* /*who*/) { }
void UpdateAI(uint32 /*diff*/) { }
void ReceiveEmote(Player* player, uint32 emote)
{
me->HandleEmoteCommand(emote);
Unit* owner = me->GetOwner();
if (emote != TEXT_EMOTE_KISS || !owner || owner->GetTypeId() != TYPEID_PLAYER ||
owner->ToPlayer()->GetTeamId(true) != player->GetTeamId(true))
{
return;
}
Talk(SAY_MOJO, player);
if (_victimGUID)
if (Player* victim = ObjectAccessor::GetPlayer(*me, _victimGUID))
victim->RemoveAura(SPELL_FEELING_FROGGY);
_victimGUID = player->GetGUID();
DoCast(player, SPELL_FEELING_FROGGY, true);
DoCast(me, SPELL_SEDUCTION_VISUAL, true);
me->GetMotionMaster()->MoveFollow(player, 0.0f, 0.0f);
}
private:
uint64 _victimGUID;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_gen_mojoAI(creature);
if (Unit* owner = me->GetOwner())
me->GetMotionMaster()->MoveFollow(owner, 0.0f, 0.0f);
}
void EnterCombat(Unit* /*who*/) { }
void UpdateAI(uint32 /*diff*/) { }
void ReceiveEmote(Player* player, uint32 emote)
{
me->HandleEmoteCommand(emote);
Unit* owner = me->GetOwner();
if (emote != TEXT_EMOTE_KISS || !owner || owner->GetTypeId() != TYPEID_PLAYER ||
owner->ToPlayer()->GetTeamId(true) != player->GetTeamId(true))
{
return;
}
Talk(SAY_MOJO, player);
if (_victimGUID)
if (Player* victim = ObjectAccessor::GetPlayer(*me, _victimGUID))
victim->RemoveAura(SPELL_FEELING_FROGGY);
_victimGUID = player->GetGUID();
DoCast(player, SPELL_FEELING_FROGGY, true);
DoCast(me, SPELL_SEDUCTION_VISUAL, true);
me->GetMotionMaster()->MoveFollow(player, 0.0f, 0.0f);
}
private:
uint64 _victimGUID;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_gen_mojoAI(creature);
}
};
enum soulTrader
@@ -102,7 +102,7 @@ public:
{
uint64 ownerGUID;
EventMap events;
npc_pet_gen_soul_trader_beaconAI(Creature *c) : ScriptedAI(c)
npc_pet_gen_soul_trader_beaconAI(Creature* c) : ScriptedAI(c)
{
events.Reset();
events.ScheduleEvent(EVENT_INITIAL_TALK, 0);
@@ -214,7 +214,7 @@ public:
struct npc_pet_gen_argent_pony_bridleAI : public ScriptedAI
{
npc_pet_gen_argent_pony_bridleAI(Creature *c) : ScriptedAI(c)
npc_pet_gen_argent_pony_bridleAI(Creature* c) : ScriptedAI(c)
{
_state = ARGENT_PONY_STATE_NONE;
_init = false;
@@ -256,10 +256,10 @@ public:
{
if (player->GetTeamId(true) == TEAM_ALLIANCE)
{
if (uint32 cooldown = player->GetSpellCooldownDelay(SPELL_AURA_POSTMAN_S+i))
if (uint32 cooldown = player->GetSpellCooldownDelay(SPELL_AURA_POSTMAN_S + i))
{
duration = cooldown;
aura = SPELL_AURA_POSTMAN_S+i;
aura = SPELL_AURA_POSTMAN_S + i;
_state = argentPonyService[TEAM_ALLIANCE][i];
me->ToTempSummon()->UnSummon(duration);
break;
@@ -267,10 +267,10 @@ public:
}
else
{
if (uint32 cooldown = player->GetSpellCooldownDelay(SPELL_AURA_BANK_G+i))
if (uint32 cooldown = player->GetSpellCooldownDelay(SPELL_AURA_BANK_G + i))
{
duration = cooldown*IN_MILLISECONDS;
aura = SPELL_AURA_BANK_G+i;
duration = cooldown * IN_MILLISECONDS;
aura = SPELL_AURA_BANK_G + i;
_state = argentPonyService[TEAM_HORDE][i];
me->ToTempSummon()->UnSummon(duration);
break;
@@ -281,7 +281,7 @@ public:
// Generate Banners
uint32 mask = player->GetTeamId(true) ? RACEMASK_HORDE : RACEMASK_ALLIANCE;
for (uint8 i = 1; i < MAX_RACES; ++i)
if (mask & (1 << (i-1)) && player->HasAchieved(argentBanners[i].achievement))
if (mask & (1 << (i - 1)) && player->HasAchieved(argentBanners[i].achievement))
_banners[i] = true;
}
@@ -331,12 +331,12 @@ public:
_state = param;
}
private:
bool _init;
uint8 _state;
int32 _mountTimer;
bool _banners[MAX_RACES];
uint32 _lastAura;
private:
bool _init;
uint8 _state;
int32 _mountTimer;
bool _banners[MAX_RACES];
uint32 _lastAura;
};
bool OnGossipHello(Player* player, Creature* creature) override
@@ -382,13 +382,13 @@ public:
creature->AI()->DoAction(ARGENT_PONY_STATE_BANK);
break;
case GOSSIP_ACTION_MAILBOX:
{
creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP|UNIT_NPC_FLAG_MAILBOX);
player->GetSession()->SendShowMailBox(creature->GetGUID());
spellId = player->GetTeamId(true) ? SPELL_AURA_POSTMAN_G : SPELL_AURA_POSTMAN_S;
creature->AI()->DoAction(ARGENT_PONY_STATE_MAILBOX);
break;
}
{
creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_MAILBOX);
player->GetSession()->SendShowMailBox(creature->GetGUID());
spellId = player->GetTeamId(true) ? SPELL_AURA_POSTMAN_G : SPELL_AURA_POSTMAN_S;
creature->AI()->DoAction(ARGENT_PONY_STATE_MAILBOX);
break;
}
default:
if (action > 60000)
{
@@ -401,9 +401,9 @@ public:
if (spellId && !creature->HasAura(spellId))
{
creature->CastSpell(creature, spellId, true);
player->AddSpellCooldown(spellId, 0, 3*MINUTE*IN_MILLISECONDS);
player->AddSpellCooldown(player->GetTeamId(true) ? SPELL_AURA_TIRED_G : SPELL_AURA_TIRED_S, 0, 3*MINUTE*IN_MILLISECONDS + 4*HOUR*IN_MILLISECONDS);
creature->DespawnOrUnsummon(3*MINUTE*IN_MILLISECONDS);
player->AddSpellCooldown(spellId, 0, 3 * MINUTE * IN_MILLISECONDS);
player->AddSpellCooldown(player->GetTeamId(true) ? SPELL_AURA_TIRED_G : SPELL_AURA_TIRED_S, 0, 3 * MINUTE * IN_MILLISECONDS + 4 * HOUR * IN_MILLISECONDS);
creature->DespawnOrUnsummon(3 * MINUTE * IN_MILLISECONDS);
}
return true;
}
@@ -433,16 +433,22 @@ public:
struct npc_pet_gen_target_following_bombAI : public NullCreatureAI
{
npc_pet_gen_target_following_bombAI(Creature *c) : NullCreatureAI(c)
npc_pet_gen_target_following_bombAI(Creature* c) : NullCreatureAI(c)
{
checkTimer = 0;
bombSpellId = 0;
switch (me->GetEntry())
{
case NPC_EXPLOSIVE_SHEEP: bombSpellId = SPELL_EXPLOSIVE_SHEEP; break;
case NPC_GOBLIN_BOMB: bombSpellId = SPELL_EXPLOSIVE_GOBLIN; break;
case NPC_HIGH_EXPLOSIVE_SHEEP: bombSpellId = SPELL_HIGH_EXPLOSIVE_SHEEP; break;
case NPC_EXPLOSIVE_SHEEP:
bombSpellId = SPELL_EXPLOSIVE_SHEEP;
break;
case NPC_GOBLIN_BOMB:
bombSpellId = SPELL_EXPLOSIVE_GOBLIN;
break;
case NPC_HIGH_EXPLOSIVE_SHEEP:
bombSpellId = SPELL_HIGH_EXPLOSIVE_SHEEP;
break;
}
}
@@ -488,7 +494,7 @@ public:
struct npc_pet_gen_gnomish_flame_turretAI : public ScriptedAI
{
npc_pet_gen_gnomish_flame_turretAI(Creature *c) : ScriptedAI(c)
npc_pet_gen_gnomish_flame_turretAI(Creature* c) : ScriptedAI(c)
{
checkTimer = 0;
}
@@ -535,7 +541,7 @@ public:
struct npc_pet_gen_valkyr_guardianAI : public ScriptedAI
{
npc_pet_gen_valkyr_guardianAI(Creature *c) : ScriptedAI(c)
npc_pet_gen_valkyr_guardianAI(Creature* c) : ScriptedAI(c)
{
me->SetReactState(REACT_DEFENSIVE);
me->SetDisableGravity(true);
@@ -590,34 +596,34 @@ public:
class spell_pet_gen_valkyr_guardian_smite : public SpellScriptLoader
{
public:
spell_pet_gen_valkyr_guardian_smite() : SpellScriptLoader("spell_pet_gen_valkyr_guardian_smite") { }
public:
spell_pet_gen_valkyr_guardian_smite() : SpellScriptLoader("spell_pet_gen_valkyr_guardian_smite") { }
class spell_pet_gen_valkyr_guardian_smite_SpellScript : public SpellScript
class spell_pet_gen_valkyr_guardian_smite_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pet_gen_valkyr_guardian_smite_SpellScript);
void RecalculateDamage()
{
PrepareSpellScript(spell_pet_gen_valkyr_guardian_smite_SpellScript);
void RecalculateDamage()
if (GetHitUnit() != GetCaster())
{
if (GetHitUnit() != GetCaster())
{
std::list<Spell::TargetInfo>* targetsInfo = GetSpell()->GetUniqueTargetInfo();
for (std::list<Spell::TargetInfo>::iterator ihit = targetsInfo->begin(); ihit != targetsInfo->end(); ++ihit)
if (ihit->targetGUID == GetCaster()->GetGUID())
ihit->damage = -int32(GetHitDamage()*0.25f);
}
std::list<Spell::TargetInfo>* targetsInfo = GetSpell()->GetUniqueTargetInfo();
for (std::list<Spell::TargetInfo>::iterator ihit = targetsInfo->begin(); ihit != targetsInfo->end(); ++ihit)
if (ihit->targetGUID == GetCaster()->GetGUID())
ihit->damage = -int32(GetHitDamage() * 0.25f);
}
void Register()
{
OnHit += SpellHitFn(spell_pet_gen_valkyr_guardian_smite_SpellScript::RecalculateDamage);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pet_gen_valkyr_guardian_smite_SpellScript();
}
void Register()
{
OnHit += SpellHitFn(spell_pet_gen_valkyr_guardian_smite_SpellScript::RecalculateDamage);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pet_gen_valkyr_guardian_smite_SpellScript();
}
};
class npc_pet_gen_imp_in_a_bottle : public CreatureScript
@@ -627,7 +633,7 @@ public:
struct npc_pet_gen_imp_in_a_bottleAI : public NullCreatureAI
{
npc_pet_gen_imp_in_a_bottleAI(Creature *c) : NullCreatureAI(c)
npc_pet_gen_imp_in_a_bottleAI(Creature* c) : NullCreatureAI(c)
{
_talkTimer = 0;
_ownerGUID = 0;
@@ -661,7 +667,7 @@ public:
_data << uint32(me->GetName().size() + 1);
_data << me->GetName();
_data << uint64(0);
_data << uint32(text.size()+1);
_data << uint32(text.size() + 1);
_data << text.c_str();
_data << uint8(0);
}
@@ -705,7 +711,7 @@ public:
struct npc_pet_gen_wind_rider_cubAI : public NullCreatureAI
{
npc_pet_gen_wind_rider_cubAI(Creature *c) : NullCreatureAI(c)
npc_pet_gen_wind_rider_cubAI(Creature* c) : NullCreatureAI(c)
{
isFlying = true;
checkTimer = 0;
@@ -762,7 +768,7 @@ public:
struct npc_pet_gen_plump_turkeyAI : public PassiveAI
{
npc_pet_gen_plump_turkeyAI(Creature *c) : PassiveAI(c)
npc_pet_gen_plump_turkeyAI(Creature* c) : PassiveAI(c)
{
goGUID = 0;
jumpTimer = 0;
@@ -831,7 +837,7 @@ public:
struct npc_pet_gen_toxic_wastelingAI : public PassiveAI
{
npc_pet_gen_toxic_wastelingAI(Creature *c) : PassiveAI(c)
npc_pet_gen_toxic_wastelingAI(Creature* c) : PassiveAI(c)
{
}
@@ -883,7 +889,7 @@ public:
struct npc_pet_gen_fetch_ballAI : public NullCreatureAI
{
npc_pet_gen_fetch_ballAI(Creature *c) : NullCreatureAI(c)
npc_pet_gen_fetch_ballAI(Creature* c) : NullCreatureAI(c)
{
}
@@ -940,7 +946,7 @@ public:
struct npc_pet_gen_mothAI : public NullCreatureAI
{
npc_pet_gen_mothAI(Creature *c) : NullCreatureAI(c)
npc_pet_gen_mothAI(Creature* c) : NullCreatureAI(c)
{
me->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
me->SetCanFly(true);

View File

@@ -28,118 +28,118 @@ enum HunterCreatures
class npc_pet_hunter_snake_trap : public CreatureScript
{
public:
npc_pet_hunter_snake_trap() : CreatureScript("npc_pet_hunter_snake_trap") { }
public:
npc_pet_hunter_snake_trap() : CreatureScript("npc_pet_hunter_snake_trap") { }
struct npc_pet_hunter_snake_trapAI : public ScriptedAI
struct npc_pet_hunter_snake_trapAI : public ScriptedAI
{
npc_pet_hunter_snake_trapAI(Creature* creature) : ScriptedAI(creature) { _init = false; }
void Reset()
{
npc_pet_hunter_snake_trapAI(Creature* creature) : ScriptedAI(creature) { _init = false; }
_spellTimer = urand(1500, 3000);
void Reset()
{
_spellTimer = urand(1500, 3000);
// Start attacking attacker of owner on first ai update after spawn - move in line of sight may choose better target
if (!me->GetVictim())
if (Unit *tgt = me->SelectNearestTarget(10.0f))
{
me->AddThreat(tgt, 100000.0f);
AttackStart(tgt);
}
}
void EnterEvadeMode()
{
// _EnterEvadeMode();
me->DeleteThreatList();
me->CombatStop(true);
me->LoadCreaturesAddon(true);
me->SetLootRecipient(nullptr);
me->ResetPlayerDamageReq();
me->SetLastDamagedTime(0);
me->AddUnitState(UNIT_STATE_EVADE);
me->GetMotionMaster()->MoveTargetedHome();
Reset();
}
//Redefined for random target selection:
void MoveInLineOfSight(Unit* who)
{
if (!me->GetVictim() && who->isTargetableForAttack() && (me->IsHostileTo(who)) && who->isInAccessiblePlaceFor(me))
// Start attacking attacker of owner on first ai update after spawn - move in line of sight may choose better target
if (!me->GetVictim())
if (Unit* tgt = me->SelectNearestTarget(10.0f))
{
if (me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
return;
if (me->IsWithinDistInMap(who, 10.0f))
{
me->AddThreat(who, 100000.0f);
AttackStart(who);
}
me->AddThreat(tgt, 100000.0f);
AttackStart(tgt);
}
}
void UpdateAI(uint32 diff)
{
if (!UpdateVictim())
return;
if (me->GetVictim()->HasBreakableByDamageCrowdControlAura(me))
{
me->InterruptNonMeleeSpells(false);
return;
}
if (!_init)
{
_init = true;
CreatureTemplate const* Info = me->GetCreatureTemplate();
uint32 health = uint32(107 * (me->getLevel() - 40) * 0.025f);
me->SetCreateHealth(health);
for (uint8 stat = 0; stat < MAX_STATS; ++stat)
{
me->SetStat(Stats(stat), 0);
me->SetCreateStat(Stats(stat), 0);
}
me->SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, (float)health);
me->SetMaxHealth(health);
//Add delta to make them not all hit the same time
uint32 delta = urand(0, 700);
me->SetAttackTime(BASE_ATTACK, Info->BaseAttackTime + delta);
me->SetStatFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER , float(Info->attackpower));
me->CastSpell(me, SPELL_HUNTER_DEADLY_POISON_PASSIVE, true);
// Glyph of Snake Trap
if (Unit* owner = me->GetOwner())
if (owner->GetAuraEffectDummy(SPELL_HUNTER_GLYPH_OF_SNAKE_TRAP))
me->CastSpell(me, SPELL_HUNTER_PET_SCALING, true);
}
_spellTimer += diff;
if (_spellTimer >= 3000)
{
if (urand(0, 2) == 0) // 33% chance to cast
DoCastVictim(RAND(SPELL_HUNTER_MIND_NUMBING_POISON, SPELL_HUNTER_CRIPPLING_POISON));
_spellTimer = 0;
}
DoMeleeAttackIfReady();
}
private:
bool _init;
uint32 _spellTimer;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_hunter_snake_trapAI(creature);
}
void EnterEvadeMode()
{
// _EnterEvadeMode();
me->DeleteThreatList();
me->CombatStop(true);
me->LoadCreaturesAddon(true);
me->SetLootRecipient(nullptr);
me->ResetPlayerDamageReq();
me->SetLastDamagedTime(0);
me->AddUnitState(UNIT_STATE_EVADE);
me->GetMotionMaster()->MoveTargetedHome();
Reset();
}
//Redefined for random target selection:
void MoveInLineOfSight(Unit* who)
{
if (!me->GetVictim() && who->isTargetableForAttack() && (me->IsHostileTo(who)) && who->isInAccessiblePlaceFor(me))
{
if (me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
return;
if (me->IsWithinDistInMap(who, 10.0f))
{
me->AddThreat(who, 100000.0f);
AttackStart(who);
}
}
}
void UpdateAI(uint32 diff)
{
if (!UpdateVictim())
return;
if (me->GetVictim()->HasBreakableByDamageCrowdControlAura(me))
{
me->InterruptNonMeleeSpells(false);
return;
}
if (!_init)
{
_init = true;
CreatureTemplate const* Info = me->GetCreatureTemplate();
uint32 health = uint32(107 * (me->getLevel() - 40) * 0.025f);
me->SetCreateHealth(health);
for (uint8 stat = 0; stat < MAX_STATS; ++stat)
{
me->SetStat(Stats(stat), 0);
me->SetCreateStat(Stats(stat), 0);
}
me->SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, (float)health);
me->SetMaxHealth(health);
//Add delta to make them not all hit the same time
uint32 delta = urand(0, 700);
me->SetAttackTime(BASE_ATTACK, Info->BaseAttackTime + delta);
me->SetStatFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER, float(Info->attackpower));
me->CastSpell(me, SPELL_HUNTER_DEADLY_POISON_PASSIVE, true);
// Glyph of Snake Trap
if (Unit* owner = me->GetOwner())
if (owner->GetAuraEffectDummy(SPELL_HUNTER_GLYPH_OF_SNAKE_TRAP))
me->CastSpell(me, SPELL_HUNTER_PET_SCALING, true);
}
_spellTimer += diff;
if (_spellTimer >= 3000)
{
if (urand(0, 2) == 0) // 33% chance to cast
DoCastVictim(RAND(SPELL_HUNTER_MIND_NUMBING_POISON, SPELL_HUNTER_CRIPPLING_POISON));
_spellTimer = 0;
}
DoMeleeAttackIfReady();
}
private:
bool _init;
uint32 _spellTimer;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_hunter_snake_trapAI(creature);
}
};
void AddSC_hunter_pet_scripts()

View File

@@ -29,192 +29,192 @@ enum MageSpells
class DeathEvent : public BasicEvent
{
public:
DeathEvent(Creature& owner) : BasicEvent(), _owner(owner) { }
public:
DeathEvent(Creature& owner) : BasicEvent(), _owner(owner) { }
bool Execute(uint64 /*eventTime*/, uint32 /*diff*/)
{
Unit::Kill(&_owner, &_owner);
return true;
}
bool Execute(uint64 /*eventTime*/, uint32 /*diff*/)
{
Unit::Kill(&_owner, &_owner);
return true;
}
private:
Creature& _owner;
private:
Creature& _owner;
};
class npc_pet_mage_mirror_image : public CreatureScript
{
public:
npc_pet_mage_mirror_image() : CreatureScript("npc_pet_mage_mirror_image") { }
public:
npc_pet_mage_mirror_image() : CreatureScript("npc_pet_mage_mirror_image") { }
struct npc_pet_mage_mirror_imageAI : CasterAI
struct npc_pet_mage_mirror_imageAI : CasterAI
{
npc_pet_mage_mirror_imageAI(Creature* creature) : CasterAI(creature) { }
uint32 selectionTimer;
uint64 _ebonGargoyleGUID;
uint32 checktarget;
uint32 dist = urand(1, 5);
void InitializeAI()
{
npc_pet_mage_mirror_imageAI(Creature* creature) : CasterAI(creature) { }
CasterAI::InitializeAI();
Unit* owner = me->GetOwner();
if (!owner)
return;
uint32 selectionTimer;
uint64 _ebonGargoyleGUID;
uint32 checktarget;
uint32 dist = urand(1, 5);
// Clone Me!
owner->CastSpell(me, SPELL_MAGE_CLONE_ME, true);
void InitializeAI()
// xinef: Glyph of Mirror Image (4th copy)
float angle = 0.0f;
switch (me->GetUInt32Value(UNIT_CREATED_BY_SPELL))
{
CasterAI::InitializeAI();
Unit* owner = me->GetOwner();
if (!owner)
return;
case SPELL_SUMMON_MIRROR_IMAGE1:
angle = 0.5f * M_PI;
break;
case SPELL_SUMMON_MIRROR_IMAGE2:
angle = M_PI;
break;
case SPELL_SUMMON_MIRROR_IMAGE3:
angle = 1.5f * M_PI;
break;
}
// Clone Me!
owner->CastSpell(me, SPELL_MAGE_CLONE_ME, true);
((Minion*)me)->SetFollowAngle(angle);
if (owner->IsInCombat())
me->NearTeleportTo(me->GetPositionX() + cos(angle)*dist, me->GetPositionY() + sin(angle)*dist, me->GetPositionZ(), me->GetOrientation(), false, false, false, false);
else
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE);
// xinef: Glyph of Mirror Image (4th copy)
float angle = 0.0f;
switch (me->GetUInt32Value(UNIT_CREATED_BY_SPELL))
me->SetReactState(REACT_DEFENSIVE);
// Xinef: Inherit Master's Threat List (not yet implemented)
//owner->CastSpell((Unit*)NULL, SPELL_MAGE_MASTERS_THREAT_LIST, true);
HostileReference* ref = owner->getHostileRefManager().getFirst();
while (ref)
{
if (Unit* unit = ref->GetSource()->GetOwner())
unit->AddThreat(me, ref->getThreat() - ref->getTempThreatModifier());
ref = ref->next();
}
_ebonGargoyleGUID = 0;
// Xinef: copy caster auras
Unit::VisibleAuraMap const* visibleAuraMap = owner->GetVisibleAuras();
for (Unit::VisibleAuraMap::const_iterator itr = visibleAuraMap->begin(); itr != visibleAuraMap->end(); ++itr)
if (Aura* visAura = itr->second->GetBase())
{
case SPELL_SUMMON_MIRROR_IMAGE1:
angle = 0.5f * M_PI;
break;
case SPELL_SUMMON_MIRROR_IMAGE2:
angle = M_PI;
break;
case SPELL_SUMMON_MIRROR_IMAGE3:
angle = 1.5f * M_PI;
break;
// Ebon Gargoyle
if (visAura->GetId() == 49206 && me->GetUInt32Value(UNIT_CREATED_BY_SPELL) == SPELL_SUMMON_MIRROR_IMAGE1)
{
if (Unit* gargoyle = visAura->GetCaster())
_ebonGargoyleGUID = gargoyle->GetGUID();
continue;
}
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(visAura->GetId());
if (bounds.first != bounds.second)
continue;
std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(visAura->GetId() + SPELL_LINK_AURA);
if (!spellTriggered || !spellTriggered->empty())
continue;
if (Aura* newAura = me->AddAura(visAura->GetId(), me))
newAura->SetDuration(visAura->GetDuration());
}
((Minion*)me)->SetFollowAngle(angle);
if (owner->IsInCombat())
me->NearTeleportTo(me->GetPositionX() + cos(angle)*dist, me->GetPositionY() + sin(angle)*dist, me->GetPositionZ(), me->GetOrientation(), false, false, false, false);
else
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE);
me->m_Events.AddEvent(new DeathEvent(*me), me->m_Events.CalculateTime(29500));
}
me->SetReactState(REACT_DEFENSIVE);
// Do not reload Creature templates on evade mode enter - prevent visual lost
void EnterEvadeMode()
{
if (me->IsInEvadeMode() || !me->IsAlive())
return;
// Xinef: Inherit Master's Threat List (not yet implemented)
//owner->CastSpell((Unit*)NULL, SPELL_MAGE_MASTERS_THREAT_LIST, true);
HostileReference* ref = owner->getHostileRefManager().getFirst();
while (ref)
{
if (Unit* unit = ref->GetSource()->GetOwner())
unit->AddThreat(me, ref->getThreat() - ref->getTempThreatModifier());
ref = ref->next();
}
Unit* owner = me->GetCharmerOrOwner();
me->CombatStop(true);
if (owner && !me->HasUnitState(UNIT_STATE_FOLLOW))
{
me->GetMotionMaster()->Clear(false);
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE);
}
}
void MySelectNextTarget()
{
if (_ebonGargoyleGUID)
{
Unit* gargoyle = ObjectAccessor::GetUnit(*me, _ebonGargoyleGUID);
if (gargoyle && gargoyle->GetAI())
gargoyle->GetAI()->AttackStart(me);
_ebonGargoyleGUID = 0;
// Xinef: copy caster auras
Unit::VisibleAuraMap const* visibleAuraMap = owner->GetVisibleAuras();
for (Unit::VisibleAuraMap::const_iterator itr = visibleAuraMap->begin(); itr != visibleAuraMap->end(); ++itr)
if (Aura* visAura = itr->second->GetBase())
{
// Ebon Gargoyle
if (visAura->GetId() == 49206 && me->GetUInt32Value(UNIT_CREATED_BY_SPELL) == SPELL_SUMMON_MIRROR_IMAGE1)
{
if (Unit* gargoyle = visAura->GetCaster())
_ebonGargoyleGUID = gargoyle->GetGUID();
continue;
}
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(visAura->GetId());
if (bounds.first != bounds.second)
continue;
std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(visAura->GetId() + SPELL_LINK_AURA);
if (!spellTriggered || !spellTriggered->empty())
continue;
if (Aura* newAura = me->AddAura(visAura->GetId(), me))
newAura->SetDuration(visAura->GetDuration());
}
me->m_Events.AddEvent(new DeathEvent(*me), me->m_Events.CalculateTime(29500));
}
// Do not reload Creature templates on evade mode enter - prevent visual lost
void EnterEvadeMode()
Unit* owner = me->GetOwner();
if (owner && owner->GetTypeId() == TYPEID_PLAYER)
{
if (me->IsInEvadeMode() || !me->IsAlive())
return;
Unit* selection = owner->ToPlayer()->GetSelectedUnit();
Unit* owner = me->GetCharmerOrOwner();
me->CombatStop(true);
if (owner && !me->HasUnitState(UNIT_STATE_FOLLOW))
if (selection)
{
me->GetMotionMaster()->Clear(false);
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE);
me->getThreatManager().resetAllAggro();
me->AddThreat(selection, 1000000.0f);
if (owner->IsInCombat())
AttackStart(selection);
}
if (!owner->IsInCombat() && !me->GetVictim())
EnterEvadeMode();
}
}
void Reset()
{
selectionTimer = 0;
checktarget = 0;
}
void UpdateAI(uint32 diff)
{
events.Update(diff);
if (events.GetTimer() < 1200)
return;
if (!me->IsInCombat() || !me->GetVictim())
{
MySelectNextTarget();
return;
}
void MySelectNextTarget()
checktarget += diff;
if (checktarget >= 1000)
{
if (_ebonGargoyleGUID)
{
Unit* gargoyle = ObjectAccessor::GetUnit(*me, _ebonGargoyleGUID);
if (gargoyle && gargoyle->GetAI())
gargoyle->GetAI()->AttackStart(me);
_ebonGargoyleGUID = 0;
}
Unit* owner = me->GetOwner();
if (owner && owner->GetTypeId() == TYPEID_PLAYER)
{
Unit* selection = owner->ToPlayer()->GetSelectedUnit();
if (selection)
{
me->getThreatManager().resetAllAggro();
me->AddThreat(selection, 1000000.0f);
if (owner->IsInCombat())
AttackStart(selection);
}
if (!owner->IsInCombat() && !me->GetVictim())
EnterEvadeMode();
}
}
void Reset()
{
selectionTimer = 0;
checktarget = 0;
}
void UpdateAI(uint32 diff)
{
events.Update(diff);
if (events.GetTimer() < 1200)
return;
if (!me->IsInCombat() || !me->GetVictim())
if (me->GetVictim()->HasBreakableByDamageCrowdControlAura() || !me->GetVictim()->IsAlive())
{
MySelectNextTarget();
me->InterruptNonMeleeSpells(true); // Stop casting if target is CC or not Alive.
return;
}
checktarget += diff;
if (checktarget >= 1000)
{
if (me->GetVictim()->HasBreakableByDamageCrowdControlAura() || !me->GetVictim()->IsAlive())
{
MySelectNextTarget();
me->InterruptNonMeleeSpells(true); // Stop casting if target is CC or not Alive.
return;
}
}
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
if (uint32 spellId = events.GetEvent())
{
events.RescheduleEvent(spellId, spellId == 59637 ? 6500 : 2500);
me->CastSpell(me->GetVictim(), spellId, false);
}
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_mage_mirror_imageAI(creature);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
if (uint32 spellId = events.GetEvent())
{
events.RescheduleEvent(spellId, spellId == 59637 ? 6500 : 2500);
me->CastSpell(me->GetVictim(), spellId, false);
}
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_mage_mirror_imageAI(creature);
}
};
void AddSC_mage_pet_scripts()

View File

@@ -25,66 +25,66 @@ enum PriestSpells
class npc_pet_pri_lightwell : public CreatureScript
{
public:
npc_pet_pri_lightwell() : CreatureScript("npc_pet_pri_lightwell") { }
public:
npc_pet_pri_lightwell() : CreatureScript("npc_pet_pri_lightwell") { }
struct npc_pet_pri_lightwellAI : public TotemAI
struct npc_pet_pri_lightwellAI : public TotemAI
{
npc_pet_pri_lightwellAI(Creature* creature) : TotemAI(creature) { }
void InitializeAI()
{
npc_pet_pri_lightwellAI(Creature* creature) : TotemAI(creature) { }
void InitializeAI()
if (Unit* owner = me->ToTempSummon()->GetSummoner())
{
if (Unit* owner = me->ToTempSummon()->GetSummoner())
{
uint32 hp = uint32(owner->GetMaxHealth()*0.3f);
me->SetMaxHealth(hp);
me->SetHealth(hp);
me->SetLevel(owner->getLevel());
}
me->CastSpell(me, SPELL_PRIEST_LIGHTWELL_CHARGES, false); // Spell for Lightwell Charges
TotemAI::InitializeAI();
uint32 hp = uint32(owner->GetMaxHealth() * 0.3f);
me->SetMaxHealth(hp);
me->SetHealth(hp);
me->SetLevel(owner->getLevel());
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_pri_lightwellAI(creature);
me->CastSpell(me, SPELL_PRIEST_LIGHTWELL_CHARGES, false); // Spell for Lightwell Charges
TotemAI::InitializeAI();
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_pri_lightwellAI(creature);
}
};
class npc_pet_pri_shadowfiend : public CreatureScript
{
public:
npc_pet_pri_shadowfiend() : CreatureScript("npc_pet_pri_shadowfiend") { }
public:
npc_pet_pri_shadowfiend() : CreatureScript("npc_pet_pri_shadowfiend") { }
struct npc_pet_pri_shadowfiendAI : public PetAI
struct npc_pet_pri_shadowfiendAI : public PetAI
{
npc_pet_pri_shadowfiendAI(Creature* creature) : PetAI(creature) { }
void Reset()
{
npc_pet_pri_shadowfiendAI(Creature* creature) : PetAI(creature) { }
PetAI::Reset();
if (!me->HasAura(SPELL_PRIEST_SHADOWFIEND_DODGE))
me->AddAura(SPELL_PRIEST_SHADOWFIEND_DODGE, me);
void Reset()
{
PetAI::Reset();
if (!me->HasAura(SPELL_PRIEST_SHADOWFIEND_DODGE))
me->AddAura(SPELL_PRIEST_SHADOWFIEND_DODGE, me);
if (Unit* target = me->SelectNearestTarget(15.0f))
AttackStart(target);
}
void JustDied(Unit* /*killer*/)
{
if (me->IsSummon())
if (Unit* owner = me->ToTempSummon()->GetSummoner())
if (owner->HasAura(SPELL_PRIEST_GLYPH_OF_SHADOWFIEND))
owner->CastSpell(owner, SPELL_PRIEST_GLYPH_OF_SHADOWFIEND_MANA, true);
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_pri_shadowfiendAI(creature);
if (Unit* target = me->SelectNearestTarget(15.0f))
AttackStart(target);
}
void JustDied(Unit* /*killer*/)
{
if (me->IsSummon())
if (Unit* owner = me->ToTempSummon()->GetSummoner())
if (owner->HasAura(SPELL_PRIEST_GLYPH_OF_SHADOWFIEND))
owner->CastSpell(owner, SPELL_PRIEST_GLYPH_OF_SHADOWFIEND_MANA, true);
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_pri_shadowfiendAI(creature);
}
};
void AddSC_priest_pet_scripts()

View File

@@ -33,132 +33,132 @@ enum ShamanEvents
class npc_pet_shaman_earth_elemental : public CreatureScript
{
public:
npc_pet_shaman_earth_elemental() : CreatureScript("npc_pet_shaman_earth_elemental") { }
public:
npc_pet_shaman_earth_elemental() : CreatureScript("npc_pet_shaman_earth_elemental") { }
struct npc_pet_shaman_earth_elementalAI : public ScriptedAI
struct npc_pet_shaman_earth_elementalAI : public ScriptedAI
{
npc_pet_shaman_earth_elementalAI(Creature* creature) : ScriptedAI(creature), _initAttack(true) { }
void EnterCombat(Unit*)
{
npc_pet_shaman_earth_elementalAI(Creature* creature) : ScriptedAI(creature), _initAttack(true) { }
void EnterCombat(Unit*)
{
_events.Reset();
_events.ScheduleEvent(EVENT_SHAMAN_ANGEREDEARTH, 0);
}
void InitializeAI()
{
me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true);
}
void UpdateAI(uint32 diff)
{
if (_initAttack)
{
if (!me->IsInCombat())
if (Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself())
if (Unit* target = owner->GetSelectedUnit())
if (me->_CanDetectFeignDeathOf(target) && me->CanCreatureAttack(target))
AttackStart(target);
_initAttack = false;
}
if (!UpdateVictim())
return;
_events.Update(diff);
if (_events.ExecuteEvent() == EVENT_SHAMAN_ANGEREDEARTH)
{
DoCastVictim(SPELL_SHAMAN_ANGEREDEARTH);
_events.ScheduleEvent(EVENT_SHAMAN_ANGEREDEARTH, urand(5000, 20000));
}
DoMeleeAttackIfReady();
}
private:
EventMap _events;
bool _initAttack;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_shaman_earth_elementalAI(creature);
_events.Reset();
_events.ScheduleEvent(EVENT_SHAMAN_ANGEREDEARTH, 0);
}
void InitializeAI()
{
me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true);
}
void UpdateAI(uint32 diff)
{
if (_initAttack)
{
if (!me->IsInCombat())
if (Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself())
if (Unit* target = owner->GetSelectedUnit())
if (me->_CanDetectFeignDeathOf(target) && me->CanCreatureAttack(target))
AttackStart(target);
_initAttack = false;
}
if (!UpdateVictim())
return;
_events.Update(diff);
if (_events.ExecuteEvent() == EVENT_SHAMAN_ANGEREDEARTH)
{
DoCastVictim(SPELL_SHAMAN_ANGEREDEARTH);
_events.ScheduleEvent(EVENT_SHAMAN_ANGEREDEARTH, urand(5000, 20000));
}
DoMeleeAttackIfReady();
}
private:
EventMap _events;
bool _initAttack;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_shaman_earth_elementalAI(creature);
}
};
class npc_pet_shaman_fire_elemental : public CreatureScript
{
public:
npc_pet_shaman_fire_elemental() : CreatureScript("npc_pet_shaman_fire_elemental") { }
public:
npc_pet_shaman_fire_elemental() : CreatureScript("npc_pet_shaman_fire_elemental") { }
struct npc_pet_shaman_fire_elementalAI : public ScriptedAI
struct npc_pet_shaman_fire_elementalAI : public ScriptedAI
{
npc_pet_shaman_fire_elementalAI(Creature* creature) : ScriptedAI(creature), _initAttack(true) { }
void InitializeAI()
{
npc_pet_shaman_fire_elementalAI(Creature* creature) : ScriptedAI(creature), _initAttack(true) { }
void InitializeAI()
{
me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true);
}
void EnterCombat(Unit*)
{
_events.Reset();
_events.ScheduleEvent(EVENT_SHAMAN_FIRENOVA, urand(5000, 20000));
_events.ScheduleEvent(EVENT_SHAMAN_FIREBLAST, urand(5000, 20000));
//_events.ScheduleEvent(EVENT_SHAMAN_FIRESHIELD, 0);
me->RemoveAurasDueToSpell(SPELL_SHAMAN_FIRESHIELD);
me->CastSpell(me, SPELL_SHAMAN_FIRESHIELD, true);
}
void UpdateAI(uint32 diff)
{
if (_initAttack)
{
if (!me->IsInCombat())
if (Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself())
if (Unit* target = owner->GetSelectedUnit())
if (me->_CanDetectFeignDeathOf(target) && me->CanCreatureAttack(target))
AttackStart(target);
_initAttack = false;
}
if (!UpdateVictim())
return;
_events.Update(diff);
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_SHAMAN_FIRENOVA:
me->CastSpell(me, SPELL_SHAMAN_FIRENOVA, false);
_events.ScheduleEvent(EVENT_SHAMAN_FIRENOVA, urand(8000, 15000));
break;
case EVENT_SHAMAN_FIREBLAST:
me->CastSpell(me->GetVictim(), SPELL_SHAMAN_FIREBLAST, false);
_events.ScheduleEvent(EVENT_SHAMAN_FIREBLAST, urand(4000, 8000));
break;
default:
break;
}
}
DoMeleeAttackIfReady();
}
private:
EventMap _events;
bool _initAttack;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_shaman_fire_elementalAI(creature);
me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true);
}
void EnterCombat(Unit*)
{
_events.Reset();
_events.ScheduleEvent(EVENT_SHAMAN_FIRENOVA, urand(5000, 20000));
_events.ScheduleEvent(EVENT_SHAMAN_FIREBLAST, urand(5000, 20000));
//_events.ScheduleEvent(EVENT_SHAMAN_FIRESHIELD, 0);
me->RemoveAurasDueToSpell(SPELL_SHAMAN_FIRESHIELD);
me->CastSpell(me, SPELL_SHAMAN_FIRESHIELD, true);
}
void UpdateAI(uint32 diff)
{
if (_initAttack)
{
if (!me->IsInCombat())
if (Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself())
if (Unit* target = owner->GetSelectedUnit())
if (me->_CanDetectFeignDeathOf(target) && me->CanCreatureAttack(target))
AttackStart(target);
_initAttack = false;
}
if (!UpdateVictim())
return;
_events.Update(diff);
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_SHAMAN_FIRENOVA:
me->CastSpell(me, SPELL_SHAMAN_FIRENOVA, false);
_events.ScheduleEvent(EVENT_SHAMAN_FIRENOVA, urand(8000, 15000));
break;
case EVENT_SHAMAN_FIREBLAST:
me->CastSpell(me->GetVictim(), SPELL_SHAMAN_FIREBLAST, false);
_events.ScheduleEvent(EVENT_SHAMAN_FIREBLAST, urand(4000, 8000));
break;
default:
break;
}
}
DoMeleeAttackIfReady();
}
private:
EventMap _events;
bool _initAttack;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_shaman_fire_elementalAI(creature);
}
};
void AddSC_shaman_pet_scripts()