Skip to content

Commit

Permalink
Merge branch '0.D-branch'
Browse files Browse the repository at this point in the history
* 0.D-branch:
  Fixes the Missing Last Item
  faction camp: slightly easier hunting and trapping
  Fixes missing stat penalties from suffer()
  Code cleanup
  basecamps: fix NPC companions deleting seeds before farming
  Fix wielding from inventory
  • Loading branch information
kevingranade committed Feb 21, 2019
2 parents 8347881 + bc9d5c1 commit 1f473dc
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
8 changes: 8 additions & 0 deletions src/character.cpp
Expand Up @@ -1821,34 +1821,42 @@ int Character::get_healthy_mod() const
void Character::set_str_bonus( int nstr )
{
str_bonus = nstr;
str_cur = str_max + str_bonus;
}
void Character::set_dex_bonus( int ndex )
{
dex_bonus = ndex;
dex_cur = dex_max + dex_bonus;
}
void Character::set_per_bonus( int nper )
{
per_bonus = nper;
per_cur = per_max + per_bonus;
}
void Character::set_int_bonus( int nint )
{
int_bonus = nint;
int_cur = int_max + int_bonus;
}
void Character::mod_str_bonus( int nstr )
{
str_bonus += nstr;
str_cur = str_max + str_bonus;
}
void Character::mod_dex_bonus( int ndex )
{
dex_bonus += ndex;
dex_cur = dex_max + dex_bonus;
}
void Character::mod_per_bonus( int nper )
{
per_bonus += nper;
per_cur = per_max + per_bonus;
}
void Character::mod_int_bonus( int nint )
{
int_bonus += nint;
int_cur = int_max + int_bonus;
}

void Character::set_healthy( int nhealthy )
Expand Down
4 changes: 1 addition & 3 deletions src/crafting.cpp
Expand Up @@ -442,10 +442,8 @@ std::list<item> player::consume_some_components_for_craft( const recipe &making,
int cou = 0;
for( const auto &it : req.get_components() ) {
// Each component currently has 50% chance of not being consumed
int chc = 1;
int ran = rng( 0, chc );
// Skip first item so failed craft with one item recipe always loses component
if( cou > 0 && ran == chc ) {
if( cou > 0 && one_in( 2 ) ) {
std::list<item> tmp = consume_items( it, batch_size );
used.splice( used.end(), tmp );
}
Expand Down
4 changes: 2 additions & 2 deletions src/defense.cpp
Expand Up @@ -973,7 +973,7 @@ Press %s to buy everything in your cart, %s to buy nothing." ),
item_selected = 0;
offset = 0;
}
if( item_selected > offset + 22 ) {
if( item_selected > offset + 12 ) {
offset++;
}
draw_caravan_items( w, &( items[category_selected] ),
Expand Down Expand Up @@ -1003,7 +1003,7 @@ Press %s to buy everything in your cart, %s to buy nothing." ),
item_selected--;
} else {
item_selected = items[category_selected].size() - 1;
offset = item_selected - 22;
offset = item_selected - 12;
if( offset < 0 ) {
offset = 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/faction_camp.cpp
Expand Up @@ -1896,14 +1896,14 @@ bool basecamp::gathering_return( npc &p, const std::string &task, time_duration
favor = 1;
danger = 15;
skill_group = "trapping";
skill = comp->get_skill_level( skill_traps );
skill = 2 * comp->get_skill_level( skill_traps ) + comp->per_cur;
checks_per_cycle = 4;
} else if( task == "_faction_camp_hunting" ) {
task_description = _( "hunting for meat" );
danger = 10;
favor = 0;
skill_group = "hunting";
skill = comp->get_skill_level( skill_gun );
skill = 1.5 * comp->get_skill_level( skill_gun ) + comp->per_cur / 2;
threat = 12;
checks_per_cycle = 2;
}
Expand Down Expand Up @@ -1938,7 +1938,7 @@ bool basecamp::gathering_return( npc &p, const std::string &task, time_duration
}
}
if( task == "_faction_camp_trapping" || task == "_faction_camp_hunting" ) {
camp_hunting_results( skill, task, checks_per_cycle * mission_time / min_time, 25 );
camp_hunting_results( skill, task, checks_per_cycle * mission_time / min_time, 30 );
} else {
camp_search_results( skill, itemlist, checks_per_cycle * mission_time / min_time, 15 );
}
Expand Down
18 changes: 14 additions & 4 deletions src/game.cpp
Expand Up @@ -9948,10 +9948,20 @@ void game::wield( item_location &loc )
add_msg( m_info, "%s", ret.c_str() );
}

// Can't use loc.obtain() here because that would cause things to spill
u.mod_moves( -loc.obtain_cost( u ) );
u.wield( *loc.get_item() );
loc.remove_item();
// Can't use loc.obtain() here because that would cause things to spill.
// The item_location gets invalidated if wielding an item from the inventory due to updating of
// the cache, so we have to use u.i_rem() instead to avoid a debug message.
const item *target = loc.get_item();
item to_wield = *target;
bool from_inventory = loc.where() == item_location::type::character;
if( u.wield( to_wield ) ) {
u.mod_moves( -loc.obtain_cost( u ) );
if( from_inventory ) {
u.i_rem( target );
} else {
loc.remove_item();
}
}
}

void game::wield()
Expand Down

0 comments on commit 1f473dc

Please sign in to comment.