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

Towing vehicles #34690

Merged
merged 5 commits into from Apr 4, 2020
Merged

Towing vehicles #34690

merged 5 commits into from Apr 4, 2020

Conversation

ghost
Copy link

@ghost ghost commented Oct 12, 2019

Summary

SUMMARY: Features "Towing vehicles"

Purpose of change

Allows you to tow a vehicle with another one, by attaching a tow-line.

this relies on some of the changes in #34616 , and therefore has those commits too.

Describe the solution

Add an item that is similar to charging cable in how it attaches to a vehicle.
When it attaches it sets references to each vehicle to the other, when the puller moves, the pulled vehicle moves too.

Describe alternatives you've considered

N/A

Testing

Still to do :-
1)saving/loading - DONE
2)currently there are pointers stored on each vehicle, these need to be managed with care to ensure they are removed and not left dangling when certain things happen - such as destruction of a vehicle, destruction of the tow line part etc. - DONE
3)Make the tow-line have more than 3 "charges" so it can be spooled further out. - DONE
4) tweak the code that makes it follow closely, so that it is smarter. - DONE
5) handle vehicle getting unloaded out of reality bubble etc. - DONE
6)add weight to the pulling vehicle to represent the added strain of the pulled vehicles weight. - DONE
7) if pulled vehicle has no wheels, make it skid? make it create shallow pits in the ground? - THIS ALREADY HAPPENS AUTOMATICALLY
8) need to handle obstacles interfering with the pulled vehicle, or when too much distance opens up between the vehicles. or when the pulled vehicle is driven away ( need to make it bidirectional somehow maybe? ) - DONE
9) spawn in various places, make it craftable. - DONE

  1. handle vehicles splitting / loaded onto racks - DONE

current limitations :
The order in which you apply the cable matters, first vehicle selected is the puller, second is the pulled, Ima see if I can work around that.
It really is better if you attach the tow-line to the rear of the puller, and the front of the pulled.
Otherwise weird things may happen.

Additional context

A gif of it -
https://gfycat.com/disguisedweepyladybug

@chaisawlajatang
Copy link
Contributor

Oh, wow. WOW

@Destragon
Copy link

Can you chain them and have another car being pulled by the pulled vehicle or is it limited to just 1?

@ghost
Copy link
Author

ghost commented Oct 12, 2019

Can you chain them and have another car being pulled by the pulled vehicle or is it limited to just 1?

Currently if a vehicle is either a tower, or a towed, then you cant attach another cable to it, I did this deliberately to keep things simple.

But I guess a towee, could also be a tower, and theoretically yes it could chain. Id be wary of it though, it would multiply the chances for things to go wrong.

@KorGgenT KorGgenT added [C++] Changes (can be) made in C++. Previously named `Code` Vehicles Vehicles, parts, mechanics & interactions labels Oct 12, 2019
@Destragon
Copy link

Will anything funny happen when #33829 gets merged and you tie a car to a helicopter?

@ghost
Copy link
Author

ghost commented Oct 13, 2019

Will anything funny happen when #33829 gets merged and you tie a car to a helicopter?

Quite likely very strange things would happen.

@ghost
Copy link
Author

ghost commented Oct 17, 2019

Rebased to latest changes in #34616

@Destragon
Copy link

Does the towed vehicle keep its momentum when the tower suddenly hits on the breaks or does it also stop immediately?

@ghost
Copy link
Author

ghost commented Oct 18, 2019

Does the towed vehicle keep its momentum when the tower suddenly hits on the breaks or does it also stop immediately?

Theres no momentum, the towed vehicle is kinda driving itself, and when the distance gets less than a certain number, then it stops moving. So no hard braking and having thw towed vehicle ram into you, not yet anyway :)

src/iuse.cpp Outdated Show resolved Hide resolved
@RustyBrute
Copy link

Hell yeah! Good job.

@ghost ghost changed the title [WIP]Towing vehicles Towing vehicles Oct 23, 2019
src/game.cpp Show resolved Hide resolved
src/vehicle.cpp Outdated Show resolved Hide resolved
src/vehicle.cpp Outdated Show resolved Hide resolved
src/vehicle.cpp Outdated Show resolved Hide resolved
@Night-Pryanik
Copy link
Contributor

Could you please add tow cable to the list of possible alternatives of rope in butchering activity?

@ghost
Copy link
Author

ghost commented Oct 24, 2019

Could you please add tow cable to the list of possible alternatives of rope in butchering activity?

Done

@mlangsdorf mlangsdorf self-requested a review October 24, 2019 14:11
Copy link
Contributor

@mlangsdorf mlangsdorf left a comment

Choose a reason for hiding this comment

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

C++ code looks good. Just need to beef up the towing line - this is 50' of 1" stick cable that can tow roughly 100,000 lbs, which is sufficiently close to "unlimited weight".

When you go back and add some weight limits, we can add some lighter tow cable and some tow lines and/or ropes.

