From 02f7e7be156b4343ef86a542d6c766cfd18d9c92 Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Sun, 24 Nov 2013 22:50:49 +0000 Subject: [PATCH 01/19] Make engines actually idle, and require them to be on to drive. --- src/map.cpp | 1 + src/savegame_json.cpp | 2 + src/vehicle.cpp | 91 ++++++++++++++++++++++++++++++++++++------- src/vehicle.h | 4 ++ 4 files changed, 84 insertions(+), 14 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 72bb75d822618..d9cefbd7d551f 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -414,6 +414,7 @@ void map::vehmove(game *g) vehicle* veh = vehs[v].v; veh->gain_moves (abs (veh->velocity)); veh->power_parts(); + veh->idle(); } } diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index df92a22fd8fc8..4c888ceca81e7 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -1121,6 +1121,7 @@ void vehicle::deserialize(JsonIn &jsin) data.read("velocity", velocity); data.read("cruise_velocity", cruise_velocity); data.read("cruise_on", cruise_on); + data.read("engine_on", engine_on); data.read("tracking_on", tracking_on); data.read("lights_on", lights_on); data.read("overhead_lights_on", overhead_lights_on); @@ -1164,6 +1165,7 @@ void vehicle::serialize(JsonOut &json) const json.member( "velocity", velocity ); json.member( "cruise_velocity", cruise_velocity ); json.member( "cruise_on", cruise_on ); + json.member( "engine_on", engine_on ); json.member( "tracking_on", tracking_on ); json.member( "lights_on", lights_on ); json.member( "overhead_lights_on", overhead_lights_on ); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 1268de27c0b7b..f9be1525bdff2 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -22,7 +22,8 @@ enum vehicle_controls { activate_horn, release_control, control_cancel, - convert_vehicle + convert_vehicle, + turn_on_engine }; vehicle::vehicle(game *ag, std::string type_id, int init_veh_fuel, int init_veh_status): g(ag), type(type_id) @@ -298,20 +299,21 @@ void vehicle::use_controls() std::vector options_choice; std::vector options_message; // Always have this option - int curent = 0; + int current = 0; int letgoent = 0; options_choice.push_back(toggle_cruise_control); options_message.push_back(uimenu_entry((cruise_on) ? _("Disable cruise control") : _("Enable cruise control"), 'c')); - curent++; + current++; bool has_lights = false; bool has_overhead_lights = false; bool has_horn = false; bool has_turrets = false; bool has_tracker = false; + bool has_engine = false; for (int p = 0; p < parts.size(); p++) { if (part_flag(p, "CONE_LIGHT")) { has_lights = true; @@ -331,6 +333,9 @@ void vehicle::use_controls() else if (part_flag(p, "TRACK")) { has_tracker = true; } + else if (part_flag(p, "ENGINE")) { + has_engine = true; + } } // Lights if they are there - Note you can turn them on even when damaged, they just don't work @@ -338,21 +343,21 @@ void vehicle::use_controls() options_choice.push_back(toggle_lights); options_message.push_back(uimenu_entry((lights_on) ? _("Turn off headlights") : _("Turn on headlights"), 'h')); - curent++; + current++; } if (has_overhead_lights) { options_choice.push_back(toggle_overhead_lights); options_message.push_back(uimenu_entry(overhead_lights_on ? _("Turn off overhead lights") : _("Turn on overhead lights"), 'v')); - curent++; + current++; } //Honk the horn! if (has_horn) { options_choice.push_back(activate_horn); options_message.push_back(uimenu_entry(_("Honk horn"), 'o')); - curent++; + current++; } // Turrets: off or burst mode @@ -360,7 +365,7 @@ void vehicle::use_controls() options_choice.push_back(toggle_turrets); options_message.push_back(uimenu_entry((0 == turret_mode) ? _("Switch turrets to burst mode") : _("Disable turrets"), 't')); - curent++; + current++; } // Tracking on the overmap @@ -369,22 +374,30 @@ void vehicle::use_controls() options_message.push_back(uimenu_entry((tracking_on) ? _("Disable tracking device") : _("Enable tracking device"), 'g')); - curent++; + current++; } if( !g->u.controlling_vehicle && tags.count("convertible") ) { options_choice.push_back(convert_vehicle); options_message.push_back(uimenu_entry(_("Fold bicycle"), 'f')); - curent++; + current++; } // Exit vehicle, if we are in it. int vpart; + if (has_engine) { + options_choice.push_back(turn_on_engine); + options_message.push_back(uimenu_entry((engine_on) ? _("Turn off the engine") : + _("Turn on the engine"), 'e')); + current++; + } + + // Exit vehicle, if we are in it. if (g->u.controlling_vehicle && g->m.veh_at(g->u.posx, g->u.posy, vpart) == this) { options_choice.push_back(release_control); options_message.push_back(uimenu_entry(_("Let go of controls"), 'l')); - letgoent = curent; + letgoent = current; } options_choice.push_back(control_cancel); @@ -433,6 +446,25 @@ void vehicle::use_controls() } g->add_msg((0 == turret_mode) ? _("Turrets: Disabled") : _("Turrets: Burst mode")); break; + case turn_on_engine: + if (engine_on) { + engine_on = false; + g->add_msg(_("You turn the engine off.")); + } + else { + if (total_power () < 1) { + if (total_power (false) < 1) + g->add_msg (_("The %s doesn't have an engine!"), name.c_str()); + else + g->add_msg (_("The %s's engine emits a sneezing sound."), name.c_str()); + } + else { + engine_on = true; + // TODO: Make chance of success based on engine condition. + g->add_msg(_("You turn the engine on.")); + } + } + break; case release_control: g->u.controlling_vehicle = false; g->add_msg(_("You let go of the controls.")); @@ -1873,8 +1905,35 @@ void vehicle::charge_battery (int amount) } } -void vehicle::thrust (int thd) -{ + +void vehicle::idle() { + if (engine_on && total_power () > 0) { + if(one_in(20)) { + for (int p = 0; p < parts.size(); p++) { + if (part_flag(p, "ENGINE")) { + //Charge the battery if the engine has an alternator + if(part_flag(p,"ALTERNATOR")) { + charge_battery(part_info(p).power * 0.3); + } + } + } + consume_fuel(); + int sound = noise()/10 + 2; + g->sound(global_x(), global_y(), sound, "hummm."); + + if (one_in(10)) { + int rdx = rng(0, 2); + int rdy = rng(0, 2); + g->m.add_field(g, global_x() + rdx, global_y() + rdy, fd_smoke, (sound / 50) + 1); + } + } + } + else { + engine_on = false; + } +} + +void vehicle::thrust (int thd) { if (velocity == 0) { turn_dir = face.dir(); @@ -1916,6 +1975,11 @@ void vehicle::thrust (int thd) cruise_velocity = 0; return; } + else if (!engine_on) { + g->add_msg (_("The %s's engine isn't on!"), name.c_str()); + cruise_velocity = 0; + return; + } consume_fuel (); @@ -1926,8 +1990,7 @@ void vehicle::thrust (int thd) if (part_flag(p, "ENGINE")) { //Charge the battery if the engine has an alternator - if(part_flag(p,"ALTERNATOR")) - { + if(part_flag(p,"ALTERNATOR")) { charge_battery(part_info(p).power * 0.3); } if(fuel_left(part_info(p).fuel_type, true) && parts[p].hp > 0 && rng (1, 100) < strn) diff --git a/src/vehicle.h b/src/vehicle.h index 4c14415fab0c6..9cb19d37ed78b 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -382,6 +382,9 @@ class vehicle : public JsonSerializer, public JsonDeserializer // calculate if it can move using its wheels configuration bool valid_wheel_config (); +// idle fuel consumption and battery charge + void idle (); + // thrust (1) or brake (-1) vehicle void thrust (int thd); @@ -501,6 +504,7 @@ class vehicle : public JsonSerializer, public JsonDeserializer int velocity; // vehicle current velocity, mph * 100 int cruise_velocity; // velocity vehicle's cruise control trying to acheive bool cruise_on; // cruise control on/off + bool engine_on; // engine on/off bool lights_on; // lights on/off bool tracking_on; // vehicle tracking on/off int om_id; // id of the om_vehicle struct corresponding to this vehicle From 5fdf9241d1cb02ad64123781432ed21510ca1f90 Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Sun, 24 Nov 2013 23:26:32 +0000 Subject: [PATCH 02/19] Properly drain lights from our current power and add floodlight object. --- src/veh_interact.cpp | 5 ++++- src/vehicle.cpp | 22 +++++++++++++++++----- src/vehicle.h | 5 +++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/veh_interact.cpp b/src/veh_interact.cpp index 176e3b158626d..62da98ef907fb 100644 --- a/src/veh_interact.cpp +++ b/src/veh_interact.cpp @@ -73,7 +73,7 @@ void veh_interact::exec (game *gm, vehicle *v, int x, int y) const int extrah = ((TERMY - FULL_SCREEN_HEIGHT) / 4) * 2; const int totalw = FULL_SCREEN_WIDTH + extraw; const int totalh = FULL_SCREEN_HEIGHT + extrah; - + // position within main display const int x1 = 1 + ((TERMX - totalw) / 2); const int y1 = 1 + ((TERMY - totalh) / 2); @@ -1331,6 +1331,9 @@ void complete_vehicle (game *g) used_item.put_in(liquid); } + // Transfer power back to batteries. + if (used_item.typeId() == "small_storage_battery") { + } g->m.add_item_or_charges(g->u.posx, g->u.posy, used_item); if(type != SEL_JACK) { // Changing tires won't make you a car mechanic g->u.practice (g->turn, "mechanics", 2 * 5 + 20); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index f9be1525bdff2..e838b70503c78 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -872,11 +872,14 @@ int vehicle::install_part (int dx, int dy, std::string id, int hp, bool force) if(part_flag(parts.size()-1,"HORN")) { horns.push_back(parts.size() - 1); } - if(part_flag(parts.size()-1,"LIGHT")) + if(part_flag(parts.size()-1,"LIGHT") || part_flag(parts.size()-1,"CONE_LIGHT")) { lights.push_back(parts.size()-1); lights_power += part_info(parts.size()-1).power; } + if (part_flag(parts.size()-1,"CIRCLE_LIGHT")) { + overhead_power += part_info(parts.size()-1).power; + } if(part_flag(parts.size()-1, "TRACK")) { tracking_power += part_info(parts.size()-1).power; @@ -1855,7 +1858,9 @@ void vehicle::consume_fuel () void vehicle::power_parts ()//TODO: more categories of powered part! { int power=0; + find_lights(); if(lights_on)power += lights_power; + if(overhead_lights_on)power += overhead_power; if(tracking_on)power += tracking_power; if(power <= 0)return; for(int f=0;f 0;f++) @@ -1864,6 +1869,7 @@ void vehicle::power_parts ()//TODO: more categories of powered part! { if(parts[fuel[f]].amount < power) { + debugmsg("Current power: %d Subtracting: %d", parts[fuel[f]].amount, power); power -= parts[fuel[f]].amount; parts[fuel[f]].amount = 0; } @@ -1913,7 +1919,7 @@ void vehicle::idle() { if (part_flag(p, "ENGINE")) { //Charge the battery if the engine has an alternator if(part_flag(p,"ALTERNATOR")) { - charge_battery(part_info(p).power * 0.3); + charge_battery(part_info(p).power); } } } @@ -1991,7 +1997,7 @@ void vehicle::thrust (int thd) { { //Charge the battery if the engine has an alternator if(part_flag(p,"ALTERNATOR")) { - charge_battery(part_info(p).power * 0.3); + charge_battery(part_info(p).power); } if(fuel_left(part_info(p).fuel_type, true) && parts[p].hp > 0 && rng (1, 100) < strn) { @@ -2743,10 +2749,16 @@ void vehicle::find_horns () void vehicle::find_lights () { lights.clear(); + lights_power = 0; + overhead_power = 0; for (int p = 0; p < parts.size(); p++) { - if(part_flag( p,"LIGHT" )) { + if(part_flag( p,"LIGHT" ) || part_flag(p,"CONE_LIGHT") || + part_flag(p,"CIRCLE_LIGHT")) { lights.push_back(p); - lights_power += part_info(p).power; + if(part_flag(p,"CIRCLE_LIGHT")) + overhead_power += part_info(p).power; + else + lights_power += part_info(p).power; } } } diff --git a/src/vehicle.h b/src/vehicle.h index 9cb19d37ed78b..7091880a69875 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -508,7 +508,7 @@ class vehicle : public JsonSerializer, public JsonDeserializer bool lights_on; // lights on/off bool tracking_on; // vehicle tracking on/off int om_id; // id of the om_vehicle struct corresponding to this vehicle - bool overhead_lights_on; //emergency vehicle flasher lights on/off + bool overhead_lights_on; //circle lights on/off int turn_dir; // direction, to wich vehicle is turning (player control). will rotate frame on next move bool skidding; // skidding mode int last_turn; // amount of last turning (for calculate skidding due to handbrake) @@ -516,7 +516,8 @@ class vehicle : public JsonSerializer, public JsonDeserializer float of_turn; // goes from ~1 to ~0 while proceeding every turn float of_turn_carry;// leftover from prev. turn int turret_mode; // turret firing mode: 0 = off, 1 = burst fire - int lights_power; // total power of components with LIGHT flag + int lights_power; // total power of components with LIGHT or CONE_LIGHT flag + int overhead_power; // total power of components with CIRCLE_LIGHT flag int tracking_power; // total power consumed by tracking devices (why would you use more than one?) }; From 2716dcba2349e47185f079fec4d7d87123071c5d Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Sun, 24 Nov 2013 23:31:43 +0000 Subject: [PATCH 03/19] Add floodlight recipe and item group. --- data/json/item_groups.json | 6 +++++- data/json/recipes/recipes.json | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/data/json/item_groups.json b/data/json/item_groups.json index 26e16092a2102..36ed8f305bddb 100644 --- a/data/json/item_groups.json +++ b/data/json/item_groups.json @@ -447,6 +447,7 @@ ["binoculars", 20], ["duct_tape", 70], ["lawnmower", 25], + ["floodlight", 10], ["char_smoker", 25], ["lawn_dart", 10], ["dehydrator", 15], @@ -1162,6 +1163,7 @@ ["duct_tape", 60], ["jerrycan", 10], ["lawnmower", 25], + ["floodlight", 20], ["char_smoker", 25], ["dehydrator", 15], ["foot_crank", 10], @@ -1263,7 +1265,8 @@ ["mag_fabrication", 12], ["duct_tape", 60], ["lawnmower", 25], - ["boltcutters", 5], + ["floodlight", 10], + ["boltcutters", 8], ["foot_crank", 10], ["cable", 60], ["textbook_mechanics", 12], @@ -2958,6 +2961,7 @@ ["tent_kit", 17], ["bat_metal", 60], ["lawnmower", 25], + ["floodlight", 20], ["char_smoker", 25], ["lawn_dart", 10], ["dehydrator", 15], diff --git a/data/json/recipes/recipes.json b/data/json/recipes/recipes.json index b35b08f2659f6..3fe20aaa00425 100644 --- a/data/json/recipes/recipes.json +++ b/data/json/recipes/recipes.json @@ -9018,6 +9018,29 @@ [ "cable", 10 ] ] ] +},{ + "type" : "recipe", + "result": "floodlight", + "category": "CC_ELECTRONIC", + "skill_used": "mechanics", + "skills_required": [ "electronics", 1 ], + "difficulty": 2, + "time": 15000, + "reversible": true, + "decomp_learn": 0, + "autolearn": true, + "components": [ + [ + [ "amplifier", 4 ] + ], + [ + [ "steel_chunk", 2 ], + [ "scrap", 6 ] + ], + [ + [ "cable", 10 ] + ] + ] },{ "type" : "recipe", "result": "soldering_iron", From 03542d3fbcf7aa42d004af554fc1d3d57754729c Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Mon, 25 Nov 2013 00:12:11 +0000 Subject: [PATCH 04/19] Fully implement idling vehicles as generators. Add floodlight. Allow removal of storage batteries and keep their charge. --- data/json/items/vehicle_parts.json | 15 ++++++++++++++ data/json/vehicle_parts.json | 20 +++++++++++++++++++ src/veh_interact.cpp | 17 +++++++++++++++- src/vehicle.cpp | 32 +++++++++++++++++++++--------- 4 files changed, 74 insertions(+), 10 deletions(-) diff --git a/data/json/items/vehicle_parts.json b/data/json/items/vehicle_parts.json index 63571cb2ca271..ec6ca4c0e514d 100644 --- a/data/json/items/vehicle_parts.json +++ b/data/json/items/vehicle_parts.json @@ -466,5 +466,20 @@ "bashing": 1, "cutting": 0, "price": 400 + }, + { + "type":"GENERIC", + "id": "floodlight", + "name": "floodlight", + "description": "A large and heavy light designed to illuminate wide areas.", + "weight": 2500, + "to_hit": 1, + "color": "white", + "symbol": ";", + "material": ["iron", "plastic"], + "volume": 8, + "bashing": 5, + "cutting": 0, + "price": 900 } ] diff --git a/data/json/vehicle_parts.json b/data/json/vehicle_parts.json index 3a5aca6a505f7..534621712f6fb 100644 --- a/data/json/vehicle_parts.json +++ b/data/json/vehicle_parts.json @@ -1880,5 +1880,25 @@ {"item": "steel_chunk", "min": 0, "max": 1}, {"item": "scrap", "min": 1, "max": 1} ] + },{ + "type" : "vehicle_part", + "id" : "floodlight", + "name" : "floodlight", + "symbol" : "*", + "color" : "white", + "broken_symbol" : "-", + "broken_color" : "dark_blue", + "damage_modifier" : 10, + "durability" : 20, + "power" : 3, + "bonus" : 600, + "item" : "floodlight", + "difficulty" : 1, + "location" : "on_roof", + "flags" : ["CIRCLE_LIGHT"], + "breaks_into" : [ + {"item": "steel_chunk", "min": 0, "max": 2}, + {"item": "scrap", "min": 1, "max": 2} + ] } ] diff --git a/src/veh_interact.cpp b/src/veh_interact.cpp index 62da98ef907fb..ab545784a54e1 100644 --- a/src/veh_interact.cpp +++ b/src/veh_interact.cpp @@ -1234,6 +1234,8 @@ void complete_vehicle (game *g) int replaced_wheel; std::vector parts; int dd = 2; + int batterycharges; // Charges in a battery + switch (cmd) { case 'i': partnum = veh->install_part (dx, dy, part_id); @@ -1241,6 +1243,7 @@ void complete_vehicle (game *g) debugmsg ("complete_vehicle install part fails dx=%d dy=%d id=%d", dx, dy, part_id.c_str()); } used_item = consume_vpart_item (g, part_id); + batterycharges = used_item.charges; veh->get_part_properties_from_item(g, partnum, used_item); //transfer damage, etc. tools.push_back(component("welder", welder_charges)); tools.push_back(component("welder_crude", welder_crude_charges)); @@ -1280,6 +1283,13 @@ void complete_vehicle (game *g) veh->parts[partnum].direction = dir; } + // Add charges if battery. + if (used_item.typeId() == "storage_battery" || used_item.typeId() == "small_storage_battery" || + used_item.typeId() == "battery_motorbike" || used_item.typeId() == "battery_car" || + used_item.typeId() == "battery_truck") { + veh->charge_battery(batterycharges); + } + g->add_msg (_("You install a %s into the %s."), vehicle_part_types[part_id].name.c_str(), veh->name.c_str()); g->u.practice (g->turn, "mechanics", vehicle_part_types[part_id].difficulty * 5 + 20); @@ -1332,7 +1342,12 @@ void complete_vehicle (game *g) used_item.put_in(liquid); } // Transfer power back to batteries. - if (used_item.typeId() == "small_storage_battery") { + // TODO: Add new flag. + if (used_item.typeId() == "storage_battery" || used_item.typeId() == "small_storage_battery" || + used_item.typeId() == "battery_motorbike" || used_item.typeId() == "battery_car" || + used_item.typeId() == "battery_truck") { + used_item.charges = veh->parts[vehicle_part].amount; + veh->parts[vehicle_part].amount = 0; } g->m.add_item_or_charges(g->u.posx, g->u.posy, used_item); if(type != SEL_JACK) { // Changing tires won't make you a car mechanic diff --git a/src/vehicle.cpp b/src/vehicle.cpp index e838b70503c78..226b7c7a4c645 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1869,7 +1869,6 @@ void vehicle::power_parts ()//TODO: more categories of powered part! { if(parts[fuel[f]].amount < power) { - debugmsg("Current power: %d Subtracting: %d", parts[fuel[f]].amount, power); power -= parts[fuel[f]].amount; parts[fuel[f]].amount = 0; } @@ -1885,7 +1884,7 @@ void vehicle::power_parts ()//TODO: more categories of powered part! lights_on = false; tracking_on = false; overhead_lights_on = false; - if(player_in_control(&g->u)) + if(player_in_control(&g->u) || g->u_see(global_x(), global_y()) ) g->add_msg("The %s's battery dies!",name.c_str()); } } @@ -1915,13 +1914,26 @@ void vehicle::charge_battery (int amount) void vehicle::idle() { if (engine_on && total_power () > 0) { if(one_in(20)) { - for (int p = 0; p < parts.size(); p++) { - if (part_flag(p, "ENGINE")) { - //Charge the battery if the engine has an alternator - if(part_flag(p,"ALTERNATOR")) { - charge_battery(part_info(p).power); - } - } + int strn = (int) (strain () * strain() * 100); + + for (int p = 0; p < parts.size(); p++) + { + if (part_flag(p, "ENGINE")) + { + //Charge the battery if the engine has an alternator + if(part_flag(p,"ALTERNATOR")) { + charge_battery(part_info(p).power); + } + if(fuel_left(part_info(p).fuel_type, true) && parts[p].hp > 0 && rng (1, 100) < strn) + { + int dmg = rng (strn * 2, strn * 4); + damage_direct (p, dmg, 0); + if(one_in(2)) + g->add_msg(_("Your engine emits a high pitched whine.")); + else + g->add_msg(_("Your engine emits a loud grinding sound.")); + } + } } consume_fuel(); int sound = noise()/10 + 2; @@ -1935,6 +1947,8 @@ void vehicle::idle() { } } else { + if (g->u_see(global_x(), global_y()) && engine_on) + g->add_msg(_("The engine dies!")); engine_on = false; } } From feed07c3cac931afe380132113ad5d2a4efe64eb Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Mon, 25 Nov 2013 00:46:49 +0000 Subject: [PATCH 05/19] Adds a working mini-fridge. Makes processing more efficient and stable. --- data/json/items/vehicle_parts.json | 2 +- data/json/vehicle_parts.json | 5 +- src/map.cpp | 13 ++++- src/savegame_json.cpp | 2 +- src/vehicle.cpp | 79 ++++++++++++++++++------------ src/vehicle.h | 4 +- 6 files changed, 68 insertions(+), 37 deletions(-) diff --git a/data/json/items/vehicle_parts.json b/data/json/items/vehicle_parts.json index ec6ca4c0e514d..d88f11ad2a921 100644 --- a/data/json/items/vehicle_parts.json +++ b/data/json/items/vehicle_parts.json @@ -260,7 +260,7 @@ "type": "GENERIC", "id": "minifridge", "name": "minifridge", - "description": "A very small fridge for keeping food cool, but without electricity it's just a very heavy box with shelves inside.", + "description": "A very small fridge for keeping food cool.", "weight": 31752, "to_hit": -8, "color": "light_blue", diff --git a/data/json/vehicle_parts.json b/data/json/vehicle_parts.json index 534621712f6fb..206d57618b5db 100644 --- a/data/json/vehicle_parts.json +++ b/data/json/vehicle_parts.json @@ -47,7 +47,7 @@ "durability": 20, "item": "veh_tracker", "difficulty": 3, - "power": 6, + "power": 1, "flags": [ "TRACK", "UNMOUNT_ON_DAMAGE" ], @@ -1241,11 +1241,12 @@ "broken_color" : "light_blue", "damage_modifier" : 80, "durability" : 100, + "power" : 10, "size" : 400, "item" : "minifridge", "difficulty" : 3, "location" : "center", - "flags" : ["CARGO", "OBSTACLE"], + "flags" : ["CARGO", "OBSTACLE", "FRIDGE"], "breaks_into" : [ {"item": "steel_lump", "min": 8, "max": 13}, {"item": "steel_chunk", "min": 8, "max": 13}, diff --git a/src/map.cpp b/src/map.cpp index d9cefbd7d551f..f0e7e80831954 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2408,6 +2408,7 @@ void map::process_active_items_in_submap(game *g, const int nonant) void map::process_active_items_in_vehicles(game *g, const int nonant) { + item *it; std::vector *vehicles = &(grid[nonant]->vehicles); for (int v = vehicles->size() - 1; v >= 0; v--) { vehicle *next_vehicle = (*vehicles)[v]; @@ -2418,7 +2419,17 @@ void map::process_active_items_in_vehicles(game *g, const int nonant) int mapx = next_vehicle->posx + next_vehicle->parts[*part_index].precalc_dx[0]; int mapy = next_vehicle->posy + next_vehicle->parts[*part_index].precalc_dy[0]; for(int n = items_in_part->size() - 1; n >= 0; n--) { - if(process_active_item(g, &((*items_in_part)[n]), nonant, mapx, mapy)) { + it = &((*items_in_part)[n]); + // Check if it's in a fridge and is food. + if (it->is_food() && next_vehicle->part_flag(*part_index, "FRIDGE") && + next_vehicle->fridge_on) { + if (one_in(2)) { + it->bday++; + it->item_tags.erase("HOT"); + it->item_counter = 0; + } + } + if(process_active_item(g, it, nonant, mapx, mapy)) { next_vehicle->remove_item(*part_index, n); } } diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 4c888ceca81e7..95903fb2379e4 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -1141,7 +1141,7 @@ void vehicle::deserialize(JsonIn &jsin) add_missing_frames(); } find_horns (); - find_lights (); + find_power (); find_fuel_tanks (); find_exhaust (); insides_dirty = true; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 226b7c7a4c645..c3aebbd6410e3 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -23,7 +23,8 @@ enum vehicle_controls { release_control, control_cancel, convert_vehicle, - turn_on_engine + toggle_engine, + toggle_fridge }; vehicle::vehicle(game *ag, std::string type_id, int init_veh_fuel, int init_veh_status): g(ag), type(type_id) @@ -314,6 +315,7 @@ void vehicle::use_controls() bool has_turrets = false; bool has_tracker = false; bool has_engine = false; + bool has_fridge = false; for (int p = 0; p < parts.size(); p++) { if (part_flag(p, "CONE_LIGHT")) { has_lights = true; @@ -336,6 +338,9 @@ void vehicle::use_controls() else if (part_flag(p, "ENGINE")) { has_engine = true; } + else if (part_flag(p, "FRIDGE")) { + has_fridge = true; + } } // Lights if they are there - Note you can turn them on even when damaged, they just don't work @@ -348,8 +353,8 @@ void vehicle::use_controls() if (has_overhead_lights) { options_choice.push_back(toggle_overhead_lights); - options_message.push_back(uimenu_entry(overhead_lights_on ? _("Turn off overhead lights") : - _("Turn on overhead lights"), 'v')); + options_message.push_back(uimenu_entry(fridge_on ? _("Turn off fridge") : + _("Turn on fridge"), 'f')); current++; } @@ -368,6 +373,14 @@ void vehicle::use_controls() current++; } + // Turn the fridge on/off + if (has_fridge) { + options_choice.push_back(toggle_fridge); + options_message.push_back(uimenu_entry(toggle_fridge ? _("Switch turrets to burst mode") : + _("Disable turrets"), 't')); + current++; + } + // Tracking on the overmap if (has_tracker) { options_choice.push_back(toggle_tracker); @@ -386,7 +399,7 @@ void vehicle::use_controls() // Exit vehicle, if we are in it. int vpart; if (has_engine) { - options_choice.push_back(turn_on_engine); + options_choice.push_back(toggle_engine); options_message.push_back(uimenu_entry((engine_on) ? _("Turn off the engine") : _("Turn on the engine"), 'e')); current++; @@ -446,7 +459,16 @@ void vehicle::use_controls() } g->add_msg((0 == turret_mode) ? _("Turrets: Disabled") : _("Turrets: Burst mode")); break; - case turn_on_engine: + case toggle_fridge: + if( !fridge_on || fuel_left("battery") ) { + fridge_on = !fridge_on; + g->add_msg((overhead_lights_on) ? _("Fridge turned on") : + _("Fridge turned off")); + } else { + g->add_msg(_("The fridge won't turn on!")); + } + break; + case toggle_engine: if (engine_on) { engine_on = false; g->add_msg(_("You turn the engine off.")); @@ -872,20 +894,10 @@ int vehicle::install_part (int dx, int dy, std::string id, int hp, bool force) if(part_flag(parts.size()-1,"HORN")) { horns.push_back(parts.size() - 1); } - if(part_flag(parts.size()-1,"LIGHT") || part_flag(parts.size()-1,"CONE_LIGHT")) - { - lights.push_back(parts.size()-1); - lights_power += part_info(parts.size()-1).power; - } - if (part_flag(parts.size()-1,"CIRCLE_LIGHT")) { - overhead_power += part_info(parts.size()-1).power; - } - if(part_flag(parts.size()-1, "TRACK")) - { - tracking_power += part_info(parts.size()-1).power; - } if(part_flag(parts.size()-1,"FUEL_TANK")) fuel.push_back(parts.size()-1); + + find_power (); find_exhaust (); precalc_mounts (0, face.dir()); insides_dirty = true; @@ -931,10 +943,7 @@ void vehicle::give_part_properties_to_item(game* g, int partnum, item& i){ void vehicle::remove_part (int p) { - if(part_flag(p,"LIGHT")) { - lights_power -= part_info( parts.size() - 1 ).power; - } else if (part_flag(p, "TRACK")) { - tracking_power -= part_info( parts.size() - 1 ).power; + if (part_flag(p, "TRACK")) { // disable tracking if there are no other trackers installed. if (tracking_on) { @@ -966,7 +975,7 @@ void vehicle::remove_part (int p) parts.erase(parts.begin() + p); find_horns (); - find_lights (); + find_power (); find_fuel_tanks (); find_exhaust (); precalc_mounts (0, face.dir()); @@ -1858,10 +1867,10 @@ void vehicle::consume_fuel () void vehicle::power_parts ()//TODO: more categories of powered part! { int power=0; - find_lights(); if(lights_on)power += lights_power; if(overhead_lights_on)power += overhead_power; if(tracking_on)power += tracking_power; + if(fridge_on) power += fridge_power; if(power <= 0)return; for(int f=0;f 0;f++) { @@ -1884,6 +1893,7 @@ void vehicle::power_parts ()//TODO: more categories of powered part! lights_on = false; tracking_on = false; overhead_lights_on = false; + fridge_on = false; if(player_in_control(&g->u) || g->u_see(global_x(), global_y()) ) g->add_msg("The %s's battery dies!",name.c_str()); } @@ -2760,19 +2770,26 @@ void vehicle::find_horns () } } -void vehicle::find_lights () +void vehicle::find_power () { lights.clear(); lights_power = 0; overhead_power = 0; + tracking_power = 0; + fridge_power = 0; for (int p = 0; p < parts.size(); p++) { - if(part_flag( p,"LIGHT" ) || part_flag(p,"CONE_LIGHT") || - part_flag(p,"CIRCLE_LIGHT")) { - lights.push_back(p); - if(part_flag(p,"CIRCLE_LIGHT")) - overhead_power += part_info(p).power; - else - lights_power += part_info(p).power; + if(part_flag(parts.size()-1,"LIGHT") || part_flag(parts.size()-1,"CONE_LIGHT")) { + lights.push_back(parts.size()-1); + lights_power += part_info(parts.size()-1).power; + } + if (part_flag(parts.size()-1,"CIRCLE_LIGHT")) { + overhead_power += part_info(parts.size()-1).power; + } + if(part_flag(parts.size()-1, "TRACK")) { + tracking_power += part_info(parts.size()-1).power; + } + if(part_flag(parts.size()-1, "FRIDGE")) { + fridge_power += part_info(parts.size()-1).power; } } } diff --git a/src/vehicle.h b/src/vehicle.h index 7091880a69875..1f66b1693d5e7 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -432,7 +432,7 @@ class vehicle : public JsonSerializer, public JsonDeserializer void find_horns (); - void find_lights (); + void find_power (); void find_fuel_tanks (); @@ -509,6 +509,7 @@ class vehicle : public JsonSerializer, public JsonDeserializer bool tracking_on; // vehicle tracking on/off int om_id; // id of the om_vehicle struct corresponding to this vehicle bool overhead_lights_on; //circle lights on/off + bool fridge_on; //fridge on/off int turn_dir; // direction, to wich vehicle is turning (player control). will rotate frame on next move bool skidding; // skidding mode int last_turn; // amount of last turning (for calculate skidding due to handbrake) @@ -519,6 +520,7 @@ class vehicle : public JsonSerializer, public JsonDeserializer int lights_power; // total power of components with LIGHT or CONE_LIGHT flag int overhead_power; // total power of components with CIRCLE_LIGHT flag int tracking_power; // total power consumed by tracking devices (why would you use more than one?) + int fridge_power; // total power consumed by tracking devices (why would you use more than one?) }; #endif From d2f08c33193556ff10bd66bc700d6d362b738e5d Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Mon, 25 Nov 2013 00:49:07 +0000 Subject: [PATCH 06/19] Fix option menu. --- src/vehicle.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index c3aebbd6410e3..0a8487b8cbc43 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -353,8 +353,8 @@ void vehicle::use_controls() if (has_overhead_lights) { options_choice.push_back(toggle_overhead_lights); - options_message.push_back(uimenu_entry(fridge_on ? _("Turn off fridge") : - _("Turn on fridge"), 'f')); + options_message.push_back(uimenu_entry(overhead_lights_on ? _("Turn off overhead lights") : + _("Turn on overhead lights"), 'f')); current++; } @@ -376,8 +376,8 @@ void vehicle::use_controls() // Turn the fridge on/off if (has_fridge) { options_choice.push_back(toggle_fridge); - options_message.push_back(uimenu_entry(toggle_fridge ? _("Switch turrets to burst mode") : - _("Disable turrets"), 't')); + options_message.push_back(uimenu_entry(toggle_fridge ? _("Turn off fridge") : + _("Turn on fridge"), 't')); current++; } @@ -462,7 +462,7 @@ void vehicle::use_controls() case toggle_fridge: if( !fridge_on || fuel_left("battery") ) { fridge_on = !fridge_on; - g->add_msg((overhead_lights_on) ? _("Fridge turned on") : + g->add_msg((fridge_on) ? _("Fridge turned on") : _("Fridge turned off")); } else { g->add_msg(_("The fridge won't turn on!")); From a140e5f09c80616eefb6ce1eafeb5b763925ac84 Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Mon, 25 Nov 2013 00:51:45 +0000 Subject: [PATCH 07/19] Save and load fridge state. --- src/savegame_json.cpp | 2 ++ src/vehicle.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 95903fb2379e4..f09eea6557c6e 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -1125,6 +1125,7 @@ void vehicle::deserialize(JsonIn &jsin) data.read("tracking_on", tracking_on); data.read("lights_on", lights_on); data.read("overhead_lights_on", overhead_lights_on); + data.read("fridge_on", fridge_on); data.read("skidding", skidding); data.read("turret_mode", turret_mode); data.read("of_turn_carry", of_turn_carry); @@ -1169,6 +1170,7 @@ void vehicle::serialize(JsonOut &json) const json.member( "tracking_on", tracking_on ); json.member( "lights_on", lights_on ); json.member( "overhead_lights_on", overhead_lights_on ); + json.member( "fridge_on", fridge_on ); json.member( "skidding", skidding ); json.member( "turret_mode", turret_mode ); json.member( "of_turn_carry", of_turn_carry ); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 0a8487b8cbc43..6deb1daa851de 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -376,7 +376,7 @@ void vehicle::use_controls() // Turn the fridge on/off if (has_fridge) { options_choice.push_back(toggle_fridge); - options_message.push_back(uimenu_entry(toggle_fridge ? _("Turn off fridge") : + options_message.push_back(uimenu_entry(fridge_on ? _("Turn off fridge") : _("Turn on fridge"), 't')); current++; } @@ -462,8 +462,8 @@ void vehicle::use_controls() case toggle_fridge: if( !fridge_on || fuel_left("battery") ) { fridge_on = !fridge_on; - g->add_msg((fridge_on) ? _("Fridge turned on") : - _("Fridge turned off")); + g->add_msg((fridge_on) ? _("Fridge turned off") : + _("Fridge turned on")); } else { g->add_msg(_("The fridge won't turn on!")); } From 0466e342007490e9b1a10038322d3ee317ab81a0 Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Mon, 25 Nov 2013 01:04:23 +0000 Subject: [PATCH 08/19] Use power at the same rate the engine makes it. --- data/json/vehicle_parts.json | 2 +- src/vehicle.cpp | 57 ++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/data/json/vehicle_parts.json b/data/json/vehicle_parts.json index 206d57618b5db..d46a00b0609c9 100644 --- a/data/json/vehicle_parts.json +++ b/data/json/vehicle_parts.json @@ -1241,7 +1241,7 @@ "broken_color" : "light_blue", "damage_modifier" : 80, "durability" : 100, - "power" : 10, + "power" : 4, "size" : 400, "item" : "minifridge", "difficulty" : 3, diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 6deb1daa851de..6dd292d3a4a01 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -462,8 +462,8 @@ void vehicle::use_controls() case toggle_fridge: if( !fridge_on || fuel_left("battery") ) { fridge_on = !fridge_on; - g->add_msg((fridge_on) ? _("Fridge turned off") : - _("Fridge turned on")); + g->add_msg((fridge_on) ? _("Fridge turned on") : + _("Fridge turned off")); } else { g->add_msg(_("The fridge won't turn on!")); } @@ -1867,26 +1867,28 @@ void vehicle::consume_fuel () void vehicle::power_parts ()//TODO: more categories of powered part! { int power=0; - if(lights_on)power += lights_power; - if(overhead_lights_on)power += overhead_power; - if(tracking_on)power += tracking_power; - if(fridge_on) power += fridge_power; - if(power <= 0)return; - for(int f=0;f 0;f++) - { - if(part_info(fuel[f]).fuel_type == "battery") - { - if(parts[fuel[f]].amount < power) - { - power -= parts[fuel[f]].amount; - parts[fuel[f]].amount = 0; - } - else - { - parts[fuel[f]].amount -= power; - power = 0; - } - } + if(one_in(6)) { // Use power at the same rate the engine makes power. + if(lights_on)power += lights_power; + if(overhead_lights_on)power += overhead_power; + if(tracking_on)power += tracking_power; + if(fridge_on) power += fridge_power; + if(power <= 0)return; + for(int f=0;f 0;f++) + { + if(part_info(fuel[f]).fuel_type == "battery") + { + if(parts[fuel[f]].amount < power) + { + power -= parts[fuel[f]].amount; + parts[fuel[f]].amount = 0; + } + else + { + parts[fuel[f]].amount -= power; + power = 0; + } + } + } } if(power) { @@ -1923,7 +1925,7 @@ void vehicle::charge_battery (int amount) void vehicle::idle() { if (engine_on && total_power () > 0) { - if(one_in(20)) { + if(one_in(6)) { int strn = (int) (strain () * strain() * 100); for (int p = 0; p < parts.size(); p++) @@ -1950,9 +1952,12 @@ void vehicle::idle() { g->sound(global_x(), global_y(), sound, "hummm."); if (one_in(10)) { - int rdx = rng(0, 2); - int rdy = rng(0, 2); - g->m.add_field(g, global_x() + rdx, global_y() + rdy, fd_smoke, (sound / 50) + 1); + int smk = noise (true, true); // Only generate smoke for gas cars. + if (smk > 0) { + int rdx = rng(0, 2); + int rdy = rng(0, 2); + g->m.add_field(g, global_x() + rdx, global_y() + rdy, fd_smoke, (sound / 50) + 1); + } } } } From 8f86d996a6351ceb45fb96fc9928c2ba6fef2e9a Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Mon, 25 Nov 2013 01:10:02 +0000 Subject: [PATCH 09/19] Make fridge keep things fresh for 5 times as long. --- src/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map.cpp b/src/map.cpp index f0e7e80831954..0c7722aac76ba 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2423,7 +2423,7 @@ void map::process_active_items_in_vehicles(game *g, const int nonant) // Check if it's in a fridge and is food. if (it->is_food() && next_vehicle->part_flag(*part_index, "FRIDGE") && next_vehicle->fridge_on) { - if (one_in(2)) { + if (!one_in(5)) { it->bday++; it->item_tags.erase("HOT"); it->item_counter = 0; From 82b55ea05444dae4c1fb88f0c021cbbce7c8347f Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Mon, 25 Nov 2013 01:15:43 +0000 Subject: [PATCH 10/19] Add the minifridge to the hardware item groups. --- data/json/item_groups.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/json/item_groups.json b/data/json/item_groups.json index 36ed8f305bddb..aeaeaed10d0c3 100644 --- a/data/json/item_groups.json +++ b/data/json/item_groups.json @@ -448,6 +448,7 @@ ["duct_tape", 70], ["lawnmower", 25], ["floodlight", 10], + ["minifridge", 5], ["char_smoker", 25], ["lawn_dart", 10], ["dehydrator", 15], @@ -1164,6 +1165,7 @@ ["jerrycan", 10], ["lawnmower", 25], ["floodlight", 20], + ["minifridge", 10], ["char_smoker", 25], ["dehydrator", 15], ["foot_crank", 10], @@ -1266,6 +1268,7 @@ ["duct_tape", 60], ["lawnmower", 25], ["floodlight", 10], + ["minifridge", 5], ["boltcutters", 8], ["foot_crank", 10], ["cable", 60], @@ -2962,6 +2965,7 @@ ["bat_metal", 60], ["lawnmower", 25], ["floodlight", 20], + ["minifridge", 20], ["char_smoker", 25], ["lawn_dart", 10], ["dehydrator", 15], From 82631db15420b3ba7920601fe862ba59691b8d82 Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Mon, 25 Nov 2013 03:49:52 +0000 Subject: [PATCH 11/19] Update rot code and store the turn we entered a fridge. --- src/item.cpp | 18 ++++++++++++++++-- src/item.h | 7 ++++--- src/map.cpp | 12 ++++++------ src/player.cpp | 7 +++++-- src/savegame_json.cpp | 3 ++- 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/item.cpp b/src/item.cpp index bfafe70d32fd3..55341b363aa5d 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -180,6 +180,7 @@ void item::init() { mission_id = -1; player_id = -1; light = nolight; + fridge = 0; } void item::make(itype* it) @@ -864,7 +865,7 @@ std::string item::tname(game *g) if (food != NULL && g != NULL && food->has_flag("HOT")) ret << _(" (hot)"); if (food != NULL && g != NULL && food_type->spoils != 0 && - int(g->turn) - (int)(food->bday) > food_type->spoils * 600) + rotten(g)) ret << _(" (rotten)"); if (has_flag("FIT")) { @@ -1135,10 +1136,23 @@ int item::has_gunmod(itype_id mod_type) bool item::rotten(game *g) { + int expiry; if (!is_food() || g == NULL) return false; it_comest* food = dynamic_cast(type); - return (food->spoils != 0 && int(g->turn) - (int)bday > food->spoils * 600); + if (food->spoils != 0) { + it_comest* food = dynamic_cast(type); + if (fridge > 0) { + // Add the number of turns we should get from refrigeration + bday += ((int)g->turn - fridge) * 0.8; + fridge = 0; + } + expiry = (int)g->turn - bday; + return (expiry > food->spoils * 600); + } + else { + return false; + } } bool item::ready_to_revive(game *g) diff --git a/src/item.h b/src/item.h index f4512d97676b1..8ed6b94dd5a21 100644 --- a/src/item.h +++ b/src/item.h @@ -33,7 +33,7 @@ struct iteminfo{ std::string sPlus; //number + bool bNewLine; //New line at the end bool bLowerIsBetter; //Lower values are better (red <-> green) - + //Inputs are: ItemType, main text, text between main text and value, value, if the value should be an int instead of a double, text after number, if there should be a newline after this item, if lower values are better iteminfo(std::string sIn0, std::string sIn1, std::string sIn2 = "", double dIn0 = -999, bool bIn0 = true, std::string sIn3 = "", bool bIn1 = true, bool bIn2 = false) { sType = sIn0; @@ -56,7 +56,7 @@ struct iteminfo{ } }; -enum LIQUID_FILL_ERROR {L_ERR_NONE, L_ERR_NO_MIX, L_ERR_NOT_CONTAINER, L_ERR_NOT_WATERTIGHT, +enum LIQUID_FILL_ERROR {L_ERR_NONE, L_ERR_NO_MIX, L_ERR_NOT_CONTAINER, L_ERR_NOT_WATERTIGHT, L_ERR_NOT_SEALED, L_ERR_FULL}; class item : public JsonSerializer, public JsonDeserializer @@ -190,7 +190,7 @@ class item : public JsonSerializer, public JsonDeserializer bool is_container() const; bool is_watertight_container() const; int is_funnel_container(int bigger_than) const; - + bool is_tool() const; bool is_software() const; bool is_macguffin() const; @@ -214,6 +214,7 @@ class item : public JsonSerializer, public JsonDeserializer char invlet; // Inventory letter int charges; bool active; // If true, it has active effects to be processed + int fridge; // The turn we entered a fridge. signed char damage; // How much damage it's sustained; generally, max is 5 int burnt; // How badly we're burnt int bday; // The turn on which it was created diff --git a/src/map.cpp b/src/map.cpp index 0c7722aac76ba..01604825d7801 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2422,12 +2422,9 @@ void map::process_active_items_in_vehicles(game *g, const int nonant) it = &((*items_in_part)[n]); // Check if it's in a fridge and is food. if (it->is_food() && next_vehicle->part_flag(*part_index, "FRIDGE") && - next_vehicle->fridge_on) { - if (!one_in(5)) { - it->bday++; - it->item_tags.erase("HOT"); - it->item_counter = 0; - } + next_vehicle->fridge_on && it->fridge == 0) { + it->fridge = (int)g->turn; + it->item_counter -= 10; } if(process_active_item(g, it, nonant, mapx, mapy)) { next_vehicle->remove_item(*part_index, n); @@ -2460,6 +2457,9 @@ bool map::process_active_item(game* g, item *it, const int nonant, const int i, grid[nonant]->active_item_count--; } } + if (it->fridge > 0) { + it->fridge = 0; + } } else if (it->is_food_container()) { // food in containers if (it->contents[0].has_flag("HOT")) { it->contents[0].item_counter--; diff --git a/src/player.cpp b/src/player.cpp index 3a8c025771492..478f286155344 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -5537,6 +5537,9 @@ bool player::process_single_active_item(game *g, item *it) it->active = false; } } + if (it->fridge > 0) { + it->fridge = 0; + } } else if (it->is_food_container()) { @@ -7048,7 +7051,7 @@ bool player::wear_item(game *g, item *to_wear, bool interactive) } return false; } - + if (armor->covers & mfb(bp_head) && has_trait("HORNS_CURLED")) { if(interactive) @@ -8140,7 +8143,7 @@ void player::try_to_sleep(game *g) if (furn_at_pos == f_bed || furn_at_pos == f_makeshift_bed || trap_at_pos == tr_cot || trap_at_pos == tr_rollmat || trap_at_pos == tr_fur_rollmat || furn_at_pos == f_armchair || - furn_at_pos == f_sofa || furn_at_pos == f_hay || + furn_at_pos == f_sofa || furn_at_pos == f_hay || (veh && veh->part_with_feature (vpart, "SEAT") >= 0) || (veh && veh->part_with_feature (vpart, "BED") >= 0)) g->add_msg(_("This is a comfortable place to sleep.")); diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index f09eea6557c6e..736aaf189ae25 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -936,7 +936,7 @@ void item::deserialize(JsonObject &data) data.read( "damage", damtmp ); damage = damtmp; // todo: check why this is done after make(), using a tmp variable data.read( "active", active ); - + data.read( "fridge", fridge ); data.read( "curammo", ammotmp ); if ( ammotmp != "null" ) { @@ -1010,6 +1010,7 @@ void item::serialize(JsonOut &json, bool save_contents) const if ( ammotmp != "null" ) json.member( "curammo", ammotmp ); if ( mode != "NULL" ) json.member( "mode", mode ); if ( active == true ) json.member( "active", true ); + if ( fridge == true ) json.member( "fridge", true ); if ( corpse != NULL ) json.member( "corpse", corpse->id ); if ( owned != -1 ) json.member( "owned", owned ); From d3b477bfba897f2c6c3acd7f25cf0929d62fda1c Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Mon, 25 Nov 2013 03:51:36 +0000 Subject: [PATCH 12/19] Remove code that would wrongly reset our fridge status. --- src/map.cpp | 3 --- src/player.cpp | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 01604825d7801..d3807859d8482 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2457,9 +2457,6 @@ bool map::process_active_item(game* g, item *it, const int nonant, const int i, grid[nonant]->active_item_count--; } } - if (it->fridge > 0) { - it->fridge = 0; - } } else if (it->is_food_container()) { // food in containers if (it->contents[0].has_flag("HOT")) { it->contents[0].item_counter--; diff --git a/src/player.cpp b/src/player.cpp index 478f286155344..8903ad21bce3d 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -5537,9 +5537,6 @@ bool player::process_single_active_item(game *g, item *it) it->active = false; } } - if (it->fridge > 0) { - it->fridge = 0; - } } else if (it->is_food_container()) { From 7e2722ff14c7edc65662566d2265fb083dcb2928 Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Mon, 25 Nov 2013 04:12:09 +0000 Subject: [PATCH 13/19] Fix turn on letters. --- src/vehicle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 6dd292d3a4a01..a20e833855ad7 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -354,7 +354,7 @@ void vehicle::use_controls() if (has_overhead_lights) { options_choice.push_back(toggle_overhead_lights); options_message.push_back(uimenu_entry(overhead_lights_on ? _("Turn off overhead lights") : - _("Turn on overhead lights"), 'f')); + _("Turn on overhead lights"), 'v')); current++; } @@ -377,7 +377,7 @@ void vehicle::use_controls() if (has_fridge) { options_choice.push_back(toggle_fridge); options_message.push_back(uimenu_entry(fridge_on ? _("Turn off fridge") : - _("Turn on fridge"), 't')); + _("Turn on fridge"), 'f')); current++; } From 02540c168eac5a7cf7396083f4856b4288f6dd17 Mon Sep 17 00:00:00 2001 From: freezerbunny Date: Mon, 25 Nov 2013 04:19:40 +0000 Subject: [PATCH 14/19] Update comment to reflect what it actually does. --- src/vehicle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vehicle.h b/src/vehicle.h index 1f66b1693d5e7..e70300eae03aa 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -520,7 +520,7 @@ class vehicle : public JsonSerializer, public JsonDeserializer int lights_power; // total power of components with LIGHT or CONE_LIGHT flag int overhead_power; // total power of components with CIRCLE_LIGHT flag int tracking_power; // total power consumed by tracking devices (why would you use more than one?) - int fridge_power; // total power consumed by tracking devices (why would you use more than one?) + int fridge_power; // total power consumed by fridges }; #endif From d2ef95cc3f3741218769daa2c9c60ef7cb5a8623 Mon Sep 17 00:00:00 2001 From: Rivet-the-Zombie Date: Mon, 25 Nov 2013 02:24:30 -0600 Subject: [PATCH 15/19] Another small weapon tweak. --- data/json/items/melee.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/items/melee.json b/data/json/items/melee.json index b4e7c44d85218..6722c8e57390c 100644 --- a/data/json/items/melee.json +++ b/data/json/items/melee.json @@ -1745,7 +1745,7 @@ "name" : "pipe", "description" : "A steel pipe, makes a good melee weapon. Useful in a few crafting recipes.", "weight" : 1262, - "to_hit" : 3, + "to_hit" : 1, "color" : "dark_gray", "symbol" : "/", "material" : ["steel", "null"], From 829fb3605685db3cbfc81598523c2202858f1e24 Mon Sep 17 00:00:00 2001 From: Rivet-the-Zombie Date: Mon, 25 Nov 2013 02:35:39 -0600 Subject: [PATCH 16/19] Flintlock fixes. --- data/json/items/ranged.json | 8 ++++---- data/json/recipes/recipes.json | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/data/json/items/ranged.json b/data/json/items/ranged.json index a9a284512bf46..6fc0708317789 100644 --- a/data/json/items/ranged.json +++ b/data/json/items/ranged.json @@ -2865,7 +2865,7 @@ "durability": 6, "burst": 0, "clip_size": 1, - "reload": 450 + "reload": 1000 }, { "id": "pistol_flint", @@ -2885,11 +2885,11 @@ "to_hit": -1, "ranged_damage": -2, "range": 3, - "dispersion": 14, - "recoil": 5, + "dispersion": 21, + "recoil": 8, "durability": 6, "burst": 0, "clip_size": 1, - "reload": 350 + "reload": 800 } ] diff --git a/data/json/recipes/recipes.json b/data/json/recipes/recipes.json index e9fb2fc630514..dfa779c81b9e1 100644 --- a/data/json/recipes/recipes.json +++ b/data/json/recipes/recipes.json @@ -21950,6 +21950,9 @@ "time": 20000, "reversible": false, "autolearn": true, + "qualities":[ + {"id":"CUT","level":1,"amount":1} + ], "tools": [ [ [ "press", -1 ] @@ -21975,7 +21978,8 @@ [ [ "money_bundle", 1 ], [ "wrapper", 1], - [ "bag_plastic", 1 ] + [ "bag_plastic", 1 ], + [ "paper", 25 ] ] ] },{ From 32ec28d117cbbeb3d442c2dbdb893df80182f83d Mon Sep 17 00:00:00 2001 From: Rivet-the-Zombie Date: Mon, 25 Nov 2013 02:39:23 -0600 Subject: [PATCH 17/19] Smores recipe fix. --- data/json/recipes/recipes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/recipes/recipes.json b/data/json/recipes/recipes.json index dfa779c81b9e1..7e2681c2bf829 100644 --- a/data/json/recipes/recipes.json +++ b/data/json/recipes/recipes.json @@ -7791,7 +7791,7 @@ "tools": [ [ [ "hotplate", 8], - [ "char_smoke", 1], + [ "char_smoker", 1], [ "toolset", 1], [ "fire", -1] ], From 213077491ea2df664ebfc09465fa661505637cdc Mon Sep 17 00:00:00 2001 From: Rivet-the-Zombie Date: Mon, 25 Nov 2013 02:40:57 -0600 Subject: [PATCH 18/19] Materials. --- data/json/recipes/recipes.json | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/data/json/recipes/recipes.json b/data/json/recipes/recipes.json index 7e2681c2bf829..30b6991ba3c9a 100644 --- a/data/json/recipes/recipes.json +++ b/data/json/recipes/recipes.json @@ -21992,6 +21992,9 @@ "time": 12000, "reversible": true, "autolearn": true, + "qualities":[ + {"id":"CUT","level":1,"amount":1} + ], "tools": [ [ [ "hacksaw", -1 ], @@ -22007,7 +22010,10 @@ [ "pipe", 1 ] ], [ - [ "2x4", 1 ] + [ "2x4", 2 ] + ], + [ + [ "rag", 1 ] ], [ [ "scrap", 1 ] @@ -22024,6 +22030,9 @@ "time": 12000, "reversible": true, "autolearn": true, + "qualities":[ + {"id":"CUT","level":1,"amount":1} + ], "tools": [ [ [ "hacksaw", -1 ], @@ -22041,6 +22050,9 @@ [ [ "2x4", 1 ] ], + [ + [ "rag", 1 ] + ], [ [ "scrap", 1 ] ] From c1a2b2eb16dbac10b87deb5fec5a3412408e4378 Mon Sep 17 00:00:00 2001 From: fnord Date: Mon, 25 Nov 2013 05:18:42 -0600 Subject: [PATCH 19/19] fix "solder" itemgroup ref --- data/json/item_groups.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/item_groups.json b/data/json/item_groups.json index 409066ed2a05f..671a64198a7db 100644 --- a/data/json/item_groups.json +++ b/data/json/item_groups.json @@ -658,7 +658,7 @@ ["smrifle_primer", 10], ["lgrifle_primer", 10], ["lead", 10], - ["solder", 10], + ["solder_wire", 10], ["tin", 10], ["bismuth", 10], ["puller", 5],