Jump to content
  • 0

NPCs hitting back


Question

Posted

Hi all...

 

I remember in C1, when a player attacked a NPC inside cities (like GKs) the NPCs started running to the player and hitting him (like a guard does) and the NPC is always invul..

 

So...I'm trying to do this in my Interlude L2jFree server...

 

I tried to put this code in onAction method:

 

else if(!isAutoAttackable(player))

           {

            // Check if the L2PcInstance is in the _aggroList of the L2GuardInstance

               if (containsTarget(player))

               {

                   if (_log.isDebugEnabled()) _log.debug(player.getObjectId()+": Attacked guard "+getObjectId());

                   

                   // Set the L2PcInstance Intention to AI_INTENTION_ATTACK

                   player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);

               }

               else

               {

               // Calculate the distance between the L2PcInstance and the L2NpcInstance

               if (!canInteract(player))

               {

                   // Notify the L2PcInstance AI with AI_INTENTION_INTERACT

                   player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);

               }

               else

               {

                   // Send a Server->Client packet SocialAction to the all L2PcInstance on the _knownPlayer of the L2NpcInstance

                   // to display a social action of the L2NpcInstance on their client

                   SocialAction sa = new SocialAction(getObjectId(), Rnd.get(8));

                   broadcastPacket(sa);

                   

                   // Open a chat window on client with the text of the L2NpcInstance

                   if (isEventMob)

                      L2Event.showEventHtml(player, String.valueOf(getObjectId()));

                   else if (_isEventMobTvT)

                      TvT.showEventHtml(player, String.valueOf(getObjectId()));

                   else if (_isEventMobDM)

                       DM.showEventHtml(player, String.valueOf(getObjectId()));

                   else if (_isEventMobFOS)

                       FortressSiege.showEventHtml(player, String.valueOf(getObjectId()));

                   else if (_isFOS_Artifact)

                    FortressSiege.showArtifactHtml(player, String.valueOf(getObjectId()));

                   else if (_isEventMobCTF)

                      CTF.showEventHtml(player, String.valueOf(getObjectId()));

                   else if (_isCTF_Flag && player._inEventCTF)

                    CTF.showFlagHtml(player, String.valueOf(this.getObjectId()),_CTF_FlagTeamName);

                   else if (_isCTF_throneSpawn)

                    CTF.CheckRestoreFlags();

                   else if (_isEventVIPNPC)

                      VIP.showJoinHTML(player, String.valueOf(getObjectId()));

                   else if (_isEventVIPNPCEnd)

                      VIP.showEndHTML(player, String.valueOf(getObjectId()));

                   else

                   {

                       Quest[] qlst = getTemplate().getEventQuests(Quest.QuestEventType.NPC_FIRST_TALK);

                       if ( (qlst != null) && qlst.length == 1)

                           qlst[0].notifyFirstTalk(this, player);

                       else

                           showChatWindow(player, 0);

                   }

               }

                   player.sendPacket(new ActionFailed());

               }

           }

           else

            player.sendPacket(new ActionFailed());

       }

    }catch (Throwable e){

    System.out.println("Error: L2NpcInstance--> onAction(){"+e.toString()+"}\n\n");

    player.sendPacket(new ActionFailed());

    return;

    }        

   }

 

But it returns this error:

 

The method containsTarget(L2PcInstance) is undefined for the type L2NpcInstance

 

I took that added part from L2GuardInstance and I belive it's what makes the Guard hitting back...I studied the code and saw that L2GuardInstance is extended by L2Attackable while L2NpcInstance is extended by L2Character...

 

So, any suggestion to help me fix this problem and see my npcs hitting back?  :P

 

Thanks

1 answer to this question

Recommended Posts

  • 0
Posted

you need to make a small rework in the core and i dont think shitlude is possible for that.

 

basically what you need is search in a real lineage2 emulator(l2j gracia final for ex)and than start to rework the aggrolist because if you put too much into the aggrolist it will fuck up your mem usage your boot time basically your server so you need a rework

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

    • L2Elixir – Patch 4 Is Live!   We’re working non-stop, day and night, to deliver the best possible quality and bring back what made L2Elixir special. This project is built with passion, not shortcuts — for the old-school players who remember, and the new ones who want to experience it properly. Thank you for being part of the journey. Together, we’re making L2Elixir great again ❤️ The legends never fade.    ⚙️ General Enabled Class Change service (same class type only) ALT + B → Services → Character Development Enabled Shift + Click on Treasure Chests Players can now identify real chests (Adena, scroll drops) and use Key / Unlock Event deaths now cancel only debuffs, All self buffs are preserved, fixes issues with Root and similar effects Bladedancer class can now log in even when Max Clients (2) is reached. Since an active Bladedancer is not available for every damage dealer and some players tried to abuse this via VPN or a second PC, this feature was added to keep things fair. protections applies, requires testing!    🎒 Items Crystallizing enchanted items now gives the correct increased crystal amount (retail-like behavior) Removed Agathion Seal Bracelet: Rudolph from Santa rewards (Gracia Final item) Added Dualsword Craft Stamp into Milestone Exchange list    🧙 Skills Fixed Banish Undead lethal chance Hot Springs Malaria and similar effects now level up faster while being attacked
    • thats new SEO level tricks you know nothing of noob - bottom line: exposed.
    • Warning: This guy is a big scammer, trying to sell everything, advertising for servers etc. That's his mail address evgesha.nrnr@gmail.com , stay away!   @Atom @Celestine
    • Warning: This guy is a big scammer, trying to sell everything, advertising for servers etc. That's his mail address evgesha.nrnr@gmail.com , stay away! @Celestine @Atom
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock