HighRate Event

katowice

Выдающийся
Участник
Сообщения
105
Розыгрыши
0
Решения
1
Репутация
14
Реакции
29
Баллы
1 348
Хроники
  1. Scions of Destiny
Исходники
Присутствуют
Сборка
l2jlisvus
Приветствую всех, перенес евент HighRate евент запускается мобы спавнятся вот только мобы после смерти не появляются
Java:
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.highrate.event;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Properties;
import java.util.concurrent.Future;
import java.util.logging.Logger;

import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.datatables.NpcTable;
import net.sf.l2j.gameserver.model.L2Spawn;
import net.sf.l2j.gameserver.model.Location;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
import net.sf.l2j.gameserver.util.Broadcast;
import net.sf.l2j.highrate.config.ConfigExtender;
import net.sf.l2j.highrate.instance.Instance;
import net.sf.l2j.highrate.instance.InstanceManager;
import net.sf.l2j.highrate.instance.InstanceMap;

/**
 * @author Trance
 * @skype chr.trance
 */
public class HighRate
{
    private static final Logger log = Logger.getLogger(HighRate.class.getName());
    
    private boolean active;
    
    private String start, end;
    private Calendar scheduledStart, scheduledEnd;
    private Future<?> startAt, endAt;
    private Instance world;
//    private Period _state;
    
    public static boolean Enabled;
    
    private static final HighRate instance = new HighRate();
    
    private final ArrayList<HighRateNpcInfo> npcs = new ArrayList<>();
    
//    private static enum Period
//    {
//        BEGIN,
//        END,
//        CANCELLED
//    }
    
    public static HighRate getInstance()
    {
        return instance;
    }
    
    public static void startUp()
    {
        if (Enabled)
        {
            instance.onLoad();
            log.info("HighRate event has been loaded.");
        }
    }
    
    protected void onLoad()
    {
        ThreadPoolManager tp = ThreadPoolManager.getInstance();
        
        startAt = tp.scheduleGeneral(new Runnable()
        {
            @Override
            public void run()
            {
                onStart();
            };
        }, scheduledStart.getTimeInMillis() - System.currentTimeMillis());
        
        endAt = tp.scheduleGeneral(new Runnable()
        {
            @Override
            public void run()
            {
                onEnd();
            }
        }, scheduledEnd.getTimeInMillis() - System.currentTimeMillis());
    }
    
