Jump to content

Recommended Posts

Posted

Hello guys i want my npc buffer when I add a buff, there should be movement, for example, of the hands. What i change or add in my code. I use l2jacis interlude. 

 

else if (currentCommand.equalsIgnoreCase("getbuff"))

{

int buffid = 0;

int bufflevel = 1;

String nextWindow = null;

 

if (st.countTokens() == 3)

{

buffid = Integer.valueOf(st.nextToken());

bufflevel = Integer.valueOf(st.nextToken());

nextWindow = st.nextToken();

}

else if (st.countTokens() == 1)

buffid = Integer.valueOf(st.nextToken());

 

if (buffid != 0)

{

player.broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 5, 0));

 

player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(buffid, bufflevel));

SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);

showSubBufferWindow(player);

showChatWindow(player, nextWindow);

}

}

Posted

Change this:

 

- player.broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 5, 0));

 

to:

 

+ player.broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 1000, 0));

 

 

Posted

Hey mates,

 

Also change this to player 

player.broadcastPacket(new MagicSkillUse(player, player, buffid, bufflevel, 1000, 0));

 

2 hours ago, Orochy said:

Change this:

 

- player.broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 5, 0));

 

to:

 

+ player.broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 1000, 0));

 

 

 

Posted
On 9/14/2023 at 9:16 PM, L2Fuss said:

Hey mates,

 

Also change this to player 

player.broadcastPacket(new MagicSkillUse(player, player, buffid, bufflevel, 1000, 0));

 

 

Very thx guys, really work but example when I use dances warrior siren and all other dances no movement. Buffs and songs work perfect.

Posted
2 minutes ago, xristoeli1994 said:

Very thx guys, really work but example when I use dances warrior siren and all other dances no movement. Buffs and songs work perfect.

if u want for dances u need to make custom skill based on buffs with animation of dance/song in order to work...

  • Thanks 1
  • 3 months later...
Posted

package net.sf.l2j.gameserver.model.actor.instance;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

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

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.data.SkillTable;
import net.sf.l2j.gameserver.data.manager.BufferManager;
import net.sf.l2j.gameserver.data.manager.BufferManager.BufferSchemeType;
import net.sf.l2j.gameserver.dev.config.JDevConfig;
import net.sf.l2j.gameserver.model.actor.Creature;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.model.actor.Summon;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.skills.L2Skill;

public class SchemeBuffer extends Folk
{
    private static final int PAGE_LIMIT = 6;
    
    public SchemeBuffer(int objectId, NpcTemplate template)
    {
        super(objectId, template);
    }
    
    @Override
    public void onBypassFeedback(Player player, String command)
    {
        StringTokenizer st = new StringTokenizer(command, " ");
        String currentCommand = st.nextToken();
        
        if (currentCommand.startsWith("menu"))
        {
            final NpcHtmlMessage html = new NpcHtmlMessage(0);
            html.setFile(getHtmlPath(getNpcId(), 0));
            html.replace("%objectId%", getObjectId());
            html.replace("%count%", player.getBuffCount() + " / " + player.getMaxBuffCount());
            player.sendPacket(html);
        }
        else if (currentCommand.startsWith("cleanup"))
        {
            player.stopAllEffectsExceptThoseThatLastThroughDeath();
            
            final Summon summon = player.getSummon();
            if (summon != null)
                summon.stopAllEffectsExceptThoseThatLastThroughDeath();
            
            player.getCubicList().stopCubics(true);
            
            final NpcHtmlMessage html = new NpcHtmlMessage(0);
            html.setFile(getHtmlPath(getNpcId(), 0));
            html.replace("%count%", player.getBuffCount() + " / " + player.getMaxBuffCount());
            html.replace("%objectId%", getObjectId());
            player.sendPacket(html);
        }
        if (currentCommand.equalsIgnoreCase("buffer_custom"))
        {
            int buffid = 0;
            String nextWindow = null;
            
            if (st.countTokens() == 2)
            {
                buffid = Integer.valueOf(st.nextToken());
                nextWindow = st.nextToken();
            }
            else if (st.countTokens() == 1)
                buffid = Integer.valueOf(st.nextToken());
            
            if (buffid != 0)
            {
                
                L2Skill skill = SkillTable.getInstance().getInfo(buffid, SkillTable.getInstance().getMaxLevel(buffid));
                if (skill != null)
                    skill.getEffects(player, player);
                
                player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(buffid, SkillTable.getInstance().getMaxLevel(buffid)));
                showChatWindow(player, nextWindow);
            }
        }
        else if (currentCommand.startsWith("heal"))
        {
            player.getStatus().setMaxCpHpMp();
            
            final Summon summon = player.getSummon();
            if (summon != null)
                summon.getStatus().setMaxHpMp();
            
            final NpcHtmlMessage html = new NpcHtmlMessage(0);
            html.setFile(getHtmlPath(getNpcId(), 0));
            html.replace("%objectId%", getObjectId());
            html.replace("%count%", player.getBuffCount() + " / " + player.getMaxBuffCount());
            player.sendPacket(html);
        }
        else if (currentCommand.startsWith("support"))
            showGiveBuffsWindow(player);
        else if (currentCommand.startsWith("getscheme"))
            BufferManager.getInstance().getSchemeSkills(BufferSchemeType.valueOf(st.nextToken().toUpperCase())).forEach(buffId -> getEffect(player, buffId));
        else if (currentCommand.startsWith("getbuff"))
        {
            final int skillId = Integer.parseInt(st.nextToken());
            final int skillLevel = Integer.parseInt(st.nextToken());
            List<L2Skill> list = new ArrayList<>();
            list.add(SkillTable.getInstance().getInfo(skillId, skillLevel));
            int cost = getFee(list);
            if (cost == 0 || player.reduceAdena("NPC Buffer", cost, this, true))
                list.forEach(buffId -> getEffect(player, buffId));
        }
        else if (currentCommand.startsWith("singlebuff"))
            showSingleBuffSelectionWindow(player, st.nextToken(), Integer.parseInt(st.nextToken()));
        else if (currentCommand.startsWith("givebuffs"))
        {
            final String schemeName = st.nextToken();
            final int cost = Integer.parseInt(st.nextToken());
            
            Creature target = null;
            if (st.hasMoreTokens())
            {
                final String targetType = st.nextToken();
                if (targetType != null && targetType.equalsIgnoreCase("pet"))
                    target = player.getSummon();
            }
            else
                target = player;
            
            if (target == null)
                player.sendMessage("You don't have a pet.");
            else if (cost == 0 || player.reduceAdena("NPC Buffer", cost, this, true))
                BufferManager.getInstance().applySchemeEffects(this, target, player.getObjectId(), schemeName);
        }
        else if (currentCommand.startsWith("editschemes"))
            showEditSchemeWindow(player, st.nextToken(), st.nextToken(), Integer.parseInt(st.nextToken()));
        else if (currentCommand.startsWith("skill"))
        {
            final String groupType = st.nextToken();
            final String schemeName = st.nextToken();
            
            final int skillId = Integer.parseInt(st.nextToken());
            final int skillLevel = Integer.parseInt(st.nextToken());
            final int page = Integer.parseInt(st.nextToken());
            
            L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLevel);
            final List<L2Skill> skills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
            premiumSkills(player, skills);
            if (currentCommand.startsWith("skillselect") && !schemeName.equalsIgnoreCase("none"))
            {
                if (skills.size() < player.getMaxBuffCount())
                    skills.add(skill);
                else
                    player.sendMessage("This scheme has reached the maximum amount of buffs.");
            }
            else if (currentCommand.startsWith("skillunselect"))
                skills.remove(skill);
            
