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...

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

    • Creature EnterWorld Invalid NPC or spawn entry.
    • 10-15-2025 - OUR TOPIC IS RELEVANT! CONTACT US BY THE CONTACTS BELOW
    • SELLING EMPTY TELEGRAM BOTS WITH AGE Registration date: November 2024 High-quality & clean bots — no subscribers, no bans, created on fresh IPs. y rested and reliable — perfect for: — Telegram search ranking — any technical or marketing tasks Delivery options: tdata, by phone number, ownership transfer, or via tokens. Current price list: From 3 pcs — $3 each From 20 pcs — $2.5 each From 60 pcs — $2.3 each From 100 pcs — $2.2 each From 400 pcs — $1.9 each Over 15,000+ bots available — ready for instant delivery. Contact on Telegram: @SMMTG6
    • Telegram Bot TOP Search Promotion | SEO Optimization for Bots | SMMTG.PRO We promote Telegram bots to the TOP of search results — by keywords, topics, and countries. What’s included: • Promotion to the TOP of Telegram search • Bot optimization for Telegram algorithms • Competitor analysis and keyword selection • Testing and securing stable ranking Delivery time: 2–3 days per bot Pricing: Starts from $40 per bot (final cost depends on competition level and target country) We work with 50+ countries: Russia • Ukraine • USA • Israel • Uzbekistan • Turkey • China • Thailand • Europe • India Training is also available: Telegram bot SEO optimization Techniques & insights for reaching TOP search positions Real-world cases and recommendations Contact: Telegram — @SMMTG6 Our SMM panel: SMMTG.PRO
    • SMMTG.PRO — TELEGRAM SERVICES PROVIDER PRICE LIST ★ Premium Subscribers for Bots Russia — from $5.6 / 1,000 subs Ukraine — from $5.6 / 1,000 subs USA — from $6.4 / 1,000 subs Israel — from $6.4 / 1,000 subs Uzbekistan — from $6.4 / 1,000 subs Turkey — from $6.4 / 1,000 subs China — from $6.4 / 1,000 subs Thailand — from $6.4 / 1,000 subs Europe — from $6.4 / 1,000 subs India — from $6.4 / 1,000 subs Other countries — from $13 / 1,000 subs OTHER SERVICES Telegram Boost — from $42 / 1,000 votes Premium Subscribers for Channels — from $2.9 / 1,000 Telegram Stars — from $16.9 / 1,000 stars Regular Subscribers for Channels — from $0.19 / 1,000 Regular Subscribers for Bots — from $0.25 / 1,000 Post Reactions — from $0.14 / 1,000 reactions Post Views — from $0.07 / 1,000 views EXCLUSIVE SERVICES ★ Telegram Search TOP Ranking | SEO Optimization ★ Aged Telegram Bots (registered accounts) — from $1.9 / bot ★ Telegram SEO & Search Training PAYMENT METHODS Heleket — any cryptocurrency CrystalPay — RUB | KZT | SBP | CryptoBot & more Payeer — multiple payment options ➤ Website (24/7): SMMTG.PRO ➤ Telegram Channel: t.me/+e_DKWnC5AFw0ZDhi ➤ 24/7 Support: @SMMTG6
  • 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