    protected void onStart()
    {
//        _state = Period.BEGIN;
//        announceHighRate();
        Broadcast.announceToOnlinePlayers("HighRate: The event has began.", true);
        
        world = InstanceManager.getInstance().create(InstanceMap.HighRateInstanceId);
        
        // when this hits, npcs get spawned
        for (HighRateNpcInfo info : npcs)
            info.spawn();
        
        NpcTable table = NpcTable.getInstance();
        
        try (Connection con = L2DatabaseFactory.getInstance().getConnection())
        {
            PreparedStatement st = con.prepareStatement("SELECT npc_templateid, locx, locy, locz, heading, respawn_delay FROM spawnlist_highrate");
            
            ResultSet rs = st.executeQuery();
            
            while (rs.next())
            {
                int pointer = 1;
                
                int npcId = rs.getInt(pointer++);
                int locX = rs.getInt(pointer++);
                int locY = rs.getInt(pointer++);
                int locZ = rs.getInt(pointer++);
                int heading = rs.getInt("heading");
                int respawn_delay = rs.getInt("respawn_delay");
                
                L2NpcTemplate tp = table.getTemplate(npcId);
                
                if (tp != null)
                {
                    L2Spawn spawn = new L2Spawn(tp);
                    spawn.setLocx(locX);
                    spawn.setLocy(locY);
                    spawn.setLocz(locZ);
                    spawn.setHeading(heading);
                    spawn.setRespawnDelay(respawn_delay);
                    
                    spawn.startRespawn();
                    
                    L2Npc npc = spawn.doSpawn();
                    
                    if (npc instanceof L2MonsterInstance)
                        npc.setInstanceId(world.getInstanceId(), false);
                    else
                    {
                        // err
                    }
                }
                else
                {
                    // err
                }
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        
        // flag it true, so we know its running
        active = true;
    }

    protected void onEnd()
    {
//        _state = Period.END;
//        announceHighRate();
        Broadcast.announceToOnlinePlayers("HighRate: The event has ended.", true);
        
        // unspawn everything
        if (active)
        {
            for (HighRateNpcInfo info : npcs)
                info.unSpawn();
            
            active = false;
            
            // teleport players back, cleanup everything else
            world.destroy();
            world = null;
        }
        
        // reschedule
        reschedule();
    }

    public void reload()
    {
        // reload the event, stop it if active
        stopEvent();
        
        ConfigExtender.processHighRate();
    }
    
    public void stopEvent()
    {
//        _state = Period.CANCELLED;
//        announceHighRate();
        Broadcast.announceToOnlinePlayers("HighRate: The event has been cancelled.", true);
        
        startAt.cancel(false);
        endAt.cancel(false);
        
        if (active)
            onEnd();
    }
    
    protected void reschedule()
    {
        String[] data = start.split("\\:");
        Calendar nc = Calendar.getInstance();
        nc.set(Calendar.HOUR_OF_DAY, Integer.parseInt(data[0]));
        nc.set(Calendar.MINUTE, Integer.parseInt(data[1]));
        
        data = end.split("\\:");
        Calendar ncEnd = Calendar.getInstance();
        ncEnd.set(Calendar.HOUR_OF_DAY, Integer.parseInt(data[0]));
        ncEnd.set(Calendar.MINUTE, Integer.parseInt(data[1]));
        
        if (nc.getTimeInMillis() < System.currentTimeMillis())
        {
            nc.set(Calendar.DAY_OF_MONTH, nc.get(Calendar.DAY_OF_MONTH) + 1);
            ncEnd.set(Calendar.DAY_OF_MONTH, nc.get(Calendar.DAY_OF_MONTH) + 1);
        }
        
        scheduledStart = nc;
        scheduledEnd = ncEnd;
        
        // If startAt is not set, that means the startup function has not been invoked yet.
        if (startAt != null)
        {
            if (!startAt.isDone())
                startAt.cancel(false);
            
            if (!endAt.isDone())
                startAt.cancel(false);
            
            onLoad();
        }
    }
    
    public static void parseConfig(Properties prop)
    {
        Enabled = Boolean.parseBoolean(prop.getProperty("HighRate", "false"));
        
        if (!Enabled)
            return;
        
        String start = prop.getProperty("HighRateLaunch");
        String end = prop.getProperty("HighRateEnd");
        
        if (start == null)
        {
            Enabled = false;
            log.warning("Failed configurating HighRate event, start time is invalid!");
        }
        
        instance.start = start;
        instance.end = end;
        
        instance.reschedule();
        
        // Spawns.
        String p = prop.getProperty("HighRateSpawns");
        p = p.trim();
        
        String[] hash = p.split("];");
        for (String string : hash)
        {
            string = string.replace('[', ' ');
            string = string.trim();
            
            String[] h = string.split("\\,");
            
            for (int i = 0; i < h.length; i++)
                h[i] = h[i].trim();
            
            int npcId = Integer.parseInt(h[0]);
            int x = Integer.parseInt(h[1]);
            int y = Integer.parseInt(h[2]);
            int z = Integer.parseInt(h[3]);
            int heading = Integer.parseInt(h[4]);
            
            L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
            
            if (template != null)
            {
                HighRateNpcInfo ni = new HighRateNpcInfo(template, new Location(x, y, z, heading));
                instance.npcs.add(ni);
            }
            else
                log.warning("Cannot find npc template with id[" + npcId + "]. Skippng spawn!");
        }
    }
    
//    public final void announceHighRate()
//    {
//        switch (_state)
//        {
//            case BEGIN:
//                Broadcast.announceToOnlinePlayers("HighRate: The event has began.", true);
//                break;
//               
//            case END:
//                Broadcast.announceToOnlinePlayers("HighRate: The event has ended.", true);
//                break;
//               
//            case CANCELLED:
//                Broadcast.announceToOnlinePlayers("HighRate: The event has been cancelled.", true);
//                break;
//               
//            default:
//                log.warning("Something wrong with announceHighRate.");
//                break;
//        }
//    }
    
    public boolean isActive()
    {
        return active;
    }
}
 
Приветствую всех, перенес евент HighRate евент запускается мобы спавнятся вот только мобы после смерти не появляются
Java:
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.highrate.event;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Properties;
import java.util.concurrent.Future;
import java.util.logging.Logger;

import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.datatables.NpcTable;
import net.sf.l2j.gameserver.model.L2Spawn;
import net.sf.l2j.gameserver.model.Location;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
import net.sf.l2j.gameserver.util.Broadcast;
import net.sf.l2j.highrate.config.ConfigExtender;
import net.sf.l2j.highrate.instance.Instance;
import net.sf.l2j.highrate.instance.InstanceManager;
import net.sf.l2j.highrate.instance.InstanceMap;

/**
 * @author Trance
 * @skype chr.trance
 */
public class HighRate
{
    private static final Logger log = Logger.getLogger(HighRate.class.getName());
   
    private boolean active;
   
    private String start, end;
    private Calendar scheduledStart, scheduledEnd;
    private Future<?> startAt, endAt;
    private Instance world;
//    private Period _state;
   
    public static boolean Enabled;
   
    private static final HighRate instance = new HighRate();
   
    private final ArrayList<HighRateNpcInfo> npcs = new ArrayList<>();
   
//    private static enum Period
//    {
//        BEGIN,
//        END,
//        CANCELLED
//    }
   
    public static HighRate getInstance()
    {
        return instance;
    }
   
    public static void startUp()
    {
        if (Enabled)
        {
            instance.onLoad();
            log.info("HighRate event has been loaded.");
        }
    }
   
    protected void onLoad()
    {
        ThreadPoolManager tp = ThreadPoolManager.getInstance();
       
        startAt = tp.scheduleGeneral(new Runnable()
        {
            @Override
            public void run()
            {
                onStart();
            };
        }, scheduledStart.getTimeInMillis() - System.currentTimeMillis());
       
        endAt = tp.scheduleGeneral(new Runnable()
        {
            @Override
            public void run()
            {
                onEnd();
            }
        }, scheduledEnd.getTimeInMillis() - System.currentTimeMillis());
    }
   
    protected void onStart()
    {
//        _state = Period.BEGIN;
//        announceHighRate();
        Broadcast.announceToOnlinePlayers("HighRate: The event has began.", true);
       
        world = InstanceManager.getInstance().create(InstanceMap.HighRateInstanceId);
       
        // when this hits, npcs get spawned
        for (HighRateNpcInfo info : npcs)
            info.spawn();
       
        NpcTable table = NpcTable.getInstance();
       
        try (Connection con = L2DatabaseFactory.getInstance().getConnection())
        {
            PreparedStatement st = con.prepareStatement("SELECT npc_templateid, locx, locy, locz, heading, respawn_delay FROM spawnlist_highrate");
           
            ResultSet rs = st.executeQuery();
           
            while (rs.next())
            {
                int pointer = 1;
               
                int npcId = rs.getInt(pointer++);
                int locX = rs.getInt(pointer++);
                int locY = rs.getInt(pointer++);
                int locZ = rs.getInt(pointer++);
                int heading = rs.getInt("heading");
                int respawn_delay = rs.getInt("respawn_delay");
               
                L2NpcTemplate tp = table.getTemplate(npcId);
               
                if (tp != null)
                {
                    L2Spawn spawn = new L2Spawn(tp);
                    spawn.setLocx(locX);
                    spawn.setLocy(locY);
                    spawn.setLocz(locZ);
                    spawn.setHeading(heading);
                    spawn.setRespawnDelay(respawn_delay);
                   
                    spawn.startRespawn();
                   
                    L2Npc npc = spawn.doSpawn();
                   
                    if (npc instanceof L2MonsterInstance)
                        npc.setInstanceId(world.getInstanceId(), false);
                    else
                    {
                        // err
                    }
                }
                else
                {
                    // err
                }
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
       
        // flag it true, so we know its running
        active = true;
    }

    protected void onEnd()
    {
//        _state = Period.END;
//        announceHighRate();
        Broadcast.announceToOnlinePlayers("HighRate: The event has ended.", true);
       
        // unspawn everything
        if (active)
        {
            for (HighRateNpcInfo info : npcs)
                info.unSpawn();
           
            active = false;
           
            // teleport players back, cleanup everything else
            world.destroy();
            world = null;
        }
       
        // reschedule
        reschedule();
    }

    public void reload()
    {
        // reload the event, stop it if active
        stopEvent();
       
        ConfigExtender.processHighRate();
    }
   
    public void stopEvent()
    {
//        _state = Period.CANCELLED;
//        announceHighRate();
        Broadcast.announceToOnlinePlayers("HighRate: The event has been cancelled.", true);
       
        startAt.cancel(false);
        endAt.cancel(false);
       
        if (active)
            onEnd();
    }
   
    protected void reschedule()
    {
        String[] data = start.split("\\:");
        Calendar nc = Calendar.getInstance();
        nc.set(Calendar.HOUR_OF_DAY, Integer.parseInt(data[0]));
        nc.set(Calendar.MINUTE, Integer.parseInt(data[1]));
       
        data = end.split("\\:");
        Calendar ncEnd = Calendar.getInstance();
        ncEnd.set(Calendar.HOUR_OF_DAY, Integer.parseInt(data[0]));
        ncEnd.set(Calendar.MINUTE, Integer.parseInt(data[1]));
       
        if (nc.getTimeInMillis() < System.currentTimeMillis())
        {
            nc.set(Calendar.DAY_OF_MONTH, nc.get(Calendar.DAY_OF_MONTH) + 1);
            ncEnd.set(Calendar.DAY_OF_MONTH, nc.get(Calendar.DAY_OF_MONTH) + 1);
        }
       
        scheduledStart = nc;
        scheduledEnd = ncEnd;
       
        // If startAt is not set, that means the startup function has not been invoked yet.
        if (startAt != null)
        {
            if (!startAt.isDone())
                startAt.cancel(false);
           
            if (!endAt.isDone())
                startAt.cancel(false);
           
            onLoad();
        }
    }
   
    public static void parseConfig(Properties prop)
    {
        Enabled = Boolean.parseBoolean(prop.getProperty("HighRate", "false"));
       
        if (!Enabled)
            return;
       
        String start = prop.getProperty("HighRateLaunch");
        String end = prop.getProperty("HighRateEnd");
       
        if (start == null)
        {
            Enabled = false;
            log.warning("Failed configurating HighRate event, start time is invalid!");
        }
       
        instance.start = start;
        instance.end = end;
       
        instance.reschedule();
       
        // Spawns.
        String p = prop.getProperty("HighRateSpawns");
        p = p.trim();
       
        String[] hash = p.split("];");
        for (String string : hash)
        {
            string = string.replace('[', ' ');
            string = string.trim();
           
            String[] h = string.split("\\,");
           
            for (int i = 0; i < h.length; i++)
                h[i] = h[i].trim();
           
            int npcId = Integer.parseInt(h[0]);
            int x = Integer.parseInt(h[1]);
            int y = Integer.parseInt(h[2]);
            int z = Integer.parseInt(h[3]);
            int heading = Integer.parseInt(h[4]);
           
            L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
           
            if (template != null)
            {
                HighRateNpcInfo ni = new HighRateNpcInfo(template, new Location(x, y, z, heading));
                instance.npcs.add(ni);
            }
            else
                log.warning("Cannot find npc template with id[" + npcId + "]. Skippng spawn!");
        }
    }
   
//    public final void announceHighRate()
//    {
//        switch (_state)
//        {
//            case BEGIN:
//                Broadcast.announceToOnlinePlayers("HighRate: The event has began.", true);
//                break;
//              
//            case END:
//                Broadcast.announceToOnlinePlayers("HighRate: The event has ended.", true);
//                break;
//              
//            case CANCELLED:
//                Broadcast.announceToOnlinePlayers("HighRate: The event has been cancelled.", true);
//                break;
//              
//            default:
//                log.warning("Something wrong with announceHighRate.");
//                break;
//        }
//    }
   
    public boolean isActive()
    {
        return active;
    }
}
Типо 1 раз убил и все, не хотят больше появлться ?)
Или нет мобов матрёшек?
 
выложи класс L2Spawn и Location
Java:
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.gameserver.model;

import net.sf.l2j.gameserver.model.actor.L2Character;
import net.sf.l2j.util.Point3D;

public class Location extends Point3D
{
    public volatile int _heading;
    private static final long serialVersionUID = -8892572567626311527L;
    
    public Location(int x, int y, int z)
    {
        super(x, y, z);
        _heading = 0;
    }
    
    public Location(int x, int y, int z, int heading)
    {
        super(x, y, z);
        _heading = heading;
    }
    
    public Location(L2Object obj)
    {
        this(obj.getX(), obj.getY(), obj.getZ());
    }
    
    public Location(L2Character obj)
    {
        this((L2Object) obj);
        _heading = obj.getHeading();
    }
    
    public int getHeading()
    {
        return _heading;
    }
}
Java:
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.gameserver.model;

import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.GeoData;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.model.actor.L2Attackable;
import net.sf.l2j.gameserver.model.actor.L2Character;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
import net.sf.l2j.util.Rnd;

/**
 * This class manages the spawn and respawn of a group of L2Npc that are in the same are and have the same type. <B><U> Concept</U> :</B><BR>
 * <BR>
 * L2Npc can be spawned either in a random position into a location area (if Lox=0 and Locy=0), either at an exact position. The heading of the L2Npc can be a random heading if not defined (value= -1) or an exact heading (ex : merchant...).<BR>
 * <BR>
 * @author Nightmare
 */
public class L2Spawn
{
    protected static final Logger _log = Logger.getLogger(L2Spawn.class.getName());
    
    /** The link on the L2NpcTemplate object containing generic and static properties of this spawn (ex : RewardExp, RewardSP, AggroRange...) */
    private L2NpcTemplate _template;
    
    /** The X position of the spawn point */
    private int _locX;
    
    /** The Y position of the spawn point */
    private int _locY;
    
    /** The Z position of the spawn point */
    private int _locZ;
    
    /** The heading of L2Npc when they are spawned */
    private int _heading;
    
    /** The fixed delay used for a L2Npc respawn */
    private int _respawnDelay;
    
    /** The random delay used for a L2Npc respawn */
    private int _randomRespawnDelay;
    
    /** Minimum delay RaidBoss */
    private int _respawnMinDelay;
    
    /** Maximum delay RaidBoss */
    private int _respawnMaxDelay;
    
    /** The generic constructor of L2Npc managed by this L2Spawn */
    private Constructor<?> _constructor;
    
    /** If True a L2Npc is respawned each time that another is killed */
    private boolean _doRespawn;
    
    private L2Npc _lastSpawn;
    private static List<SpawnListener> _spawnListeners = new ArrayList<>();
    
    /** The task launching the function doSpawn() */
    class SpawnTask implements Runnable
    {
        private final L2Npc _oldNpc;
        
        public SpawnTask(L2Npc pOldNpc)
        {
            _oldNpc = pOldNpc;
        }
        
        @Override
        public void run()
        {
            respawnNpc(_oldNpc);
        }
    }
    
    /**
     * Constructor of L2Spawn.<BR>
     * <BR>
     * <B><U> Concept</U> :</B><BR>
     * <BR>
     * Each L2Spawn owns generic and static properties (ex : RewardExp, RewardSP, AggroRange...). All of those properties are stored in a different L2NpcTemplate for each type of L2Spawn. Each template is loaded once in the server cache memory (reduce memory use). When a new instance of L2Spawn is
     * created, server just create a link between the instance and the template. This link is stored in <B>_template</B><BR>
     * <BR>
     * Each L2Npc is linked to a L2Spawn that manages its spawn and respawn (delay, location...). This link is stored in <B>_spawn</B> of the L2Npc<BR>
     * <BR>
     * <B><U> Actions</U> :</B><BR>
     * <BR>
     * <li>Set the _template of the L2Spawn</li> <li>Calculate the implementationName used to generate the generic constructor of L2Npc managed by this L2Spawn</li> <li>Create the generic constructor of L2Npc managed by this L2Spawn</li><BR>
     * <BR>
     * @param mobTemplate The L2NpcTemplate to link to this L2Spawn
     * @throws SecurityException
     * @throws ClassNotFoundException
     * @throws NoSuchMethodException
     */
    public L2Spawn(L2NpcTemplate mobTemplate) throws SecurityException, ClassNotFoundException, NoSuchMethodException
    {
        // Set the _template of the L2Spawn
        _template = mobTemplate;
        if (_template == null)
            return;
        
        // Create the generic constructor of L2Npc managed by this L2Spawn
        Class<?>[] parameters =
        {
            int.class,
            Class.forName("net.sf.l2j.gameserver.templates.chars.L2NpcTemplate")
        };
        _constructor = Class.forName("net.sf.l2j.gameserver.model.actor.instance." + _template.getType() + "Instance").getConstructor(parameters);
    }
    
    /**
     * @return the maximum number of L2Npc that this L2Spawn can manage.
     */
    public int getAmount()
    {
        return 1;
    }
    
    /**
     * @return the X position of the spawn point.
     */
    public int getLocx()
    {
        return _locX;
    }
    
    /**
     * @return the Y position of the spawn point.
     */
    public int getLocy()
    {
        return _locY;
    }
    
    /**
     * @return the Z position of the spawn point.
     */
    public int getLocz()
    {
        return _locZ;
    }
    
    /**
     * @return the Itdentifier of the L2Npc manage by this L2spawn contained in the L2NpcTemplate.
     */
    public int getNpcId()
    {
        return _template.getNpcId();
    }
    
    /**
     * @return the heading of L2Npc when they are spawned.
     */
    public int getHeading()
    {
        return _heading;
    }
    
    /**
     * @return the fixed delay used for a L2Npc respawn.
     */
    public int getRespawnDelay()
    {
        return _respawnDelay;
    }
    
    /**
     * @return the random delay used for a L2Npc respawn.
     */
    public int getRandomRespawnDelay()
    {
        return _randomRespawnDelay;
    }
    
    /**
     * @return the minimum RaidBoss spawn delay.
     */
    public int getRespawnMinDelay()
    {
        return _respawnMinDelay;
    }
    
    /**
     * @return the maximum RaidBoss spawn delay.
     */
    public int getRespawnMaxDelay()
    {
        return _respawnMaxDelay;
    }
    
    /**
     * Set the minimum respawn delay.
     * @param date
     */
    public void setRespawnMinDelay(int date)
    {
        _respawnMinDelay = date;
    }
    
    /**
     * Set Maximum respawn delay.
     * @param date
     */
    public void setRespawnMaxDelay(int date)
    {
        _respawnMaxDelay = date;
    }
    
    /**
     * Set the X position of the spawn point.
     * @param locx
     */
    public void setLocx(int locx)
    {
        _locX = locx;
    }
    
    /**
     * Set the Y position of the spawn point.
     * @param locy
     */
    public void setLocy(int locy)
    {
        _locY = locy;
    }
    
    /**
     * Set the Z position of the spawn point.
     * @param locz
     */
    public void setLocz(int locz)
    {
        _locZ = locz;
    }
    
    /**
     * Set the heading of L2Npc when they are spawned.
     * @param heading
     */
    public void setHeading(int heading)
    {
        _heading = heading;
    }
    
    /**
     * Create a SpawnTask to launch after the fixed + random delay. A respawn is ONLY possible if _doRespawn=True.<br>
     * <br>
     * The random timer is calculated here, in order each spawn got his own random timer. The * 1000 is made after Rnd.get because we don't need random ms, but seconds.
     * @param oldNpc
     */
    public void respawn(L2Npc oldNpc)
    {
        // Check if respawn is possible to prevent multiple respawning caused by lag
        if (_doRespawn)
        {
            // Calculate the random time, if any.
            final int randomTime = (_randomRespawnDelay > 0) ? Rnd.get(-_randomRespawnDelay, _randomRespawnDelay) * 1000 : 0;
            
            // Create a new SpawnTask to launch after the respawn Delay
            ThreadPoolManager.getInstance().scheduleGeneral(new SpawnTask(oldNpc), _respawnDelay + randomTime);
        }
    }
    
    /**
     * Create the initial spawning and set _doRespawn to True.
     */
    public void init()
    {
        doSpawn();
        _doRespawn = true;
    }
    
    /**
     * @return true if respawn is enabled.
     */
    public boolean isRespawnEnabled()
    {
        return _doRespawn;
    }
    
    /**
     * Set _doRespawn to False to stop respawn for this L2Spawn.
     */
    public void stopRespawn()
    {
        _doRespawn = false;
    }
    
    /**
     * Set _doRespawn to True to start or restart respawn for this L2Spawn.
     */
    public void startRespawn()
    {
        _doRespawn = true;
    }
    
    /**
     * Create the L2Npc, add it to the world and lauch its OnSpawn action.<BR>
     * <BR>
     * <B><U> Concept</U> :</B><BR>
     * <BR>
     * L2Npc can be spawned either in a random position into a location area (if Lox=0 and Locy=0), either at an exact position. The heading of the L2Npc can be a random heading if not defined (value= -1) or an exact heading (ex : merchant...).<BR>
     * <BR>
     * <B><U> Actions for an random spawn into location area</U> : <I>(if Locx=0 and Locy=0)</I></B><BR>
     * <BR>
     * <li>Get L2Npc Init parameters and its generate an Identifier</li> <li>Call the constructor of the L2Npc</li> <li>Calculate the random position in the location area (if Locx=0 and Locy=0) or get its exact position from the L2Spawn</li> <li>Set the position of the L2Npc</li> <li>Set the HP and
     * MP of the L2Npc to the max</li> <li>Set the heading of the L2Npc (random heading if not defined : value=-1)</li> <li>Link the L2Npc to this L2Spawn</li> <li>Init other values of the L2Npc (ex : from its L2CharTemplate for INT, STR, DEX...) and add it in the world</li> <li>Lauch the action
     * OnSpawn fo the L2Npc</li><BR>
     * <BR>
     * <li>Increase the current number of L2Npc managed by this L2Spawn</li><BR>
     * <BR>
     * @return the newly created instance.
     */
    public L2Npc doSpawn()
    {
        return doSpawn(false);
    }
    
    public L2Npc doSpawn(boolean isSummonSpawn)
    {
        L2Npc mob = null;
        try
        {
            // Check if the L2Spawn is not a L2Pet or L2Minion
            if (_template.isType("L2Pet") || _template.isType("L2Minion"))
                return mob;
            
            // Get L2Npc Init parameters and its generate an Identifier
            Object[] parameters =
            {
                IdFactory.getInstance().getNextId(),
                _template
            };
            
            // Call the constructor of the L2Npc
            // (can be a L2ArtefactInstance, L2FriendlyMobInstance, L2GuardInstance, L2MonsterInstance, L2SiegeGuardInstance, L2BoxInstance,
            // L2FeedableBeastInstance, L2TamedBeastInstance, L2NpcInstance)
            Object tmp = _constructor.newInstance(parameters);
            
            if (isSummonSpawn && tmp instanceof L2Character)
                ((L2Character) tmp).setShowSummonAnimation(isSummonSpawn);
            
            // Check if the Instance is a L2Npc
            if (!(tmp instanceof L2Npc))
                return mob;
            
            mob = (L2Npc) tmp;
            return initializeNpcInstance(mob);
        }
        catch (Exception e)
        {
            _log.log(Level.WARNING, "NPC " + _template.getNpcId() + " class not found", e);
        }
        return mob;
    }
    
    /**
     * @param mob
     * @return
     */
    private L2Npc initializeNpcInstance(L2Npc mob)
    {
        int newlocx, newlocy, newlocz;
        
        // If Locx=0 and Locy=0, there's a problem.
        if (getLocx() == 0 && getLocy() == 0)
        {
            _log.warning("L2Spawn : the following npcID: " + _template.getNpcId() + " misses X/Y informations.");
            return mob;
        }
        
        // The L2Npc is spawned at the exact position (Lox, Locy, Locz)
        newlocx = getLocx();
        newlocy = getLocy();
        newlocz = (Config.GEODATA > 0) ? GeoData.getInstance().getSpawnHeight(newlocx, newlocy, getLocz(), getLocz(), this) : getLocz();
        
        mob.stopAllEffects();
        mob.setIsDead(false);
        
        // Reset decay info
        mob.setDecayed(false);
        
        // Set the HP and MP of the L2Npc to the max
        mob.setCurrentHpMp(mob.getMaxHp(), mob.getMaxMp());
        
        // Reset script value.
        mob.setScriptValue(0);
        
        // Set the heading of the L2Npc (random heading if not defined)
        if (getHeading() == -1)
            mob.setHeading(Rnd.get(61794));
        else
            mob.setHeading(getHeading());
        
        // Test champion state for next spawn.
        if (Config.CHAMPION_FREQUENCY > 0)
        {
            // It can't be a Raid, a Raid minion nor a minion. Quest mobs and chests are disabled too.
            if (mob instanceof L2MonsterInstance && !getTemplate().cantBeChampion() && mob.getLevel() >= Config.CHAMP_MIN_LVL && mob.getLevel() <= Config.CHAMP_MAX_LVL && !mob.isRaid() && !((L2MonsterInstance) mob).isRaidMinion() && !((L2MonsterInstance) mob).isMinion())
                ((L2Attackable) mob).setChampion(Rnd.get(100) < Config.CHAMPION_FREQUENCY);
        }
        
        // Link the L2Npc to this L2Spawn
        mob.setSpawn(this);
        
        // Init other values of the L2Npc (ex : from its L2CharTemplate for INT, STR, DEX...) and add it in the world as a visible object
        mob.spawnMe(newlocx, newlocy, newlocz);
        
        L2Spawn.notifyNpcSpawned(mob);
        
        _lastSpawn = mob;
        
        if (Config.DEBUG)
            _log.finest("Spawned Mob ID: " + _template.getNpcId() + " at X: " + mob.getX() + ", Y: " + mob.getY() + ", 2: " + mob.getZ());
        
        return mob;
    }
    
    public static void addSpawnListener(SpawnListener listener)
    {
        synchronized (_spawnListeners)
        {
            _spawnListeners.add(listener);
        }
    }
    
    public static void removeSpawnListener(SpawnListener listener)
    {
        synchronized (_spawnListeners)
        {
            _spawnListeners.remove(listener);
        }
    }
    
    public static void notifyNpcSpawned(L2Npc npc)
    {
        synchronized (_spawnListeners)
        {
            for (SpawnListener listener : _spawnListeners)
                listener.npcSpawned(npc);
        }
    }
    
    /**
     * Set the respawn delay. It can't be inferior to 0, and is automatically modified if inferior to 10 seconds.
     * @param i delay in seconds
     */
    public void setRespawnDelay(int i)
    {
        if (i < 10)
        {
            if (i < 0)
                _log.warning("Respawn delay is negative for spawnId: " + getNpcId());
            
            i = 10;
        }
        
        _respawnDelay = i * 1000;
    }
    
    public void setRandomRespawnDelay(int i)
    {
        _randomRespawnDelay = i;
    }
    
    public L2Npc getLastSpawn()
    {
        return _lastSpawn;
    }
    
    public void respawnNpc(L2Npc oldNpc)
    {
        if (_doRespawn)
        {
            oldNpc.refreshID();
            initializeNpcInstance(oldNpc);
        }
    }
    
    public L2NpcTemplate getTemplate()
    {
        return _template;
    }
    
    @Override
    public String toString()
    {
        return "L2Spawn [_template=" + getNpcId() + ", _locX=" + _locX + ", _locY=" + _locY + ", _locZ=" + _locZ + ", _heading=" + _heading + "]";
    }
}
 
у меня были предположения по поводу инстанса ид. возможно повторный спавн идет в 0 инстанс. ид инстанс эвента какой?
через шифт клик на моба там respawn_delay что показывают.
 
аж интересно . нашел какой то сорц l2jlisvus и там нет setInstanceId ??
 
аж интересно . нашел какой то сорц l2jlisvus и там нет setInstanceId ??
L2Object.java
Java:
    public void setInstanceId(int instanceId, boolean silent)
    {
        int oldInstance = _instanceId;
        
        _instanceId = instanceId;

        if (instanceId != 0)
        {

            if (oldInstance != 0 && this instanceof L2PcInstance)
            {
                Instance ins = InstanceManager.getInstance().getInstanceId(oldInstance);
                
                if (ins != null) // Destroyed already.
                    ins.remove((L2PcInstance) this, false, false);
            }
            
            Instance ins = InstanceManager.getInstance().getInstanceId(instanceId);
            
            if (ins == null)
            {
                _instanceId = 0;
                return;
            }
            else
                ins.addObject(this);
        }
        
        if (!silent)
        {
            decayMe();
            spawnMe();
        }
    }
    
    public int getInstanceId()
    {
        return _instanceId;
     }

у меня были предположения по поводу инстанса ид. возможно повторный спавн идет в 0 инстанс. ид инстанс эвента какой?
через шифт клик на моба там respawn_delay что показывают.

аж интересно . нашел какой то сорц l2jlisvus и там нет setInstanceId ??
Все верно, его там не было. брал с aCis
Java:
Instance.java
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.highrate.instance;

import java.util.ArrayList;

import net.sf.l2j.gameserver.datatables.ItemTable;
import net.sf.l2j.gameserver.datatables.MapRegionTable.TeleportWhereType;
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket;
import net.sf.l2j.gameserver.templates.L2Item;

/**
 * @author Trance
 * @skype chr.trance
 */
public final class Instance
{
    private final int instanceId;
    
    private final ArrayList<L2PcInstance> players = new ArrayList<>();
    private final ArrayList<L2Object> objects = new ArrayList<>();
    
    public Instance(int id)
    {
        instanceId = id;
    }
    
    public void addPlayer(L2PcInstance player)
    {
        players.add(player);
    }
    
    public void addNpc(L2NpcInstance npc)
    {
        objects.add(npc);
    }
    
    public int getInstanceId()
    {
        return instanceId;
    }
    
    public void toAllInside(L2GameServerPacket packet)
    {
        for (int i = 0; i < players.size(); i++)
        {
            L2PcInstance player = players.get(i);
            player.sendPacket(packet);
        }
    }
    
    public void createItem(int id, int count)
    {
        L2Item tmp = ItemTable.getInstance().getTemplate(id);
        
        if (tmp != null)
        {
            int oid = IdFactory.getInstance().getNextId();
            L2ItemInstance ins = new L2ItemInstance(oid, id);
            
            addItem(ins);
        }
        else
        {
            // err cant find item with id
        }
    }
    
    public void addItem(L2ItemInstance ins)
    {
        objects.add(ins);
    }
    
    public ArrayList<L2PcInstance> getPlayers()
    {
        return players;
    }
    
    public ArrayList<L2Object> getObjects()
    {
        return objects;
    }
    
    public void destroy()
    {
        for (int i = 0; i < players.size(); i++)
        {
            L2PcInstance player = players.get(i);
            
            if (player.getInstanceId() == 0)
                continue; // long gone.
            
            player.setInstanceId(0, true);
            player.teleToLocation(TeleportWhereType.Town);
        }
        
        for (int i = 0; i < objects.size(); i++)
        {
            L2Object obj = objects.get(i);
            
            if (obj instanceof L2NpcInstance)
            {
                ((L2NpcInstance) obj).deleteMe();
                ((L2NpcInstance) obj).getSpawn().stopRespawn();
            }
            else if (obj instanceof L2ItemInstance)
                ((L2ItemInstance)obj).decayMe();
        }
        
        players.clear();
        objects.clear();
        
        InstanceManager.getInstance().removeMe(this);
    }
    
    public void remove(L2PcInstance player, boolean silent, boolean setIns)
    {
        players.remove(player);
        
        if (setIns)
            player.setInstanceId(0, silent);
    }
    
    public void addObject(L2Object obj)
    {
        if (obj instanceof L2PcInstance)
            addPlayer((L2PcInstance) obj);
        else if (obj instanceof L2NpcInstance)
            addNpc((L2NpcInstance) obj);
        else if (obj instanceof L2ItemInstance)
            addItem((L2ItemInstance) obj);
    }
}

InstanceManager.java
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.highrate.instance;

import java.util.HashMap;
import java.util.logging.Logger;

/**
 * @author Trance
 * @skype chr.trance
 */
public class InstanceManager
{
    private static final Logger log = Logger.getLogger(InstanceManager.class.getName());
    
    private static final InstanceManager instance = new InstanceManager();
    
    private HashMap<Integer, Instance> instances = new HashMap<>();
    
    public static InstanceManager getInstance()
    {
        return instance;
    }
    
    public Instance getInstanceId(int instanceId)
    {
        Instance ins = instances.get(instanceId);
        
        if (ins == null)
            log.warning("Cannot find instance with id: " + instanceId + "!");
        
        return ins;
    }
    
    public Instance create(int id)
    {
        Instance ins = instances.get(id);
        
        if (ins != null)
        {
            log.warning("Instance with id[" + id + "] already created!");
            return ins;
        }
        
        ins = new Instance(id);
        instances.put(id, ins);
        log.info("Created instance with id: " + id);
        return ins;
    }
    
    protected void removeMe(Instance instance)
    {
        instances.remove(instance.getInstanceId());
    }
}

InstanceMap.java
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.highrate.instance;

/**
 * @author Trance
 * @skype chr.trance
 * We hold here all the instance ids, so we dont mess them up.
 */
public class InstanceMap
{
    public static final int HighRateInstanceId = 1001;
}
 

Вложения

  • изображение_2022-09-20_190929423.png
    изображение_2022-09-20_190929423.png
    31,2 КБ · Просмотры: 28
как все сложно.
Java:
                     if (npc instanceof L2MonsterInstance)
             //   тут false  ---->>       npc.setInstanceId(world.getInstanceId(), false);
                    else
                    {
                        // err
                    }


   public void setInstanceId(int instanceId, boolean silent)
    {
        //

        if (!silent) <-- сработает
        {
            decayMe();  
            spawnMe();
        }
    }
вы инстанс добавили ради этого евента? так как инстанс требует тонну доработок.
 
Флуд / Оверпостинг
как все сложно.
Java:
                     if (npc instanceof L2MonsterInstance)
             //   тут false  ---->>       npc.setInstanceId(world.getInstanceId(), false);
                    else
                    {
                        // err
                    }


   public void setInstanceId(int instanceId, boolean silent)
    {
        //

        if (!silent) <-- сработает
        {
            decayMe();
            spawnMe();
        }
    }
вы инстанс добавили ради этого евента? так как инстанс требует тонну доработок.
Получается так, переносил с aCis данный ивент со сборки l2gold'a ибо не чего подобного не нашел в шаре.

как все сложно.
Java:
                     if (npc instanceof L2MonsterInstance)
             //   тут false  ---->>       npc.setInstanceId(world.getInstanceId(), false);
                    else
                    {
                        // err
                    }


   public void setInstanceId(int instanceId, boolean silent)
    {
        //

        if (!silent) <-- сработает
        {
            decayMe(); 
            spawnMe();
        }
    }
вы инстанс добавили ради этого евента? так как инстанс требует тонну доработок.
Java:
    protected void onStart()
    {
//        _state = Period.BEGIN;
//        announceHighRate();
        Broadcast.announceToOnlinePlayers("HighRate: Евент начался.");
        
        world = InstanceManager.getInstance().create(InstanceMap.HighRateInstanceId);
        
         // when this hits, npcs get spawned
        for (HighRateNpcInfo info : npcs)
            info.spawn();

        NpcTable table = NpcTable.getInstance();
        
        try (Connection con = L2DatabaseFactory.getInstance().getConnection())
        {
            PreparedStatement st = con.prepareStatement("SELECT npc_templateid, locx, locy, locz, heading, respawn_delay FROM spawnlist_highrate");
            
            ResultSet rs = st.executeQuery();
            
            while (rs.next())
            {
                int pointer = 1;
                
                int npcId = rs.getInt(pointer++);
                int locX = rs.getInt(pointer++);
                int locY = rs.getInt(pointer++);
                int locZ = rs.getInt(pointer++);
                int heading = rs.getInt("heading");
                int respawn_delay = rs.getInt("respawn_delay");
                
                L2NpcTemplate tp = table.getTemplate(npcId);
                
                if (tp != null)
                {
                    L2Spawn spawn = new L2Spawn(tp);
                    spawn.setLocX(locX);
                    spawn.setLocY(locY);
                    spawn.setLocZ(locZ);
                    spawn.setHeading(heading);
                    spawn.setRespawnDelay(respawn_delay);
                    
                    spawn.startRespawn();
                    
                    L2NpcInstance npc = spawn.doSpawn();
                    
                     if (npc instanceof L2MonsterInstance)
                    {
                        // err
                    }
                }
                else
                {
                    // err
                }
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        
        // flag it true, so we know its running
        active = true;
    }
Java:
    public void setInstanceId(int instanceId, boolean silent)
    {
/*         int oldInstance = _instanceId;
        
        _instanceId = instanceId;

        if (instanceId != 0)
        {

            if (oldInstance != 0 && this instanceof L2PcInstance)
            {
                Instance ins = InstanceManager.getInstance().getInstanceId(oldInstance);
                
                if (ins != null) // Destroyed already.
                    ins.remove((L2PcInstance) this, false, false);
            }
            
            Instance ins = InstanceManager.getInstance().getInstanceId(instanceId);
            
            if (ins == null)
            {
                _instanceId = 0;
                return;
            }
            else
                ins.addObject(this);
        } */
        
        if (!silent)
        {
            decayMe();
            spawnMe();
        }
    }
Мобы не респавнятся повторно

Instance NPC
Код:
        if (actualCommand.equalsIgnoreCase("omen"))
        {
            /* player.setInstanceId(InstanceMap.HighRateInstanceId, true); */
            player.teleToLocation(-19088, 13506, -4896, false);
        }
        else if (actualCommand.equalsIgnoreCase("disc"))
        {
            /* player.setInstanceId(InstanceMap.HighRateInstanceId, true); */
            player.teleToLocation(172648, -17603, -4902, false);
        }
 
другие мобы респ имеют?
Да

другие мобы респ имеют?
Причем пробовал добавлял спавн в дефолтную таблицу спаунлиста все работает, а через spawnlist_highrate мобы спавняться в начале ивента я их убиваю и больше они не появляются. Щас перепроверю
 
Причем пробовал добавлял спавн в дефолтную таблицу спаунлиста все работает, а через spawnlist_highrate мобы спавняться в начале ивента я их убиваю и больше они не появляются. Щас перепроверю
и вот такой вопрос откуда вызывается 'L2Spawn - public void respawn(L2Npc oldNpc)'???
 
и вот такой вопрос откуда вызывается 'L2Spawn - public void respawn(L2Npc oldNpc)'???
Вы про это
Java:
    public void respawnNpc(L2NpcInstance oldNpc)
    {
        oldNpc.refreshID();
        initializeNpcInstance(oldNpc);
    }

и вот такой вопрос откуда вызывается 'L2Spawn - public void respawn(L2Npc oldNpc)'???
Дак получается не откуда. Если я все правильно понял
 
Дак получается не откуда. Если я все правильно понял
Java:
    public void respawn(L2Npc oldNpc) вот Этот
    {
        // Check if respawn is possible to prevent multiple respawning caused by lag
        if (_doRespawn)
        {
            // Calculate the random time, if any.
            final int randomTime = (_randomRespawnDelay > 0) ? Rnd.get(-_randomRespawnDelay, _randomRespawnDelay) * 1000 : 0;
            
            // Create a new SpawnTask to launch after the respawn Delay
            ThreadPoolManager.getInstance().scheduleGeneral(new SpawnTask(oldNpc), _respawnDelay + randomTime);
        }
    }
    
     public void respawnNpc(L2Npc oldNpc) а не этот
    {
        if (_doRespawn)
        {
            oldNpc.refreshID();
            initializeNpcInstance(oldNpc);
        }
    }
 
Java:
    public void respawn(L2Npc oldNpc) вот Этот
    {
        // Check if respawn is possible to prevent multiple respawning caused by lag
        if (_doRespawn)
        {
            // Calculate the random time, if any.
            final int randomTime = (_randomRespawnDelay > 0) ? Rnd.get(-_randomRespawnDelay, _randomRespawnDelay) * 1000 : 0;
           
            // Create a new SpawnTask to launch after the respawn Delay
            ThreadPoolManager.getInstance().scheduleGeneral(new SpawnTask(oldNpc), _respawnDelay + randomTime);
        }
    }
   
     public void respawnNpc(L2Npc oldNpc) а не этот
    {
        if (_doRespawn)
        {
            oldNpc.refreshID();
            initializeNpcInstance(oldNpc);
        }
    }
У меня есть только вот такой кусок ласт ревизия Lusvus
Java:
    /**
     * Decrease the current number of L2NpcInstance of this L2Spawn and if necessary create a SpawnTask to launch after the respawn Delay.<BR>
     * <BR>
     * <B><U> Actions</U> :</B><BR>
     * <BR>
     * <li>Decrease the current number of L2NpcInstance of this L2Spawn</li>
     * <li>Check if respawn is possible to prevent multiple respawning caused by lag</li>
     * <li>Update the current number of SpawnTask in progress or stand by of this L2Spawn</li>
     * <li>Create a new SpawnTask to launch after the respawn Delay</li><BR>
     * <BR>
     * <FONT COLOR=#FF0000><B> <U>Caution</U> : A respawn is possible ONLY if _doRespawn=True and _scheduledCount + _currentCount < _maximumCount</B></FONT><BR>
     * <BR>
     * @param oldNpc
     */
    public void decreaseCount(L2NpcInstance oldNpc)
    {
        // sanity check
        if (_currentCount <= 0)
        {
            return;
        }
        
        // Decrease the current number of L2NpcInstance of this L2Spawn
        _currentCount--;

        // Check if respawn is possible to prevent multiple respawning caused by lag
        if (_doRespawn && ((_scheduledCount + _currentCount) < _maximumCount))
        {
            // Update the current number of SpawnTask in progress or stand by of this L2Spawn
            _scheduledCount++;

            // Create a new SpawnTask to launch after the respawn Delay
            // ClientScheduler.getInstance().scheduleLow(new SpawnTask(npcId), _respawnDelay);
            ThreadPoolManager.getInstance().scheduleGeneral(new SpawnTask(oldNpc), _respawnDelay);
        }
    }
 
а шаблон для моба стары или новый класс был создан? и посмотрите как происходят другие спавны.
 
Назад
Сверху Снизу