data/json/items/vehicle/cables.json Outdated Show resolved Hide resolved
data/json/recipes/recipe_vehicle.json Outdated Show resolved Hide resolved
data/json/items/vehicle/cables.json Outdated Show resolved Hide resolved
data/json/items/vehicle/cables.json Outdated Show resolved Hide resolved
data/json/items/vehicle/cables.json Outdated Show resolved Hide resolved
@paulenka-aleh
Copy link

It looks great to finally see the concept in game. It feels a bit wrong though:

Towing support
After the collision rework, it should be possible to have two correctly flagged vehicle parts not collide. And it should also be possible to apply force to the trailer to have it follow the towing vehicle.
Added by mlangsdorf

https://github.com/CleverRaven/Cataclysm-DDA/projects/19

@ghost
Copy link
Author

ghost commented Oct 31, 2019

It looks great to finally see the concept in game. It feels a bit wrong though:

Towing support
After the collision rework, it should be possible to have two correctly flagged vehicle parts not collide. And it should also be possible to apply force to the trailer to have it follow the towing vehicle.
Added by mlangsdorf

https://github.com/CleverRaven/Cataclysm-DDA/projects/19

This is a different route to the same end-goal, what feels wrong exactly?

@stale
Copy link

stale bot commented Nov 30, 2019

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.

@stale stale bot added the stale Closed for lack of activity, but still valid. label Nov 30, 2019
@KorGgenT KorGgenT added the (P5 - Long-term) Long-term WIP, may stay on the list for a while. label Nov 30, 2019
@stale stale bot removed the stale Closed for lack of activity, but still valid. label Nov 30, 2019
@ghost ghost changed the title [WIP]Towing vehicles Towing vehicles Mar 6, 2020
@ZhilkinSerg ZhilkinSerg force-pushed the dev branch 2 times, most recently from aa39539 to 9761f13 Compare March 10, 2020 09:21
@ZhilkinSerg ZhilkinSerg force-pushed the dev branch 6 times, most recently from 924f105 to 39e00e3 Compare March 18, 2020 07:00
@pjf
Copy link
Contributor

pjf commented Mar 25, 2020

Applied this to my local game, and had my deathmobile tow a 4x4.

Worked great on roads, but as soon as I got off-road, my deathmobile continued (slowly), but the vehicle it was towing did not.

The deathmobile isn't built for off-road use, so I suspect the weight of both vehicles combined exceeded its engine capacity. However in that case I'd expect the towing vehicle to stop, not the vehicle being towed.

Otherwise this is great. An excellent change for folks who have multiple vehicles and like to relocate. Thank you!

@ZhilkinSerg ZhilkinSerg force-pushed the dev branch 3 times, most recently from ad63e77 to 8e68539 Compare April 1, 2020 12:18
@kevingranade kevingranade force-pushed the dev branch 4 times, most recently from 621a68e to b7106d0 Compare April 2, 2020 07:42
@ZhilkinSerg ZhilkinSerg force-pushed the dev branch 3 times, most recently from 0f30a43 to d432807 Compare April 2, 2020 12:55
@ZhilkinSerg ZhilkinSerg changed the base branch from dev to master April 2, 2020 14:31
davidpwbrown added 5 commits April 3, 2020 10:20
add UI and sound cues for autopilot, and rework collision detection

remove test code

simple towin WIP

Update src/iuse.cpp

Co-Authored-By: Curtis Merrill <curtis.r.merrill@gmail.com>

increase cable length, and enable serialization/validation of tow data

in-progress - invalidate towing and dump cable part

add handling to clear towing data on part/vehicle destruction or too much distnace

json lint

make recipe use metal cables

transfer tow data when vehicle splits

DEATH TO AUTO

change breaks_into to use new metal recipe

from review: add tow cable to butchery hanging options

from review : change recipe to be HD cable

replace item groups entries for tow_cable with hd_tow_cable

json typo

clang-tidy satisfaction - redundant bool return and differing paramters

add cable to recipe

make towing aware of side it is pulled from for reverse pulling
@ghost
Copy link
Author

ghost commented Apr 3, 2020

Rebased, cleaned up, tested, working.
Fixed bug that pjf reported .

Im not sure why the tower is allowed to proceed at velocity 1, when the towed vehicle stops at velocity 1.

I managed to repro this with a bus pulling a bus, and they went off-road, this would be a situation where probably it would be impossible to get traction, so ive detected this scenario and added a message similar to when a vehicle is too heavy for its engines.

Pulling a golf cart with a military cargo truck off-road didnt have this problem, it managed to stay above 1mph.

@ZhilkinSerg ZhilkinSerg merged commit c410ebb into CleverRaven:master Apr 4, 2020
@CEG86
Copy link

CEG86 commented Apr 25, 2020

How do you detach the tow cable? I had to deconstruct the towed vechicle which resulted in the tow cable disappearing.

@ZhilkinSerg
Copy link
Contributor

Try examining vehicle tile with tow attachment.

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` (P5 - Long-term) Long-term WIP, may stay on the list for a while. Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.