Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] Creating/refractor MapleStory (odin based source) NPC Script AI using GPT4

Junior Spellweaver
Joined
Aug 13, 2009
Messages
124
Reaction score
123

Creating MapleStory (odin based source) NPC Script AI using GPT4​

This is a small technical demonstration showcasing the capabilities of GPT in relation to legacy MapleStory (odin-based source) scripts.

  • State based NPC script to stateless NPC script - These scripts are state-based and can often be laborious to write, and even more tedious to convert to a stateless alternative today (thousands upon thousands of them).
  • NPC story-writer + script-writer.

Changes:
  • 08/03/2023 -- With the release of gpt-3.5-turbo model today that makes it even better, I shall present you with the following that I have for a while.
  • 29/03/2023 -- updated for GPT4
  • 18/02/2024 -- An example has been included live.

See it live here:



LastBattle - [Release] Creating/refractor MapleStory (odin based source) NPC Script AI using GPT4 - RaGEZONE Forums


-------------------------------------

More examples:​

Converting from state-based NPC script to stateless:​


1708337959002 - [Release] Creating/refractor MapleStory (odin based source) NPC Script AI using GPT4 - RaGEZONE Forums



Creating a series of NPC scripts revolving around a single theme:​


1708337980525 - [Release] Creating/refractor MapleStory (odin based source) NPC Script AI using GPT4 - RaGEZONE Forums


Creating complex Tic-Tac-Toe NPC script:​

1708337993636 - [Release] Creating/refractor MapleStory (odin based source) NPC Script AI using GPT4 - RaGEZONE Forums


Have fun~! AI-ing~!!



Instructions to run​

Installation & setup​

  1. Install NodeJS 18:
  2. npm install
  3. Create an account, and get an key
  4. Go to config.ts and enter the API key under OPENAI_API_KEY
  5. Place your NPC scripts under _input\npc\ folder

Start​

  1. npx ts-node script.ts
  2. You should see the refractored files under _output\npc\

FYI​

Limitations​

  • You have to adjust the prompts according to your own MapleStory sources, it is not guaranteed to work as you may have different function names for the NPC conversation.
  • It may not work 100% of the time. Try to change the "temperature" parameters to 0.2 from 0 for a little added randomless to the output instead of a fixed-deterministic output.
  • ALWAYS test it, before going to production. Every single script.
  • Further optimisation is possible down the road when of a model is supported for GPT3.5/GPT4 and above. To save both cost and for higher accuracy.
  • It might not be able to refractor if the script's input size is > 32,768 tokens due to GPT4's current limitation.
  • It may sometimes hallucinate to create functions that lead to nowhere, I'm relatively sure GPT is trained on other MapleStory Odin-based sources out there on GitHub. It might be possible to solve this by showing it more examples of scripts refractored manually by a human vs its unrefractored counterpart when the limitations of 4096 tokens are lifted. Example:
Code:
function onUserEnter() {
    cm.say("I'm the head of this hair salon. If you have a #b#t5150053##k or a #b#t5151036##k allow me to take care of your hairdo. Please choose the one you want.");
}

function onUserExit() {
    cm.say("Thank you for visiting our salon. Come back soon!");
}

function onDisconnected() {
    cm.say("Oh no! You have disconnected. Please log back in and visit us again!");
}

How its done:​

  1. [System] Prompts GPT what persona it needs to be, or to act as.
  2. [System] Tells GPT the stateless NPC functions available
  3. [User] Tells GPT to refractor the script to a stateless NPC script.
  4. [Assistant] Actually shows it a valid refractored example to guide its knowledge further.
  5. [User] Give it a real unconvered script, and ask for conversion.

Useful link​

  • Chat completions
  • Explore other AI prompts, to adjust its behaviour and personality
  • (get the prompts from "/prompts" folder of this repo)
 

Attachments

You must be registered for see attachments list
Last edited:
Initiate Mage
Joined
Nov 18, 2022
Messages
2
Reaction score
0
Thx for sharing, just wonder if this means we can easily translate other JavaScript format scripts into scripts of python format(swordie server used).
 
Junior Spellweaver
Joined
Aug 13, 2009
Messages
124
Reaction score
123
Quite a release, curious on what prompted this. Really an amazing use-case for ChatGPT.
Its all here.
It can be made better once the APIs for fine-tuning GPT4 are available. At the moment everything requires to be in the first prompt.

or rather if you're instead asking what prompted me:
I was doing a regular dev-ops on my old source to keep up with the latest, and the idea just came out of nowhere. Had the stateless scripts implemented for years now, yet I just dont have the time to manually convert all of them.
It has all been converted right now, in a matter of 3 days.
----------------------

Also, there are also some other uses of GPT like story-telling, auto completing of NPC conversations or chat bubbles.

1684333184234 - [Release] Creating/refractor MapleStory (odin based source) NPC Script AI using GPT4 - RaGEZONE Forums


1684333145489 - [Release] Creating/refractor MapleStory (odin based source) NPC Script AI using GPT4 - RaGEZONE Forums


You could also give an NPC its own personality, character that is fully customised to any player. Speaking to it like a real person would.


Once that is done, why not raise the bar further with AI-players in the game. Killing monsters, joining PQs with real players?


I've also been exploring StableDiffusion. Honestly, the possibilities are endless. A single Nvidia RTX 4090 could crunch through all of v110 assets within a day.

You could leverage on existing assets to train a model to make truly original MapleStory looking-like characters, monsters, or even BGMs by just a couple of sentence prompts.

Thx for sharing, just wonder if this means we can easily translate other JavaScript format scripts into scripts of python format(swordie server used).
A large language model (or AI) simply takes away the tedious job that a human would otherwise not want to do, however it still takes a bit of technical capability on the dev part to execute this.
I'm not too sure if there's any implementation of stateless NPCs in swordie, I believe it might.

You just have to change up a few prompts to match that source. Then test each and every one of those scripts.
 

Attachments

You must be registered for see attachments list
Last edited:
Newbie Spellweaver
Joined
Dec 7, 2022
Messages
8
Reaction score
0
I tried it for free, and it is really suitable for helping to write programs. Although I didn’t write js when I tried it, but used it to write html, the result failed, only the appearance and no function, but it gradually improved with the number of times, but it probably only works if you pay for it. Because just proofreading will run out of usage times
 
Initiate Mage
Joined
Apr 15, 2021
Messages
2
Reaction score
1
Is there any chance to upgrade js script engine from state-based to stateless?
 
Junior Spellweaver
Joined
Aug 13, 2009
Messages
124
Reaction score
123
An example has been included live here:

You're now able to prompt the AI to just create a MapleStory NPC script for you with text!

You will need ChatGPT-subscription to access it, maybe some day I will just train a custom LLM model based on Mistral, or LLAMA for local access.


1708245479227 - [Release] Creating/refractor MapleStory (odin based source) NPC Script AI using GPT4 - RaGEZONE Forums


1708246415578 - [Release] Creating/refractor MapleStory (odin based source) NPC Script AI using GPT4 - RaGEZONE Forums



1708338024612 - [Release] Creating/refractor MapleStory (odin based source) NPC Script AI using GPT4 - RaGEZONE Forums


Is there any chance to upgrade js script engine from state-based to stateless?

I'll make it a separate release on how to implement it soon. It will also be backwards compatible to all of the old scripts.
 

Attachments

You must be registered for see attachments list
Last edited:
Back
Top