Barotrauma

Barotrauma

204 ratings
AI NPCs
9
9
4
4
7
2
2
3
3
2
2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
274.900 KB
Nov 5, 2023 @ 10:12pm
Dec 11, 2024 @ 4:36pm
8 Change Notes ( view )

Subscribe to download
AI NPCs

Description
Enhance Your Barotrauma Experience with AI-Enhanced NPCs
This mod integrates OpenAI's ChatGPT into Barotrauma, aiming to increase immersion by enabling NPCs to respond via an AI chat system.
Please note that this mod is currently a work-in-progress.

Requirements
  • Lua for Barotrauma
  • An API key from an AI chat provider (e.g., OpenAI)

Default Configuration
Uses OpenAI and the latest ChatGPT 4o mini model (note: this is a paid service).
Configuration can be adjusted to use free models like the 7b model from OpenRouter (Documentation Here[openrouter.ai]). Keep in mind that free models often have lower rate limits, which may be insufficient for extended gameplay.

Setup Instructions
General Setup:
Include Lua for Barotrauma and AI NPCs in your active mods list via Settings and click Apply.

Singleplayer:
  1. Install client-side Lua by following this guide: Lua Installation Guide.
  2. Start the game.
  3. Press ESC and use the AI NPCs Options menu to enter your API key. Click 'Done' when finished.

Multiplayer:
  1. Set the Server Executable to Lua for Barotrauma when starting your server.
  2. Press F3 to open the console.
  3. Use "ai_setconfig APIKey <key>" to set your API key.
  4. Use "ai_listconfig" to view all of the settings and their current values.

Optional - Using Alternative Model
To use an alternative model, modify the API endpoint and model configuration settings.
In Singleplayer, this can be done through the AI NPCs Options menu.
In Multiplayer, use the "ai_setconfig APIEndpoint <url>" and "ai_setconfig Model <name>" console commands.

For example, to use MythoMist 7b through OpenRouter:
  1. ai_setconfig APIEndpoint https://openrouter.ai/api/v1/chat/completions
  2. ai_setconfig Model gryphe/mythomist-7b:free

Usage
Compatible with Single Player and Multiplayer modes (Campaign, Mission, Sandbox).

In Multiplayer, only the server needs to set up the API information.

To interact with an NPC, type "!" followed by the NPC's name and your message. For example: !artie how are you doing?

Token usage ranges from 200 to 4000 per interaction. Adjust token usage with "ai_setconfig SessionTokenCap <amount>" to manage costs effectively.

All F3 console commands are viewable by running the "help" command. They are all prefixed with "ai_" and support TAB autofilling for certain parameters like configuration settings and NPC names. There are commands for modifying individual NPC's personalities, such as "ai_giverandomprofile <name>".
Popular Discussions View All (18)
28
Apr 14 @ 5:08pm
PINNED: Current Features and Goals
RubbingMyAxe
3
May 11 @ 9:41pm
The AI insists that i am bald.
WidowedGalaxy
1
Jun 13 @ 4:05pm
So theres a bit of a bug With openrouter it seems.
nicolas the mercenary
354 Comments
RubbingMyAxe  [author] Jul 8 @ 5:12am 
I have created a discord for the mod in case anyone wants to join to give feedback, report bugs, provide suggestions, help test or develop it, etc.

https://discord.gg/uWpFN4NPx3
jossebul Jul 6 @ 5:16pm 
nice thanks a lot ! and yeah a discord could help crowdsourcing some of the work of finding models and prompts that work well
RubbingMyAxe  [author] Jul 6 @ 4:57pm 
Also, sneak peak next update I made it pretty easy to find and select free models via the OpenRouter API: https://i.imgur.com/45SPB3I.png
RubbingMyAxe  [author] Jul 6 @ 4:50pm 
@jossebul Yeah, results can vary a lot depending on the model. I mostly use ChatGPT and I'm constantly testing so many different things that I don't try the free ones as much as I should... I should probably start a Discord server or something to get better feedback.

But anyway, it might help to tweak Artie's personality? In the Data folder of the mod, there is a UniqueCharacterProfiles.json file where I created some personality descriptions of all the special NPCs. You can try tweaking this part:

"Artie Dolittle":
{
"Description": "You are a young, incompetent, clumsy, drunk man who volunteered to work for free.",
"Style": ["peppy", "energetic", "eager", "desperate", "informal", "sarcastic"]

Maybe removing "drunk" and "peppy" would help.
jossebul Jul 6 @ 4:16pm 
so the mod has a lot of potential and already has some very fun uses, but (and that's probably an issue that depends on the model, I'm currently using the first free one I found, mistralai) I cannot let enable for NPCs on because everytime I get the same incredibly cringe and physically painful sentences from artie dolittle like look at this (he literally just killed a barotraumatic seasnek, one of the tiniest and most common random creatures you find) :
Artie Dolittle : *giggles uncontrollably* OHHHH MY GOSH -- *stumbles* -- I JUST *KILLED* A *SEASNEK* ?! *hic* DID I ?! *peeks at gun* Ohhhh no, is it *dead*? *giggles nervously* Or is it *laughing* at me ?!
appleman Jun 26 @ 1:35am 
Yes, I agree with that approach. having the feature turned off by default and allowing users to enable it if they want.
If this feature gets added, I’d personally use it in situations where I want all crewmates to respond to a specific hostile creature, or just to watch them fight with outpost security for fun.
I do understand that if all AIs respond at once, token usage could increase exponentially.
While I don’t know much about LLMs or AI systems, I wonder if, for commands like !Everybody, the response could be a fixed preset line instead of generating a new reply for each AI.
That might help reduce the token usage for that kind of command.
RubbingMyAxe  [author] Jun 26 @ 12:36am 
I am looking into both of those. I think no matter which way I go about it, it will be heavy on token usage compared to the rest of the mod so far. Tokens are getting cheaper every few months though, and some people might not care because they are using local models. So I may add it in and leave it off by default for those that want to use it.
appleman Jun 26 @ 12:02am 
This mod is really fun to play with. I especially enjoy communicating with the AI teammates.
I think it would be even better if two features were added:
First, a command like !Everybody that makes all AI crew members respond at once.
Second, it would be amazing if the AI could also communicate with each other.
Thank you so much for creating such an entertaining and immersive mod.
RubbingMyAxe  [author] Jun 25 @ 6:07pm 
Close to releasing an update to address all the errors and issues that I've been told about. I've encountered some problems with the major new features that I was going to add, so this won't be as large of an update as I was hoping.
RubbingMyAxe  [author] Jun 22 @ 8:15am 
They can respond to chat message and interpret basic commands from them. Like "bring me a wrench", they will search the submarine for a wrench and then bring it to you. You can't like teach them to do something that they execute unprompted though, at least not yet.