Jump to content

Question

Posted

Hello i have a problem with this code i get no errors in eclipse but in game it doesnt work..

to Player.java

if (getParty() != null)
		{
			for (Player p : getParty().getMembers())
			{
				if (Config.Synergy_Class.contains(p.getClassId().getId()) && p.isInCombat() && (Rnd.get(100) <= 90))
				{
					p.sendMessage("You have earned a pvp by supporting " + target.getName());
					p.getPvpKills();
				}
			}
		}


and the config
  
  public static List<Integer> Synergy_Class = new ArrayList<>();


  	String Synergy_Class = customs.getProperty("ClassesSupp", "97");
		String[] atdc_splitted = Synergy_Class.split(",");
		for (String s : atdc_splitted)
		{
			Synergy_Class.add(Integer.valueOf(s));
		}

Recommended Posts

  • 1
Posted (edited)
1 hour ago, melron said:

@Evie Frye the guy didnt ask for new assist system but asked for a fix in this one (even if it is not good) so i answered to this one. Feel free to sell your services to him :D kisses 

 

Sell? Bitches, you're all my fans !

Index: java/com/l2evie/gameserver/model/Assist.java
===================================================================
--- java/com/l2evie/gameserver/model/Assist.java	(revision 0)
+++ java/com/l2evie/gameserver/model/Assist.java	(revision 0)
@@ -0,0 +1,36 @@
+package com.l2evie.gameserver.model;
+
+import com.l2evie.gameserver.model.actor.instance.L2PcInstance;
+
+public class Assist
+{
+	private final L2PcInstance _owner;
+	private int _totalHeal = 0;
+	private long _lastHeal = 0;
+	
+	public Assist(final L2PcInstance player)
+	{
+		_owner = player;
+	}
+	
+	public L2PcInstance getPlayer()
+	{
+		return _owner;
+	}
+	
+	public int getTotalHeal()
+	{
+		return _totalHeal;
+	}
+	
+	public long lastHeal()
+	{
+		return _lastHeal;
+	}
+	
+	public void addHealPoints(int points)
+	{
+		_lastHeal = System.currentTimeMillis();
+		_totalHeal =+ points;
+	}
+}
Index: java/com/l2evie/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2evie/gameserver/model/actor/instance/L2PcInstance.java	(revision 2)
+++ java/com/l2evie/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -98,6 +98,7 @@
 import com.l2evie.gameserver.instancemanager.TerritoryWarManager;
 import com.l2evie.gameserver.instancemanager.TownManager;
+import com.l2evie.gameserver.model.Assist;
 import com.l2evie.gameserver.model.BlockList;
 import com.l2evie.gameserver.model.CharEffectList;
 import com.l2evie.gameserver.model.CursedWeapon;
@@ -6108,9 +6109,24 @@

 		setPvpKills(getPvpKills() + 1);
+			
+		for (Assist assist : getAllAssist())
+		{
+			if (getParty() == null || assist.getPlayer() == null || assist.lastHeal() + (15 * 1000) <= System.currentTimeMillis())
+			{
+				removeAssist(assist);
+			}
+			else if (getParty().getPartyMembers().contains(assist.getPlayer()) && Util.calculateDistance(this, assist.getPlayer(), false) <= 1450)
+			{ 
+				assist.addHealPoints(0);
+				assist.getPlayer().setPvpKills(assist.getPlayer().getPvpKills() + 1);
+				assist.getPlayer().sendMessage("You received 1 pvp kill for assisting player " + getName());
+			}
+		}
+			
  	
 	public void waitSecs(final int i)
@@ -16559,4 +16575,21 @@
 	{
 		return _unlockable;
 	}
+	
+	private final HashMap<Integer, Assist> _assist = new HashMap<>();
+	
+	public Assist getAssist(int healerId)
+	{
+		return _assist.get(healerId) !=null ? _assist.get(healerId) : _assist.put(healerId, new Assist(L2World.getInstance().getPlayer(healerId)));
+	}
+	
+	public void removeAssist(final Assist assist)
+	{
+		_assist.remove(assist);
+	}
+	
+	public Collection<Assist> getAllAssist()
+	{
+		return _assist.values();
+	}
 }
\ No newline at end of file

Also in Heal.java or i dont know what other files exist. 

 

