diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/scripts/scripts/npc/npc_escortAI.cpp | 53 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/npc/npc_escortAI.h | 15 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp | 55 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp | 4 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp | 3 | ||||
-rw-r--r-- | src/game/GridNotifiers.cpp | 3 | ||||
-rw-r--r-- | src/game/GridNotifiersImpl.h | 4 | ||||
-rw-r--r-- | src/game/Map.cpp | 65 | ||||
-rw-r--r-- | src/game/Map.h | 3 | ||||
-rw-r--r-- | src/game/ObjectGridLoader.cpp | 1 | ||||
-rw-r--r-- | src/game/SpellAuras.cpp | 3 | ||||
-rw-r--r-- | src/game/Unit.cpp | 3 |
12 files changed, 133 insertions, 79 deletions
diff --git a/src/bindings/scripts/scripts/npc/npc_escortAI.cpp b/src/bindings/scripts/scripts/npc/npc_escortAI.cpp index 2a0f5e16a1d..34179378b06 100644 --- a/src/bindings/scripts/scripts/npc/npc_escortAI.cpp +++ b/src/bindings/scripts/scripts/npc/npc_escortAI.cpp @@ -13,7 +13,7 @@ EndScriptData */ #include "npc_escortAI.h" #define WP_LAST_POINT -1 -#define MAX_PLAYER_DISTANCE 50 +extern std::list<PointMovement> PointMovementList; bool npc_escortAI::IsVisible(Unit* who) const { @@ -132,21 +132,29 @@ void npc_escortAI::UpdateAI(const uint32 diff) //End of the line, Despawn self then immediatly respawn if (CurrentWP == WaypointList.end()) { - debug_log("SD2: EscortAI reached end of waypoints"); + if(DespawnAtEnd) + { + debug_log("SD2: EscortAI reached end of waypoints"); - m_creature->setDeathState(JUST_DIED); - m_creature->SetHealth(0); - m_creature->CombatStop(); - m_creature->DeleteThreatList(); - m_creature->Respawn(); - m_creature->GetMotionMaster()->Clear(true); + m_creature->setDeathState(JUST_DIED); + m_creature->SetHealth(0); + m_creature->CombatStop(); + m_creature->DeleteThreatList(); + m_creature->Respawn(); + m_creature->GetMotionMaster()->Clear(true); - //Re-Enable gossip - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + //Re-Enable gossip + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - IsBeingEscorted = false; - WaitTimer = 0; - return; + IsBeingEscorted = false; + WaitTimer = 0; + return; + }else{ + debug_log("SD2: EscortAI reached end of waypoints with Despawn off"); + IsBeingEscorted = false; + WaitTimer = 0; + return; + } } if( !IsOnHold ) @@ -165,7 +173,7 @@ void npc_escortAI::UpdateAI(const uint32 diff) { Unit* p = Unit::GetUnit(*m_creature, PlayerGUID); - if (!p || m_creature->GetDistance(p) > MAX_PLAYER_DISTANCE) + if (DespawnAtFar && (!p || m_creature->GetDistance(p) > GetMaxPlayerDistance())) { JustDied(m_creature); IsBeingEscorted = false; @@ -187,16 +195,19 @@ void npc_escortAI::UpdateAI(const uint32 diff) }else PlayerTimer -= diff; } - //Check if we have a current target - if( m_creature->isAlive() && UpdateVictim()) + if(CanMelee) { - //If we are within range melee the target - if( m_creature->IsWithinMeleeRange(m_creature->getVictim())) + //Check if we have a current target + if( m_creature->isAlive() && UpdateVictim()) { - if( m_creature->isAttackReady() ) + //If we are within range melee the target + if( m_creature->IsWithinMeleeRange(m_creature->getVictim())) { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); + if( m_creature->isAttackReady() ) + { + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); + } } } } diff --git a/src/bindings/scripts/scripts/npc/npc_escortAI.h b/src/bindings/scripts/scripts/npc/npc_escortAI.h index ca284bd1b21..6e4f22e1c01 100644 --- a/src/bindings/scripts/scripts/npc/npc_escortAI.h +++ b/src/bindings/scripts/scripts/npc/npc_escortAI.h @@ -5,7 +5,7 @@ #ifndef SC_ESCORTAI_H #define SC_ESCORTAI_H -extern std::list<PointMovement> PointMovementList; +#define DEFAULT_MAX_PLAYER_DISTANCE 50 struct Escort_Waypoint { @@ -37,7 +37,7 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI virtual void Reset() = 0; // CreatureAI functions - npc_escortAI(Creature *c) : ScriptedAI(c), IsBeingEscorted(false), PlayerTimer(1000) {m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z);} + npc_escortAI(Creature *c) : ScriptedAI(c), IsBeingEscorted(false), PlayerTimer(1000), MaxPlayerDistance(DEFAULT_MAX_PLAYER_DISTANCE), CanMelee(true), DespawnAtEnd(true), DespawnAtFar(true) {m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z);} bool IsVisible(Unit*) const; @@ -62,6 +62,13 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI void Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID = 0); + void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; } + float GetMaxPlayerDistance() { return MaxPlayerDistance; } + + void SetCanMelee(bool usemelee) { CanMelee = usemelee; } + void SetDespawnAtEnd(bool despawn) { DespawnAtEnd = despawn; } + void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; } + // EscortAI variables protected: uint64 PlayerGUID; @@ -71,6 +78,7 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI private: uint32 WaitTimer; uint32 PlayerTimer; + float MaxPlayerDistance; struct { @@ -87,6 +95,9 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI bool Returning; bool ReconnectWP; bool Run; + bool CanMelee; + bool DespawnAtEnd; + bool DespawnAtFar; }; #endif diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp index 4769ac68be1..1d5b7934bd6 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp @@ -211,6 +211,7 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI npc_thrall_old_hillsbradAI(Creature *c) : npc_escortAI(c) { pInstance = ((ScriptedInstance*)c->GetInstanceData()); + m_creature->setActive(true); } ScriptedInstance *pInstance; @@ -354,32 +355,39 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI //trigger epoch Yell("Thrall! Come outside and face your fate! ....") //from here, thrall should not never be allowed to move to point 106 which he currently does. break; - case 106: - if (!PlayerGUID) - break; - //trigger taretha to run down outside - if (uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA)) + case 106: { - if (Creature* Taretha = ((Creature*)Unit::GetUnit(*m_creature, TarethaGUID))) - ((npc_escortAI*)(Taretha->AI()))->Start(false, false, true, PlayerGUID); - } + if (!PlayerGUID) + break; - //kill credit creature for quest - Map *map = m_creature->GetMap(); - Map::PlayerList const& players = map->GetPlayers(); - if (!players.isEmpty() && map->IsDungeon()) - { - for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + //trigger taretha to run down outside + if (uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA)) { - if (Player* pPlayer = itr->getSource()) - pPlayer->KilledMonster(20156,m_creature->GetGUID()); + if (Creature* Taretha = ((Creature*)Unit::GetUnit(*m_creature, TarethaGUID))) + ((npc_escortAI*)(Taretha->AI()))->Start(false, false, true, PlayerGUID); } - } - //alot will happen here, thrall and taretha talk, erozion appear at spot to explain - m_creature->SummonCreature(EROZION_ENTRY,2646.47,680.416,55.38,4.16,TEMPSUMMON_TIMED_DESPAWN,120000); - break; + //kill credit creature for quest + Map *map = m_creature->GetMap(); + Map::PlayerList const& players = map->GetPlayers(); + if (!players.isEmpty() && map->IsDungeon()) + { + for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + { + if (Player* pPlayer = itr->getSource()) + pPlayer->KilledMonster(20156,m_creature->GetGUID()); + } + } + + //alot will happen here, thrall and taretha talk, erozion appear at spot to explain + m_creature->SummonCreature(EROZION_ENTRY,2646.47,680.416,55.38,4.16,TEMPSUMMON_TIMED_DESPAWN,120000); + } + break; + case 108: + //last waypoint, just set Thrall invisible, respawn is turned off + m_creature->SetVisibility(VISIBILITY_OFF); + break; } } @@ -704,6 +712,9 @@ bool GossipSelect_npc_thrall_old_hillsbrad(Player *player, Creature *_Creature, DoScriptText(SAY_TH_START_EVENT_PART1, _Creature); ((npc_escortAI*)(_Creature->AI()))->Start(true, true, true, player->GetGUID()); + ((npc_escortAI*)(_Creature->AI()))->SetMaxPlayerDistance(100.0f);//not really needed, because it will not despawn if player is too far + ((npc_escortAI*)(_Creature->AI()))->SetDespawnAtEnd(false); + ((npc_escortAI*)(_Creature->AI()))->SetDespawnAtFar(false); break; case GOSSIP_ACTION_INFO_DEF+2: @@ -810,8 +821,8 @@ bool GossipSelect_npc_taretha(Player *player, Creature *_Creature, uint32 sender if( pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS ) { pInstance->SetData(TYPE_THRALL_PART4,IN_PROGRESS); - if(pInstance->GetData64(DATA_EPOCH) == 0) - _Creature->SummonCreature(ENTRY_EPOCH,2639.13,698.55,65.43,4.59,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000); + if(pInstance->GetData64(DATA_EPOCH) == 0) + _Creature->SummonCreature(ENTRY_EPOCH,2639.13,698.55,65.43,4.59,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000); if (uint64 ThrallGUID = pInstance->GetData64(DATA_THRALL)) { diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp index af7a4501dc7..b8c6162a809 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp @@ -287,13 +287,13 @@ struct TRINITY_DLL_DECL boss_warbringer_omroggAI : public ScriptedAI { Delay_Timer = 3500; - if (!LeftHead && !RightHead) + if (!LeftHead || !RightHead) return; Unit *Left = Unit::GetUnit(*m_creature,LeftHead); Unit *Right = Unit::GetUnit(*m_creature,RightHead); - if (!Left && !Right) + if (!Left || !Right) return; if (AggroYell) diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp index b03ec2f7d42..3f839300f3f 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp @@ -341,7 +341,8 @@ struct TRINITY_DLL_DECL boss_priestess_guestAI : public ScriptedAI boss_priestess_guestAI(Creature* c) : ScriptedAI(c) { Group.clear(); - pInstance = ((ScriptedInstance*)c->GetInstanceData()); AcquireGUIDs(); + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + AcquireGUIDs(); } ScriptedInstance* pInstance; diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp index a244e950dad..fe18dc35840 100644 --- a/src/game/GridNotifiers.cpp +++ b/src/game/GridNotifiers.cpp @@ -98,6 +98,9 @@ PlayerVisibilityNotifier::Notify() // target aura duration for caster show only if target exist at caster client if((*vItr)!=&i_player && (*vItr)->isType(TYPEMASK_UNIT)) i_player.SendInitialVisiblePackets((Unit*)(*vItr)); + + if(i_visibleNow.size() >= 30) + i_player.SetToNotify(); } void diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 491ff67aec5..0b19f89d60c 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -190,11 +190,15 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target) { if (i_check->IsFriendlyTo( target )) return; + + i_check->CombatStart(target); } else { if (!i_check->IsHostileTo( target )) return; + + i_check->CombatStart(target); } // Check target immune to spell or aura diff --git a/src/game/Map.cpp b/src/game/Map.cpp index b39fb5780e2..7fd289d8a37 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -187,7 +187,7 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode) : i_mapEntry (sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_id(id), i_InstanceId(InstanceId), m_unloadTimer(0), i_gridExpiry(expiry), m_activeNonPlayersIter(m_activeNonPlayers.end()) - , i_lock(false) + , i_lock(true) { for(unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx) { @@ -353,12 +353,14 @@ void Map::AddNotifier(T*) template<> void Map::AddNotifier(Player* obj) { + obj->m_IsInNotifyList = false; AddUnitToNotify(obj); } template<> void Map::AddNotifier(Creature* obj) { + obj->m_IsInNotifyList = false; AddUnitToNotify(obj); } @@ -460,8 +462,6 @@ bool Map::Add(Player *player) SendInitSelf(player); SendInitTransports(player); - player->m_IsInNotifyList = false; - player->m_Notified = false; player->m_clientGUIDs.clear(); AddNotifier(player); @@ -501,7 +501,7 @@ Map::Add(T *obj) //something, such as vehicle, needs to be update immediately //if(obj->GetTypeId() != TYPEID_UNIT) - UpdateObjectVisibility(obj,cell,p); + UpdateObjectVisibility(obj,cell,p); AddNotifier(obj); } @@ -603,20 +603,25 @@ bool Map::loaded(const GridPair &p) const void Map::RelocationNotify() { - //creatures may be added to the list during update - i_lock = true; + //Move backlog to notify list + for(std::vector<uint64>::iterator iter = i_unitsToNotifyBacklog.begin(); iter != i_unitsToNotifyBacklog.end(); ++iter) + { + if(Unit *unit = ObjectAccessor::GetObjectInWorld(*iter, (Unit*)NULL)) + { + i_unitsToNotify.push_back(unit); + } + } + i_unitsToNotifyBacklog.clear(); //Notify - for(std::vector<uint64>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter) + for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter) { - Unit *unit = ObjectAccessor::GetObjectInWorld(*iter, (Unit*)NULL); - if(!unit || !unit->IsInWorld() || unit->GetMapId() != GetId()) - { - *iter = 0; + Unit *unit = *iter; + if(unit->m_Notified || !unit->IsInWorld() || unit->GetMapId() != GetId()) continue; - } unit->m_Notified = true; + unit->m_IsInNotifyList = false; if(unit->GetTypeId() == TYPEID_PLAYER) { @@ -630,23 +635,30 @@ void Map::RelocationNotify() VisitAll(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), notifier); } } - - //Clear list - for(std::vector<uint64>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter) + for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter) { - if(Unit *unit = ObjectAccessor::GetObjectInWorld(*iter, (Unit*)NULL)) - { - unit->m_IsInNotifyList = false; - unit->m_Notified = false; - } + (*iter)->m_Notified = false; } i_unitsToNotify.clear(); +} - i_lock = false; +void Map::AddUnitToNotify(Unit* u) +{ + if(u->m_IsInNotifyList) + return; + + u->m_IsInNotifyList = true; + + if(i_lock) + i_unitsToNotifyBacklog.push_back(u->GetGUID()); + else + i_unitsToNotify.push_back(u); } void Map::Update(const uint32 &t_diff) { + i_lock = false; + resetMarkedCells(); Trinity::ObjectUpdater updater(t_diff); @@ -755,6 +767,8 @@ void Map::Update(const uint32 &t_diff) } } + i_lock = true; + RelocationNotify(); // Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load ! @@ -2606,12 +2620,3 @@ void BattleGroundMap::UnloadAll() /*--------------------------TRINITY-------------------------*/ -void Map::AddUnitToNotify(Unit* u) -{ - if(!i_lock && !u->m_IsInNotifyList) - { - i_unitsToNotify.push_back(u->GetGUID()); - u->m_IsInNotifyList = true; - } -} - diff --git a/src/game/Map.h b/src/game/Map.h index 89d1ad2a6c3..0719ec602ef 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -484,7 +484,8 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O time_t i_gridExpiry; bool i_lock; - std::vector<uint64> i_unitsToNotify; + std::vector<uint64> i_unitsToNotifyBacklog; + std::vector<Unit*> i_unitsToNotify; std::set<WorldObject *> i_objectsToRemove; std::map<WorldObject*, bool> i_objectsToSwitch; diff --git a/src/game/ObjectGridLoader.cpp b/src/game/ObjectGridLoader.cpp index 1ba694d9738..78727fc7c0a 100644 --- a/src/game/ObjectGridLoader.cpp +++ b/src/game/ObjectGridLoader.cpp @@ -314,6 +314,7 @@ ObjectGridStoper::Visit(CreatureMapType &m) iter->getSource()->CombatStop(); iter->getSource()->DeleteThreatList(); iter->getSource()->RemoveAllDynObjects(); + iter->getSource()->AI()->EnterEvadeMode(); } } diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index f7139d06820..fca044ba411 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -703,6 +703,9 @@ void AreaAura::Update(uint32 diff) aur = new AreaAura(actualSpellInfo, m_effIndex, NULL, (*tIter), caster, NULL); aur->SetAuraDuration(GetAuraDuration()); (*tIter)->AddAura(aur); + + if(m_areaAuraType == AREA_AURA_ENEMY) + caster->CombatStart(*tIter); } } } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 39daf01415a..f607d24cb6d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -12769,6 +12769,9 @@ bool Unit::HandleAuraRaidProcFromCharge( Aura* triggeredByAura ) void Unit::SetToNotify() { + if(m_IsInNotifyList) + return; + if(Map *map = GetMap()) map->AddUnitToNotify(this); } |