• Новые темы в этом разделе публикуются автоматически при добавлении файла в менеджер ресурсов.
    Ручное создание новых тем невозможно.
Иконка ресурса

Мануал Shift+Click To Npcs [Acis 350]

Psyancy

Знаменитый
Участник
Сообщения
26
Розыгрыши
0
Репутация
369
Реакции
60
Баллы
1 253
Hello guys, nothing special but it's not shared here this code for IL and a lot of people don't know how to do it since i added it on my project yesterday i decided to share it here with you.

Here is preview images:
COpcCa0.png
MXdrlqJ.png

Go to net.sf.l2j.gameserver.model.actor.L2Npc.java
find:

Below add:


Config files:
Config.java


npcs.properties


The voicedcommand
Create new class called ShiftClickToNpc inside paste


Import the voicedcommand on net.sf.l2j.gameserver.handler.VoicedCommandHandler.java


And now go to your datapack > data/html/mods and create new file called npcinfo.htm and inside paste


Credits: Psyancy (aka Designatix)​
 
Последнее редактирование модератором:

You can do it with requestbypassstoserver instead of using a voiced command
 
by the way it's not working for acis 370, i get a message "Usage: .show_droplist <npc_id> [<page>]" so there might be a problem with the shownpcdroplist as a voiced command
 
by the way it's not working for acis 370, i get a message "Usage: .show_droplist <npc_id> [<page>]" so there might be a problem with the shownpcdroplist as a voiced command
I cannot update the main post so i will post here the update. The code is working on my pack which is 374.
1565270568435.png 1565270575967.png 1565270582317.png

In package net.sf.l2j.gameserver.model.actor class Npc.java
Find:
Java:
// Check if the Player is a GM
        if (player.isGM())
        {
            final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
            html.setFile("data/html/admin/npcinfo.htm");
            html.replace("%class%", getClass().getSimpleName());
            html.replace("%id%", getTemplate().getNpcId());
            html.replace("%lvl%", getTemplate().getLevel());
            html.replace("%name%", getName());
            html.replace("%race%", getTemplate().getRace().toString());
            html.replace("%tmplid%", getTemplate().getIdTemplate());
            html.replace("%castle%", (getCastle() != null) ? getCastle().getName() : "none");
            html.replace("%aggro%", getTemplate().getAggroRange());
            html.replace("%corpse%", StringUtil.getTimeStamp(getTemplate().getCorpseTime()));
            html.replace("%enchant%", getTemplate().getEnchantEffect());
            html.replace("%hp%", (int) getCurrentHp());
            html.replace("%hpmax%", getMaxHp());
            html.replace("%mp%", (int) getCurrentMp());
            html.replace("%mpmax%", getMaxMp());
            html.replace("%patk%", getPAtk(null));
            html.replace("%matk%", getMAtk(null, null));
            html.replace("%pdef%", getPDef(null));
            html.replace("%mdef%", getMDef(null, null));
            html.replace("%accu%", getAccuracy());
            html.replace("%evas%", getEvasionRate(null));
            html.replace("%crit%", getCriticalHit(null, null));
            html.replace("%rspd%", getMoveSpeed());
            html.replace("%aspd%", getPAtkSpd());
            html.replace("%cspd%", getMAtkSpd());
            html.replace("%str%", getSTR());
            html.replace("%dex%", getDEX());
            html.replace("%con%", getCON());
            html.replace("%int%", getINT());
            html.replace("%wit%", getWIT());
            html.replace("%men%", getMEN());
            html.replace("%loc%", getX() + " " + getY() + " " + getZ());
            html.replace("%dist%", (int) Math.sqrt(player.getDistanceSq(this)));
            html.replace("%ele_fire%", getDefenseElementValue((byte) 2));
            html.replace("%ele_water%", getDefenseElementValue((byte) 3));
            html.replace("%ele_wind%", getDefenseElementValue((byte) 1));
            html.replace("%ele_earth%", getDefenseElementValue((byte) 4));
            html.replace("%ele_holy%", getDefenseElementValue((byte) 5));
            html.replace("%ele_dark%", getDefenseElementValue((byte) 6));
            
            if (getSpawn() != null)
            {
                html.replace("%spawn%", getSpawn().getLoc().toString());
                html.replace("%loc2d%", (int) Math.sqrt(getPlanDistanceSq(getSpawn().getLocX(), getSpawn().getLocY())));
                html.replace("%loc3d%", (int) Math.sqrt(getDistanceSq(getSpawn().getLocX(), getSpawn().getLocY(), getSpawn().getLocZ())));
                html.replace("%resp%", StringUtil.getTimeStamp(getSpawn().getRespawnDelay()));
                html.replace("%rand_resp%", StringUtil.getTimeStamp(getSpawn().getRespawnRandom()));
            }
            else
            {
                html.replace("%spawn%", "<font color=FF0000>null</font>");
                html.replace("%loc2d%", "<font color=FF0000>--</font>");
                html.replace("%loc3d%", "<font color=FF0000>--</font>");
                html.replace("%resp%", "<font color=FF0000>--</font>");
                html.replace("%rand_resp%", "<font color=FF0000>--</font>");
            }
            
            if (hasAI())
            {
                html.replace("%ai_intention%", "<font color=\"LEVEL\">Intention</font><table width=\"100%\"><tr><td><font color=\"LEVEL\">Intention:</font></td><td>" + getAI().getIntention().name() + "</td></tr>");
                html.replace("%ai%", "<tr><td><font color=\"LEVEL\">AI:</font></td><td>" + getAI().getClass().getSimpleName() + "</td></tr></table><br>");
            }
            else
            {
                html.replace("%ai_intention%", "");
                html.replace("%ai%", "");
            }
            
            html.replace("%ai_type%", getTemplate().getAiType().name());
            html.replace("%ai_clan%", (getTemplate().getClans() != null) ? "<tr><td width=100><font color=\"LEVEL\">Clan:</font></td><td align=right width=170>" + Arrays.toString(getTemplate().getClans()) + " " + getTemplate().getClanRange() + "</td></tr>" + ((getTemplate().getIgnoredIds() != null) ? "<tr><td width=100><font color=\"LEVEL\">Ignored ids:</font></td><td align=right width=170>" + Arrays.toString(getTemplate().getIgnoredIds()) + "</td></tr>" : "") : "");
            html.replace("%ai_move%", String.valueOf(getTemplate().canMove()));
            html.replace("%ai_seed%", String.valueOf(getTemplate().isSeedable()));
            html.replace("%ai_ssinfo%", _currentSsCount + "[" + getTemplate().getSsCount() + "] - " + getTemplate().getSsRate() + "%");
            html.replace("%ai_spsinfo%", _currentSpsCount + "[" + getTemplate().getSpsCount() + "] - " + getTemplate().getSpsRate() + "%");
            html.replace("%butt%", ((this instanceof Merchant) ? "<button value=\"Shop\" action=\"bypass -h admin_show_shop " + getNpcId() + "\" width=65 height=19 back=\"L2UI_ch3.smallbutton2_over\" fore=\"L2UI_ch3.smallbutton2\">" : ""));
            player.sendPacket(html);
        }

