Noticias:

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

Menú Principal

Npc Rename Manager

Iniciado por Swarlog, Ago 11, 2022, 01:22 AM

Tema anterior - Siguiente tema

Swarlog

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/network/serverpackets/PartySmallWindowDeleteAll.java
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/PartySmallWindowDeleteAll.java (revision 2)
+++ java/net/sf/l2j/gameserver/network/serverpackets/PartySmallWindowDeleteAll.java (working copy)
@@ -18,7 +18,7 @@
 {
  public static final PartySmallWindowDeleteAll STATIC_PACKET = new PartySmallWindowDeleteAll();
 
- private PartySmallWindowDeleteAll()
+ public PartySmallWindowDeleteAll()
  {
  }
 
Index: java/net/sf/l2j/gameserver/communitybbs/Manager/RegionBBSManager.java
===================================================================
--- java/net/sf/l2j/gameserver/communitybbs/Manager/RegionBBSManager.java (revision 2)
+++ java/net/sf/l2j/gameserver/communitybbs/Manager/RegionBBSManager.java (working copy)
@@ -123,4 +123,13 @@
  {
  protected static final RegionBBSManager _instance = new RegionBBSManager();
  }
+
+ /**
+ *
+ */
+ public void changeCommunityBoard()
+ {
+ // TODO Auto-generated method stub
+
+ }
 }
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java (revision 2)
+++ java/net/sf/l2j/Config.java (working copy)
@@ -365,6 +365,10 @@
  public static int GRID_NEIGHBOR_TURNON_TIME;
  public static int GRID_NEIGHBOR_TURNOFF_TIME;
 
+ public static int RENAME_NPC_ID;
+ public static int RENAME_NPC_MIN_LEVEL;
+ public static String RENAME_NPC_FEE;
+
  // --------------------------------------------------
  // Players
  // --------------------------------------------------
@@ -972,6 +976,10 @@
  GRID_NEIGHBOR_TURNON_TIME = npcs.getProperty("GridNeighborTurnOnTime", 1);
  GRID_NEIGHBOR_TURNOFF_TIME = npcs.getProperty("GridNeighborTurnOffTime", 90);
 
+ RENAME_NPC_ID = Integer.parseInt(npcs.getProperty("RenameNpcID", "36602"));
+ RENAME_NPC_MIN_LEVEL = Integer.parseInt(npcs.getProperty("RenameNpcMinLevel", "40"));
+ RENAME_NPC_FEE = npcs.getProperty("RenameNpcFee", "57,250000");
+
  // players
  ExProperties players = load(PLAYERS_FILE);
  STARTING_ADENA = players.getProperty("StartingAdena", 100);
Index: config/npcs.properties
===================================================================
--- config/npcs.properties (revision 2)
+++ config/npcs.properties (working copy)
@@ -244,4 +244,20 @@
 # The always on option allows to ignore all this and let all grids be active at all times
 GridsAlwaysOn = False
 GridNeighborTurnOnTime = 1
-GridNeighborTurnOffTime = 90
\ No newline at end of file
+GridNeighborTurnOffTime = 90
+
+#============================================================#
+# Rename Npc by Invoke
+#============================================================#
+
+# ID of Rename Npc
+# Prefer using this ID
+RenameNpcID = 36614
+
+# Minimum level to use Rename Npc...
+RenameNpcMinLevel = 40
+
+# ID of Rename Npc Fee...
+# Example: Adena = 57 , and 5000 is the item count needed
+# RenameNpcFee = 57,5000;5575,100
+RenameNpcFee = 9143,5
\ No newline at end of file

/*
 * Copyright (C) 2004-2013 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.RenameNPC;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.communitybbs.Manager.RegionBBSManager;
import net.sf.l2j.gameserver.datatables.CharNameTable;
import net.sf.l2j.gameserver.datatables.ItemTable;
import net.sf.l2j.gameserver.instancemanager.QuestManager;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.model.quest.QuestState;
import net.sf.l2j.gameserver.network.serverpackets.PartySmallWindowAll;
import net.sf.l2j.gameserver.network.serverpackets.PartySmallWindowDeleteAll;
import net.sf.l2j.gameserver.util.Util;

/**
 * @author Invoke
 */
