-
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
Lock vehicle doors #61087
Lock vehicle doors #61087
Conversation
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.
Bunch more stuff (besides the suggested) can be const-ified
Clang is also likely to scream at you for vector.size() > 0 over !vector.empty()
I'm sure many people are waiting for this feature ♥
This looks great, thanks for putting this together. We're one step away from having dedicated ignition keys for cars. Key fobs would be a great addition as well for remote starting, locking/unlocking, trunk access, and panic alarm. |
What are NPC interactions with locked doors like? They should have the same options as players. |
NPCs don't currently have any logic to interact with locked doors, but it would make sense for them to be able to do so. I'll have to read over the npc pathing and behavior code to see how this should be implemented. |
@Numbuh474 Probably something for a follow-up PR, though. The bigger the PR, the harder it is to review |
No, it needs to happen in this PR. Having the player be the only agent that can interact with locks is a misfeature. |
Added relevant code for pathfinding and behavior toggles. |
I would like to see locked doors on some (most?) cars on spawn, as you described in "alternatives" section, but I guess that could wait for subsequent PRs. Correct me if I'm wrong, but did you make it so doors can be locked and unlocked only from inside the vehicle? |
So would I! As far as I can tell this would involve a lot of changes to car template json and some tweaks to vehicle spawning code, but as you can see this PR is getting quite large on its own.
That's correct. A remote vehicle controller could be used from outside too. |
9deb186
to
0b9b1fa
Compare
Why closed? |
The "sync fork" button on Github web has done this twice now when it didn't before, and I'm scared to try a different method because last time I did that it nuked the PR (see comments from February). |
Ok I've cleared the merge conflicts and the errors from that. But I'm not sure what to do with the remaining errors when I attempt to test this.
|
Looks like some pre-made vehicles need to be updated. Not sure on the exact syntax, but here's the spots to make it easy for you. Sports car: Cataclysm-DDA/data/json/vehicles/cars.json Lines 622 to 623 in 30f23ec
Fire Engine: Cataclysm-DDA/data/json/vehicles/emergency.json Lines 192 to 197 in 30f23ec
truck_swat(will be fixed by restoring hddoor_opaque):
Stagecoach: Cataclysm-DDA/data/json/vehicles/farm.json Lines 305 to 306 in 30f23ec
aapc-gl(will be fixed by restoring hddoor_opaque):
aapc-mg(will be fixed by restoring hddoor_opaque):
apc(will be fixed by restoring hddoor_opaque):
apc-gl(will be fixed by restoring hddoor_opaque):
armored_car(will be fixed by restoring hddoor_opaque):
Hippie van: Cataclysm-DDA/data/json/vehicles/vans_busses.json Lines 354 to 355 in 30f23ec
Survivor RV (curtain needs to just be removed, looks like?): Cataclysm-DDA/data/json/vehicles/vans_busses.json Line 1322 in 30f23ec
security van(will be fixed by restoring hddoor_opaque): Cataclysm-DDA/data/json/vehicles/vans_busses.json Line 2251 in 30f23ec
prisoner_van_1(will be fixed by restoring hddoor_opaque): Cataclysm-DDA/data/json/vehicles/vans_busses.json Line 2433 in 30f23ec
Cataclysm-DDA/data/json/vehicles/vans_busses.json Line 2437 in 30f23ec
|
Found one of your problems. Some of the parts have been moved around in the last month. Here's two instances of Cataclysm-DDA/data/json/vehicleparts/doors.json Lines 230 to 231 in 4e7329e
Cataclysm-DDA/data/json/vehicleparts/vehicle_parts.json Lines 2236 to 2238 in 4e7329e
|
Same deal with door_wood. Cataclysm-DDA/data/json/vehicleparts/doors.json Lines 195 to 197 in 4e7329e
Cataclysm-DDA/data/json/vehicleparts/vehicle_parts.json Lines 2712 to 2714 in 4e7329e
|
Pushed the changes, loaded up the game created new player, world initialized with no errors then revealed map, teleported into nearest city to test vehicle doors and ctd. |
Compiled and tested this morning and it works. NPCs can also be commanded to lock doors as they pass through. |
Summary
Features "Make vehicle doors lockable and pickable"
Purpose of change
This is a contribution to #51383, addressing the ability to lock and unlock vehicle doors.
It also fixes #46160.
Describe the solution
Enable locking and unlocking of certain vehicle doors, adding the
LOCKABLE_DOOR
flag for valid doors and theDOOR_LOCKING
flag for parts that allow locking and unlocking. A new item, the door lock, was given the DOOR_LOCKING flag and most metal doors and hatches were given theLOCKABLE_DOOR
tag. A door must be a LOCKABLE_DOOR and have a part with the DOOR_LOCKING tag on the same frame to enable the feature. Modify relevant door opening code to respect locked vehicle door status for player and NPCs. Add lockpicking behavior for vehicle doors, allowing lockpick tools to pick open doors that are otherwise inaccessible.Monsters and door-opening ferals aren't able to figure out locks, but NPCs will path through locked doors if given the option. A new pair of behavior flags were added that allows you to make followers stop unlocking doors, or to also lock them if possible.
Behavior that protected door motors from damage if the door was closed was added to door locks and moved to the more generic
BOARD_INTERNAL
flag, which now also works with things installed in boards in case someone wants to add pipework or something. Doors and their locks can't be removed while a tile on the same square is in the "locked" state.Door motor menu was modified to allow you to lock and unlock all closed doors if the door is lockable, and examining a tile with a lockable door now has options for modifying the lock state based on player position.
Describe alternatives you've considered
Doors could have been made intrinsically lockable without a corresponding DOOR_LOCKING part.
Part lock state currently has nothing to do with vehicle lock state, and these could be made to work together to do things like lock doors on vehicle spawn or trigger alarms.
Lockpicking could have been excluded or made impossible for player-owned vehicles, as this gives "free" locked doors for training purposes.
Testing
Tested door opening and closing from inside and outside the vehicle, door locking and unlocking from both inside and outside the vehicle, door-opening monster behavior for closed vs. locked doors, and locking and unlocking via the door motor menu.
Tested having an NPC follow you into and out of a vehicle with a door lock while using the new rule toggles.
Additional context