Bellow add:
Java:
else if (Config.ENABLE_SHIFT_CLICK_TO_NPCS)
        {
            final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
            html.setFile("data/html/drenepiaworld/npcinfo.htm");
            html.replace("%class%", getClass().getSimpleName());
            html.replace("%id%", getTemplate().getNpcId());
            html.replace("%lvl%", getTemplate().getLevel());
            html.replace("%name%", getName());
            html.replace("%race%", getTemplate().getRace().toString());
            html.replace("%tmplid%", getTemplate().getIdTemplate());
            html.replace("%castle%", (getCastle() != null) ? getCastle().getName() : "none");
            html.replace("%aggro%", getTemplate().getAggroRange());
            html.replace("%corpse%", StringUtil.getTimeStamp(getTemplate().getCorpseTime()));
            html.replace("%enchant%", getTemplate().getEnchantEffect());
            html.replace("%hp%", (int) getCurrentHp());
            html.replace("%hpmax%", getMaxHp());
            html.replace("%mp%", (int) getCurrentMp());
            html.replace("%mpmax%", getMaxMp());
            html.replace("%patk%", getPAtk(null));
            html.replace("%matk%", getMAtk(null, null));
            html.replace("%pdef%", getPDef(null));
            html.replace("%mdef%", getMDef(null, null));
            html.replace("%accu%", getAccuracy());
            html.replace("%evas%", getEvasionRate(null));
            html.replace("%crit%", getCriticalHit(null, null));
            html.replace("%rspd%", getMoveSpeed());
            html.replace("%aspd%", getPAtkSpd());
            html.replace("%cspd%", getMAtkSpd());
            html.replace("%str%", getSTR());
            html.replace("%dex%", getDEX());
            html.replace("%con%", getCON());
            html.replace("%int%", getINT());
            html.replace("%wit%", getWIT());
            html.replace("%men%", getMEN());
            html.replace("%loc%", getX() + " " + getY() + " " + getZ());
            html.replace("%dist%", (int) Math.sqrt(player.getDistanceSq(this)));
            html.replace("%ele_fire%", getDefenseElementValue((byte) 2));
            html.replace("%ele_water%", getDefenseElementValue((byte) 3));
            html.replace("%ele_wind%", getDefenseElementValue((byte) 1));
            html.replace("%ele_earth%", getDefenseElementValue((byte) 4));
            html.replace("%ele_holy%", getDefenseElementValue((byte) 5));
            html.replace("%ele_dark%", getDefenseElementValue((byte) 6));
            
            if (getSpawn() != null)
            {
                html.replace("%spawn%", getSpawn().getLoc().toString());
                html.replace("%loc2d%", (int) Math.sqrt(getPlanDistanceSq(getSpawn().getLocX(), getSpawn().getLocY())));
                html.replace("%loc3d%", (int) Math.sqrt(getDistanceSq(getSpawn().getLocX(), getSpawn().getLocY(), getSpawn().getLocZ())));
                html.replace("%resp%", StringUtil.getTimeStamp(getSpawn().getRespawnDelay()));
                html.replace("%rand_resp%", StringUtil.getTimeStamp(getSpawn().getRespawnRandom()));
            }
            else
            {
                html.replace("%spawn%", "<font color=FF0000>null</font>");
                html.replace("%loc2d%", "<font color=FF0000>--</font>");
                html.replace("%loc3d%", "<font color=FF0000>--</font>");
                html.replace("%resp%", "<font color=FF0000>--</font>");
                html.replace("%rand_resp%", "<font color=FF0000>--</font>");
            }
            
            if (hasAI())
            {
                html.replace("%ai_intention%", "<font color=\"LEVEL\">Intention</font><table width=\"100%\"><tr><td><font color=\"LEVEL\">Intention:</font></td><td>" + getAI().getIntention().name() + "</td></tr>");
                html.replace("%ai%", "<tr><td><font color=\"LEVEL\">AI:</font></td><td>" + getAI().getClass().getSimpleName() + "</td></tr></table><br>");
            }
            else
            {
                html.replace("%ai_intention%", "");
                html.replace("%ai%", "");
            }
            
            html.replace("%ai_type%", getTemplate().getAiType().name());
            html.replace("%ai_clan%", (getTemplate().getClans() != null) ? "<tr><td width=100><font color=\"LEVEL\">Clan:</font></td><td align=right width=170>" + Arrays.toString(getTemplate().getClans()) + " " + getTemplate().getClanRange() + "</td></tr>" + ((getTemplate().getIgnoredIds() != null) ? "<tr><td width=100><font color=\"LEVEL\">Ignored ids:</font></td><td align=right width=170>" + Arrays.toString(getTemplate().getIgnoredIds()) + "</td></tr>" : "") : "");
            html.replace("%ai_move%", String.valueOf(getTemplate().canMove()));
            html.replace("%ai_seed%", String.valueOf(getTemplate().isSeedable()));
            html.replace("%ai_ssinfo%", _currentSsCount + "[" + getTemplate().getSsCount() + "] - " + getTemplate().getSsRate() + "%");
            html.replace("%ai_spsinfo%", _currentSpsCount + "[" + getTemplate().getSpsCount() + "] - " + getTemplate().getSpsRate() + "%");
            html.replace("%butt%", ((this instanceof Merchant) ? "<button value=\"Shop\" action=\"bypass -h admin_show_shop " + getNpcId() + "\" width=65 height=19 back=\"L2UI_ch3.smallbutton2_over\" fore=\"L2UI_ch3.smallbutton2\">" : ""));
            player.sendPacket(html);
        }

