Autor Tema: [NPC] Simple Delevel Npc  (Leído 1122 veces)

Julio 21, 2015, 11:07:48 am

Desconectado Atinae

  • Vips
  • Usuario
  • *
  • Mensajes: 31
  • Karma: 0
  • Sexo: Femenino


Código: You are not allowed to view links. Register or Login
--- /dev/null
+++ b/L2J_DataPack/dist/game/data/scripts/custom/delevelnpc/delevelnpc.java
@@ -0,0 +1,101 @@
+/*
+ * 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 custom.delevelnpc;
+
+import ai.npc.AbstractNpcAI;
+
+import com.l2jserver.gameserver.datatables.ExperienceTable;
+import com.l2jserver.gameserver.model.actor.L2Npc;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author Eze
+ */
+public class delevelnpc extends AbstractNpcAI
+{
+ private final int npcId = 1000010;
+ private final int itemcantidad = 15;
+ private final int itemid = 6392;
+
+ public delevelnpc()
+ {
+ super(delevelnpc.class.getSimpleName(), "custom");
+
+ addStartNpc(npcId);
+ addFirstTalkId(npcId);
+ addTalkId(npcId);
+
+ }
+
+ @Override
+ public String onFirstTalk(L2Npc npc, L2PcInstance player)
+ {
+
+ return "main.htm";
+ }
+
+ @Override
+ public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
+ {
+ String htmlText = event;
+
+ if (event.equalsIgnoreCase("delevel"))
+ {
+ try
+ {
+ if (player.getLevel() <= 1)
+ {
+ return htmlText = "Eres lvl 1 no puedes bajar mas.";
+ }
+ if ((player.getLevel() <= 40) && player.isSubClassActive())
+ {
+ return htmlText = "Eres lvl 40 no puedes bajar mas estando en subclass.";
+ }
+ if (player.getInventory().getInventoryItemCount(itemid, -1) < itemcantidad)
+ {
+ player.sendMessage("Incorrect item count.");
+ return htmlText = null;
+ }
+
+ long expplayer = player.getExp();
+ long exp = ExperienceTable.getInstance().getExpForLevel(player.getLevel() - 1);
+
+ takeItems(player, itemid, itemcantidad);
+
+ player.removeExpAndSp(expplayer - exp, 0);
+
+ player.sendMessage(itemcantidad + " event medalls han sido eliminados");
+ player.sendMessage("Has bajado un level.");
+
+ htmlText = null;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ return htmlText;
+ }
+
+ public static void main(String[] args)
+ {
+ new delevelnpc();
+ }
+}
\ No newline at end of file
--------------------------------------------------------------------------------------------------------------------------------
--- /dev/null
+++ b/L2J_DataPack/dist/game/data/stats/npcs/custom/delevel.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/npcs.xsd">
+ <npc id="1000010" displayId="32107" name="Delevel" usingServerSideName="true" title="Npc" usingServerSideTitle="true" type="L2Npc">
+ <collision>
+ <radius normal="40" />
+ <height normal="80" />
+ </collision>
+ </npc>
+</list>
\ No newline at end of file
--------------------------------------------------------------------------------------------------------------------------------------
--- a/L2J_DataPack/dist/game/data/scripts.cfg
+++ b/L2J_DataPack/dist/game/data/scripts.cfg
@@ -323,3 +323,5 @@
 #events/FreyaCelebration/FreyaCelebration.java
 #events/MasterOfEnchanting/MasterOfEnchanting.java
 #events/LoveYourGatekeeper/LoveYourGatekeeper.java
+
+custom/delevelnpc/delevelnpc.java
\ No newline at end of file
-------------------------------------------------------------------------------------------------------------------------------------
--- /dev/null
+++ b/L2J_DataPack/dist/game/data/scripts/custom/delevelnpc/main.htm
@@ -0,0 +1,11 @@
+<html>
+ <head>
+ <title>Delevel</title>
+ </head>
+ <body>
+ <center>
+ Hola aventurero. Quieres bajar un level?<br> Tu experiencia volvera a 0.<br> Te costara 15 event-medalls. <br>
+ <button action="bypass -h Quest delevelnpc delevel" value="Bajar 1 level" width=200 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF" />
+ </center>
+ </body>
+</html>
\ No newline at end of file

Creditos: execanciani

Marzo 30, 2018, 06:56:56 am
Respuesta #1

Desconectado tomalko

  • Usuario
  • *
  • Mensajes: 4
  • Karma: 1
L2jServer hf (sustitución)

-import com.l2jserver.gameserver.datatables.ExperienceTable;
+import com.l2jserver.gameserver.data.json.ExperienceData;

-long exp = ExperienceTable.getInstance().getExpForLevel(player.getLevel() - 1);
+long exp = ExperienceData.getInstance().getExpForLevel(player.getLevel() - 1);

Marzo 30, 2018, 12:37:37 pm
Respuesta #2

Desconectado swarlog

  • Desarrollador
  • Usuario
  • *
  • Mensajes: 1.580
  • Karma: 3
  • Sexo: Masculino
    • U3Games
Gracias por el aporte You are not allowed to view links. Register or Login +1

Mayo 22, 2018, 01:17:27 am
Respuesta #3

Desconectado Kryspo

  • Usuario
  • *
  • Mensajes: 149
  • Karma: 0
  • Sexo: Masculino
  • Desarrollador Java de L2jChile
Existe un NPC que suba de nivel ?

Mayo 22, 2018, 08:18:54 pm
Respuesta #4

Desconectado swarlog

  • Desarrollador
  • Usuario
  • *
  • Mensajes: 1.580
  • Karma: 3
  • Sexo: Masculino
    • U3Games
You are not allowed to view links. Register or Login
Existe un NPC que suba de nivel ?

Simpre podrias modificarlo, y en vez de restarte os suma nivel ^^