Open I-am-Erk opened 2 years ago
Not sure if this is implied by "NPC", but whatever gets into the driver's seat ought to be checked to actually be capable of driving, or you may get effects such as a fox, zombie, (normal) feral, zomborg, or exodii quadroped driving off.
Faction checks should also be performed, or you can get weirdness such as robbers attacking merchants get one of the robbers driving off with a support vehicle because the robber pathed through the vehicle (and cool but unintended stuff such as a robber accidentally drives off with the vehicle carrying all the loot).
The only bad unexpected consequence I can see is if a player faction Npc gets sucked away and despawns with the free merchant car, never to be seen again. Robbers doing that would be just emergent behaviour, since it would make the script into "bandits stole the truck".
Monsters and pets aren't characters so a check for a character in the driver's seat wouldn't register them.
Dupe/related to this one: https://github.com/CleverRaven/Cataclysm-DDA/issues/48859
Less related than it seems, since that would use the towing mechanic... but more related than it seems since towing mechanic is secretly autodrive.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not bump or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.
Is your feature request related to a problem? Please describe.
We have a robust system for autodrive, and for some time we've known that this could be used to get NPCs to drive. With the addition of random encounters, I now have a more immediate need for this function. Using random encounters as a start point for autodrive is a very good way for us to start developing NPC driving, because it lets us circumvent some of the early problems and test it out as a feature. Specifically, if used for scripted events, we don't need to worry about long distance travel on the overmap, for example, because a first pass implementation can have vehicles despawn once they hit the edge of the map. It also lets us skip various details related to the AI deciding when to drive and things, because it'll be the script, not the AI, that does it.
Solution you would like.
The gist of it is, we add an
effect
framework for giving a vehicle an autodrive destination, then have it go there. We need a few steps to this for error trapping. Theeffect
should target the vehicle, not an NPC.Example JSON code:
Breakdown
remove_vehicles
in mapgen does, for consistency. For obvious reasons, most scripts should give the vehicle a unique name so that the player's vehicle doesn't decide to leave on its own.pause
and then, if there's someone just standing there, begin moving forward at minimum speed to try to clue them in. If the option exists to have the car navigate around the player, that would also be nice. Also would be fun if the driver started using those npc snippets for yelling at people in the way.false
or cardinal directions (north/east/south/west). If the destination can't be found, the car will drive in this cardinal direction, avoiding obstacles, until it hits the edge of the reality bubble. This is mostly forexeunt
commands, like if you run into free merchants far from the refugee center and haven't yet found the center, they should still be able to drive off into the sunset.remove_vehicle
had run. Any items and NPCs in the vehicle should be removed along with it.Basic algorithm
pause
number of turnsdrive_safe
is true, check if a non-hostile character is within 10 tiles of the front of the vehicle. If yes, wait 1 turn and repeat this step.force
direction.force
direction is specified and designated OMT can't be found, cancel with an error.exeunt
was active, still despawn vehicle and NPCs once they leave the reality bubble.I am not sure if we have the infrastructure to have vehicles travel outside the reality bubble like NPCs do. If not, then for a first pass we should force
exeunt=true
for now, but keep the syntax in place for later when we can allow vehicles to travel on the overmap without the playerNote that even if the vehicle couldn't drive off for some reason, if it's set to exeunt it should still despawn when it leaves the reality bubble.
Describe alternatives you have considered.
I think this basic mechanic is pretty straightforward, but it could be made simpler by being a "drive_away" effect, which then implies some of the settings automatically. That doesn't let us do as much cool stuff with it though.
The same code could be adapted into a few other JSON effects, such as;
Additional context
Can you imagine what this will do to the 'lived in feeling' of the world? You're stopped by the road, then a car drives up, parks, people get out and take a break, then get back in and drive off? This would make that possible.