diff options
| author | Subv <s.v.h21@hotmail.com> | 2012-08-30 19:16:09 -0500 |
|---|---|---|
| committer | Subv <s.v.h21@hotmail.com> | 2012-08-30 19:16:09 -0500 |
| commit | 554e88dd63c244f740d385d8a45d4e4405e951ba (patch) | |
| tree | abcd721b4f6e7e8a9189455386a3d3b0b9eac0e4 /src/server/scripts | |
| parent | 532ddfcd402390a9caf3ac5863bba2f0db9d0efc (diff) | |
| parent | e3d9768a50a3b2b700d65e0cc96e697a5c9d22dc (diff) | |
Merge branch 'master' of github.com:TrinityCore/TrinityCore into mmaps
Diffstat (limited to 'src/server/scripts')
15 files changed, 186 insertions, 136 deletions
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 99ec263b8f9..e3cd185e4a3 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -642,19 +642,13 @@ public: { handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid); - // wpCreature - Creature* wpCreature = NULL; - if (wpGuid != 0) - { - wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - if (wpCreature) + if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT))) { wpCreature->CombatStop(); wpCreature->DeleteFromDB(); wpCreature->AddObjectToRemoveList(); } - } PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA); @@ -681,15 +675,12 @@ public: Player* chr = handler->GetSession()->GetPlayer(); Map* map = chr->GetMap(); { - // wpCreature - Creature* wpCreature = NULL; // What to do: // Move the visual spawnpoint // Respawn the owner of the waypoints if (wpGuid != 0) { - wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - if (wpCreature) + if (Creature* wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT))) { wpCreature->CombatStop(); wpCreature->DeleteFromDB(); diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp index 204fbe5223b..25c3f2e41e3 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp @@ -243,11 +243,9 @@ public: std::list<HostileReference*> threatlist = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) { - Unit* unit; if ((*i) && (*i)->getSource()) { - unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); - if (unit) + if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) { //Cast affliction DoCast(unit, RAND(SPELL_BROODAF_BLUE, SPELL_BROODAF_BLACK, diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index 06c1243645c..533a1aac2f0 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -201,12 +201,11 @@ public: { for (uint8 i = 0; i < 4; ++i) { - Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Creature::GetCreature((*me), AddGUID[i]); - if (Temp && Temp->isAlive()) - Temp->DisappearAndDie(); + Creature* temp = Creature::GetCreature((*me), AddGUID[i]); + if (temp && temp->isAlive()) + temp->DisappearAndDie(); } } } @@ -215,14 +214,13 @@ public: { for (uint8 i = 0; i < 4; ++i) { - Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Creature::GetCreature((*me), AddGUID[i]); - if (Temp && Temp->isAlive()) + Creature* temp = Creature::GetCreature((*me), AddGUID[i]); + if (temp && temp->isAlive()) { - Temp->AI()->AttackStart(me->getVictim()); - DoZoneInCombat(Temp); + temp->AI()->AttackStart(me->getVictim()); + DoZoneInCombat(temp); } else EnterEvadeMode(); } @@ -250,13 +248,12 @@ public: { for (uint8 i = 0; i < 4; ++i) { - Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Unit::GetCreature((*me), AddGUID[i]); - if (Temp && Temp->isAlive()) - if (!Temp->getVictim()) - Temp->AI()->AttackStart(me->getVictim()); + Creature* temp = Unit::GetCreature((*me), AddGUID[i]); + if (temp && temp->isAlive()) + if (!temp->getVictim()) + temp->AI()->AttackStart(me->getVictim()); } } CheckAdds_Timer = 5000; diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp index d4c037d45c3..b405f9eba85 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp @@ -240,7 +240,6 @@ public: return; Creature* pArchmage = instance->GetCreature(uiArchmageArugalGUID); - Creature* summon = NULL; if (!pArchmage || !pArchmage->isAlive()) return; @@ -252,7 +251,8 @@ public: switch (uiPhase) { case 1: - summon = pArchmage->SummonCreature(pArchmage->GetEntry(), SpawnLocation[4], TEMPSUMMON_TIMED_DESPAWN, 10000); + { + Creature* summon = pArchmage->SummonCreature(pArchmage->GetEntry(), SpawnLocation[4], TEMPSUMMON_TIMED_DESPAWN, 10000); summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); summon->SetReactState(REACT_DEFENSIVE); summon->CastSpell(summon, SPELL_ASHCROMBE_TELEPORT, true); @@ -260,13 +260,16 @@ public: uiTimer = 2000; uiPhase = 2; break; + } case 2: + { pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[1], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); uiPhase = 0; break; + } } } else uiTimer -= uiDiff; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp index 1009d3e0a0a..8fb3dd55077 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp @@ -315,14 +315,12 @@ class boss_zuljin : public CreatureScript { for (uint8 i = 0; i < 4; ++i) { - Unit* Temp = NULL; if (SpiritGUID[i]) { - Temp = Unit::GetUnit(*me, SpiritGUID[i]); - if (Temp) + if (Unit* temp = Unit::GetUnit(*me, SpiritGUID[i])) { - Temp->SetVisible(false); - Temp->setDeathState(DEAD); + temp->SetVisible(false); + temp->setDeathState(DEAD); } } SpiritGUID[i] = 0; diff --git a/src/server/scripts/EasternKingdoms/silverpine_forest.cpp b/src/server/scripts/EasternKingdoms/silverpine_forest.cpp index 870cb29c28d..c52e69787d4 100644 --- a/src/server/scripts/EasternKingdoms/silverpine_forest.cpp +++ b/src/server/scripts/EasternKingdoms/silverpine_forest.cpp @@ -230,13 +230,11 @@ public: { if (Creature* summoned = me->SummonCreature(creatureId, PyrewoodSpawnPoints[position][0], PyrewoodSpawnPoints[position][1], PyrewoodSpawnPoints[position][2], PyrewoodSpawnPoints[position][3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000)) { - Player* player = NULL; Unit* target = NULL; if (PlayerGUID) { - player = Unit::GetPlayer(*me, PlayerGUID); - if (player) - target = RAND((Unit*)me, (Unit*)player); + if (Unit* player = Unit::GetPlayer(*me, PlayerGUID)->ToUnit()) + target = RAND((Unit*)me, player); } else target = me; diff --git a/src/server/scripts/EasternKingdoms/wetlands.cpp b/src/server/scripts/EasternKingdoms/wetlands.cpp index fac8fb51c2d..34e6e7c9ddf 100644 --- a/src/server/scripts/EasternKingdoms/wetlands.cpp +++ b/src/server/scripts/EasternKingdoms/wetlands.cpp @@ -60,12 +60,12 @@ public: { npc_tapoke_slim_jahnAI(Creature* creature) : npc_escortAI(creature) { } - bool m_bFriendSummoned; + bool IsFriendSummoned; void Reset() { if (!HasEscortState(STATE_ESCORT_ESCORTING)) - m_bFriendSummoned = false; + IsFriendSummoned = false; } void WaypointReached(uint32 waypointId) @@ -83,14 +83,12 @@ public: void EnterCombat(Unit* /*who*/) { - Player* player = GetPlayerForEscort(); - - if (HasEscortState(STATE_ESCORT_ESCORTING) && !m_bFriendSummoned && player) + if (HasEscortState(STATE_ESCORT_ESCORTING) && !IsFriendSummoned && GetPlayerForEscort()) { for (uint8 i = 0; i < 3; ++i) DoCast(me, SPELL_CALL_FRIENDS, true); - m_bFriendSummoned = true; + IsFriendSummoned = true; } } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp index 5b6dc784113..ee7ef383603 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp @@ -222,11 +222,9 @@ public: ItemPosCountVec dest; uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, ITEM_TEAR_OF_GODDESS, 1); if (msg == EQUIP_ERR_OK) - { - Item* item = player->StoreNewItem(dest, ITEM_TEAR_OF_GODDESS, true); - if (item && player) + if (Item* item = player->StoreNewItem(dest, ITEM_TEAR_OF_GODDESS, true)) player->SendNewItem(item, 1, true, false, true); - } + player->SEND_GOSSIP_MENU(907, creature->GetGUID()); } return true; diff --git a/src/server/scripts/Kalimdor/silithus.cpp b/src/server/scripts/Kalimdor/silithus.cpp index 639de3dc3b2..bad278f51c7 100644 --- a/src/server/scripts/Kalimdor/silithus.cpp +++ b/src/server/scripts/Kalimdor/silithus.cpp @@ -537,7 +537,6 @@ public: if (!Fandral || !Arygos || !Caelestrasz || !Merithra) return; - Unit* mob = NULL; AnimationTimer = EventAnim[AnimationCount].Timer; if (eventEnd == false) { @@ -720,6 +719,7 @@ public: case 51: { uint32 entries[4] = { 15423, 15424, 15414, 15422 }; + Unit* mob = NULL; for (uint8 i = 0; i < 4; ++i) { mob = player->FindNearestCreature(entries[i], 50, me); @@ -844,9 +844,6 @@ public: void UpdateAI(const uint32 diff) { - Unit* target = NULL; - //Player* player = me->GetPlayer(PlayerGUID); - if (!Timers) { if (me->GetEntry() == 15424 || me->GetEntry() == 15422 || me->GetEntry() == 15414) //all but Kaldorei Soldiers @@ -890,6 +887,7 @@ public: } if (!hasTarget) { + Unit* target = NULL; if (me->GetEntry() == 15424 || me->GetEntry() == 15422 || me->GetEntry() == 15414) target = me->FindNearestCreature(15423, 20, true); if (me->GetEntry() == 15423) diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp index 2ea234775c0..d335d36e112 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp @@ -314,15 +314,14 @@ class boss_gothik : public CreatureScript bool CheckGroupSplitted() { - bool checklife = false; - bool checkdead = false; - Map* map = me->GetMap(); if (map && map->IsDungeon()) { Map::PlayerList const &PlayerList = map->GetPlayers(); if (!PlayerList.isEmpty()) { + bool checklife = false; + bool checkdead = false; for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { if (i->getSource() && i->getSource()->isAlive() && diff --git a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp index 1b2fe61e87c..ec25a8f9f60 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp @@ -248,11 +248,9 @@ public: { for (uint8 i = 0; i < 3; ++i) { - Unit* unit = NULL; if (TargetGUID[i]) { - unit = Unit::GetUnit(*me, TargetGUID[i]); - if (unit) + if (Unit* unit = Unit::GetUnit(*me, TargetGUID[i])) unit->CastSpell(unit, SPELL_ATTRACTION, true); TargetGUID[i] = 0; } diff --git a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp index 710f5c82fab..673d4bcc96f 100644 --- a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp +++ b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp @@ -299,12 +299,11 @@ public: for (uint8 i = 0; i < 4; ++i) { - Unit* Member = NULL; if (Council[i]) { - Member = Unit::GetUnit(*me, Council[i]); - if (Member && Member->isAlive()) - CAST_CRE(Member)->AI()->AttackStart(target); + Unit* member = Unit::GetUnit(*me, Council[i]); + if (member && member->isAlive()) + CAST_CRE(member)->AI()->AttackStart(target); } } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 5eebb69d7a5..5153010c0cc 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -950,14 +950,14 @@ class spell_generic_clone : public SpellScriptLoader enum CloneWeaponSpells { - SPELL_COPY_WEAPON = 41055, - SPELL_COPY_WEAPON_2 = 63416, - SPELL_COPY_WEAPON_3 = 69891, + SPELL_COPY_WEAPON_AURA = 41054, + SPELL_COPY_WEAPON_2_AURA = 63418, + SPELL_COPY_WEAPON_3_AURA = 69893, - SPELL_COPY_OFFHAND = 45206, - SPELL_COPY_OFFHAND_2 = 69892, + SPELL_COPY_OFFHAND_AURA = 45205, + SPELL_COPY_OFFHAND_2_AURA = 69896, - SPELL_COPY_RANGED = 57593 + SPELL_COPY_RANGED_AURA = 57594 }; class spell_generic_clone_weapon : public SpellScriptLoader @@ -969,80 +969,147 @@ class spell_generic_clone_weapon : public SpellScriptLoader { PrepareSpellScript(spell_generic_clone_weapon_SpellScript); - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_2) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_3) || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND) - || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_2) || !sSpellMgr->GetSpellInfo(SPELL_COPY_RANGED)) - return false; - return true; - } - void HandleScriptEffect(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) { uint32 spellId = uint32(GetSpellInfo()->Effects[EFFECT_0].CalcValue()); - target->CastSpell(caster, spellId, true); + caster->CastSpell(target, spellId, true); + } + } - if (target->GetTypeId() == TYPEID_PLAYER) - return; + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_generic_clone_weapon_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_generic_clone_weapon_SpellScript(); + } +}; + +class spell_gen_clone_weapon_aura : public SpellScriptLoader +{ + public: + spell_gen_clone_weapon_aura() : SpellScriptLoader("spell_gen_clone_weapon_aura") { } + + class spell_gen_clone_weapon_auraScript : public AuraScript + { + PrepareAuraScript(spell_gen_clone_weapon_auraScript); + + uint32 prevItem; + + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_2_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_3_AURA) + || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_2_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_RANGED_AURA)) + return false; + return true; + } + + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* caster = GetCaster(); + Unit* target = GetTarget(); - switch (GetSpellInfo()->Id) + if (!caster) + return; + + switch (GetSpellInfo()->Id) + { + case SPELL_COPY_WEAPON_AURA: + case SPELL_COPY_WEAPON_2_AURA: + case SPELL_COPY_WEAPON_3_AURA: { - case SPELL_COPY_WEAPON: - case SPELL_COPY_WEAPON_2: - case SPELL_COPY_WEAPON_3: + prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID); + + if (Player* player = caster->ToPlayer()) { - if (Player* player = caster->ToPlayer()) - { - if (Item* mainItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, mainItem->GetEntry()); - } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID)); - break; + if (Item* mainItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, mainItem->GetEntry()); } - case SPELL_COPY_OFFHAND: - case SPELL_COPY_OFFHAND_2: + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID)); + break; + } + case SPELL_COPY_OFFHAND_AURA: + case SPELL_COPY_OFFHAND_2_AURA: + { + prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID) + 1; + + if (Player* player = caster->ToPlayer()) { - if (Player* player = caster->ToPlayer()) - { - if (Item* offItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, offItem->GetEntry()); - } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)); - break; + if (Item* offItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, offItem->GetEntry()); } - case SPELL_COPY_RANGED: + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)); + break; + } + case SPELL_COPY_RANGED_AURA: + { + prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID) + 2; + + if (Player* player = caster->ToPlayer()) { - if (Player* player = caster->ToPlayer()) - { - if (Item* rangedItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, rangedItem->GetEntry()); - } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2)); - break; + if (Item* rangedItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, rangedItem->GetEntry()); } - default: - break; + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2)); + break; + } + default: + break; + } + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + + switch (GetSpellInfo()->Id) + { + case SPELL_COPY_WEAPON_AURA: + case SPELL_COPY_WEAPON_2_AURA: + case SPELL_COPY_WEAPON_3_AURA: + { + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, prevItem); + break; + } + case SPELL_COPY_OFFHAND_AURA: + case SPELL_COPY_OFFHAND_2_AURA: + { + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, prevItem); + break; } + case SPELL_COPY_RANGED_AURA: + { + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, prevItem); + break; + } + default: + break; } } void Register() { - OnEffectHitTarget += SpellEffectFn(spell_generic_clone_weapon_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + OnEffectApply += AuraEffectApplyFn(spell_gen_clone_weapon_auraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + OnEffectRemove += AuraEffectRemoveFn(spell_gen_clone_weapon_auraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); } + }; - SpellScript* GetSpellScript() const + AuraScript* GetAuraScript() const { - return new spell_generic_clone_weapon_SpellScript(); + return new spell_gen_clone_weapon_auraScript(); } }; @@ -1844,16 +1911,18 @@ class spell_gen_break_shield: public SpellScriptLoader Unit::AuraApplicationMap const& auras = target->GetAppliedAuras(); for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { - Aura* aura = itr->second->GetBase(); - SpellInfo const* auraInfo = aura->GetSpellInfo(); - if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + if (Aura* aura = itr->second->GetBase()) { - aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - // Remove dummys from rider (Necessary for updating visual shields) - if (Unit* rider = target->GetCharmer()) - if (Aura* defend = rider->GetAura(aura->GetId())) - defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - break; + SpellInfo const* auraInfo = aura->GetSpellInfo(); + if (auraInfo && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + { + aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + // Remove dummys from rider (Necessary for updating visual shields) + if (Unit* rider = target->GetCharmer()) + if (Aura* defend = rider->GetAura(aura->GetId())) + defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + break; + } } } break; @@ -1972,16 +2041,18 @@ class spell_gen_mounted_charge: public SpellScriptLoader Unit::AuraApplicationMap const& auras = target->GetAppliedAuras(); for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { - Aura* aura = itr->second->GetBase(); - SpellInfo const* auraInfo = aura->GetSpellInfo(); - if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + if (Aura* aura = itr->second->GetBase()) { - aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - // Remove dummys from rider (Necessary for updating visual shields) - if (Unit* rider = target->GetCharmer()) - if (Aura* defend = rider->GetAura(aura->GetId())) - defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - break; + SpellInfo const* auraInfo = aura->GetSpellInfo(); + if (auraInfo && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + { + aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + // Remove dummys from rider (Necessary for updating visual shields) + if (Unit* rider = target->GetCharmer()) + if (Aura* defend = rider->GetAura(aura->GetId())) + defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + break; + } } } break; @@ -3189,6 +3260,7 @@ void AddSC_generic_spell_scripts() new spell_gen_profession_research(); new spell_generic_clone(); new spell_generic_clone_weapon(); + new spell_gen_clone_weapon_aura(); new spell_gen_seaforium_blast(); new spell_gen_turkey_marker(); new spell_gen_lifeblood(); diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 3cb2300cadf..cbf45910495 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -1291,7 +1291,7 @@ class spell_q12372_destabilize_azure_dragonshrine_dummy : public SpellScriptLoad class spell_q12372_destabilize_azure_dragonshrine_dummy_SpellScript : public SpellScript { PrepareSpellScript(spell_q12372_destabilize_azure_dragonshrine_dummy_SpellScript); - + void HandleDummy(SpellEffIndex /*effIndex*/) { if (GetHitCreature()) diff --git a/src/server/scripts/World/achievement_scripts.cpp b/src/server/scripts/World/achievement_scripts.cpp index 60572ee3e6a..a6f4f7f64f9 100755 --- a/src/server/scripts/World/achievement_scripts.cpp +++ b/src/server/scripts/World/achievement_scripts.cpp @@ -278,6 +278,9 @@ class achievement_tilted : public AchievementCriteriaScript bool OnCheck(Player* player, Unit* /*target*/) { + if (!player) + return false; + bool checkArea = player->GetAreaId() == AREA_ARGENT_TOURNAMENT_FIELDS || player->GetAreaId() == AREA_RING_OF_ASPIRANTS || player->GetAreaId() == AREA_RING_OF_ARGENT_VALIANTS || @@ -285,7 +288,7 @@ class achievement_tilted : public AchievementCriteriaScript player->GetAreaId() == AREA_RING_OF_HORDE_VALIANTS || player->GetAreaId() == AREA_RING_OF_CHAMPIONS; - return player && checkArea && player->duel && player->duel->isMounted; + return checkArea && player->duel && player->duel->isMounted; } }; |
