-
Notifications
You must be signed in to change notification settings - Fork 7
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
Unify location generation and selection #573
Unify location generation and selection #573
Conversation
Options added for key item return path locations, range, whether or not enemies drop keys, and whether or not to maintain continuity (will be applied to the Seraph).
Key item, range and room type properties added. Tidied whitespace and unnecessary initialisers. Moved trview JSON file out of core project.
More robust height checks added for water scenarios - this prevents items being placed in wading locations for TR1. Items will not be placed on room portals or where mincarts stop. Fixed tiles with pickups triggers being excluded. Improved height difference tests between flipped rooms. This targets TR3 where a location has triangles, but the triangulation differs in the flipped state. Added a key item mode flag to allow individual tiles to be excluded in the JSON, but these remain valid for regular items e.g. Lost Valley room 1 tile [7,3].
Update to door mirroring to avoid treating doors that are in front of each other as side-by-side double doors. This only affected the ones at the end of Vilcabamba, which wasn't too big an issue before, but it would be possible with the coming key item changes for the gold idol to appear between the doors, so it would lead to a softlock. General environment updates: City of Khamoon - makes sure a door is open after leaving a challenge room, as key items may end up here. Obelisk - a mod may add a key to exit the level. We now leave this in a default spot rather than picking one from the mods, and key item rando will detect and move it. Mines - return paths added in the TNT area. And similar to Obelisk, we make an added key item static for key item rando to detect.
Return paths added to Opera, Wreck, The Deck, Tibet, and Ice Palace. Fixed flipmap issues in Catacombs ahead of the initial mask being randomized. Added various trigger checks ahead of key item rando. This includes converting some triggers to pickup type so they can be detected and moved, like the mask in Ice Palace. TR2 also has several checks for secret repositioning in environment mods e.g. after we have drained an area. This was specifically looking for stone, jade or gold in some cases. Secret zoning will change so these mods now look for each type.
Return paths added to Lud's and HSC, and updated in Area51 and Hallows. Key item checks performed to move triggers and/or make items visible e.g. old coin in Aldwych.
TR2 replaces P2 items with P3, to allow for the dragon to be placed in each level (the dagger is hardcoded as a P2 item). This was always done after key item rando to allow for zoning of the original items. I forgot to move this logic in LostArtefacts#568. Zoning of these items must now be done based on them being P3. Removed the puzzle reassignment checks from TR3 as it's not applicable there. Also updated the enemy adjustment logic (this clears out unused enemies in heavy-item levels) so that the items can be re-used if needed.
Moved some general consts into TRLevelControl as they're better placed there. Fixed some locations in TR2 that had the wrong room numbers set and one that was missing a skidoo flag.
Key items and secrets will now be placed using identical logic in all games. This uses routes (currently empty) to mark the minimum and maximum rooms key items can be placed in to prevent softlocks. For secrets, the previous sphere-testing method is replaced with a distance approximator, again using the provided level route. TR2 secrets will continue to be in Stone/Jade/Gold order, based on the dev-intended route of a level.
Key item alias IDs updated per LocationPicker.GetKeyItemID. Additional objects identified that can share pickup space with items.
Routing created for every level in TR1-3. This makes use of a trview plugin to allow visualisation of the created zones, which are generated by marking on waypoints low and high rooms along the route for each key item. Updated invalid item locations too as more came to light during this exercise.
All previous zoning/manual location files removed. Redundant classes removed, and redundant properties removed from Location.
On the Japanese version, secret rewards were still being included in normal item randomization because we weren't testing the version in every scenario. Made a subclass for this case to avoid duplicating the check everywhere.
LockItem(lvl, allItems.IndexOf(entity)); | ||
} | ||
return entity; | ||
} |
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.
Can we merge the 3 functions by using where T : BaseTREntity or something?
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.
I'll rework this class, there's a lot of duplication throughout
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.
I've tidied up this class, so it's now completely generic. It needed a few things adjusting elsewhere too. I think I'll follow this PR up with another for setting item locations as we do it so frequently in different places e.g. instead of entity.X = location.X; entity.Y = location.Y;
etc in so many places, just entity.SetLocation(location);
. This one's big enough for now I think 😄
Removed several duplicated methods in ItemFactory by making it generic.
Resolves #474.
Resolves #564.
Checklist
Description
This brings together location generation and selection for regular items, key items, and secrets for TR1-3 - we no longer need to manage each game in its own format. The approach is outlined below, and I've left the commits separate for now for easier review (there is a fair amount of JSON, but it's all trview- or enviro-mod- generated).
Each level now has a semi-dev-intended route that has been defined in trview. This marks waypoints in every room (that we care about), and on those waypoints we tag where specific key items can appear, using a min (inclusive) and max (exclusive) room approach. For levels that aren't quite so linear, the route is fairly arbitrary, but the benefit of the system is that we can define several zones for a key item if needed. The result during randomization is that the valid room numbers are identified from these zones, and then a suitable location picked.
We also combine with
invalid_item_locations.json
for cases where only parts of a room are suitable for key items, like here in Tihocan. The waypoints in this case mean exclude these tiles for key items, but they're perfectly fine for regular items.A new option has also been added to allow keys to be placed in locations that require return paths. This was quite loose before (hence #564) so now if the global option for return paths is disabled, or if the key item return path option is disabled, then these rooms will be excluded from the routing.
Added a few other new key item options, including one for
Range
- different waypoints are defined on the route for each possible range. This can create interesting results when combined with return paths so it opens things up for even more of a challenge.For secrets, TR1 and TR3 no longer use the sphere-testing approach, and TR2 no longer uses fixed zones. Instead, all three now use the routing system to work out proximity so that secrets aren't too close together. The level size is approximated, then the distance between each secret worked out based on the rooms you would travel through - if too close, another location is picked, and if we are struggling to place, the minimum distance is reduced. For TR2, the usual Stone/Jade/Gold dragons will be allocated in order of position on the route (not so important with texture randomization, but it's consistent with the previous method).
There are some other minor fixes identified along the way, detailed in each relevant commit.
This wouldn't have been possible without trview, so massive thanks again to @chreden. Short demo of the plugin in action: https://youtu.be/gkwW0vWrGhA