The command:
Java:
/*
 * 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 net.sf.l2j.gameserver.handler.voicedcommandhandlers;

import java.util.StringTokenizer;

import net.sf.l2j.commons.lang.StringUtil;

import net.sf.l2j.gameserver.data.ItemTable;
import net.sf.l2j.gameserver.data.NpcTable;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.model.actor.instance.Player;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.model.item.DropCategory;
import net.sf.l2j.gameserver.model.item.DropData;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;

/**
 * @author Designatix
 *
 */
public class ShiftClickToNpc implements IVoicedCommandHandler
{

private static final int PAGE_LIMIT = 20;
    
    private static String[] _voicedCommands =
    {
        "show_droplist"
    };
    
    @Override
    public boolean useVoicedCommand(String command, Player activeChar, String target)
    {
        final StringTokenizer st = new StringTokenizer(command, " ");
        st.nextToken();
        
        if (command.startsWith("show_droplist"))
        {
            try
            {
                int npcId = Integer.parseInt(st.nextToken());
                int page = (st.hasMoreTokens()) ? Integer.parseInt(st.nextToken()) : 1;
                
                showNpcDropList(activeChar, npcId, page);
            }
            catch (Exception e)
            {
                activeChar.sendMessage("Usage: .show_droplist <npc_id> [<page>]");
            }
        }
        return true;
    }
        
