Показать сообщение отдельно
Непрочитано 27.06.2011, 23:00   #20
Аватар для Azagthtot
Эксперт

По умолчанию Re: Вытянуть значение из базы


Вы уж простите за откровенность, но вы пошли по принципу "Если что-то можно сделать через ж... то надо именно так и делать"
С вашим методом саммоны будут грызть кого угодно.
И так, как стоит сделать
Код:
public boolean isAutoAttackable(L2Character attacker) 
    { 

        // Check if the attacker isn't the L2PcInstance Pet 
        if (attacker == this || attacker == getPet()) 
            return false; 
     
        // TODO: check for friendly mobs 
        // Check if the attacker is a L2MonsterInstance 
        if (attacker instanceof L2MonsterInstance) 
            return true; 

        // Check if the attacker is not in the same party 
        if (getParty() != null && getParty().getPartyMembers().contains(attacker)) 
            return false; 

        // Check if the attacker is in olympia and olympia start 
        if (attacker instanceof L2PcInstance && ((L2PcInstance)attacker).isInOlympiadMode() ){ 
            if (isInOlympiadMode() && isOlympiadStart() && ((L2PcInstance)attacker).getOlympiadGameId()==getOlympiadGameId()) 
                return true; 
            else 
                return false; 
        } 

        // Check if the attacker is in TvT and TvT is started 
        if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getObjectId())) 
            return true; 
                
        if(attacker instanceof L2Playable) {
          L2Player cha = attacker.getActingPlayer();
          if(getSpiritId() == ((L2PcInstance)cha).getSpiritId())
                      return false;
       }
                // Check if clan is at war 

        // Check if the attacker is not in the same clan 
        if (getClan() != null && attacker != null && getClan().isMember(attacker.getObjectId())) 
            return false; 

        if(attacker instanceof L2Playable && isInsideZone(ZONE_PEACE)) 
            return false; 

        // Check if the L2PcInstance has Karma 
        if (getKarma() > 0 || getPvpFlag() > 0) 
            return true; 

        // Check if the attacker is a L2Playable 
        if (attacker instanceof L2Playable) 
        { 
            // Get L2PcInstance 
            L2PcInstance cha = attacker.getActingPlayer(); 
             
            // is AutoAttackable if both players are in the same duel and the duel is still going on 
            if ( getDuelState() == Duel.DUELSTATE_DUELLING 
                    && getDuelId() == cha.getDuelId()) 
                return true; 
            // Check if the L2PcInstance is in an arena or a siege area 
            if (isInsideZone(ZONE_PVP) && cha.isInsideZone(ZONE_PVP)) 
                return true; 

            if (getClan() != null) 
            { 
                Siege siege = SiegeManager.getInstance().getSiege(getX(), getY(), getZ()); 
                if (siege != null) 
                { 
                    // Check if a siege is in progress and if attacker and the L2PcInstance aren't in the Defender clan 
                    if (siege.checkIsDefender(cha.getClan()) && 
                            siege.checkIsDefender(getClan())) 
                        return false; 

                    // Check if a siege is in progress and if attacker and the L2PcInstance aren't in the Attacker clan 
                    if (siege.checkIsAttacker(cha.getClan()) && 
                            siege.checkIsAttacker(getClan())) 
                        return false; 
                } 
                if (getClan() != null && cha.getClan() != null 
                                           && getClan().isAtWarWith(cha.getClanId()) 
                                           && cha.getClan().isAtWarWith(getClanId()) 
                                           && getWantsPeace() == 0 
                                           && cha.getWantsPeace() == 0 
                                           && !isAcademyMember()) 
                return true; 
            } 
        } 
        else if (attacker instanceof L2DefenderInstance) 
        { 
            if (getClan() != null) 
            { 
                Siege siege = SiegeManager.getInstance().getSiege(this); 
                return (siege != null && siege.checkIsAttacker(getClan())); 
            } 
        } 
        return false; 
    }
Azagthtot вне форума Отправить сообщение для Azagthtot с помощью ICQ Отправить сообщение для Azagthtot с помощью Skype™ Ответить с цитированием
Сказали спасибо: