Bases and NPC crafting

The following link is the upper levels of my CURRENT outline for implementing bases and a “Base Mode” NPC AI to match for the community’s perusal (Just the what’s planned part not the implementation; I’m not ready to open that up). At this point I am still very much in the planning stages and will gladly take any feedback, ideas or concerns people might have (not going to say anything in regards to considering it for longer than it takes to read though). This is already rapidly turning into a major undertaking so I would appreciate comments being focused on the core framework rather than the extras as those can always be added at a later date. Also, don’t expect me to be done with it in a week, I’m just starting and still want to do other things with my life like play CDDA.

It is a Microsoft Word Outline so it looks a little weird in google but i’m not bothered to change that. Have a good read!

https://drive.google.com/open?id=0B7yArTwxOX4GbGlzaFZMQ3picWc

For you more code savvy people:

[ul][li]I basically kept adding layers to this outline until I got to individual methods. [/li]
[li]The AI is going to work by making priorities from a bunch of maps. It’s very memory heavy (relatively, unless someone debugs hundreds of followers it won’t matter much) but fast. Also, it’s very easy to tweak. (Probably could put every variable you could possibly want to tweak in one file)[/li]
[li]Once I get the framework a little bit more solid I would be grateful for any collaborators especially because:
[/li][li]While I have worked in 6 or so languages C++ is not one of them (c is though). Probably going to write a bunch of sudo code and try and translate it when I’m done so I don’t get bogged down in syntax[/li]
[li]I have no friends… lol… ๐·°(৹˃̵﹏˂̵৹)°·๐ -determined not to cry[/li][/ul]

Probably should have started with this but…

SUMMERY OF MAIN PLANNED FEATURES:

[ul][li]Designate a building as “home base” by sticking a notice board on the wall through which you can post rules for the NPCs. (rationing of food, ammo and first aid; construction plans) Also, check status of base and NPC complaints [/li]
[li]Mark lockers and other storage furniture as yours and NPCs won’t touch anything there[/li]
[li]They demand a place to sleep and put their own stuff though[/li]
[li]Mark things as Communal and NPCs will feed, medicate, equip and reload themselves from there[/li]
[li]Deposits unwanted stuff there as well causing NPCs to trade among themselves[/li]
[li]NPCs WILL CRAFT STUFF THEMSELVES. Not just help you.[/li]
[li]leave crafting priorities and basic construction plans for them to follow while your gone[/li]
[li]Instruct each individual NPC to focus on crafting, construction, guarding or resting/recuperating[/li]
[li]Base stays in sudo reality bubble and NPCs will craft, construct, guard, eat, drink, sleep and fight off the hoards while your away[/li][/ul]

I’m making a new “Base Mode AI” for the NPCs will get switched to when you tell them to stay at the base. Some of but not all of my doings will be easily merged with the existing AI but probably not all. However, doing it this way makes things orders of magnitudes easier for me now.

I have no idea how any of the code for this will work so I cannot offer much in the way of help.But man, if you can do this, this will absolutely be my most favorite mod in this entire game. Best of luck to you in this endeavor!

How large would this designation be? what will determine that?, if they are connected by walls?, currently I have a base in the center of a mall if I were to put that notice board would the whole mall become my “base”?

This is a mod I always wanted, can’t wait to play Cataclysm Fortress: Slaves to Dark Days Ahead.

Start small and PR as soon as possible.
The sooner you present your code, the sooner we can help with it.

Don’t start out with grand plans until you have a good feel of the NPC code. It can be convoluted and you need to understand what can be done and what is pretty much beyond reach.

How large would this designation be? what will determine that?, if they are connected by walls?, currently I have a base in the center of a mall if I were to put that notice board would the whole mall become my “base”?

This is a mod I always wanted, can’t wait to play Cataclysm Fortress: Slaves to Dark Days Ahead.[/quote]

I’m starting with a one map tile building designated by its walls. Eventually I want to get it to 2x2 map tiles max so you can set up in some of the bigger buildings. Perimeter fences/ outer walls will also come later.

[quote=“Coolthulhu, post:5, topic:14225”]Start small and PR as soon as possible.
The sooner you present your code, the sooner we can help with it.

Don’t start out with grand plans until you have a good feel of the NPC code. It can be convoluted and you need to understand what can be done and what is pretty much beyond reach.[/quote]

Yeah I have a history of over whelming myself with projects that’s why i’m spending so much time on planning so it won’t happen this time.

[ul][li]I started by spending the entirety of a sixteen hour car ride reading the code to get an understanding of it.[/li]
[li]Then whole bunch of brain storming and thinking[/li]
[li]Created the outline I posted[/li]
[li]Continued to break it up more and more until it became a sorted list of methods (still working on this)[/li]
[li]BAM! TODO list broken up into small steps… i’ll start with the base designation[/li][/ul]

Right now my biggest problems are figuring out git and vis. Then syntax… can I put up a [CR][WIP] PR of sudo code?

PRs generally should contain code that is actually compilable. It doesn’t need to be working - you can have stubs that do nothing (but have informative names), but it should be valid C++.