    private static void showNpcDropList(Player activeChar, int npcId, int page)
    {
        final NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);
        if (npcData == null)
        {
            activeChar.sendMessage("Npc template is unknown for id: " + npcId + ".");
            return;
        }
        
        final StringBuilder sb = new StringBuilder(2000);
        StringUtil.append(sb, "<html><title>Show droplist page ", page, "</title><body><center><font color=\"LEVEL\">", npcData.getName(), "</font>.</center><br>");
        
        if (!npcData.getDropData().isEmpty())
        {
            sb.append("<center><font color=\"LEVEL\">If chance is 0% it means its lower than 1%.</font></center><br>Drop type legend: <font color=\"3BB9FF\">Drop</font> | <font color=\"00ff00\">Sweep</font><br><table><tr><td width=25>cat.</td><td width=255>item, min-max drop, chance</td></tr>");
            
            int myPage = 1;
            int i = 0;
            int shown = 0;
            boolean hasMore = false;
            
            for (DropCategory cat : npcData.getDropData())
            {
                if (shown == PAGE_LIMIT)
                {
                    hasMore = true;
                    break;
                }
                
                for (DropData drop : cat.getAllDrops())
                {
                    if (myPage != page)
                    {
                        i++;
                        if (i == PAGE_LIMIT)
                        {
                            myPage++;
                            i = 0;
                        }
                        continue;
                    }
                    
                    if (shown == PAGE_LIMIT)
                    {
                        hasMore = true;
                        break;
                    }
                    
                    StringUtil.append(sb, "<tr><td><font color=\"", ((cat.isSweep()) ? "00FF00" : "3BB9FF"), "\">", cat.getCategoryType(), "</td><td>", ItemTable.getInstance().getTemplate(drop.getItemId()).getName(), " - ", drop.getMinDrop(), "/", drop.getMaxDrop(), " - (", drop.getChance()/10000 , "%)</td></tr>");
                    shown++;
                }
            }
            
            sb.append("</table><table width=\"100%\" bgcolor=666666><tr>");
            
            if (page > 1)
            {
                StringUtil.append(sb, "<td width=120><a action=\"bypass -h voiced_show_droplist ", npcId, " ", page - 1, "\">Prev Page</a></td>");
                if (!hasMore)
                    StringUtil.append(sb, "<td width=100>Page ", page, "</td><td width=70></td></tr>");
            }
            
            if (hasMore)
            {
                if (page <= 1)
                    sb.append("<td width=120></td>");
                
                StringUtil.append(sb, "<td width=100>Page ", page, "</td><td width=70><a action=\"bypass -h voiced_show_droplist ", npcId, " ", page + 1, "\">Next Page</a></td></tr>");
            }
            sb.append("</table>");
        }
        else
            sb.append("This NPC has no drops.");
        
        sb.append("</body></html>");
        
        final NpcHtmlMessage html = new NpcHtmlMessage(0);
        html.setHtml(sb.toString());
        activeChar.sendPacket(html);
    }
        
    @Override
    public String[] getVoicedCommandList()
    {
        return _voicedCommands;
    }
}

The Configs:
Java:
public static boolean ENABLE_SHIFT_CLICK_TO_NPCS;

ENABLE_SHIFT_CLICK_TO_NPCS = players.getProperty("EnableShiftClickToNpcs", false);
Код:
# ===================================================================
# Shift + Click to NPC(s).
# ===================================================================
# Enable showing NPC(s) info by Shift + Click on NPC(s)?
# Default: False
EnableShiftClickToNpcs = True

