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?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • Inventory restock: Premium business accounts are now available.   ✔ Wallester Business EU 🇪🇺|💳 Unlimited virtual cards, physical cards, 🏦 multi-currency IBAN, ₿ crypto & stablecoin deposits. ✔ Stripe Business UK 🇬🇧|💳 Instant virtual cards (Visa/Mastercard), high-conversion checkout, multi-currency payouts, ₿ crypto payments, no-code payment links. ✔ Mercury Business US 🇺🇸|🏦 US checking & savings, 💳 unlimited virtual cards, domestic & International wires, native stablecoin settlement. ✔ Payset Business EU 🇪🇺|🏦 Multiple IBANs, UK sort code, SEPA Instant, 💳 unlimited virtual cards, multi-currency accounts. ✔ Novo Business US 🇺🇸|🏦 Business checking account, ACH payments & invoicing, 💳 virtual & physical cards, novo boost.
    • Let me see if I understand correctly, older gentlemen, when a newcomer shows up to create modern things with the help of AI, doing what you charge them to do, you point the finger and laugh. I believe that's why everything is stagnant. The product isn't for programming experts, it's for newcomers. Don't buy from you if they can do it themselves using this base. You're going to deliver a similar product, maybe even worse than this one, so why are you complaining? PowerShell, as you well know, started with it, then came new platforms and new apps, new creation models, all with different languages; I chose the simplest one for my taste. This is about being organized and knowing how to choose the right words for each situation. It's not 100%, but it already gives a good impression. Nothing is 100%, so a topic written by AI, and all the code that you charge an absurd amount for to prohibit and sell hacks, could be open source so that everyone can create new practices, new models, new information for passing packets, prohibiting the use of cheats that cause server owners to break so much. Let's remember that the Admin doesn't always shut down the server; it's the players who find problems and take advantage by buying and reselling items, and they say that the GM shuts down the server every week, but that's a lie. What they do is duplicate items with packages and sell them, but perhaps this could give some future developers a starting point to create their own protection following the model in the initial documentation. Because none of you answer a question from a newbie, you think you're superior because you have knowledge, but with AI, people like that can have the same knowledge as you, but with less practice. And if they practice a lot, 10,000 hours, they can be as good as all of you older developers in the L2J field.
    • ✨ Exclusive Offer for Marketplace Growth 🔥 Elevate your performance with a premium bonus. 💲 Top up your balance with $100 or more and receive an additional $5 credit — seamlessly added to your account. ⭐️ Designed for those who value efficiency, scale, and results. ⚡️ Effortless. Refined. Effective. 💥 Enhance your strategy today 💥
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..