Jump to content

Recommended Posts

Posted

Hello everyone 

How are you all doing?

I'd like to share with the community an open-source project I've been working on intensely: the **L2 Phantom AI Manager**.

Tired of those static bots that just stand still in the city or sink into the map because of Geodata? Me too! That's why I developed a modular Phantom system with real Artificial Intelligence, initially designed for **L2J Mobius Essence (RoseVain)**, but which can be adapted to other chronicles.

Main Features

Modular architecture: the system is split into focused files such as PhantomAI, PhantomEngine, PhantomFactory, PhantomEquipment, PhantomHuntingSpots, PhantomGeo, PhantomMenu, and more.

  • Automatic creation: create 10 or 50 phantoms from the menu or commands.
  • XML persistence: automatically created phantoms are saved into PhantomPlayers.xml, so they keep loading after server restarts.
  • Batch startup: .pstart and Start 10 load only 10 phantoms at a time.
  • Batch disconnect: disconnect 10 active phantoms without shutting down the whole system.
  • Origin towns: new phantoms spawn using PlayerTemplate.getCreationPoint(), respecting race and class.
  • Geodata-safe spawning: spawn points use NPC-like coordinate validation to avoid under-map or floating characters.
  • Real datapack spots: reads data/stats/npcs and data/spawns to build level-based hunting locations.
  • Bad target filtering: ignores Training Dummy, tutorial objects, chests, and fake farm targets.
  • Smart relocation: if a phantom cannot find useful mobs, it relocates to another spot for its level.
  • Level goals: phantoms receive leveling goals, return to town, recover resources, and go back to farming.
  • Mage MP rest mode: mages rest until MP is recovered; in PvP they try to escape when out of mana.
  • Skills and buffs: phantoms try to use offensive skills and self buffs such as Might, Shield, Focus, Haste, Empower, Acumen, Wind Walk, Chant, Song, and Dance.
  • Varied gear packs: gear packs by grade for mages and fighters, with multiple variants to avoid visual clones.
  • Automatic shots: randomized Soulshot and Spiritshot restocking by class and grade.
  • Inventory cleanup: unnecessary items are removed automatically while preserving Adena, shots, and equipped gear.
  • PvP and PK behavior: some phantoms are aggressive, may become PK, and attacked phantoms try to defend themselves.
  • Optional AI chat: optional Google Gemini integration for short social replies.
  • TXT logs: the menu displays log state and can enable/disable logging.

GM Menu

Use .pmenu to open the control panel.

Current options:

  • Start 10
  • Disconnect 10
  • Create 10
  • Create 50
  • Reload XML
  • Stop All
  • Enable Log / Disable Log

The menu also shows:

  • active phantom count;
  • XML ID count;
  • current TXT log state.

Commands

  • .pmenu - opens the control panel.
  • .pstart - starts 10 phantoms from XML.
  • .pstop - removes all active phantoms.
  • .pstop10 - disconnects 10 active phantoms.
  • .pload - reloads PhantomPlayers.xml.
  • .pcreate 10 - creates, starts, and saves 10 phantoms to XML.
  • .pcreate 50 - creates, starts, and saves 50 phantoms to XML.
  • .pm Name Message - sends a private message to a phantom.
  • .pdebug - toggles TXT logging.

Logs

Logs are created in the GameServer log/ folder:

  • log/PhantomManager.txt - global historical log.
  • log/PhantomManager-yyyyMMdd-HHmmss.txt - separate log for each session.

Useful logged events include:

  • new level goals;
  • travel to hunting spots;
  • town rest;
  • mob attacks;
  • PvP defense;
  • shot restocking;
  • inventory cleanup;
  • AI exceptions with stacktrace.

Main Files

  • PhantomManager.java - commands, logs, and bootstrap.
  • PhantomEngine.java - start, stop, spawn, respawn, batches, and AI loop.
  • PhantomAI.java - farm, PvP, PK, rest, targeting, and movement decisions.
  • PhantomConfig.java - routes, gear, shots, and XML persistence.
  • PhantomFactory.java - automatic character creation.
  • PhantomEquipment.java - buffs, progression, shots, and inventory cleanup.
  • PhantomHuntingSpots.java - real datapack NPC/spawn loader.
  • PhantomGeo.java - geodata-safe coordinate handling.
  • PhantomState.java - temporary phantom memory.
  • PhantomMenu.java - GM HTML panel.
  • PhantomBypass.java - menu button handling.
  • PhantomChat.java - messages and optional Gemini integration.
  1. Copy custom/PhantomManager into: dist/game/data/scripts/custom/PhantomManager/
  2. Place PhantomPlayers.xml in: game/config/Custom/PhantomPlayers.xml
  3. Compile scripts or restart the GameServer.
  4. Use .pmenu to create, start, and manage phantoms.
  5. https://github.com/miacodeweb/L2-Phantom-AI

Shot00049.jpg

Posted
20 hours ago, Heroic9614 said:

