bool item::rotten(game *g) { if (!is_food() || g == NULL) return false; it_comest* food = dynamic_cast<it_comest*>(type); return (food->spoils != 0 && int(g->turn) - (int)bday > food->spoils * 600); }
item item::in_its_container(std::vector<itype*> *itypes) { if (is_software()) { item ret( (*itypes)[itm_usb_drive], 0); ret.contents.push_back(*this); ret.invlet = invlet; return ret; } if (!is_food() || (dynamic_cast<it_comest*>(type))->container == itm_null) return *this; it_comest *food = dynamic_cast<it_comest*>(type); item ret((*itypes)[food->container], bday); if (dynamic_cast<it_comest*>(type)->container == itm_can_food) food->spoils = 0; if (made_of(LIQUID)) { it_container* container = dynamic_cast<it_container*>(ret.type); charges = container->contains * food->charges; } ret.contents.push_back(*this); ret.invlet = invlet; return ret; }
bool item::goes_bad() { if (!is_food()) return false; it_comest* food = dynamic_cast<it_comest*>(type); return (food->spoils != 0); }
nc_color item::color(player *u) { nc_color ret = c_ltgray; if (active && !is_food() && !is_food_container()) // Active items show up as yellow ret = c_yellow; else if (is_gun()) { // Guns are green if you are carrying ammo for them ammotype amtype = ammo_type(); if (u->has_ammo(amtype).size() > 0) ret = c_green; } else if (is_ammo()) { // Likewise, ammo is green if you have guns that use it ammotype amtype = ammo_type(); if (u->weapon.is_gun() && u->weapon.ammo_type() == amtype) ret = c_green; else { for (int i = 0; i < u->inv.size(); i++) { if (u->inv[i].is_gun() && u->inv[i].ammo_type() == amtype) { i = u->inv.size(); ret = c_green; } } } } else if (is_book()) { it_book* tmp = dynamic_cast<it_book*>(type); if (tmp->type && tmp->intel <= u->int_cur + u->skillLevel(tmp->type) && (tmp->intel == 0 || !u->has_trait(PF_ILLITERATE)) && (u->skillLevel(tmp->type) >= tmp->req) && (u->skillLevel(tmp->type) < tmp->level)) ret = c_ltblue; } return ret; }
bool item::is_weap() { if (is_gun() || is_food() || is_ammo() || is_food_container() || is_armor() || is_book() || is_tool()) return false; return (type->melee_dam > 7 || type->melee_cut > 5); }
bool item::is_other() { if( is_null() ) return false; return (!is_gun() && !is_ammo() && !is_armor() && !is_food() && !is_food_container() && !is_tool() && !is_gunmod() && !is_bionic() && !is_book() && !is_weap()); }
nc_color item::color_in_inventory(player *u) { // Items in our inventory get colorized specially nc_color ret = c_white; if (active && !is_food() && !is_food_container()) ret = c_yellow; return ret; }
item item::in_its_container(std::vector<itype*> *itypes) { if (!is_food() || (dynamic_cast<it_comest*>(type))->container == itm_null) return *this; it_comest *food = dynamic_cast<it_comest*>(type); item ret((*itypes)[food->container], bday); ret.contents.push_back(*this); ret.invlet = invlet; return ret; }
// Return an object that an be used bool object_type::is_usable_item() { if (is_staff()) return (TRUE); if (is_rod()) return (TRUE); if (is_wand()) return (TRUE); if (is_potion()) return (TRUE); if (is_scroll()) return (TRUE); if (is_food()) return (TRUE); return (FALSE); }
bool item::count_by_charges() { if (is_ammo()) return true; if (is_food()) { it_comest* food = dynamic_cast<it_comest*>(type); return (food->charges > 1); } return false; }
bool item::is_food(player *u) { if (u == NULL) return is_food(); if (type->is_food()) return true; if (u->has_bionic(bio_batteries) && is_ammo() && (dynamic_cast<it_ammo*>(type))->type == AT_BATT) return true; if (u->has_bionic(bio_furnace) && is_flammable(type->m1) && is_flammable(type->m2) && type->id != itm_corpse) return true; return false; }
bool item::is_food(player *u) const { if (!u) return is_food(); if( is_null() ) return false; if (type->is_food()) return true; if (u->has_bionic("bio_batteries") && is_ammo() && (dynamic_cast<it_ammo*>(type))->type == AT_BATT) return true; if (u->has_bionic("bio_furnace") && is_flammable(type->m1) && is_flammable(type->m2) && typeId() != "corpse") return true; return false; }
// Return an object that an be used bool object_type::is_mushroom() { if (!is_food()) return (FALSE); if (sval <= SV_FOOD_MAJOR_CURES) return (TRUE); return (FALSE); }
std::string item::tname(game *g) { std::stringstream ret; if (damage != 0 && !is_null()) { std::string damtext; switch (type->m1) { case VEGGY: case FLESH: damtext = "partially eaten "; break; case COTTON: case WOOL: if (damage == -1) damtext = "reinforced "; if (damage == 1) damtext = "ripped "; if (damage == 2) damtext = "torn "; if (damage == 3) damtext = "shredded "; if (damage == 4) damtext = "tattered "; break; case LEATHER: if (damage == -1) damtext = "reinforced "; if (damage == 1) damtext = "scratched "; if (damage == 2) damtext = "cut "; if (damage == 3) damtext = "torn "; if (damage == 4) damtext = "tattered "; break; case KEVLAR: if (damage == -1) damtext = "reinforced "; if (damage == 1) damtext = "marked "; if (damage == 2) damtext = "dented "; if (damage == 3) damtext = "scarred "; if (damage == 4) damtext = "broken "; break; case PAPER: if (damage == 1) damtext = "torn "; if (damage >= 2) damtext = "shredded "; break; case WOOD: if (damage == 1) damtext = "scratched "; if (damage == 2) damtext = "chipped "; if (damage == 3) damtext = "cracked "; if (damage == 4) damtext = "splintered "; break; case PLASTIC: case GLASS: if (damage == 1) damtext = "scratched "; if (damage == 2) damtext = "cut "; if (damage == 3) damtext = "cracked "; if (damage == 4) damtext = "shattered "; break; case IRON: if (damage == 1) damtext = "lightly rusted "; if (damage == 2) damtext = "rusted "; if (damage == 3) damtext = "very rusty "; if (damage == 4) damtext = "thoroughly rusted "; break; default: if (damage == 1) damtext = "lightly damaged "; if (damage == 2) damtext = "damaged "; if (damage == 3) damtext = "very damaged "; if (damage == 4) damtext = "thoroughly damaged "; } ret << damtext; } if (is_var_veh_part()){ if(type->bigness_aspect == BIGNESS_ENGINE_DISPLACEMENT){ //liters, e.g. "3.21-Liter V8 engine" ret.precision(4); ret << (float)bigness/100 << "-Liter "; } else if(type->bigness_aspect == BIGNESS_WHEEL_DIAMETER) { //inches, e.g. "20" wheel" ret << bigness << "\" "; } } if (volume() >= 4 && burnt >= volume() * 2) ret << "badly burnt "; else if (burnt > 0) ret << "burnt "; if (typeId() == "corpse") { ret << corpse->name << " corpse"; if (name != "") ret << " of " << name; return ret.str(); } else if (typeId() == "blood") { if (corpse == NULL || corpse->id == mon_null) ret << "human blood"; else ret << corpse->name << " blood"; return ret.str(); } if (is_gun() && contents.size() > 0 ) { ret << type->name; for (int i = 0; i < contents.size(); i++) ret << "+"; } else if (contents.size() == 1) ret << type->name << " of " << contents[0].tname(); else if (contents.size() > 0) ret << type->name << ", full"; else ret << type->name; it_comest* food = NULL; if (is_food()) food = dynamic_cast<it_comest*>(type); else if (is_food_container()) food = dynamic_cast<it_comest*>(contents[0].type); if (food != NULL && g != NULL && food->spoils != 0 && int(g->turn) < (int)bday + 100) ret << " (fresh)"; if (food != NULL && g != NULL && has_flag(IF_HOT)) ret << " (hot)"; if (food != NULL && g != NULL && is_food_container()) { if (contents[0].has_flag(IF_HOT)) ret << " (hot)"; } if (food != NULL && g != NULL && food->spoils != 0 && int(g->turn) - (int)bday > food->spoils * 600) ret << " (rotten)"; if (owned > 0) ret << " (owned)"; return ret.str(); }
std::string item::tname(game *g) { std::stringstream ret; if (damage != 0 && !is_null()) { std::string damtext; switch (type->m1) { case VEGGY: case FLESH: damtext = "partially eaten "; break; case COTTON: case WOOL: if (damage == -1) damtext = "reinforced "; if (damage == 1) damtext = "ripped "; if (damage == 2) damtext = "torn "; if (damage == 3) damtext = "shredded "; if (damage == 4) damtext = "tattered "; break; case LEATHER: if (damage == -1) damtext = "reinforced "; if (damage == 1) damtext = "scratched "; if (damage == 2) damtext = "cut "; if (damage == 3) damtext = "torn "; if (damage == 4) damtext = "tattered "; break; case KEVLAR: if (damage == -1) damtext = "reinforced "; if (damage == 1) damtext = "marked "; if (damage == 2) damtext = "dented "; if (damage == 3) damtext = "scarred "; if (damage == 4) damtext = "broken "; break; case PAPER: if (damage == 1) damtext = "torn "; if (damage >= 2) damtext = "shredded "; break; case WOOD: if (damage == 1) damtext = "scratched "; if (damage == 2) damtext = "chipped "; if (damage == 3) damtext = "cracked "; if (damage == 4) damtext = "splintered "; break; case PLASTIC: case GLASS: if (damage == 1) damtext = "scratched "; if (damage == 2) damtext = "cut "; if (damage == 3) damtext = "cracked "; if (damage == 4) damtext = "shattered "; break; case IRON: if (damage == 1) damtext = "lightly rusted "; if (damage == 2) damtext = "rusted "; if (damage == 3) damtext = "very rusty "; if (damage == 4) damtext = "thoroughly rusted "; break; default: damtext = "damaged "; } ret << damtext; } if (volume() >= 4 && burnt >= volume() * 2) ret << "badly burnt "; else if (burnt > 0) ret << "burnt "; if (typeId() == itm_corpse) { ret << corpse->name << " corpse"; if (name != "") ret << " of " << name; return ret.str(); } else if (typeId() == itm_blood) { if (corpse == NULL || corpse->id == mon_null) ret << "human blood"; else ret << corpse->name << " blood"; return ret.str(); } if (is_gun() && contents.size() > 0 ) { ret << type->name; for (int i = 0; i < contents.size(); i++) ret << "+"; } else if (contents.size() == 1) ret << type->name << " of " << contents[0].tname(); else if (contents.size() > 0) ret << type->name << ", full"; else ret << type->name; it_comest* food = NULL; if (is_food()) food = dynamic_cast<it_comest*>(type); else if (is_food_container()) food = dynamic_cast<it_comest*>(contents[0].type); if (food != NULL && g != NULL && food->spoils != 0 && int(g->turn) < (int)bday + 100) ret << " (hot)"; if (food != NULL && g != NULL && food->spoils != 0 && int(g->turn) - (int)bday > food->spoils * 600) ret << " (rotten)"; if (owned > 0) ret << " (owned)"; return ret.str(); }
std::string item::info(bool showtext) { std::stringstream dump; if( !is_null() ) { dump << " Volume: " << volume() << " Weight: " << weight() << "\n" << " Bash: " << int(type->melee_dam) << (has_flag(IF_SPEAR) ? " Pierce: " : " Cut: ") << int(type->melee_cut) << " To-hit bonus: " << (type->m_to_hit > 0 ? "+" : "" ) << int(type->m_to_hit) << "\n" << " Moves per attack: " << attack_time() << "\n"; } if (is_food()) { it_comest* food = dynamic_cast<it_comest*>(type); dump << " Nutrition: " << int(food->nutr) << "\n Quench: " << int(food->quench) << "\n Enjoyability: " << int(food->fun); } else if (is_food_container()) { // added charge display for debugging it_comest* food = dynamic_cast<it_comest*>(contents[0].type); dump << " Nutrition: " << int(food->nutr) << "\n Quench: " << int(food->quench) << "\n Enjoyability: " << int(food->fun) << "\n Charges: " << int(contents[0].charges); } else if (is_ammo()) { // added charge display for debugging it_ammo* ammo = dynamic_cast<it_ammo*>(type); dump << " Type: " << ammo_name(ammo->type) << "\n Damage: " << int(ammo->damage) << "\n Armor-pierce: " << int(ammo->pierce) << "\n Range: " << int(ammo->range) << "\n Accuracy: " << int(100 - ammo->accuracy) << "\n Recoil: " << int(ammo->recoil) << "\n Count: " << int(ammo->count); } else if (is_ammo_container()) { it_ammo* ammo = dynamic_cast<it_ammo*>(contents[0].type); dump << " Type: " << ammo_name(ammo->type) << "\n Damage: " << int(ammo->damage) << "\n Armor-pierce: " << int(ammo->pierce) << "\n Range: " << int(ammo->range) << "\n Accuracy: " << int(100 - ammo->accuracy) << "\n Recoil: " << int(ammo->recoil) << "\n Count: " << int(contents[0].charges); } else if (is_gun()) { it_gun* gun = dynamic_cast<it_gun*>(type); int ammo_dam = 0, ammo_recoil = 0; bool has_ammo = (curammo != NULL && charges > 0); if (has_ammo) { ammo_dam = curammo->damage; ammo_recoil = curammo->recoil; } dump << " Skill used: " << skill_name(gun->skill_used) << "\n Ammunition: " << clip_size() << " rounds of " << ammo_name(ammo_type()); dump << "\n Damage: "; if (has_ammo) dump << ammo_dam; dump << (gun_damage(false) >= 0 ? "+" : "" ) << gun_damage(false); if (has_ammo) dump << " = " << gun_damage(); dump << "\n Accuracy: " << int(100 - accuracy()); dump << "\n Recoil: "; if (has_ammo) dump << ammo_recoil; dump << (recoil(false) >= 0 ? "+" : "" ) << recoil(false); if (has_ammo) dump << " = " << recoil(); dump << "\n Reload time: " << int(gun->reload_time); if (has_flag(IF_RELOAD_ONE)) dump << " per round"; if (burst_size() == 0) { if (gun->skill_used == sk_pistol && has_flag(IF_RELOAD_ONE)) dump << "\n Revolver."; else dump << "\n Semi-automatic."; } else dump << "\n Burst size: " << burst_size(); if (contents.size() > 0) dump << "\n"; for (int i = 0; i < contents.size(); i++) dump << "\n+" << contents[i].tname(); } else if (is_gunmod()) { it_gunmod* mod = dynamic_cast<it_gunmod*>(type); if (mod->accuracy != 0) dump << " Accuracy: " << (mod->accuracy > 0 ? "+" : "") << int(mod->accuracy); if (mod->damage != 0) dump << "\n Damage: " << (mod->damage > 0 ? "+" : "") << int(mod->damage); if (mod->clip != 0) dump << "\n Magazine: " << (mod->clip > 0 ? "+" : "") << int(mod->damage) << "%"; if (mod->recoil != 0) dump << "\n Recoil: " << int(mod->recoil); if (mod->burst != 0) dump << "\n Burst: " << (mod->clip > 0 ? "+" : "") << int(mod->clip); if (mod->newtype != AT_NULL) dump << "\n " << ammo_name(mod->newtype); dump << "\n Used on: "; if (mod->used_on_pistol) dump << "Pistols. "; if (mod->used_on_shotgun) dump << "Shotguns. "; if (mod->used_on_smg) dump << "SMGs. "; if (mod->used_on_rifle) dump << "Rifles."; } else if (is_armor()) { it_armor* armor = dynamic_cast<it_armor*>(type); dump << " Covers: "; if (armor->covers & mfb(bp_head)) dump << "The head. "; if (armor->covers & mfb(bp_eyes)) dump << "The eyes. "; if (armor->covers & mfb(bp_mouth)) dump << "The mouth. "; if (armor->covers & mfb(bp_torso)) dump << "The torso. "; if (armor->covers & mfb(bp_arms)) dump << "The arms. "; if (armor->covers & mfb(bp_hands)) dump << "The hands. "; if (armor->covers & mfb(bp_legs)) dump << "The legs. "; if (armor->covers & mfb(bp_feet)) dump << "The feet. "; dump << "\n Encumberment: " << int(armor->encumber) << "\n Bashing protection: " << int(armor->dmg_resist) << "\n Cut protection: " << int(armor->cut_resist) << "\n Environmental protection: " << int(armor->env_resist) << "\n Warmth: " << int(armor->warmth) << "\n Storage: " << int(armor->storage); } else if (is_book()) { it_book* book = dynamic_cast<it_book*>(type); if (book->type == sk_null) dump << " Just for fun.\n"; else { dump << " Can bring your " << skill_name(book->type) << " skill to " << int(book->level) << std::endl; if (book->req == 0) dump << " It can be understood by beginners.\n"; else dump << " Requires " << skill_name(book->type) << " level " << int(book->req) << " to understand.\n"; } dump << " Requires intelligence of " << int(book->intel) << " to easily read." << std::endl; if (book->fun != 0) dump << " Reading this book affects your morale by " << (book->fun > 0 ? "+" : "") << int(book->fun) << std::endl; dump << " This book takes " << int(book->time) << " minutes to read."; } else if (is_tool()) { it_tool* tool = dynamic_cast<it_tool*>(type); dump << " Maximum " << tool->max_charges << " charges"; if (tool->ammo == AT_NULL) dump << "."; else dump << " of " << ammo_name(tool->ammo) << "."; } else if (is_style()) { dump << "\n"; it_style* style = dynamic_cast<it_style*>(type); for (int i = 0; i < style->moves.size(); i++) { dump << default_technique_name(style->moves[i].tech) << ". Requires Unarmed Skill of " << style->moves[i].level << "\n"; } } else if (!is_null() && type->techniques != 0) { dump << "\n"; for (int i = 1; i < NUM_TECHNIQUES; i++) { if (type->techniques & mfb(i)) dump << default_technique_name( technique_id(i) ) << "; "; } } if ( showtext && !is_null() ) { dump << "\n\n" << type->description << "\n"; if (contents.size() > 0) { if (is_gun()) { for (int i = 0; i < contents.size(); i++) dump << "\n " << contents[i].type->description; } else dump << "\n " << contents[0].type->description; dump << "\n"; } } return dump.str(); }
// Return an object that an be used bool object_type::is_ale() { if (!is_food()) return (FALSE); if (sval == SV_FOOD_FINE_ALE) return (TRUE); return (FALSE); }
std::string item::info(bool showtext, std::vector<iteminfo> *dump) { std::stringstream temp1, temp2; if( !is_null() ) { dump->push_back(iteminfo("BASE", " Volume: ", "", int(volume()), "", false, true)); dump->push_back(iteminfo("BASE", " Weight: ", "", int(weight()), "", true, true)); dump->push_back(iteminfo("BASE", " Bash: ", "", int(type->melee_dam), "", false)); dump->push_back(iteminfo("BASE", (has_flag(IF_SPEAR) ? " Pierce: " : " Cut: "), "", int(type->melee_cut), "", false)); dump->push_back(iteminfo("BASE", " To-hit bonus: ", ((type->m_to_hit > 0) ? "+" : ""), int(type->m_to_hit), "")); dump->push_back(iteminfo("BASE", " Moves per attack: ", "", int(attack_time()), "", true, true)); if (type->techniques != 0) for (int i = 1; i < NUM_TECHNIQUES; i++) if (type->techniques & mfb(i)) dump->push_back(iteminfo("TECHNIQUE", " +",default_technique_name( technique_id(i) ))); } if (is_food()) { it_comest* food = dynamic_cast<it_comest*>(type); dump->push_back(iteminfo("FOOD", " Nutrition: ", "", int(food->nutr))); dump->push_back(iteminfo("FOOD", " Quench: ", "", int(food->quench))); dump->push_back(iteminfo("FOOD", " Enjoyability: ", "", int(food->fun))); } else if (is_food_container()) { // added charge display for debugging it_comest* food = dynamic_cast<it_comest*>(contents[0].type); dump->push_back(iteminfo("FOOD", " Nutrition: ", "", int(food->nutr))); dump->push_back(iteminfo("FOOD", " Quench: ", "", int(food->quench))); dump->push_back(iteminfo("FOOD", " Enjoyability: ", "", int(food->fun))); dump->push_back(iteminfo("FOOD", " Portions: ", "", abs(int(contents[0].charges)))); } else if (is_ammo()) { // added charge display for debugging it_ammo* ammo = dynamic_cast<it_ammo*>(type); dump->push_back(iteminfo("AMMO", " Type: ", ammo_name(ammo->type))); dump->push_back(iteminfo("AMMO", " Damage: ", "", int(ammo->damage))); dump->push_back(iteminfo("AMMO", " Armor-pierce: ", "", int(ammo->pierce))); dump->push_back(iteminfo("AMMO", " Range: ", "", int(ammo->range))); dump->push_back(iteminfo("AMMO", " Accuracy: ", "", int(100 - ammo->accuracy))); dump->push_back(iteminfo("AMMO", " Recoil: ", "", int(ammo->recoil), "", true, true)); dump->push_back(iteminfo("AMMO", " Count: ", "", int(ammo->count))); } else if (is_ammo_container()) { it_ammo* ammo = dynamic_cast<it_ammo*>(contents[0].type); dump->push_back(iteminfo("AMMO", " Type: ", ammo_name(ammo->type))); dump->push_back(iteminfo("AMMO", " Damage: ", "", int(ammo->damage))); dump->push_back(iteminfo("AMMO", " Armor-pierce: ", "", int(ammo->pierce))); dump->push_back(iteminfo("AMMO", " Range: ", "", int(ammo->range))); dump->push_back(iteminfo("AMMO", " Accuracy: ", "", int(100 - ammo->accuracy))); dump->push_back(iteminfo("AMMO", " Recoil: ", "", int(ammo->recoil), "", true, true)); dump->push_back(iteminfo("AMMO", " Count: ", "", int(contents[0].charges))); } else if (is_gun()) { it_gun* gun = dynamic_cast<it_gun*>(type); int ammo_dam = 0, ammo_recoil = 0; bool has_ammo = (curammo != NULL && charges > 0); if (has_ammo) { ammo_dam = curammo->damage; ammo_recoil = curammo->recoil; } dump->push_back(iteminfo("GUN", " Skill used: ", gun->skill_used->name())); dump->push_back(iteminfo("GUN", " Ammunition: ", "", int(clip_size()), " rounds of " + ammo_name(ammo_type()))); temp1.str(""); if (has_ammo) temp1 << ammo_dam; temp1 << (gun_damage(false) >= 0 ? "+" : "" ); temp2.str(""); if (has_ammo) temp2 << " = " << gun_damage(); dump->push_back(iteminfo("GUN", " Damage: ", temp1.str(), int(gun_damage(false)), temp2.str())); dump->push_back(iteminfo("GUN", " Accuracy: ", "", int(100 - accuracy()))); temp1.str(""); if (has_ammo) temp1 << ammo_recoil; temp1 << (recoil(false) >= 0 ? "+" : "" ); temp2.str(""); if (has_ammo) temp2 << " = " << recoil(); dump->push_back(iteminfo("GUN"," Recoil: ", temp1.str(), int(recoil(false)), temp2.str(), true, true)); dump->push_back(iteminfo("GUN", " Reload time: ", "", int(gun->reload_time), ((has_flag(IF_RELOAD_ONE)) ? " per round" : ""), true, true)); if (burst_size() == 0) { if (gun->skill_used == Skill::skill("pistol") && has_flag(IF_RELOAD_ONE)) dump->push_back(iteminfo("GUN", " Revolver.")); else dump->push_back(iteminfo("GUN", " Semi-automatic.")); } else dump->push_back(iteminfo("GUN", " Burst size: ", "", int(burst_size()))); if (contents.size() > 0) dump->push_back(iteminfo("GUN", "\n")); temp1.str(""); for (int i = 0; i < contents.size(); i++) temp1 << "\n+" << contents[i].tname(); dump->push_back(iteminfo("GUN", temp1.str())); } else if (is_gunmod()) { it_gunmod* mod = dynamic_cast<it_gunmod*>(type); if (mod->accuracy != 0) dump->push_back(iteminfo("GUNMOD", " Accuracy: ", ((mod->accuracy > 0) ? "+" : ""), int(mod->accuracy))); if (mod->damage != 0) dump->push_back(iteminfo("GUNMOD", " Damage: ", ((mod->damage > 0) ? "+" : ""), int(mod->damage))); if (mod->clip != 0) dump->push_back(iteminfo("GUNMOD", " Magazine: ", ((mod->clip > 0) ? "+" : ""), int(mod->clip), "%")); if (mod->recoil != 0) dump->push_back(iteminfo("GUNMOD", " Recoil: ", ((mod->recoil > 0) ? "+" : ""), int(mod->recoil), "", true, true)); if (mod->burst != 0) dump->push_back(iteminfo("GUNMOD", " Burst: ", (mod->burst > 0 ? "+" : ""), int(mod->burst))); if (mod->newtype != AT_NULL) dump->push_back(iteminfo("GUNMOD", " " + ammo_name(mod->newtype))); temp1.str(""); temp1 << " Used on: "; if (mod->used_on_pistol) temp1 << "Pistols. "; if (mod->used_on_shotgun) temp1 << "Shotguns. "; if (mod->used_on_smg) temp1 << "SMGs. "; if (mod->used_on_rifle) temp1 << "Rifles."; dump->push_back(iteminfo("GUNMOD", temp1.str())); } else if (is_armor()) { it_armor* armor = dynamic_cast<it_armor*>(type); temp1.str(""); temp1 << " Covers: "; if (armor->covers & mfb(bp_head)) temp1 << "The head. "; if (armor->covers & mfb(bp_eyes)) temp1 << "The eyes. "; if (armor->covers & mfb(bp_mouth)) temp1 << "The mouth. "; if (armor->covers & mfb(bp_torso)) temp1 << "The torso. "; if (armor->covers & mfb(bp_arms)) temp1 << "The arms. "; if (armor->covers & mfb(bp_hands)) temp1 << "The hands. "; if (armor->covers & mfb(bp_legs)) temp1 << "The legs. "; if (armor->covers & mfb(bp_feet)) temp1 << "The feet. "; dump->push_back(iteminfo("ARMOR", temp1.str())); if (has_flag(IF_FIT)) { dump->push_back(iteminfo("ARMOR", " Encumberment: ", "", int(armor->encumber) - 1, " (fits)", true, true)); } else { dump->push_back(iteminfo("ARMOR", " Encumberment: ", "", int(armor->encumber), "", true, true)); } dump->push_back(iteminfo("ARMOR", " Bashing protection: ", "", int(armor->dmg_resist))); dump->push_back(iteminfo("ARMOR", " Cut protection: ", "", int(armor->cut_resist))); dump->push_back(iteminfo("ARMOR", " Environmental protection: ", "", int(armor->env_resist))); dump->push_back(iteminfo("ARMOR", " Warmth: ", "", int(armor->warmth))); dump->push_back(iteminfo("ARMOR", " Storage: ", "", int(armor->storage))); } else if (is_book()) { it_book* book = dynamic_cast<it_book*>(type); if (!book->type) dump->push_back(iteminfo("BOOK", " Just for fun.")); else { dump->push_back(iteminfo("BOOK", " Can bring your ", book->type->name() + " skill to ", int(book->level))); if (book->req == 0) dump->push_back(iteminfo("BOOK", " It can be understood by beginners.")); else dump->push_back(iteminfo("BOOK", " Requires ", book->type->name() + " level ", int(book->req), " to understand.", true, true)); } dump->push_back(iteminfo("BOOK", " Requires intelligence of ", "", int(book->intel), " to easily read.", true, true)); if (book->fun != 0) dump->push_back(iteminfo("BOOK", " Reading this book affects your morale by ", (book->fun > 0 ? "+" : ""), int(book->fun))); dump->push_back(iteminfo("BOOK", " This book takes ", "", int(book->time), " minutes to read.", true, true)); } else if (is_tool()) { it_tool* tool = dynamic_cast<it_tool*>(type); if ((tool->max_charges)!=0) dump->push_back(iteminfo("TOOL", " Maximum ", "", int(tool->max_charges), " charges" + ((tool->ammo == AT_NULL) ? "" : (" of " + ammo_name(tool->ammo))) + ".")); } else if (is_style()) { it_style* style = dynamic_cast<it_style*>(type); for (int i = 0; i < style->moves.size(); i++) { dump->push_back(iteminfo("STYLE", default_technique_name(style->moves[i].tech), ". Requires Unarmed Skill of ", int(style->moves[i].level))); } } if ( showtext && !is_null() ) { dump->push_back(iteminfo("DESCRIPTION", type->description)); if (is_armor() && has_flag(IF_FIT)) { dump->push_back(iteminfo("DESCRIPTION", "\n\n")); dump->push_back(iteminfo("DESCRIPTION", "This piece of clothing fits you perfectly.")); } if (contents.size() > 0) { if (is_gun()) { for (int i = 0; i < contents.size(); i++) dump->push_back(iteminfo("DESCRIPTION", contents[i].type->description)); } else dump->push_back(iteminfo("DESCRIPTION", contents[0].type->description)); } } temp1.str(""); std::vector<iteminfo>& vecData = *dump; // vector is not copied here for (int i = 0; i < vecData.size(); i++) { if (vecData[i].sType == "DESCRIPTION") temp1 << "\n"; temp1 << vecData[i].sName; temp1 << vecData[i].sPre; if (vecData[i].iValue != -999) temp1 << vecData[i].iValue; temp1 << vecData[i].sPost; temp1 << ((vecData[i].bNewLine) ? "\n" : ""); } return temp1.str(); }
bool item::destroyed_at_zero_charges() { return (is_ammo() || is_food()); }