Cataclysm: Dark Days Ahead - Official Forums

Cataclysm: Dark Days Ahead => The Lab - Contributions and Mods => Topic started by: Theundyingcode on September 13, 2017, 02:48:35 AM

Title: Bases and NPC crafting
Post by: Theundyingcode on September 13, 2017, 02:48:35 AM
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:
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on September 13, 2017, 07:07:32 AM
Probably should have started with this but...

SUMMERY OF MAIN PLANNED FEATURES:

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.
Title: Re: Bases and NPC crafting
Post by: CK_Kirbi on September 13, 2017, 09:35:19 AM
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!
Title: Re: Bases and NPC crafting
Post by: DemAvalon on September 13, 2017, 10:05:25 AM
  • 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

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.
Title: Re: Bases and NPC crafting
Post by: Coolthulhu on September 13, 2017, 10:12:01 AM
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.
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on September 13, 2017, 04:38:37 PM
  • 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

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.


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.

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.

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.

Right now my biggest problems are figuring out git and vis.  Then syntax... can I put up a [CR][WIP] PR of sudo code?
Title: Re: Bases and NPC crafting
Post by: Coolthulhu on September 14, 2017, 11:54:39 AM
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.
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on September 14, 2017, 05:50:36 PM
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.

Cool thanks
Title: Re: Bases and NPC crafting
Post by: Zhilkin on September 14, 2017, 09:43:20 PM
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++.

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

Quote from: KA101
Unfortunately we don't merge code that doesn't actually do anything.

;)
Title: Re: Bases and NPC crafting
Post by: Coolthulhu on September 14, 2017, 09:50:25 PM
Not merging doesn't imply not reviewing.

A great deal of the bugs and bad designs can be detected with just pseudocode.
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on September 14, 2017, 10:51:28 PM
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.
Title: Re: Bases and NPC crafting
Post by: Zhilkin on September 15, 2017, 06:17:35 AM
Not merging doesn't imply not reviewing.

A great deal of the bugs and bad designs can be detected with just pseudocode.
Yes, I know that well in my own case. :D
Title: Re: Bases and NPC crafting
Post by: Metalsoul112 on September 16, 2017, 10:17:40 PM
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!
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on September 17, 2017, 12:26:28 AM
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.
Title: Re: Bases and NPC crafting
Post by: Metalsoul112 on September 18, 2017, 05:21:43 PM
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!
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on September 23, 2017, 10:39:32 PM
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)

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.

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!

Did't actually know about that... I'm leaving the area management till later but it might be useful then.
Title: Re: Bases and NPC crafting
Post by: Coolthulhu on September 24, 2017, 02:03:30 AM
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.
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on September 24, 2017, 03:17:33 AM
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.

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...
Title: Re: Bases and NPC crafting
Post by: Reaper310 on September 24, 2017, 08:44:12 PM
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.
Title: Re: Bases and NPC crafting
Post by: EpsilonShadow on September 24, 2017, 09:00:07 PM
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?
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on September 24, 2017, 10:02:19 PM
One question. How should this camp reality bubble work? Like one around a player or something simplistic?

My plan was for something simplistic to avoid causing unnecessary lagg. I have basically pulled a bunch of information into the base class for easy reference partially as a speed increase at the cost of memory but also to simplify things for me as I'm not completely familiar with the code's structure. The side effect of doing so however, is that I have a completely separate object containing the base's stats. Thus, I can run simple use/productivity vs. time calculations and make changes accordingly upon the player's return.

Implementing reality bubbles is still far in the future though.
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on October 16, 2017, 09:13:51 PM
So I got distracted by a new internship and playing the surge (defiantly have addictive personality trait) and haven't touched cdda at all for the last 2 weeks.  I feel like I promised a bunch but am not delivering...

Anyways, i'm just about to get beck to work. As i left it the actual designation of a base is almost done and should be up as a PR for review within a day or two. There is one glaring problem already which is that I thinking submap = map tile. As a result, right now it will only actually work if your base fits into a submap.  Also, I forgot about solid rock so it's breaks in basements as well. (should be easy fix)

Here's what the first PR will(should) look like:

