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

[CR] Diesel engines. #7151

Closed
wants to merge 18 commits into from

Conversation

Projects
None yet
5 participants
@desrik
Copy link
Contributor

commented Apr 10, 2014

  • V6, V8, and straight-6 diesel engines.
  • Diesel fuel from pumps at gas stations
    ( One in six chance of replacing a normal gas pump with diesel. )
  • Diesel fuel tanks in three flavors: normal, small, and external.
  • Ability to siphon both gasoline or diesel fuels.
    ( Both through the vehicle GUI and by activating the rubber hose item )

@desrik desrik referenced this pull request Apr 10, 2014

Closed

[CR] Biodiesel engine #5182

@ghost

This comment has been minimized.

Copy link

commented Apr 10, 2014

For flavour, I'd love to see this be a straight-6 instead a V6/V8.

"Virtually every heavy duty over-the-road truck employs an inline-six diesel engine, as well as most medium duty and many light duty diesel trucks. Its virtues are superior low-end torque, very long service life, smooth operation and dependability. On-highway vehicle operators look for straight-six diesels, which are smooth-operating and quiet." https://en.wikipedia.org/wiki/Straight-six_engine#Straight-six_diesel_engines

@Wishbringer

This comment has been minimized.

Copy link
Contributor

commented Apr 10, 2014

This seems about ready for testing so I'll include it in my FrankenMod.
I like the idea of a straight-six engine, adds more flavor.
Update: Using the "amt" variable doesn't actually work correctly so you may want to use:
(got < want ? ", draining the tank completely." : ", receiving tank is full.") );
Just like its done in "iuse.cpp".
You may also want to remove all instances of "amt" since it's no longer used.

@ghost

This comment has been minimized.

Copy link

commented Apr 10, 2014

Also, I noticed you set the epower for this engine to -200. Note that using a negative epower on combustion engines is used to simulate the power drain of the ignition system (e.g. spark plugs). However, diesel engines don't use spark plugs, and don't necessarily need any electricity to run at all. (Though modern diesels have electronics...)

@desrik

This comment has been minimized.

Copy link
Contributor Author

commented Apr 10, 2014

@belenos-
Dont see why we couldn't add one in there. I was looking at the Cummings engines. They seem to be the first pick of the major truck (non-industrial) market. It would be cool to have a few V6 and V8 pickups and see a straight 6 in the Rig and Military trucks.

I didn't really know what that was for... is it a one time draw or is it constant? diesels do need electricity to start though... they dont have spark plugs they have glow plugs

@Wishbringer
amt variable works fine. vehicle::refill returns the amount left in the tank being siphoned from. If the return isn't 0, send the message about emptying the tank.

EDIT:: I also really need to figure out this biodiesel issue... How do guns have multiple accepted ammo types?

@Wishbringer

This comment has been minimized.

Copy link
Contributor

commented Apr 10, 2014

PR: #7064
This code is already merged so you will get merge conflicts.
"amt" never is anything but 0, because you never get more than you want.
want = fillv->fuel_capacity("gasoline")-fillv->fuel_left("gasoline");
got = veh->drain("gasoline", want); <----------- HERE
"refill" returns the amount left over, otherwise 0.
You will always get the message "draining the tank completely" when transferring from car to car.
Besides why use an extra variable when you don't need it?
If it could return negative numbers, that would be a different story.
I tried that first, but I didn't dare use it because it could cause problems elsewhere.

@desrik

This comment has been minimized.

Copy link
Contributor Author

commented Apr 10, 2014

I see what you mean. Changed it.

@ghost

This comment has been minimized.

Copy link

commented Apr 10, 2014

