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

basecamps: add modular basecamps #31115

Merged
merged 3 commits into from
Jun 12, 2019

Conversation

mlangsdorf
Copy link
Contributor

@mlangsdorf mlangsdorf commented Jun 4, 2019

Summary

SUMMARY Features "basecamps: add modular basecamps"

Purpose of change

Addresses #26341

Describe the solution

reorganize the basecamp recipe files by moving them into their own file and giving the primitive field camp file a more meaningful name.

add support for basecamps being able to autocalculate their upgrade build time and requirements. For that to happen, all common terrain constructions need to have a construction definition, but some constructions, like deep and shallow pits, are not meant to be selectable by the user. add the concept of a hidden construction, and add definitions for the shallow pit and deep pit construction.

add a new "blueprint_autocalculate" field to blueprint recipes. When it is present, recipe::finalize calls a function that:

  1. calls a mapgen_update function that creates a tinymap of dirt, applies the blueprint mapgen_update to that tinymap, and then returns maps of all the non-dirt ter_ids and furn_ids to their respective counts.
  2. then passes those maps to function in construction that takes all those ter_ids/furn_ids, finds the construction(s) that result in those ids, and then returns a map of requirement_ids to counts of those requirements.
  3. those requirements are then added to the reqs_internal and resolved normally.
  4. one more function then eliminates any duplicated tools or qualities and consolidates similar components.

add support for blueprints that don't have an oter_id attached to them, but are pure mapgen_update functions.

also, add a recipe_dictionary entry for blueprints, similar to the existing autolearn entry.

add a new blueprint keyword "blueprint_excludes" which can be used to create mutually exclusive branches in an camp upgrade path.

the list of completed blueprint_provides is compared to an upgrade's blueprint_excludes. If there is a match, the recipe isn't available.

There is a second list of in_progress provides, which is used to prevent people from building two mutually exclusive upgrades at the same time, while also preventing them from building upgrade B that requires upgrade A before upgrade A is completed.

reorganize the basecamp code slightly by adding a base_camps:: namespace and moving various bits of code into it.

NPCs will work on a single task for up to 11 hours, but on longer tasks, they'll only work 10 hours out of every 24. Add functions to calculate the workload from the raw task times, and update most of the existing blueprints.

add support for retrieving available basecamp upgrade path starts and expansion by oter_id from the "all_faction_base_types" and "all_faction_base_expansions" recipe groups. Also populate the expansion tabs in the basecamp control window image the same way.

Let the player select from all available basecamp upgrade path starts if there is more than 1 available for the selected basecamp terrain.

Select available upgrades from recipe_dict's collection of construction blueprints.

add the JSON definitions of the modular field camp. It can be configured to be very similar to the existing primitive field camp or built as a single large building made from wattle-and-daub, wood panel, or metal. The player can upgrade it piecemeal in the order they please. It's also going to be easier to add new features to it in the future.

Describe alternatives you've considered

This PR is huge but it includes 3600 lines of JSON changes and additions. I'd like to break it down into more manageable chunks but it doesn't decompose nicely: there's a bunch of necessary changes up front that doesn't do anything on their own and then suddenly it all comes together.

An early draft of this was submitted in #31055 but I prefer this version.

Additional context

Some pretty pictures:

Modular field camp built quickly from tents and wattle-and-daub
MFC_Primitive_complete

Full modular field camp hardshell built from wattle-and-daub
MFC_Semiprimitive_complate

Modular field camp buildings built from a mixture of tents, wattle-and-daub, wood panel, and metal.
MFC_Mix_andMatch

@mlangsdorf mlangsdorf added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Player Faction Base / Camp All about the player faction base/camp/site labels Jun 4, 2019
@Night-Pryanik
Copy link
Contributor

Addresses #26431

I believe that's wrong issue number.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the recipe code, and I only partially understand the Basecamp code, I will go back over it with more scrutiny later and see if there is anything I can meaningfully review.

doc/BASECAMP.md Outdated Show resolved Hide resolved
src/construction.cpp Outdated Show resolved Hide resolved
}
}
if( near_fields < 4 ) {
popup( _( "You need more at least 4 adjacent for camp expansions!" ) );
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended to specify the terrain needed nearby?

@ZhilkinSerg ZhilkinSerg self-assigned this Jun 4, 2019
src/faction_camp.cpp Outdated Show resolved Hide resolved
src/faction_camp.cpp Outdated Show resolved Hide resolved
add support for blueprints that don't have an oter_id attached to them,
but are pure mapgen_update functions.

also, add a recipe_dictionary entry for blueprints, similar to the
existing autolearn entry.
add support for retrieving available basecamp upgrade path starts and
expansion by oter_id from the "all_faction_base_types" and
"all_faction_base_expansions" recipe groups.  Also populate the
expansion tabs in the basecamp control window image the same way.

Let the player select from all available basecamp upgrade path starts if
there is more than 1 available for the selected basecamp terrain.

Select available upgrades from recipe_dict's collection of construction
blueprints.
add the JSON definitions of the modular field camp.  It can be configured
to be very similar to the existing primitive field camp or built as a
single large building made from wattle-and-daub, wood panel, or metal.
The player can upgrade it piecemeal in the order they please.  It's also
going to be easier to add new features to it in the future.
@mlangsdorf mlangsdorf force-pushed the modular_basecamps_phase_2 branch from d529612 to 02a566f Compare June 10, 2019 10:09
@ZhilkinSerg ZhilkinSerg self-assigned this Jun 10, 2019
@ZhilkinSerg ZhilkinSerg merged commit 74d9af4 into CleverRaven:master Jun 12, 2019
@ZhilkinSerg ZhilkinSerg removed their assignment Jun 12, 2019
@mlangsdorf mlangsdorf deleted the modular_basecamps_phase_2 branch June 12, 2019 16:56
@Regularitee
Copy link
Contributor

Can anyone else confirm/deny this change is the one causing the overmap memory erasing bug on game load?

@kevingranade
Copy link
Member

It is, Mark has identified the problem and is working on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing [JSON] Changes (can be) made in JSON Player Faction Base / Camp All about the player faction base/camp/site
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants