*Add virtual bool IsEscorted() to escort_ai.h
*Some minor cleanup and optimization --HG-- branch : trunk
This commit is contained in:
@@ -71,6 +71,7 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
|
|||||||
void SetEscortPaused(bool uPaused);
|
void SetEscortPaused(bool uPaused);
|
||||||
|
|
||||||
bool HasEscortState(uint32 uiEscortState) { return (m_uiEscortState & uiEscortState); }
|
bool HasEscortState(uint32 uiEscortState) { return (m_uiEscortState & uiEscortState); }
|
||||||
|
virtual bool IsEscorted() { return true; }
|
||||||
|
|
||||||
void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; }
|
void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; }
|
||||||
float GetMaxPlayerDistance() { return MaxPlayerDistance; }
|
float GetMaxPlayerDistance() { return MaxPlayerDistance; }
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
|
|||||||
|
|
||||||
// Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc)
|
// Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc)
|
||||||
//virtual void AttackedBy(Unit* attacker);
|
//virtual void AttackedBy(Unit* attacker);
|
||||||
virtual bool IsEscorted() {return false;}
|
virtual bool IsEscorted() { return false; }
|
||||||
|
|
||||||
// Called when creature is spawned or respawned (for reseting variables)
|
// Called when creature is spawned or respawned (for reseting variables)
|
||||||
virtual void JustRespawned() { Reset(); }
|
virtual void JustRespawned() { Reset(); }
|
||||||
|
|||||||
+2
-2
@@ -14944,9 +14944,9 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||||||
{
|
{
|
||||||
sLog.outError("Player (guidlow %d) was in BG in database, but BG was not found, and entry point was invalid! Teleport to default race/class locations.",guid);
|
sLog.outError("Player (guidlow %d) was in BG in database, but BG was not found, and entry point was invalid! Teleport to default race/class locations.",guid);
|
||||||
RelocateToHomebind();
|
RelocateToHomebind();
|
||||||
} else {
|
|
||||||
Relocate(&_loc);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Relocate(&_loc);
|
||||||
|
|
||||||
// We are not in BG anymore
|
// We are not in BG anymore
|
||||||
m_bgData.bgInstanceID = 0;
|
m_bgData.bgInstanceID = 0;
|
||||||
|
|||||||
+19
-22
@@ -5989,15 +5989,15 @@ void Spell::Delayed() // only called in DealDamage()
|
|||||||
|
|
||||||
void Spell::DelayedChannel()
|
void Spell::DelayedChannel()
|
||||||
{
|
{
|
||||||
if(!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER || getState() != SPELL_STATE_CASTING)
|
if (!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER || getState() != SPELL_STATE_CASTING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(isDelayableNoMore()) // Spells may only be delayed twice
|
if (isDelayableNoMore()) // Spells may only be delayed twice
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//check pushback reduce
|
//check pushback reduce
|
||||||
int32 delaytime = GetSpellDuration(m_spellInfo) * 25 / 100; // channeling delay is normally 25% of its time per hit
|
int32 delaytime = GetSpellDuration(m_spellInfo) * 25 / 100; // channeling delay is normally 25% of its time per hit
|
||||||
int32 delayReduce = 100; // must be initialized to 100 for percent modifiers
|
int32 delayReduce = 100; // must be initialized to 100 for percent modifiers
|
||||||
((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this);
|
((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this);
|
||||||
delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100;
|
delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100;
|
||||||
if(delayReduce >= 100)
|
if(delayReduce >= 100)
|
||||||
@@ -6005,7 +6005,7 @@ void Spell::DelayedChannel()
|
|||||||
|
|
||||||
delaytime = delaytime * (100 - delayReduce) / 100;
|
delaytime = delaytime * (100 - delayReduce) / 100;
|
||||||
|
|
||||||
if(int32(m_timer) < delaytime)
|
if(int32(m_timer) <= delaytime)
|
||||||
{
|
{
|
||||||
delaytime = m_timer;
|
delaytime = m_timer;
|
||||||
m_timer = 0;
|
m_timer = 0;
|
||||||
@@ -6016,16 +6016,9 @@ void Spell::DelayedChannel()
|
|||||||
sLog.outDebug("Spell %u partially interrupted for %i ms, new duration: %u ms", m_spellInfo->Id, delaytime, m_timer);
|
sLog.outDebug("Spell %u partially interrupted for %i ms, new duration: %u ms", m_spellInfo->Id, delaytime, m_timer);
|
||||||
|
|
||||||
for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
|
for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
|
||||||
{
|
|
||||||
if ((*ihit).missCondition == SPELL_MISS_NONE)
|
if ((*ihit).missCondition == SPELL_MISS_NONE)
|
||||||
{
|
if (Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID))
|
||||||
Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
|
|
||||||
if (unit)
|
|
||||||
{
|
|
||||||
unit->DelayAura(m_spellInfo->Id, m_caster->GetGUID(), delaytime);
|
unit->DelayAura(m_spellInfo->Id, m_caster->GetGUID(), delaytime);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// partially interrupt persistent area auras
|
// partially interrupt persistent area auras
|
||||||
if(DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id))
|
if(DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id))
|
||||||
@@ -6036,15 +6029,16 @@ void Spell::DelayedChannel()
|
|||||||
|
|
||||||
void Spell::UpdatePointers()
|
void Spell::UpdatePointers()
|
||||||
{
|
{
|
||||||
if(m_originalCasterGUID==m_caster->GetGUID())
|
if(m_originalCasterGUID == m_caster->GetGUID())
|
||||||
m_originalCaster = m_caster;
|
m_originalCaster = m_caster;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_originalCaster = ObjectAccessor::GetUnit(*m_caster,m_originalCasterGUID);
|
m_originalCaster = ObjectAccessor::GetUnit(*m_caster,m_originalCasterGUID);
|
||||||
if(m_originalCaster && !m_originalCaster->IsInWorld()) m_originalCaster = NULL;
|
if (m_originalCaster && !m_originalCaster->IsInWorld())
|
||||||
|
m_originalCaster = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_castItemGUID && m_caster->GetTypeId() == TYPEID_PLAYER)
|
if (m_castItemGUID && m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||||
m_CastItem = ((Player*)m_caster)->GetItemByGuid(m_castItemGUID);
|
m_CastItem = ((Player*)m_caster)->GetItemByGuid(m_castItemGUID);
|
||||||
|
|
||||||
m_targets.Update(m_caster);
|
m_targets.Update(m_caster);
|
||||||
@@ -6350,8 +6344,6 @@ bool SpellEvent::IsDeletable() const
|
|||||||
|
|
||||||
bool Spell::IsValidSingleTargetEffect(Unit const* target, Targets type) const
|
bool Spell::IsValidSingleTargetEffect(Unit const* target, Targets type) const
|
||||||
{
|
{
|
||||||
if (target->GetMapId() == MAPID_INVALID)
|
|
||||||
return false;
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case TARGET_UNIT_TARGET_ENEMY:
|
case TARGET_UNIT_TARGET_ENEMY:
|
||||||
@@ -6369,7 +6361,12 @@ bool Spell::IsValidSingleTargetEffect(Unit const* target, Targets type) const
|
|||||||
|
|
||||||
bool Spell::IsValidSingleTargetSpell(Unit const* target) const
|
bool Spell::IsValidSingleTargetSpell(Unit const* target) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; ++i)
|
if (target->GetMapId() == MAPID_INVALID)
|
||||||
|
{
|
||||||
|
sLog.outDebug("Spell::IsValidSingleTargetSpell - a spell was cast on '%s' (GUIDLow: %u), but they have an invalid map id!", target->GetName(), target->GetGUIDLow());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (uint8 i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
if(!IsValidSingleTargetEffect(target, Targets(m_spellInfo->EffectImplicitTargetA[i])))
|
if(!IsValidSingleTargetEffect(target, Targets(m_spellInfo->EffectImplicitTargetA[i])))
|
||||||
return false;
|
return false;
|
||||||
@@ -6383,9 +6380,9 @@ bool Spell::IsValidSingleTargetSpell(Unit const* target) const
|
|||||||
void Spell::CalculateDamageDoneForAllTargets()
|
void Spell::CalculateDamageDoneForAllTargets()
|
||||||
{
|
{
|
||||||
float multiplier[3];
|
float multiplier[3];
|
||||||
for (int i = 0; i < 3; ++i)
|
for (uint8 i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
if ( m_applyMultiplierMask & (1 << i) )
|
if (m_applyMultiplierMask & (1 << i))
|
||||||
{
|
{
|
||||||
// Get multiplier
|
// Get multiplier
|
||||||
multiplier[i] = m_spellInfo->DmgMultiplier[i];
|
multiplier[i] = m_spellInfo->DmgMultiplier[i];
|
||||||
@@ -6396,7 +6393,7 @@ void Spell::CalculateDamageDoneForAllTargets()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool usesAmmo=true;
|
bool usesAmmo = true;
|
||||||
Unit::AuraEffectList const& Auras = m_caster->GetAurasByType(SPELL_AURA_ABILITY_CONSUME_NO_AMMO);
|
Unit::AuraEffectList const& Auras = m_caster->GetAurasByType(SPELL_AURA_ABILITY_CONSUME_NO_AMMO);
|
||||||
for (Unit::AuraEffectList::const_iterator j = Auras.begin(); j != Auras.end(); ++j)
|
for (Unit::AuraEffectList::const_iterator j = Auras.begin(); j != Auras.end(); ++j)
|
||||||
{
|
{
|
||||||
@@ -6409,7 +6406,7 @@ void Spell::CalculateDamageDoneForAllTargets()
|
|||||||
TargetInfo &target = *ihit;
|
TargetInfo &target = *ihit;
|
||||||
|
|
||||||
uint32 mask = target.effectMask;
|
uint32 mask = target.effectMask;
|
||||||
if(!mask)
|
if (!mask)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Unit* unit = m_caster->GetGUID()==target.targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target.targetGUID);
|
Unit* unit = m_caster->GetGUID()==target.targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target.targetGUID);
|
||||||
|
|||||||
@@ -2354,11 +2354,11 @@ void Spell::EffectJump(uint32 i)
|
|||||||
|
|
||||||
void Spell::EffectTeleportUnits(uint32 i)
|
void Spell::EffectTeleportUnits(uint32 i)
|
||||||
{
|
{
|
||||||
if(!unitTarget || unitTarget->isInFlight())
|
if (!unitTarget || unitTarget->isInFlight())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If not exist data for dest location - return
|
// If not exist data for dest location - return
|
||||||
if(!m_targets.HasDst())
|
if (!m_targets.HasDst())
|
||||||
{
|
{
|
||||||
sLog.outError( "Spell::EffectTeleportUnits - does not have destination for spell ID %u\n", m_spellInfo->Id );
|
sLog.outError( "Spell::EffectTeleportUnits - does not have destination for spell ID %u\n", m_spellInfo->Id );
|
||||||
return;
|
return;
|
||||||
@@ -2366,7 +2366,8 @@ void Spell::EffectTeleportUnits(uint32 i)
|
|||||||
|
|
||||||
// Init dest coordinates
|
// Init dest coordinates
|
||||||
uint32 mapid = m_targets.m_dstPos.GetMapId();
|
uint32 mapid = m_targets.m_dstPos.GetMapId();
|
||||||
if(mapid == MAPID_INVALID) mapid = unitTarget->GetMapId();
|
if(mapid == MAPID_INVALID)
|
||||||
|
mapid = unitTarget->GetMapId();
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
m_targets.m_dstPos.GetPosition(x, y, z);
|
m_targets.m_dstPos.GetPosition(x, y, z);
|
||||||
float orientation = m_targets.getUnitTarget() ? m_targets.getUnitTarget()->GetOrientation() : unitTarget->GetOrientation();
|
float orientation = m_targets.getUnitTarget() ? m_targets.getUnitTarget()->GetOrientation() : unitTarget->GetOrientation();
|
||||||
@@ -2375,10 +2376,10 @@ void Spell::EffectTeleportUnits(uint32 i)
|
|||||||
if(mapid == unitTarget->GetMapId())
|
if(mapid == unitTarget->GetMapId())
|
||||||
unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster);
|
unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster);
|
||||||
else if(unitTarget->GetTypeId() == TYPEID_PLAYER)
|
else if(unitTarget->GetTypeId() == TYPEID_PLAYER)
|
||||||
((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, unitTarget==m_caster ? TELE_TO_SPELL : 0);
|
((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, unitTarget == m_caster ? TELE_TO_SPELL : 0);
|
||||||
|
|
||||||
// post effects for TARGET_DST_DB
|
// post effects for TARGET_DST_DB
|
||||||
switch ( m_spellInfo->Id )
|
switch (m_spellInfo->Id)
|
||||||
{
|
{
|
||||||
// Dimensional Ripper - Everlook
|
// Dimensional Ripper - Everlook
|
||||||
case 23442:
|
case 23442:
|
||||||
|
|||||||
+16
-18
@@ -10601,33 +10601,33 @@ void Unit::CombatStart(Unit* target, bool initialAggro)
|
|||||||
void Unit::SetInCombatState(bool PvP, Unit* enemy)
|
void Unit::SetInCombatState(bool PvP, Unit* enemy)
|
||||||
{
|
{
|
||||||
// only alive units can be in combat
|
// only alive units can be in combat
|
||||||
if(!isAlive())
|
if (!isAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(PvP)
|
if (PvP)
|
||||||
m_CombatTimer = 5000;
|
m_CombatTimer = 5000;
|
||||||
|
|
||||||
if(isInCombat() || hasUnitState(UNIT_STAT_EVADE))
|
if (isInCombat() || hasUnitState(UNIT_STAT_EVADE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||||
|
|
||||||
if(GetTypeId() != TYPEID_PLAYER)
|
if (GetTypeId() != TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
// Set home position at place of engaging combat for escorted creatures
|
// Set home position at place of engaging combat for escorted creatures
|
||||||
if(( ((Creature*)this)->IsAIEnabled && ((Creature*)this)->AI()->IsEscorted() ) ||
|
if(( IsAIEnabled && ((Creature*)this)->AI()->IsEscorted() ) ||
|
||||||
((Creature*)this)->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
|
GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
|
||||||
((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
|
((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
|
||||||
|
|
||||||
if(enemy)
|
if (enemy)
|
||||||
{
|
{
|
||||||
if(((Creature*)this)->IsAIEnabled)
|
if (IsAIEnabled)
|
||||||
((Creature*)this)->AI()->EnterCombat(enemy);
|
((Creature*)this)->AI()->EnterCombat(enemy);
|
||||||
if(((Creature*)this)->GetFormation())
|
if (((Creature*)this)->GetFormation())
|
||||||
((Creature*)this)->GetFormation()->MemberAttackStart((Creature*)this, enemy);
|
((Creature*)this)->GetFormation()->MemberAttackStart((Creature*)this, enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(((Creature*)this)->isPet())
|
if (isPet())
|
||||||
{
|
{
|
||||||
UpdateSpeed(MOVE_RUN, true);
|
UpdateSpeed(MOVE_RUN, true);
|
||||||
UpdateSpeed(MOVE_SWIM, true);
|
UpdateSpeed(MOVE_SWIM, true);
|
||||||
@@ -10648,25 +10648,23 @@ void Unit::ClearInCombat()
|
|||||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||||
|
|
||||||
// Player's state will be cleared in Player::UpdateContestedPvP
|
// Player's state will be cleared in Player::UpdateContestedPvP
|
||||||
if(GetTypeId() != TYPEID_PLAYER)
|
if (GetTypeId() != TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
clearUnitState(UNIT_STAT_ATTACK_PLAYER);
|
clearUnitState(UNIT_STAT_ATTACK_PLAYER);
|
||||||
if(HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER))
|
if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER))
|
||||||
SetUInt32Value(UNIT_DYNAMIC_FLAGS, ((Creature*)this)->GetCreatureInfo()->dynamicflags);
|
SetUInt32Value(UNIT_DYNAMIC_FLAGS, ((Creature*)this)->GetCreatureInfo()->dynamicflags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
((Player*)this)->UpdatePotionCooldown();
|
((Player*)this)->UpdatePotionCooldown();
|
||||||
|
|
||||||
if(GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->isPet())
|
if (GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->isPet())
|
||||||
{
|
{
|
||||||
if(Unit *owner = GetOwner())
|
if (Unit *owner = GetOwner())
|
||||||
{
|
|
||||||
for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
|
for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
|
||||||
if(owner->GetSpeedRate(UnitMoveType(i)) > GetSpeedRate(UnitMoveType(i)))
|
if (owner->GetSpeedRate(UnitMoveType(i)) > GetSpeedRate(UnitMoveType(i)))
|
||||||
SetSpeed(UnitMoveType(i), owner->GetSpeedRate(UnitMoveType(i)), true);
|
SetSpeed(UnitMoveType(i), owner->GetSpeedRate(UnitMoveType(i)), true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(!isCharmed())
|
else if (!isCharmed())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
|
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
|
||||||
|
|||||||
Reference in New Issue
Block a user