diff options
| author | Yehonal <yehonal.azeroth@gmail.com> | 2016-08-11 20:25:27 +0200 |
|---|---|---|
| committer | Yehonal <yehonal.azeroth@gmail.com> | 2016-08-11 20:25:27 +0200 |
| commit | 0f85ce1c54810148a5bfcfcedf64a573f4e6e482 (patch) | |
| tree | f2483faec39ed958bdd935dba9c71af35c71e8b8 /src/server/scripts/Pet | |
| parent | c62a72c0a8fc84a1c0af34f483e22a2e821640f8 (diff) | |
Big re-organization of repository [W.I.P]
Diffstat (limited to 'src/server/scripts/Pet')
| -rw-r--r-- | src/server/scripts/Pet/CMakeLists.txt | 23 | ||||
| -rw-r--r-- | src/server/scripts/Pet/pet_dk.cpp | 340 | ||||
| -rw-r--r-- | src/server/scripts/Pet/pet_generic.cpp | 983 | ||||
| -rw-r--r-- | src/server/scripts/Pet/pet_hunter.cpp | 159 | ||||
| -rw-r--r-- | src/server/scripts/Pet/pet_mage.cpp | 229 | ||||
| -rw-r--r-- | src/server/scripts/Pet/pet_priest.cpp | 105 | ||||
| -rw-r--r-- | src/server/scripts/Pet/pet_shaman.cpp | 178 |
7 files changed, 0 insertions, 2017 deletions
diff --git a/src/server/scripts/Pet/CMakeLists.txt b/src/server/scripts/Pet/CMakeLists.txt deleted file mode 100644 index 00e9988095..0000000000 --- a/src/server/scripts/Pet/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (C) -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -set(scripts_STAT_SRCS - ${scripts_STAT_SRCS} - Pet/pet_dk.cpp - Pet/pet_generic.cpp - Pet/pet_hunter.cpp - Pet/pet_mage.cpp - Pet/pet_priest.cpp - Pet/pet_shaman.cpp -) - -AC_ADD_SCRIPT_LOADER("Pet" "ScriptLoader.h") - -message(" -> Prepared: Pet") diff --git a/src/server/scripts/Pet/pet_dk.cpp b/src/server/scripts/Pet/pet_dk.cpp deleted file mode 100644 index 25daa39faf..0000000000 --- a/src/server/scripts/Pet/pet_dk.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (C) - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Ordered alphabetically using scriptname. - * Scriptnames of files in this file should be prefixed with "npc_pet_dk_". - */ - -#include "ScriptMgr.h" -#include "ScriptedCreature.h" -#include "CombatAI.h" -#include "Cell.h" -#include "CellImpl.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" - -enum DeathKnightSpells -{ - SPELL_DK_SUMMON_GARGOYLE_1 = 49206, - SPELL_DK_SUMMON_GARGOYLE_2 = 50514, - SPELL_DK_DISMISS_GARGOYLE = 50515, - SPELL_DK_SANCTUARY = 54661, - SPELL_DK_NIGHT_OF_THE_DEAD = 62137, - SPELL_DK_PET_SCALING = 61017 -}; - -class npc_pet_dk_ebon_gargoyle : public CreatureScript -{ - public: - npc_pet_dk_ebon_gargoyle() : CreatureScript("npc_pet_dk_ebon_gargoyle") { } - - struct npc_pet_dk_ebon_gargoyleAI : ScriptedAI - { - 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; - } - - uint64 GetGhoulTargetGUID() - { - uint64 ghoulTargetGUID = 0; - - std::list<Unit*> targets; - Trinity::AnyFriendlyUnitInObjectRangeCheck ghoul_check(me, me, 50); - Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(me, targets, ghoul_check); - me->VisitNearbyObject(50, searcher); - for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) - { - if ((*iter)->GetEntry() == 26125) // ghoul entry - if ((*iter)->GetOwnerGUID() == me->GetOwnerGUID()) // same owner - { - ghoulTargetGUID = (*iter)->GetTarget(); - break; - } - } - - return ghoulTargetGUID; - } - - void MySelectNextTarget() - { - Unit* owner = me->GetOwner(); - if (owner && owner->GetTypeId() == TYPEID_PLAYER) - { - Unit* ghoulTarget = ObjectAccessor::GetUnit(*me, GetGhoulTargetGUID()); - Unit* dkTarget = owner->ToPlayer()->GetSelectedUnit(); - - if (ghoulTarget && ghoulTarget != me->GetVictim() && me->IsValidAttackTarget(ghoulTarget)) - { - me->GetMotionMaster()->Clear(false); - SwitchTargetAndAttack(ghoulTarget); - return; - } - - if (dkTarget && dkTarget != me->GetVictim() && me->IsValidAttackTarget(dkTarget)) - { - me->GetMotionMaster()->Clear(false); - SwitchTargetAndAttack(dkTarget); - return; - } - - if (!me->GetVictim() || !owner->CanSeeOrDetect(me->GetVictim())) - { - me->CombatStop(true); - me->GetMotionMaster()->Clear(false); - me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, 0.0f); - RemoveTargetAura(); - return; - } - } - } - - void SwitchTargetAndAttack(Unit* who) - { - RemoveTargetAura(); - _targetGUID = who->GetGUID(); - - me->AddAura(SPELL_DK_SUMMON_GARGOYLE_1, who); - ScriptedAI::AttackStart(who); - me->SetReactState(REACT_PASSIVE); - } - - 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; - Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 50); - Trinity::UnitListSearcher<Trinity::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())) - { - SwitchTargetAndAttack((*iter)); - break; - } - } - - if (_despawnTimer > 4000) - { - _despawnTimer -= diff; - - _initialCastTimer += diff; - _selectionTimer += diff; - - if (_selectionTimer >= 1000) - { - MySelectNextTarget(); - _selectionTimer = 0; - } - // check start timer and if not casting - if(_initialCastTimer >= 2000 && !me->HasUnitState(UNIT_STATE_CASTING)) - if (!(me->HasAuraType(SPELL_AURA_MOD_FEAR) || me->HasAuraType(SPELL_AURA_MOD_ROOT) || me->HasAuraType(SPELL_AURA_MOD_CONFUSE) || me->HasAuraType(SPELL_AURA_MOD_STUN))) - if (_initialCastTimer >= 2000 && !me->HasUnitState(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") { } - - struct npc_pet_dk_ghoulAI : public CombatAI - { - 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); - } -}; - -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") { } - - struct npc_pet_dk_army_of_the_deadAI : public CombatAI - { - npc_pet_dk_army_of_the_deadAI(Creature* creature) : CombatAI(creature) { } - - 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); - } -}; - -class npc_pet_dk_dancing_rune_weapon : public CreatureScript -{ - public: - npc_pet_dk_dancing_rune_weapon() : CreatureScript("npc_pet_dk_dancing_rune_weapon") { } - - struct npc_pet_dk_dancing_rune_weaponAI : public NullCreatureAI - { - npc_pet_dk_dancing_rune_weaponAI(Creature* creature) : NullCreatureAI(creature) { } - - 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); - if (Player* player = owner->ToPlayer()) - player->setRuneWeaponGUID(me->GetGUID()); - } - - NullCreatureAI::InitializeAI(); - } - }; - - CreatureAI* GetAI(Creature* creature) const - { - return new npc_pet_dk_dancing_rune_weaponAI (creature); - } -}; - -void AddSC_deathknight_pet_scripts() -{ - new npc_pet_dk_ebon_gargoyle(); - new npc_pet_dk_ghoul(); - new npc_pet_dk_army_of_the_dead(); - new npc_pet_dk_dancing_rune_weapon(); -} diff --git a/src/server/scripts/Pet/pet_generic.cpp b/src/server/scripts/Pet/pet_generic.cpp deleted file mode 100644 index fd214985e8..0000000000 --- a/src/server/scripts/Pet/pet_generic.cpp +++ /dev/null @@ -1,983 +0,0 @@ -/* - * Copyright (C) - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Ordered alphabetically using scriptname. - * Scriptnames of files in this file should be prefixed with "npc_pet_gen_". - */ - -#include "ScriptMgr.h" -#include "ScriptedCreature.h" -#include "Player.h" -#include "Group.h" -#include "CreatureTextMgr.h" -#include "PetAI.h" - -enum Mojo -{ - SAY_MOJO = 0, - - SPELL_FEELING_FROGGY = 43906, - SPELL_SEDUCTION_VISUAL = 43919 -}; - -class npc_pet_gen_mojo : public CreatureScript -{ - public: - npc_pet_gen_mojo() : CreatureScript("npc_pet_gen_mojo") { } - - struct npc_pet_gen_mojoAI : public ScriptedAI - { - npc_pet_gen_mojoAI(Creature* creature) : ScriptedAI(creature) { } - - 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); - } -}; - -enum soulTrader -{ - SPELL_STEAL_ESSENCE_VISUAL = 50101, - SPELL_CREATE_TOKEN = 50063, - SPELL_PROC_TRIGGER_ON_KILL_AURA = 50051, - SPELL_OWNER_KILLED_INFORM = 50050, - SPELL_EMOTE_STATE_SWIM_RUN = 47127, - - EVENT_INITIAL_TALK = 1, - EVENT_ADD_TOKEN = 2 -}; - -class npc_pet_gen_soul_trader_beacon : public CreatureScript -{ -public: - npc_pet_gen_soul_trader_beacon() : CreatureScript("npc_pet_gen_soul_trader_beacon") { } - - struct npc_pet_gen_soul_trader_beaconAI : public ScriptedAI - { - uint64 ownerGUID; - EventMap events; - npc_pet_gen_soul_trader_beaconAI(Creature *c) : ScriptedAI(c) - { - events.Reset(); - events.ScheduleEvent(EVENT_INITIAL_TALK, 0); - if (me->ToTempSummon()) - if (Unit* owner = me->ToTempSummon()->GetOwner()) - { - owner->CastSpell(owner, SPELL_PROC_TRIGGER_ON_KILL_AURA, true); - ownerGUID = owner->GetGUID(); - } - } - - Player* GetOwner() const { return ObjectAccessor::GetPlayer(*me, ownerGUID); } - - void SpellHitTarget(Unit* target, const SpellInfo* spellInfo) - { - if (spellInfo->Id == SPELL_STEAL_ESSENCE_VISUAL && target == me) - { - Talk(1); - events.ScheduleEvent(EVENT_ADD_TOKEN, 3000); - me->CastSpell(me, SPELL_EMOTE_STATE_SWIM_RUN, true); - } - } - - void UpdateAI(uint32 diff) - { - events.Update(diff); - switch (events.ExecuteEvent()) - { - case EVENT_INITIAL_TALK: - Talk(0); - break; - case EVENT_ADD_TOKEN: - me->RemoveAurasDueToSpell(SPELL_EMOTE_STATE_SWIM_RUN); - me->CastSpell(me, SPELL_CREATE_TOKEN, true); - Talk(2); - break; - } - } - }; - - CreatureAI* GetAI(Creature* creature) const - { - return new npc_pet_gen_soul_trader_beaconAI (creature); - } -}; - - -enum eArgentPony -{ - ARGENT_PONY_STATE_NONE = 0, - ARGENT_PONY_STATE_ENCH = 1, - ARGENT_PONY_STATE_VENDOR = 2, - ARGENT_PONY_STATE_BANK = 3, - ARGENT_PONY_STATE_MAILBOX = 4, - - SPELL_PONY_MOUNT = 16083, - - SPELL_AURA_POSTMAN_S = 67376, - SPELL_AURA_SHOP_S = 67377, - SPELL_AURA_BANK_S = 67368, - SPELL_AURA_TIRED_S = 67401, - - SPELL_AURA_BANK_G = 68849, - SPELL_AURA_POSTMAN_G = 68850, - SPELL_AURA_SHOP_G = 68851, - SPELL_AURA_TIRED_G = 68852, - - ACHIEVEMENT_PONY_UP = 3736, - - GOSSIP_ACTION_MAILBOX = 1001, - - NPC_ARGENT_SQUIRE = 33238, - NPC_ARGENT_GRUNTLING = 33239, -}; - -static uint32 argentPonyService[2][3] = -{ - {ARGENT_PONY_STATE_MAILBOX, ARGENT_PONY_STATE_VENDOR, ARGENT_PONY_STATE_BANK}, - {ARGENT_PONY_STATE_BANK, ARGENT_PONY_STATE_MAILBOX, ARGENT_PONY_STATE_VENDOR} -}; - -struct argentPonyBanner -{ - uint32 achievement; - uint32 spell; - const char* text; -}; - -static argentPonyBanner argentBanners[MAX_RACES] = -{ - {0, 0, ""}, - {2781, 62594, "Stormwind Champion's Pennant"}, - {2783, 63433, "Orgrimmar Champion's Pennant"}, - {2780, 63427, "Ironforge Champion's Pennant"}, - {2777, 63406, "Darnassus Champion's Pennant"}, - {2787, 63430, "Forsaken Champion's Pennant"}, - {2786, 63436, "Thunder Bluff Champion's Pennant"}, - {2779, 63396, "Gnomeregan Champion's Pennant"}, - {2784, 63399, "Darkspear Champion's Pennant"}, - {0, 0, ""}, - {2785, 63403, "Silvermoon Champion's Pennant"}, - {2778, 63423, "Exodar Champion's Pennant"} -}; - -class npc_pet_gen_argent_pony_bridle : public CreatureScript -{ -public: - npc_pet_gen_argent_pony_bridle() : CreatureScript("npc_pet_gen_argent_pony_bridle") { } - - struct npc_pet_gen_argent_pony_bridleAI : public ScriptedAI - { - npc_pet_gen_argent_pony_bridleAI(Creature *c) : ScriptedAI(c) - { - _state = ARGENT_PONY_STATE_NONE; - _init = false; - _mountTimer = 4000; - _lastAura = 0; - memset(_banners, 0, sizeof(_banners)); - } - - void EnterEvadeMode() - { - if (Unit* owner = me->GetCharmerOrOwner()) - { - me->GetMotionMaster()->Clear(false); - me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE); - } - } - - void Reset() - { - if (_init) - return; - - _init = true; - uint32 duration = 0; - uint32 aura = 0; - me->SetUInt32Value(UNIT_NPC_FLAGS, 0); - - if (Unit* owner = me->GetCharmerOrOwner()) - if (Player* player = owner->ToPlayer()) - if (player->HasAchieved(ACHIEVEMENT_PONY_UP)) - { - _state = ARGENT_PONY_STATE_ENCH; - - aura = (player->GetTeamId(true) == TEAM_ALLIANCE ? SPELL_AURA_TIRED_S : SPELL_AURA_TIRED_G); - duration = player->GetSpellCooldownDelay(aura); - me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - - for (uint8 i = 0; i < 3; ++i) - { - if (player->GetTeamId(true) == TEAM_ALLIANCE) - { - if (uint32 cooldown = player->GetSpellCooldownDelay(SPELL_AURA_POSTMAN_S+i)) - { - duration = cooldown; - aura = SPELL_AURA_POSTMAN_S+i; - _state = argentPonyService[TEAM_ALLIANCE][i]; - me->ToTempSummon()->UnSummon(duration); - break; - } - } - else - { - if (uint32 cooldown = player->GetSpellCooldownDelay(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; - } - } - } - - // 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)) - _banners[i] = true; - } - - if (duration && aura) - { - if (Aura* aur = me->AddAura(aura, me)) - aur->SetDuration(duration); - } - } - - void UpdateAI(uint32 diff) - { - _mountTimer += diff; - if (_mountTimer > 5000) - { - _mountTimer = 0; - if (_state == ARGENT_PONY_STATE_NONE) - me->SetUInt32Value(UNIT_NPC_FLAGS, 0); - else if (Unit* owner = me->GetCharmerOrOwner()) - { - if (owner->IsMounted() && !me->IsMounted()) - me->CastSpell(me, SPELL_PONY_MOUNT, false); - else if (!owner->IsMounted() && me->IsMounted()) - me->RemoveAurasDueToSpell(SPELL_PONY_MOUNT); - } - } - } - - uint32 GetData(uint32 param) const - { - if (param == 0) - return _state; - - return _banners[param]; - } - - void DoAction(int32 param) - { - if (param > 60000) - { - if (_lastAura) - me->RemoveAurasDueToSpell(_lastAura); - _lastAura = param; - return; - } - - _state = param; - } - - private: - bool _init; - uint8 _state; - int32 _mountTimer; - bool _banners[MAX_RACES]; - uint32 _lastAura; - }; - - bool OnGossipHello(Player* player, Creature* creature) - { - if (player->GetGUID() != creature->GetOwnerGUID()) - return true; - - if (!creature->HasAura(player->GetTeamId(true) ? SPELL_AURA_TIRED_G : SPELL_AURA_TIRED_S)) - { - uint8 _state = creature->AI()->GetData(0 /*GET_DATA_STATE*/); - if (_state == ARGENT_PONY_STATE_ENCH || _state == ARGENT_PONY_STATE_VENDOR) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Visit a trader.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - if (_state == ARGENT_PONY_STATE_ENCH || _state == ARGENT_PONY_STATE_BANK) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Visit a bank.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_BANK); - if (_state == ARGENT_PONY_STATE_ENCH || _state == ARGENT_PONY_STATE_MAILBOX) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Visit a mailbox.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_MAILBOX); - } - - for (uint8 i = RACE_HUMAN; i < MAX_RACES; ++i) - if (creature->AI()->GetData(i) == uint32(true)) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, argentBanners[i].text, GOSSIP_SENDER_MAIN, argentBanners[i].spell); - - player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); - return true; - } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 action) - { - player->CLOSE_GOSSIP_MENU(); - uint32 spellId = 0; - switch (action) - { - case GOSSIP_ACTION_TRADE: - creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR); - player->GetSession()->SendListInventory(creature->GetGUID()); - spellId = player->GetTeamId(true) ? SPELL_AURA_SHOP_G : SPELL_AURA_SHOP_S; - creature->AI()->DoAction(ARGENT_PONY_STATE_VENDOR); - break; - case GOSSIP_ACTION_BANK: - creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER); - player->GetSession()->SendShowBank(player->GetGUID()); - spellId = player->GetTeamId(true) ? SPELL_AURA_BANK_G : SPELL_AURA_BANK_S; - 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; - } - default: - if (action > 60000) - { - creature->AI()->DoAction(action); - creature->CastSpell(creature, action, true); - } - return true; - } - - 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); - } - return true; - } - - CreatureAI* GetAI(Creature* creature) const - { - return new npc_pet_gen_argent_pony_bridleAI (creature); - } -}; - -enum eTargetFollowingBomb -{ - NPC_EXPLOSIVE_SHEEP = 2675, - SPELL_EXPLOSIVE_SHEEP = 4050, - - NPC_GOBLIN_BOMB = 8937, - SPELL_EXPLOSIVE_GOBLIN = 13259, - - NPC_HIGH_EXPLOSIVE_SHEEP = 24715, - SPELL_HIGH_EXPLOSIVE_SHEEP = 44279, -}; - -class npc_pet_gen_target_following_bomb : public CreatureScript -{ -public: - npc_pet_gen_target_following_bomb() : CreatureScript("npc_pet_gen_target_following_bomb") { } - - struct npc_pet_gen_target_following_bombAI : public NullCreatureAI - { - 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; - } - } - - uint32 bombSpellId; - uint32 checkTimer; - - void UpdateAI(uint32 diff) - { - checkTimer += diff; - if (checkTimer >= 1000) - { - checkTimer = 0; - if (Unit* target = me->SelectNearestTarget(30.0f)) - { - me->GetMotionMaster()->MoveChase(target); - if (me->GetDistance(target) < 3.0f) - { - me->CastSpell(me, bombSpellId, false); - me->DespawnOrUnsummon(500); - } - } - else if (!me->HasUnitState(UNIT_STATE_FOLLOW)) - { - if (Unit* owner = me->GetCharmerOrOwner()) - { - me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); - } - } - } - } - }; - - CreatureAI* GetAI(Creature* pCreature) const - { - return new npc_pet_gen_target_following_bombAI (pCreature); - } -}; - -class npc_pet_gen_gnomish_flame_turret : public CreatureScript -{ -public: - npc_pet_gen_gnomish_flame_turret() : CreatureScript("npc_pet_gen_gnomish_flame_turret") { } - - struct npc_pet_gen_gnomish_flame_turretAI : public ScriptedAI - { - npc_pet_gen_gnomish_flame_turretAI(Creature *c) : ScriptedAI(c) - { - checkTimer = 0; - } - - uint32 checkTimer; - - void Reset() - { - me->GetMotionMaster()->Clear(false); - } - - void AttackStart(Unit* who) - { - if (!who) - return; - - if (me->Attack(who, false)) - DoStartNoMovement(who); - } - - void UpdateAI(uint32 diff) - { - if (!me->GetVictim()) - return; - - if (Unit* target = me->SelectVictim()) - { - AttackStart(target); - DoSpellAttackIfReady(me->m_spells[0]); - } - } - }; - - CreatureAI* GetAI(Creature* creature) const - { - return new npc_pet_gen_gnomish_flame_turretAI (creature); - } -}; - -class npc_pet_gen_valkyr_guardian : public CreatureScript -{ -public: - npc_pet_gen_valkyr_guardian() : CreatureScript("npc_pet_gen_valkyr_guardian") { } - - struct npc_pet_gen_valkyr_guardianAI : public ScriptedAI - { - npc_pet_gen_valkyr_guardianAI(Creature *c) : ScriptedAI(c) - { - me->SetReactState(REACT_DEFENSIVE); - me->SetDisableGravity(true); - me->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD); - targetCheck = 0; - } - - uint32 targetCheck; - - void InitializeAI() - { - if (Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself()) - if (Unit* target = owner->GetSelectedUnit()) - if (!owner->IsFriendlyTo(target)) - AttackStart(target); - } - - void OwnerAttacked(Unit* target) - { - if (!target || (me->GetVictim() && me->GetVictim()->IsAlive() && !me->GetVictim()->HasBreakableByDamageCrowdControlAura())) - return; - - AttackStart(target); - } - - void UpdateAI(uint32 diff) - { - if (!UpdateVictim()) - { - targetCheck += diff; - if (targetCheck > 1000) - { - targetCheck = 0; - if (Unit* owner = me->GetCharmerOrOwner()) - if (Unit* ownerVictim = owner->GetVictim()) - if (!ownerVictim->HasBreakableByDamageCrowdControlAura()) - AttackStart(ownerVictim); - } - return; - } - - if (me->isAttackReady() && !me->GetVictim()->HasBreakableByDamageCrowdControlAura()) - DoSpellAttackIfReady(me->GetCreatureTemplate()->spells[0]); - } - }; - - CreatureAI* GetAI(Creature* pCreature) const - { - return new npc_pet_gen_valkyr_guardianAI (pCreature); - } -}; - -class spell_pet_gen_valkyr_guardian_smite : public SpellScriptLoader -{ - public: - spell_pet_gen_valkyr_guardian_smite() : SpellScriptLoader("spell_pet_gen_valkyr_guardian_smite") { } - - class spell_pet_gen_valkyr_guardian_smite_SpellScript : public SpellScript - { - PrepareSpellScript(spell_pet_gen_valkyr_guardian_smite_SpellScript); - - void RecalculateDamage() - { - 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); - } - } - - 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 -{ -public: - npc_pet_gen_imp_in_a_bottle() : CreatureScript("npc_pet_gen_imp_in_a_bottle") { } - - struct npc_pet_gen_imp_in_a_bottleAI : public NullCreatureAI - { - npc_pet_gen_imp_in_a_bottleAI(Creature *c) : NullCreatureAI(c) - { - _talkTimer = 0; - _ownerGUID = 0; - _hasParty = false; - } - - WorldPacket _data; - uint32 _talkTimer; - uint64 _ownerGUID; - bool _hasParty; - - void InitializeAI() - { - NullCreatureAI::InitializeAI(); - - if (TempSummon* summon = me->ToTempSummon()) - if (Unit* owner = summon->GetSummoner()) - if (owner->GetTypeId() == TYPEID_PLAYER) - { - _ownerGUID = owner->GetGUID(); - if (owner->ToPlayer()->GetGroup()) - { - _hasParty = true; - std::string const& text = sCreatureTextMgr->GetLocalizedChatString(me->GetEntry(), 0 /*text group*/, urand(0, 60) /*text id*/, LOCALE_enUS); - - _data.Initialize(SMSG_MESSAGECHAT, 200); // guess size - _data << uint8(CHAT_MSG_MONSTER_PARTY); - _data << uint32(LANG_UNIVERSAL); - _data << uint64(me->GetGUID()); - _data << uint32(0); - _data << uint32(me->GetName().size() + 1); - _data << me->GetName(); - _data << uint64(0); - _data << uint32(text.size()+1); - _data << text.c_str(); - _data << uint8(0); - } - } - } - - void UpdateAI(uint32 diff) - { - _talkTimer += diff; - if (_talkTimer >= 5000) - { - _talkTimer = 0; - me->DespawnOrUnsummon(1); - if (!_hasParty) - Talk(0, ObjectAccessor::GetPlayer(*me, _ownerGUID)); - else if (Player* player = ObjectAccessor::GetPlayer(*me, _ownerGUID)) - { - uint8 limit = 0; - if (player->GetGroup()) - for (GroupReference* itr = player->GetGroup()->GetFirstMember(); itr != NULL && limit < 4; itr = itr->next(), ++limit) - if (Player* groupPlayer = itr->GetSource()) - if (groupPlayer != player) - groupPlayer->GetSession()->SendPacket(&_data); - - player->GetSession()->SendPacket(&_data); - } - } - } - }; - - CreatureAI* GetAI(Creature* pCreature) const - { - return new npc_pet_gen_imp_in_a_bottleAI (pCreature); - } -}; - -class npc_pet_gen_wind_rider_cub : public CreatureScript -{ -public: - npc_pet_gen_wind_rider_cub() : CreatureScript("npc_pet_gen_wind_rider_cub") { } - - struct npc_pet_gen_wind_rider_cubAI : public NullCreatureAI - { - npc_pet_gen_wind_rider_cubAI(Creature *c) : NullCreatureAI(c) - { - allowMove = true; - isFlying = true; - checkTimer = 0; - checkTimer2 = 2000; - me->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD); - } - - bool isFlying; - bool allowMove; - uint32 checkTimer; - uint32 checkTimer2; - - void MovementInform(uint32 type, uint32 id) - { - if (type == POINT_MOTION_TYPE && id == 1) - allowMove = true; - } - - void UpdateAI(uint32 diff) - { - checkTimer2 += diff; - if (checkTimer2 > 2000) - { - checkTimer2 = 0; - if (Unit* owner = me->GetOwner()) - { - if (owner->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED)) - { - isFlying = true; - me->SetCanFly(true); - me->SetDisableGravity(true); - } - else if (isFlying) - { - isFlying = false; - me->SetCanFly(false); - me->SetDisableGravity(false); - me->GetMotionMaster()->MoveFall(); - } - } - } - - checkTimer += diff; - if (allowMove || checkTimer > 2000) - { - allowMove = false; - checkTimer = 0; - if (Unit* owner = me->GetOwner()) - { - if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE) == POINT_MOTION_TYPE || - me->GetDistance(owner) < 1.0f) - return; - float x, y, z; - owner->GetNearPoint2D(x, y, 0.5f, owner->GetOrientation()+PET_FOLLOW_ANGLE); - z = owner->GetPositionZ() + (isFlying ? 2.5f : 0.0f); - - me->GetMotionMaster()->MovePoint(1, x, y, z); - } - } - } - }; - - CreatureAI* GetAI(Creature* pCreature) const - { - return new npc_pet_gen_wind_rider_cubAI (pCreature); - } -}; - -enum turkey -{ - GO_BASIC_CAMPFIRE = 29784, - SPELL_TURKEY_STARTS_TO_BURN = 61768, -}; - -class npc_pet_gen_plump_turkey : public CreatureScript -{ -public: - npc_pet_gen_plump_turkey() : CreatureScript("npc_pet_gen_plump_turkey") { } - - struct npc_pet_gen_plump_turkeyAI : public PassiveAI - { - npc_pet_gen_plump_turkeyAI(Creature *c) : PassiveAI(c) - { - goGUID = 0; - jumpTimer = 0; - checkTimer = 0; - jumping = false; - } - - uint64 goGUID; - uint32 jumpTimer; - uint32 checkTimer; - bool jumping; - - void MovementInform(uint32 type, uint32 id) - { - if (type == EFFECT_MOTION_TYPE && id == 1) - { - Unit::Kill(me, me); - me->AddAura(SPELL_TURKEY_STARTS_TO_BURN, me); - } - } - - void UpdateAI(uint32 diff) - { - if (jumping) - return; - - if (jumpTimer) - { - jumpTimer += diff; - if (jumpTimer >= 2000) - { - if (GameObject* go = me->GetMap()->GetGameObject(goGUID)) - me->GetMotionMaster()->MoveJump(*go, 5.0f, 10.0f, 1); - jumping = true; - } - return; - } - - checkTimer += diff; - if (checkTimer > 3000) - { - checkTimer = 0; - if (GameObject* go = me->FindNearestGameObject(GO_BASIC_CAMPFIRE, 7.0f)) - { - goGUID = go->GetGUID(); - me->StopMoving(); - me->GetMotionMaster()->Clear(false); - me->SetFacingTo(me->GetAngle(go)); - Talk(0); - jumpTimer = 1; - } - } - } - }; - - CreatureAI* GetAI(Creature* pCreature) const - { - return new npc_pet_gen_plump_turkeyAI (pCreature); - } -}; - -class npc_pet_gen_toxic_wasteling : public CreatureScript -{ -public: - npc_pet_gen_toxic_wasteling() : CreatureScript("npc_pet_gen_toxic_wasteling") { } - - struct npc_pet_gen_toxic_wastelingAI : public PassiveAI - { - npc_pet_gen_toxic_wastelingAI(Creature *c) : PassiveAI(c) - { - } - - uint32 checkTimer; - - void Reset() { checkTimer = 3000; } - - void EnterEvadeMode() - { - } - - void MovementInform(uint32 type, uint32 id) - { - if (type == EFFECT_MOTION_TYPE && id == 1) - checkTimer = 1; - } - - void UpdateAI(uint32 diff) - { - if (checkTimer) - { - if (checkTimer == 1) - me->GetMotionMaster()->MovementExpired(false); - checkTimer += diff; - if (checkTimer >= 3000) - { - if (Unit* owner = me->GetCharmerOrOwner()) - { - me->GetMotionMaster()->Clear(false); - me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE); - } - me->AddAura(71854, me); // Growth - checkTimer = 0; - } - } - } - }; - - CreatureAI* GetAI(Creature* pCreature) const - { - return new npc_pet_gen_toxic_wastelingAI (pCreature); - } -}; - -class npc_pet_gen_fetch_ball : public CreatureScript -{ -public: - npc_pet_gen_fetch_ball() : CreatureScript("npc_pet_gen_fetch_ball") { } - - struct npc_pet_gen_fetch_ballAI : public NullCreatureAI - { - npc_pet_gen_fetch_ballAI(Creature *c) : NullCreatureAI(c) - { - } - - uint32 checkTimer; - uint64 targetGUID; - - void IsSummonedBy(Unit* summoner) - { - if (!summoner) - return; - - me->SetOwnerGUID(summoner->GetGUID()); - checkTimer = 0; - targetGUID = 0; - me->CastSpell(me, 48649 /*SPELL_PET_TOY_FETCH_BALL_COME_HERE*/, true); - } - - void SpellHitTarget(Unit* target, const SpellInfo* spellInfo) - { - if (spellInfo->Id == 48649 /*SPELL_PET_TOY_FETCH_BALL_COME_HERE*/) - { - target->GetMotionMaster()->MovePoint(50, me->GetHomePosition()); - targetGUID = target->GetGUID(); - } - } - - void UpdateAI(uint32 diff) - { - checkTimer += diff; - if (checkTimer >= 1000) - { - checkTimer = 0; - if (Creature* target = ObjectAccessor::GetCreature(*me, targetGUID)) - if (me->GetDistance2d(target) < 2.0f) - { - target->AI()->EnterEvadeMode(); - target->CastSpell(target, 48708 /*SPELL_PET_TOY_FETCH_BALL_HAS_BALL*/, true); - me->DespawnOrUnsummon(1); - } - } - } - }; - - CreatureAI* GetAI(Creature* pCreature) const - { - return new npc_pet_gen_fetch_ballAI (pCreature); - } -}; - -void AddSC_generic_pet_scripts() -{ - new npc_pet_gen_mojo(); - new npc_pet_gen_soul_trader_beacon(); - new npc_pet_gen_argent_pony_bridle(); - new npc_pet_gen_target_following_bomb(); - new npc_pet_gen_gnomish_flame_turret(); - new npc_pet_gen_valkyr_guardian(); - new spell_pet_gen_valkyr_guardian_smite(); - new npc_pet_gen_imp_in_a_bottle(); - new npc_pet_gen_wind_rider_cub(); - new npc_pet_gen_plump_turkey(); - new npc_pet_gen_toxic_wasteling(); - new npc_pet_gen_fetch_ball(); -} diff --git a/src/server/scripts/Pet/pet_hunter.cpp b/src/server/scripts/Pet/pet_hunter.cpp deleted file mode 100644 index 66e6ba38bb..0000000000 --- a/src/server/scripts/Pet/pet_hunter.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Ordered alphabetically using scriptname. - * Scriptnames of files in this file should be prefixed with "npc_pet_hun_". - */ - -#include "ScriptMgr.h" -#include "ScriptedCreature.h" - -enum HunterSpells -{ - SPELL_HUNTER_CRIPPLING_POISON = 30981, // Viper - SPELL_HUNTER_DEADLY_POISON_PASSIVE = 34657, // Venomous Snake - SPELL_HUNTER_MIND_NUMBING_POISON = 25810, // Viper - SPELL_HUNTER_GLYPH_OF_SNAKE_TRAP = 56849, - SPELL_HUNTER_PET_SCALING = 62915 -}; - -enum HunterCreatures -{ - NPC_HUNTER_VIPER = 19921 -}; - -class npc_pet_hunter_snake_trap : public CreatureScript -{ - public: - npc_pet_hunter_snake_trap() : CreatureScript("npc_pet_hunter_snake_trap") { } - - struct npc_pet_hunter_snake_trapAI : public ScriptedAI - { - npc_pet_hunter_snake_trapAI(Creature* creature) : ScriptedAI(creature) { _init = false; } - - 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(NULL); - 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() -{ - new npc_pet_hunter_snake_trap(); -} diff --git a/src/server/scripts/Pet/pet_mage.cpp b/src/server/scripts/Pet/pet_mage.cpp deleted file mode 100644 index 4f2a32ceff..0000000000 --- a/src/server/scripts/Pet/pet_mage.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (C) - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Ordered alphabetically using scriptname. - * Scriptnames of files in this file should be prefixed with "npc_pet_mag_". - */ - -#include "ScriptMgr.h" -#include "ScriptedCreature.h" -#include "CombatAI.h" -#include "Pet.h" - -enum MageSpells -{ - SPELL_MAGE_CLONE_ME = 45204, - SPELL_MAGE_MASTERS_THREAT_LIST = 58838, - SPELL_PET_HIT_SCALING = 61013, - SPELL_SUMMON_MIRROR_IMAGE1 = 58831, - SPELL_SUMMON_MIRROR_IMAGE2 = 58833, - SPELL_SUMMON_MIRROR_IMAGE3 = 58834, - SPELL_SUMMON_MIRROR_IMAGE_GLYPH = 65047 -}; - -class DeathEvent : public BasicEvent -{ - public: - DeathEvent(Creature& owner) : BasicEvent(), _owner(owner) { } - - bool Execute(uint64 /*eventTime*/, uint32 /*diff*/) - { - Unit::Kill(&_owner, &_owner); - return true; - } - - private: - Creature& _owner; -}; - -class npc_pet_mage_mirror_image : public CreatureScript -{ - public: - npc_pet_mage_mirror_image() : CreatureScript("npc_pet_mage_mirror_image") { } - - struct npc_pet_mage_mirror_imageAI : CasterAI - { - npc_pet_mage_mirror_imageAI(Creature* creature) : CasterAI(creature) { } - - uint32 selectionTimer; - uint64 _ebonGarogyleGUID; - - void InitializeAI() - { - CasterAI::InitializeAI(); - Unit* owner = me->GetOwner(); - if (!owner) - return; - - // Clone Me! - owner->CastSpell(me, SPELL_MAGE_CLONE_ME, true); - - // xinef: Glyph of Mirror Image (4th copy) - float angle = 0.0f; - switch (me->GetUInt32Value(UNIT_CREATED_BY_SPELL)) - { - 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; - } - - ((Minion*)me)->SetFollowAngle(angle); - me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE); - me->SetReactState(REACT_PASSIVE); - - // 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(); - } - - _ebonGarogyleGUID = 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* garogyle = visAura->GetCaster()) - _ebonGarogyleGUID = garogyle->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() - { - if (me->IsInEvadeMode() || !me->IsAlive()) - return; - - 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); - } - } - - bool MySelectNextTarget() - { - if (_ebonGarogyleGUID) - { - if (Unit* garogyle = ObjectAccessor::GetUnit(*me, _ebonGarogyleGUID)) - garogyle->GetAI()->AttackStart(me); - _ebonGarogyleGUID = 0; - } - Unit* owner = me->GetOwner(); - if (owner && owner->GetTypeId() == TYPEID_PLAYER) - { - Unit* selection = owner->ToPlayer()->GetSelectedUnit(); - if (selection && selection != me->GetVictim()) - { - // target has cc, search target without cc! - if (selection->HasBreakableByDamageCrowdControlAura() || !me->IsValidAttackTarget(selection)) - { - return false; - } - - me->getThreatManager().resetAllAggro(); - me->AddThreat(selection, 1000000.0f); - AttackStart(selection); - return true; - } - } - return false; - } - - void Reset() - { - selectionTimer = 0; - } - - void UpdateAI(uint32 diff) - { - events.Update(diff); - if (events.GetTimer() < 1200) - return; - - if (!me->IsInCombat() || !me->GetVictim()) - { - MySelectNextTarget(); - return; - } - - if (me->GetVictim()->HasBreakableByDamageCrowdControlAura() || !me->GetVictim()->IsAlive()) - { - me->InterruptNonMeleeSpells(false); - if (!MySelectNextTarget()) - EnterEvadeMode(); - return; - } - - selectionTimer += diff; - if (selectionTimer >= 1000) - { - MySelectNextTarget(); - selectionTimer = 0; - } - - 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() -{ - new npc_pet_mage_mirror_image(); -} diff --git a/src/server/scripts/Pet/pet_priest.cpp b/src/server/scripts/Pet/pet_priest.cpp deleted file mode 100644 index 3767034049..0000000000 --- a/src/server/scripts/Pet/pet_priest.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Ordered alphabetically using scriptname. - * Scriptnames of files in this file should be prefixed with "npc_pet_pri_". - */ - -#include "ScriptMgr.h" -#include "ScriptedCreature.h" -#include "PassiveAI.h" -#include "PetAI.h" -#include "TotemAI.h" - -enum PriestSpells -{ - SPELL_PRIEST_GLYPH_OF_SHADOWFIEND = 58228, - SPELL_PRIEST_GLYPH_OF_SHADOWFIEND_MANA = 58227, - SPELL_PRIEST_SHADOWFIEND_DODGE = 8273, - SPELL_PRIEST_LIGHTWELL_CHARGES = 59907 -}; - -class npc_pet_pri_lightwell : public CreatureScript -{ - public: - npc_pet_pri_lightwell() : CreatureScript("npc_pet_pri_lightwell") { } - - struct npc_pet_pri_lightwellAI : public TotemAI - { - npc_pet_pri_lightwellAI(Creature* creature) : TotemAI(creature) { } - - void InitializeAI() - { - 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(); - } - }; - - 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") { } - - struct npc_pet_pri_shadowfiendAI : public PetAI - { - npc_pet_pri_shadowfiendAI(Creature* creature) : PetAI(creature) { } - - 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); - } -}; - -void AddSC_priest_pet_scripts() -{ - new npc_pet_pri_lightwell(); - new npc_pet_pri_shadowfiend(); -} diff --git a/src/server/scripts/Pet/pet_shaman.cpp b/src/server/scripts/Pet/pet_shaman.cpp deleted file mode 100644 index 3c712a9120..0000000000 --- a/src/server/scripts/Pet/pet_shaman.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (C) - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Ordered alphabetically using scriptname. - * Scriptnames of files in this file should be prefixed with "npc_pet_sha_". - */ - -#include "ScriptMgr.h" -#include "ScriptedCreature.h" - -enum ShamanSpells -{ - SPELL_SHAMAN_ANGEREDEARTH = 36213, - SPELL_SHAMAN_FIREBLAST = 57984, - SPELL_SHAMAN_FIRENOVA = 12470, - SPELL_SHAMAN_FIRESHIELD = 13377 -}; - -enum ShamanEvents -{ - // Earth Elemental - EVENT_SHAMAN_ANGEREDEARTH = 1, - // Fire Elemental - EVENT_SHAMAN_FIRENOVA = 1, - EVENT_SHAMAN_FIRESHIELD = 2, - EVENT_SHAMAN_FIREBLAST = 3 -}; - -class npc_pet_shaman_earth_elemental : public CreatureScript -{ - public: - npc_pet_shaman_earth_elemental() : CreatureScript("npc_pet_shaman_earth_elemental") { } - - struct npc_pet_shaman_earth_elementalAI : public ScriptedAI - { - 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); - } -}; - -class npc_pet_shaman_fire_elemental : public CreatureScript -{ - public: - npc_pet_shaman_fire_elemental() : CreatureScript("npc_pet_shaman_fire_elemental") { } - - struct npc_pet_shaman_fire_elementalAI : public ScriptedAI - { - 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); - } -}; - -void AddSC_shaman_pet_scripts() -{ - new npc_pet_shaman_earth_elemental(); - new npc_pet_shaman_fire_elemental(); -} |
