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

[READY] Sort out my loot, please! #24488

Merged
merged 27 commits into from
Aug 24, 2018
Merged

Conversation

Robik81
Copy link
Contributor

@Robik81 Robik81 commented Jul 26, 2018

What it does

This PR adds a feature to sort out the pile of loot you just made in the middle of your base.

Why I did it

Well, you see, Zones was almost useless game feature nobody ever used and it was kind of sad... Naah, just kidding. I was happily playing the game, and after I moved to a new base, I was staring on the fore-mentioned pile of loot, wanting to trow up and jump out of the window, not necessarily in this order.

Sorting the loot is annoying busywork, not that funny even the first time you are doing it, not to mention for hundredth time. Also, it was sort of silly to sit in the middle of 3x3 squares of loot piles... efficient, but silly to look at.

It is time for some neat QoL feature, I say!

How it works

Since picture is worth thousand words... let's spam the PR with several of them.

image

This is me, sadly looking at the loot pile near the stairs (paper box). By the way, that corpse down there is a body of a volunteering zombie cop, who contributed some filthy clothing and armor for testing purposes. Round of applause for our MVP, please!

image

I defined a zone or two, here and there... name and type are the same text, that is because I tweaked adding zones to offer name of the type as default for the name of the zone, and had no reason to change it to something else, really.

image

Here's complete list of zone types. You don't have to define them all, loot without defined zone will either fall-through to parent zone (like Perishable Drink->Drink->Food), or stay on the unsorted loot pile.

image

Here is the result of "Sort out loot" action - you can compare it with picture of defined zones.

image

And here is the log.

Hope you liked it and "Death to manual sorting!".

Extra features:

  • new Ignore zone, if you have a bed or a dedicated place for specific tool / item inside your Unsorted zone, you can prevent sorting of such tiles by designating them as an Ignore zone
  • tiles on fire are ignored as a source for sorting out, to prevent moving burning two by four and such out of them
  • while playing, I noticed that I often want to do is edit position of a zone, which is the one thing that you can't edit and you have to remove the zone and add it again, there was a case for it in the game code, but it was apparently never implemented, so I implemented it

@ZhilkinSerg ZhilkinSerg added <Enhancement / Feature> New features, or enhancements on existing [JSON] Changes (can be) made in JSON [C++] Changes (can be) made in C++. Previously named `Code` Controls / Input Keyboard, mouse, keybindings, input UI, etc. labels Jul 26, 2018
@cainiaowu
Copy link
Contributor

Fantastic feature! However what if my loot zone is very small and sorting keep spilling them into adjacent unsorted pile.
Will this become a infinity loop?

@cainiaowu
Copy link
Contributor

Also add some ingame help and tips for the player so that they can know how to use this awesome feature.

@Robik81
Copy link
Contributor Author

Robik81 commented Jul 26, 2018

However what if my loot zone is very small and sorting keep spilling them into adjacent unsorted pile.
Will this become a infinity loop?

Should not happen, there is a check if destination loot pile has enough free space. Such items would be skipped and left on the unsorted pile.

@acidia
Copy link
Contributor

acidia commented Jul 26, 2018

This seems kinda familiar... So as far as balance is concerned, unless the plan is to wipe the functionality from NPCs, are you designating a single pile to sort out of as opposed to the existing area sort? What are you expecting your time requirements for the player to be adjusted to?

@ghost
Copy link

ghost commented Jul 26, 2018

Does this apply to vehicle parts? I like to keep different things in different storage spaces, so this would be a godsend if so.

@Robik81
Copy link
Contributor Author

Robik81 commented Jul 26, 2018

This seems kinda familiar... So as far as balance is concerned, unless the plan is to wipe the functionality from NPCs, are you designating a single pile to sort out of as opposed to the existing area sort? What are you expecting your time requirements for the player to be adjusted to?

That is not my plan, I don't even play with NPCs enabled in the first place.

