Jump to content
  • 0

Assist reward pvp system


ThelwHelpRePaidia

Question

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));
		}
Link to comment
Share on other sites

Recommended Posts

  • 1
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
Link to comment
Share on other sites

  • 0

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

p.getPvpKills();

with this

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

 

Link to comment
Share on other sites

  • 0
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

Link to comment
Share on other sites

  • 0

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. 

Link to comment
Share on other sites

  • 0
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

Link to comment
Share on other sites

  • 0

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
Link to comment
Share on other sites

  • 0

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

 

Link to comment
Share on other sites

  • 0

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
Link to comment
Share on other sites

  • 0

@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
Link to comment
Share on other sites

  • 0
				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

Link to comment
Share on other sites

  • 0
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
Link to comment
Share on other sites

  • 0

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
Link to comment
Share on other sites

  • 0

@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
Link to comment
Share on other sites

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
Answer this question...

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



×
×
  • Create New...