CleverRaven/Cataclysm-DDA — pull request #9374 by narc0tiq (2014-10-02 12:12:37+00:00)
Title: [WIP] Jumper cables!

Gather 'round, all, and let me tell you the story of the broad-gauge cable:

It came from nothing (you must debug-spawn it; no recipe yet), and I could take it, and it would ask for a vehicle when [a]ctivated. Giving it a vehicle and looking at it again, I noticed I could tell how long it was (number of charges indicates how much further from the source point you can go).

I tried to bring the cable to a broken-down bus nearby, but woe, it was too short, and the cable fell off my car and I had to reel it back in (costs 200 moves (rather, max_charges * 10 moves)). So then I drove my car closer, and attached the cable to both vehicles.

The bus I'd attached my car to had gas, but no battery power. I knew this. Yet, I felt compelled to turn the ignition and, lo and behold, it started! It turned out that, through the cable, the bus had drained a little of the battery from my car, that it had needed to start.

Afterward, I tried to drive the bus away, and the cable on it disconnected and fell to the ground as soon as it started moving! I allowed as to how this was okay, though, since, having started the engine, the bus was able to keep going until I had it out of the way, off-road.

I picked up my cable and reeled it back in (by [a]ctivating it again and choosing to do so), and was able to drive my car until the next lousy vehicle abandoned in the middle of the road. That one had no gas =/

---

Still some issues with this one:

- I'm not sure how to get the vpart to remove itself when you reel in a cable that used to be connected to two vehicles. Maybe when one vehicle sheds its vpart, it should trigger the other vehicle to do the same.

- There's probably some weird inefficiencies in the code that aren't immediately obvious to me. I'm really not a C++ person.

- Might even be some debug messages left in, though I don't think there are. If you spot any, let me know!

- Alternators had to stop being on-demand chargers -- they now produce power whenever the engine is running. I don't expect this will make a *lot* of difference, but it does mean that some vehicles will start consuming a little more fuel than expected. Not sure anyone will notice, though.

- Reactors... I could've made them work the same way as alternators, but they tend to generate a lot more power-per-turn, and there's rarely somewhere for all that power to go. I figure, running full-power, a reactor will probably run through its fuel in less than one in-game minute at the quantities of plutonium normally found in the world. I might be wrong, though.

Nonetheless, have at it. I don't think anyone said it was impossible to make jumper cables, but if they had, they were clearly mistaken.