Jump to content
  • 0

NPCs hitting back


KaL

Question

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

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

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

Link to comment
Share on other sites

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

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