diff options
-rw-r--r-- | src/bindings/scripts/base/escort_ai.h | 1 | ||||
-rw-r--r-- | src/game/CreatureAI.h | 2 | ||||
-rw-r--r-- | src/game/Player.cpp | 4 | ||||
-rw-r--r-- | src/game/Spell.cpp | 41 | ||||
-rw-r--r-- | src/game/SpellEffects.cpp | 11 | ||||
-rw-r--r-- | src/game/Unit.cpp | 34 |
6 files changed, 45 insertions, 48 deletions
diff --git a/src/bindings/scripts/base/escort_ai.h b/src/bindings/scripts/base/escort_ai.h index d0cb55b100a..4ac826c6c80 100644 --- a/src/bindings/scripts/base/escort_ai.h +++ b/src/bindings/scripts/base/escort_ai.h @@ -71,6 +71,7 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI void SetEscortPaused(bool uPaused); bool HasEscortState(uint32 uiEscortState) { return (m_uiEscortState & uiEscortState); } + virtual bool IsEscorted() { return true; } void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; } float GetMaxPlayerDistance() { return MaxPlayerDistance; } diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index 6b20c059828..ce2c7098623 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -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) //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) virtual void JustRespawned() { Reset(); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 858d4591e5f..d9e2f139880 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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); RelocateToHomebind(); - } else { - Relocate(&_loc); } + else + Relocate(&_loc); // We are not in BG anymore m_bgData.bgInstanceID = 0; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index f60676dd208..5251c115a89 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -5989,15 +5989,15 @@ void Spell::Delayed() // only called in DealDamage() 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; - if(isDelayableNoMore()) // Spells may only be delayed twice + if (isDelayableNoMore()) // Spells may only be delayed twice return; //check pushback reduce 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); delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100; if(delayReduce >= 100) @@ -6005,7 +6005,7 @@ void Spell::DelayedChannel() delaytime = delaytime * (100 - delayReduce) / 100; - if(int32(m_timer) < delaytime) + if(int32(m_timer) <= delaytime) { delaytime = m_timer; 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); for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) - { if ((*ihit).missCondition == SPELL_MISS_NONE) - { - Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); - if (unit) - { + if (Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID)) unit->DelayAura(m_spellInfo->Id, m_caster->GetGUID(), delaytime); - } - } - } // partially interrupt persistent area auras if(DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id)) @@ -6036,15 +6029,16 @@ void Spell::DelayedChannel() void Spell::UpdatePointers() { - if(m_originalCasterGUID==m_caster->GetGUID()) + if(m_originalCasterGUID == m_caster->GetGUID()) m_originalCaster = m_caster; else { 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_targets.Update(m_caster); @@ -6350,8 +6344,6 @@ bool SpellEvent::IsDeletable() const bool Spell::IsValidSingleTargetEffect(Unit const* target, Targets type) const { - if (target->GetMapId() == MAPID_INVALID) - return false; switch (type) { 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 { - 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]))) return false; @@ -6383,9 +6380,9 @@ bool Spell::IsValidSingleTargetSpell(Unit const* target) const void Spell::CalculateDamageDoneForAllTargets() { 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 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); for (Unit::AuraEffectList::const_iterator j = Auras.begin(); j != Auras.end(); ++j) { @@ -6409,7 +6406,7 @@ void Spell::CalculateDamageDoneForAllTargets() TargetInfo &target = *ihit; uint32 mask = target.effectMask; - if(!mask) + if (!mask) continue; Unit* unit = m_caster->GetGUID()==target.targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target.targetGUID); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index db686d660ec..0d656e5b5cb 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -2354,11 +2354,11 @@ void Spell::EffectJump(uint32 i) void Spell::EffectTeleportUnits(uint32 i) { - if(!unitTarget || unitTarget->isInFlight()) + if (!unitTarget || unitTarget->isInFlight()) 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 ); return; @@ -2366,7 +2366,8 @@ void Spell::EffectTeleportUnits(uint32 i) // Init dest coordinates 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; m_targets.m_dstPos.GetPosition(x, y, z); float orientation = m_targets.getUnitTarget() ? m_targets.getUnitTarget()->GetOrientation() : unitTarget->GetOrientation(); @@ -2375,10 +2376,10 @@ void Spell::EffectTeleportUnits(uint32 i) if(mapid == unitTarget->GetMapId()) unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster); 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 - switch ( m_spellInfo->Id ) + switch (m_spellInfo->Id) { // Dimensional Ripper - Everlook case 23442: diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index e63a0c5cf6d..459d9c40bac 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -10601,33 +10601,33 @@ void Unit::CombatStart(Unit* target, bool initialAggro) void Unit::SetInCombatState(bool PvP, Unit* enemy) { // only alive units can be in combat - if(!isAlive()) + if (!isAlive()) return; - if(PvP) + if (PvP) m_CombatTimer = 5000; - if(isInCombat() || hasUnitState(UNIT_STAT_EVADE)) + if (isInCombat() || hasUnitState(UNIT_STAT_EVADE)) return; 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 - if(( ((Creature*)this)->IsAIEnabled && ((Creature*)this)->AI()->IsEscorted() ) || - ((Creature*)this)->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE) + if(( IsAIEnabled && ((Creature*)this)->AI()->IsEscorted() ) || + GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE) ((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); - if(enemy) + if (enemy) { - if(((Creature*)this)->IsAIEnabled) + if (IsAIEnabled) ((Creature*)this)->AI()->EnterCombat(enemy); - if(((Creature*)this)->GetFormation()) + if (((Creature*)this)->GetFormation()) ((Creature*)this)->GetFormation()->MemberAttackStart((Creature*)this, enemy); } - if(((Creature*)this)->isPet()) + if (isPet()) { UpdateSpeed(MOVE_RUN, true); UpdateSpeed(MOVE_SWIM, true); @@ -10648,25 +10648,23 @@ void Unit::ClearInCombat() RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); // Player's state will be cleared in Player::UpdateContestedPvP - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_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); } else ((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) - if(owner->GetSpeedRate(UnitMoveType(i)) > GetSpeedRate(UnitMoveType(i))) + if (owner->GetSpeedRate(UnitMoveType(i)) > GetSpeedRate(UnitMoveType(i))) SetSpeed(UnitMoveType(i), owner->GetSpeedRate(UnitMoveType(i)), true); - } } - else if(!isCharmed()) + else if (!isCharmed()) return; RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); |