Jump to content

Recommended Posts

Posted (edited)

Color name - title system + Skill Reward coded on 374 acis . cheers

 

package net.sf.l2j.gameserver.datatables;

import net.sf.l2j.gameserver.templates.L2Pvp;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import net.sf.l2j.gameserver.model.holder.IntIntHolder;
import net.sf.l2j.gameserver.templates.StatsSet;
import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory;
import org.w3c.dom.*;

public class PvpTable
{

    public PvpTable()
    {
    }
    
    public static void load()
    {
        try
        {
            File f = new File("./data/xml/pvp.xml");
            Document doc = XMLDocumentFactory.getInstance().loadDocument(f);
            Node n = doc.getFirstChild();
            for(Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
                if(d.getNodeName().equalsIgnoreCase("template"))
                {
                    NamedNodeMap attrs = d.getAttributes();
                    int pvpAmount = Integer.valueOf(attrs.getNamedItem("pvp_amount").getNodeValue()).intValue();
                    int nameColor = Integer.decode((new StringBuilder()).append("0x").append(attrs.getNamedItem("name_color").getNodeValue()).toString()).intValue();
                    int titleColor = Integer.decode((new StringBuilder()).append("0x").append(attrs.getNamedItem("title_color").getNodeValue()).toString()).intValue();
                    String learnSkill = attrs.getNamedItem("learn_skill").getNodeValue().trim();
                    StatsSet set = new StatsSet();
                    set.set("pvp_amount", pvpAmount);
                    set.set("name_color", nameColor);
                    set.set("title_color", titleColor);
                    L2Pvp template = new L2Pvp(set);
                    if(learnSkill != null)
                    {
                        String property[] = learnSkill.split(";");
                        String as[] = property;
                        int i = as.length;
                        for(int j = 0; j < i; j++)
                        {
                            String data = as[j];
                            String holder[] = data.split(",");
                            template.addLearnSkill(new IntIntHolder(Integer.parseInt(holder[0]), Integer.parseInt(holder[1])));
                        }

                    }
                    _templates.add(template);
                }

        }
        catch(Exception e)
        {
            _log.severe((new StringBuilder()).append("Exception: PvpTable load: ").append(e).toString());
        }
        _log.info((new StringBuilder()).append("PvpTable: Loaded ").append(_templates.size()).append(" template(s).").toString());
    }

    public static List<L2Pvp> getTemplate()
    {
        return _templates;
    }

    private static final Logger _log = Logger.getLogger(PvpTable.class.getName());
    private static final List<L2Pvp> _templates = new ArrayList<>();

}

 

 

 

package net.sf.l2j.gameserver.templates;

import java.util.ArrayList;
import java.util.List;
import net.sf.l2j.gameserver.model.holder.IntIntHolder;
import net.sf.l2j.gameserver.templates.StatsSet;

public class L2Pvp
{

    public L2Pvp(StatsSet set)
    {
        _pvpAmount = set.getInteger("pvp_amount");
        _nameColor = set.getInteger("name_color");
        _titleColor = set.getInteger("title_color");
    }

    public int getPvpAmount()
    {
        return _pvpAmount;
    }

    public int getNameColor()
    {
        return _nameColor;
    }

    public int getTitleColor()
    {
        return _titleColor;
    }

    public List<IntIntHolder> getLearnSkills()
    {
        return _learnSkill;
    }

    public void addLearnSkill(IntIntHolder holder)
    {
        _learnSkill.add(holder);
    }

    private final int _pvpAmount;
    private final int _nameColor;
    private final int _titleColor;
    private final List<IntIntHolder> _learnSkill = new ArrayList<>();
}

 

Open : Gameserver.java
add somewhere this PvpTable.load();

Open : Player.java
add somewhere this

