Jump to content
  • 0

[Help] pvp for all players in party


Question

Posted

Hello.

I would like to do the trick on the server, for everyone in the party got a pvp point when one of them kills the player.

 

Starting in L2PcInstance under  this line --> "public boolean doDie(L2Character killer)"

and if yes how to check if player is in range?

8 answers to this question

Recommended Posts

  • 0
Posted

like that?

Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(revision 286)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -5955,6 +5955,26 @@

		if (killer != null)
		{
+			if(killer instanceof L2PcInstance)
+			{
+				L2Party party = killer.getParty();
+				if (party != null)
+				{
+					for(L2PcInstance PartyMember : party.getPartyMembers())
+					{
+						if(PartyMember.isInsideRadius(this, 1000, true, false) && PartyMember != killer)
+						{
+							PartyMember.setPvpKills(PartyMember.getPvpKills() + 1);
+							
+						}
+					}
+				}
+			}
+			
			//Bugfix pet killers
			if(killer instanceof L2SummonInstance)
			{


  • 0
Posted

is working but pvp points for party member appear when log out and log in not in real time,

 

i have thinking something about fame

 

now have this in L2PcInstance

 

			

		if (killer instanceof L2PcInstance && getPvpFlag() > 0)
					{
					   L2PcInstance kill = (L2PcInstance) killer;
					   int pointsToAdd = (int) (_fame*0.10);
					   int pointsToRemove = _fame - pointsToAdd < 0 ? 0 : _fame - pointsToAdd;
					   kill.setFame(kill.getFame() + pointsToAdd);
					   setFame(pointsToRemove);
					   killer.sendMessage("You have earned " + pointsToAdd + " Fame Points from " + getName() + "");
		               killer.broadcastPacket(new MagicSkillUse(killer, 23021, 1, 0, 0));
		       		{
       					if(killer instanceof L2PcInstance)
		 			{
		    				L2Party party = killer.getParty();
		    				if (party != null)
		    				{
		    					for(L2PcInstance PartyMember : party.getPartyMembers())
		    					{
		    						if(PartyMember.isInsideRadius(this, 1000, true, false) && PartyMember != killer)
		    						{
		    							PartyMember.setPvpKills(PartyMember.getPvpKills() + 1);
		    				}
		    			}
		    		}
				}
		    }
		 }


and howto do to distribute fame and pvp

i mean if in party is 4 players so get 10% points (divide by 4) and give 1 pvp to all players in party [in real time]

hope understand me,

  • 0
Posted

Idk much about java i just want to add that fame and pvp for all players in party, so im NooB if going about java.

So if u can help me i will be happy, and no need to by in real time. once a player must sign out  ;D

  • 0
Posted

Hello again

 

i used your code to improve mine but have bug

but I have a problem when the killer is alone, he gets 5% of the fame of the player who lost

when the killer is in the party also gets 5% of his fame and memberd party gets 5% share in the number of players in a party

 

should be so -> when a player is in the party gets 5% divided by number of players in a party

 

+			
+						if (killer instanceof L2PcInstance && getPvpFlag() > 0)
+						{
+						 
+						   L2PcInstance kill = (L2PcInstance) killer;
+						   int pointsToAdd = (int) (_fame*0.05);
+						   int pointsToRemove = _fame - pointsToAdd < 0 ? 0 : _fame - pointsToAdd;
+						   kill.setFame(kill.getFame() + pointsToAdd);
+						   kill.setSp(kill.getSp() + pointsToAdd);
+						   setFame(pointsToRemove);
+						   killer.sendMessage("You have earned " + pointsToAdd + " Fame Points from " + getName() + "");
+			               killer.broadcastPacket(new MagicSkillUse(killer, 23021, 1, 0, 0));
+			       		{
+			       		
+			       		}
+
+					    {
+       					if(killer instanceof L2PcInstance && getPvpFlag() > 0)
+			 			{
+			    				L2Party party = killer.getParty();
+			    				if (party != null)
+			    				{
+			    					for(L2PcInstance PartyMember : party.getPartyMembers())
+			    					{
+			    						if(PartyMember.isInsideRadius(this, 1600, true, false) && PartyMember != killer)
+			    						{
+			    							int numberToAdd = (int) (_fame*0.05/party.getMemberCount());
+			    							PartyMember.setFame(PartyMember.getFame() + numberToAdd);
+			    							PartyMember.setSp(PartyMember.getSp() + numberToAdd);
+			    							int pointsToRemove1 = _fame - numberToAdd < 0 ? 0 : _fame - numberToAdd;
+			    							setFame(pointsToRemove1);
+			    							PartyMember.setPvpKills(PartyMember.getPvpKills() + 1);
+			    							PartyMember.sendMessage("You have earned " + numberToAdd + " Fame Points from " + getName() + "");
+			    							PartyMember.broadcastPacket(new MagicSkillUse(killer, 23021, 1, 0, 0));
+			    				}
+			    			}
+			    		}
+					}
+			    }
+			 }

 

when i enter "L2Party party = killer.getParty();" for killer have error in console andcode dont work

 

something like that :

 

+			
+						if (killer instanceof L2PcInstance && getPvpFlag() > 0)
+						{
+						   L2Party party = killer.getParty();
+						   L2PcInstance kill = (L2PcInstance) killer;
+						   int pointsToAdd = (int) (_fame*0.05/party.getMemberCount());
+						   int pointsToRemove = _fame - pointsToAdd < 0 ? 0 : _fame - pointsToAdd;
+						   kill.setFame(kill.getFame() + pointsToAdd);
+						   kill.setSp(kill.getSp() + pointsToAdd);
+						   setFame(pointsToRemove);
+						   killer.sendMessage("You have earned " + pointsToAdd + " Fame Points from " + getName() + "");
+			               killer.broadcastPacket(new MagicSkillUse(killer, 23021, 1, 0, 0));
+			       		{
+			       		
+			       		}
+
+					    {
+       					if(killer instanceof L2PcInstance && getPvpFlag() > 0)
+			 			{
+			    				
+			    				if (party != null)
+			    				{
+			    					for(L2PcInstance PartyMember : party.getPartyMembers())
+			    					{
+			    						if(PartyMember.isInsideRadius(this, 1600, true, false) && PartyMember != killer)
+			    						{
+			    							int numberToAdd = (int) (_fame*0.05/party.getMemberCount());
+			    							PartyMember.setFame(PartyMember.getFame() + numberToAdd);
+			    							PartyMember.setSp(PartyMember.getSp() + numberToAdd);
+			    							int pointsToRemove1 = _fame - numberToAdd < 0 ? 0 : _fame - numberToAdd;
+			    							setFame(pointsToRemove1);
+			    							PartyMember.setPvpKills(PartyMember.getPvpKills() + 1);
+			    							PartyMember.sendMessage("You have earned " + numberToAdd + " Fame Points from " + getName() + "");
+			    							PartyMember.broadcastPacket(new MagicSkillUse(killer, 23021, 1, 0, 0));
+			    				}
+			    			}
+			    		}
+					}
+			    }
+			 }

 

probably a mess in the code too much, but it works so far.

  • 0
Posted

+						   L2Party party = killer.getParty();
+						   L2PcInstance kill = (L2PcInstance) killer;
+						   int pointsToAdd = (int) (_fame*0.05/party.getMemberCount());
+

that will give you NPE if the killer doesnt have party

  • 0
Posted

know that, so in first code is w/o party but give me bug, because player with and without party gets the same points, and should get as much as others in the party.

 

player without party = 5%

player with party = 5% divide by "MemberCount()"

 

 

  • 0
Posted
+						if (killer instanceof L2PcInstance && getPvpFlag() > 0)
+						{
+						   L2Party party = killer.getParty();
+						   L2PcInstance kill = (L2PcInstance) killer;
+						   int pointsToAdd;
+						   if (party == null)
+						   {
+						   	pointsToAdd = (int) _fame*0.05;
+						   }
+					           else
+						   {
+							pointsToAdd = (int) (_fame*0.05/party.getMemberCount());
+						   }
+						   
+						   int pointsToRemove = _fame - pointsToAdd < 0 ? 0 : _fame - pointsToAdd;
+						   kill.setFame(kill.getFame() + pointsToAdd);
+						   kill.setSp(kill.getSp() + pointsToAdd);
+						   setFame(pointsToRemove);
+						   killer.sendMessage("You have earned " + pointsToAdd + " Fame Points from " + getName() + "");

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