There are some other things I've added but not really implemented yet; base NPC is just a header file and the other base components just sit there and look pretty; PA system- summon/instruct NPCs from command instead of finding them, Coms System - Communicate with/allow for outposts, security controls- manage the currently non-existent base security/defense systems and finally, higher level Command Desks- levels up base.  I'm also planning a "Networked" upgrade which will let you "wire" your base and spread duplicates of the base components around your base.
Title: Re: Bases and NPC crafting
Post by: RipRoarinBoogerPenis on October 18, 2017, 11:53:06 AM
Fantastic, thrilled to see this project hasn't been forgotten!
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on October 18, 2017, 06:32:52 PM
Fantastic, thrilled to see this project hasn't been forgotten!

No just generally slow moving and kinda in a life slump at the moment.
Title: Re: Bases and NPC crafting
Post by: Beetlecat on October 20, 2017, 07:50:14 PM
No just generally slow moving and kinda in a life slump at the moment.

Ugh. Totally hear that -- Hang in there, etc. ( ;) ) but in the mean time, thank you for your efforts and creative input on this. Looking forward to what comes of it.
Title: Re: Bases and NPC crafting
Post by: AwonGardino on October 21, 2017, 02:57:22 PM
Sounds too good to be real. Will you make also a social interaction with NPC (Daily talk, telling a stories, etc) and relationships like friendship and rivalry (without killing eachother)?
Title: Re: Bases and NPC crafting
Post by: darktoes on October 22, 2017, 01:38:01 AM
Yeah, regardless of how long we have to wait, this would be an amazing addition to the game. I can't wait to see what happens. Keep at it man (When you have the time, of course)!
Title: Re: Bases and NPC crafting
Post by: chronicpayne on October 22, 2017, 02:54:44 AM
Second that, this looks fantastic, really hope everything pushes through to see the light of day!
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on October 23, 2017, 08:56:48 PM
So my computer has crashed out... I was expecting it to happen sometime but I thought I had another couple months before it happened.

Last December, My computer got a bad virus on a trip and I absolutely needed to get a bunch of work done. With no secondary device for internet and no backup tools I ended up manually disabling/deleting  a whole bunch of stuff. I got it working and finished my work but never got around to actually fixing the computer since it worked (mostly) but it has been slowly degrading since. I guess it finally decided to call it quits.

I'm getting it back up and running but its put me behind with other stuff. I'm not giving up on this project but please don't be wanting on me. Sorry.

EDIT: I should have all of my work saved elsewhere but, I was using a Visual studio license from my old school that I am not interested in recovering so it might take some time to dig it out. (Never liked vs to many things make it too complicated to do simple things but the windows builds were for it.) I'm putting in a Linux partition and will be working from that. Worst comes to worst, redoing it is simply a matter of retyping it.
Title: Re: Bases and NPC crafting
Post by: Coolthulhu on October 24, 2017, 04:10:02 AM
Not PRing anything and not even having it on github is a big risk. You can lose entire project easily if you have no backup, no history, nothing. I lost many big changes to editor crashes.
PRing (with "[WiP][CR]" tags) even something that doesn't work would get you hints on how to get it to work. Trying to figure out everything by yourself will not only slow you down, it will prevent you from learning many things.
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on October 24, 2017, 05:31:30 AM
I found it.  I wasn't worried about having lost it as everything thing is backed up to 4 different locations; the problem was I didn't know where VS put the git stuff.
Title: Re: Bases and NPC crafting
Post by: Maarberg on November 02, 2017, 04:27:16 PM
I'm super excited for this mod. Its what I've really been wanting from C:DDA.

When I started playing video games back in the 90's their was a game about Japanese warfare. the first 10 levels where you as a samurai fighting other samurai. Each level was harder with more enemy's. Every one died in one hit. Including you. Then you took over an area and now you were in charge of a group of samurai. After conquering the surrounding area (about 15 levels) you then began your fight to conquer all of japan and become Emperor. Games with this pattern are so much more interesting to me. I could always see how easy it would be for C:DDA to have this but it wasn't their. Your mod feels like its going to fill in the gap. Thank you for reaching, to create this.
Title: Re: Bases and NPC crafting
Post by: Theundyingcode on November 02, 2017, 05:51:15 PM
I forgot to announce it here but,  I PRed the start.  It's still just a framework and not ready to be added yet but it's up for review.

https://github.com/CleverRaven/Cataclysm-DDA/pull/22311 (https://github.com/CleverRaven/Cataclysm-DDA/pull/22311)