Keep the whole thing small. Any PR above 300 lines changed (300 added and 300 removed is pushing it) risks getting delayed heavily due to problems with reviews, anything above 1000 lines changed generally gets outright rejected unless it’s all JSON because it’s nearly impossible to find all the bugs in something of this size.

If your ideas require huge changes, break them up into smaller parts that can be tested individually.

PRs generally should contain code that is actually compilable. It doesn’t need to be working - you can have stubs that do nothing (but have informative names), but it should be valid C++.

Keep the whole thing small. Any PR above 300 lines changed (300 added and 300 removed is pushing it) risks getting delayed heavily due to problems with reviews, anything above 1000 lines changed generally gets outright rejected unless it’s all JSON because it’s nearly impossible to find all the bugs in something of this size.

If your ideas require huge changes, break them up into smaller parts that can be tested individually.[/quote]

Cool thanks

https://github.com/CleverRaven/Cataclysm-DDA/pull/6925#issuecomment-38744346

:wink:

Not merging doesn’t imply not reviewing.

A great deal of the bugs and bad designs can be detected with just pseudocode.

It’s more a matter of since I haven’t worked in C++ before I’ll spend all my time buggering around with syntax and getting annoyed that i’m not getting anywhere. If I write sudo code, I can just get all the implementation ideas down and be like “Look I do-ed something!” And then worry about translating it after I have a program and won’t be rewriting everything. Plus, you don’t really need to understand all the ins and outs to translate it so on the off chance I burn out or something it might still be useful.

[quote=“Coolthulhu, post:10, topic:14225”]Not merging doesn’t imply not reviewing.

A great deal of the bugs and bad designs can be detected with just pseudocode.[/quote]
Yes, I know that well in my own case. :smiley:

Very excited about this! I’m currently writing a lengthy guide on handling NPC followers and once features of this are implemented I’ll update the guide. My guide won’t include numbers from code or anything specific like that, but as you add features let me know and I’ll make sure it’s documented correctly! Also free to help test bugs and give ideas. It’s your project so let me know what you think!

Cool, thanks a lot. Understandable documentation is always really nice and something cataclysm lacks very much.

I know currently the game has the the ability to “Manage Zones” with the default hotkey ‘Y’ I feel like a lot of your methods could benefit from expanding this feature! Currently it only allows you to prevent Autopick up in a zone and Prevent NPC pickup. But perhaps the framework is already there for many of your ideas!

So, I have been extremely tired all last week and got only a couple productive hours of work in but I made some changes so I figured i’d give an update on where I am.

Constructions: (Base command is core. sub components must be built connecting to each other/ base command)

[ul][li]“Base Command” basically a desk. creates a “base” when placed which takes over current submap. Examine to change base’s rules and priorities(TODO)[/li]
[li]“Computerized Base Command” place computer on control desk. will allow use of other things in future. upgrades base command[/li]
[li]“Networked Base Command” will allow even more stuff in future and utilizing sub components . upgrades base command.[/li]
[li]“Bulletin Board” Examine to see base rules (TODO)[/li]
[li]“Electric notice board” upgrades Bulletin Board. examine to see base status and rules (TODO)[/li]
[li]“Security Systems Controller” examine to control security and defense systems (TODO)[/li]
[li]“Intercom System” instruct NPCs all at once (TODO)[/li]
[li]“Radio System” Communicate with outposts (not implementing for a while)[/li][/ul]

A base class successfully takes over a sub map upon initialization and removes all spawn points. Creates a non-saved struct that tracks information such as # of guns using each ammo type and ammo amounts in the base for quick access by other things. Method to define and mark what is and isn’t in the actual base fully planned and partially written.

TODO: link construction creation to base creation.

Honestly most of the time has gone into figuring out the existing map code which suffers severely from poor documentation and is very convoluted. (at least it’s very different to how I’d do it and thus hard to understand) I should only need another block of productive programming to get a PR up with the basic base designation.

Did’t actually know about that… I’m leaving the area management till later but it might be useful then.

That “taking over the submap” sounds alarming, as does the information tracking struct.
Submaps are fragile and there is a lot that could go very wrong here.

PR as soon as possible, even if it doesn’t work yet.

[quote=“Coolthulhu, post:17, topic:14225”]That “taking over the submap” sounds alarming, as does the information tracking struct.
Submaps are fragile and there is a lot that could go very wrong here.[/quote]

you pass it the submap during initialization so it can read the map information. Right now the only changes it makes are removing spawn points so you don’t get hulks appearing INSIDE the base though I would like a custom map symbol/name in the future.

The struct itself is fine. It’s a couple of unordered maps. I’m going to link it’s updates to player or NPC actions so it shouldn’t cause any real overhead.

But yes, hopefully in the next day or two…

it would be interesting to use this to create self sustaining survivor camps that actually use have a dedicated system of survival. unlike the survival refugee center which (supposedly) keeps people fed by trading. also being able to control npc’s might allow for automated survivor settlements with a farming system and rain collecting water system, that would make the game feel really alive.

I really like the idea of NPCs building stuff while player is away. It’d be cool if NPCs challenge players leadership from time to time so you have to work hard to make happy and loyal settlement.

One question. How should this camp reality bubble work? Like one around a player or something simplistic?