@desrik regarding l6 vs v6/v8, note that most diesel pickup trucks also use I6 diesels, not just heavy trucks. (But anyway, I'll stop pestering you on this :) )

Regarding negative epower on engines, it's a constant draw, but I just checked the code and only fuel_type_gasoline engines are checked for a epower draw, so it actually doesn't really matter what you set this to unless you want to changes to vehicle::power_parts().

Regarding engine start-up epower draw, this is handled separately in vehicle::start_engine(). Current start-up epower draw is set to 1/10th the engine power (to simulate the starter motor), but currently only for fuel_type_gasoline engines. You probably will want to add a case for fuel_type_diesel here as well, since diesel engines also use a starter motor. (I suggest an epower draw 1/8 engine power for diesel, since diesel engines need relatively heavier starter motors, plus have the glow plug draw you mentioned.)

Also, you probably want to check the vehicle class for any checks for 'fuel_type_gasoline' and see if you there also be a check made for fuel_type_diesel. I looked through the code quick, and you probably want to make changes in the following places:
vehicle::start_engine() [handle startup epower draw]
vehicle::can_mount() [allow alternators on diesel engines]
vehicle::safe_velocity()
vehicle::noise_and_smoke()
vehicle::consume_fuel()
vehicle::power_parts() [if you want the epower property to have effect for diesel]
vehicle::damage_direct() [diesel fuel tank explosions]

@@ -2398,7 +2401,7 @@ void vehicle::power_parts ()//TODO: more categories of powered part!
// Gas engines require epower to run for ignition system, ECU, etc.
for( size_t p = 0; p < engines.size(); ++p ) {
if(parts[engines[p]].hp > 0 &&
part_info(engines[p]).fuel_type == fuel_type_gasoline) {
(part_info(engines[p]).fuel_type == fuel_type_gasoline || part_info(engines[p]).fuel_type == fuel_type_gasoline)) {

This comment has been minimized.

Copy link
@ghost

ghost Apr 11, 2014

Looks like you made a typo here.

This comment has been minimized.

Copy link
@desrik

desrik Apr 11, 2014

Author Contributor

Thanks. :)

@desrik

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2014

As far as I can tell this is done... If anyone has any thoughts on what the values should be on the engines as far as balancing let me know... I just kinda guessed.

@desrik desrik changed the title [CR] [WIP] Diesel engines. ( Rework of PR #5182 - Biodiesel engine ) [CR] Diesel engines. Apr 11, 2014

@ghost

This comment has been minimized.

Copy link

commented Apr 11, 2014

Were you planning to add/modify any vehicles to use diesel as part of the PR? If so, according to wikipedia the Humvee uses a v8 diesel, so that could be an easy one to change.

Minor thing: a straight-6 engine can be abreviated as 'l6' or 'L6' if you want to keep the id strings short.

},
{
"type":"VAR_VEH_PART",
"id": "straigt_6_diesel",

This comment has been minimized.

Copy link
@Wishbringer

Wishbringer Apr 11, 2014

Contributor

Typo here : straigt_6_diesel should be straight_6_diesel.

Changed diesel_engine_straight_6 to diesel_engine_i6.
Changed some vehicles to use diesel engines instead of gasoline.
Fixed error in I6 name.
Replaced straight_6_diesel to i6_diesel in item_groups.
@desrik

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2014

@belenos- Damn sure forgot to do that :P It's done now. Straight-6 is now the I6 and used by the Schoolbus. The Semi Truck uses the V6. The Humvee, Military Cargo Truck, and the Armored Personnel Carrier use the V8.

@KA101

This comment has been minimized.

Copy link
Contributor

commented Apr 11, 2014

So to be clear: buses and trucks now use diesel engines, but diesel's only in 1 of every 6 pumps and isn't craftable.

Uh, that's a pretty big nerf to big vehicles, I think. Holding on biodiesel.

@desrik

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2014

@KA101 the one_in() can be changed... Would 1:4 be better? I was kind of aiming towards not having diesel available at every station generated, but I'm open for suggestions.

As for biodiesel... That's out of this PR. Tured out to be a bigger headache thatn I had originally planned, plus I met some resistance in IRC. It was suggested that the recipe for biodiesel could simply return regular diesel, but thats not really what I'm going for... I try to avoid "magic" functions... If you have any ideas on a way to implement biodiesel I'm all ears. That was the original reason for adding diesel to begin with.

@KA101

This comment has been minimized.

Copy link
Contributor

commented Apr 12, 2014

1:4 seems better, yeah. Ideally there'd be a guaranteed pump at every station, and then the 1:6 or maybe 1:5 could kick in for additional pumps. Issue is that there have to be enough diesel pumps that you could actually believe diesel vehicles were routinely operating pre-Cataclysm.

(So, alternatively, military bunkers/outposts could have a diesel pump or two for humvees and miltrucks. Schools might have one around the back for the buses. Not sure whether that's a better solution: just an idea.)

@desrik

This comment has been minimized.

Copy link
Contributor Author

commented Apr 12, 2014

Or possibly a truck stop? Big 2x2 store with gas pumps in the front and diesel in the back. Have a possibility for part of the store to be a fast food place.

I can see the outpost, but i can't see a bunker having a diesel pump.
As for the schools... Why not? Would be better if there was a school bus depot that always spawned within a few overmap tiles of the school.

@@ -1335,6 +1335,27 @@ void game::activity_on_turn_refill_vehicle()
break;
}
}
} else if(m.ter(u.posx + i, u.posy + j) == t_diesel_pump) {

This comment has been minimized.

Copy link
@kevingranade

kevingranade Apr 13, 2014

Member

You should be able to just have a few lines of code at the start that populate a std::string fuel_type with either "gasoline" or "disel", then use it where appropriate. There's no need to duplicate all this code.

@@ -10049,6 +10076,46 @@ bool game::handle_liquid(item &liquid, bool from_ground, bool infinite, item *so
// infinite: always handled all, to prevent loops
return infinite || liquid.charges == 0;
}
else if ((liquid.type->id == "diesel" && vehicle_near() && query_yn(_("Refill vehicle?")))) {

This comment has been minimized.

Copy link
@kevingranade

kevingranade Apr 13, 2014

Member

Same comment as above x100, we do not want to duplicate code when we add stuff like this, it makes the code fragile because if we have to fix or change it later, we have to try and remember to do it in both places in the future.

@@ -34,8 +34,8 @@ const std::string legacy_mon_id[126] = {"mon_null", "mon_squirrel", "mon_rabbit"
"mon_turkey", "mon_raccoon", "mon_opossum", "mon_rattlesnake", "mon_giant_crayfish"

};
const int num_legacy_ter = 174;
const std::string legacy_ter_id[174] = {"t_null", "t_hole", "t_dirt", "t_sand", "t_dirtmound",
const int num_legacy_ter = 176;

This comment has been minimized.

Copy link
@kevingranade

kevingranade Apr 13, 2014

Member

No need to update these, they're for loading legacy saves, and hopefully we can get rid of them eventually.

@Rivet-the-Zombie

This comment has been minimized.

Copy link
Member

commented Apr 18, 2014

It was suggested that the recipe for biodiesel could simply return regular diesel, but thats not really what I'm going for... I try to avoid "magic" functions... If you have any ideas on a way to implement biodiesel I'm all ears.

We don't bother to differentiate between grades of gasoline, or if it's E85 either. I don't see why it's an issue to call all forms of diesel the same here.

@jcd000 jcd000 referenced this pull request Oct 7, 2014

Closed

Idea: gasoline crafting. #9458

@desrik desrik referenced this pull request Oct 18, 2014

Merged

Diesel #9591

@desrik desrik closed this Oct 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.