std::list<item> obtain_activity_items( player_activity &act, player &p ) { std::list<item> res; auto items = reorder_for_dropping( p, convert_to_indexes( act ) ); debug_drop_list( items ); while( !items.empty() && ( p.is_npc() || p.moves > 0 || items.front().consumed_moves == 0 ) ) { const auto &ait = items.front(); p.mod_moves( -ait.consumed_moves ); if( p.is_worn( *ait.it ) ) { p.takeoff( *ait.it, &res ); } else if( ait.it->count_by_charges() ) { res.push_back( p.reduce_charges( const_cast<item *>( ait.it ), ait.count ) ); } else { res.push_back( p.i_rem( ait.it ) ); } items.pop_front(); } // Avoid tumbling to the ground. Unload cleanly. const units::volume excessive_volume = p.volume_carried() - p.volume_capacity(); if( excessive_volume > 0_ml ) { const auto excess = p.inv.remove_randomly_by_volume( excessive_volume ); res.insert( res.begin(), excess.begin(), excess.end() ); } // Load anything that remains (if any) into the activity act.values.clear(); if( !items.empty() ) { for( const auto &drop : convert_to_indexes( p, items ) ) { act.values.push_back( drop.first ); act.values.push_back( drop.second ); } } // And cancel if its empty. If its not, we modified in place and we will continue // to resolve the drop next turn. This is different from the pickup logic which // creates a brand new activity every turn and cancels the old activity if( act.values.empty() ) { p.cancel_activity(); } return res; }
std::list<item> obtain_activity_items( player_activity &act, player &p ) { std::list<item> res; auto items = reorder_for_dropping( p, convert_to_indexes( act ) ); debug_drop_list( items ); while( !items.empty() && ( p.is_npc() || p.moves > 0 || items.front().consumed_moves == 0 ) ) { const auto &ait = items.front(); p.mod_moves( -ait.consumed_moves ); if( p.is_worn( *ait.it ) ) { p.takeoff( *ait.it, &res ); } else if( ait.it->count_by_charges() ) { res.push_back( p.reduce_charges( const_cast<item *>( ait.it ), ait.count ) ); } else { res.push_back( p.i_rem( ait.it ) ); } items.pop_front(); } // Avoid tumbling to the ground. Unload cleanly. const units::volume excessive_volume = p.volume_carried() - p.volume_capacity(); if( excessive_volume > 0 ) { const auto excess = p.inv.remove_randomly_by_volume( excessive_volume ); res.insert( res.begin(), excess.begin(), excess.end() ); } // Load anything that remains (if any) into the activity act.values.clear(); if( !items.empty() ) { for( const auto &drop : convert_to_indexes( p, items ) ) { act.values.push_back( drop.first ); act.values.push_back( drop.second ); } } // And either cancel if it's empty, or restart if it's not. if( act.values.empty() ) { p.cancel_activity(); } else { p.assign_activity( act ); } return res; }
void inventory_drop_selector::remove_dropping_items( player &dummy ) const { std::map<item *, int> dummy_dropping; for( const auto &elem : dropping ) { dummy_dropping[&dummy.i_at( u.get_item_position( elem.first ) )] = elem.second; } for( auto &elem : dummy_dropping ) { if( elem.first->count_by_charges() ) { elem.first->mod_charges( -elem.second ); } else { const int pos = dummy.get_item_position( elem.first ); for( int i = 0; i < elem.second; ++i ) { dummy.i_rem( pos ); } } } }
void mutation_effect(player &p, std::string mut) { bool is_u = (&p == &(g->u)); bool destroy = false; std::vector<body_part> bps; if (mut == "TOUGH" || mut == "TOUGH2" || mut == "TOUGH3" || mut == "GLASSJAW" || mut == "FLIMSY" || mut == "FLIMSY2" || mut == "FLIMSY3") { p.recalc_hp(); } else if (mut == "WEBBED" || mut == "PAWS" || mut == "ARM_TENTACLES" || mut == "ARM_TENTACLES_4" || mut == "ARM_TENTACLES_8") { // Push off gloves bps.push_back(bp_hands); } else if (mut == "TALONS") { // Destroy gloves destroy = true; bps.push_back(bp_hands); } else if (mut == "BEAK" || mut == "MANDIBLES") { // Destroy mouthwear destroy = true; bps.push_back(bp_mouth); } else if (mut == "MINOTAUR" || mut == "MUZZLE" || mut == "BEAR_MUZZLE" || mut == "LONG_MUZZLE") { // Push off mouthwear bps.push_back(bp_mouth); } else if (mut == "HOOVES" || mut == "RAP_TALONS") { // Destroy footwear destroy = true; bps.push_back(bp_feet); } else if (mut == "SHELL") { // Destroy torsowear destroy = true; bps.push_back(bp_torso); } else if (mut == "HORNS_CURLED" || mut == "CHITIN3") { // Push off all helmets bps.push_back(bp_head); } else if (mut == "HORNS_POINTED" || mut == "ANTENNAE" || mut == "ANTLERS") { // Push off non-cloth helmets bps.push_back(bp_head); } else if (mut == "LARGE" || mut == "LARGE_OK") { p.str_max += 2; p.recalc_hp(); } else if (mut == "HUGE") { p.str_max += 4; p.recalc_hp(); // Bad-Huge doesn't quite have the cardio/skeletal/etc to support the mass, // so no HP bonus from the ST above/beyond that from Large for (int i = 0; i < num_hp_parts; i++) { p.hp_max[i] -= 6; } // And there goes your clothing; by now you shouldn't need it anymore g->add_msg(_("You rip out of your clothing!")); destroy = true; bps.push_back(bp_torso); bps.push_back(bp_legs); bps.push_back(bp_arms); bps.push_back(bp_hands); bps.push_back(bp_head); bps.push_back(bp_feet); } else if (mut == "HUGE_OK") { p.str_max += 4; p.recalc_hp(); // Good-Huge still can't fit places but its heart's healthy enough for // going arond being Huge, so you get the HP } else if (mut == "STR_UP") { p.str_max ++; p.recalc_hp(); } else if (mut == "STR_UP_2") { p.str_max += 2; p.recalc_hp(); } else if (mut == "STR_UP_3") { p.str_max += 4; p.recalc_hp(); } else if (mut == "STR_UP_4") { p.str_max += 7; p.recalc_hp(); } else if (mut == "DEX_UP") { p.dex_max ++; } else if (mut == "DEX_UP_2") { p.dex_max += 2; } else if (mut == "DEX_UP_3") { p.dex_max += 4; } else if (mut == "DEX_UP_4") { p.dex_max += 7; } else if (mut == "INT_UP") { p.int_max ++; } else if (mut == "INT_UP_2") { p.int_max += 2; } else if (mut == "INT_UP_3") { p.int_max += 4; } else if (mut == "INT_UP_4") { p.int_max += 7; } else if (mut == "PER_UP") { p.per_max ++; } else if (mut == "PER_UP_2") { p.per_max += 2; } else if (mut == "PER_UP_3") { p.per_max += 4; } else if (mut == "PER_UP_4") { p.per_max += 7; } for (int i = 0; i < p.worn.size(); i++) { for (int j = 0; j < bps.size(); j++) { if ((dynamic_cast<it_armor*>(p.worn[i].type))->covers & mfb(bps[j])) { if (destroy) { if (is_u) { g->add_msg(_("Your %s is destroyed!"), p.worn[i].tname().c_str()); } p.worn.erase(p.worn.begin() + i); } else { if (is_u) { g->add_msg(_("Your %s is pushed off."), p.worn[i].tname().c_str()); } int pos = player::worn_position_to_index(i); g->m.add_item_or_charges(p.posx, p.posy, p.worn[i]); p.takeoff(pos, true); p.i_rem(pos); } // Reset to the start of the vector i = 0; } } } }
void move_item( player &p, int pos, inventory_location from, inventory_location to ) { switch( from ) { case GROUND: switch( to ) { case GROUND: default: FAIL( "unimplemented" ); break; case INVENTORY: pick_up_from_feet( p, pos ); break; case WORN: wear_from_feet( p, pos ); break; case WIELDED_OR_WORN: if( p.weapon.is_null() ) { wield_from_feet( p, pos ); } else { // since we can only wield one item, wear the item instead wear_from_feet( p, pos ); } break; } break; case INVENTORY: switch( to ) { case GROUND: drop_at_feet( p, pos ); break; case INVENTORY: default: FAIL( "unimplemented" ); break; case WORN: p.wear( pos, false ); break; case WIELDED_OR_WORN: if( p.weapon.is_null() ) { p.wield( p.i_at( pos ) ); } else { // since we can only wield one item, wear the item instead p.wear( pos, false ); } break; } break; case WORN: switch( to ) { case GROUND: drop_at_feet( p, -2 - pos ); break; case INVENTORY: p.takeoff( -2 - pos ); break; case WORN: case WIELDED_OR_WORN: default: FAIL( "unimplemented" ); break; } break; case WIELDED_OR_WORN: switch( to ) { case GROUND: drop_at_feet( p, -1 - pos ); if( pos == 0 && !p.worn.empty() ) { // wield the first worn item p.wield( p.i_at( -2 ) ); } break; case INVENTORY: if( pos == 0 ) { p.i_add( p.i_rem( -1 ) ); } else { p.takeoff( -1 - pos ); } if( pos == 0 && !p.worn.empty() ) { // wield the first worn item p.wield( p.i_at( -2 ) ); } break; case WORN: case WIELDED_OR_WORN: default: FAIL( "unimplemented" ); break; } break; default: FAIL( "unimplemented" ); break; } }
void mutation_effect(game *g, player &p, pl_flag mut) { bool is_u = (&p == &(g->u)); bool destroy = false; std::vector<body_part> bps; switch (mut) { case PF_TOUGH: case PF_GLASSJAW: case PF_HARDCORE: p.recalc_hp(); // Push off gloves case PF_WEBBED: case PF_ARM_TENTACLES: case PF_ARM_TENTACLES_4: case PF_ARM_TENTACLES_8: bps.push_back(bp_hands); break; // Destroy gloves case PF_TALONS: destroy = true; bps.push_back(bp_hands); break; // Destroy mouthwear case PF_BEAK: case PF_MANDIBLES: destroy = true; bps.push_back(bp_mouth); break; // Destroy footwear case PF_HOOVES: destroy = true; bps.push_back(bp_feet); break; // Destroy torsowear case PF_SHELL: destroy = true; bps.push_back(bp_torso); break; // Push off all helmets case PF_HORNS_CURLED: case PF_CHITIN3: bps.push_back(bp_head); break; // Push off non-cloth helmets case PF_HORNS_POINTED: case PF_ANTENNAE: case PF_ANTLERS: bps.push_back(bp_head); break; case PF_STR_UP: p.str_max ++; p.recalc_hp(); break; case PF_STR_UP_2: p.str_max += 2; p.recalc_hp(); break; case PF_STR_UP_3: p.str_max += 4; p.recalc_hp(); break; case PF_STR_UP_4: p.str_max += 7; p.recalc_hp(); break; case PF_DEX_UP: p.dex_max ++; break; case PF_DEX_UP_2: p.dex_max += 2; break; case PF_DEX_UP_3: p.dex_max += 4; break; case PF_DEX_UP_4: p.dex_max += 7; break; case PF_INT_UP: p.int_max ++; break; case PF_INT_UP_2: p.int_max += 2; break; case PF_INT_UP_3: p.int_max += 4; break; case PF_INT_UP_4: p.int_max += 7; break; case PF_PER_UP: p.per_max ++; break; case PF_PER_UP_2: p.per_max += 2; break; case PF_PER_UP_3: p.per_max += 4; break; case PF_PER_UP_4: p.per_max += 7; break; } for (int i = 0; i < p.worn.size(); i++) { for (int j = 0; j < bps.size(); j++) { if ((dynamic_cast<it_armor*>(p.worn[i].type))->covers & mfb(bps[j])) { if (destroy) { if (is_u) g->add_msg("Your %s is destroyed!", p.worn[i].tname().c_str()); p.worn.erase(p.worn.begin() + i); } else { if (is_u) g->add_msg("Your %s is pushed off.", p.worn[i].tname().c_str()); char tmp_invlet = p.worn[i].invlet; g->m.add_item(p.posx, p.posy, p.worn[i]); p.takeoff( g, p.worn[i].invlet, true ); p.i_rem( tmp_invlet ); } // Reset to the start of the vector i = 0; } } } }
void mutation_effect(player &p, std::string mut) { bool is_u = (&p == &(g->u)); bool destroy = false; std::vector<body_part> bps; if (mut == "TOUGH" || mut == "TOUGH2" || mut == "TOUGH3" || mut == "GLASSJAW" || mut == "FLIMSY" || mut == "FLIMSY2" || mut == "FLIMSY3") { p.recalc_hp(); } else if (mut == "WEBBED" || mut == "PAWS" || mut == "ARM_TENTACLES" || mut == "ARM_TENTACLES_4" || mut == "ARM_TENTACLES_8") { // Push off gloves bps.push_back(bp_hands); } else if (mut == "TALONS") { // Destroy gloves destroy = true; bps.push_back(bp_hands); } else if (mut == "BEAK" || mut == "MANDIBLES" || mut == "SABER_TEETH") { // Destroy mouthwear destroy = true; bps.push_back(bp_mouth); } else if (mut == "MINOTAUR" || mut == "MUZZLE" || mut == "MUZZLE_BEAR" || mut == "MUZZLE_LONG") { // Push off mouthwear bps.push_back(bp_mouth); } else if (mut == "HOOVES" || mut == "RAP_TALONS") { // Destroy footwear destroy = true; bps.push_back(bp_feet); } else if (mut == "SHELL") { // Destroy torsowear destroy = true; bps.push_back(bp_torso); } else if (mut == "HORNS_CURLED" || mut == "CHITIN3") { // Push off all helmets bps.push_back(bp_head); } else if (mut == "HORNS_POINTED" || mut == "ANTENNAE" || mut == "ANTLERS") { // Push off non-cloth helmets bps.push_back(bp_head); } else if (mut == "LARGE" || mut == "LARGE_OK") { p.str_max += 2; p.recalc_hp(); } else if (mut == "HUGE") { p.str_max += 4; p.recalc_hp(); // Bad-Huge doesn't quite have the cardio/skeletal/etc to support the mass, // so no HP bonus from the ST above/beyond that from Large for (int i = 0; i < num_hp_parts; i++) { p.hp_max[i] -= 6; } // And there goes your clothing; by now you shouldn't need it anymore g->add_msg(_("You rip out of your clothing!")); destroy = true; bps.push_back(bp_torso); bps.push_back(bp_legs); bps.push_back(bp_arms); bps.push_back(bp_hands); bps.push_back(bp_head); bps.push_back(bp_feet); } else if (mut == "HUGE_OK") { p.str_max += 4; p.recalc_hp(); // Good-Huge still can't fit places but its heart's healthy enough for // going around being Huge, so you get the HP } else if (mut == "STOCKY_TROGLO") { p.dex_max -= 2; p.str_max += 2; p.recalc_hp(); } else if (mut == "PRED3") { // Not so much "better at learning combat skills" // as "brain changes to focus on their development". // We are talking post-humanity here. p.int_max --; } else if (mut == "PRED4") { // Might be a bit harsh, but on the other claw // we are talking folks who really wanted to // transcend their humanity by this point. p.int_max -= 3; } else if (mut == "STR_UP") { p.str_max ++; p.recalc_hp(); } else if (mut == "STR_UP_2") { p.str_max += 2; p.recalc_hp(); } else if (mut == "STR_UP_3") { p.str_max += 4; p.recalc_hp(); } else if (mut == "STR_UP_4") { p.str_max += 7; p.recalc_hp(); } else if (mut == "STR_ALPHA") { if (p.str_max <= 7) { p.str_max = 11; } else { p.str_max = 15; } p.recalc_hp(); } else if (mut == "DEX_UP") { p.dex_max ++; } else if (mut == "DEX_UP_2") { p.dex_max += 2; } else if (mut == "DEX_UP_3") { p.dex_max += 4; } else if (mut == "DEX_UP_4") { p.dex_max += 7; } else if (mut == "DEX_ALPHA") { if (p.dex_max <= 7) { p.dex_max = 11; } else { p.dex_max = 15; } } else if (mut == "INT_UP") { p.int_max ++; } else if (mut == "INT_UP_2") { p.int_max += 2; } else if (mut == "INT_UP_3") { p.int_max += 4; } else if (mut == "INT_UP_4") { p.int_max += 7; } else if (mut == "INT_ALPHA") { if (p.int_max <= 7) { p.int_max = 11; } else { p.int_max = 15; } } else if (mut == "PER_UP") { p.per_max ++; } else if (mut == "PER_UP_2") { p.per_max += 2; } else if (mut == "PER_UP_3") { p.per_max += 4; } else if (mut == "PER_UP_4") { p.per_max += 7; } else if (mut == "PER_ALPHA") { if (p.per_max <= 7) { p.per_max = 11; } else { p.per_max = 15; } } std::string mutation_safe = "OVERSIZE"; for (int i = 0; i < p.worn.size(); i++) { for (int j = 0; j < bps.size(); j++) { if ( ((dynamic_cast<it_armor*>(p.worn[i].type))->covers & mfb(bps[j])) && (!(p.worn[i].has_flag(mutation_safe))) ) { if (destroy) { if (is_u) { g->add_msg(_("Your %s is destroyed!"), p.worn[i].tname().c_str()); } p.worn.erase(p.worn.begin() + i); } else { if (is_u) { g->add_msg(_("Your %s is pushed off."), p.worn[i].tname().c_str()); } int pos = player::worn_position_to_index(i); g->m.add_item_or_charges(p.posx, p.posy, p.worn[i]); p.i_rem(pos); } // Reset to the start of the vector i = 0; } } } }
void mutation_effect(game *g, player &p, std::string mut) { bool is_u = (&p == &(g->u)); bool destroy = false; std::vector<body_part> bps; if (mut == "TOUGH" || mut == "GLASSJAW" || mut == "HARDCORE") { p.recalc_hp(); } else if (mut == "WEBBED" || mut == "ARM_TENTACLES" || mut == "ARM_TENTACLES_4" || mut == "ARM_TENTACLES_8") { // Push off gloves bps.push_back(bp_hands); } else if (mut == "TALONS") { // Destroy gloves destroy = true; bps.push_back(bp_hands); } else if (mut == "BEAK" || mut == "MANDIBLES") { // Destroy mouthwear destroy = true; bps.push_back(bp_mouth); } else if (mut == "HOOVES") { // Destroy footwear destroy = true; bps.push_back(bp_feet); } else if (mut == "SHELL") { // Destroy torsowear destroy = true; bps.push_back(bp_torso); } else if (mut == "HORNS_CURLED" || mut == "CHITIN3") { // Push off all helmets bps.push_back(bp_head); } else if (mut == "HORNS_POINTED" || mut == "ANTENNAE" || mut == "ANTLERS") { // Push off non-cloth helmets bps.push_back(bp_head); } else if (mut == "STR_UP") { p.str_max ++; p.recalc_hp(); } else if (mut == "STR_UP_2") { p.str_max += 2; p.recalc_hp(); } else if (mut == "STR_UP_3") { p.str_max += 4; p.recalc_hp(); } else if (mut == "STR_UP_4") { p.str_max += 7; p.recalc_hp(); } else if (mut == "DEX_UP") { p.dex_max ++; } else if (mut == "DEX_UP_2") { p.dex_max += 2; } else if (mut == "DEX_UP_3") { p.dex_max += 4; } else if (mut == "DEX_UP_4") { p.dex_max += 7; } else if (mut == "INT_UP") { p.int_max ++; } else if (mut == "INT_UP_2") { p.int_max += 2; } else if (mut == "INT_UP_3") { p.int_max += 4; } else if (mut == "INT_UP_4") { p.int_max += 7; } else if (mut == "PER_UP") { p.per_max ++; } else if (mut == "PER_UP_2") { p.per_max += 2; } else if (mut == "PER_UP_3") { p.per_max += 4; } else if (mut == "PER_UP_4") { p.per_max += 7; } for (int i = 0; i < p.worn.size(); i++) { for (int j = 0; j < bps.size(); j++) { if ((dynamic_cast<it_armor*>(p.worn[i].type))->covers & mfb(bps[j])) { if (destroy) { if (is_u) { g->add_msg(_("Your %s is destroyed!"), p.worn[i].tname().c_str()); } p.worn.erase(p.worn.begin() + i); } else { if (is_u) { g->add_msg(_("Your %s is pushed off."), p.worn[i].tname().c_str()); } char tmp_invlet = p.worn[i].invlet; g->m.add_item(p.posx, p.posy, p.worn[i]); p.takeoff( g, p.worn[i].invlet, true ); p.i_rem( tmp_invlet ); } // Reset to the start of the vector i = 0; } } } }