Jump to content

Question

Posted (edited)

Hello Could you all help me create a switch Antharas bomber off/on in boss.properties

Antharas.java

 

package com.l2jfrozen.gameserver.ai.special;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ScheduledFuture;

import javolution.util.FastList;

import org.apache.log4j.Logger;

import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.ai.CtrlIntention;
import com.l2jfrozen.gameserver.datatables.SkillTable;
import com.l2jfrozen.gameserver.datatables.sql.NpcTable;
import com.l2jfrozen.gameserver.datatables.sql.SpawnTable;
import com.l2jfrozen.gameserver.geo.GeoData;
import com.l2jfrozen.gameserver.managers.GrandBossManager;
import com.l2jfrozen.gameserver.model.L2Character;
import com.l2jfrozen.gameserver.model.L2Skill;
import com.l2jfrozen.gameserver.model.L2World;
import com.l2jfrozen.gameserver.model.actor.instance.L2GrandBossInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.model.actor.position.L2CharPosition;
import com.l2jfrozen.gameserver.model.quest.Quest;
import com.l2jfrozen.gameserver.model.spawn.L2Spawn;
import com.l2jfrozen.gameserver.model.zone.type.L2BossZone;
import com.l2jfrozen.gameserver.network.serverpackets.Earthquake;
import com.l2jfrozen.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jfrozen.gameserver.network.serverpackets.PlaySound;
import com.l2jfrozen.gameserver.network.serverpackets.SpecialCamera;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
import com.l2jfrozen.gameserver.templates.StatsSet;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.util.random.Rnd;

/**
 * This class ... control for sequence of fight against Antharas.
 * @version $Revision: $ $Date: $
 * @author L2J_JP SANDMAN
 */
public class Antharas extends Quest implements Runnable
{
    protected static final Logger LOGGER = Logger.getLogger(Antharas.class);

    // config
    private static final int FWA_ACTIVITYTIMEOFANTHARAS = 120;
    // private static final int FWA_APPTIMEOFANTHARAS = 1800000;
    // private static final int FWA_INACTIVITYTIME = 900000;
    // private static final boolean FWA_OLDANTHARAS = true; //use antharas interlude with minions
    protected static final boolean FWA_OLDANTHARAS = Config.ANTHARAS_OLD; // use antharas interlude with minions
    private static final boolean FWA_MOVEATRANDOM = true;
    private static final boolean FWA_DOSERVEREARTHQUAKE = true;
    private static final int FWA_LIMITOFWEAK = 45;
    private static final int FWA_LIMITOFNORMAL = 63;

    private static final int FWA_MAXMOBS = 10; // this includes Antharas itself
    private static final int FWA_INTERVALOFMOBSWEAK = 180000;
    private static final int FWA_INTERVALOFMOBSNORMAL = 150000;
    private static final int FWA_INTERVALOFMOBSSTRONG = 120000;
    private static final int FWA_PERCENTOFBEHEMOTH = 60;
    private static final int FWA_SELFDESTRUCTTIME = 15000;
    // Location of teleport cube.
    private final int _teleportCubeId = 31859;
    private final int _teleportCubeLocation[][] =
    {
        {
            177615,
            114941,
            -7709,
            0
        }
    };

    protected List<L2Spawn> _teleportCubeSpawn = new FastList<>();
    protected List<L2NpcInstance> _teleportCube = new FastList<>();

    // Spawn data of monsters.
    protected HashMap<Integer, L2Spawn> _monsterSpawn = new HashMap<>();

    // Instance of monsters.
    protected List<L2NpcInstance> _monsters = new FastList<>();
    protected L2GrandBossInstance _antharas = null;

    // monstersId
    private static final int ANTHARASOLDID = 29019;
    private static final int ANTHARASWEAKID = 29066;
    private static final int ANTHARASNORMALID = 29067;
    private static final int ANTHARASSTRONGID = 29068;

    // Tasks.
    protected ScheduledFuture<?> _cubeSpawnTask = null;
    protected volatile ScheduledFuture<?> _monsterSpawnTask = null;
    protected ScheduledFuture<?> _activityCheckTask = null;
    protected ScheduledFuture<?> _socialTask = null;
    protected ScheduledFuture<?> _mobiliseTask = null;
    protected ScheduledFuture<?> _mobsSpawnTask = null;
    protected ScheduledFuture<?> _selfDestructionTask = null;
    protected ScheduledFuture<?> _moveAtRandomTask = null;
    protected ScheduledFuture<?> _movieTask = null;

    // Antharas Status Tracking :
    private static final int DORMANT = 0; // Antharas is spawned and no one has entered yet. Entry is unlocked
    private static final int WAITING = 1; // Antharas is spawend and someone has entered, triggering a 30 minute window for additional people to enter
    // before he unleashes his attack. Entry is unlocked
    private static final int FIGHTING = 2; // Antharas is engaged in battle, annihilating his foes. Entry is locked
    private static final int DEAD = 3; // Antharas has been killed. Entry is locked

    protected static long _LastAction = 0;

    protected static L2BossZone _Zone;

    // Boss: Antharas
    public Antharas(final int id, final String name, final String descr)
    {
        super(id, name, descr);
        final int[] mob =
        {
            ANTHARASOLDID,
            ANTHARASWEAKID,
            ANTHARASNORMALID,
            ANTHARASSTRONGID,
            29069,
            29070,
            29071,
            29072,
            29073,
            29074,
            29075,
            29076
        };
        this.registerMobs(mob);
        init();
    }

