Jump to content
  • 0

[Help] Pvp points from Mobs


Question

Posted

Hello i have pvp points on my server. From each killed pleyera gets his 10% pvpPoints and that points has stored in db new column in characters

Wanna know how to add these points to the mobs and get them together with exp and sp.

but if exp is set to 7000 is a mob would give me 7 pvppoints.

hope u understand me cuz my english is more funny than the understandable.

Recommended Posts

  • 0
Posted

Hello again ;]

Have problem with Raid boss

I added the PvpPoints to L2RaidBossInstance but my bosses is strong and need party to kill him and only 1 player get points ;/

Want add for party and have problem with distribute points

 

look:

public boolean doDie(L2Character killer)
{
	if (!super.doDie(killer))
		return false;

	L2PcInstance player = null;
	if (killer instanceof L2PcInstance)
		player = (L2PcInstance) killer;
	else if (killer instanceof L2Summon)
		player = ((L2Summon) killer).getOwner();

	if (player != null)
	{
		broadcastPacket(new SystemMessage(SystemMessageId.RAID_WAS_SUCCESSFUL));
		if (player.getParty() != null)
		{
			for (L2PcInstance member : player.getParty().getPartyMembers())
			{
				int numberToAdd = 500;
				member.setPvpPoints(member.getPvpPoints() + numberToAdd );
				member.sendMessage("You have earned " + numberToAdd + " PvP Points");
				RaidBossPointsManager.addPoints(member, this.getNpcId(), (this.getLevel() / 2) + Rnd.get(-5, 5));
				if(member.isNoble())
					Hero.getInstance().setRBkilled(member.getObjectId(), this.getNpcId());


			}
		}
		else
		{
			int numberToAdd = 500;
			player.setPvpPoints(player.getPvpPoints() + numberToAdd );
			player.sendMessage("You have earned " + numberToAdd + " PvP Points");				
			RaidBossPointsManager.addPoints(player, this.getNpcId(), (this.getLevel() / 2) + Rnd.get(-5, 5));
			if(player.isNoble())
				Hero.getInstance().setRBkilled(player.getObjectId(), this.getNpcId());

		}
	}

	RaidBossSpawnManager.getInstance().updateStatus(this, true);
	return true;
}

 

raidboss everyone has a lvl 80 so everybody gives the same number of points

tried to add:  int numberToAdd = 500 / this.getPartyMember();  but error ;/

want to ex if in party is 4 members - int numberToAdd = 500/4

is posible or not??

  • 0
Posted

Never initialize a variable inside a (for, while) loop.

	if (player != null)
	{
		int numberToAdd = 500;
		broadcastPacket(new SystemMessage(SystemMessageId.RAID_WAS_SUCCESSFUL));

		if (player.getParty() != null)
		{
			for (L2PcInstance member : player.getParty().getPartyMembers())
			{
				member.setPvpPoints(member.getPvpPoints() + numberToAdd );
				member.sendMessage("You have earned " + numberToAdd + " PvP Points");
				RaidBossPointsManager.addPoints(member, this.getNpcId(), (this.getLevel() / 2) + Rnd.get(-5, 5));

				if(member.isNoble())
					Hero.getInstance().setRBkilled(member.getObjectId(), this.getNpcId());
			}
		}
		else
		{
			player.setPvpPoints(player.getPvpPoints() + numberToAdd );
			player.sendMessage("You have earned " + numberToAdd + " PvP Points");				
			RaidBossPointsManager.addPoints(player, this.getNpcId(), (this.getLevel() / 2) + Rnd.get(-5, 5));
			if(player.isNoble())
				Hero.getInstance().setRBkilled(player.getObjectId(), this.getNpcId());

		}
	}

 

And don't say "I got an error", send the error :p. I'm not 3 years old indian programmer genius.

 

I want to add your code give 500 pvppoints to each member. It's not 500 points in total splitted in "x" party members. Well perhaps you know it, but better to say.

 

PS :I reread your message, and it's what you were asking lol :). Check the xp/sp sharing system for party members, you have your answer here.

  • 0
Posted

