diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Achievements/AchievementMgr.cpp | 3 | ||||
-rwxr-xr-x | src/server/game/Battlegrounds/ArenaTeam.cpp | 12 | ||||
-rwxr-xr-x | src/server/game/Battlegrounds/ArenaTeam.h | 2 | ||||
-rwxr-xr-x | src/server/game/Battlegrounds/Battleground.cpp | 2 | ||||
-rwxr-xr-x | src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp | 1 | ||||
-rwxr-xr-x | src/server/game/Conditions/ConditionMgr.cpp | 10 | ||||
-rwxr-xr-x | src/server/game/Conditions/ConditionMgr.h | 6 | ||||
-rwxr-xr-x | src/server/game/Entities/Player/Player.cpp | 13 | ||||
-rwxr-xr-x | src/server/game/Entities/Unit/Unit.cpp | 5 | ||||
-rwxr-xr-x | src/server/game/Spells/Spell.cpp | 3 | ||||
-rwxr-xr-x | src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp | 1 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 426 | ||||
-rwxr-xr-x | src/server/scripts/World/achievement_scripts.cpp | 19 |
13 files changed, 254 insertions, 249 deletions
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 02686993fbb..271e78abf67 100755 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -1176,10 +1176,9 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui // speedup for non-login case if (miscValue1 && achievementCriteria->own_item.itemID != miscValue1) continue; - SetCriteriaProgress(achievementCriteria, GetPlayer()->GetItemCount(achievementCriteria->own_item.itemID, true)); + SetCriteriaProgress(achievementCriteria, miscValue2, PROGRESS_ACCUMULATE); break; case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA: - // miscvalue1 contains the personal rating if (!miscValue1) // no update at login continue; diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index 8e30743f107..02707261d13 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -455,7 +455,7 @@ void ArenaTeam::Inspect(WorldSession* session, uint64 guid) session->SendPacket(&data); } -void ArenaTeamMember::ModifyPersonalRating(Player* player, int32 mod, uint32 slot) +void ArenaTeamMember::ModifyPersonalRating(Player* player, int32 mod, uint32 type) { if (int32(PersonalRating) + mod < 0) PersonalRating = 0; @@ -464,8 +464,8 @@ void ArenaTeamMember::ModifyPersonalRating(Player* player, int32 mod, uint32 slo if (player) { - player->SetArenaTeamInfoField(slot, ARENA_TEAM_PERSONAL_RATING, PersonalRating); - player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING, PersonalRating, slot); + player->SetArenaTeamInfoField(ArenaTeam::GetSlotByType(type), ARENA_TEAM_PERSONAL_RATING, PersonalRating); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING, PersonalRating, type); } } @@ -725,7 +725,7 @@ void ArenaTeam::MemberLost(Player* player, uint32 againstMatchmakerRating, int32 { // Update personal rating int32 mod = GetRatingMod(itr->PersonalRating, againstMatchmakerRating, false); - itr->ModifyPersonalRating(player, mod, GetSlot()); + itr->ModifyPersonalRating(player, mod, GetType()); // Update matchmaker rating itr->ModifyMatchmakerRating(MatchmakerRatingChange, GetSlot()); @@ -751,7 +751,7 @@ void ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstMatchmakerRating, i { // update personal rating int32 mod = GetRatingMod(itr->PersonalRating, againstMatchmakerRating, false); - itr->ModifyPersonalRating(NULL, mod, GetSlot()); + itr->ModifyPersonalRating(NULL, mod, GetType()); // update matchmaker rating itr->ModifyMatchmakerRating(MatchmakerRatingChange, GetSlot()); @@ -773,7 +773,7 @@ void ArenaTeam::MemberWon(Player* player, uint32 againstMatchmakerRating, int32 { // update personal rating int32 mod = GetRatingMod(itr->PersonalRating, againstMatchmakerRating, true); - itr->ModifyPersonalRating(player, mod, GetSlot()); + itr->ModifyPersonalRating(player, mod, GetType()); // update matchmaker rating itr->ModifyMatchmakerRating(MatchmakerRatingChange, GetSlot()); diff --git a/src/server/game/Battlegrounds/ArenaTeam.h b/src/server/game/Battlegrounds/ArenaTeam.h index 03ddea1dd3a..d8ad2c09e59 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.h +++ b/src/server/game/Battlegrounds/ArenaTeam.h @@ -97,7 +97,7 @@ struct ArenaTeamMember uint16 PersonalRating; uint16 MatchMakerRating; - void ModifyPersonalRating(Player* player, int32 mod, uint32 slot); + void ModifyPersonalRating(Player* player, int32 mod, uint32 type); void ModifyMatchmakerRating(int32 mod, uint32 slot); }; diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 5d121869f54..08ca406e373 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -824,7 +824,7 @@ void Battleground::EndBattleground(uint32 winner) // update achievement BEFORE personal rating update ArenaTeamMember* member = winner_arena_team->GetMember(player->GetGUID()); if (member) - player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, member->PersonalRating); + player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, 1); winner_arena_team->MemberWon(player, loser_matchmaker_rating, winner_matchmaker_change); } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index 1e7f79b8391..cbc3ec85055 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -196,7 +196,6 @@ void BattlegroundEY::CheckSomeoneLeftPoint() //move not existed player to "free space" - this will cause many error showing in log, but it is a very important bug m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]); m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j); - ++j; continue; } if (!player->CanCaptureTowerPoint() || !player->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS)) diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index a745c5a2f13..330a38ba5dd 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -344,17 +344,17 @@ ConditionList ConditionMgr::GetConditionsForVehicleSpell(uint32 creatureID, uint return cond; } -ConditionList ConditionMgr::GetConditionsForSmartEvent(uint32 entry, uint32 eventId, uint32 sourceType) +ConditionList ConditionMgr::GetConditionsForSmartEvent(int32 entryOrGuid, uint32 eventId, uint32 sourceType) { ConditionList cond; - SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entry, sourceType)); + SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entryOrGuid, sourceType)); if (itr != SmartEventConditionStore.end()) { ConditionTypeContainer::const_iterator i = (*itr).second.find(eventId + 1); if (i != (*itr).second.end()) { cond = (*i).second; - sLog->outDebug(LOG_FILTER_CONDITIONSYS, "GetConditionsForSmartEvent: found conditions for Smart Event entry %u event_id %u", entry, eventId); + sLog->outDebug(LOG_FILTER_CONDITIONSYS, "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid %d event_id %u", entryOrGuid, eventId); } } return cond; @@ -410,7 +410,7 @@ void ConditionMgr::LoadConditions(bool isReload) Condition* cond = new Condition(); int32 iSourceTypeOrReferenceId = fields[0].GetInt32(); cond->mSourceGroup = fields[1].GetUInt32(); - cond->mSourceEntry = fields[2].GetUInt32(); + cond->mSourceEntry = fields[2].GetInt32(); cond->mSourceId = fields[3].GetUInt32(); cond->mElseGroup = fields[4].GetUInt32(); int32 iConditionTypeOrReference = fields[5].GetInt32(); @@ -553,7 +553,7 @@ void ConditionMgr::LoadConditions(bool isReload) case CONDITION_SOURCE_TYPE_SMART_EVENT: { // If the entry does not exist, create a new list - std::pair<uint32, uint32> key = std::make_pair(cond->mSourceEntry, cond->mSourceId); + std::pair<int32, uint32> key = std::make_pair(cond->mSourceEntry, cond->mSourceId); if (SmartEventConditionStore.find(key) == SmartEventConditionStore.end()) { ConditionTypeContainer cmap; diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index a9bb97251da..1641642dd86 100755 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -104,7 +104,7 @@ struct Condition { ConditionSourceType mSourceType; //SourceTypeOrReferenceId uint32 mSourceGroup; - uint32 mSourceEntry; + int32 mSourceEntry; uint32 mSourceId; // So far, only used in CONDITION_SOURCE_TYPE_SMART_EVENT uint32 mElseGroup; ConditionType mConditionType; //ConditionTypeOrReference @@ -138,7 +138,7 @@ typedef std::list<Condition*> ConditionList; typedef std::map<uint32, ConditionList> ConditionTypeContainer; typedef std::map<ConditionSourceType, ConditionTypeContainer> ConditionContainer; typedef std::map<uint32, ConditionTypeContainer> VehicleSpellConditionContainer; -typedef std::map<std::pair<uint32, uint32 /*SAI source_type*/>, ConditionTypeContainer> SmartEventConditionContainer; +typedef std::map<std::pair<int32, uint32 /*SAI source_type*/>, ConditionTypeContainer> SmartEventConditionContainer; typedef std::map<uint32, ConditionList> ConditionReferenceContainer;//only used for references @@ -157,7 +157,7 @@ class ConditionMgr bool IsPlayerMeetToConditions(Player* player, ConditionList const& conditions, Unit* invoker = NULL); ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry); - ConditionList GetConditionsForSmartEvent(uint32 entry, uint32 eventId, uint32 sourceType); + ConditionList GetConditionsForSmartEvent(int32 entryOrGuid, uint32 eventId, uint32 sourceType); ConditionList GetConditionsForVehicleSpell(uint32 creatureID, uint32 spellID); private: diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 44186dad95c..9eece3003af 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -2314,14 +2314,9 @@ bool Player::TeleportToBGEntryPoint() if (m_bgData.joinPos.m_mapId == MAPID_INVALID) return false; - Group* group = GetGroup(); - if (group && group->isLFGGroup() && group->GetMembersCount() == 1) - group->Disband(); - else - ScheduleDelayedOperation(DELAYED_BG_GROUP_RESTORE); - ScheduleDelayedOperation(DELAYED_BG_MOUNT_RESTORE); ScheduleDelayedOperation(DELAYED_BG_TAXI_RESTORE); + ScheduleDelayedOperation(DELAYED_BG_GROUP_RESTORE); return TeleportTo(m_bgData.joinPos); } @@ -12043,7 +12038,7 @@ Item* Player::StoreItem(ItemPosCountVec const& dest, Item* pItem, bool update) lastItem = _StoreItem(pos, pItem, count, true, update); } - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM, entry); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM, entry, 1); return lastItem; } @@ -14829,7 +14824,9 @@ bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg) void Player::AddQuest(Quest const* quest, Object* questGiver) { uint16 log_slot = FindQuestSlot(0); - ASSERT(log_slot < MAX_QUEST_LOG_SIZE); + + if (log_slot >= MAX_QUEST_LOG_SIZE) // Player does not have any free slot in the quest log + return; uint32 quest_id = quest->GetQuestId(); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index e02331e00e7..289a600e88a 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -775,7 +775,10 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam ASSERT(he->duel); - he->SetHealth(1); + if (duel_wasMounted) // In this case victim==mount + victim->SetHealth(1); + else + he->SetHealth(1); he->duel->opponent->CombatStopWithPets(true); he->CombatStopWithPets(true); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index c8e4c55c7c0..3c73edb880d 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5401,6 +5401,9 @@ SpellCastResult Spell::CheckCast(bool strict) } case SPELL_AURA_PERIODIC_MANA_LEECH: { + if (m_spellInfo->Effects[i].IsArea()) + break; + if (!m_targets.GetUnitTarget()) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index 04ae6f933d8..ac246abdc7c 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -106,6 +106,7 @@ class boss_lord_marrowgar : public CreatureScript events.ScheduleEvent(EVENT_COLDFLAME, 5000, EVENT_GROUP_SPECIAL); events.ScheduleEvent(EVENT_WARN_BONE_STORM, urand(45000, 50000)); events.ScheduleEvent(EVENT_ENRAGE, 600000); + _boneSlice = false; } void EnterCombat(Unit* /*who*/) diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 96d259817c0..3d552901295 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -342,11 +342,8 @@ class spell_gen_remove_flight_auras : public SpellScriptLoader PrepareSpellScript(spell_gen_remove_flight_auras_SpellScript); void HandleScript(SpellEffIndex /*effIndex*/) { - Unit* target = GetHitUnit(); - if (!target) - return; - target->RemoveAurasByType(SPELL_AURA_FLY); - target->RemoveAurasByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED); + GetHitUnit()->RemoveAurasByType(SPELL_AURA_FLY); + GetHitUnit()->RemoveAurasByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED); } void Register() @@ -448,25 +445,22 @@ class spell_gen_elune_candle : public SpellScriptLoader void HandleScript(SpellEffIndex /*effIndex*/) { - if (Unit* target = GetHitUnit()) - { - uint32 spellId = 0; + uint32 spellId = 0; - if (target->GetEntry() == NPC_OMEN) + if (GetHitUnit()->GetEntry() == NPC_OMEN) + { + switch (urand(0, 3)) { - switch (urand(0, 3)) - { - case 0: spellId = SPELL_ELUNE_CANDLE_OMEN_HEAD; break; - case 1: spellId = SPELL_ELUNE_CANDLE_OMEN_CHEST; break; - case 2: spellId = SPELL_ELUNE_CANDLE_OMEN_HAND_R; break; - case 3: spellId = SPELL_ELUNE_CANDLE_OMEN_HAND_L; break; - } + case 0: spellId = SPELL_ELUNE_CANDLE_OMEN_HEAD; break; + case 1: spellId = SPELL_ELUNE_CANDLE_OMEN_CHEST; break; + case 2: spellId = SPELL_ELUNE_CANDLE_OMEN_HAND_R; break; + case 3: spellId = SPELL_ELUNE_CANDLE_OMEN_HAND_L; break; } - else - spellId = SPELL_ELUNE_CANDLE_NORMAL; - - GetCaster()->CastSpell(target, spellId, true, NULL); } + else + spellId = SPELL_ELUNE_CANDLE_NORMAL; + + GetCaster()->CastSpell(GetHitUnit(), spellId, true, NULL); } void Register() @@ -947,11 +941,8 @@ class spell_generic_clone : public SpellScriptLoader void HandleScriptEffect(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - Unit* caster = GetCaster(); uint32 spellId = uint32(GetSpellInfo()->Effects[effIndex].CalcValue()); - - if (Unit* target = GetHitUnit()) - target->CastSpell(caster, spellId, true); + GetHitUnit()->CastSpell(GetCaster(), spellId, true); } void Register() @@ -1591,7 +1582,6 @@ class spell_gen_dalaran_disguise : public SpellScriptLoader void HandleScript(SpellEffIndex /*effIndex*/) { - if (Player* player = GetHitPlayer()) { uint8 gender = player->getGender(); @@ -1661,66 +1651,74 @@ enum BreakShieldSpells class spell_gen_break_shield: public SpellScriptLoader { -public: - spell_gen_break_shield() : SpellScriptLoader("spell_gen_break_shield") { } - - class spell_gen_break_shield_SpellScript : public SpellScript - { - PrepareSpellScript(spell_gen_break_shield_SpellScript) + public: + spell_gen_break_shield() : SpellScriptLoader("spell_gen_break_shield") { } - void HandleScriptEffect(SpellEffIndex effIndex) + class spell_gen_break_shield_SpellScript : public SpellScript { - Unit* caster = GetCaster(); - Unit* target = GetTargetUnit(); - - if (!caster || !target) - return; + PrepareSpellScript(spell_gen_break_shield_SpellScript) - switch (effIndex) + void HandleScriptEffect(SpellEffIndex effIndex) { - case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual) - uint32 spellId; - switch (GetSpellInfo()->Id) + Unit* target = GetHitUnit(); + + switch (effIndex) + { + case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual) { - case SPELL_BREAK_SHIELD_TRIGGER_UNK: - case SPELL_BREAK_SHIELD_TRIGGER_CAMPAING_WARHORSE: - spellId = SPELL_BREAK_SHIELD_DAMAGE_10K; - break; - case SPELL_BREAK_SHIELD_TRIGGER_FACTION_MOUNTS: - spellId = SPELL_BREAK_SHIELD_DAMAGE_2K; - break; - default: - return; - } + uint32 spellId; - if (Unit* rider = caster->GetCharmer()) - rider->CastSpell(target, spellId, false); - else - caster->CastSpell(target, spellId, false); - break; - case EFFECT_1: // On damaging spells, for removing the a defend layer - Unit::AuraApplicationMap const& auras = target->GetAppliedAuras(); - for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + switch (GetSpellInfo()->Id) + { + case SPELL_BREAK_SHIELD_TRIGGER_UNK: + case SPELL_BREAK_SHIELD_TRIGGER_CAMPAING_WARHORSE: + spellId = SPELL_BREAK_SHIELD_DAMAGE_10K; + break; + case SPELL_BREAK_SHIELD_TRIGGER_FACTION_MOUNTS: + spellId = SPELL_BREAK_SHIELD_DAMAGE_2K; + break; + default: + return; + } + + if (Unit* rider = GetCaster()->GetCharmer()) + rider->CastSpell(target, spellId, false); + else + GetCaster()->CastSpell(target, spellId, false); + break; + } + case EFFECT_1: // On damaging spells, for removing a defend layer { - Aura* aura = itr->second->GetBase(); - SpellInfo const* auraInfo = aura->GetSpellInfo(); - if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) - aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + 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)) + { + 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; } - break; + } } - } - void Register() + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_gen_break_shield_SpellScript::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_gen_break_shield_SpellScript::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT); + return new spell_gen_break_shield_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_gen_break_shield_SpellScript(); - } }; /* DOCUMENTATION: Charge spells @@ -1775,109 +1773,110 @@ enum ChargeSpells class spell_gen_mounted_charge: public SpellScriptLoader { -public: - spell_gen_mounted_charge() : SpellScriptLoader("spell_gen_mounted_charge") { } - - class spell_gen_mounted_charge_SpellScript : public SpellScript - { - PrepareSpellScript(spell_gen_mounted_charge_SpellScript) + public: + spell_gen_mounted_charge() : SpellScriptLoader("spell_gen_mounted_charge") { } - void HandleScriptEffect(SpellEffIndex effIndex) + class spell_gen_mounted_charge_SpellScript : public SpellScript { - Unit* caster = GetCaster(); - Unit* target = GetTargetUnit(); + PrepareSpellScript(spell_gen_mounted_charge_SpellScript) - if (!caster || !target) - return; - - switch (effIndex) + void HandleScriptEffect(SpellEffIndex effIndex) { - case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual) - uint32 spellId; + Unit* target = GetHitUnit(); - switch (GetSpellInfo()->Id) + switch (effIndex) + { + case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual) { - case SPELL_CHARGE_TRIGGER_TRIAL_CHAMPION: - spellId = SPELL_CHARGE_CHARGING_EFFECT_20K_1; - case SPELL_CHARGE_TRIGGER_FACTION_MOUNTS: - spellId = SPELL_CHARGE_CHARGING_EFFECT_8K5; - break; - default: - return; - } + uint32 spellId; - if (Unit* vehicle = caster->GetVehicleBase()) - vehicle->CastSpell(target, spellId, false); - else - caster->CastSpell(target, spellId, false); - break; - case EFFECT_1: // On damaging spells, for removing the a defend layer - case EFFECT_2: - Unit::AuraApplicationMap const& auras = target->GetAppliedAuras(); - for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + switch (GetSpellInfo()->Id) + { + case SPELL_CHARGE_TRIGGER_TRIAL_CHAMPION: + spellId = SPELL_CHARGE_CHARGING_EFFECT_20K_1; + case SPELL_CHARGE_TRIGGER_FACTION_MOUNTS: + spellId = SPELL_CHARGE_CHARGING_EFFECT_8K5; + break; + default: + return; + } + + // If target isn't a training dummy there's a chance of failing the charge + if (!target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE) && roll_chance_f(12.5f)) + spellId = SPELL_CHARGE_MISS_EFFECT; + + if (Unit* vehicle = GetCaster()->GetVehicleBase()) + vehicle->CastSpell(target, spellId, false); + else + GetCaster()->CastSpell(target, spellId, false); + break; + } + case EFFECT_1: // On damaging spells, for removing a defend layer + case EFFECT_2: { - Aura* aura = itr->second->GetBase(); - SpellInfo const* auraInfo = aura->GetSpellInfo(); - if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) - aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + 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)) + { + 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; } - break; + } } - } - void HandleChargeEffect(SpellEffIndex effIndex) - { - Unit* caster = GetCaster(); - Unit* target = GetTargetUnit(); + void HandleChargeEffect(SpellEffIndex effIndex) + { + uint32 spellId; - if (!caster || !target) - return; + switch (GetSpellInfo()->Id) + { + case SPELL_CHARGE_CHARGING_EFFECT_8K5: + spellId = SPELL_CHARGE_DAMAGE_8K5; + break; + case SPELL_CHARGE_CHARGING_EFFECT_20K_1: + case SPELL_CHARGE_CHARGING_EFFECT_20K_2: + spellId = SPELL_CHARGE_DAMAGE_20K; + break; + case SPELL_CHARGE_CHARGING_EFFECT_45K_1: + case SPELL_CHARGE_CHARGING_EFFECT_45K_2: + spellId = SPELL_CHARGE_DAMAGE_45K; + break; + default: + return; + } - uint32 spellId; - - switch (GetSpellInfo()->Id) - { - case SPELL_CHARGE_CHARGING_EFFECT_8K5: - spellId = SPELL_CHARGE_DAMAGE_8K5; - break; - case SPELL_CHARGE_CHARGING_EFFECT_20K_1: - case SPELL_CHARGE_CHARGING_EFFECT_20K_2: - spellId = SPELL_CHARGE_DAMAGE_20K; - break; - case SPELL_CHARGE_CHARGING_EFFECT_45K_1: - case SPELL_CHARGE_CHARGING_EFFECT_45K_2: - spellId = SPELL_CHARGE_DAMAGE_45K; - break; - default: - return; + if (Unit* rider = GetCaster()->GetCharmer()) + rider->CastSpell(GetHitUnit(), spellId, false); + else + GetCaster()->CastSpell(GetHitUnit(), spellId, false); } - // If target isn't a training dummy there's a chance of failing the charge - if (!target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE) && urand(0,7) == 0) - spellId = SPELL_CHARGE_MISS_EFFECT; - - if (Unit* rider = caster->GetCharmer()) - rider->CastSpell(target, spellId, false); - else - caster->CastSpell(target, spellId, false); - } + void Register() + { + SpellInfo const* spell = sSpellMgr->GetSpellInfo(m_scriptSpellId); - void Register() - { - SpellInfo const* spell = sSpellMgr->GetSpellInfo(m_scriptSpellId); + if (spell->HasEffect(SPELL_EFFECT_SCRIPT_EFFECT)) + OnEffectHitTarget += SpellEffectFn(spell_gen_mounted_charge_SpellScript::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT); - if (spell->HasEffect(SPELL_EFFECT_SCRIPT_EFFECT)) - OnEffectHit += SpellEffectFn(spell_gen_mounted_charge_SpellScript::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT); + if (spell->Effects[EFFECT_0].Effect == SPELL_EFFECT_CHARGE) + OnEffectHitTarget += SpellEffectFn(spell_gen_mounted_charge_SpellScript::HandleChargeEffect, EFFECT_0, SPELL_EFFECT_CHARGE); + } + }; - if (spell->Effects[EFFECT_0].Effect == SPELL_EFFECT_CHARGE) - OnEffectHit += SpellEffectFn(spell_gen_mounted_charge_SpellScript::HandleChargeEffect, EFFECT_0, SPELL_EFFECT_CHARGE); + SpellScript* GetSpellScript() const + { + return new spell_gen_mounted_charge_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_gen_mounted_charge_SpellScript(); - } }; enum DefendVisuals @@ -1907,44 +1906,33 @@ class spell_gen_defend : public SpellScriptLoader return true; } - void RefreshVisualShields(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + void RefreshVisualShields(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - Unit* caster = GetCaster(); - Unit* target = GetTarget(); - - if(!target) - return; - - if (!caster) + if (Unit* caster = GetCaster()) { - target->RemoveAurasDueToSpell(GetId()); - return; - } + Unit* target = GetTarget(); - for (uint8 i = 0; i < GetSpellInfo()->StackAmount; ++i) - target->RemoveAurasDueToSpell(SPELL_VISUAL_SHIELD_1 + i); + for (uint8 i = 0; i < GetSpellInfo()->StackAmount; ++i) + target->RemoveAurasDueToSpell(SPELL_VISUAL_SHIELD_1 + i); - target->CastSpell(target, SPELL_VISUAL_SHIELD_1 + GetAura()->GetStackAmount() - 1); + target->CastSpell(target, SPELL_VISUAL_SHIELD_1 + GetAura()->GetStackAmount() - 1, true, NULL, aurEff); + } + else + GetTarget()->RemoveAurasDueToSpell(GetId()); } void RemoveVisualShields(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - Unit* target = GetTarget(); - - if(!target) - return; - for (uint8 i = 0; i < GetSpellInfo()->StackAmount; ++i) - target->RemoveAurasDueToSpell(SPELL_VISUAL_SHIELD_1 + i); + GetTarget()->RemoveAurasDueToSpell(SPELL_VISUAL_SHIELD_1 + i); } void RemoveDummyFromDriver(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - Unit* caster = GetCaster(); - - if (caster && caster->ToTempSummon()) - if (Unit* rider = caster->ToTempSummon()->GetSummoner()) - rider->RemoveAurasDueToSpell(GetId()); + if (Unit* caster = GetCaster()) + if (TempSummon* vehicle = caster->ToTempSummon()) + if (Unit* rider = vehicle->GetSummoner()) + rider->RemoveAurasDueToSpell(GetId()); } void Register() @@ -1955,7 +1943,7 @@ class spell_gen_defend : public SpellScriptLoader if (spell->Effects[EFFECT_0].ApplyAuraName == SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN) { AfterEffectApply += AuraEffectApplyFn(spell_gen_defendAuraScript::RefreshVisualShields, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - OnEffectRemove += AuraEffectRemoveFn(spell_gen_defendAuraScript::RemoveVisualShields, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL); + OnEffectRemove += AuraEffectRemoveFn(spell_gen_defendAuraScript::RemoveVisualShields, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); } // Remove Defend spell from player when he dismounts @@ -1966,7 +1954,7 @@ class spell_gen_defend : public SpellScriptLoader if (spell->Effects[EFFECT_1].ApplyAuraName == SPELL_AURA_DUMMY) { AfterEffectApply += AuraEffectApplyFn(spell_gen_defendAuraScript::RefreshVisualShields, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - OnEffectRemove += AuraEffectRemoveFn(spell_gen_defendAuraScript::RemoveVisualShields, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectRemove += AuraEffectRemoveFn(spell_gen_defendAuraScript::RemoveVisualShields, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); } } }; @@ -2003,33 +1991,24 @@ class spell_gen_tournament_duel : public SpellScriptLoader void HandleScriptEffect(SpellEffIndex effIndex) { - Unit* caster = GetCaster(); - Unit* target = GetTargetUnit(); - Unit* player = GetCaster()->GetCharmer(); - - if (!caster || !target || !player) - return; - - if (target->GetTypeId() == TYPEID_PLAYER) - { - - if (!target->HasAura(SPELL_ON_TOURNAMENT_MOUNT) || !target->GetVehicleBase()) - return; - - player->CastSpell(target, SPELL_MOUNTED_DUEL, true); - } - else if (target->GetTypeId() == TYPEID_UNIT) + if (Unit* rider = GetCaster()->GetCharmer()) { - if (!target->GetCharmer() || target->GetCharmer()->GetTypeId() != TYPEID_PLAYER || !target->GetCharmer()->HasAura(SPELL_ON_TOURNAMENT_MOUNT)) - return; - - player->CastSpell(target->GetCharmer(), SPELL_MOUNTED_DUEL, true); + if (Player* plrTarget = GetHitPlayer()) + { + if (plrTarget->HasAura(SPELL_ON_TOURNAMENT_MOUNT) && plrTarget->GetVehicleBase()) + rider->CastSpell(plrTarget, SPELL_MOUNTED_DUEL, true); + } + else if (Unit* unitTarget = GetHitUnit()) + { + if (unitTarget->GetCharmer() && unitTarget->GetCharmer()->GetTypeId() == TYPEID_PLAYER && unitTarget->GetCharmer()->HasAura(SPELL_ON_TOURNAMENT_MOUNT)) + rider->CastSpell(unitTarget->GetCharmer(), SPELL_MOUNTED_DUEL, true); + } } } void Register() { - OnEffectHit += SpellEffectFn(spell_gen_tournament_duel_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + OnEffectHitTarget += SpellEffectFn(spell_gen_tournament_duel_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; @@ -2062,9 +2041,13 @@ class spell_gen_summon_tournament_mount : public SpellScriptLoader SpellCastResult CheckIfLanceEquiped() { - Unit* caster = GetCaster(); + if (GetCaster()->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) + { + SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_CANT_MOUNT_WITH_SHAPESHIFT); + return SPELL_FAILED_CUSTOM_ERROR; + } - if (!caster->HasAura(SPELL_LANCE_EQUIPPED)) + if (!GetCaster()->HasAura(SPELL_LANCE_EQUIPPED)) { SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_MUST_HAVE_LANCE_EQUIPPED); return SPELL_FAILED_CUSTOM_ERROR; @@ -2194,25 +2177,24 @@ class spell_gen_on_tournament_mount : public SpellScriptLoader bool Load() { _pennantSpellId = 0; - return (GetCaster()->GetTypeId() == TYPEID_PLAYER); + return GetCaster() && GetCaster()->GetTypeId() == TYPEID_PLAYER; } void HandleApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - Unit* caster = GetCaster(); - - if (caster && caster->GetVehicleBase()) + if (Unit* caster = GetCaster()) { - _pennantSpellId = GetPennatSpellId(caster->ToPlayer(), caster->GetVehicleBase()); - caster->CastSpell(caster, _pennantSpellId,true); + if (Unit* vehicle = caster->GetVehicleBase()) + { + _pennantSpellId = GetPennatSpellId(caster->ToPlayer(), vehicle); + caster->CastSpell(caster, _pennantSpellId, true); + } } } void HandleRemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - Unit* caster = GetCaster(); - - if (caster) + if (Unit* caster = GetCaster()) caster->RemoveAurasDueToSpell(_pennantSpellId); } @@ -2348,12 +2330,16 @@ class spell_gen_tournament_pennant : public SpellScriptLoader { PrepareAuraScript(spell_gen_tournament_pennantAuraScript); - void HandleApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + bool Load() { - Unit* caster = GetCaster(); + return GetCaster() && GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - if (caster && caster->GetTypeId() == TYPEID_PLAYER && !caster->GetVehicleBase()) - caster->RemoveAurasDueToSpell(GetId()); + void HandleApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) + if (!caster->GetVehicleBase()) + caster->RemoveAurasDueToSpell(GetId()); } void Register() diff --git a/src/server/scripts/World/achievement_scripts.cpp b/src/server/scripts/World/achievement_scripts.cpp index 135f22e0a01..9bcf450b3aa 100755 --- a/src/server/scripts/World/achievement_scripts.cpp +++ b/src/server/scripts/World/achievement_scripts.cpp @@ -285,6 +285,16 @@ class achievement_bg_sa_defense_of_ancients : public AchievementCriteriaScript } }; +enum ArgentTournamentAreas +{ + AREA_ARGENT_TOURNAMENT_FIELDS = 4658, + AREA_RING_OF_ASPIRANTS = 4670, + AREA_RING_OF_ARGENT_VALIANTS = 4671, + AREA_RING_OF_ALLIANCE_VALIANTS = 4672, + AREA_RING_OF_HORDE_VALIANTS = 4673, + AREA_RING_OF_CHAMPIONS = 4669, +}; + class achievement_tilted : public AchievementCriteriaScript { public: @@ -292,7 +302,14 @@ class achievement_tilted : public AchievementCriteriaScript bool OnCheck(Player* player, Unit* /*target*/) { - return player && player->duel && player->duel->isMounted; + bool checkArea = player->GetAreaId() == AREA_ARGENT_TOURNAMENT_FIELDS || + player->GetAreaId() == AREA_RING_OF_ASPIRANTS || + player->GetAreaId() == AREA_RING_OF_ARGENT_VALIANTS || + player->GetAreaId() == AREA_RING_OF_ALLIANCE_VALIANTS || + player->GetAreaId() == AREA_RING_OF_HORDE_VALIANTS || + player->GetAreaId() == AREA_RING_OF_CHAMPIONS; + + return player && checkArea && player->duel && player->duel->isMounted; } }; |