Jump to content
  • 0

Freya minimum and maximum players allowed


Question

Posted

Hello good as I might like to add conditional IceQueenCastle.java the instance to put a maximum to a minimum of people who can enter the instance freya and not have to be alone in a party.

 

 

 

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

import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.instancemanager.InstanceManager.InstanceWorld;
import com.l2jserver.gameserver.model.L2CharPosition;
import com.l2jserver.gameserver.model.skills.L2Skill;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Instance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.clientpackets.Say2;
import com.l2jserver.gameserver.network.serverpackets.NpcSay;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;

import java.util.Arrays;

/**
** @author GKR
**
** 2011-03-24
*/

public class IceQueenCastle1 extends Quest
{
    private class IQWorld extends InstanceWorld
    {
        public long[] storeTime = {0,0};
        public boolean showIsInProgress = false; 
        public IQWorld()
        {
            
        }
    }
    
    private static final String qn = "IceQueenCastle1";
    private static final int INSTANCEID = 137;
    
    //NPC's, mobs
    private static final int JINIA2 = 32781;
    private static final int FREYA = 18847;
    private static final int[] CROWD = { 18848, 18849, 18926, 22767};
    
    //Freya Skills
    //private static final L2Skill _attackSkill = SkillTable.getInstance().getInfo(6278, 1);
    private static final L2Skill _showBlizzard = SkillTable.getInstance().getInfo(6276, 1);
    
    private static final int[] ENTRY_POINT = { 114000, -112357, -11200 };
    private int[] RETURN_POINT = { 113883, -108777, -848 };
    
    private class teleCoord {/**
         * 
         */
        public teleCoord()
        {
            // TODO Auto-generated constructor stub
        }

    int instanceId; int x; int y; int z;}
    
    private void teleportplayer(L2PcInstance player, teleCoord teleto)
    {
        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
        player.setInstanceId(teleto.instanceId);
        player.teleToLocation(teleto.x, teleto.y, teleto.z);
        return;
    }
    
    private boolean checkConditions(L2PcInstance player)
    {
        if (player.getLevel() < 82 || player.getLevel() > 85)
        {
            SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
            sm.addPcName(player);
            player.sendPacket(sm);
            return false;
        }
        
        return true; 
    }

    protected void exitInstance(L2PcInstance player, teleCoord tele)
    {
        player.setInstanceId(0);
        player.teleToLocation(tele.x, tele.y, tele.z);
    }
     
