Jump to content
  • 0

[HELP] Implementing NPC Relations


Question

Posted

Hello everybody, nice to see all the useless help posts and some fimilar names.

 

Something that I've been working on is creating your own 'Instance' of the world independent of what other players do. To create a bit more of a dynamic role playing situation for players I've been wanting to implement relationships between NPC's. I'm currently using standard interlude L2j from the nightlies folder (r1434) incase you're wondering, though I'm wondering more about the concept of it rather than the practice.

 

The idea to paint an example of what I mean:

 

There is Tom and there is Joe. Tom is a trader. Tom receives his supplies from Joe and resells them. Joe is a traveling NPC which travels from location A to B. Joe dies, either by the hands of the player or a hostile NPC. Because Tom no longer has a supplier he cannot sell supplies anymore to the player.

 

Obviously it won't be so specific every time and it was just to illustrate what I mean but I want to implement something generic enough that I can define an entry point interface ( like checkRelation or something ) and from there script it myself in specific classes. However I'm running into trouble with a good implementation with the current system of npc's and spawning.

 

1) My original idea was to have the NPC's have a Map with the NPC id as the key and the value being some kind of relation interface (classes implement this with a doCheck as stated above, or something when the player interacts with the NPC). However NPC's can have multiple spawns, which means this is unreliable (or it can be managed if I'm the one managing the custom npcs)

 

2) The second idea is to use the spawn id's of npcs, however this wouldn't be known at compile time. To manage this I'd have to completely overwrite the current spawn system to make something to keep track of it then, which would then have to spawn things inside of a relation 'group'.

 

Anybody maybe have some kind of idea about how to go about this?

 

 

 

6 answers to this question

Recommended Posts

  • 0
Posted

It's interesting, but I'm not even sure you can rely on npc objectId after server shutdown. As CtrlIntention, you can make a Enum with all possible actions, and code any action.

 

About individual behavior (such as your Tom/Joe), I clearly doubt you can do something global. Each A type enters in a "case" you have to code. It could be patrolling an area, you have to give an area manually, or based on actual region.

 

How will you manage to say Tom and Joe are related, for exemple ? I see mostly a "clan" system. How will you manage to make them walk ? I see a pathnode system.

 

You could also do as L2J currently make, aka coding any single behavior. It is very long.

 

Anyway, even on The Sims, you haven't such relation, and it's a game based only about relations between NPCs.

 

You should better take a look on AI systems from others games.

  • 0
Posted

i got a bit lost:

"Instances": check how postIl did it, but it must be just controling knownList or smth like that

 

Relations between Npc's you can create a manager that save the info (Joe alive?) onCreate() turn it true, onDie() false [no idea if Npcs have onCreate(), they must, because some make an animation or a skill, i dont know] that manager may be static so you can access it easy.

 

AIs, there are some usefull information about this, i have read long time ago something about birds/fish simulations that are based on 3 keys:

- they follow a leader

- they have a formation

- they do random moves inside that formation

or something like that

 

Edit: http://www.red3d.com/cwr/boids/

  • 0
Posted

If u would like to make relation between single npcs(each npc spawn have got different relations) and u want those relations to be saved after restart. Npc = spawn, if spawns would be indexed it would be very easy, except that there is no option i think :/

Now, when something happends = relation is changed, it would have to be saved somewhere, best option is new Sql table with spawn relations. When relation has been removed(for example when 1 npc died) it can be just removed from database very fast.

 

Now about relations, u will need to create enum of them. I dont know what relations u want to do but i think that u will need to make each class for each relation so it will be easiest way. Seems like something not really hard to do :)

  • 0
Posted

Well I'm going to start with something simple to begin with. I have an enumation object with 2 statuses. Either the NPC's are going to like each other or they're going to hate each other (two poles to start simple). Let's just say they're both merchants. If you deal with Merchant A, Merchant B is going to hate you, and vice versa: If you deal with B, A is going to hate you. For now deal 2 is going to the player additional as I will have to add things in the L2PcInstance for that. Deal 1 my focus now is how the two NPC's see each other and how to bind them uniquely.

 