I am personally designating a single pile to be a source of unsorted items, though technically zone can be bigger than one tile and the code covers that. I did not tested multiple tiles behavior though.

Limitation is that player has to be in max 10 tiles range from unsorted pile for feature to work at all, and only zones in 10 tiles from player are covered.

It is meant to cover crafting area and have some leeway for where the player is standing. The only cost is the cost of moving of items, the cost of moving around to pick / drop location is neglected (as is in AFAIK in crafting).

@Robik81
Copy link
Contributor Author

Robik81 commented Jul 26, 2018

Does this apply to vehicle parts? I like to keep different things in different storage spaces, so this would be a godsend if so.

Zones currently do not support vehicles. But it is quite possible I'l add the feature later, after I build new deathmobile. Unless someone beats me to it.

@ghost
Copy link

ghost commented Jul 26, 2018

darn.

@acidia
Copy link
Contributor

acidia commented Jul 26, 2018

But if it's essentially free and instant, why would any one ever bother with having NPCs do it in exchange for food, slowly? The existing function covers most of the reality bubble but I intended to scale that based on how much stuff they had to move, the more stuff, the less radius they would sort in 3 hours.

You're certainly a better coder than me but it does kinda undercut the primary feature of a low level camp, literally 10 days after it got merged. There's got to be some kinda balance otherwise it just invalidates what I just worked on.

@Robik81
Copy link
Contributor Author

Robik81 commented Jul 26, 2018

You're certainly a better coder than me

I don't know about that, maybe more experienced, but probably not even that, as I am not really a C++ programmer.

but it does kinda undercut the primary feature of a low level camp, literally 10 days after it got merged

I can assure you that was not my intention. It was as I said in the OP, I returned recently to the game and got fer up with manual loot sorting while playing. So I browsed the forum, found this thread with Kevin's post in it. Then I browsed issues and commits at git. That is when I found out that there is some recent camp / NPC stuff does some loot sorting, though i did not study it thoroughly.

I decided that Zones are the way to go and implemented it.

But if it's essentially free and instant, why would any one ever bother with having NPCs do it in exchange for food, slowly?

It costs equivalent time as it would take to move same items via move all action from Advanced Inventroy.

Argument could be made that it should take longer - because of distances, and that it shouldn't - because of crafting in crafting range.

I seriously don't know what the the cost of the low level camp is or how you pay your NPCs to sort the loot for you, but balancing of time (or other) cost should not be against NPCs, but against the player who would do it manually (and went insane in the process).

What I am trying to say is, we should not IMO have unfriendly user interface forcing the player to do repetitive and boring manual tasks just to justify some NPCs existence.

@RadHazard
Copy link
Contributor

It'd be great if the two systems could be merged. Let the player sort items themselves at the cost of having to spend their own time, or let an NPC do it at the cost of food and the NPC's time.

One benefit that could be given to NPC sorting would be to make it automatic. Instead of assigning an NPC to a "sort" job, it'd be cool if they could just be given a role as "loot sorter" and have them continuously sort any loot dropped off by the player (possibly requiring the loot to be dropped into a designated "dropoff" point).

@lucasmr
Copy link
Contributor

lucasmr commented Jul 26, 2018

The NPC suggestions would be a better addition on a different PR, I think. No need to delay this for additional features.

@ItsJustAlexC
Copy link
Contributor

ItsJustAlexC commented Jul 26, 2018

I agree, this should be merged asap, robik and acidia could maybe collab. at a later time to heavily improve such a feature...possibly even make designation zones like in df.

@DracoGriffin
Copy link
Contributor

DracoGriffin commented Jul 26, 2018

Zones currently do not support vehicles. But it is quite possible I'l add the feature later, after I build new deathmobile. Unless someone beats me to it.

This. This would be greatly appreciated.

I understand where acidia is coming from, but the difference between the two mainly is: time. Sure, players should be given the option to micromanage to optimize, but most players will easily avoid this extreme monotony/tedium in accordance to the options given to them, by this PR and camp. I honestly see it more as a stepping stone to reducing tedium for player, at relatively fair costs.

