Changeset 281
- Timestamp:
- 11/22/08 00:36:29 (17 years ago)
- Location:
- trunk/src
- Files:
-
- 16 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
r279 r281 7 7 * This program is distributed in the hope that it will be useful, 8 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 10 * GNU General Public License for more details. 11 11 * 12 12 * You should have received a copy of the GNU General Public License 13 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 15 */ 16 16 … … 965 965 DoZoneInCombat(); 966 966 } 967 break; 968 969 // TRINITY ONLY 970 case ACTION_T_SET_ACTIVE: 971 m_creature->setActive(param1 ? true : false); 972 break; 973 case ACTION_T_SET_AGGRESSIVE: 974 m_creature->SetAggressive(param1 ? true : false); 975 break; 976 case ACTION_T_ATTACK_START_PULSE: 977 AttackStart(m_creature->SelectNearestTarget((float)param1)); 967 978 break; 968 979 } … … 1193 1204 } 1194 1205 1195 if (m_creature->isCivilian() && m_creature->IsNeutralToAll()) 1196 return; 1197 1198 if (m_creature->canAttack(who) && who->isInAccessiblePlaceFor(m_creature) && m_creature->IsHostileTo(who)) 1199 { 1200 if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) 1201 return; 1202 1203 float attackRadius = m_creature->GetAttackDistance(who); 1204 if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) 1205 { 1206 //if(who->HasStealthAura()) 1207 // who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 1208 1209 //Begin melee attack if we are within range 1210 AttackStart(who); 1211 } 1212 } 1206 // do we need this? 1207 //if (m_creature->isCivilian() && m_creature->IsNeutralToAll()) 1208 // return; 1209 1210 if(m_creature->canStartAttack(who)) 1211 AttackStart(who); 1213 1212 } 1214 1213 … … 1293 1292 if (!((*i).Event.event_inverse_phase_mask & (1 << Phase))) 1294 1293 (*i).Time -= EventDiff; 1294 1295 1295 //Skip processing of events that have time remaining 1296 1296 continue; … … 1329 1329 if (Combat && MeleeEnabled) 1330 1330 DoMeleeAttackIfReady(); 1331 1331 1332 } 1332 1333 }; -
trunk/src/bindings/scripts/scripts/creature/mob_event_ai.h
r272 r281 1 1 /* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> 2 * This program is free software licensed under GPL version 23 * Please see the included DOCS/LICENSE.TXT for more information */2 * This program is free software licensed under GPL version 2 3 * Please see the included DOCS/LICENSE.TXT for more information */ 4 4 5 5 #ifndef SC_EVENTAI_H … … 77 77 ACTION_T_ZONE_COMBAT_PULSE = 38, //No Params 78 78 79 ACTION_T_SET_ACTIVE = 101, //Apply 80 ACTION_T_SET_AGGRESSIVE = 102, //Apply 81 ACTION_T_ATTACK_START_PULSE = 103, //Distance 82 79 83 ACTION_T_END, 80 84 }; -
trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp
r272 r281 302 302 data << value; 303 303 304 ((InstanceMap*)map)->SendToPlayers(&data);304 map->SendToPlayers(&data); 305 305 306 306 // TODO: Uncomment and remove everything above this line only when the core patch for this is accepted -
trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp
r279 r281 150 150 data << value; 151 151 152 ((InstanceMap*)instance)->SendToPlayers(&data);152 instance->SendToPlayers(&data); 153 153 } 154 154 -
trunk/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp
r279 r281 18 18 SDName: Hellfire_Peninsula 19 19 SD%Complete: 100 20 SDComment: Quest support: 10129, 10146, 10162, 10163, 10340, 10346, 10347, 10382 (Special flight paths)20 SDComment: Quest support: 9375, 10129, 10146, 10162, 10163, 10340, 10346, 10347, 10382 (Special flight paths) 21 21 SDCategory: Hellfire Peninsula 22 22 EndScriptData */ … … 26 26 npc_gryphoneer_windbellow 27 27 npc_wing_commander_brack 28 npc_wounded_blood_elf 28 29 EndContentData */ 29 30 30 31 #include "precompiled.h" 32 #include "../../npc/npc_escortAI.h" 31 33 32 34 /*###### … … 158 160 } 159 161 return true; 162 } 163 164 /*###### 165 ## npc_wounded_blood_elf 166 ######*/ 167 168 #define QUEST_THE_ROAD_TO_FALCON_WATCH 9375 169 #define SAY1 "Thank you for agreeing to help. Now, let's get out of here $N." 170 #define SAY2 "Over there! They're following us!" 171 #define SAY3 "Allow me a moment to rest. The journey taxes what little strength I have." 172 #define SAY4 "Did you hear something?" 173 #define SAY5 "Falcon Watch, at last! Now, where's my... Oh no! My pack, it's missing! Where has -" 174 #define SAYAGGRO "You won't keep me from getting to Falcon Watch!" 175 176 struct TRINITY_DLL_DECL npc_wounded_blood_elfAI : public npc_escortAI 177 { 178 npc_wounded_blood_elfAI(Creature *c) : npc_escortAI(c) {Reset();} 179 180 void WaypointReached(uint32 i) 181 { 182 Unit* player = Unit::GetUnit((*m_creature), PlayerGUID); 183 184 if (!player) 185 return; 186 187 switch (i) 188 { 189 190 case 0: 191 DoSay(SAY1, LANG_UNIVERSAL, player); 192 // Change faction, so mobs can attack 193 m_creature->setFaction(1610); 194 break; 195 196 case 9: 197 DoSay(SAY2, LANG_UNIVERSAL, player); 198 // Spawn two Haal'eshi Talonguard 199 { 200 Creature* temp1 = m_creature->SummonCreature(16967, m_creature->GetPositionX()-15, m_creature->GetPositionY()-15, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000); 201 if (temp1) temp1->AI()->AttackStart(m_creature); 202 Creature* temp2 = m_creature->SummonCreature(16967, m_creature->GetPositionX()-17, m_creature->GetPositionY()-17, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000); 203 if (temp2) temp2->AI()->AttackStart(m_creature); 204 } 205 break; 206 207 case 13: 208 DoSay(SAY3, LANG_UNIVERSAL, player); 209 // NPC "should" kneel 210 m_creature->HandleEmoteCommand(EMOTE_STATE_KNEEL); 211 break; 212 213 case 14: 214 DoSay(SAY4, LANG_UNIVERSAL, player); 215 // Spawn two Haal'eshi Windwalker 216 { 217 Creature* temp3 = m_creature->SummonCreature(16966, m_creature->GetPositionX()-15, m_creature->GetPositionY()-15, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000); 218 if (temp3) temp3->AI()->AttackStart(m_creature); 219 Creature* temp4 = m_creature->SummonCreature(16966, m_creature->GetPositionX()-17, m_creature->GetPositionY()-17, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000); 220 if (temp4) temp4->AI()->AttackStart(m_creature); 221 } 222 break; 223 224 case 27: 225 DoSay(SAY5, LANG_UNIVERSAL, player); 226 // Set faction back to normal 227 m_creature->setFaction(1604); 228 // Award quest credit 229 if( PlayerGUID ) 230 { 231 Unit* player = Unit::GetUnit((*m_creature), PlayerGUID); 232 if( player && player->GetTypeId() == TYPEID_PLAYER ) 233 ((Player*)player)->GroupEventHappens(9375,m_creature); 234 } 235 break; 236 } 237 } 238 239 void Aggro(Unit* who) 240 { 241 DoSay(SAYAGGRO, LANG_UNIVERSAL, who); 242 } 243 244 void Reset() { } 245 246 void JustDied(Unit* killer) 247 // If NPC dies, Quest fail 248 { 249 if (PlayerGUID) 250 { 251 Unit* player = Unit::GetUnit((*m_creature), PlayerGUID); 252 if (player) 253 ((Player*)player)->FailQuest(QUEST_THE_ROAD_TO_FALCON_WATCH); 254 } 255 } 256 257 void UpdateAI(const uint32 diff) 258 { 259 npc_escortAI::UpdateAI(diff); 260 } 261 }; 262 263 bool QuestAccept_wounded_blood_elf(Player* player, Creature* creature, Quest const* quest) 264 // Begin the escort quest 265 { 266 if (quest->GetQuestId() == QUEST_THE_ROAD_TO_FALCON_WATCH) 267 { 268 ((npc_escortAI*)(creature->AI()))->Start(true, true, false, player->GetGUID()); 269 } 270 return true; 271 } 272 273 CreatureAI* GetAI_npc_wounded_blood_elf(Creature *_Creature) 274 { 275 npc_wounded_blood_elfAI* thisAI = new npc_wounded_blood_elfAI(_Creature); 276 277 thisAI->AddWaypoint(0, -1137.72, 4272.10, 14.04, 3000); 278 thisAI->AddWaypoint(1, -1141.34, 4232.42, 14.63); 279 thisAI->AddWaypoint(2, -1133.47, 4220.88, 11.78); 280 thisAI->AddWaypoint(3, -1126.18, 4213.26, 13.51); 281 thisAI->AddWaypoint(4, -1100.12, 4204.32, 16.41); 282 thisAI->AddWaypoint(5, -1063.68, 4197.92, 15.51); 283 thisAI->AddWaypoint(6, -1027.28, 4194.36, 15.52); 284 thisAI->AddWaypoint(7, -995.68, 4189.59, 19.84); 285 thisAI->AddWaypoint(8, -970.90, 4188.60, 24.61); 286 thisAI->AddWaypoint(9, -961.93, 4193.34, 26.11, 80000); // Summon 1 287 thisAI->AddWaypoint(10, -935.52, 4210.99, 31.98); 288 thisAI->AddWaypoint(11, -913.42, 4218.27, 37.29); 289 thisAI->AddWaypoint(12, -896.53, 4207.73, 43.23); 290 thisAI->AddWaypoint(13, -868.49, 4194.77, 46.75, 17000); // Kneel and Rest Here 291 thisAI->AddWaypoint(14, -852.83, 4198.29, 47.28, 80000); // Summon 2 292 thisAI->AddWaypoint(15, -819.85, 4200.50, 46.37); 293 thisAI->AddWaypoint(16, -791.92, 4201.96, 44.19); 294 thisAI->AddWaypoint(17, -774.42, 4202.46, 47.41); 295 thisAI->AddWaypoint(18, -762.90, 4202.17, 48.81); 296 thisAI->AddWaypoint(19, -728.25, 4195.35, 50.68); 297 thisAI->AddWaypoint(20, -713.58, 4192.07, 53.98); 298 thisAI->AddWaypoint(21, -703.09, 4189.74, 56.96); 299 thisAI->AddWaypoint(22, -693.70, 4185.43, 57.06); 300 thisAI->AddWaypoint(23, -686.38, 4159.81, 60.26); 301 thisAI->AddWaypoint(24, -679.88, 4147.04, 64.20); 302 thisAI->AddWaypoint(25, -656.74, 4147.72, 64.11); 303 thisAI->AddWaypoint(26, -652.22, 4137.50, 64.58); 304 thisAI->AddWaypoint(27, -649.99, 4136.38, 64.63, 20000); // Award Quest Credit 305 306 return (CreatureAI*)thisAI; 160 307 } 161 308 … … 185 332 newscript->pGossipSelect = &GossipSelect_npc_wing_commander_brack; 186 333 newscript->RegisterSelf(); 187 } 334 335 newscript = new Script; 336 newscript->Name="npc_wounded_blood_elf"; 337 newscript->GetAI = &GetAI_npc_wounded_blood_elf; 338 newscript->pQuestAccept = &QuestAccept_wounded_blood_elf; 339 newscript->RegisterSelf(); 340 } -
trunk/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp
r279 r281 391 391 392 392 /*###### 393 ## mob_phase_hunter 394 ######*/ 395 396 #define SUMMONED_MOB 19595 397 #define EMOTE_WEAK "is very weak" 398 399 // Spells 400 #define SPELL_PHASE_SLIP 36574 401 #define SPELL_MANA_BURN 13321 402 403 struct TRINITY_DLL_DECL mob_phase_hunterAI : public ScriptedAI 404 { 405 406 mob_phase_hunterAI(Creature *c) : ScriptedAI(c) {Reset();} 407 408 bool Weak; 409 int WeakPercent; 410 uint32 PlayerGUID; 411 uint32 Health; 412 uint32 Level; 413 uint32 PhaseSlipVulnerabilityTimer; 414 uint32 ManaBurnTimer; 415 416 void Reset() 417 { 418 Weak = false; 419 WeakPercent = 25 + (rand()%16); // 25-40 420 PlayerGUID = 0; 421 ManaBurnTimer = 5000 + (rand()%3 * 1000); // 5-8 sec cd 422 } 423 424 void Aggro(Unit *who) 425 { 426 PlayerGUID = who->GetGUID(); 427 } 428 429 void UpdateAI(const uint32 diff) 430 { 431 432 Player* target = NULL; 433 target = ((Player*)Unit::GetUnit((*m_creature), PlayerGUID)); 434 435 if(!target) 436 return; 437 438 if(m_creature->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED) || m_creature->hasUnitState(UNIT_STAT_ROOT)) // if the mob is rooted/slowed by spells eg.: Entangling Roots, Frost Nova, Hamstring, Crippling Poison, etc. => remove it 439 DoCast(m_creature, SPELL_PHASE_SLIP); 440 if(ManaBurnTimer < diff) // cast Mana Burn 441 { 442 if(target->GetCreateMana() > 0) 443 { 444 DoCast(target, SPELL_MANA_BURN); 445 ManaBurnTimer = 8000 + (rand()%10 * 1000); // 8-18 sec cd 446 } 447 } 448 else ManaBurnTimer -= diff; 449 450 if(!Weak && m_creature->GetHealth() < (m_creature->GetMaxHealth() / 100 * WeakPercent) && target->GetQuestStatus(10190) == QUEST_STATUS_INCOMPLETE) // start: support for quest 10190 451 { 452 DoTextEmote(EMOTE_WEAK, 0); 453 Weak = true; 454 } 455 if(Weak && m_creature->HasAura(34219, 0)) 456 { 457 Health = m_creature->GetHealth(); // get the normal mob's data 458 Level = m_creature->getLevel(); 459 460 m_creature->AttackStop(); // delete the normal mob 461 m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); 462 m_creature->RemoveCorpse(); 463 464 Creature* DrainedPhaseHunter = NULL; 465 466 if(!DrainedPhaseHunter) 467 DrainedPhaseHunter = m_creature->SummonCreature(SUMMONED_MOB, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000); // summon the mob 468 469 if(DrainedPhaseHunter) 470 { 471 DrainedPhaseHunter->SetLevel(Level); // set the summoned mob's data 472 DrainedPhaseHunter->SetHealth(Health); 473 DrainedPhaseHunter->AI()->AttackStart(target); 474 } 475 } // end: support for quest 10190 476 } 477 478 }; 479 480 CreatureAI* GetAI_mob_phase_hunter(Creature *_Creature) 481 { 482 return new mob_phase_hunterAI (_Creature); 483 } 484 485 /*###### 393 486 ## 394 487 ######*/ … … 419 512 newscript->pGossipSelect = &GossipSelect_npc_veronia; 420 513 newscript->RegisterSelf(); 421 } 514 515 newscript = new Script; 516 newscript->Name = "mob_phase_hunter"; 517 newscript->GetAI = GetAI_mob_phase_hunter; 518 newscript->RegisterSelf(); 519 } -
trunk/src/bindings/scripts/scripts/zone/zulaman/boss_akilzon.cpp
r279 r281 170 170 data << uint32(weather) << (float)grade << uint8(0); 171 171 172 ((InstanceMap*)map)->SendToPlayers(&data);172 map->SendToPlayers(&data); 173 173 } 174 174 -
trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp
r279 r281 177 177 WorldPacket data(SMSG_UPDATE_WORLD_STATE, 8); 178 178 data << field << value; 179 ((InstanceMap*)instance)->SendToPlayers(&data);179 instance->SendToPlayers(&data); 180 180 } 181 181 -
trunk/src/game/GridStates.cpp
r272 r281 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 37 37 if( info.getTimeTracker().Passed() ) 38 38 { 39 if( grid.ActiveObjectsInGrid() == 0 && ! ObjectAccessor::Instance().ActiveObjectsNearGrid(x, y, m.GetId(), m.GetInstanceId()) )39 if( grid.ActiveObjectsInGrid() == 0 && !m.ActiveObjectsNearGrid(x, y) ) 40 40 { 41 41 ObjectGridStoper stoper(grid); … … 51 51 52 52 void 53 IdleState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 &x, const uint32 &y, const uint32 &) const53 IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32 &x, const uint32 &y, const uint32 &) const 54 54 { 55 55 m.ResetGridExpiry(grid); -
trunk/src/game/Map.cpp
r279 r281 595 595 } 596 596 597 void Map::Update(const uint32 &t_diff) 598 { 599 // TODO: need have an active object list for every map 600 601 /*resetMarkedCells(); 602 597 void Map::UpdateActiveCells(const float &x, const float &y, const uint32 &t_diff) 598 { 599 CellPair standing_cell(Trinity::ComputeCellPair(x, y)); 600 601 // Check for correctness of standing_cell, it also avoids problems with update_cell 602 if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) 603 return; 604 605 // will this reduce the speed? 603 606 Trinity::ObjectUpdater updater(t_diff); 604 607 // for creature … … 607 610 TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater); 608 611 612 // the overloaded operators handle range checking 613 // so ther's no need for range checking inside the loop 614 CellPair begin_cell(standing_cell), end_cell(standing_cell); 615 begin_cell << 1; begin_cell -= 1; // upper left 616 end_cell >> 1; end_cell += 1; // lower right 617 618 for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x) 619 { 620 for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) 621 { 622 // marked cells are those that have been visited 623 // don't visit the same cell twice 624 uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x; 625 if(!isCellMarked(cell_id)) 626 { 627 markCell(cell_id); 628 CellPair pair(x,y); 629 Cell cell(pair); 630 cell.data.Part.reserved = CENTER_DISTRICT; 631 cell.SetNoCreate(); 632 CellLock<NullGuard> cell_lock(cell, pair); 633 cell_lock->Visit(cell_lock, grid_object_update, *this); 634 cell_lock->Visit(cell_lock, world_object_update, *this); 635 } 636 } 637 } 638 } 639 640 void Map::Update(const uint32 &t_diff) 641 { 642 resetMarkedCells(); 643 644 // update cells around players 609 645 for(MapRefManager::iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) 610 646 { 611 647 Player* plr = iter->getSource(); 612 if(!plr->IsInWorld()) 613 continue; 614 615 CellPair standing_cell(Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY())); 616 617 // Check for correctness of standing_cell, it also avoids problems with update_cell 618 if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) 619 continue; 620 621 // the overloaded operators handle range checking 622 // so ther's no need for range checking inside the loop 623 CellPair begin_cell(standing_cell), end_cell(standing_cell); 624 begin_cell << 1; begin_cell -= 1; // upper left 625 end_cell >> 1; end_cell += 1; // lower right 626 627 for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x) 628 { 629 for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) 630 { 631 // marked cells are those that have been visited 632 // don't visit the same cell twice 633 uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x; 634 if(!isCellMarked(cell_id)) 635 { 636 markCell(cell_id); 637 CellPair pair(x,y); 638 Cell cell(pair); 639 cell.data.Part.reserved = CENTER_DISTRICT; 640 cell.SetNoCreate(); 641 CellLock<NullGuard> cell_lock(cell, pair); 642 cell_lock->Visit(cell_lock, grid_object_update, *this); 643 cell_lock->Visit(cell_lock, world_object_update, *this); 644 } 645 } 646 } 647 }*/ 648 if(plr->IsInWorld()) 649 UpdateActiveCells(plr->GetPositionX(), plr->GetPositionY(), t_diff); 650 } 651 652 // update cells around active objects 653 // clone the active object list, because update might remove from it 654 std::set<WorldObject *> activeObjects(i_activeObjects); 655 for(std::set<WorldObject *>::iterator iter = activeObjects.begin(); iter != activeObjects.end(); ++iter) 656 { 657 if((*iter)->IsInWorld()) 658 UpdateActiveCells((*iter)->GetPositionX(), (*iter)->GetPositionY(), t_diff); 659 } 648 660 649 661 // 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 ! … … 814 826 AddCreatureToMoveList(creature,x,y,z,ang); 815 827 // in diffcell/diffgrid case notifiers called at finishing move creature in Map::MoveAllCreaturesInMoveList 816 if(creature->isPossessedByPlayer()) 817 EnsureGridLoadedForPlayer(new_cell, (Player*)creature->GetCharmer(), false); 828 if(creature->isActive()) 829 { 830 if(creature->isPossessedByPlayer()) 831 EnsureGridLoadedForPlayer(new_cell, (Player*)creature->GetCharmer(), false); 832 else 833 EnsureGridLoadedForPlayer(new_cell, NULL, false); 834 } 818 835 } 819 836 else … … 1502 1519 1503 1520 CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY()); 1521 if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && 1522 (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) 1523 return true; 1524 } 1525 1526 return false; 1527 } 1528 1529 bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const 1530 { 1531 CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS); 1532 CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); 1533 cell_min << 2; 1534 cell_min -= 2; 1535 cell_max >> 2; 1536 cell_max += 2; 1537 1538 for(MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) 1539 { 1540 Player* plr = iter->getSource(); 1541 1542 CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY()); 1543 if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && 1544 (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) 1545 return true; 1546 } 1547 1548 for(std::set<WorldObject*>::const_iterator itr = i_activeObjects.begin(); itr != i_activeObjects.end(); ++itr) 1549 { 1550 CellPair p = Trinity::ComputeCellPair((*itr)->GetPositionX(), (*itr)->GetPositionY()); 1504 1551 if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && 1505 1552 (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) -
trunk/src/game/Map.h
r279 r281 243 243 uint32 GetPlayersCountExceptGMs() const; 244 244 bool PlayersNearGrid(uint32 x,uint32 y) const; 245 bool ActiveObjectsNearGrid(uint32 x, uint32 y) const; 246 247 void AddActiveObject(WorldObject* obj) { i_activeObjects.insert(obj); } 248 void RemoveActiveObject(WorldObject* obj) { i_activeObjects.erase(obj); } 245 249 246 250 void SendToPlayers(WorldPacket const* data) const; … … 288 292 inline void setNGrid(NGridType* grid, uint32 x, uint32 y); 289 293 294 void UpdateActiveCells(const float &x, const float &y, const uint32 &t_diff); 290 295 protected: 291 296 typedef Trinity::ObjectLevelLockable<Map, ZThread::Mutex>::Lock Guard; … … 308 313 time_t i_gridExpiry; 309 314 315 std::set<WorldObject *> i_activeObjects; 310 316 std::set<WorldObject *> i_objectsToRemove; 311 317 -
trunk/src/game/Object.cpp
r272 r281 991 991 WorldObject::~WorldObject() 992 992 { 993 if(m_isActive && IsInWorld())994 ObjectAccessor::Instance().RemoveActiveObject(this);993 if(m_isActive && !isType(TYPEMASK_PLAYER) && IsInWorld()) 994 GetMap()->RemoveActiveObject(this); 995 995 } 996 996 … … 998 998 { 999 999 // if already in the same activity state as we try to set, do nothing 1000 if(isActive == m_isActive )1000 if(isActive == m_isActive || isType(TYPEMASK_PLAYER)) 1001 1001 return; 1002 1002 1003 m_isActive = isActive; 1003 1004 if(IsInWorld()) 1004 1005 { 1005 1006 if(isActive) 1006 ObjectAccessor::Instance().AddActiveObject(this);1007 GetMap()->AddActiveObject(this); 1007 1008 else 1008 ObjectAccessor::Instance().RemoveActiveObject(this);1009 GetMap()->RemoveActiveObject(this); 1009 1010 } 1010 1011 } … … 1013 1014 { 1014 1015 Object::AddToWorld(); 1015 if(m_isActive )1016 ObjectAccessor::Instance().AddActiveObject(this);1016 if(m_isActive && !isType(TYPEMASK_PLAYER)) 1017 GetMap()->AddActiveObject(this); 1017 1018 } 1018 1019 1019 1020 void WorldObject::RemoveFromWorld() 1020 1021 { 1021 if(m_isActive )1022 ObjectAccessor::Instance().RemoveActiveObject(this);1022 if(m_isActive && !isType(TYPEMASK_PLAYER)) 1023 GetMap()->RemoveActiveObject(this); 1023 1024 Object::RemoveFromWorld(); 1024 1025 } -
trunk/src/game/Object.h
r272 r281 456 456 GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime); 457 457 bool isActive() const { return m_isActive; } 458 v irtual void setActive(bool isActive);458 void setActive(bool isActive); 459 459 protected: 460 460 explicit WorldObject(); -
trunk/src/game/ObjectAccessor.cpp
r279 r281 488 488 489 489 void 490 ObjectAccessor::AddActiveObject( WorldObject * obj )491 {492 i_activeobjects.insert(obj);493 }494 495 void496 ObjectAccessor::RemoveActiveObject( WorldObject * obj )497 {498 i_activeobjects.erase(obj);499 }500 501 void502 490 ObjectAccessor::Update(uint32 diff) 503 491 { 504 505 { 492 /* { 506 493 //Player update now in MapManager -> UpdatePlayers 507 /*508 494 // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. 509 495 HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); … … 514 500 iter->second->Update(diff); 515 501 } 516 } */502 } 517 503 518 504 // TODO: move this to Map::Update … … 575 561 } 576 562 } 577 } 563 }*/ 578 564 579 565 UpdateDataMapType update_players; … … 609 595 } 610 596 611 bool612 ObjectAccessor::ActiveObjectsNearGrid(uint32 x, uint32 y, uint32 m_id, uint32 i_id) const613 {614 CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS);615 CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);616 cell_min << 2;617 cell_min -= 2;618 cell_max >> 2;619 cell_max += 2;620 621 for(std::set<WorldObject*>::const_iterator itr = i_activeobjects.begin(); itr != i_activeobjects.end(); ++itr)622 {623 if( m_id != (*itr)->GetMapId() || i_id != (*itr)->GetInstanceId() )624 continue;625 626 CellPair p = Trinity::ComputeCellPair((*itr)->GetPositionX(), (*itr)->GetPositionY());627 if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&628 (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) )629 return true;630 }631 632 return false;633 }634 635 597 void 636 598 ObjectAccessor::WorldObjectChangeAccumulator::Visit(PlayerMapType &m) -
trunk/src/game/ObjectAccessor.h
r279 r281 195 195 Corpse* ConvertCorpseForPlayer(uint64 player_guid); 196 196 197 bool ActiveObjectsNearGrid(uint32 x,uint32 y,uint32 m_id,uint32 i_id) const;198 199 197 static void UpdateObject(Object* obj, Player* exceptPlayer); 200 198 static void _buildUpdateObject(Object* obj, UpdateDataMapType &); … … 202 200 static void UpdateObjectVisibility(WorldObject* obj); 203 201 static void UpdateVisibilityForPlayer(Player* player); 204 205 void AddActiveObject(WorldObject*);206 void RemoveActiveObject(WorldObject*);207 202 private: 208 203 struct WorldObjectChangeAccumulator … … 229 224 void _update(void); 230 225 std::set<Object *> i_objects; 231 std::set<WorldObject *> i_activeobjects;232 226 LockType i_playerGuard; 233 227 LockType i_updateGuard; -
trunk/src/game/Player.h
r279 r281 898 898 void AddToWorld(); 899 899 void RemoveFromWorld(); 900 // always active901 void setActive(bool) {}902 900 903 901 void SetViewport(uint64 guid, bool movable);