Changeset 272 for trunk/src/game/Creature.cpp
- Timestamp:
- 11/22/08 00:35:41 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Creature.cpp
r267 r272 123 123 m_lootMoney(0), m_lootRecipient(0), 124 124 m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f), 125 m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_isAggressive(true),125 m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), 126 126 m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), 127 127 m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), … … 148 148 i_AI = NULL; 149 149 150 DeletePossessedAI(); 150 if (i_AI_possessed) 151 { 152 delete i_AI_possessed; 153 i_AI_possessed = NULL; 154 } 151 155 } 152 156 … … 178 182 float x,y,z,o; 179 183 GetRespawnCoord(x, y, z, &o); 180 GetMap()->CreatureRelocation(this,x,y,z,o);184 MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,o); 181 185 } 182 186 … … 210 214 } 211 215 212 Set Entry(Entry);// normal entry always216 SetUInt32Value(OBJECT_FIELD_ENTRY, Entry); // normal entry always 213 217 m_creatureInfo = cinfo; // map mode related always 214 218 … … 294 298 SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags); 295 299 296 SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool));297 300 SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor)); 298 301 SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(GetCreatureInfo()->resistance1)); … … 325 328 SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); 326 329 327 if(isTotem() || isCivilian() || GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER328 || GetCreatureType() == CREATURE_TYPE_CRITTER)329 m_isAggressive = false;330 else331 m_isAggressive = true;332 333 330 return true; 334 331 } … … 360 357 lootForBody = false; 361 358 362 if(m_originalEntry != Get Entry())359 if(m_originalEntry != GetUInt32Value(OBJECT_FIELD_ENTRY)) 363 360 UpdateEntry(m_originalEntry); 364 361 … … 379 376 380 377 //Call AI respawn virtual function 381 i_AI->JustRespawned();382 383 GetMap()->Add(this);378 AI()->JustRespawned(); 379 380 MapManager::Instance().GetMap(GetMapId(), this)->Add(this); 384 381 } 385 382 break; … … 443 440 // do not allow the AI to be changed during update 444 441 m_AI_locked = true; 445 i_AI->UpdateAI(diff);442 AI()->UpdateAI(diff); 446 443 m_AI_locked = false; 447 444 } … … 563 560 } 564 561 565 void Creature::D eletePossessedAI()562 void Creature::DisablePossessedAI() 566 563 { 567 564 if (!i_AI_possessed) return; 568 569 delete i_AI_possessed;570 i_AI_possessed = NULL;571 565 572 566 // Signal the old AI that it's been re-enabled … … 1418 1412 SetPower(POWER_MANA,data->curmana); 1419 1413 1414 SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); 1415 1420 1416 // checked at creature_template loading 1421 1417 m_defaultMovementType = MovementGeneratorType(data->movementType); … … 1542 1538 { 1543 1539 return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER)); 1544 }1545 1546 bool Creature::canStartAttack(Unit const* who) const1547 {1548 if(!who->isInAccessiblePlaceFor(this)1549 || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE1550 || !IsWithinDistInMap(who, GetAttackDistance(who)))1551 return false;1552 1553 if(!canAttack(who))1554 return false;1555 1556 return IsWithinLOSInMap(who);1557 1540 } 1558 1541 … … 1836 1819 } 1837 1820 1838 Unit* Creature::SelectNearestTarget(float dist) const1839 {1840 CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));1841 Cell cell(p);1842 cell.data.Part.reserved = ALL_DISTRICT;1843 cell.SetNoCreate();1844 1845 Unit *target = NULL;1846 1847 {1848 Trinity::NearestHostileUnitInAttackDistanceCheck u_check(this, dist);1849 Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck> searcher(target, u_check);1850 1851 TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);1852 TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);1853 1854 CellLock<GridReadGuard> cell_lock(cell, p);1855 cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap());1856 cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap());1857 }1858 1859 return target;1860 }1861 1862 1821 void Creature::CallAssistence() 1863 1822 { … … 2139 2098 } 2140 2099 2141 std::string Creature::GetScriptName() 2142 { 2143 return objmgr.GetScriptName(GetScriptId()); 2144 } 2145 2146 uint32 Creature::GetScriptId() 2147 { 2148 return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID; 2100 char const* Creature::GetScriptName() const 2101 { 2102 return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptName; 2149 2103 } 2150 2104