diff options
-rw-r--r-- | sql/FULL/world_spell_full.sql | 10 | ||||
-rw-r--r-- | sql/updates/5448_world_scripts_ulduar.sql | 13 | ||||
-rw-r--r-- | src/bindings/scripts/include/sc_creature.cpp | 29 | ||||
-rw-r--r-- | src/bindings/scripts/include/sc_creature.h | 3 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp | 56 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp | 8 | ||||
-rw-r--r-- | src/game/Creature.cpp | 18 | ||||
-rw-r--r-- | src/game/CreatureAI.cpp | 59 | ||||
-rw-r--r-- | src/game/CreatureAI.h | 11 | ||||
-rw-r--r-- | src/game/CreatureAIImpl.h | 73 | ||||
-rw-r--r-- | src/game/ObjectMgr.cpp | 1 | ||||
-rw-r--r-- | src/game/PointMovementGenerator.cpp | 3 | ||||
-rw-r--r-- | src/game/Spell.cpp | 21 | ||||
-rw-r--r-- | src/game/SpellEffects.cpp | 18 | ||||
-rw-r--r-- | src/game/ThreatManager.cpp | 2 | ||||
-rw-r--r-- | src/game/Traveller.h | 12 | ||||
-rw-r--r-- | src/game/Unit.cpp | 17 | ||||
-rw-r--r-- | src/game/Vehicle.cpp | 44 | ||||
-rw-r--r-- | src/game/Vehicle.h | 7 |
19 files changed, 241 insertions, 164 deletions
diff --git a/sql/FULL/world_spell_full.sql b/sql/FULL/world_spell_full.sql index 22d04e6f37b..56886d85191 100644 --- a/sql/FULL/world_spell_full.sql +++ b/sql/FULL/world_spell_full.sql @@ -2161,7 +2161,8 @@ INSERT INTO `spell_script_target` (`entry`, `type`, `targetEntry`) VALUES -- ULDUAR -- -------- INSERT INTO creature_template (entry, vehicleid) VALUES -(32930, 312), # Kologarn +(32930, 338), # Kologarn +(32934, 380), # Right Arm (33113, 340), # Flame Leviathan (33114, 341), # Flame Leviathan Seat (33214, 348) # Mechanolift 304-A @@ -2192,12 +2193,14 @@ spell5 = VALUES(spell5), spell6 = VALUES(spell6), vehicleid = VALUES(vehicleid); -DELETE FROM `spell_script_target` WHERE `entry` IN (62427,62374,62399); +DELETE FROM `spell_script_target` WHERE `entry` IN (62427,62374,62399,62056,63985); INSERT INTO `spell_script_target` (`entry`, `type`, `targetEntry`) VALUES (62427, 1, 33109), # Load into Catapult (62374, 1, 33060), # Pursued (62374, 1, 33109), -(62399, 1, 33139); # Overload Circuit +(62399, 1, 33139), # Overload Circuit +(63985, 1, 32934), # Stone Grip +(62056, 1, 32934); DELETE FROM `spell_linked_spell` WHERE `spell_trigger` IN (-62475,62427); INSERT INTO `spell_linked_spell` (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES @@ -2213,6 +2216,7 @@ INSERT INTO `npc_spellclick_spells` (`npc_entry`, `spell_id`, `quest_start`, `qu update creature_template set spell1=62395, AIName = 'TurretAI', scriptname='' where entry = 33139; update creature_template set spell1=62402 where entry = 33142; update creature_template set ScriptName = 'boss_kologarn' where entry = 32930; +update creature_template set scriptname = "boss_flame_leviathan_safety_container" where entry = 33218; -- -------- diff --git a/sql/updates/5448_world_scripts_ulduar.sql b/sql/updates/5448_world_scripts_ulduar.sql new file mode 100644 index 00000000000..6402dc29043 --- /dev/null +++ b/sql/updates/5448_world_scripts_ulduar.sql @@ -0,0 +1,13 @@ +INSERT INTO creature_template (entry, vehicleid) VALUES +(32930, 338), # Kologarn +(32934, 380), # Right Arm +(33214, 348) # Mechanolift 304-A +ON DUPLICATE KEY UPDATE +vehicleid = VALUES(vehicleid); + +DELETE FROM `spell_script_target` WHERE `entry` IN (62056,63985); +INSERT INTO `spell_script_target` (`entry`, `type`, `targetEntry`) VALUES +(63985, 1, 32934), # Stone Grip +(62056, 1, 32934); + +update creature_template set scriptname = "boss_flame_leviathan_safety_container" where entry = 33218; diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index fe644b85a60..1320fdb4776 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -70,12 +70,13 @@ void SummonList::DespawnAll() else { erase(begin()); - summon->SetVisibility(VISIBILITY_OFF); - if(summon->isSummon() && !summon->isPet()) + if(summon->isSummon()) + { + summon->DestroyForNearbyPlayers(); CAST_SUM(summon)->UnSummon(); + } else - summon->setDeathState(JUST_DIED); - summon->RemoveCorpse(); + summon->DisappearAndDie(); } } } @@ -163,26 +164,6 @@ Creature* ScriptedAI::DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, return m_creature->SummonCreature(uiId, m_creature->GetPositionX()+fX, m_creature->GetPositionY()+fY, m_creature->GetPositionZ()+fZ, fAngle, (TempSummonType)uiType, uiDespawntime); } -Creature *ScriptedAI::DoSummon(uint32 uiEntry, const float fPos[4], uint32 uiDespawntime, TempSummonType uiType) -{ - return me->SummonCreature(uiEntry, fPos[0], fPos[1], fPos[2], fPos[3], uiType, uiDespawntime); -} - -Creature *ScriptedAI::DoSummon(uint32 uiEntry, WorldObject* pGo, float fRadius, uint32 uiDespawntime, TempSummonType uiType) -{ - float fX, fY, fZ; - pGo->GetGroundPointAroundUnit(fX, fY, fZ, fRadius * rand_norm(), rand_norm()*2*M_PI); - return me->SummonCreature(uiEntry, fX, fY, fZ, me->GetOrientation(), uiType, uiDespawntime); -} - -Creature *ScriptedAI::DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float _fZ, float fRadius, uint32 uiDespawntime, TempSummonType uiType) -{ - float fX, fY, fZ; - obj->GetGroundPointAroundUnit(fX, fY, fZ, fRadius * rand_norm(), rand_norm()*2*M_PI); - return me->SummonCreature(uiEntry, fX, fY, fZ + _fZ, me->GetOrientation(), uiType, uiDespawntime); -} - - Unit* ScriptedAI::SelectUnit(SelectAggroTarget target, uint32 uiPosition) { //ThreatList m_threatlist; diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h index c4066a95598..91073bf4032 100644 --- a/src/bindings/scripts/include/sc_creature.h +++ b/src/bindings/scripts/include/sc_creature.h @@ -151,9 +151,6 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI //Spawns a creature relative to m_creature Creature* DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime); - Creature *DoSummon(uint32 uiEntry, const float fPos[4], uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); - Creature *DoSummon(uint32 uiEntry, WorldObject *obj, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); - Creature *DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float fZ, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); //Selects a unit from the creature's current aggro list Unit* SelectUnit(SelectAggroTarget target, uint32 uiPosition); diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp index 71746299d9b..98238022d36 100644 --- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp +++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp @@ -111,24 +111,6 @@ struct TRINITY_DLL_DECL boss_flame_leviathanAI : public BossAI vehicle->InstallAllAccessories(); } - void JustSummoned(Creature *summon) - { - if(summon->GetEntry() == MOB_MECHANOLIFT) - { - summons.Summon(summon); - } - } - - void SummonedCreatureDespawn(Creature *summon) - { - if(summon->GetEntry() == MOB_MECHANOLIFT) - { - summons.Despawn(summon); - //if(Creature* container = DoSummon(MOB_CONTAINER, summon, 0, 0)) - // container->GetMotionMaster()->MovePoint(1, container->GetPositionX(), container->GetPositionY(), me->GetPositionZ()); - } - } - void UpdateAI(const uint32 diff) { if (!me->isInCombat()) @@ -174,7 +156,7 @@ struct TRINITY_DLL_DECL boss_flame_leviathanAI : public BossAI events.RepeatEvent(15000); return; case EVENT_SUMMON: - if(summons.size() < 10) + if(summons.size() < 15) // 4seat+1turret+10lift if(Creature *lift = DoSummonFlyer(MOB_MECHANOLIFT, me, rand()%20 + 20, 50, 0)) lift->GetMotionMaster()->MoveRandom(100); events.RepeatEvent(2000); @@ -296,6 +278,32 @@ struct TRINITY_DLL_DECL boss_flame_leviathan_overload_deviceAI : public PassiveA } }; +struct TRINITY_DLL_DECL boss_flame_leviathan_safety_containerAI : public PassiveAI +{ + boss_flame_leviathan_safety_containerAI(Creature *c) : PassiveAI(c) {} + + void MovementInform(uint32 type, uint32 id) + { + if(id == me->GetEntry()) + { + if(Creature *liquid = DoSummon(MOB_LIQUID, me, 0)) + liquid->CastSpell(liquid, 62494, true); + me->DisappearAndDie(); // this will relocate creature to sky + } + } + + void UpdateAI(const uint32 diff) + { + if(!me->GetVehicle() && me->isSummon() && me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE) + { + //me->AddUnitMovementFlag(MOVEMENTFLAG_FALLING); + me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + me->SendMovementFlagUpdate(); + me->GetMotionMaster()->MovePoint(me->GetEntry(), me->GetPositionX(), me->GetPositionY(), 409.8f); + } + } +}; + struct TRINITY_DLL_DECL spell_pool_of_tarAI : public TriggerAI { spell_pool_of_tarAI(Creature *c) : TriggerAI(c) @@ -335,6 +343,11 @@ CreatureAI* GetAI_boss_flame_leviathan_overload_device(Creature* pCreature) return new boss_flame_leviathan_overload_deviceAI (pCreature); } +CreatureAI* GetAI_boss_flame_leviathan_safety_containerAI(Creature* pCreature) +{ + return new boss_flame_leviathan_safety_containerAI(pCreature); +} + CreatureAI* GetAI_spell_pool_of_tar(Creature* pCreature) { return new spell_pool_of_tarAI (pCreature); @@ -364,6 +377,11 @@ void AddSC_boss_flame_leviathan() newscript->RegisterSelf(); newscript = new Script; + newscript->Name="boss_flame_leviathan_safety_container"; + newscript->GetAI = &GetAI_boss_flame_leviathan_safety_containerAI; + newscript->RegisterSelf(); + + newscript = new Script; newscript->Name="spell_pool_of_tar"; newscript->GetAI = &GetAI_spell_pool_of_tar; newscript->RegisterSelf(); diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp index 775456e875e..b17682a9104 100644 --- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp +++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp @@ -35,12 +35,7 @@ struct TRINITY_DLL_DECL boss_kologarnAI : public BossAI leftArm(NULL), rightArm(NULL) { assert(vehicle); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); - } - - void Reset() - { - _Reset(); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } @@ -58,6 +53,7 @@ struct TRINITY_DLL_DECL boss_kologarnAI : public BossAI leftArm = apply ? CAST_CRE(who) : NULL; else if(who->GetEntry() == 32934) rightArm = apply ? CAST_CRE(who) : NULL; + who->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } void UpdateAI(const uint32 diff) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 6b018a6254f..e5f99c5f871 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -46,6 +46,7 @@ #include "OutdoorPvPMgr.h" #include "GameEventMgr.h" #include "CreatureGroups.h" +#include "Vehicle.h" // apply implementation of the singletons #include "Policies/SingletonImp.h" @@ -169,7 +170,7 @@ Creature::~Creature() } //if(m_uint32Values) - // sLog.outDetail("Deconstruct Creature Entry = %u", GetEntry()); + // sLog.outError("Deconstruct Creature Entry = %u", GetEntry()); } void Creature::AddToWorld() @@ -183,6 +184,8 @@ void Creature::AddToWorld() Unit::AddToWorld(); SearchFormationAndPath(); AIM_Initialize(); + if(IsVehicle()) + GetVehicleKit()->Install(); } } @@ -201,11 +204,12 @@ void Creature::RemoveFromWorld() void Creature::DisappearAndDie() { - //DestroyForNearbyPlayers(); - SetVisibility(VISIBILITY_OFF); - ObjectAccessor::UpdateObjectVisibility(this); + DestroyForNearbyPlayers(); + //SetVisibility(VISIBILITY_OFF); + //ObjectAccessor::UpdateObjectVisibility(this); if(isAlive()) setDeathState(JUST_DIED); + RemoveCorpse(); } void Creature::SearchFormationAndPath() @@ -1804,6 +1808,8 @@ void Creature::setDeathState(DeathState s) ResetPlayerDamageReq(); CreatureInfo const *cinfo = GetCreatureInfo(); AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + if(GetCreatureInfo()->InhabitType & INHABIT_AIR) + AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE + MOVEMENTFLAG_FLYING); SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag); clearUnitState(UNIT_STAT_ALL_STATE); SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool)); @@ -1811,6 +1817,7 @@ void Creature::setDeathState(DeathState s) Motion_Initialize(); if(GetCreatureData() && GetPhaseMask() != GetCreatureData()->phaseMask) SetPhaseMask(GetCreatureData()->phaseMask, false); + if(m_vehicleKit) m_vehicleKit->Reset(); Unit::setDeathState(ALIVE); } } @@ -1827,7 +1834,10 @@ bool Creature::FallGround() if (fabs(ground_Z - z) < 0.1f) return false; + SetFlying(false); RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + SendMovementFlagUpdate(); + //AddUnitMovementFlag(MOVEMENTFLAG_FALLING); GetMotionMaster()->MovePoint(EVENT_FALL_GROUND, x, y, ground_Z); Unit::setDeathState(DEAD_FALLING); return true; diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 20acf216c82..53d9286fba7 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -125,42 +125,6 @@ void CreatureAI::SelectNearestTarget(Unit *who) } } -void CreatureAI::SetGazeOn(Unit *target) -{ - if(me->canAttack(target)) - { - AttackStart(target); - me->SetReactState(REACT_PASSIVE); - } -} - -bool CreatureAI::UpdateVictimWithGaze() -{ - if(!me->isInCombat()) - return false; - - if(me->HasReactState(REACT_PASSIVE)) - { - if(me->getVictim()) - return true; - else - me->SetReactState(REACT_AGGRESSIVE); - } - - if(Unit *victim = me->SelectVictim()) - AttackStart(victim); - return me->getVictim(); -} - -bool CreatureAI::UpdateVictim() -{ - if(!me->isInCombat()) - return false; - if(Unit *victim = me->SelectVictim()) - AttackStart(victim); - return me->getVictim(); -} - bool CreatureAI::UpdateCombatState() { if(!me->isInCombat()) @@ -181,26 +145,13 @@ bool CreatureAI::UpdateCombatState() return true; } -bool CreatureAI::_EnterEvadeMode() -{ - if(me->IsInEvadeMode() || !me->isAlive()) - return false; - - me->RemoveAllAuras(); - me->DeleteThreatList(); - me->CombatStop(true); - me->LoadCreaturesAddon(); - me->SetLootRecipient(NULL); - me->ResetPlayerDamageReq(); - - return true; -} - void CreatureAI::EnterEvadeMode() { if(!_EnterEvadeMode()) return; + sLog.outDebug("Creature %u enters evade mode.", me->GetEntry()); + if(!me->GetVehicle()) // otherwise me will be in evade mode forever { if(Unit *owner = me->GetCharmerOrOwner()) @@ -212,10 +163,10 @@ void CreatureAI::EnterEvadeMode() me->GetMotionMaster()->MoveTargetedHome(); } - if(me->IsVehicle()) - me->GetVehicleKit()->InstallAllAccessories(); - Reset(); + + if(me->IsVehicle()) // use the same sequence of addtoworld, aireset may remove all summons! + me->GetVehicleKit()->Reset(); } /*void CreatureAI::AttackedBy( Unit* attacker ) diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index 5a5a7528bf0..7a3fb9137c2 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -75,6 +75,13 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI bool UpdateCombatState(); void SelectNearestTarget(Unit *who); + + void SetGazeOn(Unit *target); + + Creature *DoSummon(uint32 uiEntry, const Position fPos, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); + Creature *DoSummon(uint32 uiEntry, WorldObject *obj, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); + Creature *DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float fZ, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); + public: explicit CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c), m_creature(c) {} @@ -151,15 +158,13 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI //virtual bool IsVisible(Unit *) const { return false; } // Called when victim entered water and creature can not enter water - virtual bool canReachByRangeAttack(Unit*) { return false; } + //virtual bool canReachByRangeAttack(Unit*) { return false; } ///== Fields ======================================= // Pointer to controlled by AI creature //Creature* const m_creature; - void SetGazeOn(Unit *target); - virtual void PassengerBoarded(Unit *who, int8 seatId, bool apply) {} protected: diff --git a/src/game/CreatureAIImpl.h b/src/game/CreatureAIImpl.h index bcedd108d44..ef3ea285b1f 100644 --- a/src/game/CreatureAIImpl.h +++ b/src/game/CreatureAIImpl.h @@ -20,6 +20,8 @@ #include "Common.h" #include "Platform/Define.h" +#include "Creature.h" +#include "CreatureAI.h" #define HEROIC(n,h) (HeroicMode ? h : n) @@ -257,5 +259,76 @@ struct AISpellInfoType TRINITY_DLL_SPEC AISpellInfoType * GetAISpellInfo(uint32 i); + +inline void CreatureAI::SetGazeOn(Unit *target) +{ + if(me->canAttack(target)) + { + AttackStart(target); + me->SetReactState(REACT_PASSIVE); + } +} + +inline bool CreatureAI::UpdateVictimWithGaze() +{ + if(!me->isInCombat()) + return false; + + if(me->HasReactState(REACT_PASSIVE)) + { + if(me->getVictim()) + return true; + else + me->SetReactState(REACT_AGGRESSIVE); + } + + if(Unit *victim = me->SelectVictim()) + AttackStart(victim); + return me->getVictim(); +} + +inline bool CreatureAI::UpdateVictim() +{ + if(!me->isInCombat()) + return false; + if(Unit *victim = me->SelectVictim()) + AttackStart(victim); + return me->getVictim(); +} + +inline bool CreatureAI::_EnterEvadeMode() +{ + if(me->IsInEvadeMode() || !me->isAlive()) + return false; + + me->RemoveAllAuras(); + me->DeleteThreatList(); + me->CombatStop(true); + me->LoadCreaturesAddon(); + me->SetLootRecipient(NULL); + me->ResetPlayerDamageReq(); + + return true; +} + +inline Creature *CreatureAI::DoSummon(uint32 uiEntry, const Position fPos, uint32 uiDespawntime, TempSummonType uiType) +{ + return me->SummonCreature(uiEntry, fPos[0], fPos[1], fPos[2], fPos[3], uiType, uiDespawntime); +} + +inline Creature *CreatureAI::DoSummon(uint32 uiEntry, WorldObject* pGo, float fRadius, uint32 uiDespawntime, TempSummonType uiType) +{ + float fX, fY, fZ; + pGo->GetGroundPointAroundUnit(fX, fY, fZ, fRadius * rand_norm(), rand_norm()*2*M_PI); + return me->SummonCreature(uiEntry, fX, fY, fZ, me->GetOrientation(), uiType, uiDespawntime); +} + +inline Creature *CreatureAI::DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float _fZ, float fRadius, uint32 uiDespawntime, TempSummonType uiType) +{ + float fX, fY, fZ; + obj->GetGroundPointAroundUnit(fX, fY, fZ, fRadius * rand_norm(), rand_norm()*2*M_PI); + return me->SummonCreature(uiEntry, fX, fY, fZ + _fZ, me->GetOrientation(), uiType, uiDespawntime); +} + #endif diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 7b97db2eac4..885a8c843f7 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1033,6 +1033,7 @@ uint32 ObjectMgr::ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const case 28511: // Eye of Acherus case 33114: // Flame Leviathan Seat (model 24914 chair) case 33167: // Salvaged Demolisher Mechanic Seat + case 33189: // Liquid Pryite return cinfo->DisplayID_A[0]; case 33218: // Pyrite Safety Container return cinfo->DisplayID_A[1]; diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index ac5a4568480..a24178ccb99 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -80,7 +80,10 @@ void PointMovementGenerator<T>::MovementInform(T &unit) template <> void PointMovementGenerator<Creature>::MovementInform(Creature &unit) { if(id == EVENT_FALL_GROUND) + { unit.setDeathState(JUST_DIED); + unit.SetFlying(true); + } unit.AI()->MovementInform(POINT_MOTION_TYPE, id); } diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index e2adba9043a..5ead8c6fe92 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -6600,7 +6600,9 @@ float tangent(float x) if(x >= 100000.0f) return 100000.0f; if(x <= 100000.0f) return -100000.0f; return 0.0f; -} +} + +#define DEBUG_TRAJ(a) //a void Spell::SelectTrajTargets() { @@ -6623,24 +6625,25 @@ void Spell::SelectTrajTargets() float b = tangent(m_targets.m_elevation); float a = (dz - dist2d * b) / (dist2d * dist2d); if(a > -0.0001f) a = 0; - //sLog.outError("Spell::SelectTrajTargets: a %f b %f", a, b); + DEBUG_TRAJ(sLog.outError("Spell::SelectTrajTargets: a %f b %f", a, b);) float bestDist; UnitList::const_iterator itr = unitList.begin(); for(; itr != unitList.end(); ++itr) { - if(m_caster == *itr || m_caster->IsOnVehicle(*itr) || (*itr)->IsOnVehicle(m_caster)) + if(m_caster == *itr || m_caster->IsOnVehicle(*itr) || (*itr)->GetVehicle())//(*itr)->IsOnVehicle(m_caster)) continue; const float size = std::max((*itr)->GetObjectSize() * 0.7f, 1.0f); // 1/sqrt(3) - const float objDist2d = m_caster->GetExactDistance2d((*itr)->GetPositionX(), (*itr)->GetPositionY()) * cos(m_caster->GetRelativeAngle(*itr)); - const float dz = (*itr)->GetPositionZ() - m_caster->GetPositionZ(); + // TODO: all calculation should be based on src instead of m_caster + const float objDist2d = (*itr)->GetExactDistance2d(m_targets.m_srcX, m_targets.m_srcY) * cos(m_caster->GetRelativeAngle(*itr)); + const float dz = (*itr)->GetPositionZ() - m_targets.m_srcZ; - //sLog.outError("Spell::SelectTrajTargets: check %u, dist between %f %f, height between %f %f.", (*itr)->GetEntry(), objDist2d - size, objDist2d + size, dz - size, dz + size); + DEBUG_TRAJ(sLog.outError("Spell::SelectTrajTargets: check %u, dist between %f %f, height between %f %f.", (*itr)->GetEntry(), objDist2d - size, objDist2d + size, dz - size, dz + size);) float dist = objDist2d - size; float height = dist * (a * dist + b); - //sLog.outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height); + DEBUG_TRAJ(sLog.outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);) if(height < dz + size && height > dz - size) { bestDist = dist > 0 ? dist : 0; @@ -6648,6 +6651,7 @@ void Spell::SelectTrajTargets() } #define CHECK_DIST {\ + DEBUG_TRAJ(sLog.outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)\ if(dist < objDist2d + size && dist > objDist2d - size)\ { bestDist = dist; break; }\ } @@ -6698,9 +6702,11 @@ void Spell::SelectTrajTargets() float x = m_targets.m_srcX + cos(m_caster->GetOrientation()) * bestDist; float y = m_targets.m_srcY + sin(m_caster->GetOrientation()) * bestDist; float z = m_targets.m_srcZ + bestDist * (a * bestDist + b); + float distSq = (*itr)->GetExactDistSq(x, y, z); float sizeSq = (*itr)->GetObjectSize(); sizeSq *= sizeSq; + DEBUG_TRAJ(sLog.outError("Initial %f %f %f %f %f", x, y, z, distSq, sizeSq);) if(distSq > sizeSq) { float factor = 1 - sqrt(sizeSq / distSq); @@ -6709,6 +6715,7 @@ void Spell::SelectTrajTargets() z += factor * ((*itr)->GetPositionZ() - z); distSq = (*itr)->GetExactDistSq(x, y, z); + DEBUG_TRAJ(sLog.outError("Initial %f %f %f %f %f", x, y, z, distSq, sizeSq);) } m_targets.setDestination(x, y, z); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 433a677e019..1bf992f366d 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -5295,11 +5295,23 @@ void Spell::EffectScriptEffect(uint32 effIndex) return; } case 62428: // Load into Catapult - if(Unit *demolisher = m_caster->GetVehicleBase()) - if(Vehicle *seat = m_caster->GetVehicleKit()) - if(Unit *passenger = seat->GetPassenger(0)) + if(Vehicle *seat = m_caster->GetVehicleKit()) + if(Unit *passenger = seat->GetPassenger(0)) + if(Unit *demolisher = m_caster->GetVehicleBase()) passenger->CastSpell(demolisher, damage, true); return; + case 62482: // Grab Crate + if(unitTarget) + { + if(Vehicle *seat = m_caster->GetVehicleKit()) + { + if(Creature *oldContainer = dynamic_cast<Creature*>(seat->GetPassenger(1))) + oldContainer->DisappearAndDie(); + unitTarget->CastSpell(seat->GetBase(), 62473, true); + unitTarget->EnterVehicle(seat, 1); + } + } + return; case 60123: // Lightwell { if (m_caster->GetTypeId() != TYPEID_UNIT || !((Creature*)m_caster)->isSummon()) diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp index 001778d7b66..11e4f2ab61e 100644 --- a/src/game/ThreatManager.cpp +++ b/src/game/ThreatManager.cpp @@ -136,7 +136,7 @@ void HostilReference::updateOnlineStatus() online = getTarget()->isInAccessiblePlaceFor(creature); if(!online) { - if(creature->AI()->canReachByRangeAttack(getTarget())) + if(creature->IsWithinCombatRange(getTarget(), creature->m_CombatDistance)) online = true; // not accessible but stays online } else diff --git a/src/game/Traveller.h b/src/game/Traveller.h index e68aa3d6a32..279af30428a 100644 --- a/src/game/Traveller.h +++ b/src/game/Traveller.h @@ -98,10 +98,10 @@ inline float Traveller<Creature>::GetMoveDestinationTo(float x, float y, float z float dy = y - GetPositionY(); float dz = z - GetPositionZ(); - if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING)) + //if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING)) return sqrt((dx*dx) + (dy*dy) + (dz*dz)); - else //Walking on the ground - return sqrt((dx*dx) + (dy*dy)); + //else //Walking on the ground + // return sqrt((dx*dx) + (dy*dy)); } @@ -131,10 +131,10 @@ inline float Traveller<Player>::GetMoveDestinationTo(float x, float y, float z) float dy = y - GetPositionY(); float dz = z - GetPositionZ(); - if (i_traveller.isInFlight()) + //if (i_traveller.isInFlight()) return sqrt((dx*dx) + (dy*dy) + (dz*dz)); - else //Walking on the ground - return sqrt((dx*dx) + (dy*dy)); + //else //Walking on the ground + // return sqrt((dx*dx) + (dy*dy)); } template<> diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 4b18db2c0a1..d6170c323d9 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -11149,7 +11149,6 @@ void Unit::setDeathState(DeathState s) if (m_deathState != ALIVE && s == ALIVE) { //_ApplyAllAuraMods(); - if(m_vehicleKit) m_vehicleKit->Reset(); // Reset display id on resurection - needed by corpse explosion to cleanup after display change SetDisplayId(GetNativeDisplayId()); } @@ -12164,8 +12163,6 @@ void Unit::AddToWorld() assert(m_NotifyListPos < 0); //instance : crash //m_NotifyListPos = -1; SetToNotify(); - if(IsVehicle()) - GetVehicleKit()->Install(); } } @@ -14642,7 +14639,17 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ) { - if(GetTypeId() == TYPEID_UNIT) + Player *player = NULL; + if(GetTypeId() == TYPEID_PLAYER) + player = (Player*)this; + else + { + player = dynamic_cast<Player*>(GetCharmer()); + if(player && player->m_mover != this) + player = NULL; + } + + if(!player) { GetMotionMaster()->MoveKnockbackFrom(x, y, speedXY, speedZ); } @@ -14659,7 +14666,7 @@ void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ) data << float(speedXY); // Horizontal speed data << float(-speedZ); // Z Movement speed (vertical) - ((Player*)this)->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); } } diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp index d666f0f76f9..a81c6bb6629 100644 --- a/src/game/Vehicle.cpp +++ b/src/game/Vehicle.cpp @@ -81,7 +81,7 @@ void Vehicle::InstallAllAccessories() switch(me->GetEntry()) { //case 27850:InstallAccessory(27905,1);break; - case 28782:InstallAccessory(28768,0);break; // Acherus Deathcharger + case 28782:InstallAccessory(28768,0,false);break; // Acherus Deathcharger case 28312:InstallAccessory(28319,7);break; case 32627:InstallAccessory(32629,7);break; case 32930: @@ -101,28 +101,33 @@ void Vehicle::InstallAllAccessories() InstallAccessory(33143,2); // Overload Control Device InstallAccessory(33142,1); // Leviathan Defense Turret break; - case 33214:InstallAccessory(33218,1);break; + case 33214:InstallAccessory(33218,1,false);break; // Mechanolift 304-A } } void Vehicle::Uninstall() { + sLog.outDebug("Vehicle::Uninstall %u", me->GetEntry()); + for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr) + if(Unit *passenger = itr->second.passenger) + if(passenger->HasUnitTypeMask(UNIT_MASK_ACCESSORY)) + ((TempSummon*)passenger)->UnSummon(); RemoveAllPassengers(); } void Vehicle::Die() { + sLog.outDebug("Vehicle::Die %u", me->GetEntry()); for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr) - { if(Unit *passenger = itr->second.passenger) if(passenger->HasUnitTypeMask(UNIT_MASK_ACCESSORY)) passenger->setDeathState(JUST_DIED); - } RemoveAllPassengers(); } void Vehicle::Reset() { + sLog.outDebug("Vehicle::Reset"); InstallAllAccessories(); if(m_usableSeatNum) me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); @@ -130,6 +135,7 @@ void Vehicle::Reset() void Vehicle::RemoveAllPassengers() { + sLog.outDebug("Vehicle::RemoveAllPassengers"); for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr) if(Unit *passenger = itr->second.passenger) { @@ -185,7 +191,7 @@ int8 Vehicle::GetNextEmptySeat(int8 seatId, bool next) const return seat->first; } -void Vehicle::InstallAccessory(uint32 entry, int8 seatId) +void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion) { if(Unit *passenger = GetPassenger(seatId)) { @@ -200,13 +206,15 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId) passenger->ExitVehicle(); // this should not happen } - Creature *accessory = me->SummonCreature(entry, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000); - if(!accessory) - return; - accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY); - accessory->EnterVehicle(this, seatId); - // This is not good, we have to send update twice - accessory->SendMovementFlagUpdate(); + //TODO: accessory should be minion + if(Creature *accessory = me->SummonCreature(entry, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000)) + { + if(minion) + accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY); + accessory->EnterVehicle(this, seatId); + // This is not good, we have to send update twice + accessory->SendMovementFlagUpdate(); + } } bool Vehicle::AddPassenger(Unit *unit, int8 seatId) @@ -324,16 +332,8 @@ void Vehicle::RemovePassenger(Unit *unit) void Vehicle::Dismiss() { - for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr) - { - if(Unit *passenger = itr->second.passenger) - if(passenger->GetTypeId() == TYPEID_UNIT && ((Creature*)passenger)->IsVehicle()) - { - passenger->ExitVehicle(); - passenger->GetVehicleKit()->Dismiss(); - } - } - RemoveAllPassengers(); + sLog.outDebug("Vehicle::Dismiss %u", me->GetEntry()); + Uninstall(); me->SendObjectDeSpawnAnim(me->GetGUID()); me->CombatStop(); me->AddObjectToRemoveList(); diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h index 3a600625c7b..3c1bd3508f5 100644 --- a/src/game/Vehicle.h +++ b/src/game/Vehicle.h @@ -42,10 +42,11 @@ class TRINITY_DLL_SPEC Vehicle void Install(); void Uninstall(); - void Reset(); void Die(); + void InstallAllAccessories(); + Unit *GetBase() const { return me; } VehicleEntry const *GetVehicleInfo() { return m_vehicleInfo; } bool HasEmptySeat(int8 seatId) const; @@ -54,17 +55,15 @@ class TRINITY_DLL_SPEC Vehicle bool AddPassenger(Unit *passenger, int8 seatId = -1); void RemovePassenger(Unit *passenger); void RemoveAllPassengers(); - void InstallAllAccessories(); void Dismiss(); SeatMap m_Seats; - Unit *GetBase() const { return me; } protected: Unit *me; VehicleEntry const *m_vehicleInfo; uint32 m_usableSeatNum; - void InstallAccessory(uint32 entry, int8 seatId); + void InstallAccessory(uint32 entry, int8 seatId, bool minion = true); }; #endif |