            showEditSchemeWindow(player, groupType, schemeName, page);
        }
        else if (currentCommand.startsWith("createscheme"))
        {
            try
            {
                final String schemeName = st.nextToken();
                if (schemeName.length() > 14)
                {
                    player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
                    return;
                }
                
                final Map<String, ArrayList<L2Skill>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
                if (schemes != null)
                {
                    if (schemes.size() == Config.BUFFER_MAX_SCHEMES)
                    {
                        player.sendMessage("Maximum schemes amount is already reached.");
                        return;
                    }
                    
                    if (schemes.containsKey(schemeName))
                    {
                        player.sendMessage("The scheme name already exists.");
                        return;
                    }
                }
                
                BufferManager.getInstance().setScheme(player.getObjectId(), schemeName.trim(), new ArrayList<>());
                showGiveBuffsWindow(player);
            }
            catch (Exception e)
            {
                player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
            }
        }
        else if (currentCommand.startsWith("deletescheme"))
        {
            try
            {
                final String schemeName = st.nextToken();
                final Map<String, ArrayList<L2Skill>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
                
                if (schemes != null && schemes.containsKey(schemeName))
                    schemes.remove(schemeName);
            }
            catch (Exception e)
            {
                player.sendMessage("This scheme name is invalid.");
            }
            showGiveBuffsWindow(player);
        }
        
        super.onBypassFeedback(player, command);
    }
    
    private void getEffect(Player player, L2Skill buff)
    {
        buff.getEffects(this, player);
    }
    
    @Override
    public String getHtmlPath(int npcId, int val)
    {
        String filename = "";
        if (val == 0)
            filename = "" + npcId;
        else
            filename = npcId + "-" + val;
        
        return "data/html/mods/buffer/" + filename + ".htm";
    }
    
    /**
     * Send an html packet to the {@link Player} set a parameter with Give Buffs menu info for player and pet, depending on targetType parameter {player, pet}.
     * @param player : The {@link Player} to make checks on.
     */
    private void showGiveBuffsWindow(Player player)
    {
        final StringBuilder sb = new StringBuilder(200);
        
        final Map<String, ArrayList<L2Skill>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
        if (schemes == null || schemes.isEmpty())
            sb.append("<font color=\"LEVEL\">You haven't defined any scheme.</font>");
        else
        {
            for (Map.Entry<String, ArrayList<L2Skill>> scheme : schemes.entrySet())
            {
                final int cost = getFee(scheme.getValue());
                StringUtil.append(sb, "<font color=\"LEVEL\">", scheme.getKey(), " [", scheme.getValue().size(), " / ", player.getMaxBuffCount(), "]", ((cost > 0) ? " - cost: " + StringUtil.formatNumber(cost) : ""), "</font><br1>");
                StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_givebuffs ", scheme.getKey(), " ", cost, "\">Use on Me</a>&nbsp;|&nbsp;");
                StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_givebuffs ", scheme.getKey(), " ", cost, " pet\">Use on Pet</a>&nbsp;|&nbsp;");
                StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_editschemes Buffs ", scheme.getKey(), " 1\">Edit</a>&nbsp;|&nbsp;");
                StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_deletescheme ", scheme.getKey(), "\">Delete</a><br>");
            }
        }
        
        final NpcHtmlMessage html = new NpcHtmlMessage(0);
        html.setFile(getHtmlPath(getNpcId(), 1));
        html.replace("%schemes%", sb.toString());
        html.replace("%max_schemes%", Config.BUFFER_MAX_SCHEMES);
        html.replace("%count%", player.getBuffCount() + " / " + player.getMaxBuffCount());
        html.replace("%objectId%", getObjectId());
        player.sendPacket(html);
    }
    
    /**
     * Send an html packet to the {@link Player} set as parameter with Edit Scheme Menu info. This allows the {@link Player} to edit each created scheme (add/delete skills)
     * @param player : The {@link Player} to make checks on.
     * @param groupType : The group of skills to select.
     * @param schemeName : The scheme to make check.
     * @param page : The current checked page.
     */
    private void showEditSchemeWindow(Player player, String groupType, String schemeName, int page)
    {
        final NpcHtmlMessage html = new NpcHtmlMessage(0);
        final List<L2Skill> schemeSkills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
        premiumSkills(player, schemeSkills);
        html.setFile(getHtmlPath(getNpcId(), 2));
        html.replace("%schemename%", schemeName);
        html.replace("%count%", schemeSkills.size() + " / " + player.getMaxBuffCount());
        html.replace("%typesframe%", getTypesFrame(player, groupType, schemeName, false));
        html.replace("%skilllistframe%", getGroupSkillList(player, groupType, schemeName, false, page));
        html.replace("%objectId%", getObjectId());
        player.sendPacket(html);
    }
    
    private void showSingleBuffSelectionWindow(Player player, String groupType, int page)
    {
        final NpcHtmlMessage html = new NpcHtmlMessage(0);
        html.setFile(getHtmlPath(getNpcId(), 3));
        html.replace("%typesframe%", getTypesFrame(player, groupType, "", true));
        html.replace("%skilllistframe%", getGroupSkillList(player, groupType, "", true, page));
        html.replace("%objectId%", getObjectId());
        player.sendPacket(html);
    }
    
    /**
     * @param player : The {@link Player} to make checks on.
     * @param groupType : The group of skills to select.
     * @param schemeName : The scheme to make check.
     * @param singleSelection : Indicate if it's single buff selection or not.
     * @param page : The current checked page.
     * @return A {@link String} representing skills available for selection for a given groupType.
     */
    private String getGroupSkillList(Player player, String groupType, String schemeName, boolean singleSelection, int page)
    {
        // Retrieve the entire skills list based on group type.
        List<L2Skill> skills = BufferManager.getInstance().getSkillsIdsByType(groupType);
        
        premiumSkills(player, skills);
        
        if (skills.isEmpty())
            return "That group doesn't contain any skills.";
        
        // Calculate page number.
        final int max = MathUtil.countPagesNumber(skills.size(), PAGE_LIMIT);
        if (page > max)
            page = max;
        
        // Cut skills list up to page number.
        skills = skills.subList((page - 1) * PAGE_LIMIT, Math.min(page * PAGE_LIMIT, skills.size()));
        
        final List<L2Skill> schemeSkills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
        final StringBuilder sb = new StringBuilder(skills.size() * 150);
        
        int row = 0;
        for (L2Skill skill : skills)
        {
            int skillId = skill.getId();
            int skillLevel = skill.getLevel();
            
            sb.append(((row % 2) == 0 ? "<table width=\"280\" bgcolor=\"000000\"><tr>" : "<table width=\"280\"><tr>"));
            
            if (singleSelection)
                StringUtil.append(sb, "<td height=40 width=40><button action=\"bypass npc_" + getObjectId() + "_getbuff ", skillId, " ", skillLevel, " ", "\" width=32 height=32 back=\"", getIconForBufferId(skillId), "\" fore=\"", getIconForBufferId(skillId), "\" /></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferManager.getInstance().getAvailableBuff(skill).getDescription(), "</font></td>");
            else
            {
                if (schemeSkills.contains(skill))
                    StringUtil.append(sb, "<td height=40 width=40><img src=\"", getIconForBufferId(skillId), "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferManager.getInstance().getAvailableBuff(skill).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillunselect ", groupType, " ", schemeName, " ", skillId, " ", skillLevel, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomout2\" fore=\"L2UI_CH3.mapbutton_zoomout1\"></td>");
                else
                    StringUtil.append(sb, "<td height=40 width=40><img src=\"", getIconForBufferId(skillId), "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferManager.getInstance().getAvailableBuff(skill).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillselect ", groupType, " ", schemeName, " ", skillId, " ", skillLevel, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomin2\" fore=\"L2UI_CH3.mapbutton_zoomin1\"></td>");
            }
            
            sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=280 height=1>");
            row++;
        }
        
        for (int i = PAGE_LIMIT; i > row; i--)
            StringUtil.append(sb, "<img height=41>");
        
        // Build page footer.
        sb.append("<br><img src=\"L2UI.SquareGray\" width=280 height=1><table width=\"100%\" bgcolor=000000><tr>");
        
        if (page > 1)
        {
            if (singleSelection)
                StringUtil.append(sb, "<td align=left width=70><a action=\"bypass npc_" + getObjectId() + "_singlebuff ", groupType, " ", page - 1, "\">Previous</a></td>");
            else
                StringUtil.append(sb, "<td align=left width=70><a action=\"bypass npc_" + getObjectId() + "_editschemes ", groupType, " ", schemeName, " ", page - 1, "\">Previous</a></td>");
        }
        else
            StringUtil.append(sb, "<td align=left width=70>Previous</td>");
        
        StringUtil.append(sb, "<td align=center width=100>Page ", page, "</td>");
        
        if (page < max)
        {
            if (singleSelection)
                StringUtil.append(sb, "<td align=right width=70><a action=\"bypass npc_" + getObjectId() + "_singlebuff ", groupType, " ", page + 1, "\">Next</a></td>");
            else
                StringUtil.append(sb, "<td align=right width=70><a action=\"bypass npc_" + getObjectId() + "_editschemes ", groupType, " ", schemeName, " ", page + 1, "\">Next</a></td>");
        }
        else
            StringUtil.append(sb, "<td align=right width=70>Next</td>");
        
        sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=280 height=1>");
        
        return sb.toString();
    }
    
    /**
     * @param player
     * @param groupType : The group of skills to select.
     * @param schemeName : The scheme to make check.
     * @param singleSelection : Indicate if it's single buff selection or not.
     * @return A {@link String} representing all groupTypes available. The group currently on selection isn't linkable.
     */
    private static String getTypesFrame(Player player, String groupType, String schemeName, boolean singleSelection)
    {
        final StringBuilder sb = new StringBuilder(500);
        sb.append("<table>");
        
        int count = 0;
        for (String type : BufferManager.getInstance().getSkillTypes())
        {
            if (player.getPremiumService() == 0)
            {
                if (JDevConfig.PREMIUM_BUFFS_CATEGORY.isEmpty())
                    continue;
            }
            
            if (count == 0)
                sb.append("<tr>");
            
            if (groupType.equalsIgnoreCase(type))
                StringUtil.append(sb, "<td width=65>", type, "</td>");
            else
            {
                if (singleSelection)
                    StringUtil.append(sb, "<td width=65><a action=\"bypass npc_%objectId%_singlebuff ", type, " 1\">", type, "</a></td>");
                else
                    StringUtil.append(sb, "<td width=65><a action=\"bypass npc_%objectId%_editschemes ", type, " ", schemeName, " 1\">", type, "</a></td>");
            }
            
            count++;
            if (count == 4)
            {
                sb.append("</tr>");
                count = 0;
            }
        }
        
        if (!sb.toString().endsWith("</tr>"))
            sb.append("</tr>");
        
        sb.append("</table>");
        
        return sb.toString();
    }
    
    /**
     * @param list : A {@link List} of skill ids.
     * @return a global fee for all skills contained in the {@link List}.
     */
    private static int getFee(List<L2Skill> list)
    {
        if (Config.BUFFER_STATIC_BUFF_COST > 0)
            return list.size() * Config.BUFFER_STATIC_BUFF_COST;
        
        int fee = 0;
        for (L2Skill sk : list)
            fee += BufferManager.getInstance().getAvailableBuff(sk).getPrice();
        
        return fee;
    }
    
    private static void premiumSkills(Player player, List<L2Skill> skills)
    {
        if (player.getPremiumService() == 0)
            skills.removeIf(skill -> JDevConfig.BUFFS_CATEGORY.contains(BufferManager.getInstance().getAvailableBuff(skill).getType()));
    }
    
    public static String getIconForBufferId(int skillId)
    {
        if (skillId == 4702)
        {
            return "icon.skill1332";
        }
        else if (skillId == 4703)
        {
            return "icon.skill1332";
        }
        else if (skillId == 4551)
        {
            return "icon.skill1164";
        }
        else if (skillId == 4552)
        {
            return "icon.skill1164";
        }
        else if (skillId == 4553)
        {
            return "icon.skill1164";
        }
        else if (skillId == 4554)
        {
            return "icon.skill1164";
        }
        else if (skillId == 4700)
        {
            return "icon.skill1331";
        }
        else if (skillId == 4699)
        {
            return "icon.skill1331";
        }
        else
        {
            return (skillId < 10) ? "icon.skill000" + skillId : (skillId < 100) ? "icon.skill00" + skillId : (skillId < 1000) ? "icon.skill0" + skillId : "icon.skill" + skillId;
        }
    }
}

