Changeset 279 for trunk/src/game/Creature.cpp
- Timestamp:
- 11/22/08 00:36:22 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Creature.cpp
r272 r279 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), 125 m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_isAggressive(true), 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), … … 182 182 float x,y,z,o; 183 183 GetRespawnCoord(x, y, z, &o); 184 MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,o);184 GetMap()->CreatureRelocation(this,x,y,z,o); 185 185 } 186 186 … … 214 214 } 215 215 216 Set UInt32Value(OBJECT_FIELD_ENTRY, Entry);// normal entry always216 SetEntry(Entry); // normal entry always 217 217 m_creatureInfo = cinfo; // map mode related always 218 218 … … 298 298 SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags); 299 299 300 SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); 300 301 SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor)); 301 302 SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(GetCreatureInfo()->resistance1)); … … 328 329 SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); 329 330 331 if(isTotem() || isCivilian() || GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER 332 || GetCreatureType() == CREATURE_TYPE_CRITTER) 333 m_isAggressive = false; 334 else 335 m_isAggressive = true; 336 330 337 return true; 331 338 } … … 357 364 lootForBody = false; 358 365 359 if(m_originalEntry != Get UInt32Value(OBJECT_FIELD_ENTRY))366 if(m_originalEntry != GetEntry()) 360 367 UpdateEntry(m_originalEntry); 361 368 … … 376 383 377 384 //Call AI respawn virtual function 378 AI()->JustRespawned();379 380 MapManager::Instance().GetMap(GetMapId(), this)->Add(this);385 i_AI->JustRespawned(); 386 387 GetMap()->Add(this); 381 388 } 382 389 break; … … 440 447 // do not allow the AI to be changed during update 441 448 m_AI_locked = true; 442 AI()->UpdateAI(diff);449 i_AI->UpdateAI(diff); 443 450 m_AI_locked = false; 444 451 } … … 1412 1419 SetPower(POWER_MANA,data->curmana); 1413 1420 1414 SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool));1415 1416 1421 // checked at creature_template loading 1417 1422 m_defaultMovementType = MovementGeneratorType(data->movementType); … … 1538 1543 { 1539 1544 return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER)); 1545 } 1546 1547 bool Creature::canStartAttack(Unit const* who) const 1548 { 1549 if(!who->isInAccessiblePlaceFor(this) 1550 || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE 1551 || !IsWithinDistInMap(who, GetAttackDistance(who))) 1552 return false; 1553 1554 if(!canAttack(who)) 1555 return false; 1556 1557 return IsWithinLOSInMap(who); 1540 1558 } 1541 1559 … … 1819 1837 } 1820 1838 1839 Unit* Creature::SelectNearestTarget(float dist) const 1840 { 1841 CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); 1842 Cell cell(p); 1843 cell.data.Part.reserved = ALL_DISTRICT; 1844 cell.SetNoCreate(); 1845 1846 Unit *target = NULL; 1847 1848 { 1849 Trinity::NearestHostileUnitInAttackDistanceCheck u_check(this, dist); 1850 Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck> searcher(target, u_check); 1851 1852 TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); 1853 TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); 1854 1855 CellLock<GridReadGuard> cell_lock(cell, p); 1856 cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap()); 1857 cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap()); 1858 } 1859 1860 return target; 1861 } 1862 1821 1863 void Creature::CallAssistence() 1822 1864 { … … 2098 2140 } 2099 2141 2100 char const* Creature::GetScriptName() const 2101 { 2102 return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptName; 2142 std::string Creature::GetScriptName() 2143 { 2144 return objmgr.GetScriptName(GetScriptId()); 2145 } 2146 2147 uint32 Creature::GetScriptId() 2148 { 2149 return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID; 2103 2150 } 2104 2151