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

Jumper cable coming loose causes brief loss of vehicle control #25548

Open
Regularitee opened this Issue Sep 12, 2018 · 4 comments

Comments

Projects
None yet
4 participants
@Regularitee
Contributor

Regularitee commented Sep 12, 2018

If the player is driving a vehicle connecting to something else by jumper cable, and the jumper cable becomes overextended and breaks loose, the player briefly loses control of the vehicle. It's similar to what you would experience if you hit the "wait" key several times in a row: you cannot steer the vehicle, and instead continue forward at whatever speed cruise control is set at.

@narc0tiq

This comment has been minimized.

Show comment
Hide comment
@narc0tiq

narc0tiq Sep 12, 2018

Contributor

Yup, I can confirm with a quick code read at

Cataclysm-DDA/src/item.cpp

Lines 6173 to 6188 in 86ff329

void item::reset_cable( player *p )
{
int max_charges = type->maximum_charges();
set_var( "state", "attach_first" );
erase_var( "source_x" );
erase_var( "source_y" );
erase_var( "source_z" );
active = false;
charges = max_charges;
if( p != nullptr ) {
p->add_msg_if_player( m_info, _( "You reel in the cable." ) );
p->moves -= charges * 10;
}
}

This should only ever happen while you're carrying the cable yourself:
if( p != nullptr && p->has_item( *this ) ) {

It's consuming 30 or 200 moves every time the cable is reset, regardless of how extended it was (this should nominally translate to about 0.3/2 turns, but depends on character speed). A nicer solution would be to use max_charges - charges (saved before resetting the item data), though of course for an actually over-extended cable, this won't make much difference.

Someone should definitely double-check that consuming p->moves correctly deducts just the 30/200 moves expected.

Contributor

narc0tiq commented Sep 12, 2018

Yup, I can confirm with a quick code read at

Cataclysm-DDA/src/item.cpp

Lines 6173 to 6188 in 86ff329

void item::reset_cable( player *p )
{
int max_charges = type->maximum_charges();
set_var( "state", "attach_first" );
erase_var( "source_x" );
erase_var( "source_y" );
erase_var( "source_z" );
active = false;
charges = max_charges;
if( p != nullptr ) {
p->add_msg_if_player( m_info, _( "You reel in the cable." ) );
p->moves -= charges * 10;
}
}

This should only ever happen while you're carrying the cable yourself:
if( p != nullptr && p->has_item( *this ) ) {

It's consuming 30 or 200 moves every time the cable is reset, regardless of how extended it was (this should nominally translate to about 0.3/2 turns, but depends on character speed). A nicer solution would be to use max_charges - charges (saved before resetting the item data), though of course for an actually over-extended cable, this won't make much difference.

Someone should definitely double-check that consuming p->moves correctly deducts just the 30/200 moves expected.

@nexusmrsep

This comment has been minimized.

Show comment
Hide comment
@nexusmrsep

nexusmrsep Sep 13, 2018

Contributor

I wonder it it was intended. If you'd drive a car fixed to a cable it would pull you before breaking and that might make vehicle uncontrollable for a moment, although it's true when it comes to tug cable and not jumper cable.

Contributor

nexusmrsep commented Sep 13, 2018

I wonder it it was intended. If you'd drive a car fixed to a cable it would pull you before breaking and that might make vehicle uncontrollable for a moment, although it's true when it comes to tug cable and not jumper cable.

@narc0tiq

This comment has been minimized.

Show comment
Hide comment
@narc0tiq

narc0tiq Sep 13, 2018

Contributor

I wonder it it was intended.

Not really; I don't recall exactly what I was thinking at the time, but I'm pretty sure it was simply an expedient solution (as distinct from correct).

The vision was that, after affixing the cable to something, you would walk away (holding the other end of the cable, and paying it out) until you got too far -- at which point, the fixed end of the cable will have gotten disconnected[*] and you would have a cable dragging on the floor behind you.

Since I didn't want to deal with simulating a dragged cable, I forced the player character to reel it back in and/or coil it up, which obviously had to consume some moves.


So imagine the player with a cable snaking behind them, getting into a car (presumably making sure to put the cable through the car door's window, so they can shut the door) and driving off. The cable keeps paying out until it reaches its maximum extension, it stretches a bit... and comes loose from its other end!

At that point, and as a matter of the utmost urgency, the player lets go of the steering wheel and takes the time to reel in the (now loose) cable and painstakingly coil it back up, and only after this critically important task is completed do they look up and see where they're driving to.


[*] Re: cable comes loose: The alternative was to warn the player that they're overextending the cable and ask them to choose what to do (drop the cable where it is, or tug it loose and re-spool it). At the time, I wasn't too terribly aware of the uimenu system (which wasn't nearly as advanced as it is now), so I picked the simpler option.

Contributor

narc0tiq commented Sep 13, 2018

I wonder it it was intended.

Not really; I don't recall exactly what I was thinking at the time, but I'm pretty sure it was simply an expedient solution (as distinct from correct).

The vision was that, after affixing the cable to something, you would walk away (holding the other end of the cable, and paying it out) until you got too far -- at which point, the fixed end of the cable will have gotten disconnected[*] and you would have a cable dragging on the floor behind you.

Since I didn't want to deal with simulating a dragged cable, I forced the player character to reel it back in and/or coil it up, which obviously had to consume some moves.


So imagine the player with a cable snaking behind them, getting into a car (presumably making sure to put the cable through the car door's window, so they can shut the door) and driving off. The cable keeps paying out until it reaches its maximum extension, it stretches a bit... and comes loose from its other end!

At that point, and as a matter of the utmost urgency, the player lets go of the steering wheel and takes the time to reel in the (now loose) cable and painstakingly coil it back up, and only after this critically important task is completed do they look up and see where they're driving to.


[*] Re: cable comes loose: The alternative was to warn the player that they're overextending the cable and ask them to choose what to do (drop the cable where it is, or tug it loose and re-spool it). At the time, I wasn't too terribly aware of the uimenu system (which wasn't nearly as advanced as it is now), so I picked the simpler option.

@AMurkin

This comment has been minimized.

Show comment
Hide comment
@AMurkin

AMurkin Sep 14, 2018

Contributor

Related #17772, #22529.

Contributor

AMurkin commented Sep 14, 2018

Related #17772, #22529.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment