Core/Vehicles: Make the vehicle system more aura driven. Get rid of redundant checks and update relevant data.
Closes #805
This commit is contained in:
1 parent
c2a2d7201b
commit
a9582964d3
14 files changed
+80
-79
No files matched your search
@@ -2553,10 +2553,6 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
|
||||
// Resist
|
||||
SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool CanReflect)
|
||||
{
|
||||
// Return evade for units in evade mode
|
||||
if (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->ToCreature()->IsInEvadeMode() && this != pVictim)
|
||||
return SPELL_MISS_EVADE;
|
||||
|
||||
// Check for immune
|
||||
if (pVictim->IsImmunedToSpell(spell))
|
||||
return SPELL_MISS_IMMUNE;
|
||||
@@ -2573,6 +2569,10 @@ SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool
|
||||
if (this == pVictim)
|
||||
return SPELL_MISS_NONE;
|
||||
|
||||
// Return evade for units in evade mode
|
||||
if (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->ToCreature()->IsInEvadeMode())
|
||||
return SPELL_MISS_EVADE;
|
||||
|
||||
// Try victim reflect spell
|
||||
if (CanReflect)
|
||||
{
|
||||
@@ -12347,7 +12347,6 @@ void Unit::setDeathState(DeathState s)
|
||||
UnsummonAllTotems();
|
||||
RemoveAllControlled();
|
||||
RemoveAllAurasOnDeath();
|
||||
ExitVehicle();
|
||||
}
|
||||
|
||||
if (s == JUST_DIED)
|
||||
@@ -16512,14 +16511,20 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
|
||||
}
|
||||
}
|
||||
|
||||
if (this->ToCreature())
|
||||
if (this->ToCreature() && this->ToCreature()->IsAIEnabled)
|
||||
this->ToCreature()->AI()->DoAction(EVENT_SPELLCLICK);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, AuraApplication const * aurApp)
|
||||
void Unit::EnterVehicle(Unit *base, int8 seatId)
|
||||
{
|
||||
CastCustomSpell(VEHICLE_SPELL_RIDE_HARDCODED, SPELLVALUE_BASE_POINT0, seatId+1, base, false);
|
||||
}
|
||||
|
||||
void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* aurApp)
|
||||
{
|
||||
// Must be called only from aura handler
|
||||
if (!isAlive() || GetVehicleKit() == vehicle || vehicle->GetBase()->IsOnVehicle(this))
|
||||
return;
|
||||
|
||||
@@ -16541,6 +16546,9 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, AuraApplication const * a
|
||||
}
|
||||
}
|
||||
|
||||
if (aurApp && aurApp->GetRemoveMode())
|
||||
return;
|
||||
|
||||
if (Player* plr = ToPlayer())
|
||||
{
|
||||
if (vehicle->GetBase()->GetTypeId() == TYPEID_PLAYER && plr->isInCombat())
|
||||
@@ -16557,11 +16565,6 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, AuraApplication const * a
|
||||
bg->EventPlayerDroppedFlag(plr);
|
||||
}
|
||||
|
||||
// vehicle is applied by aura, and aura effect remove handler was called during apply handler execution
|
||||
// prevent undefined behaviour
|
||||
if (aurApp && aurApp->GetRemoveMode())
|
||||
return;
|
||||
|
||||
if (Player* thisPlr = this->ToPlayer())
|
||||
{
|
||||
WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
|
||||
@@ -16598,6 +16601,7 @@ void Unit::ChangeSeat(int8 seatId, bool next)
|
||||
|
||||
void Unit::ExitVehicle(Position const* exitPosition)
|
||||
{
|
||||
// This function can be called at upper level code to initialize an exit from the passenger's side.
|
||||
if (!m_vehicle)
|
||||
return;
|
||||
|
||||
@@ -16612,6 +16616,11 @@ void Unit::ExitVehicle(Position const* exitPosition)
|
||||
}
|
||||
}
|
||||
|
||||
_ExitVehicle(exitPosition);
|
||||
}
|
||||
|
||||
void Unit::_ExitVehicle(Position const* exitPosition)
|
||||
{
|
||||
if (!m_vehicle)
|
||||
return;
|
||||
|
||||
@@ -16650,6 +16659,16 @@ void Unit::ExitVehicle(Position const* exitPosition)
|
||||
if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
|
||||
if (((Minion*)vehicle->GetBase())->GetOwner() == this)
|
||||
vehicle->Dismiss();
|
||||
|
||||
if (HasUnitTypeMask(UNIT_MASK_ACCESSORY))
|
||||
{
|
||||
// Vehicle just died, we die too
|
||||
if (vehicle->GetBase()->getDeathState() == JUST_DIED)
|
||||
setDeathState(JUST_DIED);
|
||||
// If for other reason we as minion are exiting the vehicle (ejected, master unmounted) - unsummon
|
||||
else
|
||||
ToTempSummon()->UnSummon();
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::BuildMovementPacket(ByteBuffer *data) const
|
||||
|
||||
Reference in new issue
Block a user