Where and what i change to see casting effect on buffs?

1 minute ago, xristoeli1994 said:

package net.sf.l2j.gameserver.model.actor.instance;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

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

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.data.SkillTable;
import net.sf.l2j.gameserver.data.manager.BufferManager;
import net.sf.l2j.gameserver.data.manager.BufferManager.BufferSchemeType;
import net.sf.l2j.gameserver.dev.config.JDevConfig;
import net.sf.l2j.gameserver.model.actor.Creature;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.model.actor.Summon;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.skills.L2Skill;

public class SchemeBuffer extends Folk
{
    private static final int PAGE_LIMIT = 6;
    
    public SchemeBuffer(int objectId, NpcTemplate template)
    {
        super(objectId, template);
    }
    
    @Override
    public void onBypassFeedback(Player player, String command)
    {
        StringTokenizer st = new StringTokenizer(command, " ");
        String currentCommand = st.nextToken();
        
        if (currentCommand.startsWith("menu"))
        {
            final NpcHtmlMessage html = new NpcHtmlMessage(0);
            html.setFile(getHtmlPath(getNpcId(), 0));
            html.replace("%objectId%", getObjectId());
            html.replace("%count%", player.getBuffCount() + " / " + player.getMaxBuffCount());
            player.sendPacket(html);
        }
        else if (currentCommand.startsWith("cleanup"))
        {
            player.stopAllEffectsExceptThoseThatLastThroughDeath();
            
            final Summon summon = player.getSummon();
            if (summon != null)
                summon.stopAllEffectsExceptThoseThatLastThroughDeath();
            
            player.getCubicList().stopCubics(true);
            
            final NpcHtmlMessage html = new NpcHtmlMessage(0);
            html.setFile(getHtmlPath(getNpcId(), 0));
            html.replace("%count%", player.getBuffCount() + " / " + player.getMaxBuffCount());
            html.replace("%objectId%", getObjectId());
            player.sendPacket(html);
        }
        if (currentCommand.equalsIgnoreCase("buffer_custom"))
        {
            int buffid = 0;
            String nextWindow = null;
            
            if (st.countTokens() == 2)
            {
                buffid = Integer.valueOf(st.nextToken());
                nextWindow = st.nextToken();
            }
            else if (st.countTokens() == 1)
                buffid = Integer.valueOf(st.nextToken());
            
            if (buffid != 0)
            {
                
                L2Skill skill = SkillTable.getInstance().getInfo(buffid, SkillTable.getInstance().getMaxLevel(buffid));
                if (skill != null)
                    skill.getEffects(player, player);
                
                player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(buffid, SkillTable.getInstance().getMaxLevel(buffid)));
                showChatWindow(player, nextWindow);
            }
        }
        else if (currentCommand.startsWith("heal"))
        {
            player.getStatus().setMaxCpHpMp();
            
            final Summon summon = player.getSummon();
            if (summon != null)
                summon.getStatus().setMaxHpMp();
            
            final NpcHtmlMessage html = new NpcHtmlMessage(0);
            html.setFile(getHtmlPath(getNpcId(), 0));
            html.replace("%objectId%", getObjectId());
            html.replace("%count%", player.getBuffCount() + " / " + player.getMaxBuffCount());
            player.sendPacket(html);
        }
        else if (currentCommand.startsWith("support"))
            showGiveBuffsWindow(player);
        else if (currentCommand.startsWith("getscheme"))
            BufferManager.getInstance().getSchemeSkills(BufferSchemeType.valueOf(st.nextToken().toUpperCase())).forEach(buffId -> getEffect(player, buffId));
        else if (currentCommand.startsWith("getbuff"))
        {
            final int skillId = Integer.parseInt(st.nextToken());
            final int skillLevel = Integer.parseInt(st.nextToken());
            List<L2Skill> list = new ArrayList<>();
            list.add(SkillTable.getInstance().getInfo(skillId, skillLevel));
            int cost = getFee(list);
            if (cost == 0 || player.reduceAdena("NPC Buffer", cost, this, true))
                list.forEach(buffId -> getEffect(player, buffId));
        }
        else if (currentCommand.startsWith("singlebuff"))
            showSingleBuffSelectionWindow(player, st.nextToken(), Integer.parseInt(st.nextToken()));
        else if (currentCommand.startsWith("givebuffs"))
        {
            final String schemeName = st.nextToken();
            final int cost = Integer.parseInt(st.nextToken());
            
            Creature target = null;
            if (st.hasMoreTokens())
            {
                final String targetType = st.nextToken();
                if (targetType != null && targetType.equalsIgnoreCase("pet"))
                    target = player.getSummon();
            }
            else
                target = player;
            
            if (target == null)
                player.sendMessage("You don't have a pet.");
            else if (cost == 0 || player.reduceAdena("NPC Buffer", cost, this, true))
                BufferManager.getInstance().applySchemeEffects(this, target, player.getObjectId(), schemeName);
        }
        else if (currentCommand.startsWith("editschemes"))
            showEditSchemeWindow(player, st.nextToken(), st.nextToken(), Integer.parseInt(st.nextToken()));
        else if (currentCommand.startsWith("skill"))
        {
            final String groupType = st.nextToken();
            final String schemeName = st.nextToken();
            
            final int skillId = Integer.parseInt(st.nextToken());
            final int skillLevel = Integer.parseInt(st.nextToken());
            final int page = Integer.parseInt(st.nextToken());
            
            L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLevel);
            final List<L2Skill> skills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
            premiumSkills(player, skills);
            if (currentCommand.startsWith("skillselect") && !schemeName.equalsIgnoreCase("none"))
            {
                if (skills.size() < player.getMaxBuffCount())
                    skills.add(skill);
                else
                    player.sendMessage("This scheme has reached the maximum amount of buffs.");
            }
            else if (currentCommand.startsWith("skillunselect"))
                skills.remove(skill);
            