if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance)
{
	final L2Party party = ((L2PcInstance) activeChar).getParty();
			
	if (party !=null && party.getPartyMembers().contains(((L2PcInstance) target)))
	{
		if (((L2PcInstance) activeChar).isInCombat() && !((L2PcInstance) activeChar).getAttackByList().isEmpty() && !((L2PcInstance) activeChar).getAttackByList().contains(target))
		{
			((L2PcInstance) target).getAssist(activeChar.getObjectId()).addHealPoints((int) hp);
		}
	}
}

 

Ps its not tested or so. But just the idea. 

Edited by Evie Frye
  • 0
Posted

what this one supposed to do? Increase pvp in supporter class? if yes
replace
 

p.getPvpKills();

with this

p.setPvpKills(p.getPvpKills() +1);

 

  • 0
Posted
1 hour ago, ThelwHelpRePaidia said:

i've tried it but it doesnt work and like that  xD

then the location of your code is wrong or you do not meet the conditions. add debugs for each boolean for all these 'if' and check out whats going on

  • 0
Posted

How you expect people to help you? You don't provide any info just some fail coding. 

Where did you place the code? What are your configurations? Does the message appear ? Possibly you've added the code in wrong place

or you ignored the config and you haven't add your class ID in their. Or even worst the config is wrong and u just didn't see the error

because config errors appear upon server load which is barely visible. 

  • 0
Posted
3 minutes ago, Evie Frye said:

How you expect people to help you? You don't provide any info just some fail coding. 

Where did you place the code? What are your configurations? Does the message appear ? Possibly you've added the code in wrong place

or you ignored the config and you haven't add your class ID in their. Or even worst the config is wrong and u just didn't see the error

because config errors appear upon server load which is barely visible. 

holy shit

  • 0
Posted (edited)

1st im getting 0 errors on eclipse and on gameserver

2nd i dont get the message

3rd i placed the code here

