Skip to content

Commit

Permalink
Merge pull request cataclysmbnteam#11 from TGITS-Solutions/dev
Browse files Browse the repository at this point in the history
Merge dev to master
  • Loading branch information
TrainTurningPoint authored Jan 13, 2019
2 parents dc5629c + 8fe84da commit 1b6907e
Show file tree
Hide file tree
Showing 16 changed files with 612 additions and 673 deletions.
1 change: 1 addition & 0 deletions data/json/player_activities.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@
"id": "ACT_AIM",
"type": "activity_type",
"stop_phrase": "Stop aiming?",
"atomic": true,
"suspendable": false,
"based_on": "neither",
"no_resume": true
Expand Down
54 changes: 29 additions & 25 deletions data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -800,43 +800,47 @@
"type": "keybinding",
"id": "AIM",
"name": "Aim",
"bindings": [ { "input_method": "keyboard", "key": "." }, { "input_method": "keyboard", "key": "5" } ]
},
{
"type": "keybinding",
"id": "AIMED_SHOT",
"name": "Aimed Shot",
"bindings": [ { "input_method": "keyboard", "key": "a" } ]
},
{
"type": "keybinding",
"id": "CAREFUL_SHOT",
"name": "Careful Shot",
"bindings": [ { "input_method": "keyboard", "key": "c" } ]
"bindings": [
{ "input_method": "keyboard", "key": "S" },
{ "input_method": "keyboard", "key": "s" },
{ "input_method": "keyboard", "key": "." },
{ "input_method": "keyboard", "key": "5" }
]
},
{
"type": "keybinding",
"id": "PRECISE_SHOT",
"name": "Precise Shot",
"bindings": [ { "input_method": "keyboard", "key": "p" } ]
"id": "SWITCH_AMMO",
"name": "Switch ammo",
"bindings": [
{ "input_method": "keyboard", "key": "R" },
{ "input_method": "keyboard", "key": "r" }
]
},
{
"type": "keybinding",
"id": "SWITCH_AIM",
"name": "Switch Aiming Mode",
"bindings": [ { "input_method": "keyboard", "key": "m" } ]
"id": "SWITCH_MODE",
"name": "Switch firing mode",
"bindings": [
{ "input_method": "keyboard", "key": "C" },
{ "input_method": "keyboard", "key": "c" }
]
},
{
"type": "keybinding",
"id": "SWITCH_AMMO",
"name": "Switch ammo",
"bindings": [ { "input_method": "keyboard", "key": "o" } ]
"id": "SWITCH_TARGET_ORDER",
"name": "Switch target order",
"bindings": [
{ "input_method": "keyboard", "key": "O" },
{ "input_method": "keyboard", "key": "o" }
]
},
{
"type": "keybinding",
"id": "SWITCH_MODE",
"name": "Switch Firing Mode",
"bindings": [ { "input_method": "keyboard", "key": "s" } ]
"id": "TARGET_UI_HELP",
"name": "Show targeting UI help",
"bindings": [
{ "input_method": "keyboard", "key": "F1" }
]
},
{
"type": "keybinding",
Expand Down
1 change: 1 addition & 0 deletions doc/PLAYER_ACTIVITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Activities are long term actions, that can be interrupted and (optionally) conti
* stop_phrase: What to say when asking whether to cancel the activity or not. For example, in "You see the zombie approaching! Stop reading? (Y/N)", the stop_phrase is "Stop reading?".
* suspendable (true): If true, the activity can be continued without starting from scratch again. This is only possible if `can_resume_with()` returns true.
* rooted (false): If true, then during the activity, recoil is reduced, plant mutants sink their roots into the ground, etc.
* atomic (false): If true, queries to stop activity on distraction will be suppressed.
* based_on: Can be 'time', 'speed', or 'neither'.
* time: The amount that `player_activity::moves_left` is decremented by is independent from the character's speed.
* speed: `player_activity::moves_left` may be decremented faster or slower, depending on the character's speed.
Expand Down
1 change: 1 addition & 0 deletions lua/class_definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ classes = {
{ name = "no_resume", rval = "bool", args = { } },
{ name = "rooted", rval = "bool", args = { } },
{ name = "suspendable", rval = "bool", args = { } },
{ name = "atomic", rval = "bool", args = { } },
{ name = "stop_phrase", rval = "string", args = { } },
}
},
Expand Down
1 change: 1 addition & 0 deletions src/activity_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void activity_type::load( JsonObject &jo )
result.stop_phrase_ = _( jo.get_string( "stop_phrase" ).c_str() );
assign( jo, "suspendable", result.suspendable_, true );
assign( jo, "no_resume", result.no_resume_, true );
assign (jo, "atomic", result.atomic_, false );
assign( jo, "refuel_fires", result.refuel_fires, false );