First step: manual sorting as it is now. Takes time, tedium, player awareness ("Oh no, where did I put all those multivitamins or gun mods").

Second step: "Automated" sorting (as this PR details). Takes player time. Could be bugs (items misplaced due to player unaware of zone types, etcs).

Third step: NPC sorting (acidia's camp). Takes food and NPC's, rather than player's, time. By this time, food shouldn't be a huge issue as it is for a player early game (before they've managed to set up crops or forage food reliably), but it is a good resource sink/cost.

As this PR skips on movement, perhaps the autosorting time cost could be bumped up 10-25% in move/action cost to "simulate" the movement if unable to actually do the proper pathfinding (although not sure how this goes for player control, seems a bit strange to hit a button and character begins moving itself in accordance to sorting --- the only other time this occurs is with the V - 'Look All Items' where the player can select an item and move towards it
traveltoitem
, so this could be used to do the movement, although trying to min/max volume/weight to autosort could be obtuse). So autosorting could still fall under a long action that is interruptable / stoppable, without taking away agency from the player.

Lastly, what occurs if the player is autosorting and a monster attacks without Safe Mode on? Likewise, what happens during autosorting if a monster gets close with Safe Mode on? Will the character keep sorting and being eaten alive or does it prompt to stop autosorting?

Either way, this came outta left field and seems amazing.

@acidia
Copy link
Contributor

acidia commented Jul 26, 2018

I understand where acidia is coming from, but the difference between the two mainly is: time. Sure, players should be given the option to micromanage to optimize, but most players will easily avoid this extreme monotony/tedium in accordance to the options given to them, by this PR and camp. I honestly see it more as a stepping stone to reducing tedium for player, at relatively fair costs.

Have you tried it? The sort process is instant for the player and only takes "time" in the since that the clock ticked and you have become hungrier. Since you have to feed NPCs anyways, just skip the whole camp. Without any sort of balancing there is literally no reason to have an NPCs sorting gear at all. Which is why I didn't make auto-sort immediately available to the player when I added it. If everything is instant why would anyone ever invest time into NPCs?

@ItsJustAlexC
Copy link
Contributor

If everything is instant why would anyone ever invest time into NPCs?

I think it's quite safe to say that most of us are waiting for someone who would be able to fix Npcs in general. Ones that are actually functioning entities that makes it feel like you're not the only intelligent being in the universe. Until then, NPCs by default just don't have much use. I also think it's safe to say that everyone here is also extremely pleased and satisfied with what you recently accomplished. Like @DracoGriffin said, it's a step in the right direction.

Without any sort of balancing there is literally no reason to have an NPCs sorting gear at all

Ofc there is. Having them do it means you don't have too. But the reverse should also be true. If you do it, that just means theybdont have to and you can let them focus on some thing else. Currently with the rarity of npcs, I wouldn't want to waste an Npc entity to only sort loot. As your camp grows, I don't see a problem with using an Npc as a hauler.

@NoCreativeNames
Copy link
Contributor

PC time is basically the games primary resource. Having NPCs sort items turns an action that normally takes potentially large amounts of PC time into an action that takes NPC time, so it's not made useless by this PR.

@acidia
Copy link
Contributor

acidia commented Jul 27, 2018

All of ya'll are actually testing the change right? 4min to sort 100 steel frames, which is accomplished by a single press of the "O" key as soon as you generate a new character. As opposed to NPCs taking 3 hours to sort items on top of requiring navigating a menu 2x (once to tell them to do it and another to recall them since sorting shouldn't magically be done instantaneously), starting an NPC camp, and recruiting NPCs. I don't see why anyone would go through all of the work for NPCs if we just make the reward instantly available?

@DracoGriffin
Copy link
Contributor

Just to clarify with examples:

Currently, if a player comes back from looting the city, say it takes 15 minutes in-game (assuming the player doesn't make a mistake and put stuff in the wrong piles), but might take a few minutes or longer outside of the game using AIM and such to place everything.

In-game: 15 minutes
Real life: Minutes or more

Using this option to autosort, should also take 15 minutes in-game but time spent outside the game may be instant.

In-game: 15 minutes
Real life: Instant or seconds

Likewise, using NPC autosort should also take 15 minutes in-game BUT it's at the expense of the NPC, so the survivor (and player) are free to do something else in the meantime. Also costs food to "pay" NPC for this work. Again, time spent outside the game should be instant (as soon as survivor drops off loot, they are free to do other actions while NPC(s) begin their work). The caveat to this option is there may not be Strength/volume differentiation (potentially favoring either survivor or NPC in ability to sort) and/or reality bubble/coding limitations.

In-game: 15 minutes
Real life: Instant or seconds

So basically, either autosort option is a QOL improvement (one costs survivor time and the other costs food/NPC time), and not some type of exploit.

So like acidia is pointing out, it should not be a shortcut for in-game time that can be exploited, it should still take the same amount of time regardless, only removing the need for player micromanaging item placement via dropping/AIM use.

@ItsJustAlexC
Copy link
Contributor

ItsJustAlexC commented Jul 27, 2018

4min to sort 100 steel frames

I mean yea in this sense there should be a HUGE balance change, I thought you meant in general "if you can do x, then this just makes npcs obsolete again"

EDIT: what about the AIM system? I'd imagine that would need an adjustment aswell since it does instantly move items that would collectively weigh in the tons?


// Check that we can pick it up.
if( !it.made_of( LIQUID ) ) {
g->u.mod_moves( -Pickup::cost_to_move_item( g->u, it ) );
Copy link
Member

Choose a reason for hiding this comment

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

This needs to factor in cost to shuttle player between loot and target pile.
If you want to reduce trips it can be one trip per available inventory capacity, but then it needs to include inventory insertion/removal time as well.

Copy link

Choose a reason for hiding this comment

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

Fixed here 774ee22 (?)

@kevingranade
Copy link
Member

The reason moe costs are neglected in crafting is that it's assumed to be a very small portion of the action, most of the time is spent doing crafting.
In this case move time is most likely going to be larger than pickup/drop time, so it's too significant to ignore.

@Robik81
Copy link
Contributor Author

Robik81 commented Jul 27, 2018

The reason moe costs are neglected in crafting is that it's assumed to be a very small portion of the action, most of the time is spent doing crafting.

Makes sense.

In this case move time is most likely going to be larger than pickup/drop time

That would depend on whether you are using shopping cart / how much free space you have in inventory, amount of items you need to move, whether or not you are taking items for multiple zones "on the way" in one go...

This needs to factor in cost to shuttle player between loot and target pile.
If you want to reduce trips it can be one trip per available inventory capacity, but then it needs to include inventory insertion/removal time as well.

I agree that time cost should be increased, but precise simulation would need more code than this PR has to date, potentially much more, and I don't think that we need to do such complex simulation. How about we assume the player would move items intelligently and approximate necessary time?

How about cost_to_move_item (already in) + pickup cost + drop cost for each item?

@kevingranade
Copy link
Member

How about cost_to_move_item (already in) + pickup cost + drop cost for each item?

I'm fine with an approximation, but move cost should be included as well.
So someting like 100 (typical flat ground move cost) * rl_dist( src, target) * ( item_volume / player.inventory.total_capacity() )
Basically it makes some costs static instead of measuring them, assumes the player dumps inventory capacity to make room, and amortizes per-item costs assuming multiple relatively efficient trips.

This is in addition to pickup and drop costs per item if you're planning on leveraging player inventory.

@Robik81
Copy link
Contributor Author

Robik81 commented Jul 27, 2018

I'm fine with an approximation, but move cost should be included as well.
So someting like 100 (typical flat ground move cost) * rl_dist( src, target) * ( item_volume / player.inventory.total_capacity() )
Basically it makes some costs static instead of measuring them, assumes the player dumps inventory capacity to make room, and amortizes per-item costs assuming multiple relatively efficient trips.

This is in addition to pickup and drop costs per item if you're planning on leveraging player inventory.

Looks sensible.

I'l implement it as pickup + drop + your formula for move cost and remove the redundant move cost that is already in.

@kevingranade
Copy link
Member

and remove the redundant move cost that is already in.

Yes, it is redundant at that point.

Robik81 added 17 commits August 16, 2018 10:58
gorgon and travis complaints
for food that goes bad but doesn't, like canned stuff
to prevent "food" like ammonia or paper on food piles, even though they do have nutritional values
to not use tiles which are in UNSORTED and also in IGNORE as a source

also prevents tiles on fire as a source
for items that are in food category but don't have comestible properties ,like MREs
prevent using tiles with inaccessible furniture, like filled charcoal kiln, as a source or destination when sortung
where necessary
adds a flag FIREWOOD and adds it to 2x4, log, splinter, stick, pine_bough and stick_long
as per Kevin's request "Alternately, only use available inventory capacity when calculating things in move_item() instead of using max capacity."
@kevingranade
Copy link
Member

I apologise for how long this has taken, move cost looks good now.

I noticed a few major issues.
If the player stands in a hidden location where they can see the target items and destination, and monsters can also see the items, the player can use this feature to teleport items from the source to the destination without risking them.
There is also no check for a path to either destination, so it teleports items through obstacles.

The second issue is simple, juct check for clear paths to item sources and destinations.
The first is trickier because the obvious solution of moving the player around and checking whether monsters can see them is extremely expensive.

@Robik81
Copy link
Contributor Author

Robik81 commented Aug 24, 2018

Yes, I agree that this feature could be misused to teleport stuff from sealed / guarded location. Would have to be done by intentionally misusing the feature for unintended purpose and not by accident though, so it is akin to cheating and at that point, player could use wish for an item. Because this is not multiplayer game and the cheater would ruin the game only for himself, I do not think it is a big deal.

If you disagree, I would like to ask for a temporary leniency instead.

I do have prepared branch for tilling zones, as described in #24826 for PR, which contains the code that would help solve the issue. We would be able to force the player to move to the loot source piles before any item teleportation, which would keep the player honest. I can't PR it beforehand though, as it is dependent on code in this PR.

@kevingranade
Copy link
Member

kevingranade commented Aug 24, 2018

If you plan on moving the player around to make the action happen, we can tolerate the exploit for a while.

A note on exploits, some players characterize exploits as distinct from "cheating", and are therefore willing to use exploits until they are closed, even if it indirectly harms their game experience. Basically, "if the game let's you do it, its allowed".

@kevingranade kevingranade merged commit 3a64f0c into CleverRaven:master Aug 24, 2018
@Robik81 Robik81 deleted the loot branch August 25, 2018 05:28
@JosephCarrington
Copy link
Contributor

There is a bug I often experience where I get stuck in a sorting loop (with the only way to stop being force quit), I wonder if there is already an issue written for it?

@Robik81
Copy link
Contributor Author

Robik81 commented Oct 7, 2018

There was similar problem, when spilled liquid was around, but that was fixed.

If you could provide save or description how it could be reliable reproduced, I will look into it.

@JosephCarrington
Copy link
Contributor

I would love to provide save, but haven't been able to determine where my save files are on Mac with Homebrew.

@ZhilkinSerg
Copy link
Contributor

Saves are in ~\Library\Application Support\Cataclysm.

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` Controls / Input Keyboard, mouse, keybindings, input UI, etc. <Enhancement / Feature> New features, or enhancements on existing [JSON] Changes (can be) made in JSON
Projects
None yet
Development

Successfully merging this pull request may close these issues.