Проблема с движением Agathion

katowice

Выдающийся
Местный
Сообщения
143
Розыгрыши
0
Решения
1
Репутация
15
Реакции
73
Баллы
1 373
Хроники
  1. Interlude
Исходники
Присутствуют
Сборка
ruAcis 3.8
Здравствуйте сборка aCis 3.8 наблюдается проблема с движением агатиона сколько то летит потом встает на 1 сек
В
public void followToOwner()
{
if (owner == null)
return;
setTarget(owner);

if (_followTask == null)
_followTask = ThreadPool.scheduleAtFixedRate(new Follow(this), 100, 100);

getPosition().setHeading(owner.getHeading());
int rnd = Rnd.get(-15, +15);
Location toMoveLoc = new Location(owner.getX(), owner.getY(), owner.getZ());

if (!isIn2DRadius(owner, 2000))
{
teleportTo(owner.getPosition().clone(), rnd);
return;
}
if (!isIn2DRadius(owner, 50) && !isMoving())
{
getMove().maybeMoveToLocation(toMoveLoc, rnd, true, false);
return;
}
if (isIn2DRadius(owner, 30))
{
getMove().stop();
getAI().thinkIdle();
return;
}
getMove().maybeMoveToLocation(toMoveLoc, rnd, true, false);
}
Если делаю так _followTask = ThreadPool.scheduleAtFixedRate(new Follow(this), 10, 10); то все становиться нормально но как это повлияет на нагрузку
 
Agathion.java приложил
Java:
package net.sf.l2j.gameserver.model.actor.instance;

import java.util.concurrent.Future;

import net.sf.l2j.commons.pool.ThreadPool;
import net.sf.l2j.commons.random.Rnd;

import net.sf.l2j.gameserver.model.actor.Npc;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.model.location.Location;
import net.sf.l2j.gameserver.network.serverpackets.PetDelete;

/**
 * @author maxi5
 */
public class Agathion extends Npc
{
    private Player owner;
    private Future<?> _followTask;
    
    private ItemInstance item;
    
    public Agathion(int objectId, NpcTemplate template, Player owner)
    {
        super(objectId, template);
        
        // Set the magical circle animation.
        setShowSummonAnimation(true);
        
        // Set the Player owner.
        this.owner = owner;
    }
    
    @Override
    public void onSpawn()
    {
        disableCoreAi(true);
        setSpawnLocation(getPosition());
        followToOwner();
        super.onSpawn();
    }
    
    public void unSummon(Player owner)
    {
        // Abort attack, cast and move.
        abortAll(true);
        
        if (item != null)
            item.setAgathion(owner, false);
        
        owner.sendPacket(new PetDelete(2, getObjectId()));
        owner.setAgathion(null);
        
        if (owner.getSummon() != null)
            owner.getSummon().sendInfo(owner);
        owner.broadcastUserInfo();
        
        if (_followTask != null)
            _followTask.cancel(true);
        
        decayMe();
        deleteMe();
        
        super.deleteMe();
    }
    
    public void followToOwner()
    {
        if (owner == null)
            return;
        setTarget(owner);
        
        if (_followTask == null)
            _followTask = ThreadPool.scheduleAtFixedRate(new Follow(this), 1000, 1000);
        
        getPosition().setHeading(owner.getHeading());
        int rnd = Rnd.get(-15, +15);
        Location toMoveLoc = new Location(owner.getX(), owner.getY(), owner.getZ());
        
        if (!isIn2DRadius(owner, 2000))
        {
            teleportTo(owner.getPosition().clone(), rnd);
            return;
        }
        if (!isIn2DRadius(owner, 50) && !isMoving())
        {
            getMove().maybeMoveToLocation(toMoveLoc, rnd, true, false);
            return;
        }
        if (isIn2DRadius(owner, 30))
        {
            getMove().stop();
            getAI().thinkIdle();
            return;
        }
        getMove().maybeMoveToLocation(toMoveLoc, rnd, true, false);
    }
    
    @Override
    public boolean isInMyTerritory()
    {
        return false;
    }
    
    private static class Follow implements Runnable
    {
        private final Agathion agathion;
        
        protected Follow(Agathion aga)
        {
            agathion = aga;
        }
        
        @Override
        public void run()
        {
            agathion.followToOwner();
        }
    }
    
    public void setAgathionItem(ItemInstance item)
    {
        this.item = item;
    }
    
    public Player getOwner()
    {
        return owner;
    }
}
 
package net.sf.l2j.gameserver.model.actor.instance;

import java.util.concurrent.Future;

import net.sf.l2j.commons.pool.ThreadPool;
import net.sf.l2j.commons.random.Rnd;

import net.sf.l2j.gameserver.model.actor.Npc;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.model.location.Location;
import net.sf.l2j.gameserver.network.serverpackets.PetDelete;




public class Agathion extends Npc
{
private Player owner;
private Future<?> _followTask;

private ItemInstance item;

public Agathion(int objectId, NpcTemplate template, Player owner)
{
super(objectId, template);


setShowSummonAnimation(true);


this.owner = owner;
}

@Override
public void onSpawn()
{
disableCoreAi(true);
setSpawnLocation(getPosition());

if (_followTask == null)
_followTask = ThreadPool.scheduleAtFixedRate(new Follow(this), 1000, 1000);

super.onSpawn();
}

public void unSummon(Player owner)
{

abortAll(true);

if (item != null)
item.setAgathion(owner, false);

owner.sendPacket(new PetDelete(2, getObjectId()));
owner.setAgathion(null);

if (owner.getSummon() != null)
owner.getSummon().sendInfo(owner);
owner.broadcastUserInfo();

if (_followTask != null)
{
_followTask.cancel(true);
_followTask = null;
}

decayMe();
deleteMe();


}

public void followToOwner()
{
Player currentOwner = this.owner;
if (currentOwner == null)
return;

setTarget(currentOwner);




getPosition().setHeading(currentOwner.getHeading());
int rnd = Rnd.get(-15, +15);
Location toMoveLoc = new Location(currentOwner.getX(), currentOwner.getY(), currentOwner.getZ());

if (!isIn2DRadius(currentOwner, 2000))
{
teleportTo(currentOwner.getPosition().clone(), rnd);
return;
}
if (!isIn2DRadius(currentOwner, 50) && !isMoving())
{
getMove().maybeMoveToLocation(toMoveLoc, rnd, true, false);
return;
}
if (isIn2DRadius(currentOwner, 30))
{
getMove().stop();
getAI().thinkIdle();
return;
}
getMove().maybeMoveToLocation(toMoveLoc, rnd, true, false);
}

@Override
public boolean isInMyTerritory()
{
return false;
}

private static class Follow implements Runnable
{
private final Agathion agathion;

protected Follow(Agathion aga)
{
agathion = aga;
}

@Override
public void run()
{
agathion.followToOwner();
}
}

public void setAgathionItem(ItemInstance item)
{
this.item = item;
}

public Player getOwner()
{
return owner;
}
}
Этот вариант попробуй
 
Дома буду проверю , спасибо
 
Дома буду проверю , спасибо
Все тоже самое
 
Ну делать таск с частотой вызова в 10мс - это реально извращение, да...

З.Ы. ну и в любом случае такая костыльная реализация агатионов на интерлюде - то еще извращение...
 
попробуй с выкл гео и проверить
Хорошо , попробую
Выставил в 50 мс дёргается но не так заметно.
 
Данный сайт использует cookie. Вы должны принять их для продолжения использования. Узнать больше…