Jump to content

Recommended Posts

Posted

 

Hello.

 

I have made a custom instance based on the Kamaloka instance. I basically got the script, removed all zones except one and i added mobs and i adapted it to Devastated Castle.

All works fine except when i enter instance the doors inside the castle light up when i hover the mouse cursor over it, but they are untargetable.  I tryed to add L2DoorInstance but nothing happened, aldough server had no errors in running the script.

 

Also, it would be much apreciated if  someone could make the RaidBoss spawn after the miniboss is killed. Tryed a few things but none worked.

 

I must state that i don t have a good knowledge of java scripts or programing... but with time i learned how scripts in L2 work.

 

Any help would be much apreciated. Thank you.

 

Script is Kamaloka from L2Sunrise Source.

 

Thank you !

 

Here is the modified script >

 

/*
 * Copyright (C) 2004-2015 L2J DataPack
 *
 * This file is part of L2J DataPack.
 *
 * L2J DataPack 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.
 *
 * L2J DataPack 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 instances.BloodRun;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Map;

import l2r.gameserver.data.xml.impl.SkillData;
import l2r.gameserver.instancemanager.InstanceManager;
import l2r.gameserver.model.L2Party;
import l2r.gameserver.model.L2Spawn;
import l2r.gameserver.model.L2World;
import l2r.gameserver.model.Location;
import l2r.gameserver.model.actor.L2Character;
import l2r.gameserver.model.actor.L2Npc;
import l2r.gameserver.model.actor.instance.L2PcInstance;
import l2r.gameserver.model.effects.L2Effect;
import l2r.gameserver.model.entity.Instance;
import l2r.gameserver.model.instancezone.InstanceWorld;
import l2r.gameserver.model.skills.L2Skill;
import l2r.gameserver.network.SystemMessageId;
import l2r.gameserver.network.serverpackets.SystemMessage;

import instances.AbstractInstance;

public final class BloodRun extends AbstractInstance
{
    /*
     * Reset time for all BloodRun Default: 6:30AM on server time
     */
    private static final int RESET_HOUR = 6;
    private static final int RESET_MIN = 30;
    
    /*
     * Time after which instance without players will be destroyed Default: 5 minutes
     */
    private static final int EMPTY_DESTROY_TIME = 5;
    
    /*
     * Time to destroy instance (and eject players away) after boss defeat Default: 5 minutes
     */
    private static final int EXIT_TIME = 5;
    
    /*
     * Maximum level difference between players level and BloodRun level Default: 5
     */
    private static final int MAX_LEVEL_DIFFERENCE = 5;
    
    /*
     * If true shaman in the first room will have same npcId as other mobs, making radar useless Default: true (but not retail like)
     */
    private static final boolean STEALTH_SHAMAN = true;
    // Template IDs for BloodRun
    // @formatter:off
    private static final int[] TEMPLATE_IDS =
    {
        161, 162
    };
    
    // Level of the BloodRun
    private static final int[] LEVEL =
    {
        81
    };
    
    // Duration of the instance, minutes
    private static final int[] DURATION =
    {
        60
    };
    // Maximum party size for the instance
    private static final int[] MAX_PARTY_SIZE =
    {
        9
    };

    /**
     * List of buffs NOT removed on enter from player and pet<br>
     * On retail only newbie guide buffs not removed<br>
     * CAUTION: array must be sorted in ascension order!
     */
    protected static final int[] BUFFS_WHITELIST =
    {
        4322, 4323, 4324, 4325, 4326, 4327, 4328, 4329, 4330, 4331, 5632, 5637, 5950, 982, 915, 274, 307, 309, 276, 825, 1537, 1538, 1548, 1232, 1307, 1257, 1047, 4351, 4344, 4348, 4347, 4353, 4346, 4352, 4356, 4355, 1303, 4358, 4359, 4357, 4354, 4360, 1392, 1393, 1354, 1353, 1352, 4349, 4350, 1284, 1461, 1397, 1416, 1085, 1304, 1087, 1062, 1243, 1045, 1048, 1397, 1078, 1242, 1059, 1077, 1240, 1086, 1043, 1032, 1036, 1460, 1035, 1068, 1044, 1182, 1191, 1033, 1259, 1189, 1040, 1268, 1284, 1139, 1140, 1141, 1144, 1145, 1146, 1497, 1388, 1389, 1413, 1363, 1356, 1355, 1357, 1414, 4702, 4703, 4699, 4700, 1349, 1346, 1347, 1348, 1002, 1311, 1087, 1007, 1009, 1229, 1251, 1252, 1253, 1284, 1308, 1309, 1310, 1362, 1363, 1390, 1391, 1413, 1006, 1204, 1003, 1004, 1005, 1008, 1010, 1249, 1250, 1256, 1260, 1261, 1282, 1364, 1365, 1415, 1416, 1238, 1501, 1502, 1503, 1504, 1519, 1500, 1499, 1545, 1536, 1542, 1562, 1535, 4342, 4345, 4343, 264, 266, 306, 308, 268, 363, 364, 349, 265, 304, 270, 305, 269, 829, 530, 914, 277, 275, 826, 827, 271, 828, 830, 272, 310, 311, 529, 1323, 267, 273, 365, 764, 765, 7006, 7029, 1549, 366,
    };
    // @formatter:on
    // Teleport points into instances x, y, z
    private static final Location[] TELEPORTS =
    {
    new Location(178330, -15269, -2256)
    };
    // Respawn delay for the mobs in the first room, seconds Default: 25
    private static final int FIRST_ROOM_RESPAWN_DELAY = 25;
    
    //@formatter:off
    
    /*
     * First room information, null if room not spawned
     * Skill is casted on the boss when shaman is defeated and mobs respawn stopped
     * Default: 5699 (decrease pdef)
     *
     * shaman npcId, minions npcId, skillId, skillLvl
     */
    private static final int[][] FIRST_ROOM =
    {
        { 22857, 22857, 5699, 1 }
    };
    
    /*
     * First room spawns, null if room not spawned
     *
     * x, y, z
     */
    private static final int[][][] FIRST_ROOM_SPAWNS =
    {    
        {
            { 177547, -14832, -2232 }, { 177753, -15083, -2232 },
            { 177504, -15232, -2232 }, { 177055, -15446, -2256 },
            { 177198, -15924, -2256 }, { 177496, -15544, -2256 },
            { 177569, -16064, -2256 }, { 177776, -15486, -2256 },
            { 177723, -15806, -2256 }, { 177841, -16243, -2256 },
            { 178059, -16010, -2256 }, { 178032, -15403, -2256 },
            { 178093, -15695, -2256 }, { 178156, -16290, -2224 },
            { 178345, -16278, -2224 }, { 178370, -15632, -2256 },
            { 178394, -16049, -2256 }, { 178681, -15468, -2256 },
            { 178974, -15411, -2256 }, { 178581, -15855, -2256 },
            { 178723, -16192, -2256 }, { 178832, -15955, -2256 },
            { 178863, -15695, -2256 }, { 179029, -16148, -2256 },
            { 179580, -15364, -2256 }, { 179310, -15521, -2256 },
            { 179454, -15066, -2232 }, { 179325, -14826, -2232 },
            { 179216, -15186, -2232 }, { 179392, -15823, -2256 },
            { 179659, -15940, -2256 }, { 179522, -16118, -2256 },
            { 179671, -16304, -2256 }, { 179538, -16550, -2256 },
            { 179627, -16698, -2256 }, { 179508, -16885, -2256 },
            { 179603, -17094, -2256 }, { 179474, -17294, -2256 },
            { 179697, -17278, -2256 }, { 179615, -17499, -2256 },
            { 179489, -17673, -2256 }, { 179650, -17804, -2256 },
            { 179492, -17918, -2256 }, { 179699, -18012, -2256 },
            { 179593, -18246, -2256 }, { 179705, -18501, -2256 },
            { 179467, -18861, -2256 }, { 179518, -18604, -2256 },
            { 179303, -18702, -2256 }, { 179181, -18512, -2256 },
            { 179027, -18785, -2256 }, { 178922, -18548, -2256 },
            { 178620, -18730, -2256 }, { 178654, -18517, -2256 },
            { 178858, -18996, -2256 }, { 178417, -18595, -2256 },
            { 178731, -18159, -2224 }, { 178058, -18041, -2224 },
            { 178134, -17738, -2224 }, { 178750, -17810, -2224 },
            { 178957, -17509, -2224 }, { 178757, -17304, -2224 },
            { 178999, -17166, -2224 }, { 178875, -17009, -2224 },
            { 179082, -16850, -2224 }, { 178863, -16595, -2224 },
            { 178585, -16812, -2224 }, { 178342, -16640, -2224 }
        }
    };
    
    /*
     * Second room information, null if room not spawned
     * Skill is casted on the boss when all mobs are defeated
     * Default: 5700 (decrease mdef)
     *
     * npcId, skillId, skillLvl
     */
    private static final int[][] SECOND_ROOM =
    {
        { 22856, 5699, 1 }
    };
    
    /*
     * Spawns for second room, null if room not spawned
     *
     * x, y, z
     */
    private static final int[][][] SECOND_ROOM_SPAWNS =
    {    
        {
            { 178078, -16888, -2224 }, { 177899, -16615, -2224 },
            { 177680, -16928, -2224 }, { 177516, -16607, -2224 },
            { 177334, -16836, -2224 }, { 177209, -17060, -2224 },
            { 177234, -17374, -2224 }, { 177321, -17712, -2224 },
            { 177524, -17191, -2224 }, { 177850, -17190, -2224 },
            { 178136, -17279, -2224 }, { 178035, -17408, -2224 },
            { 177669, -17389, -2224 }, { 177518, -17596, -2224 },
            { 177492, -17859, -2224 }, { 177657, -17764, -2224 },
            { 177856, -17560, -2224 }, { 177803, -17919, -2224 },
            { 178019, -17759, -2224 }, { 178098, -17986, -2224 },
            { 178347, -18052, -2224 }, { 177927, -16789, -2224 }
        }
    };
    
    // miniboss info
    // skill is casted on the boss when miniboss is defeated
    // npcId, x, y, z, skill id, skill level
    /*
     * Miniboss information, null if miniboss not spawned
     * Skill is casted on the boss when miniboss is defeated
     * Default: 5701 (decrease patk)
     *
     * npcId, x, y, z, skillId, skillLvl
     */
    private static final int[][] MINIBOSS =
    {
        { 10156, 178325, -17779, -2200, 5701, 1 }
    };
    
    /*
     * Bosses of the BloodRun
     * Instance ends when boss is defeated
     *
     * npcId, x, y, z
     */
    private static final int[][] BOSS =
    {
        { 10000, 178310, -17489, -2200 },
    };
    
    /*
     * Escape telepoters spawns, null if not spawned
     *
     * x, y, z
     */
    private static final int[][] TELEPORTERS =
    {
        null, null,
    };
    
    /*
     * Escape teleporter npcId
     */
    private static final int TELEPORTER = 32496;

    /*
     * BloodRun captains (start npc's) npcIds.
     */
    private static final int[] CAPTAINS =
    { 500 };
    
    //@formatter:on
    
    protected class BloodWorld extends InstanceWorld
    {
        public int index; // 0-18 index of the Blood type in arrays
        public int shaman = 0; // objectId of the shaman
        public List<L2Spawn> firstRoom; // list of the spawns in the first room (excluding shaman)
        public List<Integer> secondRoom;// list of objectIds mobs in the second room
        public int miniBoss = 0; // objectId of the miniboss
        public L2Npc boss = null; // boss
    }
    
    public BloodRun()
    {
        super(BloodRun.class.getSimpleName());
        addFirstTalkId(TELEPORTER);
        addTalkId(TELEPORTER);
        addStartNpc(CAPTAINS);
        addTalkId(CAPTAINS);
        
        for (int[] mob : FIRST_ROOM)
        {
            if (mob != null)
            {
                if (STEALTH_SHAMAN)
                {
                    addKillId(mob[1]);
                }
                else
                {
                    addKillId(mob[0]);
                }
            }
        }
        for (int[] mob : SECOND_ROOM)
        {
            if (mob != null)
            {
                addKillId(mob[0]);
            }
        }
        for (int[] mob : MINIBOSS)
        {
            if (mob != null)
            {
                addKillId(mob[0]);
            }
        }
        for (int[] mob : BOSS)
        {
            addKillId(mob[0]);
        }
    }
    
    /**
     * Check if party with player as leader allowed to enter
     * @param player party leader
     * @param index (0-18) index of the BloodRun in arrays
     * @return true if party allowed to enter
     */
    private static final boolean checkPartyConditions(L2PcInstance player, int index)
    {
        if (player.isGM())
        {
            return true;
        }
        
        final L2Party party = player.getParty();
        // player must be in party
        if (party == null)
        {
            player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
            return false;
        }
        // ...and be party leader
        if (party.getLeader() != player)
        {
            player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
            return false;
        }
        // party must not exceed max size for selected instance
        if (party.getMemberCount() > MAX_PARTY_SIZE[index])
        {
            player.sendPacket(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER);
            return false;
        }
        
        // get level of the instance
        final int level = LEVEL[index];
        // and client name
        final String instanceName = InstanceManager.getInstance().getInstanceIdName(TEMPLATE_IDS[index]);
        
        Map<Integer, Long> instanceTimes;
        // for each party member
        for (L2PcInstance partyMember : party.getMembers())
        {
            // player level must be in range
            if (Math.abs(partyMember.getLevel() - level) > MAX_LEVEL_DIFFERENCE)
            {
                SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_LEVEL_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED);
                sm.addPcName(partyMember);
                player.sendPacket(sm);
                return false;
            }
            // player must be near party leader
            if (!partyMember.isInsideRadius(player, 1000, true, true))
            {
                SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
                sm.addPcName(partyMember);
                player.sendPacket(sm);
                return false;
            }
            // get instances reenter times for player
            instanceTimes = InstanceManager.getInstance().getAllInstanceTimes(partyMember.getObjectId());
            if (instanceTimes != null)
            {
                for (int id : instanceTimes.keySet())
                {
                    // find instance with same name (BloodRun or labyrinth)
                    // TODO: Zoey76: Don't use instance name, use other system.
                    if (!instanceName.equals(InstanceManager.getInstance().getInstanceIdName(id)))
                    {
                        continue;
                    }
                    // if found instance still can't be reentered - exit
                    if (System.currentTimeMillis() < instanceTimes.get(id))
                    {
                        SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_RE_ENTER_YET);
                        sm.addPcName(partyMember);
                        player.sendPacket(sm);
                        return false;
                    }
                }
            }
        }
        return true;
    }


    /**
     * Removing all buffs from player and pet except BUFFS_WHITELIST
     * @param ch player
     */
    private static final void removeBuffs(L2Character ch)
    {
        for (L2Effect e : ch.getEffectList().getEffects())
        {
            if (e == null)
            {
                continue;
            }
            L2Skill skill = e.getSkill();
            if (skill.isDebuff() || skill.isStayAfterDeath())
            {
                continue;
            }
            if (Arrays.binarySearch(BUFFS_WHITELIST, skill.getId()) >= 0)
            {
                continue;
            }
            e.exit();
        }
        if (ch.getSummon() != null)
        {
            for (L2Effect e : ch.getSummon().getEffectList().getEffects())
            {
                if (e == null)
                {
                    continue;
                }
                L2Skill skill = e.getSkill();
                if (skill.isDebuff() || skill.isStayAfterDeath())
                {
                    continue;
                }
                if (Arrays.binarySearch(BUFFS_WHITELIST, skill.getId()) >= 0)
                {
                    continue;
                }
                e.exit();
            }
        }
    }
    
    /**
     * Handling enter of the players into BloodRun
     * @param player party leader
     * @param index (0-18) BloodRun index in arrays
     */
    private final synchronized void enterInstance(L2PcInstance player, int index)
    {
        int templateId = TEMPLATE_IDS[index];
        // check for existing instances for this player
        InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
        // player already in the instance
        if (world != null)
        {
            // but not in BloodRun
            if (!(world instanceof BloodWorld) || (world.getTemplateId() != templateId))
            {
                player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_ANOTHER_INSTANT_ZONE_THEREFORE_YOU_CANNOT_ENTER_CORRESPONDING_DUNGEON);
                return;
            }
            // check for level difference again on reenter
            if (Math.abs(player.getLevel() - LEVEL[((BloodWorld) world).index]) > MAX_LEVEL_DIFFERENCE)
            {
                SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_LEVEL_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED);
                sm.addPcName(player);
                player.sendPacket(sm);
                return;
            }
            // check what instance still exist
            Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
            if (inst != null)
            {
                removeBuffs(player);
                teleportPlayer(player, TELEPORTS[index], world.getInstanceId());
                world.addAllowed(player.getObjectId());
            }
            return;
        }
        // Creating new BloodRun instance
        if (!checkPartyConditions(player, index))
        {
            return;
        }
        
        // Creating dynamic instance without template
        final int instanceId = InstanceManager.getInstance().createDynamicInstance(null);
        final Instance inst = InstanceManager.getInstance().getInstance(instanceId);
        // set name for the BloodRun
        inst.setName(InstanceManager.getInstance().getInstanceIdName(templateId));
        // set return location
        inst.setExitLoc(new Location(player));
        // disable summon friend into instance
        inst.setAllowSummon(false);
        // set duration and empty destroy time
        inst.setDuration(DURATION[index] * 60000);
        inst.setEmptyDestroyTime(EMPTY_DESTROY_TIME * 60000);
        
        // Creating new instanceWorld, using our instanceId and templateId
        world = new BloodWorld();
        world.setInstanceId(instanceId);
        world.setTemplateId(templateId);
        // set index for easy access to the arrays
        ((BloodWorld) world).index = index;
        InstanceManager.getInstance().addWorld(world);
        world.setStatus(0);
        // spawn npcs
        spawnBlood((BloodWorld) world);
        
        if (player.isGM())
        {
            world.addAllowed(player.getObjectId());
            teleportPlayer(player, TELEPORTS[index], instanceId);
        }
        else
        {
            // and finally teleport party into instance
            final L2Party party = player.getParty();
            for (L2PcInstance partyMember : party.getMembers())
            {
                world.addAllowed(partyMember.getObjectId());
                
                teleportPlayer(partyMember, TELEPORTS[index], instanceId);
            }
        }
        return;
    }
    
    /**
     * Called on instance finish and handles reenter time for instance
     * @param world instanceWorld
     */
    @Override
    protected final void finishInstance(InstanceWorld world)
    {
        if (world instanceof BloodWorld)
        {
            Calendar reenter = Calendar.getInstance();
            reenter.set(Calendar.MINUTE, RESET_MIN);
            // if time is >= RESET_HOUR - roll to the next day
            if (reenter.get(Calendar.HOUR_OF_DAY) >= RESET_HOUR)
            {
                reenter.add(Calendar.DATE, 1);
            }
            reenter.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
            
            SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_FROM_HERE_S1_S_ENTRY_HAS_BEEN_RESTRICTED);
            sm.addInstanceName(world.getTemplateId());
            
            // set instance reenter time for all allowed players
            for (int objectId : world.getAllowed())
            {
                L2PcInstance obj = L2World.getInstance().getPlayer(objectId);
                if ((obj != null) && obj.isOnline())
                {
                    InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
                    obj.sendPacket(sm);
                }
            }
            
            // destroy instance after EXIT_TIME
            Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
            inst.setDuration(EXIT_TIME * 60000);
            inst.setEmptyDestroyTime(0);
        }
    }
    
    /**
     * Spawn all NPCs in BloodRun
     * @param world instanceWorld
     */
    private final void spawnBlood(BloodWorld world)
    {
        int[] npcs;
        int[][] spawns;
        L2Npc npc;
        final int index = world.index;
        
        // first room
        npcs = FIRST_ROOM[index];
        spawns = FIRST_ROOM_SPAWNS[index];
        if (npcs != null)
        {
            world.firstRoom = new ArrayList<>(spawns.length - 1);
            int shaman = getRandom(spawns.length); // random position for shaman
            
            for (int i = 0; i < spawns.length; i++)
            {
                if (i == shaman)
                {
                    // stealth shaman use same npcId as other mobs
                    npc = addSpawn(STEALTH_SHAMAN ? npcs[1] : npcs[0], spawns[i][0], spawns[i][1], spawns[i][2], 0, false, 0, false, world.getInstanceId());
                    world.shaman = npc.getObjectId();
                }
                else
                {
                    npc = addSpawn(npcs[1], spawns[i][0], spawns[i][1], spawns[i][2], 0, false, 0, false, world.getInstanceId());
                    L2Spawn spawn = npc.getSpawn();
                    spawn.setRespawnDelay(FIRST_ROOM_RESPAWN_DELAY);
                    spawn.setAmount(1);
                    spawn.startRespawn();
                    world.firstRoom.add(spawn); // store mobs spawns
                }
                npc.setIsNoRndWalk(true);
            }
        }
        
        // second room
        npcs = SECOND_ROOM[index];
        spawns = SECOND_ROOM_SPAWNS[index];
        if (npcs != null)
        {
            world.secondRoom = new ArrayList<>(spawns.length);
            
            for (int[] spawn : spawns)
            {
                npc = addSpawn(npcs[0], spawn[0], spawn[1], spawn[2], 0, false, 0, false, world.getInstanceId());
                npc.setIsNoRndWalk(true);
                world.secondRoom.add(npc.getObjectId());
            }
        }
        
        // miniboss
        if (MINIBOSS[index] != null)
        {
            npc = addSpawn(MINIBOSS[index][0], MINIBOSS[index][1], MINIBOSS[index][2], MINIBOSS[index][3], 0, false, 0, false, world.getInstanceId());
            npc.setIsNoRndWalk(true);
            world.miniBoss = npc.getObjectId();
        }
        
        // escape teleporter
        if (TELEPORTERS[index] != null)
        {
            addSpawn(TELEPORTER, TELEPORTERS[index][0], TELEPORTERS[index][1], TELEPORTERS[index][2], 0, false, 0, false, world.getInstanceId());
        }
        
        // boss
        world.boss = addSpawn(BOSS[index][0], BOSS[index][1], BOSS[index][2], BOSS[index][3], 0, false, 0, false, world.getInstanceId());
    }
    
    /**
     * Handles only player's enter, single parameter - integer BloodRun index
     */
    @Override
    public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
    {
        enterInstance(player, Integer.parseInt(event));
        return "";
    }
    
    /**
     * Talk with captains and using of the escape teleporter
     */
    @Override
    public final String onTalk(L2Npc npc, L2PcInstance player)
    {
        final int npcId = npc.getId();
        if (npcId == TELEPORTER)
        {
            final L2Party party = player.getParty();
            // only party leader can talk with escape teleporter
            if ((party != null) && party.isLeader(player))
            {
                final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
                if (world instanceof BloodWorld)
                {
                    // party members must be in the instance
                    if (world.isAllowed(player.getObjectId()))
                    {
                        Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
                        
                        // teleports entire party away
                        for (L2PcInstance partyMember : party.getMembers())
                        {
                            if ((partyMember != null) && (partyMember.getInstanceId() == world.getInstanceId()))
                            {
                                teleportPlayer(partyMember, inst.getExitLoc(), 0);
                            }
                        }
                    }
                }
            }
        }
        else
        {
            return npcId + ".htm";
        }
        
        return "";
    }
    
    /**
     * Only escape teleporters first talk handled
     */
    @Override
    public final String onFirstTalk(L2Npc npc, L2PcInstance player)
    {
        if (npc.getId() == TELEPORTER)
        {
            if (player.isGM())
            {
                return "32496.htm";
            }
            
            if (player.isInParty() && player.getParty().isLeader(player))
            {
                return "32496.htm";
            }
            return "32496-no.htm";
        }
        return "";
    }
    
    @Override
    public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
    {
        final InstanceWorld tmpWorld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
        if (tmpWorld instanceof BloodWorld)
        {
            final BloodWorld world = (BloodWorld) tmpWorld;
            final int objectId = npc.getObjectId();
            
            // first room was spawned ?
            if (world.firstRoom != null)
            {
                // is shaman killed ?
                if ((world.shaman != 0) && (world.shaman == objectId))
                {
                    world.shaman = 0;
                    // stop respawn of the minions
                    for (L2Spawn spawn : world.firstRoom)
                    {
                        if (spawn != null)
                        {
                            spawn.stopRespawn();
                        }
                    }
                    world.firstRoom.clear();
                    world.firstRoom = null;
                    
                    if (world.boss != null)
                    {
                        final int skillId = FIRST_ROOM[world.index][2];
                        final int skillLvl = FIRST_ROOM[world.index][3];
                        if ((skillId != 0) && (skillLvl != 0))
                        {
                            final L2Skill skill = SkillData.getInstance().getInfo(skillId, skillLvl);
                            if (skill != null)
                            {
                                skill.getEffects(world.boss, world.boss);
                            }
                        }
                    }
                    
                    return super.onKill(npc, player, isSummon);
                }
            }
            
            // second room was spawned ?
            if (world.secondRoom != null)
            {
                boolean all = true;
                // check for all mobs in the second room
                for (int i = 0; i < world.secondRoom.size(); i++)
                {
                    // found killed now mob
                    if (world.secondRoom.get(i) == objectId)
                    {
                        world.secondRoom.set(i, 0);
                    }
                    else if (world.secondRoom.get(i) != 0)
                    {
                        all = false;
                    }
                }
                // all mobs killed ?
                if (all)
                {
                    world.secondRoom.clear();
                    world.secondRoom = null;
                    
                    if (world.boss != null)
                    {
                        final int skillId = SECOND_ROOM[world.index][1];
                        final int skillLvl = SECOND_ROOM[world.index][2];
                        if ((skillId != 0) && (skillLvl != 0))
                        {
                            final L2Skill skill = SkillData.getInstance().getInfo(skillId, skillLvl);
                            if (skill != null)
                            {
                                skill.getEffects(world.boss, world.boss);
                            }
                        }
                    }
                    
                    return super.onKill(npc, player, isSummon);
                }
            }
            
            // miniboss spawned ?
            if ((world.miniBoss != 0) && (world.miniBoss == objectId))
            {
                world.miniBoss = 0;
                
                if (world.boss != null)
                {
                    final int skillId = MINIBOSS[world.index][4];
                    final int skillLvl = MINIBOSS[world.index][5];
                    if ((skillId != 0) && (skillLvl != 0))
                    {
                        final L2Skill skill = SkillData.getInstance().getInfo(skillId, skillLvl);
                        if (skill != null)
                        {
                            skill.getEffects(world.boss, world.boss);
                            

                        }
                    }
                }
                
                return super.onKill(npc, player, isSummon);
            }
            
            // boss was killed, finish instance
            if ((world.boss != null) && (world.boss == npc))
            {
                world.boss = null;
                finishInstance(world);
            }
        }
        return super.onKill(npc, player, isSummon);
    }
    
    @Override
    public void onEnterInstance(L2PcInstance player, InstanceWorld world, boolean firstEntrance)
    {    
    if (firstEntrance)
        {
            world.addAllowed(player.getObjectId());
        }
    }
}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • 🔥 L2Gold.co x15 Interlude Server 2025 – Grand Opening! 🔥 Join us today and be part of the legendary L2Gold community! 🎉 Grand Opening: 14 March 2025 🎉 ⏰ Time: 21:00 GMT +2 🌍 Server Type: EURO PTS/L2OFF 🌟 Why Play on L2Gold.co? 🌟 ✅ No Wipes – Keep Your Progress Forever! Your characters and progress are permanent. No resets! ✅ Balanced & Fun Gameplay! Experience x15 rates for a smooth and enjoyable progression. ✅ Solo or Party Play Use MP potions and NPC buffers for a great solo experience or team up with friends. ✅ Long-Term Stability Our server is built to last with no interruptions! 📊 Server Rates & Details 📊 Category Rate EXP/SP x15 (Official rate without rune or VIP) Adena x10 (Official rate without rune or VIP) Drop x10 (Official rate without rune or VIP) Spoil x10 (Official rate without rune or VIP) Raid Boss Drop x10 (Official rate without rune or VIP) 🚀 Exciting New Features! 🚀 🎟️ 💰 Weekly Lottery System! – Win rare items, in-game currency, and exclusive rewards! 🎁 More Events & Rewards! – Special in-game activities with exclusive items! 📈 Real-Time Stats! – Track your progress, achievements, and rankings live! ⚔️ New Items Weekly! – Discover rare gear and unique items every week! 🌍 A Growing Global Community 🌍 Players from Greece 🇬🇷, Brazil 🇧🇷, Spain 🇪🇸, and beyond! 🔗 Stay Connected 🔗 Follow us on social media to stay updated! 🌎 Website: L2Gold.co 🎙️ Discord: Server 📘 Facebook: Page | Group 🎥 YouTube:   Watch Videos 🎵 TikTok: Follow Us 🔥 Prepare for Battle! 🔥 📅 The adventure begins on 14 March 2025! Join L2Gold.co and Experience an Unforgettable Adventure! 🎮✨
    • y girate unos archivitos del powerclass dale..... sin encrypt
    • Hi, im looking for cardinal pvp script for auto cleanse/rez/nobles etc etc and guide on how to setup as well as what programms do i need to run such scripts as i have never used any helper or something before,
    • [Release] Solo PvP Zone System 🔹 Compatible with: aCis 401+ 📜 Features: ✅ Automatic Exit on Restart: Players are removed from the zone if a restart occurs or logout. ✅ Custom Exit Command: Players can exit the Solo Zone with the voice command .exit. ✅ Teleport NPC Command: new bypass solopvp for gatekeeper. ✅ Random Name Generator: Generates random names. ✅ PvP Flag: The players are flagged within this zone.   xml preview & java code backup code -> https://pastebin.com/974V2p2p   SoloZone.xml <?xml version="1.0" encoding="UTF-8"?> <list> <zone shape="NPoly" minZ="-5200" maxZ="-4680"><!-- Frintezza Solo Zone --> <stat name="name" val="Solo PvP Zone" /> <stat name="locs" val="174244,-89089,-5112;174260,-86881,-5112;173184,-88090,-5112;175309,-88018,-5112;174231,-88019,-5112;175136,-88828,-5104;174962,-87025,-5104;173149,-87142,-5104;173470,-88908,-5112" /> <stat name="restrictedClasses" val="15,16,97" /> <node x="172031" y="-90127"/> <node x="176428" y="-90089"/> <node x="176428" y="-74051"/> <node x="172057" y="-74108"/> </zone> </list> SoloZone Code: diff --git a/java/net/sf/l2j/gameserver/taskmanager/SoloZoneTaskManager.java b/java/net/sf/l2j/gameserver/taskmanager/SoloZoneTaskManager.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/taskmanager/SoloZoneTaskManager.java @@ -0,0 +1,98 @@ +package net.sf.l2j.gameserver.taskmanager; + +import java.security.SecureRandom; +import java.util.ArrayList; +import java.util.logging.Logger; + +import net.sf.l2j.commons.random.Rnd; + +import net.sf.l2j.gameserver.data.manager.ZoneManager; +import net.sf.l2j.gameserver.enums.ZoneId; +import net.sf.l2j.gameserver.handler.voicecommandhandlers.VoiceExitSoloZone; +import net.sf.l2j.gameserver.model.World; +import net.sf.l2j.gameserver.model.actor.Player; +import net.sf.l2j.gameserver.model.location.Location; +import net.sf.l2j.gameserver.model.zone.type.SoloZone; + + +/** + * @author MarGaZeaS + */ +public class SoloZoneTaskManager implements Runnable { + + private static final Location EXIT_LOCATION = VoiceExitSoloZone.getExitLocation(); // Λαμβάνουμε την έξοδο από το VoiceExitSoloZone + + @Override + public void run() + { + // Διασχίζουμε όλους τους παίκτες του κόσμου + for (Player player : World.getInstance().getPlayers()) + { + // Ελέγχουμε αν ο παίκτης είναι στο SoloZone + if (player.isInsideZone(ZoneId.SOLO)) + { + // Μεταφέρουμε τον παίκτη στην έξοδο + player.teleportTo(EXIT_LOCATION.getX(), EXIT_LOCATION.getY(), EXIT_LOCATION.getZ(), 0); + player.sendMessage("The server is restarting, you have been moved out of the Solo Zone."); + } + } + } + + private int _id; + + private static final Logger _log = Logger.getLogger(SoloZoneTaskManager.class.getName()); + private static final ArrayList<String> _rndNames = new ArrayList<>(); + private static final int RANDOM_NAMES = 500; + private static final String CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + private int _playersInSoloZone = 0; + + public int getPlayersInside() { + return _playersInSoloZone; + } + + public void setPlayersInside(int val) { + _playersInSoloZone = val; + } + + public SoloZoneTaskManager() { + _log.info("Solo Zone System: Loading..."); + for (int i = 0; i < RANDOM_NAMES; i++) { + String name = generateName(); + _rndNames.add(name); + _log.info("Generated name: " + name); + } + _log.info("Solo Zone System: Loaded " + _rndNames.size() + " names."); + } + + public String getAName() { + if (_rndNames.isEmpty()) { + _log.warning("SoloZoneManager: No random names available."); + return "Unknown"; + } + return _rndNames.get(Rnd.get(5, RANDOM_NAMES - 5)); + } + + private static String generateName() { + SecureRandom rnd = new SecureRandom(); + StringBuilder sb = new StringBuilder(15); + for (int i = 0; i < 15; i++) { + sb.append(CHARS.charAt(rnd.nextInt(CHARS.length()))); + } + return sb.toString(); + } + + public int getZoneId() + { + return _id; + } + + public final static SoloZone getCurrentZone() { + return ZoneManager.getInstance().getAllZones(SoloZone.class) + .stream() + .findFirst() // Επιστρέφει την πρώτη SoloZone (αν υπάρχει μόνο μία) + .orElse(null); + } + + public static SoloZoneTaskManager getInstance() { + return SingletonHolder._instance; + } + + private static class SingletonHolder { + private static final SoloZoneTaskManager _instance = new SoloZoneTaskManager(); + } +} diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/taskmanager/PvpFlagTaskManager.java b/aCis_gameserver/java/net/sf/l2j/gameserver/taskmanager/PvpFlagTaskManager.java index a707ce5..d247e2e 100644 --- a/aCis_gameserver/java/net/sf/l2j/gameserver/taskmanager/PvpFlagTaskManager.java final Player player = entry.getKey(); final long timeLeft = entry.getValue(); + if(player.isInsideZone(ZoneId.SOLO)) + continue; if(player.isInsideZone(ZoneId.BOSS)) continue; // Time is running out, clear PvP flag and remove from list. if (currentTime > timeLeft) diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/RequestCharacterCreate.java b/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/RequestCharacterCreate.java index a707ce5..d247e2e 100644 +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/RequestCharacterCreate.java if (Config.ALLOW_FISH_CHAMPIONSHIP) FishingChampionshipManager.getInstance(); + if (Config.ENABLE_STARTUP) + StartupManager.getInstance(); diff --git a/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminMaintenance.java b/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminMaintenance.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminMaintenance.java if (!st.hasMoreTokens()) { sendHtmlForm(player); return; } try { switch (st.nextToken()) { case "shutdown": + SoloZoneTaskManager exitTask = new SoloZoneTaskManager(); + ThreadPool.schedule(exitTask, 0); Shutdown.getInstance().startShutdown(player, null, Integer.parseInt(st.nextToken()), false); break; case "restart": + exitTask = new SoloZoneTaskManager(); + ThreadPool.schedule(exitTask, 0); Shutdown.getInstance().startShutdown(player, null, Integer.parseInt(st.nextToken()), true); break; case "abort": Shutdown.getInstance().abort(player); break; diff --git a/java/net/sf/l2j/gameserver/handler/voicecommandhandlers/VoiceExitSoloZone.java b/java/net/sf/l2j/gameserver/handler/voicecommandhandlers/VoiceExitSoloZone.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/handler/voicecommandhandlers/VoiceExitSoloZone.java +package net.sf.l2j.gameserver.handler.voicecommandhandlers; + +import net.sf.l2j.commons.pool.ThreadPool; + +import net.sf.l2j.gameserver.enums.ZoneId; +import net.sf.l2j.gameserver.handler.IVoiceCommandHandler; +import net.sf.l2j.gameserver.model.actor.Player; +import net.sf.l2j.gameserver.model.location.Location; +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse; + +/** + * Handles the voice command for exiting the Solo Zone with delay and effects. + * + * @author MarGaZeaS + */ +public class VoiceExitSoloZone implements IVoiceCommandHandler +{ + private static final String[] VOICE_COMMANDS = + { + "exit" + }; + + // Default location to teleport players when exiting the Solo Zone + private static final Location EXIT_LOCATION = new Location(81318, 148064, -3464); // Replace with your desired coordinates + + // Προσθήκη της μεθόδου για να πάρουμε την τοποθεσία εξόδου + public static Location getExitLocation() { + return EXIT_LOCATION; + } + + @Override + public void useVoiceCommand(Player player, String command) + { + if (command.equalsIgnoreCase("exit")) + { + if (!player.isInsideZone(ZoneId.SOLO)) + { + player.sendMessage("You are not inside the Solo Zone."); + return; + } + + // Notify the player about the delay + player.sendMessage("You will be teleported out of the Solo Zone in 2 seconds."); + + // Cast skill effect (Skill ID: 2100, Level: 1) + player.broadcastPacket(new MagicSkillUse(player, player, 2100, 1, 2000, 0)); + + // Schedule the teleportation after a 2-second delay + ThreadPool.schedule(() -> { + // Teleport the player to the designated exit location + player.teleportTo(EXIT_LOCATION.getX(), EXIT_LOCATION.getY(), EXIT_LOCATION.getZ(), 0); + + // Inform the player + player.sendMessage("You have exited the Solo Zone."); + }, 2000); // Delay in milliseconds (2000ms = 2 seconds) + } + } + + @Override + public String[] getVoiceCommandList() + { + return VOICE_COMMANDS; + } +} diff --git a/java/net/sf/l2j/gameserver/handler/VoiceCommandHandler.java b/java/net/sf/l2j/gameserver/handler/VoiceCommandHandler.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/handler/VoiceCommandHandler.java public class VoiceCommandHandler { private final Map<String, IVoiceCommandHandler> _entries = new HashMap<>(); protected VoiceCommandHandler() { ............ ............ + registerHandler(new VoiceExitSoloZone()); } public void registerHandler(IVoiceCommandHandler handler) { for (String command : handler.getVoiceCommandList()) _entries.put(command, handler); } diff --git a/java/net/sf/l2j/gameserver/model/actor/Npc.java b/java/net/sf/l2j/gameserver/model/actor/Npc.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/model/actor/Npc.java else if (command.startsWith("Chat")) { int val = 0; try { val = Integer.parseInt(command.substring(5)); } catch (final IndexOutOfBoundsException ioobe) { } catch (final NumberFormatException nfe) { } showChatWindow(player, val); + ) + else if (command.startsWith("solopvp")) + { + SoloZoneTaskManager.getInstance(); + player.teleportTo(SoloZoneTaskManager.getCurrentZone().getLoc(), 25); + } else if (command.startsWith("Link")) { final String path = command.substring(5).trim(); if (path.indexOf("..") != -1) return; final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId()); html.setFile("data/html/" + path); html.replace("%objectId%", getObjectId()); player.sendPacket(html); } diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java // Fixed. - else if (_requestType == 4) - { - if (!player.isGM() && !player.isFestivalParticipant()) - return; - - loc = player.getPosition(); - } + if (_requestType == 4) + { + // Έλεγχος αν ο παίκτης δεν είναι GM, δεν είναι μέρος του φεστιβάλ και δεν είναι στην Solo Zone + if (!player.isGM() && !player.isFestivalParticipant() && !player.isInsideZone(ZoneId.SOLO)) + { + return; + } + + SoloZoneTaskManager.getInstance(); + SoloZone currentZone = SoloZoneTaskManager.getCurrentZone(); + if (currentZone != null && currentZone.getLoc() != null) + { + // Αν υπάρχει ζώνη και οι τοποθεσίες δεν είναι κενές, χρησιμοποιούμε τυχαία τοποθεσία από την ζώνη + loc = currentZone.getLoc(); + } else + { + // Διαφορετικά, κάνουμε respawn στην τρέχουσα θέση του παίκτη + loc = player.getPosition(); + } + } diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java if (player.isFestivalParticipant() && FestivalOfDarknessManager.getInstance().isFestivalInitialized()) { player.sendPacket(SystemMessageId.NO_RESTART_HERE); sendPacket(RestartResponse.valueOf(false)); return; } + if (player.isInsideZone(ZoneId.SOLO)) + { + player.sendMessage("You cannot restart your character while in Solo Zone. Use .exit to leave"); + player.setFakeName(null); + sendPacket(RestartResponse.valueOf(false)); + return; + } player.removeFromBossZone(); diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java b/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java player.removeFromBossZone(); player.logout(true); } } + + if (player.isInsideZone(ZoneId.SOLO)) + { + player.sendMessage("You cannot logout or restart your character while in Solo Zone. Use .exit to leave"); + player.setFakeName(null); + player.sendPacket(ActionFailed.STATIC_PACKET); + return; + } + player.removeFromBossZone(); player.logout(true); } } diff --git a/java/net/sf/l2j/gameserver/model/zone/type/SoloZone.java b/java/net/sf/l2j/gameserver/model/zone/type/SoloZone.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/model/zone/type/SoloZone.java +package net.sf.l2j.gameserver.model.zone.type; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.sf.l2j.commons.random.Rnd; + +import net.sf.l2j.Config; +import net.sf.l2j.gameserver.enums.MessageType; +import net.sf.l2j.gameserver.enums.ZoneId; +import net.sf.l2j.gameserver.handler.voicecommandhandlers.VoiceExitSoloZone; +import net.sf.l2j.gameserver.model.World; +import net.sf.l2j.gameserver.model.actor.Creature; +import net.sf.l2j.gameserver.model.actor.Player; +import net.sf.l2j.gameserver.model.location.Location; +import net.sf.l2j.gameserver.model.zone.type.subtype.ZoneType; +import net.sf.l2j.gameserver.network.SystemMessageId; +import net.sf.l2j.gameserver.network.serverpackets.EtcStatusUpdate; +import net.sf.l2j.gameserver.taskmanager.PvpFlagTaskManager; +import net.sf.l2j.gameserver.taskmanager.SoloZoneTaskManager; + +/** + * @author MarGaZeaS + * + */ +public class SoloZone extends ZoneType +{ + private String _name; + private List<Location> _locations = new ArrayList<>(); + + public SoloZone(int id) + { + super(id); + } + + @Override + public void setParameter(String name, String value) + { + if (name.equals("name")) + _name = value; + else if (name.equals("locs")) + { + for (String locs : value.split(";")) + { + String[] coordinates = locs.split(","); + if (coordinates.length == 3) + { + int x = Integer.parseInt(coordinates[0]); + int y = Integer.parseInt(coordinates[1]); + int z = Integer.parseInt(coordinates[2]); + _locations.add(new Location(x, y, z)); + } + else + { + LOGGER.warn("Invalid location format: " + locs); + } + } + } + } + + + @Override + protected void onEnter(Creature character) + { + if (character instanceof Player) + { + final Player player = (Player) character; + + if ((player.getClassId().getId() == 15 || player.getClassId().getId() == 16 || player.getClassId().getId() == 97)) + { + Location respawnLocation = VoiceExitSoloZone.getExitLocation(); + player.instantTeleportTo(respawnLocation, 20); + player.sendMessage("Your class is not allowed in this zone."); + return; + } + + String randomName = SoloZoneTaskManager.getInstance().getAName(); + if (randomName == null || randomName.isEmpty() || !isValidName(randomName)) + { + randomName = generateRandomName(); + } + if (isNameAlreadyTaken(randomName)) + { + randomName = generateRandomName(); + } + player.setFakeName(randomName); + player.sendMessage("Welcome to the Solo Zone, your random name is: " + randomName); + player.sendPacket(SystemMessageId.ENTERED_COMBAT_ZONE); + character.setInsideZone(ZoneId.SOLO, true); + character.setInsideZone(ZoneId.NO_STORE, true); + character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, true); + + if (player.getParty() != null) + { + player.getParty().removePartyMember(player, MessageType.DISCONNECTED); + } + + if (player.getPvpFlag() > 0) + PvpFlagTaskManager.getInstance().remove(player, true); + + player.updatePvPStatus(); + player.broadcastUserInfo(); + } + } + + private static boolean isValidName(String name) { + return name.matches("[a-zA-Z0-9_]+"); + } + + private static String generateRandomName() { + Random rand = new Random(); + int nameLength = rand.nextInt(12) + 4; + StringBuilder nameBuilder = new StringBuilder(); + + for (int i = 0; i < nameLength; i++) { + char randomChar = (char) (rand.nextInt(26) + 'a'); + nameBuilder.append(randomChar); + } + + return nameBuilder.toString(); + } + + private static boolean isNameAlreadyTaken(String name) { + return World.getInstance().getPlayers().stream().anyMatch(player -> player.getFakeName().equals(name)); + } + + @Override + protected void onExit(Creature character) + { + character.setInsideZone(ZoneId.SOLO, false); // Solo zone + character.setInsideZone(ZoneId.NO_STORE, false); // Allow making a store + character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, false); // Allow summon + + if (character instanceof Player) + { + final Player player = (Player) character; + + if (player.getFakeName() != null) + { + player.setFakeName(null); + } + + player.sendPacket(SystemMessageId.LEFT_COMBAT_ZONE); + { + if(!player.isInObserverMode() && player.getPvpFlag() > 0) + PvpFlagTaskManager.getInstance().add(player, Config.PVP_NORMAL_TIME); + + player.sendPacket(new EtcStatusUpdate(player)); + player.broadcastUserInfo(); + } + } + } + + public String getName() + { + return _name; + } + + public Location getLoc() + { + if (_locations.isEmpty()) + { + return null; // Αν η λίστα είναι κενή, επιστρέφουμε null + } + return _locations.get(Rnd.get(0, _locations.size() - 1)); // Επιλέγουμε τυχαία τοποθεσία + } +} diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/GameServer.java if (Config.ALLOW_FISH_CHAMPIONSHIP) FishingChampionshipManager.getInstance(); + StringUtil.printSection("Custom Features"); + SoloZoneTaskManager.getInstance(); StringUtil.printSection("Handlers"); LOGGER.info("Loaded {} admin command handlers.", AdminCommandHandler.getInstance().size()); diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/Shutdown.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/Shutdown.java // disconnect players try { disconnectAllPlayers(); LOGGER.info("All players have been disconnected."); } catch (Exception e) { // Silent catch. } + // Restore real names for players in SoloZone + restoreRealNamesInSoloZone(); // stop all threadpolls ThreadPool.shutdown(); try { LoginServerThread.getInstance().interrupt(); } catch (Exception e) { // Silent catch. } // avoids new players from logging in if (_secondsShut <= 60 && LoginServerThread.getInstance().getServerType() != ServerType.DOWN) LoginServerThread.getInstance().setServerType(ServerType.DOWN); _secondsShut--; Thread.sleep(1000); } } catch (InterruptedException e) { } } + // This method restores the real names of players in SoloZone + private static void restoreRealNamesInSoloZone() + { + for (Player player : World.getInstance().getPlayers()) + { + // Check if player is inside the SoloZone + if (player.isInsideZone(ZoneId.SOLO)) + { + // Restore the real name by removing the fake name + if (player.getFakeName() != null) + { + player.setFakeName(null); // Restore the real name + LOGGER.info("Player {}'s fake name has been removed and real name restored.", player.getName()); + } + } + } + } private static void sendServerQuit(int seconds) { World.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.THE_SERVER_WILL_BE_COMING_DOWN_IN_S1_SECONDS).addNumber(seconds)); } diff --git a/java/net/sf/l2j/gameserver/enums/ZoneId.java b/java/net/sf/l2j/gameserver/enums/ZoneId.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/enums/ZoneId.java public enum ZoneId { PVP(0), PEACE(1), SIEGE(2), MOTHER_TREE(3), CLAN_HALL(4), NO_LANDING(5), WATER(6), JAIL(7), MONSTER_TRACK(8), CASTLE(9), SWAMP(10), NO_SUMMON_FRIEND(11), NO_STORE(12), TOWN(13), HQ(14), DANGER_AREA(15), CAST_ON_ARTIFACT(16), NO_RESTART(17), SCRIPT(18), - BOSS(19), + BOSS(19), + SOLO(20); private final int _id; private ZoneId(int id) { _id = id; } diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/Die.java b/java/net/sf/l2j/gameserver/network/serverpackets/Die.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/network/serverpackets/Die.java if (creature instanceof Player) { Player player = (Player) creature; - _allowFixedRes = player.getAccessLevel().allowFixedRes(); + _allowFixedRes = player.getAccessLevel().allowFixedRes() || player.isInsideZone(ZoneId.SOLO); _clan = player.getClan(); } diff --git a/java/net/sf/l2j/gameserver/model/actor/Player.java b/java/net/sf/l2j/gameserver//model/actor/Player.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java // Attacker or spectator logging into a siege zone will be ported at town. if (player.isInsideZone(ZoneId.SIEGE) && player.getSiegeState() < 2) player.teleportTo(TeleportType.TOWN); + if (player.isInsideZone(ZoneId.SOLO)) + { + ThreadPool.schedule(() -> { + Location exitLocation = VoiceExitSoloZone.getExitLocation(); + + if (exitLocation != null) + { + player.teleportTo(exitLocation.getX(), exitLocation.getY(), exitLocation.getZ(), 0); + player.sendMessage("You have been moved to the exit of the SoloZone."); + } + }, 5000); // 5000 milliseconds (5sec) + } diff --git a/java/net/sf/l2j/gameserver/model/actor/Player.java b/java/net/sf/l2j/gameserver/model/actor/Player.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/model/actor/Player.java @Override public void doRevive() { super.doRevive(); stopEffects(EffectType.CHARM_OF_COURAGE); sendPacket(new EtcStatusUpdate(this)); getStatus().setCpHpMp(getStatus().getMaxCp(), getStatus().getMaxHp(), getStatus().getMaxMp()); _reviveRequested = 0; _revivePower = 0; if (isMounted()) startFeed(_mountNpcId); + if (isInsideZone(ZoneId.SOLO)) + { + // Give Nobless (1323 ID) + L2Skill no = SkillTable.getInstance().getInfo(1323, 1); + no.getEffects(this, this); + sendMessage("You have received the Nobless status in the Solo Zone."); + } + }   If anyone thinks the code is wrong, please make an update and upload it here so I can update the post. A part was edited with chatgpt
    • Always remember, when you buy files, just compare with my files that I publish for free. and you will know that you are being ripped off. Greetings to all community!!! 🙂
  • Topics

×
×
  • Create New...