public void onKillUpdatePvPKarma(Playable target)
	{
		if (target == null)
			return;
		
		final Player targetPlayer = target.getActingPlayer();
		if (targetPlayer == null || targetPlayer == this)
			return;
		
		// Don't rank up the CW if it was a summon.
		if (isCursedWeaponEquipped() && target instanceof Player)
		{
			CursedWeaponsManager.getInstance().increaseKills(_cursedWeaponEquippedId);
			return;
		}
		
		// If in duel and you kill (only can kill l2summon), do nothing
		if (isInDuel() && targetPlayer.isInDuel())
			return;
		
		if (EventManager.getInstance().isRunning() && EventManager.getInstance().isRegistered(this) && EventManager.getInstance().isRegistered(targetPlayer))
			return;
		
		if (getParty() != null)
		{
			for (Player player : getParty().getMembers())
			{
				if (Config.Synergy_Class.contains(player.getClassId().getId()) && player.isInCombat() && (Rnd.get(100) <= 90))
				{
					player.sendMessage("You have earned a pvp by supporting " + target.getName());
					player.setPvpKills(player.getPvpKills() + 1);
				}
			}
		}
		// If in pvp zone, do nothing.
		if (isInsideZone(ZoneId.PVP) && targetPlayer.isInsideZone(ZoneId.PVP))
		{
			// Until the zone was a siege zone. Check also if victim was a player. Randomers aren't counted.
			if (target instanceof Player && getSiegeState() > 0 && targetPlayer.getSiegeState() > 0 && getSiegeState() != targetPlayer.getSiegeState())
			{
				// Now check clan relations.
				final Clan killerClan = getClan();
				if (killerClan != null)
					killerClan.setSiegeKills(killerClan.getSiegeKills() + 1);
				
				final Clan targetClan = targetPlayer.getClan();
				if (targetClan != null)
					targetClan.setSiegeDeaths(targetClan.getSiegeDeaths() + 1);
			}
			return;
		}

 

Edited by ThelwHelpRePaidia
  • 0
Posted

Try add the code after this: 

  // Check if it's pvp (cases : regular, wars, victim is PKer)
  if (checkIfPvP(target) || (targetPlayer.getClan() != null && getClan() != null && getClan().isAtWarWith(targetPlayer.getClanId()) && targetPlayer.getClan().isAtWarWith(getClanId()) && targetPlayer.getPledgeType() != Clan.SUBUNIT_ACADEMY && getPledgeType() != Clan.SUBUNIT_ACADEMY) || (targetPlayer.getKarma() > 0 && Config.KARMA_AWARD_PK_KILL))
  {
   if (target instanceof Player)
   {

        //here

 

  • 0
Posted (edited)

How many times did you test it? I mean how many kills did you got?

 

As you didnt understood my last suggestion i will explain you:

 

You have to meet 4 conditions in order the party member to get pvp point too.

 

  • Be in party
  • Config got the user class id
  • user is in combat
  • And 90% chance.

 

Are you sure for all these conditions ?

 

Why you do not simply add debugs to check it?

 

if (getParty() != null)
{
	for (Player player : getParty().getMembers())
	{
		final int rnd = Rnd.get(100);
		System.out.println("Checking for " + player.getName() + " Conditions...");
		System.out.println(Config.Synergy_Class.contains(player.getClassId().getId()) ? "Config missing player's class ID!" : " Config got player's ID!");
		System.out.println(player.isInCombat() ? " Player is in combat!" : " Player is not in combat!");
		System.out.println(rnd <= 90 ? " Chance is OK!" : " Chance is not OK! ( " + rnd + "");
		System.out.println(Config.Synergy_Class.contains(player.getClassId().getId()) && player.isInCombat() && (rnd <= 90) ? " Reward can be given!" : " Cannot give the reward!");
		if (Config.Synergy_Class.contains(player.getClassId().getId()) && player.isInCombat() && (rnd <= 90))
		{
			player.sendMessage("You have earned a pvp by supporting " + target.getName());
			player.setPvpKills(player.getPvpKills() + 1);
		}
	}
}
else
	System.out.println("No party found.");

 

Edited by melron
  • 0
Posted (edited)

@melron it's working like this but im getting something that it seems weird i dont get +1 pvp i get the pvps that my party mate has if he has 551 and me 0 if he gets pvp i will go 552

 

Party party = getParty();
				
				if (party != null)
				{
					for (Player partymate : party.getMembers())
					{
						if (partymate == null)
							continue;
						
						if (partymate.getClassId().getId() == 97 && partymate.isInCombat() && partymate.getPvpFlag() > 0)
						{
							if (partymate.isInsideRadius(this, 1100, false, false))
							{
								if (Rnd.nextInt(100) < 100)
								{
									partymate.setPvpKills(partymate.getPvpKills() + 1);
									break;
								}
							}
						}
					}
				}
				
					
					// Add PvP point to attacker.
					setPvpKills(getPvpKills() + 1);

 

Edited by ThelwHelpRePaidia
  • 0
Posted
				for(Player member : getParty().getMembers())
				{
					if(member != null)
					{
						if(member.getClassId().getId() == 97 && member.isInCombat() && member.isInsideRadius(this, 1100, false, false) && Rnd.nextInt(100) < 100)
						{
							setPvpKills(getPvpKills() + 1);
						}
					}
				}

i dont know if help this

  • 0
Posted (edited)
3 hours ago, ThelwHelpRePaidia said:

@melron it's working like this but im getting something that it seems weird i dont get +1 pvp i get the pvps that my party mate has if he has 551 and me 0 if he gets pvp i will go 552

 

 

 

  • Check the method setPvpKills and getPvpKills maybe you forgot to delete some custom things inside
  • Add a check for same player like 
if (partymate == this)
     continue;
  • Remove break, you dont need this

 

about the pvp value issue, probably when you compiled your code was like this

 

if (Rnd.nextInt(100) < 100)
{
	partymate.setPvpKills(getPvpKills() + 1);
	break;
}

 

Edited by melron
  • 0
Posted (edited)

Holy shit with these answers.

 

I imagine Melron and Tazerman in a group of superheroes fighting against stackoverflow bad guys! This would be more epic than Avengers which is coming in 2 months. Speaking of assist. You must make it a bit more "comblex" in order to work properly. Example each player must have a holder of the healerId (the objectId of person who healed it) & the heal ammount. Upon kill it must check the healAmmount if > than Rnd(X) and if the objectId (healer) is still in range to give him +1 pvp. 

so basically a

private final HashMap<Integer, Long> _healerData = new HashMap<>():
  
public HashMap<Integer, Long> getHealerData()
{
  return _healerData;
}
  
public void addHeal(int objectId, long heal)
{
 	if (_healerData.containsKey(objectId))
  	{
   		_healerData.put(objectId, _healerData.get(objectId) + heal);
  	}
  	else
  	{
  		_healerData.put(objectId, heal);
  	}
}

at Heal.java do something

if (target instanceof L2PcInstance && target.getParty() !=null && target.getParty().containMember(activeChar)
{
 	((L2PcInstance) target).addHeal(activeChar.getObjectId(), healAmmount);
}

and in increasePvPKills() method reset the data for > X ammounts of heal and give reward.

 

All these.. Rnd and Rnd its amateur and useless. If you want to make a assist system at least make it properly. Consider the code i also wrote is fail by default cause mostly i didn't even sit to think about it + i didn't open intellij but just to give you the idea of how not properly working is the code you post.

Edited by Evie Frye
  • 0
Posted (edited)

@Evie Frye the guy didnt ask for new assist system but asked for a fix in this one (even if it is not good) so i answered to this one. Feel free to sell your services to him :D kisses 

Edited by melron

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

    • Do you sell interlude interfaces?
    • in conclusion when somebody who has a project for 10+ years still on development writes an e-say to try until you succeed and then advertises his project, one of the reasons is he needs money, so l2j has once more become pure expensive hobby, you wont make money out of it.   You can still use L2jFrozen and get better results for this, i know some people that done it    keep in mind that C in aCis stands for Crappy, and after all these years its not a cool wordplay anymore, its a fact, prove me wrong.
    • First, don't really follow the "main voice", moreover if you consider it an hobby. Simply do what you want, you got only one life so use it as you want. If you make it an hobby, it's exactly like piano, or velo - only practice makes you better.   Secondly, how do you learn things ? It's actually a really important question, since some can simply be scholar, read books (theory) then practice ; and some simply can't read books. I'm the second type, I hated school, I find it boring - my knowledge in Java comes from try-and-fail. You improve your coding style every year or so, I can myself rewrite my own code (which I already considered top-notched) after a while. You always learn something new - even if Java barely evolves. L2J is a fun way to learn programming, it's a giant sandbox where you can edit anything, and I believe it should be taken as it.   My own way of learning was as follow : Add existing customs, no matter what they are : the point is to know main classes used by L2J / customs. L2J is barely Java knowledge ; the true knowledge is to know WHAT to search in WHICH location (what I call, organization). You have to understand than EVERYTHING you think already exists, in a form on another, in the source code. A custom is only the association of the different mechanisms you found "here and there", glued together in a proper goal. Once you know main classes to edit, and the customs you added are compiling fine, the main point is to know WHAT exactly you DID. Try to understand WHY and WHERE you actually copied the code. Third point would be to MANIPULATE the customs you added in order to fit your wish. First edit little values, then logic conditions ; eventually add a new Config, or a new functionality to the custom. Fourth point would be to begin to craft your own ideas. Once again, EVERYTHING already exists, in a form or another. You want a cycled event ? You got Seven Signs main task as exemple. Npc ? Search any type of Npc and figure out what it does. Fifth point would be to understand Java - mostly containers (WHAT and WHERE to use them), variables types and main Java mechanisms (inheritance, static modifier, etc). You should also begin to cut your code into maintainable classes or methods. Java can actually run without optimization, but bigger your ideas, more optimized and well-thought it should be. It's direct saved time in the future, and you would thank yourself doing so. Main tips : ALWAYS use any type of versioning system - GIT or SVN. It allows to save your work, step by step and eventually revert back anytime you want if you terribly messed up. L2J is 80% organization knowledge, and 20% Java knowledge. Basically, if you know WHAT and WHERE to search, if you aren't dumb, it's easy to replicate and re-use things. Cherry on top is to use a already good coded pack to avoid copy-paste crap and get bad habits. Avoid any type of russian or brazilian packs, for exemple - their best ability is to leak someone's else code. Obviously you need some default sense of logic, but Java and programming in general help you to improve it.   Finally, most of your questions could be solved joining related Discord (at least for aCis, I can't speak for others) - from the moment your question was correctly asked (and you seemed to search for the answer). My community (and myself) welcomes newbies, but got some issues with noobies.   The simpliest is to try, fail and repeat until you succeed - it sounds stupid, but that's basically how life works.   PS : about Java ressources, before ChatGPT, it was mostly about stackoverflow website, and site like Baeldung's one. With ChatGPT and alike, you generally double-cross AI output to avoid fucked up answers. Also, care about AI, they are often hallucinating really hard, even today. They can give you complete wrong answer, you tell them they are wrong, and they say "indeed, I suck, sorry - here's a new fucked up answer". You shouldn't 100% rely over AI answer, even if that can give sometimes legit answers, full code or just skeletons of ideas.   PPS : I don't think there are reliable ressources regarding L2J itself, also most of the proposed code decays pretty fast if the source code is actually maintained (at least for aCis). Still, old coded customs for old aCis sources are actually a good beginner challenge to apply on latest source.
  • 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