here is xp/sp sharing but dont know from where i can take party size

 

	public void distributeXpAndSp(long xpReward, int spReward, List<L2Playable> rewardedMembers, int topLvl, int partyDmg, L2Attackable target)
{
	L2SummonInstance summon = null;
	List<L2Playable> validMembers = getValidMembers(rewardedMembers, topLvl);

	float penalty;
	double sqLevel;
	double preCalculation;

	xpReward *= getExpBonus(validMembers.size());
	spReward *= getSpBonus(validMembers.size());

	double sqLevelSum = 0;
	for (L2Playable character : validMembers)
		sqLevelSum += (character.getLevel() * character.getLevel());

       final float vitalityPoints = target.getVitalityPoints(partyDmg) * Config.RATE_PARTY_XP / validMembers.size();
       final boolean useVitalityRate = target.useVitalityRate();

       // Go through the L2PcInstances and L2PetInstances (not L2SummonInstances) that must be rewarded
	synchronized(rewardedMembers)
	{
		for (L2Character member : rewardedMembers)
		{
			if(member.isDead()) continue;

			penalty = 0;

			// The L2SummonInstance penalty
			if (member.getPet() instanceof L2SummonInstance)
			{
				summon     = (L2SummonInstance)member.getPet();
				penalty    = summon.getExpPenalty();
			}
			// Pets that leech xp from the owner (like babypets) do not get rewarded directly
			if (member instanceof L2PetInstance)
			{
				if (((L2PetInstance)member).getPetData().getOwnerExpTaken() > 0)
					continue;
				else // TODO: This is a temporary fix while correct pet xp in party is figured out
					penalty = (float)0.85;
			}


			// Calculate and add the EXP and SP reward to the member
			if (validMembers.contains(member))
			{
				sqLevel = member.getLevel() * member.getLevel();
				preCalculation = (sqLevel / sqLevelSum) * (1 - penalty);

				// Add the XP/SP points to the requested party member
				if (!member.isDead())
                   {
                       long addexp = Math.round(member.calcStat(Stats.EXPSP_RATE, xpReward * preCalculation, null, null));
                       int addsp = (int)member.calcStat(Stats.EXPSP_RATE, spReward * preCalculation, null, null);
                       if (member instanceof L2PcInstance)
                       {
                       	if (((L2PcInstance)member).getSkillLevel(467) > 0)
                       	{
                       		L2Skill skill = SkillTable.getInstance().getInfo(467,((L2PcInstance)member).getSkillLevel(467));
                       		
                       		if (skill.getExpNeeded() <= addexp)
                       			((L2PcInstance)member).absorbSoul(skill,target);
                       	}
                           ((L2PcInstance)member).addExpAndSp(addexp, addsp, useVitalityRate);
                           if (addexp > 0)
                               ((L2PcInstance)member).updateVitalityPoints(vitalityPoints, true, false);
                       }
                       else
                           member.addExpAndSp(addexp, addsp);
                   }
			}
			else
			{
				member.addExpAndSp(0, 0);
			}
		}
	}
}

 

"parytRoom" is party matching = distribute in party ?

  • 0
Posted

ok done i have all i need (i think that)

 

look

	public boolean doDie(L2Character killer)
{
	if (!super.doDie(killer))
		return false;

	L2PcInstance player = null;
	if (killer instanceof L2PcInstance)
		player = (L2PcInstance) killer;
	else if (killer instanceof L2Summon)
		player = ((L2Summon) killer).getOwner();

	if (player != null)
	{
		int numberToAdd = (500/(player.getParty().getMemberCount()));
		broadcastPacket(new SystemMessage(SystemMessageId.RAID_WAS_SUCCESSFUL));

		if (player.getParty() != null)
		{
			for (L2PcInstance member : player.getParty().getPartyMembers())
			{
				member.setPvpPoints(member.getPvpPoints() + numberToAdd);
				member.sendMessage("You have earned " + numberToAdd + " PvP Points");
				RaidBossPointsManager.addPoints(member, this.getNpcId(), (this.getLevel() / 2) + Rnd.get(-5, 5));

				if(member.isNoble())
					Hero.getInstance().setRBkilled(member.getObjectId(), this.getNpcId());
			}
		}
		else
		{
			player.setPvpPoints(player.getPvpPoints() + numberToAdd );
			player.sendMessage("You have earned " + numberToAdd + " PvP Points");				
			RaidBossPointsManager.addPoints(player, this.getNpcId(), (this.getLevel() / 2) + Rnd.get(-5, 5));
			if(player.isNoble())
				Hero.getInstance().setRBkilled(player.getObjectId(), this.getNpcId());

		}
	}

	RaidBossSpawnManager.getInstance().updateStatus(this, true);
	return true;
}

 

and work fine tested with 2 and 3 party members

 

Sorry for post after post*

 

 

