Show
Ignore:
Timestamp:
11/22/08 00:36:22 (17 years ago)
Author:
yumileroy
Message:

Merged commit 269 (5f0e38da128a).

Original author: gvcoman
Date: 2008-11-21 14:34:05-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Creature.cpp

    r272 r279  
    123123m_lootMoney(0), m_lootRecipient(0), 
    124124m_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), 
     125m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_isAggressive(true), 
    126126m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), 
    127127m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), 
     
    182182    float x,y,z,o; 
    183183    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); 
    185185} 
    186186 
     
    214214    } 
    215215 
    216     SetUInt32Value(OBJECT_FIELD_ENTRY, Entry);              // normal entry always 
     216    SetEntry(Entry);                                        // normal entry always 
    217217    m_creatureInfo = cinfo;                                 // map mode related always 
    218218 
     
    298298    SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags); 
    299299 
     300    SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); 
    300301    SetModifierValue(UNIT_MOD_ARMOR,             BASE_VALUE, float(GetCreatureInfo()->armor)); 
    301302    SetModifierValue(UNIT_MOD_RESISTANCE_HOLY,   BASE_VALUE, float(GetCreatureInfo()->resistance1)); 
     
    328329        SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); 
    329330 
     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 
    330337    return true; 
    331338} 
     
    357364                lootForBody         = false; 
    358365 
    359                 if(m_originalEntry != GetUInt32Value(OBJECT_FIELD_ENTRY)) 
     366                if(m_originalEntry != GetEntry()) 
    360367                    UpdateEntry(m_originalEntry); 
    361368 
     
    376383 
    377384                //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); 
    381388            } 
    382389            break; 
     
    440447                // do not allow the AI to be changed during update 
    441448                m_AI_locked = true; 
    442                 AI()->UpdateAI(diff); 
     449                i_AI->UpdateAI(diff); 
    443450                m_AI_locked = false; 
    444451            } 
     
    14121419    SetPower(POWER_MANA,data->curmana); 
    14131420 
    1414     SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); 
    1415  
    14161421    // checked at creature_template loading 
    14171422    m_defaultMovementType = MovementGeneratorType(data->movementType); 
     
    15381543{ 
    15391544    return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER)); 
     1545} 
     1546 
     1547bool 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); 
    15401558} 
    15411559 
     
    18191837} 
    18201838 
     1839Unit* 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 
    18211863void Creature::CallAssistence() 
    18221864{ 
     
    20982140} 
    20992141 
    2100 char const* Creature::GetScriptName() const 
    2101 { 
    2102     return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptName; 
     2142std::string Creature::GetScriptName() 
     2143{ 
     2144    return objmgr.GetScriptName(GetScriptId()); 
     2145} 
     2146 
     2147uint32 Creature::GetScriptId() 
     2148{ 
     2149    return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID; 
    21032150} 
    21042151