    protected int enterInstance(L2PcInstance player, String template, teleCoord teleto)
    {
        int instanceId = 0;
        InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
        //existing instance
        if (world != null)
        {
            //this instance
            if (!(world instanceof IQWorld))
            {
                player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER));
                return 0;
            }
            teleto.instanceId = world.instanceId;
            teleportplayer(player,teleto);
            return instanceId;
        }
        //New instance
        if (!checkConditions(player))
            return 0;

        instanceId = InstanceManager.getInstance().createDynamicInstance(template);
        world = new IQWorld();
        world.instanceId = instanceId;
        world.templateId = INSTANCEID;
        world.status = 0;
        ((IQWorld)world).storeTime[0] = System.currentTimeMillis();
        InstanceManager.getInstance().addWorld(world);
        _log.info("IQWorld started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
        teleto.instanceId = instanceId;
        teleportplayer(player,teleto);
        world.allowed.add(player.getObjectId());

        //Open door
        L2DoorInstance door = InstanceManager.getInstance().getInstance(instanceId).getDoor(23140101);
        if (door != null)
            door.openMe();          

        return instanceId;
    }

  @Override
    public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
    {
        InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
        if (tmpworld != null && tmpworld instanceof IQWorld && tmpworld.templateId == 137)
        {
            IQWorld world = (IQWorld) tmpworld;
            L2PcInstance pl = L2World.getInstance().getPlayer(world.allowed.get(0));

            if (npc.getNpcId() == FREYA)
            {
                if (event.equalsIgnoreCase("moving"))
                {
                    npc.setIsNoRndWalk(false);
                    npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(114730, -114805, -11200, 0));
                    return null;
                }
        
                else if (event.equalsIgnoreCase("blizzard"))
                {
                    //NpcSay cs = new NpcSay(npc.getObjectId(), Say2.ALL, npc.getNpcId(), 1801125);
                    NpcSay cs = new NpcSay(npc.getObjectId(), Say2.ALL, npc.getNpcId(), "I can no longer stand by.");
                    npc.broadcastPacket(cs);
                    npc.stopMove(null);
                    npc.setIsImmobilized(true);
                    npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
                    npc.setIsInvul(true);
                    npc.setTarget(npc);
                    if (_showBlizzard != null)
                        npc.doCast(_showBlizzard);
                    return null;
                }

                else if (event.equalsIgnoreCase("movie") && pl != null)
                {
                    pl.showQuestMovie(21);
                    npc.deleteMe();
                    startQuestTimer("movie_end", 24000, npc, null);
                }

                else if (event.equalsIgnoreCase("movie_end") && pl != null)
                {
                    QuestState hostQuest = pl.getQuestState("10285_MeetingSirra");

                    if (hostQuest != null && hostQuest.getState() == State.STARTED && hostQuest.getInt("progress") == 2)
                    {
                        hostQuest.set("cond", "10");
                        hostQuest.playSound("ItemSound.quest_middle");
                        hostQuest.set("progress", "3");
                    }
                
                    //Leave instance
                    world.allowed.remove(world.allowed.indexOf(pl.getObjectId()));
                    teleCoord tele = new teleCoord();
                    tele.instanceId = 0;
                    tele.x = RETURN_POINT[0];    
                    tele.y = RETURN_POINT[1];
                    tele.z = RETURN_POINT[2];
                    exitInstance(pl,tele);

                    // destroy instance after 1 min
                    Instance inst = InstanceManager.getInstance().getInstance(npc.getInstanceId());
                    inst.setDuration(60000);
                    inst.setEmptyDestroyTime(0);
                }
            }
            
            else if (!world.showIsInProgress && event.equalsIgnoreCase("immobilize") && Arrays.binarySearch(CROWD, npc.getNpcId()) >= 0)
                npc.setIsImmobilized(true);
        }

        return null;
    }
            
  @Override
public String onTalk ( L2Npc npc, L2PcInstance player)
    {
        int npcId = npc.getNpcId();
        QuestState st = player.getQuestState(qn);
        if (st == null)
            st = newQuestState(player);

        if (npcId == JINIA2)
        {
            teleCoord tele = new teleCoord();
            tele.x = ENTRY_POINT[0];      
            tele.y = ENTRY_POINT[1];
            tele.z = ENTRY_POINT[2];

            QuestState hostQuest = player.getQuestState("10285_MeetingSirra");

            if (hostQuest != null && hostQuest.getState() == State.STARTED && hostQuest.getInt("progress") == 2)
            {
                hostQuest.set("cond", "9");
                hostQuest.playSound("ItemSound.quest_middle");
            }

            if (enterInstance(player, "IceQueenCastle1.xml", tele) <= 0)
                return "32781-10.htm";
        }
        
        return "";
    }

    @Override
    public String onEnterZone(L2Character character, L2ZoneType zone)
    {
        InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
        if (tmpworld != null && tmpworld instanceof IQWorld && tmpworld.templateId == 137)
        {
            IQWorld world = (IQWorld) tmpworld;
            if (!world.showIsInProgress && character instanceof L2PcInstance) //triggers show begin
            {
                addSpawn(FREYA, 114720,-117085,-11088,15956, false, 0, false, character.getInstanceId());
                Instance inst = InstanceManager.getInstance().getInstance(character.getInstanceId());
                for (L2Npc npc : inst.getNpcs())
                {
                    if (Arrays.binarySearch(CROWD, npc.getNpcId()) >= 0)
                    {
                        npc.setIsImmobilized(false); //Fight!!!
                    }
                }
                world.showIsInProgress = true;
            }
        }
        
        return null;
    }

  @Override
    public final String onSpawn(L2Npc npc)
    {
        if (npc.getNpcId() == FREYA)
        {
            startQuestTimer("moving", 60000, npc, null);
            startQuestTimer("blizzard", 180000, npc, null);
            npc.setIsNoRndWalk(true);
        }
        
        //Immobilize mobs until trigger will not switched on
        //else if (!world.showIsInProgress && Arrays.binarySearch(CROWD, npc.getNpcId()) >= 0)
        else if (Arrays.binarySearch(CROWD, npc.getNpcId()) >= 0)
            startQuestTimer("immobilize", 1000, npc, null);

        
        return null;
    }

    @Override
    public String onSpellFinished(L2Npc npc, L2PcInstance player, L2Skill skill)
    {
        if (skill == _showBlizzard)
            startQuestTimer("movie", 1000, npc, null);

        return null;
    }

  public IceQueenCastle1(int questId, String name, String descr)
    {
        super(questId, name, descr);

        addStartNpc(JINIA2);
        addTalkId(JINIA2);
        addEnterZoneId(200010);
        addSpawnId(FREYA);
        for (int i = 0; i < CROWD.length; i++)
            addSpawnId(CROWD[i]);
        addSpellFinishedId(FREYA);
    }
    
    public static void main(String[] args)
    {
        new IceQueenCastle1(-1,qn,"instances");
    }
}

