diff --git a/crafting.cpp b/crafting.cpp index 83e265db7c721..300cb4e2079a7 100644 --- a/crafting.cpp +++ b/crafting.cpp @@ -505,6 +505,14 @@ RECIPE(itm_c4, CC_WEAPON, sk_mechanics, sk_electronics, 4, 8000); TOOL(itm_rock, -1, itm_toolset, -1, NULL); COMP(itm_apple, 3, NULL); + RECIPE(itm_long_island, CC_FOOD, sk_cooking, sk_null, 1, 7000, false); + COMP(itm_cola, 1, NULL); + COMP(itm_vodka, 1, NULL); + COMP(itm_gin, 1, NULL); + COMP(itm_rum, 1, NULL); + COMP(itm_tequila, 1, NULL); + COMP(itm_triple_sec, 1, NULL); + RECIPE(itm_jerky, CC_FOOD, sk_cooking, sk_null, 3, 30000, false); TOOL(itm_hotplate, 10, itm_toolset, 5, itm_fire, -1, NULL); COMP(itm_salt_water, 1, itm_salt, 4, NULL); diff --git a/item.cpp b/item.cpp index e4825ccf30aa6..4cd26e83ef2eb 100644 --- a/item.cpp +++ b/item.cpp @@ -1505,7 +1505,7 @@ int item::pick_reload_ammo(player &u, bool interactive) (has_spare_mag != -1 && contents[has_spare_mag].charges < tmp->clip)) { std::vector tmpammo = u.has_ammo(ammo_type()); for (int i = 0; i < tmpammo.size(); i++) - if (charges >= 0 || u.inv[tmpammo[i]].typeId() == curammo->id) + if (charges <= 0 || u.inv[tmpammo[i]].typeId() == curammo->id) am.push_back(tmpammo[i]); } @@ -1516,7 +1516,7 @@ int item::pick_reload_ammo(player &u, bool interactive) contents[i].charges < (dynamic_cast(contents[i].type))->clip) { std::vector tmpammo = u.has_ammo((dynamic_cast(contents[i].type))->newtype); for(int j = 0; j < tmpammo.size(); j++) - if (contents[i].charges >= 0 || + if (contents[i].charges <= 0 || u.inv[tmpammo[j]].typeId() == contents[i].curammo->id) am.push_back(tmpammo[j]); } @@ -1568,6 +1568,11 @@ bool item::reload(player &u, int index) bool single_load = false; int max_load = 1; item *reload_target = NULL; + item *ammo_to_use = &u.inv[index]; + + // Handle ammo in containers, currently only gasoline + if(ammo_to_use->is_container()) + ammo_to_use = &ammo_to_use->contents[0]; if (is_gun()) { // Reload using a spare magazine @@ -1584,27 +1589,27 @@ bool item::reload(player &u, int index) // Determine what we're reloading, the gun, a spare magazine, or another gunmod. // Prefer the active gunmod if there is one item* gunmod = active_gunmod(); - if (gunmod != NULL && gunmod->ammo_type() == u.inv[index].ammo_type() && - (gunmod->charges <= 0 || gunmod->curammo->id == u.inv[index].typeId())) { + if (gunmod != NULL && gunmod->ammo_type() == ammo_to_use->ammo_type() && + (gunmod->charges <= 0 || gunmod->curammo->id == ammo_to_use->typeId())) { reload_target = gunmod; // Then prefer the gun itself } else if (charges < clip_size() && - ammo_type() == u.inv[index].ammo_type() && - (charges <= 0 || curammo->id == u.inv[index].typeId())) { + ammo_type() == ammo_to_use->ammo_type() && + (charges <= 0 || curammo->id == ammo_to_use->typeId())) { reload_target = this; // Then prefer a spare mag if present } else if (spare_mag != -1 && - ammo_type() == u.inv[index].ammo_type() && + ammo_type() == ammo_to_use->ammo_type() && contents[spare_mag].charges != (dynamic_cast(type))->clip && - (charges <= 0 || curammo->id == u.inv[index].typeId())) { + (charges <= 0 || curammo->id == ammo_to_use->typeId())) { reload_target = &contents[spare_mag]; // Finally consider other gunmods } else { for (int i = 0; i < contents.size(); i++) { if (&contents[i] != gunmod && i != spare_mag && contents[i].is_gunmod() && - contents[i].has_flag(IF_MODE_AUX) && contents[i].ammo_type() == u.inv[index].ammo_type() && + contents[i].has_flag(IF_MODE_AUX) && contents[i].ammo_type() == ammo_to_use->ammo_type() && (contents[i].charges <= (dynamic_cast(contents[i].type))->clip || - (contents[i].charges <= 0 || contents[i].curammo->id == u.inv[index].typeId()))) { + (contents[i].charges <= 0 || contents[i].curammo->id == ammo_to_use->typeId()))) { reload_target = &contents[i]; break; } @@ -1636,30 +1641,33 @@ bool item::reload(player &u, int index) // If the gun is currently loaded with a different type of ammo, reloading fails if ((reload_target->is_gun() || reload_target->is_gunmod()) && reload_target->charges > 0 && - reload_target->curammo->id != u.inv[index].typeId()) + reload_target->curammo->id != ammo_to_use->typeId()) return false; if (reload_target->is_gun() || reload_target->is_gunmod()) { - if (!u.inv[index].is_ammo()) { + if (!ammo_to_use->is_ammo()) { debugmsg("Tried to reload %s with %s!", tname().c_str(), - u.inv[index].tname().c_str()); + ammo_to_use->tname().c_str()); return false; } - reload_target->curammo = dynamic_cast((u.inv[index].type)); + reload_target->curammo = dynamic_cast((ammo_to_use->type)); } if (single_load || max_load == 1) { // Only insert one cartridge! reload_target->charges++; - u.inv[index].charges--; + ammo_to_use->charges--; } else { - reload_target->charges += u.inv[index].charges; - u.inv[index].charges = 0; + reload_target->charges += ammo_to_use->charges; + ammo_to_use->charges = 0; if (reload_target->charges > max_load) { // More rounds than the clip holds, put some back - u.inv[index].charges += reload_target->charges - max_load; + ammo_to_use->charges += reload_target->charges - max_load; reload_target->charges = max_load; } } - if (u.inv[index].charges == 0) - u.i_remn(index); + if (ammo_to_use->charges == 0) + if (u.inv[index].is_container()) + u.inv[index].contents.erase(u.inv[index].contents.begin()); + else + u.i_remn(index); return true; } else return false; diff --git a/itype.h b/itype.h index 68a5303f139af..7c13344b09189 100644 --- a/itype.h +++ b/itype.h @@ -39,7 +39,8 @@ itm_fire, itm_toolset, itm_apparatus, // Drinks itm_water, itm_water_clean, itm_sewage, itm_salt_water, itm_oj, itm_apple_cider, itm_energy_drink, itm_cola, itm_rootbeer, itm_milk, itm_V8, itm_broth, - itm_soup, itm_whiskey, itm_vodka, itm_rum, itm_tequila, itm_beer, itm_bleach, + itm_soup, itm_whiskey, itm_vodka, itm_gin, itm_rum, itm_tequila, itm_triple_sec, + itm_long_island, itm_beer, itm_bleach, itm_ammonia, itm_mutagen, itm_purifier, itm_tea, itm_coffee, itm_blood, // Monster Meats itm_meat, itm_veggy, itm_meat_tainted, itm_veggy_tainted, itm_meat_cooked, diff --git a/itypedef.cpp b/itypedef.cpp index 605a026848420..3934cd9c7e374 100644 --- a/itypedef.cpp +++ b/itypedef.cpp @@ -131,6 +131,10 @@ DRINK("vodka", 20, 78, c_ltcyan, itm_bottle_glass, -10, 2, 0,-12, -2, 5, 7, 15,&iuse::alcohol, ADD_ALCOHOL, "\ In Soviet Russia, vodka drinks you!"); +DRINK("gin", 20, 78, c_ltcyan, itm_bottle_glass, + -10, 2, 0,-12, -2, 5, 7, 15,&iuse::alcohol, ADD_ALCOHOL, "\ +Smells faintly of elderberries, but mostly booze."); + DRINK("rum", 14, 85, c_ltcyan, itm_bottle_glass, -12, 2, 0,-10, -2, 5, 7, 15,&iuse::alcohol, ADD_ALCOHOL, "\ Drinking this might make you feel like a pirate. Or not."); @@ -139,6 +143,15 @@ DRINK("tequila", 12, 88, c_brown, itm_bottle_glass, -12, 2, 0,-12, -2, 6, 7, 18,&iuse::alcohol, ADD_ALCOHOL, "\ Don't eat the worm! Wait, there's no worm in this bottle."); +DRINK("triple sec", 12, 55, c_brown, itm_bottle_glass, + -8, 2, 0,-10, -2, 4, 7, 10,&iuse::alcohol, ADD_ALCOHOL, "\ +An orange flavored liquor used in many mixed drinks."); + +DRINK("long island iced tea", 8, 100, c_brown, itm_bottle_glass, + -10, 2, 0,-10, -2, 5, 6, 20,&iuse::alcohol, ADD_ALCOHOL, "\ +A blend of incredibly strong-flavored liquors that somehow tastes\n\ +like none of them."); + DRINK("beer", 60, 35, c_brown, itm_can_drink, 16, 4, 0, -4, -1, 2, 1, 10, &iuse::alcohol, ADD_ALCOHOL, "\ Best served cold, in a glass, and with a lime - but you're not that lucky."); diff --git a/mapitemsdef.cpp b/mapitemsdef.cpp index 43933aff56636..3c4b61b86027c 100644 --- a/mapitemsdef.cpp +++ b/mapitemsdef.cpp @@ -240,7 +240,7 @@ void game::init_mapitems() setvector( mapitems[mi_alcohol], - itm_whiskey, itm_vodka, itm_rum, itm_tequila, NULL); + itm_whiskey, itm_vodka, itm_gin, itm_rum, itm_tequila, itm_triple_sec, NULL); setvector( mapitems[mi_pool_table], diff --git a/player.cpp b/player.cpp index 56881c255470c..2140ce9edff48 100644 --- a/player.cpp +++ b/player.cpp @@ -4903,6 +4903,12 @@ std::vector player::has_ammo(ammotype at) } if (newtype) ret.push_back(a); + // Handle gasoline nested in containers + } else if (at == AT_GAS && inv[a].is_container() && + !inv[a].contents.empty() && inv[a].contents[0].is_ammo() && + dynamic_cast(inv[a].contents[0].type)->type == at) { + ret.push_back(a); + return ret; } } return ret;