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

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.



  • Posts

    • I would like to know about the Acis base of the data pack I use. The server source and server file could not find that information. I respectfully ask for the help of masters.🥲
    • discord - adver745645   https://t.me/adenala2   THERE ARE A LOT OF ADEN AT A VERY GOOD PRICE!!! HURRY  
    • Artificial Intelligence for all Chronicles. Developed in L2 HighFive branch since 2023 but it can be adapted to any project including Fand-C, aCis, Frozen, Scripts even compiled projects such as Lucera with some aditional cost.   Features:  1. Grouped of templates to create your own BOT (including skill, items, appearance, sex e.t.c.) 2. Bot can participate in Olympiad (+ any event with extra cost base on your event engine) 3. Bot walk nearby NPC to receive buff, receive equipment and teleport to any other area 4. Bot will accept party & clan invitation and follow party leader to wherever he go including teleport 6. Bot will trade player back dropped items from PK or fallen Raid Bosses after they visit a peace zone 7. Bot will open store and sell configurable item in configurable prices to players. 8. Bot will attack and cast spells in a realistic way. All classes are used including buffers, summoners, bishops e.t.c. 9. Buffer and bishops will cast buff to party members when player has no available or overriden buffs. 10. Bot will enchant their equipent and re-purchase upon failure. Their weapon will also switched between hero weapon and retail weapon when they need to. 11. Bot can move in complex map system and find monsters or players but they can also follow routes for specific paths using configurable XML if you want to.   Preview of some features: Olympiad Trade Store PvP   Example of a single configurable template in XML: https://pastebin.com/RXZVGCfA   Price: 270 Euro (Compiled) - 450 Euro (Source)    Contact Me Discord: https://discord.gg/gKAsAhJNuq MaxCheaters: https://maxcheaters.com/profile/243647-out-of-time/ Gmail: l2outoftime@gmail.com RCS Message: +30 698 740 8501  
    • Good day! Due to the increasing number of questions, "Do you provide services for the client?" - I decided to answer with a separate topic. I provide services for editing/modifying the client and individual files, namely: 1. Transfer/Creation/Editing locations, geodata.   2. All kinds of work with NPCs, including transfer, animation, adding effects to them and logos.   3. Actually, Transfer/Creation/Edit any EFFECTS, including Abnormal Effects.   4. Any work with weapons, armor, accessories and everything related to it.   5. Create or edit textures, including dynamic textures.   6. Creating a Lobby Screen, Lobby Char Selection (character selection window) and Lobby Char Creation (character creation window). What I don't do: 1. Coding in any form (except for CB).   I started publishing my work recently, here - YouTube And here - RuTube If required, I respect confidentiality. Any other questions? Welcome to Telegram or PM.
  • Topics

×
×
  • Create New...