Jump to content
  • 0

Question

Posted

Hello, I have a small problem, and it seems I cant find the solution... I want to make an NPC automatically attack a player who has more than 1000 PVP's... like guard.. I want to make it with guards, please don't answer something else, its not helping... I need to do it with NPC. Thank you.

6 answers to this question

Recommended Posts

  • 0
Posted

just coded, untested

### Eclipse Workspace Patch 1.0
#P L2J_Server
Index: java/com/l2jserver/gameserver/ai/L2AttackableAI.java
===================================================================
--- java/com/l2jserver/gameserver/ai/L2AttackableAI.java	(revision 4868)
+++ java/com/l2jserver/gameserver/ai/L2AttackableAI.java	(working copy)
@@ -227,7 +227,8 @@
		{

			// Check if the L2PcInstance target has karma (=PK)
-			if (target instanceof L2PcInstance && ((L2PcInstance) target).getKarma() > 0)
+			if (target instanceof L2PcInstance && (((L2PcInstance) target).getKarma() > 0
+					|| ((L2PcInstance)target).getPvpKills() >= 1000))
				// Los Check
				return GeoData.getInstance().canSeeTarget(me, target);

Index: java/com/l2jserver/gameserver/model/actor/knownlist/GuardKnownList.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/knownlist/GuardKnownList.java	(revision 4868)
+++ java/com/l2jserver/gameserver/model/actor/knownlist/GuardKnownList.java	(working copy)
@@ -42,7 +42,7 @@
		if (object instanceof L2PcInstance)
		{
			// Check if the object added is a L2PcInstance that owns Karma
-			if (((L2PcInstance)object).getKarma() > 0)
+			if (((L2PcInstance)object).getKarma() > 0 || ((L2PcInstance)object).getPvpKills() >= 1000)
			{
				if (Config.DEBUG)
					_log.fine(getActiveChar().getObjectId()+": PK "+object.getObjectId()+" entered scan range");

  • 0
Posted

I have a problem... in L2AttackableAI... actually look, i dont want to make it with 1000 pvp's, i just said it as an example but it seems i shouldnt hide it. so, i am making a Good vs Evil server, and i want to make guards hit only the enemies. so i used code 1st

to check the location, I used getClosest Town, and also i checked if its inside zone, named ZONE_CASTLE so then it reads who owns this territory,  and attack the enemies. Now, about your code, a lot of errors appear in gameserver console, the error is: Actor: Guard onEvtThink() L2GuardInstance can not be cast to L2PcInstance.

I think this cant be fixed so.. i need an other idea or somehow fix this :/

  • 0
Posted

i did not understand much well what you explain, but sounds a crappy code. All you have to do is replace the 1000 pvps check by the character faction and the zone faction owner. If they are different, attack

  • 0
Posted

Check here some of the code i made:

 

if (target instanceof L2PcInstance && ((L2PcInstance) target).isTeam1Member() || ((L2PcInstance) target).isTeam2Member())
{
        if(getActiveChar().getNpcId() == 90005)
{
                	if(MapRegionTable.getInstance().getClosestTownName(getActiveChar()).contains("Giran"))
                	{
                		if(getActiveChar().isInsideZone(L2Character.ZONE_CASTLE))
                		{
                			if(GameServer.girancastle == 1)
                			{
                			if(((L2PcInstance) target).isTeam2Member())
                			{
                				return GeoData.getInstance().canSeeTarget(me, target);
                			}
                			}
                			else
                			{
                				if(((L2PcInstance) target).isTeam1Member())
                			{
                					return GeoData.getInstance().canSeeTarget(me, target);
                			}
                			}
                		}
                		if(GameServer.girantown == 1)
            			{
                			if(((L2PcInstance) target).isTeam2Member())
                			{
                				return GeoData.getInstance().canSeeTarget(me, target);
                			}
            			}
            			else
            			{
            				if(((L2PcInstance) target).isTeam1Member())
                			{
            					return GeoData.getInstance().canSeeTarget(me, target);
                			}
            			}
		}

 

What could be wrong?

  • 0
Posted

1) My code cannot throw such errors about cast exceptions since im not using any other object to be casted to L2PcInstance than the original one

2) You wrotte double checks of the same thing (like team2 member)

3) So, as i understand from your code, the guards should attack those players inside castle zone which are from different faction than the castle owner?

  • 0
Posted

double check ? hmmm, maybe I should recheck my code.. and i dont really want to hit them only in the castle, as you see there is also "else" which means if it is not in castle zone, it checks the town area, and they should hit the enemies.

any other help?

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