From 8df577ebfed34131184d2fd08b131b29b96d4fd3 Mon Sep 17 00:00:00 2001 From: xinef1 Date: Sun, 19 Feb 2017 06:30:04 +0100 Subject: Corrected points per level calculation for some spells (#19105) (cherry picked from commit 9142c778dd861eda188ba868433af05038c4e13c) --- src/server/game/Spells/SpellInfo.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 12eb37b6861..3b27c060639 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -510,14 +510,16 @@ int32 SpellEffectInfo::CalcValue(Unit const* caster /*= nullptr*/, int32 const* if (Scaling.ResourceCoefficient) comboDamage = Scaling.ResourceCoefficient * value; } - else + else if (GetScalingExpectedStat() == ExpectedStatType::None) { - if (GetScalingExpectedStat() == ExpectedStatType::None) + if (caster && basePointsPerLevel != 0.0f) { - int32 level = caster ? int32(caster->getLevel()) : 0; + int32 level = int32(caster->getLevel()); if (level > int32(_spellInfo->MaxLevel) && _spellInfo->MaxLevel > 0) level = int32(_spellInfo->MaxLevel); - level -= int32(_spellInfo->BaseLevel); + + // if base level is greater than spell level, reduce by base level (eg. pilgrims foods) + level -= int32(std::max(_spellInfo->BaseLevel, _spellInfo->SpellLevel)); if (level < 0) level = 0; value += level * basePointsPerLevel; -- cgit v1.2.3 From e36497aef57899f18e0d55c0640bfd96e2251a8e Mon Sep 17 00:00:00 2001 From: xinef1 Date: Thu, 2 Mar 2017 00:10:15 +0100 Subject: Core/Misc: Always reward all necessary reputations on creature kill (#19106) (cherry picked from commit fb2aebe46be7439a8f9b99067edb27fd844c1a28) --- src/server/game/Entities/Player/Player.cpp | 12 ++++++------ src/server/game/Reputation/ReputationMgr.cpp | 7 +++++-- src/server/game/Reputation/ReputationMgr.h | 8 ++++---- 3 files changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index b932d9e35c4..ae089ed5398 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -6415,8 +6415,8 @@ void Player::RewardReputation(Unit* victim, float rate) FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction1); uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1); - if (factionEntry1 && current_reputation_rank1 <= Rep->ReputationMaxCap1) - GetReputationMgr().ModifyReputation(factionEntry1, donerep1); + if (factionEntry1) + GetReputationMgr().ModifyReputation(factionEntry1, donerep1, current_reputation_rank1 > Rep->ReputationMaxCap1); } if (Rep->RepFaction2 && (!Rep->TeamDependent || team == HORDE)) @@ -6426,8 +6426,8 @@ void Player::RewardReputation(Unit* victim, float rate) FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction2); uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2); - if (factionEntry2 && current_reputation_rank2 <= Rep->ReputationMaxCap2) - GetReputationMgr().ModifyReputation(factionEntry2, donerep2); + if (factionEntry2) + GetReputationMgr().ModifyReputation(factionEntry2, donerep2, current_reputation_rank2 > Rep->ReputationMaxCap2); } } @@ -6479,7 +6479,7 @@ void Player::RewardReputation(Quest const* quest) rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); bool noSpillover = (quest->GetRewardReputationMask() & (1 << i)) != 0; - GetReputationMgr().ModifyReputation(factionEntry, rep, noSpillover); + GetReputationMgr().ModifyReputation(factionEntry, rep, false, noSpillover); } } @@ -6937,7 +6937,7 @@ void Player::ModifyCurrency(uint32 id, int32 count, bool printLog/* = true*/, bo { if (currency->Flags & CURRENCY_FLAG_HIGH_PRECISION) count /= 100; - GetReputationMgr().ModifyReputation(factionEntry, count, true); + GetReputationMgr().ModifyReputation(factionEntry, count, false, true); return; } diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index 1c362984ecc..b017947d56c 100644 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -267,7 +267,7 @@ void ReputationMgr::Initialize() } } -bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool noSpillover) +bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool spillOverOnly, bool noSpillover) { sScriptMgr->OnPlayerReputationChange(_player, factionEntry->ID, standing, incremental); bool res = false; @@ -334,7 +334,10 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi FactionStateList::iterator faction = _factions.find(factionEntry->ReputationIndex); if (faction != _factions.end()) { - res = SetOneFactionReputation(factionEntry, standing, incremental); + // if we update spillover only, do not update main reputation (rank exceeds creature reward rate) + if (!spillOverOnly) + res = SetOneFactionReputation(factionEntry, standing, incremental); + // only this faction gets reported to client, even if it has no own visible standing SendState(&faction->second); } diff --git a/src/server/game/Reputation/ReputationMgr.h b/src/server/game/Reputation/ReputationMgr.h index 3ad0958107c..ffc9ad826b5 100644 --- a/src/server/game/Reputation/ReputationMgr.h +++ b/src/server/game/Reputation/ReputationMgr.h @@ -118,11 +118,11 @@ class TC_GAME_API ReputationMgr public: // modifiers bool SetReputation(FactionEntry const* factionEntry, int32 standing) { - return SetReputation(factionEntry, standing, false, false); + return SetReputation(factionEntry, standing, false, false, false); } - bool ModifyReputation(FactionEntry const* factionEntry, int32 standing, bool noSpillover = false) + bool ModifyReputation(FactionEntry const* factionEntry, int32 standing, bool spillOverOnly = false, bool noSpillover = false) { - return SetReputation(factionEntry, standing, true, noSpillover); + return SetReputation(factionEntry, standing, true, spillOverOnly, noSpillover); } void SetVisible(FactionTemplateEntry const* factionTemplateEntry); @@ -144,7 +144,7 @@ class TC_GAME_API ReputationMgr private: // internal helper functions void Initialize(); uint32 GetDefaultStateFlags(FactionEntry const* factionEntry) const; - bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool noSpillover); + bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool spillOverOnly, bool noSpillover); void SetVisible(FactionState* faction); void SetAtWar(FactionState* faction, bool atWar) const; void SetInactive(FactionState* faction, bool inactive) const; -- cgit v1.2.3 From fc2872e16c5973d2a41bb9cbf8fcdbb63b095fb2 Mon Sep 17 00:00:00 2001 From: Keader Date: Sat, 1 Apr 2017 21:16:55 -0300 Subject: Core/Scripts: Fixed Volatile Ooze/Gas Cloud issues in Professor Putricide Closes #18925 (cherry picked from commit 8d198cb36050e63811f8f7f81a3daf2a3c961950) --- .../Northrend/IcecrownCitadel/boss_professor_putricide.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index d34819efbef..a1277ae754a 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -278,7 +278,7 @@ class boss_professor_putricide : public CreatureScript Talk(SAY_AGGRO); DoCast(me, SPELL_OOZE_TANK_PROTECTION, true); DoZoneInCombat(me); - + me->SetCombatPulseDelay(5); instance->SetBossState(DATA_PROFESSOR_PUTRICIDE, IN_PROGRESS); } @@ -730,7 +730,7 @@ class npc_putricide_oozeAI : public ScriptedAI { public: npc_putricide_oozeAI(Creature* creature, uint32 auraSpellId, uint32 hitTargetSpellId) : ScriptedAI(creature), - _auraSpellId(auraSpellId), _hitTargetSpellId(hitTargetSpellId), _newTargetSelectTimer(0) { } + _auraSpellId(auraSpellId), _hitTargetSpellId(hitTargetSpellId), _newTargetSelectTimer(0), _instance(creature->GetInstanceScript()){ } void SpellHitTarget(Unit* /*target*/, SpellInfo const* spell) override { @@ -740,6 +740,10 @@ class npc_putricide_oozeAI : public ScriptedAI void Reset() override { + if (_instance->GetBossState(DATA_PROFESSOR_PUTRICIDE) != IN_PROGRESS) + me->DespawnOrUnsummon(); + + me->SetInCombatWithZone(); DoCastAOE(_auraSpellId, true); } @@ -780,6 +784,7 @@ class npc_putricide_oozeAI : public ScriptedAI uint32 _auraSpellId; uint32 _hitTargetSpellId; uint32 _newTargetSelectTimer; + InstanceScript* _instance; }; class npc_volatile_ooze : public CreatureScript -- cgit v1.2.3 From 410585361a44c94ccc08a0d40ea2dc4fd45dc644 Mon Sep 17 00:00:00 2001 From: Keader Date: Sat, 1 Apr 2017 21:18:15 -0300 Subject: Core/Scripts: Typo in last commit (cherry picked from commit a2a8ffe72328590b43481b430b9a6f281ccdd4be) --- .../scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index a1277ae754a..116843c2398 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -730,7 +730,7 @@ class npc_putricide_oozeAI : public ScriptedAI { public: npc_putricide_oozeAI(Creature* creature, uint32 auraSpellId, uint32 hitTargetSpellId) : ScriptedAI(creature), - _auraSpellId(auraSpellId), _hitTargetSpellId(hitTargetSpellId), _newTargetSelectTimer(0), _instance(creature->GetInstanceScript()){ } + _auraSpellId(auraSpellId), _hitTargetSpellId(hitTargetSpellId), _newTargetSelectTimer(0), _instance(creature->GetInstanceScript()) { } void SpellHitTarget(Unit* /*target*/, SpellInfo const* spell) override { -- cgit v1.2.3 From 287ed04c8b89c7a265452576f288ec83e4fa7e7c Mon Sep 17 00:00:00 2001 From: Keader Date: Sun, 2 Apr 2017 11:08:29 -0300 Subject: Core/Scripts: Fixed Baltharus the Warborn clones *Clones not working after wipe *Changed Clone Action for a event (to check casting) (cherry picked from commit 6b8c4fb74feb2210d2fb9ea60ec23ab407ffeb39) --- .../RubySanctum/boss_baltharus_the_warborn.cpp | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp index e39a01547f1..2c48fee879e 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp @@ -51,7 +51,8 @@ enum Events EVENT_CLEAVE, EVENT_ENERVATING_BRAND, EVENT_INTRO_TALK, - EVENT_SUMMONS_ATTACK + EVENT_SUMMONS_ATTACK, + EVENT_CLONE }; enum Actions @@ -73,10 +74,8 @@ class boss_baltharus_the_warborn : public CreatureScript struct boss_baltharus_the_warbornAI : public BossAI { - boss_baltharus_the_warbornAI(Creature* creature) : BossAI(creature, DATA_BALTHARUS_THE_WARBORN), _introDone(false) - { - _cloneCount = RAID_MODE(1, 2, 2, 2); - } + boss_baltharus_the_warbornAI(Creature* creature) : BossAI(creature, DATA_BALTHARUS_THE_WARBORN), + _introDone(false), _cloneCount(RAID_MODE(1, 2, 2, 2)) { } void Reset() override { @@ -85,6 +84,7 @@ class boss_baltharus_the_warborn : public CreatureScript instance->SetData(DATA_BALTHARUS_SHARED_HEALTH, me->GetMaxHealth()); if (Creature* channelTarget = instance->GetCreature(DATA_CRYSTAL_CHANNEL_TARGET)) DoCast(channelTarget, SPELL_BARRIER_CHANNEL); + _cloneCount = RAID_MODE(1, 2, 2, 2); } void DoAction(int32 action) override @@ -100,8 +100,8 @@ class boss_baltharus_the_warborn : public CreatureScript break; case ACTION_CLONE: { - DoCastSelf(SPELL_CLEAR_DEBUFFS); - DoCastSelf(SPELL_CLONE); + DoCastSelf(SPELL_CLEAR_DEBUFFS, true); + DoCastSelf(SPELL_CLONE, true); DoCastSelf(SPELL_REPELLING_WAVE); Talk(SAY_CLONE); --_cloneCount; @@ -150,14 +150,14 @@ class boss_baltharus_the_warborn : public CreatureScript if (GetDifficulty() == DIFFICULTY_10_N) { if (me->HealthBelowPctDamaged(50, damage) && _cloneCount == 1) - DoAction(ACTION_CLONE); + events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); } else { if (me->HealthBelowPctDamaged(66, damage) && _cloneCount == 2) - DoAction(ACTION_CLONE); + events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); else if (me->HealthBelowPctDamaged(33, damage) && _cloneCount == 1) - DoAction(ACTION_CLONE); + events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); } if (me->GetHealth() > damage) @@ -173,19 +173,18 @@ class boss_baltharus_the_warborn : public CreatureScript void UpdateAI(uint32 diff) override { - bool introPhase = events.IsInPhase(PHASE_INTRO); - if (!introPhase && !UpdateVictim()) + if (!events.IsInPhase(PHASE_INTRO) && !UpdateVictim()) return; - if (!introPhase) + if (!events.IsInPhase(PHASE_INTRO)) me->SetHealth(instance->GetData(DATA_BALTHARUS_SHARED_HEALTH)); - events.Update(diff); - - if (!introPhase && me->HasUnitState(UNIT_STATE_CASTING)) + if (!events.IsInPhase(PHASE_INTRO) && me->HasUnitState(UNIT_STATE_CASTING)) return; + events.Update(diff); + while (uint32 eventId = events.ExecuteEvent()) { switch (eventId) @@ -210,6 +209,9 @@ class boss_baltharus_the_warborn : public CreatureScript case EVENT_SUMMONS_ATTACK: summons.DoZoneInCombat(NPC_BALTHARUS_THE_WARBORN_CLONE); break; + case EVENT_CLONE: + DoAction(ACTION_CLONE); + break; default: break; } -- cgit v1.2.3 From 14cf4c06921be90a7f5b9bba6ed110a2b8a7633c Mon Sep 17 00:00:00 2001 From: Keader Date: Sun, 2 Apr 2017 11:14:24 -0300 Subject: Core/Scripts: Fixing Carbonion/Travis (cherry picked from commit 270a6396783ccb2b8dff181fca2760adb47d2110) --- .../ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp index 2c48fee879e..c0aa45f1e21 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp @@ -75,7 +75,7 @@ class boss_baltharus_the_warborn : public CreatureScript struct boss_baltharus_the_warbornAI : public BossAI { boss_baltharus_the_warbornAI(Creature* creature) : BossAI(creature, DATA_BALTHARUS_THE_WARBORN), - _introDone(false), _cloneCount(RAID_MODE(1, 2, 2, 2)) { } + _cloneCount(RAID_MODE(1, 2, 2, 2)), _introDone(false) { } void Reset() override { -- cgit v1.2.3 From d6e293c7182dcdc317168d3769ef42d003b479a5 Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 3 Apr 2017 03:28:31 -0300 Subject: Core/AHBot: Refactor of AuctionHouseBotSeller: - Use AuctionHouseBot.Class.* for what they really are, priorities, factor them when calculating item amount per class, changed enums to CONFIG_AHBOT_CLASS_*_PRIORITY to reflect this change - Don't factor in the priority calc empty item lists: * Let's say you had AuctionHouseBot.Class.Glyph set to 10, sum of AuctionHouseBot.Class.* is 20, and AuctionHouseBot.Items.Amount.White is 5000 * If there were no glyphs on the item list, you automatically lost 50% of the total item amount, meaning only 2500 of original 5000 were alloted to fill - Fixed AuctionHouseBot.AH.Price.Ratio to be an actual percentage factor - Separated containers in SellerConfiguration, each one better reflects what kind of data is stored there, now we won't use magic index 0 from _ItemInfo :P - General cleanup, removal of bad voodoo and magical numbers - Use unordered_sets for loading item lists, as they were only used to check for item presence (cherry picked from commit 7f8bfe68d0f660643c8bd4c63d2129d220c2184c) --- .../game/AuctionHouseBot/AuctionHouseBot.cpp | 43 ++-- src/server/game/AuctionHouseBot/AuctionHouseBot.h | 39 +-- .../game/AuctionHouseBot/AuctionHouseBotSeller.cpp | 281 ++++++++------------- .../game/AuctionHouseBot/AuctionHouseBotSeller.h | 76 +++--- 4 files changed, 187 insertions(+), 252 deletions(-) (limited to 'src') diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp index f4c8aa5c320..588e3b50d4a 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp @@ -179,21 +179,21 @@ void AuctionBotConfig::GetConfigFromFile() SetConfig(CONFIG_AHBOT_ITEM_ORANGE_AMOUNT, "AuctionHouseBot.Items.Amount.Orange", 0); SetConfig(CONFIG_AHBOT_ITEM_YELLOW_AMOUNT, "AuctionHouseBot.Items.Amount.Yellow", 0); - SetConfigMax(CONFIG_AHBOT_CLASS_CONSUMABLE_AMOUNT, "AuctionHouseBot.Class.Consumable", 6, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_CONTAINER_AMOUNT, "AuctionHouseBot.Class.Container", 4, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_WEAPON_AMOUNT, "AuctionHouseBot.Class.Weapon", 8, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_GEM_AMOUNT, "AuctionHouseBot.Class.Gem", 3, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_ARMOR_AMOUNT, "AuctionHouseBot.Class.Armor", 8, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_REAGENT_AMOUNT, "AuctionHouseBot.Class.Reagent", 1, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_PROJECTILE_AMOUNT, "AuctionHouseBot.Class.Projectile", 2, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_TRADEGOOD_AMOUNT, "AuctionHouseBot.Class.TradeGood", 10, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_GENERIC_AMOUNT, "AuctionHouseBot.Class.Generic", 1, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_RECIPE_AMOUNT, "AuctionHouseBot.Class.Recipe", 6, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_QUIVER_AMOUNT, "AuctionHouseBot.Class.Quiver", 1, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_QUEST_AMOUNT, "AuctionHouseBot.Class.Quest", 1, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_KEY_AMOUNT, "AuctionHouseBot.Class.Key", 1, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_MISC_AMOUNT, "AuctionHouseBot.Class.Misc", 5, 10); - SetConfigMax(CONFIG_AHBOT_CLASS_GLYPH_AMOUNT, "AuctionHouseBot.Class.Glyph", 3, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_CONSUMABLE_PRIORITY, "AuctionHouseBot.Class.Consumable", 6, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_CONTAINER_PRIORITY, "AuctionHouseBot.Class.Container", 4, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_WEAPON_PRIORITY, "AuctionHouseBot.Class.Weapon", 8, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_GEM_PRIORITY, "AuctionHouseBot.Class.Gem", 3, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_ARMOR_PRIORITY, "AuctionHouseBot.Class.Armor", 8, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_REAGENT_PRIORITY, "AuctionHouseBot.Class.Reagent", 1, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_PROJECTILE_PRIORITY, "AuctionHouseBot.Class.Projectile", 2, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_TRADEGOOD_PRIORITY, "AuctionHouseBot.Class.TradeGood", 10, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_GENERIC_PRIORITY, "AuctionHouseBot.Class.Generic", 1, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_RECIPE_PRIORITY, "AuctionHouseBot.Class.Recipe", 6, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_QUIVER_PRIORITY, "AuctionHouseBot.Class.Quiver", 1, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_QUEST_PRIORITY, "AuctionHouseBot.Class.Quest", 1, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_KEY_PRIORITY, "AuctionHouseBot.Class.Key", 1, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_MISC_PRIORITY, "AuctionHouseBot.Class.Misc", 5, 10); + SetConfigMax(CONFIG_AHBOT_CLASS_GLYPH_PRIORITY, "AuctionHouseBot.Class.Glyph", 3, 10); SetConfig(CONFIG_AHBOT_ALLIANCE_PRICE_RATIO, "AuctionHouseBot.Alliance.Price.Ratio", 100); SetConfig(CONFIG_AHBOT_HORDE_PRICE_RATIO, "AuctionHouseBot.Horde.Price.Ratio", 100); @@ -351,6 +351,19 @@ uint32 AuctionBotConfig::GetConfigItemAmountRatio(AuctionHouseType houseType) co } } +uint32 AuctionBotConfig::GetConfigPriceRatio(AuctionHouseType houseType) const +{ + switch (houseType) + { + case AUCTION_HOUSE_ALLIANCE: + return GetConfig(CONFIG_AHBOT_ALLIANCE_PRICE_RATIO); + case AUCTIONHOUSE_HORDE: + return GetConfig(CONFIG_AHBOT_HORDE_PRICE_RATIO); + default: + return GetConfig(CONFIG_AHBOT_NEUTRAL_PRICE_RATIO); + } +} + bool AuctionBotConfig::GetConfigBuyerEnabled(AuctionHouseType houseType) const { switch (houseType) diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBot.h b/src/server/game/AuctionHouseBot/AuctionHouseBot.h index 75145c498e6..3bf9caef9f8 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBot.h +++ b/src/server/game/AuctionHouseBot/AuctionHouseBot.h @@ -71,21 +71,21 @@ enum AuctionBotConfigUInt32Values CONFIG_AHBOT_ITEM_PURPLE_AMOUNT, CONFIG_AHBOT_ITEM_ORANGE_AMOUNT, CONFIG_AHBOT_ITEM_YELLOW_AMOUNT, - CONFIG_AHBOT_CLASS_CONSUMABLE_AMOUNT, - CONFIG_AHBOT_CLASS_CONTAINER_AMOUNT, - CONFIG_AHBOT_CLASS_WEAPON_AMOUNT, - CONFIG_AHBOT_CLASS_GEM_AMOUNT, - CONFIG_AHBOT_CLASS_ARMOR_AMOUNT, - CONFIG_AHBOT_CLASS_REAGENT_AMOUNT, - CONFIG_AHBOT_CLASS_PROJECTILE_AMOUNT, - CONFIG_AHBOT_CLASS_TRADEGOOD_AMOUNT, - CONFIG_AHBOT_CLASS_GENERIC_AMOUNT, - CONFIG_AHBOT_CLASS_RECIPE_AMOUNT, - CONFIG_AHBOT_CLASS_QUIVER_AMOUNT, - CONFIG_AHBOT_CLASS_QUEST_AMOUNT, - CONFIG_AHBOT_CLASS_KEY_AMOUNT, - CONFIG_AHBOT_CLASS_MISC_AMOUNT, - CONFIG_AHBOT_CLASS_GLYPH_AMOUNT, + CONFIG_AHBOT_CLASS_CONSUMABLE_PRIORITY, + CONFIG_AHBOT_CLASS_CONTAINER_PRIORITY, + CONFIG_AHBOT_CLASS_WEAPON_PRIORITY, + CONFIG_AHBOT_CLASS_GEM_PRIORITY, + CONFIG_AHBOT_CLASS_ARMOR_PRIORITY, + CONFIG_AHBOT_CLASS_REAGENT_PRIORITY, + CONFIG_AHBOT_CLASS_PROJECTILE_PRIORITY, + CONFIG_AHBOT_CLASS_TRADEGOOD_PRIORITY, + CONFIG_AHBOT_CLASS_GENERIC_PRIORITY, + CONFIG_AHBOT_CLASS_RECIPE_PRIORITY, + CONFIG_AHBOT_CLASS_QUIVER_PRIORITY, + CONFIG_AHBOT_CLASS_QUEST_PRIORITY, + CONFIG_AHBOT_CLASS_KEY_PRIORITY, + CONFIG_AHBOT_CLASS_MISC_PRIORITY, + CONFIG_AHBOT_CLASS_GLYPH_PRIORITY, CONFIG_AHBOT_ALLIANCE_PRICE_RATIO, CONFIG_AHBOT_HORDE_PRICE_RATIO, CONFIG_AHBOT_NEUTRAL_PRICE_RATIO, @@ -205,8 +205,8 @@ enum AuctionBotConfigFloatValues class TC_GAME_API AuctionBotConfig { private: - AuctionBotConfig(): _itemsPerCycleBoost(1000), _itemsPerCycleNormal(20) { } - ~AuctionBotConfig() { } + AuctionBotConfig(): _itemsPerCycleBoost(1000), _itemsPerCycleNormal(20) {} + ~AuctionBotConfig() {} AuctionBotConfig(AuctionBotConfig const&) = delete; AuctionBotConfig& operator=(AuctionBotConfig const&) = delete; @@ -225,6 +225,7 @@ public: void SetConfig(AuctionBotConfigFloatValues index, float value) { _configFloatValues[index] = value; } uint32 GetConfigItemAmountRatio(AuctionHouseType houseType) const; + uint32 GetConfigPriceRatio(AuctionHouseType houseType) const; bool GetConfigBuyerEnabled(AuctionHouseType houseType) const; uint32 GetConfigItemQualityAmount(AuctionQuality quality) const; @@ -286,8 +287,8 @@ class TC_GAME_API AuctionHouseBot private: AuctionHouseBot(); ~AuctionHouseBot(); - AuctionHouseBot(const AuctionHouseBot&); - AuctionHouseBot& operator=(const AuctionHouseBot&); + AuctionHouseBot(AuctionHouseBot const&) = delete; + AuctionHouseBot& operator=(AuctionHouseBot const&) = delete; public: static AuctionHouseBot* instance(); diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp index 44ee9fcc2a4..9d7252dea93 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp @@ -22,6 +22,7 @@ #include "GameTime.h" #include "Item.h" #include "Log.h" +#include "Containers.h" #include "ObjectMgr.h" #include "Random.h" #include @@ -29,7 +30,7 @@ AuctionBotSeller::AuctionBotSeller() { // Define faction for our main data class. - for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i) + for (uint8 i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i) _houseConfig[i].Initialize(AuctionHouseType(i)); } @@ -117,11 +118,11 @@ bool AuctionBotSeller::Initialize() continue; // forced exclude filter - if (excludeItems.find(itemId) != excludeItems.end()) + if (excludeItems.count(itemId)) continue; // forced include filter - if (includeItems.find(itemId) != includeItems.end()) + if (includeItems.count(itemId)) { _itemPool[prototype->GetQuality()][prototype->GetClass()].push_back(itemId); ++itemsAdded; @@ -207,19 +208,20 @@ bool AuctionBotSeller::Initialize() // vendor filter if (!sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEMS_VENDOR)) - if (npcItems.find(itemId) != npcItems.end()) + if (npcItems.count(itemId)) continue; // loot filter if (!sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEMS_LOOT)) - if (lootItems.find(itemId) != lootItems.end()) + if (lootItems.count(itemId)) continue; // not vendor/loot filter if (!sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEMS_MISC)) { - bool isVendorItem = npcItems.find(itemId) != npcItems.end(); - bool isLootItem = lootItems.find(itemId) != lootItems.end(); + bool const isVendorItem = npcItems.count(itemId) > 0; + bool const isLootItem = lootItems.count(itemId) > 0; + if (!isLootItem && !isVendorItem) continue; } @@ -368,7 +370,7 @@ bool AuctionBotSeller::Initialize() void AuctionBotSeller::LoadConfig() { - for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i) + for (uint8 i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i) if (sAuctionBotConfig->GetConfigItemAmountRatio(AuctionHouseType(i))) LoadSellerValues(_houseConfig[i]); } @@ -377,129 +379,11 @@ void AuctionBotSeller::LoadItemsQuantity(SellerConfiguration& config) { uint32 ratio = sAuctionBotConfig->GetConfigItemAmountRatio(config.GetHouseType()); - config.SetItemsAmountPerQuality(AUCTION_QUALITY_GRAY, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_GRAY_AMOUNT) * ratio / 100); - config.SetItemsAmountPerQuality(AUCTION_QUALITY_WHITE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_WHITE_AMOUNT) * ratio / 100); - config.SetItemsAmountPerQuality(AUCTION_QUALITY_GREEN, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_GREEN_AMOUNT) * ratio / 100); - config.SetItemsAmountPerQuality(AUCTION_QUALITY_BLUE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_BLUE_AMOUNT) * ratio / 100); - config.SetItemsAmountPerQuality(AUCTION_QUALITY_PURPLE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_PURPLE_AMOUNT) * ratio / 100); - config.SetItemsAmountPerQuality(AUCTION_QUALITY_ORANGE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_ORANGE_AMOUNT) * ratio / 100); - config.SetItemsAmountPerQuality(AUCTION_QUALITY_YELLOW, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_YELLOW_AMOUNT) * ratio / 100); - - // Set quantity wanted but only on possible item color - // This avoid any no-exist class-color items selection by random items create function - // ============================================================================================ - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_CONSUMABLE, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_CONTAINER, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_WEAPON, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_WEAPON_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_GEM, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_ARMOR, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_ARMOR_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_REAGENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_PROJECTILE, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_TRADE_GOODS, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_TRADEGOOD_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_ITEM_ENHANCEMENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_RECIPE, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_QUIVER, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_QUEST, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUEST_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_KEY, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_MISCELLANEOUS, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_MISC_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GRAY, ITEM_CLASS_GLYPH, 0); - - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_CONSUMABLE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONSUMABLE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_CONTAINER, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONTAINER_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_WEAPON, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_WEAPON_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_GEM, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_GEM_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_ARMOR, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_ARMOR_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_REAGENT, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_REAGENT_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_PROJECTILE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_PROJECTILE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_TRADE_GOODS, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_TRADEGOOD_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_ITEM_ENHANCEMENT, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_GENERIC_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_RECIPE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_RECIPE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_QUIVER, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUIVER_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_QUEST, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUEST_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_KEY, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_KEY_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_MISCELLANEOUS, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_MISC_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_WHITE, ITEM_CLASS_GLYPH, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_GLYPH_AMOUNT)); - - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_CONSUMABLE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONSUMABLE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_CONTAINER, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONTAINER_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_WEAPON, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_WEAPON_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_GEM, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_GEM_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_ARMOR, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_ARMOR_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_REAGENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_PROJECTILE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_PROJECTILE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_TRADE_GOODS, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_TRADEGOOD_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_ITEM_ENHANCEMENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_RECIPE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_RECIPE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_QUIVER, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUIVER_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_QUEST, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUEST_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_KEY, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_KEY_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_MISCELLANEOUS, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_MISC_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_GREEN, ITEM_CLASS_GLYPH, 0); - - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_CONSUMABLE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONSUMABLE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_CONTAINER, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONTAINER_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_WEAPON, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_WEAPON_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_GEM, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_GEM_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_ARMOR, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_ARMOR_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_REAGENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_PROJECTILE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_PROJECTILE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_TRADE_GOODS, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_TRADEGOOD_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_ITEM_ENHANCEMENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_RECIPE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_RECIPE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_QUIVER, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUIVER_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_QUEST, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUEST_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_KEY, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_MISCELLANEOUS, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_MISC_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_BLUE, ITEM_CLASS_GLYPH, 0); - - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_CONSUMABLE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONSUMABLE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_CONTAINER, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONTAINER_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_WEAPON, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_WEAPON_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_GEM, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_GEM_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_ARMOR, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_ARMOR_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_REAGENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_PROJECTILE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_PROJECTILE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_TRADE_GOODS, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_TRADEGOOD_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_ITEM_ENHANCEMENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_RECIPE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_RECIPE_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_QUIVER, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_QUEST, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUEST_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_KEY, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_MISCELLANEOUS, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_MISC_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_PURPLE, ITEM_CLASS_GLYPH, 0); - - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_CONSUMABLE, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_CONTAINER, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_WEAPON, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_WEAPON_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_GEM, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_ARMOR, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_ARMOR_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_REAGENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_PROJECTILE, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_TRADE_GOODS, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_TRADEGOOD_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_ITEM_ENHANCEMENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_RECIPE, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_QUIVER, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_QUEST, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_KEY, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_MISCELLANEOUS, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_ORANGE, ITEM_CLASS_GLYPH, 0); - - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_CONSUMABLE, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_CONTAINER, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_WEAPON, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_WEAPON_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_GEM, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_ARMOR, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_ARMOR_AMOUNT)); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_REAGENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_PROJECTILE, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_TRADE_GOODS, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_ITEM_ENHANCEMENT, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_RECIPE, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_QUIVER, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_QUEST, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_KEY, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_MISCELLANEOUS, 0); - config.SetItemsQuantityPerClass(AUCTION_QUALITY_YELLOW, ITEM_CLASS_GLYPH, 0); - // ============================================================================================ + for (uint32 i = 0; i < MAX_AUCTION_QUALITY; ++i) + { + uint32 amount = sAuctionBotConfig->GetConfig(AuctionBotConfigUInt32Values(CONFIG_AHBOT_ITEM_GRAY_AMOUNT + i)); + config.SetItemsAmountPerQuality(AuctionQuality(i), std::lroundf(amount * ratio / 100.f)); + } // Set Stack Quantities config.SetRandomStackRatioPerClass(ITEM_CLASS_CONSUMABLE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_RANDOMSTACKRATIO_CONSUMABLE)); @@ -519,45 +403,95 @@ void AuctionBotSeller::LoadItemsQuantity(SellerConfiguration& config) config.SetRandomStackRatioPerClass(ITEM_CLASS_GLYPH, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_RANDOMSTACKRATIO_GLYPH)); // Set the best value to get nearest amount of items wanted + auto getPriorityForClass = [](uint32 itemClass) -> uint32 + { + AuctionBotConfigUInt32Values index; + switch (itemClass) + { + case ITEM_CLASS_CONSUMABLE: + index = CONFIG_AHBOT_CLASS_CONSUMABLE_PRIORITY; break; + case ITEM_CLASS_CONTAINER: + index = CONFIG_AHBOT_CLASS_CONTAINER_PRIORITY; break; + case ITEM_CLASS_WEAPON: + index = CONFIG_AHBOT_CLASS_WEAPON_PRIORITY; break; + case ITEM_CLASS_GEM: + index = CONFIG_AHBOT_CLASS_GEM_PRIORITY; break; + case ITEM_CLASS_ARMOR: + index = CONFIG_AHBOT_CLASS_ARMOR_PRIORITY; break; + case ITEM_CLASS_REAGENT: + index = CONFIG_AHBOT_CLASS_REAGENT_PRIORITY; break; + case ITEM_CLASS_PROJECTILE: + index = CONFIG_AHBOT_CLASS_PROJECTILE_PRIORITY; break; + case ITEM_CLASS_TRADE_GOODS: + index = CONFIG_AHBOT_CLASS_TRADEGOOD_PRIORITY; break; + case ITEM_CLASS_ITEM_ENHANCEMENT: + index = CONFIG_AHBOT_CLASS_GENERIC_PRIORITY; break; + case ITEM_CLASS_RECIPE: + index = CONFIG_AHBOT_CLASS_RECIPE_PRIORITY; break; + case ITEM_CLASS_QUIVER: + index = CONFIG_AHBOT_CLASS_QUIVER_PRIORITY; break; + case ITEM_CLASS_QUEST: + index = CONFIG_AHBOT_CLASS_QUEST_PRIORITY; break; + case ITEM_CLASS_KEY: + index = CONFIG_AHBOT_CLASS_KEY_PRIORITY; break; + case ITEM_CLASS_MISCELLANEOUS: + index = CONFIG_AHBOT_CLASS_MISC_PRIORITY; break; + case ITEM_CLASS_GLYPH: + index = CONFIG_AHBOT_CLASS_GLYPH_PRIORITY; break; + default: + return 0; + } + + return sAuctionBotConfig->GetConfig(index); + }; + + std::vector totalPrioPerQuality(MAX_AUCTION_QUALITY); + for (uint32 j = 0; j < MAX_AUCTION_QUALITY; ++j) + { + for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i) + { + // skip empty pools + if (_itemPool[j][i].empty()) + continue; + + totalPrioPerQuality[j] += getPriorityForClass(i); + } + } + for (uint32 j = 0; j < MAX_AUCTION_QUALITY; ++j) { - uint32 index = config.GetItemsAmountPerQuality(AuctionQuality(j)) / - (sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONSUMABLE_AMOUNT) + sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONTAINER_AMOUNT) + sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_WEAPON_AMOUNT) + - sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_GEM_AMOUNT) + sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_ARMOR_AMOUNT) + sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_REAGENT_AMOUNT) + - sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_PROJECTILE_AMOUNT) + sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_TRADEGOOD_AMOUNT) + sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_GENERIC_AMOUNT) + - sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_RECIPE_AMOUNT) + sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUIVER_AMOUNT) + sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUEST_AMOUNT) + - sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_KEY_AMOUNT) + sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_MISC_AMOUNT) + sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_GLYPH_AMOUNT)); + uint32 qualityAmount = config.GetItemsAmountPerQuality(AuctionQuality(j)); + if (!totalPrioPerQuality[j]) + continue; for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i) - config.SetItemsAmountPerClass(AuctionQuality(j), ItemClass(i), index); + { + uint32 classPrio = getPriorityForClass(i); + if (_itemPool[j][i].empty()) + classPrio = 0; + + uint32 weightedAmount = std::lroundf(classPrio / float(totalPrioPerQuality[j]) * qualityAmount); + config.SetItemsAmountPerClass(AuctionQuality(j), ItemClass(i), weightedAmount); + } } + + // do some assert checking, GetItemAmount must always return 0 iif selected _itemPool is empty + for (uint32 j = 0; j < MAX_AUCTION_QUALITY; ++j) + for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i) + ASSERT(_itemPool[j][i].empty() == (config.GetItemsAmountPerClass(AuctionQuality(j), ItemClass(i)) == 0)); } void AuctionBotSeller::LoadSellerValues(SellerConfiguration& config) { LoadItemsQuantity(config); - uint32 PriceRatio; - switch (config.GetHouseType()) + uint32 ratio = sAuctionBotConfig->GetConfigPriceRatio(config.GetHouseType()); + + for (uint32 i = 0; i < MAX_AUCTION_QUALITY; ++i) { - case AUCTION_HOUSE_ALLIANCE: - PriceRatio = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ALLIANCE_PRICE_RATIO); - break; - case AUCTION_HOUSE_HORDE: - PriceRatio = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_HORDE_PRICE_RATIO); - break; - default: - PriceRatio = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_NEUTRAL_PRICE_RATIO); - break; + uint32 amount = sAuctionBotConfig->GetConfig(AuctionBotConfigUInt32Values(CONFIG_AHBOT_ITEM_GRAY_PRICE_RATIO + i)); + config.SetPriceRatioPerQuality(AuctionQuality(i), std::lroundf(amount * ratio / 100.f)); } - config.SetPriceRatioPerQuality(AUCTION_QUALITY_GRAY, PriceRatio * sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_GRAY_PRICE_RATIO)); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_WHITE, PriceRatio * sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_WHITE_PRICE_RATIO)); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_GREEN, PriceRatio * sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_GREEN_PRICE_RATIO)); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_BLUE, PriceRatio * sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_BLUE_PRICE_RATIO)); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_PURPLE, PriceRatio * sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_PURPLE_PRICE_RATIO)); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_ORANGE, PriceRatio * sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_ORANGE_PRICE_RATIO)); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_YELLOW, PriceRatio * sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEM_YELLOW_PRICE_RATIO)); - config.SetPriceRatioPerClass(ITEM_CLASS_CONSUMABLE, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONSUMABLE_PRICE_RATIO)); config.SetPriceRatioPerClass(ITEM_CLASS_CONTAINER, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONTAINER_PRICE_RATIO)); config.SetPriceRatioPerClass(ITEM_CLASS_WEAPON, sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_WEAPON_PRICE_RATIO)); @@ -579,18 +513,6 @@ void AuctionBotSeller::LoadSellerValues(SellerConfiguration& config) //load min and max auction times config.SetMinTime(sAuctionBotConfig->GetConfig(CONFIG_AHBOT_MINTIME)); config.SetMaxTime(sAuctionBotConfig->GetConfig(CONFIG_AHBOT_MAXTIME)); - - TC_LOG_DEBUG("ahbot", "AHBot: minTime = %u", config.GetMinTime()); - TC_LOG_DEBUG("ahbot", "AHBot: maxTime = %u", config.GetMaxTime()); - - TC_LOG_DEBUG("ahbot", "AHBot: For AH type %u", config.GetHouseType()); - TC_LOG_DEBUG("ahbot", "AHBot: GrayItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_GRAY)); - TC_LOG_DEBUG("ahbot", "AHBot: WhiteItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_WHITE)); - TC_LOG_DEBUG("ahbot", "AHBot: GreenItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_GREEN)); - TC_LOG_DEBUG("ahbot", "AHBot: BlueItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_BLUE)); - TC_LOG_DEBUG("ahbot", "AHBot: PurpleItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_PURPLE)); - TC_LOG_DEBUG("ahbot", "AHBot: OrangeItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_ORANGE)); - TC_LOG_DEBUG("ahbot", "AHBot: YellowItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_YELLOW)); } // Set static of items on one AH faction. @@ -644,12 +566,13 @@ bool AuctionBotSeller::GetItemsToSell(SellerConfiguration& config, ItemsToSellAr { for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i) { - if (config.GetMissedItemsPerClass(AuctionQuality(j), ItemClass(i)) > addedItem[j][i] && !_itemPool[j][i].empty()) + // if _itemPool for chosen is empty, MissedItemsPerClass will return 0 here (checked at startup) + if (config.GetMissedItemsPerClass(AuctionQuality(j), ItemClass(i)) > addedItem[j][i]) { ItemToSell miss_item; miss_item.Color = j; miss_item.Itemclass = i; - itemsToSellArray.push_back(miss_item); + itemsToSellArray.emplace_back(std::move(miss_item)); found = true; } } @@ -908,11 +831,11 @@ void AuctionBotSeller::AddNewAuctions(SellerConfiguration& config) --items; // Select random position from missed items table - uint32 pos = urand(0, itemsToSell.size() - 1); + ItemToSell const& sellItem = Trinity::Containers::SelectRandomContainerElement(itemsToSell); // Set itemId with random item ID for selected categories and color, from _itemPool table - uint32 itemId = _itemPool[itemsToSell[pos].Color][itemsToSell[pos].Itemclass][urand(0, _itemPool[itemsToSell[pos].Color][itemsToSell[pos].Itemclass].size() - 1)]; - ++allItems[itemsToSell[pos].Color][itemsToSell[pos].Itemclass]; // Helper table to avoid rescan from DB in this loop. (has we add item in random orders) + uint32 itemId = Trinity::Containers::SelectRandomContainerElement(_itemPool[sellItem.Color][sellItem.Itemclass]); + ++allItems[sellItem.Color][sellItem.Itemclass]; // Helper table to avoid rescan from DB in this loop. (has we add item in random orders) if (!itemId) { @@ -951,16 +874,14 @@ void AuctionBotSeller::AddNewAuctions(SellerConfiguration& config) switch (etime) { case 1: - etime = 43200; - break; - case 2: - etime = 86400; + etime = DAY / 2; break; case 3: - etime = 172800; + etime = 2 *DAY; break; + case 2: default: - etime = 86400; + etime = DAY; break; } diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.h b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.h index ea82dd991f4..29288c6fb3b 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.h +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.h @@ -32,36 +32,28 @@ struct ItemToSell typedef std::vector ItemsToSellArray; typedef std::array, MAX_ITEM_QUALITY> AllItemsArray; -struct SellerItemClassInfo +struct SellerItemInfo { - SellerItemClassInfo(): AmountOfItems(0), MissItems(0), Quantity(0), PriceRatio(0), RandomStackRatio(100) {} - - uint32 AmountOfItems; - uint32 MissItems; - uint32 Quantity; - uint32 PriceRatio; - uint32 RandomStackRatio; + uint32 AmountOfItems = 0; + uint32 MissItems = 0; }; -struct SellerItemInfo +struct SellerItemClassSharedInfo { - SellerItemInfo(): AmountOfItems(0), MissItems(0), PriceRatio(0) {} - - uint32 AmountOfItems; - uint32 MissItems; - uint32 PriceRatio; + uint32 PriceRatio = 0; + uint32 RandomStackRatio = 100; +}; - SellerItemClassInfo ItemClassInfos[MAX_ITEM_CLASS]; +struct SellerItemQualitySharedInfo +{ + uint32 AmountOfItems = 0; + uint32 PriceRatio = 0; }; class SellerConfiguration { public: - SellerConfiguration(): LastMissedItem(0), _houseType(AUCTION_HOUSE_NEUTRAL), _minTime(1), _maxTime(72) - { - } - - ~SellerConfiguration() {} + SellerConfiguration() : LastMissedItem(0), _houseType(AUCTION_HOUSE_NEUTRAL), _minTime(1), _maxTime(72), _itemInfo(), _itemSharedQualityInfo(), _itemSharedClassInfo() { } void Initialize(AuctionHouseType houseType) { @@ -83,35 +75,43 @@ public: void SetMaxTime(uint32 value) { _maxTime = value; } uint32 GetMaxTime() const { return _maxTime; } + // Data access classified by item class and item quality - void SetItemsAmountPerClass(AuctionQuality quality, ItemClass itemclass, uint32 amount) { _ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems = amount * _ItemInfo[quality].ItemClassInfos[itemclass].Quantity; } - uint32 GetItemsAmountPerClass(AuctionQuality quality, ItemClass itemclass) const { return _ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems; } - void SetItemsQuantityPerClass(AuctionQuality quality, ItemClass itemclass, uint32 qty) { _ItemInfo[quality].ItemClassInfos[itemclass].Quantity = qty; } - uint32 GetItemsQuantityPerClass(AuctionQuality quality, ItemClass itemclass) const { return _ItemInfo[quality].ItemClassInfos[itemclass].Quantity; } - void SetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass, uint32 found) + void SetItemsAmountPerClass(AuctionQuality quality, ItemClass itemClass, uint32 amount) { _itemInfo[quality][itemClass].AmountOfItems = amount; } + uint32 GetItemsAmountPerClass(AuctionQuality quality, ItemClass itemClass) const { return _itemInfo[quality][itemClass].AmountOfItems; } + + void SetMissedItemsPerClass(AuctionQuality quality, ItemClass itemClass, uint32 found) { - if (_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems > found) - _ItemInfo[quality].ItemClassInfos[itemclass].MissItems = _ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems - found; + if (_itemInfo[quality][itemClass].AmountOfItems > found) + _itemInfo[quality][itemClass].MissItems = _itemInfo[quality][itemClass].AmountOfItems - found; else - _ItemInfo[quality].ItemClassInfos[itemclass].MissItems = 0; + _itemInfo[quality][itemClass].MissItems = 0; } - uint32 GetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass) const { return _ItemInfo[quality].ItemClassInfos[itemclass].MissItems; } + uint32 GetMissedItemsPerClass(AuctionQuality quality, ItemClass itemClass) const { return _itemInfo[quality][itemClass].MissItems; } // Data for every quality of item - void SetItemsAmountPerQuality(AuctionQuality quality, uint32 cnt) { _ItemInfo[quality].AmountOfItems = cnt; } - uint32 GetItemsAmountPerQuality(AuctionQuality quality) const { return _ItemInfo[quality].AmountOfItems; } - void SetPriceRatioPerQuality(AuctionQuality quality, uint32 value) { _ItemInfo[quality].PriceRatio = value; } - uint32 GetPriceRatioPerQuality(AuctionQuality quality) const { return _ItemInfo[quality].PriceRatio; } - void SetPriceRatioPerClass(ItemClass item, uint32 value) { _ItemInfo[0].ItemClassInfos[item].PriceRatio = value; } - uint32 GetPriceRatioPerClass(ItemClass item) const { return _ItemInfo[0].ItemClassInfos[item].PriceRatio; } - void SetRandomStackRatioPerClass(ItemClass item, uint32 value) { _ItemInfo[0].ItemClassInfos[item].RandomStackRatio = value; } - uint32 GetRandomStackRatioPerClass(ItemClass item) const { return _ItemInfo[0].ItemClassInfos[item].RandomStackRatio; } + void SetItemsAmountPerQuality(AuctionQuality quality, uint32 cnt) { _itemSharedQualityInfo[quality].AmountOfItems = cnt; } + uint32 GetItemsAmountPerQuality(AuctionQuality quality) const { return _itemSharedQualityInfo[quality].AmountOfItems; } + + void SetPriceRatioPerQuality(AuctionQuality quality, uint32 value) { _itemSharedQualityInfo[quality].PriceRatio = value; } + uint32 GetPriceRatioPerQuality(AuctionQuality quality) const { return _itemSharedQualityInfo[quality].PriceRatio; } + + // data for every class of item + void SetPriceRatioPerClass(ItemClass itemClass, uint32 value) { _itemSharedClassInfo[itemClass].PriceRatio = value; } + uint32 GetPriceRatioPerClass(ItemClass itemClass) const { return _itemSharedClassInfo[itemClass].PriceRatio; } + + void SetRandomStackRatioPerClass(ItemClass itemClass, uint32 value) { _itemSharedClassInfo[itemClass].RandomStackRatio = value; } + uint32 GetRandomStackRatioPerClass(ItemClass itemClass) const { return _itemSharedClassInfo[itemClass].RandomStackRatio; } private: AuctionHouseType _houseType; uint32 _minTime; uint32 _maxTime; - SellerItemInfo _ItemInfo[MAX_AUCTION_QUALITY]; + + SellerItemInfo _itemInfo[MAX_AUCTION_QUALITY][MAX_ITEM_CLASS]; + + SellerItemQualitySharedInfo _itemSharedQualityInfo[MAX_ITEM_QUALITY]; + SellerItemClassSharedInfo _itemSharedClassInfo[MAX_ITEM_CLASS]; }; // This class handle all Selling method -- cgit v1.2.3 From 8be8b7cff452a966a9d6fef42cdd2054f6eab82b Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 3 Apr 2017 03:53:50 -0300 Subject: Core/AHBot: fix a typo (cherry picked from commit e594c2d096c101a5b722793612febb6276b3b48e) --- src/server/game/AuctionHouseBot/AuctionHouseBot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp index 588e3b50d4a..b93a979033c 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp @@ -357,7 +357,7 @@ uint32 AuctionBotConfig::GetConfigPriceRatio(AuctionHouseType houseType) const { case AUCTION_HOUSE_ALLIANCE: return GetConfig(CONFIG_AHBOT_ALLIANCE_PRICE_RATIO); - case AUCTIONHOUSE_HORDE: + case AUCTION_HOUSE_HORDE: return GetConfig(CONFIG_AHBOT_HORDE_PRICE_RATIO); default: return GetConfig(CONFIG_AHBOT_NEUTRAL_PRICE_RATIO); -- cgit v1.2.3 From d80350da6886bea546c01b2d3e15c9bad39606fd Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 3 Apr 2017 04:04:02 -0300 Subject: Core/Spell: don't set scaleAura for some special spells Closes #14541 (cherry picked from commit 1ca8434b365687dbd12ca232a615d126234eba5e) --- src/server/game/Spells/SpellInfo.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 3b27c060639..98604c278d4 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -4329,6 +4329,10 @@ bool SpellInfo::_IsPositiveEffect(uint32 effIndex, bool deep) const if (HasAttribute(SPELL_ATTR0_NEGATIVE_1)) return false; + // these spells must not be downscaled, thus marking them negative (see GetAuraRankForLevel) + if (HasAttribute(SPELL_ATTR2_UNK3)) + return false; + switch (SpellFamilyName) { case SPELLFAMILY_GENERIC: -- cgit v1.2.3 From 847990f030753e5545c75672968c7e99d758d6dc Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 3 Apr 2017 04:46:39 -0300 Subject: Core/AHBot: fixed assert check (cherry picked from commit c36854677c4cef0c83a81afa23b45ba322d354cc) --- src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp index 9d7252dea93..ea400b30989 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp @@ -475,10 +475,15 @@ void AuctionBotSeller::LoadItemsQuantity(SellerConfiguration& config) } } - // do some assert checking, GetItemAmount must always return 0 iif selected _itemPool is empty + // do some assert checking, GetItemAmount must always return 0 if selected _itemPool is empty for (uint32 j = 0; j < MAX_AUCTION_QUALITY; ++j) + { for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i) - ASSERT(_itemPool[j][i].empty() == (config.GetItemsAmountPerClass(AuctionQuality(j), ItemClass(i)) == 0)); + { + if (_itemPool[j][i].empty()) + ASSERT(config.GetItemsAmountPerClass(AuctionQuality(j), ItemClass(i)) == 0); + } + } } void AuctionBotSeller::LoadSellerValues(SellerConfiguration& config) -- cgit v1.2.3 From f97c28f2f1deadd75a35631bb7ed878c6a1bec3f Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 3 Apr 2017 05:42:12 -0300 Subject: Core/AHBot: fix price calc - priceRatio is already a factor (cherry picked from commit 4a654be2fbb1857f31180f8d4edca91f7825c34a) --- src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp index ea400b30989..da14231ec3c 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp @@ -616,7 +616,9 @@ void AuctionBotSeller::SetPricesOfItem(ItemTemplate const* itemProto, SellerConf if (sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYPRICE_SELLER)) buyPrice = sellPrice; - float basePriceFloat = (buyPrice * stackCount * priceRatio) / (itemProto->GetClass() == 6 ? 200.0f : static_cast(itemProto->GetBuyCount())) / 100.0f; + float basePriceFloat = buyPrice * stackCount / (itemProto->GetClass() == 6 ? 200.0f : static_cast(itemProto->GetBuyCount())); + basePriceFloat *= priceRatio; + float range = basePriceFloat * 0.04f; buyout = (static_cast(frand(basePriceFloat - range, basePriceFloat + range) + 0.5f) / SILVER) * SILVER; -- cgit v1.2.3 From f623fea9237d1a076f55aa49128201a59cb0045b Mon Sep 17 00:00:00 2001 From: Keader Date: Mon, 3 Apr 2017 10:02:13 -0300 Subject: Core/Scripts: Baltharus the Warborn make clone count more readable *Also fixed issue that make Baltharus summons alot of clones when he is casting (cherry picked from commit 58f2e62098f2c78b77b6b3851709c83f33e1cafd) --- .../RubySanctum/boss_baltharus_the_warborn.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp index c0aa45f1e21..445404ce961 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp @@ -75,7 +75,7 @@ class boss_baltharus_the_warborn : public CreatureScript struct boss_baltharus_the_warbornAI : public BossAI { boss_baltharus_the_warbornAI(Creature* creature) : BossAI(creature, DATA_BALTHARUS_THE_WARBORN), - _cloneCount(RAID_MODE(1, 2, 2, 2)), _introDone(false) { } + _cloneCount(0), _introDone(false) { } void Reset() override { @@ -84,7 +84,7 @@ class boss_baltharus_the_warborn : public CreatureScript instance->SetData(DATA_BALTHARUS_SHARED_HEALTH, me->GetMaxHealth()); if (Creature* channelTarget = instance->GetCreature(DATA_CRYSTAL_CHANNEL_TARGET)) DoCast(channelTarget, SPELL_BARRIER_CHANNEL); - _cloneCount = RAID_MODE(1, 2, 2, 2); + _cloneCount = 0; } void DoAction(int32 action) override @@ -104,7 +104,6 @@ class boss_baltharus_the_warborn : public CreatureScript DoCastSelf(SPELL_CLONE, true); DoCastSelf(SPELL_REPELLING_WAVE); Talk(SAY_CLONE); - --_cloneCount; break; } default: @@ -149,15 +148,24 @@ class boss_baltharus_the_warborn : public CreatureScript { if (GetDifficulty() == DIFFICULTY_10_N) { - if (me->HealthBelowPctDamaged(50, damage) && _cloneCount == 1) + if (me->HealthBelowPctDamaged(50, damage) && _cloneCount == 0) + { + _cloneCount++; events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); + } } else { - if (me->HealthBelowPctDamaged(66, damage) && _cloneCount == 2) + if (me->HealthBelowPctDamaged(66, damage) && _cloneCount == 0) + { + _cloneCount++; events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); + } else if (me->HealthBelowPctDamaged(33, damage) && _cloneCount == 1) + { + _cloneCount++; events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); + } } if (me->GetHealth() > damage) -- cgit v1.2.3 From af3934e8ce181241db04b397299f36626bf0ed68 Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 3 Apr 2017 22:44:14 -0300 Subject: Core/Auction: wrap item deletions from AHBot auction on a transaction This speeds up the query execution time tremendously Refs #19182 (cherry picked from commit ae9995f463ec9797eaa4a803bdca4fbf5978a9b7) --- src/server/game/AuctionHouse/AuctionHouseMgr.cpp | 10 +++++----- src/server/game/AuctionHouse/AuctionHouseMgr.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 421c701089c..a7a06b3c32f 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -653,7 +653,7 @@ void AuctionHouseMgr::AddAItem(Item* item) _itemsByGuid[item->GetGUID()] = item; } -bool AuctionHouseMgr::RemoveAItem(ObjectGuid id, bool deleteItem) +bool AuctionHouseMgr::RemoveAItem(ObjectGuid id, bool deleteItem /*= false*/, CharacterDatabaseTransaction* trans /*= nullptr*/) { auto i = _itemsByGuid.find(id); if (i == _itemsByGuid.end()) @@ -661,9 +661,9 @@ bool AuctionHouseMgr::RemoveAItem(ObjectGuid id, bool deleteItem) if (deleteItem) { - CharacterDatabaseTransaction trans = CharacterDatabaseTransaction(nullptr); + ASSERT(trans); i->second->FSetState(ITEM_REMOVED); - i->second->SaveToDB(trans); + i->second->SaveToDB(*trans); } _itemsByGuid.erase(i); @@ -1850,7 +1850,7 @@ void AuctionHouseObject::SendAuctionWon(AuctionPosting const* auction, Player* b { // bidder doesn't exist, delete the item for (Item* item : auction->Items) - sAuctionMgr->RemoveAItem(item->GetGUID(), true); + sAuctionMgr->RemoveAItem(item->GetGUID(), true, &trans); } } @@ -1902,7 +1902,7 @@ void AuctionHouseObject::SendAuctionExpired(AuctionPosting const* auction, Chara { // owner doesn't exist, delete the item for (Item* item : auction->Items) - sAuctionMgr->RemoveAItem(item->GetGUID(), true); + sAuctionMgr->RemoveAItem(item->GetGUID(), true, &trans); } } diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.h b/src/server/game/AuctionHouse/AuctionHouseMgr.h index 86e311a67af..4513e86089d 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.h +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.h @@ -373,7 +373,7 @@ class TC_GAME_API AuctionHouseMgr void LoadAuctions(); void AddAItem(Item* item); - bool RemoveAItem(ObjectGuid itemGuid, bool deleteItem = false); + bool RemoveAItem(ObjectGuid itemGuid, bool deleteItem = false, CharacterDatabaseTransaction* trans = nullptr); bool PendingAuctionAdd(Player* player, uint32 auctionHouseId, uint32 auctionId, uint64 deposit); std::size_t PendingAuctionCount(Player const* player) const; void PendingAuctionProcess(Player* player); -- cgit v1.2.3 From 7f64eaa3ee28d3eb29f602dd0f36435734014789 Mon Sep 17 00:00:00 2001 From: ariel- Date: Thu, 6 Apr 2017 20:38:27 -0300 Subject: Core/Player: fix weapon dependent aura talents not applied on talent learn Closes #19408 (cherry picked from commit 5cb1555de6db43db03d6202b7edaa9c6835ecfab) --- src/server/game/Entities/Player/Player.cpp | 14 +++++++++----- src/server/game/Entities/Player/Player.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index ae089ed5398..958d636f70c 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -2936,7 +2936,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent if (active) { - if (spellInfo->IsPassive() && IsNeedCastPassiveSpellAtLearn(spellInfo)) + if (spellInfo->IsPassive() && HandlePassiveSpellLearn(spellInfo)) CastSpell(this, spellId, true); } else if (IsInWorld()) @@ -3063,7 +3063,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent // also cast passive spells (including all talents without SPELL_EFFECT_LEARN_SPELL) with additional checks else if (spellInfo->IsPassive()) { - if (IsNeedCastPassiveSpellAtLearn(spellInfo)) + if (HandlePassiveSpellLearn(spellInfo)) CastSpell(this, spellId, true); } else if (spellInfo->HasEffect(SPELL_EFFECT_SKILL_STEP)) @@ -3194,7 +3194,7 @@ void Player::RemoveTemporarySpell(uint32 spellId) m_spells.erase(itr); } -bool Player::IsNeedCastPassiveSpellAtLearn(SpellInfo const* spellInfo) const +bool Player::HandlePassiveSpellLearn(SpellInfo const* spellInfo) { // note: form passives activated with shapeshift spells be implemented by HandleShapeshiftBoosts instead of spell_learn_spell // talent dependent passives activated at form apply have proper stance data @@ -3206,12 +3206,16 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellInfo const* spellInfo) const need_cast &= IsCurrentSpecMasterySpell(spellInfo); // Check EquippedItemClass - // passive spells which apply aura and have an item requirement are to be added in Player::ApplyItemDependentAuras - if (spellInfo->IsPassive() && spellInfo->EquippedItemClass >= 0) + // passive spells which apply aura and have an item requirement are to be added manually, instead of casted + if (spellInfo->EquippedItemClass >= 0) { for (SpellEffectInfo const* effectInfo : spellInfo->GetEffectsForDifficulty(DIFFICULTY_NONE)) if (effectInfo && effectInfo->IsAura()) + { + if (!HasAura(spellInfo->Id) && HasItemFitToSpellRequirements(spellInfo)) + AddAura(spellInfo->Id, this); return false; + } } //Check CasterAuraStates diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 0eacdb13fe1..cd43d319960 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1556,7 +1556,7 @@ class TC_GAME_API Player : public Unit, public GridObject bool HasActiveSpell(uint32 spell) const; // show in spellbook SpellInfo const* GetCastSpellInfo(SpellInfo const* spellInfo) const override; bool IsSpellFitByClassAndRace(uint32 spell_id) const; - bool IsNeedCastPassiveSpellAtLearn(SpellInfo const* spellInfo) const; + bool HandlePassiveSpellLearn(SpellInfo const* spellInfo); bool IsCurrentSpecMasterySpell(SpellInfo const* spellInfo) const; void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) const; -- cgit v1.2.3 From 14c6a4d8238e4f383557359436b5f73cb730d4ea Mon Sep 17 00:00:00 2001 From: ccrs Date: Fri, 7 Apr 2017 21:35:23 +0200 Subject: [3.3.5] Core/Movement: MotionMaster & MovementGenerators cleaning (#19361) (cherry picked from commit 21b8c4997a260b5e2dc24ab07df17d3daa6b8b5d) --- src/server/game/Entities/Unit/Unit.cpp | 6 +- src/server/game/Entities/Unit/Unit.h | 2 +- src/server/game/Movement/MotionMaster.cpp | 10 +- src/server/game/Movement/MotionMaster.h | 2 +- src/server/game/Movement/MovementGenerator.h | 17 +- src/server/game/Movement/MovementGeneratorImpl.h | 8 +- .../ConfusedMovementGenerator.cpp | 109 +++--- .../MovementGenerators/ConfusedMovementGenerator.h | 13 +- .../FleeingMovementGenerator.cpp | 253 ++++++------ .../MovementGenerators/FleeingMovementGenerator.h | 24 +- .../MovementGenerators/HomeMovementGenerator.cpp | 80 ++-- .../MovementGenerators/HomeMovementGenerator.h | 32 +- .../MovementGenerators/IdleMovementGenerator.cpp | 32 +- .../MovementGenerators/IdleMovementGenerator.h | 15 +- .../MovementGenerators/PointMovementGenerator.cpp | 149 ++++---- .../MovementGenerators/PointMovementGenerator.h | 41 +- .../MovementGenerators/RandomMovementGenerator.cpp | 208 +++++----- .../MovementGenerators/RandomMovementGenerator.h | 21 +- .../TargetedMovementGenerator.cpp | 425 ++++++++++++--------- .../MovementGenerators/TargetedMovementGenerator.h | 104 +++-- 20 files changed, 815 insertions(+), 736 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 0f809261bc0..7479b955435 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -8658,7 +8658,7 @@ void Unit::SetSpeedRate(UnitMoveType mtype, float rate) m_speed_rate[mtype] = rate; - propagateSpeedChange(); + PropagateSpeedChange(); // Spline packets are for creatures and move_update are for players static OpcodeServer const moveTypeToOpcode[MAX_MOVE_TYPE][3] = @@ -10661,9 +10661,9 @@ void Unit::SendPetAIReaction(ObjectGuid guid) owner->ToPlayer()->SendDirectMessage(packet.Write()); } -void Unit::propagateSpeedChange() +void Unit::PropagateSpeedChange() { - GetMotionMaster()->propagateSpeedChange(); + GetMotionMaster()->PropagateSpeedChange(); } ///----------End of Pet responses methods---------- diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 7db8583f69f..e96b63f7013 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1915,7 +1915,7 @@ class TC_GAME_API Unit : public WorldObject void SendPetAIReaction(ObjectGuid guid); ///----------End of Pet responses methods---------- - void propagateSpeedChange(); + void PropagateSpeedChange(); // reactive attacks void ClearAllReactives(); diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 3e775d238a4..b124edb22d1 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -32,6 +32,7 @@ #include "SplineChainMovementGenerator.h" #include "MoveSpline.h" #include "MoveSplineInit.h" +#include "PathGenerator.h" inline bool IsStatic(MovementGenerator* movement) { @@ -76,7 +77,7 @@ void MotionMaster::InitDefault() if (_owner->GetTypeId() == TYPEID_UNIT) { MovementGenerator* movement = FactorySelector::selectMovementGenerator(_owner->ToCreature()); - Mutate(movement == NULL ? &si_idleMovement : movement, MOTION_SLOT_IDLE); + Mutate(movement == nullptr ? &si_idleMovement : movement, MOTION_SLOT_IDLE); } else { @@ -89,9 +90,6 @@ void MotionMaster::UpdateMotion(uint32 diff) if (!_owner) return; - if (_owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED)) // what about UNIT_STATE_DISTRACTED? Why is this not included? - return; - ASSERT(!empty()); _cleanFlag |= MMCF_UPDATE; @@ -174,12 +172,12 @@ MovementGenerator* MotionMaster::GetMotionSlot(int slot) const return _slot[slot]; } -void MotionMaster::propagateSpeedChange() +void MotionMaster::PropagateSpeedChange() { for (int i = 0; i <= _top; ++i) { if (_slot[i]) - _slot[i]->unitSpeedChanged(); + _slot[i]->UnitSpeedChanged(); } } diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index c496a0ec4ec..8a3f8e5d0b2 100644 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -125,7 +125,7 @@ class TC_GAME_API MotionMaster MovementGeneratorType GetMotionSlotType(int slot) const; MovementGenerator* GetMotionSlot(int slot) const; - void propagateSpeedChange(); + void PropagateSpeedChange(); bool GetDestination(float &x, float &y, float &z); diff --git a/src/server/game/Movement/MovementGenerator.h b/src/server/game/Movement/MovementGenerator.h index a28ffca0172..fdf5506dd15 100755 --- a/src/server/game/Movement/MovementGenerator.h +++ b/src/server/game/Movement/MovementGenerator.h @@ -33,14 +33,12 @@ class TC_GAME_API MovementGenerator virtual void Initialize(Unit*) = 0; virtual void Finalize(Unit*) = 0; - virtual void Reset(Unit*) = 0; - - virtual bool Update(Unit*, uint32 time_diff) = 0; + virtual bool Update(Unit*, uint32 diff) = 0; virtual MovementGeneratorType GetMovementGeneratorType() const = 0; - virtual void unitSpeedChanged() { } + virtual void UnitSpeedChanged() { } // used by Evade code for select point to evade with expected restart default movement virtual bool GetResetPosition(Unit*, float& /*x*/, float& /*y*/, float& /*z*/) { return false; } @@ -52,42 +50,39 @@ class MovementGeneratorMedium : public MovementGenerator public: void Initialize(Unit* u) override { - //u->AssertIsType(); (static_cast(this))->DoInitialize(static_cast(u)); } void Finalize(Unit* u) override { - //u->AssertIsType(); (static_cast(this))->DoFinalize(static_cast(u)); } void Reset(Unit* u) override { - //u->AssertIsType(); (static_cast(this))->DoReset(static_cast(u)); } bool Update(Unit* u, uint32 time_diff) override { - //u->AssertIsType(); return (static_cast(this))->DoUpdate(static_cast(u), time_diff); } }; struct SelectableMovement : public FactoryHolder { - SelectableMovement(MovementGeneratorType mgt) : FactoryHolder(mgt) { } + SelectableMovement(MovementGeneratorType movementGeneratorType) : FactoryHolder(movementGeneratorType) { } }; -template +template struct MovementGeneratorFactory : public SelectableMovement { - MovementGeneratorFactory(MovementGeneratorType mgt) : SelectableMovement(mgt) { } + MovementGeneratorFactory(MovementGeneratorType movementGeneratorType) : SelectableMovement(movementGeneratorType) { } MovementGenerator* Create(void *) const override; }; typedef FactoryHolder MovementGeneratorCreator; typedef FactoryHolder::FactoryHolderRegistry MovementGeneratorRegistry; + #endif diff --git a/src/server/game/Movement/MovementGeneratorImpl.h b/src/server/game/Movement/MovementGeneratorImpl.h index 346fae28d1f..0b5474b22b3 100644 --- a/src/server/game/Movement/MovementGeneratorImpl.h +++ b/src/server/game/Movement/MovementGeneratorImpl.h @@ -20,10 +20,10 @@ #include "MovementGenerator.h" -template -inline MovementGenerator* -MovementGeneratorFactory::Create(void * /*data*/) const +template +inline MovementGenerator* MovementGeneratorFactory::Create(void * /*data*/) const { - return (new MOVEMENT_GEN()); + return (new Movement()); } + #endif diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp index 37b0cf912ad..0432241432d 100755 --- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp @@ -16,92 +16,95 @@ */ #include "Creature.h" -#include "ConfusedMovementGenerator.h" +#include "Player.h" #include "PathGenerator.h" #include "MoveSplineInit.h" #include "MoveSpline.h" -#include "Player.h" #include "Random.h" +#include "ConfusedMovementGenerator.h" template -void ConfusedMovementGenerator::DoInitialize(T* unit) +ConfusedMovementGenerator::~ConfusedMovementGenerator() { - unit->AddUnitState(UNIT_STATE_CONFUSED); - unit->AddUnitFlag(UNIT_FLAG_CONFUSED); - unit->GetPosition(i_x, i_y, i_z); + delete _path; +} - if (!unit->IsAlive() || unit->IsStopped()) +template +void ConfusedMovementGenerator::DoInitialize(T* owner) +{ + if (!owner || !owner->IsAlive()) return; - unit->StopMoving(); - unit->AddUnitState(UNIT_STATE_CONFUSED_MOVE); + owner->AddUnitState(UNIT_STATE_CONFUSED); + owner->AddUnitFlag(UNIT_FLAG_CONFUSED); + owner->StopMoving(); + + _timer.Reset(0); + owner->GetPosition(_reference.m_positionX, _reference.m_positionY, _reference.m_positionZ); } template -void ConfusedMovementGenerator::DoReset(T* unit) +void ConfusedMovementGenerator::DoReset(T* owner) { - i_nextMoveTime.Reset(0); - - if (!unit->IsAlive() || unit->IsStopped()) - return; - - unit->StopMoving(); - unit->AddUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_CONFUSED_MOVE); + DoInitialize(owner); } template -bool ConfusedMovementGenerator::DoUpdate(T* unit, uint32 diff) +bool ConfusedMovementGenerator::DoUpdate(T* owner, uint32 diff) { - if (unit->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED)) - return true; + if (!owner || !owner->IsAlive()) + return false; - if (i_nextMoveTime.Passed()) + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting()) { - // currently moving, update location - unit->AddUnitState(UNIT_STATE_CONFUSED_MOVE); - - if (unit->movespline->Finalized()) - i_nextMoveTime.Reset(urand(800, 1500)); + _interrupt = true; + owner->StopMoving(); + return true; } else + _interrupt = false; + + // waiting for next move + _timer.Update(diff); + if (!_interrupt && _timer.Passed() && owner->movespline->Finalized()) { - // waiting for next move - i_nextMoveTime.Update(diff); - if (i_nextMoveTime.Passed()) + // start moving + owner->AddUnitState(UNIT_STATE_CONFUSED_MOVE); + + Position destination(_reference); + float distance = 4.0f * frand(0.0f, 1.0f) - 2.0f; + float angle = frand(0.0f, 1.0f) * float(M_PI) * 2.0f; + owner->MovePositionToFirstCollision(destination, distance, angle); + + if (!_path) + _path = new PathGenerator(owner); + + _path->SetPathLengthLimit(30.0f); + bool result = _path->CalculatePath(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ()); + if (!result || (_path->GetPathType() & PATHFIND_NOPATH)) { - // start moving - unit->AddUnitState(UNIT_STATE_CONFUSED_MOVE); - - float dest = 4.0f * (float)rand_norm() - 2.0f; - - Position pos; - pos.Relocate(i_x, i_y, i_z); - unit->MovePositionToFirstCollision(pos, dest, 0.0f); - - PathGenerator path(unit); - path.SetPathLengthLimit(30.0f); - bool result = path.CalculatePath(pos.m_positionX, pos.m_positionY, pos.m_positionZ); - if (!result || (path.GetPathType() & PATHFIND_NOPATH)) - { - i_nextMoveTime.Reset(100); - return true; - } - - Movement::MoveSplineInit init(unit); - init.MovebyPath(path.GetPath()); - init.SetWalk(true); - init.Launch(); + _timer.Reset(100); + return true; } + + Movement::MoveSplineInit init(owner); + init.MovebyPath(_path->GetPath()); + init.SetWalk(true); + int32 traveltime = init.Launch(); + _timer.Reset(traveltime + urand(800, 1500)); } return true; } +template +void ConfusedMovementGenerator::DoFinalize(T*) { } + template<> void ConfusedMovementGenerator::DoFinalize(Player* unit) { unit->RemoveUnitFlag(UNIT_FLAG_CONFUSED); - unit->ClearUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_CONFUSED_MOVE); + unit->ClearUnitState(UNIT_STATE_CONFUSED); unit->StopMoving(); } @@ -114,6 +117,8 @@ void ConfusedMovementGenerator::DoFinalize(Creature* unit) unit->SetTarget(unit->EnsureVictim()->GetGUID()); } +template ConfusedMovementGenerator::~ConfusedMovementGenerator(); +template ConfusedMovementGenerator::~ConfusedMovementGenerator(); template void ConfusedMovementGenerator::DoInitialize(Player*); template void ConfusedMovementGenerator::DoInitialize(Creature*); template void ConfusedMovementGenerator::DoReset(Player*); diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.h b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.h index a67afb72024..7d4cd073457 100755 --- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.h @@ -25,16 +25,21 @@ template class ConfusedMovementGenerator : public MovementGeneratorMedium< T, ConfusedMovementGenerator > { public: - explicit ConfusedMovementGenerator() : i_nextMoveTime(0), i_x(0), i_y(0), i_z(0) { } + explicit ConfusedMovementGenerator() : _path(nullptr), _timer(0), _reference(0.f, 0.f, 0.f), _interrupt(false) { } + ~ConfusedMovementGenerator(); + + MovementGeneratorType GetMovementGeneratorType() const override { return CONFUSED_MOTION_TYPE; } void DoInitialize(T*); void DoFinalize(T*); void DoReset(T*); bool DoUpdate(T*, uint32); - MovementGeneratorType GetMovementGeneratorType() const override { return CONFUSED_MOTION_TYPE; } private: - TimeTracker i_nextMoveTime; - float i_x, i_y, i_z; + PathGenerator* _path; + TimeTracker _timer; + Position _reference; + bool _interrupt; }; + #endif diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp index bfe3f4399d0..a1d179c23ce 100644 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp @@ -15,176 +15,203 @@ * with this program. If not, see . */ -#include "Creature.h" +#include "VMapFactory.h" #include "CreatureAI.h" -#include "FleeingMovementGenerator.h" -#include "PathGenerator.h" #include "ObjectAccessor.h" +#include "Creature.h" +#include "Player.h" +#include "PathGenerator.h" #include "MoveSplineInit.h" #include "MoveSpline.h" #include "PhasingHandler.h" -#include "Player.h" -#include "VMapFactory.h" +#include "FleeingMovementGenerator.h" #define MIN_QUIET_DISTANCE 28.0f #define MAX_QUIET_DISTANCE 43.0f template -void FleeingMovementGenerator::_setTargetLocation(T* owner) +FleeingMovementGenerator::~FleeingMovementGenerator() +{ + delete _path; +} + +template +void FleeingMovementGenerator::DoInitialize(T* owner) { if (!owner) return; - if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED)) + owner->AddUnitFlag(UNIT_FLAG_FLEEING); + owner->AddUnitState(UNIT_STATE_FLEEING); + SetTargetLocation(owner); +} + +template +void FleeingMovementGenerator::DoFinalize(T *) +{ +} + +template<> +void FleeingMovementGenerator::DoFinalize(Player* owner) +{ + owner->RemoveUnitFlag(UNIT_FLAG_FLEEING); + owner->ClearUnitState(UNIT_STATE_FLEEING); + owner->StopMoving(); +} + +template<> +void FleeingMovementGenerator::DoFinalize(Creature* owner) +{ + owner->RemoveUnitFlag(UNIT_FLAG_FLEEING); + owner->ClearUnitState(UNIT_STATE_FLEEING | UNIT_STATE_FLEEING_MOVE); + if (owner->GetVictim()) + owner->SetTarget(owner->EnsureVictim()->GetGUID()); +} + +template +void FleeingMovementGenerator::DoReset(T* owner) +{ + DoInitialize(owner); +} + +template +bool FleeingMovementGenerator::DoUpdate(T* owner, uint32 diff) +{ + if (!owner || !owner->IsAlive()) + return false; + + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting()) + { + _interrupt = true; + owner->StopMoving(); + return true; + } + else + _interrupt = false; + + _timer.Update(diff); + if (!_interrupt && _timer.Passed() && owner->movespline->Finalized()) + SetTargetLocation(owner); + + return true; +} + +template +void FleeingMovementGenerator::SetTargetLocation(T* owner) +{ + if (!owner) return; - if (owner->IsMovementPreventedByCasting()) + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting()) { - owner->CastStop(); + _interrupt = true; + owner->StopMoving(); return; } owner->AddUnitState(UNIT_STATE_FLEEING_MOVE); - float x, y, z; - _getPoint(owner, x, y, z); + Position destination = owner->GetPosition(); + GetPoint(owner, destination); // Add LOS check for target point - Position mypos = owner->GetPosition(); - bool isInLOS = VMAP::VMapFactory::createOrGetVMapManager()->isInLineOfSight( - PhasingHandler::GetTerrainMapId(owner->GetPhaseShift(), owner->GetMap(), mypos.m_positionX, mypos.m_positionY), - mypos.m_positionX, mypos.m_positionY, mypos.m_positionZ + 2.0f, x, y, z + 2.0f, VMAP::ModelIgnoreFlags::Nothing); - if (!isInLOS) + Position currentPosition = owner->GetPosition(); + if (!VMAP::VMapFactory::createOrGetVMapManager()->isInLineOfSight(PhasingHandler::GetTerrainMapId(owner->GetPhaseShift(), owner->GetMap(), currentPosition.m_positionX, currentPosition.m_positionY), currentPosition.m_positionX, currentPosition.m_positionY, currentPosition.m_positionZ + 2.0f, destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ() + 2.0f, VMAP::ModelIgnoreFlags::Nothing)) { - i_nextCheckTime.Reset(200); + _timer.Reset(200); return; } - PathGenerator path(owner); - path.SetPathLengthLimit(30.0f); - bool result = path.CalculatePath(x, y, z); - if (!result || (path.GetPathType() & PATHFIND_NOPATH)) + if (!_path) + _path = new PathGenerator(owner); + + _path->SetPathLengthLimit(30.0f); + bool result = _path->CalculatePath(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ()); + if (!result || (_path->GetPathType() & PATHFIND_NOPATH)) { - i_nextCheckTime.Reset(100); + _timer.Reset(100); return; } Movement::MoveSplineInit init(owner); - init.MovebyPath(path.GetPath()); + init.MovebyPath(_path->GetPath()); init.SetWalk(false); int32 traveltime = init.Launch(); - i_nextCheckTime.Reset(traveltime + urand(800, 1500)); + _timer.Reset(traveltime + urand(800, 1500)); } template -void FleeingMovementGenerator::_getPoint(T* owner, float &x, float &y, float &z) +void FleeingMovementGenerator::GetPoint(T* owner, Position &position) { - float dist_from_caster, angle_to_caster; - if (Unit* fright = ObjectAccessor::GetUnit(*owner, i_frightGUID)) + float casterDistance, casterAngle; + if (Unit* fleeTarget = ObjectAccessor::GetUnit(*owner, _fleeTargetGUID)) { - dist_from_caster = fright->GetDistance(owner); - if (dist_from_caster > 0.2f) - angle_to_caster = fright->GetAngle(owner); + casterDistance = fleeTarget->GetDistance(owner); + if (casterDistance > 0.2f) + casterAngle = fleeTarget->GetAngle(owner); else - angle_to_caster = frand(0, 2 * static_cast(M_PI)); + casterAngle = frand(0.0f, 2.0f * float(M_PI)); } else { - dist_from_caster = 0.0f; - angle_to_caster = frand(0, 2 * static_cast(M_PI)); + casterDistance = 0.0f; + casterAngle = frand(0.0f, 2.0f * float(M_PI)); } - float dist, angle; - if (dist_from_caster < MIN_QUIET_DISTANCE) + float distance, angle; + if (casterDistance < MIN_QUIET_DISTANCE) { - dist = frand(0.4f, 1.3f)*(MIN_QUIET_DISTANCE - dist_from_caster); - angle = angle_to_caster + frand(-static_cast(M_PI)/8, static_cast(M_PI)/8); + distance = frand(0.4f, 1.3f) * (MIN_QUIET_DISTANCE - casterDistance); + angle = casterAngle + frand(-float(M_PI) / 8.0f, float(M_PI) / 8.0f); } - else if (dist_from_caster > MAX_QUIET_DISTANCE) + else if (casterDistance > MAX_QUIET_DISTANCE) { - dist = frand(0.4f, 1.0f)*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE); - angle = -angle_to_caster + frand(-static_cast(M_PI)/4, static_cast(M_PI)/4); + distance = frand(0.4f, 1.0f) * (MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE); + angle = -casterAngle + frand(-float(M_PI) / 4.0f, float(M_PI) / 4.0f); } else // we are inside quiet range { - dist = frand(0.6f, 1.2f)*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE); - angle = frand(0, 2*static_cast(M_PI)); + distance = frand(0.6f, 1.2f) * (MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE); + angle = frand(0.0f, 2.0f * float(M_PI)); } - Position pos = owner->GetFirstCollisionPosition(dist, angle); - x = pos.m_positionX; - y = pos.m_positionY; - z = pos.m_positionZ; -} - -template -void FleeingMovementGenerator::DoInitialize(T* owner) -{ - if (!owner) - return; - - owner->AddUnitFlag(UNIT_FLAG_FLEEING); - owner->AddUnitState(UNIT_STATE_FLEEING | UNIT_STATE_FLEEING_MOVE); - _setTargetLocation(owner); + owner->MovePositionToFirstCollision(position, distance, angle); } -template<> -void FleeingMovementGenerator::DoFinalize(Player* owner) -{ - owner->RemoveUnitFlag(UNIT_FLAG_FLEEING); - owner->ClearUnitState(UNIT_STATE_FLEEING | UNIT_STATE_FLEEING_MOVE); - owner->StopMoving(); -} - -template<> -void FleeingMovementGenerator::DoFinalize(Creature* owner) -{ - owner->RemoveUnitFlag(UNIT_FLAG_FLEEING); - owner->ClearUnitState(UNIT_STATE_FLEEING|UNIT_STATE_FLEEING_MOVE); - if (owner->GetVictim()) - owner->SetTarget(owner->EnsureVictim()->GetGUID()); -} +template FleeingMovementGenerator::~FleeingMovementGenerator(); +template FleeingMovementGenerator::~FleeingMovementGenerator(); +template void FleeingMovementGenerator::DoInitialize(Player*); +template void FleeingMovementGenerator::DoInitialize(Creature*); +template void FleeingMovementGenerator::DoReset(Player*); +template void FleeingMovementGenerator::DoReset(Creature*); +template bool FleeingMovementGenerator::DoUpdate(Player*, uint32); +template bool FleeingMovementGenerator::DoUpdate(Creature*, uint32); +template void FleeingMovementGenerator::SetTargetLocation(Player*); +template void FleeingMovementGenerator::SetTargetLocation(Creature*); +template void FleeingMovementGenerator::GetPoint(Player*, Position &); +template void FleeingMovementGenerator::GetPoint(Creature*, Position &); -template -void FleeingMovementGenerator::DoReset(T* owner) -{ - DoInitialize(owner); -} +//---- TimedFleeingMovementGenerator -template -bool FleeingMovementGenerator::DoUpdate(T* owner, uint32 time_diff) +bool TimedFleeingMovementGenerator::Update(Unit* owner, uint32 time_diff) { - if (!owner || !owner->IsAlive()) + if (!owner->IsAlive()) return false; - if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED)) - { - owner->ClearUnitState(UNIT_STATE_FLEEING_MOVE); - return true; - } - - i_nextCheckTime.Update(time_diff); - if (i_nextCheckTime.Passed() && owner->movespline->Finalized()) - _setTargetLocation(owner); + _totalFleeTime.Update(time_diff); + if (_totalFleeTime.Passed()) + return false; - return true; + // This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, uint32) version + // This is done instead of casting Unit& to Creature& and call parent method, then we can use Unit directly + return MovementGeneratorMedium< Creature, FleeingMovementGenerator >::Update(owner, time_diff); } -template void FleeingMovementGenerator::DoInitialize(Player*); -template void FleeingMovementGenerator::DoInitialize(Creature*); -template void FleeingMovementGenerator::_getPoint(Player*, float&, float&, float&); -template void FleeingMovementGenerator::_getPoint(Creature*, float&, float&, float&); -template void FleeingMovementGenerator::_setTargetLocation(Player*); -template void FleeingMovementGenerator::_setTargetLocation(Creature*); -template void FleeingMovementGenerator::DoReset(Player*); -template void FleeingMovementGenerator::DoReset(Creature*); -template bool FleeingMovementGenerator::DoUpdate(Player*, uint32); -template bool FleeingMovementGenerator::DoUpdate(Creature*, uint32); - void TimedFleeingMovementGenerator::Finalize(Unit* owner) { owner->RemoveUnitFlag(UNIT_FLAG_FLEEING); - owner->ClearUnitState(UNIT_STATE_FLEEING|UNIT_STATE_FLEEING_MOVE); + owner->ClearUnitState(UNIT_STATE_FLEEING); + owner->StopMoving(); if (Unit* victim = owner->GetVictim()) { if (owner->IsAlive()) @@ -194,23 +221,3 @@ void TimedFleeingMovementGenerator::Finalize(Unit* owner) } } } - -bool TimedFleeingMovementGenerator::Update(Unit* owner, uint32 time_diff) -{ - if (!owner->IsAlive()) - return false; - - if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED)) - { - owner->ClearUnitState(UNIT_STATE_FLEEING_MOVE); - return true; - } - - i_totalFleeTime.Update(time_diff); - if (i_totalFleeTime.Passed()) - return false; - - // This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, uint32) version - // This is done instead of casting Unit& to Creature& and call parent method, then we can use Unit directly - return MovementGeneratorMedium< Creature, FleeingMovementGenerator >::Update(owner, time_diff); -} diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h index 025e783be5b..7481e340154 100755 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h @@ -19,41 +19,43 @@ #define TRINITY_FLEEINGMOVEMENTGENERATOR_H #include "MovementGenerator.h" +#include "Timer.h" template class FleeingMovementGenerator : public MovementGeneratorMedium< T, FleeingMovementGenerator > { public: - FleeingMovementGenerator(ObjectGuid fright) : i_frightGUID(fright), i_nextCheckTime(0) { } + explicit FleeingMovementGenerator(ObjectGuid fleeTargetGUID) : _path(nullptr), _fleeTargetGUID(fleeTargetGUID), _timer(0), _interrupt(false) { } + ~FleeingMovementGenerator(); + + MovementGeneratorType GetMovementGeneratorType() const override { return FLEEING_MOTION_TYPE; } void DoInitialize(T*); void DoFinalize(T*); void DoReset(T*); bool DoUpdate(T*, uint32); - MovementGeneratorType GetMovementGeneratorType() const override { return FLEEING_MOTION_TYPE; } - private: - void _setTargetLocation(T*); - void _getPoint(T*, float &x, float &y, float &z); + void SetTargetLocation(T*); + void GetPoint(T*, Position &position); - ObjectGuid i_frightGUID; - TimeTracker i_nextCheckTime; + PathGenerator* _path; + ObjectGuid _fleeTargetGUID; + TimeTracker _timer; + bool _interrupt; }; class TimedFleeingMovementGenerator : public FleeingMovementGenerator { public: - TimedFleeingMovementGenerator(ObjectGuid fright, uint32 time) : - FleeingMovementGenerator(fright), - i_totalFleeTime(time) { } + explicit TimedFleeingMovementGenerator(ObjectGuid fleeTargetGUID, uint32 time) : FleeingMovementGenerator(fleeTargetGUID), _totalFleeTime(time) { } MovementGeneratorType GetMovementGeneratorType() const override { return TIMED_FLEEING_MOTION_TYPE; } bool Update(Unit*, uint32) override; void Finalize(Unit*) override; private: - TimeTracker i_totalFleeTime; + TimeTracker _totalFleeTime; }; #endif diff --git a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp index e8fa2ba6c53..041961ce91c 100644 --- a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp @@ -15,36 +15,31 @@ * with this program. If not, see . */ -#include "HomeMovementGenerator.h" #include "Creature.h" #include "CreatureAI.h" #include "MoveSplineInit.h" #include "MoveSpline.h" +#include "PathGenerator.h" +#include "HomeMovementGenerator.h" -void HomeMovementGenerator::DoInitialize(Creature* owner) -{ - _setTargetLocation(owner); -} +template +HomeMovementGenerator::~HomeMovementGenerator() { } -void HomeMovementGenerator::DoFinalize(Creature* owner) +template<> +HomeMovementGenerator::~HomeMovementGenerator() { - if (arrived) - { - owner->ClearUnitState(UNIT_STATE_EVADE); - owner->SetWalk(true); - owner->LoadCreaturesAddon(); - owner->AI()->JustReachedHome(); - owner->SetSpawnHealth(); - } + delete _path; } -void HomeMovementGenerator::DoReset(Creature*) { } +template +void HomeMovementGenerator::SetTargetLocation(T*) { } -void HomeMovementGenerator::_setTargetLocation(Creature* owner) +template<> +void HomeMovementGenerator::SetTargetLocation(Creature* owner) { if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED)) { // if we are ROOT/STUNNED/DISTRACTED even after aura clear, finalize on next update - otherwise we would get stuck in evade - skipToHome = true; + _skipToHome = true; return; } @@ -60,14 +55,55 @@ void HomeMovementGenerator::_setTargetLocation(Creature* owner) init.SetWalk(false); init.Launch(); - skipToHome = false; - arrived = false; + _skipToHome = false; + _arrived = false; owner->ClearUnitState(UNIT_STATE_ALL_ERASABLE & ~UNIT_STATE_EVADE); } -bool HomeMovementGenerator::DoUpdate(Creature* owner, const uint32 /*time_diff*/) +template +void HomeMovementGenerator::DoInitialize(T*) { } + +template<> +void HomeMovementGenerator::DoInitialize(Creature* owner) +{ + SetTargetLocation(owner); +} + +template +void HomeMovementGenerator::DoFinalize(T*) { } + +template<> +void HomeMovementGenerator::DoFinalize(Creature* owner) +{ + if (_arrived) + { + owner->ClearUnitState(UNIT_STATE_EVADE); + owner->SetWalk(true); + owner->LoadCreaturesAddon(); + owner->AI()->JustReachedHome(); + owner->SetSpawnHealth(); + } +} + +template +void HomeMovementGenerator::DoReset(T*) { } + +template<> +void HomeMovementGenerator::DoReset(Creature* owner) +{ + DoInitialize(owner); +} + +template +bool HomeMovementGenerator::DoUpdate(T*, uint32) +{ + return false; +} + +template<> +bool HomeMovementGenerator::DoUpdate(Creature* owner, uint32 /*diff*/) { - arrived = skipToHome || owner->movespline->Finalized(); - return !arrived; + _arrived = _skipToHome || owner->movespline->Finalized(); + return !_arrived; } diff --git a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h index d3489a249f3..5e1c25d9361 100644 --- a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h @@ -20,28 +20,26 @@ #include "MovementGenerator.h" -class Creature; - -template < class T > -class HomeMovementGenerator; - -template <> -class HomeMovementGenerator : public MovementGeneratorMedium< Creature, HomeMovementGenerator > +template +class HomeMovementGenerator : public MovementGeneratorMedium< T, HomeMovementGenerator > { public: + explicit HomeMovementGenerator() : _path(nullptr), _arrived(false), _skipToHome(false) { } + ~HomeMovementGenerator(); - HomeMovementGenerator() : arrived(false), skipToHome(false) { } - ~HomeMovementGenerator() { } - - void DoInitialize(Creature*); - void DoFinalize(Creature*); - void DoReset(Creature*); - bool DoUpdate(Creature*, const uint32); MovementGeneratorType GetMovementGeneratorType() const override { return HOME_MOTION_TYPE; } + void DoInitialize(T*); + void DoFinalize(T*); + void DoReset(T*); + bool DoUpdate(T*, uint32); + private: - void _setTargetLocation(Creature*); - bool arrived; - bool skipToHome; + void SetTargetLocation(T*); + + PathGenerator* _path; + bool _arrived; + bool _skipToHome; }; + #endif diff --git a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp index 811dc54fa79..76b1aca3cc2 100644 --- a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp @@ -35,6 +35,8 @@ void IdleMovementGenerator::Reset(Unit* owner) owner->StopMoving(); } +//----------------------------------------------------// + void RotateMovementGenerator::Initialize(Unit* owner) { if (!owner->IsStopped()) @@ -50,27 +52,29 @@ void RotateMovementGenerator::Initialize(Unit* owner) bool RotateMovementGenerator::Update(Unit* owner, uint32 diff) { float angle = owner->GetOrientation(); - angle += (float(diff) * static_cast(M_PI * 2) / m_maxDuration) * (m_direction == ROTATE_DIRECTION_LEFT ? 1.0f : -1.0f); + angle += (float(diff) * static_cast(M_PI * 2) / _maxDuration) * (_direction == ROTATE_DIRECTION_LEFT ? 1.0f : -1.0f); angle = G3D::wrap(angle, 0.0f, float(G3D::twoPi())); owner->SetOrientation(angle); // UpdateSplinePosition does not set orientation with UNIT_STATE_ROTATING owner->SetFacingTo(angle); // Send spline movement to clients - if (m_duration > diff) - m_duration -= diff; + if (_duration > diff) + _duration -= diff; else return false; return true; } -void RotateMovementGenerator::Finalize(Unit* unit) +void RotateMovementGenerator::Finalize(Unit* owner) { - unit->ClearUnitState(UNIT_STATE_ROTATING); - if (unit->GetTypeId() == TYPEID_UNIT) - unit->ToCreature()->AI()->MovementInform(ROTATE_MOTION_TYPE, 0); + owner->ClearUnitState(UNIT_STATE_ROTATING); + if (owner->GetTypeId() == TYPEID_UNIT) + owner->ToCreature()->AI()->MovementInform(ROTATE_MOTION_TYPE, 0); } +//----------------------------------------------------// + void DistractMovementGenerator::Initialize(Unit* owner) { // Distracted creatures stand up if not standing @@ -92,17 +96,19 @@ void DistractMovementGenerator::Finalize(Unit* owner) } } -bool DistractMovementGenerator::Update(Unit* /*owner*/, uint32 time_diff) +bool DistractMovementGenerator::Update(Unit* /*owner*/, uint32 diff) { - if (time_diff > m_timer) + if (diff > _timer) return false; - m_timer -= time_diff; + _timer -= diff; return true; } -void AssistanceDistractMovementGenerator::Finalize(Unit* unit) +//----------------------------------------------------// + +void AssistanceDistractMovementGenerator::Finalize(Unit* owner) { - unit->ClearUnitState(UNIT_STATE_DISTRACTED); - unit->ToCreature()->SetReactState(REACT_AGGRESSIVE); + owner->ClearUnitState(UNIT_STATE_DISTRACTED); + owner->ToCreature()->SetReactState(REACT_AGGRESSIVE); } diff --git a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h index 022bda5a394..9bb58419433 100755 --- a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h @@ -19,11 +19,11 @@ #define TRINITY_IDLEMOVEMENTGENERATOR_H #include "MovementGenerator.h" +#include "Timer.h" class IdleMovementGenerator : public MovementGenerator { public: - void Initialize(Unit*) override; void Finalize(Unit*) override { } void Reset(Unit*) override; @@ -36,7 +36,7 @@ TC_GAME_API extern IdleMovementGenerator si_idleMovement; class RotateMovementGenerator : public MovementGenerator { public: - explicit RotateMovementGenerator(uint32 time, RotateDirection direction) : m_duration(time), m_maxDuration(time), m_direction(direction) { } + explicit RotateMovementGenerator(uint32 time, RotateDirection direction) : _duration(time), _maxDuration(time), _direction(direction) { } void Initialize(Unit*) override; void Finalize(Unit*) override; @@ -45,14 +45,14 @@ class RotateMovementGenerator : public MovementGenerator MovementGeneratorType GetMovementGeneratorType() const override { return ROTATE_MOTION_TYPE; } private: - uint32 m_duration, m_maxDuration; - RotateDirection m_direction; + uint32 _duration, _maxDuration; + RotateDirection _direction; }; class DistractMovementGenerator : public MovementGenerator { public: - explicit DistractMovementGenerator(uint32 timer) : m_timer(timer) { } + explicit DistractMovementGenerator(uint32 timer) : _timer(timer) { } void Initialize(Unit*) override; void Finalize(Unit*) override; @@ -61,14 +61,13 @@ class DistractMovementGenerator : public MovementGenerator MovementGeneratorType GetMovementGeneratorType() const override { return DISTRACT_MOTION_TYPE; } private: - uint32 m_timer; + uint32 _timer; }; class AssistanceDistractMovementGenerator : public DistractMovementGenerator { public: - AssistanceDistractMovementGenerator(uint32 timer) : - DistractMovementGenerator(timer) { } + explicit AssistanceDistractMovementGenerator(uint32 timer) : DistractMovementGenerator(timer) { } MovementGeneratorType GetMovementGeneratorType() const override { return ASSISTANCE_DISTRACT_MOTION_TYPE; } void Finalize(Unit*) override; diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp index 3cf0711dc41..9c2567ad6a3 100755 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp @@ -15,33 +15,42 @@ * with this program. If not, see . */ -#include "PointMovementGenerator.h" -#include "Errors.h" -#include "Creature.h" #include "CreatureAI.h" -#include "World.h" +#include "Creature.h" +#include "CreatureGroups.h" +#include "Player.h" #include "MoveSplineInit.h" #include "MoveSpline.h" -#include "Player.h" -#include "CreatureGroups.h" #include "ObjectAccessor.h" +#include "World.h" +#include "PointMovementGenerator.h" //----- Point Movement Generator + template -void PointMovementGenerator::DoInitialize(T* unit) +void PointMovementGenerator::DoInitialize(T* owner) { - if (!unit->IsStopped()) - unit->StopMoving(); + if (_movementId == EVENT_CHARGE_PREPATH) + { + owner->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE); + return; + } - unit->AddUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE); + owner->AddUnitState(UNIT_STATE_ROAMING); - if (id == EVENT_CHARGE_PREPATH) + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting()) + { + _interrupt = true; + owner->StopMoving(); return; + } - Movement::MoveSplineInit init(unit); - init.MoveTo(i_x, i_y, i_z, m_generatePath); - if (speed > 0.0f) - init.SetVelocity(speed); + owner->AddUnitState(UNIT_STATE_ROAMING_MOVE); + + Movement::MoveSplineInit init(owner); + init.MoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ(), _generatePath); + if (_speed > 0.0f) + init.SetVelocity(_speed); if (i_faceTarget) init.SetFacing(i_faceTarget); if (i_spellEffectExtra) @@ -49,69 +58,73 @@ void PointMovementGenerator::DoInitialize(T* unit) init.Launch(); // Call for creature group update - if (Creature* creature = unit->ToCreature()) + if (Creature* creature = owner->ToCreature()) if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature) - creature->GetFormation()->LeaderMoveTo(i_x, i_y, i_z); + creature->GetFormation()->LeaderMoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ()); } template -bool PointMovementGenerator::DoUpdate(T* unit, uint32 /*diff*/) +bool PointMovementGenerator::DoUpdate(T* owner, uint32 /*diff*/) { - if (!unit) + if (!owner) return false; - if (unit->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED)) + if (_movementId == EVENT_CHARGE_PREPATH) + return !owner->movespline->Finalized(); + + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting()) { - unit->ClearUnitState(UNIT_STATE_ROAMING_MOVE); + _interrupt = true; + owner->StopMoving(); return true; } - unit->AddUnitState(UNIT_STATE_ROAMING_MOVE); - - if (id != EVENT_CHARGE_PREPATH && i_recalculateSpeed && !unit->movespline->Finalized()) + if ((_interrupt && owner->movespline->Finalized()) || (_recalculateSpeed && !owner->movespline->Finalized())) { - i_recalculateSpeed = false; - Movement::MoveSplineInit init(unit); - init.MoveTo(i_x, i_y, i_z, m_generatePath); - if (speed > 0.0f) // Default value for point motion type is 0.0, if 0.0 spline will use GetSpeed on unit - init.SetVelocity(speed); + _recalculateSpeed = false; + _interrupt = false; + + owner->AddUnitState(UNIT_STATE_ROAMING_MOVE); + + Movement::MoveSplineInit init(owner); + init.MoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ(), _generatePath); + if (_speed > 0.0f) // Default value for point motion type is 0.0, if 0.0 spline will use GetSpeed on unit + init.SetVelocity(_speed); init.Launch(); // Call for creature group update - if (Creature* creature = unit->ToCreature()) + if (Creature* creature = owner->ToCreature()) if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature) - creature->GetFormation()->LeaderMoveTo(i_x, i_y, i_z); + creature->GetFormation()->LeaderMoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ()); } - return !unit->movespline->Finalized(); + return !owner->movespline->Finalized(); } template -void PointMovementGenerator::DoFinalize(T* unit) +void PointMovementGenerator::DoFinalize(T* owner) { - if (unit->HasUnitState(UNIT_STATE_CHARGING)) - unit->ClearUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE); + owner->ClearUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE); - if (unit->movespline->Finalized()) - MovementInform(unit); + if (owner->movespline->Finalized()) + MovementInform(owner); } template -void PointMovementGenerator::DoReset(T* unit) +void PointMovementGenerator::DoReset(T* owner) { - if (!unit->IsStopped()) - unit->StopMoving(); - - unit->AddUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE); + owner->StopMoving(); + DoInitialize(owner); } template -void PointMovementGenerator::MovementInform(T* /*unit*/) { } +void PointMovementGenerator::MovementInform(T*) { } -template <> void PointMovementGenerator::MovementInform(Creature* unit) +template <> +void PointMovementGenerator::MovementInform(Creature* owner) { - if (unit->AI()) - unit->AI()->MovementInform(POINT_MOTION_TYPE, id); + if (owner->AI()) + owner->AI()->MovementInform(POINT_MOTION_TYPE, _movementId); } template void PointMovementGenerator::DoInitialize(Player*); @@ -123,34 +136,36 @@ template void PointMovementGenerator::DoReset(Creature*); template bool PointMovementGenerator::DoUpdate(Player*, uint32); template bool PointMovementGenerator::DoUpdate(Creature*, uint32); -void AssistanceMovementGenerator::Finalize(Unit* unit) +//---- AssistanceMovementGenerator + +void AssistanceMovementGenerator::Finalize(Unit* owner) +{ + owner->ClearUnitState(UNIT_STATE_ROAMING); + owner->StopMoving(); + owner->ToCreature()->SetNoCallAssistance(false); + owner->ToCreature()->CallAssistance(); + if (owner->IsAlive()) + owner->GetMotionMaster()->MoveSeekAssistanceDistract(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY)); +} + +//---- EffectMovementGenerator + +bool EffectMovementGenerator::Update(Unit* owner, uint32 /*diff*/) { - unit->ToCreature()->SetNoCallAssistance(false); - unit->ToCreature()->CallAssistance(); - if (unit->IsAlive()) - unit->GetMotionMaster()->MoveSeekAssistanceDistract(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY)); + return !owner->movespline->Finalized(); } -bool EffectMovementGenerator::Update(Unit* unit, uint32) +void EffectMovementGenerator::Finalize(Unit* owner) { - return !unit->movespline->Finalized(); + MovementInform(owner); } -void EffectMovementGenerator::Finalize(Unit* unit) +void EffectMovementGenerator::MovementInform(Unit* owner) { if (_arrivalSpellId) - unit->CastSpell(ObjectAccessor::GetUnit(*unit, _arrivalSpellTargetGuid), _arrivalSpellId, true); - - if (unit->GetTypeId() != TYPEID_UNIT) - return; - - // Need restore previous movement since we have no proper states system - if (unit->IsAlive() && !unit->HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_FLEEING)) - { - if (Unit* victim = unit->GetVictim()) - unit->GetMotionMaster()->MoveChase(victim); - } + owner->CastSpell(ObjectAccessor::GetUnit(*owner, _arrivalSpellTargetGuid), _arrivalSpellId, true); - if (unit->ToCreature()->AI()) - unit->ToCreature()->AI()->MovementInform(EFFECT_MOTION_TYPE, _id); + if (Creature* creature = owner->ToCreature()) + if (creature->AI()) + creature->AI()->MovementInform(EFFECT_MOTION_TYPE, _pointId); } diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h index 7b5451daa9e..18f552cc1cd 100644 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h @@ -19,7 +19,6 @@ #define TRINITY_POINTMOVEMENTGENERATOR_H #include "MovementGenerator.h" -#include "FollowerReference.h" class Creature; namespace Movement @@ -31,56 +30,54 @@ template class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementGenerator > { public: - PointMovementGenerator(uint32 _id, float _x, float _y, float _z, bool _generatePath, float _speed = 0.0f, Unit const* faceTarget = nullptr, - Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr) : id(_id), - i_x(_x), i_y(_y), i_z(_z), speed(_speed), i_faceTarget(faceTarget), i_spellEffectExtra(spellEffectExtraData), - m_generatePath(_generatePath), i_recalculateSpeed(false) { } +explicit PointMovementGenerator(uint32 id, float x, float y, float z, bool generatePath, float speed = 0.0f, Unit const* faceTarget = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr) : _movementId(id), _destination(x, y, z), _speed(speed), i_faceTarget(faceTarget), i_spellEffectExtra(spellEffectExtraData), _generatePath(generatePath), _recalculateSpeed(false), _interrupt(false) { } + + MovementGeneratorType GetMovementGeneratorType() const override { return POINT_MOTION_TYPE; } void DoInitialize(T*); void DoFinalize(T*); void DoReset(T*); bool DoUpdate(T*, uint32); - void MovementInform(T*); - - void unitSpeedChanged() override { i_recalculateSpeed = true; } - - MovementGeneratorType GetMovementGeneratorType() const override { return POINT_MOTION_TYPE; } + void UnitSpeedChanged() override { _recalculateSpeed = true; } - void GetDestination(float& x, float& y, float& z) const { x = i_x; y = i_y; z = i_z; } private: - uint32 id; - float i_x, i_y, i_z; - float speed; + void MovementInform(T*); + + uint32 _movementId; + Position _destination; + float _speed; Unit const* i_faceTarget; Movement::SpellEffectExtraData const* i_spellEffectExtra; - bool m_generatePath; - bool i_recalculateSpeed; + bool _generatePath; + bool _recalculateSpeed; + bool _interrupt; }; class AssistanceMovementGenerator : public PointMovementGenerator { public: - AssistanceMovementGenerator(float _x, float _y, float _z) : - PointMovementGenerator(0, _x, _y, _z, true) { } + explicit AssistanceMovementGenerator(float _x, float _y, float _z) : PointMovementGenerator(0, _x, _y, _z, true) { } MovementGeneratorType GetMovementGeneratorType() const override { return ASSISTANCE_MOTION_TYPE; } void Finalize(Unit*) override; }; -// Does almost nothing - just doesn't allows previous movegen interrupt current effect. class EffectMovementGenerator : public MovementGenerator { public: - EffectMovementGenerator(uint32 id, uint32 arrivalSpellId = 0, ObjectGuid const& arrivalSpellTargetGuid = ObjectGuid::Empty) - : _id(id), _arrivalSpellId(arrivalSpellId), _arrivalSpellTargetGuid(arrivalSpellTargetGuid) { } + explicit EffectMovementGenerator(uint32 id, uint32 arrivalSpellId = 0, ObjectGuid const& arrivalSpellTargetGuid = ObjectGuid::Empty) : _pointId(id), _arrivalSpellId(arrivalSpellId), _arrivalSpellTargetGuid(arrivalSpellTargetGuid) { } + void Initialize(Unit*) override { } void Finalize(Unit*) override; void Reset(Unit*) override { } bool Update(Unit*, uint32) override; MovementGeneratorType GetMovementGeneratorType() const override { return EFFECT_MOTION_TYPE; } + private: - uint32 _id; + void MovementInform(Unit*); + + uint32 _pointId; uint32 _arrivalSpellId; ObjectGuid _arrivalSpellTargetGuid; }; diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp index 473e63447ed..4c4f8945bfd 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp @@ -16,165 +16,133 @@ */ #include "Creature.h" -#include "RandomMovementGenerator.h" -#include "Map.h" -#include "Util.h" #include "CreatureGroups.h" +#include "Map.h" #include "MoveSplineInit.h" #include "MoveSpline.h" +#include "PathGenerator.h" #include "Random.h" +#include "RandomMovementGenerator.h" -#define RUNNING_CHANCE_RANDOMMV 20 //will be "1 / RUNNING_CHANCE_RANDOMMV" +template +RandomMovementGenerator::~RandomMovementGenerator() { } template<> -void RandomMovementGenerator::_setRandomLocation(Creature* creature) +RandomMovementGenerator::~RandomMovementGenerator() { - if (creature->IsMovementPreventedByCasting()) - { - creature->CastStop(); + delete _path; +} + +template +void RandomMovementGenerator::DoInitialize(T*) { } + +template<> +void RandomMovementGenerator::DoInitialize(Creature* owner) +{ + if (!owner || !owner->IsAlive()) return; - } - float respX, respY, respZ, respO, destX, destY, destZ, travelDistZ; - creature->GetHomePosition(respX, respY, respZ, respO); - Map const* map = creature->GetMap(); + owner->AddUnitState(UNIT_STATE_ROAMING); + owner->GetPosition(_reference.m_positionX, _reference.m_positionY, _reference.m_positionZ); + owner->StopMoving(); + + if (!_wanderDistance) + _wanderDistance = owner->GetRespawnRadius(); - // For 2D/3D system selection - //bool is_land_ok = creature.CanWalk(); // not used? - //bool is_water_ok = creature.CanSwim(); // not used? - bool is_air_ok = creature->CanFly(); + _timer.Reset(0); +} - const float angle = float(rand_norm()) * static_cast(M_PI*2.0f); - const float range = float(rand_norm()) * wander_distance; - const float distanceX = range * std::cos(angle); - const float distanceY = range * std::sin(angle); +template +void RandomMovementGenerator::DoFinalize(T*) { } - destX = respX + distanceX; - destY = respY + distanceY; +template<> +void RandomMovementGenerator::DoFinalize(Creature* owner) +{ + owner->ClearUnitState(UNIT_STATE_ROAMING); + owner->StopMoving(); + owner->SetWalk(false); +} - // prevent invalid coordinates generation - Trinity::NormalizeMapCoord(destX); - Trinity::NormalizeMapCoord(destY); +template +void RandomMovementGenerator::DoReset(T*) { } - travelDistZ = range; // sin^2+cos^2=1, so travelDistZ=range^2; no need for sqrt below +template<> +void RandomMovementGenerator::DoReset(Creature* owner) +{ + DoInitialize(owner); +} - if (is_air_ok) // 3D system above ground and above water (flying mode) - { - // Limit height change - const float distanceZ = float(rand_norm()) * travelDistZ/2.0f; - destZ = respZ + distanceZ; - float levelZ = map->GetWaterOrGroundLevel(creature->GetPhaseShift(), destX, destY, destZ-2.5f); - - // Problem here, we must fly above the ground and water, not under. Let's try on next tick - if (levelZ >= destZ) - return; - } - //else if (is_water_ok) // 3D system under water and above ground (swimming mode) - else // 2D only - { - // 10.0 is the max that vmap high can check (MAX_CAN_FALL_DISTANCE) - travelDistZ = travelDistZ >= 10.0f ? 10.0f : travelDistZ; - - // The fastest way to get an accurate result 90% of the time. - // Better result can be obtained like 99% accuracy with a ray light, but the cost is too high and the code is too long. - destZ = map->GetHeight(creature->GetPhaseShift(), destX, destY, respZ+travelDistZ-2.0f, false); - - if (std::fabs(destZ - respZ) > travelDistZ) // Map check - { - // Vmap Horizontal or above - destZ = map->GetHeight(creature->GetPhaseShift(), destX, destY, respZ - 2.0f, true); - - if (std::fabs(destZ - respZ) > travelDistZ) - { - // Vmap Higher - destZ = map->GetHeight(creature->GetPhaseShift(), destX, destY, respZ+travelDistZ-2.0f, true); - - // let's forget this bad coords where a z cannot be find and retry at next tick - if (std::fabs(destZ - respZ) > travelDistZ) - return; - } - } - } +template +void RandomMovementGenerator::SetRandomLocation(T*) { } - if (is_air_ok) - i_nextMoveTime.Reset(0); - else +template<> +void RandomMovementGenerator::SetRandomLocation(Creature* owner) +{ + if (!owner) + return; + + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting()) { - if (roll_chance_i(50)) - i_nextMoveTime.Reset(urand(5000, 10000)); - else - i_nextMoveTime.Reset(urand(50, 400)); + _interrupt = true; + owner->StopMoving(); + return; } - creature->AddUnitState(UNIT_STATE_ROAMING_MOVE); + owner->AddUnitState(UNIT_STATE_ROAMING_MOVE); - Movement::MoveSplineInit init(creature); - init.MoveTo(destX, destY, destZ); - init.SetWalk(true); - init.Launch(); + Position position(_reference); + float distance = frand(0.f, 1.f) * _wanderDistance; + float angle = frand(0.f, 1.f) * float(M_PI) * 2.f; + owner->MovePositionToFirstCollision(position, distance, angle); - //Call for creature group update - if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature) - creature->GetFormation()->LeaderMoveTo(destX, destY, destZ); -} + uint32 resetTimer = roll_chance_i(50) ? urand(5000, 10000) : urand(1000, 2000); -template<> -void RandomMovementGenerator::DoInitialize(Creature* creature) -{ - if (!creature->IsAlive()) + if (!_path) + _path = new PathGenerator(owner); + + _path->SetPathLengthLimit(30.0f); + bool result = _path->CalculatePath(position.GetPositionX(), position.GetPositionY(), position.GetPositionZ()); + if (!result || (_path->GetPathType() & PATHFIND_NOPATH)) + { + _timer.Reset(100); return; + } - if (!wander_distance) - wander_distance = creature->GetRespawnRadius(); + Movement::MoveSplineInit init(owner); + init.MovebyPath(_path->GetPath()); + init.SetWalk(true); + int32 traveltime = init.Launch(); + _timer.Reset(traveltime + resetTimer); - creature->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE); - _setRandomLocation(creature); + // Call for creature group update + if (owner->GetFormation() && owner->GetFormation()->getLeader() == owner) + owner->GetFormation()->LeaderMoveTo(position.m_positionX, position.m_positionY, position.m_positionZ); } -template<> -void RandomMovementGenerator::DoReset(Creature* creature) +template +bool RandomMovementGenerator::DoUpdate(T*, uint32) { - DoInitialize(creature); + return false; } template<> -void RandomMovementGenerator::DoFinalize(Creature* creature) +bool RandomMovementGenerator::DoUpdate(Creature* owner, uint32 diff) { - creature->ClearUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE); - creature->SetWalk(false); -} - -template<> -bool RandomMovementGenerator::DoUpdate(Creature* creature, const uint32 diff) -{ - if (!creature || !creature->IsAlive()) + if (!owner || !owner->IsAlive()) return false; - if (creature->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED)) + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting()) { - i_nextMoveTime.Reset(0); // Expire the timer - creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE); + _interrupt = true; + owner->StopMoving(); return true; } + else + _interrupt = false; - if (creature->movespline->Finalized()) - { - i_nextMoveTime.Update(diff); - if (i_nextMoveTime.Passed()) - _setRandomLocation(creature); - } - return true; -} - -template<> -bool RandomMovementGenerator::GetResetPos(Creature* creature, float& x, float& y, float& z) -{ - float radius; - creature->GetRespawnPosition(x, y, z, NULL, &radius); - - // use current if in range - if (creature->IsWithinDist2d(x, y, radius)) - creature->GetPosition(x, y, z); + _timer.Update(diff); + if (!_interrupt && _timer.Passed() && owner->movespline->Finalized()) + SetRandomLocation(owner); return true; } diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h index 080c594ea01..a615bec49bc 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h @@ -19,23 +19,30 @@ #define TRINITY_RANDOMMOTIONGENERATOR_H #include "MovementGenerator.h" +#include "Timer.h" template class RandomMovementGenerator : public MovementGeneratorMedium< T, RandomMovementGenerator > { public: - RandomMovementGenerator(float spawn_dist = 0.0f) : i_nextMoveTime(0), wander_distance(spawn_dist) { } + explicit RandomMovementGenerator(float distance = 0.0f) : _path(nullptr), _timer(0), _reference(0.f, 0.f, 0.f), _wanderDistance(distance), _interrupt(false) { } + ~RandomMovementGenerator(); + + MovementGeneratorType GetMovementGeneratorType() const override { return RANDOM_MOTION_TYPE; } - void _setRandomLocation(T*); void DoInitialize(T*); void DoFinalize(T*); void DoReset(T*); - bool DoUpdate(T*, const uint32); - bool GetResetPos(T*, float& x, float& y, float& z); - MovementGeneratorType GetMovementGeneratorType() const override { return RANDOM_MOTION_TYPE; } + bool DoUpdate(T*, uint32); + private: - TimeTrackerSmall i_nextMoveTime; + void SetRandomLocation(T*); - float wander_distance; + PathGenerator* _path; + TimeTracker _timer; + Position _reference; + float _wanderDistance; + bool _interrupt; }; + #endif diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index 54cc97ab418..122156f165e 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -15,226 +15,209 @@ * with this program. If not, see . */ -#include "ByteBuffer.h" -#include "TargetedMovementGenerator.h" -#include "Errors.h" -#include "Creature.h" #include "CreatureAI.h" -#include "World.h" -#include "MoveSplineInit.h" -#include "MoveSpline.h" +#include "Creature.h" #include "Player.h" #include "VehicleDefines.h" +#include "MoveSplineInit.h" +#include "MoveSpline.h" +#include "PathGenerator.h" +#include "World.h" +#include "TargetedMovementGenerator.h" template -void TargetedMovementGeneratorMedium::_setTargetLocation(T* owner, bool updateDestination) +TargetedMovementGenerator::~TargetedMovementGenerator() { - if (!i_target.isValid() || !i_target->IsInWorld()) - return; + delete _path; +} + +template +bool TargetedMovementGenerator::DoUpdate(T* owner, uint32 diff) +{ + if (!IsTargetValid() || !GetTarget()->IsInWorld()) + return false; + + if (!owner || !owner->IsAlive()) + return false; + + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting() || HasLostTarget(owner) + || (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsFocusing(nullptr, true))) + { + _interrupt = true; + owner->StopMoving(); + return true; + } + + if (_interrupt || _recalculateTravel) + { + _interrupt = false; + SetTargetLocation(owner, true); + return true; + } + + bool targetMoved = false; + _timer.Update(diff); + if (!_interrupt && _timer.Passed()) + { + _timer.Reset(100); + + float distance = owner->GetCombatReach() + sWorld->getRate(RATE_TARGET_POS_RECALCULATION_RANGE); + if (owner->IsPet() && (owner->GetCharmerOrOwnerGUID() == GetTarget()->GetGUID())) + distance = 1.f; // pet following owner + + G3D::Vector3 destination = owner->movespline->FinalDestination(); + if (owner->movespline->onTransport) + if (TransportBase* transport = owner->GetDirectTransport()) + transport->CalculatePassengerPosition(destination.x, destination.y, destination.z); + + // First check distance + if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->CanFly()) + targetMoved = !GetTarget()->IsWithinDist3d(destination.x, destination.y, destination.z, distance); + else + targetMoved = !GetTarget()->IsWithinDist2d(destination.x, destination.y, distance); + + // then, if the target is in range, check also Line of Sight. + if (!targetMoved) + targetMoved = !GetTarget()->IsWithinLOSInMap(owner); + } + + if (targetMoved) + SetTargetLocation(owner, targetMoved); + + if (!_targetReached && owner->movespline->Finalized()) + { + MovementInform(owner); + if (_angle == 0.f && !owner->HasInArc(0.01f, GetTarget())) + owner->SetInFront(GetTarget()); + + if (!_targetReached) + { + _targetReached = true; + ReachTarget(owner); + } + } - if (owner->HasUnitState(UNIT_STATE_NOT_MOVE)) + return true; +} + +template +void TargetedMovementGenerator::SetTargetLocation(T* owner, bool updateDestination) +{ + if (!IsTargetValid() || !GetTarget()->IsInWorld()) return; - if (owner->IsMovementPreventedByCasting()) + if (!owner || !owner->IsAlive()) return; - if (owner->GetTypeId() == TYPEID_UNIT && !i_target->isInAccessiblePlaceFor(owner->ToCreature())) + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting() || HasLostTarget(owner) + || (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsFocusing(nullptr, true))) { - owner->ToCreature()->SetCannotReachTarget(true); + _interrupt = true; + owner->StopMoving(); return; } - if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsFocusing(nullptr, true)) + if (owner->GetTypeId() == TYPEID_UNIT && !GetTarget()->isInAccessiblePlaceFor(owner->ToCreature())) + { + owner->ToCreature()->SetCannotReachTarget(true); return; + } float x, y, z; - - if (updateDestination || !i_path) + if (updateDestination || !_path) { - if (!i_offset) + if (!_offset) { - if (i_target->IsWithinDistInMap(owner, CONTACT_DISTANCE)) + if (GetTarget()->IsWithinDistInMap(owner, CONTACT_DISTANCE)) return; - // to nearest contact position - i_target->GetContactPoint(owner, x, y, z); + GetTarget()->GetContactPoint(owner, x, y, z); } else { - float dist; - float size; - - // Pets need special handling. - // We need to subtract GetCombatReach() because it gets added back further down the chain - // and that makes pets too far away. Subtracting it allows pets to properly - // be (GetCombatReach() + i_offset) away. - // Only applies when i_target is pet's owner otherwise pets and mobs end up - // doing a "dance" while fighting - if (owner->IsPet() && i_target->GetTypeId() == TYPEID_PLAYER) - { - dist = 1.0f; //i_target->GetCombatReach(); - size = 1.0f; //i_target->GetCombatReach() - i_target->GetCombatReach(); - } - else + float distance = _offset + 1.0f; + float size = owner->GetCombatReach(); + + if (owner->IsPet() && GetTarget()->GetTypeId() == TYPEID_PLAYER) { - dist = i_offset + 1.0f; - size = owner->GetCombatReach(); + distance = 1.0f; + size = 1.0f; } - if (i_target->IsWithinDistInMap(owner, dist)) + if (GetTarget()->IsWithinDistInMap(owner, distance)) return; - // to at i_offset distance from target and i_angle from target facing - i_target->GetClosePoint(x, y, z, size, i_offset, i_angle); + GetTarget()->GetClosePoint(x, y, z, size, _offset, _angle); } } else { // the destination has not changed, we just need to refresh the path (usually speed change) - G3D::Vector3 end = i_path->GetEndPosition(); + G3D::Vector3 end = _path->GetEndPosition(); x = end.x; y = end.y; z = end.z; } - if (!i_path) - i_path = new PathGenerator(owner); + if (!_path) + _path = new PathGenerator(owner); // allow pets to use shortcut if no path found when following their master - bool forceDest = (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsPet() - && owner->HasUnitState(UNIT_STATE_FOLLOW)); + bool forceDest = (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsPet() && owner->HasUnitState(UNIT_STATE_FOLLOW)); - bool result = i_path->CalculatePath(x, y, z, forceDest); - if (!result || (i_path->GetPathType() & PATHFIND_NOPATH)) + bool result = _path->CalculatePath(x, y, z, forceDest); + if (!result || (_path->GetPathType() & PATHFIND_NOPATH)) { // can't reach target - i_recalculateTravel = true; + _recalculateTravel = true; if (owner->GetTypeId() == TYPEID_UNIT) owner->ToCreature()->SetCannotReachTarget(true); return; } - D::_addUnitStateMove(owner); - i_targetReached = false; - i_recalculateTravel = false; - owner->AddUnitState(UNIT_STATE_CHASE); + _targetReached = false; + _recalculateTravel = false; + + AddUnitStateMove(owner); + if (owner->GetTypeId() == TYPEID_UNIT) owner->ToCreature()->SetCannotReachTarget(false); Movement::MoveSplineInit init(owner); - init.MovebyPath(i_path->GetPath()); - init.SetWalk(((D*)this)->EnableWalking()); + init.MovebyPath(_path->GetPath()); + init.SetWalk(EnableWalking()); // Using the same condition for facing target as the one that is used for SetInFront on movement end // - applies to ChaseMovementGenerator mostly - if (i_angle == 0.f) - init.SetFacing(i_target.getTarget()); + if (_angle == 0.f) + init.SetFacing(GetTarget()); init.Launch(); } template -bool TargetedMovementGeneratorMedium::DoUpdate(T* owner, uint32 time_diff) +bool TargetedMovementGenerator::IsReachable() const { - if (!i_target.isValid() || !i_target->IsInWorld()) - return false; - - if (!owner || !owner->IsAlive()) - return false; - - if (owner->HasUnitState(UNIT_STATE_NOT_MOVE)) - { - D::_clearUnitStateMove(owner); - return true; - } - - // prevent movement while casting spells with cast time or channel time - if (owner->IsMovementPreventedByCasting()) - { - if (!owner->IsStopped()) - owner->StopMoving(); - return true; - } - - // prevent crash after creature killed pet - if (static_cast(this)->_lostTarget(owner)) - { - D::_clearUnitStateMove(owner); - return true; - } - - bool targetMoved = false; - i_recheckDistance.Update(time_diff); - if (i_recheckDistance.Passed()) - { - i_recheckDistance.Reset(100); - - //More distance let have better performance, less distance let have more sensitive reaction at target move. - float allowed_dist = 0.0f; - - if (owner->IsPet() && (owner->GetCharmerOrOwnerGUID() == i_target->GetGUID())) - allowed_dist = 1.0f; // pet following owner - else - allowed_dist = owner->GetCombatReach() + sWorld->getRate(RATE_TARGET_POS_RECALCULATION_RANGE); - - G3D::Vector3 dest = owner->movespline->FinalDestination(); - if (owner->movespline->onTransport) - if (TransportBase* transport = owner->GetDirectTransport()) - transport->CalculatePassengerPosition(dest.x, dest.y, dest.z); - - // First check distance - if (owner->GetTypeId() == TYPEID_UNIT && (owner->ToCreature()->CanFly() || owner->ToCreature()->CanSwim())) - targetMoved = !i_target->IsWithinDist3d(dest.x, dest.y, dest.z, allowed_dist); - else - targetMoved = !i_target->IsWithinDist2d(dest.x, dest.y, allowed_dist); - - // then, if the target is in range, check also Line of Sight. - if (!targetMoved) - targetMoved = !i_target->IsWithinLOSInMap(owner); - } - - if (i_recalculateTravel || targetMoved) - _setTargetLocation(owner, targetMoved); - - if (owner->movespline->Finalized()) - { - static_cast(this)->MovementInform(owner); - if (i_angle == 0.f && !owner->HasInArc(0.01f, i_target.getTarget())) - owner->SetInFront(i_target.getTarget()); - - if (!i_targetReached) - { - i_targetReached = true; - static_cast(this)->_reachTarget(owner); - } - } - - return true; + return (_path) ? (_path->GetPathType() & PATHFIND_NORMAL) : true; } -//-----------------------------------------------// +//---- ChaseMovementGenerator + template -void ChaseMovementGenerator::_reachTarget(T* owner) -{ - _clearUnitStateMove(owner); - if (owner->IsWithinMeleeRange(this->i_target.getTarget())) - owner->Attack(this->i_target.getTarget(), true); - if (owner->GetTypeId() == TYPEID_UNIT) - owner->ToCreature()->SetCannotReachTarget(false); -} +void ChaseMovementGenerator::DoInitialize(T*) { } template<> void ChaseMovementGenerator::DoInitialize(Player* owner) { - owner->AddUnitState(UNIT_STATE_CHASE | UNIT_STATE_CHASE_MOVE); - _setTargetLocation(owner, true); + owner->AddUnitState(UNIT_STATE_CHASE); + SetTargetLocation(owner, true); } template<> void ChaseMovementGenerator::DoInitialize(Creature* owner) { owner->SetWalk(false); - owner->AddUnitState(UNIT_STATE_CHASE | UNIT_STATE_CHASE_MOVE); - _setTargetLocation(owner, true); + owner->AddUnitState(UNIT_STATE_CHASE); + SetTargetLocation(owner, true); } template @@ -250,41 +233,60 @@ void ChaseMovementGenerator::DoReset(T* owner) } template -void ChaseMovementGenerator::MovementInform(T* /*unit*/) { } +void ChaseMovementGenerator::ClearUnitStateMove(T* owner) +{ + owner->ClearUnitState(UNIT_STATE_CHASE_MOVE); +} -template<> -void ChaseMovementGenerator::MovementInform(Creature* unit) +template +void ChaseMovementGenerator::AddUnitStateMove(T* owner) { - // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle - if (unit->AI()) - unit->AI()->MovementInform(CHASE_MOTION_TYPE, i_target.getTarget()->GetGUID().GetCounter()); + owner->AddUnitState(UNIT_STATE_CHASE_MOVE); } -//-----------------------------------------------// -template<> -bool FollowMovementGenerator::EnableWalking() const +template +bool ChaseMovementGenerator::HasLostTarget(T* owner) const { - return i_target.isValid() && i_target->IsWalking(); + return owner->GetVictim() != TargetedMovementGeneratorBase::GetTarget(); } -template<> -bool FollowMovementGenerator::EnableWalking() const +template +void ChaseMovementGenerator::ReachTarget(T* owner) { - return false; + ClearUnitStateMove(owner); + + if (owner->IsWithinMeleeRange(TargetedMovementGeneratorBase::GetTarget())) + owner->Attack(TargetedMovementGeneratorBase::GetTarget(), true); + + if (owner->GetTypeId() == TYPEID_UNIT) + owner->ToCreature()->SetCannotReachTarget(false); } +template +void ChaseMovementGenerator::MovementInform(T*) { } + template<> -void FollowMovementGenerator::_updateSpeed(Player* /*owner*/) +void ChaseMovementGenerator::MovementInform(Creature* owner) { - // nothing to do for Player + // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle + if (owner->AI()) + owner->AI()->MovementInform(CHASE_MOTION_TYPE, GetTarget()->GetGUID().GetCounter()); } +//---- FollowMovementGenerator + +template +void FollowMovementGenerator::UpdateSpeed(T*) { } + +template<> +void FollowMovementGenerator::UpdateSpeed(Player* /*owner*/) { } + template<> -void FollowMovementGenerator::_updateSpeed(Creature* owner) +void FollowMovementGenerator::UpdateSpeed(Creature* owner) { - // pet only sync speed with owner - /// Make sure we are not in the process of a map change (IsInWorld) - if (!owner->IsPet() || !owner->IsInWorld() || !i_target.isValid() || i_target->GetGUID() != owner->GetOwnerGUID()) + // Pet only sync speed with owner + // Make sure we are not in the process of a map change (IsInWorld) + if (!owner->IsPet() || !owner->IsInWorld() || !IsTargetValid() || GetTarget()->GetGUID() != owner->GetOwnerGUID()) return; owner->UpdateSpeed(MOVE_RUN); @@ -292,27 +294,19 @@ void FollowMovementGenerator::_updateSpeed(Creature* owner) owner->UpdateSpeed(MOVE_SWIM); } -template<> -void FollowMovementGenerator::DoInitialize(Player* owner) -{ - owner->AddUnitState(UNIT_STATE_FOLLOW | UNIT_STATE_FOLLOW_MOVE); - _updateSpeed(owner); - _setTargetLocation(owner, true); -} - -template<> -void FollowMovementGenerator::DoInitialize(Creature* owner) +template +void FollowMovementGenerator::DoInitialize(T* owner) { - owner->AddUnitState(UNIT_STATE_FOLLOW | UNIT_STATE_FOLLOW_MOVE); - _updateSpeed(owner); - _setTargetLocation(owner, true); + owner->AddUnitState(UNIT_STATE_FOLLOW); + UpdateSpeed(owner); + TargetedMovementGenerator>::SetTargetLocation(owner, true); } template void FollowMovementGenerator::DoFinalize(T* owner) { owner->ClearUnitState(UNIT_STATE_FOLLOW | UNIT_STATE_FOLLOW_MOVE); - _updateSpeed(owner); + UpdateSpeed(owner); } template @@ -322,36 +316,85 @@ void FollowMovementGenerator::DoReset(T* owner) } template -void FollowMovementGenerator::MovementInform(T* /*unit*/) { } +void FollowMovementGenerator::ClearUnitStateMove(T* owner) +{ + owner->ClearUnitState(UNIT_STATE_FOLLOW_MOVE); +} + +template +void FollowMovementGenerator::AddUnitStateMove(T* owner) +{ + owner->AddUnitState(UNIT_STATE_FOLLOW_MOVE); +} + +template +void FollowMovementGenerator::ReachTarget(T* owner) +{ + ClearUnitStateMove(owner); +} + +template<> +bool FollowMovementGenerator::EnableWalking() const +{ + return IsTargetValid() && GetTarget()->IsWalking(); +} + +template<> +bool FollowMovementGenerator::EnableWalking() const +{ + return false; +} + +template +void FollowMovementGenerator::MovementInform(T*) { } template<> void FollowMovementGenerator::MovementInform(Creature* unit) { // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle if (unit->AI()) - unit->AI()->MovementInform(FOLLOW_MOTION_TYPE, i_target.getTarget()->GetGUID().GetCounter()); + unit->AI()->MovementInform(FOLLOW_MOTION_TYPE, GetTarget()->GetGUID().GetCounter()); } //-----------------------------------------------// -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player*, bool); -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player*, bool); -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature*, bool); -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature*, bool); -template bool TargetedMovementGeneratorMedium >::DoUpdate(Player*, uint32); -template bool TargetedMovementGeneratorMedium >::DoUpdate(Player*, uint32); -template bool TargetedMovementGeneratorMedium >::DoUpdate(Creature*, uint32); -template bool TargetedMovementGeneratorMedium >::DoUpdate(Creature*, uint32); - -template void ChaseMovementGenerator::_reachTarget(Player*); -template void ChaseMovementGenerator::_reachTarget(Creature*); + +template TargetedMovementGenerator >::~TargetedMovementGenerator(); +template TargetedMovementGenerator >::~TargetedMovementGenerator(); +template TargetedMovementGenerator >::~TargetedMovementGenerator(); +template TargetedMovementGenerator >::~TargetedMovementGenerator(); +template bool TargetedMovementGenerator >::DoUpdate(Player*, uint32); +template bool TargetedMovementGenerator >::DoUpdate(Player*, uint32); +template bool TargetedMovementGenerator >::DoUpdate(Creature*, uint32); +template bool TargetedMovementGenerator >::DoUpdate(Creature*, uint32); +template void TargetedMovementGenerator >::SetTargetLocation(Player*, bool); +template void TargetedMovementGenerator >::SetTargetLocation(Player*, bool); +template void TargetedMovementGenerator >::SetTargetLocation(Creature*, bool); +template void TargetedMovementGenerator >::SetTargetLocation(Creature*, bool); + template void ChaseMovementGenerator::DoFinalize(Player*); template void ChaseMovementGenerator::DoFinalize(Creature*); template void ChaseMovementGenerator::DoReset(Player*); template void ChaseMovementGenerator::DoReset(Creature*); +template void ChaseMovementGenerator::ClearUnitStateMove(Player*); +template void ChaseMovementGenerator::ClearUnitStateMove(Creature*); +template void ChaseMovementGenerator::AddUnitStateMove(Player*); +template void ChaseMovementGenerator::AddUnitStateMove(Creature*); +template bool ChaseMovementGenerator::HasLostTarget(Player*) const; +template bool ChaseMovementGenerator::HasLostTarget(Creature*) const; +template void ChaseMovementGenerator::ReachTarget(Player*); +template void ChaseMovementGenerator::ReachTarget(Creature*); template void ChaseMovementGenerator::MovementInform(Player*); +template void FollowMovementGenerator::DoInitialize(Player*); +template void FollowMovementGenerator::DoInitialize(Creature*); template void FollowMovementGenerator::DoFinalize(Player*); template void FollowMovementGenerator::DoFinalize(Creature*); template void FollowMovementGenerator::DoReset(Player*); template void FollowMovementGenerator::DoReset(Creature*); +template void FollowMovementGenerator::ClearUnitStateMove(Player*); +template void FollowMovementGenerator::ClearUnitStateMove(Creature*); +template void FollowMovementGenerator::AddUnitStateMove(Player*); +template void FollowMovementGenerator::AddUnitStateMove(Creature*); +template void FollowMovementGenerator::ReachTarget(Player*); +template void FollowMovementGenerator::ReachTarget(Creature*); template void FollowMovementGenerator::MovementInform(Player*); diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h index 79a1c7952db..2bd04e292f4 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h @@ -21,95 +21,93 @@ #include "MovementGenerator.h" #include "FollowerReference.h" #include "Timer.h" -#include "Unit.h" -#include "PathGenerator.h" class TargetedMovementGeneratorBase { public: - TargetedMovementGeneratorBase(Unit* target) { i_target.link(target, this); } + TargetedMovementGeneratorBase(Unit* target) + { + _target.link(target, this); + } + + bool IsTargetValid() const { return _target.isValid(); } + Unit* GetTarget() const { return _target.getTarget(); } void stopFollowing() { } - protected: - FollowerReference i_target; + + private: + FollowerReference _target; }; template -class TargetedMovementGeneratorMedium : public MovementGeneratorMedium< T, D >, public TargetedMovementGeneratorBase +class TargetedMovementGenerator : public MovementGeneratorMedium< T, D >, public TargetedMovementGeneratorBase { - protected: - TargetedMovementGeneratorMedium(Unit* target, float offset, float angle) : - TargetedMovementGeneratorBase(target), i_path(NULL), - i_recheckDistance(0), i_offset(offset), i_angle(angle), - i_recalculateTravel(false), i_targetReached(false) - { - } - ~TargetedMovementGeneratorMedium() { delete i_path; } - public: + explicit TargetedMovementGenerator(Unit* target, float offset, float angle) : TargetedMovementGeneratorBase(target), _path(nullptr), _timer(0), _offset(offset), _angle(angle), _recalculateTravel(false), _targetReached(false), _interrupt(false) { } + ~TargetedMovementGenerator(); + bool DoUpdate(T*, uint32); - Unit* GetTarget() const { return i_target.getTarget(); } - - void unitSpeedChanged() override { i_recalculateTravel = true; } - bool IsReachable() const { return (i_path) ? (i_path->GetPathType() & PATHFIND_NORMAL) : true; } - protected: - void _setTargetLocation(T* owner, bool updateDestination); - - PathGenerator* i_path; - TimeTrackerSmall i_recheckDistance; - float i_offset; - float i_angle; - bool i_recalculateTravel : 1; - bool i_targetReached : 1; + + void UnitSpeedChanged() override { _recalculateTravel = true; } + + virtual void ClearUnitStateMove(T*) { } + virtual void AddUnitStateMove(T*) { } + virtual bool HasLostTarget(T*) const { return false; } + virtual void ReachTarget(T*) { } + virtual bool EnableWalking() const { return false; } + virtual void MovementInform(T*) { } + + bool IsReachable() const; + void SetTargetLocation(T* owner, bool updateDestination); + + private: + PathGenerator* _path; + TimeTrackerSmall _timer; + float _offset; + float _angle; + bool _recalculateTravel; + bool _targetReached; + bool _interrupt; }; template -class ChaseMovementGenerator : public TargetedMovementGeneratorMedium > +class ChaseMovementGenerator : public TargetedMovementGenerator > { public: - ChaseMovementGenerator(Unit* target) - : TargetedMovementGeneratorMedium >(target) { } - ChaseMovementGenerator(Unit* target, float offset, float angle) - : TargetedMovementGeneratorMedium >(target, offset, angle) { } - ~ChaseMovementGenerator() { } + explicit ChaseMovementGenerator(Unit* target, float offset, float angle) : TargetedMovementGenerator >(target, offset, angle) { } MovementGeneratorType GetMovementGeneratorType() const override { return CHASE_MOTION_TYPE; } void DoInitialize(T*); void DoFinalize(T*); void DoReset(T*); - void MovementInform(T*); - static void _clearUnitStateMove(T* u) { u->ClearUnitState(UNIT_STATE_CHASE_MOVE); } - static void _addUnitStateMove(T* u) { u->AddUnitState(UNIT_STATE_CHASE_MOVE); } - bool EnableWalking() const { return false;} - bool _lostTarget(T* u) const { return u->GetVictim() != this->GetTarget(); } - void _reachTarget(T*); + void ClearUnitStateMove(T*) override; + void AddUnitStateMove(T*) override; + bool HasLostTarget(T*) const override; + void ReachTarget(T*) override; + void MovementInform(T*) override; }; template -class FollowMovementGenerator : public TargetedMovementGeneratorMedium > +class FollowMovementGenerator : public TargetedMovementGenerator > { public: - FollowMovementGenerator(Unit* target) - : TargetedMovementGeneratorMedium >(target){ } - FollowMovementGenerator(Unit* target, float offset, float angle) - : TargetedMovementGeneratorMedium >(target, offset, angle) { } - ~FollowMovementGenerator() { } + explicit FollowMovementGenerator(Unit* target, float offset, float angle) : TargetedMovementGenerator >(target, offset, angle) { } MovementGeneratorType GetMovementGeneratorType() const override { return FOLLOW_MOTION_TYPE; } void DoInitialize(T*); void DoFinalize(T*); void DoReset(T*); - void MovementInform(T*); - static void _clearUnitStateMove(T* u) { u->ClearUnitState(UNIT_STATE_FOLLOW_MOVE); } - static void _addUnitStateMove(T* u) { u->AddUnitState(UNIT_STATE_FOLLOW_MOVE); } - bool EnableWalking() const; - bool _lostTarget(T*) const { return false; } - void _reachTarget(T*) { } + void ClearUnitStateMove(T*) override; + void AddUnitStateMove(T*) override; + bool HasLostTarget(T*) const override { return false; } + void ReachTarget(T*) override; + bool EnableWalking() const override; + void MovementInform(T*) override; private: - void _updateSpeed(T* owner); + void UpdateSpeed(T* owner); }; #endif -- cgit v1.2.3 From c31f875cc8e7870659a1c9bd565d37b334e5dba8 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sat, 8 Apr 2017 20:59:48 +0200 Subject: Core/Misc: Fix static analysis issues (cherry picked from commit 3c4c67160afbe15cc48e5390201157c416cb9a09) --- src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp | 6 +----- src/server/game/Time/UpdateTime.cpp | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index 25400dd00b4..ec3e7488400 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -721,8 +721,7 @@ void BattlegroundEY::EventTeamLostPoint(Player* player, uint32 Point) UpdatePointsCount(Team); //remove bonus honor aura trigger creature when node is lost - if (Point < EY_POINTS_MAX) - DelCreature(Point + 6);//NULL checks are in DelCreature! 0-5 spirit guides + DelCreature(Point + 6);//NULL checks are in DelCreature! 0-5 spirit guides } void BattlegroundEY::EventTeamCapturedPoint(Player* player, uint32 Point) @@ -774,9 +773,6 @@ void BattlegroundEY::EventTeamCapturedPoint(Player* player, uint32 Point) UpdatePointsIcons(Team, Point); UpdatePointsCount(Team); - if (Point >= EY_POINTS_MAX) - return; - Creature* trigger = GetBGCreature(Point + 6, false);//0-5 spirit guides if (!trigger) trigger = AddCreature(WORLD_TRIGGER, Point+6, BG_EY_TriggerPositions[Point], GetTeamIndexByTeamId(Team)); diff --git a/src/server/game/Time/UpdateTime.cpp b/src/server/game/Time/UpdateTime.cpp index ffd985c2caf..6f3f5d6ff83 100644 --- a/src/server/game/Time/UpdateTime.cpp +++ b/src/server/game/Time/UpdateTime.cpp @@ -31,6 +31,7 @@ UpdateTime::UpdateTime() _maxUpdateTime = 0; _maxUpdateTimeOfLastTable = 0; _maxUpdateTimeOfCurrentTable = 0; + _recordedTime = 0; _updateTimeDataTable = { }; } -- cgit v1.2.3 From 84df2c57a385df4503fc1f8ff5dfdf445ea2e31f Mon Sep 17 00:00:00 2001 From: ccrs Date: Sun, 9 Apr 2017 14:13:29 +0200 Subject: Core/Movement: FormationMovementGenerator Use own movement generator for creatures following on a formation. First step of implementation, huge room for improvement. Closes #19422 (cherry picked from commit 46221b6dc1272989e0de85a4563fc49dba8e7851) --- .../game/Entities/Creature/CreatureGroups.cpp | 11 +- src/server/game/Entities/Creature/CreatureGroups.h | 3 +- src/server/game/Movement/MotionMaster.cpp | 10 ++ src/server/game/Movement/MotionMaster.h | 3 + .../FormationMovementGenerator.cpp | 130 +++++++++++++++++++++ .../FormationMovementGenerator.h | 49 ++++++++ .../MovementGenerators/PointMovementGenerator.cpp | 4 +- .../MovementGenerators/RandomMovementGenerator.cpp | 2 +- .../WaypointMovementGenerator.cpp | 15 +-- 9 files changed, 210 insertions(+), 17 deletions(-) create mode 100644 src/server/game/Movement/MovementGenerators/FormationMovementGenerator.cpp create mode 100644 src/server/game/Movement/MovementGenerators/FormationMovementGenerator.h (limited to 'src') diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index 1643a712f8e..07547ae9139 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -224,13 +224,15 @@ void CreatureGroup::FormationReset(bool dismiss) m_Formed = !dismiss; } -void CreatureGroup::LeaderMoveTo(float x, float y, float z) +void CreatureGroup::LeaderMoveTo(Position destination, uint32 id /*= 0*/, uint32 moveType /*= 0*/, bool orientation /*= false*/) { //! To do: This should probably get its own movement generator or use WaypointMovementGenerator. //! If the leader's path is known, member's path can be plotted as well using formation offsets. if (!m_leader) return; + float x = destination.GetPositionX(), y = destination.GetPositionY(), z = destination.GetPositionZ(); + float pathangle = std::atan2(m_leader->GetPositionY() - y, m_leader->GetPositionX() - x); for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) @@ -256,12 +258,9 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z) if (!member->IsFlying()) member->UpdateGroundPositionZ(dx, dy, dz); - if (member->IsWithinDist(m_leader, dist + MAX_DESYNC)) - member->SetUnitMovementFlags(m_leader->GetUnitMovementFlags()); - else - member->SetWalk(false); + Position point(dx, dy, dz, destination.GetOrientation()); - member->GetMotionMaster()->MovePoint(0, dx, dy, dz); + member->GetMotionMaster()->MoveFormation(id, point, moveType, !member->IsWithinDist(m_leader, dist + MAX_DESYNC), orientation); member->SetHomePosition(dx, dy, dz, pathangle); } } diff --git a/src/server/game/Entities/Creature/CreatureGroups.h b/src/server/game/Entities/Creature/CreatureGroups.h index 38e86ea4c12..85eb7454432 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.h +++ b/src/server/game/Entities/Creature/CreatureGroups.h @@ -19,6 +19,7 @@ #define _FORMATIONS_H #include "Define.h" +#include "Position.h" #include "ObjectGuid.h" #include #include @@ -87,7 +88,7 @@ class TC_GAME_API CreatureGroup void RemoveMember(Creature* member); void FormationReset(bool dismiss); - void LeaderMoveTo(float x, float y, float z); + void LeaderMoveTo(Position destination, uint32 id = 0, uint32 moveType = 0, bool orientation = false); void MemberAttackStart(Creature* member, Unit* target); }; diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index b124edb22d1..3b446733bbb 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -30,6 +30,7 @@ #include "WaypointMovementGenerator.h" #include "RandomMovementGenerator.h" #include "SplineChainMovementGenerator.h" +#include "FormationMovementGenerator.h" #include "MoveSpline.h" #include "MoveSplineInit.h" #include "PathGenerator.h" @@ -711,6 +712,15 @@ void MotionMaster::MoveRotate(uint32 time, RotateDirection direction) Mutate(new RotateMovementGenerator(time, direction), MOTION_SLOT_ACTIVE); } +void MotionMaster::MoveFormation(uint32 id, Position destination, uint32 moveType, bool forceRun /*= false*/, bool forceOrientation /*= false*/) +{ + if (_owner->GetTypeId() == TYPEID_UNIT) + { + TC_LOG_DEBUG("misc", "MotionMaster::MoveFormation: Creature (Entry: %u %s) targeted point (Id: %u X: %f Y: %f Z: %f).", _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), id, destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ()); + Mutate(new FormationMovementGenerator(id, destination, moveType, forceRun, forceOrientation), MOTION_SLOT_ACTIVE); + } +} + /******************** Private methods ********************/ void MotionMaster::pop() diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index 8a3f8e5d0b2..7cb72c353f7 100644 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -66,6 +66,7 @@ enum MovementGeneratorType : uint8 ROTATE_MOTION_TYPE = 15, EFFECT_MOTION_TYPE = 16, SPLINE_CHAIN_MOTION_TYPE = 17, // SplineChainMovementGenerator.h + FORMATION_MOTION_TYPE = 18, // FormationMovementGenerator.h MAX_MOTION_TYPE // limit }; @@ -176,6 +177,8 @@ class TC_GAME_API MotionMaster void MovePath(uint32 path_id, bool repeatable); void MoveRotate(uint32 time, RotateDirection direction); + void MoveFormation(uint32 id, Position destination, uint32 moveType, bool forceRun = false, bool forceOrientation = false); + private: typedef std::vector MovementList; diff --git a/src/server/game/Movement/MovementGenerators/FormationMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FormationMovementGenerator.cpp new file mode 100644 index 00000000000..a1382ec673e --- /dev/null +++ b/src/server/game/Movement/MovementGenerators/FormationMovementGenerator.cpp @@ -0,0 +1,130 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * 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 . + */ + +#include "Creature.h" +#include "CreatureAI.h" +#include "MoveSplineInit.h" +#include "MoveSpline.h" +#include "FormationMovementGenerator.h" + +void FormationMovementGenerator::DoInitialize(Creature* owner) +{ + owner->AddUnitState(UNIT_STATE_ROAMING); + + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting()) + { + _interrupt = true; + owner->StopMoving(); + return; + } + + owner->AddUnitState(UNIT_STATE_ROAMING_MOVE); + + Movement::MoveSplineInit init(owner); + init.MoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ()); + if (_orientation) + init.SetFacing(_destination.GetOrientation()); + + switch (_moveType) + { + case 2: // WAYPOINT_MOVE_TYPE_LAND + init.SetAnimation(Movement::ToGround); + break; + case 3: // WAYPOINT_MOVE_TYPE_TAKEOFF + init.SetAnimation(Movement::ToFly); + break; + case 1: // WAYPOINT_MOVE_TYPE_RUN + init.SetWalk(false); + break; + case 0: // WAYPOINT_MOVE_TYPE_WALK + init.SetWalk(true); + break; + } + + if (_run) + init.SetWalk(false); + + init.Launch(); +} + +bool FormationMovementGenerator::DoUpdate(Creature* owner, uint32 /*diff*/) +{ + if (!owner) + return false; + + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting()) + { + _interrupt = true; + owner->StopMoving(); + return true; + } + + if ((_interrupt && owner->movespline->Finalized()) || (_recalculateSpeed && !owner->movespline->Finalized())) + { + _recalculateSpeed = false; + _interrupt = false; + + owner->AddUnitState(UNIT_STATE_ROAMING_MOVE); + + Movement::MoveSplineInit init(owner); + init.MoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ()); + if (_orientation) + init.SetFacing(_destination.GetOrientation()); + + switch (_moveType) + { + case 2: // WAYPOINT_MOVE_TYPE_LAND + init.SetAnimation(Movement::ToGround); + break; + case 3: // WAYPOINT_MOVE_TYPE_TAKEOFF + init.SetAnimation(Movement::ToFly); + break; + case 1: // WAYPOINT_MOVE_TYPE_RUN + init.SetWalk(false); + break; + case 0: // WAYPOINT_MOVE_TYPE_WALK + init.SetWalk(true); + break; + } + + if (_run) + init.SetWalk(false); + init.Launch(); + } + + return !owner->movespline->Finalized(); +} + +void FormationMovementGenerator::DoFinalize(Creature* owner) +{ + owner->ClearUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE); + + if (owner->movespline->Finalized()) + MovementInform(owner); +} + +void FormationMovementGenerator::DoReset(Creature* owner) +{ + owner->StopMoving(); + DoInitialize(owner); +} + +void FormationMovementGenerator::MovementInform(Creature* owner) +{ + if (owner->AI()) + owner->AI()->MovementInform(FORMATION_MOTION_TYPE, _movementId); +} diff --git a/src/server/game/Movement/MovementGenerators/FormationMovementGenerator.h b/src/server/game/Movement/MovementGenerators/FormationMovementGenerator.h new file mode 100644 index 00000000000..27ab7d50da5 --- /dev/null +++ b/src/server/game/Movement/MovementGenerators/FormationMovementGenerator.h @@ -0,0 +1,49 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * 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 . + */ + +#ifndef TRINITY_FORMATIONMOVEMENTGENERATOR_H +#define TRINITY_FORMATIONMOVEMENTGENERATOR_H + +#include "MovementGenerator.h" + +class FormationMovementGenerator : public MovementGeneratorMedium< Creature, FormationMovementGenerator > +{ + public: + explicit FormationMovementGenerator(uint32 id, Position destination, uint32 moveType, bool run, bool orientation) : _movementId(id), _destination(destination), _moveType(moveType), _run(run), _orientation(orientation), _recalculateSpeed(false), _interrupt(false) { } + + MovementGeneratorType GetMovementGeneratorType() const override { return FORMATION_MOTION_TYPE; } + + void DoInitialize(Creature*); + void DoFinalize(Creature*); + void DoReset(Creature*); + bool DoUpdate(Creature*, uint32); + + void UnitSpeedChanged() override { _recalculateSpeed = true; } + + private: + void MovementInform(Creature*); + + uint32 _movementId; + Position _destination; + uint32 _moveType; + bool _run; + bool _orientation; + bool _recalculateSpeed; + bool _interrupt; +}; + +#endif // TRINITY_FORMATIONMOVEMENTGENERATOR_H diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp index 9c2567ad6a3..ff3a2699128 100755 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp @@ -60,7 +60,7 @@ void PointMovementGenerator::DoInitialize(T* owner) // Call for creature group update if (Creature* creature = owner->ToCreature()) if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature) - creature->GetFormation()->LeaderMoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ()); + creature->GetFormation()->LeaderMoveTo(_destination, _movementId); } template @@ -95,7 +95,7 @@ bool PointMovementGenerator::DoUpdate(T* owner, uint32 /*diff*/) // Call for creature group update if (Creature* creature = owner->ToCreature()) if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature) - creature->GetFormation()->LeaderMoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ()); + creature->GetFormation()->LeaderMoveTo(_destination, _movementId); } return !owner->movespline->Finalized(); diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp index 4c4f8945bfd..7b0025d644f 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp @@ -116,7 +116,7 @@ void RandomMovementGenerator::SetRandomLocation(Creature* owner) // Call for creature group update if (owner->GetFormation() && owner->GetFormation()->getLeader() == owner) - owner->GetFormation()->LeaderMoveTo(position.m_positionX, position.m_positionY, position.m_positionZ); + owner->GetFormation()->LeaderMoveTo(position); } template diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index 9f07641d74d..0a01d7f3a96 100644 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -139,7 +139,7 @@ bool WaypointMovementGenerator::StartMove(Creature* creature) creature->AddUnitState(UNIT_STATE_ROAMING_MOVE); - Movement::Location formationDest(node->x, node->y, node->z, 0.0f); + Position formationDest(node->x, node->y, node->z, (node->orientation && node->delay) ? node->orientation : 0.0f); Movement::MoveSplineInit init(creature); //! If creature is on transport, we assume waypoints set in DB are already transport offsets @@ -147,7 +147,11 @@ bool WaypointMovementGenerator::StartMove(Creature* creature) { init.DisableTransportPathTransformations(); if (TransportBase* trans = creature->GetDirectTransport()) - trans->CalculatePassengerPosition(formationDest.x, formationDest.y, formationDest.z, &formationDest.orientation); + { + float orientation = formationDest.GetOrientation(); + trans->CalculatePassengerPosition(formationDest.m_positionX, formationDest.m_positionY, formationDest.m_positionZ, &orientation); + formationDest.SetOrientation(orientation); + } } //! Do not use formationDest here, MoveTo requires transport offsets due to DisableTransportPathTransformations() call @@ -176,12 +180,9 @@ bool WaypointMovementGenerator::StartMove(Creature* creature) init.Launch(); - //Call for creature group update + // Call for creature group update if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature) - { - creature->SetWalk(node->move_type != WAYPOINT_MOVE_TYPE_RUN); - creature->GetFormation()->LeaderMoveTo(formationDest.x, formationDest.y, formationDest.z); - } + creature->GetFormation()->LeaderMoveTo(formationDest, node->id, node->move_type, (node->orientation && node->delay) ? true : false); return true; } -- cgit v1.2.3 From 304eeea570c153ea1b9598eb7b15b0e2ec2b8399 Mon Sep 17 00:00:00 2001 From: Keader Date: Sun, 9 Apr 2017 09:25:58 -0300 Subject: Core/Scripts: Baltharus the Warborn preincrement _cloneCount (cherry picked from commit 2921449a333ea27a62c7b21d003650421c982917) --- .../ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp index 445404ce961..1440f800260 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp @@ -150,7 +150,7 @@ class boss_baltharus_the_warborn : public CreatureScript { if (me->HealthBelowPctDamaged(50, damage) && _cloneCount == 0) { - _cloneCount++; + ++_cloneCount; events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); } } @@ -158,12 +158,12 @@ class boss_baltharus_the_warborn : public CreatureScript { if (me->HealthBelowPctDamaged(66, damage) && _cloneCount == 0) { - _cloneCount++; + ++_cloneCount; events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); } else if (me->HealthBelowPctDamaged(33, damage) && _cloneCount == 1) { - _cloneCount++; + ++_cloneCount; events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); } } -- cgit v1.2.3 From 9e945615bc9967cc1f49c801c708cf5881cd8de9 Mon Sep 17 00:00:00 2001 From: ariel- Date: Sun, 9 Apr 2017 18:43:35 -0300 Subject: Core/Quest: fix RewardNextQuest being used to condition previous quests in chain (cherry picked from commit 214b8e53c5598695915c1392702e059d79cfc260) --- src/server/game/Entities/Player/Player.cpp | 36 ++---------------------------- src/server/game/Entities/Player/Player.h | 1 - src/server/game/Globals/ObjectMgr.cpp | 6 ++--- src/server/game/Quests/QuestDef.h | 1 - 4 files changed, 4 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 958d636f70c..be4dfa08e24 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -15209,7 +15209,7 @@ bool Player::CanSeeStartQuest(Quest const* quest) if (!DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) && SatisfyQuestClass(quest, false) && SatisfyQuestRace(quest, false) && SatisfyQuestSkill(quest, false) && SatisfyQuestExclusiveGroup(quest, false) && SatisfyQuestReputation(quest, false) && SatisfyQuestDependentQuests(quest, false) && SatisfyQuestNextChain(quest, false) && - SatisfyQuestPrevChain(quest, false) && SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) && + SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) && SatisfyQuestMonth(quest, false) && SatisfyQuestSeasonal(quest, false)) { return int32(getLevel() + sWorld->getIntConfig(CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF)) >= GetQuestMinLevel(quest); @@ -15225,7 +15225,7 @@ bool Player::CanTakeQuest(Quest const* quest, bool msg) && SatisfyQuestClass(quest, msg) && SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg) && SatisfyQuestSkill(quest, msg) && SatisfyQuestReputation(quest, msg) && SatisfyQuestDependentQuests(quest, msg) && SatisfyQuestTimed(quest, msg) - && SatisfyQuestNextChain(quest, msg) && SatisfyQuestPrevChain(quest, msg) + && SatisfyQuestNextChain(quest, msg) && SatisfyQuestDay(quest, msg) && SatisfyQuestWeek(quest, msg) && SatisfyQuestMonth(quest, msg) && SatisfyQuestSeasonal(quest, msg) && SatisfyQuestConditions(quest, msg); @@ -16386,38 +16386,6 @@ bool Player::SatisfyQuestNextChain(Quest const* qInfo, bool msg) const return true; } -bool Player::SatisfyQuestPrevChain(Quest const* qInfo, bool msg) -{ - // No previous quest in chain - if (qInfo->PrevChainQuests.empty()) - return true; - - for (uint32 prevQuestId : qInfo->PrevChainQuests) - { - auto itr = m_QuestStatus.find(prevQuestId); - - // If any of the previous quests in chain active, return false - if (itr != m_QuestStatus.end() && itr->second.Status != QUEST_STATUS_NONE) - { - if (msg) - { - SendCanTakeQuestResponse(QUEST_ERR_NONE); - TC_LOG_DEBUG("misc", "Player::SatisfyQuestNextChain: Sent QUEST_ERR_NONE (QuestID: %u) because player '%s' (%s) already did or started next quest in chain.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); - } - return false; - } - - // check for all quests further down the chain - // only necessary if there are quest chains with more than one quest that can be skipped - //if (!SatisfyQuestPrevChain(prevId, msg)) - // return false; - } - - // No previous quest in chain active - return true; -} - bool Player::SatisfyQuestDay(Quest const* qInfo, bool /*msg*/) const { if (!qInfo->IsDaily() && !qInfo->IsDFQuest()) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index cd43d319960..9f56b7f91b5 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1353,7 +1353,6 @@ class TC_GAME_API Player : public Unit, public GridObject bool SatisfyQuestTimed(Quest const* qInfo, bool msg) const; bool SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const; bool SatisfyQuestNextChain(Quest const* qInfo, bool msg) const; - bool SatisfyQuestPrevChain(Quest const* qInfo, bool msg); bool SatisfyQuestDay(Quest const* qInfo, bool msg) const; bool SatisfyQuestWeek(Quest const* qInfo, bool msg) const; bool SatisfyQuestMonth(Quest const* qInfo, bool msg) const; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 4ab04447914..57922dd84eb 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -4529,8 +4529,6 @@ void ObjectMgr::LoadQuests() qinfo->GetQuestId(), qinfo->_nextQuestInChain, qinfo->_nextQuestInChain); qinfo->_nextQuestInChain = 0; } - else - qNextItr->second->PrevChainQuests.push_back(qinfo->GetQuestId()); } for (uint8 j = 0; j < QUEST_REWARD_CURRENCY_COUNT; ++j) @@ -4617,9 +4615,9 @@ void ObjectMgr::LoadQuests() if (qinfo->_nextQuestID) { - auto qNextItr = _questTemplates.find(qinfo->GetNextQuestId()); + auto qNextItr = _questTemplates.find(qinfo->_nextQuestID); if (qNextItr == _questTemplates.end()) - TC_LOG_ERROR("sql.sql", "Quest %d has NextQuestId %u, but no such quest", qinfo->GetQuestId(), qinfo->GetNextQuestId()); + TC_LOG_ERROR("sql.sql", "Quest %d has NextQuestId %u, but no such quest", qinfo->GetQuestId(), qinfo->_nextQuestID); else qNextItr->second->DependentPreviousQuests.push_back(qinfo->GetQuestId()); } diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index 2023a4de8e8..44347222711 100644 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -497,7 +497,6 @@ class TC_GAME_API Quest void BuildQuestRewards(WorldPackets::Quest::QuestRewards& rewards, Player* player) const; std::vector DependentPreviousQuests; - std::vector PrevChainQuests; WorldPacket QueryData[TOTAL_LOCALES]; private: -- cgit v1.2.3 From 16e3796c7f3261f406187605ed3f74ad2544a1a7 Mon Sep 17 00:00:00 2001 From: ariel- Date: Sun, 9 Apr 2017 19:18:22 -0300 Subject: Core/Misc: fix static analysis issues CID 1373466 CID 1373481 CID 1373482 (cherry picked from commit e478434146fd479fab955aaa80eb925c15e29809) --- src/server/game/Entities/Unit/Unit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 7479b955435..590d2148a84 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1700,7 +1700,7 @@ uint32 Unit::CalcSpellResistedDamage(Unit* attacker, Unit* victim, uint32 damage while (r >= probabilitySum && resistance < 10) probabilitySum += discreteResistProbability[++resistance]; - float damageResisted = float(damage * resistance / 10); + float damageResisted = damage * resistance / 10.f; if (damageResisted > 0.0f) // if any damage was resisted { int32 ignoredResistance = 0; -- cgit v1.2.3 From 1960a95425c63f3b45409bcc1ee544472be598a3 Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 10 Apr 2017 04:50:09 -0300 Subject: Core/Unit: cleanup and minor fixes of miss and resist calculations - Removed Unit::GetUnitMeleeSkill as it was basically a copy of GetMaxSkillValueForLevel - Removed static from GetEffectiveResistChance, as this was passed anyways, changed name to CalculateAverageResistReduction, which better reflects what it does - Fix melee miss chances calculated from attacker maxskill instead of victim maxskill - Do actual checks if spell can be resisted/missed in MagicSpellHitResult (ie chances > 0) - Fixed SPELLMOD_RESIST_MISS_CHANCE calculation in MeleeSpellMissChance - Minor codestyle and cleanup of diminishing returns calcs (cherry picked from commit e565b34f6d24411e210151d0d03e524f94cdff85) --- src/server/game/Entities/Unit/StatSystem.cpp | 98 +++++++++++++--------- src/server/game/Entities/Unit/Unit.cpp | 120 ++++++++++++--------------- src/server/game/Entities/Unit/Unit.h | 2 +- 3 files changed, 116 insertions(+), 104 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index 2170ba4d7c7..88fb805a71d 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -577,7 +577,7 @@ void Player::UpdateHealingDonePercentMod() SetUpdateFieldStatValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ModHealingDonePercent), value); } -const float m_diminishing_k[MAX_CLASSES] = +float const m_diminishing_k[MAX_CLASSES] = { 0.9560f, // Warrior 0.9560f, // Paladin @@ -593,27 +593,50 @@ const float m_diminishing_k[MAX_CLASSES] = 0.9830f // Demon Hunter }; -void Player::UpdateParryPercentage() +// helper function +float CalculateDiminishingReturns(float const (&capArray)[MAX_CLASSES], uint8 playerClass, float nonDiminishValue, float diminishValue) { - const float parry_cap[MAX_CLASSES] = - { - 65.631440f, // Warrior - 65.631440f, // Paladin - 145.560408f, // Hunter - 145.560408f, // Rogue - 0.0f, // Priest - 65.631440f, // DK - 145.560408f, // Shaman - 0.0f, // Mage - 0.0f, // Warlock - 90.6425f, // Monk - 0.0f, // Druid - 65.631440f // Demon Hunter - }; + // 1 1 k cx + // --- = --- + --- <=> x' = -------- + // x' c x x + ck + + // where: + // k is m_diminishing_k for that class + // c is capArray for that class + // x is chance before DR (diminishValue) + // x' is chance after DR (our result) + + uint32 const classIdx = playerClass - 1; + + float const k = m_diminishing_k[classIdx]; + float const c = capArray[classIdx]; + + float result = c * diminishValue / (diminishValue + c * k); + result += nonDiminishValue; + return result; +} + +float const parry_cap[MAX_CLASSES] = +{ + 65.631440f, // Warrior + 65.631440f, // Paladin + 145.560408f, // Hunter + 145.560408f, // Rogue + 0.0f, // Priest + 65.631440f, // DK + 145.560408f, // Shaman + 0.0f, // Mage + 0.0f, // Warlock + 90.6425f, // Monk + 0.0f, // Druid + 65.631440f // Demon Hunter +}; +void Player::UpdateParryPercentage() +{ // No parry float value = 0.0f; - uint32 pclass = getClass()-1; + uint32 pclass = getClass() - 1; if (CanParry() && parry_cap[pclass] > 0.0f) { float nondiminishing = 5.0f; @@ -621,8 +644,9 @@ void Player::UpdateParryPercentage() float diminishing = GetRatingBonusValue(CR_PARRY); // Parry from SPELL_AURA_MOD_PARRY_PERCENT aura nondiminishing += GetTotalAuraModifier(SPELL_AURA_MOD_PARRY_PERCENT); + // apply diminishing formula to diminishing parry chance - value = nondiminishing + diminishing * parry_cap[pclass] / (diminishing + parry_cap[pclass] * m_diminishing_k[pclass]); + value = CalculateDiminishingReturns(parry_cap, getClass(), nondiminishing, diminishing); if (sWorld->getBoolConfig(CONFIG_STATS_LIMITS_ENABLE)) value = value > sWorld->getFloatConfig(CONFIG_STATS_LIMITS_PARRY) ? sWorld->getFloatConfig(CONFIG_STATS_LIMITS_PARRY) : value; @@ -631,33 +655,33 @@ void Player::UpdateParryPercentage() SetUpdateFieldStatValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ParryPercentage), value); } -void Player::UpdateDodgePercentage() +float const dodge_cap[MAX_CLASSES] = { - const float dodge_cap[MAX_CLASSES] = - { - 65.631440f, // Warrior - 65.631440f, // Paladin - 145.560408f, // Hunter - 145.560408f, // Rogue - 150.375940f, // Priest - 65.631440f, // DK - 145.560408f, // Shaman - 150.375940f, // Mage - 150.375940f, // Warlock - 145.560408f, // Monk - 116.890707f, // Druid - 145.560408f // Demon Hunter - }; + 65.631440f, // Warrior + 65.631440f, // Paladin + 145.560408f, // Hunter + 145.560408f, // Rogue + 150.375940f, // Priest + 65.631440f, // DK + 145.560408f, // Shaman + 150.375940f, // Mage + 150.375940f, // Warlock + 145.560408f, // Monk + 116.890707f, // Druid + 145.560408f // Demon Hunter +}; +void Player::UpdateDodgePercentage() +{ float diminishing = 0.0f, nondiminishing = 0.0f; GetDodgeFromAgility(diminishing, nondiminishing); // Dodge from SPELL_AURA_MOD_DODGE_PERCENT aura nondiminishing += GetTotalAuraModifier(SPELL_AURA_MOD_DODGE_PERCENT); // Dodge from rating diminishing += GetRatingBonusValue(CR_DODGE); + // apply diminishing formula to diminishing dodge chance - uint32 pclass = getClass()-1; - float value = nondiminishing + (diminishing * dodge_cap[pclass] / (diminishing + dodge_cap[pclass] * m_diminishing_k[pclass])); + float value = CalculateDiminishingReturns(dodge_cap, getClass(), nondiminishing, diminishing); if (sWorld->getBoolConfig(CONFIG_STATS_LIMITS_ENABLE)) value = value > sWorld->getFloatConfig(CONFIG_STATS_LIMITS_DODGE) ? sWorld->getFloatConfig(CONFIG_STATS_LIMITS_DODGE) : value; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 590d2148a84..142cc75a20d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1474,27 +1474,22 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) GetTypeId() != TYPEID_PLAYER && !ToCreature()->IsControlledByPlayer() && !victim->HasInArc(float(M_PI), this) && (victim->GetTypeId() == TYPEID_PLAYER || !victim->ToCreature()->isWorldBoss())&& !victim->IsVehicle()) { - // -probability is between 0% and 40% // 20% base chance - float Probability = 20.0f; + float chance = 20.0f; // there is a newbie protection, at level 10 just 7% base chance; assuming linear function if (victim->getLevel() < 30) - Probability = 0.65f * victim->GetLevelForTarget(this) + 0.5f; - - uint32 VictimDefense = victim->GetMaxSkillValueForLevel(this); - uint32 AttackerMeleeSkill = GetMaxSkillValueForLevel(); - - Probability *= AttackerMeleeSkill/(float)VictimDefense*0.16f; + chance = 0.65f * victim->GetLevelForTarget(this) + 0.5f; - if (Probability < 0) - Probability = 0; + uint32 const victimDefense = victim->GetMaxSkillValueForLevel(this); + uint32 const attackerMeleeSkill = GetMaxSkillValueForLevel(); - if (Probability > 40.0f) - Probability = 40.0f; + chance *= attackerMeleeSkill / float(victimDefense) * 0.16f; - if (roll_chance_f(Probability)) - CastSpell(victim, 1604, true); + // -probability is between 0% and 40% + RoundToInterval(chance, 0.0f, 40.0f); + if (roll_chance_f(chance)) + CastSpell(victim, 1604 /*SPELL_DAZED*/, true); } if (GetTypeId() == TYPEID_PLAYER) @@ -1676,29 +1671,28 @@ uint32 Unit::CalcSpellResistedDamage(Unit* attacker, Unit* victim, uint32 damage return 0; } - float averageResist = GetEffectiveResistChance(this, schoolMask, victim, spellInfo); - - float discreteResistProbability[11]; - for (uint32 i = 0; i < 11; ++i) - { - discreteResistProbability[i] = 0.5f - 2.5f * std::fabs(0.1f * i - averageResist); - if (discreteResistProbability[i] < 0.0f) - discreteResistProbability[i] = 0.0f; - } + float const averageResist = CalculateAverageResistReduction(schoolMask, victim, spellInfo); + float discreteResistProbability[11] = { }; if (averageResist <= 0.1f) { discreteResistProbability[0] = 1.0f - 7.5f * averageResist; discreteResistProbability[1] = 5.0f * averageResist; discreteResistProbability[2] = 2.5f * averageResist; } + else + { + for (uint32 i = 0; i < 11; ++i) + discreteResistProbability[i] = std::max(0.5f - 2.5f * std::fabs(0.1f * i - averageResist), 0.0f); + } - uint32 resistance = 0; - float r = float(rand_norm()); - float probabilitySum = discreteResistProbability[0]; + float roll = float(rand_norm()); + float probabilitySum = 0.0f; - while (r >= probabilitySum && resistance < 10) - probabilitySum += discreteResistProbability[++resistance]; + uint32 resistance = 0; + for (; resistance < 11; ++resistance) + if (roll < (probabilitySum += discreteResistProbability[resistance])) + break; float damageResisted = damage * resistance / 10.f; if (damageResisted > 0.0f) // if any damage was resisted @@ -1714,31 +1708,31 @@ uint32 Unit::CalcSpellResistedDamage(Unit* attacker, Unit* victim, uint32 damage if (spellInfo && spellInfo->HasAttribute(SPELL_ATTR0_CU_SCHOOLMASK_NORMAL_WITH_MAGIC)) { uint32 damageAfterArmor = CalcArmorReducedDamage(attacker, victim, damage, spellInfo, BASE_ATTACK); - uint32 armorReduction = damage - damageAfterArmor; - if (armorReduction < damageResisted) // pick the lower one, the weakest resistance counts - damageResisted = armorReduction; + float armorReduction = damage - damageAfterArmor; + + // pick the lower one, the weakest resistance counts + damageResisted = std::min(damageResisted, armorReduction); } } - return damageResisted; + damageResisted = std::max(damageResisted, 0.f); + return uint32(damageResisted); } -float Unit::GetEffectiveResistChance(Unit const* owner, SpellSchoolMask schoolMask, Unit const* victim, SpellInfo const* spellInfo) +float Unit::CalculateAverageResistReduction(SpellSchoolMask schoolMask, Unit const* victim, SpellInfo const* spellInfo) const { float victimResistance = float(victim->GetResistance(schoolMask)); - if (owner) + + // pets inherit 100% of masters penetration + // excluding traps + Player const* player = GetSpellModOwner(); + if (player && GetEntry() != WORLD_TRIGGER) { - // pets inherit 100% of masters penetration - // excluding traps - Player const* player = owner->GetSpellModOwner(); - if (player && owner->GetEntry() != WORLD_TRIGGER) - { - victimResistance += float(player->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask)); - victimResistance -= float(player->GetSpellPenetrationItemMod()); - } - else - victimResistance += float(owner->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask)); + victimResistance += float(player->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask)); + victimResistance -= float(player->GetSpellPenetrationItemMod()); } + else + victimResistance += float(GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask)); // holy resistance exists in pve and comes from level difference, ignore template values if (schoolMask & SPELL_SCHOOL_MASK_HOLY) @@ -1749,8 +1743,10 @@ float Unit::GetEffectiveResistChance(Unit const* owner, SpellSchoolMask schoolMa victimResistance = 0.0f; victimResistance = std::max(victimResistance, 0.0f); - if (owner) - victimResistance += std::max((float(victim->GetLevelForTarget(owner)) - float(owner->GetLevelForTarget(victim))) * 5.0f, 0.0f); + + // level-based resistance does not apply to binary spells, and cannot be overcome by spell penetration + if (!spellInfo->HasAttribute(SPELL_ATTR0_CU_BINARY_SPELL)) + victimResistance += std::max((float(victim->GetLevelForTarget(this)) - float(GetLevelForTarget(victim))) * 5.0f, 0.0f); static uint32 const bossLevel = 83; static float const bossResistanceConstant = 510.0f; @@ -2534,7 +2530,6 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo return SPELL_MISS_NONE; } -/// @todo need use unit spell resistances in calculations SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo) const { // Can`t miss on dead target (on skinning for example) @@ -2590,23 +2585,21 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo int32 tmp = 10000 - HitChance; int32 rand = irand(0, 9999); - if (rand < tmp) + if (tmp > 0 && rand < tmp) return SPELL_MISS_MISS; // Chance resist mechanic (select max value from every mechanic spell effect) int32 resist_chance = victim->GetMechanicResistChance(spellInfo) * 100; - tmp += resist_chance; // Roll chance - if (rand < tmp) + if (resist_chance > 0 && rand < (tmp += resist_chance)) return SPELL_MISS_RESIST; // cast by caster in front of victim if (!victim->HasUnitState(UNIT_STATE_CONTROLLED) && (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))) { int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100; - tmp += deflect_chance; - if (rand < tmp) + if (deflect_chance > 0 && rand < (tmp += deflect_chance)) return SPELL_MISS_DEFLECT; } @@ -2748,7 +2741,7 @@ float Unit::GetUnitParryChance(WeaponAttackType attType, Unit const* victim) con float Unit::GetUnitMissChance(WeaponAttackType attType) const { - float miss_chance = 5.00f; + float miss_chance = 5.0f; if (attType == RANGED_ATTACK) miss_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE); @@ -12426,25 +12419,23 @@ void Unit::ApplyResilience(Unit const* victim, int32* damage) const // Melee based spells can be miss, parry or dodge on this step // Crit or block - determined on damage calculation phase! (and can be both in some time) -float Unit::MeleeSpellMissChance(const Unit* victim, WeaponAttackType attType, uint32 spellId) const +float Unit::MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, uint32 spellId) const { //calculate miss chance float missChance = victim->GetUnitMissChance(attType); + // melee attacks while dual wielding have +19% chance to miss if (!spellId && haveOffhandWeapon() && !IsInFeralForm()) - missChance += 19; - - // Calculate hit chance - float hitChance = 100.0f; + missChance += 19.0f; // Spellmod from SPELLMOD_RESIST_MISS_CHANCE + float resistMissChance = 100.0f; if (spellId) { if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellId, SPELLMOD_RESIST_MISS_CHANCE, hitChance); + modOwner->ApplySpellMod(spellId, SPELLMOD_RESIST_MISS_CHANCE, resistMissChance); } - - missChance += hitChance - 100.0f; + missChance -= resistMissChance - 100.0f; if (attType == RANGED_ATTACK) missChance -= m_modRangedHitChance; @@ -12452,10 +12443,7 @@ float Unit::MeleeSpellMissChance(const Unit* victim, WeaponAttackType attType, u missChance -= m_modMeleeHitChance; // Limit miss chance from 0 to 60% - if (missChance < 0.0f) - return 0.0f; - if (missChance > 77.0f) - return 77.0f; + RoundToInterval(missChance, 0.f, 60.f); return missChance; } @@ -13562,7 +13550,7 @@ void Unit::SendClearTarget() int32 Unit::GetResistance(SpellSchoolMask mask) const { Optional resist; - for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) + for (int32 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) { int32 schoolResistance = GetResistance(SpellSchools(i)) + GetBonusResistanceMod(SpellSchools(i)); if (mask & (1 << i) && (!resist || *resist > schoolResistance)) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index e96b63f7013..70271f3023b 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1042,7 +1042,7 @@ class TC_GAME_API Unit : public WorldObject int32 GetResistance(SpellSchoolMask mask) const; void SetResistance(SpellSchools school, int32 val) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Resistances, school), val); } void SetBonusResistanceMod(SpellSchools school, int32 val) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::BonusResistanceMods, school), val); } - float GetEffectiveResistChance(Unit const* owner, SpellSchoolMask schoolMask, Unit const* victim, SpellInfo const* spellInfo = nullptr); + float CalculateAverageResistReduction(SpellSchoolMask schoolMask, Unit const* victim, SpellInfo const* spellInfo = nullptr) const; uint64 GetHealth() const { return m_unitData->Health; } uint64 GetMaxHealth() const { return m_unitData->MaxHealth; } -- cgit v1.2.3 From e5e37f0d8608f7823e016acf3b6e86a15b5c0491 Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 10 Apr 2017 12:17:08 -0300 Subject: Core/Unit: fix crash on magic school autoattacks Closes #19436 (cherry picked from commit 0b50ea072e504ac7d5bf87b08d564955785f7197) --- src/server/game/Entities/Unit/Unit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 142cc75a20d..674864da67f 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1745,7 +1745,7 @@ float Unit::CalculateAverageResistReduction(SpellSchoolMask schoolMask, Unit con victimResistance = std::max(victimResistance, 0.0f); // level-based resistance does not apply to binary spells, and cannot be overcome by spell penetration - if (!spellInfo->HasAttribute(SPELL_ATTR0_CU_BINARY_SPELL)) + if (!spellInfo || !spellInfo->HasAttribute(SPELL_ATTR0_CU_BINARY_SPELL)) victimResistance += std::max((float(victim->GetLevelForTarget(this)) - float(GetLevelForTarget(victim))) * 5.0f, 0.0f); static uint32 const bossLevel = 83; -- cgit v1.2.3 From 4e03d2717a7f971263f17639eb496c0b3b248018 Mon Sep 17 00:00:00 2001 From: ccrs Date: Tue, 11 Apr 2017 15:03:34 +0200 Subject: Core/Movement: correct no point recalculation on speed change in TargetedMovementGenerator (cherry picked from commit 4d7e7a97b329dc8ee4354f7be26c5e5efbaeba6b) --- .../game/Movement/MovementGenerators/TargetedMovementGenerator.cpp | 5 ++++- .../game/Movement/MovementGenerators/TargetedMovementGenerator.h | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index 122156f165e..a4efd581a4e 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -82,7 +82,9 @@ bool TargetedMovementGenerator::DoUpdate(T* owner, uint32 diff) } if (targetMoved) - SetTargetLocation(owner, targetMoved); + SetTargetLocation(owner, true); + else if (_speedChanged) + SetTargetLocation(owner, false); if (!_targetReached && owner->movespline->Finalized()) { @@ -177,6 +179,7 @@ void TargetedMovementGenerator::SetTargetLocation(T* owner, bool updateDes _targetReached = false; _recalculateTravel = false; + _speedChanged = false; AddUnitStateMove(owner); diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h index 2bd04e292f4..9f4e3712b5c 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h @@ -42,12 +42,12 @@ template class TargetedMovementGenerator : public MovementGeneratorMedium< T, D >, public TargetedMovementGeneratorBase { public: - explicit TargetedMovementGenerator(Unit* target, float offset, float angle) : TargetedMovementGeneratorBase(target), _path(nullptr), _timer(0), _offset(offset), _angle(angle), _recalculateTravel(false), _targetReached(false), _interrupt(false) { } + explicit TargetedMovementGenerator(Unit* target, float offset, float angle) : TargetedMovementGeneratorBase(target), _path(nullptr), _timer(0), _offset(offset), _angle(angle), _recalculateTravel(false), _speedChanged(false), _targetReached(false), _interrupt(false) { } ~TargetedMovementGenerator(); bool DoUpdate(T*, uint32); - void UnitSpeedChanged() override { _recalculateTravel = true; } + void UnitSpeedChanged() override { _speedChanged = true; } virtual void ClearUnitStateMove(T*) { } virtual void AddUnitStateMove(T*) { } @@ -65,6 +65,7 @@ class TargetedMovementGenerator : public MovementGeneratorMedium< T, D >, public float _offset; float _angle; bool _recalculateTravel; + bool _speedChanged; bool _targetReached; bool _interrupt; }; -- cgit v1.2.3 From 090fd8304a7a6e2f7c233ac39c94ccc67cc816f8 Mon Sep 17 00:00:00 2001 From: xinef1 Date: Wed, 12 Apr 2017 03:22:50 +0200 Subject: Core/Loot: implement Loot Item Storage (#19018) * Created Item Loot Storage, no more synchronous DB selects * Fixed buyback case, where stored loot was not removed from db * Added Primary key, and changed field types to be unsigned for table item_loot_money (cherry picked from commit 9dc3de10f0044c35a95e9b72e7b874f4b5b8e867) --- sql/base/characters_database.sql | 6 +- ...4_26_00_characters_2017_04_12_00_characters.sql | 2 + .../Database/Implementation/CharacterDatabase.cpp | 6 +- src/server/game/Entities/Item/Item.cpp | 190 +---------- src/server/game/Entities/Item/Item.h | 8 - src/server/game/Entities/Player/Player.cpp | 44 ++- src/server/game/Handlers/LootHandler.cpp | 3 +- src/server/game/Loot/Loot.cpp | 28 -- src/server/game/Loot/Loot.h | 8 +- src/server/game/Loot/LootItemStorage.cpp | 365 +++++++++++++++++++++ src/server/game/Loot/LootItemStorage.h | 96 ++++++ src/server/game/World/World.cpp | 4 + 12 files changed, 512 insertions(+), 248 deletions(-) create mode 100644 sql/updates/characters/master/2020_04_26_00_characters_2017_04_12_00_characters.sql create mode 100644 src/server/game/Loot/LootItemStorage.cpp create mode 100644 src/server/game/Loot/LootItemStorage.h (limited to 'src') diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql index 302bcbb918c..b23013bc0d1 100644 --- a/sql/base/characters_database.sql +++ b/sql/base/characters_database.sql @@ -3181,7 +3181,7 @@ DROP TABLE IF EXISTS `item_loot_money`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `item_loot_money` ( `container_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'guid of container (item_instance.guid)', - `money` int(10) NOT NULL DEFAULT '0' COMMENT 'money loot (in copper)', + `money` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'money loot (in copper)', PRIMARY KEY (`container_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -3772,7 +3772,9 @@ INSERT INTO `updates` VALUES ('2020_02_17_00_characters.sql','E1519A81D35F19B48B3C75A83A270CB4BA0B84F2','RELEASED','2020-02-17 21:55:17',0), ('2020_04_20_00_characters.sql','977B5E0C894E0A7E80B2A9626F17CA636A69BD22','RELEASED','2020-04-20 19:08:18',0), ('2020_04_24_00_characters.sql','85E2E0395A9457A53D73A9E0A7BB39B7E4C429BF','RELEASED','2020-04-24 22:04:59',0), -('2020_04_25_00_characters_2017_04_03_00_characters.sql','00FA3EFADAF807AC96619A3FE47216E21C3FCB19','RELEASED','2020-04-25 00:00:00',0); +('2020_04_25_00_characters_2017_04_03_00_characters.sql','00FA3EFADAF807AC96619A3FE47216E21C3FCB19','RELEASED','2020-04-25 00:00:00',0), +('2020_04_26_00_characters_2017_04_12_00_characters.sql','86AA94DA9B1EA283101100886C10F648C0CE6494','RELEASED','2020-04-26 00:00:00',0); + /*!40000 ALTER TABLE `updates` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/updates/characters/master/2020_04_26_00_characters_2017_04_12_00_characters.sql b/sql/updates/characters/master/2020_04_26_00_characters_2017_04_12_00_characters.sql new file mode 100644 index 00000000000..5340fbfca3e --- /dev/null +++ b/sql/updates/characters/master/2020_04_26_00_characters_2017_04_12_00_characters.sql @@ -0,0 +1,2 @@ +ALTER TABLE `item_loot_money` +CHANGE `money` `money` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'money loot (in copper)'; diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp index 13f25a9d4bd..26d3a907c6e 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp @@ -689,11 +689,11 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_GUILD_FINDER_GUILD_SETTINGS, "DELETE FROM guild_finder_guild_settings WHERE guildId = ?", CONNECTION_ASYNC); // Items that hold loot or money - PrepareStatement(CHAR_SEL_ITEMCONTAINER_ITEMS, "SELECT item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_bonus, context, bonus_list_ids FROM item_loot_items WHERE container_id = ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_ITEMCONTAINER_ITEMS, "SELECT container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_bonus, context, bonus_list_ids FROM item_loot_items", CONNECTION_SYNCH); PrepareStatement(CHAR_DEL_ITEMCONTAINER_ITEMS, "DELETE FROM item_loot_items WHERE container_id = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_ITEMCONTAINER_ITEM, "DELETE FROM item_loot_items WHERE container_id = ? AND item_id = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_DEL_ITEMCONTAINER_ITEM, "DELETE FROM item_loot_items WHERE container_id = ? AND item_id = ? AND item_count = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_ITEMCONTAINER_ITEMS, "INSERT INTO item_loot_items (container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_bonus, context, bonus_list_ids) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_ITEMCONTAINER_MONEY, "SELECT money FROM item_loot_money WHERE container_id = ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_ITEMCONTAINER_MONEY, "SELECT container_id, money FROM item_loot_money", CONNECTION_SYNCH); PrepareStatement(CHAR_DEL_ITEMCONTAINER_MONEY, "DELETE FROM item_loot_money WHERE container_id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_ITEMCONTAINER_MONEY, "INSERT INTO item_loot_money (container_id, money) VALUES (?, ?)", CONNECTION_ASYNC); diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 99235c38da3..56eabab98d1 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -30,6 +30,7 @@ #include "ItemEnchantmentMgr.h" #include "ItemPackets.h" #include "Log.h" +#include "LootItemStorage.h" #include "LootMgr.h" #include "Map.h" #include "ObjectAccessor.h" @@ -763,7 +764,7 @@ void Item::SaveToDB(CharacterDatabaseTransaction& trans) // Delete the items if this is a container if (!loot.isLooted()) - ItemContainerDeleteLootMoneyAndLootItemsFromDB(); + sLootItemStorage->RemoveStoredLootForContainer(GetGUID().GetCounter()); delete this; return; @@ -1058,7 +1059,7 @@ void Item::DeleteFromDB(CharacterDatabaseTransaction& trans) // Delete the items if this is a container if (!loot.isLooted()) - ItemContainerDeleteLootMoneyAndLootItemsFromDB(); + sLootItemStorage->RemoveStoredLootForContainer(GetGUID().GetCounter()); } /*static*/ @@ -2141,191 +2142,6 @@ uint32 Item::GetSellPrice(ItemTemplate const* proto, uint32 quality, uint32 item return 0; } -void Item::ItemContainerSaveLootToDB() -{ - // Saves the money and item loot associated with an openable item to the DB - if (loot.isLooted()) // no money and no loot - return; - - CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); - - loot.containerID = GetGUID(); // Save this for when a LootItem is removed - - // Save money - if (loot.gold > 0) - { - CharacterDatabasePreparedStatement* stmt_money = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_MONEY); - stmt_money->setUInt64(0, loot.containerID.GetCounter()); - trans->Append(stmt_money); - - stmt_money = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_MONEY); - stmt_money->setUInt64(0, loot.containerID.GetCounter()); - stmt_money->setUInt32(1, loot.gold); - trans->Append(stmt_money); - } - - // Save items - if (!loot.isLooted()) - { - CharacterDatabasePreparedStatement* stmt_items = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEMS); - stmt_items->setUInt64(0, loot.containerID.GetCounter()); - trans->Append(stmt_items); - - // Now insert the items - for (LootItemList::const_iterator _li = loot.items.begin(); _li != loot.items.end(); ++_li) - { - // When an item is looted, it doesn't get removed from the items collection - // but we don't want to resave it. - if (!_li->canSave) - continue; - // Conditions are not checked when loot is generated, it is checked when loot is sent to a player. - // For items that are lootable, loot is saved to the DB immediately, that means that loot can be - // saved to the DB that the player never should have gotten. This check prevents that, so that only - // items that the player should get in loot are in the DB. - // IE: Horde items are not saved to the DB for Ally players. - Player* const guid = GetOwner(); - if (!_li->AllowedForPlayer(guid)) - continue; - - stmt_items = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_ITEMS); - - // container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_prop, context, bonus_list_ids - stmt_items->setUInt64(0, loot.containerID.GetCounter()); - stmt_items->setUInt32(1, _li->itemid); - stmt_items->setUInt32(2, _li->count); - stmt_items->setBool(3, _li->follow_loot_rules); - stmt_items->setBool(4, _li->freeforall); - stmt_items->setBool(5, _li->is_blocked); - stmt_items->setBool(6, _li->is_counted); - stmt_items->setBool(7, _li->is_underthreshold); - stmt_items->setBool(8, _li->needs_quest); - stmt_items->setUInt32(9, _li->randomBonusListId); - stmt_items->setUInt8(10, AsUnderlyingType(_li->context)); - std::ostringstream bonusListIDs; - for (int32 bonusListID : _li->BonusListIDs) - bonusListIDs << bonusListID << ' '; - stmt_items->setString(11, bonusListIDs.str()); - trans->Append(stmt_items); - } - } - - CharacterDatabase.CommitTransaction(trans); -} - -bool Item::ItemContainerLoadLootFromDB() -{ - // Loads the money and item loot associated with an openable item from the DB - // Default. If there are no records for this item then it will be rolled for in Player::SendLoot() - m_lootGenerated = false; - - // Save this for later use - loot.containerID = GetGUID(); - - // First, see if there was any money loot. This gets added directly to the container. - CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ITEMCONTAINER_MONEY); - stmt->setUInt64(0, loot.containerID.GetCounter()); - PreparedQueryResult money_result = CharacterDatabase.Query(stmt); - - if (money_result) - { - Field* fields = money_result->Fetch(); - loot.gold = fields[0].GetUInt32(); - } - - // Next, load any items that were saved - stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ITEMCONTAINER_ITEMS); - stmt->setUInt64(0, loot.containerID.GetCounter()); - PreparedQueryResult item_result = CharacterDatabase.Query(stmt); - - if (item_result) - { - // Get a LootTemplate for the container item. This is where - // the saved loot was originally rolled from, we will copy conditions from it - LootTemplate const* lt = LootTemplates_Item.GetLootFor(GetEntry()); - if (lt) - { - do - { - // Create an empty LootItem - LootItem loot_item = LootItem(); - - // Fill in the rest of the LootItem from the DB - Field* fields = item_result->Fetch(); - - // item_id, itm_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_prop, context, bonus_list_ids - loot_item.itemid = fields[0].GetUInt32(); - loot_item.count = fields[1].GetUInt32(); - loot_item.follow_loot_rules = fields[2].GetBool(); - loot_item.freeforall = fields[3].GetBool(); - loot_item.is_blocked = fields[4].GetBool(); - loot_item.is_counted = fields[5].GetBool(); - loot_item.canSave = true; - loot_item.is_underthreshold = fields[6].GetBool(); - loot_item.needs_quest = fields[7].GetBool(); - loot_item.randomBonusListId = fields[8].GetUInt32(); - loot_item.context = ItemContext(fields[9].GetUInt8()); - Tokenizer bonusLists(fields[10].GetString(), ' '); - std::transform(bonusLists.begin(), bonusLists.end(), std::back_inserter(loot_item.BonusListIDs), [](char const* token) - { - return int32(strtol(token, NULL, 10)); - }); - - // Copy the extra loot conditions from the item in the loot template - lt->CopyConditions(&loot_item); - - // If container item is in a bag, add that player as an allowed looter - if (GetBagSlot()) - loot_item.AddAllowedLooter(GetOwner()); - - // Finally add the LootItem to the container - loot.items.push_back(loot_item); - - // Increment unlooted count - loot.unlootedCount++; - - } - while (item_result->NextRow()); - } - } - - // Mark the item if it has loot so it won't be generated again on open - m_lootGenerated = !loot.isLooted(); - - return m_lootGenerated; -} - -void Item::ItemContainerDeleteLootItemsFromDB() -{ - // Deletes items associated with an openable item from the DB - CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEMS); - stmt->setUInt64(0, GetGUID().GetCounter()); - CharacterDatabase.Execute(stmt); -} - -void Item::ItemContainerDeleteLootItemFromDB(uint32 itemID) -{ - // Deletes a single item associated with an openable item from the DB - CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEM); - stmt->setUInt64(0, GetGUID().GetCounter()); - stmt->setUInt32(1, itemID); - CharacterDatabase.Execute(stmt); -} - -void Item::ItemContainerDeleteLootMoneyFromDB() -{ - // Deletes the money loot associated with an openable item from the DB - CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_MONEY); - stmt->setUInt64(0, GetGUID().GetCounter()); - CharacterDatabase.Execute(stmt); -} - -void Item::ItemContainerDeleteLootMoneyAndLootItemsFromDB() -{ - // Deletes money and items associated with an openable item from the DB - ItemContainerDeleteLootMoneyFromDB(); - ItemContainerDeleteLootItemsFromDB(); -} - uint32 Item::GetItemLevel(Player const* owner) const { ItemTemplate const* itemTemplate = GetTemplate(); diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index c4c5ee62d5a..007b9ef46c5 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -231,14 +231,6 @@ class TC_GAME_API Item : public Object virtual void DeleteFromDB(CharacterDatabaseTransaction& trans); static void DeleteFromInventoryDB(CharacterDatabaseTransaction& trans, ObjectGuid::LowType itemGuid); - // Lootable items and their contents - void ItemContainerSaveLootToDB(); - bool ItemContainerLoadLootFromDB(); - void ItemContainerDeleteLootItemsFromDB(); - void ItemContainerDeleteLootItemFromDB(uint32 itemID); - void ItemContainerDeleteLootMoneyFromDB(); - void ItemContainerDeleteLootMoneyAndLootItemsFromDB(); - void DeleteFromInventoryDB(CharacterDatabaseTransaction& trans); void SaveRefundDataToDB(); void DeleteRefundDataFromDB(CharacterDatabaseTransaction* trans); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index be4dfa08e24..abad9678510 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -75,6 +75,7 @@ #include "LFGMgr.h" #include "Language.h" #include "Log.h" +#include "LootItemStorage.h" #include "LootMgr.h" #include "LootPackets.h" #include "Mail.h" @@ -8838,9 +8839,12 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type, bool aeLooting/* = fa loot = &item->loot; + // Store container id + loot->containerID = item->GetGUID(); + // If item doesn't already have loot, attempt to load it. If that - // fails then this is first time opening, generate loot - if (!item->m_lootGenerated && !item->ItemContainerLoadLootFromDB()) + // fails then this is first time opening, generate loot + if (!item->m_lootGenerated && !sLootItemStorage->LoadStoredLoot(item, this)) { item->m_lootGenerated = true; loot->clear(); @@ -8863,7 +8867,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type, bool aeLooting/* = fa // Force save the loot and money items that were just rolled // Also saves the container item ID in Loot struct (not to DB) if (loot->gold > 0 || loot->unlootedCount > 0) - item->ItemContainerSaveLootToDB(); + sLootItemStorage->AddNewStoredLoot(loot, this); break; } @@ -12803,6 +12807,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount()); sScriptMgr->OnItemRemove(this, pItem); + ItemTemplate const* pProto = pItem->GetTemplate(); if (bag == INVENTORY_SLOT_BAG_0) { SetInvSlot(slot, ObjectGuid::Empty); @@ -12810,8 +12815,6 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) // equipment and equipped bags can have applied bonuses if (slot < INVENTORY_SLOT_BAG_END) { - ItemTemplate const* pProto = pItem->GetTemplate(); - // item set bonuses applied only at equip and removed at unequip, and still active for broken items if (pProto && pProto->GetItemSet()) RemoveItemsSetItem(this, pProto); @@ -12847,9 +12850,8 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) // Delete rolled money / loot from db. // MUST be done before RemoveFromWorld() or GetTemplate() fails - if (ItemTemplate const* pTmp = pItem->GetTemplate()) - if (pTmp->GetFlags() & ITEM_FLAG_HAS_LOOT) - pItem->ItemContainerDeleteLootMoneyAndLootItemsFromDB(); + if (pProto->GetFlags() & ITEM_FLAG_HAS_LOOT) + sLootItemStorage->RemoveStoredLootForContainer(pItem->GetGUID().GetCounter()); if (IsInWorld() && update) { @@ -13766,7 +13768,7 @@ void Player::SwapItem(uint16 src, uint16 dst) { if (Item* bagItem = bag->GetItemByPos(i)) { - if (bagItem->m_lootGenerated) + if (bagItem->GetGUID() == GetLootGUID()) { m_session->DoLootRelease(GetLootGUID()); released = true; // so we don't need to look at dstBag @@ -13783,7 +13785,7 @@ void Player::SwapItem(uint16 src, uint16 dst) { if (Item* bagItem = bag->GetItemByPos(i)) { - if (bagItem->m_lootGenerated) + if (bagItem->GetGUID() == GetLootGUID()) { m_session->DoLootRelease(GetLootGUID()); break; @@ -13872,7 +13874,12 @@ void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del) { pItem->RemoveFromWorld(); if (del) + { pItem->SetState(ITEM_REMOVED, this); + if (ItemTemplate const* itemTemplate = pItem->GetTemplate()) + if (itemTemplate->GetFlags() & ITEM_FLAG_HAS_LOOT) + sLootItemStorage->RemoveStoredLootForContainer(pItem->GetGUID().GetCounter()); + } } m_items[slot] = nullptr; @@ -20846,12 +20853,25 @@ void Player::_SaveInventory(CharacterDatabaseTransaction& trans) for (uint8 i = BUYBACK_SLOT_START; i < BUYBACK_SLOT_END; ++i) { Item* item = m_items[i]; - if (!item || item->GetState() == ITEM_NEW) + if (!item) continue; + if (item->GetState() == ITEM_NEW) + { + if (ItemTemplate const* itemTemplate = item->GetTemplate()) + if (itemTemplate->GetFlags() & ITEM_FLAG_HAS_LOOT) + sLootItemStorage->RemoveStoredLootForContainer(item->GetGUID().GetCounter()); + + continue; + } + item->DeleteFromInventoryDB(trans); item->DeleteFromDB(trans); m_items[i]->FSetState(ITEM_NEW); + + if (ItemTemplate const* itemTemplate = item->GetTemplate()) + if (itemTemplate->GetFlags() & ITEM_FLAG_HAS_LOOT) + sLootItemStorage->RemoveStoredLootForContainer(item->GetGUID().GetCounter()); } // Updated played time for refundable items. We don't do this in Player::Update because there's simply no need for it, @@ -26197,7 +26217,7 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot, AELootResult* aeResult/* // LootItem is being removed (looted) from the container, delete it from the DB. if (!loot->containerID.IsEmpty()) - loot->DeleteLootItemFromContainerItemDB(item->itemid); + sLootItemStorage->RemoveStoredLootItemForContainer(loot->containerID.GetCounter(), item->itemid, item->count); } else SendEquipError(msg, nullptr, nullptr, item->itemid); diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp index 7335b5f3676..68911435766 100644 --- a/src/server/game/Handlers/LootHandler.cpp +++ b/src/server/game/Handlers/LootHandler.cpp @@ -28,6 +28,7 @@ #include "GuildMgr.h" #include "Item.h" #include "Log.h" +#include "LootItemStorage.h" #include "LootMgr.h" #include "LootPackets.h" #include "Object.h" @@ -255,7 +256,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPackets::Loot::LootMoney& /*packet // Delete the money loot record from the DB if (!loot->containerID.IsEmpty()) - loot->DeleteLootMoneyFromContainerItemDB(); + sLootItemStorage->RemoveStoredMoneyForContainer(loot->containerID.GetCounter()); // Delete container if empty if (loot->isLooted() && guid.IsItem()) diff --git a/src/server/game/Loot/Loot.cpp b/src/server/game/Loot/Loot.cpp index 88365d6641f..9e4dc90cab9 100644 --- a/src/server/game/Loot/Loot.cpp +++ b/src/server/game/Loot/Loot.cpp @@ -54,7 +54,6 @@ LootItem::LootItem(LootStoreItem const& li) is_underthreshold = 0; is_counted = 0; rollWinnerGUID = ObjectGuid::Empty; - canSave = true; } // Basic checks for player/item compatibility - if false no chance to see the item in the loot @@ -104,33 +103,6 @@ Loot::~Loot() clear(); } -void Loot::DeleteLootItemFromContainerItemDB(uint32 itemID) -{ - // Deletes a single item associated with an openable item from the DB - CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEM); - stmt->setUInt64(0, containerID.GetCounter()); - stmt->setUInt32(1, itemID); - CharacterDatabase.Execute(stmt); - - // Mark the item looted to prevent resaving - for (LootItemList::iterator _itr = items.begin(); _itr != items.end(); ++_itr) - { - if (_itr->itemid != itemID) - continue; - - _itr->canSave = false; - break; - } -} - -void Loot::DeleteLootMoneyFromContainerItemDB() -{ - // Deletes money loot associated with an openable item from the DB - CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_MONEY); - stmt->setUInt64(0, containerID.GetCounter()); - CharacterDatabase.Execute(stmt); -} - void Loot::clear() { for (NotNormalLootItemMap::const_iterator itr = PlayerQuestItems.begin(); itr != PlayerQuestItems.end(); ++itr) diff --git a/src/server/game/Loot/Loot.h b/src/server/game/Loot/Loot.h index 27f9c89f040..1aaed3f3cf7 100644 --- a/src/server/game/Loot/Loot.h +++ b/src/server/game/Loot/Loot.h @@ -148,7 +148,6 @@ struct TC_GAME_API LootItem bool is_counted : 1; bool needs_quest : 1; // quest drop bool follow_loot_rules : 1; - bool canSave; // Constructor, copies most fields from LootStoreItem, generates random count and random suffixes/properties // Should be called for non-reference LootStoreItem entries only (reference = 0) @@ -156,8 +155,7 @@ struct TC_GAME_API LootItem // Empty constructor for creating an empty LootItem to be filled in with DB data LootItem() : itemid(0), randomBonusListId(0), context(ItemContext::NONE), count(0), is_looted(false), is_blocked(false), - freeforall(false), is_underthreshold(false), is_counted(false), needs_quest(false), follow_loot_rules(false), - canSave(true){ }; + freeforall(false), is_underthreshold(false), is_counted(false), needs_quest(false), follow_loot_rules(false) { }; // Basic checks for player/item compatibility - if false no chance to see the item in the loot bool AllowedForPlayer(Player const* player) const; @@ -230,10 +228,6 @@ struct TC_GAME_API Loot ObjectGuid const& GetGUID() const { return _GUID; } void SetGUID(ObjectGuid const& guid) { _GUID = guid; } - // For deleting items at loot removal since there is no backward interface to the Item() - void DeleteLootItemFromContainerItemDB(uint32 itemID); - void DeleteLootMoneyFromContainerItemDB(); - // if loot becomes invalid this reference is used to inform the listener void addLootValidatorRef(LootValidatorRef* pLootValidatorRef) { diff --git a/src/server/game/Loot/LootItemStorage.cpp b/src/server/game/Loot/LootItemStorage.cpp new file mode 100644 index 00000000000..4e3464eb31c --- /dev/null +++ b/src/server/game/Loot/LootItemStorage.cpp @@ -0,0 +1,365 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * 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 . + */ + +#include "DatabaseEnv.h" +#include "Item.h" +#include "ItemTemplate.h" +#include "Log.h" +#include "LootItemStorage.h" +#include "LootMgr.h" +#include "ObjectMgr.h" +#include "Player.h" + +#include +#include + +#include + +namespace +{ + std::unordered_map _lootItemStore; +} + +StoredLootItem::StoredLootItem(LootItem const& lootItem) : ItemId(lootItem.itemid), Count(lootItem.count), FollowRules(lootItem.follow_loot_rules), +FFA(lootItem.freeforall), Blocked(lootItem.is_blocked), Counted(lootItem.is_counted), UnderThreshold(lootItem.is_underthreshold), +NeedsQuest(lootItem.needs_quest), RandomBonusListId(lootItem.randomBonusListId), Context(lootItem.context), BonusListIDs(lootItem.BonusListIDs) +{ +} + +LootItemStorage* LootItemStorage::instance() +{ + static LootItemStorage instance; + return &instance; +} + +boost::shared_mutex* LootItemStorage::GetLock() +{ + static boost::shared_mutex _lock; + return &_lock; +} + +void LootItemStorage::LoadStorageFromDB() +{ + uint32 oldMSTime = getMSTime(); + _lootItemStore.clear(); + uint32 count = 0; + + CharacterDatabaseTransaction trans = CharacterDatabaseTransaction(nullptr); + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ITEMCONTAINER_ITEMS); + PreparedQueryResult result = CharacterDatabase.Query(stmt); + if (result) + { + do + { + Field* fields = result->Fetch(); + + uint64 key = fields[0].GetUInt64(); + auto itr = _lootItemStore.find(key); + if (itr == _lootItemStore.end()) + { + bool added; + std::tie(itr, added) = _lootItemStore.emplace(std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(key)); + + ASSERT(added); + } + + StoredLootContainer& storedContainer = itr->second; + + LootItem lootItem; + lootItem.itemid = fields[1].GetUInt32(); + lootItem.count = fields[2].GetUInt32(); + lootItem.follow_loot_rules = fields[3].GetBool(); + lootItem.freeforall = fields[4].GetBool(); + lootItem.is_blocked = fields[5].GetBool(); + lootItem.is_counted = fields[6].GetBool(); + lootItem.is_underthreshold = fields[7].GetBool(); + lootItem.needs_quest = fields[8].GetBool(); + lootItem.randomBonusListId = fields[9].GetUInt32(); + lootItem.context = ItemContext(fields[10].GetUInt8()); + Tokenizer bonusLists(fields[11].GetString(), ' '); + std::transform(bonusLists.begin(), bonusLists.end(), std::back_inserter(lootItem.BonusListIDs), [](char const* token) + { + return int32(strtol(token, NULL, 10)); + }); + + storedContainer.AddLootItem(lootItem, trans); + + ++count; + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u stored item loots in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); + } + else + TC_LOG_INFO("server.loading", ">> Loaded 0 stored item loots"); + + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ITEMCONTAINER_MONEY); + result = CharacterDatabase.Query(stmt); + if (result) + { + count = 0; + do + { + Field* fields = result->Fetch(); + + uint64 key = fields[0].GetUInt64(); + auto itr = _lootItemStore.find(key); + if (itr == _lootItemStore.end()) + { + bool added; + std::tie(itr, added) = _lootItemStore.emplace(std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(key)); + + ASSERT(added); + } + + StoredLootContainer& storedContainer = itr->second; + storedContainer.AddMoney(fields[1].GetUInt32(), trans); + + ++count; + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u stored item money in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); + } + else + TC_LOG_INFO("server.loading", ">> Loaded 0 stored item money"); +} + +bool LootItemStorage::LoadStoredLoot(Item* item, Player* player) +{ + Loot* loot = &item->loot; + StoredLootContainer const* container = nullptr; + + // read + { + boost::shared_lock lock(*GetLock()); + + auto itr = _lootItemStore.find(loot->containerID.GetCounter()); + if (itr == _lootItemStore.end()) + return false; + + container = &itr->second; + } + + // container is never null at this point + loot->gold = container->GetMoney(); + + if (LootTemplate const* lt = LootTemplates_Item.GetLootFor(item->GetEntry())) + { + for (auto const& storedItemPair : container->GetLootItems()) + { + LootItem li; + li.itemid = storedItemPair.first; + li.count = storedItemPair.second.Count; + li.follow_loot_rules = storedItemPair.second.FollowRules; + li.freeforall = storedItemPair.second.FFA; + li.is_blocked = storedItemPair.second.Blocked; + li.is_counted = storedItemPair.second.Counted; + li.is_underthreshold = storedItemPair.second.UnderThreshold; + li.needs_quest = storedItemPair.second.NeedsQuest; + li.randomBonusListId = storedItemPair.second.RandomBonusListId; + li.context = storedItemPair.second.Context; + li.BonusListIDs = storedItemPair.second.BonusListIDs; + + // Copy the extra loot conditions from the item in the loot template + lt->CopyConditions(&li); + + // If container item is in a bag, add that player as an allowed looter + if (item->GetBagSlot()) + li.AddAllowedLooter(player); + + // Finally add the LootItem to the container + loot->items.push_back(li); + + // Increment unlooted count + ++loot->unlootedCount; + } + } + + // Mark the item if it has loot so it won't be generated again on open + item->m_lootGenerated = true; + return true; +} + +void LootItemStorage::RemoveStoredMoneyForContainer(uint64 containerId) +{ + // write + boost::unique_lock lock(*GetLock()); + + auto itr = _lootItemStore.find(containerId); + if (itr == _lootItemStore.end()) + return; + + itr->second.RemoveMoney(); +} + +void LootItemStorage::RemoveStoredLootForContainer(uint64 containerId) +{ + // write + { + boost::unique_lock lock(*GetLock()); + _lootItemStore.erase(containerId); + } + + CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEMS); + stmt->setUInt64(0, containerId); + trans->Append(stmt); + + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_MONEY); + stmt->setUInt64(0, containerId); + trans->Append(stmt); + + CharacterDatabase.CommitTransaction(trans); +} + +void LootItemStorage::RemoveStoredLootItemForContainer(uint64 containerId, uint32 itemId, uint32 count) +{ + // write + boost::unique_lock lock(*GetLock()); + + auto itr = _lootItemStore.find(containerId); + if (itr == _lootItemStore.end()) + return; + + itr->second.RemoveItem(itemId, count); +} + +void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player) +{ + // Saves the money and item loot associated with an openable item to the DB + if (loot->isLooted()) // no money and no loot + return; + + // read + { + boost::shared_lock lock(*GetLock()); + + auto itr = _lootItemStore.find(loot->containerID.GetCounter()); + if (itr != _lootItemStore.end()) + { + TC_LOG_ERROR("misc", "Trying to store item loot by player: %s for container id: %lu that is already in storage!", player->GetGUID().ToString().c_str(), loot->containerID.GetCounter()); + return; + } + } + + StoredLootContainer container(loot->containerID.GetCounter()); + + CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); + if (loot->gold) + container.AddMoney(loot->gold, trans); + + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEMS); + stmt->setUInt64(0, loot->containerID.GetCounter()); + trans->Append(stmt); + + for (LootItem const& li : loot->items) + { + // Conditions are not checked when loot is generated, it is checked when loot is sent to a player. + // For items that are lootable, loot is saved to the DB immediately, that means that loot can be + // saved to the DB that the player never should have gotten. This check prevents that, so that only + // items that the player should get in loot are in the DB. + // IE: Horde items are not saved to the DB for Ally players. + if (!li.AllowedForPlayer(player)) + continue; + + // Don't save currency tokens + ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(li.itemid); + if (!itemTemplate || itemTemplate->IsCurrencyToken()) + continue; + + container.AddLootItem(li, trans); + } + + CharacterDatabase.CommitTransaction(trans); + + // write + { + boost::unique_lock lock(*GetLock()); + _lootItemStore.emplace(loot->containerID.GetCounter(), std::move(container)); + } +} + +void StoredLootContainer::AddLootItem(LootItem const& lootItem, CharacterDatabaseTransaction& trans) +{ + _lootItems.emplace(std::piecewise_construct, std::forward_as_tuple(lootItem.itemid), std::forward_as_tuple(lootItem)); + if (!trans) + return; + + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_ITEMS); + + // container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_prop, rnd_suffix + stmt->setUInt64(0, _containerId); + stmt->setUInt32(1, lootItem.itemid); + stmt->setUInt32(2, lootItem.count); + stmt->setBool(3, lootItem.follow_loot_rules); + stmt->setBool(4, lootItem.freeforall); + stmt->setBool(5, lootItem.is_blocked); + stmt->setBool(6, lootItem.is_counted); + stmt->setBool(7, lootItem.is_underthreshold); + stmt->setBool(8, lootItem.needs_quest); + stmt->setInt32(9, lootItem.randomBonusListId); + stmt->setUInt8(10, AsUnderlyingType(lootItem.context)); + std::ostringstream bonusListIDs; + for (int32 bonusListID : lootItem.BonusListIDs) + bonusListIDs << bonusListID << ' '; + stmt->setString(11, bonusListIDs.str()); + trans->Append(stmt); +} + +void StoredLootContainer::AddMoney(uint32 money, CharacterDatabaseTransaction& trans) +{ + _money = money; + if (!trans) + return; + + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_MONEY); + stmt->setUInt64(0, _containerId); + trans->Append(stmt); + + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_MONEY); + stmt->setUInt64(0, _containerId); + stmt->setUInt32(1, _money); + trans->Append(stmt); +} + +void StoredLootContainer::RemoveMoney() +{ + _money = 0; + + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_MONEY); + stmt->setUInt64(0, _containerId); + CharacterDatabase.Execute(stmt); +} + +void StoredLootContainer::RemoveItem(uint32 itemId, uint32 count) +{ + auto bounds = _lootItems.equal_range(itemId); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + { + if (itr->second.Count == count) + { + _lootItems.erase(itr); + break; + } + } + + // Deletes a single item associated with an openable item from the DB + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEM); + stmt->setUInt64(0, _containerId); + stmt->setUInt32(1, itemId); + stmt->setUInt32(2, count); + CharacterDatabase.Execute(stmt); +} diff --git a/src/server/game/Loot/LootItemStorage.h b/src/server/game/Loot/LootItemStorage.h new file mode 100644 index 00000000000..7d221eaefc0 --- /dev/null +++ b/src/server/game/Loot/LootItemStorage.h @@ -0,0 +1,96 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * 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 . + */ + +#ifndef __LOOTITEMSTORAGE_H +#define __LOOTITEMSTORAGE_H + +#include "Define.h" +#include "DBCEnums.h" +#include "ItemEnchantmentMgr.h" + +#include + +class Item; +class Player; +struct Loot; +struct LootItem; +namespace boost +{ + class shared_mutex; +} + +struct StoredLootItem +{ + explicit StoredLootItem(LootItem const& lootItem); + + uint32 ItemId; + uint32 Count; + bool FollowRules; + bool FFA; + bool Blocked; + bool Counted; + bool UnderThreshold; + bool NeedsQuest; + ItemRandomBonusListId RandomBonusListId; + ItemContext Context; + std::vector BonusListIDs; +}; + +class StoredLootContainer +{ + public: + typedef std::unordered_multimap StoredLootItemContainer; + + explicit StoredLootContainer(uint64 containerId) : _containerId(containerId), _money(0) { } + + void AddLootItem(LootItem const& lootItem, CharacterDatabaseTransaction& trans); + void AddMoney(uint32 money, CharacterDatabaseTransaction& trans); + + void RemoveMoney(); + void RemoveItem(uint32 itemId, uint32 count); + + uint32 GetContainer() const { return _containerId; } + uint32 GetMoney() const { return _money; } + StoredLootItemContainer const& GetLootItems() const { return _lootItems; } + + private: + StoredLootItemContainer _lootItems; + uint64 const _containerId; + uint32 _money; +}; + +class LootItemStorage +{ + public: + static LootItemStorage* instance(); + static boost::shared_mutex* GetLock(); + + void LoadStorageFromDB(); + bool LoadStoredLoot(Item* item, Player* player); + void RemoveStoredMoneyForContainer(uint64 containerId); + void RemoveStoredLootForContainer(uint64 containerId); + void RemoveStoredLootItemForContainer(uint64 containerId, uint32 itemId, uint32 count); + void AddNewStoredLoot(Loot* loot, Player* player); + + private: + LootItemStorage() { } + ~LootItemStorage() { } +}; + +#define sLootItemStorage LootItemStorage::instance() + +#endif diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index e1e71ce01e2..a94e06034ba 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -60,6 +60,7 @@ #include "IPLocation.h" #include "Language.h" #include "LFGMgr.h" +#include "LootItemStorage.h" #include "LootMgr.h" #include "M2Stores.h" #include "MapManager.h" @@ -2073,6 +2074,9 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading Calendar data..."); sCalendarMgr->LoadFromDB(); + TC_LOG_INFO("server.loading", "Loading Item loot..."); + sLootItemStorage->LoadStorageFromDB(); + TC_LOG_INFO("server.loading", "Initialize query data..."); sObjectMgr->InitializeQueriesData(QUERY_DATA_ALL); -- cgit v1.2.3 From 7c571c5b0a983de9b6f67de55cf6a15f8bac4868 Mon Sep 17 00:00:00 2001 From: ariel- Date: Tue, 11 Apr 2017 23:23:02 -0300 Subject: Core/Misc: fix non-pch build (cherry picked from commit 5e0485178de0ab794c72d845e331559171301b22) --- src/server/game/Loot/LootItemStorage.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/server/game/Loot/LootItemStorage.h b/src/server/game/Loot/LootItemStorage.h index 7d221eaefc0..a1ae9133724 100644 --- a/src/server/game/Loot/LootItemStorage.h +++ b/src/server/game/Loot/LootItemStorage.h @@ -22,12 +22,14 @@ #include "DBCEnums.h" #include "ItemEnchantmentMgr.h" +#include #include class Item; class Player; struct Loot; struct LootItem; + namespace boost { class shared_mutex; -- cgit v1.2.3 From 0d8c1b49b82081eac42ca68ec0d9ee199bb1eda3 Mon Sep 17 00:00:00 2001 From: ariel- Date: Tue, 11 Apr 2017 23:23:52 -0300 Subject: Core/Creature: fix integer overflow in Creature::Update leading to endless thrashing of characters database Closes #19182 (cherry picked from commit 66755eecf117d21504b13a86410aa01cfc44c3ba) --- src/server/game/Entities/Creature/Creature.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 4bbb29d43c1..1e60264c8aa 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -622,7 +622,18 @@ void Creature::Update(uint32 diff) if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day) SetRespawnTime(DAY); else - m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // else copy time from master and add a little + { + // else copy time from master and add a little + time_t baseRespawnTime = std::max(linkedRespawntime, now); + time_t const offset = urand(5, MINUTE); + + // linked guid can be a boss, uses std::numeric_limits::max to never respawn in that instance + // we shall inherit it instead of adding and causing an overflow + if (baseRespawnTime <= std::numeric_limits::max() - offset) + m_respawnTime = baseRespawnTime + offset; + else + m_respawnTime = std::numeric_limits::max(); + } SaveRespawnTime(); // also save to DB immediately } } -- cgit v1.2.3 From a2ee35d9a3c390e32ddbe758ec9b2cdc14569970 Mon Sep 17 00:00:00 2001 From: ariel- Date: Tue, 11 Apr 2017 23:30:47 -0300 Subject: Core/Misc: pch fixes pt 2 (cherry picked from commit e32a4f26aaa51fba2647aeb8ef751dd398bc09d8) --- src/server/game/Loot/LootItemStorage.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/server/game/Loot/LootItemStorage.h b/src/server/game/Loot/LootItemStorage.h index a1ae9133724..7855559ce1e 100644 --- a/src/server/game/Loot/LootItemStorage.h +++ b/src/server/game/Loot/LootItemStorage.h @@ -18,6 +18,7 @@ #ifndef __LOOTITEMSTORAGE_H #define __LOOTITEMSTORAGE_H +#include "DatabaseEnvFwd.h" #include "Define.h" #include "DBCEnums.h" #include "ItemEnchantmentMgr.h" -- cgit v1.2.3 From 7dcc185a151745c8a12e23708bb5d457e5796032 Mon Sep 17 00:00:00 2001 From: ariel- Date: Tue, 11 Apr 2017 23:57:29 -0300 Subject: Core/Instance: stop updating the instance resettimes based on creature respawns - Rather update normal instance reset time to 2 hours after last creature kill - This fixes yet another integer overflow due to the possibility of having time_t max showing up - Also change respawntime and resettime fields to bigint on respawn/instance related tables - Start using prepared statements on the InstanceSaveMgr (cherry picked from commit 4c593f12caa162c1bfb831bdbed934bb39155ddb) --- sql/base/characters_database.sql | 11 ++-- ...4_26_01_characters_2017_04_12_01_characters.sql | 4 ++ .../Database/Implementation/CharacterDatabase.cpp | 5 +- .../Database/Implementation/CharacterDatabase.h | 3 +- src/server/game/Entities/Player/Player.cpp | 5 +- src/server/game/Entities/Unit/Unit.cpp | 2 +- src/server/game/Instances/InstanceSaveMgr.cpp | 62 +++++++++++----------- src/server/game/Maps/Map.cpp | 8 +-- 8 files changed, 54 insertions(+), 46 deletions(-) create mode 100644 sql/updates/characters/master/2020_04_26_01_characters_2017_04_12_01_characters.sql (limited to 'src') diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql index b23013bc0d1..625ad4ef783 100644 --- a/sql/base/characters_database.sql +++ b/sql/base/characters_database.sql @@ -1895,7 +1895,7 @@ DROP TABLE IF EXISTS `creature_respawn`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `creature_respawn` ( `guid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier', - `respawnTime` int(10) unsigned NOT NULL DEFAULT '0', + `respawnTime` bigint(20) unsigned NOT NULL DEFAULT '0', `mapId` smallint(10) unsigned NOT NULL DEFAULT '0', `instanceId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Instance Identifier', PRIMARY KEY (`guid`,`instanceId`), @@ -1969,7 +1969,7 @@ DROP TABLE IF EXISTS `gameobject_respawn`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `gameobject_respawn` ( `guid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier', - `respawnTime` int(10) unsigned NOT NULL DEFAULT '0', + `respawnTime` bigint(20) unsigned NOT NULL DEFAULT '0', `mapId` smallint(10) unsigned NOT NULL DEFAULT '0', `instanceId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Instance Identifier', PRIMARY KEY (`guid`,`instanceId`), @@ -2616,7 +2616,7 @@ DROP TABLE IF EXISTS `instance`; CREATE TABLE `instance` ( `id` int(10) unsigned NOT NULL DEFAULT '0', `map` smallint(5) unsigned NOT NULL DEFAULT '0', - `resettime` int(10) unsigned NOT NULL DEFAULT '0', + `resettime` bigint(20) unsigned NOT NULL DEFAULT '0', `difficulty` tinyint(3) unsigned NOT NULL DEFAULT '0', `completedEncounters` int(10) unsigned NOT NULL DEFAULT '0', `data` tinytext NOT NULL, @@ -2647,7 +2647,7 @@ DROP TABLE IF EXISTS `instance_reset`; CREATE TABLE `instance_reset` ( `mapid` smallint(5) unsigned NOT NULL DEFAULT '0', `difficulty` tinyint(3) unsigned NOT NULL DEFAULT '0', - `resettime` int(10) unsigned NOT NULL DEFAULT '0', + `resettime` bigint(20) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`mapid`,`difficulty`), KEY `difficulty` (`difficulty`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -3773,7 +3773,8 @@ INSERT INTO `updates` VALUES ('2020_04_20_00_characters.sql','977B5E0C894E0A7E80B2A9626F17CA636A69BD22','RELEASED','2020-04-20 19:08:18',0), ('2020_04_24_00_characters.sql','85E2E0395A9457A53D73A9E0A7BB39B7E4C429BF','RELEASED','2020-04-24 22:04:59',0), ('2020_04_25_00_characters_2017_04_03_00_characters.sql','00FA3EFADAF807AC96619A3FE47216E21C3FCB19','RELEASED','2020-04-25 00:00:00',0), -('2020_04_26_00_characters_2017_04_12_00_characters.sql','86AA94DA9B1EA283101100886C10F648C0CE6494','RELEASED','2020-04-26 00:00:00',0); +('2020_04_26_00_characters_2017_04_12_00_characters.sql','86AA94DA9B1EA283101100886C10F648C0CE6494','RELEASED','2020-04-26 00:00:00',0), +('2020_04_26_01_characters_2017_04_12_01_characters.sql','5A8A1215E3A2356722F52CD7A64BBE03D21FBEA3','RELEASED','2020-04-26 00:00:00',0); /*!40000 ALTER TABLE `updates` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/updates/characters/master/2020_04_26_01_characters_2017_04_12_01_characters.sql b/sql/updates/characters/master/2020_04_26_01_characters_2017_04_12_01_characters.sql new file mode 100644 index 00000000000..ed5617d2750 --- /dev/null +++ b/sql/updates/characters/master/2020_04_26_01_characters_2017_04_12_01_characters.sql @@ -0,0 +1,4 @@ +ALTER TABLE `creature_respawn` CHANGE `respawnTime` `respawnTime` bigint(20) unsigned NOT NULL DEFAULT '0'; +ALTER TABLE `gameobject_respawn` CHANGE `respawnTime` `respawnTime` bigint(20) unsigned NOT NULL DEFAULT '0'; +ALTER TABLE `instance` CHANGE `resettime` `resettime` bigint(20) unsigned NOT NULL DEFAULT '0'; +ALTER TABLE `instance_reset` CHANGE `resettime` `resettime` bigint(20) unsigned NOT NULL DEFAULT '0'; diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp index 26d3a907c6e..24ae14580f9 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp @@ -429,7 +429,6 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_REP_CREATURE_RESPAWN, "REPLACE INTO creature_respawn (guid, respawnTime, mapId, instanceId) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CREATURE_RESPAWN, "DELETE FROM creature_respawn WHERE guid = ? AND mapId = ? AND instanceId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE, "DELETE FROM creature_respawn WHERE mapId = ? AND instanceId = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_MAX_CREATURE_RESPAWNS, "SELECT MAX(respawnTime), instanceId FROM creature_respawn WHERE instanceId > 0 GROUP BY instanceId", CONNECTION_SYNCH); // Gameobject respawn PrepareStatement(CHAR_SEL_GO_RESPAWNS, "SELECT guid, respawnTime FROM gameobject_respawn WHERE mapId = ? AND instanceId = ?", CONNECTION_SYNCH); @@ -511,7 +510,9 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_GROUP_INSTANCE_BY_GUID, "DELETE FROM group_instance WHERE guid = ? AND instance = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_REP_GROUP_INSTANCE, "REPLACE INTO group_instance (guid, instance, permanent) VALUES (?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_INSTANCE_RESETTIME, "UPDATE instance SET resettime = ? WHERE id = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME, "UPDATE instance_reset SET resettime = ? WHERE mapid = ? AND difficulty = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_GLOBAL_INSTANCE_RESETTIME, "INSERT INTO instance_reset (mapid, difficulty, resettime) VALUES (?, ?, ?)", CONNECTION_SYNCH); + PrepareStatement(CHAR_DEL_GLOBAL_INSTANCE_RESETTIME, "DELETE FROM instance_reset WHERE mapid = ? AND difficulty = ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME, "UPDATE instance_reset SET resettime = ? WHERE mapid = ? AND difficulty = ?", CONNECTION_BOTH); PrepareStatement(CHAR_UPD_CHAR_ONLINE, "UPDATE characters SET online = 1 WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_CHAR_NAME_AT_LOGIN, "UPDATE characters SET name = ?, at_login = ? WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_WORLDSTATE, "UPDATE worldstates SET value = ? WHERE entry = ?", CONNECTION_ASYNC); diff --git a/src/server/database/Database/Implementation/CharacterDatabase.h b/src/server/database/Database/Implementation/CharacterDatabase.h index 8e1f12416b0..8dc1d522e47 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.h +++ b/src/server/database/Database/Implementation/CharacterDatabase.h @@ -340,7 +340,6 @@ enum CharacterDatabaseStatements : uint32 CHAR_REP_CREATURE_RESPAWN, CHAR_DEL_CREATURE_RESPAWN, CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE, - CHAR_SEL_MAX_CREATURE_RESPAWNS, CHAR_SEL_GO_RESPAWNS, CHAR_REP_GO_RESPAWN, @@ -400,6 +399,8 @@ enum CharacterDatabaseStatements : uint32 CHAR_DEL_GROUP_INSTANCE_BY_GUID, CHAR_REP_GROUP_INSTANCE, CHAR_UPD_INSTANCE_RESETTIME, + CHAR_INS_GLOBAL_INSTANCE_RESETTIME, + CHAR_DEL_GLOBAL_INSTANCE_RESETTIME, CHAR_UPD_GLOBAL_INSTANCE_RESETTIME, CHAR_UPD_CHAR_ONLINE, CHAR_UPD_CHAR_NAME_AT_LOGIN, diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index abad9678510..ee367012efd 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -19819,7 +19819,8 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) Group* group = GetGroup(); - //QueryResult* result = CharacterDatabase.PQuery("SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); + // 0 1 2 3 4 5 6 + // SELECT id, permanent, map, difficulty, extendState, resettime, entranceId FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = ? if (result) { do @@ -19832,7 +19833,7 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) uint8 difficulty = fields[3].GetUInt8(); BindExtensionState extendState = BindExtensionState(fields[4].GetUInt8()); - time_t resetTime = time_t(fields[5].GetUInt32()); + time_t resetTime = time_t(fields[5].GetUInt64()); // the resettime for normal instances is only saved when the InstanceSave is unloaded // so the value read from the DB may be wrong here but only if the InstanceSave is loaded // and in that case it is not used diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 674864da67f..d522deddc03 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -11513,7 +11513,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) { // the reset time is set but not added to the scheduler // until the players leave the instance - time_t resettime = creature->GetRespawnTimeEx() + 2 * HOUR; + time_t resettime = GameTime::GetGameTime() + 2 * HOUR; if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(creature->GetInstanceId())) if (save->GetResetTime() < resettime) save->SetResetTime(resettime); diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index 903e4f084d6..fdeee7535a1 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -168,7 +168,7 @@ void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId) { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_INSTANCE_RESETTIME); - stmt->setUInt32(0, uint32(resettime)); + stmt->setUInt64(0, uint64(resettime)); stmt->setUInt32(1, InstanceId); CharacterDatabase.Execute(stmt); @@ -222,7 +222,7 @@ void InstanceSave::SaveToDB() CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_INSTANCE_SAVE); stmt->setUInt32(0, m_instanceid); stmt->setUInt16(1, GetMapId()); - stmt->setUInt32(2, uint32(GetResetTimeForDB())); + stmt->setUInt64(2, uint64(GetResetTimeForDB())); stmt->setUInt8(3, uint8(GetDifficultyID())); stmt->setUInt32(4, completedEncounters); stmt->setString(5, data); @@ -329,8 +329,7 @@ void InstanceSaveManager::LoadResetTimes() typedef std::pair ResetTimeMapDiffInstancesBounds; ResetTimeMapDiffInstances mapDiffResetInstances; - QueryResult result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance ORDER BY id ASC"); - if (result) + if (QueryResult result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance ORDER BY id ASC")) { do { @@ -346,7 +345,7 @@ void InstanceSaveManager::LoadResetTimes() // Mark instance id as being used sMapMgr->RegisterInstanceId(instanceId); - if (time_t resettime = time_t(fields[3].GetUInt32())) + if (time_t resettime = time_t(fields[3].GetUInt64())) { uint32 mapid = fields[1].GetUInt16(); uint32 difficulty = fields[2].GetUInt8(); @@ -357,24 +356,6 @@ void InstanceSaveManager::LoadResetTimes() } while (result->NextRow()); - // update reset time for normal instances with the max creature respawn time + X hours - if (PreparedQueryResult result2 = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAX_CREATURE_RESPAWNS))) - { - do - { - Field* fields = result2->Fetch(); - uint32 instance = fields[1].GetUInt32(); - time_t resettime = time_t(fields[0].GetUInt32() + 2 * HOUR); - InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance); - if (itr != instResetTime.end() && itr->second.second != resettime) - { - CharacterDatabase.DirectPExecute("UPDATE instance SET resettime = '" UI64FMTD "' WHERE id = '%u'", uint64(resettime), instance); - itr->second.second = resettime; - } - } - while (result2->NextRow()); - } - // schedule the reset times for (InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr) if (itr->second.second > now) @@ -383,28 +364,37 @@ void InstanceSaveManager::LoadResetTimes() // load the global respawn times for raid/heroic instances uint32 diff = sWorld->getIntConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR; - result = CharacterDatabase.Query("SELECT mapid, difficulty, resettime FROM instance_reset"); - if (result) + if (QueryResult result = CharacterDatabase.Query("SELECT mapid, difficulty, resettime FROM instance_reset")) { do { Field* fields = result->Fetch(); uint32 mapid = fields[0].GetUInt16(); Difficulty difficulty = Difficulty(fields[1].GetUInt8()); - uint64 oldresettime = fields[2].GetUInt32(); + uint64 oldresettime = fields[2].GetUInt64(); MapDifficultyEntry const* mapDiff = sDB2Manager.GetMapDifficultyData(mapid, difficulty); if (!mapDiff) { TC_LOG_ERROR("misc", "InstanceSaveManager::LoadResetTimes: invalid mapid(%u)/difficulty(%u) pair in instance_reset!", mapid, uint32(difficulty)); - CharacterDatabase.DirectPExecute("DELETE FROM instance_reset WHERE mapid = '%u' AND difficulty = '%u'", mapid, uint32(difficulty)); + + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GLOBAL_INSTANCE_RESETTIME); + stmt->setUInt16(0, uint16(mapid)); + stmt->setUInt8(1, uint8(difficulty)); + CharacterDatabase.DirectExecute(stmt); continue; } // update the reset time if the hour in the configs changes uint64 newresettime = (oldresettime / DAY) * DAY + diff; if (oldresettime != newresettime) - CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '%u' WHERE mapid = '%u' AND difficulty = '%u'", uint32(newresettime), mapid, uint32(difficulty)); + { + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME); + stmt->setUInt64(0, uint64(newresettime)); + stmt->setUInt16(1, uint16(mapid)); + stmt->setUInt8(2, uint8(difficulty)); + CharacterDatabase.DirectExecute(stmt); + } InitializeResetTimeFor(mapid, difficulty, newresettime); } while (result->NextRow()); @@ -433,7 +423,12 @@ void InstanceSaveManager::LoadResetTimes() { // initialize the reset time t = today + period + diff; - CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u', '%u', '%u')", mapid, uint32(difficulty), (uint32)t); + + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GLOBAL_INSTANCE_RESETTIME); + stmt->setUInt16(0, uint16(mapid)); + stmt->setUInt8(1, uint8(difficulty)); + stmt->setUInt64(2, uint64(t)); + CharacterDatabase.DirectExecute(stmt); } if (t < now) @@ -442,7 +437,12 @@ void InstanceSaveManager::LoadResetTimes() // calculate the next reset time t = (t / DAY) * DAY; t += ((today - t) / period + 1) * period + diff; - CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '" UI64FMTD "' WHERE mapid = '%u' AND difficulty= '%u'", (uint64)t, mapid, uint32(difficulty)); + + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME); + stmt->setUInt64(0, uint64(t)); + stmt->setUInt16(1, uint16(mapid)); + stmt->setUInt8(2, uint8(difficulty)); + CharacterDatabase.DirectExecute(stmt); } InitializeResetTimeFor(mapid, difficulty, t); @@ -702,7 +702,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b // Update it in the DB stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME); - stmt->setUInt32(0, next_reset); + stmt->setUInt64(0, uint64(next_reset)); stmt->setUInt16(1, uint16(mapid)); stmt->setUInt8(2, uint8(difficulty)); diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 7b83e3412d5..24392412710 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3982,7 +3982,7 @@ void Map::SaveCreatureRespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CREATURE_RESPAWN); stmt->setUInt64(0, dbGuid); - stmt->setUInt32(1, uint32(respawnTime)); + stmt->setUInt64(1, uint64(respawnTime)); stmt->setUInt16(2, GetId()); stmt->setUInt32(3, GetInstanceId()); CharacterDatabase.Execute(stmt); @@ -4012,7 +4012,7 @@ void Map::SaveGORespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime) CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GO_RESPAWN); stmt->setUInt64(0, dbGuid); - stmt->setUInt32(1, uint32(respawnTime)); + stmt->setUInt64(1, uint64(respawnTime)); stmt->setUInt16(2, GetId()); stmt->setUInt32(3, GetInstanceId()); CharacterDatabase.Execute(stmt); @@ -4040,7 +4040,7 @@ void Map::LoadRespawnTimes() { Field* fields = result->Fetch(); ObjectGuid::LowType loguid = fields[0].GetUInt64(); - uint32 respawnTime = fields[1].GetUInt32(); + uint64 respawnTime = fields[1].GetUInt64(); _creatureRespawnTimes[loguid] = time_t(respawnTime); } while (result->NextRow()); @@ -4055,7 +4055,7 @@ void Map::LoadRespawnTimes() { Field* fields = result->Fetch(); ObjectGuid::LowType loguid = fields[0].GetUInt64(); - uint32 respawnTime = fields[1].GetUInt32(); + uint64 respawnTime = fields[1].GetUInt64(); _goRespawnTimes[loguid] = time_t(respawnTime); } while (result->NextRow()); -- cgit v1.2.3 From fc0a037eef2a6a1dd1cc43f0233aaa1d400393be Mon Sep 17 00:00:00 2001 From: ariel- Date: Wed, 12 Apr 2017 02:53:25 -0300 Subject: Core/Spell: fix SPELL_ATTR3_IGNORE_HIT_RESULT bypassing reflects Closes #19440 (cherry picked from commit 83177e771a373514913d066e14d5a7f9775407fe) --- src/server/game/Entities/Unit/Unit.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index d522deddc03..93ea45dc476 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2616,18 +2616,6 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo // Resist SpellMissInfo Unit::SpellHitResult(Unit* victim, SpellInfo const* spellInfo, bool canReflect /*= false*/) { - if (spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT)) - return SPELL_MISS_NONE; - - // Check for immune - if (victim->IsImmunedToSpell(spellInfo, this)) - return SPELL_MISS_IMMUNE; - - // Damage immunity is only checked if the spell has damage effects, this immunity must not prevent aura apply - // returns SPELL_MISS_IMMUNE in that case, for other spells, the SMSG_SPELL_GO must show hit - if (spellInfo->HasOnlyDamageEffects() && victim->IsImmunedToDamage(spellInfo)) - return SPELL_MISS_IMMUNE; - // All positive spells can`t miss /// @todo client not show miss log for this spells - so need find info for this in dbc and use it! if (spellInfo->IsPositive() && !IsHostileTo(victim)) // prevent from affecting enemy by "positive" spell @@ -2650,6 +2638,18 @@ SpellMissInfo Unit::SpellHitResult(Unit* victim, SpellInfo const* spellInfo, boo return SPELL_MISS_REFLECT; } + if (spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT)) + return SPELL_MISS_NONE; + + // Check for immune + if (victim->IsImmunedToSpell(spellInfo, this)) + return SPELL_MISS_IMMUNE; + + // Damage immunity is only checked if the spell has damage effects, this immunity must not prevent aura apply + // returns SPELL_MISS_IMMUNE in that case, for other spells, the SMSG_SPELL_GO must show hit + if (spellInfo->HasOnlyDamageEffects() && victim->IsImmunedToDamage(spellInfo)) + return SPELL_MISS_IMMUNE; + switch (spellInfo->DmgClass) { case SPELL_DAMAGE_CLASS_RANGED: -- cgit v1.2.3 From 296abf3e1229ea477fa5e266a6375c4a970f6300 Mon Sep 17 00:00:00 2001 From: ariel- Date: Wed, 12 Apr 2017 13:31:11 -0300 Subject: Core/Player: fix use after free crash (cherry picked from commit d914c55c0585fe31a9a1b9fe4e9d4a9b498e8e8f) --- src/server/game/Entities/Player/Player.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index ee367012efd..c511f318309 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -13875,10 +13875,11 @@ void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del) pItem->RemoveFromWorld(); if (del) { - pItem->SetState(ITEM_REMOVED, this); if (ItemTemplate const* itemTemplate = pItem->GetTemplate()) if (itemTemplate->GetFlags() & ITEM_FLAG_HAS_LOOT) sLootItemStorage->RemoveStoredLootForContainer(pItem->GetGUID().GetCounter()); + + pItem->SetState(ITEM_REMOVED, this); } } -- cgit v1.2.3 From f31e380499b9ecceca9e86b1ee55eb29c7f87c88 Mon Sep 17 00:00:00 2001 From: ariel- Date: Thu, 13 Apr 2017 03:18:20 -0300 Subject: Core/Spell: check aura positivity per effect on spell hit - Fixes applying DR to positive effects, and changing duration of whole aura Closes #19447 (cherry picked from commit 232e631390a504b51d82a7b678b7cf26d49d182a) --- src/server/game/Entities/Unit/Unit.cpp | 7 +++---- src/server/game/Entities/Unit/Unit.h | 2 +- src/server/game/Spells/Spell.cpp | 23 ++++++++++++++++------- 3 files changed, 20 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 93ea45dc476..bb739265c0d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -9208,11 +9208,11 @@ void Unit::IncrDiminishing(SpellInfo const* auraSpellInfo) ++diminish.hitCount; } -float Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, int32& duration, Unit* caster, DiminishingLevels previousLevel) +bool Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, int32& duration, Unit* caster, DiminishingLevels previousLevel) const { DiminishingGroup const group = auraSpellInfo->GetDiminishingReturnsGroupForSpell(); if (duration == -1 || group == DIMINISHING_NONE) - return 1.0f; + return true; int32 const limitDuration = auraSpellInfo->GetDiminishingReturnsLimitDuration(); @@ -9232,7 +9232,6 @@ float Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, int32& du } float mod = 1.0f; - switch (group) { case DIMINISHING_TAUNT: @@ -9289,7 +9288,7 @@ float Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, int32& du } duration = int32(duration * mod); - return mod; + return (duration != 0); } void Unit::ApplyDiminishingAura(DiminishingGroup group, bool apply) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 70271f3023b..d0a246d6b90 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -948,7 +948,7 @@ class TC_GAME_API Unit : public WorldObject DiminishingLevels GetDiminishing(DiminishingGroup group); void IncrDiminishing(SpellInfo const* auraSpellInfo); - float ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, int32& duration, Unit* caster, DiminishingLevels previousLevel); + bool ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, int32& duration, Unit* caster, DiminishingLevels previousLevel) const; void ApplyDiminishingAura(DiminishingGroup group, bool apply); void ClearDiminishings(); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index a03788cdda5..4c2468cc3bc 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2626,11 +2626,24 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask) } // Now Reduce spell duration using data received at spell hit + // check whatever effects we're going to apply, diminishing returns only apply to negative aura effects + bool positive = true; + if (m_originalCaster == unit || !m_originalCaster->IsFriendlyTo(unit)) + { + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + { + if ((effectMask & (1 << i)) && !m_spellInfo->IsPositiveEffect(i)) + { + positive = false; + break; + } + } + } + int32 duration = m_spellAura->GetMaxDuration(); - float diminishMod = unit->ApplyDiminishingToDuration(m_spellInfo, duration, m_originalCaster, diminishLevel); // unit is immune to aura if it was diminished to 0 duration - if (diminishMod == 0.0f) + if (!positive && !unit->ApplyDiminishingToDuration(m_spellInfo, duration, m_originalCaster, diminishLevel)) { m_spellAura->Remove(); bool found = false; @@ -2642,11 +2655,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask) } else { - ((UnitAura*)m_spellAura)->SetDiminishGroup(diminishGroup); - - bool positive = m_spellAura->GetSpellInfo()->IsPositive(); - if (AuraApplication* aurApp = m_spellAura->GetApplicationOfTarget(m_originalCaster->GetGUID())) - positive = aurApp->IsPositive(); + static_cast(m_spellAura)->SetDiminishGroup(diminishGroup); duration = m_originalCaster->ModSpellDuration(m_spellInfo, unit, duration, positive, effectMask); -- cgit v1.2.3 From 52e00746cf4a8f1b5455210dfe1baed0f342f2c4 Mon Sep 17 00:00:00 2001 From: ariel- Date: Fri, 14 Apr 2017 03:47:23 -0300 Subject: Core/Spell: fixed SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT to actually check effects - This commit enables stack rule 3 to be properly used to fix auras that should be active but only one providing effects, even if the spell has multiple auras Closes #19454 (cherry picked from commit 9900899dd9d7f685a1c862bc75e7614e3f0a3ce6) --- src/server/game/Entities/Unit/Unit.cpp | 4 +- src/server/game/Spells/SpellMgr.cpp | 174 +++++++++++++++++++++++++++------ src/server/game/Spells/SpellMgr.h | 12 ++- 3 files changed, 152 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index bb739265c0d..70b236dc980 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -4664,7 +4664,7 @@ int32 Unit::GetTotalAuraModifier(AuraType auratype, std::functionAddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), aurEff->GetAmount(), sameEffectSpellGroup)) + if (!sSpellMgr->AddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), auratype, aurEff->GetAmount(), sameEffectSpellGroup)) modifier += aurEff->GetAmount(); } } @@ -4691,7 +4691,7 @@ float Unit::GetTotalAuraMultiplier(AuraType auratype, std::functionAddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), aurEff->GetAmount(), sameEffectSpellGroup)) + if (!sSpellMgr->AddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), auratype, aurEff->GetAmount(), sameEffectSpellGroup)) AddPct(multiplier, aurEff->GetAmount()); } } diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 1dcc18773e1..7b176fbb94a 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -335,32 +335,34 @@ void SpellMgr::GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set& } } -bool SpellMgr::AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, int32 amount, std::map& groups) const +bool SpellMgr::AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, AuraType auraType, int32 amount, std::map& groups) const { uint32 spellId = spellInfo->GetFirstRankSpell()->Id; - SpellSpellGroupMapBounds spellGroup = GetSpellSpellGroupMapBounds(spellId); + auto spellGroupBounds = GetSpellSpellGroupMapBounds(spellId); // Find group with SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT if it belongs to one - for (SpellSpellGroupMap::const_iterator itr = spellGroup.first; itr != spellGroup.second; ++itr) + for (auto itr = spellGroupBounds.first; itr != spellGroupBounds.second; ++itr) { SpellGroup group = itr->second; - SpellGroupStackMap::const_iterator found = mSpellGroupStack.find(group); - if (found != mSpellGroupStack.end()) + auto found = mSpellSameEffectStack.find(group); + if (found != mSpellSameEffectStack.end()) { - if (found->second == SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT) + // check auraTypes + if (!found->second.count(uint32(auraType))) + continue; + + // Put the highest amount in the map + auto groupItr = groups.find(group); + if (groupItr == groups.end()) + groups.emplace(group, amount); + else { - // Put the highest amount in the map - if (groups.find(group) == groups.end()) - groups[group] = amount; - else - { - int32 curr_amount = groups[group]; - // Take absolute value because this also counts for the highest negative aura - if (abs(curr_amount) < abs(amount)) - groups[group] = amount; - } - // return because a spell should be in only one SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT group - return true; + int32 curr_amount = groups[group]; + // Take absolute value because this also counts for the highest negative aura + if (std::abs(curr_amount) < std::abs(amount)) + groupItr->second = amount; } + // return because a spell should be in only one SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT group per auraType + return true; } } // Not in a SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT group, so return false @@ -1181,19 +1183,19 @@ void SpellMgr::LoadSpellGroups() } int32 spell_id = fields[1].GetInt32(); - groups.insert(std::set::value_type(group_id)); - mSpellGroupSpell.insert(SpellGroupSpellMap::value_type((SpellGroup)group_id, spell_id)); + groups.insert(group_id); + mSpellGroupSpell.emplace(SpellGroup(group_id), spell_id); } while (result->NextRow()); - for (SpellGroupSpellMap::iterator itr = mSpellGroupSpell.begin(); itr!= mSpellGroupSpell.end();) + for (auto itr = mSpellGroupSpell.begin(); itr!= mSpellGroupSpell.end();) { if (itr->second < 0) { if (groups.find(abs(itr->second)) == groups.end()) { TC_LOG_ERROR("sql.sql", "SpellGroup id %u listed in `spell_group` does not exist", abs(itr->second)); - mSpellGroupSpell.erase(itr++); + itr = mSpellGroupSpell.erase(itr); } else ++itr; @@ -1201,31 +1203,30 @@ void SpellMgr::LoadSpellGroups() else { SpellInfo const* spellInfo = GetSpellInfo(itr->second); - if (!spellInfo) { TC_LOG_ERROR("sql.sql", "The spell %u listed in `spell_group` does not exist", itr->second); - mSpellGroupSpell.erase(itr++); + itr = mSpellGroupSpell.erase(itr); } else if (spellInfo->GetRank() > 1) { TC_LOG_ERROR("sql.sql", "The spell %u listed in `spell_group` is not the first rank of the spell.", itr->second); - mSpellGroupSpell.erase(itr++); + itr = mSpellGroupSpell.erase(itr); } else ++itr; } } - for (std::set::iterator groupItr = groups.begin(); groupItr != groups.end(); ++groupItr) + for (auto groupItr = groups.begin(); groupItr != groups.end(); ++groupItr) { std::set spells; GetSetOfSpellsInSpellGroup(SpellGroup(*groupItr), spells); - for (std::set::iterator spellItr = spells.begin(); spellItr != spells.end(); ++spellItr) + for (auto spellItr = spells.begin(); spellItr != spells.end(); ++spellItr) { ++count; - mSpellSpellGroup.insert(SpellSpellGroupMap::value_type(*spellItr, SpellGroup(*groupItr))); + mSpellSpellGroup.emplace(*spellItr, SpellGroup(*groupItr)); } } @@ -1237,6 +1238,9 @@ void SpellMgr::LoadSpellGroupStackRules() uint32 oldMSTime = getMSTime(); mSpellGroupStack.clear(); // need for reload case + mSpellSameEffectStack.clear(); + + std::vector sameEffectGroups; // 0 1 QueryResult result = WorldDatabase.Query("SELECT group_id, stack_rule FROM spell_group_stack_rules"); @@ -1259,20 +1263,126 @@ void SpellMgr::LoadSpellGroupStackRules() continue; } - SpellGroupSpellMapBounds spellGroup = GetSpellGroupSpellMapBounds((SpellGroup)group_id); - - if (spellGroup.first == spellGroup.second) + auto bounds = GetSpellGroupSpellMapBounds((SpellGroup)group_id); + if (bounds.first == bounds.second) { TC_LOG_ERROR("sql.sql", "SpellGroup id %u listed in `spell_group_stack_rules` does not exist.", group_id); continue; } - mSpellGroupStack[(SpellGroup)group_id] = (SpellGroupStackRule)stack_rule; + // different container for same effect stack rules, need to check effect types + if (stack_rule != SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT) + mSpellGroupStack.emplace(SpellGroup(group_id), SpellGroupStackRule(stack_rule)); + else + sameEffectGroups.push_back(group_id); ++count; } while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded %u spell group stack rules in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); + + count = 0; + oldMSTime = getMSTime(); + TC_LOG_INFO("server.loading", ">> Parsing SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT stack rules..."); + + for (uint32 group_id : sameEffectGroups) + { + std::set spellIds; + GetSetOfSpellsInSpellGroup(SpellGroup(group_id), spellIds); + + std::unordered_set auraTypes; + + // we have to 'guess' what effect this group corresponds to + { + std::unordered_multiset frequencyContainer; + + // only waylay for the moment (shared group) + std::vector> const SubGroups = + { + { SPELL_AURA_MOD_MELEE_HASTE, SPELL_AURA_MOD_MELEE_RANGED_HASTE, SPELL_AURA_MOD_RANGED_HASTE } + }; + + for (uint32 spellId : spellIds) + { + SpellInfo const* spellInfo = AssertSpellInfo(spellId); + for (SpellEffectInfo const* effectInfo : spellInfo->GetEffectsForDifficulty(DIFFICULTY_NONE)) + { + if (!effectInfo->IsAura()) + continue; + + int32 auraName = static_cast(effectInfo->ApplyAuraName); + for (std::vector const& subGroup : SubGroups) + { + if (std::find(subGroup.begin(), subGroup.end(), auraName) != subGroup.end()) + { + // count as first aura + auraName = subGroup.front(); + break; + } + } + + frequencyContainer.insert(auraName); + } + } + + uint32 auraType = 0; + size_t auraTypeCount = 0; + for (uint32 auraName : frequencyContainer) + { + size_t currentCount = frequencyContainer.count(auraName); + if (currentCount > auraTypeCount) + { + auraType = auraName; + auraTypeCount = currentCount; + } + } + + for (std::vector const& subGroup : SubGroups) + { + if (auraType == subGroup.front()) + { + auraTypes.insert(subGroup.begin(), subGroup.end()); + break; + } + } + + if (auraTypes.empty()) + auraTypes.insert(auraType); + } + + // re-check spells against guessed group + for (uint32 spellId : spellIds) + { + SpellInfo const* spellInfo = AssertSpellInfo(spellId); + + bool found = false; + while (spellInfo) + { + for (uint32 auraType : auraTypes) + { + if (spellInfo->HasAura(DIFFICULTY_NONE, AuraType(auraType))) + { + found = true; + break; + } + } + + if (found) + break; + + spellInfo = spellInfo->GetNextRankSpell(); + } + + // not found either, log error + if (!found) + TC_LOG_ERROR("sql.sql", "SpellId %u listed in `spell_group` with stack rule 3 does not share aura assigned for group %u", spellId, group_id); + } + + mSpellSameEffectStack[SpellGroup(group_id)] = auraTypes; + ++count; + } + + TC_LOG_INFO("server.loading", ">> Parsed %u SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT stack rules in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } void SpellMgr::LoadSpellProcs() diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index 6bf843cfff1..8de5c791822 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -31,6 +31,7 @@ #include #include #include +#include class SpellInfo; class Player; @@ -312,11 +313,11 @@ enum SpellGroup #define SPELL_GROUP_DB_RANGE_MIN 1000 // spell_id, group_id -typedef std::multimap SpellSpellGroupMap; +typedef std::unordered_multimap SpellSpellGroupMap; typedef std::pair SpellSpellGroupMapBounds; // group_id, spell_id -typedef std::multimap SpellGroupSpellMap; +typedef std::unordered_multimap SpellGroupSpellMap; typedef std::pair SpellGroupSpellMapBounds; enum SpellGroupStackRule @@ -329,7 +330,9 @@ enum SpellGroupStackRule SPELL_GROUP_STACK_RULE_MAX }; -typedef std::map SpellGroupStackMap; +typedef std::unordered_map SpellGroupStackMap; + +typedef std::unordered_map> SameEffectStackMap; struct SpellThreatEntry { @@ -655,7 +658,7 @@ class TC_GAME_API SpellMgr void GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set& foundSpells, std::set& usedGroups) const; // Spell Group Stack Rules table - bool AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, int32 amount, std::map& groups) const; + bool AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, AuraType auraType, int32 amount, std::map& groups) const; SpellGroupStackRule CheckSpellGroupStackRules(SpellInfo const* spellInfo1, SpellInfo const* spellInfo2) const; SpellGroupStackRule GetSpellGroupStackRule(SpellGroup groupid) const; @@ -750,6 +753,7 @@ class TC_GAME_API SpellMgr SpellSpellGroupMap mSpellSpellGroup; SpellGroupSpellMap mSpellGroupSpell; SpellGroupStackMap mSpellGroupStack; + SameEffectStackMap mSpellSameEffectStack; SpellProcMap mSpellProcMap; SpellThreatMap mSpellThreatMap; SpellPetAuraMap mSpellPetAuraMap; -- cgit v1.2.3 From 4523c5619b3b9b1b6dd4087b53f3218814c0564d Mon Sep 17 00:00:00 2001 From: ariel- Date: Fri, 14 Apr 2017 04:26:27 -0300 Subject: Core/Spell: build fix (cherry picked from commit 9a051570035f7812786158eb00cf482af35bfb10) --- src/server/game/Spells/SpellMgr.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index 8de5c791822..470ce497644 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -310,6 +310,18 @@ enum SpellGroup SPELL_GROUP_CORE_RANGE_MAX = 5 }; +namespace std +{ + template<> + struct hash + { + size_t operator()(SpellGroup const& group) const + { + return hash()(uint32(group)); + } + }; +} + #define SPELL_GROUP_DB_RANGE_MIN 1000 // spell_id, group_id -- cgit v1.2.3 From 3675d2b49468417efd3df5084a761131acd1910a Mon Sep 17 00:00:00 2001 From: ariel- Date: Fri, 14 Apr 2017 04:36:12 -0300 Subject: Core/Spell: fix nopch build (cherry picked from commit f0a93140e88d9dad96aaf60faf0cb8b6e22b5a97) --- src/server/game/Spells/SpellMgr.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index 470ce497644..c2b9cdbf479 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -55,6 +55,7 @@ struct SpellScalingEntry; struct SpellShapeshiftEntry; struct SpellTargetRestrictionsEntry; struct SpellTotemsEntry; +enum AuraType; // only used in code enum SpellCategories -- cgit v1.2.3 From 60824d8c7af4f3a5c6756049939f3533457ef098 Mon Sep 17 00:00:00 2001 From: ariel- Date: Fri, 14 Apr 2017 04:45:12 -0300 Subject: Core/Spell: fix nopch build x2 (cherry picked from commit abaa9d635a6c52f78ec5eb87a5a39890645d5649) --- src/server/game/Entities/Unit/Unit.cpp | 4 ++-- src/server/game/Spells/SpellMgr.cpp | 4 ++-- src/server/game/Spells/SpellMgr.h | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 70b236dc980..c1ba570d498 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -4664,7 +4664,7 @@ int32 Unit::GetTotalAuraModifier(AuraType auratype, std::functionAddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), auratype, aurEff->GetAmount(), sameEffectSpellGroup)) + if (!sSpellMgr->AddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), static_cast(auratype), aurEff->GetAmount(), sameEffectSpellGroup)) modifier += aurEff->GetAmount(); } } @@ -4691,7 +4691,7 @@ float Unit::GetTotalAuraMultiplier(AuraType auratype, std::functionAddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), auratype, aurEff->GetAmount(), sameEffectSpellGroup)) + if (!sSpellMgr->AddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), static_cast(auratype), aurEff->GetAmount(), sameEffectSpellGroup)) AddPct(multiplier, aurEff->GetAmount()); } } diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 7b176fbb94a..496b6386581 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -335,7 +335,7 @@ void SpellMgr::GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set& } } -bool SpellMgr::AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, AuraType auraType, int32 amount, std::map& groups) const +bool SpellMgr::AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, uint32 auraType, int32 amount, std::map& groups) const { uint32 spellId = spellInfo->GetFirstRankSpell()->Id; auto spellGroupBounds = GetSpellSpellGroupMapBounds(spellId); @@ -347,7 +347,7 @@ bool SpellMgr::AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, Aur if (found != mSpellSameEffectStack.end()) { // check auraTypes - if (!found->second.count(uint32(auraType))) + if (!found->second.count(auraType)) continue; // Put the highest amount in the map diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index c2b9cdbf479..c121f1ec8f1 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -55,7 +55,6 @@ struct SpellScalingEntry; struct SpellShapeshiftEntry; struct SpellTargetRestrictionsEntry; struct SpellTotemsEntry; -enum AuraType; // only used in code enum SpellCategories @@ -671,7 +670,7 @@ class TC_GAME_API SpellMgr void GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set& foundSpells, std::set& usedGroups) const; // Spell Group Stack Rules table - bool AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, AuraType auraType, int32 amount, std::map& groups) const; + bool AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, uint32 auraType, int32 amount, std::map& groups) const; SpellGroupStackRule CheckSpellGroupStackRules(SpellInfo const* spellInfo1, SpellInfo const* spellInfo2) const; SpellGroupStackRule GetSpellGroupStackRule(SpellGroup groupid) const; -- cgit v1.2.3 From 1edfd0d064a4417bc0a2ad38e23e9830f26cb0c5 Mon Sep 17 00:00:00 2001 From: ariel- Date: Fri, 14 Apr 2017 16:52:13 -0300 Subject: Core/Spell: fix broken Unit::GetHighestExclusiveSameEffectSpellGroupValue - Affects 3 aura effects currently, should be rewritten with GetTotalAuraModifier maybe? (cherry picked from commit d44a44abacdf3f9fabc37e62806970f97e06332b) --- src/server/game/Spells/SpellMgr.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 496b6386581..22f2e0cd530 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -1270,10 +1270,10 @@ void SpellMgr::LoadSpellGroupStackRules() continue; } + mSpellGroupStack.emplace(SpellGroup(group_id), SpellGroupStackRule(stack_rule)); + // different container for same effect stack rules, need to check effect types - if (stack_rule != SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT) - mSpellGroupStack.emplace(SpellGroup(group_id), SpellGroupStackRule(stack_rule)); - else + if (stack_rule == SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT) sameEffectGroups.push_back(group_id); ++count; -- cgit v1.2.3 From 677df56d2da9eb5ae997537c9cc952ac86c8f8db Mon Sep 17 00:00:00 2001 From: ariel- Date: Fri, 14 Apr 2017 19:07:11 -0300 Subject: Core/Auras: don't skip stack rule check whenever spells have same ID - The auras might not have the same amounts due to spellmods Closes #1626 (cherry picked from commit 9414f50f5c60b03871b4bd8d147786f77476ea04) --- src/server/game/Spells/SpellMgr.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 22f2e0cd530..b1d52d1906e 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -376,8 +376,6 @@ SpellGroupStackRule SpellMgr::CheckSpellGroupStackRules(SpellInfo const* spellIn uint32 spellid_1 = spellInfo1->GetFirstRankSpell()->Id; uint32 spellid_2 = spellInfo2->GetFirstRankSpell()->Id; - if (spellid_1 == spellid_2) - return SPELL_GROUP_STACK_RULE_DEFAULT; // find SpellGroups which are common for both spells SpellSpellGroupMapBounds spellGroup1 = GetSpellSpellGroupMapBounds(spellid_1); -- cgit v1.2.3 From 71c2fda1132d5fba3864f133d0e3ee4e81de508f Mon Sep 17 00:00:00 2001 From: ariel- Date: Sat, 15 Apr 2017 15:58:56 -0300 Subject: Core/Spell: register spell mod owner properly on spell cast - This fixes pets and totems getting mods from owner (cherry picked from commit 8b52cf902bf98a05197efa4e96ddd6188eb1a178) --- src/server/game/Spells/Spell.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 4c2468cc3bc..337ca5e1423 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3125,11 +3125,12 @@ void Spell::_cast(bool skipCheck) m_caster->SetInFront(m_targets.GetObjectTarget()); // Should this be done for original caster? - if (m_caster->GetTypeId() == TYPEID_PLAYER) + Player* modOwner = m_caster->GetSpellModOwner(); + if (modOwner) { // Set spell which will drop charges for triggered cast spells // if not successfully cast, will be remove in finish(false) - m_caster->ToPlayer()->SetSpellModTakingSpell(this, true); + modOwner->SetSpellModTakingSpell(this, true); } CallScriptBeforeCastHandlers(); @@ -3144,8 +3145,8 @@ void Spell::_cast(bool skipCheck) SendCastResult(castResult, ¶m1, ¶m2); SendInterrupted(0); - if (m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->ToPlayer()->SetSpellModTakingSpell(this, false); + if (modOwner) + modOwner->SetSpellModTakingSpell(this, false); finish(false); SetExecutedCurrently(false); @@ -3156,9 +3157,9 @@ void Spell::_cast(bool skipCheck) // if trade not complete then remember it in trade data if (m_targets.GetTargetMask() & TARGET_FLAG_TRADE_ITEM) { - if (m_caster->GetTypeId() == TYPEID_PLAYER) + if (modOwner) { - if (TradeData* my_trade = m_caster->ToPlayer()->GetTradeData()) + if (TradeData* my_trade = modOwner->GetTradeData()) { if (!my_trade->IsInAcceptProcess()) { @@ -3167,7 +3168,7 @@ void Spell::_cast(bool skipCheck) SendCastResult(SPELL_FAILED_DONT_REPORT); SendInterrupted(0); - m_caster->ToPlayer()->SetSpellModTakingSpell(this, false); + modOwner->SetSpellModTakingSpell(this, false); finish(false); SetExecutedCurrently(false); @@ -3284,12 +3285,12 @@ void Spell::_cast(bool skipCheck) m_caster->CastSpell(m_targets.GetUnitTarget() ? m_targets.GetUnitTarget() : m_caster, *i, true); } - if (m_caster->GetTypeId() == TYPEID_PLAYER) + if (modOwner) { - m_caster->ToPlayer()->SetSpellModTakingSpell(this, false); + modOwner->SetSpellModTakingSpell(this, false); //Clear spell cooldowns after every spell is cast if .cheat cooldown is enabled. - if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN)) + if (modOwner->GetCommandStatus(CHEAT_COOLDOWN)) { m_caster->GetSpellHistory()->ResetCooldown(m_spellInfo->Id, true); m_caster->GetSpellHistory()->RestoreCharge(m_spellInfo->ChargeCategoryId); @@ -3420,8 +3421,9 @@ uint64 Spell::handle_delayed(uint64 t_offset) if (single_missile && !t_offset) return m_delayMoment; - if (m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->ToPlayer()->SetSpellModTakingSpell(this, true); + Player* modOwner = m_caster->GetSpellModOwner(); + if (modOwner) + modOwner->SetSpellModTakingSpell(this, true); PrepareTargetProcessing(); @@ -3460,8 +3462,8 @@ uint64 Spell::handle_delayed(uint64 t_offset) FinishTargetProcessing(); - if (m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->ToPlayer()->SetSpellModTakingSpell(this, false); + if (modOwner) + modOwner->SetSpellModTakingSpell(this, false); // All targets passed - need finish phase if (next_time == 0) -- cgit v1.2.3 From 8889b6f54c803805fe28ca9e015efe064759262a Mon Sep 17 00:00:00 2001 From: ariel- Date: Thu, 20 Apr 2017 02:12:15 -0300 Subject: Core/Unit: fix SPELL_AURA_MOD_DAMAGE_DONE damage calculation on non-melee schools for Keader :P (cherry picked from commit 66ac1509ae925edc8848cdf6c370f8ed52c688ec) --- src/server/game/Entities/Unit/Unit.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c1ba570d498..2c8cf177669 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -9579,7 +9579,13 @@ void Unit::UpdateDamageDoneMods(WeaponAttackType attackType) break; } - float amount = GetTotalAuraModifier(SPELL_AURA_MOD_DAMAGE_DONE, std::bind(&Unit::CheckAttackFitToAuraRequirement, this, attackType, std::placeholders::_1)); + float amount = GetTotalAuraModifier(SPELL_AURA_MOD_DAMAGE_DONE, [&](AuraEffect const* aurEff) -> bool + { + if (!(aurEff->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)) + return false; + + return CheckAttackFitToAuraRequirement(attackType, aurEff); + }); SetStatFlatModifier(unitMod, TOTAL_VALUE, amount); } -- cgit v1.2.3 From 92719d1dc9f8294b7a07129297e23cae1ef0a659 Mon Sep 17 00:00:00 2001 From: ariel- Date: Fri, 21 Apr 2017 01:35:42 -0300 Subject: Revert "Core/Spell: don't set scaleAura for some special spells" This reverts commit 1ca8434b365687dbd12ca232a615d126234eba5e. Closes #19472 (cherry picked from commit c296d255e25a2d0eb7155f64eea32cc36fed280a) --- src/server/game/Spells/SpellInfo.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 98604c278d4..eb37c3da5d7 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -4329,10 +4329,6 @@ bool SpellInfo::_IsPositiveEffect(uint32 effIndex, bool deep) const if (HasAttribute(SPELL_ATTR0_NEGATIVE_1)) return false; - // these spells must not be downscaled, thus marking them negative (see GetAuraRankForLevel) - if (HasAttribute(SPELL_ATTR2_UNK3)) - return false; - switch (SpellFamilyName) { case SPELLFAMILY_GENERIC: @@ -4513,6 +4509,7 @@ bool SpellInfo::_IsPositiveEffect(uint32 effIndex, bool deep) const case SPELL_AURA_MOD_STALKED: case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: case SPELL_AURA_PREVENT_RESURRECTION: + case SPELL_AURA_EMPATHY: return false; case SPELL_AURA_PERIODIC_DAMAGE: // used in positive spells also. // part of negative spell if cast at self (prevent cancel) -- cgit v1.2.3 From e3eca0c26410a6c9dc7fbef46ffb938cdd0901bc Mon Sep 17 00:00:00 2001 From: ariel- Date: Sat, 22 Apr 2017 04:00:49 -0300 Subject: Core/Spell: fix creature focus with channeled spells - Remove one not needed ReleaseFocus, this is done at finish already (cherry picked from commit 88c12b45d0adbe7ca18a72a53cb1416b1621975b) --- src/server/game/Spells/Spell.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 337ca5e1423..c064c64ae62 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3299,9 +3299,6 @@ void Spell::_cast(bool skipCheck) SetExecutedCurrently(false); - if (Creature* creatureCaster = m_caster->ToCreature()) - creatureCaster->ReleaseFocus(this); - if (!m_originalCaster) return; @@ -4460,8 +4457,17 @@ void Spell::SendChannelStart(uint32 duration) m_timer = duration; for (TargetInfo const& target : m_UniqueTargetInfo) + { m_caster->AddChannelObject(target.targetGUID); + if (m_UniqueTargetInfo.size() == 1 && m_UniqueGOTargetInfo.empty()) + { + if (Creature* creatureCaster = m_caster->ToCreature()) + if (!creatureCaster->IsFocusing(this)) + creatureCaster->FocusTarget(this, ObjectAccessor::GetWorldObject(*creatureCaster, target.targetGUID)); + } + } + for (GOTargetInfo const& target : m_UniqueGOTargetInfo) m_caster->AddChannelObject(target.targetGUID); -- cgit v1.2.3 From cfdde556cdf3318d2db96d2e1bd60bace1dbf9b3 Mon Sep 17 00:00:00 2001 From: ariel- Date: Sat, 22 Apr 2017 06:33:05 -0300 Subject: Core/Player: don't randomly change temporary spell status - They shouldn't be saved in db - Prevented temporary spell removal after a save Closes #14373 (cherry picked from commit 7ffe0563664c2ed5ba90832dcc42bc15acc177c3) --- src/server/game/Entities/Player/Player.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index c511f318309..d007bf3e7ff 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -21395,13 +21395,14 @@ void Player::_SaveSpells(CharacterDatabaseTransaction& trans) if (itr->second->state == PLAYERSPELL_REMOVED) { delete itr->second; - m_spells.erase(itr++); + itr = m_spells.erase(itr); + continue; } - else - { + + if (itr->second->state != PLAYERSPELL_TEMPORARY) itr->second->state = PLAYERSPELL_UNCHANGED; - ++itr; - } + + ++itr; } } -- cgit v1.2.3 From cf3c5dc9485d8cace0ba18e1afe1a5152f6f2ddc Mon Sep 17 00:00:00 2001 From: tkrokli Date: Sun, 23 Apr 2017 01:15:00 +0200 Subject: Core/Scripts: Willix the Importer - $n in aggro text * In the existing core script, Willix the Importer in Razorfen Kraul says "Help! Get this $n off of me!" (showing the $n part in his SAY text) instead of naming the attacker when using his 'SAY_AGGRO1' creature_text. * With this commit change, unit target is no longer missing for Talk, making Willix name the attacking unit when he shouts for help. (cherry picked from commit 6cc267d90918a0663f928db302ef1465f7952c61) --- src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp b/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp index d7bb4c2b6fa..226e1e0efd7 100644 --- a/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp +++ b/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp @@ -114,9 +114,9 @@ public: void Reset() override { } - void EnterCombat(Unit* /*who*/) override + void EnterCombat(Unit* who) override { - Talk(SAY_AGGRO1); + Talk(SAY_AGGRO1, who); } void JustSummoned(Creature* summoned) override -- cgit v1.2.3 From 2bd7c9aa40cefcfc401b81cfacd7dd832a3a736b Mon Sep 17 00:00:00 2001 From: Xyventh Date: Sun, 23 Apr 2017 23:55:07 +0200 Subject: [3.3.5] Core/Quest: always send the specified RewardNextQuest regardless of eventual scripts (#19498) - Fixes certain situations in which the quest window would get stuck after completing a quest (cherry picked from commit f0bf1fc77aa304ad278618aae25274ed46d308d5) --- src/server/game/Handlers/QuestHandler.cpp | 43 ++++++++++++++----------------- 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index b56e0ec130c..3ccee95e9e0 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -350,46 +350,41 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPackets::Quest::Quest { //For AutoSubmition was added plr case there as it almost same exclute AI script cases. Creature* creatureQGiver = object->ToCreature(); - if (!creatureQGiver || !sScriptMgr->OnQuestReward(_player, creatureQGiver, quest, packet.ItemChoiceID)) + // Send next quest + if (Quest const* nextQuest = _player->GetNextQuest(packet.QuestGiverGUID, quest)) { - // Send next quest - if (Quest const* nextQuest = _player->GetNextQuest(packet.QuestGiverGUID, quest)) + // Only send the quest to the player if the conditions are met + if (_player->CanTakeQuest(nextQuest, false)) { - // Only send the quest to the player if the conditions are met - if (_player->CanTakeQuest(nextQuest, false)) - { - if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true)) - _player->AddQuestAndCheckCompletion(nextQuest, object); + if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true)) + _player->AddQuestAndCheckCompletion(nextQuest, object); - _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, packet.QuestGiverGUID, true, false); - } + _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, packet.QuestGiverGUID, true, false); } - - if (creatureQGiver) - creatureQGiver->GetAI()->sQuestReward(_player, quest, packet.ItemChoiceID); } + + if (creatureQGiver && !sScriptMgr->OnQuestReward(_player, creatureQGiver, quest, packet.ItemChoiceID)) + creatureQGiver->GetAI()->sQuestReward(_player, quest, packet.ItemChoiceID); break; } case TYPEID_GAMEOBJECT: { GameObject* questGiver = object->ToGameObject(); - if (!sScriptMgr->OnQuestReward(_player, questGiver, quest, packet.ItemChoiceID)) + // Send next quest + if (Quest const* nextQuest = _player->GetNextQuest(packet.QuestGiverGUID, quest)) { - // Send next quest - if (Quest const* nextQuest = _player->GetNextQuest(packet.QuestGiverGUID, quest)) + // Only send the quest to the player if the conditions are met + if (_player->CanTakeQuest(nextQuest, false)) { - // Only send the quest to the player if the conditions are met - if (_player->CanTakeQuest(nextQuest, false)) - { - if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true)) - _player->AddQuestAndCheckCompletion(nextQuest, object); + if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true)) + _player->AddQuestAndCheckCompletion(nextQuest, object); - _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, packet.QuestGiverGUID, true, false); - } + _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, packet.QuestGiverGUID, true, false); } + } + if (!sScriptMgr->OnQuestReward(_player, questGiver, quest, packet.ItemChoiceID)) questGiver->AI()->QuestReward(_player, quest, packet.ItemChoiceID); - } break; } default: -- cgit v1.2.3 From 9c53ee0fe8ec98b3a192f065bd1ac30fc111f73c Mon Sep 17 00:00:00 2001 From: ariel- Date: Sun, 23 Apr 2017 20:36:46 -0300 Subject: Core/AI: prevent launching a new MoveChase if victim didn't change Thanks ccrs for feedback :P (cherry picked from commit b6b0353bff151d180d98f4f7a67414cfca4bd585) --- src/server/game/AI/CreatureAI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index b9d052cb528..af9104b6c09 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -251,7 +251,7 @@ bool CreatureAI::UpdateVictim() if (!me->HasReactState(REACT_PASSIVE)) { if (Unit* victim = me->SelectVictim()) - if (!me->IsFocusing(nullptr, true)) + if (!me->IsFocusing(nullptr, true) && victim != me->GetVictim()) AttackStart(victim); return me->GetVictim() != nullptr; -- cgit v1.2.3 From 5e32e96278757aa52ef87cb122dd99825e6c8de9 Mon Sep 17 00:00:00 2001 From: ariel- Date: Sun, 23 Apr 2017 20:38:14 -0300 Subject: Core/Spell: define channels without movement interrupt flags as allowed move - Remove script hacks no longer needed (cherry picked from commit 3a0cb90ea994e82dd8c70888fb847082f738d5dc) --- src/server/game/Spells/SpellInfo.cpp | 2 +- .../scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp | 4 ---- .../scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp | 1 - src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp | 1 - src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp | 1 - src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp | 2 -- src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp | 1 - src/server/scripts/Outland/BlackTemple/boss_illidan.cpp | 1 - 8 files changed, 1 insertion(+), 12 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index eb37c3da5d7..bec8a653fee 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1675,7 +1675,7 @@ bool SpellInfo::IsChanneled() const bool SpellInfo::IsMoveAllowedChannel() const { - return IsChanneled() && HasAttribute(SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING); + return IsChanneled() && (HasAttribute(SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING) || (!(ChannelInterruptFlags[0] & (AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING)))); } bool SpellInfo::NeedsComboPoints() const diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index 50dcb98bcab..4e7ddbc453b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -1129,10 +1129,7 @@ class npc_dark_nucleus : public CreatureScript if (Unit* victim = me->GetVictim()) { if (me->GetDistance(victim) < 15.0f && !victim->HasAura(SPELL_SHADOW_RESONANCE_RESIST, me->GetGUID())) - { DoCast(victim, SPELL_SHADOW_RESONANCE_RESIST); - me->ClearUnitState(UNIT_STATE_CASTING); - } else MoveInLineOfSight(me->GetVictim()); } @@ -1146,7 +1143,6 @@ class npc_dark_nucleus : public CreatureScript } DoCast(who, SPELL_SHADOW_RESONANCE_RESIST); - me->ClearUnitState(UNIT_STATE_CASTING); } void DamageTaken(Unit* attacker, uint32& /*damage*/) override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index 116843c2398..f21051a36b3 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -933,7 +933,6 @@ class spell_putricide_ooze_channel : public SpellScriptLoader void StartAttack() { - GetCaster()->ClearUnitState(UNIT_STATE_CASTING); GetCaster()->DeleteThreatList(); GetCaster()->ToCreature()->AI()->AttackStart(GetHitUnit()); GetCaster()->AddThreat(GetHitUnit(), 500000000.0f); // value seen in sniff diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 94bf769b771..73877fa1ac9 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -725,7 +725,6 @@ class boss_the_lich_king : public CreatureScript summon->CastSpell(summon, SPELL_ICE_SPHERE, false); summon->CastSpell(summon, SPELL_ICE_BURST_TARGET_SEARCH, false); summon->CastSpell(target, SPELL_ICE_PULSE, false); - summon->ClearUnitState(UNIT_STATE_CASTING); summon->GetMotionMaster()->MoveFollow(target, 0.0f, 0.0f); } else diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp index d5859e27f3a..e51db2e2878 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp @@ -161,7 +161,6 @@ public: break; case EVENT_RESUME_PULSING_SHOCKWAVE: DoCast(me, SPELL_PULSING_SHOCKWAVE_AURA, true); - me->ClearUnitState(UNIT_STATE_CASTING); // This flag breaks movement. DoCast(me, SPELL_PULSING_SHOCKWAVE, true); break; case EVENT_INTRO_DIALOGUE: diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index 5a6c4aeeef6..ec3c449f0ca 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp @@ -230,8 +230,6 @@ class boss_kologarn : public CreatureScript summon->CastSpell(summon, SPELL_FOCUSED_EYEBEAM_PERIODIC, true); summon->CastSpell(summon, SPELL_FOCUSED_EYEBEAM_VISUAL, true); summon->SetReactState(REACT_PASSIVE); - // One of the above spells is a channeled spell, we need to clear this unit state for MoveChase to work - summon->ClearUnitState(UNIT_STATE_CASTING); // Victim gets 67351 if (!eyebeamTarget.IsEmpty()) diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index fd4d7b02229..4d9ed335279 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -1304,7 +1304,6 @@ class npc_mimiron_assault_bot : public CreatureScript { case EVENT_MAGNETIC_FIELD: DoCastVictim(SPELL_MAGNETIC_FIELD); - me->ClearUnitState(UNIT_STATE_CASTING); events.RescheduleEvent(EVENT_MAGNETIC_FIELD, 30000); break; default: diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index b41199670a9..706bc7d99eb 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -2305,7 +2305,6 @@ class spell_illidan_find_target : public SpellScriptLoader if (Creature* caster = GetCaster()->ToCreature()) { caster->CastSpell(target, SPELL_PARALYZE, true); - caster->ClearUnitState(UNIT_STATE_CASTING); caster->AI()->SetGUID(target->GetGUID(), 0); } } -- cgit v1.2.3 From 52ab2707682f37bbf35a0d384e81c79e8b064ebf Mon Sep 17 00:00:00 2001 From: ariel- Date: Sun, 23 Apr 2017 20:38:48 -0300 Subject: Core/Spell: don't make creature change orientation to 0 if channeling self (cherry picked from commit 1f4439ece49790bee43016ea2462e3803b2f6218) --- src/server/game/Spells/Spell.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index c064c64ae62..1590ffb5c2a 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4461,11 +4461,10 @@ void Spell::SendChannelStart(uint32 duration) m_caster->AddChannelObject(target.targetGUID); if (m_UniqueTargetInfo.size() == 1 && m_UniqueGOTargetInfo.empty()) - { - if (Creature* creatureCaster = m_caster->ToCreature()) - if (!creatureCaster->IsFocusing(this)) - creatureCaster->FocusTarget(this, ObjectAccessor::GetWorldObject(*creatureCaster, target.targetGUID)); - } + if(target.targetGUID != m_caster->GetGUID()) + if (Creature* creatureCaster = m_caster->ToCreature()) + if (!creatureCaster->IsFocusing(this)) + creatureCaster->FocusTarget(this, ObjectAccessor::GetWorldObject(*creatureCaster, target.targetGUID)); } for (GOTargetInfo const& target : m_UniqueGOTargetInfo) -- cgit v1.2.3 From 9ef39fa5d2f76459e3e529a0877655b0f69b98d6 Mon Sep 17 00:00:00 2001 From: ariel- Date: Sun, 23 Apr 2017 20:40:23 -0300 Subject: Core/Movement: allow focused spells to not break movement if it's movement allowed spell - Core/Unit: made IsFocusing virtual Thanks to ccrs for suggestion (cherry picked from commit 522f537048189b40a12d68583485d1de7fcbf1d2) --- src/server/game/Entities/Creature/Creature.h | 2 +- src/server/game/Entities/Unit/Unit.cpp | 3 +++ src/server/game/Entities/Unit/Unit.h | 2 ++ .../game/Movement/MovementGenerators/TargetedMovementGenerator.cpp | 6 ++---- 4 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 1be3e00e39a..b4eaf0e4cfa 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -328,7 +328,7 @@ class TC_GAME_API Creature : public Unit, public GridObject, public Ma void MustReacquireTarget() { m_shouldReacquireTarget = true; } // flags the Creature for forced (client displayed) target reacquisition in the next ::Update call void DoNotReacquireTarget() { m_shouldReacquireTarget = false; m_suppressedTarget = ObjectGuid::Empty; m_suppressedOrientation = 0.0f; } void FocusTarget(Spell const* focusSpell, WorldObject const* target); - bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false); + bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false) override; void ReleaseFocus(Spell const* focusSpell = nullptr, bool withDelay = true); // Part of Evade mechanics diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 2c8cf177669..f15294e8054 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3133,6 +3133,9 @@ bool Unit::IsMovementPreventedByCasting() const if (spell->GetSpellInfo()->IsMoveAllowedChannel()) return false; + if (const_cast(this)->IsFocusing(nullptr, true)) + return false; + // prohibit movement for all other spell casts return true; } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index d0a246d6b90..c61146e063b 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1659,6 +1659,8 @@ class TC_GAME_API Unit : public WorldObject virtual SpellInfo const* GetCastSpellInfo(SpellInfo const* spellInfo) const; uint32 GetCastSpellXSpellVisualId(SpellInfo const* spellInfo) const; + virtual bool IsFocusing(Spell const* /*focusSpell*/ = nullptr, bool /*withDelay*/ = false) { return false; } + // Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING bool IsMovementPreventedByCasting() const; diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index a4efd581a4e..5c8eb721e18 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -40,8 +40,7 @@ bool TargetedMovementGenerator::DoUpdate(T* owner, uint32 diff) if (!owner || !owner->IsAlive()) return false; - if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting() || HasLostTarget(owner) - || (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsFocusing(nullptr, true))) + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting() || HasLostTarget(owner)) { _interrupt = true; owner->StopMoving(); @@ -111,8 +110,7 @@ void TargetedMovementGenerator::SetTargetLocation(T* owner, bool updateDes if (!owner || !owner->IsAlive()) return; - if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting() || HasLostTarget(owner) - || (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsFocusing(nullptr, true))) + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting() || HasLostTarget(owner)) { _interrupt = true; owner->StopMoving(); -- cgit v1.2.3 From 16cf95654f35f6bb563e82608476d8f53837bd06 Mon Sep 17 00:00:00 2001 From: xinef1 Date: Mon, 24 Apr 2017 05:46:06 +0200 Subject: Various quest system fixes (seasonal quests, timed quests and more) (#18940) - Unify quest status checking function, use dedicated function instead of direct map checks - Fixed seasonal quest chains and ability to complete the same quests rewarded in past - Update area dependent auras on quest status change (they often requires specific quest status) - Send all not stored quest rewards by mail - When casting quest reward spell, check if it is not self casted, if so - use player to cast this spell - Perform full db save on quest reward to prevent data desynchronization - Don't allow to fail completed timed quests, except for quests which are completed right from the start - Don't allow to share pooled quests, if they are not available in the current pool (eg sharing easy dalaran weeklies, stored at alt character) - Remove seasonal quest if rewarded quest is removed - Don't complete whole quest on AreaExplore event, check if there are no more requirements that should be fulfilled - Quests with flag QUEST_SPECIAL_FLAGS_PLAYER_KILL can be only credited in quest zone Closes #18913 Closes #11187 Closes #15279 (cherry picked from commit cbbb74524623ea22fc5375697d6ec2ec16a1755f) --- src/server/game/Entities/Player/Player.cpp | 90 +++++++++++++++++++----------- src/server/game/Globals/ObjectMgr.cpp | 21 +++++++ src/server/game/Quests/QuestDef.h | 3 +- 3 files changed, 81 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index d007bf3e7ff..5442360a165 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -91,6 +91,7 @@ #include "OutdoorPvPMgr.h" #include "Pet.h" #include "PetPackets.h" +#include "PoolMgr.h" #include "PhasingHandler.h" #include "QueryCallback.h" #include "QueryHolder.h" @@ -15271,7 +15272,7 @@ bool Player::CanCompleteQuest(uint32 quest_id) if (!qInfo) return false; - if (!qInfo->IsRepeatable() && m_RewardedQuests.find(quest_id) != m_RewardedQuests.end()) + if (!qInfo->IsRepeatable() && GetQuestRewardStatus(quest_id)) return false; // not allow re-complete quest // auto complete quest @@ -15664,10 +15665,10 @@ uint32 Player::GetQuestMoneyReward(Quest const* quest) const uint32 Player::GetQuestXPReward(Quest const* quest) { - bool rewarded = (m_RewardedQuests.find(quest->GetQuestId()) != m_RewardedQuests.end()); + bool rewarded = IsQuestRewarded(quest->GetQuestId()) && !quest->IsDFQuest(); // Not give XP in case already completed once repeatable quest - if (rewarded && !quest->IsDFQuest()) + if (rewarded) return 0; uint32 XP = quest->XPValue(this) * sWorld->getRate(RATE_XP_QUEST); @@ -15819,7 +15820,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, SendNewItem(item, quest->RewardItemCount[i], true, false); } else if (quest->IsDFQuest()) - SendItemRetrievalMail(quest->RewardItemId[i], quest->RewardItemCount[i], ItemContext::Quest_Reward); + SendItemRetrievalMail(itemId, quest->RewardItemCount[i], ItemContext::Quest_Reward); } } } @@ -15898,12 +15899,6 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, if (quest->CanIncreaseRewardedQuestCounters()) SetRewardedQuest(quest_id); - // StoreNewItem, mail reward, etc. save data directly to the database - // to prevent exploitable data desynchronisation we save the quest status to the database too - // (to prevent rewarding this quest another time while rewards were already given out) - CharacterDatabaseTransaction trans = CharacterDatabaseTransaction(nullptr); - _SaveQuestStatus(trans); - SendQuestReward(quest, questGiver ? questGiver->ToCreature() : nullptr, XP, !announce); // cast spells after mark quest complete (some spells have quest completed state requirements in spell_area data) @@ -15939,6 +15934,9 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, UpdateCriteria(CRITERIA_TYPE_COMPLETE_QUEST_COUNT); UpdateCriteria(CRITERIA_TYPE_COMPLETE_QUEST, quest->GetQuestId()); + // make full db save + SaveToDB(false); + if (uint32 questBit = sDB2Manager.GetQuestUniqueBitFlag(quest_id)) SetQuestCompletedBit(questBit, true); @@ -15969,13 +15967,15 @@ void Player::FailQuest(uint32 questId) { if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId)) { - // Already complete quests shouldn't turn failed. - if (GetQuestStatus(questId) == QUEST_STATUS_COMPLETE && !quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_TIMED)) - return; + QuestStatus qStatus = GetQuestStatus(questId); - // You can't fail a quest if you don't have it, or if it's already rewarded. - if (GetQuestStatus(questId) == QUEST_STATUS_NONE || GetQuestStatus(questId) == QUEST_STATUS_REWARDED) - return; + // we can only fail incomplete quest or... + if (qStatus != QUEST_STATUS_INCOMPLETE) + { + // completed timed quest with no requirements + if (qStatus != QUEST_STATUS_COMPLETE || !quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_TIMED) || !quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_COMPLETED_AT_START)) + return; + } SetQuestStatus(questId, QUEST_STATUS_FAILED); @@ -16356,7 +16356,7 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const } // alternative quest already started or completed - but don't check rewarded states if both are repeatable - if (GetQuestStatus(exclude_Id) != QUEST_STATUS_NONE || (!(qInfo->IsRepeatable() && Nquest->IsRepeatable()) && (m_RewardedQuests.find(exclude_Id) != m_RewardedQuests.end()))) + if (GetQuestStatus(exclude_Id) != QUEST_STATUS_NONE || (!(qInfo->IsRepeatable() && Nquest->IsRepeatable()) && GetQuestRewardStatus(exclude_Id))) { if (msg) { @@ -16521,7 +16521,7 @@ bool Player::GetQuestRewardStatus(uint32 quest_id) const // for repeatable quests: rewarded field is set after first reward only to prevent getting XP more than once if (!qInfo->IsRepeatable()) - return m_RewardedQuests.find(quest_id) != m_RewardedQuests.end(); + return IsQuestRewarded(quest_id); return false; } @@ -16536,14 +16536,8 @@ QuestStatus Player::GetQuestStatus(uint32 quest_id) const if (itr != m_QuestStatus.end()) return itr->second.Status; - if (Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id)) - { - if (qInfo->IsSeasonal() && !qInfo->IsRepeatable()) - return SatisfyQuestSeasonal(qInfo, false) ? QUEST_STATUS_NONE : QUEST_STATUS_REWARDED; - - if (!qInfo->IsRepeatable() && IsQuestRewarded(quest_id)) - return QUEST_STATUS_REWARDED; - } + if (GetQuestRewardStatus(quest_id)) + return QUEST_STATUS_REWARDED; } return QUEST_STATUS_NONE; } @@ -16551,7 +16545,22 @@ QuestStatus Player::GetQuestStatus(uint32 quest_id) const bool Player::CanShareQuest(uint32 quest_id) const { Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id); - return qInfo && qInfo->HasFlag(QUEST_FLAGS_SHARABLE) && IsActiveQuest(quest_id); + if (qInfo && qInfo->HasFlag(QUEST_FLAGS_SHARABLE)) + { + QuestStatusMap::const_iterator itr = m_QuestStatus.find(quest_id); + if (itr != m_QuestStatus.end()) + { + if (itr->second.Status != QUEST_STATUS_INCOMPLETE) + return false; + + // in pool and not currently available (wintergrasp weekly, dalaran weekly) - can't share + if (sPoolMgr->IsPartOfAPool(quest_id) && !sPoolMgr->IsSpawnedObject(quest_id)) + return false; + + return true; + } + } + return false; } void Player::SetQuestStatus(uint32 questId, QuestStatus status, bool update /*= true*/) @@ -16597,6 +16606,18 @@ void Player::RemoveRewardedQuest(uint32 questId, bool update /*= true*/) if (uint32 questBit = sDB2Manager.GetQuestUniqueBitFlag(questId)) SetQuestCompletedBit(questBit, false); + // Remove seasonal quest also + Quest const* qInfo = sObjectMgr->GetQuestTemplate(questId); + if (qInfo->IsSeasonal()) + { + uint16 eventId = qInfo->GetEventIdForQuest(); + if (m_seasonalquests.find(eventId) != m_seasonalquests.end()) + { + m_seasonalquests[eventId].erase(questId); + m_SeasonalQuestChanged = true; + } + } + if (update) SendQuestUpdate(questId); } @@ -16855,8 +16876,10 @@ void Player::AreaExploredOrEventHappens(uint32 questId) { q_status.Explored = true; m_QuestStatusSave[questId] = QUEST_DEFAULT_SAVE_TYPE; - SetQuestSlotState(log_slot, QUEST_STATE_COMPLETE); - SendQuestComplete(questId); + + // if we cannot complete quest send exploration succeded (to mark exploration on client) + if (!CanCompleteQuest(questId)) + SendQuestComplete(questId); }**/ } if (CanCompleteQuest(questId)) @@ -21269,7 +21292,7 @@ void Player::_SaveWeeklyQuestStatus(CharacterDatabaseTransaction& trans) void Player::_SaveSeasonalQuestStatus(CharacterDatabaseTransaction& trans) { - if (!m_SeasonalQuestChanged || m_seasonalquests.empty()) + if (!m_SeasonalQuestChanged) return; // we don't need transactions here. @@ -21277,6 +21300,11 @@ void Player::_SaveSeasonalQuestStatus(CharacterDatabaseTransaction& trans) stmt->setUInt64(0, GetGUID().GetCounter()); trans->Append(stmt); + m_SeasonalQuestChanged = false; + + if (m_seasonalquests.empty()) + return; + for (SeasonalEventQuestMap::const_iterator iter = m_seasonalquests.begin(); iter != m_seasonalquests.end(); ++iter) { uint16 eventId = iter->first; @@ -21292,8 +21320,6 @@ void Player::_SaveSeasonalQuestStatus(CharacterDatabaseTransaction& trans) trans->Append(stmt); } } - - m_SeasonalQuestChanged = false; } void Player::_SaveMonthlyQuestStatus(CharacterDatabaseTransaction& trans) diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 57922dd84eb..f519c69948f 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -4626,6 +4626,27 @@ void ObjectMgr::LoadQuests() _exclusiveQuestGroups.insert(std::pair(qinfo->_exclusiveGroup, qinfo->GetQuestId())); if (qinfo->_limitTime) qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAGS_TIMED); + + // Special flag to determine if quest is completed from the start, used to determine if we can fail timed quest if it is completed + if (!qinfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_KILL | QUEST_SPECIAL_FLAGS_CAST | QUEST_SPECIAL_FLAGS_SPEAKTO | QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT)) + { + bool addFlag = true; + if (qinfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_DELIVER)) + { + for (QuestObjective const& obj : qinfo->GetObjectives()) + { + if (obj.Type == QUEST_OBJECTIVE_ITEM) + if (static_cast(obj.ObjectID) != qinfo->GetSrcItemId() || static_cast(obj.Amount) > qinfo->GetSrcItemCount()) + { + addFlag = false; + break; + } + } + } + + if (addFlag) + qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAGS_COMPLETED_AT_START); + } } // check QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index 44347222711..da9d80dad63 100644 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -224,7 +224,8 @@ enum QuestSpecialFlags QUEST_SPECIAL_FLAGS_SPEAKTO = 0x100, // Internal flag computed only QUEST_SPECIAL_FLAGS_KILL = 0x200, // Internal flag computed only QUEST_SPECIAL_FLAGS_TIMED = 0x400, // Internal flag computed only - QUEST_SPECIAL_FLAGS_PLAYER_KILL = 0x800 // Internal flag computed only + QUEST_SPECIAL_FLAGS_PLAYER_KILL = 0x800, // Internal flag computed only + QUEST_SPECIAL_FLAGS_COMPLETED_AT_START = 0x1000 // Internal flag computed only }; enum QuestObjectiveType -- cgit v1.2.3 From 292c03ec048158c31b2e2900c6a38d57aa926342 Mon Sep 17 00:00:00 2001 From: Keader Date: Mon, 24 Apr 2017 08:48:34 -0300 Subject: Core/Scripts: Fix a typo in Blood Prince Council Thanks ariel- (cherry picked from commit 136f1e75aa8968eee9b94fa0d19e46e97332867a) --- .../scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index 4e7ddbc453b..3f5bf56faf9 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -788,7 +788,7 @@ class boss_prince_valanar_icc : public CreatureScript struct boss_prince_valanarAI : public BloodPrincesBossAI { - boss_prince_valanarAI(Creature* creature) : BloodPrincesBossAI(creature, DATA_PRINCE_TALDARAM) { } + boss_prince_valanarAI(Creature* creature) : BloodPrincesBossAI(creature, DATA_PRINCE_VALANAR) { } void ScheduleEvents() override { -- cgit v1.2.3 From 3eee76b1c63469152a9e531da4f973d0e0471ac6 Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 24 Apr 2017 16:33:51 -0300 Subject: Core/Quests: implemented MSG_QUEST_PUSH_RESULT notifications - Allow to share already completed (but not rewarded) quests, restriction was unblizzlike thanks Cannix for the heads up (cherry picked from commit 157e9311c41a8d33f7a2e3d5381ffc09d4585c42) --- src/server/game/Entities/Player/Player.cpp | 8 ++++---- src/server/game/Entities/Player/Player.h | 2 +- src/server/game/Handlers/QuestHandler.cpp | 9 +++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 5442360a165..b4a8660708c 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -16550,12 +16550,12 @@ bool Player::CanShareQuest(uint32 quest_id) const QuestStatusMap::const_iterator itr = m_QuestStatus.find(quest_id); if (itr != m_QuestStatus.end()) { - if (itr->second.Status != QUEST_STATUS_INCOMPLETE) - return false; - // in pool and not currently available (wintergrasp weekly, dalaran weekly) - can't share if (sPoolMgr->IsPartOfAPool(quest_id) && !sPoolMgr->IsSpawnedObject(quest_id)) + { + SendPushToPartyResponse(this, QUEST_PUSH_NOT_DAILY); return false; + } return true; } @@ -17654,7 +17654,7 @@ void Player::SendQuestConfirmAccept(Quest const* quest, Player* receiver) const receiver->GetSession()->SendPacket(packet.Write()); } -void Player::SendPushToPartyResponse(Player* player, QuestPushReason reason) const +void Player::SendPushToPartyResponse(Player const* player, QuestPushReason reason) const { if (player) { diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 9f56b7f91b5..a81afcb8bba 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1418,7 +1418,7 @@ class TC_GAME_API Player : public Unit, public GridObject void SendQuestTimerFailed(uint32 questID) const; void SendCanTakeQuestResponse(QuestFailedReason reason, bool sendErrorMessage = true, std::string reasonText = "") const; void SendQuestConfirmAccept(Quest const* quest, Player* receiver) const; - void SendPushToPartyResponse(Player* player, QuestPushReason reason) const; + void SendPushToPartyResponse(Player const* player, QuestPushReason reason) const; void SendQuestUpdateAddCredit(Quest const* quest, ObjectGuid guid, QuestObjective const& obj, uint16 count) const; void SendQuestUpdateAddCreditSimple(QuestObjective const& obj) const; void SendQuestUpdateAddPlayer(Quest const* quest, uint16 newCount) const; diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 3ccee95e9e0..aeafff6d1cc 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -585,7 +585,10 @@ void WorldSession::HandlePushQuestToParty(WorldPackets::Quest::PushQuestToParty& Group* group = sender->GetGroup(); if (!group) + { + sender->SendPushToPartyResponse(sender, QUEST_PUSH_NOT_IN_PARTY); return; + } for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { @@ -606,6 +609,12 @@ void WorldSession::HandlePushQuestToParty(WorldPackets::Quest::PushQuestToParty& continue; } + if (!receiver->SatisfyQuestDay(quest, false)) + { + sender->SendPushToPartyResponse(receiver, QUEST_PUSH_DIFFERENT_SERVER_DAILY); + continue; + } + if (!receiver->CanTakeQuest(quest, false)) { sender->SendPushToPartyResponse(receiver, QUEST_PUSH_INVALID); -- cgit v1.2.3 From dea71597455d3846c801cd340f0f2a6248c61800 Mon Sep 17 00:00:00 2001 From: ariel- Date: Tue, 25 Apr 2017 02:57:58 -0300 Subject: Core/Scripts: fix gaseous bloat proc (again) - UNIT_STATE_CASTING removal not needed for movement now, but it's needed for melee attacking (cherry picked from commit 85076dd799a76b889d1d22890771f4bc445fd7f8) --- .../scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index f21051a36b3..116843c2398 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -933,6 +933,7 @@ class spell_putricide_ooze_channel : public SpellScriptLoader void StartAttack() { + GetCaster()->ClearUnitState(UNIT_STATE_CASTING); GetCaster()->DeleteThreatList(); GetCaster()->ToCreature()->AI()->AttackStart(GetHitUnit()); GetCaster()->AddThreat(GetHitUnit(), 500000000.0f); // value seen in sniff -- cgit v1.2.3 From 6611211d31e20a9bdce7089d38999f2a2d9fbc12 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Tue, 25 Apr 2017 11:52:50 +0200 Subject: Core/Misc: Fix static analysis issues (cherry picked from commit 65aeeafad385cca7d836272c37ee6f4d180d2842) --- src/server/game/Chat/Chat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 88670fa59fd..2d18d2d035c 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -892,7 +892,7 @@ GameTele const* ChatHandler::extractGameTeleFromLink(char* text) return nullptr; // id case (explicit or from shift link) - if (cId[0] >= '0' || cId[0] >= '9') + if (cId[0] >= '0' && cId[0] <= '9') if (uint32 id = atoi(cId)) return sObjectMgr->GetGameTele(id); -- cgit v1.2.3 From cc148ebc4025af6727c57a83e154a02fc40f0366 Mon Sep 17 00:00:00 2001 From: Keader Date: Tue, 25 Apr 2017 11:46:38 -0300 Subject: Core/Scripts: Added a missing break in Illidan Stormrage script Thanks Jackpoz (cherry picked from commit 3194d089cbf2dd30bb3fed3a7f6f7e85730ad0cb) --- src/server/scripts/Outland/BlackTemple/boss_illidan.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index 706bc7d99eb..e66584c802e 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -524,6 +524,7 @@ public: events.ScheduleEvent(EVENT_SHADOW_BLAST, Seconds(1), group); events.ScheduleEvent(EVENT_FLAME_BURST, Seconds(6), group); events.ScheduleEvent(EVENT_SHADOW_DEMON, Seconds(18), Seconds(30), group); + break; case GROUP_PHASE_4: ScheduleEvents(GROUP_PHASE_3, group); events.ScheduleEvent(EVENT_FRENZY, Seconds(40), group); -- cgit v1.2.3 From 49f25f6e33aa4b4f67a46ba3cb71a183570da67e Mon Sep 17 00:00:00 2001 From: jackpoz Date: Tue, 25 Apr 2017 17:33:53 +0200 Subject: Core/Misc: Fix static analysis issues (cherry picked from commit 486b03234304526d8f7d66ff0d99ea3de975745e) --- src/common/Collision/Maps/TileAssembler.cpp | 5 ++--- src/server/game/Entities/Player/Player.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/common/Collision/Maps/TileAssembler.cpp b/src/common/Collision/Maps/TileAssembler.cpp index 1ef09e55391..0a50ef21e40 100644 --- a/src/common/Collision/Maps/TileAssembler.cpp +++ b/src/common/Collision/Maps/TileAssembler.cpp @@ -202,13 +202,12 @@ namespace VMAP return false; } printf("Read coordinate mapping...\n"); - uint32 mapID, check=0; + uint32 mapID, check; std::map data; while (!feof(dirf)) { - check = 0; // read mapID, Flags, NameSet, UniqueId, Pos, Rot, Scale, Bound_lo, Bound_hi, name - check += fread(&mapID, sizeof(uint32), 1, dirf); + check = fread(&mapID, sizeof(uint32), 1, dirf); if (check == 0) // EoF... break; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index b4a8660708c..cdbfad950f2 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -12817,7 +12817,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) if (slot < INVENTORY_SLOT_BAG_END) { // item set bonuses applied only at equip and removed at unequip, and still active for broken items - if (pProto && pProto->GetItemSet()) + if (pProto->GetItemSet()) RemoveItemsSetItem(this, pProto); _ApplyItemMods(pItem, slot, false); -- cgit v1.2.3 From bb3f2a11cfa909a0b40450050f33a3893f6bb061 Mon Sep 17 00:00:00 2001 From: ariel- Date: Wed, 26 Apr 2017 04:16:32 -0300 Subject: Core/AI: added a function to allow 0 damage attacks (sparring) depending on target (cherry picked from commit 3a2ecaa05f0a3da96b3d4a0bec44175d6a7dda6a) --- src/server/game/AI/CoreAI/UnitAI.cpp | 10 ++++++++-- src/server/game/AI/CoreAI/UnitAI.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 21d15731b11..124361f0c07 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -65,14 +65,20 @@ void UnitAI::DoMeleeAttackIfReady() //Make sure our attack is ready and we aren't currently casting before checking distance if (me->isAttackReady()) { - me->AttackerStateUpdate(victim); + if (ShouldSparWith(victim)) + me->FakeAttackerStateUpdate(victim); + else + me->AttackerStateUpdate(victim); me->resetAttackTimer(); } if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK)) { - me->AttackerStateUpdate(victim, OFF_ATTACK); + if (ShouldSparWith(victim)) + me->FakeAttackerStateUpdate(victim, OFF_ATTACK); + else + me->AttackerStateUpdate(victim, OFF_ATTACK); me->resetAttackTimer(OFF_ATTACK); } diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 0145233e3c9..9ffee6c146c 100644 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -265,6 +265,8 @@ class TC_GAME_API UnitAI void DoCastVictim(uint32 spellId, bool triggered = false); void DoCastAOE(uint32 spellId, bool triggered = false); + virtual bool ShouldSparWith(Unit const* /*target*/) const { return false; } + void DoMeleeAttackIfReady(); bool DoSpellAttackIfReady(uint32 spellId); -- cgit v1.2.3 From f3a49059acb7b19ef95ebb7f6fe6887a123cd1c9 Mon Sep 17 00:00:00 2001 From: ariel- Date: Wed, 26 Apr 2017 04:19:01 -0300 Subject: Core/AI: some tweaks on boundary functionality: - Moved SetBoundary to public scope to allow for greater flexibility (ie set from external script) - Extended to allow checking inverted boundaries (cherry picked from commit 6892404b270f57380ffdc9ad084e0f43d94134e0) --- src/server/game/AI/CreatureAI.cpp | 22 +++++++++------------- src/server/game/AI/CreatureAI.h | 7 ++++--- .../AzjolNerub/AzjolNerub/boss_anubarak.cpp | 2 +- 3 files changed, 14 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index af9104b6c09..835f5369c9f 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -44,7 +44,7 @@ void CreatureAI::OnCharmed(bool apply) AISpellInfoType* UnitAI::AISpellInfo; AISpellInfoType* GetAISpellInfo(uint32 i) { return &UnitAI::AISpellInfo[i]; } -CreatureAI::CreatureAI(Creature* creature) : UnitAI(creature), me(creature), _boundary(nullptr), m_MoveInLineOfSight_locked(false) +CreatureAI::CreatureAI(Creature* creature) : UnitAI(creature), me(creature), _boundary(nullptr), _negateBoundary(false), m_MoveInLineOfSight_locked(false) { } @@ -364,32 +364,28 @@ int32 CreatureAI::VisualizeBoundary(uint32 duration, Unit* owner, bool fill) con bool CreatureAI::CheckBoundary(Position const* who) const { + if (!_boundary) + return true; + if (!who) who = me; - if (_boundary) - for (AreaBoundary const* areaBoundary : *_boundary) - if (!areaBoundary->IsWithinBoundary(who)) - return false; - - return true; + return (CreatureAI::IsInBounds(*_boundary, who) != _negateBoundary); } -bool CreatureAI::IsInBounds(CreatureBoundary const* boundary, Position const* pos) +bool CreatureAI::IsInBounds(CreatureBoundary const& boundary, Position const* pos) { - if (!boundary) - return true; - - for (AreaBoundary const* areaBoundary : *boundary) + for (AreaBoundary const* areaBoundary : boundary) if (!areaBoundary->IsWithinBoundary(pos)) return false; return true; } -void CreatureAI::SetBoundary(CreatureBoundary const* boundary) +void CreatureAI::SetBoundary(CreatureBoundary const* boundary, bool negateBoundaries /*= false*/) { _boundary = boundary; + _negateBoundary = negateBoundaries; me->DoImmediateBoundaryCheck(); } diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h index 5fe93e7675a..edc09a650c7 100644 --- a/src/server/game/AI/CreatureAI.h +++ b/src/server/game/AI/CreatureAI.h @@ -83,7 +83,6 @@ class TC_GAME_API CreatureAI : public UnitAI bool CheckBoundary(Position const* who = nullptr) const; - void SetBoundary(CreatureBoundary const* boundary); public: enum EvadeReason { @@ -211,11 +210,12 @@ class TC_GAME_API CreatureAI : public UnitAI virtual PlayerAI* GetAIForCharmedPlayer(Player* /*who*/) { return nullptr; } // intended for encounter design/debugging. do not use for other purposes. expensive. - int32 VisualizeBoundary(uint32 duration, Unit* owner=nullptr, bool fill=false) const; + int32 VisualizeBoundary(uint32 duration, Unit* owner = nullptr, bool fill = false) const; virtual bool CheckInRoom(); CreatureBoundary const* GetBoundary() const { return _boundary; } + void SetBoundary(CreatureBoundary const* boundary, bool negativeBoundaries = false); - static bool IsInBounds(CreatureBoundary const* boundary, Position const* who); + static bool IsInBounds(CreatureBoundary const& boundary, Position const* who); protected: virtual void MoveInLineOfSight(Unit* /*who*/); @@ -223,6 +223,7 @@ class TC_GAME_API CreatureAI : public UnitAI bool _EnterEvadeMode(EvadeReason why = EVADE_REASON_OTHER); CreatureBoundary const* _boundary; + bool _negateBoundary; private: bool m_MoveInLineOfSight_locked; diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp index 9112fd9ccd2..37aa313b662 100644 --- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp @@ -499,7 +499,7 @@ class npc_anubarak_anub_ar_assassin : public CreatureScript Position jumpTo; do jumpTo = GetRandomPositionAround(anubarak); - while (!CreatureAI::IsInBounds(boundary, &jumpTo)); + while (!CreatureAI::IsInBounds(*boundary, &jumpTo)); me->GetMotionMaster()->MoveJump(jumpTo, 40.0f, 40.0f); DoCastSelf(SPELL_ASSASSIN_VISUAL, true); } -- cgit v1.2.3 From 3c2882c29d8ed8b9012b6c59662f68b0237249e2 Mon Sep 17 00:00:00 2001 From: ariel- Date: Thu, 27 Apr 2017 00:22:05 -0300 Subject: Core/Player: don't check quest requirements against RewardNextQuest - This field is only used to propose a new quest to player after completion, shouldn't be used to condition current quest Closes #19515 (cherry picked from commit a82a12b5ef5c466496c314b5a1eb6838dc598b15) --- src/server/game/Entities/Player/Player.cpp | 27 +-------------------------- src/server/game/Entities/Player/Player.h | 1 - 2 files changed, 1 insertion(+), 27 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index cdbfad950f2..1895aace00f 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -15217,7 +15217,7 @@ bool Player::CanSeeStartQuest(Quest const* quest) { if (!DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) && SatisfyQuestClass(quest, false) && SatisfyQuestRace(quest, false) && SatisfyQuestSkill(quest, false) && SatisfyQuestExclusiveGroup(quest, false) && SatisfyQuestReputation(quest, false) && - SatisfyQuestDependentQuests(quest, false) && SatisfyQuestNextChain(quest, false) && + SatisfyQuestDependentQuests(quest, false) && SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) && SatisfyQuestMonth(quest, false) && SatisfyQuestSeasonal(quest, false)) { @@ -15234,7 +15234,6 @@ bool Player::CanTakeQuest(Quest const* quest, bool msg) && SatisfyQuestClass(quest, msg) && SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg) && SatisfyQuestSkill(quest, msg) && SatisfyQuestReputation(quest, msg) && SatisfyQuestDependentQuests(quest, msg) && SatisfyQuestTimed(quest, msg) - && SatisfyQuestNextChain(quest, msg) && SatisfyQuestDay(quest, msg) && SatisfyQuestWeek(quest, msg) && SatisfyQuestMonth(quest, msg) && SatisfyQuestSeasonal(quest, msg) && SatisfyQuestConditions(quest, msg); @@ -16370,30 +16369,6 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const return true; } -bool Player::SatisfyQuestNextChain(Quest const* qInfo, bool msg) const -{ - uint32 nextQuest = qInfo->GetNextQuestInChain(); - if (!nextQuest) - return true; - - // next quest in chain already started or completed - if (GetQuestStatus(nextQuest) != QUEST_STATUS_NONE) // GetQuestStatus returns QUEST_STATUS_COMPLETED for rewarded quests - { - if (msg) - { - SendCanTakeQuestResponse(QUEST_ERR_NONE); - TC_LOG_DEBUG("misc", "Player::SatisfyQuestNextChain: Sent QUEST_ERR_NONE (QuestID: %u) because player '%s' (%s) already did or started next quest in chain.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); - } - return false; - } - - // check for all quests further up the chain - // only necessary if there are quest chains with more than one quest that can be skipped - //return SatisfyQuestNextChain(qInfo->GetNextQuestInChain(), msg); - return true; -} - bool Player::SatisfyQuestDay(Quest const* qInfo, bool /*msg*/) const { if (!qInfo->IsDaily() && !qInfo->IsDFQuest()) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index a81afcb8bba..297c90fc5d9 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1352,7 +1352,6 @@ class TC_GAME_API Player : public Unit, public GridObject bool SatisfyQuestConditions(Quest const* qInfo, bool msg); bool SatisfyQuestTimed(Quest const* qInfo, bool msg) const; bool SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const; - bool SatisfyQuestNextChain(Quest const* qInfo, bool msg) const; bool SatisfyQuestDay(Quest const* qInfo, bool msg) const; bool SatisfyQuestWeek(Quest const* qInfo, bool msg) const; bool SatisfyQuestMonth(Quest const* qInfo, bool msg) const; -- cgit v1.2.3 From 9842ca3f4a843e97815512e84e9860737ab5db21 Mon Sep 17 00:00:00 2001 From: xinef1 Date: Thu, 27 Apr 2017 08:34:43 +0200 Subject: Core/Spells: Corrected aura SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK handling for auras with very high values (#19054) (cherry picked from commit e30e11d4c74872c6de87df831696aa643321f6d9) --- src/server/game/Entities/Unit/Unit.cpp | 11 +++++---- src/server/game/Entities/Unit/Unit.h | 4 ++++ src/server/game/Spells/Auras/SpellAuraEffects.cpp | 28 +++++++++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index f15294e8054..3fad48d4e6d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -285,12 +285,12 @@ SpellNonMeleeDamage::SpellNonMeleeDamage(Unit* _attacker, Unit* _target, uint32 } Unit::Unit(bool isWorldObject) : - WorldObject(isWorldObject), m_playerMovingMe(NULL), m_lastSanctuaryTime(0), + WorldObject(isWorldObject), m_playerMovingMe(nullptr), m_lastSanctuaryTime(0), IsAIEnabled(false), NeedChangeAI(false), LastCharmerGUID(), m_ControlledByPlayer(false), movespline(new Movement::MoveSpline()), - i_AI(NULL), i_disabledAI(NULL), m_AutoRepeatFirstCast(false), m_procDeep(0), + i_AI(nullptr), i_disabledAI(nullptr), m_AutoRepeatFirstCast(false), m_procDeep(0), m_removedAurasCount(0), i_motionMaster(new MotionMaster(this)), m_regenTimer(0), m_ThreatManager(this), - m_vehicle(NULL), m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), + m_vehicle(nullptr), m_vehicleKit(nullptr), m_unitTypeMask(UNIT_MASK_NONE), m_HostileRefManager(this), _aiAnimKitId(0), _movementAnimKitId(0), _meleeAnimKitId(0), _spellHistory(new SpellHistory(this)) { @@ -389,10 +389,11 @@ Unit::Unit(bool isWorldObject) : m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE); - _lastLiquid = NULL; + _lastLiquid = nullptr; _oldFactionId = 0; _isWalkingBeforeCharm = false; + _instantCast = false; } //////////////////////////////////////////////////////////// @@ -9158,7 +9159,7 @@ void Unit::ModSpellCastTime(SpellInfo const* spellInfo, int32 & castTime, Spell* if (!(spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) && ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT)) - castTime = int32(float(castTime) * m_unitData->ModCastingSpeed); + castTime = CanInstantCast() ? 0 : int32(float(castTime) * m_unitData->ModCastingSpeed); else if (spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG)) castTime = int32(float(castTime) * m_modAttackSpeedPct[RANGED_ATTACK]); else if (IsPartOfSkillLine(SKILL_COOKING, spellInfo->Id) && HasAura(67556)) // cooking with Chef Hat. diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index c61146e063b..7d5f47ebb04 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1999,6 +1999,9 @@ class TC_GAME_API Unit : public WorldObject ObjectGuid GetTarget() const { return m_unitData->Target; } virtual void SetTarget(ObjectGuid const& /*guid*/) = 0; + void SetInstantCast(bool set) { _instantCast = set; } + bool CanInstantCast() const { return _instantCast; } + // Movement info Movement::MoveSpline * movespline; @@ -2151,6 +2154,7 @@ class TC_GAME_API Unit : public WorldObject bool m_cleanupDone; // lock made to not add stuff after cleanup before delete bool m_duringRemoveFromWorld; // lock made to not add stuff after begining removing from world + bool _instantCast; uint32 _oldFactionId; ///< faction before charm bool _isWalkingBeforeCharm; ///< Are we walking before we were charmed? diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 566ecfd9df8..f43aaab35e3 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -4072,6 +4072,34 @@ void AuraEffect::HandleModCastingSpeed(AuraApplication const* aurApp, uint8 mode Unit* target = aurApp->GetTarget(); + // Do not apply such auras in normal way + if (GetAmount() >= 1000) + { + if (apply) + target->SetInstantCast(true); + else + { + // only SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK can have this high amount + // it's some rare case that you have 2 auras like that, but just in case ;) + + bool remove = true; + Unit::AuraEffectList const& castingSpeedNotStack = target->GetAuraEffectsByType(SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK); + for (AuraEffect const* aurEff : castingSpeedNotStack) + { + if (aurEff != this && aurEff->GetAmount() >= 1000) + { + remove = false; + break; + } + } + + if (remove) + target->SetInstantCast(false); + } + + return; + } + target->ApplyCastTimePercentMod((float)GetAmount(), apply); } -- cgit v1.2.3 From 9a57e95f102a9d35ac8416d02e24c0dddbc755ed Mon Sep 17 00:00:00 2001 From: ccrs Date: Thu, 27 Apr 2017 13:53:18 +0200 Subject: Core/Misc: 522f537048 followup (cherry picked from commit 5043639c563514c079ba6eb959dd4c1c555fa494) --- src/server/game/Entities/Creature/Creature.cpp | 20 ++++++++++++++++++++ src/server/game/Entities/Creature/Creature.h | 4 +++- src/server/game/Entities/Unit/Unit.cpp | 3 --- src/server/game/Entities/Unit/Unit.h | 5 +---- 4 files changed, 24 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 1e60264c8aa..bf309ee0089 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -3154,6 +3154,26 @@ void Creature::ReleaseFocus(Spell const* focusSpell, bool withDelay) m_focusDelay = (!IsPet() && withDelay) ? GameTime::GetGameTimeMS() : 0; // don't allow re-target right away to prevent visual bugs } +bool Creature::IsMovementPreventedByCasting() const +{ + // first check if currently a movement allowed channel is active and we're not casting + if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) + { + if (spell->getState() != SPELL_STATE_FINISHED && spell->IsChannelActive()) + if (spell->GetSpellInfo()->IsMoveAllowedChannel()) + if (HasUnitState(UNIT_STATE_CASTING)) + return true; + } + + if (const_cast(this)->IsFocusing(nullptr, true)) + return true; + + if (HasUnitState(UNIT_STATE_CASTING)) + return true; + + return false; +} + void Creature::StartPickPocketRefillTimer() { _pickpocketLootRestore = time(nullptr) + sWorld->getIntConfig(CONFIG_CREATURE_PICKPOCKET_REFILL); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index b4eaf0e4cfa..c19c6854239 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -328,9 +328,11 @@ class TC_GAME_API Creature : public Unit, public GridObject, public Ma void MustReacquireTarget() { m_shouldReacquireTarget = true; } // flags the Creature for forced (client displayed) target reacquisition in the next ::Update call void DoNotReacquireTarget() { m_shouldReacquireTarget = false; m_suppressedTarget = ObjectGuid::Empty; m_suppressedOrientation = 0.0f; } void FocusTarget(Spell const* focusSpell, WorldObject const* target); - bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false) override; + bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false); void ReleaseFocus(Spell const* focusSpell = nullptr, bool withDelay = true); + bool IsMovementPreventedByCasting() const override; + // Part of Evade mechanics time_t GetLastDamagedTime() const { return _lastDamagedTime; } void SetLastDamagedTime(time_t val) { _lastDamagedTime = val; } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 3fad48d4e6d..4c0d1ef81bd 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3134,9 +3134,6 @@ bool Unit::IsMovementPreventedByCasting() const if (spell->GetSpellInfo()->IsMoveAllowedChannel()) return false; - if (const_cast(this)->IsFocusing(nullptr, true)) - return false; - // prohibit movement for all other spell casts return true; } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 7d5f47ebb04..e098542216c 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1659,10 +1659,7 @@ class TC_GAME_API Unit : public WorldObject virtual SpellInfo const* GetCastSpellInfo(SpellInfo const* spellInfo) const; uint32 GetCastSpellXSpellVisualId(SpellInfo const* spellInfo) const; - virtual bool IsFocusing(Spell const* /*focusSpell*/ = nullptr, bool /*withDelay*/ = false) { return false; } - - // Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING - bool IsMovementPreventedByCasting() const; + virtual bool IsMovementPreventedByCasting() const; SpellHistory* GetSpellHistory() { return _spellHistory; } SpellHistory const* GetSpellHistory() const { return _spellHistory; } -- cgit v1.2.3 From 5d411e0b21b1f1a4653d274d9b1cc7fef17f232b Mon Sep 17 00:00:00 2001 From: ccrs Date: Thu, 27 Apr 2017 14:00:57 +0200 Subject: Core/CreatureAI: b6b0353bff followup (cherry picked from commit 5fc366d03bf4e5250443e0573a4c9fa4611968a4) --- src/server/game/AI/CreatureAI.cpp | 4 ++-- .../Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp | 3 ++- .../Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 835f5369c9f..7d1aaca570e 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -217,7 +217,7 @@ void CreatureAI::SetGazeOn(Unit* target) { if (me->IsValidAttackTarget(target)) { - if (!me->IsFocusing(nullptr, true)) + if (!me->IsFocusing(nullptr, true) && target != me->GetVictim()) AttackStart(target); me->SetReactState(REACT_PASSIVE); } @@ -237,7 +237,7 @@ bool CreatureAI::UpdateVictimWithGaze() } if (Unit* victim = me->SelectVictim()) - if (!me->IsFocusing(nullptr, true)) + if (!me->IsFocusing(nullptr, true) && victim != me->GetVictim()) AttackStart(victim); return me->GetVictim() != nullptr; diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp index 18788ac23f7..6983e745e5e 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp @@ -1342,7 +1342,8 @@ class npc_the_lich_king_escape_hor : public CreatureScript if (!me->HasReactState(REACT_PASSIVE)) { if (Unit* victim = me->SelectVictim()) - AttackStart(victim); + if (!me->IsFocusing(nullptr, true) && victim != me->GetVictim()) + AttackStart(victim); return me->GetVictim() != nullptr; } else if (me->getThreatManager().getThreatList().size() < 2 && me->HasAura(SPELL_REMORSELESS_WINTER)) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp index 18aaf715bf3..a9ffaeb5871 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -635,7 +635,8 @@ protected: if (!me->HasReactState(REACT_PASSIVE)) { if (Unit* victim = me->SelectVictim()) - AttackStart(victim); + if (!me->IsFocusing(nullptr, true) && victim != me->GetVictim()) + AttackStart(victim); return me->GetVictim() != nullptr; } -- cgit v1.2.3 From 8c12f36915b2fddd48a5e4c9244c2b0498a64ae9 Mon Sep 17 00:00:00 2001 From: ccrs Date: Thu, 27 Apr 2017 14:16:40 +0200 Subject: Core/Spell: move creature focus bellow the possible interruptions (cherry picked from commit df96e053a554692127cce7148447147477351da8) --- src/server/game/Spells/Spell.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 1590ffb5c2a..85388dc5821 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2953,15 +2953,6 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered else m_casttime = m_spellInfo->CalcCastTime(m_caster->getLevel(), this); - if (m_caster->GetTypeId() == TYPEID_UNIT && !m_caster->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)) // _UNIT actually means creature. for some reason. - if (!(m_spellInfo->IsNextMeleeSwingSpell() || IsAutoRepeat() || (_triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING))) - { - if (m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget()) - m_caster->ToCreature()->FocusTarget(this, m_targets.GetObjectTarget()); - else if (m_spellInfo->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST)) - m_caster->ToCreature()->FocusTarget(this, nullptr); - } - // don't allow channeled spells / spells with cast time to be cast while moving // exception are only channeled spells that have no casttime and SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING // (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in) @@ -2978,6 +2969,18 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered } } + // focus if not controlled creature + if (m_caster->GetTypeId() == TYPEID_UNIT && !m_caster->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)) + { + if (!(m_spellInfo->IsNextMeleeSwingSpell() || IsAutoRepeat() || (_triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING))) + { + if (m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget()) + m_caster->ToCreature()->FocusTarget(this, m_targets.GetObjectTarget()); + else if (m_spellInfo->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST)) + m_caster->ToCreature()->FocusTarget(this, nullptr); + } + } + // set timer base at cast time ReSetTimer(); -- cgit v1.2.3 From d1bdb8bdd3e90fc435094a8615a0cbcbf472079a Mon Sep 17 00:00:00 2001 From: Keader Date: Thu, 27 Apr 2017 09:41:07 -0300 Subject: Core/Scripts: Re-hack Boss Loken. Followup 3a0cb90ea994e82dd8c70888fb847082f738d5dc Loken still need ClearUnitState Hack to DoMeleeAttackifReady work (cherry picked from commit 4431a1149da7bc48ad1047fc8c6135ed02b2e77b) --- src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp index e51db2e2878..9ac7fc0931b 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp @@ -161,6 +161,7 @@ public: break; case EVENT_RESUME_PULSING_SHOCKWAVE: DoCast(me, SPELL_PULSING_SHOCKWAVE_AURA, true); + me->ClearUnitState(UNIT_STATE_CASTING); // Workaround to allow DoMeleeAttackIfReady work DoCast(me, SPELL_PULSING_SHOCKWAVE, true); break; case EVENT_INTRO_DIALOGUE: -- cgit v1.2.3 From 2d4549023a6655d19671f7f7e6b4f7c9b71ae632 Mon Sep 17 00:00:00 2001 From: ccrs Date: Thu, 27 Apr 2017 14:55:06 +0200 Subject: Core/Unit: 2170541a51 followup use true as default value since pretty much all the script calls will expect that (cherry picked from commit c7a57e2a093ada2ece7a01eac2f627aeb26b08d5) --- src/server/game/AI/CreatureAI.cpp | 4 ++-- src/server/game/Entities/Creature/Creature.cpp | 12 ++++++------ src/server/game/Entities/Unit/Unit.cpp | 9 +++++---- src/server/game/Entities/Unit/Unit.h | 4 ++-- src/server/game/Spells/SpellEffects.cpp | 6 +++--- .../scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp | 2 +- .../scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp | 2 +- src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp | 2 +- .../FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp | 2 +- .../scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp | 4 ++-- .../scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp | 4 ++-- .../Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp | 2 +- src/server/scripts/Northrend/VioletHold/boss_erekem.cpp | 2 +- src/server/scripts/Northrend/zone_dragonblight.cpp | 2 +- src/server/scripts/Outland/BlackTemple/boss_illidan.cpp | 6 +++--- .../scripts/Outland/BlackTemple/boss_shade_of_akama.cpp | 2 +- src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp | 2 +- src/server/scripts/Outland/zone_hellfire_peninsula.cpp | 2 +- 18 files changed, 35 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 7d1aaca570e..3c65160aaf6 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -173,9 +173,9 @@ void CreatureAI::TriggerAlert(Unit const* who) const me->SendAIReaction(AI_REACTION_ALERT); // Face the unit (stealthed player) and set distracted state for 5 seconds - me->SetFacingTo(me->GetAngle(who->GetPositionX(), who->GetPositionY()), true); - me->StopMoving(); me->GetMotionMaster()->MoveDistract(5 * IN_MILLISECONDS); + me->StopMoving(); + me->SetFacingTo(me->GetAngle(who)); } void CreatureAI::EnterEvadeMode(EvadeReason why) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index bf309ee0089..c844767b6ba 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -681,10 +681,10 @@ void Creature::Update(uint32 diff) if (!m_suppressedTarget.IsEmpty()) { if (WorldObject const* objTarget = ObjectAccessor::GetWorldObject(*this, m_suppressedTarget)) - SetFacingToObject(objTarget); + SetFacingToObject(objTarget, false); } else - SetFacingTo(m_suppressedOrientation); + SetFacingTo(m_suppressedOrientation, false); m_shouldReacquireTarget = false; } @@ -3088,10 +3088,10 @@ void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target) bool const canTurnDuringCast = !spellInfo->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST); // Face the target - we need to do this before the unit state is modified for no-turn spells if (target) - SetFacingToObject(target); + SetFacingToObject(target, false); else if (!canTurnDuringCast) if (Unit* victim = GetVictim()) - SetFacingToObject(victim); // ensure orientation is correct at beginning of cast + SetFacingToObject(victim, false); // ensure orientation is correct at beginning of cast if (!canTurnDuringCast) AddUnitState(UNIT_STATE_CANNOT_TURN); @@ -3137,10 +3137,10 @@ void Creature::ReleaseFocus(Spell const* focusSpell, bool withDelay) if (!m_suppressedTarget.IsEmpty()) { if (WorldObject const* objTarget = ObjectAccessor::GetWorldObject(*this, m_suppressedTarget)) - SetFacingToObject(objTarget); + SetFacingToObject(objTarget, false); } else - SetFacingTo(m_suppressedOrientation); + SetFacingTo(m_suppressedOrientation, false); } else // tell the creature that it should reacquire its actual target after the delay expires (this is handled in ::Update) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 4c0d1ef81bd..815ef9a4a62 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2027,7 +2027,7 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr return; // ignore ranged case if (GetTypeId() == TYPEID_UNIT && !HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)) - SetFacingToObject(victim); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) + SetFacingToObject(victim, false); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) // melee attack spell cast at main hand attack only - no normal melee dmg dealt if (attType == BASE_ATTACK && m_currentSpells[CURRENT_MELEE_SPELL] && !extra) @@ -2108,7 +2108,7 @@ void Unit::FakeAttackerStateUpdate(Unit* victim, WeaponAttackType attType /*= BA return; // ignore ranged case if (GetTypeId() == TYPEID_UNIT && !HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)) - SetFacingToObject(victim); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) + SetFacingToObject(victim, false); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) CalcDamageInfo damageInfo; damageInfo.attacker = this; @@ -13645,7 +13645,8 @@ void Unit::SetInFront(WorldObject const* target) void Unit::SetFacingTo(float ori, bool force) { - if (!force && !IsStopped()) + // do not face when already moving + if (!force && (!IsStopped() || !movespline->Finalized())) return; Movement::MoveSplineInit init(this); @@ -13659,7 +13660,7 @@ void Unit::SetFacingTo(float ori, bool force) void Unit::SetFacingToObject(WorldObject const* object, bool force) { // do not face when already moving - if (!force && !IsStopped()) + if (!force && (!IsStopped() || !movespline->Finalized())) return; /// @todo figure out under what conditions creature will move towards object instead of facing it where it currently is. diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index e098542216c..83f631311d2 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1383,8 +1383,8 @@ class TC_GAME_API Unit : public WorldObject void UpdateMovementForcesModMagnitude(); void SetInFront(WorldObject const* target); - void SetFacingTo(float ori, bool force = false); - void SetFacingToObject(WorldObject const* object, bool force = false); + void SetFacingTo(float const ori, bool force = true); + void SetFacingToObject(WorldObject const* object, bool force = true); void SendChangeCurrentVictimOpcode(HostileReference* pHostileReference); void SendClearThreatListOpcode(); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 56a050eea65..8f77c39afe2 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -2232,11 +2232,11 @@ void Spell::EffectDistract(SpellEffIndex /*effIndex*/) if (unitTarget->HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING)) return; - unitTarget->SetFacingTo(unitTarget->GetAngle(destTarget)); - unitTarget->ClearUnitState(UNIT_STATE_MOVING); - if (unitTarget->GetTypeId() == TYPEID_UNIT) unitTarget->GetMotionMaster()->MoveDistract(damage * IN_MILLISECONDS); + + unitTarget->StopMoving(); + unitTarget->SetFacingTo(unitTarget->GetAngle(destTarget)); } void Spell::EffectPickPocket(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp index da6aebea818..c5366285de7 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp @@ -328,7 +328,7 @@ public: DoResetThreat(); if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) { - me->SetFacingToObject(target, true); + me->SetFacingToObject(target); DoCast(target, SPELL_RAIN_OF_BONES); } break; diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp index 607a89fabb7..334e3ebb26c 100644 --- a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp +++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp @@ -199,7 +199,7 @@ public: { case 4: SetEscortPaused(true); - me->SetFacingTo(1.775791f, true); + me->SetFacingTo(1.775791f); me->AddNpcFlag(UNIT_NPC_FLAG_GOSSIP); Talk(SAY_MORRIDUNE_2); break; diff --git a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp index a7daac95144..2deec5fa15e 100644 --- a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp +++ b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp @@ -249,7 +249,7 @@ public: me->SetCanFly(true); me->SetDisableGravity(true); me->SetAnimTier(UnitBytes1_Flags(UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER), false); - me->SetFacingTo(me->GetOrientation() + float(M_PI), true); + me->SetFacingTo(me->GetOrientation() + float(M_PI)); if (Creature * trigger = me->SummonCreature(NPC_TRIGGER, MiddleRoomLocation, TEMPSUMMON_CORPSE_DESPAWN)) triggerGUID = trigger->GetGUID(); me->GetMotionMaster()->MoveTakeoff(11, Phase2Floating); diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp index 5a4532be849..265db80d353 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp @@ -309,7 +309,7 @@ class boss_devourer_of_souls : public CreatureScript case EVENT_WAILING_SOULS_TICK: beamAngle += beamAngleDiff; - me->SetFacingTo(beamAngle, true); + me->SetFacingTo(beamAngle); me->StopMoving(); DoCast(me, SPELL_WAILING_SOULS); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 590291c6e30..e1cc3c12f54 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -735,7 +735,7 @@ class npc_spinestalker : public CreatureScript me->SetDisableGravity(false); me->SetAnimTier(UNIT_BYTE1_FLAG_NONE, false); me->SetHomePosition(SpinestalkerLandPos); - me->SetFacingTo(SpinestalkerLandPos.GetOrientation(), true); + me->SetFacingTo(SpinestalkerLandPos.GetOrientation()); me->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE); me->SetReactState(REACT_AGGRESSIVE); } @@ -872,7 +872,7 @@ class npc_rimefang : public CreatureScript me->SetDisableGravity(false); me->SetAnimTier(UNIT_BYTE1_FLAG_NONE, false); me->SetHomePosition(RimefangLandPos); - me->SetFacingTo(RimefangLandPos.GetOrientation(), true); + me->SetFacingTo(RimefangLandPos.GetOrientation()); me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); me->SetReactState(REACT_AGGRESSIVE); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 73877fa1ac9..7f6b970e42e 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -819,7 +819,7 @@ class boss_the_lich_king : public CreatureScript events.ScheduleEvent(EVENT_INTRO_TALK_1, 9000, 0, PHASE_INTRO); break; case POINT_CENTER_1: - me->SetFacingTo(0.0f, true); + me->SetFacingTo(0.0f); Talk(SAY_LK_REMORSELESS_WINTER); me->GetMap()->SetZoneMusic(AREA_ICECROWN_CITADEL, MUSIC_SPECIAL); DoCast(me, SPELL_REMORSELESS_WINTER_1); @@ -835,7 +835,7 @@ class boss_the_lich_king : public CreatureScript events.ScheduleEvent(EVENT_SOUL_REAPER, 94000, 0, PHASE_TWO); break; case POINT_CENTER_2: - me->SetFacingTo(0.0f, true); + me->SetFacingTo(0.0f); Talk(SAY_LK_REMORSELESS_WINTER); me->GetMap()->SetZoneMusic(AREA_ICECROWN_CITADEL, MUSIC_SPECIAL); DoCast(me, SPELL_REMORSELESS_WINTER_2); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp index 1884efd8916..e70769ffd11 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp @@ -444,7 +444,7 @@ class boss_algalon_the_observer : public CreatureScript me->SetDisableGravity(false); else if (pointId == POINT_ALGALON_OUTRO) { - me->SetFacingTo(1.605703f, true); + me->SetFacingTo(1.605703f); events.ScheduleEvent(EVENT_OUTRO_3, 1200); events.ScheduleEvent(EVENT_OUTRO_4, 2400); events.ScheduleEvent(EVENT_OUTRO_5, 8500); diff --git a/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp b/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp index 5a4c90451f4..5b7eabe4f00 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp @@ -78,7 +78,7 @@ class boss_erekem : public CreatureScript void MovementInform(uint32 type, uint32 pointId) override { if (type == EFFECT_MOTION_TYPE && pointId == POINT_INTRO) - me->SetFacingTo(4.921828f, true); + me->SetFacingTo(4.921828f); } void JustReachedHome() override diff --git a/src/server/scripts/Northrend/zone_dragonblight.cpp b/src/server/scripts/Northrend/zone_dragonblight.cpp index 74d5af9f484..f2c59c76c1d 100644 --- a/src/server/scripts/Northrend/zone_dragonblight.cpp +++ b/src/server/scripts/Northrend/zone_dragonblight.cpp @@ -174,7 +174,7 @@ class npc_commander_eligor_dawnbringer : public CreatureScript { if (id == 1) { - me->SetFacingTo(PosTalkLocations[talkWing].GetOrientation(), true); + me->SetFacingTo(PosTalkLocations[talkWing].GetOrientation()); TurnAudience(); switch (talkWing) diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index e66584c802e..c92e304152c 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -865,7 +865,7 @@ public: events.ScheduleEvent(EVENT_FLY_TO_RANDOM_PILLAR, Seconds(2), GROUP_PHASE_ALL); break; case EVENT_CHANGE_ORIENTATION: - me->SetFacingTo(_orientation, true); + me->SetFacingTo(_orientation); break; case EVENT_FLY: ChangeOrientation(3.137039f); @@ -882,7 +882,7 @@ public: case EVENT_FACE_MIDDLE: { float angle = me->GetAngle(IllidanMiddlePoint); - me->SetFacingTo(angle, true); + me->SetFacingTo(angle); break; } case EVENT_EYE_BLAST: @@ -1299,7 +1299,7 @@ public: me->SetEmoteState(EMOTE_STATE_READY1H); break; case EVENT_CHANGE_ORIENTATION: - me->SetFacingTo(_orientation, true); + me->SetFacingTo(_orientation); break; case EVENT_HEALING_POTION: if (me->HealthBelowPct(20)) diff --git a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp index 4a868084e41..610d12a377b 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp @@ -499,7 +499,7 @@ public: _events.Repeat(Seconds(3), Seconds(7)); break; case EVENT_START_SOUL_RETRIEVE: - me->SetFacingTo(FACE_THE_DOOR, true); + me->SetFacingTo(FACE_THE_DOOR); DoCast(SPELL_AKAMA_SOUL_RETRIEVE); _events.ScheduleEvent(EVENT_START_BROKEN_FREE, Seconds(15)); break; diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 9ba6a1cefc9..e08071fc475 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -597,7 +597,7 @@ class boss_kaelthas : public CreatureScript events.ScheduleEvent(EVENT_TRANSITION_1, 1000); break; case POINT_TRANSITION_CENTER_ASCENDING: - me->SetFacingTo(float(M_PI), true); + me->SetFacingTo(float(M_PI)); Talk(SAY_PHASE5_NUTS); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetDisableGravity(true); diff --git a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp index b69d42244b0..3a3902a5668 100644 --- a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp +++ b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp @@ -957,7 +957,7 @@ public: void StartFight(Player* player) { me->Dismount(); - me->SetFacingToObject(player, true); + me->SetFacingToObject(player); me->RemoveNpcFlag(UNIT_NPC_FLAG_GOSSIP); _playerGUID = player->GetGUID(); _events.ScheduleEvent(EVENT_TALK, Seconds(2)); -- cgit v1.2.3 From 104e745edfb89f95e34cad7840eae0b6e183bf94 Mon Sep 17 00:00:00 2001 From: ccrs Date: Thu, 27 Apr 2017 15:34:01 +0200 Subject: Core/Misc: cleanup SetInFront uses Set in front modifies only the serverside orientation, use with care. Also check for current focus to prevent things like incorrect damage on casting creatures (ie dragon breath direction change in your face because of some taunt missclick) (cherry picked from commit 229444b74a7e2176db142e0446d4268995c5aad6) --- src/server/game/AI/CoreAI/TotemAI.cpp | 3 +-- src/server/game/Entities/Creature/Creature.h | 2 +- src/server/game/Entities/Unit/Unit.cpp | 8 +++++--- src/server/game/Entities/Unit/Unit.h | 1 + src/server/game/Handlers/PetHandler.cpp | 6 ++++-- .../scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp | 4 ++-- src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp | 4 ++-- src/server/scripts/Northrend/zone_zuldrak.cpp | 4 ++-- src/server/scripts/Outland/zone_terokkar_forest.cpp | 2 +- src/server/scripts/World/npcs_special.cpp | 2 +- 10 files changed, 20 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp index 70ed58d853d..a2f0f8f664b 100644 --- a/src/server/game/AI/CoreAI/TotemAI.cpp +++ b/src/server/game/AI/CoreAI/TotemAI.cpp @@ -83,8 +83,7 @@ void TotemAI::UpdateAI(uint32 /*diff*/) i_victimGuid = victim->GetGUID(); // attack - me->SetInFront(victim); // client change orientation by self - me->CastSpell(victim, me->ToTotem()->GetSpell(), false); + me->CastSpell(victim, me->ToTotem()->GetSpell()); } else i_victimGuid.Clear(); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index c19c6854239..cc5608bfc3d 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -328,7 +328,7 @@ class TC_GAME_API Creature : public Unit, public GridObject, public Ma void MustReacquireTarget() { m_shouldReacquireTarget = true; } // flags the Creature for forced (client displayed) target reacquisition in the next ::Update call void DoNotReacquireTarget() { m_shouldReacquireTarget = false; m_suppressedTarget = ObjectGuid::Empty; m_suppressedOrientation = 0.0f; } void FocusTarget(Spell const* focusSpell, WorldObject const* target); - bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false); + bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false) override; void ReleaseFocus(Spell const* focusSpell = nullptr, bool withDelay = true); bool IsMovementPreventedByCasting() const override; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 815ef9a4a62..df7273a5b2d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -8839,7 +8839,8 @@ void Unit::TauntApply(Unit* taunter) if (target && target == taunter) return; - SetInFront(taunter); + if (!IsFocusing(nullptr, true)) + SetInFront(taunter); if (creature->IsAIEnabled) creature->AI()->AttackStart(taunter); @@ -8878,7 +8879,8 @@ void Unit::TauntFadeOut(Unit* taunter) if (target && target != taunter) { - SetInFront(target); + if (!IsFocusing(nullptr, true)) + SetInFront(target); if (creature->IsAIEnabled) creature->AI()->AttackStart(target); } @@ -8960,7 +8962,7 @@ Unit* Creature::SelectVictim() if (target && _IsTargetAcceptable(target) && CanCreatureAttack(target)) { - if (!IsFocusing()) + if (!IsFocusing(nullptr, true)) SetInFront(target); return target; } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 83f631311d2..7f126fa2c3e 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1659,6 +1659,7 @@ class TC_GAME_API Unit : public WorldObject virtual SpellInfo const* GetCastSpellInfo(SpellInfo const* spellInfo) const; uint32 GetCastSpellXSpellVisualId(SpellInfo const* spellInfo) const; + virtual bool IsFocusing(Spell const* /*focusSpell*/ = nullptr, bool /*withDelay*/ = false) { return false; } virtual bool IsMovementPreventedByCasting() const; SpellHistory* GetSpellHistory() { return _spellHistory; } diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 8dc2523afcc..73bc95f2caf 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -331,13 +331,15 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe { if (unit_target) { - pet->SetInFront(unit_target); + if (!pet->IsFocusing()) + pet->SetInFront(unit_target); if (Player* player = unit_target->ToPlayer()) pet->SendUpdateToPlayer(player); } else if (Unit* unit_target2 = spell->m_targets.GetUnitTarget()) { - pet->SetInFront(unit_target2); + if (!pet->IsFocusing()) + pet->SetInFront(unit_target2); if (Player* player = unit_target2->ToPlayer()) pet->SendUpdateToPlayer(player); } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp index 5d760eecbbc..23f9d315457 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp @@ -196,8 +196,8 @@ public: ++IntroPhase; break; case 1: - me->SetInFront(Madrigosa); - Madrigosa->SetInFront(me); + me->SetFacingToObject(Madrigosa); + Madrigosa->SetFacingToObject(me); Madrigosa->AI()->Talk(YELL_MADR_INTRO, me); IntroPhaseTimer = 9000; ++IntroPhase; diff --git a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp index 029ea6ad9ce..d7bc3bd5240 100644 --- a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp +++ b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp @@ -532,8 +532,8 @@ public: return 1000; case 2: Talk(GEEZLE_SAY_1, Spark); - Spark->SetInFront(me); - me->SetInFront(Spark); + Spark->SetFacingToObject(me); + me->SetFacingToObject(Spark); return 5000; case 3: Spark->AI()->Talk(SPARK_SAY_2); diff --git a/src/server/scripts/Northrend/zone_zuldrak.cpp b/src/server/scripts/Northrend/zone_zuldrak.cpp index 0e42a431d93..23716389e7e 100644 --- a/src/server/scripts/Northrend/zone_zuldrak.cpp +++ b/src/server/scripts/Northrend/zone_zuldrak.cpp @@ -70,8 +70,8 @@ public: void LockRageclaw(Creature* rageclaw) { // pointer check not needed - me->SetInFront(rageclaw); - rageclaw->SetInFront(me); + me->SetFacingToObject(rageclaw); + rageclaw->SetFacingToObject(me); DoCast(rageclaw, SPELL_LEFT_CHAIN, true); DoCast(rageclaw, SPELL_RIGHT_CHAIN, true); diff --git a/src/server/scripts/Outland/zone_terokkar_forest.cpp b/src/server/scripts/Outland/zone_terokkar_forest.cpp index 2e604b4291f..bf595557c49 100644 --- a/src/server/scripts/Outland/zone_terokkar_forest.cpp +++ b/src/server/scripts/Outland/zone_terokkar_forest.cpp @@ -469,7 +469,7 @@ public: player->GroupEventHappens(ESCAPE_FROM_FIREWING_POINT_A, me); else if (player->GetTeam() == HORDE) player->GroupEventHappens(ESCAPE_FROM_FIREWING_POINT_H, me); - me->SetInFront(player); + me->SetFacingToObject(player); break; case 30: me->HandleEmoteCommand(EMOTE_ONESHOT_WAVE); diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 671a03918ca..a5d11011ea1 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -420,7 +420,7 @@ public: { if (me->IsWithinLOS(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()) && me->IsWithinDistInMap(player, 30.0f)) { - me->SetInFront(player); + me->SetFacingToObject(player); Active = false; switch (emote) -- cgit v1.2.3 From 6a96addadd5dea633b3066b8d0427302ba514364 Mon Sep 17 00:00:00 2001 From: ariel- Date: Thu, 27 Apr 2017 10:59:09 -0300 Subject: Core/Unit: 229444b74a follow-up - IsFocusing is made virtual again, so there's no need to keep a duplicated function This reverts commit 5043639c563514c079ba6eb959dd4c1c555fa494. (cherry picked from commit 3ea46e57afe26778704647084cc6fa55a798e510) --- src/server/game/Entities/Creature/Creature.cpp | 20 -------------------- src/server/game/Entities/Creature/Creature.h | 2 -- src/server/game/Entities/Unit/Unit.cpp | 3 +++ src/server/game/Entities/Unit/Unit.h | 4 +++- 4 files changed, 6 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index c844767b6ba..ba948d4ede3 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -3154,26 +3154,6 @@ void Creature::ReleaseFocus(Spell const* focusSpell, bool withDelay) m_focusDelay = (!IsPet() && withDelay) ? GameTime::GetGameTimeMS() : 0; // don't allow re-target right away to prevent visual bugs } -bool Creature::IsMovementPreventedByCasting() const -{ - // first check if currently a movement allowed channel is active and we're not casting - if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) - { - if (spell->getState() != SPELL_STATE_FINISHED && spell->IsChannelActive()) - if (spell->GetSpellInfo()->IsMoveAllowedChannel()) - if (HasUnitState(UNIT_STATE_CASTING)) - return true; - } - - if (const_cast(this)->IsFocusing(nullptr, true)) - return true; - - if (HasUnitState(UNIT_STATE_CASTING)) - return true; - - return false; -} - void Creature::StartPickPocketRefillTimer() { _pickpocketLootRestore = time(nullptr) + sWorld->getIntConfig(CONFIG_CREATURE_PICKPOCKET_REFILL); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index cc5608bfc3d..b4eaf0e4cfa 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -331,8 +331,6 @@ class TC_GAME_API Creature : public Unit, public GridObject, public Ma bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false) override; void ReleaseFocus(Spell const* focusSpell = nullptr, bool withDelay = true); - bool IsMovementPreventedByCasting() const override; - // Part of Evade mechanics time_t GetLastDamagedTime() const { return _lastDamagedTime; } void SetLastDamagedTime(time_t val) { _lastDamagedTime = val; } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index df7273a5b2d..a9eeed7c4e6 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3134,6 +3134,9 @@ bool Unit::IsMovementPreventedByCasting() const if (spell->GetSpellInfo()->IsMoveAllowedChannel()) return false; + if (const_cast(this)->IsFocusing(nullptr, true)) + return false; + // prohibit movement for all other spell casts return true; } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 7f126fa2c3e..5f4b0f9ac98 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1660,7 +1660,9 @@ class TC_GAME_API Unit : public WorldObject uint32 GetCastSpellXSpellVisualId(SpellInfo const* spellInfo) const; virtual bool IsFocusing(Spell const* /*focusSpell*/ = nullptr, bool /*withDelay*/ = false) { return false; } - virtual bool IsMovementPreventedByCasting() const; + + // Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING + bool IsMovementPreventedByCasting() const; SpellHistory* GetSpellHistory() { return _spellHistory; } SpellHistory const* GetSpellHistory() const { return _spellHistory; } -- cgit v1.2.3 From a46286a803b41b375ed9352858c742626bb85720 Mon Sep 17 00:00:00 2001 From: ccrs Date: Thu, 27 Apr 2017 19:40:23 +0200 Subject: Core/Unit: revert 3ea46e57af After discussion we realized, ariel and me, that Creature and Unit IsMovementPreventedByCasting() have not the same checks (order matters) (cherry picked from commit 5a2f0ce29e29d934c200f617fec6dad619fab9a5) --- src/server/game/Entities/Creature/Creature.cpp | 20 ++++++++++++++++++++ src/server/game/Entities/Creature/Creature.h | 2 ++ src/server/game/Entities/Unit/Unit.cpp | 3 --- src/server/game/Entities/Unit/Unit.h | 4 +--- 4 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index ba948d4ede3..c844767b6ba 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -3154,6 +3154,26 @@ void Creature::ReleaseFocus(Spell const* focusSpell, bool withDelay) m_focusDelay = (!IsPet() && withDelay) ? GameTime::GetGameTimeMS() : 0; // don't allow re-target right away to prevent visual bugs } +bool Creature::IsMovementPreventedByCasting() const +{ + // first check if currently a movement allowed channel is active and we're not casting + if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) + { + if (spell->getState() != SPELL_STATE_FINISHED && spell->IsChannelActive()) + if (spell->GetSpellInfo()->IsMoveAllowedChannel()) + if (HasUnitState(UNIT_STATE_CASTING)) + return true; + } + + if (const_cast(this)->IsFocusing(nullptr, true)) + return true; + + if (HasUnitState(UNIT_STATE_CASTING)) + return true; + + return false; +} + void Creature::StartPickPocketRefillTimer() { _pickpocketLootRestore = time(nullptr) + sWorld->getIntConfig(CONFIG_CREATURE_PICKPOCKET_REFILL); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index b4eaf0e4cfa..cc5608bfc3d 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -331,6 +331,8 @@ class TC_GAME_API Creature : public Unit, public GridObject, public Ma bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false) override; void ReleaseFocus(Spell const* focusSpell = nullptr, bool withDelay = true); + bool IsMovementPreventedByCasting() const override; + // Part of Evade mechanics time_t GetLastDamagedTime() const { return _lastDamagedTime; } void SetLastDamagedTime(time_t val) { _lastDamagedTime = val; } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index a9eeed7c4e6..df7273a5b2d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3134,9 +3134,6 @@ bool Unit::IsMovementPreventedByCasting() const if (spell->GetSpellInfo()->IsMoveAllowedChannel()) return false; - if (const_cast(this)->IsFocusing(nullptr, true)) - return false; - // prohibit movement for all other spell casts return true; } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 5f4b0f9ac98..7f126fa2c3e 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1660,9 +1660,7 @@ class TC_GAME_API Unit : public WorldObject uint32 GetCastSpellXSpellVisualId(SpellInfo const* spellInfo) const; virtual bool IsFocusing(Spell const* /*focusSpell*/ = nullptr, bool /*withDelay*/ = false) { return false; } - - // Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING - bool IsMovementPreventedByCasting() const; + virtual bool IsMovementPreventedByCasting() const; SpellHistory* GetSpellHistory() { return _spellHistory; } SpellHistory const* GetSpellHistory() const { return _spellHistory; } -- cgit v1.2.3 From 93c19c4194b7eb82984bd13349c8ce3953a9ad92 Mon Sep 17 00:00:00 2001 From: ariel- Date: Fri, 28 Apr 2017 02:24:04 -0300 Subject: Core/Misc: camelize GetFaction/SetFaction properly (cherry picked from commit 4c4dca6d694bd1064b403a31a5b1c776a326f3ce) --- src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp | 2 +- .../game/AI/ScriptedAI/ScriptedFollowerAI.cpp | 6 +-- src/server/game/AI/SmartScripts/SmartAI.cpp | 2 +- src/server/game/AI/SmartScripts/SmartScript.cpp | 6 +-- .../game/Battlefield/Zones/BattlefieldTB.cpp | 2 +- .../game/Battlefield/Zones/BattlefieldWG.cpp | 24 ++++++------ .../game/Battlegrounds/Zones/BattlegroundAB.cpp | 2 +- .../game/Battlegrounds/Zones/BattlegroundAV.cpp | 4 +- .../game/Battlegrounds/Zones/BattlegroundEY.cpp | 2 +- .../game/Battlegrounds/Zones/BattlegroundIC.cpp | 12 +++--- .../game/Battlegrounds/Zones/BattlegroundSA.cpp | 8 ++-- src/server/game/Entities/Creature/Creature.cpp | 6 +-- .../game/Entities/Creature/TemporarySummon.cpp | 8 ++-- src/server/game/Entities/GameObject/GameObject.cpp | 4 +- src/server/game/Entities/Object/Object.cpp | 2 +- .../Object/Updates/ViewerDependentValues.h | 2 +- src/server/game/Entities/Pet/Pet.cpp | 2 +- src/server/game/Entities/Player/Player.cpp | 12 +++--- src/server/game/Entities/Unit/Unit.cpp | 24 ++++++------ src/server/game/Entities/Unit/Unit.h | 4 +- src/server/game/Handlers/AuctionHouseHandler.cpp | 34 ++++++++--------- src/server/game/Handlers/NPCHandler.cpp | 2 +- src/server/game/Spells/Auras/SpellAuraEffects.cpp | 2 +- src/server/game/Spells/SpellEffects.cpp | 12 +++--- src/server/scripts/Commands/cs_modify.cpp | 4 +- src/server/scripts/Commands/cs_npc.cpp | 4 +- src/server/scripts/Commands/cs_pet.cpp | 2 +- .../EasternKingdoms/AlteracValley/boss_balinda.cpp | 2 +- .../BlackrockDepths/blackrock_depths.cpp | 2 +- .../BlackrockDepths/boss_coren_direbrew.cpp | 8 ++-- .../boss_emperor_dagran_thaurissan.cpp | 2 +- .../BlackrockDepths/boss_tomb_of_seven.cpp | 4 +- .../BlackrockDepths/instance_blackrock_depths.cpp | 4 +- .../BlackwingLair/boss_nefarian.cpp | 6 +-- .../BlackwingLair/boss_vaelastrasz.cpp | 4 +- .../MoltenCore/boss_majordomo_executus.cpp | 4 +- .../BlackrockMountain/MoltenCore/boss_ragnaros.cpp | 4 +- .../EasternKingdoms/Gnomeregan/gnomeregan.cpp | 6 +-- .../Karazhan/boss_prince_malchezaar.cpp | 4 +- .../Karazhan/boss_shade_of_aran.cpp | 6 +-- .../EasternKingdoms/Karazhan/bosses_opera.cpp | 4 +- .../MagistersTerrace/boss_felblood_kaelthas.cpp | 4 +- .../EasternKingdoms/ScarletEnclave/chapter1.cpp | 10 ++--- .../EasternKingdoms/ScarletEnclave/chapter2.cpp | 2 +- .../EasternKingdoms/ScarletEnclave/chapter5.cpp | 44 +++++++++++----------- .../ShadowfangKeep/boss_apothecary_hummel.cpp | 6 +-- .../SunwellPlateau/boss_kalecgos.cpp | 4 +- .../SunwellPlateau/boss_kiljaeden.cpp | 6 +-- .../EasternKingdoms/Uldaman/boss_archaedas.cpp | 14 +++---- .../EasternKingdoms/Uldaman/instance_uldaman.cpp | 16 ++++---- .../EasternKingdoms/ZulGurub/boss_mandokir.cpp | 2 +- .../EasternKingdoms/zone_arathi_highlands.cpp | 2 +- .../scripts/EasternKingdoms/zone_ghostlands.cpp | 2 +- .../scripts/EasternKingdoms/zone_hinterlands.cpp | 2 +- .../EasternKingdoms/zone_stranglethorn_vale.cpp | 4 +- .../scripts/EasternKingdoms/zone_wetlands.cpp | 2 +- .../CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp | 4 +- .../BattleForMountHyjal/hyjal_trash.cpp | 2 +- .../scripts/Kalimdor/Firelands/boss_alysrazor.cpp | 2 +- .../scripts/Kalimdor/Maraudon/boss_noxxion.cpp | 4 +- .../Kalimdor/RazorfenDowns/razorfen_downs.cpp | 2 +- .../Kalimdor/RazorfenKraul/razorfen_kraul.cpp | 2 +- .../Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp | 4 +- .../TempleOfAhnQiraj/boss_twinemperors.cpp | 6 +-- .../Kalimdor/WailingCaverns/wailing_caverns.cpp | 2 +- .../scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp | 2 +- .../scripts/Kalimdor/ZulFarrak/zulfarrak.cpp | 12 +++--- src/server/scripts/Kalimdor/zone_ashenvale.cpp | 4 +- .../scripts/Kalimdor/zone_azuremyst_isle.cpp | 8 ++-- .../scripts/Kalimdor/zone_dustwallow_marsh.cpp | 2 +- src/server/scripts/Kalimdor/zone_felwood.cpp | 2 +- src/server/scripts/Kalimdor/zone_silithus.cpp | 6 +-- src/server/scripts/Kalimdor/zone_tanaris.cpp | 6 +-- src/server/scripts/Kalimdor/zone_the_barrens.cpp | 18 ++++----- src/server/scripts/Kalimdor/zone_winterspring.cpp | 2 +- .../TrialOfTheChampion/boss_argent_challenge.cpp | 4 +- .../TrialOfTheCrusader/boss_anubarak_trial.cpp | 2 +- .../TrialOfTheCrusader/boss_faction_champions.cpp | 4 +- .../IcecrownCitadel/boss_deathbringer_saurfang.cpp | 4 +- .../IcecrownCitadel/boss_lady_deathwhisper.cpp | 2 +- .../Northrend/Nexus/EyeOfEternity/boss_malygos.cpp | 2 +- .../Northrend/Nexus/Nexus/instance_nexus.cpp | 10 ++--- .../Ulduar/Ulduar/boss_algalon_the_observer.cpp | 2 +- .../Ulduar/Ulduar/boss_flame_leviathan.cpp | 2 +- .../scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp | 4 +- .../scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp | 2 +- .../scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp | 2 +- .../Northrend/Ulduar/Ulduar/boss_mimiron.cpp | 2 +- .../Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp | 4 +- .../scripts/Northrend/zone_borean_tundra.cpp | 14 +++---- src/server/scripts/Northrend/zone_dragonblight.cpp | 2 +- .../scripts/Northrend/zone_grizzly_hills.cpp | 4 +- .../scripts/Northrend/zone_howling_fjord.cpp | 2 +- src/server/scripts/Northrend/zone_icecrown.cpp | 6 +-- .../scripts/Northrend/zone_sholazar_basin.cpp | 2 +- src/server/scripts/Northrend/zone_storm_peaks.cpp | 2 +- src/server/scripts/Northrend/zone_wintergrasp.cpp | 4 +- src/server/scripts/Northrend/zone_zuldrak.cpp | 4 +- .../AuchenaiCrypts/boss_exarch_maladaar.cpp | 2 +- .../boss_shirrak_the_dead_watcher.cpp | 2 +- .../Outland/BlackTemple/boss_shade_of_akama.cpp | 10 ++--- .../Outland/BlackTemple/instance_black_temple.cpp | 4 +- .../SerpentShrine/boss_fathomlord_karathress.cpp | 2 +- .../SerpentShrine/boss_lady_vashj.cpp | 6 +-- .../SerpentShrine/boss_morogrim_tidewalker.cpp | 2 +- .../HellfireRamparts/boss_vazruden_the_herald.cpp | 2 +- .../ShatteredHalls/boss_nethekurse.cpp | 2 +- .../scripts/Outland/TempestKeep/Eye/boss_alar.cpp | 2 +- .../Outland/TempestKeep/Eye/boss_kaelthas.cpp | 2 +- .../Outland/TempestKeep/arcatraz/arcatraz.cpp | 2 +- .../scripts/Outland/zone_hellfire_peninsula.cpp | 10 ++--- src/server/scripts/Outland/zone_nagrand.cpp | 4 +- src/server/scripts/Outland/zone_netherstorm.cpp | 4 +- .../scripts/Outland/zone_shadowmoon_valley.cpp | 8 ++-- src/server/scripts/Outland/zone_shattrath_city.cpp | 4 +- .../scripts/Outland/zone_terokkar_forest.cpp | 18 ++++----- src/server/scripts/Outland/zone_zangarmarsh.cpp | 8 ++-- src/server/scripts/Spells/spell_generic.cpp | 2 +- src/server/scripts/World/go_scripts.cpp | 2 +- src/server/scripts/World/npcs_special.cpp | 6 +-- 120 files changed, 327 insertions(+), 327 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 20a1c895dae..46e4159bb4c 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -176,7 +176,7 @@ void npc_escortAI::JustRespawned() //add a small delay before going to first waypoint, normal in near all cases m_uiWPWaitTimer = 2500; - if (me->getFaction() != me->GetCreatureTemplate()->faction) + if (me->GetFaction() != me->GetCreatureTemplate()->faction) me->RestoreFaction(); Reset(); diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index 961700d43b1..6c38e34df97 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -166,8 +166,8 @@ void FollowerAI::JustRespawned() if (!IsCombatMovementAllowed()) SetCombatMovement(true); - if (me->getFaction() != me->GetCreatureTemplate()->faction) - me->setFaction(me->GetCreatureTemplate()->faction); + if (me->GetFaction() != me->GetCreatureTemplate()->faction) + me->SetFaction(me->GetCreatureTemplate()->faction); Reset(); } @@ -303,7 +303,7 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, const Qu m_uiLeaderGUID = player->GetGUID(); if (factionForFollower) - me->setFaction(factionForFollower); + me->SetFaction(factionForFollower); m_pQuestForFollow = quest; diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index a215153b550..2621a91d8ee 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -580,7 +580,7 @@ void SmartAI::JustRespawned() mDespawnState = 0; mEscortState = SMART_ESCORT_NONE; me->SetVisible(true); - if (me->getFaction() != me->GetCreatureTemplate()->faction) + if (me->GetFaction() != me->GetCreatureTemplate()->faction) me->RestoreFaction(); mJustReset = true; JustReachedHome(); diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 6224533846e..8b34e84cddb 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -365,7 +365,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (e.action.faction.factionID) { - (*itr)->ToCreature()->setFaction(e.action.faction.factionID); + (*itr)->ToCreature()->SetFaction(e.action.faction.factionID); TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry %u, %s set faction to %u", (*itr)->GetEntry(), (*itr)->GetGUID().ToString().c_str(), e.action.faction.factionID); } @@ -373,9 +373,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate((*itr)->ToCreature()->GetEntry())) { - if ((*itr)->ToCreature()->getFaction() != ci->faction) + if ((*itr)->ToCreature()->GetFaction() != ci->faction) { - (*itr)->ToCreature()->setFaction(ci->faction); + (*itr)->ToCreature()->SetFaction(ci->faction); TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry %u, %s set faction to %u", (*itr)->GetEntry(), (*itr)->GetGUID().ToString().c_str(), ci->faction); } diff --git a/src/server/game/Battlefield/Zones/BattlefieldTB.cpp b/src/server/game/Battlefield/Zones/BattlefieldTB.cpp index f2130d973db..1d610373c94 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldTB.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldTB.cpp @@ -609,7 +609,7 @@ void BattlefieldTB::OnCreatureCreate(Creature* creature) HideNpc(creature); break; case NPC_ABANDONED_SIEGE_ENGINE: - creature->setFaction(TBFactions[GetDefenderTeam()]); + creature->SetFaction(TBFactions[GetDefenderTeam()]); creature->CastSpell(creature, SPELL_THICK_LAYER_OF_RUST, true); break; case NPC_SIEGE_ENGINE_TURRET: diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 3589d7dd08c..6e1bba5f1a9 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -580,7 +580,7 @@ void BattlefieldWG::OnBattleStart() if (Creature* creature = GetCreature(*itr)) { ShowNpc(creature, true); - creature->setFaction(WintergraspFaction[GetDefenderTeam()]); + creature->SetFaction(WintergraspFaction[GetDefenderTeam()]); } } @@ -664,7 +664,7 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer) if (Creature* creature = GetCreature(*itr)) { if (!endByTimer) - creature->setFaction(WintergraspFaction[GetDefenderTeam()]); + creature->SetFaction(WintergraspFaction[GetDefenderTeam()]); HideNpc(creature); } } @@ -891,9 +891,9 @@ void BattlefieldWG::OnCreatureRemove(Creature* /*creature*/) case NPC_WINTERGRASP_DEMOLISHER: { uint8 team; - if (creature->getFaction() == WintergraspFaction[TEAM_ALLIANCE]) + if (creature->GetFaction() == WintergraspFaction[TEAM_ALLIANCE]) team = TEAM_ALLIANCE; - else if (creature->getFaction() == WintergraspFaction[TEAM_HORDE]) + else if (creature->GetFaction() == WintergraspFaction[TEAM_HORDE]) team = TEAM_HORDE; else return; @@ -1604,12 +1604,12 @@ void BfWGGameObjectBuilding::Init(GameObject* go) case GO_WINTERGRASP_FORTRESS_TOWER_2: case GO_WINTERGRASP_FORTRESS_TOWER_3: case GO_WINTERGRASP_FORTRESS_TOWER_4: - turret->setFaction(WintergraspFaction[_wg->GetDefenderTeam()]); + turret->SetFaction(WintergraspFaction[_wg->GetDefenderTeam()]); break; case GO_WINTERGRASP_SHADOWSIGHT_TOWER: case GO_WINTERGRASP_WINTER_S_EDGE_TOWER: case GO_WINTERGRASP_FLAMEWATCH_TOWER: - turret->setFaction(WintergraspFaction[_wg->GetAttackerTeam()]); + turret->SetFaction(WintergraspFaction[_wg->GetAttackerTeam()]); break; } @@ -1629,12 +1629,12 @@ void BfWGGameObjectBuilding::Init(GameObject* go) case GO_WINTERGRASP_FORTRESS_TOWER_2: case GO_WINTERGRASP_FORTRESS_TOWER_3: case GO_WINTERGRASP_FORTRESS_TOWER_4: - turret->setFaction(WintergraspFaction[_wg->GetDefenderTeam()]); + turret->SetFaction(WintergraspFaction[_wg->GetDefenderTeam()]); break; case GO_WINTERGRASP_SHADOWSIGHT_TOWER: case GO_WINTERGRASP_WINTER_S_EDGE_TOWER: case GO_WINTERGRASP_FLAMEWATCH_TOWER: - turret->setFaction(WintergraspFaction[_wg->GetAttackerTeam()]); + turret->SetFaction(WintergraspFaction[_wg->GetAttackerTeam()]); break; } _wg->HideNpc(turret); @@ -1689,14 +1689,14 @@ void BfWGGameObjectBuilding::UpdateTurretAttack(bool disable) case GO_WINTERGRASP_FORTRESS_TOWER_3: case GO_WINTERGRASP_FORTRESS_TOWER_4: { - creature->setFaction(WintergraspFaction[_wg->GetDefenderTeam()]); + creature->SetFaction(WintergraspFaction[_wg->GetDefenderTeam()]); break; } case GO_WINTERGRASP_SHADOWSIGHT_TOWER: case GO_WINTERGRASP_WINTER_S_EDGE_TOWER: case GO_WINTERGRASP_FLAMEWATCH_TOWER: { - creature->setFaction(WintergraspFaction[_wg->GetAttackerTeam()]); + creature->SetFaction(WintergraspFaction[_wg->GetAttackerTeam()]); break; } } @@ -1719,14 +1719,14 @@ void BfWGGameObjectBuilding::UpdateTurretAttack(bool disable) case GO_WINTERGRASP_FORTRESS_TOWER_3: case GO_WINTERGRASP_FORTRESS_TOWER_4: { - creature->setFaction(WintergraspFaction[_wg->GetDefenderTeam()]); + creature->SetFaction(WintergraspFaction[_wg->GetDefenderTeam()]); break; } case GO_WINTERGRASP_SHADOWSIGHT_TOWER: case GO_WINTERGRASP_WINTER_S_EDGE_TOWER: case GO_WINTERGRASP_FLAMEWATCH_TOWER: { - creature->setFaction(WintergraspFaction[_wg->GetAttackerTeam()]); + creature->SetFaction(WintergraspFaction[_wg->GetAttackerTeam()]); break; } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index 6e89bc86b3f..ebe3f5462b6 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -384,7 +384,7 @@ void BattlegroundAB::_NodeOccupied(uint8 node, Team team) //aura should only apply to players who have accupied the node, set correct faction for trigger if (trigger) { - trigger->setFaction(team == ALLIANCE ? 84 : 83); + trigger->SetFaction(team == ALLIANCE ? 84 : 83); trigger->CastSpell(trigger, SPELL_HONORABLE_DEFENDER_25Y, false); } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index fd31810e4b8..1dabe1a572d 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -342,7 +342,7 @@ Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type) { if (Creature* trigger = AddCreature(WORLD_TRIGGER, triggerSpawnID, BG_AV_CreaturePos[triggerSpawnID])) { - trigger->setFaction(newFaction); + trigger->SetFaction(newFaction); trigger->CastSpell(trigger, SPELL_HONORABLE_DEFENDER_25Y, false); } } @@ -756,7 +756,7 @@ void BattlegroundAV::PopulateNode(BG_AV_Nodes node) DelCreature(node + 302); return; } - trigger->setFaction(owner == ALLIANCE ? 84 : 83); + trigger->SetFaction(owner == ALLIANCE ? 84 : 83); trigger->CastSpell(trigger, SPELL_HONORABLE_DEFENDER_25Y, false); } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index ec3e7488400..9cf74c56dd9 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -782,7 +782,7 @@ void BattlegroundEY::EventTeamCapturedPoint(Player* player, uint32 Point) //aura should only apply to players who have accupied the node, set correct faction for trigger if (trigger) { - trigger->setFaction(Team == ALLIANCE ? 84 : 83); + trigger->SetFaction(Team == ALLIANCE ? 84 : 83); trigger->CastSpell(trigger, SPELL_HONORABLE_DEFENDER_25Y, false); } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index e93fc640d31..b8c28b586f8 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -363,9 +363,9 @@ bool BattlegroundIC::SetupBattleground() // setting correct factions for Keep Cannons for (uint8 i = BG_IC_NPC_KEEP_CANNON_1; i <= BG_IC_NPC_KEEP_CANNON_12; ++i) - GetBGCreature(i)->setFaction(BG_IC_Factions[0]); + GetBGCreature(i)->SetFaction(BG_IC_Factions[0]); for (uint8 i = BG_IC_NPC_KEEP_CANNON_13; i <= BG_IC_NPC_KEEP_CANNON_24; ++i) - GetBGCreature(i)->setFaction(BG_IC_Factions[1]); + GetBGCreature(i)->SetFaction(BG_IC_Factions[1]); // correcting spawn time for keeps bombs for (uint8 i = BG_IC_GO_HUGE_SEAFORIUM_BOMBS_A_1; i < BG_IC_GO_HUGE_SEAFORIUM_BOMBS_H_4; ++i) @@ -694,7 +694,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* node, bool recapture) continue; if (AddCreature(node->faction == TEAM_ALLIANCE ? NPC_GLAIVE_THROWER_A : NPC_GLAIVE_THROWER_H, type, BG_IC_DocksVehiclesGlaives[i], node->faction, RESPAWN_ONE_DAY)) - GetBGCreature(type)->setFaction(BG_IC_Factions[(node->faction == TEAM_ALLIANCE ? 0 : 1)]); + GetBGCreature(type)->SetFaction(BG_IC_Factions[(node->faction == TEAM_ALLIANCE ? 0 : 1)]); } // spawning catapults @@ -706,7 +706,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* node, bool recapture) continue; if (AddCreature(NPC_CATAPULT, type, BG_IC_DocksVehiclesCatapults[i], node->faction, RESPAWN_ONE_DAY)) - GetBGCreature(type)->setFaction(BG_IC_Factions[(node->faction == TEAM_ALLIANCE ? 0 : 1)]); + GetBGCreature(type)->SetFaction(BG_IC_Factions[(node->faction == TEAM_ALLIANCE ? 0 : 1)]); } break; case BG_IC_GO_WORKSHOP_BANNER: @@ -738,7 +738,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* node, bool recapture) continue; if (AddCreature(NPC_DEMOLISHER, type, BG_IC_WorkshopVehicles[i], node->faction, RESPAWN_ONE_DAY)) - GetBGCreature(type)->setFaction(BG_IC_Factions[(node->faction == TEAM_ALLIANCE ? 0 : 1)]); + GetBGCreature(type)->SetFaction(BG_IC_Factions[(node->faction == TEAM_ALLIANCE ? 0 : 1)]); } // we check if the opossing siege engine is in use @@ -763,7 +763,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* node, bool recapture) if (Creature* siegeEngine = GetBGCreature(siegeType)) { siegeEngine->AddUnitFlag(UnitFlags(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_CANNOT_SWIM | UNIT_FLAG_IMMUNE_TO_PC)); - siegeEngine->setFaction(BG_IC_Factions[(node->faction == TEAM_ALLIANCE ? 0 : 1)]); + siegeEngine->SetFaction(BG_IC_Factions[(node->faction == TEAM_ALLIANCE ? 0 : 1)]); } } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index 52cb90f5e0c..0abb08afd0f 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -654,13 +654,13 @@ void BattlegroundSA::OverrideGunFaction() for (uint8 i = BG_SA_GUN_1; i <= BG_SA_GUN_10; i++) { if (Creature* gun = GetBGCreature(i)) - gun->setFaction(BG_SA_Factions[Attackers ? TEAM_ALLIANCE : TEAM_HORDE]); + gun->SetFaction(BG_SA_Factions[Attackers ? TEAM_ALLIANCE : TEAM_HORDE]); } for (uint8 i = BG_SA_DEMOLISHER_1; i <= BG_SA_DEMOLISHER_4; i++) { if (Creature* dem = GetBGCreature(i)) - dem->setFaction(BG_SA_Factions[Attackers]); + dem->SetFaction(BG_SA_Factions[Attackers]); } } @@ -831,7 +831,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source) AddCreature(BG_SA_NpcEntries[j], j, BG_SA_NpcSpawnlocs[j], (Attackers == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE), 600); if (Creature* dem = GetBGCreature(j)) - dem->setFaction(BG_SA_Factions[Attackers]); + dem->SetFaction(BG_SA_Factions[Attackers]); } UpdateWorldState(BG_SA_LEFT_GY_ALLIANCE, GraveyardStatus[i] == TEAM_ALLIANCE); @@ -856,7 +856,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source) AddCreature(BG_SA_NpcEntries[j], j, BG_SA_NpcSpawnlocs[j], Attackers == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE, 600); if (Creature* dem = GetBGCreature(j)) - dem->setFaction(BG_SA_Factions[Attackers]); + dem->SetFaction(BG_SA_Factions[Attackers]); } UpdateWorldState(BG_SA_RIGHT_GY_ALLIANCE, GraveyardStatus[i] == TEAM_ALLIANCE); diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index c844767b6ba..f9f68237d0d 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -501,7 +501,7 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/, if (!GetCreatureAddon()) SetSheath(SHEATH_STATE_MELEE); - setFaction(cInfo->faction); + SetFaction(cInfo->faction); uint64 npcFlags; uint32 unitFlags, unitFlags2, unitFlags3, dynamicFlags; @@ -555,7 +555,7 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/, { if (Player* owner = Creature::GetCharmerOrOwnerPlayerOrPlayerItself()) // this check comes in case we don't have a player { - setFaction(owner->getFaction()); // vehicles should have same as owner faction + SetFaction(owner->GetFaction()); // vehicles should have same as owner faction owner->VehicleSpellInitialize(); } } @@ -2342,7 +2342,7 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction / // only from same creature faction if (checkfaction) { - if (getFaction() != u->getFaction()) + if (GetFaction() != u->GetFaction()) return false; } else diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index 63578dfd872..18613f0fda2 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -187,7 +187,7 @@ void TempSummon::InitStats(uint32 duration) if (owner && IsTrigger() && m_spells[0]) { - setFaction(owner->getFaction()); + SetFaction(owner->GetFaction()); SetLevel(owner->getLevel()); if (owner->GetTypeId() == TYPEID_PLAYER) m_ControlledByPlayer = true; @@ -212,9 +212,9 @@ void TempSummon::InitStats(uint32 duration) } if (m_Properties->Faction) - setFaction(m_Properties->Faction); + SetFaction(m_Properties->Faction); else if (IsVehicle() && owner) // properties should be vehicle - setFaction(owner->getFaction()); + SetFaction(owner->GetFaction()); } void TempSummon::InitSummon() @@ -307,7 +307,7 @@ void Minion::InitStats(uint32 duration) SetReactState(REACT_PASSIVE); SetCreatorGUID(GetOwner()->GetGUID()); - setFaction(GetOwner()->getFaction()); + SetFaction(GetOwner()->GetFaction()); GetOwner()->SetMinion(this, true); } diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 4e34c8b4785..1bc8383a51c 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -2112,7 +2112,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId, TriggerCastFlags trigge if (Unit* owner = GetOwner()) { - trigger->setFaction(owner->getFaction()); + trigger->SetFaction(owner->GetFaction()); if (owner->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE)) trigger->AddUnitFlag(UNIT_FLAG_PVP_ATTACKABLE); // copy pvp state flags from owner @@ -2123,7 +2123,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId, TriggerCastFlags trigge } else { - trigger->setFaction(spellInfo->IsPositive() ? 35 : 14); + trigger->SetFaction(spellInfo->IsPositive() ? 35 : 14); // Set owner guid for target if no owner available - needed by trigger auras // - trigger gets despawned and there's no caster avalible (see AuraEffect::TriggerSpell()) trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, target ? target->GetGUID() : ObjectGuid::Empty); diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 94fd3e932c8..5e79eb1316c 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1889,7 +1889,7 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3 //summon->SetName(GetName()); if (GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT) { - summon->setFaction(((Unit*)this)->getFaction()); + summon->SetFaction(((Unit*)this)->GetFaction()); summon->SetLevel(((Unit*)this)->getLevel()); } diff --git a/src/server/game/Entities/Object/Updates/ViewerDependentValues.h b/src/server/game/Entities/Object/Updates/ViewerDependentValues.h index 52813dd4c82..1901e5e623d 100644 --- a/src/server/game/Entities/Object/Updates/ViewerDependentValues.h +++ b/src/server/game/Entities/Object/Updates/ViewerDependentValues.h @@ -147,7 +147,7 @@ public: FactionTemplateEntry const* ft2 = receiver->GetFactionTemplateEntry(); if (ft1 && ft2 && !ft1->IsFriendlyTo(ft2)) // pretend that all other HOSTILE players have own faction, to allow follow, heal, rezz (trade wont work) - factionTemplate = receiver->getFaction(); + factionTemplate = receiver->GetFaction(); } return factionTemplate; diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 9c16502dd25..56f2d4447df 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -186,7 +186,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c PhasingHandler::InheritPhaseShift(this, owner); setPetType(petType); - setFaction(owner->getFaction()); + SetFaction(owner->GetFaction()); SetCreatedBySpell(summonSpellId); if (IsCritter()) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 1895aace00f..87f03539599 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -2200,13 +2200,13 @@ void Player::SetGameMaster(bool on) if (on) { m_ExtraFlags |= PLAYER_EXTRA_GM_ON; - setFaction(35); + SetFaction(35); AddPlayerFlag(PLAYER_FLAGS_GM); AddUnitFlag2(UNIT_FLAG2_ALLOW_CHEAT_SPELLS); if (Pet* pet = GetPet()) { - pet->setFaction(35); + pet->SetFaction(35); pet->getHostileRefManager().setOnlineOfflineState(false); } @@ -2230,7 +2230,7 @@ void Player::SetGameMaster(bool on) if (Pet* pet = GetPet()) { - pet->setFaction(getFaction()); + pet->SetFaction(GetFaction()); pet->getHostileRefManager().setOnlineOfflineState(true); } @@ -6298,7 +6298,7 @@ void Player::setFactionForRace(uint8 race) m_team = TeamForRace(race); ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race); - setFaction(rEntry ? rEntry->FactionID : 0); + SetFaction(rEntry ? rEntry->FactionID : 0); } ReputationRank Player::GetReputationRank(uint32 faction) const @@ -22618,7 +22618,7 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc float discount = GetReputationPriceDiscount(npc); totalcost = uint32(ceil(totalcost * discount)); firstcost = uint32(ceil(firstcost * discount)); - m_taxi.SetFlightMasterFactionTemplateId(npc->getFaction()); + m_taxi.SetFlightMasterFactionTemplateId(npc->GetFaction()); } else m_taxi.SetFlightMasterFactionTemplateId(0); @@ -28213,7 +28213,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy PhasingHandler::InheritPhaseShift(pet, this); pet->SetCreatorGUID(GetGUID()); - pet->setFaction(getFaction()); + pet->SetFaction(GetFaction()); pet->SetNpcFlags(UNIT_NPC_FLAG_NONE); pet->SetNpcFlags2(UNIT_NPC_FLAG_2_NONE); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index df7273a5b2d..84e6cb9ea16 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -5429,15 +5429,15 @@ void Unit::UpdateDisplayPower() FactionTemplateEntry const* Unit::GetFactionTemplateEntry() const { - FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(getFaction()); + FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(GetFaction()); if (!entry) { if (Player const* player = ToPlayer()) - TC_LOG_ERROR("entities.unit", "Player %s has invalid faction (faction template id) #%u", player->GetName().c_str(), getFaction()); + TC_LOG_ERROR("entities.unit", "Player %s has invalid faction (faction template id) #%u", player->GetName().c_str(), GetFaction()); else if (Creature const* creature = ToCreature()) - TC_LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, getFaction()); + TC_LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, GetFaction()); else - TC_LOG_ERROR("entities.unit", "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName().c_str(), uint32(GetTypeId()), getFaction()); + TC_LOG_ERROR("entities.unit", "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName().c_str(), uint32(GetTypeId()), GetFaction()); ABORT(); } @@ -11225,7 +11225,7 @@ Pet* Unit::CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id) bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id) { pet->SetCreatorGUID(GetGUID()); - pet->setFaction(getFaction()); + pet->SetFaction(GetFaction()); pet->SetCreatedBySpell(spell_id); if (GetTypeId() == TYPEID_PLAYER) @@ -11881,8 +11881,8 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au if (aurApp && aurApp->GetRemoveMode()) return false; - _oldFactionId = getFaction(); - setFaction(charmer->getFaction()); + _oldFactionId = GetFaction(); + SetFaction(charmer->GetFaction()); // Set charmed charmer->SetCharm(this, true); @@ -11998,7 +11998,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) if (_oldFactionId) { - setFaction(_oldFactionId); + SetFaction(_oldFactionId); _oldFactionId = 0; } else @@ -12090,13 +12090,13 @@ void Unit::RestoreFaction() { if (Unit* owner = GetOwner()) { - setFaction(owner->getFaction()); + SetFaction(owner->GetFaction()); return; } } if (CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate()) // normal creature - setFaction(cinfo->faction); + SetFaction(cinfo->faction); } } @@ -12191,7 +12191,7 @@ bool Unit::IsInPartyWith(Unit const* unit) const (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)) return true; - return u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && u1->getFaction() == u2->getFaction(); + return u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && u1->GetFaction() == u2->GetFaction(); } bool Unit::IsInRaidWith(Unit const* unit) const @@ -12210,7 +12210,7 @@ bool Unit::IsInRaidWith(Unit const* unit) const (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)) return true; - return u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && u1->getFaction() == u2->getFaction(); + return u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && u1->GetFaction() == u2->GetFaction(); } void Unit::GetPartyMembers(std::list &TagUnitMap) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 7f126fa2c3e..1df51077ae4 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1119,8 +1119,8 @@ class TC_GAME_API Unit : public WorldObject void SetSheath(SheathState sheathed) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::SheatheState), sheathed); } // faction template id - uint32 getFaction() const { return m_unitData->FactionTemplate; } - void setFaction(uint32 faction) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::FactionTemplate), faction); } + uint32 GetFaction() const { return m_unitData->FactionTemplate; } + void SetFaction(uint32 faction) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::FactionTemplate), faction); } FactionTemplateEntry const* GetFactionTemplateEntry() const; ReputationRank GetReactionTo(Unit const* target) const; diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index e4ccc62f5dc..95454d49f90 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -52,7 +52,7 @@ void WorldSession::HandleAuctionBrowseQuery(WorldPackets::AuctionHouse::AuctionB if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); TC_LOG_DEBUG("auctionHouse", "Auctionhouse search (%s), searchedname: %s, levelmin: %u, levelmax: %u, filters: %u", browseQuery.Auctioneer.ToString().c_str(), browseQuery.Name.c_str(), browseQuery.MinLevel, browseQuery.MaxLevel, AsUnderlyingType(browseQuery.Filters)); @@ -115,7 +115,7 @@ void WorldSession::HandleAuctionCancelCommoditiesPurchase(WorldPackets::AuctionH if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); auctionHouse->CancelCommodityQuote(_player->GetGUID()); } @@ -136,7 +136,7 @@ void WorldSession::HandleAuctionConfirmCommoditiesPurchase(WorldPackets::Auction if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); if (auctionHouse->BuyCommodity(trans, _player, confirmCommoditiesPurchase.ItemID, confirmCommoditiesPurchase.Quantity, throttle.DelayUntilNext)) @@ -190,7 +190,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPackets::AuctionHouse::Auct if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); WorldPackets::AuctionHouse::AuctionListBidderItemsResult result; @@ -218,7 +218,7 @@ void WorldSession::HandleAuctionListBucketsByBucketKeys(WorldPackets::AuctionHou if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); WorldPackets::AuctionHouse::AuctionListBucketsResult listBucketsResult; @@ -248,7 +248,7 @@ void WorldSession::HandleAuctionListItemsByBucketKey(WorldPackets::AuctionHouse: if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); WorldPackets::AuctionHouse::AuctionListItemsResult listItemsResult; listItemsResult.DesiredDelay = uint32(throttle.DelayUntilNext.count()); @@ -279,7 +279,7 @@ void WorldSession::HandleAuctionListItemsByItemID(WorldPackets::AuctionHouse::Au if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); WorldPackets::AuctionHouse::AuctionListItemsResult listItemsResult; listItemsResult.DesiredDelay = uint32(throttle.DelayUntilNext.count()); @@ -311,7 +311,7 @@ void WorldSession::HandleAuctionListOwnerItems(WorldPackets::AuctionHouse::Aucti if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); WorldPackets::AuctionHouse::AuctionListOwnerItemsResult result; @@ -345,7 +345,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPackets::AuctionHouse::AuctionPlac if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); AuctionPosting* auction = auctionHouse->GetAuction(placeBid.AuctionID); if (!auction || auction->IsCommodity()) @@ -467,7 +467,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPackets::AuctionHouse::AuctionRe if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); AuctionPosting* auction = auctionHouse->GetAuction(removeItem.AuctionID); Player* player = GetPlayer(); @@ -529,7 +529,7 @@ void WorldSession::HandleAuctionReplicateItems(WorldPackets::AuctionHouse::Aucti if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); WorldPackets::AuctionHouse::AuctionReplicateResponse response; @@ -569,7 +569,7 @@ void WorldSession::HandleAuctionSellCommodity(WorldPackets::AuctionHouse::Auctio } uint32 houseId = 0; - AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(creature->getFaction(), &houseId); + AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(creature->GetFaction(), &houseId); if (!auctionHouseEntry) { TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (%s) has wrong faction.", sellCommodity.Auctioneer.ToString().c_str()); @@ -645,7 +645,7 @@ void WorldSession::HandleAuctionSellCommodity(WorldPackets::AuctionHouse::Auctio } Seconds auctionTime = Seconds(int64(std::chrono::duration_cast(Minutes(sellCommodity.RunTime)).count() * double(sWorld->getRate(RATE_AUCTION_TIME)))); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); uint64 deposit = AuctionHouseMgr::GetCommodityAuctionDeposit(items2.begin()->second.first->GetTemplate(), Minutes(sellCommodity.RunTime), totalCount); if (!_player->HasEnoughMoney(deposit)) @@ -793,7 +793,7 @@ void WorldSession::HandleAuctionSellItem(WorldPackets::AuctionHouse::AuctionSell } uint32 houseId = 0; - AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(creature->getFaction(), &houseId); + AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(creature->GetFaction(), &houseId); if (!auctionHouseEntry) { TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (%s) has wrong faction.", sellItem.Auctioneer.ToString().c_str()); @@ -837,7 +837,7 @@ void WorldSession::HandleAuctionSellItem(WorldPackets::AuctionHouse::AuctionSell } Seconds auctionTime = Seconds(int64(std::chrono::duration_cast(Minutes(sellItem.RunTime)).count() * double(sWorld->getRate(RATE_AUCTION_TIME)))); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); uint64 deposit = AuctionHouseMgr::GetItemAuctionDeposit(_player, item, Minutes(sellItem.RunTime)); if (!_player->HasEnoughMoney(deposit)) @@ -947,7 +947,7 @@ void WorldSession::HandleAuctionStartCommoditiesPurchase(WorldPackets::AuctionHo if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); + AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->GetFaction()); WorldPackets::AuctionHouse::AuctionCommodityQuote auctionCommodityQuote; @@ -972,7 +972,7 @@ void WorldSession::SendAuctionHello(ObjectGuid guid, Creature* unit) return; } - AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction(), nullptr); + AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->GetFaction(), nullptr); if (!ahEntry) return; diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index 08981180970..1cda9ba2f1c 100644 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -159,7 +159,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPackets::NPC::Hello& packet) } // set faction visible if needed - if (FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction())) + if (FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->GetFaction())) _player->GetReputationMgr().SetVisible(factionTemplateEntry); GetPlayer()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TALK); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index f43aaab35e3..80918422f53 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -4928,7 +4928,7 @@ void AuraEffect::HandleAuraModFaction(AuraApplication const* aurApp, uint8 mode, if (apply) { - target->setFaction(GetMiscValue()); + target->SetFaction(GetMiscValue()); if (target->GetTypeId() == TYPEID_PLAYER) target->RemoveUnitFlag(UNIT_FLAG_PVP_ATTACKABLE); } diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 8f77c39afe2..a533517c6f6 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -2031,7 +2031,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) if (properties->Control == SUMMON_CATEGORY_ALLY) { summon->SetOwnerGUID(m_originalCaster->GetGUID()); - summon->setFaction(m_originalCaster->getFaction()); + summon->SetFaction(m_originalCaster->GetFaction()); summon->SetCreatedBySpell(m_spellInfo->Id); } @@ -2072,9 +2072,9 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) uint32 faction = properties->Faction; if (!faction) - faction = m_originalCaster->getFaction(); + faction = m_originalCaster->GetFaction(); - summon->setFaction(faction); + summon->SetFaction(faction); break; } @@ -3604,7 +3604,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex) PhasingHandler::InheritPhaseShift(go, m_caster); - go->SetFaction(m_caster->getFaction()); + go->SetFaction(m_caster->GetFaction()); go->SetLevel(m_caster->getLevel()+1); int32 duration = m_spellInfo->CalcDuration(m_caster); go->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); @@ -4688,7 +4688,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) { case GAMEOBJECT_TYPE_FISHINGNODE: { - go->SetFaction(m_caster->getFaction()); + go->SetFaction(m_caster->GetFaction()); ObjectGuid bobberGuid = go->GetGUID(); // client requires fishing bobber guid in channel object slot 0 to be usable m_caster->SetChannelObject(0, bobberGuid); @@ -5206,7 +5206,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* ((Guardian*)summon)->InitStatsForLevel(level); if (properties && properties->Control == SUMMON_CATEGORY_ALLY) - summon->setFaction(caster->getFaction()); + summon->SetFaction(caster->GetFaction()); if (summon->HasUnitTypeMask(UNIT_MASK_MINION) && m_targets.HasDst()) ((Minion*)summon)->SetFollowAngle(m_caster->GetAngle(summon)); diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index a9d9ddf2008..83ac3e43b4f 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -218,7 +218,7 @@ public: if (!pfactionid) { - uint32 factionid = target->getFaction(); + uint32 factionid = target->GetFaction(); uint32 flag = target->m_unitData->Flags; uint64 npcflag; memcpy(&npcflag, target->m_unitData->NpcFlags.begin(), sizeof(uint64)); @@ -261,7 +261,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_FACTION, target->GetGUID().ToString().c_str(), factionid, flag, std::to_string(npcflag).c_str(), dyflag); - target->setFaction(factionid); + target->SetFaction(factionid); target->SetUnitFlags(UnitFlags(flag)); target->SetNpcFlags(NPCFlags(npcflag & 0xFFFFFFFF)); target->SetNpcFlags2(NPCFlags2(npcflag >> 32)); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 7a2e6cff30e..595af9223bc 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -606,7 +606,7 @@ public: return false; } - creature->setFaction(factionId); + creature->SetFaction(factionId); // Faction is set in creature_template - not inside creature @@ -725,7 +725,7 @@ public: CreatureTemplate const* cInfo = target->GetCreatureTemplate(); - uint32 faction = target->getFaction(); + uint32 faction = target->GetFaction(); uint64 npcflags; memcpy(&npcflags, target->m_unitData->NpcFlags.begin(), sizeof(npcflags)); uint32 mechanicImmuneMask = cInfo->MechanicImmuneMask; diff --git a/src/server/scripts/Commands/cs_pet.cpp b/src/server/scripts/Commands/cs_pet.cpp index 5a373419634..1e0cd4ab835 100644 --- a/src/server/scripts/Commands/cs_pet.cpp +++ b/src/server/scripts/Commands/cs_pet.cpp @@ -102,7 +102,7 @@ public: creatureTarget->SetHealth(0); // just for nice GM-mode view pet->SetCreatorGUID(player->GetGUID()); - pet->setFaction(player->getFaction()); + pet->SetFaction(player->GetFaction()); if (!pet->InitStatsForLevel(creatureTarget->getLevel())) { diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp index 6d87e944368..853b03245d0 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp @@ -91,7 +91,7 @@ public: void JustSummoned(Creature* summoned) override { summoned->AI()->AttackStart(SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true)); - summoned->setFaction(me->getFaction()); + summoned->SetFaction(me->GetFaction()); WaterElementalGUID = summoned->GetGUID(); summons.Summon(summoned); } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp index e9bcdeeba0f..b0c7e149bd3 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp @@ -600,7 +600,7 @@ public: //spell by trap has effect61, this indicate the bar go hostile if (Unit* tmp = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_PHALANX))) - tmp->setFaction(14); + tmp->SetFaction(14); //for later, this event(s) has alot more to it. //optionally, DONE can trigger bar to go hostile. diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp index 8eb276ed5fa..af91790fb12 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp @@ -143,7 +143,7 @@ public: { _Reset(); me->AddUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); - me->setFaction(COREN_DIREBREW_FACTION_FRIEND); + me->SetFaction(COREN_DIREBREW_FACTION_FRIEND); events.SetPhase(PHASE_ALL); for (uint8 i = 0; i < MAX_ANTAGONISTS; ++i) @@ -166,7 +166,7 @@ public: { events.SetPhase(PHASE_ONE); me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); - me->setFaction(COREN_DIREBREW_FACTION_HOSTILE); + me->SetFaction(COREN_DIREBREW_FACTION_HOSTILE); me->SetInCombatWithZone(); EntryCheckPredicate pred(NPC_ANTAGONIST); @@ -357,7 +357,7 @@ public: void Reset() override { - me->setFaction(COREN_DIREBREW_FACTION_HOSTILE); + me->SetFaction(COREN_DIREBREW_FACTION_HOSTILE); DoCastAOE(SPELL_MOLE_MACHINE_EMERGE, true); me->SetInCombatWithZone(); } @@ -399,7 +399,7 @@ public: break; case ACTION_ANTAGONIST_HOSTILE: me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); - me->setFaction(COREN_DIREBREW_FACTION_HOSTILE); + me->SetFaction(COREN_DIREBREW_FACTION_HOSTILE); me->SetInCombatWithZone(); break; default: diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp index 4ae113289f6..9015420d079 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp @@ -75,7 +75,7 @@ class boss_emperor_dagran_thaurissan : public CreatureScript if (Creature* moira = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_MOIRA))) { moira->AI()->EnterEvadeMode(); - moira->setFaction(35); + moira->SetFaction(35); } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp index 39f9869cc22..afb97ec93d1 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp @@ -134,7 +134,7 @@ class boss_doomrel : public CreatureScript case GOSSIP_ACTION_INFO_DEF+2: CloseGossipMenuFor(player); //start event here - creature->setFaction(FACTION_HOSTILE); + creature->SetFaction(FACTION_HOSTILE); creature->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); creature->AI()->AttackStart(player); InstanceScript* instance = creature->GetInstanceScript(); @@ -170,7 +170,7 @@ class boss_doomrel : public CreatureScript { Initialize(); - me->setFaction(FACTION_FRIEND); + me->SetFaction(FACTION_FRIEND); // was set before event start, so set again me->AddUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp index 589a4757ec7..219414e29a7 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp @@ -354,7 +354,7 @@ public: { if (Creature* boss = instance->GetCreature(TombBossGUIDs[TombEventCounter])) { - boss->setFaction(FACTION_HOSTILE); + boss->SetFaction(FACTION_HOSTILE); boss->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); if (Unit* target = boss->SelectNearestTarget(500)) boss->AI()->AttackStart(target); @@ -380,7 +380,7 @@ public: boss->GetMotionMaster()->MoveTargetedHome(); boss->SetLootRecipient(NULL); } - boss->setFaction(FACTION_FRIEND); + boss->SetFaction(FACTION_FRIEND); } } GhostKillCount = 0; diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp index 10b4ed5c91e..5af9bf91aaa 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp @@ -190,7 +190,7 @@ public: me->SetVisible(true); me->SetNpcFlags(UNIT_NPC_FLAG_GOSSIP); - me->setFaction(35); + me->SetFaction(35); me->SetStandState(UNIT_STAND_STATE_SIT_HIGH_CHAIR); me->RemoveAura(SPELL_NEFARIANS_BARRIER); } @@ -207,7 +207,7 @@ public: Talk(SAY_GAMESBEGIN_2); - me->setFaction(103); + me->SetFaction(103); me->SetNpcFlags(UNIT_NPC_FLAG_NONE); DoCast(me, SPELL_NEFARIANS_BARRIER); me->SetStandState(UNIT_STAND_STATE_STAND); @@ -342,7 +342,7 @@ public: CreatureID = Entry[urand(0, 4)]; if (Creature* dragon = me->SummonCreature(CreatureID, DrakeSpawnLoc[i])) { - dragon->setFaction(103); + dragon->SetFaction(103); dragon->AI()->AttackStart(me->GetVictim()); } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp index 41dbc2f2a8b..43c0d05805b 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp @@ -75,7 +75,7 @@ public: { Initialize(); creature->AddNpcFlag(UNIT_NPC_FLAG_GOSSIP); - creature->setFaction(35); + creature->SetFaction(35); creature->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); } @@ -153,7 +153,7 @@ public: events.ScheduleEvent(EVENT_SPEECH_4, 16000); break; case EVENT_SPEECH_4: - me->setFaction(103); + me->SetFaction(103); if (Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID)) AttackStart(player); break; diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp index 147396ab2a2..6d03826d7b6 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp @@ -110,7 +110,7 @@ class boss_majordomo : public CreatureScript if (!me->FindNearestCreature(NPC_FLAMEWAKER_HEALER, 100.0f) && !me->FindNearestCreature(NPC_FLAMEWAKER_ELITE, 100.0f)) { instance->UpdateEncounterStateForKilledCreature(me->GetEntry(), me); - me->setFaction(FACTION_FRIENDLY); + me->SetFaction(FACTION_FRIENDLY); EnterEvadeMode(); Talk(SAY_DEFEAT); _JustDied(); @@ -191,7 +191,7 @@ class boss_majordomo : public CreatureScript } else if (action == ACTION_START_RAGNAROS_ALT) { - me->setFaction(FACTION_FRIENDLY); + me->SetFaction(FACTION_FRIENDLY); me->AddNpcFlag(UNIT_NPC_FLAG_GOSSIP); } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp index 361d84c137d..4e245db8aad 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp @@ -175,7 +175,7 @@ class boss_ragnaros : public CreatureScript { //Become unbanished again me->SetReactState(REACT_AGGRESSIVE); - me->setFaction(14); + me->SetFaction(14); me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetEmoteState(EMOTE_ONESHOT_NONE); me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); @@ -253,7 +253,7 @@ class boss_ragnaros : public CreatureScript me->InterruptNonMeleeSpells(false); //Root self //DoCast(me, 23973); - me->setFaction(35); + me->SetFaction(35); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetEmoteState(EMOTE_STATE_SUBMERGED); me->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE); diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp index d3667627db7..a7998726e1e 100644 --- a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp +++ b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp @@ -130,7 +130,7 @@ public: { Start(true, false, player->GetGUID()); - me->setFaction(player->getFaction()); + me->SetFaction(player->GetFaction()); SetData(1, 0); player->PlayerTalkClass->SendCloseGossip(); @@ -225,8 +225,8 @@ public: { //just in case if (GetPlayerForEscort()) - if (me->getFaction() != GetPlayerForEscort()->getFaction()) - me->setFaction(GetPlayerForEscort()->getFaction()); + if (me->GetFaction() != GetPlayerForEscort()->GetFaction()) + me->SetFaction(GetPlayerForEscort()->GetFaction()); switch (waypointId) { diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index 911912168e6..1c4f1c112eb 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -374,7 +374,7 @@ public: if (infernal) { infernal->SetDisplayId(INFERNAL_MODEL_INVISIBLE); - infernal->setFaction(me->getFaction()); + infernal->SetFaction(me->GetFaction()); if (point) ENSURE_AI(netherspite_infernal::netherspite_infernalAI, infernal->AI())->point = point; ENSURE_AI(netherspite_infernal::netherspite_infernalAI, infernal->AI())->malchezaar = me->GetGUID(); @@ -449,7 +449,7 @@ public: if (axe) { axe->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - axe->setFaction(me->getFaction()); + axe->SetFaction(me->GetFaction()); axes[i] = axe->GetGUID(); if (target) { diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index 990788b7c9d..8172ec257d0 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -428,7 +428,7 @@ public: if (Creature* pSpawn = me->SummonCreature(CREATURE_ARAN_BLIZZARD, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 25000)) { - pSpawn->setFaction(me->getFaction()); + pSpawn->SetFaction(me->GetFaction()); pSpawn->CastSpell(pSpawn, SPELL_CIRCULAR_BLIZZARD, false); } break; @@ -446,7 +446,7 @@ public: if (Creature* unit = me->SummonCreature(CREATURE_WATER_ELEMENTAL, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 90000)) { unit->Attack(me->GetVictim(), true); - unit->setFaction(me->getFaction()); + unit->SetFaction(me->GetFaction()); } } @@ -460,7 +460,7 @@ public: if (Creature* unit = me->SummonCreature(CREATURE_SHADOW_OF_ARAN, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000)) { unit->Attack(me->GetVictim(), true); - unit->setFaction(me->getFaction()); + unit->SetFaction(me->GetFaction()); } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index fafc756dc07..bfc74a71127 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -1382,7 +1382,7 @@ void boss_julianne::boss_julianneAI::UpdateAI(uint32 diff) { Talk(SAY_JULIANNE_AGGRO); me->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE); - me->setFaction(16); + me->SetFaction(16); AggroYellTimer = 0; } else AggroYellTimer -= diff; } @@ -1410,7 +1410,7 @@ void boss_julianne::boss_julianneAI::UpdateAI(uint32 diff) ENSURE_AI(boss_romulo::boss_romuloAI, pRomulo->AI())->Phase = PHASE_ROMULO; DoZoneInCombat(pRomulo); - pRomulo->setFaction(16); + pRomulo->SetFaction(16); } SummonedRomulo = true; } else SummonRomuloTimer -= diff; diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp index 7d31ee88873..9fa6e43ae5d 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp @@ -454,7 +454,7 @@ public: Initialize(); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - me->setFaction(14); + me->SetFaction(14); DoCast(me, SPELL_FLAMESTRIKE2, true); } @@ -659,7 +659,7 @@ public: me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetDisableGravity(true); - me->setFaction(14); + me->SetFaction(14); DoCast(me, SPELL_ARCANE_SPHERE_PASSIVE, true); } diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index 257bc278235..89d8c159194 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -128,7 +128,7 @@ public: { Initialize(); events.Reset(); - me->setFaction(7); + me->SetFaction(7); me->AddUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->LoadEquipment(0, true); @@ -234,7 +234,7 @@ public: wait_timer -= diff; else { - me->setFaction(14); + me->SetFaction(14); me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); phase = PHASE_ATTACKING; @@ -594,7 +594,7 @@ public: { if (m_uiDuelTimer <= uiDiff) { - me->setFaction(FACTION_HOSTILE); + me->SetFaction(FACTION_HOSTILE); if (Unit* unit = ObjectAccessor::GetUnit(*me, m_uiDuelerGUID)) AttackStart(unit); @@ -780,7 +780,7 @@ public: { charmer->RemoveAurasDueToSpell(SPELL_EFFECT_STOLEN_HORSE); caster->RemoveNpcFlag(UNIT_NPC_FLAG_SPELLCLICK); - caster->setFaction(35); + caster->SetFaction(35); DoCast(caster, SPELL_CALL_DARK_RIDER, true); if (Creature* Dark_Rider = me->FindNearestCreature(NPC_DARK_RIDER_OF_ACHERUS, 15)) ENSURE_AI(npc_dark_rider_of_acherus::npc_dark_rider_of_acherusAI, Dark_Rider->AI())->InitDespawnHorse(caster); @@ -872,7 +872,7 @@ public: { deathcharger->AddNpcFlag(UNIT_NPC_FLAG_SPELLCLICK); deathcharger->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - deathcharger->setFaction(2096); + deathcharger->SetFaction(2096); } } }; diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp index 30457fb0de8..2733669aa9d 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp @@ -87,7 +87,7 @@ public: playerGUID = player->GetGUID(); speechTimer = 1000; speechCounter = 1; - me->setFaction(player->getFaction()); + me->SetFaction(player->GetFaction()); me->CombatStop(true); me->GetMotionMaster()->MoveIdle(); me->SetReactState(REACT_PASSIVE); diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp index 3cc188d9bc0..97c0296df30 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp @@ -653,7 +653,7 @@ public: { Unit* temp = me->SummonCreature(NPC_ACHERUS_GHOUL, (me->GetPositionX() - 20) + rand32() % 40, (me->GetPositionY() - 20) + rand32() % 40, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); temp->SetWalk(false); - temp->setFaction(2084); + temp->SetFaction(2084); uiGhoulGUID[uiSummon_counter] = temp->GetGUID(); ++uiSummon_counter; } @@ -671,7 +671,7 @@ public: { Unit* temp = me->SummonCreature(NPC_RAMPAGING_ABOMINATION, (me->GetPositionX() - 20) + rand32() % 40, (me->GetPositionY() - 20) + rand32() % 40, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); temp->SetWalk(false); - temp->setFaction(2084); + temp->SetFaction(2084); uiAbominationGUID[uiSummon_counter] = temp->GetGUID(); ++uiSummon_counter; } @@ -689,7 +689,7 @@ public: { Unit* temp = me->SummonCreature(NPC_WARRIOR_OF_THE_FROZEN_WASTES, (me->GetPositionX() - 20) + rand32() % 40, (me->GetPositionY() - 20) + rand32() % 40, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); temp->SetWalk(false); - temp->setFaction(2084); + temp->SetFaction(2084); uiWarriorGUID[uiSummon_counter] = temp->GetGUID(); ++uiSummon_counter; } @@ -707,7 +707,7 @@ public: { Unit* temp = me->SummonCreature(NPC_FLESH_BEHEMOTH, (me->GetPositionX() - 20) + rand32() % 40, (me->GetPositionY() - 20) + rand32() % 40, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); temp->SetWalk(false); - temp->setFaction(2084); + temp->SetFaction(2084); uiBehemothGUID[uiSummon_counter] = temp->GetGUID(); ++uiSummon_counter; } @@ -1002,7 +1002,7 @@ public: temp->SetEmoteState(EMOTE_STATE_ATTACK_UNARMED); temp->SetWalk(false); temp->SetSpeedRate(MOVE_RUN, 2.0f); - temp->setFaction(me->getFaction()); + temp->SetFaction(me->GetFaction()); temp->GetMotionMaster()->MovePoint(0, fLichPositionX, fLichPositionY, fLichPositionZ); uiDefenderGUID[0] = temp->GetGUID(); @@ -1010,7 +1010,7 @@ public: temp->SetEmoteState(EMOTE_STATE_ATTACK_UNARMED); temp->SetWalk(false); temp->SetSpeedRate(MOVE_RUN, 2.0f); - temp->setFaction(me->getFaction()); + temp->SetFaction(me->GetFaction()); temp->GetMotionMaster()->MovePoint(0, fLichPositionX, fLichPositionY, fLichPositionZ); uiEarthshatterGUID[0] = temp->GetGUID(); } @@ -1402,7 +1402,7 @@ public: if (!uiTirionGUID) if (Creature* temp = me->SummonCreature(NPC_HIGHLORD_TIRION_FORDRING, LightofDawnLoc[0].GetPositionWithOffset({ 0.0f, 0.0f, 0.0f, 1.528f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000)) { - temp->setFaction(me->getFaction()); + temp->SetFaction(me->GetFaction()); temp->SetVirtualItem(0, uint32(EQUIP_UNEQUIP)); temp->AI()->Talk(SAY_LIGHT_OF_DAWN25); uiTirionGUID = temp->GetGUID(); @@ -1440,7 +1440,7 @@ public: temp->DeleteThreatList(); temp->CombatStop(true); temp->AttackStop(); - temp->setFaction(me->getFaction()); + temp->SetFaction(me->GetFaction()); temp->SetWalk(false); temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[9]); } @@ -1451,7 +1451,7 @@ public: temp->DeleteThreatList(); temp->CombatStop(true); temp->AttackStop(); - temp->setFaction(me->getFaction()); + temp->SetFaction(me->GetFaction()); temp->SetWalk(false); temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[12]); } @@ -1462,7 +1462,7 @@ public: temp->DeleteThreatList(); temp->CombatStop(true); temp->AttackStop(); - temp->setFaction(me->getFaction()); + temp->SetFaction(me->GetFaction()); temp->SetWalk(false); temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[15]); } @@ -1474,7 +1474,7 @@ public: temp->DeleteThreatList(); temp->CombatStop(true); temp->AttackStop(); - temp->setFaction(me->getFaction()); + temp->SetFaction(me->GetFaction()); temp->SetWalk(false); temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[18]); temp->CastSpell(temp, SPELL_THE_LIGHT_OF_DAWN, false); @@ -1489,7 +1489,7 @@ public: temp->DeleteThreatList(); temp->CombatStop(true); temp->AttackStop(); - temp->setFaction(me->getFaction()); + temp->SetFaction(me->GetFaction()); temp->SetWalk(false); temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[20]); temp->CastSpell(temp, SPELL_THE_LIGHT_OF_DAWN, false); @@ -1539,7 +1539,7 @@ public: if (!temp) { temp = me->SummonCreature(NPC_ACHERUS_GHOUL, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); - temp->setFaction(2084); + temp->SetFaction(2084); uiGhoulGUID[i] = temp->GetGUID(); } } @@ -1549,7 +1549,7 @@ public: if (!temp) { temp = me->SummonCreature(NPC_WARRIOR_OF_THE_FROZEN_WASTES, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); - temp->setFaction(2084); + temp->SetFaction(2084); uiAbominationGUID[i] = temp->GetGUID(); } } @@ -1559,7 +1559,7 @@ public: if (!temp) { temp = me->SummonCreature(NPC_RAMPAGING_ABOMINATION, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); - temp->setFaction(2084); + temp->SetFaction(2084); uiWarriorGUID[i] = temp->GetGUID(); } } @@ -1569,7 +1569,7 @@ public: if (!temp) { temp = me->SummonCreature(NPC_FLESH_BEHEMOTH, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); - temp->setFaction(2084); + temp->SetFaction(2084); uiBehemothGUID[i] = temp->GetGUID(); } } @@ -1581,7 +1581,7 @@ public: if (!temp) { temp = me->SummonCreature(NPC_DEFENDER_OF_THE_LIGHT, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); - temp->setFaction(2089); + temp->SetFaction(2089); me->AddThreat(temp, 0.0f); uiDefenderGUID[i] = temp->GetGUID(); } @@ -1592,7 +1592,7 @@ public: if (!temp) { temp = me->SummonCreature(NPC_RIMBLAT_EARTHSHATTER, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); - temp->setFaction(2089); + temp->SetFaction(2089); me->AddThreat(temp, 0.0f); uiEarthshatterGUID[i] = temp->GetGUID(); } @@ -1601,7 +1601,7 @@ public: if (!temp) { temp = me->SummonCreature(NPC_KORFAX_CHAMPION_OF_THE_LIGHT, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); - temp->setFaction(2089); + temp->SetFaction(2089); me->AddThreat(temp, 0.0f); uiKorfaxGUID = temp->GetGUID(); } @@ -1609,7 +1609,7 @@ public: if (!temp) { temp = me->SummonCreature(NPC_LORD_MAXWELL_TYROSUS, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); - temp->setFaction(2089); + temp->SetFaction(2089); me->AddThreat(temp, 0.0f); uiMaxwellGUID = temp->GetGUID(); } @@ -1617,7 +1617,7 @@ public: if (!temp) { temp = me->SummonCreature(NPC_COMMANDER_ELIGOR_DAWNBRINGER, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); - temp->setFaction(2089); + temp->SetFaction(2089); me->AddThreat(temp, 0.0f); uiEligorGUID = temp->GetGUID(); } @@ -1625,7 +1625,7 @@ public: if (!temp) { temp = me->SummonCreature(NPC_RAYNE, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); - temp->setFaction(2089); + temp->SetFaction(2089); me->AddThreat(temp, 0.0f); uiRayneGUID = temp->GetGUID(); } diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp index 18238ba3883..6edda7824be 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp @@ -118,7 +118,7 @@ class boss_apothecary_hummel : public CreatureScript _deadCount = 0; _isDead = false; events.SetPhase(PHASE_ALL); - me->setFaction(FACTION_APOTHECARY_FRIENDLY); + me->SetFaction(FACTION_APOTHECARY_FRIENDLY); me->SummonCreatureGroup(1); } @@ -137,7 +137,7 @@ class boss_apothecary_hummel : public CreatureScript events.ScheduleEvent(EVENT_HUMMEL_SAY_0, Milliseconds(1)); me->AddUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); - me->setFaction(FACTION_APOTHECARY_HOSTILE); + me->SetFaction(FACTION_APOTHECARY_HOSTILE); DummyEntryCheckPredicate pred; summons.DoAction(ACTION_START_EVENT, pred); } @@ -290,7 +290,7 @@ struct npc_apothecary_genericAI : public ScriptedAI if (action == ACTION_START_EVENT) { me->AddUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); - me->setFaction(FACTION_APOTHECARY_HOSTILE); + me->SetFaction(FACTION_APOTHECARY_HOSTILE); me->GetMotionMaster()->MovePoint(1, _movePos); } else if (action == ACTION_START_FIGHT) diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 986c3af28a5..d68a463a5ee 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -159,7 +159,7 @@ public: if (Creature* Sath = ObjectAccessor::GetCreature(*me, SathGUID)) Sath->AI()->EnterEvadeMode(); - me->setFaction(14); + me->SetFaction(14); if (!bJustReset) //first reset at create { me->RemoveUnitFlag(UnitFlags(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)); @@ -386,7 +386,7 @@ public: switch (TalkSequence) { case 1: - me->setFaction(35); + me->SetFaction(35); TalkTimer = 1000; break; case 2: diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index f95ddb5ce62..1a4999d450f 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -610,7 +610,7 @@ public: else summoned->SetLevel(me->getLevel()); - summoned->setFaction(me->getFaction()); + summoned->SetFaction(me->GetFaction()); summons.Summon(summoned); } @@ -936,7 +936,7 @@ public: void JustSummoned(Creature* summoned) override { - summoned->setFaction(me->getFaction()); + summoned->SetFaction(me->GetFaction()); summoned->SetLevel(me->getLevel()); } @@ -1036,7 +1036,7 @@ public: void JustSummoned(Creature* summoned) override { - summoned->setFaction(me->getFaction()); + summoned->SetFaction(me->GetFaction()); summoned->SetLevel(me->getLevel()); } diff --git a/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp b/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp index 335e50a9223..38ab7cd851f 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp @@ -98,7 +98,7 @@ class boss_archaedas : public CreatureScript Initialize(); instance->SetData(0, 5); // respawn any dead minions - me->setFaction(35); + me->SetFaction(35); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetControlled(true, UNIT_STATE_ROOT); me->AddAura(SPELL_FREEZE_ANIM, me); @@ -114,14 +114,14 @@ class boss_archaedas : public CreatureScript minion->CastSpell(minion, SPELL_ARCHAEDAS_AWAKEN, true); minion->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); minion->SetControlled(false, UNIT_STATE_ROOT); - minion->setFaction(14); + minion->SetFaction(14); minion->RemoveAura(SPELL_MINION_FREEZE_ANIM); } } void EnterCombat(Unit* /*who*/) override { - me->setFaction(14); + me->SetFaction(14); me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetControlled(false, UNIT_STATE_ROOT); } @@ -261,7 +261,7 @@ class npc_archaedas_minions : public CreatureScript { Initialize(); - me->setFaction(35); + me->SetFaction(35); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetControlled(true, UNIT_STATE_ROOT); me->RemoveAllAuras(); @@ -270,7 +270,7 @@ class npc_archaedas_minions : public CreatureScript void EnterCombat(Unit* /*who*/) override { - me->setFaction (14); + me->SetFaction(14); me->RemoveAllAuras(); me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetControlled(false, UNIT_STATE_ROOT); @@ -350,7 +350,7 @@ class npc_stonekeepers : public CreatureScript void Reset() override { - me->setFaction(35); + me->SetFaction(35); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetControlled(true, UNIT_STATE_ROOT); me->RemoveAllAuras(); @@ -359,7 +359,7 @@ class npc_stonekeepers : public CreatureScript void EnterCombat(Unit* /*who*/) override { - me->setFaction(14); + me->SetFaction(14); me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetControlled(false, UNIT_STATE_ROOT); } diff --git a/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp b/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp index 01613bf5a5f..ac3d2aa110f 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp @@ -149,7 +149,7 @@ class instance_uldaman : public InstanceMapScript void SetFrozenState(Creature* creature) { - creature->setFaction(35); + creature->SetFaction(35); creature->RemoveAllAuras(); creature->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); creature->SetControlled(true, UNIT_STATE_ROOT); @@ -184,7 +184,7 @@ class instance_uldaman : public InstanceMapScript if (!target || !target->IsAlive()) continue; target->SetControlled(false, UNIT_STATE_ROOT); - target->setFaction(14); + target->SetFaction(14); target->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); target->RemoveAura(SPELL_MINION_FREEZE_ANIM); @@ -205,11 +205,11 @@ class instance_uldaman : public InstanceMapScript for (GuidVector::const_iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i) { Creature* target = instance->GetCreature(*i); - if (!target || !target->IsAlive() || target->getFaction() == 14) + if (!target || !target->IsAlive() || target->GetFaction() == 14) continue; target->SetControlled(false, UNIT_STATE_ROOT); target->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - target->setFaction(14); + target->SetFaction(14); target->RemoveAura(SPELL_MINION_FREEZE_ANIM); archaedas->CastSpell(target, SPELL_AWAKEN_VAULT_WALKER, true); target->CastSpell(target, SPELL_ARCHAEDAS_AWAKEN, true); @@ -225,7 +225,7 @@ class instance_uldaman : public InstanceMapScript for (GuidVector::const_iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i) { Creature* target = instance->GetCreature(*i); - if (!target || target->isDead() || target->getFaction() != 14) + if (!target || target->isDead() || target->GetFaction() != 14) continue; target->DespawnOrUnsummon(); } @@ -234,7 +234,7 @@ class instance_uldaman : public InstanceMapScript for (GuidVector::const_iterator i = vaultWalkers.begin(); i != vaultWalkers.end(); ++i) { Creature* target = instance->GetCreature(*i); - if (!target || target->isDead() || target->getFaction() != 14) + if (!target || target->isDead() || target->GetFaction() != 14) continue; target->DespawnOrUnsummon(); } @@ -243,7 +243,7 @@ class instance_uldaman : public InstanceMapScript for (GuidVector::const_iterator i = earthenGuardians.begin(); i != earthenGuardians.end(); ++i) { Creature* target = instance->GetCreature(*i); - if (!target || target->isDead() || target->getFaction() != 14) + if (!target || target->isDead() || target->GetFaction() != 14) continue; target->DespawnOrUnsummon(); } @@ -269,7 +269,7 @@ class instance_uldaman : public InstanceMapScript if (!ironaya) return; - ironaya->setFaction(415); + ironaya->SetFaction(415); ironaya->SetControlled(false, UNIT_STATE_ROOT); ironaya->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp index bfa3983e8e4..3ad749d537d 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp @@ -144,7 +144,7 @@ class boss_mandokir : public CreatureScript { if (Creature* chainedSpirit = ObjectAccessor::GetCreature(*me, *itr)) if (chainedSpirit->GetEntry() == NPC_CHAINED_SPIRIT && chainedSpirit->AI()) - chainedSpirit->setFaction(FACTION_NONE); + chainedSpirit->SetFaction(FACTION_NONE); } } diff --git a/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp b/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp index 4d858c29c29..f07c55b2752 100644 --- a/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp @@ -113,7 +113,7 @@ class npc_professor_phizzlethorpe : public CreatureScript { Talk(SAY_PROGRESS_1, player); npc_escortAI::Start(false, false, player->GetGUID(), quest); - me->setFaction(FACTION_SUNKEN_TREASURE); + me->SetFaction(FACTION_SUNKEN_TREASURE); } } diff --git a/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp b/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp index 00acb433a61..1e4d75852a2 100644 --- a/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp @@ -133,7 +133,7 @@ public: { if (quest->GetQuestId() == QUEST_ESCAPE_FROM_THE_CATACOMBS) { - creature->setFaction(FACTION_QUEST_ESCAPE); + creature->SetFaction(FACTION_QUEST_ESCAPE); if (npc_escortAI* pEscortAI = CAST_AI(npc_ranger_lilatha::npc_ranger_lilathaAI, creature->AI())) pEscortAI->Start(true, false, player->GetGUID()); diff --git a/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp b/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp index 7466162b472..821f99ffc9a 100644 --- a/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp @@ -79,7 +79,7 @@ public: if (quest->GetQuestId() == QUEST_RESQUE_OOX_09) { me->SetStandState(UNIT_STAND_STATE_STAND); - me->setFaction(player->GetTeam() == ALLIANCE ? FACTION_ESCORTEE_A : FACTION_ESCORTEE_H); + me->SetFaction(player->GetTeam() == ALLIANCE ? FACTION_ESCORTEE_A : FACTION_ESCORTEE_H); Talk(SAY_OOX_START, player); npc_escortAI::Start(false, false, player->GetGUID(), quest); } diff --git a/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp b/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp index 1b328c3127b..16306014b1d 100644 --- a/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp +++ b/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp @@ -87,7 +87,7 @@ public: me->SetEmoteState(EMOTE_STATE_STUN); me->CombatStop(); // stop combat me->DeleteThreatList(); // unsure of this - me->setFaction(FACTION_HORDE_GENERIC); // horde generic + me->SetFaction(FACTION_HORDE_GENERIC); // horde generic bReset = true; Reset_Timer = 60000; @@ -105,7 +105,7 @@ public: { EnterEvadeMode(); bReset = false; - me->setFaction(FACTION_TROLL_BLOODSCALP); // troll, bloodscalp + me->SetFaction(FACTION_TROLL_BLOODSCALP); // troll, bloodscalp return; } diff --git a/src/server/scripts/EasternKingdoms/zone_wetlands.cpp b/src/server/scripts/EasternKingdoms/zone_wetlands.cpp index 1b1f2e0b9d0..f561db22727 100644 --- a/src/server/scripts/EasternKingdoms/zone_wetlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_wetlands.cpp @@ -84,7 +84,7 @@ public: if (me->HasStealthAura()) me->RemoveAurasByType(SPELL_AURA_MOD_STEALTH); SetRun(); - me->setFaction(FACTION_ENEMY); + me->SetFaction(FACTION_ENEMY); break; } } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp index 5ca36e99e0d..823ddd33aa9 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp @@ -917,7 +917,7 @@ void hyjalAI::HideNearPos(float x, float y) for (std::list::const_iterator itr = creatures.begin(); itr != creatures.end(); ++itr) { (*itr)->SetVisible(false); - (*itr)->setFaction(35);//make them friendly so mobs won't attack them + (*itr)->SetFaction(35);//make them friendly so mobs won't attack them } } } @@ -995,7 +995,7 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff) if ((*itr) && (*itr)->IsAlive()) { (*itr)->CastSpell(*itr, SPELL_TELEPORT_VISUAL, true); - (*itr)->setFaction(35);//make them friendly so mobs won't attack them + (*itr)->SetFaction(35);//make them friendly so mobs won't attack them (*itr)->AddUnitFlag(UNIT_FLAG_NON_ATTACKABLE); } } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp index ede1d589535..00ff25951df 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp @@ -470,7 +470,7 @@ public: if (Creature* trigger = me->SummonCreature(NPC_WORLD_TRIGGER_TINY, me->GetPositionWithOffset({ 8.0f, 8.0f, frand(25.0f, 35.0f), 0.0f }), TEMPSUMMON_TIMED_DESPAWN, 1000)) { trigger->SetVisible(false); - trigger->setFaction(me->getFaction()); + trigger->SetFaction(me->GetFaction()); trigger->SetDisableGravity(true); trigger->CastSpell(me, SPELL_METEOR, true); } diff --git a/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp b/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp index 98f22411a5e..1bb7bae6842 100644 --- a/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp +++ b/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp @@ -297,7 +297,7 @@ class npc_blazing_monstrosity : public CreatureScript // Our passenger is another vehicle (boardable by players) DoCast(passenger, SPELL_SHARE_HEALTH, true); - passenger->setFaction(35); + passenger->SetFaction(35); passenger->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); // Hack to relocate vehicle on vehicle so exiting players are not moved under map diff --git a/src/server/scripts/Kalimdor/Maraudon/boss_noxxion.cpp b/src/server/scripts/Kalimdor/Maraudon/boss_noxxion.cpp index 1e9bca04fb8..cb715b6f1e2 100644 --- a/src/server/scripts/Kalimdor/Maraudon/boss_noxxion.cpp +++ b/src/server/scripts/Kalimdor/Maraudon/boss_noxxion.cpp @@ -82,7 +82,7 @@ public: if (Invisible && InvisibleTimer <= diff) { //Become visible again - me->setFaction(14); + me->SetFaction(14); me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); //Noxxion model me->SetDisplayId(11172); @@ -122,7 +122,7 @@ public: //Interrupt any spell casting //me->m_canMove = true; me->InterruptNonMeleeSpells(false); - me->setFaction(35); + me->SetFaction(35); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); // Invisible Model me->SetDisplayId(11686); diff --git a/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp index d3167d2272c..adfca4e9a7e 100644 --- a/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp +++ b/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp @@ -136,7 +136,7 @@ public: eventInProgress = true; Talk(SAY_QUEST_ACCEPTED); me->RemoveNpcFlag(UNIT_NPC_FLAG_QUESTGIVER); - me->setFaction(FACTION_ESCORT); + me->SetFaction(FACTION_ESCORT); me->GetMotionMaster()->MovePath(PATH_ESCORT, false); } } diff --git a/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp b/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp index 226e1e0efd7..7fa68b2771a 100644 --- a/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp +++ b/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp @@ -58,7 +58,7 @@ public: { Start(true, false, player->GetGUID()); Talk(SAY_READY, player); - me->setFaction(113); + me->SetFaction(113); } } diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp index 4068f1491b6..3495a1a6d2b 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp @@ -111,7 +111,7 @@ public: //Cast me->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - me->setFaction(35); + me->SetFaction(35); DoCast(me, SPELL_DIRTMOUND_PASSIVE); Submerged = true; @@ -134,7 +134,7 @@ public: if (Submerged && Back_Timer <= diff) { me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - me->setFaction(14); + me->SetFaction(14); DoCastVictim(SPELL_GROUND_RUPTURE); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp index e9bd5488027..4dd49bb1c66 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp @@ -332,7 +332,7 @@ struct boss_twinemperorsAI : public ScriptedAI if (c->isDead()) { c->Respawn(); - c->setFaction(7); + c->SetFaction(7); c->RemoveAllAuras(); } if (c->IsWithinDistInMap(me, ABUSE_BUG_RANGE)) @@ -427,7 +427,7 @@ public: void CastSpellOnBug(Creature* target) override { - target->setFaction(14); + target->SetFaction(14); target->AI()->AttackStart(me->getThreatManager().getHostilTarget()); target->AddAura(SPELL_MUTATE_BUG, target); target->SetFullHealth(); @@ -518,7 +518,7 @@ public: void CastSpellOnBug(Creature* target) override { - target->setFaction(14); + target->SetFaction(14); target->AddAura(SPELL_EXPLODEBUG, target); target->SetFullHealth(); } diff --git a/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp b/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp index bdd909b5fff..d8fee227711 100644 --- a/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp +++ b/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp @@ -97,7 +97,7 @@ public: creature->AI()->Talk(SAY_MAKE_PREPARATIONS); - creature->setFaction(250); + creature->SetFaction(250); creature->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); ENSURE_AI(npc_escortAI, (creature->AI()))->Start(false, false, player->GetGUID()); diff --git a/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp b/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp index 3105164490a..f8b39df3d93 100644 --- a/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp +++ b/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp @@ -74,7 +74,7 @@ public: void Reset() override { - me->setFaction(ZUMRAH_FRIENDLY_FACTION); // areatrigger sets faction to enemy + me->SetFaction(ZUMRAH_FRIENDLY_FACTION); // areatrigger sets faction to enemy Initialize(); } diff --git a/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp b/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp index 0eb55441232..af4e5f4ec69 100644 --- a/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp +++ b/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp @@ -131,7 +131,7 @@ public: { Initialize(); - me->setFaction(FACTION_FRIENDLY); + me->SetFaction(FACTION_FRIENDLY); } void UpdateAI(uint32 diff) override @@ -154,7 +154,7 @@ public: Text_Timer = 5000; break; case 3: - me->setFaction(FACTION_HOSTILE); + me->SetFaction(FACTION_HOSTILE); if (Player* target = ObjectAccessor::GetPlayer(*me, PlayerGUID)) AttackStart(target); @@ -199,7 +199,7 @@ public: { if (Creature* crew = ObjectAccessor::GetCreature(*me, instance->GetGuidData(entry))) if (crew->IsAlive()) - crew->setFaction(FACTION_HOSTILE); + crew->SetFaction(FACTION_HOSTILE); } }; @@ -238,7 +238,7 @@ private: crew->SetWalk(true); crew->SetHomePosition(x, y, z, 0); crew->GetMotionMaster()->MovePoint(1, x, y, z); - crew->setFaction(FACTION_FREED); + crew->SetFaction(FACTION_FREED); } } }; @@ -387,7 +387,7 @@ public: { if (me->IsAlive()) { - me->setFaction(FACTION_FRIENDLY); + me->SetFaction(FACTION_FRIENDLY); me->GetMotionMaster()->MovePoint(0, 1858.57f, 1146.35f, 14.745f); me->SetHomePosition(1858.57f, 1146.35f, 14.745f, 3.85f); // in case he gets interrupted Talk(SAY_WEEGLI_OK_I_GO); @@ -454,7 +454,7 @@ public: if (!pZumrah) return false; - pZumrah->setFaction(ZUMRAH_HOSTILE_FACTION); + pZumrah->SetFaction(ZUMRAH_HOSTILE_FACTION); return true; } diff --git a/src/server/scripts/Kalimdor/zone_ashenvale.cpp b/src/server/scripts/Kalimdor/zone_ashenvale.cpp index 6bf389dc180..af7ca599b3f 100644 --- a/src/server/scripts/Kalimdor/zone_ashenvale.cpp +++ b/src/server/scripts/Kalimdor/zone_ashenvale.cpp @@ -83,7 +83,7 @@ public: { if (quest->GetQuestId() == QUEST_FREEDOM_TO_RUUL) { - me->setFaction(FACTION_QUEST); + me->SetFaction(FACTION_QUEST); npc_escortAI::Start(true, false, player->GetGUID()); } } @@ -226,7 +226,7 @@ public: if (quest->GetQuestId() == QUEST_VORSHA) { Talk(SAY_MUG_START1); - me->setFaction(FACTION_QUEST); + me->SetFaction(FACTION_QUEST); npc_escortAI::Start(true, false, player->GetGUID()); } } diff --git a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp index d7bc3bd5240..2e15e2d2118 100644 --- a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp +++ b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp @@ -201,7 +201,7 @@ public: npc_engineer_spark_overgrindAI(Creature* creature) : ScriptedAI(creature) { Initialize(); - NormFaction = creature->getFaction(); + NormFaction = creature->GetFaction(); NpcFlags = NPCFlags(creature->m_unitData->NpcFlags[0]); } @@ -220,7 +220,7 @@ public: { Initialize(); - me->setFaction(NormFaction); + me->SetFaction(NormFaction); me->SetNpcFlags(NpcFlags); } @@ -232,7 +232,7 @@ public: void sGossipSelect(Player* player, uint32 /*menuId*/, uint32 /*gossipListId*/) override { CloseGossipMenuFor(player); - me->setFaction(FACTION_HOSTILE); + me->SetFaction(FACTION_HOSTILE); me->Attack(player, true); } @@ -403,7 +403,7 @@ public: case EVENT_ACCEPT_QUEST: if (Player* player = ObjectAccessor::GetPlayer(*me, _player)) Talk(SAY_START, player); - me->setFaction(FACTION_QUEST); + me->SetFaction(FACTION_QUEST); _events.ScheduleEvent(EVENT_START_ESCORT, Seconds(1)); break; case EVENT_START_ESCORT: diff --git a/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp b/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp index bf6b78ea005..5c2f4299068 100644 --- a/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp +++ b/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp @@ -105,7 +105,7 @@ public: bool OnQuestAccept(Player* /*player*/, Creature* creature, const Quest* quest) override { if (quest->GetQuestId() == QUEST_MISSING_DIPLO_PT16) - creature->setFaction(FACTION_HOSTILE); + creature->SetFaction(FACTION_HOSTILE); return true; } diff --git a/src/server/scripts/Kalimdor/zone_felwood.cpp b/src/server/scripts/Kalimdor/zone_felwood.cpp index adc4d92a01c..f3aff8909f7 100644 --- a/src/server/scripts/Kalimdor/zone_felwood.cpp +++ b/src/server/scripts/Kalimdor/zone_felwood.cpp @@ -59,7 +59,7 @@ public: { me->CastSpell(me, SPELL_INFECTED_WOULD); me->SetEntry(NPC_CORRUPTED_LASHER); - me->setFaction(FACTION_HOSTILE); + me->SetFaction(FACTION_HOSTILE); } else { diff --git a/src/server/scripts/Kalimdor/zone_silithus.cpp b/src/server/scripts/Kalimdor/zone_silithus.cpp index 9e4de29c00d..2df4806adac 100644 --- a/src/server/scripts/Kalimdor/zone_silithus.cpp +++ b/src/server/scripts/Kalimdor/zone_silithus.cpp @@ -980,7 +980,7 @@ public: Merithra->SetNpcFlags(UNIT_NPC_FLAG_NONE); Merithra->SetStandState(UNIT_STAND_STATE_STAND); Merithra->SetDisplayId(MERITHRA_NIGHT_ELF_FORM); - Merithra->setFaction(35); + Merithra->SetFaction(35); } if (Caelestrasz) @@ -988,7 +988,7 @@ public: Caelestrasz->SetNpcFlags(UNIT_NPC_FLAG_NONE); Caelestrasz->SetStandState(UNIT_STAND_STATE_STAND); Caelestrasz->SetDisplayId(CAELESTRASZ_NIGHT_ELF_FORM); - Caelestrasz->setFaction(35); + Caelestrasz->SetFaction(35); } if (Arygos) @@ -996,7 +996,7 @@ public: Arygos->SetNpcFlags(UNIT_NPC_FLAG_NONE); Arygos->SetStandState(UNIT_STAND_STATE_STAND); Arygos->SetDisplayId(ARYGOS_GNOME_FORM); - Arygos->setFaction(35); + Arygos->SetFaction(35); } if (Anachronos) diff --git a/src/server/scripts/Kalimdor/zone_tanaris.cpp b/src/server/scripts/Kalimdor/zone_tanaris.cpp index 393ee9fcff6..2d5ad0bc50b 100644 --- a/src/server/scripts/Kalimdor/zone_tanaris.cpp +++ b/src/server/scripts/Kalimdor/zone_tanaris.cpp @@ -90,7 +90,7 @@ public: void Reset() override { Initialize(); - me->setFaction(35); + me->SetFaction(35); } void SendItem(Unit* receiver) @@ -120,7 +120,7 @@ public: { if (SwitchFactionTimer <= diff) { - me->setFaction(91); + me->SetFaction(91); isFriendly = false; } else SwitchFactionTimer -= diff; } @@ -318,7 +318,7 @@ public: { if (quest->GetQuestId() == Q_OOX17) { - creature->setFaction(113); + creature->SetFaction(113); creature->SetFullHealth(); creature->SetStandState(UNIT_STAND_STATE_STAND); creature->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); diff --git a/src/server/scripts/Kalimdor/zone_the_barrens.cpp b/src/server/scripts/Kalimdor/zone_the_barrens.cpp index 7c36c9a1af5..2ac0c1dc8dd 100644 --- a/src/server/scripts/Kalimdor/zone_the_barrens.cpp +++ b/src/server/scripts/Kalimdor/zone_the_barrens.cpp @@ -101,7 +101,7 @@ public: { if (quest->GetQuestId() == QUEST_FREE_FROM_HOLD) { - creature->setFaction(FACTION_ESCORTEE); + creature->SetFaction(FACTION_ESCORTEE); creature->SetStandState(UNIT_STAND_STATE_STAND); creature->AI()->Talk(SAY_GIL_START, player); @@ -196,7 +196,7 @@ public: npc_taskmaster_fizzuleAI(Creature* creature) : ScriptedAI(creature) { Initialize(); - factionNorm = creature->getFaction(); + factionNorm = creature->GetFaction(); } void Initialize() @@ -214,7 +214,7 @@ public: void Reset() override { Initialize(); - me->setFaction(factionNorm); + me->SetFaction(factionNorm); } void DoFriend() @@ -226,7 +226,7 @@ public: me->StopMoving(); me->GetMotionMaster()->MoveIdle(); - me->setFaction(FACTION_FRIENDLY_F); + me->SetFaction(FACTION_FRIENDLY_F); me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); } @@ -266,7 +266,7 @@ public: { if (FlareCount >= 2) { - if (me->getFaction() == FACTION_FRIENDLY_F) + if (me->GetFaction() == FACTION_FRIENDLY_F) return; DoFriend(); @@ -419,7 +419,7 @@ public: Creature* creature = me->SummonCreature(NPC_AFFRAY_CHALLENGER, AffrayChallengerLoc[i], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); if (!creature) continue; - creature->setFaction(35); + creature->SetFaction(35); creature->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); creature->AddUnitFlag(UNIT_FLAG_NON_ATTACKABLE); creature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR); @@ -460,7 +460,7 @@ public: creature->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); creature->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE); creature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR); - creature->setFaction(14); + creature->SetFaction(14); creature->AI()->AttackStart(warrior); ++Wave; WaveTimer = 20000; @@ -492,7 +492,7 @@ public: creature->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); creature->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE); creature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR); - creature->setFaction(14); + creature->SetFaction(14); creature->AI()->AttackStart(warrior); } } @@ -653,7 +653,7 @@ public: { if (quest->GetQuestId() == QUEST_ESCAPE) { - creature->setFaction(FACTION_RATCHET); + creature->SetFaction(FACTION_RATCHET); creature->AI()->Talk(SAY_START); if (npc_escortAI* pEscortAI = CAST_AI(npc_wizzlecrank_shredder::npc_wizzlecrank_shredderAI, creature->AI())) pEscortAI->Start(true, false, player->GetGUID()); diff --git a/src/server/scripts/Kalimdor/zone_winterspring.cpp b/src/server/scripts/Kalimdor/zone_winterspring.cpp index 97084ad9d28..c0d5b422cb9 100644 --- a/src/server/scripts/Kalimdor/zone_winterspring.cpp +++ b/src/server/scripts/Kalimdor/zone_winterspring.cpp @@ -299,7 +299,7 @@ public: if (quest->GetQuestId() == QUEST_GUARDIANS_ALTAR) { creature->AI()->Talk(SAY_QUEST_START); - creature->setFaction(FACTION_ESCORT_A_NEUTRAL_PASSIVE); + creature->SetFaction(FACTION_ESCORT_A_NEUTRAL_PASSIVE); if (npc_ranshallaAI* escortAI = dynamic_cast(creature->AI())) escortAI->Start(false, false, player->GetGUID(), quest); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp index ff34eb5851a..81dcf1846a6 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp @@ -195,7 +195,7 @@ public: { damage = 0; EnterEvadeMode(); - me->setFaction(35); + me->SetFaction(35); bDone = true; } } @@ -323,7 +323,7 @@ public: { damage = 0; EnterEvadeMode(); - me->setFaction(35); + me->SetFaction(35); bDone = true; } } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index 4d41e3b4c14..868bb4e07c8 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -226,7 +226,7 @@ class boss_anubarak_trial : public CreatureScript for (int i = 0; i < 10; i++) if (Creature* scarab = me->SummonCreature(NPC_SCARAB, AnubarakLoc[1].GetPositionX()+urand(0, 50)-25, AnubarakLoc[1].GetPositionY()+urand(0, 50)-25, AnubarakLoc[1].GetPositionZ())) { - scarab->setFaction(31); + scarab->SetFaction(31); scarab->GetMotionMaster()->MoveRandom(10); } } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp index a40b30d6128..871214b8c21 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp @@ -922,7 +922,7 @@ class npc_toc_shaman : public CreatureScript events.ScheduleEvent(EVENT_SPIRIT_CLEANSE, urand(15*IN_MILLISECONDS, 35*IN_MILLISECONDS)); return; case EVENT_HEAL_BLOODLUST_HEROISM: - if (me->getFaction()) // alliance = 1 + if (me->GetFaction()) // alliance = 1 { if (!me->HasAura(AURA_EXHAUSTION)) DoCastAOE(SPELL_HEROISM); @@ -2030,7 +2030,7 @@ class npc_toc_enh_shaman : public CreatureScript events.ScheduleEvent(EVENT_STORMSTRIKE, urand(8*IN_MILLISECONDS, 10*IN_MILLISECONDS)); return; case EVENT_DPS_BLOODLUST_HEROISM: - if (me->getFaction()) //Am i alliance? + if (me->GetFaction()) //Am i alliance? { if (!me->HasAura(AURA_EXHAUSTION)) DoCastAOE(SPELL_HEROISM); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp index 80ab44fe32a..fbe2655cf84 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp @@ -463,7 +463,7 @@ class boss_deathbringer_saurfang : public CreatureScript { case EVENT_INTRO_ALLIANCE_2: me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - me->setFaction(FACTION_SCOURGE); + me->SetFaction(FACTION_SCOURGE); Talk(SAY_INTRO_ALLIANCE_2); break; case EVENT_INTRO_ALLIANCE_3: @@ -476,7 +476,7 @@ class boss_deathbringer_saurfang : public CreatureScript break; case EVENT_INTRO_HORDE_2: me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - me->setFaction(FACTION_SCOURGE); + me->SetFaction(FACTION_SCOURGE); Talk(SAY_INTRO_HORDE_2); break; case EVENT_INTRO_HORDE_4: diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp index 217dc86e342..f4e8d4e10b1 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp @@ -359,7 +359,7 @@ class boss_lady_deathwhisper : public CreatureScript { if (darnavan->IsAlive()) { - darnavan->setFaction(35); + darnavan->SetFaction(35); darnavan->CombatStop(true); darnavan->GetMotionMaster()->MoveIdle(); darnavan->SetReactState(REACT_PASSIVE); diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 997ab3c0180..0aa77ef0eb2 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -1214,7 +1214,7 @@ public: me->SetCanFly(false); } - me->setFaction(FACTION_FRIENDLY); + me->SetFaction(FACTION_FRIENDLY); me->RemoveAllAuras(); } } diff --git a/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp b/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp index 8fa9aabb59e..857ce9c32b4 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp @@ -61,31 +61,31 @@ class instance_nexus : public InstanceMapScript // Alliance npcs are spawned by default, if you are alliance, you will fight against horde npcs. case NPC_ALLIANCE_BERSERKER: if (ServerAllowsTwoSideGroups()) - creature->setFaction(FACTION_HOSTILE_FOR_ALL); + creature->SetFaction(FACTION_HOSTILE_FOR_ALL); if (_teamInInstance == ALLIANCE) creature->UpdateEntry(NPC_HORDE_BERSERKER); break; case NPC_ALLIANCE_RANGER: if (ServerAllowsTwoSideGroups()) - creature->setFaction(FACTION_HOSTILE_FOR_ALL); + creature->SetFaction(FACTION_HOSTILE_FOR_ALL); if (_teamInInstance == ALLIANCE) creature->UpdateEntry(NPC_HORDE_RANGER); break; case NPC_ALLIANCE_CLERIC: if (ServerAllowsTwoSideGroups()) - creature->setFaction(FACTION_HOSTILE_FOR_ALL); + creature->SetFaction(FACTION_HOSTILE_FOR_ALL); if (_teamInInstance == ALLIANCE) creature->UpdateEntry(NPC_HORDE_CLERIC); break; case NPC_ALLIANCE_COMMANDER: if (ServerAllowsTwoSideGroups()) - creature->setFaction(FACTION_HOSTILE_FOR_ALL); + creature->SetFaction(FACTION_HOSTILE_FOR_ALL); if (_teamInInstance == ALLIANCE) creature->UpdateEntry(NPC_HORDE_COMMANDER); break; case NPC_COMMANDER_STOUTBEARD: if (ServerAllowsTwoSideGroups()) - creature->setFaction(FACTION_HOSTILE_FOR_ALL); + creature->SetFaction(FACTION_HOSTILE_FOR_ALL); if (_teamInInstance == ALLIANCE) creature->UpdateEntry(NPC_COMMANDER_KOLURG); break; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp index e70769ffd11..6ebe372fe25 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp @@ -538,7 +538,7 @@ class boss_algalon_the_observer : public CreatureScript damage = 0; me->SetReactState(REACT_PASSIVE); me->AttackStop(); - me->setFaction(35); + me->SetFaction(35); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); DoCast(me, SPELL_SELF_STUN); events.Reset(); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp index 8e734e6d3e7..c301d287a97 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -607,7 +607,7 @@ class boss_flame_leviathan_seat : public CreatureScript if (Unit* turretPassenger = me->GetVehicleKit()->GetPassenger(SEAT_TURRET)) if (Creature* turret = turretPassenger->ToCreature()) { - turret->setFaction(me->GetVehicleBase()->getFaction()); + turret->SetFaction(me->GetVehicleBase()->GetFaction()); turret->SetUnitFlags(UnitFlags(0)); // unselectable turret->AI()->AttackStart(who); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp index 5cfc0d75481..33e346e0c94 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp @@ -226,7 +226,7 @@ class npc_iron_roots : public CreatureScript SetCombatMovement(false); me->ApplySpellImmune(0, IMMUNITY_ID, 49560, true); // Death Grip - me->setFaction(14); + me->SetFaction(14); me->SetReactState(REACT_PASSIVE); } @@ -610,7 +610,7 @@ class boss_freya : public CreatureScript _JustDied(); me->RemoveAllAuras(); me->AttackStop(); - me->setFaction(35); + me->SetFaction(35); me->DeleteThreatList(); me->CombatStop(true); me->DespawnOrUnsummon(7500); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp index 4d8a49160bc..a320994dc07 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp @@ -408,7 +408,7 @@ class boss_hodir : public CreatureScript DoCastAOE(SPELL_KILL_CREDIT, true); /// need to be cast before changing boss faction /// spell will target enemies only - me->setFaction(35); + me->SetFaction(35); me->DespawnOrUnsummon(10000); _JustDied(); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp index 37141085731..cfe2d3879d1 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp @@ -180,7 +180,7 @@ class boss_ignis : public CreatureScript { if (summon->GetEntry() == NPC_IRON_CONSTRUCT) { - summon->setFaction(16); + summon->SetFaction(16); summon->SetReactState(REACT_AGGRESSIVE); summon->RemoveUnitFlag(UnitFlags(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED | UNIT_FLAG_STUNNED | UNIT_FLAG_IMMUNE_TO_PC)); summon->SetControlled(false, UNIT_STATE_ROOT); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index 4d9ed335279..940c5b4f52f 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -637,7 +637,7 @@ class boss_mimiron : public CreatureScript case EVENT_OUTTRO_1: me->RemoveAurasDueToSpell(SPELL_SLEEP_VISUAL_1); DoCast(me, SPELL_SLEEP_VISUAL_2); - me->setFaction(35); + me->SetFaction(35); events.ScheduleEvent(EVENT_OUTTRO_2, 3000); break; case EVENT_OUTTRO_2: diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp index 79214b5b0e1..e36e32fd882 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp @@ -774,7 +774,7 @@ class boss_sara : public CreatureScript { me->RemoveAllAuras(); me->SetReactState(REACT_PASSIVE); - me->setFaction(35); + me->SetFaction(35); _events.Reset(); _events.SetPhase(PHASE_ONE); } @@ -817,7 +817,7 @@ class boss_sara : public CreatureScript case EVENT_TRANSFORM_3: Talk(SAY_SARA_TRANSFORM_4); DoCast(me, SPELL_FULL_HEAL); - me->setFaction(16); + me->SetFaction(16); if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) voice->AI()->DoAction(ACTION_PHASE_TWO); if (Creature* mimiron = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_MIMIRON_YS))) diff --git a/src/server/scripts/Northrend/zone_borean_tundra.cpp b/src/server/scripts/Northrend/zone_borean_tundra.cpp index 61c5a52c24e..1dcc2de11c2 100644 --- a/src/server/scripts/Northrend/zone_borean_tundra.cpp +++ b/src/server/scripts/Northrend/zone_borean_tundra.cpp @@ -668,11 +668,11 @@ public: switch (player->GetTeam()) { case ALLIANCE: - creature->setFaction(FACTION_ESCORTEE_A); + creature->SetFaction(FACTION_ESCORTEE_A); break; default: case HORDE: - creature->setFaction(FACTION_ESCORTEE_H); + creature->SetFaction(FACTION_ESCORTEE_H); break; } @@ -710,7 +710,7 @@ public: owner->GetMotionMaster()->MoveFollow(GetCaster(), 4.0f, 0.0f); owner->CastSpell(owner, SPELL_SUBDUED, true); GetCaster()->CastSpell(GetCaster(), SPELL_DRAKE_HATCHLING_SUBDUED, true); - owner->setFaction(35); + owner->SetFaction(35); owner->AddUnitFlag(UnitFlags(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC)); owner->DespawnOrUnsummon(3 * MINUTE*IN_MILLISECONDS); } @@ -891,7 +891,7 @@ public: if (talbot) { talbot->UpdateEntry(NPC_PRINCE_VALANAR); - talbot->setFaction(14); + talbot->SetFaction(14); talbot->AddUnitFlag(UNIT_FLAG_NON_ATTACKABLE); talbot->SetReactState(REACT_PASSIVE); } @@ -1629,10 +1629,10 @@ public: switch (player->GetTeam()) { case ALLIANCE: - creature->setFaction(FACTION_ESCORTEE_A); + creature->SetFaction(FACTION_ESCORTEE_A); break; case HORDE: - creature->setFaction(FACTION_ESCORTEE_H); + creature->SetFaction(FACTION_ESCORTEE_H); break; } creature->SetStandState(UNIT_STAND_STATE_STAND); @@ -2217,7 +2217,7 @@ public: void AttackPlayer() { - me->setFaction(14); + me->SetFaction(14); if (Player* player = ObjectAccessor::GetPlayer(*me, uiPlayerGUID)) AttackStart(player); } diff --git a/src/server/scripts/Northrend/zone_dragonblight.cpp b/src/server/scripts/Northrend/zone_dragonblight.cpp index f2c59c76c1d..05cb11fc414 100644 --- a/src/server/scripts/Northrend/zone_dragonblight.cpp +++ b/src/server/scripts/Northrend/zone_dragonblight.cpp @@ -414,7 +414,7 @@ public: else if (roll == 0) // enemy version { tree->AI()->Talk(SAY_WALKER_ENEMY, player); - tree->setFaction(FACTION_WALKER_ENEMY); + tree->SetFaction(FACTION_WALKER_ENEMY); tree->Attack(player, true); } } diff --git a/src/server/scripts/Northrend/zone_grizzly_hills.cpp b/src/server/scripts/Northrend/zone_grizzly_hills.cpp index 5519d70d21c..a9495310e89 100644 --- a/src/server/scripts/Northrend/zone_grizzly_hills.cpp +++ b/src/server/scripts/Northrend/zone_grizzly_hills.cpp @@ -103,7 +103,7 @@ public: Talk(SAY_WORGRAGGRO3); if (Creature* RWORG = me->SummonCreature(NPC_RAVENOUS_WORG, me->GetPositionX()+10, me->GetPositionY()+8, me->GetPositionZ()+2, 3.229f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000)) { - RWORG->setFaction(35); + RWORG->SetFaction(35); _RavenousworgGUID = RWORG->GetGUID(); } break; @@ -136,7 +136,7 @@ public: { RWORG->Kill(Mrfloppy); Mrfloppy->ExitVehicle(); - RWORG->setFaction(14); + RWORG->SetFaction(14); RWORG->GetMotionMaster()->MovePoint(0, RWORG->GetPositionX()+10, RWORG->GetPositionY()+80, RWORG->GetPositionZ()); Talk(SAY_VICTORY2); } diff --git a/src/server/scripts/Northrend/zone_howling_fjord.cpp b/src/server/scripts/Northrend/zone_howling_fjord.cpp index ed389a87d4a..9f49df63596 100644 --- a/src/server/scripts/Northrend/zone_howling_fjord.cpp +++ b/src/server/scripts/Northrend/zone_howling_fjord.cpp @@ -164,7 +164,7 @@ public: break; case EVENT_START_ESCORT: events.Reset(); - me->setFaction(FACTION_ESCORTEE_H); + me->SetFaction(FACTION_ESCORTEE_H); me->SetReactState(REACT_AGGRESSIVE); ENSURE_AI(npc_escortAI, (me->AI()))->Start(true, true, _player); break; diff --git a/src/server/scripts/Northrend/zone_icecrown.cpp b/src/server/scripts/Northrend/zone_icecrown.cpp index 181d24d7761..8adbd37d884 100644 --- a/src/server/scripts/Northrend/zone_icecrown.cpp +++ b/src/server/scripts/Northrend/zone_icecrown.cpp @@ -47,7 +47,7 @@ public: { Initialize(); creature->GetMotionMaster()->MovePoint(0, 8599.258f, 963.951f, 547.553f); - creature->setFaction(35); //wrong faction in db? + creature->SetFaction(35); //wrong faction in db? } void Initialize() @@ -69,7 +69,7 @@ public: if (uiType != POINT_MOTION_TYPE) return; - me->setFaction(14); + me->SetFaction(14); } void DamageTaken(Unit* pDoneBy, uint32& uiDamage) override @@ -78,7 +78,7 @@ public: { uiDamage = 0; pDoneBy->CastSpell(pDoneBy, SPELL_KILL_CREDIT, true); - me->setFaction(35); + me->SetFaction(35); me->DespawnOrUnsummon(5000); me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation()); EnterEvadeMode(); diff --git a/src/server/scripts/Northrend/zone_sholazar_basin.cpp b/src/server/scripts/Northrend/zone_sholazar_basin.cpp index c6489dcb6c8..1c226c23528 100644 --- a/src/server/scripts/Northrend/zone_sholazar_basin.cpp +++ b/src/server/scripts/Northrend/zone_sholazar_basin.cpp @@ -326,7 +326,7 @@ public: if (npc_engineer_heliceAI* pEscortAI = CAST_AI(npc_engineer_helice::npc_engineer_heliceAI, creature->AI())) { creature->GetMotionMaster()->MoveJumpTo(0, 0.4f, 0.4f); - creature->setFaction(113); + creature->SetFaction(113); pEscortAI->Start(false, false, player->GetGUID()); creature->AI()->Talk(SAY_WP_1); diff --git a/src/server/scripts/Northrend/zone_storm_peaks.cpp b/src/server/scripts/Northrend/zone_storm_peaks.cpp index 700b64c0417..6b3cc445c9d 100644 --- a/src/server/scripts/Northrend/zone_storm_peaks.cpp +++ b/src/server/scripts/Northrend/zone_storm_peaks.cpp @@ -93,7 +93,7 @@ public: if (menuId == GOSSIP_ID && gossipListId == GOSSIP_OPTION_ID) { CloseGossipMenuFor(player); - me->setFaction(113); + me->SetFaction(113); Start(true, true, player->GetGUID()); } } diff --git a/src/server/scripts/Northrend/zone_wintergrasp.cpp b/src/server/scripts/Northrend/zone_wintergrasp.cpp index 1ead42b9a39..7233bf3db61 100644 --- a/src/server/scripts/Northrend/zone_wintergrasp.cpp +++ b/src/server/scripts/Northrend/zone_wintergrasp.cpp @@ -345,8 +345,8 @@ class go_wg_vehicle_teleporter : public GameObjectScript bool IsFriendly(Unit* passenger) { - return ((go->GetFaction() == WintergraspFaction[TEAM_HORDE] && passenger->getFaction() == HORDE) || - (go->GetFaction() == WintergraspFaction[TEAM_ALLIANCE] && passenger->getFaction() == ALLIANCE)); + return ((go->GetFaction() == WintergraspFaction[TEAM_HORDE] && passenger->GetFaction() == HORDE) || + (go->GetFaction() == WintergraspFaction[TEAM_ALLIANCE] && passenger->GetFaction() == ALLIANCE)); } Creature* GetValidVehicle(Creature* cVeh) diff --git a/src/server/scripts/Northrend/zone_zuldrak.cpp b/src/server/scripts/Northrend/zone_zuldrak.cpp index 23716389e7e..e9e94189bf7 100644 --- a/src/server/scripts/Northrend/zone_zuldrak.cpp +++ b/src/server/scripts/Northrend/zone_zuldrak.cpp @@ -138,7 +138,7 @@ public: void Reset() override { - me->setFaction(35); + me->SetFaction(35); DoCast(me, SPELL_KNEEL, true); // Little Hack for kneel - Thanks Illy :P } @@ -151,7 +151,7 @@ public: me->RemoveAurasDueToSpell(SPELL_LEFT_CHAIN); me->RemoveAurasDueToSpell(SPELL_RIGHT_CHAIN); me->RemoveAurasDueToSpell(SPELL_KNEEL); - me->setFaction(me->GetCreatureTemplate()->faction); + me->SetFaction(me->GetCreatureTemplate()->faction); DoCast(me, SPELL_UNSHACKLED, true); Talk(SAY_RAGECLAW); me->GetMotionMaster()->MoveRandom(10); diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp index 8b2e7d01220..e02d3f206d5 100644 --- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp +++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp @@ -228,7 +228,7 @@ public: //SPELL_STOLEN_SOUL_VISUAL has shapeshift effect, but not implemented feature in Trinity for this spell. summoned->CastSpell(summoned, SPELL_STOLEN_SOUL_VISUAL, false); summoned->SetDisplayId(soulmodel); - summoned->setFaction(me->getFaction()); + summoned->SetFaction(me->GetFaction()); if (Unit* target = ObjectAccessor::GetUnit(*me, soulholder)) { diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp index d0ba63b17f9..c07ddb0cb23 100644 --- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp +++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp @@ -96,7 +96,7 @@ public: if (summoned && summoned->GetEntry() == NPC_FOCUS_FIRE) { summoned->CastSpell(summoned, SPELL_FOCUS_FIRE_VISUAL, false); - summoned->setFaction(me->getFaction()); + summoned->SetFaction(me->GetFaction()); summoned->SetLevel(me->getLevel()); summoned->AddUnitState(UNIT_STATE_ROOT); diff --git a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp index 610d12a377b..dc5d479bf58 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp @@ -384,7 +384,7 @@ public: void Reset() override { Initialize(); - me->setFaction(ASHTONGUE_FACTION_FRIEND); + me->SetFaction(ASHTONGUE_FACTION_FRIEND); DoCastSelf(SPELL_STEALTH); if (_instance->GetBossState(DATA_SHADE_OF_AKAMA) != DONE) @@ -430,7 +430,7 @@ public: { _isInCombat = false; me->CombatStop(true); - me->setFaction(ASHTONGUE_FACTION_FRIEND); + me->SetFaction(ASHTONGUE_FACTION_FRIEND); me->SetWalk(true); _events.Reset(); me->GetMotionMaster()->MovePoint(AKAMA_INTRO_WAYPOINT, AkamaWP[1]); @@ -484,7 +484,7 @@ public: case EVENT_SHADE_CHANNEL: me->SetFacingTo(FACE_THE_PLATFORM); DoCastSelf(SPELL_AKAMA_SOUL_CHANNEL); - me->setFaction(AKAMA_FACTION_COMBAT); + me->SetFaction(AKAMA_FACTION_COMBAT); _events.ScheduleEvent(EVENT_FIXATE, Seconds(5)); break; case EVENT_FIXATE: @@ -532,7 +532,7 @@ public: } } - if (me->getFaction() == AKAMA_FACTION_COMBAT) + if (me->GetFaction() == AKAMA_FACTION_COMBAT) { if (!UpdateVictim()) return; @@ -1170,7 +1170,7 @@ public: Talk(SAY_BROKEN_SPECIAL); break; case ACTION_BROKEN_HAIL: - me->setFaction(ASHTONGUE_FACTION_FRIEND); + me->SetFaction(ASHTONGUE_FACTION_FRIEND); Talk(SAY_BROKEN_HAIL); break; case ACTION_BROKEN_EMOTE: diff --git a/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp b/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp index 8684879ac42..66600ccb4d0 100644 --- a/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp +++ b/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp @@ -128,7 +128,7 @@ class instance_black_temple : public InstanceMapScript case NPC_STORM_FURY: AshtongueGUIDs.emplace_back(creature->GetGUID()); if (GetBossState(DATA_SHADE_OF_AKAMA) == DONE) - creature->setFaction(ASHTONGUE_FACTION_FRIEND); + creature->SetFaction(ASHTONGUE_FACTION_FRIEND); break; default: break; @@ -175,7 +175,7 @@ class instance_black_temple : public InstanceMapScript if (state == DONE) for (ObjectGuid ashtongueGuid : AshtongueGUIDs) if (Creature* ashtongue = instance->GetCreature(ashtongueGuid)) - ashtongue->setFaction(ASHTONGUE_FACTION_FRIEND); + ashtongue->SetFaction(ASHTONGUE_FACTION_FRIEND); // no break case DATA_TERON_GOREFIEND: case DATA_GURTOGG_BLOODBOIL: diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp index 0187d263a5e..a8485ecbdf3 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp @@ -668,7 +668,7 @@ public: { Cyclone->SetObjectScale(3.0f); Cyclone->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - Cyclone->setFaction(me->getFaction()); + Cyclone->SetFaction(me->GetFaction()); Cyclone->CastSpell(Cyclone, SPELL_CYCLONE_CYCLONE, true); if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) Cyclone->AI()->AttackStart(target); diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp index 520ee2c9e9b..a454599bbf7 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp @@ -753,7 +753,7 @@ public: void Reset() override { me->SetDisableGravity(true); - me->setFaction(14); + me->SetFaction(14); Initialize(); } @@ -788,7 +788,7 @@ public: { if (Creature* trig = me->SummonCreature(TOXIC_SPORES_TRIGGER, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000)) { - trig->setFaction(14); + trig->SetFaction(14); trig->CastSpell(trig, SPELL_TOXIC_SPORES, true); } } @@ -804,7 +804,7 @@ public: if (!Vashj || !Vashj->IsAlive() || ENSURE_AI(boss_lady_vashj::boss_lady_vashjAI, Vashj->ToCreature()->AI())->Phase != 3) { // remove - me->setFaction(35); + me->SetFaction(35); me->DespawnOrUnsummon(); return; } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp index 265787589e4..eca80aec5e6 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp @@ -321,7 +321,7 @@ public: me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - me->setFaction(14); + me->SetFaction(14); } void EnterCombat(Unit* /*who*/) override { } diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp index 009c5b261df..858705111b0 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp @@ -104,7 +104,7 @@ class boss_nazan : public CreatureScript if (summoned && summoned->GetEntry() == NPC_LIQUID_FIRE) { summoned->SetLevel(me->getLevel()); - summoned->setFaction(me->getFaction()); + summoned->SetFaction(me->GetFaction()); summoned->CastSpell(summoned, DUNGEON_MODE(SPELL_SUMMON_LIQUID_FIRE, SPELL_SUMMON_LIQUID_FIRE_H), true); summoned->CastSpell(summoned, SPELL_FIRE_NOVA_VISUAL, true); } diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp index a128e0349fb..765a7d5a7de 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp @@ -207,7 +207,7 @@ class boss_grand_warlock_nethekurse : public CreatureScript void JustSummoned(Creature* summoned) override { - summoned->setFaction(16); + summoned->SetFaction(16); summoned->AddUnitFlag(UNIT_FLAG_NON_ATTACKABLE); summoned->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp index d30cb2e08f0..6fba85f3580 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp @@ -410,7 +410,7 @@ class boss_alar : public CreatureScript Summoned->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); Summoned->SetObjectScale(Summoned->GetObjectScale() * 2.5f); Summoned->SetDisplayId(11686); - Summoned->setFaction(me->getFaction()); + Summoned->SetFaction(me->GetFaction()); Summoned->SetLevel(me->getLevel()); Summoned->CastSpell(Summoned, SPELL_FLAME_PATCH, false); } diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index e08071fc475..ee44f0c0f46 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -1278,7 +1278,7 @@ class npc_kael_flamestrike : public CreatureScript Initialize(); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - me->setFaction(14); + me->SetFaction(14); } void MoveInLineOfSight(Unit* /*who*/) override { } diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp index fc45410e932..70b1da72d93 100644 --- a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp +++ b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp @@ -539,7 +539,7 @@ class npc_zerekethvoidzone : public CreatureScript void Reset() override { me->SetNpcFlags(UNIT_NPC_FLAG_NONE); - me->setFaction(16); + me->SetFaction(16); me->AddUnitFlag(UNIT_FLAG_NOT_SELECTABLE); DoCast(me, SPELL_VOID_ZONE_DAMAGE); diff --git a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp index 3a3902a5668..7e3afcbc225 100644 --- a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp +++ b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp @@ -76,7 +76,7 @@ public: Initialize(); me->RemoveNpcFlag(UNIT_NPC_FLAG_QUESTGIVER); - me->setFaction(FACTION_FRIENDLY); + me->SetFaction(FACTION_FRIENDLY); Talk(SAY_SUMMON); } @@ -87,7 +87,7 @@ public: { if (faction_Timer <= diff) { - me->setFaction(FACTION_HOSTILE); + me->SetFaction(FACTION_HOSTILE); faction_Timer = 0; } else faction_Timer -= diff; } @@ -97,7 +97,7 @@ public: if (HealthBelowPct(30)) { - me->setFaction(FACTION_FRIENDLY); + me->SetFaction(FACTION_FRIENDLY); me->AddNpcFlag(UNIT_NPC_FLAG_QUESTGIVER); me->RemoveAllAuras(); me->DeleteThreatList(); @@ -281,7 +281,7 @@ public: { if (quest->GetQuestId() == QUEST_ROAD_TO_FALCON_WATCH) { - me->setFaction(FACTION_FALCON_WATCH_QUEST); + me->SetFaction(FACTION_FALCON_WATCH_QUEST); npc_escortAI::Start(true, false, player->GetGUID()); } } @@ -1004,7 +1004,7 @@ public: break; case EVENT_ATTACK: me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); - me->setFaction(FACTION_HOSTILE); + me->SetFaction(FACTION_HOSTILE); if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID)) me->CombatStart(player); _events.ScheduleEvent(EVENT_FIREBALL, 1); diff --git a/src/server/scripts/Outland/zone_nagrand.cpp b/src/server/scripts/Outland/zone_nagrand.cpp index ae5e1a60708..2f662558c93 100644 --- a/src/server/scripts/Outland/zone_nagrand.cpp +++ b/src/server/scripts/Outland/zone_nagrand.cpp @@ -79,7 +79,7 @@ public: if (npc_maghar_captiveAI* EscortAI = dynamic_cast(creature->AI())) { creature->SetStandState(UNIT_STAND_STATE_STAND); - creature->setFaction(232); + creature->SetFaction(232); EscortAI->Start(true, false, player->GetGUID(), quest); creature->AI()->Talk(SAY_MAG_START); @@ -433,7 +433,7 @@ public: if (npc_kurenai_captiveAI* EscortAI = dynamic_cast(creature->AI())) { creature->SetStandState(UNIT_STAND_STATE_STAND); - creature->setFaction(231); + creature->SetFaction(231); EscortAI->Start(true, false, player->GetGUID(), quest); creature->AI()->Talk(SAY_KUR_START); diff --git a/src/server/scripts/Outland/zone_netherstorm.cpp b/src/server/scripts/Outland/zone_netherstorm.cpp index f11a2f2df65..cc10c1d619c 100644 --- a/src/server/scripts/Outland/zone_netherstorm.cpp +++ b/src/server/scripts/Outland/zone_netherstorm.cpp @@ -498,7 +498,7 @@ public: { if (quest->GetQuestId() == Q_ALMABTRIEB) { - creature->setFaction(113); + creature->SetFaction(113); creature->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE); ENSURE_AI(npc_escortAI, (creature->AI()))->Start(true, false, player->GetGUID()); } @@ -664,7 +664,7 @@ public: { if (npc_maxx_a_million_escortAI* pEscortAI = CAST_AI(npc_maxx_a_million_escort::npc_maxx_a_million_escortAI, creature->AI())) { - creature->setFaction(113); + creature->SetFaction(113); pEscortAI->Start(false, false, player->GetGUID()); } } diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp index a8bd85023a2..af98238d5b5 100644 --- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp @@ -379,7 +379,7 @@ public: void Reset() override { if (!Tapped) - me->setFaction(FACTION_DEFAULT); + me->SetFaction(FACTION_DEFAULT); FlyTimer = 10000; me->SetDisableGravity(false); @@ -395,7 +395,7 @@ public: Tapped = true; PlayerGUID = caster->GetGUID(); - me->setFaction(FACTION_FRIENDLY); + me->SetFaction(FACTION_FRIENDLY); DoCast(caster, SPELL_FORCE_OF_NELTHARAKU, true); Unit* Dragonmaw = me->FindNearestCreature(NPC_DRAGONMAW_SUBJUGATOR, 50); @@ -602,7 +602,7 @@ public: if (quest->GetQuestId() == QUEST_ESCAPE_COILSCAR) { creature->AI()->Talk(SAY_WIL_START, player); - creature->setFaction(FACTION_EARTHEN); + creature->SetFaction(FACTION_EARTHEN); if (npc_earthmender_wildaAI* pEscortAI = CAST_AI(npc_earthmender_wilda::npc_earthmender_wildaAI, creature->AI())) pEscortAI->Start(false, false, player->GetGUID(), quest); @@ -1479,7 +1479,7 @@ public: totemOspirits = me->FindNearestCreature(ENTRY_TOTEM_OF_SPIRITS, RADIUS_TOTEM_OF_SPIRITS); if (totemOspirits) { - Summoned->setFaction(FACTION_ENRAGED_SOUL_FRIENDLY); + Summoned->SetFaction(FACTION_ENRAGED_SOUL_FRIENDLY); Summoned->GetMotionMaster()->MovePoint(0, totemOspirits->GetPositionX(), totemOspirits->GetPositionY(), Summoned->GetPositionZ()); if (Unit* owner = totemOspirits->GetOwner()) diff --git a/src/server/scripts/Outland/zone_shattrath_city.cpp b/src/server/scripts/Outland/zone_shattrath_city.cpp index 948a47fca33..c76e803c168 100644 --- a/src/server/scripts/Outland/zone_shattrath_city.cpp +++ b/src/server/scripts/Outland/zone_shattrath_city.cpp @@ -62,7 +62,7 @@ public: if (action == GOSSIP_ACTION_INFO_DEF+1) { CloseGossipMenuFor(player); - creature->setFaction(FACTION_OGRE_HOSTILE); + creature->SetFaction(FACTION_OGRE_HOSTILE); creature->AI()->Talk(SAY_RALIQ_ATTACK, player); creature->AI()->AttackStart(player); } @@ -152,7 +152,7 @@ public: if (action == GOSSIP_ACTION_INFO_DEF+1) { CloseGossipMenuFor(player); - creature->setFaction(FACTION_DEMON_HOSTILE); + creature->SetFaction(FACTION_DEMON_HOSTILE); creature->AI()->Talk(SAY_DEMONIC_AGGRO, player); creature->AI()->AttackStart(player); } diff --git a/src/server/scripts/Outland/zone_terokkar_forest.cpp b/src/server/scripts/Outland/zone_terokkar_forest.cpp index bf595557c49..d5521265fe4 100644 --- a/src/server/scripts/Outland/zone_terokkar_forest.cpp +++ b/src/server/scripts/Outland/zone_terokkar_forest.cpp @@ -86,7 +86,7 @@ public: { Initialize(); me->SetStandState(UNIT_STAND_STATE_STAND); - me->setFaction(FACTION_HOSTILE); + me->SetFaction(FACTION_HOSTILE); } void EnterCombat(Unit* /*who*/) override { } @@ -94,7 +94,7 @@ public: void DoNice() { Talk(SAY_SUBMIT); - me->setFaction(FACTION_FRIENDLY); + me->SetFaction(FACTION_FRIENDLY); me->SetStandState(UNIT_STAND_STATE_SIT); me->RemoveAllAuras(); me->DeleteThreatList(); @@ -338,7 +338,7 @@ public: if (action == GOSSIP_ACTION_INFO_DEF+1) { CloseGossipMenuFor(player); - creature->setFaction(FACTION_HOSTILE_FLOON); + creature->SetFaction(FACTION_HOSTILE_FLOON); creature->AI()->Talk(SAY_FLOON_ATTACK, player); creature->AI()->AttackStart(player); } @@ -364,7 +364,7 @@ public: npc_floonAI(Creature* creature) : ScriptedAI(creature) { Initialize(); - m_uiNormFaction = creature->getFaction(); + m_uiNormFaction = creature->GetFaction(); } void Initialize() @@ -382,8 +382,8 @@ public: void Reset() override { Initialize(); - if (me->getFaction() != m_uiNormFaction) - me->setFaction(m_uiNormFaction); + if (me->GetFaction() != m_uiNormFaction) + me->SetFaction(m_uiNormFaction); } void EnterCombat(Unit* /*who*/) override { } @@ -503,7 +503,7 @@ public: if (quest->GetQuestId() == ESCAPE_FROM_FIREWING_POINT_H || quest->GetQuestId() == ESCAPE_FROM_FIREWING_POINT_A) { ENSURE_AI(npc_escortAI, (creature->AI()))->Start(true, false, player->GetGUID()); - creature->setFaction(FACTION_ESCORTEE); + creature->SetFaction(FACTION_ESCORTEE); } return true; } @@ -643,9 +643,9 @@ public: pEscortAI->Start(false, false, player->GetGUID()); if (player->GetTeamId() == TEAM_ALLIANCE) - creature->setFaction(FACTION_ESCORT_A_NEUTRAL_PASSIVE); + creature->SetFaction(FACTION_ESCORT_A_NEUTRAL_PASSIVE); else - creature->setFaction(FACTION_ESCORT_H_NEUTRAL_PASSIVE); + creature->SetFaction(FACTION_ESCORT_H_NEUTRAL_PASSIVE); } return true; } diff --git a/src/server/scripts/Outland/zone_zangarmarsh.cpp b/src/server/scripts/Outland/zone_zangarmarsh.cpp index a31d8e4fe33..d73acd789f9 100644 --- a/src/server/scripts/Outland/zone_zangarmarsh.cpp +++ b/src/server/scripts/Outland/zone_zangarmarsh.cpp @@ -168,7 +168,7 @@ public: { npc_cooshcooshAI(Creature* creature) : ScriptedAI(creature) { - m_uiNormFaction = creature->getFaction(); + m_uiNormFaction = creature->GetFaction(); Initialize(); } @@ -183,8 +183,8 @@ public: void Reset() override { Initialize(); - if (me->getFaction() != m_uiNormFaction) - me->setFaction(m_uiNormFaction); + if (me->GetFaction() != m_uiNormFaction) + me->SetFaction(m_uiNormFaction); } void EnterCombat(Unit* /*who*/) override { } @@ -224,7 +224,7 @@ public: if (action == GOSSIP_ACTION_INFO_DEF) { CloseGossipMenuFor(player); - creature->setFaction(FACTION_HOSTILE_CO); + creature->SetFaction(FACTION_HOSTILE_CO); creature->AI()->AttackStart(player); } return true; diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index eb800765b7c..85fb71cccec 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -3704,7 +3704,7 @@ class spell_gen_gm_freeze : public SpellScriptLoader if (Player* player = GetTarget()->ToPlayer()) { // stop combat + make player unattackable + duel stop + stop some spells - player->setFaction(35); + player->SetFaction(35); player->CombatStop(); if (player->IsNonMeleeSpellCast(true)) player->InterruptNonMeleeSpells(true); diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index c0e1fdaae33..8e63c84fe2a 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -256,7 +256,7 @@ public: if (Spell) creature->CastSpell(player, Spell, false); else - TC_LOG_ERROR("scripts", "go_ethereum_prison summoned Creature (entry %u) but faction (%u) are not expected by script.", creature->GetEntry(), creature->getFaction()); + TC_LOG_ERROR("scripts", "go_ethereum_prison summoned Creature (entry %u) but faction (%u) are not expected by script.", creature->GetEntry(), creature->GetFaction()); } } } diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index a5d11011ea1..7c367705d36 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -285,7 +285,7 @@ public: void Reset() override { Initialize(); - me->setFaction(FACTION_CHICKEN); + me->SetFaction(FACTION_CHICKEN); me->RemoveNpcFlag(UNIT_NPC_FLAG_QUESTGIVER); } @@ -317,7 +317,7 @@ public: if (player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_NONE && rand32() % 30 == 1) { me->AddNpcFlag(UNIT_NPC_FLAG_QUESTGIVER); - me->setFaction(FACTION_FRIENDLY); + me->SetFaction(FACTION_FRIENDLY); Talk(player->GetTeam() == HORDE ? EMOTE_HELLO_H : EMOTE_HELLO_A); } break; @@ -325,7 +325,7 @@ public: if (player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_COMPLETE) { me->AddNpcFlag(UNIT_NPC_FLAG_QUESTGIVER); - me->setFaction(FACTION_FRIENDLY); + me->SetFaction(FACTION_FRIENDLY); Talk(EMOTE_CLUCK_TEXT); } break; -- cgit v1.2.3 From 1929ca3aa14f6cd83ea3ac9d7e8c0e2ed0e87a26 Mon Sep 17 00:00:00 2001 From: ariel- Date: Fri, 28 Apr 2017 17:58:39 -0300 Subject: Core/Scripts: remove OnDummyEffect hook/sOnDummyEffect ai hook - Duplicated logic never used, sometimes only ScriptMgr version was called, sometimes only AI - They only encourage bad scripting practices - You can still use OnSpellHit or a SpellScript (cherry picked from commit b6b59f6c239bc0259c92c28bf43bbb50573330b5) --- src/server/game/AI/CoreAI/UnitAI.h | 1 - src/server/game/AI/SmartScripts/SmartAI.cpp | 6 ----- src/server/game/AI/SmartScripts/SmartAI.h | 1 - src/server/game/AI/SmartScripts/SmartScript.cpp | 7 ------ src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 9 -------- src/server/game/AI/SmartScripts/SmartScriptMgr.h | 4 ++-- src/server/game/Scripting/ScriptMgr.cpp | 27 ---------------------- src/server/game/Scripting/ScriptMgr.h | 12 ---------- src/server/game/Spells/Auras/SpellAuraEffects.cpp | 7 +----- src/server/game/Spells/SpellEffects.cpp | 9 -------- 10 files changed, 3 insertions(+), 80 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 9ffee6c146c..73dc7afc2ec 100644 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -279,7 +279,6 @@ class TC_GAME_API UnitAI virtual void sQuestAccept(Player* /*player*/, Quest const* /*quest*/) { } virtual void sQuestSelect(Player* /*player*/, Quest const* /*quest*/) { } virtual void sQuestReward(Player* /*player*/, Quest const* /*quest*/, uint32 /*opt*/) { } - virtual bool sOnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/) { return false; } virtual void sOnGameEvent(bool /*start*/, uint16 /*eventId*/) { } private: diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 2621a91d8ee..1d4c2150585 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -830,12 +830,6 @@ void SmartAI::sQuestReward(Player* player, Quest const* quest, uint32 opt) GetScript()->ProcessEventsFor(SMART_EVENT_REWARD_QUEST, player, quest->GetQuestId(), opt); } -bool SmartAI::sOnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex) -{ - GetScript()->ProcessEventsFor(SMART_EVENT_DUMMY_EFFECT, caster, spellId, (uint32)effIndex); - return true; -} - void SmartAI::SetCombatMove(bool on) { if (mCanCombatMove == on) diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index 02cb4529a38..cce8ffd57ad 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -182,7 +182,6 @@ class TC_GAME_API SmartAI : public CreatureAI void sQuestAccept(Player* player, Quest const* quest) override; //void sQuestSelect(Player* player, Quest const* quest) override; void sQuestReward(Player* player, Quest const* quest, uint32 opt) override; - bool sOnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex) override; void sOnGameEvent(bool start, uint16 eventId) override; uint32 mEscortQuestID; diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 8b34e84cddb..abf80f95794 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -3831,13 +3831,6 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui ProcessAction(e, unit, var0, var1); break; } - case SMART_EVENT_DUMMY_EFFECT: - { - if (e.event.dummy.spell != var0 || e.event.dummy.effIndex != var1) - return; - ProcessAction(e, unit, var0, var1); - break; - } case SMART_EVENT_GAME_EVENT_START: case SMART_EVENT_GAME_EVENT_END: { diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 9faaab903e6..42f0a4b4f2c 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -857,15 +857,6 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) if (!IsTextValid(e, e.event.textOver.textGroupID)) return false; break; - case SMART_EVENT_DUMMY_EFFECT: - { - if (!IsSpellValid(e, e.event.dummy.spell)) - return false; - - if (e.event.dummy.effIndex > EFFECT_2) - return false; - break; - } case SMART_EVENT_IS_BEHIND_TARGET: { if (!IsMinMaxValid(e, e.event.behindTarget.cooldownMin, e.event.behindTarget.cooldownMax)) diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 1ff452f4182..392cdc7cc22 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -177,7 +177,7 @@ enum SMART_EVENT SMART_EVENT_JUST_CREATED = 63, // none SMART_EVENT_GOSSIP_HELLO = 64, // noReportUse (for GOs) SMART_EVENT_FOLLOW_COMPLETED = 65, // none - SMART_EVENT_DUMMY_EFFECT = 66, // spellId, effectIndex + // 66 unused SMART_EVENT_IS_BEHIND_TARGET = 67, // cooldownMin, CooldownMax SMART_EVENT_GAME_EVENT_START = 68, // game_event.Entry SMART_EVENT_GAME_EVENT_END = 69, // game_event.Entry @@ -1492,7 +1492,7 @@ const uint32 SmartAIEventMask[SMART_EVENT_END][2] = {SMART_EVENT_JUST_CREATED, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT }, {SMART_EVENT_GOSSIP_HELLO, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT }, {SMART_EVENT_FOLLOW_COMPLETED, SMART_SCRIPT_TYPE_MASK_CREATURE }, - {SMART_EVENT_DUMMY_EFFECT, SMART_SCRIPT_TYPE_MASK_SPELL }, + {66, 0 }, // unused {SMART_EVENT_IS_BEHIND_TARGET, SMART_SCRIPT_TYPE_MASK_CREATURE }, {SMART_EVENT_GAME_EVENT_START, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT }, {SMART_EVENT_GAME_EVENT_END, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT }, diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index e9596c4fdd3..fea767fa9a5 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -1637,15 +1637,6 @@ InstanceScript* ScriptMgr::CreateInstanceData(InstanceMap* map) return tmpscript->GetInstanceScript(map); } -bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Item* target) -{ - ASSERT(caster); - ASSERT(target); - - GET_SCRIPT_RET(ItemScript, target->GetScriptId(), tmpscript, false); - return tmpscript->OnDummyEffect(caster, spellId, effIndex, target); -} - bool ScriptMgr::OnQuestAccept(Player* player, Item* item, Quest const* quest) { ASSERT(player); @@ -1695,15 +1686,6 @@ bool ScriptMgr::OnCastItemCombatSpell(Player* player, Unit* victim, SpellInfo co return tmpscript->OnCastItemCombatSpell(player, victim, spellInfo, item); } -bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Creature* target) -{ - ASSERT(caster); - ASSERT(target); - - GET_SCRIPT_RET(CreatureScript, target->GetScriptId(), tmpscript, false); - return tmpscript->OnDummyEffect(caster, spellId, effIndex, target); -} - bool ScriptMgr::OnGossipHello(Player* player, Creature* creature) { ASSERT(player); @@ -1920,15 +1902,6 @@ void ScriptMgr::OnGameObjectUpdate(GameObject* go, uint32 diff) tmpscript->OnUpdate(go, diff); } -bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, GameObject* target) -{ - ASSERT(caster); - ASSERT(target); - - GET_SCRIPT_RET(GameObjectScript, target->GetScriptId(), tmpscript, false); - return tmpscript->OnDummyEffect(caster, spellId, effIndex, target); -} - bool ScriptMgr::OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger, bool entered) { ASSERT(player); diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 53465b1dca2..518cc5f4a70 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -374,9 +374,6 @@ class TC_GAME_API ItemScript : public ScriptObject public: - // Called when a dummy spell effect is triggered on the item. - virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, Item* /*target*/) { return false; } - // Called when a player accepts a quest from the item. virtual bool OnQuestAccept(Player* /*player*/, Item* /*item*/, Quest const* /*quest*/) { return false; } @@ -424,9 +421,6 @@ class TC_GAME_API CreatureScript : public UnitScript, public UpdatableScriptToCreature(); - if (!c || !caster || !sScriptMgr->OnDummyEffect(caster, GetId(), SpellEffIndex(GetEffIndex()), target->ToCreature()) || - !c->AI()->sOnDummyEffect(caster, GetId(), SpellEffIndex(GetEffIndex()))) - TC_LOG_DEBUG("spells", "AuraEffect::HandlePeriodicTriggerSpellAuraTick: Spell %u has non-existent spell %u in EffectTriggered[%d] and is therefor not triggered.", GetId(), triggerSpellId, GetEffIndex()); - } + TC_LOG_DEBUG("spells", "AuraEffect::HandlePeriodicTriggerSpellAuraTick: Spell %u has non-existent spell %u in EffectTriggered[%d] and is therefor not triggered.", GetId(), triggerSpellId, GetEffIndex()); } void AuraEffect::HandlePeriodicTriggerSpellWithValueAuraTick(Unit* target, Unit* caster) const diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index a533517c6f6..7deab6b85e6 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -616,15 +616,6 @@ void Spell::EffectDummy(SpellEffIndex effIndex) // normal DB scripted effect TC_LOG_DEBUG("spells", "Spell ScriptStart spellid %u in EffectDummy(%u)", m_spellInfo->Id, effIndex); m_caster->GetMap()->ScriptsStart(sSpellScripts, uint32(m_spellInfo->Id | (effIndex << 24)), m_caster, unitTarget); - - // Script based implementation. Must be used only for not good for implementation in core spell effects - // So called only for not proccessed cases - if (gameObjTarget) - sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, gameObjTarget); - else if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT) - sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, unitTarget->ToCreature()); - else if (itemTarget) - sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, itemTarget); } void Spell::EffectTriggerSpell(SpellEffIndex /*effIndex*/) -- cgit v1.2.3 From 4f6d38fe9d5c07e6e8eb88e517af71b6cdc4f9f8 Mon Sep 17 00:00:00 2001 From: ariel- Date: Fri, 28 Apr 2017 18:11:23 -0300 Subject: Core/Entities: moved PetAura handling to Player where it belongs (cherry picked from commit 231ec8331b2ba3cded9f0d67c77c949cd45f5a60) --- src/server/game/Entities/Pet/Pet.cpp | 4 ++-- src/server/game/Entities/Pet/Pet.h | 1 + src/server/game/Entities/Player/Player.cpp | 14 ++++++++++++++ src/server/game/Entities/Player/Player.h | 6 ++++++ src/server/game/Entities/Unit/Unit.cpp | 20 -------------------- src/server/game/Entities/Unit/Unit.h | 7 ------- src/server/game/Spells/Auras/SpellAuraEffects.cpp | 8 ++++---- src/server/game/Spells/SpellEffects.cpp | 9 ++++++--- 8 files changed, 33 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 56f2d4447df..8852af1be8c 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -1676,7 +1676,7 @@ void Pet::CastPetAuras(bool current) if (!IsPermanentPetFor(owner)) return; - for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();) + for (auto itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();) { PetAura const* pa = *itr; ++itr; @@ -1708,7 +1708,7 @@ bool Pet::IsPetAura(Aura const* aura) Player* owner = GetOwner(); // if the owner has that pet aura, return true - for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end(); ++itr) + for (auto itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end(); ++itr) { if ((*itr)->GetAura(GetEntry()) == aura->GetId()) return true; diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index 2e17b976be6..09a6e0a8afe 100644 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -40,6 +40,7 @@ typedef std::unordered_map PetSpellMap; typedef std::vector AutoSpellList; class Player; +class PetAura; class TC_GAME_API Pet : public Guardian { diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 87f03539599..3dd310f4b52 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -21834,6 +21834,20 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) } } +void Player::AddPetAura(PetAura const* petSpell) +{ + m_petAuras.insert(petSpell); + if (Pet* pet = GetPet()) + pet->CastPetAura(petSpell); +} + +void Player::RemovePetAura(PetAura const* petSpell) +{ + m_petAuras.erase(petSpell); + if (Pet* pet = GetPet()) + pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry())); +} + void Player::StopCastingCharm() { Unit* charm = GetCharm(); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 297c90fc5d9..dafedb22e77 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -78,6 +78,7 @@ class Item; class LootStore; class OutdoorPvP; class Pet; +class PetAura; class PlayerAI; class PlayerAchievementMgr; class PlayerMenu; @@ -1097,6 +1098,11 @@ class TC_GAME_API Player : public Unit, public GridObject Pet* SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime); void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false); + // pet auras + std::unordered_set m_petAuras; + void AddPetAura(PetAura const* petSpell); + void RemovePetAura(PetAura const* petSpell); + /// Handles said message in regular chat based on declared language and in config pre-defined Range. void Say(std::string const& text, Language language, WorldObject const* = nullptr) override; void Say(uint32 textId, WorldObject const* target = nullptr) override; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 84e6cb9ea16..ad69398d494 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -11162,26 +11162,6 @@ void Unit::SetContestedPvP(Player* attackedPlayer) } } -void Unit::AddPetAura(PetAura const* petSpell) -{ - if (GetTypeId() != TYPEID_PLAYER) - return; - - m_petAuras.insert(petSpell); - if (Pet* pet = ToPlayer()->GetPet()) - pet->CastPetAura(petSpell); -} - -void Unit::RemovePetAura(PetAura const* petSpell) -{ - if (GetTypeId() != TYPEID_PLAYER) - return; - - m_petAuras.erase(petSpell); - if (Pet* pet = ToPlayer()->GetPet()) - pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry())); -} - Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id) { if (GetTypeId() != TYPEID_PLAYER) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 1df51077ae4..48ab77e3856 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -200,7 +200,6 @@ class Item; class Minion; class MotionMaster; class Pet; -class PetAura; class Spell; class SpellCastTargets; class SpellEffectInfo; @@ -1929,12 +1928,6 @@ class TC_GAME_API Unit : public WorldObject bool CanProc() const { return !m_procDeep; } void SetCantProc(bool apply); - // pet auras - typedef std::set PetAuraSet; - PetAuraSet m_petAuras; - void AddPetAura(PetAura const* petSpell); - void RemovePetAura(PetAura const* petSpell); - uint32 GetModelForForm(ShapeshiftForm form, uint32 spellId) const; // Redirect Threat diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index f8e98d186eb..9281d012f55 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -4485,15 +4485,15 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool Unit* caster = GetCaster(); - if (mode & AURA_EFFECT_HANDLE_REAL) + // pet auras + if (target->GetTypeId() == TYPEID_PLAYER && (mode & AURA_EFFECT_HANDLE_REAL)) { - // pet auras if (PetAura const* petSpell = sSpellMgr->GetPetAura(GetId(), m_effIndex)) { if (apply) - target->AddPetAura(petSpell); + target->ToPlayer()->AddPetAura(petSpell); else - target->RemovePetAura(petSpell); + target->ToPlayer()->RemovePetAura(petSpell); } } diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 7deab6b85e6..53e9c98b0db 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -607,10 +607,13 @@ void Spell::EffectDummy(SpellEffIndex effIndex) } // pet auras - if (PetAura const* petSpell = sSpellMgr->GetPetAura(m_spellInfo->Id, effIndex)) + if (m_caster->GetTypeId() == TYPEID_PLAYER) { - m_caster->AddPetAura(petSpell); - return; + if (PetAura const* petSpell = sSpellMgr->GetPetAura(m_spellInfo->Id, effIndex)) + { + m_caster->ToPlayer()->AddPetAura(petSpell); + return; + } } // normal DB scripted effect -- cgit v1.2.3 From 08635c740a7ee04da9b0cd5045075a9432121b06 Mon Sep 17 00:00:00 2001 From: Keader Date: Fri, 7 Apr 2017 17:41:43 -0300 Subject: Core/Spells: Fixed Chilled to the Bone Closes #19417 thanks ariel- (cherry picked from commit 164af391c9662732dfc9cfe677c48bd3f927c2be) --- src/server/game/Spells/SpellMgr.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index b1d52d1906e..eb2621954cf 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3450,6 +3450,13 @@ void SpellMgr::LoadSpellInfoCorrections() spellInfo->Speed = 0.0f; // This spell's summon happens instantly }); + // Chilled to the Bone + ApplySpellFix({ 70106 }, [](SpellInfo* spellInfo) + { + spellInfo->AttributesEx3 |= SPELL_ATTR3_NO_DONE_BONUS; + spellInfo->AttributesEx6 |= SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS; + }); + // Ice Lock ApplySpellFix({ 71614 }, [](SpellInfo* spellInfo) { -- cgit v1.2.3 From 05ba662d5daaa3428cc01cdaa3794bf5a073ef17 Mon Sep 17 00:00:00 2001 From: ariel- Date: Sat, 22 Apr 2017 06:45:03 -0300 Subject: Core/Spell: implement pvp trinket immunity against Judgement of Justice By Riztazz, closes #19484 (cherry picked from commit 25a449a90e01d7100d482c156fffa3ac2e7730d2) --- src/server/game/Spells/SpellInfo.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index bec8a653fee..b9f26ed4e08 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -3384,11 +3384,14 @@ void SpellInfo::_LoadImmunityInfo() { switch (Id) { + case 42292: // PvP trinket + case 59752: // Every Man for Himself + mechanicImmunityMask |= IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; + immuneInfo.AuraTypeImmune.insert(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED); + break; case 34471: // The Beast Within case 19574: // Bestial Wrath - case 42292: // PvP trinket case 46227: // Medallion of Immunity - case 59752: // Every Man for Himself case 53490: // Bullheaded case 65547: // PvP Trinket case 134946: // Supremacy of the Alliance -- cgit v1.2.3