Ejemplo n.º 1
0
// called when we create a new monster [attack players?]
bool CMonster::OnSpawn( bool Attack )
{
     lastSighCheck = clock();
    if(IsGhost( ) && Attack )
    {
        CPlayer* player = GetNearPlayer( );
        if(player==NULL) // no players or too far
            return true;
        StartAction( (CCharacter*)player, NORMAL_ATTACK, 0 );
    }

    return true;
}
Ejemplo n.º 2
0
// update attack values and destiny  position
bool CMonster::UpdateValues( )
{       
    //LMA: Some special case where special monsters stay still (mc, bonfires and so on...)
    if(stay_still&&(!IsBonfire()))
       return true;
        
    if(IsSummon( ) && CanMove( ))
    {
        CPlayer* thisclient = GetOwner( );
        if(thisclient!=NULL)
        {               
            if(!IsBonfire())
            {
                if(!IsOnBattle( ) && thisclient->IsAttacking( ))
                {
                    Battle->target = thisclient->Battle->target;
                    Battle->atktarget = Battle->target;
                    Battle->atktype = NORMAL_ATTACK;
                    Battle->contatk = true;
                    CCharacter* Enemy = GetCharTarget( );
                    if(Enemy!=NULL)
                        StartAction( Enemy, NORMAL_ATTACK );
                }
                else
                if(!IsOnBattle( ))
                {
                    Position->source = thisclient->Position->current;
                    float distance = GServer->distance( Position->destiny , thisclient->Position->current );
                    if((distance>15 && !IsOnBattle()) || distance>50)
                        Move( );                
                }
            
            }
            else
            {
                //LMA: Let's kill bonfires if owner too far away :).
                float distance = GServer->distance( Position->current , thisclient->Position->current );
                if(distance>25)
                {
                   UnspawnMonster( );
                   return false;                
                }
                
                return true;
            }
            
        }
        else
        {
            UnspawnMonster( );
            return false;
        }
    }                           
    if(!IsMoving( ) && !IsOnBattle( ) && CanMove( ))        
    {         
        clock_t etime = clock() - Position->lastMoveTime;  
        if(etime > 20*CLOCKS_PER_SEC) 
            Move( );    
    }
    if(!IsSummon( ))
    {
        CPlayer* player = GetNearPlayer( 10 );
        if(player!=NULL)
            OnEnemyOnSight( player );
    } 
    return true;
}