edit: sorry I was glad too fast

 

when I'm in a party and party member is in town and so divided the party and give away even as they are

 

i found somethink like this:

 

	if (!Util.checkIfInRange(Config.ALT_PARTY_RANGE2, player, member, true)) continue;

 

but dont know wher put this code ;[

 

  • 0
Posted

You have to test the range of each party member, so you have to test inside the loop.

 

for (L2PcInstance member : player.getParty().getPartyMembers())
{
   if(Util.checkIfInRange(....
  { 
      member.setPvpPoints(me...
  }
}

 

You should check the checkIfInRange about the boolean in the method.

checkIfInRange(Config.ALT_PARTY_RANGE2, player, member, true)

As you can see, it takes a config range, the player loc, the member loc, and a boolean. Be sure what does this boolean. Just as security.

 

I don't want to bitch, but you should have problem with your code if you haven't a party. Well, ok, RB can't be made w/o party, but imagine if a destro leave the party and kill the boss alone. Well, you guess it, the numberToAdd check about the member count of the party, but the party will be null. So normally you have a NPE error.

 

Initialize numberToAdd without any values.

 

int numberToAdd;

 

if player.get.party != null ---------> numberToAdd = (500/(player.getParty().getMemberCount()));

and for the "else" part ----------------> numberToAdd = 500

 

Put this just before .setPvpPoints methods.

 

first part will look like that :

for (L2PcInstance member : player.getParty().getPartyMembers())
{
   if(Util.checkIfInRange(....
  { 
      numberToAdd = (500/(player.getParty().getMemberCount()));
      member.setPvpPoints(me...
  }
}

 

Basically you don't even need to use "numberToAdd" for a single player.

 

			else
		{
			player.setPvpPoints(player.getPvpPoints() + 500);

 

------------

 

Remember the checkIfInRange is a boolean type. It returns true if it's in range, and false if not.

  • 0
Posted

I did as you wrote but dont work cuz never use boolean and dont know how ;/ tried looks in other scripts but did not succeed.

 

for now have:

 

	public boolean doDie(L2Character killer)
{
	if (!super.doDie(killer))
		return false;

	L2PcInstance player = null;
	if (killer instanceof L2PcInstance)
		player = (L2PcInstance) killer;
	else if (killer instanceof L2Summon)
		player = ((L2Summon) killer).getOwner();

	if (player != null)
	{
		List<L2PcInstance> ToReward = FastList.newInstance();
		int count = 500 / ToReward.size(); 
		broadcastPacket(new SystemMessage(SystemMessageId.RAID_WAS_SUCCESSFUL));
		if (player.getParty() != null )
		{							
			for (L2PcInstance member :  player.getParty().getPartyMembers())					
			{				
			if (!Util.checkIfInRange(Config.ALT_PARTY_RANGE2, player, member, true)) continue;
			ToReward.add(member);

			{					
				member.setPvpPoints(member.getPvpPoints() + count);
				member.sendMessage("You have earned " + count + " PvP Points");
				RaidBossPointsManager.addPoints(member, this.getNpcId(), (this.getLevel() / 2) + Rnd.get(-5, 5));

				if(member.isNoble())
					Hero.getInstance().setRBkilled(member.getObjectId(), this.getNpcId());
				}				
			FastList.recycle((FastList<?>) ToReward);
			}
		}
		else
		{

			player.setPvpPoints(player.getPvpPoints() + 500);
			player.sendMessage("You have earned 500 PvP Points");				
			RaidBossPointsManager.addPoints(player, this.getNpcId(), (this.getLevel() / 2) + Rnd.get(-5, 5));
			if(player.isNoble())
				Hero.getInstance().setRBkilled(player.getObjectId(), this.getNpcId());

		}
	}

	RaidBossSpawnManager.getInstance().updateStatus(this, true);
	return true;
}

 

 

i read about boolean and know only: have 2 option false or true but how use this dont know ;/

 

  • 0
Posted

What doesn't work, be more accurate.

 

  • Compilation ? If yes, give error.
  • Ingame ? If yes, try to make your code talks for you, adding some
     
    player.sendMessage("Test to see if that work");
     
    in good places (after each conditions).

  • 0
Posted

when i'am in paryt have error; (when party member is in range and out of range)

Failed executing hittask.

java.lang.ArthmeticException:  / by zero

 

I know what it means [ToReward.size()] is still 0

 

Whe i read about bolean i came to this; when party memmbers is out of range partysize=1 but how to write this (or im wong)

GN i didnt sleep 2 night in a row now need to rest a little cu soon ;]

  • 0
Posted

I just reread your code, wtf are you using

 

			List<L2PcInstance> ToReward = FastList.newInstance();
		int count = 500 / ToReward.size(); 

 

Drop the ToReward stuff, it's what it bugs.

 

You initialize a FastList in a list, and divide this empty list from 500. Total illogismadnessupawesomerror.

 

Just do as you did later about the number of party mmebers, I don't get this "new List feature" lol.

 

----

 

I don't think you understand you have to initialize the variable OUT of the for loop, but must add this variable INSIDE it aswell.

 

And remove the CONTINUE after the "if" omg. Try to understand what you copy/paste.

 

----

 

Reread correctly all my posts, you have all answers. If you're blocked in a point I already talked sooner, you won't have any answer. Post back your code with error in the same post, that will avoid me to ask for error or for the code.

  • 0
Posted

lost myself, I do not know what I have now remove.

 

i need this;

 

List<L2PcInstance> ToReward = FastList.newInstance();

 

and this:

 

FastList.recycle((FastList<?>) ToReward);

 

and if checkIfInRange is boolean type how do I calculate the number of players in the party and the range?

 

now i have nothing new in code and stuck.

 

  • 0
Posted

Take back your code of the 20th december, it was near all good. I don't get why you began to use ToReward stuff.

 

	public boolean doDie(L2Character killer)
{
	if (!super.doDie(killer))
		return false;

	L2PcInstance player = null;
	if (killer instanceof L2PcInstance)
		player = (L2PcInstance) killer;
	else if (killer instanceof L2Summon)
		player = ((L2Summon) killer).getOwner();

	if (player != null)
	{
		int numberToAdd = (500/(player.getParty().getMemberCount()));
		broadcastPacket(new SystemMessage(SystemMessageId.RAID_WAS_SUCCESSFUL));

		if (player.getParty() != null)
		{
			for (L2PcInstance member : player.getParty().getPartyMembers())
			{
				member.setPvpPoints(member.getPvpPoints() + numberToAdd);
				member.sendMessage("You have earned " + numberToAdd + " PvP Points");
				RaidBossPointsManager.addPoints(member, this.getNpcId(), (this.getLevel() / 2) + Rnd.get(-5, 5));

				if(member.isNoble())
					Hero.getInstance().setRBkilled(member.getObjectId(), this.getNpcId());
			}
		}
		else
		{
			player.setPvpPoints(player.getPvpPoints() + numberToAdd );
			player.sendMessage("You have earned " + numberToAdd + " PvP Points");				
			RaidBossPointsManager.addPoints(player, this.getNpcId(), (this.getLevel() / 2) + Rnd.get(-5, 5));
			if(player.isNoble())
				Hero.getInstance().setRBkilled(player.getObjectId(), this.getNpcId());

		}
	}

	RaidBossSpawnManager.getInstance().updateStatus(this, true);
	return true;
}

 

Instead of int numberToAdd = (500/(player.getParty().getMemberCount())); write int numberToAdd = 500;. You will initialize it to 500. I explain why after.

 

Now we have to change value on numberToAdd, right ? The value differs from if you got a party (numberToAdd divided by party members) or if you solo (numberToAdd). Again right ?

 

So basically, we initialized numberToAdd with a fixed number, 500. Where to calculate this value for the team ? Logically, you have to put it after the party check.

			if (player.getParty() != null)
		{
                              numberToAdd = (500/(player.getParty().getMemberCount()));

 

The solo part will use the basic value, 500. So you haven't to change anything on it.

  • 0
Posted

When i killl RB solo its ok 500 PvP Points.

When i kill RB in party and 1 party member is far in town killer takes 250 PvP Pooints and member takes 250 PvP Points.

why I want to add (!(Util.checkIfInRange... for checking member if in range.

that "ToReward." is from distributionAdena but u tell me is wrong, now i don know what is wrong and where i must put code util for check who is in range.

  • 0
Posted

Well first do as I said, post a clean code and try to add ONLY the range check.

 

I know (!(Util.checkIfInRange... is for range, but that doesn't have any relation with ToReward lol.

 

I want to see how you include the check, I think you did one or 2 errors, and I perhaps know them.

 

About the location of the check, take one minute to think. When do you want to verify the range ? "Only when I got a party" is a first point. Second point is "who is affected ?" Only the killer, or each member ? With those 2 questions you got the location.

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