Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

Subir nivel al matar a un npc/mob

Iniciado por Swarlog, Ago 12, 2022, 01:18 AM

Tema anterior - Siguiente tema

Swarlog

En este codigo os muestro como hacer que al matar un mob/npc nos de el nivel que queramos. En este caso he puesto que nos de nivel 40, y ademas he especificado que si ya tienes nivel 40 no te da el nivel. Solo da nivel 40 a aquellos que tengan menos de dicho nivel.

private static final int NPC_MOB = 666777;
private static final int NIVEL = 40;

if (this.getId() == NPC_MOB)
{
if (killer.getLevel() < NIVEL)
{
byte lvl = killer.getStat().getLevel();
byte lvlup = (byte) (lvl + NIVEL);
killer.getStat().setLevel(lvlup);

killer.broadcastStatusUpdate();
killer.broadcastUserInfo();
killer.sendPacket(new UserInfo(killer));
killer.sendPacket(new ExBrExtraUserInfo(killer));
killer.giveAvailableAutoGetSkills();
killer.giveAvailableSkills(true, true);
killer.sendSkillList();

killer.sendMessage("Congratulations! You are now " + lvlup + " level.");
}
else
{
killer.sendMessage("You've reached level 40!");
}
}

lmitrion230

Debes de estar registrado para poder ver el contenido indicado. Registrate o ConectateEn este codigo os muestro como hacer que al matar un mob/npc nos de el nivel que queramos. En este caso he puesto que nos de nivel 40, y ademas he especificado que si ya tienes nivel 40 no te da el nivel. Solo da nivel 40 a aquellos que tengan menos de dicho nivel.

private static final int NPC_MOB = 666777;
private static final int NIVEL = 40;

        if (this.getId() == NPC_MOB)
        {
            if (killer.getLevel() < NIVEL)
            {
                byte lvl = killer.getStat().getLevel();
                byte lvlup = (byte) (lvl + NIVEL);
                killer.getStat().setLevel(lvlup);
               
                killer.broadcastStatusUpdate();
                killer.broadcastUserInfo();
                killer.sendPacket(new UserInfo(killer));
                killer.sendPacket(new ExBrExtraUserInfo(killer));
                killer.giveAvailableAutoGetSkills();
                killer.giveAvailableSkills(true, true);
                killer.sendSkillList();
               
                killer.sendMessage("Congratulations! You are now " + lvlup + " level.");
            }
            else
            {
                killer.sendMessage("You've reached level 40!");
            }
        }


Tengo una consulta, estos codigos donde van pegados? perdon por la ignorancia es que soy nuevo en esto, y quiero entender! .. gracias

Neron

Puedes crear una clase nueva y añadirlos.

Lo ideal seria añadir en la clase a todos los mobs.

* Recuerda luego cargar dicha clase en "Script", añadiendo la linea.

Swarlog

Aqui te dejo uno que acabo de hacer, adaptalo antes de compilar el servidor.

Posiblemente tengas que actualizar librerias y/o añadirlas; la clase esta creada desde el note :P

/*
 * Copyright © 2004-2022 L2JDevs_Private_Data
 *
 * 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 <https://www.gnu.org/licenses/>.
 */
package custom;

import org.l2jdevs.gameserver.model.actor.L2Npc;
import org.l2jdevs.gameserver.model.actor.instance.L2PcInstance;
import org.l2jdevs.gameserver.model.quest.Quest;
import org.l2jdevs.gameserver.model.quest.QuestState;

/**
 * U3Games - Test kill mob
 * @author swarlog
 */
public class U3Games extends Quest
{
private final int NPC_MOB = 666777;
private final int NIVEL = 40;

private u3games ()
{
super(-1, U3Games.class.getSimpleName(), "custom");

for (L2NpcTemplate template : NpcData.getInstance().getAllNpcOfClassType("L2Monster"))
{
if (template != null)
{
addKillId(template.getId());
}
}
}

@Override
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
{
if (npc.getId() == NPC_MOB)
        {
            if (killer.getLevel() < NIVEL)
            {
                byte lvl = killer.getStat().getLevel();
                byte lvlup = (byte) (lvl + NIVEL);
                killer.getStat().setLevel(lvlup);
               
                killer.broadcastStatusUpdate();
                killer.broadcastUserInfo();
                killer.sendPacket(new UserInfo(killer));
                killer.sendPacket(new ExBrExtraUserInfo(killer));
                killer.giveAvailableAutoGetSkills();
                killer.giveAvailableSkills(true, true);
                killer.sendSkillList();
               
                killer.sendMessage("Congratulations! You are now " + lvlup + " level.");
            }
            else
            {
                killer.sendMessage("You've reached level 40!");
            }
        }

return super.onKill(npc, killer, isSummon);
}

public static void main(String[] args)
{
new U3Games();
}
}

Como dijo Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate, recuerda agregar la línea de esa nueva clase en el archivo Script.