Show
Ignore:
Timestamp:
11/21/08 16:54:14 (17 years ago)
Author:
yumileroy
Message:

*Let creature search nearby target before enter evade mode
*Add function canStartAttack to reduce code in MoveInLineOfSight?
*Fix a bug that cancelling bind sight auras may crash the server

Original author: megamage
Date: 2008-11-21 10:07:11-06:00

Files:
1 modified

Legend:

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

    r266 r267  
    15441544} 
    15451545 
     1546bool Creature::canStartAttack(Unit const* who) const 
     1547{ 
     1548    if(!who->isInAccessiblePlaceFor(this) 
     1549        || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE 
     1550        || !IsWithinDistInMap(who, GetAttackDistance(who))) 
     1551        return false; 
     1552 
     1553    if(!canAttack(who)) 
     1554        return false; 
     1555 
     1556    return IsWithinLOSInMap(who); 
     1557} 
     1558 
    15461559float Creature::GetAttackDistance(Unit const* pl) const 
    15471560{ 
     
    18251838Unit* Creature::SelectNearestTarget(float dist) const 
    18261839{ 
    1827     /*CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); 
     1840    CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); 
    18281841    Cell cell(p); 
    18291842    cell.data.Part.reserved = ALL_DISTRICT; 
    18301843    cell.SetNoCreate(); 
    18311844 
    1832     Unit *target; 
     1845    Unit *target = NULL; 
    18331846 
    18341847    { 
     
    18401853 
    18411854        CellLock<GridReadGuard> cell_lock(cell, p); 
    1842         cell_lock->Visit(cell_lock, world_unit_searcher, GetMap()); 
    1843         cell_lock->Visit(cell_lock, grid_unit_searcher, GetMap()); 
    1844     }*/ 
    1845     return NULL; 
     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; 
    18461860} 
    18471861