public class RenameNPC extends Quest
{
    private final static int NPC = Config.RENAME_NPC_ID;

    public RenameNPC(int questId, String name, String descr)
    {
        super(questId, name, descr);
        addFirstTalkId(NPC);
        addStartNpc(NPC);
        addTalkId(NPC);
    }
   
    @Override
    public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
    {
        String htmltext = "New Name:<br1><edit var=\"newname\" width=120 height=18>";
        String eventSplit[] = event.split(" ");
        QuestState st = player.getQuestState(getName());
       
        if (eventSplit[0].equalsIgnoreCase("rename"))
        {
            st.getPlayer().setTarget(st.getPlayer());
            if (eventSplit.length != 2)
                htmltext = "Enter a new name or remove the space between the names.";
            else if (st.getPlayer().getLevel() < Config.RENAME_NPC_MIN_LEVEL)
                htmltext = "Minimum Level is: " + String.valueOf(Config.RENAME_NPC_MIN_LEVEL);
            else if (validItemFee(st))
                htmltext = "You do not have enough items for exchange.";
            else if (eventSplit[1].length() < 1 || eventSplit[1].length() > 16)
                htmltext = "Maximum number of characters: 16";
            else if (!Util.isAlphaNumeric(eventSplit[1]))
                htmltext = "The name must only contain alpha-numeric characters.";
            else
            {
                CharNameTable.getInstance();
                if (CharNameTable.doesCharNameExist(eventSplit[1]))
                    htmltext = "The name chosen is already in use. Choose another name.";
                else
                {
                    try
                    {
                        L2World.getInstance().removeFromAllPlayers(player);
                        player.setName(eventSplit[1]);
                        player.store();
                        L2World.getInstance().addToAllPlayers(player);
                        htmltext = "Your name has been changed successfully.";
                        player.broadcastUserInfo();
                       
                        String itemFeeSplit[] = Config.RENAME_NPC_FEE.split("\\;");
                        for (String anItemFeeSplit : itemFeeSplit)
                        {
                            String item[] = anItemFeeSplit.split("\\,");
                            st.takeItems(Integer.parseInt(item[0]), Integer.parseInt(item[1]));
                        }
               
                        if (player.isInParty())
                        {
                            player.getParty().broadcastToPartyMembers(player, new PartySmallWindowDeleteAll());
                            for (L2PcInstance member : player.getParty().getPartyMembers())
                            {
                                if (member != player)
                                    member.sendPacket(new PartySmallWindowAll(member, player.getParty()));
                            }
                        }
                        if (player.getClan() != null)
                            player.getClan().broadcastClanStatus();
                        RegionBBSManager.getInstance().changeCommunityBoard();
                    }
                    catch (StringIndexOutOfBoundsException e)
                    {
                        htmltext = "Service unavailable!";
                    }
                }
            }
            return (page(htmltext,1));
        }
        return (page(htmltext,0));
    }
   
    @Override
    public String onFirstTalk(L2Npc npc, L2PcInstance player)
    {
        String htmltext = "";
        QuestState st = player.getQuestState(getName());
        if (st == null)
        {
            Quest q = QuestManager.getInstance().getQuest(getName());
            st = q.newQuestState(player);
        }
        htmltext = page("New Name:<br1><edit var=\"newname\" width=70 height=10>",0);
        return htmltext;
    }
   