    public static void updatePvp(Player player)
    {
        for(Iterator<L2Pvp> iterator = PvpTable.getTemplate().iterator(); iterator.hasNext();)
        {
            L2Pvp template = iterator.next();
            if(template.getPvpAmount() <= player.getPvpKills())
            {
                player.getAppearance().setNameColor(template.getNameColor());
                player.getAppearance().setTitleColor(template.getTitleColor());
                Iterator<IntIntHolder> iterator1 = template.getLearnSkills().iterator();
                while(iterator1.hasNext()) 
                {
                    IntIntHolder holder = iterator1.next();
                    net.sf.l2j.gameserver.model.L2Skill skill = SkillTable.getInstance().getInfo(holder.getId(), holder.getValue());
                    if(skill != null)
                        player.addSkill(skill, false);
                }
            }
        }

        player.broadcastUserInfo();
    }

find in Player.java
below this line setPvpKills(getPvpKills() + 1);  add ->  updatePvp(this);

find  : public boolean setActiveClass(int classIndex)
under this line  restoreSkills(); add - > updatePvp(this);

find : public void onPlayerEnter() add somewhere under : updatePvp(this);

XML

loc : data/xml/pvp.xml

<?xml version='1.0' encoding='utf-8'?>
<list>
	<!-- <template pvp_amount="100" name_color="FFAA00" title_color="FFFF77" learn_skill="0,0;" /> -->
		<template pvp_amount="5" name_color="FFAA00" title_color="FFFF77" learn_skill="0,0;" />
</list>

 

Edited by Kishin
  • Thanks 1
  • 4 months later...
  • 2 months later...
Posted

Wouldn't it be better to have a simple config location, where you would specify the different pvp's and pk's as follows?:

ExampleSystemPvPs = 300,00ff00;

300 is the amount of pvp's you need and then the colour in Hexa. This is what I've personally done to make it easier, rather than reading an XML code.

Posted (edited)
On 1/14/2020 at 1:47 AM, xFranky said:

Wouldn't it be better to have a simple config location, where you would specify the different pvp's and pk's as follows?:

ExampleSystemPvPs = 300,00ff00;

300 is the amount of pvp's you need and then the colour in Hexa. This is what I've personally done to make it easier, rather than reading an XML code.

why running the code all over than have it catched? though this one not just rewards color name or title but skill reward aswell , also its more readable than 123,ff0000;1234,ff01234

you can add and do w/e you want with the templates ->

<list>
       <template pvp_amount="50" name_color="FFAA00" title_color="FFFF00" learn_skill="0,0;" />
       <template pvp_amount="100" name_color="FF0000" title_color="FFAA00" learn_skill="2106,1;" />
       <template pvp_amount="150" name_color="FF0000" title_color="FFFFAA" learn_skill="0,0;" />
</list>

 

Edited by Kishin
Posted
11 hours ago, Kishin said:

why running the code all over than have it catched? though this one not just rewards color name or title but skill reward aswell , also its more readable than 123,ff0000;1234,ff01234

you can add and do w/e you want with the templates ->


<list>
       <template pvp_amount="50" name_color="FFAA00" title_color="FFFF77" learn_skill="0,0;" />
       <template pvp_amount="100" name_color="FF0000" title_color="FFAA00" learn_skill="2106,1;" />
       <template pvp_amount="100" name_color="FF00AA" title_color="FFAAAA" learn_skill="2107,1;" />
</list>

 

In my opinion, it takes extra time to read an extra XML file, rather than a config file that is read already, and adds extra space to the memory just to hold the data of the XML. Also, you could have separated the pvp kills with the name colours, and the PK kills with the title colours, and have your extra Skills. I do not believe that anyone would create a server for extra kills, just to make their character stronger and increase their penetration. You have to create extra skills for the characters, which requires l2 client knowledge in order to get this right. Finally, I believe that this could have happened a lot quicker and easier, with less lines of code, rather than doing it with the way you attempted. 

 

What I suggested is just an opinion and is not meant to judge you, or you as a programmer or your work. I believe you have done a great job bringing this code for the community and I hope I see more shares from you like this one. I will be releasing my personal version of this system, so you are welcome to judge me and suggest your own opinion.

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Hello, I'm working with custom Icons and noticed that you can use 64x64 icons and the client will handle them without problems in the Inventory and when you Drag them, they look HD so it's really cool, the problem starts when you move them to the shortcut bar, when they're placed there instead of rescaling the icon it just show the upper left corner (so it's 32x32 but showing only the part that fits in that space). I tried checking interface.u but can't find the line where the size for the icons in the shortcut bar are handled.   When in Inventory the item shows in a 32x32 size, if I use a 64x64 icon it re-scales so the icon looks great When dragging the item the image becomes 64x64 which looks pretty big, but it works good When placing the item in the shortcut bar only the top left of the icon is visible   Is there a way I can adjust the shortcut bar so that it re-scales the icon?
    • If you want to edit a large amount of entries in the L2 File-edit I recommend using excel, since both work with columns you can copy the entire file or just a few lines and paste it in excel and it will copy without problems, after you're done with editing you just select the cells and paste them in the .dat file making sure you're formatting correctly. I'm currently doing a massive edit on all gear and that's how i'm handling the .dat work
    • the logic is the "stacking" that is a filter if you use it then the item cannot co-exist (stack)
    • [Exclusive L2Gold Weekend Server] Available ONLY on Saturdays & Sundays – nowhere else, no other time ! Custom Armors (Dynasty, Apella) Custom Weapons (L2Gold Weapons) Custom Jewelry (L2Gold Jewelry) Custom Teleport System Custom AIO Buffer Custom Zones & NPCs Custom Raidboss … and much more waiting for you every weekend! This is not just another private server – it’s a limited-time battleground. When the weekend comes, everyone gathers in one place for the ultimate L2 experience. 👉 Online: Saturday–Sunday only 👉 Contact / Info: [https://www.facebook.com/profile.php?id=61578869175323]
    • ⏳ The price drops like sand slipping down in an hourglass.   📉 USA numbers are already at the lowest 💸 🌍 Next in line: Europe, Asia, and dozens of other countries.     All next week we’ll be actively working on lowering prices. The process has already started  soon costs will be much cheaper. 🔥 Get ready: the price drop will affect every country!   Website link — https://vibe-sms.net/ Our Telegram channel — https://t.me/vibe_sms
  • 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