result.based_on_ = io::string_to_enum_look_up( based_on_type_values, jo.get_string( "based_on" ) );
Expand Down
4 changes: 4 additions & 0 deletions src/activity_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class activity_type
bool suspendable_ = true;
based_on_type based_on_ = based_on_type::SPEED;
bool no_resume_ = false;
bool atomic_ = false;
bool refuel_fires = false;

public:
Expand All @@ -52,6 +53,9 @@ class activity_type
bool no_resume() const {
return no_resume_;
}
bool atomic() const {
return atomic_;
}
/**
* If true, player will refuel one adjacent fire if there is firewood spot adjacent.
*/
Expand Down
59 changes: 31 additions & 28 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,8 @@ bool cancel_auto_move( player &p, const std::string &text )

bool game::cancel_activity_or_ignore_query( const distraction_type type, const std::string &text )
{
if( cancel_auto_move( u, text ) || !u.activity || u.activity.is_distraction_ignored( type ) ) {
if( cancel_auto_move( u, text ) || !u.activity || u.activity.is_distraction_ignored( type )
|| u.activity.atomic()) {
return false;
}

Expand Down Expand Up @@ -2001,35 +2002,37 @@ std::list<std::string> game::get_npc_kill()

void game::handle_key_blocking_activity()
{
// If player is performing a task and a monster is dangerously close, warn them
// regardless of previous safemode warnings
if( u.activity && !u.has_activity( activity_id( "ACT_AIM" ) ) &&
u.activity.moves_left > 0 &&
!u.activity.is_distraction_ignored( distraction_type::hostile_spotted ) ) {
Creature *hostile_critter = is_hostile_very_close();
if( hostile_critter != nullptr ) {
if( cancel_activity_or_ignore_query( distraction_type::hostile_spotted,
string_format( _( "You see %s approaching!" ),
hostile_critter->disp_name().c_str() ) ) ) {
return;
if ( u.activity && u.activity.moves_left > 0) {
//never interrupt aiming, it's a quick activity
if ( !u.has_activity ( activity_id( "ACT_AIM" ))) {

// If player is performing a task and a monster is dangerously close, warn them
// regardless of previous safemode warnings
if( !u.activity.is_distraction_ignored( distraction_type::hostile_spotted ) ) {
Creature *hostile_critter = is_hostile_very_close();
if( hostile_critter != nullptr ) {
if( cancel_activity_or_ignore_query( distraction_type::hostile_spotted,
string_format( _( "You see %s approaching!" ),
hostile_critter->disp_name().c_str() ) ) ) {
return;
}
}
}
}
}

if( u.activity && u.activity.moves_left > 0 ) {
input_context ctxt = get_default_mode_input_context();
const std::string action = ctxt.handle_input( 0 );
if( action == "pause" ) {
cancel_activity_query( _( "Confirm:" ) );
} else if( action == "player_data" ) {
u.disp_info();
refresh_all();
} else if( action == "messages" ) {
Messages::display_messages();
refresh_all();
} else if( action == "help" ) {
get_help().display_help();
refresh_all();
input_context ctxt = get_default_mode_input_context();
const std::string action = ctxt.handle_input( 0 );
if( action == "pause" ) {
cancel_activity_query( _( "Confirm:" ) );
} else if( action == "player_data" ) {
u.disp_info();
refresh_all();
} else if( action == "messages" ) {
Messages::display_messages();
refresh_all();
} else if( action == "help" ) {
get_help().display_help();
refresh_all();
}
}
}
}
Expand Down
22 changes: 10 additions & 12 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1324,19 +1324,17 @@ std::string item::info( std::vector<iteminfo> &info, const iteminfo_query *parts
info.emplace_back( "GUN", _( "Base aim speed: " ), "<num>", iteminfo::no_flags,
g->u.aim_per_move( *mod, MAX_RECOIL ) );
for( const aim_type &type : g->u.get_aim_types( *mod ) ) {
// Nameless aim levels don't get an entry.
if( type.name.empty() ) {
continue;
if( !type.name.empty() ) {
info.emplace_back( "GUN", _( type.name.c_str() ) );
int max_dispersion = g->u.get_weapon_dispersion( *mod ).max();
int range = range_with_even_chance_of_good_hit( max_dispersion + type.threshold );
info.emplace_back( "GUN", _( "Even chance of good hit at range: " ),
_( "<num>" ), iteminfo::no_flags, range );
int aim_mv = g->u.gun_engagement_moves( *mod, type.threshold );
info.emplace_back( "GUN", _( "Time to reach aim level: " ), _( "<num> seconds" ),
iteminfo::is_decimal | iteminfo::lower_is_better,
TICKS_TO_SECONDS( aim_mv ) );
}
info.emplace_back( "GUN", _( type.name.c_str() ) );
int max_dispersion = g->u.get_weapon_dispersion( *mod ).max();
int range = range_with_even_chance_of_good_hit( max_dispersion + type.threshold );
info.emplace_back( "GUN", _( "Even chance of good hit at range: " ),
_( "<num>" ), iteminfo::no_flags, range );
int aim_mv = g->u.gun_engagement_moves( *mod, type.threshold );
info.emplace_back( "GUN", _( "Time to reach aim level: " ), _( "<num> seconds" ),
iteminfo::is_decimal | iteminfo::lower_is_better,
TICKS_TO_SECONDS( aim_mv ) );
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6635,12 +6635,21 @@ int iuse::radiocontrol( player *p, item *it, bool t, const tripoint & )
choice_str << choice;
signal += choice_str.str();

int bombCount = 0;
std::string bombName = "";
auto item_list = p->get_radio_items();
for( auto &elem : item_list ) {
if( ( elem )->has_flag( "BOMB" ) && ( elem )->has_flag( signal ) ) {
p->add_msg_if_player( m_warning,
_( "The %s in you inventory would explode on this signal. Place it down before sending the signal." ),
( elem )->display_name().c_str() );
bombCount++;
bombName = ( elem )->display_name().c_str();
}
}
if (bombCount == 1) {
if( !p->query_yn( _( "The %s in you inventory would explode. Are you sure you want to press the button?" ), bombName ) ) {
return 0;
}
} else if (bombCount > 1) {
if( !p->query_yn( _( "The %s and %d other item(s) in you inventory would explode. Are you sure you want to press the button?" ), bombName, --bombCount ) ) {
return 0;
}
}
Expand Down
41 changes: 27 additions & 14 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,25 +538,38 @@ std::pair<std::string, nc_color> hp_description( int cur_hp, int max_hp )

int monster::print_info( const catacurses::window &w, int vStart, int vLines, int column ) const
{
const int vEnd = vStart + vLines;
int width = getmaxx( w );
if (vLines > 1) {
const int vEnd = vStart + vLines;

mvwprintz( w, vStart, column, c_white, "%s ", name().c_str() );
mvwprintz( w, vStart, column, c_white, "%s ", name().c_str() );

const auto att = get_attitude();
wprintz( w, att.second, att.first );
const auto att = get_attitude();
wprintz( w, att.second, att.first );

std::string effects = get_effect_status();
long long used_space = att.first.length() + name().length() + 3;
trim_and_print( w, vStart++, used_space, getmaxx( w ) - used_space - 2,
h_white, effects );
std::string effects = get_effect_status();
int used_space = att.first.length() + name().length() + 3;
trim_and_print( w, vStart++, used_space, width - used_space - 2,
h_white, effects );

const auto hp_desc = hp_description( hp, type->hp );
mvwprintz( w, vStart++, column, hp_desc.second, hp_desc.first );
const auto hp_desc = hp_description( hp, type->hp );
mvwprintz( w, vStart++, column, hp_desc.second, hp_desc.first );

std::vector<std::string> lines = foldstring( type->get_description(), getmaxx( w ) - 1 - column );
int numlines = lines.size();
for( int i = 0; i < numlines && vStart <= vEnd; i++ ) {
mvwprintz( w, vStart++, column, c_white, lines[i] );
std::vector<std::string> lines = foldstring( type->get_description(), width - 1 - column );
int numlines = lines.size();
for( int i = 0; i < numlines && vStart <= vEnd; i++ ) {
mvwprintz( w, vStart++, column, c_white, lines[i] );
}
} else {
const auto att = get_attitude();
const auto hp_desc = get_hp_bar( hp, type->hp );

int padding = 14;
mvwprintz( w, vStart, width - padding, hp_desc.second, hp_desc.first );
padding += 2 + att.first.length();
mvwprintz( w, vStart, width - padding, att.second, att.first );
padding += 2;
trim_and_print( w, vStart, column, width - column - padding, c_white, "%s ", name().c_str() );
}

return vStart;
Expand Down
6 changes: 3 additions & 3 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ int npc::print_info( const catacurses::window &w, int line, int vLines, int colu
// because it's a border as well; so we have lines 6 through 11.
// w is also 48 characters wide - 2 characters for border = 46 characters for us
mvwprintz( w, line++, column, c_white, _( "NPC: %s" ), name.c_str() );
if( is_armed() ) {
if( line < last_line && is_armed() ) {
trim_and_print( w, line++, column, iWidth, c_red, _( "Wielding a %s" ), weapon.tname().c_str() );
}

Expand All @@ -1774,7 +1774,7 @@ int npc::print_info( const catacurses::window &w, int line, int vLines, int colu
const std::string worn_str = enumerate_as_string( worn.begin(), worn.end(), []( const item & it ) {
return it.tname();
} );
if( !worn_str.empty() ) {
if( line < last_line && !worn_str.empty() ) {
std::string wearing = _( "Wearing: " ) + remove_color_tags( worn_str );
enumerate_print( wearing, c_blue );
}
Expand All @@ -1783,7 +1783,7 @@ int npc::print_info( const catacurses::window &w, int line, int vLines, int colu
const int visibility_cap = g->u.get_per() - rl_dist( g->u.pos(), pos() );

const auto trait_str = visible_mutations( visibility_cap );
if( !trait_str.empty() ) {
if( line < last_line && !trait_str.empty() ) {
std::string mutations = _( "Traits: " ) + remove_color_tags( trait_str );
enumerate_print( mutations, c_green );
}
Expand Down
19 changes: 19 additions & 0 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,25 @@ std::vector<std::string> get_hotkeys( const std::string &s )
return hotkeys;
}

std::string highlight_hotkeys(input_context ctxt, std::string message, std::string action)
{
std::vector<char> keys = ctxt.keys_bound_to(action);
for( const char item : keys ) {
std::string::size_type index = message.find(item);
if(index != std::string::npos) {
message.insert(index + 1, "</color>");
message.insert(index, "<color_yellow>");
return message;
}
}
if (keys.size() > 0) {
message.append(" (<color_yellow>");
message.push_back(keys[0]);
message.append("</color>)");
}
return message;
}

long popup( const std::string &text, PopupFlags flags )
{
query_popup pop;
Expand Down
2 changes: 2 additions & 0 deletions src/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ inline bool query_int( int &result, const char *const msg, Args &&... args )

std::vector<std::string> get_hotkeys( const std::string &s );

std::string highlight_hotkeys(input_context ctxt, std::string message, std::string action);

/**
* @name Popup windows
*
Expand Down
5 changes: 5 additions & 0 deletions src/player_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ std::string player_activity::get_stop_phrase() const
return type->stop_phrase();
}

bool player_activity::atomic() const
{
return type->atomic();
}

int player_activity::get_value( size_t index, int def ) const
{
return ( index < values.size() ) ? values[index] : def;
Expand Down
3 changes: 3 additions & 0 deletions src/player_activity.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class player_activity
// e.g. "Stop doing something?", already translated.
std::string get_stop_phrase() const;

// Ignore distractions
bool atomic() const;

int get_value( size_t index, int def = 0 ) const;
std::string get_str_value( size_t index, const std::string &def = "" ) const;
/**
Expand Down
Loading

0 comments on commit 1b6907e

Please sign in to comment.