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

So from what I understand, when you kill an enemy, you steal (or just got, not a big deal) him 10% of his pvp points.

 

Ex : you have 10 pvps, you kill someone with 70 pvp, you earn 7 pvp so your total pvpkill = 17 ?

 

----

 

Now you want to add a similar system to mobs, but based on their experience (as they don't have pvpkills...).

 

If you made the XP balance yourself (aka 7k xp is a lot for you), I suggest you to simply add a fixed multiplier.

 

You can take in consideration the mob HP multiplier, if he is champion type, or simply his level. Mix all or pick up only one formula as you want.

 

Easiest will be to take only the level, but the most accurate would be a multiplier of all values. I let you imagine the end formula :). Just think the result haven't to be too much or too low compared to player kill.

 

I dunno your server, but taking a "normal" retail environnement, the value should be around /10 compared to what you eanr killing players.

 

And gratz about idea, it's funny, even if I haven't the use of it, it's still clever :D.

  • 0
Posted

So from what I understand, when you kill an enemy, you steal (or just got, not a big deal) him 10% of his pvp points.

 

Ex : you have 10 pvps, you kill someone with 70 pvp, you earn 7 pvp so your total pvpkill = 17 ?

 

----

 

 

Needs to have the mob because pvppoints Starting with the game has 0 points which means that during the pvp does not get any points from your opponent will not be because they had.

 

When it comes to amount of points from the mob can be according to it's already a lvl They presented

 

-So far I am listing NPC points on pvp weapons and armor

 

-voicecommad .stat for players to know how much of May and how many others have points

 

so when i finish with mobs i share all system with .diff and npc here

  • 0
Posted

Well from your second answer I have no clue if I have answered your question or not lol.

 

And you can judge pvp kills are supposed to be *only* related to players, so you don't have to earn anything from mobs. And the problem is in fact the 10% of pvpkills. Your system don't work correctly if the killed have between 0 and 9 kills. But I agree it's a good system to balance big pvpers and low pvpers.

 

If the killed have just 0 kills, you can say the killer won't earn anything (and code it that way, put just before the reward :

if killed.pvpKills() == 0 
return;

 

Or you can do like CRPs, put a negative number. That means pvpkills can be negative.

 

Anyway gl whatever you do.

  • 0
Posted

And you can judge pvp kills are supposed to be *only* related to players, so you don't have to earn anything from mobs. And the problem is in fact the 10% of pvpkills. Your system don't work correctly if the killed have between 0 and 9 kills. But I agree it's a good system to balance big pvpers and low pvpers.

 

If the killed have just 0 kills, you can say the killer won't earn anything (and code it that way, put just before the reward :

if killed.pvpKills() == 0 
return;

 

Or you can do like CRPs, put a negative number. That means pvpkills can be negative.

 

Anyway gl whatever you do.

 

When u kill player with 0-9 pvppoints u earn 1 point and they lost 1 point (rounded)

 

I do not know if I were you I understand it, or do you understand me well, but it's about pvppoints, not pkpkill.

And have new idea:

pvppoints turn for fame, because fame can add to multisell but how to adda fame to drop

for now when i add fame(-300) have error in gameserver console ;/

 

 

 

 

--  One more thing, the entire text is translated in google translator --

  • 0
Posted

Is in my posts I have use "pkkills" term once ? Consider I understood what you said then.

 

I don't understand your problem, and if there was one, I answered in my first post.

 

In both pvp kills and pk kills there are victim and murderer, a victim and a killer, so I don't get your last post. Even mob is a victim and you're the killer... It's how java see the thing.

 

About fame it's exactly the same than pvpkills add. I don't see the problem, it's related only on the killer caracteristics. If you can pvpkills from the mob death method, you can reach fame.

 

And dont change of idea like that, you ask for pvp or for fame, make a split, it's 2 differents codes, even if it's exactly the same solution. You expand too much, make the idea clear in your head.

 

Which error ? Post it if you want help too, I'm not you, I can't see it...

 

And post your question because there aren't questions, you just expose mod idea. It's "help" section, not "suggestion" section :P. I say that if you want help, I won't post anymore if you continue like that.

  • 0
Posted

My English is not too good and it is a problem, I could understand you wrong

 

That is my code in L2PcInstance under // Kill the L2PcInstance

 

if (killer instanceof L2PcInstance && getPvpFlag() > 0)
		{
		   L2PcInstance kill = (L2PcInstance) killer;
		   int pointsToAdd = (int) (_pvpPoints*0.10);
		   int pointsToRemove = _pvpPoints - pointsToAdd < 0 ? 0 : _pvpPoints - pointsToAdd;
		   kill.setpvpPoints(kill.getpvpPoints() + pointsToAdd);
		   setpvpPoints(pointsToRemove);
		}

 

