Пример #1
0
bool Character::can_pickVolume( int volume, bool safe ) const
{
    if( !safe ) {
        return volume_carried() + volume <= volume_capacity();
    } else {
        return volume_carried() + volume <= volume_capacity() - 2;
    }
}
Пример #2
0
void Character::drop_inventory_overflow() {
    if( volume_carried() > volume_capacity() ) {
        for( auto &item_to_drop :
               inv.remove_randomly_by_volume( volume_carried() - volume_capacity() ) ) {
            g->m.add_item_or_charges( pos(), item_to_drop );
        }
        add_msg_if_player( m_bad, _("Some items tumble to the ground.") );
    }
}
Пример #3
0
bool npc::wield(game *g, int index)
{
 if (index < 0 || index >= inv.size()) {
  debugmsg("npc::wield(%d) [inv.size() = %d]", index, inv.size());
  return false;
 }
 if (volume_carried() + weapon.volume() <= volume_capacity()) {
  i_add(remove_weapon());
  moves -= 15;
 } else // No room for weapon, so we drop it
  g->m.add_item(posx, posy, remove_weapon());
 moves -= 15;
 weapon = inv[index];
 i_remn(index);
 int linet;
 if (g->u_see(posx, posy, linet))
  g->add_msg("%s wields a %s.", name.c_str(), weapon.tname().c_str());
 return true;
}
Пример #4
0
void npc::make_shopkeep(game *g, oter_id type)
{
 randomize(g, NC_TRADER);
 itype_id item_type;
 item tmp;
 std::vector<items_location> pool;
 bool done = false;
 switch (type) {
 case ot_set_food:
  pool.push_back(mi_snacks);
  for (int i = 0; i < 4; i++)	// Weighted to be more likely
   pool.push_back(mi_cannedfood);
  pool.push_back(mi_pasta);
  pool.push_back(mi_produce);
  pool.push_back(mi_alcohol);
  break;
  break;
 case ot_set_weapons:
  pool.push_back(mi_weapons);
  break;
 case ot_set_guns:
  pool.push_back(mi_allguns);
  break;
 case ot_set_clinic:
  pool.push_back(mi_softdrugs);
  pool.push_back(mi_harddrugs);
  break;
 case ot_set_clothing:
  pool.push_back(mi_allclothes);
  break;
 case ot_set_general:
  pool.push_back(mi_cleaning);
  pool.push_back(mi_hardware);
  pool.push_back(mi_tools);
  pool.push_back(mi_bigtools);
  pool.push_back(mi_mischw);
  pool.push_back(mi_gunxtras);
  pool.push_back(mi_electronics);
  for (int i = 0; i < 4; i++)
   pool.push_back(mi_survival_tools);
  break;
 case ot_set_library:
  pool.push_back(mi_magazines);
  pool.push_back(mi_novels);
  pool.push_back(mi_novels);
  pool.push_back(mi_manuals);
  pool.push_back(mi_manuals);
  pool.push_back(mi_textbooks);
  break;
 case ot_set_bionics:
  pool.push_back(mi_electronics);
  pool.push_back(mi_bionics);
  break;
 }

 if (pool.size() > 0) {
  do {
   items_location place = pool[rng(0, pool.size() - 1)];
   item_type = g->mapitems[place][rng(0, g->mapitems[place].size() - 1)];
   tmp = item(g->itypes[item_type], g->turn);
   if (volume_carried() + tmp.volume() > volume_capacity() ||
       weight_carried() + tmp.weight() > weight_capacity()   )
    done = true;
   else
    inv.push_back(tmp);
  } while (!done);
 }
 mission = NPC_MISSION_SHOPKEEP;
 update_worst_item_value();
}
Пример #5
0
bool Character::can_pickVolume( int volume, bool ) const
{
   return volume_carried() + volume <= volume_capacity();
}