From 1e08b4d2a10fc1cc6812eb0ff23ba576b4a78975 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Sun, 5 Jan 2020 16:19:22 +0300 Subject: [PATCH 1/6] Remove unused declarators --- src/game.cpp | 2 -- src/mapgen.cpp | 1 - src/mapgen_functions.cpp | 2 -- src/melee.cpp | 3 --- src/monattack.cpp | 1 - src/player.cpp | 4 ---- src/suffer.cpp | 1 - 7 files changed, 14 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index c3b8d2d7449ca..053aadc3a0c32 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -210,14 +210,12 @@ static const efftype_id effect_winded( "winded" ); static const bionic_id bio_remote( "bio_remote" ); -static const trait_id trait_GRAZER( "GRAZER" ); static const trait_id trait_ILLITERATE( "ILLITERATE" ); static const trait_id trait_INFIMMUNE( "INFIMMUNE" ); static const trait_id trait_INFRESIST( "INFRESIST" ); static const trait_id trait_LEG_TENT_BRACE( "LEG_TENT_BRACE" ); static const trait_id trait_M_IMMUNE( "M_IMMUNE" ); static const trait_id trait_PARKOUR( "PARKOUR" ); -static const trait_id trait_RUMINANT( "RUMINANT" ); static const trait_id trait_VINES2( "VINES2" ); static const trait_id trait_VINES3( "VINES3" ); diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 1a1879cc23c67..ce0bfcbf741d8 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -91,7 +91,6 @@ static const mongroup_id GROUP_TRIFFID_HEART( "GROUP_TRIFFID_HEART" ); static const mongroup_id GROUP_TRIFFID( "GROUP_TRIFFID" ); static const mongroup_id GROUP_TRIFFID_OUTER( "GROUP_TRIFFID_OUTER" ); static const mongroup_id GROUP_TURRET( "GROUP_TURRET" ); -static const mongroup_id GROUP_VANILLA( "GROUP_VANILLA" ); static const mongroup_id GROUP_ZOMBIE( "GROUP_ZOMBIE" ); static const mongroup_id GROUP_ZOMBIE_COP( "GROUP_ZOMBIE_COP" ); diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index d861fc1f44aeb..9288b2c4d94ed 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -48,8 +48,6 @@ static const mtype_id mon_bee( "mon_bee" ); static const mtype_id mon_beekeeper( "mon_beekeeper" ); static const mtype_id mon_rat_king( "mon_rat_king" ); static const mtype_id mon_sewer_rat( "mon_sewer_rat" ); -static const mtype_id mon_spider_widow_giant( "mon_spider_widow_giant" ); -static const mtype_id mon_spider_cellar_giant( "mon_spider_cellar_giant" ); static const mtype_id mon_zombie_jackson( "mon_zombie_jackson" ); tripoint rotate_point( const tripoint &p, int rotations ) diff --git a/src/melee.cpp b/src/melee.cpp index 596dfd06760f4..ac928389c7259 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -87,7 +87,6 @@ static const efftype_id effect_poison( "poison" ); static const efftype_id effect_stunned( "stunned" ); static const trait_id trait_CLAWS( "CLAWS" ); -static const trait_id trait_CLAWS_RAT( "CLAWS_RAT" ); static const trait_id trait_CLAWS_RETRACT( "CLAWS_RETRACT" ); static const trait_id trait_CLAWS_ST( "CLAWS_ST" ); static const trait_id trait_CLAWS_TENTACLE( "CLAWS_TENTACLE" ); @@ -100,8 +99,6 @@ static const trait_id trait_NAILS( "NAILS" ); static const trait_id trait_POISONOUS2( "POISONOUS2" ); static const trait_id trait_POISONOUS( "POISONOUS" ); static const trait_id trait_PROF_SKATER( "PROF_SKATER" ); -static const trait_id trait_SLIME_HANDS( "SLIME_HANDS" ); -static const trait_id trait_TALONS( "TALONS" ); static const trait_id trait_THORNS( "THORNS" ); static const efftype_id effect_amigara( "amigara" ); diff --git a/src/monattack.cpp b/src/monattack.cpp index d4e182667ef3f..3fdedfa3b7294 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -96,7 +96,6 @@ static const mtype_id mon_manhack( "mon_manhack" ); static const mtype_id mon_shadow( "mon_shadow" ); static const mtype_id mon_leech_stalk( "mon_leech_stalk" ); static const mtype_id mon_leech_blossom( "mon_leech_blossom" ); -static const mtype_id mon_leech_pod_cluster( "mon_leech_pod_cluster" ); static const mtype_id mon_leech_root_runner( "mon_leech_root_runner" ); static const mtype_id mon_leech_root_drone( "mon_leech_root_drone" ); static const mtype_id mon_hound_tindalos_afterimage( "mon_hound_tindalos_afterimage" ); diff --git a/src/player.cpp b/src/player.cpp index cc0d4ccc26468..69f05974c072e 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -147,7 +147,6 @@ static const efftype_id effect_sleep( "sleep" ); static const efftype_id effect_stunned( "stunned" ); static const efftype_id effect_tapeworm( "tapeworm" ); static const efftype_id effect_weed_high( "weed_high" ); -static const efftype_id effect_winded( "winded" ); static const efftype_id effect_magnesium_supplements( "magnesium" ); static const bionic_id bio_armor_arms( "bio_armor_arms" ); @@ -195,7 +194,6 @@ static const trait_id trait_DEBUG_CLOAK( "DEBUG_CLOAK" ); static const trait_id trait_DEBUG_HS( "DEBUG_HS" ); static const trait_id trait_DEBUG_LS( "DEBUG_LS" ); static const trait_id trait_DEBUG_NODMG( "DEBUG_NODMG" ); -static const trait_id trait_DISIMMUNE( "DISIMMUNE" ); static const trait_id trait_DISRESISTANT( "DISRESISTANT" ); static const trait_id trait_EASYSLEEPER( "EASYSLEEPER" ); static const trait_id trait_EASYSLEEPER2( "EASYSLEEPER2" ); @@ -261,7 +259,6 @@ static const trait_id trait_SAVANT( "SAVANT" ); static const trait_id trait_SEESLEEP( "SEESLEEP" ); static const trait_id trait_SELFAWARE( "SELFAWARE" ); static const trait_id trait_SHELL2( "SHELL2" ); -static const trait_id trait_SLEEK_SCALES( "SLEEK_SCALES" ); static const trait_id trait_SLIMESPAWNER( "SLIMESPAWNER" ); static const trait_id trait_SLIMY( "SLIMY" ); static const trait_id trait_SLOWLEARNER( "SLOWLEARNER" ); @@ -271,7 +268,6 @@ static const trait_id trait_SPIRITUAL( "SPIRITUAL" ); static const trait_id trait_SQUEAMISH( "SQUEAMISH" ); static const trait_id trait_STRONGSTOMACH( "STRONGSTOMACH" ); static const trait_id trait_SUNLIGHT_DEPENDENT( "SUNLIGHT_DEPENDENT" ); -static const trait_id trait_TAIL_FIN( "TAIL_FIN" ); static const trait_id trait_THORNS( "THORNS" ); static const trait_id trait_THRESH_SPIDER( "THRESH_SPIDER" ); static const trait_id trait_TOUGH_FEET( "TOUGH_FEET" ); diff --git a/src/suffer.cpp b/src/suffer.cpp index b85a31b8bdb81..3b771e81ae0f9 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -74,7 +74,6 @@ static const efftype_id effect_formication( "formication" ); static const efftype_id effect_glowy_led( "glowy_led" ); static const efftype_id effect_hallu( "hallu" ); static const efftype_id effect_iodine( "iodine" ); -static const efftype_id effect_lying_down( "lying_down" ); static const efftype_id effect_mending( "mending" ); static const efftype_id effect_narcosis( "narcosis" ); static const efftype_id effect_nausea( "nausea" ); From 8925fea9506e487f13ef8b5c84e1c0831b506da4 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Sun, 5 Jan 2020 16:20:32 +0300 Subject: [PATCH 2/6] Remove excessive incements --- src/cata_tiles.cpp | 2 +- src/main_menu.cpp | 2 +- src/npctalk_funcs.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 9562a0d95d826..98d1a6add8c17 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -3124,7 +3124,7 @@ void cata_tiles::draw_explosion_frame() draw_from_id_string( exp_name, exp_pos + point( i, i ), subtile, rotation++, LL_LIT, nv_goggles_activated ); draw_from_id_string( exp_name, exp_pos + point( i, -i ), - subtile, rotation++, LL_LIT, nv_goggles_activated ); + subtile, rotation, LL_LIT, nv_goggles_activated ); subtile = edge; for( int j = 1 - i; j < 0 + i; j++ ) { diff --git a/src/main_menu.cpp b/src/main_menu.cpp index f398b07f228bd..3b82ff511309f 100644 --- a/src/main_menu.cpp +++ b/src/main_menu.cpp @@ -199,7 +199,7 @@ void main_menu::print_menu( const catacurses::window &w_open, int iSel, const po } iLine++; - center_print( w_open, iLine++, cColor3, string_format( _( "Version: %s" ), getVersionString() ) ); + center_print( w_open, iLine, cColor3, string_format( _( "Version: %s" ), getVersionString() ) ); int menu_length = 0; for( size_t i = 0; i < vMenuItems.size(); ++i ) { diff --git a/src/npctalk_funcs.cpp b/src/npctalk_funcs.cpp index a4a48b01995d6..e425b69d661eb 100644 --- a/src/npctalk_funcs.cpp +++ b/src/npctalk_funcs.cpp @@ -293,7 +293,7 @@ void talk_function::goto_location( npc &p ) iter->camp_name(), iter->camp_omt_pos().x, iter->camp_omt_pos().y ); } selection_menu.addentry( i++, true, MENU_AUTOASSIGN, _( "My current location" ) ); - selection_menu.addentry( i++, true, MENU_AUTOASSIGN, _( "Cancel" ) ); + selection_menu.addentry( i, true, MENU_AUTOASSIGN, _( "Cancel" ) ); selection_menu.selected = 0; selection_menu.query(); auto index = selection_menu.ret; From f1490fcdedaab154ee868b16f26d5eeee4e507ca Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Sun, 5 Jan 2020 16:21:10 +0300 Subject: [PATCH 3/6] Remove excessive empty lines --- src/character.cpp | 2 -- src/game.cpp | 1 - src/item_category.cpp | 1 - src/monmove.cpp | 1 - src/mutation_data.cpp | 1 - 5 files changed, 6 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index fc3cad28d7feb..1f9d310d921f7 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -4123,8 +4123,6 @@ hp_part Character::body_window( const std::string &menu_header, max_bp_name_len = std::max( max_bp_name_len, utf8_width( e.name ) ); } - - uilist bmenu; bmenu.desc_enabled = true; bmenu.text = menu_header; diff --git a/src/game.cpp b/src/game.cpp index 053aadc3a0c32..75344c505db1d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4142,7 +4142,6 @@ void game::mon_info_update( ) mostseen = newseen; } - void game::cleanup_dead() { // Dead monsters need to stay in the tracker until everything else that needs to die does so diff --git a/src/item_category.cpp b/src/item_category.cpp index 59dd5f5d07cab..3cc830eadc9e2 100644 --- a/src/item_category.cpp +++ b/src/item_category.cpp @@ -32,7 +32,6 @@ void zone_priority_data::load( JsonObject &jo ) optional( jo, was_loaded, "filthy", filthy, false ); } - void item_category::load_item_cat( const JsonObject &jo, const std::string &src ) { item_category_factory.load( jo, src ); diff --git a/src/monmove.cpp b/src/monmove.cpp index 2f0fd5d52f0e5..673b882e22900 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -1112,7 +1112,6 @@ tripoint monster::scent_move() right_scent = false; } - if( ( !fleeing && smell < bestsmell ) || ( fleeing && smell > bestsmell ) || !right_scent ) { continue; } diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index a0426b2cba72b..de2a59c3da335 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -382,7 +382,6 @@ void mutation_branch::load( const JsonObject &jo, const std::string & ) rand_bash_bonus.second = sm.get_int( "max" ); } - if( jo.has_object( "social_modifiers" ) ) { JsonObject sm = jo.get_object( "social_modifiers" ); social_mods = load_mutation_social_mods( sm ); From 1cabb58163109c7a2af655c1d136b37a3837ee20 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Sun, 5 Jan 2020 16:27:03 +0300 Subject: [PATCH 4/6] Normalized TODO/HACK/FIXME comments --- src/auto_pickup.cpp | 2 +- src/calendar.cpp | 2 +- src/character.cpp | 2 +- src/clzones.cpp | 2 +- src/flat_set.h | 6 +++--- src/game.cpp | 6 +++--- src/itype.h | 2 +- src/iuse_actor.cpp | 4 ++-- src/magic.cpp | 2 +- src/map.cpp | 4 ++-- src/map_extras.cpp | 2 +- src/mapgendata.h | 6 +++--- src/mapsharing.cpp | 2 +- src/monster.cpp | 2 +- src/npc.cpp | 4 ++-- src/npcmove.cpp | 2 +- src/npctalk_funcs.cpp | 2 +- src/overmap.cpp | 6 +++--- src/player.cpp | 4 ++-- src/ranged.cpp | 2 +- src/savegame.cpp | 2 +- src/text_snippets.h | 2 +- src/translations.cpp | 4 ++-- src/vehicle.cpp | 10 +++++----- src/vehicle_use.cpp | 2 +- src/weather_data.cpp | 2 +- 26 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index 94fd78e676704..08600ec6c96cd 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -576,7 +576,7 @@ void rule_list::create_rule( cache &map_items, const std::string &to_match ) void player_settings::create_rule( const item *it ) { - // @todo change it to be a reference + // @TODO: change it to be a reference global_rules.create_rule( map_items, *it ); character_rules.create_rule( map_items, *it ); } diff --git a/src/calendar.cpp b/src/calendar.cpp index 0068fa18b93dd..e59952c8bec06 100644 --- a/src/calendar.cpp +++ b/src/calendar.cpp @@ -118,7 +118,7 @@ time_point night_time( const time_point &p ) time_point daylight_time( const time_point &p ) { - // @TODO Actual dailight should start 18 degrees before sunrise + // @TODO: Actual dailight should start 18 degrees before sunrise return sunrise( p ) + 15_minutes; } diff --git a/src/character.cpp b/src/character.cpp index 1f9d310d921f7..98ceaf846869c 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -3829,7 +3829,7 @@ void Character::update_bodytemp() // Morale bonus for comfiness - only if actually comfy (not too warm/cold) // Spread the morale bonus in time. if( comfortable_warmth > 0 && - // @todo make this simpler and use time_duration/time_point + // @TODO: make this simpler and use time_duration/time_point to_turn( calendar::turn ) % to_turns( 1_minutes ) == to_turns ( 1_minutes * bp ) / to_turns( 1_minutes * num_bp ) && get_effect_int( effect_cold, num_bp ) == 0 && diff --git a/src/clzones.cpp b/src/clzones.cpp index 8c1779da24afe..354738390a6de 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -561,7 +561,7 @@ void zone_manager::cache_vzones() const std::string &type_hash = elem->get_type_hash(); auto &cache = area_cache[type_hash]; - // @todo looks very similar to the above cache_data - maybe merge it? + // @TODO: looks very similar to the above cache_data - maybe merge it? // Draw marked area for( const tripoint &p : tripoint_range( elem->get_start_point(), elem->get_end_point() ) ) { diff --git a/src/flat_set.h b/src/flat_set.h index 0d3c831f32a5e..0f7b47cd491a0 100644 --- a/src/flat_set.h +++ b/src/flat_set.h @@ -147,11 +147,11 @@ class flat_set : private Compare, Data } iterator insert( iterator, const value_type &value ) { - /// @todo Use insertion hint + /// @TODO: Use insertion hint return insert( value ).first; } iterator insert( iterator, value_type &&value ) { - /// @todo Use insertion hint + /// @TODO: Use insertion hint return insert( std::move( value ) ).first; } std::pair insert( const value_type &value ) { @@ -171,7 +171,7 @@ class flat_set : private Compare, Data template void insert( InputIt first, InputIt last ) { - /// @todo could be faster when inserting only a few elements + /// @TODO: could be faster when inserting only a few elements Data::insert( end(), first, last ); sort_data(); } diff --git a/src/game.cpp b/src/game.cpp index 75344c505db1d..93361bff9b1cb 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3975,7 +3975,7 @@ void game::mon_info_update( ) new_seen_mon.clear(); static int previous_turn = 0; - // @todo change current_turn to time_point + // @TODO: change current_turn to time_point const int current_turn = to_turns( calendar::turn - calendar::turn_zero ); const int sm_ignored_turns = get_option( "SAFEMODEIGNORETURNS" ); @@ -4722,7 +4722,7 @@ monster *game::place_critter_at( const shared_ptr_fast mon, const tripo monster *game::place_critter_around( const mtype_id &id, const tripoint ¢er, const int radius ) { - // @todo change this into an assert, it must never happen. + // @TODO: change this into an assert, it must never happen. if( id.is_null() ) { return nullptr; } @@ -4753,7 +4753,7 @@ monster *game::place_critter_around( const shared_ptr_fast mon, monster *game::place_critter_within( const mtype_id &id, const tripoint_range &range ) { - // @todo change this into an assert, it must never happen. + // @TODO: change this into an assert, it must never happen. if( id.is_null() ) { return nullptr; } diff --git a/src/itype.h b/src/itype.h index 52848aeffdcd2..69bca7de28515 100644 --- a/src/itype.h +++ b/src/itype.h @@ -833,7 +833,7 @@ struct itype { bool stackable_ = false; /** Minimum and maximum amount of damage to an item (state of maximum repair). */ - // @todo create and use a MinMax class or similar to put both values into one object. + // @TODO: create and use a MinMax class or similar to put both values into one object. /// @{ int damage_min_ = -1000; int damage_max_ = +4000; diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 2827692c9b4e1..c61a3b34709af 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -4648,8 +4648,8 @@ int sew_advanced_actor::use( player &p, item &it, bool, const tripoint & ) const bool enab = false; std::string prompt; if( mod.item_tags.count( obj.flag ) == 0 ) { - // @TODO Fix for UTF-8 strings - // @TODO find other places where this is used and make a global function for all + // @TODO: Fix for UTF-8 strings + // @TODO: find other places where this is used and make a global function for all static const auto tolower = []( std::string t ) { if( !t.empty() ) { t.front() = std::tolower( t.front() ); diff --git a/src/magic.cpp b/src/magic.cpp index ad0641717a34c..0ad585519c369 100644 --- a/src/magic.cpp +++ b/src/magic.cpp @@ -1018,7 +1018,7 @@ std::string spell::enumerate_targets() const return all_valid_targets[0]; } std::string ret; - // @todo if only we had a function to enumerate strings and concatenate them... + // @TODO: if only we had a function to enumerate strings and concatenate them... for( auto iter = all_valid_targets.begin(); iter != all_valid_targets.end(); iter++ ) { if( iter + 1 == all_valid_targets.end() ) { ret = string_format( _( "%s and %s" ), ret, *iter ); diff --git a/src/map.cpp b/src/map.cpp index 3ac2ebf3829c7..ce14c70389466 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -7093,7 +7093,7 @@ void map::spawn_monsters_submap_group( const tripoint &gp, mongroup &group, bool } static const auto allow_on_terrain = [&]( const tripoint & p ) { - // @todo flying creatures should be allowed to spawn without a floor, + // @TODO: flying creatures should be allowed to spawn without a floor, // but the new creature is created *after* determining the terrain, so // we can't check for it here. return passable( p ) && has_floor( p ); @@ -8125,7 +8125,7 @@ tripoint_range map::points_in_radius( const tripoint ¢er, size_t radius, siz tripoint_range map::points_on_zlevel( const int z ) const { if( z < -OVERMAP_DEPTH || z > OVERMAP_HEIGHT ) { - // @todo need a default constructor that creates an empty range. + // @TODO: need a default constructor that creates an empty range. return tripoint_range( tripoint_zero, tripoint_zero - tripoint_above ); } return tripoint_range( tripoint( 0, 0, z ), tripoint( SEEX * my_MAPSIZE - 1, SEEY * my_MAPSIZE - 1, diff --git a/src/map_extras.cpp b/src/map_extras.cpp index e4a7ce5854eeb..42edc720e6b85 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -926,7 +926,7 @@ static void mx_portal( map &m, const tripoint &abs_sub ) // Get a random location from our points that is not the portal location, does not have the // NO_FLOOR flag, and isn't currently occupied by a creature. const cata::optional mon_pos = random_point( points, [&]( const tripoint & p ) { - /// @todo wrong: this checks for creatures on the main game map. Not within the map m. + /// @TODO: wrong: this checks for creatures on the main game map. Not within the map m. return !m.has_flag_ter( TFLAG_NO_FLOOR, p ) && *portal_pos != p && !g->critter_at( p ); } ); diff --git a/src/mapgendata.h b/src/mapgendata.h index ebad9f4b8e514..0616dac01332b 100644 --- a/src/mapgendata.h +++ b/src/mapgendata.h @@ -28,8 +28,8 @@ enum class type : int; * An instance of this class is passed through most of the mapgen code. * If any of these functions need more information, add them here. */ -// @todo documentation -// @todo encapsulate data member +// @TODO: documentation +// @TODO: encapsulate data member class mapgendata { private: @@ -94,7 +94,7 @@ class mapgendata return mission_; } int zlevel() const { - // @todo should be able to determine this from the map itself + // @TODO: should be able to determine this from the map itself return zlevel_; } diff --git a/src/mapsharing.cpp b/src/mapsharing.cpp index 17e5ed14e4f87..473e5ca1b3ae4 100644 --- a/src/mapsharing.cpp +++ b/src/mapsharing.cpp @@ -113,7 +113,7 @@ void ofstream_wrapper::open( const std::ios::openmode mode ) temp_path = path + "." + std::to_string( GetCurrentProcessId() ) + ".temp"; #else - // @todo exclusive I/O for other systems + // @TODO: exclusive I/O for other systems temp_path = path + ".temp"; #endif diff --git a/src/monster.cpp b/src/monster.cpp index c8b3924a904dc..43ca8ab8ddd0e 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -363,7 +363,7 @@ void monster::try_upgrade( bool pin_time ) upgrade_time += current_day; } else { // offset by starting season - // @todo revisit this and make it simpler + // @TODO: revisit this and make it simpler upgrade_time += to_days( calendar::start_of_cataclysm - calendar::turn_zero ); } } diff --git a/src/npc.cpp b/src/npc.cpp index 97388f25faf9a..28ee25a717be2 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -1166,8 +1166,8 @@ bool npc::wield( item &it ) assert( !maybe_holster.contents.empty() ); const size_t old_size = maybe_holster.contents.size(); invoke_item( &maybe_holster ); - // @TODO change invoke_item to somehow report this change - // Hacky: test whether wielding the item from the holster has been done. + // @TODO: change invoke_item to somehow report this change + // @HACK: test whether wielding the item from the holster has been done. // (Wielding may be prevented by various reasons: see player::wield_contained) if( old_size != maybe_holster.contents.size() ) { return true; diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 80b52f8e5b41f..33e1bda363c0d 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -235,7 +235,7 @@ tripoint npc::good_escape_direction( bool include_pos ) float rating = threat_val; for( const auto &e : g->m.field_at( pt ) ) { if( is_dangerous_field( e.second ) ) { - // @todo: Rate fire higher than smoke + // @TODO: Rate fire higher than smoke rating += e.second.get_field_intensity(); } } diff --git a/src/npctalk_funcs.cpp b/src/npctalk_funcs.cpp index e425b69d661eb..b9f3bed282182 100644 --- a/src/npctalk_funcs.cpp +++ b/src/npctalk_funcs.cpp @@ -181,7 +181,7 @@ void spawn_animal( npc &p, const mtype_id &mon ) mon_ptr->friendly = -1; mon_ptr->add_effect( effect_pet, 1_turns, num_bp, true ); } else { - // @todo handle this gracefully (return the money, proper in-character message from npc) + // @TODO: handle this gracefully (return the money, proper in-character message from npc) add_msg( m_debug, "No space to spawn purchased pet" ); } } diff --git a/src/overmap.cpp b/src/overmap.cpp index 4632092bcf53b..7190820786637 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -1146,7 +1146,7 @@ void overmap::init_layers() void overmap::ter_set( const tripoint &p, const oter_id &id ) { if( !inbounds( p ) ) { - /// @todo Add a debug message reporting this, but currently there are way too many place that would trigger it. + /// @TODO: Add a debug message reporting this, but currently there are way too many place that would trigger it. return; } @@ -1156,7 +1156,7 @@ void overmap::ter_set( const tripoint &p, const oter_id &id ) const oter_id &overmap::ter( const tripoint &p ) const { if( !inbounds( p ) ) { - /// @todo Add a debug message reporting this, but currently there are way too many place that would trigger it. + /// @TODO: Add a debug message reporting this, but currently there are way too many place that would trigger it. return ot_null; } @@ -3568,7 +3568,7 @@ void overmap::chip_rock( const tripoint &p ) bool overmap::check_ot( const std::string &otype, ot_match_type match_type, const tripoint &p ) const { - /// @todo this check should be done by the caller. Probably. + /// @TODO: this check should be done by the caller. Probably. if( !inbounds( p ) ) { return false; } diff --git a/src/player.cpp b/src/player.cpp index 69f05974c072e..ee6a91057b512 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2206,7 +2206,7 @@ void player::update_body( const time_point &from, const time_point &to ) update_needs( five_mins ); regen( five_mins ); // Note: mend ticks once per 5 minutes, but wants rate in TURNS, not 5 minute intervals - //@todo change @ref med to take time_duration + //@TODO: change @ref med to take time_duration mend( five_mins * to_turns( 5_minutes ) ); } if( ticks_between( from, to, 24_hours ) > 0 ) { @@ -6909,7 +6909,7 @@ void player::place_corpse( const tripoint &om_target ) // Q: Why check for furniture? (Check for passable or can-place-items seems more useful.) // Q: Why not grep a random point out of all the possible points (e.g. via random_entry)? // Q: Why use furn_str_id instead of f_null? - // @todo fix it, see above. + // @TODO: fix it, see above. if( bay.furn( point( finX, finY ) ) != furn_str_id( "f_null" ) ) { for( const tripoint &p : bay.points_on_zlevel() ) { if( bay.furn( p ) == furn_str_id( "f_null" ) ) { diff --git a/src/ranged.cpp b/src/ranged.cpp index 64e3460bd1669..a23593ceed864 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -1325,7 +1325,7 @@ std::vector target_handler::target_ui( player &pc, target_mode mode, aim_mode = aim_types.begin(); } - // @TODO this assumes that relevant == null means firing turrets, but that may not + // @TODO: this assumes that relevant == null means firing turrets, but that may not // always be the case. Consider passing a name into this function. int num_instruction_lines = draw_targeting_window( w_target, relevant ? relevant->tname() : _( "turrets" ), mode, ctxt, aim_types, tiny ); diff --git a/src/savegame.cpp b/src/savegame.cpp index 06c440cd8bd2f..b80f61ed933b5 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -1719,7 +1719,7 @@ void Creature_tracker::deserialize( JsonIn &jsin ) monsters_by_location.clear(); jsin.start_array(); while( !jsin.end_array() ) { - // @todo would be nice if monster had a constructor using JsonIn or similar, so this could be one statement. + // @TODO: would be nice if monster had a constructor using JsonIn or similar, so this could be one statement. shared_ptr_fast mptr = make_shared_fast(); jsin.read( *mptr ); add( mptr ); diff --git a/src/text_snippets.h b/src/text_snippets.h index 91d062efd4946..0504c5bd523d7 100644 --- a/src/text_snippets.h +++ b/src/text_snippets.h @@ -78,7 +78,7 @@ class snippet_library * The tags in the snippet are not automatically expanded - you need to * call `expand()` to do that. * - * @todo: make the result stay the same through different game sessions + * @TODO: make the result stay the same through different game sessions */ cata::optional random_from_category( const std::string &cat, unsigned int seed ) const; /** diff --git a/src/translations.cpp b/src/translations.cpp index 0f58e0bfeea30..2b65e4e6335eb 100644 --- a/src/translations.cpp +++ b/src/translations.cpp @@ -518,8 +518,8 @@ void translation::deserialize( JsonIn &jsin ) try { const std::string str_before = utf32_to_utf8( std::u32string( beg, to ) ); // +1 for the starting quotation mark - //@todo: properly handle escape sequences inside strings, instead - //of using `length()` here. + // @TODO: properly handle escape sequences inside strings, instead + // of using `length()` here. throw_error( err, 1 + str_before.length() ); } catch( const JsonError &e ) { debugmsg( "\n%s", e.what() ); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index bbb7b0e8e20c1..b8c8100f37f07 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -127,7 +127,7 @@ class DefaultRemovePartHandler : public RemovePartHandler } } } - // @todo maybe do this for all the nearby NPCs as well? + // @TODO: maybe do this for all the nearby NPCs as well? if( g->u.get_grab_type() == OBJECT_VEHICLE && g->u.grab_point == veh.global_part_pos3( part ) ) { if( veh.parts_at_relative( veh.parts[part].mount, false ).empty() ) { @@ -174,7 +174,7 @@ class MapgenRemovePartHandler : public RemovePartHandler // Ignored for now. We don't initialize the transparency cache in mapgen anyway. } void removed( vehicle &veh, const int /*part*/ ) override { - // @todo check if this is necessary, it probably isn't during mapgen + // @TODO: check if this is necessary, it probably isn't during mapgen m.dirty_vehicle_list.insert( &veh ); } void spawn_animal_from_part( item &/*base*/, const tripoint &/*loc*/ ) override { @@ -182,7 +182,7 @@ class MapgenRemovePartHandler : public RemovePartHandler // Ignored. The base item will not be changed and will spawn as is: // still containing the animal. // This should not happend during mapgen anyway. - // @todo *if* this actually happens: create a spawn point for the animal instead. + // @TODO: *if* this actually happens: create a spawn point for the animal instead. } }; @@ -2094,7 +2094,7 @@ bool vehicle::remove_part( const int p, RemovePartHandler &handler ) for( auto &i : get_items( p ) ) { // Note: this can spawn items on the other side of the wall! - // @todo fix this ^^ + // @TODO: fix this ^^ tripoint dest( part_loc + point( rng( -3, 3 ), rng( -3, 3 ) ) ); handler.add_item_or_charges( dest, i ); } @@ -3805,7 +3805,7 @@ void vehicle::noise_and_smoke( int load, time_duration time ) if( !combustion ) { return; } - /// @todo handle other engine types: muscle / animal / wind / coal / ... + /// @TODO: handle other engine types: muscle / animal / wind / coal / ... if( exhaust_part != -1 && engine_on ) { spew_field( mufflesmoke, exhaust_part, fd_smoke, diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 5fa06a8184dd1..398b0de599e34 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -940,7 +940,7 @@ bool vehicle::start_engine( const int e ) "engine_single_click_fail" ); return false; } - // @todo start_moves is in moves, but it's an integer, convert it to some time class + // @TODO: start_moves is in moves, but it's an integer, convert it to some time class const int start_draw_bat = power_to_energy_bat( engine_power * ( 1.0 + dmg / 2 + cold_factor / 5 ) * 10, 1_turns * start_moves / 100 ); diff --git a/src/weather_data.cpp b/src/weather_data.cpp index daabd5c9fd172..56b0e7504a6af 100644 --- a/src/weather_data.cpp +++ b/src/weather_data.cpp @@ -47,7 +47,7 @@ static weather_result weather_data_internal( weather_type const type ) * light modifier, sound attenuation, warn player? * Note light modifier assumes baseline of default_daylight_level() at 60 */ - // @todo but it actually isn't 60, it's 100. Fix this comment or fix the value + // @TODO: but it actually isn't 60, it's 100. Fix this comment or fix the value static const std::array data {{ weather_datum { "NULL Weather - BUG (weather_data.cpp:weather_data)", c_magenta, c_magenta_red, From 7c7fc4dac6b49824f11468a0dc8c1b493c8b2b31 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Sun, 5 Jan 2020 16:27:58 +0300 Subject: [PATCH 5/6] Removed redundant empty statement --- src/character.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/character.cpp b/src/character.cpp index 98ceaf846869c..01fb36bf048f2 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -4201,7 +4201,7 @@ hp_part Character::body_window( const std::string &menu_header, std::pair h_bar = get_hp_bar( current_hp, maximal_hp, false ); hp_str = colorize( h_bar.first, h_bar.second ) + colorize( std::string( 5 - utf8_width( h_bar.first ), '.' ), c_white ); - }; + } msg += colorize( aligned_name, all_state_col ) + " " + hp_str; // BLEEDING block From d941b4f85bb065e49af30a38786725778d9d5788 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Sun, 5 Jan 2020 17:33:19 +0300 Subject: [PATCH 6/6] Put comments to separate lines --- src/cata_io.h | 3 +- src/consumption.cpp | 72 +++++++----- src/game_inventory.cpp | 12 +- src/monattack.cpp | 243 +++++++++++++++++++++++++-------------- src/mondeath.h | 114 ++++++++++++------ src/monmove.cpp | 3 +- src/monstergenerator.cpp | 132 ++++++++++++++------- src/npcmove.cpp | 3 +- src/player.h | 3 +- 9 files changed, 381 insertions(+), 204 deletions(-) diff --git a/src/cata_io.h b/src/cata_io.h index bbeac546bad44..e7f3a9a8628ba 100644 --- a/src/cata_io.h +++ b/src/cata_io.h @@ -279,7 +279,8 @@ class JsonObjectInputArchive : public JsonObject bool io( const std::string &name, T *&pointer, const std::function &load, const std::function &save, bool required = false ) { - ( void ) save; // Only used by the matching function in the output archive classes. + // Only used by the matching function in the output archive classes. + ( void ) save; std::string ident; if( !io( name, ident ) ) { if( required ) { diff --git a/src/consumption.cpp b/src/consumption.cpp index 08ea0258df406..e26111abc7ff9 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -10,7 +10,7 @@ #include "addiction.h" #include "avatar.h" #include "bionics.h" -#include "calendar.h" // ticks_between +#include "calendar.h" #include "cata_utility.h" #include "debug.h" #include "game.h" @@ -347,8 +347,9 @@ std::pair Character::fun_for( const item &comest ) const // As float to avoid rounding too many times float fun = comest.get_comestible_fun(); + // Food doesn't taste as good when you're sick if( ( has_effect( effect_common_cold ) || has_effect( effect_flu ) ) && fun > 0 ) { - fun /= 3; // food doesn't taste as good when you're sick + fun /= 3; } // Rotten food should be pretty disgusting const float relative_rot = comest.get_relative_rot(); @@ -373,9 +374,10 @@ std::pair Character::fun_for( const item &comest ) const event.component_hash == comest.make_component_hash() ) { fun -= comest.get_comestible()->monotony_penalty; // This effect can't drop fun below 0, unless the food has the right flag. + // 0 is the lowest we'll go, no need to keep looping. if( fun <= 0 && !comest.has_flag( "NEGATIVE_MONOTONY_OK" ) ) { fun = 0; - break; // 0 is the lowest we'll go, no need to keep looping. + break; } } } @@ -395,8 +397,9 @@ std::pair Character::fun_for( const item &comest ) const if( fun > 0 ) { fun *= 0.5; } else { - fun *= 1.25; // melted freezable food tastes 25% worse than frozen freezable food - // frozen freezable food... say that 5 times fast + // Melted freezable food tastes 25% worse than frozen freezable food. + // Frozen freezable food... say that 5 times fast + fun *= 1.25; } } @@ -451,7 +454,7 @@ int Character::vitamin_mod( const vitamin_id &vit, int qty, bool capped ) const auto &v = it->first.obj(); if( qty > 0 ) { - // accumulations can never occur from food sources + // Accumulations can never occur from food sources it->second = std::min( it->second + qty, capped ? 0 : v.max() ); update_vitamins( vit ); @@ -788,7 +791,7 @@ bool player::eat( item &food, bool force ) add_msg_if_player( m_good, _( "Mmm, this %s tastes delicious…" ), food.tname() ); } if( !consume_effects( food ) ) { - //Already consumed by using `food.type->invoke`? + // Already consumed by using `food.type->invoke`? if( charges_used > 0 ) { food.mod_charges( -charges_used ); } @@ -805,7 +808,7 @@ bool player::eat( item &food, bool force ) has_trait( trait_id( "FANGS_SPIDER" ) ) ) { mealtime /= 2; } else if( has_trait( trait_id( "SHARKTEETH" ) ) ) { - //SHARKBAIT! HOO HA HA! + // SHARKBAIT! HOO HA HA! mealtime /= 3; } else if( has_trait( trait_id( "GOURMAND" ) ) ) { // Don't stack those two - that would be 25 moves per item @@ -813,9 +816,11 @@ bool player::eat( item &food, bool force ) } if( has_trait( trait_id( "BEAK_HUM" ) ) && !drinkable ) { - mealtime += 200; // Much better than PROBOSCIS but still optimized for fluids + // Much better than PROBOSCIS but still optimized for fluids + mealtime += 200; } else if( has_trait( trait_id( "SABER_TEETH" ) ) ) { - mealtime += 250; // They get In The Way + // They get In The Way + mealtime += 250; } if( amorphous ) { @@ -1003,7 +1008,7 @@ bool player::eat( item &food, bool force ) if( food.has_flag( "URSINE_HONEY" ) && ( !crossed_threshold() || has_trait( trait_id( "THRESH_URSINE" ) ) ) && mutation_category_level["URSINE"] > 40 ) { - //Need at least 5 bear mutations for effect to show, to filter out mutations in common with other categories + // Need at least 5 bear mutations for effect to show, to filter out mutations in common with other categories int honey_fun = has_trait( trait_id( "THRESH_URSINE" ) ) ? std::min( mutation_category_level["URSINE"] / 8, 20 ) : mutation_category_level["URSINE"] / 12; @@ -1015,7 +1020,7 @@ bool player::eat( item &food, bool force ) add_morale( MORALE_HONEY, honey_fun, 100 ); } - // chance to become parasitised + // Chance to become parasitised if( !will_vomit && !( has_bionic( bio_digestion ) || has_trait( trait_id( "PARAIMMUNE" ) ) ) ) { if( food.get_comestible()->parasites > 0 && !food.has_flag( "NO_PARASITES" ) && one_in( food.get_comestible()->parasites ) ) { @@ -1039,7 +1044,7 @@ bool player::eat( item &food, bool force ) } } - // chance to get food poisoning from bacterial contamination + // Chance to get food poisoning from bacterial contamination if( !will_vomit && !has_bionic( bio_digestion ) ) { const int contamination = food.get_comestible()->contamination; if( rng( 1, 100 ) <= contamination ) { @@ -1063,7 +1068,8 @@ bool player::eat( item &food, bool force ) void player::modify_health( const islot_comestible &comest ) { const int effective_health = comest.healthy; - const int health_cap = 200; // Effectively no cap on health modifiers from food and meds + // Effectively no cap on health modifiers from food and meds + const int health_cap = 200; mod_healthy_mod( effective_health, effective_health >= 0 ? health_cap : -health_cap ); } @@ -1137,7 +1143,7 @@ bool player::consume_effects( item &food ) } if( has_trait( trait_id( "THRESH_PLANT" ) ) && food.type->can_use( "PLANTBLECH" ) ) { - // used to cap nutrition and thirst, but no longer + // Was used to cap nutrition and thirst, but no longer does this return false; } if( ( has_trait( trait_id( "HERBIVORE" ) ) || has_trait( trait_id( "RUMINANT" ) ) ) && @@ -1160,9 +1166,11 @@ bool player::consume_effects( item &food ) add_msg( m_debug, "%d health from %0.2f%% rotten food", h_loss, rottedness ); } - const auto nutr = nutrition_for( food ); // used in hibernation messages. + // Used in hibernation messages. + const auto nutr = nutrition_for( food ); const bool skip_health = has_trait( trait_id( "PROJUNK2" ) ) && comest.healthy < 0; - if( !skip_health ) { // we can handle junk just fine + // We can handle junk just fine + if( !skip_health ) { modify_health( comest ); } modify_stimulation( comest ); @@ -1172,18 +1180,18 @@ bool player::consume_effects( item &food ) const bool hibernate = has_active_mutation( trait_id( "HIBERNATE" ) ); if( hibernate ) { if( ( nutr > 0 && get_hunger() < -60 ) || ( comest.quench > 0 && get_thirst() < -60 ) ) { - //Tell the player what's going on + // Tell the player what's going on add_msg_if_player( _( "You gorge yourself, preparing to hibernate." ) ); if( one_in( 2 ) ) { - //50% chance of the food tiring you + // 50% chance of the food tiring you mod_fatigue( nutr ); } } if( ( nutr > 0 && get_hunger() < -200 ) || ( comest.quench > 0 && get_thirst() < -200 ) ) { - //Hibernation should cut burn to 60/day + // Hibernation should cut burn to 60/day add_msg_if_player( _( "You feel stocked for a day or two. Got your bed all ready and secured?" ) ); if( one_in( 2 ) ) { - //And another 50%, intended cumulative + // And another 50%, intended cumulative mod_fatigue( nutr ); } } @@ -1192,7 +1200,7 @@ bool player::consume_effects( item &food ) add_msg_if_player( _( "Mmm. You can still fit some more in… but maybe you should get comfortable and sleep." ) ); if( !one_in( 3 ) ) { - //Third check, this one at 66% + // Third check, this one at 66% mod_fatigue( nutr ); } } @@ -1220,8 +1228,8 @@ bool player::consume_effects( item &food ) } mod_hunger( 40 ); mod_thirst( 40 ); - //~slimespawns have *small voices* which may be the Nice equivalent - //~of the Rat King's ALL CAPS invective. Probably shared-brain telepathy. + //~ slimespawns have *small voices* which may be the Nice equivalent + //~ of the Rat King's ALL CAPS invective. Probably shared-brain telepathy. add_msg_if_player( m_good, _( "hey, you look like me! let's work together!" ) ); } @@ -1252,7 +1260,7 @@ bool player::consume_effects( item &food ) contained_food.base_volume() - std::max( water, 0_ml ), compute_effective_nutrients( contained_food ) }; - // maybe move tapeworm to digestion + // Maybe move tapeworm to digestion if( has_effect( efftype_id( "tapeworm" ) ) ) { ingested.nutr /= 2; } @@ -1335,7 +1343,8 @@ bool player::can_feed_furnace_with( const item &it ) const return false; } - if( it.charges_per_volume( furnace_max_volume ) < 1 ) { // not even one charge fits + // Not even one charge fits + if( it.charges_per_volume( furnace_max_volume ) < 1 ) { return false; } @@ -1418,7 +1427,8 @@ bool player::fuel_bionic_with( item &it ) const std::string new_charge = std::to_string( loadable + loaded ); it.charges -= loadable; - set_value( it.typeId(), new_charge );// type and amount of fuel + // Type and amount of fuel + set_value( it.typeId(), new_charge ); update_fuel_storage( it.typeId() ); add_msg_player_or_npc( m_info, //~ %1$i: charge number, %2$s: item name, %3$s: bionics name @@ -1469,7 +1479,8 @@ int player::get_acquirable_energy( const item &it, rechargeable_cbm cbm ) const const double n_stacks = static_cast( it.charges_per_volume( furnace_max_volume ) ) / it.type->stack_size; consumed_vol = it.type->volume * n_stacks; - consumed_mass = it.type->weight * 10 * n_stacks; // it.type->weight is in 10g units? + // it.type->weight is in 10g units? + consumed_mass = it.type->weight * 10 * n_stacks; } int amount = ( consumed_vol / 250_ml + consumed_mass / 1_gram ) / 9; @@ -1513,7 +1524,7 @@ bool player::can_consume( const item &it ) const if( can_consume_as_is( it ) ) { return true; } - // checking NO_RELOAD to prevent consumption of `battery` when contained in `battery_car` (#20012) + // Checking NO_RELOAD to prevent consumption of `battery` when contained in `battery_car` (#20012) return !it.is_container_empty() && !it.has_flag( "NO_RELOAD" ) && can_consume_as_is( it.contents.front() ); } @@ -1527,6 +1538,7 @@ item &player::get_consumable_from( item &it ) const } static item null_comestible; - null_comestible = item(); // Since it's not const. + // Since it's not const. + null_comestible = item(); return null_comestible; } diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index c1f2b746152e4..747ca195ae9f0 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1521,7 +1521,8 @@ static item_location autodoc_internal( player &u, player &patient, } if( !b_filter.empty() ) { - hint = string_format( _( "Available kit: %i" ), b_filter.size() );// legacy + // Legacy + hint = string_format( _( "Available kit: %i" ), b_filter.size() ); } else { hint = string_format( _( "Available anesthetic: %i mL" ), drug_count ); } @@ -1681,11 +1682,13 @@ class bionic_install_preset: public inventory_selector_preset duration * weight; std::vector b_filter = p.crafting_inventory().items_with( []( const item & it ) { - return it.has_flag( "ANESTHESIA" ); // legacy + // Legacy + return it.has_flag( "ANESTHESIA" ); } ); if( !b_filter.empty() ) { - return _( "kit available" );// legacy + // Legacy + return _( "kit available" ); } else { return string_format( _( "%i mL" ), req_anesth.get_tools().front().front().count ); } @@ -1764,10 +1767,11 @@ class bionic_install_surgeon_preset : public inventory_selector_preset player &installer = p; const int assist_bonus = installer.get_effect_int( effect_assisted ); + // Override player's skills with surgeon skill const int adjusted_skill = installer.bionics_adjusted_skill( skill_firstaid, skill_computer, skill_electronics, - 20 );//override player's skills with surgeon skill + 20 ); if( ( get_option < bool >( "SAFE_AUTODOC" ) ) || g->u.has_trait( trait_id( "DEBUG_BIONICS" ) ) ) { diff --git a/src/monattack.cpp b/src/monattack.cpp index 3fdedfa3b7294..b645ca62b5c28 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -186,9 +186,10 @@ static Creature *sting_get_target( monster *z, float range = 5.0f ) return nullptr; } + // Can't see/reach target, no attack if( !z->sees( *target ) || !g->m.clear_path( z->pos(), target->pos(), range, 1, 100 ) ) { - return nullptr; // Can't see/reach target, no attack + return nullptr; } return rl_dist( z->pos(), target->pos() ) <= range ? target : nullptr; @@ -350,20 +351,24 @@ bool mattack::antqueen( monster *z ) } if( !ants.empty() ) { - z->moves -= 100; // It takes a while + // It takes a while + z->moves -= 100; monster *ant = random_entry( ants ); if( g->u.sees( *z ) && g->u.sees( *ant ) ) { add_msg( m_warning, _( "The %1$s feeds an %2$s and it grows!" ), z->name(), ant->name() ); } ant->poly( ant->type->upgrade_into ); - } else if( egg_points.empty() ) { // There's no eggs nearby--lay one. + } else if( egg_points.empty() ) { + // There's no eggs nearby--lay one. if( g->u.sees( *z ) ) { add_msg( _( "The %s lays an egg!" ), z->name() ); } g->m.spawn_item( z->pos(), "ant_egg", 1, 0, calendar::turn ); - } else { // There are eggs nearby. Let's hatch some. - z->moves -= 20 * egg_points.size(); // It takes a while + } else { + // There are eggs nearby. Let's hatch some. + // It takes a while + z->moves -= 20 * egg_points.size(); if( g->u.sees( *z ) ) { add_msg( m_warning, _( "The %s tends nearby eggs, and they hatch!" ), z->name() ); } @@ -375,10 +380,11 @@ bool mattack::antqueen( monster *z ) continue; } const mtype_id &mt = z->type->id == mon_ant_acid_queen ? mon_ant_acid_larva : mon_ant_larva; + // Max one hatch per tile if( monster *const mon = g->place_critter_at( mt, egg_pos ) ) { mon->make_ally( *z ); it = items.erase( it ); - break; // Max one hatch per tile + break; } } } @@ -396,7 +402,8 @@ bool mattack::shriek( monster *z ) return false; } - z->moves -= 240; // It takes a while + // It takes a while + z->moves -= 240; sounds::sound( z->pos(), 50, sounds::sound_t::alert, _( "a terrible shriek!" ), false, "shout", "shriek" ); return true; @@ -451,13 +458,16 @@ bool mattack::shriek_stun( monster *z ) for( const tripoint &cone : g->m.points_in_radius( z->pos(), 4 ) ) { int tile_angle = coord_to_angle( z->pos(), cone ); int diff = abs( target_angle - tile_angle ); + // Skip the target, because it's outside cone or it's the source if( diff + cone_angle > 360 || diff > cone_angle || cone == z->pos() ) { - continue; // skip the target, because it's outside cone or it's the source + continue; } - // affect the target - g->m.bash( cone, 4, true ); //Small bash to every square, silent to not flood message box + // Affect the target + // Small bash to every square, silent to not flood message box + g->m.bash( cone, 4, true ); - Creature *target = g->critter_at( cone ); //If a monster is there, chance for stun + // If a monster is there, chance for stun + Creature *target = g->critter_at( cone ); if( target == nullptr ) { continue; } @@ -480,11 +490,13 @@ bool mattack::howl( monster *z ) return false; } - z->moves -= 200; // It takes a while + // It takes a while + z->moves -= 200; sounds::sound( z->pos(), 35, sounds::sound_t::alert, _( "an ear-piercing howl!" ), false, "shout", "howl" ); - if( z->friendly != 0 ) { // TODO: Make this use mon's faction when those are in + // TODO: Make this use mon's faction when those are in + if( z->friendly != 0 ) { for( monster &other : g->all_monsters() ) { if( other.type != z->type ) { continue; @@ -505,14 +517,16 @@ bool mattack::rattle( monster *z ) { // TODO: Let it rattle at non-player friendlies const int min_dist = z->friendly != 0 ? 1 : 4; - Creature *target = &g->u; // Can't use attack_target - the snake has no target + Creature *target = &g->u; + // Can't use attack_target - the snake has no target if( target == nullptr || rl_dist( z->pos(), target->pos() ) > min_dist || !z->sees( *target ) ) { return false; } - z->moves -= 20; // It takes a very short while + // It takes a very short while + z->moves -= 20; sounds::sound( z->pos(), 10, sounds::sound_t::alarm, _( "a sibilant rattling sound!" ), false, "misc", "rattling" ); @@ -530,17 +544,20 @@ bool mattack::acid( monster *z ) return false; } + // Can't see/reach target, no attack if( !z->sees( *target ) || !g->m.clear_path( z->pos(), target->pos(), 10, 1, 100 ) ) { - return false; // Can't see/reach target, no attack + return false; } - z->moves -= 300; // It takes a while + // It takes a while + z->moves -= 300; sounds::sound( z->pos(), 4, sounds::sound_t::combat, _( "a spitting noise." ), false, "misc", "spitting" ); projectile proj; proj.speed = 10; - proj.impact.add_damage( DT_ACID, 5 ); // Mostly just for momentum + // Mostly just for momentum + proj.impact.add_damage( DT_ACID, 5 ); proj.range = 10; proj.proj_effects.insert( "NO_OVERSHOOT" ); auto dealt = projectile_attack( proj, z->pos(), target->pos(), { 5400 }, z ); @@ -673,12 +690,14 @@ bool mattack::shockstorm( monster *z ) } bool seen = g->u.sees( *z ); + // Can't see/reach target, no attack if( !z->sees( *target ) || !g->m.clear_path( z->pos(), target->pos(), 12, 1, 100 ) ) { - return false; // Can't see/reach target, no attack + return false; } - z->moves -= 50; // It takes a while + // It takes a while + z->moves -= 50; if( seen ) { auto msg_type = target == &g->u ? m_bad : m_neutral; @@ -691,7 +710,8 @@ bool mattack::shockstorm( monster *z ) target->posy() + rng( -1, 1 ) + rng( -1, 1 ), target->posz() ); std::vector bolt = line_to( z->pos(), tarp, 0, 0 ); - for( auto &i : bolt ) { // Fill the LOS with electricity + // Fill the LOS with electricity + for( auto &i : bolt ) { if( !one_in( 4 ) ) { g->m.add_field( i, fd_electricity, rng( 1, 3 ) ); } @@ -736,9 +756,10 @@ bool mattack::pull_metal_weapon( monster *z ) return false; } + // Can't see/reach target, no attack if( !z->sees( *target ) || !g->m.clear_path( z->pos(), target->pos(), max_distance, 1, 100 ) ) { - return false; // Can't see/reach target, no attack + return false; } player *foe = dynamic_cast< player * >( target ); if( foe != nullptr ) { @@ -749,7 +770,8 @@ bool mattack::pull_metal_weapon( monster *z ) foe->weapon.made_of( material_id( "steel" ) ) || foe->weapon.made_of( material_id( "budget_steel" ) ) ) ) { int wp_skill = foe->get_skill_level( skill_melee ); - z->moves -= att_cost_pull; // It takes a while + // It takes a while + z->moves -= att_cost_pull; int success = 100; ///\EFFECT_STR increases resistance to pull_metal_weapon special attack if( foe->str_cur > min_str ) { @@ -787,7 +809,8 @@ bool mattack::boomer( monster *z ) } std::vector line = g->m.find_clear_path( z->pos(), target->pos() ); - z->moves -= 250; // It takes a while + // It takes a while + z->moves -= 250; bool u_see = g->u.sees( *z ); if( u_see ) { add_msg( m_warning, _( "The %s spews bile!" ), z->name() ); @@ -830,7 +853,8 @@ bool mattack::boomer_glow( monster *z ) } std::vector line = g->m.find_clear_path( z->pos(), target->pos() ); - z->moves -= 250; // It takes a while + // It takes a while + z->moves -= 250; bool u_see = g->u.sees( *z ); if( u_see ) { add_msg( m_warning, _( "The %s spews bile!" ), z->name() ); @@ -966,7 +990,8 @@ bool mattack::resurrect( monster *z ) } std::pair raised = random_entry( corpses ); - assert( raised.second ); // To appease static analysis + // To appease static analysis + assert( raised.second ); // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) float corpse_damage = raised.second->damage_level( 4 ); // Did we successfully raise something? @@ -976,7 +1001,8 @@ bool mattack::resurrect( monster *z ) add_msg( m_info, _( "The %s gestures at a nearby corpse." ), z->name() ); } z->remove_effect( effect_raising ); - z->moves -= z->type->speed; // Takes one turn + // Takes one turn + z->moves -= z->type->speed; // Penalize speed by between 10% and 50% based on how damaged the corpse is. float speed_penalty = 0.1 + ( corpse_damage * 0.1 ); z->set_speed_base( z->get_speed_base() - speed_penalty * z->type->speed ); @@ -1138,10 +1164,14 @@ bool mattack::science( monster *const z ) // I said SCIENCE again! constexpr int att_cost_flavor = 80; // radiation attack behavior - constexpr int att_rad_dodge_diff = 16; // how hard it is to dodge - constexpr int att_rad_mutate_chance = 6; // (1/x) inverse chance to cause mutation. - constexpr int att_rad_dose_min = 20; // min radiation - constexpr int att_rad_dose_max = 50; // max radiation + // how hard it is to dodge + constexpr int att_rad_dodge_diff = 16; + // (1/x) inverse chance to cause mutation. + constexpr int att_rad_mutate_chance = 6; + // min radiation + constexpr int att_rad_dose_min = 20; + // max radiation + constexpr int att_rad_dose_max = 50; // acid attack behavior constexpr int att_acid_intensity = 3; @@ -1422,7 +1452,8 @@ bool mattack::growplants( monster *z ) } } - return true; // added during refactor, previously had no cooldown reset + // added during refactor, previously had no cooldown reset + return true; } bool mattack::grow_vine( monster *z ) @@ -1589,7 +1620,8 @@ bool mattack::triffid_heartbeat( monster *z ) bool mattack::fungus( monster *z ) { // TODO: Infect NPCs? - z->moves -= 200; // It takes a while + // It takes a while + z->moves -= 200; if( g->u.has_trait( trait_THRESH_MYCUS ) ) { z->friendly = 100; } @@ -1718,7 +1750,8 @@ bool mattack::fungus_big_blossom( monster *z ) bool mattack::fungus_inject( monster *z ) { - Creature *target = &g->u; // For faster copy+paste + // For faster copy+paste + Creature *target = &g->u; if( rl_dist( z->pos(), g->u.pos() ) > 1 ) { return false; } @@ -1850,7 +1883,8 @@ bool mattack::fungus_growth( monster *z ) bool mattack::fungus_sprout( monster *z ) { - bool push_player = false; // To avoid map shift weirdness + // To avoid map shift weirdness + bool push_player = false; for( const tripoint &dest : g->m.points_in_radius( z->pos(), 1 ) ) { if( g->u.pos() == dest ) { push_player = true; @@ -1878,8 +1912,9 @@ bool mattack::fungus_fortify( monster *z ) Creature *target = &g->u; bool mycus = false; bool peaceful = true; + //No nifty support effects. Yet. This lets it rebuild hedges. if( g->u.has_trait( trait_THRESH_MARLOSS ) || g->u.has_trait( trait_THRESH_MYCUS ) ) { - mycus = true; //No nifty support effects. Yet. This lets it rebuild hedges. + mycus = true; } if( ( g->u.has_trait( trait_MARLOSS ) ) && ( g->u.has_trait( trait_MARLOSS_BLUE ) ) && !g->u.crossed_threshold() && !mycus ) { @@ -2674,7 +2709,8 @@ bool mattack::grab_drag( monster *z ) player *foe = dynamic_cast< player * >( target ); - grab( z ); //First, grab the target + // First, grab the target + grab( z ); if( !target->has_effect( effect_grabbed ) ) { //Can't drag if isn't grabbed, otherwise try and move return false; @@ -2710,7 +2746,8 @@ bool mattack::grab_drag( monster *z ) z->add_effect( effect_grabbing, 2_turns ); target->add_effect( effect_grabbed, 2_turns, bp_torso, false, prev_effect + 3 ); - return true; // cooldown was not reset prior to refactor here + // cooldown was not reset prior to refactor here + return true; } bool mattack::gene_sting( monster *z ) @@ -2833,13 +2870,14 @@ bool mattack::nurse_check_up( monster *z ) } if( found_target ) { - if( !z->has_effect( - effect_countdown ) ) { // first we offer the check up then we wait to the player to come close + // First we offer the check up then we wait to the player to come close + if( !z->has_effect( effect_countdown ) ) { sounds::sound( z->pos(), 8, sounds::sound_t::electronic_speech, string_format( _( "a soft robotic voice say, \"Come here. I'll give you a check-up.\"" ) ) ); z->add_effect( effect_countdown, 1_minutes ); - } else if( rl_dist( target->pos(), z->pos() ) > 1 ) { // giving them some encouragement + } else if( rl_dist( target->pos(), z->pos() ) > 1 ) { + // Giving them some encouragement sounds::sound( z->pos(), 8, sounds::sound_t::electronic_speech, string_format( _( "a soft robotic voice say, \"Come on. I don't bite, I promise it won't hurt one bit.\"" ) ) ); @@ -2871,9 +2909,9 @@ bool mattack::nurse_assist( monster *z ) tripoint tmp_pos( z->pos() + point( 12, 12 ) ); for( auto critter : g->m.get_creatures_in_radius( z->pos(), 6 ) ) { player *tmp_player = dynamic_cast( critter ); + // No need to scan players we can't reach if( tmp_player != nullptr && z->sees( *tmp_player ) && - g->m.clear_path( z->pos(), tmp_player->pos(), 10, 0, - 100 ) ) { // no need to scan players we can't reach + g->m.clear_path( z->pos(), tmp_player->pos(), 10, 0, 100 ) ) { if( rl_dist( z->pos(), tmp_player->pos() ) < rl_dist( z->pos(), tmp_pos ) ) { tmp_pos = tmp_player->pos(); target = tmp_player; @@ -2926,9 +2964,9 @@ bool mattack::nurse_operate( monster *z ) tripoint tmp_pos( z->pos() + point( 12, 12 ) ); for( auto critter : g->m.get_creatures_in_radius( z->pos(), 6 ) ) { player *tmp_player = dynamic_cast< player *>( critter ); + // No need to scan players we can't reach if( tmp_player != nullptr && z->sees( *tmp_player ) && - g->m.clear_path( z->pos(), tmp_player->pos(), 10, 0, - 100 ) ) { // no need to scan players we can't reach + g->m.clear_path( z->pos(), tmp_player->pos(), 10, 0, 100 ) ) { if( tmp_player->has_any_bionic() ) { if( rl_dist( z->pos(), tmp_player->pos() ) < rl_dist( z->pos(), tmp_pos ) ) { tmp_pos = tmp_player->pos(); @@ -2939,8 +2977,9 @@ bool mattack::nurse_operate( monster *z ) } } if( found_target && z->attitude_to( g->u ) == Creature::Attitude::A_FRIENDLY ) { + // 50% chance to not turn hostile again if( one_in( 2 ) ) { - return false; // 50% chance to not turn hostile again + return false; } } if( found_target && u_see ) { @@ -2960,9 +2999,11 @@ bool mattack::nurse_operate( monster *z ) z->anger = 0; return false; } - z->set_dest( target->pos() );// should designate target as the attack_target + // Should designate target as the attack_target + z->set_dest( target->pos() ); - if( target->has_effect( effect_grabbed ) ) {// check if target is already grabbed by something else + // Check if target is already grabbed by something else + if( target->has_effect( effect_grabbed ) ) { for( auto critter : g->m.get_creatures_in_radius( target->pos(), 1 ) ) { monster *mon = dynamic_cast( critter ); if( mon != nullptr && mon != z ) { @@ -2970,19 +3011,22 @@ bool mattack::nurse_operate( monster *z ) sounds::sound( z->pos(), 8, sounds::sound_t::electronic_speech, string_format( _( "a soft robotic voice say, \"Unhand this patient immediately! If you keep interfering with the procedure I'll be forced to call law enforcement.\"" ) ) ); - z->push_to( mon->pos(), 6, 0 );// try to push the perpetrator away + // Try to push the perpetrator away + z->push_to( mon->pos(), 6, 0 ); } else { sounds::sound( z->pos(), 8, sounds::sound_t::electronic_speech, string_format( _( "a soft robotic voice say, \"Greetings kinbot. Please take good care of this patient.\"" ) ) ); z->anger = 0; - return false; // situation is under control no need to intervene; + // Situation is under control no need to intervene; + return false; } } } } else { grab( z ); - if( target->has_effect( effect_grabbed ) ) { // check if we succesfully grabbed the target + // Check if we succesfully grabbed the target + if( target->has_effect( effect_grabbed ) ) { z->dragged_foe_id = target->getID(); z->add_effect( effect_dragging, 1_turns, num_bp, true ); return true; @@ -3175,7 +3219,8 @@ bool mattack::tazer( monster *z ) void mattack::taze( monster *z, Creature *target ) { - z->moves -= 200; // It takes a while + // It takes a while + z->moves -= 200; if( target == nullptr || target->uncanny_dodge() ) { return; } @@ -3210,7 +3255,8 @@ void mattack::rifle( monster *z, Creature *target ) npc tmp = make_fake_npc( z, 16, 10, 8, 12 ); tmp.set_skill_level( skill_rifle, 8 ); tmp.set_skill_level( skill_gun, 6 ); - tmp.recoil = 0; // no need to aim + // No need to aim + tmp.recoil = 0; if( target == &g->u ) { if( !z->has_effect( effect_targeted ) ) { @@ -3220,7 +3266,8 @@ void mattack::rifle( monster *z, Creature *target ) return; } } - z->moves -= 150; // It takes a while + // It takes a while + z->moves -= 150; if( z->ammo[ammo_type] <= 0 ) { if( one_in( 3 ) ) { @@ -3263,8 +3310,8 @@ void mattack::frag( monster *z, Creature *target ) // This is for the bots, not //~ Potential grenading detected. add_msg( m_warning, _( "Those laser dots don't seem very friendly…" ) ); } - g->u.add_effect( effect_laserlocked, - 3_turns ); // Effect removed in game.cpp, duration doesn't much matter + // Effect removed in game.cpp, duration doesn't much matter + g->u.add_effect( effect_laserlocked, 3_turns ); sounds::sound( z->pos(), 10, sounds::sound_t::electronic_speech, _( "Targeting." ), false, "speech", z->type->id.str() ); z->add_effect( effect_targeted, 5_turns ); @@ -3277,8 +3324,10 @@ void mattack::frag( monster *z, Creature *target ) // This is for the bots, not npc tmp = make_fake_npc( z, 16, 10, 8, 12 ); tmp.set_skill_level( skill_launcher, 8 ); tmp.set_skill_level( skill_gun, 6 ); - tmp.recoil = 0; // no need to aim - z->moves -= 150; // It takes a while + // No need to aim + tmp.recoil = 0; + // It takes a while + z->moves -= 150; if( z->ammo[ammo_type] <= 0 ) { if( one_in( 3 ) ) { @@ -3335,8 +3384,10 @@ void mattack::tankgun( monster *z, Creature *target ) npc tmp = make_fake_npc( z, 12, 8, 8, 8 ); tmp.set_skill_level( skill_launcher, 1 ); tmp.set_skill_level( skill_gun, 1 ); - tmp.recoil = 0; // no need to aim - z->moves -= 150; // It takes a while + // No need to aim + tmp.recoil = 0; + // It takes a while + z->moves -= 150; if( z->ammo[ammo_type] <= 0 ) { if( one_in( 3 ) ) { @@ -3547,18 +3598,22 @@ bool mattack::flamethrower( monster *z ) // TODO: handle friendly monsters return false; } - if( z->friendly != 0 ) { // TODO: that is always false! + // TODO: that is always false! + if( z->friendly != 0 ) { // Attacking monsters, not the player! int boo_hoo; Creature *target = z->auto_find_hostile_target( 5, boo_hoo ); - if( target == nullptr ) { // Couldn't find any targets! - if( boo_hoo > 0 && g->u.sees( *z ) ) { // because that stupid oaf was in the way! + // Couldn't find any targets! + if( target == nullptr ) { + // Because that stupid oaf was in the way! + if( boo_hoo > 0 && g->u.sees( *z ) ) { add_msg( m_warning, ngettext( "Pointed in your direction, the %s emits an IFF warning beep.", "Pointed in your direction, the %s emits %d annoyed sounding beeps.", boo_hoo ), z->name(), boo_hoo ); } - return false; // did reset before refactor, changed to match other turret behaviors + // Did reset before refactor, changed to match other turret behaviors + return false; } flame( z, target ); return true; @@ -3578,7 +3633,8 @@ void mattack::flame( monster *z, Creature *target ) int dist = rl_dist( z->pos(), target->pos() ); if( target != &g->u ) { // friendly - z->moves -= 500; // It takes a while + // It takes a while + z->moves -= 500; if( !g->m.sees( z->pos(), target->pos(), dist ) ) { // shouldn't happen debugmsg( "mattack::flame invoked on invisible target" ); @@ -3602,7 +3658,8 @@ void mattack::flame( monster *z, Creature *target ) return; } - z->moves -= 500; // It takes a while + // It takes a while + z->moves -= 500; if( !g->m.sees( z->pos(), target->pos(), dist + 1 ) ) { // shouldn't happen debugmsg( "mattack::flame invoked on invisible target" ); @@ -3722,8 +3779,9 @@ bool mattack::chickenbot( monster *z ) mode = 2; } + // No attacks were valid! if( mode == 0 ) { - return false; // No attacks were valid! + return false; } if( mode > cap ) { @@ -3748,7 +3806,8 @@ bool mattack::chickenbot( monster *z ) } break; default: - return false; // Weak stuff, shouldn't bother with + // Weak stuff, shouldn't bother with + return false; } return true; @@ -3804,8 +3863,9 @@ bool mattack::multi_robot( monster *z ) } } + // No attacks were valid! if( mode == 0 ) { - return false; // No attacks were valid! + return false; } if( mode > cap ) { @@ -3823,7 +3883,8 @@ bool mattack::multi_robot( monster *z ) } break; default: - return false; // Weak stuff, shouldn't bother with + // Weak stuff, shouldn't bother with + return false; } return true; @@ -3896,7 +3957,8 @@ bool mattack::upgrade( monster *z ) z->anger = 5; } - z->moves -= z->type->speed; // Takes one turn + // Takes one turn + z->moves -= z->type->speed; monster *target = random_entry( targets ); @@ -3931,7 +3993,8 @@ bool mattack::upgrade( monster *z ) bool mattack::breathe( monster *z ) { - z->moves -= 100; // It takes a while + // It takes a while + z->moves -= 100; bool able = ( z->type->id == mon_breather_hub ); if( !able ) { @@ -3996,7 +4059,8 @@ bool mattack::stretch_bite( monster *z ) } body_part hit = target->get_random_body_part(); - int dam = rng( 5, 15 ); //more damage due to the speed of the moving head + // More damage due to the speed of the moving head + int dam = rng( 5, 15 ); dam = target->deal_damage( z, hit, damage_instance( DT_STAB, dam ) ).total_damage(); if( dam > 0 ) { @@ -4036,8 +4100,9 @@ bool mattack::brandish( monster *z ) // TODO: handle friendly monsters return false; } + // Only brandish if we can see you! if( !z->sees( g->u ) ) { - return false; // Only brandish if we can see you! + return false; } add_msg( m_warning, _( "He's brandishing a knife!" ) ); add_msg( _( "Quiet, quiet" ) ); @@ -4181,8 +4246,9 @@ bool mattack::lunge( monster *z ) bool seen = g->u.sees( *z ); if( dist > 1 ) { if( one_in( 5 ) ) { + // Out of range if( dist > 4 || !z->sees( *target ) ) { - return false; // Out of range + return false; } z->moves += 200; if( seen ) { @@ -4245,8 +4311,9 @@ bool mattack::longswipe( monster *z ) if( target == nullptr ) { return false; } + // Out of range if( rl_dist( z->pos(), target->pos() ) > 3 || !z->sees( *target ) ) { - return false; //out of range + return false; } //Is there something impassable blocking the claw? for( const auto &pnt : g->m.find_clear_path( z->pos(), target->pos() ) ) { @@ -4344,7 +4411,8 @@ bool mattack::longswipe( monster *z ) static void parrot_common( monster *parrot ) { - parrot->moves -= 100; // It takes a while + // It takes a while + parrot->moves -= 100; const SpeechBubble &speech = get_speech( parrot->type->id.str() ); sounds::sound( parrot->pos(), speech.volume, sounds::sound_t::speech, speech.text.translated(), false, "speech", parrot->type->id.str() ); @@ -4396,10 +4464,12 @@ bool mattack::darkman( monster *z ) z->name() ); } } + // Wont do the combat stuff unless it can see you if( !z->sees( g->u ) ) { - return true; // Wont do the combat stuff unless it can see you + return true; } - switch( rng( 1, 7 ) ) { // What do we say? + // What do we say? + switch( rng( 1, 7 ) ) { case 1: add_msg( _( "\"Stop it please\"" ) ); break; @@ -4705,9 +4775,11 @@ bool mattack::riotbot( monster *z ) z->moves -= 50; - int delta = dist / 4 + 1; //precautionary shot + // Precautionary shot + int delta = dist / 4 + 1; + // Precision shot if( z->get_hp() < z->get_hp_max() ) { - delta = 1; //precision shot + delta = 1; } tripoint dest( target->posx() + rng( 0, delta ) - rng( 0, delta ), @@ -4990,8 +5062,10 @@ bool mattack::bio_op_takedown( monster *z ) int dam = rng( 3, 9 ); if( foe == nullptr ) { // Handle mons earlier - less to check for - dam = rng( 6, 18 ); // Always aim for the torso - target->deal_damage( z, bp_torso, damage_instance( DT_BASH, dam ) ); // Two hits - "leg" and torso + dam = rng( 6, 18 ); + // Always aim for the torso + target->deal_damage( z, bp_torso, damage_instance( DT_BASH, dam ) ); + // Two hits - "leg" and torso target->deal_damage( z, bp_torso, damage_instance( DT_BASH, dam ) ); target->add_effect( effect_downed, 3_turns ); if( seen ) { @@ -5019,7 +5093,8 @@ bool mattack::bio_op_takedown( monster *z ) if( !target->is_immune_effect( effect_downed ) ) { if( one_in( 4 ) ) { hit = bp_head; - dam = rng( 9, 21 ); // 50% damage buff for the headshot. + // 50% damage buff for the headshot. + dam = rng( 9, 21 ); target->add_msg_if_player( m_bad, _( "and slams you, face first, to the ground for %d damage!" ), dam ); foe->deal_damage( z, hit, damage_instance( DT_BASH, dam ) ); diff --git a/src/mondeath.h b/src/mondeath.h index 7ba70daccb6d4..ac6c6ada367d5 100644 --- a/src/mondeath.h +++ b/src/mondeath.h @@ -6,45 +6,83 @@ class monster; namespace mdeath { -void normal( monster &z ); // Drop a body -void splatter( monster &z ); // Overkill splatter (also part of normal under conditions) -void acid( monster &z ); // Acid instead of a body -void boomer( monster &z ); // Explodes in vomit :3 -void boomer_glow( monster &z ); // Explodes in vomit :3 -void kill_vines( monster &z ); // Kill all nearby vines -void vine_cut( monster &z ); // Kill adjacent vine if it's cut -void triffid_heart( monster &z ); // Destroy all roots -void fungus( monster &z ); // Explodes in spores D: -void disintegrate( monster &z ); // Falls apart -void shriek( monster &z ); // Screams loudly -void howl( monster &z ); // Wolf's howling -void rattle( monster &z ); // Rattles like a rattlesnake -void worm( monster &z ); // Spawns 2 half-worms -void disappear( monster &z ); // Hallucination disappears -void guilt( monster &z ); // Morale penalty -void brainblob( monster &z ); // Frees blobs, redirects to blobsplit -void blobsplit( monster &z ); // Creates more blobs -void jackson( monster &z ); // Reverts dancers -void melt( monster &z ); // Normal death, but melts -void amigara( monster &z ); // Removes hypnosis if last one -void thing( monster &z ); // Turn into a full thing -void explode( monster &z ); // Damaging explosion -void focused_beam( monster &z ); // blinding ray -void broken( monster &z ); // Broken robot drop -void ratking( monster &z ); // Cure verminitis -void darkman( monster &z ); // sight returns to normal -void gas( monster &z ); // Explodes in toxic gas -void kill_breathers( monster &z );// All breathers die -void smokeburst( monster &z ); // Explode like a huge smoke bomb. -void fungalburst( monster &z ); // Explode releasing fungal haze. -void jabberwock( monster &z ); // Snicker-snack! -void detonate( monster &z ); // Take the enemy with you -void broken_ammo( monster &z ); // Breaks ammo and then itself -void preg_roach( monster &z ); // Spawns 1-3 roach nymphs -void fireball( monster &z ); // Explodes in fire -void conflagration( monster &z ); // Similar to above but bigger and guaranteed. +// Drop a body +void normal( monster &z ); +// Overkill splatter (also part of normal under conditions) +void splatter( monster &z ); +// Acid instead of a body +void acid( monster &z ); +// Explodes in vomit :3 +void boomer( monster &z ); +// Explodes in vomit :3 +void boomer_glow( monster &z ); +// Kill all nearby vines +void kill_vines( monster &z ); +// Kill adjacent vine if it's cut +void vine_cut( monster &z ); +// Destroy all roots +void triffid_heart( monster &z ); +// Explodes in spores D: +void fungus( monster &z ); +// Falls apart +void disintegrate( monster &z ); +// Screams loudly +void shriek( monster &z ); +// Wolf's howling +void howl( monster &z ); +// Rattles like a rattlesnake +void rattle( monster &z ); +// Spawns 2 half-worms +void worm( monster &z ); +// Hallucination disappears +void disappear( monster &z ); +// Morale penalty +void guilt( monster &z ); +// Frees blobs, redirects to blobsplit +void brainblob( monster &z ); +// Creates more blobs +void blobsplit( monster &z ); +// Reverts dancers +void jackson( monster &z ); +// Normal death, but melts +void melt( monster &z ); +// Removes hypnosis if last one +void amigara( monster &z ); +// Turn into a full thing +void thing( monster &z ); +// Damaging explosion +void explode( monster &z ); +// Blinding ray +void focused_beam( monster &z ); +// Broken robot drop +void broken( monster &z ); +// Cure verminitis +void ratking( monster &z ); +// Sight returns to normal +void darkman( monster &z ); +// Explodes in toxic gas +void gas( monster &z ); +// All breathers die +void kill_breathers( monster &z ); +// Explode like a huge smoke bomb. +void smokeburst( monster &z ); +// Explode releasing fungal haze. +void fungalburst( monster &z ); +// Snicker-snack! +void jabberwock( monster &z ); +// Take the enemy with you +void detonate( monster &z ); +// Breaks ammo and then itself +void broken_ammo( monster &z ); +// Spawns 1-3 roach nymphs +void preg_roach( monster &z ); +// Explodes in fire +void fireball( monster &z ); +// Similar to above but bigger and guaranteed. +void conflagration( monster &z ); -void gameover( monster &z ); // Game over! Defense mode +// Game over! Defense mode +void gameover( monster &z ); } //namespace mdeath void make_mon_corpse( monster &z, int damageLvl ); diff --git a/src/monmove.cpp b/src/monmove.cpp index 673b882e22900..d127ca252ec30 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -982,7 +982,8 @@ void monster::nursebot_operate( player *dragged_foe ) dragged_foe->setpos( goal ); - add_effect( effect_countdown, 2_turns );// there's still time to get away + // There's still time to get away + add_effect( effect_countdown, 2_turns ); add_msg( m_bad, _( "The %s produces a syringe full of some translucent liquid." ), name() ); } else if( g->critter_at( goal ) != nullptr && has_effect( effect_dragging ) ) { sounds::sound( pos(), 8, sounds::sound_t::electronic_speech, diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index fc64f2d0859f2..25a45d5833b6a 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -237,9 +237,11 @@ void MonsterGenerator::reset() static int calc_bash_skill( const mtype &t ) { - int ret = t.melee_dice * t.melee_sides; // IOW, the critter's max bashing damage + // IOW, the critter's max bashing damage + int ret = t.melee_dice * t.melee_sides; + // This is for stuff that goes through solid rock: minerbots, dark wyrms, etc if( t.has_flag( MF_BORES ) ) { - ret *= 15; // This is for stuff that goes through solid rock: minerbots, dark wyrms, etc + ret *= 15; } else if( t.has_flag( MF_DESTROYS ) ) { ret *= 2.5; } else if( !t.has_flag( MF_BASHES ) ) { @@ -354,7 +356,8 @@ void MonsterGenerator::finalize_mtypes() mon.armor_fire = 0; } - mon.hp = std::max( mon.hp, 1 ); // lower bound for hp scaling + // Lower bound for hp scaling + mon.hp = std::max( mon.hp, 1 ); finalize_pathfinding_settings( mon ); } @@ -407,47 +410,84 @@ void MonsterGenerator::init_phases() void MonsterGenerator::init_death() { - death_map["NORMAL"] = &mdeath::normal;// Drop a body - death_map["SPLATTER"] = &mdeath::splatter;//Explodes in gibs and chunks - death_map["ACID"] = &mdeath::acid;// Acid instead of a body - death_map["BOOMER"] = &mdeath::boomer;// Explodes in vomit :3 - death_map["BOOMER_GLOW"] = &mdeath::boomer_glow;// Explodes in glowing vomit :3 - death_map["KILL_VINES"] = &mdeath::kill_vines;// Kill all nearby vines - death_map["VINE_CUT"] = &mdeath::vine_cut;// Kill adjacent vine if it's cut - death_map["TRIFFID_HEART"] = &mdeath::triffid_heart;// Destroy all roots - death_map["FUNGUS"] = &mdeath::fungus;// Explodes in spores D: - death_map["DISINTEGRATE"] = &mdeath::disintegrate;// Falls apart - death_map["WORM"] = &mdeath::worm;// Spawns 2 half-worms - death_map["DISAPPEAR"] = &mdeath::disappear;// Hallucination disappears - death_map["GUILT"] = &mdeath::guilt;// Morale penalty - death_map["BRAINBLOB"] = &mdeath::brainblob;// Frees blobs, redirects to brainblob() - death_map["BLOBSPLIT"] = &mdeath::blobsplit;// Creates more blobs - death_map["JACKSON"] = &mdeath::jackson;// Reverts dancers - death_map["MELT"] = &mdeath::melt;// Normal death, but melts - death_map["AMIGARA"] = &mdeath::amigara;// Removes hypnosis if last one - death_map["THING"] = &mdeath::thing;// Turn into a full thing - death_map["EXPLODE"] = &mdeath::explode;// Damaging explosion - death_map["FOCUSEDBEAM"] = &mdeath::focused_beam;// Blinding ray - death_map["BROKEN"] = &mdeath::broken;// Spawns a broken robot. - death_map["RATKING"] = &mdeath::ratking;// Cure verminitis - death_map["DARKMAN"] = &mdeath::darkman;// sight returns to normal - death_map["GAS"] = &mdeath::gas;// Explodes in toxic gas - death_map["KILL_BREATHERS"] = &mdeath::kill_breathers;// All breathers die + // Drop a body + death_map["NORMAL"] = &mdeath::normal; + // Explodes in gibs and chunks + death_map["SPLATTER"] = &mdeath::splatter; + // Acid instead of a body + death_map["ACID"] = &mdeath::acid; + // Explodes in vomit :3 + death_map["BOOMER"] = &mdeath::boomer; + // Explodes in glowing vomit :3 + death_map["BOOMER_GLOW"] = &mdeath::boomer_glow; + // Kill all nearby vines + death_map["KILL_VINES"] = &mdeath::kill_vines; + // Kill adjacent vine if it's cut + death_map["VINE_CUT"] = &mdeath::vine_cut; + // Destroy all roots + death_map["TRIFFID_HEART"] = &mdeath::triffid_heart; + // Explodes in spores D: + death_map["FUNGUS"] = &mdeath::fungus; + // Falls apart + death_map["DISINTEGRATE"] = &mdeath::disintegrate; + // Spawns 2 half-worms + death_map["WORM"] = &mdeath::worm; + // Hallucination disappears + death_map["DISAPPEAR"] = &mdeath::disappear; + // Morale penalty + death_map["GUILT"] = &mdeath::guilt; + // Frees blobs, redirects to brainblob() + death_map["BRAINBLOB"] = &mdeath::brainblob; + // Creates more blobs + death_map["BLOBSPLIT"] = &mdeath::blobsplit; + // Reverts dancers + death_map["JACKSON"] = &mdeath::jackson; + // Normal death, but melts + death_map["MELT"] = &mdeath::melt; + // Removes hypnosis if last one + death_map["AMIGARA"] = &mdeath::amigara; + // Turn into a full thing + death_map["THING"] = &mdeath::thing; + // Damaging explosion + death_map["EXPLODE"] = &mdeath::explode; + // Blinding ray + death_map["FOCUSEDBEAM"] = &mdeath::focused_beam; + // Spawns a broken robot. + death_map["BROKEN"] = &mdeath::broken; + // Cure verminitis + death_map["RATKING"] = &mdeath::ratking; + // Sight returns to normal + death_map["DARKMAN"] = &mdeath::darkman; + // Explodes in toxic gas + death_map["GAS"] = &mdeath::gas; + // All breathers die + death_map["KILL_BREATHERS"] = &mdeath::kill_breathers; // Gives a message about destroying ammo and then calls "BROKEN" death_map["BROKEN_AMMO"] = &mdeath::broken_ammo; - death_map["SMOKEBURST"] = &mdeath::smokeburst;// Explode like a huge smoke bomb. - death_map["FUNGALBURST"] = &mdeath::fungalburst;// Explode with a cloud of fungal haze. - death_map["JABBERWOCKY"] = &mdeath::jabberwock; // Snicker-snack! - death_map["DETONATE"] = &mdeath::detonate; // Take them with you - death_map["GAMEOVER"] = &mdeath::gameover;// Game over! Defense mode - death_map["PREG_ROACH"] = &mdeath::preg_roach;// Spawn some cockroach nymphs - death_map["FIREBALL"] = &mdeath::fireball;// Explode in a fireball - death_map["CONFLAGRATION"] = &mdeath::conflagration; // Explode in a huge fireball + // Explode like a huge smoke bomb. + death_map["SMOKEBURST"] = &mdeath::smokeburst; + // Explode with a cloud of fungal haze. + death_map["FUNGALBURST"] = &mdeath::fungalburst; + // Snicker-snack! + death_map["JABBERWOCKY"] = &mdeath::jabberwock; + // Take them with you + death_map["DETONATE"] = &mdeath::detonate; + // Game over! Defense mode + death_map["GAMEOVER"] = &mdeath::gameover; + // Spawn some cockroach nymphs + death_map["PREG_ROACH"] = &mdeath::preg_roach; + // Explode in a fireball + death_map["FIREBALL"] = &mdeath::fireball; + // Explode in a huge fireball + death_map["CONFLAGRATION"] = &mdeath::conflagration; /* Currently Unimplemented */ - //death_map["SHRIEK"] = &mdeath::shriek;// Screams loudly - //death_map["HOWL"] = &mdeath::howl;// Wolf's howling - //death_map["RATTLE"] = &mdeath::rattle;// Rattles like a rattlesnake + // Screams loudly + //death_map["SHRIEK"] = &mdeath::shriek; + // Wolf's howling + //death_map["HOWL"] = &mdeath::howl; + // Rattles like a rattlesnake + //death_map["RATTLE"] = &mdeath::rattle; } void MonsterGenerator::init_attack() @@ -549,10 +589,14 @@ void MonsterGenerator::init_attack() void MonsterGenerator::init_defense() { - defense_map["NONE"] = &mdefense::none; //No special attack-back - defense_map["ZAPBACK"] = &mdefense::zapback; //Shock attacker on hit - defense_map["ACIDSPLASH"] = &mdefense::acidsplash; //Splash acid on the attacker - defense_map["RETURN_FIRE"] = &mdefense::return_fire; //Blind fire on unseen attacker + // No special attack-back + defense_map["NONE"] = &mdefense::none; + // Shock attacker on hit + defense_map["ZAPBACK"] = &mdefense::zapback; + // Splash acid on the attacker + defense_map["ACIDSPLASH"] = &mdefense::acidsplash; + // Blind fire on unseen attacker + defense_map["RETURN_FIRE"] = &mdefense::return_fire; } void MonsterGenerator::set_species_ids( mtype &mon ) diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 33e1bda363c0d..5b8e9b58c3945 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -680,9 +680,10 @@ void npc::move() } regen_ai_cache(); adjust_power_cbms(); + // NPCs under operation should just stay still if( activity.id() == "ACT_OPERATION" ) { execute_action( npc_player_activity ); - return;// NPCs under operation should just stay still + return; } npc_action action = npc_undecided; diff --git a/src/player.h b/src/player.h index 469ebf77180a1..aa0456f584663 100644 --- a/src/player.h +++ b/src/player.h @@ -1170,7 +1170,8 @@ class player : public Character int blocks_left; int cash; int movecounter; - bool death_drops;// Turned to false for simulating NPCs on distant missions so they don't drop all their gear in sight + // Turned to false for simulating NPCs on distant missions so they don't drop all their gear in sight + bool death_drops; bool reach_attacking = false; bool manual_examine = false;