and its work correctly for player vs player have .stat where can see target points and when i target self, my points.

But for me is hard to add points for mobs some about 2-100 points from mobs ex: mob lvl 80 give me 10 points and raidboss give me 100 points (for 2 players in party 50 points each)

That idea (system) is good i think. Blocking me just a little knowledge of programming and English. So therefore, decided to write on this forum. Until now, only read. Maybe someone will like it and add something of my own.

  • 0
Posted

First you should write code around this location :

 

if (killer != null)

{

L2PcInstance pk = killer.getActingPlayer();

                                   >>> HERE <<<

 

Because where you put you miss important checks (and you can have a NPE).

 

Second you don't need to change killer for kill... pk is enough, it's used by others things too. Your code should look like :

 

if (killer != null)

{

L2PcInstance pk = killer.getActingPlayer();

{

             // if the victim was pvpflagged

             if (getPvpFlag() != 0)

             {

                   int pointsToAdd = (int) (_pvpPoints*0.10);

                   int pointsToRemove = _pvpPoints - pointsToAdd < 0 ? 0 : _pvpPoints - pointsToAdd;

 

                  // remove points to the victims and add points to the killer.

                   pk.setpvpPoints(pk.getpvpPoints() + pointsToAdd);

                   setpvpPoints(pointsToRemove);

              }

 

About L2PcInstance, I suppose you have understood it was the instance of the player. Checks on mobs must be done in another file, L2MonsterInstance. You have to add code in the doDie method.

 

Monsters got their own instance, guards their, player their, artifact, etc etc. Some depends of others, so you have to choose wisely. For example if you modify the doDie of L2NpcInstance, you add pvpkills for monsters, but not only, for artifact, guards, etc.

 

L2MonsterInstance is supposed to be (for INTERLUDE) for normal monsters, and it's the master class of minion and raidboss too. So basically, you use 1 stone to kill 3 birds.

 

----

 

I have to add summons which kill a player won't make earn pvpkills to their owners. Summoners will cry in your server lol :). Well you should test but that shouldn't work correctly.

 

If a test with summoners is negative you have to use killer instead of pk (because killer is related to L2Character when pk is related to only L2PcInstance), and put your code after

 

		if (killer != null)
	{

 

and add another check for summon specially (instead of my "if (getPvpFlag() != 0)", use :)

 

if ((killer instanceof L2SummonInstance || killer instanceof L2PlayerInstance) && getPvpFlag() != 0)

 

-----

 

From this point you have all cards in your hand.

 

Sry for the edit if you were checking, I just pickuped a L2J post IL example.

  • 0
Posted

I want to add pvppoints only mobs (monsters) just on the farm made by me. And these mobs have 80 to 87  lvl and are a  L2Monster. Now, how to add  pvppoints inL2MonsterInstance to get  sequentially from 80lvl 2 points, from 81lvl 4 points...... from 87lvl 14 points. I'm already almost done server need to do pvppoints from mobs.

  • 0
Posted

You can create a complete new mob type, like L2FarmZoneMobInstance, depending of the L2MobInstance.

 

On your datapack, copy paste a mob and instead of L2Mob type it will be a L2FarmZoneMob. Well you got the idea.

 

Check L2Minion for example, it's a class who inherits caracters from L2Monster, L2Monster inherit from others classes too etc etc.

 

About the calcul to have pvppoints :

 

take the result number of the difference between the mob level - 79, and multiply it by 2.

 

(mobLevel - 79)*2

 

lvl 80 = 80-79 = 1*2 = 2

lvl 82 = 82 - 79 = 3*2 = 6

 

Well my exemple doesn't follow your logic suit, but else you have to do an exception for lvl 80, and others lvl can be calcultated automatically.

 

    If > 80
       exception to the rule
   else
       normal calcul

  • 0
Posted

That is too hard for me i cant do nothing always have errors. but have new ide with item take 10% items from victim and give to killer. and set for this no tradeable  no dropable no sellable no desroyable. and easiest add to mobs. i fight with this code 3 days and dont have nothing for now. But if some one is interesing can help to finish this.

  • 0
Posted

Well, the way I said is far easier than trying to make weapons giving pvp...

 

Just copy/paste L2MinionInstance, you rename it, you delete code inside (just keep the doDie override method) and put your custom code when a mob die.

 

Once coded, the only thing you have to do is to create mobs in your database with your custom name instance (like L2Minion dpeends of L2MinionInstance, etc), and to //spawn ingame.

 

I don't get how to code weapon could be easier neither, anyway, gl with it.

 

If you don't like L2Minion, just pick up another.

 

What's your errors and mainly, what are you trying to do ?

  • 0
Posted

copied L2minionInstance and create new L2pvpmobInstance

 


/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
* 
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
* 
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.actor.instance;

import com.l2jserver.gameserver.ai.L2AttackableAI;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.L2WorldRegion;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;

/**
* This class manages all Minions.
* In a group mob, there are one master called RaidBoss and several slaves called Minions.
*
* @version $Revision: 1.20.4.6 $ $Date: 2005/04/06 16:13:39 $
*/
public class L2pvpmobInstance extends L2MonsterInstance
{
//private static Logger _log = Logger.getLogger(L2RaidMinionInstance.class.getName());

/** The master L2Character whose depends this L2MinionInstance on */
private L2MonsterInstance _master;

/**
 * Constructor of L2MinionInstance (use L2Character and L2NpcInstance constructor).<BR><BR>
 *
 * <B><U> Actions</U> :</B><BR><BR>
 * <li>Call the L2Character constructor to set the _template of the L2MinionInstance (copy skills from template to object and link _calculators to NPC_STD_CALCULATOR) </li>
 * <li>Set the name of the L2MinionInstance</li>
 * <li>Create a RandomAnimation Task that will be launched after the calculated delay if the server allow it </li><BR><BR>
 *
 * @param objectId Identifier of the object to initialized
 * @param L2NpcTemplate Template to apply to the NPC
 */
public L2pvpmobInstance(int objectId, L2NpcTemplate template)
{
	super(objectId, template);
	setInstanceType(InstanceType.L2MinionInstance);
}

/**
 * Return the master of this L2MinionInstance.<BR><BR>
 */
public L2MonsterInstance getLeader()
{
	return _master;
}

@Override
public void onSpawn()
{
	setIsNoRndWalk(true);
	if (getLeader() != null)
	{


	}
	// check the region where this mob is, do not activate the AI if region is inactive.
	L2WorldRegion region = L2World.getInstance().getRegion(getX(),getY());
	if ((region !=null) && (!region.isActive()))
		((L2AttackableAI) getAI()).stopAITask();
	super.onSpawn();
}

/**
 * Set the master of this L2MinionInstance.<BR><BR>
 *
 * @param leader The L2Character that leads this L2MinionInstance
 *
 */
public void setLeader(L2MonsterInstance leader)
{
	_master = leader;
}

/**
* Manages the doDie event for this L2MinionInstance.<BR><BR>
*
* @param killer The L2Character that killed this L2MinionInstance.<BR><BR>
*/
@Override
public boolean doDie(L2Character killer)
{
	if (!super.doDie(killer))
		return false;
	// if the victim was pvpflagged
[color=red]        if (getPvpFlag() != 0)[/color]
        {
[color=green]              int pointsToAdd = (int) (_pvpPoints*0.10);[/color]
           [color=red]   int pointsToRemove = _pvpPoints - pointsToAdd < 0 ? 0 : _pvpPoints - pointsToAdd;[/color]
[color=red]
             // remove points to the victims and add points to the killer.
              pk.setpvpPoints(pk.getpvpPoints() + pointsToAdd);
              setpvpPoints(pointsToRemove);    [/color]                                   
         }
	return true;
}

@Override
public float getVitalityPoints(int damage)
{
	return 0;
}
}


 

hope i understand u, have errors where is pvp points. in red i mark what think need to remove in green need to cange but dont know how.

  • 0
Posted

Well, I don't think you understand how the whole thing works, so let's explain some things, even if that goes beyond X-Files and Mulder + Scully must search me atm :).

 

----

 

This instance is specially made for your mob. Other codes made for the old particular instance (here, it's L2Minion) have to be deleted or corrected. We take L2Minion because of the pre-made template, and we delete all others things in. That's all.

 

----

 

Second thing you have to understand, an instance IS the thing the instance is created for. Why I say that, it's because you have to put yourself in the point of view of the instance. Here you have to think as a L2PvpMob.

 

It's surealist, but good question could be : "why I exist ?".

 

Good answer : "To reward players with pvp points when I die."

 

I said to you about X-Files, aren't you ? :D

 

----

 

Third thing for you to understand it's all about variables. Some variables are taken from others java parts. You have to do the inventory about what you got on your instance, and use it as tools.

 

----

 

Ok, I stop saying bullshit now, you must be already sleeping on your keyboard.

 

Let's take all points one by one. From your code, you have first to delete things which are useless. It will make your code easier to read, and easier to find bugs if there are.

 

The @Override means this method already exists in the main model this instance inherits for (in this exemple, your L2PvpMob inherits from L2MonsterInstance because of the extends,

public class L2PvpMobInstance extends L2MonsterInstance

and use your method written in L2PvpMobInstance instead of the super model one (which is, I hope you follow, the L2MobInstance one). You have to keep only the doDie override method.

 

Shorter version = main method + override  = override. The main method is pushed out by your custom one.

 

Secondly, in the L2MinionInstance code, it's normal there is a master, as a L2Minion is nothing without a master. You already played to L2 aren't you ? So delete all things related to master too, we aren't a L2Minion anymore, but a proud L2PvpMob.

 

  • NOTE ABOUT THE CLEAN ON IMPORT PACKAGES. As we don't need the OnSpawn override, near all old imports are useless. Imports don't count at all in your compiled project, but it's more cleaner like that.
  • NOTE ABOUT COMMENTS. Comments are cool, but not-related ones are hell. Clean or modify useless/outdated comments, it can save you some minutes in the future.

 

 

 

As 1 + 2 are clean related, I made only one code part :

 

package com.l2jserver.gameserver.model.actor.instance;

import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;

/**
* This class manages special pvpkill rewards mobs.
*/
public class L2PvpMobInstance extends L2MonsterInstance
{
public L2PvpMobInstance(int objectId, L2NpcTemplate template)
{
	super(objectId, template);
	setInstanceType(InstanceType.L2PvpMobInstance);
}

/**
* Manages the doDie event<BR><BR>
*
* @param killer The L2Character that killed this instance.<BR><BR>
*/
@Override
public boolean doDie(L2Character killer)
{
	if (!super.doDie(killer))
		return false;

	return true;
}
}

 

See how the code have been reduced ? The code upper is supposed to work as a L2Monster, with a custom doDie method.

 

I don't know L2J higher than IL, as I work only on it, so if you have problems with setInstanceType(InstanceType.L2MinionInstance);, please send an error report or try to correct it.

 

----

 

Second part was a part of clean, but it's a part of creation too. The question is :

 

"How to give to player an amount of pvppoints, as the mob haven't this feature ?"

 

I already answered higher, saying something about mob lvl :P. So why do you try to copy past your old code ? Ofc it will bug.

 

As you tried to do it, it's related on the doDie method. The doDie method says : if I die, what I (the current instance, so see from the PoV of a L2PvpMobInstance)'m supposed to do".

 

----

 

Third about the variable stuff. We have to exploit possibilities we have.

 

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

	return true;
}

What do you understand from that ?

 

1 - it's an override method, so a main method exists. Basically if you change the supermethod, your custom mob won't be affected.

2 - (L2Character killer) is VERY important. It significates : when I die, I remember the L2Character which killed me. A L2Character is many things, but mainly players and summons. If you open L2Character, you know more about it :

 

/**
* Mother class of all character objects of the world (PC, NPC...)<BR><BR>
*
* L2Character :<BR><BR>
* <li>L2CastleGuardInstance</li>
* <li>L2DoorInstance</li>
* <li>L2NpcInstance</li>
* <li>L2PlayableInstance </li><BR><BR>

 

Currently, L2PlayableInstance is the main class of L2SummonInstance and L2PcInstance.

 

----

 

Now about your custom code :

  • you will have to interrogate killer. As killer is a L2Character, you will have to transform it to a L2PcInstance at one point of your code. Try to find codes which do that, they are a lot - do a search with (L2Character).
  • as killer can be many things, you have to make checks (NPEs checks, but too others checks if L2Character is related more than summons and players). As example, if the killer is a L2Summon, it's stupid to give pvpkills points to the summon, so you have to redirect points to summon owner.
  • as there are no pvp points on the mob, you have to use a custom calculation. So find how to get the mob level instead (anywhere in your java project).

 

Many, many things already exists. If I want to poke you, I could say you don't have to code anything, because all is already existing.

 

You have to read existing circumpstances to make your own circumpstance. How work the system if a player is killed by a summon ? You got the summon -> owner redirection here. Think like that for all, and little by little you will have all pieces in your pocket.

 

----

 

Basically your code would be like that. You can keep the comments to help you, and code between it.

 

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

	// check if the killer is different of null (to avoid NPE error)
		// check if the killer was a player or a summon
			// if killer is a summon, redirect to a L2PcInstance type
				// do a custom calcul using mob level
				// add the custom calcul result to the L2PcInstance total pvp points
			// if killer is a player
				// do a custom calcul using mob level
				// add the custom calcul result to the L2PcInstance total pvp points

	return true;
}

 

FOR EACH IF, YOU GOT AN IF { LOWER LEVELS COMMENTS }. So yeah, you will have imbricated "if" statements. Example below

 

	if
{ 
	if
	{
		if
		{

		}
	}

	if
	{

	}
}

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