I tried it, very neat work.

Just keep improving it, there's potential.

Thank you for your feedback. To help me improve the system, please leave your comments or report any bugs. I will try to release weekly updates. 

Posted (edited)

Very nice work, once you start it's addictive and there's no stopping to it right ?

  1. Try to make your LLMs act like an agent in a loop and give them tools (functions to call shout, whisper, invite to party, invite to clan, goto target, assist, pass command)
  2. Give them a vector based memory
  3. Use a situational score based system for skill selection by priority.

    The sky's the limit 

    https://imgur.com/a/H6FdBpT

    This is me and my clan of AI's in my server.
Edited by aguy
Posted
On 5/29/2026 at 5:23 PM, aguy said:

Very nice work, once you start it's addictive and there's no stopping to it right ?

  1. Try to make your LLMs act like an agent in a loop and give them tools (functions to call shout, whisper, invite to party, invite to clan, goto target, assist, pass command)
  2. Give them a vector based memory
  3. Use a situational score based system for skill selection by priority.

    The sky's the limit 

    https://imgur.com/a/H6FdBpT

    This is me and my clan of AI's in my server.

Thanks for your comment. That's what I'm working on, but it takes a lot of planning and getting it to work. I hope I can pull it off. Right now, I'm working on the Party feature, and I'm also working on AI conversations focused solely on Lineage, meaning the AI will only talk about the game. We'll see how it goes. The idea is to develop the system so thoroughly that there are sieges and the Phantom Players are undetectable, making them seem as realistic as possible.

On 5/29/2026 at 8:07 AM, Heroic9614 said:

Maybe you could try to summon a buyer NPC as an admin

example: .buyer_npc 40387 50000

and then he would buy Einhasad for 50000 adena / item.

Appear with a random name, wear random clothes, etc.

 

I'm sorry, but I don't see it as a useful modification. I'm also doing modifications on request, so if you're interested, you can send me a PM.

Posted (edited)

Let me give you something for inspiration and get you addicted to bot AI
 


 

And a siege 😛
 

 

What I have notice helps a lot the LLM to act real, is to give it a real-persons background. So for each LLM in the context beggining, besides the L2 facts, give it a real-life back story "You are a 67 years old retired nurse who plays Lineage 2 while her husband reads his newspaper, you are calm, collected but get mad if insulted".

But that makes for a creative bot but its repetitive. So what you can also do, is pick random 20 news sites and for each bot every 2-3 days, initialize a context that is affected by the "news" the bot reads in the "real world". 

So for example there's Iran - US war ok ? You take the news, put it in an LLM and ask it, extract the "abstract feelings" that this news piece invokes into you without mentioning anything related to the news.

Then you take the result and inject it to the bots LLM prompt after its backstory. 

This leads to some VERY human-like behavior from bots. 

Edited by aguy

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

    • Hi, great work! Are there any bugs? And will it work with a high five?
    • For others that would like to understand in more details:   The login server also uses a protocol (sent by the server to the client in the very first packet). For instance, the C4 client (the one I'm developing my emulator for) expects the protocol number `50721` (or `0xc621`) which works as follow (from what I've gathered): Preamble: L2 packets are divided into two parts: size and payload; As mentioned, every packet starts with two bytes containing the whole packet size (thus including those two bytes, e.g. a packet of size 15 will have the number `15` written onto its first two bytes and a following payload of 13 bytes); For login server, first byte of the payload is the opcode (game server must deal with variable-sized opcodes); Next bytes are the packet content; Before sending the packet, its buffer size (minus the initial two bytes) is padded to 8 bytes (required by upcoming Blowfish encoding); A checksum of the packet is appended at the end, then the payload is again padded to 8 bytes; If the opcode is not `0` (also written as `0x00`), then the payload is encoded by Blowfish; Packet is sent over the network. You can have a look at my implementation (in C++) here (do note I'm assuming little-endian).   In this protocol, the auth packet (`0x00`) sent back by the client is RSA encrypted using the RSA modulus sent in the first server packet, inserted right after the protocol number.  
    • Hello guys I wanna buy some  Lessons for an L2J Developer
    • Let me give you something for inspiration and get you addicted to bot AI     And a siege 😛     What I have notice helps a lot the LLM to act real, is to give it a real-persons background. So for each LLM in the context beggining, besides the L2 facts, give it a real-life back story "You are a 67 years old retired nurse who plays Lineage 2 while her husband reads his newspaper, you are calm, collected but get mad if insulted". But that makes for a creative bot but its repetitive. So what you can also do, is pick random 20 news sites and for each bot every 2-3 days, initialize a context that is affected by the "news" the bot reads in the "real world".  So for example there's Iran - US war ok ? You take the news, put it in an LLM and ask it, extract the "abstract feelings" that this news piece invokes into you without mentioning anything related to the news. Then you take the result and inject it to the bots LLM prompt after its backstory.  This leads to some VERY human-like behavior from bots. 
  • 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..