I'm making the decision right now that all boss NPC's and all interactable NPC's are only going to be allowed 1 spawn. I'm blocking spawning two uniquely identified NPC's from being spawned at the same time. This way the NPC id is going to become a reliable key for looking up relations.

 

I don't want to make a global solution for the implementation but I'd like to have a generic interface with a function

( RelationInterface.CheckRelations(L2Player ) ) with classes that implement the interface based on whom you're talking with.

 

public interface RelationInterface { public Something getRelations(); }

 

Keep in mind I'm focusing on simple relations of NPC's right now, the addition of players will come next (need to take this one step at a time since it's quite ambitious).

 

Adenaman: I'll take a look at the link and give it a read over, thanks for the link.

 

  • 0
Posted

If you deal with B, A is going to hate you.

It means player got a role to play. Your system (even that simple one) can't work without player interaction.

 

For such "simple" exemple, you have to register every player. You have also to create a static link between both L2Npc (another map ?), which you have to feed by yourself (or at least finding a particular variable to make checks on, like ALL Gludio merchants hate ALL Dion merchants - in that case, the region).

 

Basically, for a global table, as simple as possible, I see something like :

npcId EnumAction parameter

The parameter being related to EnumAction. Could be a Location model (patrol), a L2PcInstance (trade), another L2Npc (follow/escort), a monster (hunt).

 

SQL table feeding a ConcurrentHashMap, which can return all stored interactions following npcId. Then the AI will act following priority of action.

 


 

About a PURE relation system, just do like the SIMS. One variable put to 100, at 0 it means hate, 100 love. Following npc template, react according other npc template.

  • 0
Posted

You can copy the Varka/Ketra system, if you add the Tryskell idea

-100 to -20 = love completly Varka

-20 to +20 = neutral

+20 to 100 = love Ketra

 

If you want any interface then it must be something like Comparable (or Comparator dont remmember now) but i dont think that you need it.

 

if it is personal player based (love Dion or love Heine) then just add a int / boolean at L2PcInstance and some help method "boolean isDionFriend()" or "int getDionHeineFriendship()"

 

if it is not, (like Hellbound levels more or less) then you need a manager that store that var, it can be singleton because there will be only one (no 2 Dion-Heine relationship)

 

Btw the link is about behavior simulations, dont think that is relevant

Guest
This topic is now closed to further replies.


  • Posts

    • Hello guys, I’d like to introduce your audience to my original project, which has gained popularity in Europe and among the Russian-speaking community. I just never got around to posting about it here until now. At one point, I wanted to develop a launcher (game file downloader) in the browser, and that idea eventually evolved into a full-fledged CMS engine with extensive functionality. SphereWeb is a massive ecosystem for Lineage 2 JAVA servers, packed with everything a server administrator and players might need. From October 2024 to April 24, 2025, my project has been installed on 250 different domains. SphereWeb is your best choice — a modern web engine designed specifically for administrators of Lineage 2 Java game servers. It offers a rich and user-friendly interface for managing your server with ease. ✅ Player Control Panel – covers all player needs: Authorization, registration, password change, account linking and synchronization, contacting the admin via support system, teleporting a character (and sending items to warehouse) to a town, warehouse management (sending items in-game), and making server donations. ✅ Admin Control Panel – opens up new horizons, giving you access to: Extensive panel customization (more on this later) Donation history with charts News and page creation Stream management (add streams) Item shop creation Starter packs creation Bonus code generation XenForo news integration Email message settings Global activity log Traffic insights (track where your users come from) Extensions section (plugins – more on that later) Server management Auto software updates Tech support Custom translations Now, about the Control Panel settings: The standard settings are organized into several tabs: Language There are 5 available languages: Russian, English, Spanish, Portuguese, and Greek, covering 99% of translation needs. You can also set a default language for the panel.   Features Toggle built-in features of the control panel: News, Shop, Balance, Statistics, Support, Balance Transfer, Bonus Code, Streams, Data Emulation. Enable/disable options to keep the panel clean and focused on what you need. Captcha Support for Google reCAPTCHA, Cloudflare Turnstile, or default hCaptcha. Old-school recommendation: use Google reCAPTCHA v2. Fake Online Boosting Basic settings for boosting the online counter. Registration Settings Configuration options for the registration process. Email Connect your panel to an SMTP server. Misc General-purpose settings and adjustments. Template Choose and preview the design template for your landing page. Logo Upload your control panel logo and favicon. Palette Customize the color scheme of your control panel interface. Menu Add links to your site’s navigation menu. Background Upload high-resolution background images for login, registration, and password recovery pages. Notifications Set up Telegram notifications for selected events. In Sphere 2, I’ve paid special attention to plugins, making it easy to add and expand functionality. By default, the panel includes several built-in extensions (plugins).   Giveaway – allows you to host item giveaways for users directly on the website. Internal Forum – a built-in forum system inside the Control Panel (more details on it below). Launcher – a free solution for updating game files. It delivers unmatched speed and runs directly in the browser, allowing full design customization. Traders – (currently for Lucera2 only) displays a list of offline shops, their items, prices, and player locations directly on the website. Roulette – a fun game where users spin the wheel to win items. Item Editor – a tool for creating custom in-game items. Item Increase – tracks and displays item count by ID across the server in graph form, showing which players hold the most. Registration Statistics – a simple chart showing registration trends over time. SQL Collection – a plugin for adding or adjusting Java server builds if your current build isn’t supported or needs customization. ✅ Supported Java Server Builds The system currently supports a variety of popular Java server builds. Full list available in the admin panel. 🧩 Forum Plugin In the first version of Sphere, a basic internal forum was quite popular among server admins — so in Sphere 2, it came back better than ever. Inspired by XenForo, the forum is rich in features and designed for both community and solo players: Players can create clan communities to connect and play together. Clan creators can upload clan logos and header banners, customize text color for the clan name. Clan members can post on the public clan wall or chat in a dedicated clan chat. Clan logos and banners appear across the forum for all members. For players who like to show off: Under each username, the forum can display PvP/PK stats, in-game time, and character list. Players can choose to hide this data if they prefer privacy. Admins can assign moderator roles to users for specific forum sections, ensuring proper content management and community moderation.   💰 Donations & Rewards The administrator has a wide range of reward settings for player donations — almost every suggested method has been implemented: Cumulative discount system – discounts increase as the total donation amount grows. One-time bonus – an extra reward for a specific donation. Permanent shop discounts – based on the player's total donation history. One-time item shop discounts – also based on total donations. Item-based rewards – configurable rewards delivered automatically after donation. ✅ Supported Payment Systems (Current list is available in the admin panel and may vary by region.) 🔄 SphereWeb Auto-Update System Sphere is actively developed — I improve it almost daily. To ensure everyone stays updated, I’ve implemented multiple update methods: Automatic – once I push updates to GitHub, they are downloaded to Sphere clients within 5 minutes. Manual – if automatic updates are disabled or your site was offline during update release, you can trigger the update manually with one click. File Scanner – this feature scans your Sphere installation, compares files with the latest version, and shows missing or modified files you can restore. 📸 Control Panel Screenshots (Here you’d typically show screenshots or say where they can be found.)   💬 Final Words A lot of work has gone into this project. I occasionally post updates in the Sphere Telegram channel — when I don’t forget. I’m truly proud of the results. 🚀 Want to Install It? Before you rush in, please note: Installation won’t work on localhost. A valid SSL certificate is required. Repo: GitHub - Cannabytes/SphereWeb2 Upload the archive to your hosting. Open your website in the browser — the installer will guide you. ⚠️ Some Russian hosting providers block wide IP ranges, which may interfere with installation. 💸 Pricing Three usage plans available: Free – limited to 20 game account registrations per day. $12.5/month – no Sphere limitations. $20/month – no Sphere limitations + access to all commercial plugins. Your balance is shown in the admin panel, and you can renew access anytime. ✅ All users receive updates, regardless of subscription tier. A lot of work has been done, and from time to time I share updates in the Sphere Telegram channel — when I don’t forget. I’m truly proud of what I’ve built. Did you like it? Want to install it yourself? Please note — you won’t be able to install it on a local server. A valid SSL certificate is also required. Steps to install: Download the package from the GitHub repository: Cannabytes/SphereWeb2 Extract the archive on your hosting. Open your website in a browser — the installer will launch automatically. Just follow the instructions. 🔧 Minimum Requirements: PHP 8.2 MariaDB or MySQL 5.8 SSL certificate for your website   💵 Pricing SphereWeb offers 3 usage options: Free Plan – limited to 20 game account registrations per day. $12.5/month – no limitations, full access to Sphere features. 3. $20/month – no limitations + access to all commercial plugins. Your current balance is shown in the admin panel, and you can renew your license whenever you wish. Regardless of your plan, you will always receive updates. 🆕 Latest Updates: User Registration Source Tracking: Now, when a user registers, you can see where they came from before landing on the site via Telegram notifications. Bulk Deletion of Bonus Codes: Added functionality to bulk delete bonus codes for better management. Starter Pack Editor: A new editor for creating and managing starter packs is now available. Item Removal from Warehouse: Admins can now remove items from a user's warehouse. Server-Specific Settings: Each server now has a "Functions" button, providing additional customization options for each server. Warehouse Cleanup: Admins can now clear the warehouse for all users or by specific item ID. Custom Return Button: The "Return to Site" button can now be disabled, and you can set a custom link for it. Character List UI Overhaul: The character list in the admin panel has been redesigned to be more minimalist and user-friendly. User Info Page Improvements: The user information page has been enhanced for better navigation and access to key data. Donation History Updates: The donation history page has been improved for better data presentation. Item Stacking and Splitting: Users can now stack or split identical items (e.g., ID 57 (150) + ID 150 = ID 57 (300)). Admins can configure which items can be stacked and split. Account Deletion: Users now have the option to delete their own accounts from the account list. Success Chest Plugin: A new "Success Chest" plugin has been added, allowing admins to define chests with specific items, their prices, and visual parameters. Reworked Warehouse: The warehouse now operates in a separate modal window. When items are purchased, they are automatically added to the warehouse without page reloads. Registration Reward: Admins now have the ability to reward users for registration, adding more incentives. Item Stacking and Splitting Customization: Admins can now specify which items players can split and stack in their warehouse. These settings are available in the admin panel under the server's "Functions" button, offering granular control over item management. Account Deletion Feature: Players now have the ability to remove their accounts from the account list (but not from the server). In the future, this feature will be customizable for each server. Success Chest Plugin: A new "Success Chest" plugin has been added, allowing admins to define the items inside the chest. Players can then randomly draw one item from the chest. This feature is still in early testing, and any feedback or issues will be addressed in future updates. Improved Warehouse/Inventory: The warehouse/inventory system has been enhanced. Now, when items (such as starter packs or chests) are purchased, they are immediately added to the warehouse without requiring a page refresh. Additionally, the modal window for the warehouse now opens when the warehouse button is clicked with the mouse wheel. 😊 Log Sorting by Server: Logs now include the ability to sort by server, making it easier to manage and review data for each individual server. Registration Source Tracking: Telegram notifications now include information about where a user came from before registering on your site. Bulk Deletion of Bonus Codes: Admins can now bulk delete server-specific bonus codes, as well as bonus codes that were generated for all servers. Customizable Starter Packs: A new option has been added to modify and customize starter packs, giving more flexibility to server admins. Item Removal from Warehouse in Profile: Admins can now remove items from a user's warehouse directly from their profile. "Functions" Button in Admin Panel: A new "Functions" button has been added to the admin panel, offering additional tools for server management. This includes the ability to clear the server’s warehouse entirely or by specific item ID. Disabling the "Return to Site" Button: Under Admin Panel -> Settings -> Miscellaneous, there is now an option to disable the "Return to Site" button in the site menu
    • We are waiting you today at 8pm +3 GMT website: https://l2evo.net The patch will be available 30 min before the grand opening. Come join the best Interlude pvp server.  
    • We are certainly not an ambulance, but we will definitely cure you of blacklists and empty pockets. Live freely with SX! Each of you will receive a trial version of SX to familiarize yourself with the product, all you have to do is post in this thread
  • Topics

×
×
  • Create New...