    // Initialize
    private void init()
    {
        // Setting spawn data of monsters.
        try
        {
            _Zone = GrandBossManager.getInstance().getZone(179700, 113800, -7709);
            L2NpcTemplate template1;
            L2Spawn tempSpawn;

            // Old Antharas
            template1 = NpcTable.getInstance().getTemplate(ANTHARASOLDID);
            tempSpawn = new L2Spawn(template1);
            tempSpawn.setLocx(181323);
            tempSpawn.setLocy(114850);
            tempSpawn.setLocz(-7623);
            tempSpawn.setHeading(32542);
            tempSpawn.setAmount(1);
            tempSpawn.setRespawnDelay(FWA_ACTIVITYTIMEOFANTHARAS * 2);
            SpawnTable.getInstance().addNewSpawn(tempSpawn, false);
            _monsterSpawn.put(29019, tempSpawn);

            // Weak Antharas
            template1 = NpcTable.getInstance().getTemplate(ANTHARASWEAKID);
            tempSpawn = new L2Spawn(template1);
            tempSpawn.setLocx(181323);
            tempSpawn.setLocy(114850);
            tempSpawn.setLocz(-7623);
            tempSpawn.setHeading(32542);
            tempSpawn.setAmount(1);
            tempSpawn.setRespawnDelay(FWA_ACTIVITYTIMEOFANTHARAS * 2);
            SpawnTable.getInstance().addNewSpawn(tempSpawn, false);
            _monsterSpawn.put(29066, tempSpawn);

            // Normal Antharas
            template1 = NpcTable.getInstance().getTemplate(ANTHARASNORMALID);
            tempSpawn = new L2Spawn(template1);
            tempSpawn.setLocx(181323);
            tempSpawn.setLocy(114850);
            tempSpawn.setLocz(-7623);
            tempSpawn.setHeading(32542);
            tempSpawn.setAmount(1);
            tempSpawn.setRespawnDelay(FWA_ACTIVITYTIMEOFANTHARAS * 2);
            SpawnTable.getInstance().addNewSpawn(tempSpawn, false);
            _monsterSpawn.put(29067, tempSpawn);

            // Strong Antharas
            template1 = NpcTable.getInstance().getTemplate(ANTHARASSTRONGID);
            tempSpawn = new L2Spawn(template1);
            tempSpawn.setLocx(181323);
            tempSpawn.setLocy(114850);
            tempSpawn.setLocz(-7623);
            tempSpawn.setHeading(32542);
            tempSpawn.setAmount(1);
            tempSpawn.setRespawnDelay(FWA_ACTIVITYTIMEOFANTHARAS * 2);
            SpawnTable.getInstance().addNewSpawn(tempSpawn, false);
            _monsterSpawn.put(29068, tempSpawn);
        }
        catch (final Exception e)
        {
            LOGGER.warn(e.getMessage());
        }

        // Setting spawn data of teleport cube.
        try
        {
            final L2NpcTemplate Cube = NpcTable.getInstance().getTemplate(_teleportCubeId);
            L2Spawn spawnDat;
            for (final int[] element : _teleportCubeLocation)
            {
                spawnDat = new L2Spawn(Cube);
                spawnDat.setAmount(1);
                spawnDat.setLocx(element[0]);
                spawnDat.setLocy(element[1]);
                spawnDat.setLocz(element[2]);
                spawnDat.setHeading(element[3]);
                spawnDat.setRespawnDelay(60);
                spawnDat.setLocation(0);
                SpawnTable.getInstance().addNewSpawn(spawnDat, false);
                _teleportCubeSpawn.add(spawnDat);
            }
        }
        catch (final Exception e)
        {
            LOGGER.warn(e.getMessage());
        }

        Integer status = GrandBossManager.getInstance().getBossStatus(ANTHARASOLDID);

        if (FWA_OLDANTHARAS || status == WAITING)
        {
            final StatsSet info = GrandBossManager.getInstance().getStatsSet(ANTHARASOLDID);
            final Long respawnTime = info.getLong("respawn_time");
            if (status == DEAD && respawnTime <= System.currentTimeMillis())
            {
                // the time has already expired while the server was offline. Immediately spawn antharas in his cave.
                // also, the status needs to be changed to DORMANT
                GrandBossManager.getInstance().setBossStatus(ANTHARASOLDID, DORMANT);
                status = DORMANT;
            }
            else if (status == FIGHTING)
            {
                final int loc_x = info.getInteger("loc_x");
                final int loc_y = info.getInteger("loc_y");
                final int loc_z = info.getInteger("loc_z");
                final int heading = info.getInteger("heading");
                final int hp = info.getInteger("currentHP");
                final int mp = info.getInteger("currentMP");
                _antharas = (L2GrandBossInstance) addSpawn(ANTHARASOLDID, loc_x, loc_y, loc_z, heading, false, 0);
                GrandBossManager.getInstance().addBoss(_antharas);
                _antharas.setCurrentHpMp(hp, mp);
                _LastAction = System.currentTimeMillis();
                // Start repeating timer to check for inactivity
                _activityCheckTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new CheckActivity(), 60000, 60000);
            }
            else if (status == DEAD)
            {
                ThreadPoolManager.getInstance().scheduleGeneral(new UnlockAntharas(ANTHARASOLDID), respawnTime - System.currentTimeMillis());
            }
            else if (status == DORMANT)
            {
                // Here status is 0 on Database, dont do nothing
            }
            else
            {
                setAntharasSpawnTask();
            }
        }
        else
        {
            final Integer statusWeak = GrandBossManager.getInstance().getBossStatus(ANTHARASWEAKID);

            final Integer statusNormal = GrandBossManager.getInstance().getBossStatus(ANTHARASNORMALID);

            final Integer statusStrong = GrandBossManager.getInstance().getBossStatus(ANTHARASSTRONGID);

            int antharasId = 0;
            if (statusWeak == FIGHTING || statusWeak == DEAD)
            {
                antharasId = ANTHARASWEAKID;
                status = statusWeak;
            }
            else if (statusNormal == FIGHTING || statusNormal == DEAD)
            {
                antharasId = ANTHARASNORMALID;
                status = statusNormal;
            }
            else if (statusStrong == FIGHTING || statusStrong == DEAD)
            {
                antharasId = ANTHARASSTRONGID;
                status = statusStrong;
            }
            if (antharasId != 0 && status == FIGHTING)
            {
                final StatsSet info = GrandBossManager.getInstance().getStatsSet(antharasId);
                final int loc_x = info.getInteger("loc_x");
                final int loc_y = info.getInteger("loc_y");
                final int loc_z = info.getInteger("loc_z");
                final int heading = info.getInteger("heading");
                final int hp = info.getInteger("currentHP");
                final int mp = info.getInteger("currentMP");
                _antharas = (L2GrandBossInstance) addSpawn(antharasId, loc_x, loc_y, loc_z, heading, false, 0);
                GrandBossManager.getInstance().addBoss(_antharas);
                _antharas.setCurrentHpMp(hp, mp);
                _LastAction = System.currentTimeMillis();
                // Start repeating timer to check for inactivity
                _activityCheckTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new CheckActivity(), 60000, 60000);
            }
            else if (antharasId != 0 && status == DEAD)
            {
                final StatsSet info = GrandBossManager.getInstance().getStatsSet(antharasId);
                final Long respawnTime = info.getLong("respawn_time");
                if (respawnTime <= System.currentTimeMillis())
                {
                    // the time has already expired while the server was offline. Immediately spawn antharas in his cave.
                    // also, the status needs to be changed to DORMANT
                    GrandBossManager.getInstance().setBossStatus(antharasId, DORMANT);
                    status = DORMANT;
                }
                else
                {
                    ThreadPoolManager.getInstance().scheduleGeneral(new UnlockAntharas(antharasId), respawnTime - System.currentTimeMillis());
                }
            }
        }
    }

    // Do spawn teleport cube.
    public void spawnCube()
    {
        if (_mobsSpawnTask != null)
        {
            _mobsSpawnTask.cancel(true);
            _mobsSpawnTask = null;
        }
        if (_selfDestructionTask != null)
        {
            _selfDestructionTask.cancel(true);
            _selfDestructionTask = null;
        }
        if (_activityCheckTask != null)
        {
            _activityCheckTask.cancel(false);
            _activityCheckTask = null;
        }

        for (final L2Spawn spawnDat : _teleportCubeSpawn)
        {
            _teleportCube.add(spawnDat.doSpawn());
        }
    }

    // Setting Antharas spawn task.
    public void setAntharasSpawnTask()
    {
        if (_monsterSpawnTask == null)
        {
            synchronized (this)
            {
                if (_monsterSpawnTask == null)
                {
                    GrandBossManager.getInstance().setBossStatus(ANTHARASOLDID, WAITING);
                    _monsterSpawnTask = ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(1), 60000 * Config.ANTHARAS_WAIT_TIME);
                }
            }
        }
    }

    protected void startMinionSpawns(final int antharasId)
    {
        int intervalOfMobs;

        // Interval of minions is decided by the type of Antharas
        // that invaded the lair.
        switch (antharasId)
        {
            case ANTHARASWEAKID:
                intervalOfMobs = FWA_INTERVALOFMOBSWEAK;
                break;
            case ANTHARASNORMALID:
                intervalOfMobs = FWA_INTERVALOFMOBSNORMAL;
                break;
            default:
                intervalOfMobs = FWA_INTERVALOFMOBSSTRONG;
                break;
        }

        // Spawn mobs.
        _mobsSpawnTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new MobsSpawn(), intervalOfMobs, intervalOfMobs);
    }

    // Do spawn Antharas.
    private class AntharasSpawn implements Runnable
    {
        private int _taskId = 0;
        private Collection<L2Character> _players;

        AntharasSpawn(final int taskId)
        {
            _taskId = taskId;
            if (_Zone.getCharactersInside() != null)
            {
                _players = _Zone.getCharactersInside().values();
            }
        }

        @Override
        public void run()
        {
            int npcId;
            L2Spawn antharasSpawn = null;

            switch (_taskId)
            {
                case 1: // Spawn.
                    // Strength of Antharas is decided by the number of players that
                    // invaded the lair.
                    _monsterSpawnTask.cancel(false);
                    _monsterSpawnTask = null;
                    if (FWA_OLDANTHARAS)
                        npcId = 29019; // old
                    else if (_players == null || _players != null && _players.size() <= FWA_LIMITOFWEAK)
                        npcId = 29066; // weak
                    else if (_players != null && _players.size() > FWA_LIMITOFNORMAL)
                        npcId = 29068; // strong
                    else
                        npcId = 29067; // normal

                    // Do spawn.
                    antharasSpawn = _monsterSpawn.get(npcId);
                    _antharas = (L2GrandBossInstance) antharasSpawn.doSpawn();
                    GrandBossManager.getInstance().addBoss(_antharas);

                    _monsters.add(_antharas);
                    _antharas.setIsImobilised(true);

                    GrandBossManager.getInstance().setBossStatus(ANTHARASOLDID, DORMANT);
                    GrandBossManager.getInstance().setBossStatus(npcId, FIGHTING);
                    _LastAction = System.currentTimeMillis();
                    // Start repeating timer to check for inactivity
                    _activityCheckTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new CheckActivity(), 60000, 60000);

                    // Setting 1st time of minions spawn task.
                    if (!FWA_OLDANTHARAS)
                    {
                        startMinionSpawns(npcId);
                    }

                    // Set next task.
                    if (_socialTask != null)
                    {
                        _socialTask.cancel(true);
                        _socialTask = null;
                    }
                    _socialTask = ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(2), 16);
                    break;
                case 2:
                    // Set camera.
                    broadcastPacket(new SpecialCamera(_antharas.getObjectId(), 700, 13, -19, 0, 20000));

                    // Set next task.
                    if (_socialTask != null)
                    {
                        _socialTask.cancel(true);
                        _socialTask = null;
                    }
                    _socialTask = ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(3), 3000);
                    break;

                case 3:
                    // Do social.
                    broadcastPacket(new SpecialCamera(_antharas.getObjectId(), 700, 13, 0, 6000, 20000));
                    // Set next task.
                    if (_socialTask != null)
                    {
                        _socialTask.cancel(true);
                        _socialTask = null;
                    }
                    _socialTask = ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(4), 10000);
                    break;
                case 4:
                    broadcastPacket(new SpecialCamera(_antharas.getObjectId(), 3700, 0, -3, 0, 10000));
                    // Set next task.
                    if (_socialTask != null)
                    {
                        _socialTask.cancel(true);
                        _socialTask = null;
                    }
                    _socialTask = ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(5), 200);
                    break;

                case 5:
                    // Do social.
                    broadcastPacket(new SpecialCamera(_antharas.getObjectId(), 1100, 0, -3, 22000, 30000));
                    // Set next task.
                    if (_socialTask != null)
                    {
                        _socialTask.cancel(true);
                        _socialTask = null;
                    }
                    _socialTask = ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(6), 10800);
                    break;

                case 6:
                    // Set camera.
                    broadcastPacket(new SpecialCamera(_antharas.getObjectId(), 1100, 0, -3, 300, 7000));
                    // Set next task.
                    if (_socialTask != null)
                    {
                        _socialTask.cancel(true);
                        _socialTask = null;
                    }
                    _socialTask = ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(7), 1900);
                    break;

                case 7:
                    _antharas.abortCast();

                    _mobiliseTask = ThreadPoolManager.getInstance().scheduleGeneral(new SetMobilised(_antharas), 16);

                    // Move at random.
                    if (FWA_MOVEATRANDOM)
                    {
                        final L2CharPosition pos = new L2CharPosition(Rnd.get(175000, 178500), Rnd.get(112400, 116000), -7707, 0);
                        _moveAtRandomTask = ThreadPoolManager.getInstance().scheduleGeneral(new MoveAtRandom(_antharas, pos), 500);
                    }

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

    protected void broadcastPacket(final L2GameServerPacket mov)
    {
        if (_Zone != null)
        {
            for (final L2Character characters : _Zone.getCharactersInside().values())
            {
                if (characters instanceof L2PcInstance)
                    characters.sendPacket(mov);
            }
        }
    }

    // Do spawn Behemoth or Bomber.
    private class MobsSpawn implements Runnable
    {
        public MobsSpawn()
        {
        }

        @Override
        public void run()
        {
            L2NpcTemplate template1;
            L2Spawn tempSpawn;
            final boolean isBehemoth = Rnd.get(100) < FWA_PERCENTOFBEHEMOTH;
            try
            {
                final int mobNumber = (isBehemoth ? 2 : 3);
                // Set spawn.
                for (int i = 0; i < mobNumber; i++)
                {
                    if (_monsters.size() >= FWA_MAXMOBS)
                        break;
                    int npcId;
                    if (isBehemoth)
                        npcId = 29069;
                    else
                        npcId = Rnd.get(29070, 29076);
                    template1 = NpcTable.getInstance().getTemplate(npcId);
                    tempSpawn = new L2Spawn(template1);
                    // allocates it at random in the lair of Antharas.
                    int tried = 0;
                    boolean notFound = true;
                    int x = 175000;
                    int y = 112400;
                    int dt = (_antharas.getX() - x) * (_antharas.getX() - x) + (_antharas.getY() - y) * (_antharas.getY() - y);
                    while (tried++ < 25 && notFound)
                    {
                        final int rx = Rnd.get(175000, 179900);
                        final int ry = Rnd.get(112400, 116000);
                        final int rdt = (_antharas.getX() - rx) * (_antharas.getX() - rx) + (_antharas.getY() - ry) * (_antharas.getY() - ry);
                        if (GeoData.getInstance().canSeeTarget(_antharas.getX(), _antharas.getY(), -7704, rx, ry, -7704))
                            if (rdt < dt)
                            {
                                x = rx;
                                y = ry;
                                dt = rdt;
                                if (rdt <= 900000)
                                    notFound = false;
                            }
                    }
                    tempSpawn.setLocx(x);
                    tempSpawn.setLocy(y);
                    tempSpawn.setLocz(-7704);
                    tempSpawn.setHeading(0);
                    tempSpawn.setAmount(1);
                    tempSpawn.setRespawnDelay(FWA_ACTIVITYTIMEOFANTHARAS * 2);
                    SpawnTable.getInstance().addNewSpawn(tempSpawn, false);
                    // Do spawn.
                    _monsters.add(tempSpawn.doSpawn());
                }
            }
            catch (final Exception e)
            {
                LOGGER.warn(e.getMessage());
            }
        }
    }

    @Override
    public String onAggroRangeEnter(final L2NpcInstance npc, final L2PcInstance player, final boolean isPet)
    {
        switch (npc.getNpcId())
        {
            case 29070:
            case 29071:
            case 29072:
            case 29073:
            case 29074:
            case 29075:
            case 29076:
                if (_selfDestructionTask == null && !npc.isDead())
                    _selfDestructionTask = ThreadPoolManager.getInstance().scheduleGeneral(new SelfDestructionOfBomber(npc), FWA_SELFDESTRUCTTIME);
                break;
        }
        return super.onAggroRangeEnter(npc, player, isPet);
    }

    // Do self destruction.
    private class SelfDestructionOfBomber implements Runnable
    {
        private final L2NpcInstance _bomber;

        public SelfDestructionOfBomber(final L2NpcInstance bomber)
        {
            _bomber = bomber;
        }

        @Override
        public void run()
        {
            L2Skill skill = null;
            switch (_bomber.getNpcId())
            {
                case 29070:
                case 29071:
                case 29072:
                case 29073:
                case 29074:
                case 29075:
                    skill = SkillTable.getInstance().getInfo(5097, 1);
                    break;
                case 29076:
                    skill = SkillTable.getInstance().getInfo(5094, 1);
                    break;
            }

            _bomber.doCast(skill);

            if (_selfDestructionTask != null)
            {
                _selfDestructionTask.cancel(false);
                _selfDestructionTask = null;
            }

        }
    }

    @Override
    public String onSpellFinished(final L2NpcInstance npc, final L2PcInstance player, final L2Skill skill)
    {
        if (npc.isInvul())
        {
            return null;
        }
        else if (skill != null && (skill.getId() == 5097 || skill.getId() == 5094))
        {
            switch (npc.getNpcId())
            {
                case 29070:
                case 29071:
                case 29072:
                case 29073:
                case 29074:
                case 29075:
                case 29076:
                    npc.doDie(npc);
                    break;
            }
        }
        return super.onSpellFinished(npc, player, skill);
    }

    // At end of activity time.
    protected class CheckActivity implements Runnable
    {
        @Override
        public void run()
        {
            final Long temp = (System.currentTimeMillis() - _LastAction);
            if (temp > (Config.ANTHARAS_DESPAWN_TIME * 60000))
            {
                GrandBossManager.getInstance().setBossStatus(_antharas.getNpcId(), DORMANT);
                setUnspawn();
            }
        }
    }

    // Clean Antharas's lair.
    public void setUnspawn()
    {
        // Eliminate players.
        _Zone.oustAllPlayers();

        // Not executed tasks is canceled.
        if (_cubeSpawnTask != null)
        {
            _cubeSpawnTask.cancel(true);
            _cubeSpawnTask = null;
        }
        if (_monsterSpawnTask != null)
        {
            _monsterSpawnTask.cancel(true);
            _monsterSpawnTask = null;
        }
        if (_activityCheckTask != null)
        {
            _activityCheckTask.cancel(false);
            _activityCheckTask = null;
        }
        if (_socialTask != null)
        {
            _socialTask.cancel(true);
            _socialTask = null;
        }
        if (_mobiliseTask != null)
        {
            _mobiliseTask.cancel(true);
            _mobiliseTask = null;
        }
        if (_mobsSpawnTask != null)
        {
            _mobsSpawnTask.cancel(true);
            _mobsSpawnTask = null;
        }
        if (_selfDestructionTask != null)
        {
            _selfDestructionTask.cancel(true);
            _selfDestructionTask = null;
        }
        if (_moveAtRandomTask != null)
        {
            _moveAtRandomTask.cancel(true);
            _moveAtRandomTask = null;
        }

        // Delete monsters.
        for (final L2NpcInstance mob : _monsters)
        {
            mob.getSpawn().stopRespawn();
            mob.deleteMe();
        }
        _monsters.clear();

        // Delete teleport cube.
        for (final L2NpcInstance cube : _teleportCube)
        {
            cube.getSpawn().stopRespawn();
            cube.deleteMe();
        }
        _teleportCube.clear();
    }

    // Do spawn teleport cube.
    private class CubeSpawn implements Runnable
    {
        private final int _type;

        CubeSpawn(final int type)
        {
            _type = type;
        }

        @Override
        public void run()
        {
            if (_type == 0)
            {
                spawnCube();
                _cubeSpawnTask = ThreadPoolManager.getInstance().scheduleGeneral(new CubeSpawn(1), 1800000);
            }
            else
                setUnspawn();
        }
    }

    // UnLock Antharas.
    private static class UnlockAntharas implements Runnable
    {
        private final int _bossId;

        public UnlockAntharas(final int bossId)
        {
            _bossId = bossId;
        }

        @Override
        public void run()
        {
            GrandBossManager.getInstance().setBossStatus(_bossId, DORMANT);
            if (FWA_DOSERVEREARTHQUAKE)
                for (final L2PcInstance p : L2World.getInstance().getAllPlayers())
                    p.broadcastPacket(new Earthquake(185708, 114298, -8221, 20, 10));
        }
    }

    // Action is enabled the boss.
    private class SetMobilised implements Runnable
    {
        private final L2GrandBossInstance _boss;

        public SetMobilised(final L2GrandBossInstance boss)
        {
            _boss = boss;
        }

        @Override
        public void run()
        {
            _boss.setIsImobilised(false);

            // When it is possible to act, a social action is canceled.
            if (_socialTask != null)
            {
                _socialTask.cancel(true);
                _socialTask = null;
            }
        }
    }

    // Move at random on after Antharas appears.
    private static class MoveAtRandom implements Runnable
    {
        private final L2NpcInstance _npc;
        private final L2CharPosition _pos;

        public MoveAtRandom(final L2NpcInstance npc, final L2CharPosition pos)
        {
            _npc = npc;
            _pos = pos;
        }

        @Override
        public void run()
        {
            _npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, _pos);
        }
    }

    @Override
    public String onAttack(final L2NpcInstance npc, final L2PcInstance attacker, final int damage, final boolean isPet)
    {

        if (npc.getSpawn() != null && !npc.getSpawn().is_customBossInstance() && npc.getNpcId() == 29019 || npc.getNpcId() == 29066 || npc.getNpcId() == 29067 || npc.getNpcId() == 29068)
        {
            _LastAction = System.currentTimeMillis();
            /*
             * if (GrandBossManager.getInstance().getBossStatus(_antharas.getNpcId()) != FIGHTING) { _Zone.oustAllPlayers(); } else
             */if (!FWA_OLDANTHARAS && _mobsSpawnTask == null)
            {
                startMinionSpawns(npc.getNpcId());
            }
        }
        else if (npc.getNpcId() > 29069 && npc.getNpcId() < 29077 && npc.getCurrentHp() <= damage)
        {
            L2Skill skill = null;
            switch (npc.getNpcId())
            {
                case 29070:
                case 29071:
                case 29072:
                case 29073:
                case 29074:
                case 29075:
                    skill = SkillTable.getInstance().getInfo(5097, 1);
                    break;
                case 29076:
                    skill = SkillTable.getInstance().getInfo(5094, 1);
                    break;
            }

            npc.doCast(skill);
        }
        return super.onAttack(npc, attacker, damage, isPet);
    }

    @Override
    public String onKill(final L2NpcInstance npc, final L2PcInstance killer, final boolean isPet)
    {
        if (npc.getNpcId() == 29019 || npc.getNpcId() == 29066 || npc.getNpcId() == 29067 || npc.getNpcId() == 29068)
        {
            npc.broadcastPacket(new PlaySound(1, "BS01_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));

            if (!npc.getSpawn().is_customBossInstance())
            {
                _cubeSpawnTask = ThreadPoolManager.getInstance().scheduleGeneral(new CubeSpawn(0), 10000);
                GrandBossManager.getInstance().setBossStatus(npc.getNpcId(), DEAD);
                final long respawnTime = (Config.ANTHARAS_RESP_FIRST + Rnd.get(Config.ANTHARAS_RESP_SECOND)) * 3600000;
                ThreadPoolManager.getInstance().scheduleGeneral(new UnlockAntharas(npc.getNpcId()), respawnTime);
                // also save the respawn time so that the info is maintained past reboots
                final StatsSet info = GrandBossManager.getInstance().getStatsSet(npc.getNpcId());
                info.set("respawn_time", (System.currentTimeMillis() + respawnTime));
                GrandBossManager.getInstance().setStatsSet(npc.getNpcId(), info);
            }

        }
        else if (npc.getNpcId() == 29069)
        {
            final int countHPHerb = Rnd.get(6, 18);
            final int countMPHerb = Rnd.get(6, 18);
            for (int i = 0; i < countHPHerb; i++)
                ((L2MonsterInstance) npc).DropItem(killer, 8602, 1);
            for (int i = 0; i < countMPHerb; i++)
                ((L2MonsterInstance) npc).DropItem(killer, 8605, 1);
        }
        if (_monsters.contains(npc))
            _monsters.remove(npc);
        return super.onKill(npc, killer, isPet);
    }

    @Override
    public void run()
    {
    }
}
Edited by stepas30

4 answers to this question

Recommended Posts

  • 0
Posted

You should make it at the beginning of startMinionSpawns(int) method.

If you know how to make configs, just put in there:

if(!Config.ENABLE_ANTHARAS_MINIONS)//You will need to create ENABLE_ANTHARAS_MINIONS field in Config.java
     return;

If you are total newbie, you can just remove the content of that method and it will make a job too :P However that's not recommended, because if you will change your mind, then you will have a problem :)

  • 0
Posted

You should make it at the beginning of startMinionSpawns(int) method.

If you know how to make configs, just put in there:

if(!Config.ENABLE_ANTHARAS_MINIONS)//You will need to create ENABLE_ANTHARAS_MINIONS field in Config.java
     return;

If you are total newbie, you can just remove the content of that method and it will make a job too :P However that's not recommended, because if you will change your mind, then you will have a problem :)

Maybe we could show where to save at all? not because you know how to create confings

  • 0
Posted

Could you help create a whole where the order of priority as the created config? and where exactly to paste this code instead.
 

if(!Config.ENABLE_ANTHARAS_MINIONS)//You will need to create ENABLE_ANTHARAS_MINIONS field in Config.java
     return;
  • 0
Posted (edited)

You should make it at the beginning of startMinionSpawns(int) method.

If you know how to make configs, just put in there:

if(!Config.ENABLE_ANTHARAS_MINIONS)//You will need to create ENABLE_ANTHARAS_MINIONS field in Config.java
     return;

If you are total newbie, you can just remove the content of that method and it will make a job too :P However that's not recommended, because if you will change your mind, then you will have a problem :)

    protected void startMinionSpawns(final int antharasId)
    {
+       if(!Config.ENABLE_ANTHARAS_MINIONS)//You will need to create ENABLE_ANTHARAS_MINIONS field in Config.java
+       return;
        int intervalOfMobs;
 
        // Interval of minions is decided by the type of Antharas
        // that invaded the lair.
        switch (antharasId)
        {
            case ANTHARASWEAKID:
                intervalOfMobs = FWA_INTERVALOFMOBSWEAK;
                break;
            case ANTHARASNORMALID:
                intervalOfMobs = FWA_INTERVALOFMOBSNORMAL;
                break;
            default:
                intervalOfMobs = FWA_INTERVALOFMOBSSTRONG;
                break;
        }
 
        // Spawn mobs.
        _mobsSpawnTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new MobsSpawn(), intervalOfMobs, intervalOfMobs);
    }
