diff options
| author | megamage <none@none> | 2008-11-07 09:36:46 -0600 |
|---|---|---|
| committer | megamage <none@none> | 2008-11-07 09:36:46 -0600 |
| commit | fd3fcb461253bb8d269faa90af877e1e3e8b12a8 (patch) | |
| tree | 8c23861b1fc3b14908d1a22c5f491c1aad9d2d21 /src/game | |
| parent | fdff7330d29eee31d6f7849067d1a68441402370 (diff) | |
[svn] Remove isVisible function. Check stealth and invisible in canAttack();
Use new remove aura by interrupt flag function.
--HG--
branch : trunk
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/AggressorAI.cpp | 2 | ||||
| -rw-r--r-- | src/game/Creature.cpp | 7 | ||||
| -rw-r--r-- | src/game/Creature.h | 1 | ||||
| -rw-r--r-- | src/game/GameEvent.cpp | 4 | ||||
| -rw-r--r-- | src/game/GlobalEvents.cpp | 4 | ||||
| -rw-r--r-- | src/game/GridNotifiersImpl.h | 6 | ||||
| -rw-r--r-- | src/game/GuardAI.cpp | 2 | ||||
| -rw-r--r-- | src/game/Map.cpp | 30 | ||||
| -rw-r--r-- | src/game/OutdoorPvPObjectiveAI.cpp | 3 | ||||
| -rw-r--r-- | src/game/PetAI.cpp | 4 | ||||
| -rw-r--r-- | src/game/Player.cpp | 2 | ||||
| -rw-r--r-- | src/game/PossessedAI.cpp | 2 | ||||
| -rw-r--r-- | src/game/Spell.cpp | 23 | ||||
| -rw-r--r-- | src/game/Spell.h | 8 | ||||
| -rw-r--r-- | src/game/SpellEffects.cpp | 2 | ||||
| -rw-r--r-- | src/game/SpellMgr.cpp | 4 | ||||
| -rw-r--r-- | src/game/Unit.cpp | 46 | ||||
| -rw-r--r-- | src/game/Unit.h | 3 | ||||
| -rw-r--r-- | src/game/UnitEvents.h | 4 |
19 files changed, 85 insertions, 72 deletions
diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index 7b1c9d7ad46..e8836e374be 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -49,7 +49,7 @@ AggressorAI::MoveInLineOfSight(Unit *u) if( !i_creature.canFly() && i_creature.GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE ) return; - if( !i_creature.getVictim() && !i_creature.hasUnitState(UNIT_STAT_STUNNED) && u->isTargetableForAttack() && + if( !i_creature.getVictim() && !i_creature.hasUnitState(UNIT_STAT_STUNNED) && i_creature.canAttack(u) && ( i_creature.IsHostileTo( u ) /*|| u->getVictim() && i_creature.IsFriendlyTo( u->getVictim() )*/ ) && u->isInAccessablePlaceFor(&i_creature) ) { diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 0bb7c024c1a..14ebf19b94c 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1532,6 +1532,11 @@ bool Creature::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList) co return u->IsWithinLOS(GetPositionX(),GetPositionY(),GetPositionZ()); } +bool Creature::IsWithinSightDist(Unit const* u) const +{ + return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER)); +} + float Creature::GetAttackDistance(Unit const* pl) const { float aggroRate = sWorld.getRate(RATE_CREATURE_AGGRO); @@ -1866,7 +1871,7 @@ bool Creature::IsOutOfThreatArea(Unit* pVictim) const if(!pVictim->IsInMap(this)) return true; - if(!pVictim->isTargetableForAttack()) + if(!canAttack(pVictim)) return true; if(!pVictim->isInAccessablePlaceFor(this)) diff --git a/src/game/Creature.h b/src/game/Creature.h index e65c72465f2..fcc614eb2f9 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -548,6 +548,7 @@ class TRINITY_DLL_SPEC Creature : public Unit uint32 m_GlobalCooldown; bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList) const; + bool IsWithinSightDist(Unit const* u) const; float GetAttackDistance(Unit const* pl) const; void CallAssistence(); diff --git a/src/game/GameEvent.cpp b/src/game/GameEvent.cpp index 496d6b46f76..6a7ce09a02d 100644 --- a/src/game/GameEvent.cpp +++ b/src/game/GameEvent.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "GameEvent.h" diff --git a/src/game/GlobalEvents.cpp b/src/game/GlobalEvents.cpp index a37bfdf7777..2781339235d 100644 --- a/src/game/GlobalEvents.cpp +++ b/src/game/GlobalEvents.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 04eaa41d658..80ab442bcd6 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -74,7 +74,7 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c) // Creature AI reaction if(!c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) { - if( c->AI() && c->AI()->IsVisible(pl) && !c->IsInEvadeMode() ) + if( c->AI() && c->IsWithinSightDist(pl) /*c->AI()->IsVisible(pl)*/ && !c->IsInEvadeMode() ) c->AI()->MoveInLineOfSight(pl); } } @@ -83,13 +83,13 @@ inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2) { if(!c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) { - if( c1->AI() && c1->AI()->IsVisible(c2) && !c1->IsInEvadeMode() ) + if( c1->AI() && c1->IsWithinSightDist(c2) /*c1->AI()->IsVisible(c2)*/ && !c1->IsInEvadeMode() ) c1->AI()->MoveInLineOfSight(c2); } if(!c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) { - if( c2->AI() && c2->AI()->IsVisible(c1) && !c2->IsInEvadeMode() ) + if( c2->AI() && c1->IsWithinSightDist(c2) /*c2->AI()->IsVisible(c1)*/ && !c2->IsInEvadeMode() ) c2->AI()->MoveInLineOfSight(c1); } } diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index 17d62efe44c..5e049d77b71 100644 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -43,7 +43,7 @@ void GuardAI::MoveInLineOfSight(Unit *u) if ( !i_creature.canFly() && i_creature.GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE ) return; - if( !i_creature.getVictim() && u->isTargetableForAttack() && + if( !i_creature.getVictim() && i_creature.canAttack(u) && ( u->IsHostileToPlayers() || i_creature.IsHostileTo(u) /*|| u->getVictim() && i_creature.IsFriendlyTo(u->getVictim())*/ ) && u->isInAccessablePlaceFor(&i_creature)) { diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 0d251ee5912..a6bbd12c01b 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MapManager.h" @@ -90,7 +90,7 @@ bool Map::ExistVMap(uint32 mapid,int x,int y) { if(vmgr->isMapLoadingEnabled()) { - // x and y are swaped !! => fixed now + // x and y are swapped !! => fixed now bool exists = vmgr->existsMap((sWorld.GetDataPath()+ "vmaps").c_str(), mapid, x,y); if(!exists) { @@ -106,7 +106,7 @@ bool Map::ExistVMap(uint32 mapid,int x,int y) void Map::LoadVMap(int x,int y) { - // x and y are swaped !! + // x and y are swapped !! int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld.GetDataPath()+ "vmaps").c_str(), GetId(), x,y); switch(vmapLoadResult) { @@ -144,7 +144,7 @@ void Map::LoadMap(uint32 mapid, uint32 instanceid, int x,int y) return; } - //map already load, delete it before reloading (Is it neccessary? Do we really need the abilty the reload maps during runtime?) + //map already load, delete it before reloading (Is it necessary? Do we really need the ability the reload maps during runtime?) if(GridMaps[x][y]) { sLog.outDetail("Unloading already loaded map %u before reloading.",mapid); @@ -334,7 +334,7 @@ template void Map::SwitchGridContainers(Corpse *, bool); template<class T> void Map::DeleteFromWorld(T* obj) { - // Note: In case resurrectable corpse and pet its removed from gloabal lists in own destructors + // Note: In case resurrectable corpse and pet its removed from global lists in own destructor delete obj; } @@ -441,7 +441,7 @@ Map::LoadGrid(const Cell& cell, bool no_unload) bool Map::Add(Player *player) { - player->SetInstanceId(this->GetInstanceId()); + player->SetInstanceId(GetInstanceId()); // update player state for other player and visa-versa CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); @@ -670,7 +670,6 @@ Map::Remove(T *obj, bool remove) assert( grid != NULL ); obj->RemoveFromWorld(); - RemoveFromGrid(obj,grid,cell); UpdateObjectVisibility(obj,cell,p); @@ -1390,7 +1389,7 @@ void Map::RemoveAllObjectsInRemoveList() Remove((GameObject*)obj,true); break; case TYPEID_UNIT: - // in case triggred sequence some spell can continue casting after prev CleanupsBeforeDelete call + // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call // make sure that like sources auras/etc removed before destructor start ((Creature*)obj)->CleanupsBeforeDelete (); Remove((Creature*)obj,true); @@ -1470,13 +1469,6 @@ bool InstanceMap::CanEnter(Player *player) return false; } - /*if(!player->isGameMaster() && i_data && i_data->IsEncounterInProgress()) - { - sLog.outDebug("InstanceMap::CanEnter - Player '%s' can't enter instance '%s' while an encounter is in progress.", player->GetName(), GetMapName()); - player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); - return false; - }*/ - return Map::CanEnter(player); } @@ -1586,10 +1578,10 @@ bool InstanceMap::Add(Player *player) void InstanceMap::Update(const uint32& t_diff) { - Map::Update(t_diff); + Map::Update(t_diff); - if(i_data) - i_data->Update(t_diff); + if(i_data) + i_data->Update(t_diff); } void InstanceMap::Remove(Player *player, bool remove) diff --git a/src/game/OutdoorPvPObjectiveAI.cpp b/src/game/OutdoorPvPObjectiveAI.cpp index 62c4cb96191..9c9603a7f91 100644 --- a/src/game/OutdoorPvPObjectiveAI.cpp +++ b/src/game/OutdoorPvPObjectiveAI.cpp @@ -34,7 +34,8 @@ void OutdoorPvPObjectiveAI::MoveInLineOfSight(Unit *u) { // IsVisible only passes for players in range, so no need to check again // leaving/entering distance will be checked based on go range data - sOutdoorPvPMgr.HandleCaptureCreaturePlayerMoveInLos(((Player*)u),&i_creature); + if((u->GetTypeId() == TYPEID_PLAYER) && i_creature.IsWithinDistInMap(u, MAX_OUTDOOR_PVP_DISTANCE)) + sOutdoorPvPMgr.HandleCaptureCreaturePlayerMoveInLos(((Player*)u),&i_creature); } int OutdoorPvPObjectiveAI::Permissible(const Creature * c) diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index d8f7725687b..61446220192 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -48,7 +48,7 @@ void PetAI::MoveInLineOfSight(Unit *u) { if( !i_pet.getVictim() && i_pet.GetCharmInfo() && i_pet.GetCharmInfo()->HasReactState(REACT_AGGRESSIVE) && - u->isTargetableForAttack() && i_pet.IsHostileTo( u ) && + i_pet.IsHostileTo( u ) && i_pet.canAttack(u) && u->isInAccessablePlaceFor(&i_pet)) { float attackRadius = i_pet.GetAttackDistance(u); @@ -95,7 +95,7 @@ bool PetAI::_needToStop() const if(i_pet.isCharmed() && i_pet.getVictim() == i_pet.GetCharmer()) return true; - return !i_pet.getVictim()->isTargetableForAttack(); + return !i_pet.canAttack(i_pet.getVictim()); } void PetAI::_stopAttack() diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 4b8a1e00d40..12d1dd99941 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -16546,7 +16546,7 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, uint32 mount_i ModifyMoney(-(int32)totalcost); // prevent stealth flight - RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH); + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH); WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); data << uint32(ERR_TAXIOK); diff --git a/src/game/PossessedAI.cpp b/src/game/PossessedAI.cpp index cb0fde5c1d6..b66a648294f 100644 --- a/src/game/PossessedAI.cpp +++ b/src/game/PossessedAI.cpp @@ -45,7 +45,7 @@ bool PossessedAI::_needToStop() const if(i_pet.getVictim() == i_pet.GetCharmer())
return true;
- return !i_pet.getVictim()->isTargetableForAttack();
+ return !i_pet.canAttack(i_pet.getVictim());
}
void PossessedAI::_stopAttack()
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 858fc03c86e..d700683c7d1 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -1005,7 +1005,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) //if(!IsPositiveSpell(m_spellInfo->Id)) { //do not remove feign death - unit->RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH + AURA_INTERRUPT_FLAG_DAMAGE); + unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH + AURA_INTERRUPT_FLAG_DAMAGE); } } else @@ -2147,7 +2147,7 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) // skip triggered spell (item equip spell casting and other not explicit character casts/item uses) if ( !m_IsTriggeredSpell && isSpellBreakStealth(m_spellInfo) ) { - m_caster->RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH); + m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH); } if(m_IsTriggeredSpell) @@ -2206,7 +2206,7 @@ void Spell::cancel() void Spell::cast(bool skipCheck) { SetExecutedCurrently(true); - + uint8 castResult = 0; // update pointers base at GUIDs to prevent access to non-existed already object @@ -2321,7 +2321,7 @@ void Spell::cast(bool skipCheck) // Immediate spell, no big deal handle_immediate(); } - + SetExecutedCurrently(false); } @@ -3082,7 +3082,7 @@ void Spell::SendChannelStart(uint32 duration) { WorldObject* target = NULL; - // select first not rsusted target from target list for _0_ effect + // select first not resisted target from target list for _0_ effect if(!m_UniqueTargetInfo.empty()) { for(std::list<TargetInfo>::iterator itr= m_UniqueTargetInfo.begin();itr != m_UniqueTargetInfo.end();++itr) @@ -3340,7 +3340,7 @@ void Spell::TriggerSpell() { for(TriggerSpells::iterator si=m_TriggerSpells.begin(); si!=m_TriggerSpells.end(); ++si) { - Spell* spell = new Spell(m_caster, (*si), true, m_originalCasterGUID, this->m_selfContainer); + Spell* spell = new Spell(m_caster, (*si), true, m_originalCasterGUID, m_selfContainer); spell->prepare(&m_targets); // use original spell original targets } } @@ -3398,7 +3398,6 @@ uint8 Spell::CanCast(bool strict) if(m_spellInfo->TargetAuraStateNot && target->HasAuraState(AuraState(m_spellInfo->TargetAuraStateNot))) return SPELL_FAILED_TARGET_AURASTATE; - if(target != m_caster) { // target state requirements (apply to non-self only), to allow cast affects to self like Dirty Deeds @@ -4076,7 +4075,7 @@ int16 Spell::PetCanCast(Unit* target) if(!m_caster->isAlive()) return SPELL_FAILED_CASTER_DEAD; - if(m_caster->IsNonMeleeSpellCasted(false)) //prevent spellcast interuption by another spellcast + if(m_caster->IsNonMeleeSpellCasted(false)) //prevent spellcast interruption by another spellcast return SPELL_FAILED_SPELL_IN_PROGRESS; if(m_caster->isInCombat() && IsNonCombatSpell(m_spellInfo)) return SPELL_FAILED_AFFECTING_COMBAT; @@ -4168,7 +4167,7 @@ uint8 Spell::CheckCasterAuras() const else if(m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_DISPEL_IMMUNITY) dispel_immune |= GetDispellMask(DispelType(m_spellInfo->EffectMiscValue[i])); } - //immune movement impairement and loss of control + //immune movement impairment and loss of control if(m_spellInfo->Id==(uint32)42292) mechanic_immune = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; } @@ -4650,7 +4649,7 @@ uint8 Spell::CheckItems() return SPELL_FAILED_CANT_BE_DISENCHANTED; uint32 item_quality = itemProto->Quality; - // 2.0.x addon: Check player enchanting level agains the item desenchanting requirements + // 2.0.x addon: Check player enchanting level against the item disenchanting requirements uint32 item_disenchantskilllevel = itemProto->RequiredDisenchantSkill; if (item_disenchantskilllevel == uint32(-1)) return SPELL_FAILED_CANT_BE_DISENCHANTED; diff --git a/src/game/Spell.h b/src/game/Spell.h index bdfffff3db9..2a724d41b68 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __SPELL_H @@ -578,14 +578,14 @@ namespace Trinity switch (i_TargetType) { case SPELL_TARGETS_FRIENDLY: - if (!itr->getSource()->isTargetableForAttack() || !i_caster->IsFriendlyTo( itr->getSource() )) + if (!itr->getSource()->isAttackableByAOE() || !i_caster->IsFriendlyTo( itr->getSource() )) continue; break; case SPELL_TARGETS_AOE_DAMAGE: { if(itr->getSource()->GetTypeId()==TYPEID_UNIT && ((Creature*)itr->getSource())->isTotem()) continue; - if(!itr->getSource()->isTargetableForAttack()) + if(!itr->getSource()->isAttackableByAOE()) continue; Unit* check = i_caster->GetCharmerOrOwnerOrSelf(); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index e1f80bdcc58..01fcbd87d45 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3477,7 +3477,7 @@ void Spell::EffectPickPocket(uint32 /*i*/) else { // Reveal action + get attack - m_caster->RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH); + m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH); if (((Creature*)unitTarget)->AI()) ((Creature*)unitTarget)->AI()->AttackStart(m_caster); } diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index a248bb8d2d5..ec67d55e645 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "SpellMgr.h" diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index aec00fa2b82..7eaf495b234 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -463,7 +463,7 @@ void Unit::RemoveSpellsCausingAura(AuraType auraType) } } -void Unit::RemoveInterruptableAura(uint32 flag) +void Unit::RemoveAurasWithInterruptFlags(uint32 flag) { AuraList::iterator iter, next; for (iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end(); iter = next) @@ -509,7 +509,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa // remove affects from attacker at any non-DoT damage (including 0 damage) if( damagetype != DOT) { - RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH); + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH); if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED)) pVictim->SetStandState(PLAYER_STATE_NONE); @@ -4103,17 +4103,6 @@ void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) } } -void Unit::RemoveAurasWithInterruptFlags(uint32 flags) -{ - for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) - { - if (iter->second->GetSpellProto()->AuraInterruptFlags & flags) - RemoveAura(iter); - else - ++iter; - } -} - void Unit::RemoveNotOwnSingleTargetAuras() { // single target auras from other casters @@ -8506,15 +8495,40 @@ void Unit::ClearInCombat() clearUnitState(UNIT_STAT_ATTACK_PLAYER); } +//TODO: remove this function bool Unit::isTargetableForAttack() const { - if (GetTypeId()==TYPEID_PLAYER && ((Player *)this)->isGameMaster()) + return isAttackableByAOE() && !hasUnitState(UNIT_STAT_DIED); +} + +bool Unit::canAttack(Unit const* target) const +{ + assert(target); + + if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED)) + return false; + + if((m_invisibilityMask || target->m_invisibilityMask) && !canDetectInvisibilityOf(target)) + return false; + + if(target->GetVisibility() == VISIBILITY_GROUP_STEALTH && !canDetectStealthOf(target, GetDistance(target))) + return false; + + return true; +} + +bool Unit::isAttackableByAOE() const +{ + if(!isAlive()) return false; if(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)) return false; - return isAlive() && !hasUnitState(UNIT_STAT_DIED)&& !isInFlight() /*&& !isStealth()*/; + if(GetTypeId()==TYPEID_PLAYER && ((Player *)this)->isGameMaster()) + return false; + + return !isInFlight(); } int32 Unit::ModifyHealth(int32 dVal) @@ -9066,7 +9080,7 @@ bool Unit::SelectHostilTarget() { for(AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr) { - if( (*itr)->IsInMap(this) && (*itr)->isTargetableForAttack() && (*itr)->isInAccessablePlaceFor((Creature*)this) ) + if( (*itr)->IsInMap(this) && canAttack(*itr) && (*itr)->isInAccessablePlaceFor((Creature*)this) ) return false; } } diff --git a/src/game/Unit.h b/src/game/Unit.h index c113587a5ff..0f2949b6ee3 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -922,6 +922,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject bool isFrozen() const; bool isTargetableForAttack() const; + bool isAttackableByAOE() const; + bool canAttack(Unit const* target) const; virtual bool IsInWater() const; virtual bool IsUnderWater() const; bool isInAccessablePlaceFor(Creature const* c) const; @@ -1031,7 +1033,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void RemoveNotOwnSingleTargetAuras(); void RemoveSpellsCausingAura(AuraType auraType); - void RemoveInterruptableAura(uint32 flag); void RemoveRankAurasDueToSpell(uint32 spellId); bool RemoveNoStackAurasDueToAura(Aura *Aur); void RemoveAurasWithInterruptFlags(uint32 flags); diff --git a/src/game/UnitEvents.h b/src/game/UnitEvents.h index d02c8f40465..35003c3d09e 100644 --- a/src/game/UnitEvents.h +++ b/src/game/UnitEvents.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _UNITEVENTS |