            showEditSchemeWindow(player, groupType, schemeName, page);
        }
        else if (currentCommand.startsWith("createscheme"))
        {
            try
            {
                final String schemeName = st.nextToken();
                if (schemeName.length() > 14)
                {
                    player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
                    return;
                }
                
                final Map<String, ArrayList<L2Skill>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
                if (schemes != null)
                {
                    if (schemes.size() == Config.BUFFER_MAX_SCHEMES)
                    {
                        player.sendMessage("Maximum schemes amount is already reached.");
                        return;
                    }
                    
                    if (schemes.containsKey(schemeName))
                    {
                        player.sendMessage("The scheme name already exists.");
                        return;
                    }
                }
                
                BufferManager.getInstance().setScheme(player.getObjectId(), schemeName.trim(), new ArrayList<>());
                showGiveBuffsWindow(player);
            }
            catch (Exception e)
            {
                player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
            }
        }
        else if (currentCommand.startsWith("deletescheme"))
        {
            try
            {
                final String schemeName = st.nextToken();
                final Map<String, ArrayList<L2Skill>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
                
                if (schemes != null && schemes.containsKey(schemeName))
                    schemes.remove(schemeName);
            }
            catch (Exception e)
            {
                player.sendMessage("This scheme name is invalid.");
            }
            showGiveBuffsWindow(player);
        }
        
        super.onBypassFeedback(player, command);
    }
    
    private void getEffect(Player player, L2Skill buff)
    {
        buff.getEffects(this, player);
    }
    
    @Override
    public String getHtmlPath(int npcId, int val)
    {
        String filename = "";
        if (val == 0)
            filename = "" + npcId;
        else
            filename = npcId + "-" + val;
        
        return "data/html/mods/buffer/" + filename + ".htm";
    }
    
    /**
     * Send an html packet to the {@link Player} set a parameter with Give Buffs menu info for player and pet, depending on targetType parameter {player, pet}.
     * @param player : The {@link Player} to make checks on.
     */
    private void showGiveBuffsWindow(Player player)
    {
        final StringBuilder sb = new StringBuilder(200);
        
        final Map<String, ArrayList<L2Skill>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
        if (schemes == null || schemes.isEmpty())
            sb.append("<font color=\"LEVEL\">You haven't defined any scheme.</font>");
        else
        {
            for (Map.Entry<String, ArrayList<L2Skill>> scheme : schemes.entrySet())
            {
                final int cost = getFee(scheme.getValue());
                StringUtil.append(sb, "<font color=\"LEVEL\">", scheme.getKey(), " [", scheme.getValue().size(), " / ", player.getMaxBuffCount(), "]", ((cost > 0) ? " - cost: " + StringUtil.formatNumber(cost) : ""), "</font><br1>");
                StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_givebuffs ", scheme.getKey(), " ", cost, "\">Use on Me</a>&nbsp;|&nbsp;");
                StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_givebuffs ", scheme.getKey(), " ", cost, " pet\">Use on Pet</a>&nbsp;|&nbsp;");
                StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_editschemes Buffs ", scheme.getKey(), " 1\">Edit</a>&nbsp;|&nbsp;");
                StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_deletescheme ", scheme.getKey(), "\">Delete</a><br>");
            }
        }
        
        final NpcHtmlMessage html = new NpcHtmlMessage(0);
        html.setFile(getHtmlPath(getNpcId(), 1));
        html.replace("%schemes%", sb.toString());
        html.replace("%max_schemes%", Config.BUFFER_MAX_SCHEMES);
        html.replace("%count%", player.getBuffCount() + " / " + player.getMaxBuffCount());
        html.replace("%objectId%", getObjectId());
        player.sendPacket(html);
    }
    
    /**
     * Send an html packet to the {@link Player} set as parameter with Edit Scheme Menu info. This allows the {@link Player} to edit each created scheme (add/delete skills)
     * @param player : The {@link Player} to make checks on.
     * @param groupType : The group of skills to select.
     * @param schemeName : The scheme to make check.
     * @param page : The current checked page.
     */
    private void showEditSchemeWindow(Player player, String groupType, String schemeName, int page)
    {
        final NpcHtmlMessage html = new NpcHtmlMessage(0);
        final List<L2Skill> schemeSkills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
        premiumSkills(player, schemeSkills);
        html.setFile(getHtmlPath(getNpcId(), 2));
        html.replace("%schemename%", schemeName);
        html.replace("%count%", schemeSkills.size() + " / " + player.getMaxBuffCount());
        html.replace("%typesframe%", getTypesFrame(player, groupType, schemeName, false));
        html.replace("%skilllistframe%", getGroupSkillList(player, groupType, schemeName, false, page));
        html.replace("%objectId%", getObjectId());
        player.sendPacket(html);
    }
    
    private void showSingleBuffSelectionWindow(Player player, String groupType, int page)
    {
        final NpcHtmlMessage html = new NpcHtmlMessage(0);
        html.setFile(getHtmlPath(getNpcId(), 3));
        html.replace("%typesframe%", getTypesFrame(player, groupType, "", true));
        html.replace("%skilllistframe%", getGroupSkillList(player, groupType, "", true, page));
        html.replace("%objectId%", getObjectId());
        player.sendPacket(html);
    }
    
    /**
     * @param player : The {@link Player} to make checks on.
     * @param groupType : The group of skills to select.
     * @param schemeName : The scheme to make check.
     * @param singleSelection : Indicate if it's single buff selection or not.
     * @param page : The current checked page.
     * @return A {@link String} representing skills available for selection for a given groupType.
     */
    private String getGroupSkillList(Player player, String groupType, String schemeName, boolean singleSelection, int page)
    {
        // Retrieve the entire skills list based on group type.
        List<L2Skill> skills = BufferManager.getInstance().getSkillsIdsByType(groupType);
        
        premiumSkills(player, skills);
        
        if (skills.isEmpty())
            return "That group doesn't contain any skills.";
        
        // Calculate page number.
        final int max = MathUtil.countPagesNumber(skills.size(), PAGE_LIMIT);
        if (page > max)
            page = max;
        
        // Cut skills list up to page number.
        skills = skills.subList((page - 1) * PAGE_LIMIT, Math.min(page * PAGE_LIMIT, skills.size()));
        
        final List<L2Skill> schemeSkills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
        final StringBuilder sb = new StringBuilder(skills.size() * 150);
        
        int row = 0;
        for (L2Skill skill : skills)
        {
            int skillId = skill.getId();
            int skillLevel = skill.getLevel();
            
            sb.append(((row % 2) == 0 ? "<table width=\"280\" bgcolor=\"000000\"><tr>" : "<table width=\"280\"><tr>"));
            
            if (singleSelection)
                StringUtil.append(sb, "<td height=40 width=40><button action=\"bypass npc_" + getObjectId() + "_getbuff ", skillId, " ", skillLevel, " ", "\" width=32 height=32 back=\"", getIconForBufferId(skillId), "\" fore=\"", getIconForBufferId(skillId), "\" /></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferManager.getInstance().getAvailableBuff(skill).getDescription(), "</font></td>");
            else
            {
                if (schemeSkills.contains(skill))
                    StringUtil.append(sb, "<td height=40 width=40><img src=\"", getIconForBufferId(skillId), "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferManager.getInstance().getAvailableBuff(skill).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillunselect ", groupType, " ", schemeName, " ", skillId, " ", skillLevel, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomout2\" fore=\"L2UI_CH3.mapbutton_zoomout1\"></td>");
                else
                    StringUtil.append(sb, "<td height=40 width=40><img src=\"", getIconForBufferId(skillId), "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferManager.getInstance().getAvailableBuff(skill).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillselect ", groupType, " ", schemeName, " ", skillId, " ", skillLevel, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomin2\" fore=\"L2UI_CH3.mapbutton_zoomin1\"></td>");
            }
            
            sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=280 height=1>");
            row++;
        }
        
        for (int i = PAGE_LIMIT; i > row; i--)
            StringUtil.append(sb, "<img height=41>");
        
        // Build page footer.
        sb.append("<br><img src=\"L2UI.SquareGray\" width=280 height=1><table width=\"100%\" bgcolor=000000><tr>");
        
        if (page > 1)
        {
            if (singleSelection)
                StringUtil.append(sb, "<td align=left width=70><a action=\"bypass npc_" + getObjectId() + "_singlebuff ", groupType, " ", page - 1, "\">Previous</a></td>");
            else
                StringUtil.append(sb, "<td align=left width=70><a action=\"bypass npc_" + getObjectId() + "_editschemes ", groupType, " ", schemeName, " ", page - 1, "\">Previous</a></td>");
        }
        else
            StringUtil.append(sb, "<td align=left width=70>Previous</td>");
        
        StringUtil.append(sb, "<td align=center width=100>Page ", page, "</td>");
        
        if (page < max)
        {
            if (singleSelection)
                StringUtil.append(sb, "<td align=right width=70><a action=\"bypass npc_" + getObjectId() + "_singlebuff ", groupType, " ", page + 1, "\">Next</a></td>");
            else
                StringUtil.append(sb, "<td align=right width=70><a action=\"bypass npc_" + getObjectId() + "_editschemes ", groupType, " ", schemeName, " ", page + 1, "\">Next</a></td>");
        }
        else
            StringUtil.append(sb, "<td align=right width=70>Next</td>");
        
        sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=280 height=1>");
        
        return sb.toString();
    }
    
    /**
     * @param player
     * @param groupType : The group of skills to select.
     * @param schemeName : The scheme to make check.
     * @param singleSelection : Indicate if it's single buff selection or not.
     * @return A {@link String} representing all groupTypes available. The group currently on selection isn't linkable.
     */
    private static String getTypesFrame(Player player, String groupType, String schemeName, boolean singleSelection)
    {
        final StringBuilder sb = new StringBuilder(500);
        sb.append("<table>");
        
        int count = 0;
        for (String type : BufferManager.getInstance().getSkillTypes())
        {
            if (player.getPremiumService() == 0)
            {
                if (JDevConfig.PREMIUM_BUFFS_CATEGORY.isEmpty())
                    continue;
            }
            
            if (count == 0)
                sb.append("<tr>");
            
            if (groupType.equalsIgnoreCase(type))
                StringUtil.append(sb, "<td width=65>", type, "</td>");
            else
            {
                if (singleSelection)
                    StringUtil.append(sb, "<td width=65><a action=\"bypass npc_%objectId%_singlebuff ", type, " 1\">", type, "</a></td>");
                else
                    StringUtil.append(sb, "<td width=65><a action=\"bypass npc_%objectId%_editschemes ", type, " ", schemeName, " 1\">", type, "</a></td>");
            }
            
            count++;
            if (count == 4)
            {
                sb.append("</tr>");
                count = 0;
            }
        }
        
        if (!sb.toString().endsWith("</tr>"))
            sb.append("</tr>");
        
        sb.append("</table>");
        
        return sb.toString();
    }
    
    /**
     * @param list : A {@link List} of skill ids.
     * @return a global fee for all skills contained in the {@link List}.
     */
    private static int getFee(List<L2Skill> list)
    {
        if (Config.BUFFER_STATIC_BUFF_COST > 0)
            return list.size() * Config.BUFFER_STATIC_BUFF_COST;
        
        int fee = 0;
        for (L2Skill sk : list)
            fee += BufferManager.getInstance().getAvailableBuff(sk).getPrice();
        
        return fee;
    }
    
    private static void premiumSkills(Player player, List<L2Skill> skills)
    {
        if (player.getPremiumService() == 0)
            skills.removeIf(skill -> JDevConfig.BUFFS_CATEGORY.contains(BufferManager.getInstance().getAvailableBuff(skill).getType()));
    }
    
    public static String getIconForBufferId(int skillId)
    {
        if (skillId == 4702)
        {
            return "icon.skill1332";
        }
        else if (skillId == 4703)
        {
            return "icon.skill1332";
        }
        else if (skillId == 4551)
        {
            return "icon.skill1164";
        }
        else if (skillId == 4552)
        {
            return "icon.skill1164";
        }
        else if (skillId == 4553)
        {
            return "icon.skill1164";
        }
        else if (skillId == 4554)
        {
            return "icon.skill1164";
        }
        else if (skillId == 4700)
        {
            return "icon.skill1331";
        }
        else if (skillId == 4699)
        {
            return "icon.skill1331";
        }
        else
        {
            return (skillId < 10) ? "icon.skill000" + skillId : (skillId < 100) ? "icon.skill00" + skillId : (skillId < 1000) ? "icon.skill0" + skillId : "icon.skill" + skillId;
        }
    }
}

