-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[WIP]Framework for out-of-reality-bubble NPC activities 1:foraging #35540
Conversation
This is a question about knock-on impacts from this kind of change, I feel like I currently have a hard time finding large game already for hunting for food. Will NPCs have the same problems? Will these problems get worse as time goes on? Edit: I wondered mainly with the changes to mutant meat containing toxins as I could basically see multi season games being forced into vegetarianism or raising livestock. All of which are reasonable possibilities. |
To be honest with you, I've not thought about the impact on hunting and how that affects the population of animals in the area, or how they are spawned. Thats a problem for another time lol. Though I suspect it can be abstracted somewhat, when it comes to spawning potential animals for an NPC to hunt. For the moment - this PR just deals with the known quantity of foraging from plants. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should encapsulate all the job implementation details in classes and just call some standard accessor functions so that npc::
doesn't know the details.
src/activity_handlers.cpp
Outdated
std::vector<item *> dropped = ma.put_items_from_loc( loc, pos, calendar::turn ); | ||
for( item *it : dropped ) { | ||
if( messages ) { | ||
add_msg( m_good, _( "You found: %s!" ), it->tname() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all these add_msg()
need to be add_msg_player_or_npc
and need to be gated on whether the player can see the NPC or else the player is going to get spammed by messages for NPCs harvesting bushes on the other side of the world.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_msg_player_or_npc
already checks whether the player can see the NPC (or monster) and only displays the message if the player can see it.
src/npc.cpp
Outdated
|
||
void npc::check_mission_resume() | ||
{ | ||
if( offscreen_job == NPC_OFFSCREEN_JOB_FORAGE ){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this right upfront.
Create an npc_offscreen_job::
class which contains whatever generic data and functions all off-screen jobs need to have.
Create an npc_offscreen_foraging::
class which is a child class of npc_offscreen_job
.
Create an npc_offscreen_no_job::
class which is a child class of npc_offscreen_job
and is the default null job.
if( has_offscreen_job() ) { check_mission_resume(); }
becomes offscreen_job.work_on_job()
which is an immediate return in npc_offscreen_no_job
and if( at_capacity_or_over_time_list_for_travel_job() ) { ...
for npc_offscreen_foraging
But basically we want to encapsulate all the details of how the offscreen job actually works in npc_offscreen_job
and it's child classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I've attempted that, my first ever go at this kinda structure, so it's probably all wrong, but its working, at least.
…y using ui_manager
Window manager for properly refreshing and resizing multiple layers of windows
Use ui_manager in main menu and related menus
924f105
to
39e00e3
Compare
ad63e77
to
8e68539
Compare
621a68e
to
b7106d0
Compare
0f30a43
to
d432807
Compare
Feel free to reopen when you come back. |
Summary
SUMMARY: Features "Framework for out-of-reality-bubble NPC activities 1:foraging"
Purpose of change
First step in a framework for NPCs to be able to actually travel to locations on the overmap and do stuff there, loot, forage, build, when they arent in reality bubble.
Describe the solution
You can now talk to your follower and ask them to go foraging for you.
They will actually travel to a nearby forest ( can see their progress on the overmap ), then some time passes to simulate how long it would take to forage that area ( based on NPCs survival skill )
When this reaches 100%, the area is loaded in a simulated map ( tinymap ) and the foraging is done in a slightly abstracted way, from bushes and trees and anything that actually is available there, the shrubs will become empty, the trees will actually be harvested., and the NPC will then be carrying pinecones and wild veggies etc.
IF they are loaded into the reality bubble during this time passing, then this resolves the % completion up to that point, then the NPC transitions to a local player_activity,so you can then see them doing the same thing - runinng around foraging.
So hopefully - the results are the same, whether its simulated out or in reality bubble, and the transition should be smooth from out-of-bubble simulation to in-bubble activity.
Once that area has been foraged ( and the NPC keeps track of what areas theyve foraged already ) , theyll set their overmap travel target to another forest, they will keep this up until 6 hours pass or their inventory is full.
When theyve finished this, they will then travel on the overmap back to their base location, their base location is your facton camp ( if they are assigned to it ) or the players location.
In the future this kind of thing will be able to do two main things.
Replace faction camp missions, so the NPC wont dissappear into the ether then reappear when the job is finished, they will actually travel to the spot, do the work, then travel back and the results of the job will be real results that really loot/forage that area, and youll be able to follow them and see them doing the activity, or radio them and call them back.
Dynamic NPC factions - they should be able to form their own faction camp and go off looting and foraging, this is the first step in that direction.
This lays the foundations for this sort of framework, set a target, travel there, do the thing, and handle out-of-bubble/in-bubble transitions.
so for now - just foraging, and I havnt used it to replace the faction camp mission yet.
Describe alternatives you've considered
Testing
Tested numerous times of telling NPC to go foraging, waiting hours, for them to come back and deposit the stuff in a nearby zone.
Tested following them and they did the activity in real-time, then walked off to another forest and repeated it until their inventory was full,
tested letting them start the foraging at a forest, then walked near them so they loaded in halfway through the % completion, the area "resolved" and half of the shrubs were foraged, and the NPC finished the rest with a local activity.
tested various permutations of telling them to change their activity, tell them to guard, tell them to follow, radio them, while they are travelling / working.
Despite this, marking as WIP, as it will undoubtedly be post 0.E, and being NPCs I expect them to break in numerous ways I cant even imagine right now, and I will expect @mlangsdorf and others to have opinions on how best to structure this, so I expect a few more iterations.
Additional context
N/A