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 | |
parent | fdff7330d29eee31d6f7849067d1a68441402370 (diff) |
[svn] Remove isVisible function. Check stealth and invisible in canAttack();
Use new remove aura by interrupt flag function.
--HG--
branch : trunk
-rw-r--r-- | sql/updates/194_world_blacktemple.sql (renamed from sql/updates/163_world.sql) | 8 | ||||
-rw-r--r-- | src/bindings/scripts/include/sc_creature.cpp | 24 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/creature/mob_event_ai.cpp | 7 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp | 60 | ||||
-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 |
23 files changed, 128 insertions, 128 deletions
diff --git a/sql/updates/163_world.sql b/sql/updates/194_world_blacktemple.sql index 37c1b838f7b..1229b034315 100644 --- a/sql/updates/163_world.sql +++ b/sql/updates/194_world_blacktemple.sql @@ -2,8 +2,10 @@ DELETE FROM spell_linked_spell WHERE `spell_trigger` IN (39992, 39835, 42052, -4 -- INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (39992, 39835, 1, 'Needle Spine');
INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (39835, 39968, 1, 'Needle Spine');
INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (-41376, 41377, 0, 'Spite');
-INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (-41914, 41915, 0, 'Summon Parasitic Shadowfiend');
INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (41126, 41131, 1, 'Flame Crash');
+INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (-41914, 41915, 0, 'Summon Parasitic Shadowfiend');
+INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (39908, 40017, 1, 'Eye Blast');
+
-- molten_flame
UPDATE creature_template SET flags_extra = 128, speed = 1.0 WHERE entry = 23095;
@@ -12,4 +14,6 @@ UPDATE creature_template SET spell1 = 40117, flags_extra = 128, scriptname = '' -- flame crash
update creature_template set spell1 = 40836, flags_extra = 128, scriptname = '' where entry = 23336;
-- blaze
-update creature_template set spell1 = 40610, flags_extra = 128, scriptname = '' where entry = 23259;
\ No newline at end of file +update creature_template set spell1 = 40610, flags_extra = 128, scriptname = '' where entry = 23259;
+-- glaive
+update creature_template set scriptname = 'mob_blade_of_azzinoth' where entry = 22996;
\ No newline at end of file diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index f352583dd3f..5848623ab2d 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -73,18 +73,18 @@ bool ScriptedAI::IsVisible(Unit* who) const void ScriptedAI::MoveInLineOfSight(Unit *who) { - if (!m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature)) - { - if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; + if(m_creature->getVictim() || !m_creature->IsHostileTo(who) || !who->isInAccessablePlaceFor(m_creature)) + return; - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) - { - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - AttackStart(who); - } - } + if(!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + if(!m_creature->IsWithinDistInMap(who, m_creature->GetAttackDistance(who)) || !m_creature->IsWithinLOSInMap(who)) + return; + + if(m_creature->canAttack(who)) + //who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + AttackStart(who); } void ScriptedAI::AttackStart(Unit* who, bool melee) @@ -777,7 +777,7 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 s void Scripted_NoMovementAI::MoveInLineOfSight(Unit *who) { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + if( !m_creature->getVictim() && m_creature->canAttack(who) && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) { if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) return; diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp index ca3361d9dd2..a0498969094 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -1195,8 +1195,7 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI if (m_creature->isCivilian() && m_creature->IsNeutralToAll()) return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + if (m_creature->canAttack(who) && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) { if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) return; @@ -1204,8 +1203,8 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI float attackRadius = m_creature->GetAttackDistance(who); if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + //if(who->HasStealthAura()) + // who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); //Begin melee attack if we are within range AttackStart(who); diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp index c5c867125f2..628329ab11b 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp @@ -413,7 +413,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI } EnterPhase(PHASE_FLIGHT); } - else + else // handle flight sequence Timer[EVENT_FLIGHT_SEQUENCE] = 1000; } @@ -691,10 +691,10 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI Event = EVENT_NULL; for(uint32 i = 1; i <= MaxTimer[Phase]; i++) { - if(Timer[i]) + if(Timer[i]) // Event is enabled if(Timer[i] <= diff) { - if(!Event) + if(!Event) // No event with higher priority Event = (EventIllidan)i; } else Timer[i] -= diff; @@ -708,12 +708,12 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI break; case PHASE_NORMAL_2: - if(m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30) + if(HPPCT(m_creature) < 30) EnterPhase(PHASE_TALK_SEQUENCE); break; case PHASE_NORMAL_MAIEV: - if(m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 1) + if(HPPCT(m_creature) < 1) EnterPhase(PHASE_TALK_SEQUENCE); break; @@ -758,7 +758,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI if(soundid) DoPlaySoundToSet(m_creature, soundid); } - Timer[EVENT_TAUNT] = 32000; + Timer[EVENT_TAUNT] = 25000 + rand()%10000; break; case EVENT_SHEAR: @@ -833,12 +833,9 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI case EVENT_MOVE_POINT: Phase = PHASE_FLIGHT_SEQUENCE; Timer[EVENT_FLIGHT_SEQUENCE] = 0;//do not start Event when changing hover point - for (uint8 i = 0; i <= rand()%3; i++) - { - HoverPoint++; - if(HoverPoint > 3) - HoverPoint = 0; - } + HoverPoint += (rand()%3 + 1); + if(HoverPoint > 3) + HoverPoint -= 4; m_creature->GetMotionMaster()->MovePoint(0, HoverPosition[HoverPoint].x, HoverPosition[HoverPoint].y, HoverPosition[HoverPoint].z); break; @@ -2059,27 +2056,17 @@ void boss_illidan_stormrageAI::CastEyeBlast() final.x = 2 * final.x - initial.x; final.y = 2 * final.y - initial.y; - for(uint8 i = 0; i < 2; ++i)//core bug, two buff do not coexist - { - Creature* Trigger = NULL; - Trigger = m_creature->SummonCreature(DEMON_FIRE, initial.x, initial.y, initial.z, 0, TEMPSUMMON_TIMED_DESPAWN, 13000); - if(Trigger) - { - ((demonfireAI*)Trigger->AI())->IsTrigger = true; - Trigger->SetSpeed(MOVE_WALK, 3); - Trigger->SetUnitMovementFlags(MOVEMENTFLAG_WALK_MODE); - Trigger->GetMotionMaster()->MovePoint(0, final.x, final.y, final.z); + Creature* Trigger = m_creature->SummonCreature(DEMON_FIRE, initial.x, initial.y, initial.z, 0, TEMPSUMMON_TIMED_DESPAWN, 13000); + if(!Trigger) return; - if(!i) - Trigger->CastSpell(Trigger, SPELL_EYE_BLAST_TRIGGER, true); - else - { - Trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Trigger->GetGUID()); - DoCast(Trigger, SPELL_EYE_BLAST); - } - } - } + ((demonfireAI*)Trigger->AI())->IsTrigger = true; + Trigger->SetSpeed(MOVE_WALK, 3); + Trigger->SetUnitMovementFlags(MOVEMENTFLAG_WALK_MODE); + Trigger->GetMotionMaster()->MovePoint(0, final.x, final.y, final.z); + + Trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Trigger->GetGUID()); + DoCast(Trigger, SPELL_EYE_BLAST); } void boss_illidan_stormrageAI::SummonFlamesOfAzzinoth() @@ -2162,13 +2149,10 @@ void boss_illidan_stormrageAI::EnterPhase(PhaseIllidan NextPhase) m_creature->InterruptNonMeleeSpells(false); m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); m_creature->GetMotionMaster()->Clear(false); - //m_creature->GetMotionMaster()->MoveIdle(); m_creature->AttackStop(); break; case PHASE_FLIGHT_SEQUENCE: - if(Phase == PHASE_FLIGHT) //land - Timer[EVENT_FLIGHT_SEQUENCE] = 2000; - else //lift off + if(Phase == PHASE_NORMAL) //lift off { FlightCount = 1; Timer[EVENT_FLIGHT_SEQUENCE] = 1; @@ -2176,9 +2160,10 @@ void boss_illidan_stormrageAI::EnterPhase(PhaseIllidan NextPhase) m_creature->InterruptNonMeleeSpells(false); m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); m_creature->GetMotionMaster()->Clear(false); - //m_creature->GetMotionMaster()->MoveIdle(); m_creature->AttackStop(); } + else //land + Timer[EVENT_FLIGHT_SEQUENCE] = 2000; break; case PHASE_TRANSFORM_SEQUENCE: if(Phase == PHASE_DEMON) @@ -2191,7 +2176,6 @@ void boss_illidan_stormrageAI::EnterPhase(PhaseIllidan NextPhase) DoPlaySoundToSet(m_creature, SOUND_MORPH); } m_creature->GetMotionMaster()->Clear(); - //m_creature->GetMotionMaster()->MoveIdle(); m_creature->AttackStop(); break; default: 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 |