-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add priority field to zones, use in loot sorting. #79353
base: master
Are you sure you want to change the base?
Conversation
…placing loot. Update existing zone selection tests and add new ones to test the new functionality.
…into zone_priority
… one call to reduce repetition. Used this only in code already touched and tested by this PR for now.
Why do you need a separate field for priority when you already have order in the list? Just make zones closer to the top take precedence, which IIRC is already the case within a type. |
To me the priority and positioning in the display are different concepts. I like to order the zones for display within the zone manager by world position so that I can find them more easily. I often have a daft number of zones. But I'd be happy to drop the new field and just use order in the list instead if that's the consensus. |
I'm in favor of separating zone order and priority, when I make the zones for my base I make them and organize them in order with their distance from one another, so that I can easily locate them. |
@Stu33 What do you think about viewing \ or even editing priorities from the main zone manager table? |
Please resolve clang tidy errors |
I like the idea of displaying the priority on the main zone list, but it's
already short on space for displaying zone names. Perhaps I could
investigate that in a new PR if this one and #79347 are accepted?
…On Mon, 27 Jan 2025, 05:30 o175, ***@***.***> wrote:
@Stu33 <https://github.com/Stu33> What do you think about viewing \ or
even editing priorities from the main zone manager table?
—
Reply to this email directly, view it on GitHub
<#79353 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXRMU7454FMSMU3K7YKHCAD2MW76BAVCNFSM6AAAAABV4RYDFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMJUHA3TQNBTGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I personally think you may be better with moving zone stuff to imgui, it sound like having proper mouse and better UI would benefit it, and make your further work much easier |
Was the issues raised in #35782 resolved? |
Sorry, I missed #35782 when considering this. Thanks for pointing it out.
My changes have exactly the same problem in terms of turning this into an exhaustive search of the zones, although most should be rejected pretty quickly if they don't match. I've not noticed that causing a problem in my current game, but I can see the point Kevin made back then about performance issues in the future or for situations I've not seen. I'll look into what I can do to fix that.
|
RE the UI, I had hoped to just learn one are of code at a time, but I agree moving to imgui is a good idea. I'm happy to do it, but perhaps that would belong in a new PR rather than making this one bigger?
|
Sure, i just point out that it would be easier for you to start with imgui and then expand it than the other way around; no issues finishing this and another PRs of yours before doing UI |
(TLDR; skip to the numbered list below and express a preference please?) I can see a few ways to proceed. I wonder what anyone thinks is best? Given Kevin's comments on #35782, perhaps Kevin or someone else more familiar than me with plans to use zones in faction camps and other NPC activities could comment? This change affects only the users of the zone_manager::get_near_zone_type_for_item() method, but like I said in the description that does include loot placement from NPC missions and trader goods placement as well as loot sorting activities. The implementation before this PR did a search through LOOT_CUSTOM zones, then all LOOT_ITEM_GROUP zones, returning as soon as it found a matching zone within range. If none of those matched it would determine which zone types could match the item and search for near points in the caches for those zone types and matching faction in a specific priority order. Note at this point it just finds the best zone type ID, not the best point; the loot sorting activity then calls zone_manager::get_near to get the std::unordered_set of all points of a matching zone type within range, so there is no kind of priority applied between zones of the same type unless by accident of the implementation of std::unordered_set on a given platform. It's also going to do the exhaustive search through custom and item group zones even if the correct match ends up being a firewood zone, weapon zone or whatever. My initial implementation instead did an exhaustive search through all zones, quickly skipping any that don't have a matching faction, are disabled or are lower priority than the best seen so far. Then it checked whether the zone's bounding rectangle was within range and whether the zone was a suitable destination. It does need to iterate through all zones rather than returning as soon as a match is found. I've done my best to keep that quick, but if there are large numbers of zones that are not custom or item group ones then it probably will be slower than the pre-existing code. Having determined the best zone ID and priority, it then calls an overload of zone_manager::get_near to make another search through all the zones and calculate covered point sets; I think this second call could be mostly optimised away by making the first search optionally collect covered points as it searches, or it could make some use of the point caches, but I didn't do that yet. Possible solutions to allow this PR to proceed without hurting other uses of zones:
Presumably the non-default priority zones will just be user-added zones, so there won't be many of them. This means most of the extra caches in solution 2 and the priority ordered lists in 3 will be small. Option 1 is a much smaller change to the pre-existing code and I think is still better than having no priority control. If nobody else has an opinion I'll go ahead and implement option 3 from that list. I think this will have minimal impact on existing uses that stick to default zone priority while allowing maximum flexibility for zones the player configures. But please tell me if you think differently or if this PR won't be accepted regardless of any of those choices. |
Summary
Features "Add priority field to zones, use in loot sorting."
Purpose of change
Sometimes there are multiple zones that might be valid to place an item into when sorting the loot or placing NPC items. The game already has a priority ordering by zone type (custom filter > special cases > specific category > default) but it doesn't always do what the player would like, particularly if there are multiple custom loot zones with filters that match the item. Adding a priority field to zones that the player can edit allows them to get items to go where they want them.
In the future a priority field would be useful for other zone-based activities as well, for example specifying the order in which an NPC should try to complete construction blueprints.
Describe the solution
Add a priority attribute to zones, defaulting to 0. Display it in the zone manager UI and allow it to be set there. The priority may be set to any positive or negative value within the range of an integer.
Use this priority field to select which zone loot is moved to if more than one zone is a suitable target for a loot sorting activity. Zones with higher priority are considered first, even if they would have been disregarded in the previous system (e.g. if you have a priority 1 default loot zone then even weapons will go there rather than to a weapon loot zone with priority 0).
Because this is implemented by changing the zone_manager::get_near_zone_type_for_item method, it also affects placement of NPC items in shop restocking, trade and drops as the result of NPC missions, but unless the player or another PR deliberately changes zone priorities from the default this will have no visible effect.
Describe alternatives you've considered
None. In previous games I have either under-used zones or carefully set up custom filter zones to avoid having more than one possible destination for an item in loot sorting.
Testing
One quick and easy case to demonstrate this, using this zipped save:
repro.zip
Additional context
Examples of the changed zone manager:
![zone_manager_example_1](https://private-user-images.githubusercontent.com/98749055/406743221-ce961093-6f6e-4f81-9c17-b2cb1312cb8b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODgzMzksIm5iZiI6MTczOTE4ODAzOSwicGF0aCI6Ii85ODc0OTA1NS80MDY3NDMyMjEtY2U5NjEwOTMtNmY2ZS00ZjgxLTljMTctYjJjYjEzMTJjYjhiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDExNDcxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYwMTM4MzRlNWE3NzRhOTY1NjZlMjkxMDUxNzk0ODk4NGM2MjczMGZlOGZjOTRkZDhhZWY1ZGMyNzQ4ZWUxZDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.hunZdcaQ11BBiIWDBIwd-_dj9BlEtVqt1zYe6uVshCg)
![zone_manager_example_2](https://private-user-images.githubusercontent.com/98749055/406743250-7603e62a-b0ff-4f29-98be-40c1e48ae038.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODgzMzksIm5iZiI6MTczOTE4ODAzOSwicGF0aCI6Ii85ODc0OTA1NS80MDY3NDMyNTAtNzYwM2U2MmEtYjBmZi00ZjI5LTk4YmUtNDBjMWU0OGFlMDM4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDExNDcxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk5YzFiZmJjZTBlMmQxOGNmM2YxNzUzMmZiNjM1YmY5MjkxNzBhODU4N2Q1MTVkYTA3Y2QzYmFlNzJiZjJlMDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Rtz4a7jhGVysfQltutfmYae0gqx4e3iVTFmKZy3kGRw)
New option to set priority in the zone editing menu:
![zone_manager_edit_zone_ui](https://private-user-images.githubusercontent.com/98749055/406743286-9e3f61f5-8f2f-405c-b20e-3ce59a0d561d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODgzMzksIm5iZiI6MTczOTE4ODAzOSwicGF0aCI6Ii85ODc0OTA1NS80MDY3NDMyODYtOWUzZjYxZjUtOGYyZi00MDVjLWIyMGUtM2NlNTlhMGQ1NjFkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDExNDcxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM0ZDQxYmEzMjVhZTRmNjgwZmNiMWY2MWE2N2QxMTcwODAyNzZhOTU5MTQwZmM3OWY0Y2QzYzkwOTBiZTg4YmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.xGV8MBmZ0tVCUVsWkMBd36kdKFPwCIjgGOomIyGRd0U)
Popup to set the priority:
![zone_manager_set_priority_dialog](https://private-user-images.githubusercontent.com/98749055/406743323-29eacb9a-9ecd-442c-91c0-b5e2c9ed2c51.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODgzMzksIm5iZiI6MTczOTE4ODAzOSwicGF0aCI6Ii85ODc0OTA1NS80MDY3NDMzMjMtMjllYWNiOWEtOWVjZC00NDJjLTkxYzAtYjVlMmM5ZWQyYzUxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDExNDcxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVkZDg5NTIxNzcwYmYwNGRkNDhkYjAyM2E4NWQ1ZWM4MTY1MmUyNTYxNmQ4NDgzZDhkYjMyOTYxMDY4ZTY0YjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.rnCN10Pi4HCoEvvWWHzzUWJumX2AfYQJPQPIASCrR_g)