Where and what i change to see casting effect on buffs?

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • This update resaves 25_25 from the original (with sounds) (without the cave below) Some emitter fixes (removed waterfalls with high-poly meshes) The geodata is old, but it works Everything else is unchanged Download P.S. The effect files are taken from the high client for Interlude, so if you're experiencing critical skills, use the default ones for your Version.  
    • GX-Ext Which file of the svn files should i edit to make blow skills to have 100% chance so i can add the settings in the IlExt.ini? because when im changing it from the skilldata.txt it just helps
    • 我们感谢您的 反馈 并希望让服务变得更加 优秀! 如果您使用过我们的服务并愿意分享您的体验(任何体验——积极或建设性),请在Trustpilot上留下评价,并获得$1作为感谢。 链接: https://www.trustpilot.com/review/socnet.pro 如何获得奖励: 1. 前往Trustpilot并留下您的评价 2. 向我们发送发布确认截图,以及带有与评价用户名一致的授权账户截图。 3. 指定哪个商店应收到这 $1 奖励。根据商店不同,可能需要您的用户名/电子邮箱。 您的反馈帮助我们成长,并让项目对社区中的每一位成员变得更好。感谢您与我们同行! 条款: 此活动仅适用于一个唯一用户。不允许多账号行为。 项目有效链接: 数字商品商店(网站): 前往 商店 Telegram 机器人: 前往 – 通过 Telegram 方便访问商店。 虚拟号码服务: 前往 用于购买 Telegram Stars 的 Telegram 机器人: 前往 – 在 Telegram 中快捷且优惠地购买 Stars。 SMM 面板: 前往 – 推广您的社交媒体账户。 我们想向您展示当前的 促销和特别优惠列表 用于购买我们提供的产品与服务: 1. 您可在首次购买时使用优惠码:SOCNET(15% 折扣) 2. 获得 $1 商店余额或 10–20% 折扣——只需在我们网站注册后,按照模板填写您的用户名:“SEND ME BONUS, MY USERNAME IS...”并在我们的论坛主题中发布! 3. 首次启动 SMM 面板可获得 $1:只需在我们的网站(Support)提交主题为 “Get Trial Bonus” 的工单。 4. 我们的 Telegram 频道以及 Stars 购买机器人中每周都有 Telegram Stars 抽奖! 新闻: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • 我们感谢您的 反馈 并希望让服务变得更加 优秀! 如果您使用过我们的服务并愿意分享您的体验(任何体验——积极或建设性),请在Trustpilot上留下评价,并获得$1作为感谢。 链接: https://www.trustpilot.com/review/socnet.pro 如何获得奖励: 1. 前往Trustpilot并留下您的评价 2. 向我们发送发布确认截图,以及带有与评价用户名一致的授权账户截图。 3. 指定哪个商店应收到这 $1 奖励。根据商店不同,可能需要您的用户名/电子邮箱。 您的反馈帮助我们成长,并让项目对社区中的每一位成员变得更好。感谢您与我们同行! 条款: 此活动仅适用于一个唯一用户。不允许多账号行为。 项目有效链接: 数字商品商店(网站): 前往 商店 Telegram 机器人: 前往 – 通过 Telegram 方便访问商店。 虚拟号码服务: 前往 用于购买 Telegram Stars 的 Telegram 机器人: 前往 – 在 Telegram 中快捷且优惠地购买 Stars。 SMM 面板: 前往 – 推广您的社交媒体账户。 我们想向您展示当前的 促销和特别优惠列表 用于购买我们提供的产品与服务: 1. 您可在首次购买时使用优惠码:SOCNET(15% 折扣) 2. 获得 $1 商店余额或 10–20% 折扣——只需在我们网站注册后,按照模板填写您的用户名:“SEND ME BONUS, MY USERNAME IS...”并在我们的论坛主题中发布! 3. 首次启动 SMM 面板可获得 $1:只需在我们的网站(Support)提交主题为 “Get Trial Bonus” 的工单。 4. 我们的 Telegram 频道以及 Stars 购买机器人中每周都有 Telegram Stars 抽奖! 新闻: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • 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