From 2317af8dd3faac12b583978e14e47fd90ade4520 Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Sun, 9 Sep 2012 03:59:34 +0200 Subject: [PATCH 01/10] Core/Spells: Convert Gift of the Naaru in spell script Closes #6545 --- ...2012_09_09_02_world_spell_script_names.sql | 10 ++++ .../2012_09_09_03_world_spell_bonus_data.sql | 9 ++++ src/server/game/Entities/Unit/Unit.cpp | 10 ---- src/server/scripts/Spells/spell_generic.cpp | 53 +++++++++++++++++++ 4 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 sql/updates/world/2012_09_09_02_world_spell_script_names.sql create mode 100644 sql/updates/world/2012_09_09_03_world_spell_bonus_data.sql diff --git a/sql/updates/world/2012_09_09_02_world_spell_script_names.sql b/sql/updates/world/2012_09_09_02_world_spell_script_names.sql new file mode 100644 index 0000000000..9c2beee82a --- /dev/null +++ b/sql/updates/world/2012_09_09_02_world_spell_script_names.sql @@ -0,0 +1,10 @@ +-- Gabe der Naaru +DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_gift_of_naaru'; +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(28880,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_WARRIOR +(59542,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_PALADIN +(59543,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_HUNTER +(59544,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_PRIEST +(59545,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_DEATHKNIGHT +(59547,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_SHAMAN +(59548,'spell_gen_gift_of_naaru'); -- SPELLFAMILY_MAGE diff --git a/sql/updates/world/2012_09_09_03_world_spell_bonus_data.sql b/sql/updates/world/2012_09_09_03_world_spell_bonus_data.sql new file mode 100644 index 0000000000..340bb8e28b --- /dev/null +++ b/sql/updates/world/2012_09_09_03_world_spell_bonus_data.sql @@ -0,0 +1,9 @@ +DELETE FROM `spell_bonus_data` WHERE `entry` IN (28880,59542,59543,59544,59545,59547,59548) +INSERT INTO `spell_bonus_data` (`entry`,`direct_bonus`,`dot_bonus`,`ap_bonus`,`ap_dot_bonus`,`comments`) VALUES +(28880,0,0,0,0,'Warrior - Gabe der Naaru'), +(59542,0,0,0,0,'Paladin - Gabe der Naaru'), +(59543,0,0,0,0,'Hunter - Gabe der Naaru'), +(59544,0,0,0,0,'Priest - Gabe der Naaru'), +(59545,0,0,0,0,'Deathknight - Gabe der Naaru'), +(59547,0,0,0,0,'Shaman - Gabe der Naaru'), +(59548,0,0,0,0,'Mage - Gabe der Naaru'); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 737d75cdf1..52e282157b 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -11263,16 +11263,6 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod); } - // Gift of the Naaru - if (spellProto->SpellFamilyFlags[2] & 0x80000000 && spellProto->SpellIconID == 329) - { - int32 apBonus = int32(std::max(GetTotalAttackPowerValue(BASE_ATTACK), GetTotalAttackPowerValue(RANGED_ATTACK))); - if (apBonus > DoneAdvertisedBenefit) - DoneTotal += int32(apBonus * 0.22f); // 22% of AP per tick - else - DoneTotal += int32(DoneAdvertisedBenefit * 0.377f); // 37.7% of BH per tick - } - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { switch (spellProto->Effects[i].ApplyAuraName) diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index ed4148cd03..0a947afaa2 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -3250,6 +3250,58 @@ class spell_gen_bonked : public SpellScriptLoader } }; +class spell_gen_gift_of_naaru : public SpellScriptLoader +{ + public: + spell_gen_gift_of_naaru() : SpellScriptLoader("spell_gen_gift_of_naaru") { } + + class spell_gen_gift_of_naaru_AuraScript : public AuraScript + { + PrepareAuraScript(spell_gen_gift_of_naaru_AuraScript); + + void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) + { + if (!GetCaster()) + return; + + float heal = 0.0f; + switch (GetSpellInfo()->SpellFamilyName) + { + case SPELLFAMILY_MAGE: + case SPELLFAMILY_WARLOCK: + case SPELLFAMILY_PRIEST: + heal = 1.885f * float(GetCaster()->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask())); + break; + case SPELLFAMILY_PALADIN: + case SPELLFAMILY_SHAMAN: + heal = std::max(1.885f * float(GetCaster()->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask())), 1.1f * float(GetCaster()->GetTotalAttackPowerValue(BASE_ATTACK))); + break; + case SPELLFAMILY_WARRIOR: + case SPELLFAMILY_HUNTER: + case SPELLFAMILY_DEATHKNIGHT: + heal = 1.1f * float(std::max(GetCaster()->GetTotalAttackPowerValue(BASE_ATTACK), GetCaster()->GetTotalAttackPowerValue(RANGED_ATTACK))); + break; + case SPELLFAMILY_GENERIC: + default: + break; + } + + int32 healTick = floor(heal / aurEff->GetTotalTicks()); + amount += int32(std::max(heal, 0.0f)); + } + + void Register() + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_gift_of_naaru_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_PERIODIC_HEAL); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_gen_gift_of_naaru_AuraScript(); + } +}; + void AddSC_generic_spell_scripts() { new spell_gen_absorb0_hitlimit1(); @@ -3325,4 +3377,5 @@ void AddSC_generic_spell_scripts() new spell_gen_mount("spell_x53_touring_rocket", 0, 0, 0, SPELL_X53_TOURING_ROCKET_150, SPELL_X53_TOURING_ROCKET_280, SPELL_X53_TOURING_ROCKET_310); new spell_gen_upper_deck_create_foam_sword(); new spell_gen_bonked(); + new spell_gen_gift_of_naaru(); } From 3d360e116cb3fa2a6e1ec21666e9148c318bd91f Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Sun, 9 Sep 2012 04:12:08 +0200 Subject: [PATCH 02/10] SQL: Fix sql fails :-/ --- .../2012_09_09_02_world_spell_script_names.sql | 2 +- .../2012_09_09_03_world_spell_bonus_data.sql | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sql/updates/world/2012_09_09_02_world_spell_script_names.sql b/sql/updates/world/2012_09_09_02_world_spell_script_names.sql index 9c2beee82a..36e5b08c36 100644 --- a/sql/updates/world/2012_09_09_02_world_spell_script_names.sql +++ b/sql/updates/world/2012_09_09_02_world_spell_script_names.sql @@ -1,4 +1,4 @@ --- Gabe der Naaru +-- Gift of the Naaru DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_gift_of_naaru'; INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES (28880,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_WARRIOR diff --git a/sql/updates/world/2012_09_09_03_world_spell_bonus_data.sql b/sql/updates/world/2012_09_09_03_world_spell_bonus_data.sql index 340bb8e28b..a08c494da1 100644 --- a/sql/updates/world/2012_09_09_03_world_spell_bonus_data.sql +++ b/sql/updates/world/2012_09_09_03_world_spell_bonus_data.sql @@ -1,9 +1,9 @@ -DELETE FROM `spell_bonus_data` WHERE `entry` IN (28880,59542,59543,59544,59545,59547,59548) +DELETE FROM `spell_bonus_data` WHERE `entry` IN (28880,59542,59543,59544,59545,59547,59548); INSERT INTO `spell_bonus_data` (`entry`,`direct_bonus`,`dot_bonus`,`ap_bonus`,`ap_dot_bonus`,`comments`) VALUES -(28880,0,0,0,0,'Warrior - Gabe der Naaru'), -(59542,0,0,0,0,'Paladin - Gabe der Naaru'), -(59543,0,0,0,0,'Hunter - Gabe der Naaru'), -(59544,0,0,0,0,'Priest - Gabe der Naaru'), -(59545,0,0,0,0,'Deathknight - Gabe der Naaru'), -(59547,0,0,0,0,'Shaman - Gabe der Naaru'), -(59548,0,0,0,0,'Mage - Gabe der Naaru'); +(28880,0,0,0,0,'Warrior - Gift of the Naaru'), +(59542,0,0,0,0,'Paladin - Gift of the Naaru'), +(59543,0,0,0,0,'Hunter - Gift of the Naaru'), +(59544,0,0,0,0,'Priest - Gift of the Naaru'), +(59545,0,0,0,0,'Deathknight - Gift of the Naaru'), +(59547,0,0,0,0,'Shaman - Gift of the Naaru'), +(59548,0,0,0,0,'Mage - Gift of the Naaru'); From 637894da1ae8186eeb921f3b8f7ce959d4965eec Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Sun, 9 Sep 2012 04:19:17 +0200 Subject: [PATCH 03/10] Core/Spells: Fix typo (I need sleep) --- src/server/scripts/Spells/spell_generic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 0a947afaa2..d10d7725e2 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -3287,7 +3287,7 @@ class spell_gen_gift_of_naaru : public SpellScriptLoader } int32 healTick = floor(heal / aurEff->GetTotalTicks()); - amount += int32(std::max(heal, 0.0f)); + amount += int32(std::max(healTick, 0)); } void Register() From 8541167ff22ad4644b0d7fe0e026f25ae0573887 Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Sun, 9 Sep 2012 04:27:06 +0200 Subject: [PATCH 04/10] DB/Quests: Fix OfferRewardText for quest "Warsong Supplies" Closes #7279 --- sql/updates/world/2012_09_09_04_world_quest_template.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 sql/updates/world/2012_09_09_04_world_quest_template.sql diff --git a/sql/updates/world/2012_09_09_04_world_quest_template.sql b/sql/updates/world/2012_09_09_04_world_quest_template.sql new file mode 100644 index 0000000000..418c5badb3 --- /dev/null +++ b/sql/updates/world/2012_09_09_04_world_quest_template.sql @@ -0,0 +1 @@ +UPDATE `quest_template` SET `OfferRewardText`='Excellent, $N. You''ve saved me a lot of work!$b$bBut don''t think that I''m not grateful!' WHERE `Id`=6571; From 6677908382dde7fac1a6a6ea9793c2270ab95bc3 Mon Sep 17 00:00:00 2001 From: Subv Date: Sun, 9 Sep 2012 07:44:17 -0500 Subject: [PATCH 05/10] Core/Achievements: Change ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE behavior Allow it to be used with value1 = 0 and value2 = 0 to only check if the target is a player. Fixes some startup errors. --- src/server/game/Achievements/AchievementMgr.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 037000133c..d06d0849ef 100755 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -128,12 +128,6 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria) } return true; case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE: - if (!classRace.class_id && !classRace.race_id) - { - sLog->outError(LOG_FILTER_SQL, "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE (%u) must not have 0 in either value field, ignored.", - criteria->ID, criteria->requiredType, dataType); - return false; - } if (classRace.class_id && ((1 << (classRace.class_id-1)) & CLASSMASK_ALL_PLAYABLE) == 0) { sLog->outError(LOG_FILTER_SQL, "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE (%u) has non-existing class in value1 (%u), ignored.", From e3775502801ba36568795937aa324f6185d8fe3c Mon Sep 17 00:00:00 2001 From: oMadMano <> Date: Sun, 9 Sep 2012 16:24:06 +0200 Subject: [PATCH 06/10] Scripts/Karazhan: Fix Prince Malchezaar Infernal start timer Closes #5700 --- .../scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index d5add0f0bb..f4195620dd 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -233,7 +233,7 @@ public: SWPainTimer = 20000; AmplifyDamageTimer = 5000; Cleave_Timer = 8000; - InfernalTimer = 45000; + InfernalTimer = 40000; InfernalCleanupTimer = 47000; AxesTargetSwitchTimer = urand(7500, 20000); SunderArmorTimer = urand(5000, 10000); From 53002dfe03012e5f725016da1ac882f9a80e55b6 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 9 Sep 2012 17:52:27 +0200 Subject: [PATCH 07/10] Core/Spells: Set UNIT_FIELD_CHANNEL_OBJECT also for spells that don't have explicit target unit but use NEARBY selection, fixes #7246 --- src/server/game/Spells/Spell.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 4d095e0f95..cdf17b0504 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4278,6 +4278,10 @@ void Spell::SendChannelUpdate(uint32 time) void Spell::SendChannelStart(uint32 duration) { uint64 channelTarget = m_targets.GetObjectTargetGUID(); + if (!channelTarget && !m_spellInfo->NeedsExplicitUnitTarget()) + if (m_UniqueTargetInfo.size() + m_UniqueGOTargetInfo.size() == 1) // this is for TARGET_SELECT_CATEGORY_NEARBY + if (!m_UniqueTargetInfo.empty()) + channelTarget = !m_UniqueTargetInfo.empty() ? m_UniqueTargetInfo.front().targetGUID : m_UniqueGOTargetInfo.front().targetGUID; WorldPacket data(MSG_CHANNEL_START, (8+4+4)); data.append(m_caster->GetPackGUID()); From 97a92036d153e1c47f3f35fa7ec713fb9b50e699 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 9 Sep 2012 19:22:30 +0200 Subject: [PATCH 08/10] Core/Spells: Fixed typo in previous commit --- src/server/game/Spells/Spell.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index cdf17b0504..fea299cf16 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4280,8 +4280,7 @@ void Spell::SendChannelStart(uint32 duration) uint64 channelTarget = m_targets.GetObjectTargetGUID(); if (!channelTarget && !m_spellInfo->NeedsExplicitUnitTarget()) if (m_UniqueTargetInfo.size() + m_UniqueGOTargetInfo.size() == 1) // this is for TARGET_SELECT_CATEGORY_NEARBY - if (!m_UniqueTargetInfo.empty()) - channelTarget = !m_UniqueTargetInfo.empty() ? m_UniqueTargetInfo.front().targetGUID : m_UniqueGOTargetInfo.front().targetGUID; + channelTarget = !m_UniqueTargetInfo.empty() ? m_UniqueTargetInfo.front().targetGUID : m_UniqueGOTargetInfo.front().targetGUID; WorldPacket data(MSG_CHANNEL_START, (8+4+4)); data.append(m_caster->GetPackGUID()); From 83817afd996af9eedadc366037cc73c83caa8fd0 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 9 Sep 2012 19:56:00 +0200 Subject: [PATCH 09/10] Core/Vehicles: Improved vehicle passenger position calculation (still not complete) --- .../game/Entities/Transport/Transport.cpp | 10 +++--- .../game/Entities/Transport/Transport.h | 8 ++++- src/server/game/Entities/Unit/Unit.cpp | 18 +++++------ src/server/game/Entities/Unit/Unit.h | 3 ++ src/server/game/Entities/Vehicle/Vehicle.cpp | 32 +++++++++++++++---- src/server/game/Entities/Vehicle/Vehicle.h | 8 ++++- .../game/Entities/Vehicle/VehicleDefines.h | 10 ++++++ .../game/Movement/Spline/MoveSplineInit.cpp | 12 ++----- 8 files changed, 68 insertions(+), 33 deletions(-) diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 88d3108dbe..558fdd72a9 100755 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -704,17 +704,15 @@ void Transport::UpdateNPCPositions() } } -//! This method transforms supplied transport offsets into global coordinates void Transport::CalculatePassengerPosition(float& x, float& y, float& z, float& o) { float inx = x, iny = y, inz = z, ino = o; o = GetOrientation() + ino; - x = GetPositionX() + (inx * cos(GetOrientation()) + iny * sin(GetOrientation() + M_PI)); - y = GetPositionY() + (iny * cos(GetOrientation()) + inx * sin(GetOrientation())); + x = GetPositionX() + inx * cos(GetOrientation()) - iny * sin(GetOrientation()); + y = GetPositionY() + iny * cos(GetOrientation()) + inx * sin(GetOrientation()); z = GetPositionZ() + inz; } -//! This method transforms supplied global coordinates into local offsets void Transport::CalculatePassengerOffset(float& x, float& y, float& z, float& o) { o -= GetOrientation(); @@ -722,6 +720,6 @@ void Transport::CalculatePassengerOffset(float& x, float& y, float& z, float& o) y -= GetPositionY(); // y = searchedY * cos(o) + searchedX * sin(o) x -= GetPositionX(); // x = searchedX * cos(o) + searchedY * sin(o + pi) float inx = x, iny = y; - y = (iny - inx * tan(GetOrientation())) / (cos(GetOrientation()) - sin(GetOrientation() + M_PI) * tan(GetOrientation())); - x = (inx - iny * sin(GetOrientation() + M_PI) / cos(GetOrientation())) / (cos(GetOrientation()) - tan(GetOrientation()) * sin(GetOrientation() + M_PI)); + y = (iny - inx * tan(GetOrientation())) / (cos(GetOrientation()) + sin(GetOrientation()) * tan(GetOrientation())); + x = (inx + iny * tan(GetOrientation())) / (cos(GetOrientation()) + sin(GetOrientation()) * tan(GetOrientation())); } diff --git a/src/server/game/Entities/Transport/Transport.h b/src/server/game/Entities/Transport/Transport.h index 4b0c42c907..8fd12b5069 100755 --- a/src/server/game/Entities/Transport/Transport.h +++ b/src/server/game/Entities/Transport/Transport.h @@ -20,12 +20,13 @@ #define TRANSPORTS_H #include "GameObject.h" +#include "VehicleDefines.h" #include #include #include -class Transport : public GameObject +class Transport : public GameObject, public TransportBase { public: Transport(uint32 period, uint32 script); @@ -47,8 +48,13 @@ class Transport : public GameObject uint32 AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, float z, float o, uint32 anim=0); void UpdatePosition(MovementInfo* mi); void UpdateNPCPositions(); + + /// This method transforms supplied transport offsets into global coordinates void CalculatePassengerPosition(float& x, float& y, float& z, float& o); + + /// This method transforms supplied global coordinates into local offsets void CalculatePassengerOffset(float& x, float& y, float& z, float& o); + void BuildStartMovePacket(Map const* targetMap); void BuildStopMovePacket(Map const* targetMap); uint32 GetScriptId() const { return ScriptId; } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 52e282157b..ffe45c63df 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -406,15 +406,8 @@ void Unit::UpdateSplineMovement(uint32 t_diff) pos.m_positionZ = loc.z; pos.m_orientation = loc.orientation; - if (Unit* vehicle = GetVehicleBase()) - { - loc.x += vehicle->GetPositionX(); - loc.y += vehicle->GetPositionY(); - loc.z += vehicle->GetPositionZMinusOffset(); - loc.orientation = vehicle->GetOrientation(); - } - else if (Transport* trans = GetTransport()) - trans->CalculatePassengerPosition(loc.x, loc.y, loc.z, loc.orientation); + if (TransportBase* transport = GetDirectTransport()) + transport->CalculatePassengerPosition(loc.x, loc.y, loc.z, loc.orientation); } UpdatePosition(loc.x, loc.y, loc.z, loc.orientation); @@ -16289,6 +16282,13 @@ uint64 Unit::GetTransGUID() const return 0; } +TransportBase* Unit::GetDirectTransport() const +{ + if (Vehicle* veh = GetVehicle()) + return veh; + return GetTransport(); +} + bool Unit::IsInPartyWith(Unit const* unit) const { if (this == unit) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 415d63a0c8..d0edd55040 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -339,6 +339,7 @@ class UnitAI; class Totem; class Transport; class Vehicle; +class TransportBase; typedef std::list UnitList; typedef std::list< std::pair > DispelChargesList; @@ -2169,6 +2170,8 @@ class Unit : public WorldObject uint32 GetTransTime() const { return m_movementInfo.t_time; } int8 GetTransSeat() const { return m_movementInfo.t_seat; } uint64 GetTransGUID() const; + /// Returns the transport this unit is on directly (if on vehicle and transport, return vehicle) + TransportBase* GetDirectTransport() const; bool m_ControlledByPlayer; diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 710821f2f2..f8eacf8f7c 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -441,19 +441,19 @@ void Vehicle::RelocatePassengers(float x, float y, float z, float ang) { ASSERT(_me->GetMap()); - // not sure that absolute position calculation is correct, it must depend on vehicle orientation and pitch angle + // not sure that absolute position calculation is correct, it must depend on vehicle pitch angle for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr) + { if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger)) { ASSERT(passenger->IsInWorld()); - float px = x + passenger->m_movementInfo.t_pos.m_positionX; - float py = y + passenger->m_movementInfo.t_pos.m_positionY; - float pz = z + passenger->m_movementInfo.t_pos.m_positionZ; - float po = ang + passenger->m_movementInfo.t_pos.m_orientation; - + float px, py, pz, po; + passenger->m_movementInfo.t_pos.GetPosition(px, py, pz, po); + CalculatePassengerPosition(px, py, pz, po); passenger->UpdatePosition(px, py, pz, po); } + } } void Vehicle::Dismiss() @@ -512,3 +512,23 @@ uint8 Vehicle::GetAvailableSeatCount() const return ret; } + +void Vehicle::CalculatePassengerPosition(float& x, float& y, float& z, float& o) +{ + float inx = x, iny = y, inz = z, ino = o; + o = GetBase()->GetOrientation() + ino; + x = GetBase()->GetPositionX() + inx * cos(GetBase()->GetOrientation()) - iny * sin(GetBase()->GetOrientation()); + y = GetBase()->GetPositionY() + iny * cos(GetBase()->GetOrientation()) + inx * sin(GetBase()->GetOrientation()); + z = GetBase()->GetPositionZ() + inz; +} + +void Vehicle::CalculatePassengerOffset(float& x, float& y, float& z, float& o) +{ + o -= GetBase()->GetOrientation(); + z -= GetBase()->GetPositionZ(); + y -= GetBase()->GetPositionY(); // y = searchedY * cos(o) + searchedX * sin(o) + x -= GetBase()->GetPositionX(); // x = searchedX * cos(o) + searchedY * sin(o + pi) + float inx = x, iny = y; + y = (iny - inx * tan(GetBase()->GetOrientation())) / (cos(GetBase()->GetOrientation()) + sin(GetBase()->GetOrientation()) * tan(GetBase()->GetOrientation())); + x = (inx + iny * tan(GetBase()->GetOrientation())) / (cos(GetBase()->GetOrientation()) + sin(GetBase()->GetOrientation()) * tan(GetBase()->GetOrientation())); +} diff --git a/src/server/game/Entities/Vehicle/Vehicle.h b/src/server/game/Entities/Vehicle/Vehicle.h index 95fc236425..e5d39e5339 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.h +++ b/src/server/game/Entities/Vehicle/Vehicle.h @@ -27,7 +27,7 @@ class Unit; typedef std::set GuidSet; -class Vehicle +class Vehicle : public TransportBase { public: explicit Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry); @@ -66,6 +66,12 @@ class Vehicle SeatMap::iterator GetSeatIteratorForPassenger(Unit* passenger); void InitMovementInfoForBase(); + /// This method transforms supplied transport offsets into global coordinates + void CalculatePassengerPosition(float& x, float& y, float& z, float& o); + + /// This method transforms supplied global coordinates into local offsets + void CalculatePassengerOffset(float& x, float& y, float& z, float& o); + Unit* _me; VehicleEntry const* _vehicleInfo; GuidSet vehiclePlayers; diff --git a/src/server/game/Entities/Vehicle/VehicleDefines.h b/src/server/game/Entities/Vehicle/VehicleDefines.h index df34a61d44..423497660b 100644 --- a/src/server/game/Entities/Vehicle/VehicleDefines.h +++ b/src/server/game/Entities/Vehicle/VehicleDefines.h @@ -75,4 +75,14 @@ typedef std::vector VehicleAccessoryList; typedef std::map VehicleAccessoryContainer; typedef std::map SeatMap; +class TransportBase +{ + public: + /// This method transforms supplied transport offsets into global coordinates + virtual void CalculatePassengerPosition(float& x, float& y, float& z, float& o) = 0; + + /// This method transforms supplied global coordinates into local offsets + virtual void CalculatePassengerOffset(float& x, float& y, float& z, float& o) = 0; +}; + #endif diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index 76215ec83c..fec629c332 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -160,17 +160,9 @@ namespace Movement { if (_transformForTransport) { - if (Unit* vehicle = _owner.GetVehicleBase()) - { - input.x -= vehicle->GetPositionX(); - input.y -= vehicle->GetPositionY(); - input.z -= vehicle->GetPositionZMinusOffset(); - } - else if (Transport* transport = _owner.GetTransport()) - { - float unused = 0.0f; + float unused = 0.0f; + if (TransportBase* transport = _owner.GetDirectTransport()) transport->CalculatePassengerOffset(input.x, input.y, input.z, unused); - } } return input; From 7a8652c06f71e430c3cff9667edcbb0335be7cc0 Mon Sep 17 00:00:00 2001 From: "e@cacaw.net" Date: Sun, 9 Sep 2012 23:41:36 +0100 Subject: [PATCH 10/10] Core/Players: Do not allow polearm to be equipped in the offhand. Signed-off-by: Nay Closes #7709 --- src/server/game/Entities/Player/Player.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index dc3fe6b0f0..3ad3eb0ddd 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -11531,7 +11531,11 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16 &dest, Item* pItem, bool if (eslot == EQUIPMENT_SLOT_OFFHAND) { - if (type == INVTYPE_WEAPON || type == INVTYPE_WEAPONOFFHAND) + // Do not allow polearm to be equipped in the offhand (rare case for the only 1h polearm 41750) + if (pProto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM) + return EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT; + + else if (type == INVTYPE_WEAPON || type == INVTYPE_WEAPONOFFHAND) { if (!CanDualWield()) return EQUIP_ERR_CANT_DUAL_WIELD;