And the HTML
HTML:
<html><title>NPC Info</title><body>
    <center>
        <table width="100%">
        <tr>
            <td align=center>
                <button value="Show Droplist" action="bypass -h voiced_show_droplist %id%" width=134 height=21 back="L2UI_ch3.BigButton3_over" fore="L2UI_ch3.BigButton3">
            </td>
        </tr>
        </table>

        <br><img src="L2UI.SquareWhite" width=260 height=1><br>
        <font color="LEVEL">General Informations</font>
        <table width="100%">
            <tr><td><font color="LEVEL">Name:</font></td><td>%name%</td><td><font color="LEVEL">Level:</font></td><td>%lvl%</td></tr>
            <tr><td><font color="LEVEL">Type:</font></td><td>%class%</td></tr>
            <tr><td><font color="LEVEL">Race:</font></td><td>%race%</td><td><font color="LEVEL">Castle:</font></td><td>%castle%</td></tr>
        </table><br>

        <font color="LEVEL">AI Informations</font>
        <table width="100%">
            <tr><td width=100><font color="LEVEL">Aggro:</font></td><td align=right width=170>%aggro%</td></tr>
            <tr><td width=100><font color="LEVEL">canMove:</font></td><td align=right width=170>%ai_move%</td></tr>
            <tr><td width=100><font color="LEVEL">isSeedable:</font></td><td align=right width=170>%ai_seed%</td></tr>
            %ai_clan%
        </table><br>
        
        <font color="LEVEL">Combat Informations</font>
        <table width="100%">
            <tr><td><font color="LEVEL">HP:</font></td><td><font color=FF4040>%hp%/%hpmax%</font></td><td><font color="LEVEL">MP:</font></td><td><font color=6161FF>%mp%/%mpmax%</font></td></tr>
            <tr><td>P.Atk.</td><td>%patk%</td><td>M.Atk.</td><td>%matk%</td></tr>
            <tr><td>P.Def.</td><td>%pdef%</td><td>M.Def.</td><td>%mdef%</td></tr>
            <tr><td>Accuracy</td><td>%accu%</td><td>Evasion</td><td>%evas%</td></tr>
            <tr><td>Critical</td><td>%crit%</td><td>Speed</td><td>%rspd%</td></tr>
            <tr><td>Atk.Spd</td><td>%aspd%</td><td>Cast.Spd</td><td>%cspd%</td></tr>
        </table><br>

        <font color="LEVEL">Basic Stats</font>
        <table width="100%">
            <tr>
                <td>STR</td><td>%str%</td>
                <td>DEX</td><td>%dex%</td>
                <td>CON</td><td>%con%</td>
            </tr>
            <tr>
                <td>INT</td><td>%int%</td>
                <td>WIT</td><td>%wit%</td>
                <td>MEN</td><td>%men%</td>
            </tr>
        </table><br>

        <font color="LEVEL">Elements</font>
        <table border="0" width="100%">
            <tr>
                <td>Fire</td><td>%ele_fire%</td>
                <td>Water</td><td>%ele_water%</td>
            </tr>
            <tr>
                <td>Wind</td><td>%ele_wind%</td>
                <td>Earth</td><td>%ele_earth%</td>
            </tr>
            <tr>
                <td>Holy</td><td>%ele_holy%</td>
                <td>Dark</td><td>%ele_dark%</td>
            </tr>
        </table><br>
        <br><img src="L2UI.SquareWhite" width=260 height=1><br>
    </center>
</body></html>
 
thanks for sharing, i've already added to my project
 
Hello guys, nothing special but it's not shared here this code for IL and a lot of people don't know how to do it since i added it on my project yesterday i decided to share it here with you.

Here is preview images:
COpcCa0.png
MXdrlqJ.png

Go to net.sf.l2j.gameserver.model.actor.L2Npc.java
find:
*** Скрытый текст не может быть процитирован. ***
Below add:
*** Скрытый текст не может быть процитирован. ***

Config files:
Config.java
*** Скрытый текст не может быть процитирован. ***

npcs.properties
*** Скрытый текст не может быть процитирован. ***

The voicedcommand
Create new class called ShiftClickToNpc inside paste
*** Скрытый текст не может быть процитирован. ***

Import the voicedcommand on net.sf.l2j.gameserver.handler.VoicedCommandHandler.java
*** Скрытый текст не может быть процитирован. ***

And now go to your datapack > data/html/mods and create new file called npcinfo.htm and inside paste
*** Скрытый текст не может быть процитирован. ***

Credits: Psyancy (aka Designatix)​
Спасибо за информацию.
 
Thanks for share.
 
Thanks for sharing
Keep it up in self growing
 
Thanks for Shared
 
Обратите внимание, что данный пользователь заблокирован! Не совершайте с ним никаких сделок! Перейдите в его профиль, чтобы узнать причину блокировки.
Глянем.
 
thx
 
Спасибо
 
Спасибо.
 
Назад
Сверху Снизу