Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving faction camp maps #18

Open
mlangsdorf opened this issue Aug 9, 2018 · 6 comments
Open

Improving faction camp maps #18

mlangsdorf opened this issue Aug 9, 2018 · 6 comments

Comments

@mlangsdorf
Copy link
Owner

Add JSON support for defining an upgrade.
Instead of replacing the maps wholesale (why why why what a non-great idea), create an upgrade template, something like this:

"upgrade_terrain": {
  "startpos": [ 3, 3 ],
  "skills": [ [ "fabrication", 5 ], [ "survival", 2 ] ],
  "changes": [
    { "terrain": "t_brick_wall", "x": [ 0, 5 ], "y": [ 0, 0 ], "time": 240 },
    { "terrain": "t_brick_wall", "x": [ 0, 0 ], "y": [ 1, 5 ], "time": 240 },
    { "terrain": "t_brick_wall", "x": [ 1, 5 ], "y": [ 5, 5 ], "time": 240 },
    { "terrain": "t_brick_wall", "x": [ 5, 5 ], "y": [ 1, 2 ], "time": 240 },
    { "terrain": "t_brick_wall", "x": [ 5, 5 ], "y": [ 4, 4 ], "time": 240 },
    { "terrain": "t_door", "x": [ 5, 5 ], "y": [ 2, 2 ], "time": 120 },
    { "furniture": "f_bed", "x": [ 1, 1 ], "y": [ 3, 3 ], "time": 120 }
  ]
}

which would be a 6x6 roofless brick building, starting at offset 3, 3 on the map, with a single door and bed inside.
The building algorithm would proc every hour inside the reality bubble and would check to see how much stuff the NPC could have built in the hour, then look at the terrain/furniture at a location and either add a change or if that change is already there, skip to the next one. Construction outside the reality bubble wouldn't happen but would be caught up when the reality bubble is loaded. Supplies would be consumed piecemeal. Work would break if the NPC can't change the terrain because of a vehicle in the way.

Lot of work, but the advantages:

  1. Supplies are consumed gradually
  2. Visible progress is being made.
  3. Not replacing maps, just churning terrain and furniture, so no need to fuck with vehicles or keep them off site.
  4. Player can contribute because NPCs just skip bits that are already complete.
  5. Possibly could actually have NPCs in location - better immersion.
  6. Multiple NPCs speed up work.
  7. Can take NPCs off the job, suspending work, and restart it without much penalty because update always starts from 0,0 position and checks each tile.
  8. Possibly easier for other people to contribute.
@mlangsdorf
Copy link
Owner Author

I've got a script that spits out the differences between camps:

comparing old base_camp_0 to new base_camp_1
   0: ........................
   1: ........................
   2: ........................
   3: .................WWWWW..
   4: .................W;;;W..
   5: .................D;G;W..
   6: .................W;;;W..
   7: .................WWWWW..
   8: ........................
   9: ........................
  10: ........................
  11: ........................
  12: ........................
  13: ........................
  14: ........................
  15: ........................
  16: ........................
  17: ........................
  18: ........................
  19: ........................
  20: ........................
  21: ........................
  22: ........................
  23: ........................
comparing old base_camp_1 to new base_camp_2
   0: ........................
   1: ........................
   2: ........................
   3: ........................
   4: ...................bb...
   5: .............U..........
   6: ........................
   7: ........................
   8: ........................
   9: ........................
  10: ........................
  11: ........................
  12: ........................
  13: ........................
  14: ........................
  15: ........................
  16: ........................
  17: ........................
  18: ........................
  19: ........................
  20: ........................
  21: ........................
  22: ........................
  23: ........................
comparing old base_camp_2 to new base_camp_3
   0: ........................
   1: ........................
   2: ........................
   3: ................$.......
   4: ................$.......
   5: ........................
   6: ................$.......
   7: ................$.......
   8: ........................
   9: ........................
  10: ........................
  11: ........................
  12: ........................
  13: ........................
  14: ........................
  15: ........................
  16: ........................
  17: ........................
  18: ........................
  19: ........................
  20: ........................
  21: ........................
  22: ........................
  23: ........................

still need to figure out how acidia was doing stuff, but hopefully I can replace his overmap gen with tailored stuff.

@Maddremor
Copy link

With this method you could also have buildings smaller than an entire overmap tile and thus having a more compact base.

@Maddremor
Copy link

However, how would this recognise terrain partially built by the player? Would the resource cost be itemized on a per tile basis as opposed to being summed up for the entire upgrade recipie?

@mlangsdorf
Copy link
Owner Author

Right, resources are consumed on a per tile basis as the work is performed.

When you requested an upgrade, the camp manager would give you an estimate of the time to complete and material cost based on the upgrade plan.

Each time you bring the NPC (or possibly overmap tile) into the reality bubble, the NPC would calculate the elapsed time since he last performed work. Then he'd look through the upgrade plan, find the first piece of work that needed to be done that can be done with the available materials, and perform that work. He subtract the time taken from the elapsed time, consume the materials, and if there was elapsed time remaining, move on to the next tile. When the relevant tiles match the upgrade plan, he reports to the camp manager that the job is complete.

So if you're upgrading to camp3, the upgrade plan is essentially 4x $. If you build the first one, the NPC will build the second instead. If while the NPC is building the second one, you destroy the first one, when the NPC goes looking for the next piece of work, he'll go back and rebuild the first one.

The NPC camp manager would also be able to detect/report that you're out of materials before an upgrade plan is complete, or if there's some obstruction/obstacle that prevents completing the upgrade plan: your truck is in the way, or you're trying to build on lava or whatever.

I'd really like for work to be performed on an hourly basis, whether or not you're in the reality bubble, but I don't know if that's currently feasible. It would great if NPCs did stuff outside the reality bubble, though.

@mlangsdorf
Copy link
Owner Author

While working through the npctalk refactor, I noticed that the refugee ranch upgrades are already handled something like this, though it's all hard-coded and instant.
When I start real work on this, I'm going to move all that to JSON. Then I'll add a repairman to the refugee center, who will go around repairing windows smashed by zombies / upgrading the places defenses over time.

@mlangsdorf
Copy link
Owner Author

Figured out why acidia used overmap tiles: so he could check the number of the overmap tile name as a way to determine what level of faction camp you'd built. That's going to break if we start doing flexible upgrades, plus it leads to wackiness like the player deconstructing buildings for parts but still getting the benefits of the buildings.

So let's make some use of out basecamps. They're already written to the save file, we just need to expand the definition. They're currently associated with bulletin boards but they don't (as far as I can tell) depend on them.

So expand the basecamp definition to include feature flags and terrain locations. As you upgrade, you get flags. Dialogue options are controlled by flags.

If the code can "watch" individual pieces of terrain or trigger callbacks when terrain is changed, it would be easy to detect if a piece of furniture was destroyed or in use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants