From d181b0c4477d9e9d1eaac62297f3eedfa18539bc Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 19 Feb 2020 08:55:19 -0500 Subject: [PATCH] Move more string consts --- src/activity_handlers.cpp | 6 +- src/cata_string_consts.h | 26 ++++--- src/character.cpp | 2 +- src/item.cpp | 2 +- src/melee.cpp | 152 +++++++++++++------------------------- src/mondeath.cpp | 18 ++--- src/player.cpp | 4 +- 7 files changed, 83 insertions(+), 127 deletions(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 506bc1952fdaf..cc864a6b4a691 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -500,9 +500,9 @@ static void set_up_butchery( player_activity &act, player &u, butcher_type actio // applies to all butchery actions const bool is_human = corpse.id == mtype_id::NULL_ID() || ( corpse.in_species( HUMAN ) && !corpse.in_species( ZOMBIE ) ); - if( is_human && !( u.has_trait_flag( trait_flag_CANNIBAL ) || - u.has_trait_flag( trait_flag_PSYCHOPATH ) || - u.has_trait_flag( trait_flag_SAPIOVORE ) ) ) { + if( is_human && !( u.has_trait_flag( flag_CANNIBAL ) || + u.has_trait_flag( flag_PSYCHOPATH ) || + u.has_trait_flag( flag_SAPIOVORE ) ) ) { if( u.is_player() ) { if( query_yn( _( "Would you dare desecrate the mortal remains of a fellow human being?" ) ) ) { diff --git a/src/cata_string_consts.h b/src/cata_string_consts.h index cda318081a5ff..6ae8e3a5255ba 100644 --- a/src/cata_string_consts.h +++ b/src/cata_string_consts.h @@ -400,6 +400,7 @@ static const efftype_id effect_weed_high( "weed_high" ); static const efftype_id effect_winded( "winded" ); static const efftype_id effect_zapped( "zapped" ); + static const trait_id trait_ACIDBLOOD( "ACIDBLOOD" ); static const trait_id trait_ACIDPROOF( "ACIDPROOF" ); static const trait_id trait_ADDICTIVE( "ADDICTIVE" ); @@ -719,11 +720,6 @@ static const trait_id trait_WOOLALLERGY( "WOOLALLERGY" ); static const trait_id trait_XS( "XS" ); static const trait_id trait_XXXL( "XXXL" ); -static const trait_id debug_nodmg( "DEBUG_NODMG" ); - -static const std::string trait_flag_CANNIBAL( "CANNIBAL" ); -static const std::string trait_flag_PSYCHOPATH( "PSYCHOPATH" ); -static const std::string trait_flag_SAPIOVORE( "SAPIOVORE" ); static const mongroup_id GROUP_BLOB( "GROUP_BLOB" ); static const mongroup_id GROUP_BREATHER( "GROUP_BREATHER" ); @@ -966,6 +962,7 @@ static const std::string flag_CAMERA( "CAMERA" ); static const std::string flag_CAMERA_CONTROL( "CAMERA_CONTROL" ); static const std::string flag_CAMERA_PRO( "CAMERA_PRO" ); static const std::string flag_CAN_SIT( "CAN_SIT" ); +static const std::string flag_CANNIBAL( "CANNIBAL" ); static const std::string flag_CANNIBALISM( "CANNIBALISM" ); static const std::string flag_CARNIVORE_OK( "CARNIVORE_OK" ); static const std::string flag_CASING( "CASING" ); @@ -1146,9 +1143,14 @@ static const std::string flag_PLOWABLE( "PLOWABLE" ); static const std::string flag_POCKETS( "POCKETS" ); static const std::string flag_POWERARMOR_COMPATIBLE( "POWERARMOR_COMPATIBLE" ); static const std::string flag_POWERED( "POWERED" ); +static const std::string flag_PRED1( "PRED1" ); +static const std::string flag_PRED2( "PRED2" ); +static const std::string flag_PRED3( "PRED3" ); +static const std::string flag_PRED4( "PRED4" ); static const std::string flag_PRIMITIVE_RANGED_WEAPON( "PRIMITIVE_RANGED_WEAPON" ); static const std::string flag_PROCESSING( "PROCESSING" ); static const std::string flag_PROCESSING_RESULT( "PROCESSING_RESULT" ); +static const std::string flag_PSYCHOPATH( "PSYCHOPATH" ); static const std::string flag_PULPED( "PULPED" ); static const std::string flag_PUMP_ACTION( "PUMP_ACTION" ); static const std::string flag_PUMP_RAIL_COMPATIBLE( "PUMP_RAIL_COMPATIBLE" ); @@ -1186,6 +1188,7 @@ static const std::string flag_RUBBLE( "RUBBLE" ); static const std::string flag_SAFE_FUEL_OFF( "SAFE_FUEL_OFF" ); static const std::string flag_SAFECRACK( "SAFECRACK" ); static const std::string flag_SALT_WATER( "SALT_WATER" ); +static const std::string flag_SAPIOVORE( "SAPIOVORE" ); static const std::string flag_SEALED( "SEALED" ); static const std::string flag_SECRET( "SECRET" ); static const std::string flag_SEMITANGIBLE( "SEMITANGIBLE" ); @@ -1383,11 +1386,14 @@ static const species_id ROBOT( "ROBOT" ); static const species_id SPIDER( "SPIDER" ); static const species_id ZOMBIE( "ZOMBIE" ); -static const matec_id tec_none( "tec_none" ); -static const matec_id WBLOCK_1( "WBLOCK_1" ); -static const matec_id WBLOCK_2( "WBLOCK_2" ); -static const matec_id WBLOCK_3( "WBLOCK_3" ); -static const matec_id WHIP_DISARM( "WHIP_DISARM" ); +static const matec_id matec_no_technique_id( "" ); +static const matec_id matec_RAPID( "RAPID" ); +static const matec_id matec_tec_none( "tec_none" ); +static const matec_id matec_VORPAL( "VORPAL" ); +static const matec_id matec_WBLOCK_1( "WBLOCK_1" ); +static const matec_id matec_WBLOCK_2( "WBLOCK_2" ); +static const matec_id matec_WBLOCK_3( "WBLOCK_3" ); +static const matec_id matec_WHIP_DISARM( "WHIP_DISARM" ); static const ter_str_id ter_dirt( "t_dirt" ); static const ter_str_id ter_grass_dead( "t_grass_dead" ); diff --git a/src/character.cpp b/src/character.cpp index c49a18314e3a5..68ab2f398fb4f 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -5376,7 +5376,7 @@ nc_color Character::symbol_color() const bool Character::is_immune_field( const field_type_id &fid ) const { // Obviously this makes us invincible - if( has_trait( debug_nodmg ) ) { + if( has_trait( trait_DEBUG_NODMG ) ) { return true; } // Check to see if we are immune diff --git a/src/item.cpp b/src/item.cpp index f4c867a691acb..a2eeb3cd7edd8 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1438,7 +1438,7 @@ void item::food_info( const item *food_item, std::vector &info, if( food_item->has_flag( flag_CANNIBALISM ) && parts->test( iteminfo_parts::FOOD_CANNIBALISM ) ) { - if( !g->u.has_trait_flag( trait_flag_CANNIBAL ) ) { + if( !g->u.has_trait_flag( flag_CANNIBAL ) ) { info.emplace_back( "DESCRIPTION", _( "* This food contains human flesh." ) ); } else { diff --git a/src/melee.cpp b/src/melee.cpp index 5d6633a510d1b..db8bc2be63f3e 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -56,54 +56,7 @@ #include "vehicle.h" #include "vpart_position.h" #include "mapdata.h" - -static const bionic_id bio_cqb( "bio_cqb" ); -static const bionic_id bio_memory( "bio_memory" ); - -static const matec_id tec_none( "tec_none" ); -static const matec_id WBLOCK_1( "WBLOCK_1" ); -static const matec_id WBLOCK_2( "WBLOCK_2" ); -static const matec_id WBLOCK_3( "WBLOCK_3" ); - -static const skill_id skill_stabbing( "stabbing" ); -static const skill_id skill_cutting( "cutting" ); -static const skill_id skill_unarmed( "unarmed" ); -static const skill_id skill_bashing( "bashing" ); -static const skill_id skill_melee( "melee" ); - -static const efftype_id effect_badpoison( "badpoison" ); -static const efftype_id effect_beartrap( "beartrap" ); -static const efftype_id effect_bouldering( "bouldering" ); -static const efftype_id effect_contacts( "contacts" ); -static const efftype_id effect_downed( "downed" ); -static const efftype_id effect_drunk( "drunk" ); -static const efftype_id effect_grabbed( "grabbed" ); -static const efftype_id effect_grabbing( "grabbing" ); -static const efftype_id effect_heavysnare( "heavysnare" ); -static const efftype_id effect_hit_by_player( "hit_by_player" ); -static const efftype_id effect_lightsnare( "lightsnare" ); -static const efftype_id effect_narcosis( "narcosis" ); -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_RETRACT( "CLAWS_RETRACT" ); -static const trait_id trait_CLAWS_ST( "CLAWS_ST" ); -static const trait_id trait_CLAWS_TENTACLE( "CLAWS_TENTACLE" ); -static const trait_id trait_CLUMSY( "CLUMSY" ); -static const trait_id trait_DEBUG_NIGHTVISION( "DEBUG_NIGHTVISION" ); -static const trait_id trait_DEFT( "DEFT" ); -static const trait_id trait_DRUNKEN( "DRUNKEN" ); -static const trait_id trait_HYPEROPIC( "HYPEROPIC" ); -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_THORNS( "THORNS" ); - -static const efftype_id effect_amigara( "amigara" ); - -static const species_id HUMAN( "HUMAN" ); +#include "cata_string_consts.h" void player_hit_message( player *attacker, const std::string &message, Creature &t, int dam, bool crit = false ); @@ -142,7 +95,7 @@ bool Character::is_armed() const bool Character::unarmed_attack() const { const item &weap = used_weapon(); - return weap.is_null() || weap.has_flag( "UNARMED_WEAPON" ); + return weap.is_null() || weap.has_flag( flag_UNARMED_WEAPON ); } bool player::handle_melee_wear( item &shield, float wear_multiplier ) @@ -156,7 +109,7 @@ bool player::handle_melee_wear( item &shield, float wear_multiplier ) } // UNBREAKABLE_MELEE items can't be damaged through melee combat usage. - if( shield.has_flag( "UNBREAKABLE_MELEE" ) ) { + if( shield.has_flag( flag_UNBREAKABLE_MELEE ) ) { return false; } @@ -174,7 +127,7 @@ bool player::handle_melee_wear( item &shield, float wear_multiplier ) itype_id weak_comp; itype_id big_comp = "null"; // Fragile items that fall apart easily when used as a weapon due to poor construction quality - if( shield.has_flag( "FRAGILE_MELEE" ) ) { + if( shield.has_flag( flag_FRAGILE_MELEE ) ) { const float fragile_factor = 6; int weak_chip = INT_MAX; units::volume big_vol = 0_ml; @@ -204,7 +157,7 @@ bool player::handle_melee_wear( item &shield, float wear_multiplier ) int damage_chance = static_cast( stat_factor * material_factor / wear_multiplier ); // DURABLE_MELEE items are made to hit stuff and they do it well, so they're considered to be a lot tougher // than other weapons made of the same materials. - if( shield.has_flag( "DURABLE_MELEE" ) ) { + if( shield.has_flag( flag_DURABLE_MELEE ) ) { damage_chance *= 4; } @@ -240,7 +193,7 @@ bool player::handle_melee_wear( item &shield, float wear_multiplier ) remove_item( shield ); // Breakdown fragile weapons into components - if( temp.has_flag( "FRAGILE_MELEE" ) && !temp.components.empty() ) { + if( temp.has_flag( flag_FRAGILE_MELEE ) && !temp.components.empty() ) { add_msg_player_or_npc( m_bad, _( "Your %s breaks apart!" ), _( "'s %s breaks apart!" ), str ); @@ -381,8 +334,7 @@ static void melee_train( player &p, int lo, int hi, const item &weap ) void player::melee_attack( Creature &t, bool allow_special ) { - static const matec_id no_technique_id( "" ); - melee_attack( t, allow_special, no_technique_id ); + melee_attack( t, allow_special, matec_no_technique_id ); } // Melee calculation is in parts. This sets up the attack, then in deal_melee_attack, @@ -484,20 +436,20 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc } else if( has_force_technique ) { technique_id = force_technique; } else { - technique_id = tec_none; + technique_id = matec_tec_none; } // if you have two broken arms you aren't doing any martial arts // and your hits are not going to hurt very much if( get_working_arm_count() < 1 ) { - technique_id = tec_none; + technique_id = matec_tec_none; d.mult_damage( 0.1 ); } const ma_technique &technique = technique_id.obj(); // Handles effects as well; not done in melee_affect_* - if( technique.id != tec_none ) { + if( technique.id != matec_tec_none ) { perform_technique( technique, t, d, move_cost ); } @@ -599,10 +551,10 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc void player::reach_attack( const tripoint &p ) { - matec_id force_technique = tec_none; + matec_id force_technique = matec_tec_none; /** @EFFECT_MELEE >5 allows WHIP_DISARM technique */ - if( weapon.has_flag( "WHIP" ) && ( get_skill_level( skill_melee ) > 5 ) && one_in( 3 ) ) { - force_technique = matec_id( "WHIP_DISARM" ); + if( weapon.has_flag( flag_WHIP ) && ( get_skill_level( skill_melee ) > 5 ) && one_in( 3 ) ) { + force_technique = matec_WHIP_DISARM; } Creature *critter = g->critter_at( p ); @@ -629,8 +581,8 @@ void player::reach_attack( const tripoint &p ) /** @EFFECT_STABBING increases ability to reach attack through fences */ } else if( g->m.impassable( p ) && // Fences etc. Spears can stab through those - !( weapon.has_flag( "SPEAR" ) && - g->m.has_flag( "THIN_OBSTACLE", p ) && + !( weapon.has_flag( flag_SPEAR ) && + g->m.has_flag( flag_THIN_OBSTACLE, p ) && x_in_y( skill, 10 ) ) ) { /** @EFFECT_STR increases bash effects when reach attacking past something */ g->m.bash( p, str_cur + weapon.damage_melee( DT_BASH ) ); @@ -759,7 +711,7 @@ float player::get_dodge() const { //If we're asleep or busy we can't dodge if( in_sleep_state() || has_effect( effect_narcosis ) || - has_effect( efftype_id( "winded" ) ) ) { + has_effect( effect_winded ) ) { return 0.0f; } @@ -783,9 +735,9 @@ float player::get_dodge() const } } - if( worn_with_flag( "ROLLER_INLINE" ) || - worn_with_flag( "ROLLER_QUAD" ) || - worn_with_flag( "ROLLER_ONE" ) ) { + if( worn_with_flag( flag_ROLLER_INLINE ) || + worn_with_flag( flag_ROLLER_QUAD ) || + worn_with_flag( flag_ROLLER_ONE ) ) { ret /= has_trait( trait_PROF_SKATER ) ? 2 : 5; } @@ -862,12 +814,12 @@ void player::roll_bash_damage( bool crit, damage_instance &di, bool average, if( left_empty || right_empty ) { float per_hand = 0.0f; for( const std::pair< const trait_id, trait_data > &mut : my_mutations ) { - if( mut.first->flags.count( "NEED_ACTIVE_TO_MELEE" ) > 0 && !has_active_mutation( mut.first ) ) { + if( mut.first->flags.count( flag_NEED_ACTIVE_TO_MELEE ) > 0 && !has_active_mutation( mut.first ) ) { continue; } float unarmed_bonus = 0.0f; const int bash_bonus = mut.first->bash_dmg_bonus; - if( mut.first->flags.count( "UNARMED_BONUS" ) > 0 && bash_bonus > 0 ) { + if( mut.first->flags.count( flag_UNARMED_BONUS ) > 0 && bash_bonus > 0 ) { unarmed_bonus += std::min( get_skill_level( skill_unarmed ) / 2, 4 ); } per_hand += bash_bonus + unarmed_bonus; @@ -942,16 +894,16 @@ void player::roll_cut_damage( bool crit, damage_instance &di, bool average, cons weap.is_null(); if( left_empty || right_empty ) { float per_hand = 0.0f; - if( has_bionic( bionic_id( "bio_razors" ) ) ) { + if( has_bionic( bio_razors ) ) { per_hand += 2; } for( const std::pair< const trait_id, trait_data > &mut : my_mutations ) { - if( mut.first->flags.count( "NEED_ACTIVE_TO_MELEE" ) > 0 && !has_active_mutation( mut.first ) ) { + if( mut.first->flags.count( flag_NEED_ACTIVE_TO_MELEE ) > 0 && !has_active_mutation( mut.first ) ) { continue; } float unarmed_bonus = 0.0f; const int cut_bonus = mut.first->cut_dmg_bonus; - if( mut.first->flags.count( "UNARMED_BONUS" ) > 0 && cut_bonus > 0 ) { + if( mut.first->flags.count( flag_UNARMED_BONUS ) > 0 && cut_bonus > 0 ) { unarmed_bonus += std::min( get_skill_level( skill_unarmed ) / 2, 4 ); } per_hand += cut_bonus + unarmed_bonus; @@ -1021,7 +973,7 @@ void player::roll_stab_damage( bool crit, damage_instance &di, bool average, per_hand += .5; } - if( has_bionic( bionic_id( "bio_razors" ) ) ) { + if( has_bionic( bio_razors ) ) { per_hand += 2; } @@ -1168,7 +1120,7 @@ matec_id player::pick_technique( Creature &t, const item &weap, } } - return random_entry( possible, tec_none ); + return random_entry( possible, matec_tec_none ); } bool player::valid_aoe_technique( Creature &t, const ma_technique &technique ) @@ -1396,7 +1348,7 @@ void player::perform_technique( const ma_technique &technique, Creature &t, dama if( technique.knockback_follow ) { const optional_vpart_position vp0 = g->m.veh_at( pos() ); vehicle *const veh0 = veh_pointer_or_null( vp0 ); - bool to_swimmable = g->m.has_flag( "SWIMMABLE", prev_pos ); + bool to_swimmable = g->m.has_flag( flag_SWIMMABLE, prev_pos ); bool to_deepwater = g->m.has_flag( TFLAG_DEEP_WATER, prev_pos ); // Check if it's possible to move to the new tile @@ -1477,7 +1429,7 @@ void player::perform_technique( const ma_technique &technique, Creature &t, dama if( has_active_bionic( bio_cqb ) && !martial_arts_data.knows_selected_style() ) { /** @EFFECT_INT slightly increases chance to learn techniques when using CQB bionic */ // Enhanced Memory Banks bionic doubles chance to learn martial art - const int bionic_boost = has_active_bionic( bionic_id( bio_memory ) ) ? 2 : 1; + const int bionic_boost = has_active_bionic( bio_memory ) ? 2 : 1; if( one_in( ( 1400 - ( get_int() * 50 ) ) / bionic_boost ) ) { martial_arts_data.learn_current_style_CQB( is_player() ); } @@ -1487,13 +1439,13 @@ void player::perform_technique( const ma_technique &technique, Creature &t, dama static int blocking_ability( const item &shield ) { int block_bonus = 0; - if( shield.has_technique( WBLOCK_3 ) ) { + if( shield.has_technique( matec_WBLOCK_3 ) ) { block_bonus = 10; - } else if( shield.has_technique( WBLOCK_2 ) ) { + } else if( shield.has_technique( matec_WBLOCK_2 ) ) { block_bonus = 6; - } else if( shield.has_technique( WBLOCK_1 ) ) { + } else if( shield.has_technique( matec_WBLOCK_1 ) ) { block_bonus = 4; - } else if( shield.has_flag( "BLOCK_WHILE_WORN" ) ) { + } else if( shield.has_flag( flag_BLOCK_WHILE_WORN ) ) { block_bonus = 2; } return block_bonus; @@ -1507,7 +1459,7 @@ item &player::best_shield() best_value = best_value == 2 ? 0 : best_value; item *best = best_value > 0 ? &weapon : &null_item_reference(); for( item &shield : worn ) { - if( shield.has_flag( "BLOCK_WHILE_WORN" ) && blocking_ability( shield ) >= best_value ) { + if( shield.has_flag( flag_BLOCK_WHILE_WORN ) && blocking_ability( shield ) >= best_value ) { best = &shield; } } @@ -1522,7 +1474,7 @@ bool player::block_hit( Creature *source, body_part &bp_hit, damage_instance &da // TODO: It should probably be moved to the section that regenerates blocks // and to effects that disallow blocking if( blocks_left < 1 || in_sleep_state() || has_effect( effect_narcosis ) || - has_effect( efftype_id( "winded" ) ) ) { + has_effect( effect_winded ) ) { return false; } blocks_left--; @@ -1537,7 +1489,7 @@ bool player::block_hit( Creature *source, body_part &bp_hit, damage_instance &da // Extract this to make it easier to implement shields/multiwield later item &shield = best_shield(); bool conductive_shield = shield.conductive(); - bool unarmed = shield.has_flag( "UNARMED_WEAPON" ); + bool unarmed = shield.has_flag( flag_UNARMED_WEAPON ); // This gets us a number between: // str ~0 + skill 0 = 0 @@ -1686,7 +1638,7 @@ bool player::block_hit( Creature *source, body_part &bp_hit, damage_instance &da // Check if we have any block counters matec_id tec = pick_technique( *source, shield, false, false, true ); - if( tec != tec_none && !is_dead_state() ) { + if( tec != matec_tec_none && !is_dead_state() ) { if( get_stamina() < get_stamina_max() / 3 ) { add_msg( m_bad, _( "You try to counterattack but you are too exhausted!" ) ); } else if( weapon.made_of( material_id( "glass" ) ) ) { @@ -1732,7 +1684,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item std::string target = t.disp_name(); - if( has_active_bionic( bionic_id( "bio_shock" ) ) && get_power_level() >= 2_kJ && + if( has_active_bionic( bio_shock ) && get_power_level() >= 2_kJ && ( !is_armed() || weapon.conductive() ) ) { mod_power_level( -2_kJ ); d.add_damage( DT_ELECTRIC, rng( 2, 10 ) ); @@ -1744,7 +1696,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item } } - if( has_active_bionic( bionic_id( "bio_heat_absorb" ) ) && !is_armed() && t.is_warm() ) { + if( has_active_bionic( bio_heat_absorb ) && !is_armed() && t.is_warm() ) { mod_power_level( 3_kJ ); d.add_damage( DT_COLD, 3 ); if( is_player() ) { @@ -1754,7 +1706,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item } } - if( weapon.has_flag( "FLAMING" ) ) { + if( weapon.has_flag( flag_FLAMING ) ) { d.add_damage( DT_HEAT, rng( 1, 8 ) ); if( is_player() ) { @@ -1765,7 +1717,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item } //Hurting the wielder from poorly-chosen weapons - if( weap.has_flag( "HURT_WHEN_WIELDED" ) && x_in_y( 2, 3 ) ) { + if( weap.has_flag( flag_HURT_WHEN_WIELDED ) && x_in_y( 2, 3 ) ) { add_msg_if_player( m_bad, _( "The %s cuts your hand!" ), weap.tname() ); deal_damage( nullptr, bp_hand_r, damage_instance::physical( 0, weap.damage_melee( DT_CUT ), 0 ) ); if( weap.is_two_handed( *this ) ) { // Hurt left hand too, if it was big @@ -1814,7 +1766,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item static damage_instance hardcoded_mutation_attack( const player &u, const trait_id &id ) { - if( id == "BEAK_PECK" ) { + if( id == trait_BEAK_PECK ) { // method open to improvement, please feel free to suggest // a better way to simulate target's anti-peck efforts /** @EFFECT_DEX increases number of hits with BEAK_PECK */ @@ -1825,15 +1777,15 @@ static damage_instance hardcoded_mutation_attack( const player &u, const trait_i return damage_instance::physical( 0, 0, num_hits * 10 ); } - if( id == "ARM_TENTACLES" || id == "ARM_TENTACLES_4" || id == "ARM_TENTACLES_8" ) { + if( id == trait_ARM_TENTACLES || id == trait_ARM_TENTACLES_4 || id == trait_ARM_TENTACLES_8 ) { int num_attacks = 1; - if( id == "ARM_TENTACLES_4" ) { + if( id == trait_ARM_TENTACLES_4 ) { num_attacks = 3; - } else if( id == "ARM_TENTACLES_8" ) { + } else if( id == trait_ARM_TENTACLES_8 ) { num_attacks = 7; } // Note: we're counting arms, so we want wielded item here, not weapon used for attack - if( u.weapon.is_two_handed( u ) || !u.has_two_arms() || u.worn_with_flag( "RESTRICT_HANDS" ) ) { + if( u.weapon.is_two_handed( u ) || !u.has_two_arms() || u.worn_with_flag( flag_RESTRICT_HANDS ) ) { num_attacks--; } @@ -1854,8 +1806,8 @@ static damage_instance hardcoded_mutation_attack( const player &u, const trait_i return ret; } - if( id == "VINES2" || id == "VINES3" ) { - const int num_attacks = id == "VINES2" ? 2 : 3; + if( id == trait_VINES2 || id == trait_VINES3 ) { + const int num_attacks = id == trait_VINES2 ? 2 : 3; /** @EFFECT_STR increases damage with VINES* */ damage_instance ret; ret.add_damage( DT_BASH, u.get_str() / 2.0f, 0, 1.0f, num_attacks ); @@ -1872,7 +1824,7 @@ std::vector player::mutation_attacks( Creature &t ) const std::string target = t.disp_name(); - const auto usable_body_parts = exclusive_flag_coverage( "ALLOWS_NATURAL_ATTACKS" ); + const auto usable_body_parts = exclusive_flag_coverage( flag_ALLOWS_NATURAL_ATTACKS ); const int unarmed = get_skill_level( skill_unarmed ); for( const auto &pr : my_mutations ) { @@ -2018,7 +1970,7 @@ std::string melee_message( const ma_technique &tec, player &p, const dealt_damag const int cut_dam = ddi.type_damage( DT_CUT ); const int stab_dam = ddi.type_damage( DT_STAB ); - if( tec.id != tec_none ) { + if( tec.id != matec_tec_none ) { std::string message; if( p.is_npc() ) { message = _( tec.npc_message ); @@ -2128,7 +2080,7 @@ void player_hit_message( player *attacker, const std::string &message, int player::attack_speed( const item &weap ) const { const int base_move_cost = weap.attack_time() / 2; - const int melee_skill = has_active_bionic( bionic_id( bio_cqb ) ) ? BIO_CQB_LEVEL : get_skill_level( + const int melee_skill = has_active_bionic( bio_cqb ) ? BIO_CQB_LEVEL : get_skill_level( skill_melee ); /** @EFFECT_MELEE increases melee attack speed */ const int skill_cost = static_cast( ( base_move_cost * ( 15 - melee_skill ) / 15 ) ); @@ -2207,8 +2159,8 @@ double player::melee_value( const item &weap ) const } int move_cost = attack_speed( weap ); - static const matec_id rapid_strike( "RAPID" ); - if( weap.has_technique( rapid_strike ) ) { + + if( weap.has_technique( matec_RAPID ) ) { move_cost /= 2; avg_dmg *= 0.66; } diff --git a/src/mondeath.cpp b/src/mondeath.cpp index 3571cdf0a129c..fa0ffa96ac00f 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -189,7 +189,7 @@ void mdeath::splatter( monster &z ) item corpse = item::make_corpse( z.type->id, calendar::turn, z.unique_name, z.get_upgrade_time() ); // Set corpse to damage that aligns with being pulped corpse.set_damage( 4000 ); - corpse.set_flag( "GIBBED" ); + corpse.set_flag( flag_GIBBED ); if( z.has_effect( effect_no_ammo ) ) { corpse.set_var( "no_ammo", "no_ammo" ); } @@ -381,8 +381,8 @@ void mdeath::guilt( monster &z ) guilt_tresholds[50] = _( "You regret killing %s." ); guilt_tresholds[25] = _( "You feel remorse for killing %s." ); - if( g->u.has_trait( trait_PSYCHOPATH ) || g->u.has_trait_flag( "PRED3" ) || - g->u.has_trait_flag( "PRED4" ) || g->u.has_trait( trait_KILLER ) ) { + if( g->u.has_trait( trait_PSYCHOPATH ) || g->u.has_trait_flag( flag_PRED3 ) || + g->u.has_trait_flag( flag_PRED4 ) || g->u.has_trait( trait_KILLER ) ) { return; } if( rl_dist( z.pos(), g->u.pos() ) > MAX_GUILT_DISTANCE ) { @@ -401,7 +401,7 @@ void mdeath::guilt( monster &z ) "about their deaths anymore." ), z.name( maxKills ) ); } return; - } else if( ( g->u.has_trait_flag( "PRED1" ) ) || ( g->u.has_trait_flag( "PRED2" ) ) ) { + } else if( ( g->u.has_trait_flag( flag_PRED1 ) ) || ( g->u.has_trait_flag( flag_PRED2 ) ) ) { msg = ( _( "Culling the weak is distasteful, but necessary." ) ); msgtype = m_neutral; } else { @@ -424,9 +424,9 @@ void mdeath::guilt( monster &z ) moraleMalus /= 10; if( g->u.has_trait( trait_PACIFIST ) ) { moraleMalus *= 5; - } else if( g->u.has_trait_flag( "PRED1" ) ) { + } else if( g->u.has_trait_flag( flag_PRED1 ) ) { moraleMalus /= 4; - } else if( g->u.has_trait_flag( "PRED2" ) ) { + } else if( g->u.has_trait_flag( flag_PRED2 ) ) { moraleMalus /= 5; } } @@ -700,17 +700,17 @@ void mdeath::jabberwock( monster &z ) player *ch = dynamic_cast( z.get_killer() ); bool vorpal = ch && ch->is_player() && - ch->weapon.has_flag( "DIAMOND" ) && + ch->weapon.has_flag( flag_DIAMOND ) && ch->weapon.volume() > 750_ml; - if( vorpal && !ch->weapon.has_technique( matec_id( "VORPAL" ) ) ) { + if( vorpal && !ch->weapon.has_technique( matec_VORPAL ) ) { if( ch->sees( z ) ) { ch->add_msg_if_player( m_info, //~ %s is the possessive form of the monster's name _( "As the flames in %s eyes die out, your weapon seems to shine slightly brighter." ), z.disp_name( true ) ); } - ch->weapon.add_technique( matec_id( "VORPAL" ) ); + ch->weapon.add_technique( matec_VORPAL ); } mdeath::normal( z ); diff --git a/src/player.cpp b/src/player.cpp index 32e0a66ccb478..055cb5a243772 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1220,8 +1220,6 @@ bool player::is_dead_state() const void player::on_dodge( Creature *source, float difficulty ) { - static const matec_id tec_none( "tec_none" ); - // Each avoided hit consumes an available dodge // When no more available we are likely to fail player::dodge_roll dodges_left--; @@ -1242,7 +1240,7 @@ void player::on_dodge( Creature *source, float difficulty ) if( source && square_dist( pos(), source->pos() ) == 1 ) { matec_id tec = pick_technique( *source, used_weapon(), false, true, false ); - if( tec != tec_none && !is_dead_state() ) { + if( tec != matec_tec_none && !is_dead_state() ) { if( get_stamina() < get_stamina_max() / 3 ) { add_msg( m_bad, _( "You try to counterattack but you are too exhausted!" ) ); } else {