4 answers to this question

Recommended Posts

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
Answer this question...

×   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

    • most eggciting post in 2025 for sure!!!!
    • https://github.com/JulioPradoL2j/L2JDreamV2/commit/8f788b03c40404b72d7a321ef24e113f91a619ac     Descrição Este é um sistema de Reset de Personagem Personalizado criado para servidores L2J, inspirado em mecânicas clássicas de MMORPGs com foco em progressão PvP. Totalmente configurável via XML, este sistema permite criar um ciclo de evolução contínuo, recompensando jogadores que atingem o ápice com benefícios e novas metas.  Principais Funcionalidades Reset ativado ao atingir nível máximo, com requisitos de: Itens específicos Quantidade mínima de PvP Custo em moedas/itens Configuração via arquivo XML: Recompensas personalizáveis (itens, moedas, skills, etc) Redução de EXP ou retorno ao nível inicial Condições específicas para liberar o reset Sistema de Ranking: Rankings de Reset Diário e Mensal Premiação automática para os Top players Rankings reiniciam automaticamente no final do período Suporte a jogadores offline: Reset pode remover skills e aplicar recompensas direto no banco de dados Requisitos Técnicos Baseado em L2J DreamV2 / aCis 409 Compatível com bancos de dados MySQL Leitura de configuração via XML (resetData.xml)    Explicação das Configurações  Requisitos levelMax="80" → o jogador precisa atingir o nível 80. requiredPvps="0" → não exige PvP para resetar. expPenalty="0.8" → perde 20% da EXP total ao resetar. <item required="57-10000000;" /> → exige 10kk Adena.  Recompensas Recompensa fixa por reset: 57-15000 → 15k Adena 6392-3 → 3 unidades de item com ID 6392 Recompensa por skill (exemplo): 3135-4 (até nível 4) 3130-2 (até nível 2) 3131-10 (até nível 10)    Comandos para Administradores (Admin Commands) O sistema conta com comandos dedicados para encerrar manualmente os rankings de reset (diário ou mensal), forçando a distribuição imediata dos prêmios para os jogadores que se destacaram.  Comandos Disponíveis Comando Descrição //reset_end_daily Finaliza manualmente o ranking diário e distribui os prêmios configurados. //reset_end_monthly Finaliza manualmente o ranking mensal e distribui os prêmios configurados.   <?xml version="1.0" encoding="UTF-8"?> <list> <reset levelMax="80" requiredPvps="0" expPenalty="0.8"> <set rankingDisplayLimit="3" /> <set dailyPoints="2" /> <set monthlyPoints="1" /> <set removeResetSkills="true" /> <set logger="false" /> <requiredItems> <item required="57-10000000;" /> </requiredItems> <rewardItems> <item reward="57-15000;6392-3" skill="3135-4;3130-2;3131-10" /> </rewardItems> <prizes enable="true" type="DAILY" time="13:00"> <prize position="1" reward="57-15000;6392-3" /> <prize position="2" reward="57-10000;6392-2" /> <prize position="3" reward="57-5000;6392-1" /> </prizes> <prizes enable="true" type="MONTH" time="00:00"> <prize position="1" reward="57-15000;6392-3" /> <prize position="2" reward="57-10000;6392-2" /> <prize position="3" reward="57-5000;6392-1" /> </prizes> </reset> </list>  
    • This topic reminds me a bit of the old glory days! 😂 
    • Funny part is, i wouldnt make the effort of downvoting you if you weren't constantly sniping my profile to downvote me, and then when i downvote back you cry about it LOL
  • 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