    public String page(String msg, int t)
    {
        String htmltext = "";
        htmltext += htmlPage("Title");
        htmltext += "Hello I'm here to help you change your name.<br>" + "Enter your new name, but make sure you have items for exchange:<br1>";
        String itemFeeSplit[] = Config.RENAME_NPC_FEE.split("\\;");
        for (String anItemFeeSplit : itemFeeSplit)
        {
            String item[] = anItemFeeSplit.split("\\,");
            htmltext += "<font color=\"LEVEL\">" + item[1] + " " + ItemTable.getInstance().getTemplate(Integer.parseInt(item[0])).getName() + "</font><br1>";
        }
        if (t == 0)
        {
            htmltext += "<br><font color=\"339966\">" + msg + "</font>";
            htmltext += "<br><center>" + button("Rename", "rename $newname", 70, 23) + "</center>";
        }
        else
        {
            htmltext += "<br><font color=\"FF0000\">" + msg + "</font>";
            htmltext += "<br><center>" + button("Back", "begin", 70, 23) + "</center>";
        }
        htmltext += htmlPage("Footer");
        return htmltext;
    }
    public Boolean validItemFee(QuestState st)
    {
        String itemFeeSplit[] = Config.RENAME_NPC_FEE.split("\\;");
        for (String anItemFeeSplit : itemFeeSplit)
        {
            String item[] = anItemFeeSplit.split("\\,");
            if (st.getQuestItemsCount(Integer.parseInt(item[0])) < Integer.parseInt(item[1]))
                return true;
        }
        return false;
    }
   
    public String htmlPage(String op)
    {
        String texto = "";
        if (op.equals("Title"))
        {
            texto += "<html><body><title>Rename Manager</title><center><br>" + "<b><font color=ffcc00>Rename Manager Information</font></b>" + "<br><img src=\"L2UI_CH3.herotower_deco\" width=\"256\" height=\"32\"><br></center>";
        }
        else if (op.equals("Footer"))
        {
            texto += "<br><center><img src=\"L2UI_CH3.herotower_deco\" width=\"256\" height=\"32\"><br>" + "<br><font color=\"303030\">---</font></center></body></html>";
        }
        else
        {
            texto = "Not Found!";
        }
        return texto;
    }

    public String button(String name, String event, int w, int h)
    {
        return "<button value=\"" + name + "\" action=\"bypass -h Quest RenameNPC " + event + "\" " + "width=\"" + Integer.toString(w) + "\" height=\"" + Integer.toString(h) + "\" " + "back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
    }

    public String link(String name, String event, String color)
    {
        return "<a action=\"bypass -h Quest RenameNPC " + event + "\">" + "<font color=\"" + color + "\">" + name + "</font></a>";
    }
   
    public static void main(String[] args)
    {
        new RenameNPC(-1, "RenameNPC", "custom");
    }
}

# Custom

  custom/EchoCrystals/EchoCrystals.java
  custom/ShadowWeapon/ShadowWeapon.java
  custom/MissQueen/MissQueen.java
  custom/KetraOrcSupport/KetraOrcSupport.java
  custom/VarkaSilenosSupport/VarkaSilenosSupport.java
  custom/RaidbossInfo/RaidbossInfo.java
  custom/NpcLocationInfo/NpcLocationInfo.java
  custom/HeroCirclet/HeroCirclet.java
  custom/HeroWeapon/HeroWeapon.java
+ custom/RenameNPC/RenameNPC.java

<list>
<npc id="36614" idTemplate="31280" name="Nombre Manager" title="">
        <set name="level" val="70"/>
        <set name="radius" val="8"/>
        <set name="height" val="23"/>
        <set name="rHand" val="0"/>
        <set name="lHand" val="0"/>
        <set name="type" val="L2Npc"/>
        <set name="exp" val="0"/>
        <set name="sp" val="0"/>
        <set name="hp" val="2444.46819"/>
        <set name="mp" val="1345.8"/>
        <set name="hpRegen" val="7.5"/>
        <set name="mpRegen" val="2.7"/>
        <set name="pAtk" val="688.86373"/>
        <set name="pDef" val="295.91597"/>
        <set name="mAtk" val="470.40463"/>
        <set name="mDef" val="216.53847"/>
        <set name="crit" val="4"/>
        <set name="atkSpd" val="253"/>
        <set name="str" val="40"/>
        <set name="int" val="21"/>
        <set name="dex" val="30"/>
        <set name="wit" val="20"/>
        <set name="con" val="43"/>
        <set name="men" val="20"/>
        <set name="corpseTime" val="7"/>
        <set name="walkSpd" val="50"/>
        <set name="runSpd" val="120"/>
        <set name="dropHerbGroup" val="0"/>
        <set name="attackRange" val="40"/>
        <ai type="default" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
        <skills>
            <skill id="4045" level="1"/>
            <skill id="4416" level="14"/>
        </skills>
    </npc>