Edited by StealthyS4m

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • I connected everything without any problems. Does anyone know why I'm not getting experience for killing mobs? Has anyone encountered this? I'm setting the rates to x300, but it still doesn't give experience or level for killing mobs.
    • I'm using Myext64 HF and recently tried to replicate the "br_xmas09_event" Raising Rudolph Event. Detailed event information can be found at https://legacy-lineage2.com/news/_rudolf_the_red.html After configuring .eventdata.xml and starting the server, t  server log shows: 12/02/2025 15:39:01.809, [NO_ERROR] SpawnEx2 [br_xmas2009_invisible][schuttgart20_npc2213_xs03m1] [1][0][0][0][0][346796390] 12/02/2025 15:39:02.057, DummyPacket received from L2Server 12/02/2025 15:39:02.058, server socket close 312ac(f0820224) error(997) 12/02/2025 15:39:02.058, [CallStack][tid:0][tick:2][0] Begin 12/02/2025 15:39:02.058, [CallStack][tid:0][tick:2][1][0] void __cdecl IOThreadCallback::IOThread_common(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][2][1] void IOThread_common 1 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][3][2] void __cdecl CIOSocketEx<class CIOBufferEx<16384> >::Close(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][4][3] void __cdecl CServerSocket::OnClose(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][5] End l2server log: 12/02/2025 15:39:02.112, npc server closed(127.0.0.1) error: 64 read buffer size: (server:0 npc:0) 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.131, dwTime[0] < 80 !!!!!!! 12/02/2025 15:39:02.131, [CallStack][tid:7][tick:1][0] Begin 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][1][0] void __cdecl IOThreadCallback::IOThread_common(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][2][1] void IOThread_common 1 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][4][3] void __cdecl NpcSocket::OnClose(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][3][2] void __cdecl CIOSocketEx<class CIOBufferEx<16384> >::Close(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][5] End 12/02/2025 15:39:31.767, server closed(127.0.0.1) Error: 64 Read buffer size: (server:0 npc:0) 12/02/2025 15:39:31.768, [NO_ERROR] Logout All Characters : 1   The NPC server sent a packet to the L2 server while generating the br_xmas2009_invisible game NPC server, and the NPC server subsequently crashed.     After some digging, I found a clue in a very old MXC post, but the fix was for the GF version. The whole problem is in l2server side support for NPC function CreateOnePrivateNearUser. It sends CreatePacket but Koreans made some changes in it (added instance ID) so it got broken. As Santa event is the only AI that uses this function, they probably don't know about it    So is there a way to fix this problem, specifically for Myext64 HF? I'd be happy to buy him coffee. set_compiler_opt base_event_type(@NTYPE_NPC_EVENT) class ai_br_vital_manager : default_npc { parameter: int br_vitality2010_EVENT_ID = 20108888; handler: EventHandler CREATED() { } EventHandler TALKED(talker) { ShowPage(talker, "br_vi_stevu001.htm"); super; } EventHandler GIVE_EVENT_DATA(talker, i0, i1, i2, i3, i4) { i3 = i2 / 3600; i2 = i2 - i3 * 3600; i4 = i2 / 60; i2 = i2 - i4 * 60; if (i1 == 20108888) { if (i0 == 1) { CastBuffForQuestReward(talker, @s_br_vitality_day_1); CastBuffForQuestReward(talker, @s_br_vitality_day_2); ShowPage(talker, "br_vi_stevu002.htm"); } else { ShowPage(talker, "br_vi_stevu003.htm"); } } } EventHandler MENU_SELECTED(talker, ask, reply, c0) { if (ask == 50021) { select (reply) { case 1: CanGiveEventData(talker, 20108888); break; case 2: if (talker.level <= 75) { ShowPage(talker, "br_vi_stevu005.htm"); } else if (IsInCategory(@fighter_group, talker.occupation)) { CastBuffForQuestReward(talker, @s_wind_walk_for_newbie); CastBuffForQuestReward(talker, @s_shield_for_newbie); CastBuffForQuestReward(talker, @s_magic_barrier_for_adventurer); CastBuffForQuestReward(talker, @s_bless_the_body_for_newbie); CastBuffForQuestReward(talker, @s_vampiric_rage_for_newbie); CastBuffForQuestReward(talker, @s_regeneration_for_newbie); CastBuffForQuestReward(talker, @s_haste_for_adventurer); ShowPage(talker, "br_vi_stevu006.htm"); } else if (IsInCategory(@mage_group, talker.occupation)) { CastBuffForQuestReward(talker, @s_wind_walk_for_newbie); CastBuffForQuestReward(talker, @s_shield_for_newbie); CastBuffForQuestReward(talker, @s_magic_barrier_for_adventurer); CastBuffForQuestReward(talker, @s_bless_the_soul_for_newbie); CastBuffForQuestReward(talker, @s_acumen_for_newbie); CastBuffForQuestReward(talker, @s_concentration_for_newbie); CastBuffForQuestReward(talker, @s_empower_for_newbie); ShowPage(talker, "br_vi_stevu007.htm"); } break; case 3: c0 = GetSummon(talker); if (talker.level <= 75) { ShowPage(talker, "br_vi_stevu011.htm"); } else if (IsNullCreature(c0) == 0 && IsInCategory(@summon_npc_group, c0.class_id) && IsInCategory(@pet_group, c0.class_id) == 0) { CastBuffForQuestReward(c0, @s_wind_walk_for_newbie); CastBuffForQuestReward(c0, @s_shield_for_newbie); CastBuffForQuestReward(c0, @s_magic_barrier_for_adventurer); CastBuffForQuestReward(c0, @s_bless_the_body_for_newbie); CastBuffForQuestReward(c0, @s_vampiric_rage_for_newbie); CastBuffForQuestReward(c0, @s_regeneration_for_newbie); CastBuffForQuestReward(c0, @s_bless_the_soul_for_newbie); CastBuffForQuestReward(c0, @s_acumen_for_newbie); CastBuffForQuestReward(c0, @s_concentration_for_newbie); CastBuffForQuestReward(c0, @s_empower_for_newbie); CastBuffForQuestReward(c0, @s_haste_for_adventurer); ShowPage(talker, "br_vi_stevu009.htm"); } else { ShowPage(talker, "br_vi_stevu010.htm"); } break; } } } } Another one is about the " br_vitality2010_event event".   GIVE_EVENT_DATA is likely the only one in the activity AI script that uses this handle.      
    • Offtopic, personal attacks, probably too old to use that much memes and what's YOUR actual contribution to L2J, in order I laugh aswell ?   The main poster quotes my pack so I answer accordingly, while you advertise L2JFrozen in both of your posts - discontinued since 2014 (? 1132 rev), with none taking back the open source lead while anyone could.   If you're somewhat affiliated to hopzone, you probably packed way more money than me. Packs don't make any type of money (barely 100e/month) and if you would follow me, you would know there are ways to handle it or even getting paid.   Hope I was short enough, 🧂🤡.
    • Hi guys, this is a CMS im sharing for lineage 2 servers, im tired of the crap i see on new release servers. Dont let me start on the IA developed ones lmao.   📋 Description Free and open source template to create landing pages for Lineage 2 private servers. Designed with a dark fantasy theme and modern animations. ✨ Current Features This FREE version includes: Complete Landing Page - Professional design ready to use Multi-language Support - Spanish, English, Portuguese Dark Fantasy Theme - With animated UI elements Server Information - Rates, features, and rules Olympiad Ranking - Rankings display Download Section - For game client Skins and Animations Gallery Streaming Widget - Twitch/Kick integration Fully Customizable - Via configuration files ❌ Not Included in Free Version ❌ User Registration System ❌ Online Players Counter ❌ Donation Panel 💎 Premium Integrations IntegrationPrice Registration System $50 USD Online Players Counter $50 USD Donation Panel $50 USD   📧 Contact: https://gh0tstudio.com 🛠️ Tech Stack Technology    Version    Description React              19.2.0       UI Library TypeScript       5.8.2        Static typing Vite                 6.2.0         Build tool TailwindCSS   CDNCSS    Framework Lucide React   0.554.0         Icons i18next           23.16.0       Internationalization react-i18next   15.1.0        React bindings for i18n All documentation provided for AI AGENTS to make changes on the ui texts and so on. u can have a look on the cms fully working with donation panel, online count and register via: https://crmlineage2.vercel.app/ https://github.com/6h0T/CRM-LINEAGE2-FREE If u are in the lookings to develop a unique website for ur projects, u can dm me or contact me throw my socials on my profile. all code has encrypted references so any type of rebranding, copying or selling without authorization will result in take downs
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock