diff --git a/data/json/items/tool/science.json b/data/json/items/tool/science.json index 7958465f0a7ea..7c4ed25576bea 100644 --- a/data/json/items/tool/science.json +++ b/data/json/items/tool/science.json @@ -1317,25 +1317,10 @@ ], "name": { "str_sp": "Mi-go Biotech" }, "conditional_names": [ - { "type": "VAR", "condition": "npctalk_var_mbt_f_function", "value": "morale", "name": { "str_sp": "%s (happy)" } }, - { - "type": "VAR", - "condition": "npctalk_var_mbt_f_function", - "value": "focus", - "name": { "str_sp": "%s (focus)" } - }, - { - "type": "VAR", - "condition": "npctalk_var_mbt_f_function", - "value": "pain", - "name": { "str_sp": "%s (pain relief)" } - }, - { - "type": "VAR", - "condition": "npctalk_var_mbt_f_function", - "value": "sleepiness", - "name": { "str_sp": "%s (wake up)" } - } + { "type": "VAR", "condition": "mbt_f_function", "value": "morale", "name": { "str_sp": "%s (happy)" } }, + { "type": "VAR", "condition": "mbt_f_function", "value": "focus", "name": { "str_sp": "%s (focus)" } }, + { "type": "VAR", "condition": "mbt_f_function", "value": "pain", "name": { "str_sp": "%s (pain relief)" } }, + { "type": "VAR", "condition": "mbt_f_function", "value": "sleepiness", "name": { "str_sp": "%s (wake up)" } } ], "description": "A piece of mi-go biotechnology.", "material": [ "alien_resin" ], diff --git a/data/json/npcs/isolated_road/isolated_road_jay_convert.json b/data/json/npcs/isolated_road/isolated_road_jay_convert.json index cdb2133865138..a3116f2916646 100644 --- a/data/json/npcs/isolated_road/isolated_road_jay_convert.json +++ b/data/json/npcs/isolated_road/isolated_road_jay_convert.json @@ -307,8 +307,8 @@ }, { "type": "var_migration", - "from": "npctalk_var_number_artisans_gunsmith_ammo_ammount", - "to": "npctalk_var_number_artisans_gunsmith_ammo_amount" + "from": "number_artisans_gunsmith_ammo_ammount", + "to": "number_artisans_gunsmith_ammo_amount" }, { "id": "TALK_GUNSMITH_BULLET_PICKUP", diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index 5cbac8af44dbe..ff3c58ced9f00 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -3973,7 +3973,7 @@ The `conditional_names` field allows defining alternate names for items that wil }, { "type": "VAR", - "condition": "npctalk_var_DISPLAY_NAME_MORALE", + "condition": "DISPLAY_NAME_MORALE", "name": { "str_sp": "%s (morale)" }, "value" : "true" }, @@ -3992,7 +3992,7 @@ You can list as many conditional names for a given item as you want. Each condit - `COMPONENT_ID` Similar to `COMPONENT_ID_SUBSTRING`, but search the exact component match - `FLAG` which checks if an item has the specified flag (exact match). - `VITAMIN` which checks if an item has the specified vitamin (exact match). - - `VAR` which checks if an item has a variable with the given name (exact match) and value = `value`. Variables set with effect_on_conditions will have `npctalk_var_` in front of their name. So a variable created with: `"npc_add_var": "MORALE", "value": "Felt Great" }` would be named: `npctalk_var_MORALE`. + - `VAR` which checks if an item has a variable with the given name (exact match) and value = `value`. - `SNIPPET_ID`which checks if an item has a snippet id variable set by an effect_on_condition with the given name (exact match) and snippets id = `value`. 2. The condition you want to look for. 3. The name to use if a match is found. Follows all the rules of a standard `name` field, with valid keys being `str`, `str_pl`, and `ctxt`. You may use %s here, which will be replaced by the name of the item. Conditional names defined prior to this one are taken into account. diff --git a/src/bionics.cpp b/src/bionics.cpp index 48b680bf8ef27..cb66c7d45e9b8 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -783,7 +783,7 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics for( const effect_on_condition_id &eoc : bio.id->activated_eocs ) { dialogue d( get_talker_for( *this ), nullptr ); - write_var_value( var_type::context, "npctalk_var_act_cost", &d, + write_var_value( var_type::context, "act_cost", &d, units::to_millijoule( bio.info().power_activate ) ); if( eoc->type == eoc_type::ACTIVATION ) { eoc->activate( d ); diff --git a/src/character.cpp b/src/character.cpp index d3def233ed518..c3101d18c32dd 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -516,8 +516,8 @@ void Character::queue_effect( const std::string &name, const time_duration &dela const time_duration &effect_duration ) { std::unordered_map ctx = { - { "npctalk_var_effect", name }, - { "npctalk_var_duration", std::to_string( to_turns( effect_duration ) ) } + { "effect", name }, + { "duration", std::to_string( to_turns( effect_duration ) ) } }; effect_on_conditions::queue_effect_on_condition( delay, effect_on_condition_add_effect, *this, @@ -529,7 +529,7 @@ int Character::count_queued_effects( const std::string &effect ) const return std::count_if( queued_effect_on_conditions.list.begin(), queued_effect_on_conditions.list.end(), [&effect]( const queued_eoc & eoc ) { return eoc.eoc == effect_on_condition_add_effect && - eoc.context.at( "npctalk_var_effect" ) == effect; + eoc.context.at( "effect" ) == effect; } ); } diff --git a/src/condition.cpp b/src/condition.cpp index d40e43d8fdb6a..e629dee38a9db 100644 --- a/src/condition.cpp +++ b/src/condition.cpp @@ -172,11 +172,8 @@ std::string get_talk_varname( const JsonObject &jo, std::string_view member, jo.throw_error( "invalid " + std::string( member ) + " condition in " + jo.str() ); } const std::string &var_basename = jo.get_string( std::string( member ) ); - const std::string &type_var = jo.get_string( "type", "" ); - const std::string &var_context = jo.get_string( "context", "" ); default_val = get_dbl_or_var( jo, "default", false ); - return "npctalk_var" + ( type_var.empty() ? "" : "_" + type_var ) + ( var_context.empty() ? "" : "_" - + var_context ) + "_" + var_basename; + return var_basename; } std::string get_talk_var_basename( const JsonObject &jo, std::string_view member, @@ -432,11 +429,7 @@ static abstract_var_info abstract_read_var_info( const JsonObject &jo ) } if( jo.has_string( "var_name" ) ) { - const std::string &type_var = jo.get_string( "type", "" ); - const std::string &var_context = jo.get_string( "context", "" ); - name = "npctalk_var_" + type_var + ( type_var.empty() ? "" : "_" ) + var_context + - ( var_context.empty() ? "" : "_" ) - + jo.get_string( "var_name" ); + name = jo.get_string( "var_name" ); } if( jo.has_member( "u_val" ) ) { type = var_type::u; @@ -1165,7 +1158,7 @@ conditional_t::func f_expects_vars( const JsonObject &jo, std::string_view membe return [to_check]( const_dialogue const & d ) { std::string missing_variables; for( const str_or_var &val : to_check ) { - if( d.get_context().find( "npctalk_var_" + val.evaluate( d ) ) == d.get_context().end() ) { + if( d.get_context().find( val.evaluate( d ) ) == d.get_context().end() ) { missing_variables += val.evaluate( d ) + ", "; } } diff --git a/src/damage.cpp b/src/damage.cpp index 6fda13eb70975..84cfcc1bb1886 100644 --- a/src/damage.cpp +++ b/src/damage.cpp @@ -437,9 +437,9 @@ void damage_type::ondamage_effects( Creature *source, Creature *target, bodypart dialogue d( source == nullptr ? nullptr : get_talker_for( source ), target == nullptr ? nullptr : get_talker_for( target ) ); - d.set_value( "npctalk_var_damage_taken", std::to_string( damage_taken ) ); - d.set_value( "npctalk_var_total_damage", std::to_string( total_damage ) ); - d.set_value( "npctalk_var_bp", bp.str() ); + d.set_value( "damage_taken", std::to_string( damage_taken ) ); + d.set_value( "total_damage", std::to_string( total_damage ) ); + d.set_value( "bp", bp.str() ); if( eoc->type == eoc_type::ACTIVATION ) { eoc->activate( d ); diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index fb78686cfdc49..2526ff1cb2343 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -614,11 +614,10 @@ static void edit_global_npctalk_vars() std::string key; string_input_popup popup_key; popup_key - //~This is the title for an input window, where strings like npctalk_var_my_variable are concatenated. The trailing "npctalk_var_" is intended to show that their entry is automatically prepended with that. e.g. if they type "cigar" the resulting var's string is "npctalk_var_cigar" - .title( _( "Key\n npctalk_var_" ) ) + .title( _( "Key\n" ) ) .width( 85 ) .edit( key ); - globvars.set_global_value( "npctalk_var_" + key, query_npctalkvar_new_value() ); + globvars.set_global_value( key, query_npctalkvar_new_value() ); } else if( selected_globvar > 0 && selected_globvar <= static_cast( keymap_index.size() ) ) { globvars.set_global_value( keymap_index[selected_globvar], query_npctalkvar_new_value() ); } @@ -655,11 +654,10 @@ static void edit_character_npctalk_vars( Character &you ) std::string key; string_input_popup popup_key; popup_key - //~This is the title for an input window, where strings like npctalk_var_my_variable are concatenated. The trailing "npctalk_var_" is intended to show that their entry is automatically prepended with that. e.g. if they type "cigar" the resulting var's string is "npctalk_var_cigar" - .title( _( "Key\n npctalk_var_" ) ) + .title( _( "Key\n" ) ) .width( 85 ) .edit( key ); - you.set_value( "npctalk_var_" + key, query_npctalkvar_new_value() ); + you.set_value( key, query_npctalkvar_new_value() ); } else if( selected_globvar > 0 && selected_globvar <= static_cast( keymap_index.size() ) ) { you.set_value( keymap_index[selected_globvar], query_npctalkvar_new_value() ); } diff --git a/src/dialogue_helpers.cpp b/src/dialogue_helpers.cpp index 27e449fc7e724..95d04ed724c02 100644 --- a/src/dialogue_helpers.cpp +++ b/src/dialogue_helpers.cpp @@ -88,7 +88,7 @@ var_info process_variable( const std::string &type ) ret_str = type.substr( 1, type.size() - 1 ); } - return var_info( vt, "npctalk_var_" + ret_str ); + return var_info( vt, ret_str ); } template<> @@ -109,9 +109,6 @@ std::string str_or_var::evaluate( const_dialogue const &d ) const return default_val.value(); } std::string var_name = var_val.value().name; - if( var_name.find( "npctalk_var" ) != std::string::npos ) { - var_name = var_name.substr( 12 ); - } debugmsg( "No default value provided for str_or_var_part while encountering unused " "variable %s. Add a \"default_str\" member to prevent this. %s", var_name, d.get_callstack() ); @@ -139,9 +136,6 @@ std::string translation_or_var::evaluate( const_dialogue const &d ) const return default_val.value().translated(); } std::string var_name = var_val.value().name; - if( var_name.find( "npctalk_var" ) != std::string::npos ) { - var_name = var_name.substr( 12 ); - } debugmsg( "No default value provided for str_or_var_part while encountering unused " "variable %s. Add a \"default_str\" member to prevent this. %s", var_name, d.get_callstack() ); @@ -172,9 +166,6 @@ double dbl_or_var_part::evaluate( const_dialogue const &d ) const return default_val.value(); } std::string var_name = var_val.value().name; - if( var_name.find( "npctalk_var" ) != std::string::npos ) { - var_name = var_name.substr( 12 ); - } debugmsg( "No default value provided for dbl_or_var_part while encountering unused " "variable %s. Add a \"default\" member to prevent this. %s", var_name, d.get_callstack() ); @@ -212,9 +203,6 @@ time_duration duration_or_var_part::evaluate( const_dialogue const &d ) const return default_val.value(); } std::string var_name = var_val.value().name; - if( var_name.find( "npctalk_var" ) != std::string::npos ) { - var_name = var_name.substr( 12 ); - } debugmsg( "No default value provided for duration_or_var_part while encountering unused " "variable %s. Add a \"default\" member to prevent this. %s", var_name, d.get_callstack() ); diff --git a/src/effect_on_condition.cpp b/src/effect_on_condition.cpp index 0084c75df6171..eece9d0b28178 100644 --- a/src/effect_on_condition.cpp +++ b/src/effect_on_condition.cpp @@ -568,7 +568,7 @@ void eoc_events::notify( const cata::event &e, std::unique_ptr alpha, dialogue d; std::unordered_map context; for( const auto &val : e.data() ) { - context["npctalk_var_" + val.first] = val.second.get_string(); + context[val.first] = val.second.get_string(); } // if we have an NPC to trigger this event for, do so, diff --git a/src/faction_camp.cpp b/src/faction_camp.cpp index 60f03342bbe54..10a04ee913645 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -203,10 +203,10 @@ static const std::string camp_om_fortifications_spiked_trench_parameter = faction_wall_level_n_1_string; static const std::string var_time_between_succession = - "npctalk_var_time_between_succession"; + "time_between_succession"; static const std::string var_timer_time_of_last_succession = - "npctalk_var_timer_time_of_last_succession"; + "timer_time_of_last_succession"; // These strings are matched against recipe group 'building_type'. Definite candidates for JSON definitions of // the various UI strings corresponding to these groups. diff --git a/src/game.cpp b/src/game.cpp index 281f50c59a667..5fb585a7c72e7 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -870,6 +870,29 @@ void game::load_map( const tripoint_abs_sm &pos_sm, m.load( pos_sm, true, pump_events ); } +void game::legacy_migrate_npctalk_var_prefix( std::unordered_map + map_of_vars ) +{ + // migrate existing variables with npctalk_var prefix to no prefix (npctalk_var_foo to just foo) + // remove after 0.J + + if( savegame_loading_version >= 35 ) { + return; + } + + const std::string prefix = "npctalk_var_"; + for( auto i = map_of_vars.begin(); i != map_of_vars.end(); ) { + if( i->first.rfind( prefix, 0 ) == 0 ) { + auto extracted = map_of_vars.extract( i++ ); + std::string new_key = extracted.key().substr( prefix.size() ); + extracted.key() = new_key; + map_of_vars.insert( std::move( extracted ) ); + } else { + ++i; + } + } +} + // Set up all default values for a new game bool game::start_game() { diff --git a/src/game.h b/src/game.h index ddd7078c9a681..fb2dc6ceb337e 100644 --- a/src/game.h +++ b/src/game.h @@ -735,6 +735,9 @@ class game * disabled). */ void load_map( const tripoint_abs_sm &pos_sm, bool pump_events = false ); + // Removes legacy npctalk_var_ prefix from older versions of the game. Should be removed after 0.J + static void legacy_migrate_npctalk_var_prefix( std::unordered_map + map_of_vars ); /** * The overmap which contains the center submap of the reality bubble. */ diff --git a/src/iexamine_actors.cpp b/src/iexamine_actors.cpp index 85a4bbd272496..00d8270538f75 100644 --- a/src/iexamine_actors.cpp +++ b/src/iexamine_actors.cpp @@ -256,8 +256,8 @@ std::unique_ptr cardreader_examine_actor::clone() const void eoc_examine_actor::call( Character &you, const tripoint_bub_ms &examp ) const { dialogue d( get_talker_for( you ), nullptr ); - d.set_value( "npctalk_var_this", get_map().furn( examp ).id().str() ); - d.set_value( "npctalk_var_pos", get_map().getglobal( examp ).to_string() ); + d.set_value( "this", get_map().furn( examp ).id().str() ); + d.set_value( "pos", get_map().getglobal( examp ).to_string() ); for( const effect_on_condition_id &eoc : eocs ) { eoc->activate( d ); } diff --git a/src/item.cpp b/src/item.cpp index fcb500a96a153..f3c921fa82bfc 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -339,8 +339,8 @@ item::item( const itype *type, time_point turn, int qty ) : type( type ), bday( if( has_flag( flag_ENERGY_SHIELD ) ) { const islot_armor *sh = find_armor_data(); - set_var( "npctalk_var_MAX_ENERGY_SHIELD_HP", sh->max_energy_shield_hp ); - set_var( "npctalk_var_ENERGY_SHIELD_HP", sh->max_energy_shield_hp ); + set_var( "MAX_ENERGY_SHIELD_HP", sh->max_energy_shield_hp ); + set_var( "ENERGY_SHIELD_HP", sh->max_energy_shield_hp ); } if( has_flag( flag_COLLAPSE_CONTENTS ) ) { @@ -9042,10 +9042,10 @@ item::armor_status item::damage_armor_durability( damage_unit &du, damage_unit & { //Energy shields aren't damaged by attacks but do get their health variable reduced. They are also only //damaged by the damage types they actually protect against. - if( has_var( "npctalk_var_ENERGY_SHIELD_HP" ) && resist( du.type, false, bp ) > 0.0f ) { - double shield_hp = get_var( "npctalk_var_ENERGY_SHIELD_HP", 0.0 ); + if( has_var( "ENERGY_SHIELD_HP" ) && resist( du.type, false, bp ) > 0.0f ) { + double shield_hp = get_var( "ENERGY_SHIELD_HP", 0.0 ); shield_hp -= premitigated.amount; - set_var( "npctalk_var_ENERGY_SHIELD_HP", shield_hp ); + set_var( "ENERGY_SHIELD_HP", shield_hp ); if( shield_hp > 0 ) { return armor_status::UNDAMAGED; } else { diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 8b8ff6beaf657..1d9156a35e62e 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -5636,7 +5636,7 @@ std::optional effect_on_conditons_actor::use( Character *p, item &it, } dialogue d( ( char_ptr == nullptr ? nullptr : get_talker_for( char_ptr ) ), get_talker_for( loc ) ); - write_var_value( var_type::context, "npctalk_var_id", &d, it.typeId().str() ); + write_var_value( var_type::context, "id", &d, it.typeId().str() ); for( const effect_on_condition_id &eoc : eocs ) { if( eoc->type == eoc_type::ACTIVATION ) { eoc->activate( d ); diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 32b49676a3aab..a642f07c1e1c0 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -1893,7 +1893,7 @@ void spell_effect::effect_on_condition( const spell &sp, Creature &caster, Creature *victim = creatures.creature_at( potential_target ); dialogue d( victim ? get_talker_for( victim ) : nullptr, get_talker_for( caster ) ); const tripoint_abs_ms target_abs = get_map().getglobal( potential_target ); - write_var_value( var_type::context, "npctalk_var_spell_location", &d, + write_var_value( var_type::context, "spell_location", &d, target_abs.to_string() ); d.amend_callstack( string_format( "Spell: %s Caster: %s", sp.id().c_str(), caster.disp_name() ) ); effect_on_condition_id eoc = effect_on_condition_id( sp.effect_data() ); diff --git a/src/mapgen.cpp b/src/mapgen.cpp index d0e813b8922eb..63d1f53114041 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -8130,7 +8130,7 @@ void set_queued_points() { global_variables &globvars = get_globals(); for( std::pair &queued_point : queued_points ) { - globvars.set_global_value( "npctalk_var_" + queued_point.first, queued_point.second.to_string() ); + globvars.set_global_value( queued_point.first, queued_point.second.to_string() ); } queued_points.clear(); } diff --git a/src/math_parser.cpp b/src/math_parser.cpp index 509cb14abb737..25da45a20f18c 100644 --- a/src/math_parser.cpp +++ b/src/math_parser.cpp @@ -797,7 +797,7 @@ void math_exp::math_exp_impl::new_var( std::string_view str ) scoped = scoped.substr( 1 ); } validate_string( scoped, "variable", " \'" ); - output.emplace( std::in_place_type_t(), type, "npctalk_var_" + std::string{ scoped } ); + output.emplace( std::in_place_type_t(), type, std::string{ scoped } ); } std::string math_exp::math_exp_impl::error( std::string_view str, std::string_view what ) @@ -815,7 +815,7 @@ std::string math_exp::math_exp_impl::error( std::string_view str, std::string_vi std::holds_alternative( output.top().data ) ) { // NOLINTNEXTLINE(cata-translate-string-literal): debug message mess = string_format( "%s (or unknown function %s)", mess, - std::get( output.top().data ).varinfo.name.substr( 12 ) ); + std::get( output.top().data ).varinfo.name ); } offset = std::max( 0, offset - 1 ); diff --git a/src/math_parser_jmath.cpp b/src/math_parser_jmath.cpp index d641487fee0cb..f082b8aff6d74 100644 --- a/src/math_parser_jmath.cpp +++ b/src/math_parser_jmath.cpp @@ -78,7 +78,7 @@ double jmath_func::eval( const_dialogue const &d, std::vector const &par { const_dialogue d_next( d ); for( std::vector::size_type i = 0; i < params.size(); i++ ) { - d_next.set_value( "npctalk_var_" + std::to_string( i ), string_format( "%g", params[i] ) ); + d_next.set_value( std::to_string( i ), string_format( "%g", params[i] ) ); } return eval( d_next ); diff --git a/src/mattack_actors.cpp b/src/mattack_actors.cpp index da1e05e3933b7..fa9450841390c 100644 --- a/src/mattack_actors.cpp +++ b/src/mattack_actors.cpp @@ -919,7 +919,7 @@ bool melee_actor::call( monster &z ) const //run EoCs for( const effect_on_condition_id &eoc : eoc ) { dialogue d( get_talker_for( z ), get_talker_for( target ) ); - write_var_value( var_type::context, "npctalk_var_damage", &d, damage_total ); + write_var_value( var_type::context, "damage", &d, damage_total ); eoc->activate( d ); } diff --git a/src/mission_companion.cpp b/src/mission_companion.cpp index e6cb7105b5ad0..cc6669e4638b1 100644 --- a/src/mission_companion.cpp +++ b/src/mission_companion.cpp @@ -142,13 +142,13 @@ static const trait_id trait_NPC_CONSTRUCTION_LEV_2( "NPC_CONSTRUCTION_LEV_2" ); static const trait_id trait_NPC_MISSION_LEV_1( "NPC_MISSION_LEV_1" ); static const std::string var_DOCTOR_ANESTHETIC_SCAVENGERS_HELPED = - "npctalk_var_mission_tacoma_ranch_doctor_anesthetic_scavengers_helped"; + "mission_tacoma_ranch_doctor_anesthetic_scavengers_helped"; static const std::string var_PURCHASED_FIELD_1_FENCE = - "npctalk_var_dialogue_tacoma_ranch_purchased_field_1_fence"; + "dialogue_tacoma_ranch_purchased_field_1_fence"; static const std::string var_SCAVENGER_HOSPITAL_RAID = - "npctalk_var_mission_tacoma_ranch_scavenger_hospital_raid"; + "mission_tacoma_ranch_scavenger_hospital_raid"; static const std::string var_SCAVENGER_HOSPITAL_RAID_STARTED = - "npctalk_var_mission_tacoma_ranch_scavenger_hospital_raid_started"; + "mission_tacoma_ranch_scavenger_hospital_raid_started"; static const std::string role_id_faction_camp = "FACTION_CAMP"; diff --git a/src/mutation.cpp b/src/mutation.cpp index e99d54d7cccd3..a6fef23a36699 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -856,7 +856,7 @@ void Character::activate_mutation( const trait_id &mut ) if( !mut->activated_eocs.empty() ) { for( const effect_on_condition_id &eoc : mut->activated_eocs ) { dialogue d( get_talker_for( *this ), nullptr ); - d.set_value( "npctalk_var_this", mut.str() ); + d.set_value( "this", mut.str() ); if( eoc->type == eoc_type::ACTIVATION ) { eoc->activate( d ); } else { @@ -1013,7 +1013,7 @@ void Character::deactivate_mutation( const trait_id &mut ) for( const effect_on_condition_id &eoc : mut->deactivated_eocs ) { dialogue d( get_talker_for( *this ), nullptr ); - d.set_value( "npctalk_var_this", mut.str() ); + d.set_value( "this", mut.str() ); if( eoc->type == eoc_type::ACTIVATION ) { eoc->activate( d ); } else { diff --git a/src/npctalk.cpp b/src/npctalk.cpp index d2d4601190bc9..f83561a1e28b0 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -2372,7 +2372,7 @@ void parse_tags( std::string &phrase, const_talker const &u, const_talker const var.pop_back(); // resolve nest parse_tags( var, u, me, d, item_type ); - phrase.replace( fa, l, u.get_value( "npctalk_var_" + var ) ); + phrase.replace( fa, l, u.get_value( var ) ); } else if( tag.find( "get_unique_id() ); + cur_var.name.insert( 0, guy->get_unique_id() ); } tripoint_abs_ms target_location = get_tripoint_from_var( cur_var, d, is_npc ); guy->set_guard_pos( target_location ); @@ -5723,7 +5722,7 @@ talk_effect_fun_t::func f_run_eocs( const JsonObject &jo, std::string_view membe if( jo.has_object( "variables" ) ) { const JsonObject &variables = jo.get_object( "variables" ); for( const JsonMember &jv : variables ) { - context["npctalk_var_" + jv.name()] = get_str_translation_or_var( jv, jv.name(), true ); + context[jv.name()] = get_str_translation_or_var( jv, jv.name(), true ); } } @@ -5826,7 +5825,7 @@ talk_effect_fun_t::func f_run_eoc_selector( const JsonObject &jo, std::string_vi const JsonObject &variables = member.get_object(); std::unordered_map temp_context; for( const JsonMember &jv : variables ) { - temp_context["npctalk_var_" + jv.name()] = get_str_translation_or_var( jv, jv.name(), true ); + temp_context[jv.name()] = get_str_translation_or_var( jv, jv.name(), true ); } context.emplace_back( temp_context ); } @@ -6998,8 +6997,8 @@ talk_effect_fun_t::func f_closest_city( const JsonObject &jo, std::string_view m if( city ) { tripoint_abs_omt city_center_omt = project_to( city.abs_sm_pos ); write_var_value( type, var_name, &d, city_center_omt.to_string() ); - write_var_value( var_type::context, "npctalk_var_city_name", &d, city.city->name ); - write_var_value( var_type::context, "npctalk_var_city_size", &d, city.city->size ); + write_var_value( var_type::context, "city_name", &d, city.city->name ); + write_var_value( var_type::context, "city_size", &d, city.city->size ); } else { return; } @@ -7008,8 +7007,8 @@ talk_effect_fun_t::func f_closest_city( const JsonObject &jo, std::string_view m if( city ) { tripoint_abs_omt city_center_omt = project_to( city.abs_sm_pos ); write_var_value( type, var_name, &d, city_center_omt.to_string() ); - write_var_value( var_type::context, "npctalk_var_city_name", &d, city.city->name ); - write_var_value( var_type::context, "npctalk_var_city_size", &d, city.city->size ); + write_var_value( var_type::context, "city_name", &d, city.city->name ); + write_var_value( var_type::context, "city_size", &d, city.city->size ); } } }; @@ -7906,7 +7905,7 @@ json_dynamic_line_effect::json_dynamic_line_effect( const JsonObject &jo, // set the sentinel if( jo.has_string( "sentinel" ) ) { const std::string sentinel = jo.get_string( "sentinel" ); - const std::string varname = "npctalk_var_sentinel_" + id + "_" + sentinel; + const std::string varname = "sentinel_" + id + "_" + sentinel; condition = [varname, tmp_condition]( dialogue & d ) { return d.actor( false )->get_value( varname ) != "yes" && tmp_condition( d ); }; diff --git a/src/projectile.cpp b/src/projectile.cpp index fef70423babab..e19d5477609e8 100644 --- a/src/projectile.cpp +++ b/src/projectile.cpp @@ -197,8 +197,8 @@ void apply_ammo_effects( Creature *source, const tripoint_bub_ms &p, dialogue d( get_talker_for( *source ), critter == nullptr ? nullptr : get_talker_for( critter ) ); // `p` is tripoint relative to the upper left corner of currently loaded overmap // not very useful for player's purposes methinks, but much appreciated - // write_var_value( var_type::context, "npctalk_var_proj_target_tripoint", &d, p.abs().to_string()); - write_var_value( var_type::context, "npctalk_var_proj_damage", &d, dealt_damage ); + // write_var_value( var_type::context, "proj_target_tripoint", &d, p.abs().to_string()); + write_var_value( var_type::context, "proj_damage", &d, dealt_damage ); eoc->activate( d ); } //cast ammo effect spells diff --git a/src/savegame.cpp b/src/savegame.cpp index 014ca9bdbc81a..263fce9bc6ef7 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -69,7 +69,7 @@ extern std::map> quick_shortcuts_map; * Changes that break backwards compatibility should bump this number, so the game can * load a legacy format loader. */ -const int savegame_version = 34; +const int savegame_version = 35; /* * This is a global set by detected version header in .sav, maps.txt, or overmap. @@ -1550,6 +1550,7 @@ void weather_manager::unserialize_all( const JsonObject &w ) void global_variables::unserialize( JsonObject &jo ) { + // global variables jo.read( "global_vals", global_values ); // potentially migrate some variable names for( std::pair migration : migrations ) { @@ -1559,6 +1560,8 @@ void global_variables::unserialize( JsonObject &jo ) global_values.insert( std::move( extracted ) ); } } + + game::legacy_migrate_npctalk_var_prefix( global_values ); } void timed_event_manager::unserialize_all( const JsonArray &ja ) diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index a2c11e559729f..f04b3073728d9 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -1265,9 +1265,12 @@ void Character::load( const JsonObject &data ) temp.time = time_point( elem.get_int( "time" ) ); temp.eoc = effect_on_condition_id( elem.get_string( "eoc" ) ); std::unordered_map context; + // context variables for( const JsonMember &jm : elem.get_object( "context" ) ) { context[jm.name()] = jm.get_string(); } + game::legacy_migrate_npctalk_var_prefix( context ); + temp.context = context; queued_effect_on_conditions.push( temp ); } @@ -2808,7 +2811,25 @@ void item::io( Archive &archive ) archive.io( "bday", bday, calendar::start_of_cataclysm ); archive.io( "mission_id", mission_id, -1 ); archive.io( "player_id", player_id, -1 ); + // item variables archive.io( "item_vars", item_vars, io::empty_default_tag() ); + + // game::legacy_migrate_npctalk_var_prefix( item_vars ); + // doesn't work here, because item_vars is cata::heap>, not std::unordered_map<> + // remove after 0.J + if( savegame_loading_version < 35 ) { + const std::string prefix = "npctalk_var_"; + for( auto i = item_vars.begin(); i != item_vars.end(); ) { + if( i->first.rfind( prefix, 0 ) == 0 ) { + std::map::node_type extracted = ( *item_vars ).extract( i++ ); + std::string new_key = extracted.key().substr( prefix.size() ); + extracted.key() = new_key; + item_vars.insert( std::move( extracted ) ); + } else { + ++i; + } + } + } // TODO: change default to empty string archive.io( "name", corpse_name, std::string() ); archive.io( "owner", owner, faction_id::NULL_ID() ); @@ -3762,6 +3783,7 @@ void Creature::load( const JsonObject &jsin ) jsin.read( "effects", *effects ); } + // u/npc variables jsin.read( "values", values ); // potentially migrate some values for( std::pair migration : get_globals().migrations ) { @@ -3772,6 +3794,8 @@ void Creature::load( const JsonObject &jsin ) } } + game::legacy_migrate_npctalk_var_prefix( values ); + jsin.read( "damage_over_time_map", damage_over_time_map ); jsin.read( "blocks_left", num_blocks ); diff --git a/src/suffer.cpp b/src/suffer.cpp index dd43ba37b7b17..696d873ab9e39 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -298,7 +298,7 @@ void suffer::mutation_power( Character &you, const trait_id &mut_id ) // if you haven't deactivated then run the EOC for( const effect_on_condition_id &eoc : mut_id->processed_eocs ) { dialogue d( get_talker_for( you ), nullptr ); - d.set_value( "npctalk_var_this", mut_id.str() ); + d.set_value( "this", mut_id.str() ); if( eoc->type == eoc_type::ACTIVATION ) { eoc->activate( d ); } else { diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index f5e22ba3ca37d..d59037230c359 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -193,7 +193,7 @@ weather_type_id weather_generator::get_weather_conditions( const w_point &w ) co w_point original_weather_precise = *game_weather.weather_precise; *game_weather.weather_precise = w; std::unordered_map context; - context["npctalk_var_weather_location"] = w.location.to_string(); + context["weather_location"] = w.location.to_string(); weather_type_id current_conditions = WEATHER_CLEAR; dialogue d( get_talker_for( get_avatar() ), nullptr, {}, context ); for( const weather_type_id &type : sorted_weather ) { diff --git a/src/widget.cpp b/src/widget.cpp index d81d908d6256e..263c049fea0d0 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -309,7 +309,7 @@ bool widget_clause::meets_condition( const std::string &opt_var ) const { dialogue d( get_talker_for( get_avatar() ), nullptr ); d.reason = opt_var; // TODO: remove since it's replaced by context var - write_var_value( var_type::context, "npctalk_var_widget", &d, opt_var ); + write_var_value( var_type::context, "widget", &d, opt_var ); return !has_condition || condition( d ); } diff --git a/tests/eoc_test.cpp b/tests/eoc_test.cpp index ffb53f93a60f6..3c2918c1c7a86 100644 --- a/tests/eoc_test.cpp +++ b/tests/eoc_test.cpp @@ -232,15 +232,15 @@ TEST_CASE( "EOC_math_integration", "[eoc][math_parser]" ) dialogue d( get_talker_for( get_avatar() ), std::make_unique() ); global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_math_test" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_math_test_result" ).empty() ); + REQUIRE( globvars.get_global_value( "math_test" ).empty() ); + REQUIRE( globvars.get_global_value( "math_test_result" ).empty() ); calendar::turn = calendar::start_of_cataclysm; CHECK_FALSE( effect_on_condition_EOC_math_test_greater_increment->test_condition( d ) ); effect_on_condition_EOC_math_test_greater_increment->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_math_test" ) ) == Approx( -1 ) ); + CHECK( std::stod( globvars.get_global_value( "math_test" ) ) == Approx( -1 ) ); effect_on_condition_EOC_math_switch_math->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_math_test_result" ) ) == Approx( 1 ) ); + CHECK( std::stod( globvars.get_global_value( "math_test_result" ) ) == Approx( 1 ) ); CHECK( effect_on_condition_EOC_math_duration->recurrence.evaluate( d ) == 1_turns ); calendar::turn += 1_days; @@ -250,16 +250,16 @@ TEST_CASE( "EOC_math_integration", "[eoc][math_parser]" ) CHECK( effect_on_condition_EOC_math_test_equals_assign->test_condition( d ) ); CHECK( effect_on_condition_EOC_math_test_inline_condition->test_condition( d ) ); effect_on_condition_EOC_math_test_equals_assign->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_math_test" ) ) == Approx( 9 ) ); + CHECK( std::stod( globvars.get_global_value( "math_test" ) ) == Approx( 9 ) ); effect_on_condition_EOC_math_switch_math->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_math_test_result" ) ) == Approx( 2 ) ); + CHECK( std::stod( globvars.get_global_value( "math_test_result" ) ) == Approx( 2 ) ); CHECK( effect_on_condition_EOC_math_duration->recurrence.evaluate( d ) == 2_turns ); CHECK( effect_on_condition_EOC_math_test_greater_increment->test_condition( d ) ); effect_on_condition_EOC_math_test_greater_increment->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_math_test" ) ) == Approx( 10 ) ); + CHECK( std::stod( globvars.get_global_value( "math_test" ) ) == Approx( 10 ) ); effect_on_condition_EOC_math_switch_math->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_math_test_result" ) ) == Approx( 3 ) ); + CHECK( std::stod( globvars.get_global_value( "math_test_result" ) ) == Approx( 3 ) ); CHECK( effect_on_condition_EOC_math_duration->recurrence.evaluate( d ) == 3_turns ); int const stam_pre = get_avatar().get_stamina(); @@ -269,34 +269,34 @@ TEST_CASE( "EOC_math_integration", "[eoc][math_parser]" ) get_avatar().set_pain( 0 ); get_avatar().set_stamina( 9000 ); effect_on_condition_EOC_math_weighted_list->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_weighted_var" ) ) == Approx( -999 ) ); + CHECK( std::stod( globvars.get_global_value( "weighted_var" ) ) == Approx( -999 ) ); get_avatar().set_pain( 9000 ); get_avatar().set_stamina( 0 ); effect_on_condition_EOC_math_weighted_list->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_weighted_var" ) ) == Approx( 1 ) ); + CHECK( std::stod( globvars.get_global_value( "weighted_var" ) ) == Approx( 1 ) ); } TEST_CASE( "EOC_jmath", "[eoc][math_parser]" ) { global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_blorgy" ).empty() ); + REQUIRE( globvars.get_global_value( "blorgy" ).empty() ); dialogue d( get_talker_for( get_avatar() ), std::make_unique() ); effect_on_condition_EOC_jmath_test->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_blorgy" ) ) == Approx( 7 ) ); + CHECK( std::stod( globvars.get_global_value( "blorgy" ) ) == Approx( 7 ) ); } TEST_CASE( "EOC_diag_with_vars", "[eoc][math_parser]" ) { global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_myskill_math" ).empty() ); + REQUIRE( globvars.get_global_value( "myskill_math" ).empty() ); dialogue d( get_talker_for( get_avatar() ), std::make_unique() ); effect_on_condition_EOC_math_diag_w_vars->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_myskill_math" ) ) == Approx( 0 ) ); + CHECK( std::stod( globvars.get_global_value( "myskill_math" ) ) == Approx( 0 ) ); get_avatar().set_skill_level( skill_survival, 3 ); effect_on_condition_EOC_math_diag_w_vars->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_myskill_math" ) ) == Approx( 3 ) ); + CHECK( std::stod( globvars.get_global_value( "myskill_math" ) ) == Approx( 3 ) ); } TEST_CASE( "EOC_transform_radius", "[eoc][timed_event]" ) @@ -350,7 +350,7 @@ TEST_CASE( "EOC_activity_finish", "[eoc][timed_event]" ) complete_activity( get_avatar() ); - CHECK( stoi( get_avatar().get_value( "npctalk_var_activitiy_incrementer" ) ) == 1 ); + CHECK( stoi( get_avatar().get_value( "activitiy_incrementer" ) ) == 1 ); } TEST_CASE( "EOC_combat_mutator_test", "[eoc]" ) @@ -365,13 +365,13 @@ TEST_CASE( "EOC_combat_mutator_test", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key3" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key3" ).empty() ); CHECK( effect_on_condition_EOC_combat_mutator_test->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key1" ) == "RAPID_TEST" ); - CHECK( globvars.get_global_value( "npctalk_var_key2" ) == "Rapid Strike Test" ); - CHECK( globvars.get_global_value( "npctalk_var_key3" ) == "50% moves, 66% damage" ); + CHECK( globvars.get_global_value( "key1" ) == "RAPID_TEST" ); + CHECK( globvars.get_global_value( "key2" ) == "Rapid Strike Test" ); + CHECK( globvars.get_global_value( "key3" ) == "50% moves, 66% damage" ); } TEST_CASE( "EOC_alive_test", "[eoc]" ) @@ -383,9 +383,9 @@ TEST_CASE( "EOC_alive_test", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); CHECK( effect_on_condition_EOC_alive_test->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key1" ) == "alive" ); + CHECK( globvars.get_global_value( "key1" ) == "alive" ); } TEST_CASE( "EOC_attack_test", "[eoc]" ) @@ -407,19 +407,19 @@ TEST_CASE( "EOC_context_test", "[eoc][math_parser]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_simple_global" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_nested_simple_global" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_non_nested_simple_global" ).empty() ); + REQUIRE( globvars.get_global_value( "simple_global" ).empty() ); + REQUIRE( globvars.get_global_value( "nested_simple_global" ).empty() ); + REQUIRE( globvars.get_global_value( "non_nested_simple_global" ).empty() ); CHECK( effect_on_condition_EOC_math_test_context->activate( d ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_simple_global" ) ) == Approx( 12 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_nested_simple_global" ) ) == Approx( + CHECK( std::stod( globvars.get_global_value( "simple_global" ) ) == Approx( 12 ) ); + CHECK( std::stod( globvars.get_global_value( "nested_simple_global" ) ) == Approx( 7 ) ); // shouldn't be passed back up - CHECK( std::stod( globvars.get_global_value( "npctalk_var_non_nested_simple_global" ) ) == Approx( + CHECK( std::stod( globvars.get_global_value( "non_nested_simple_global" ) ) == Approx( 0 ) ); // value shouldn't exist in the original dialogue - CHECK( d.get_value( "npctalk_var_simple" ).empty() ); + CHECK( d.get_value( "simple" ).empty() ); } TEST_CASE( "EOC_option_test", "[eoc][math_parser]" ) @@ -432,13 +432,13 @@ TEST_CASE( "EOC_option_test", "[eoc][math_parser]" ) globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key3" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key3" ).empty() ); CHECK( effect_on_condition_EOC_options_tests->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key1" ) == "ALWAYS" ); - CHECK( globvars.get_global_value( "npctalk_var_key2" ) == "4" ); - CHECK( globvars.get_global_value( "npctalk_var_key3" ) == "1" ); + CHECK( globvars.get_global_value( "key1" ) == "ALWAYS" ); + CHECK( globvars.get_global_value( "key2" ) == "4" ); + CHECK( globvars.get_global_value( "key3" ) == "1" ); } TEST_CASE( "EOC_mutator_test", "[eoc][math_parser]" ) @@ -450,11 +450,11 @@ TEST_CASE( "EOC_mutator_test", "[eoc][math_parser]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); CHECK( effect_on_condition_EOC_mutator_test->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key1" ) == "zombie" ); - CHECK( globvars.get_global_value( "npctalk_var_key2" ) == "zombie" ); + CHECK( globvars.get_global_value( "key1" ) == "zombie" ); + CHECK( globvars.get_global_value( "key2" ) == "zombie" ); } TEST_CASE( "EOC_math_addiction", "[eoc][math_parser]" ) @@ -466,16 +466,16 @@ TEST_CASE( "EOC_math_addiction", "[eoc][math_parser]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key_add_intensity" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_add_turn" ).empty() ); + REQUIRE( globvars.get_global_value( "key_add_intensity" ).empty() ); + REQUIRE( globvars.get_global_value( "key_add_turn" ).empty() ); CHECK( effect_on_condition_EOC_math_addiction_setup->activate( d ) ); // Finish drinking complete_activity( get_avatar() ); CHECK( effect_on_condition_EOC_math_addiction_check->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key_add_intensity" ) == "1" ); - CHECK( globvars.get_global_value( "npctalk_var_key_add_turn" ) == "3600" ); + CHECK( globvars.get_global_value( "key_add_intensity" ) == "1" ); + CHECK( globvars.get_global_value( "key_add_turn" ) == "3600" ); } TEST_CASE( "EOC_math_armor", "[eoc][math_parser]" ) @@ -489,13 +489,13 @@ TEST_CASE( "EOC_math_armor", "[eoc][math_parser]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key3" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key3" ).empty() ); CHECK( effect_on_condition_EOC_math_armor->activate( d ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key1" ) ) == Approx( 4 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key2" ) ) == Approx( 9 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key3" ) ) == Approx( 0 ) ); + CHECK( std::stod( globvars.get_global_value( "key1" ) ) == Approx( 4 ) ); + CHECK( std::stod( globvars.get_global_value( "key2" ) ) == Approx( 9 ) ); + CHECK( std::stod( globvars.get_global_value( "key3" ) ) == Approx( 0 ) ); } TEST_CASE( "EOC_math_field", "[eoc][math_parser]" ) @@ -510,11 +510,11 @@ TEST_CASE( "EOC_math_field", "[eoc][math_parser]" ) get_map().add_field( get_avatar().pos_bub(), fd_blood, 3 ); get_map().add_field( get_avatar().pos_bub() + point_south, fd_blood_insect, 3 ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_field_strength" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_field_strength_north" ).empty() ); + REQUIRE( globvars.get_global_value( "key_field_strength" ).empty() ); + REQUIRE( globvars.get_global_value( "key_field_strength_north" ).empty() ); CHECK( effect_on_condition_EOC_math_field->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key_field_strength" ) == "3" ); - CHECK( globvars.get_global_value( "npctalk_var_key_field_strength_north" ) == "3" ); + CHECK( globvars.get_global_value( "key_field_strength" ) == "3" ); + CHECK( globvars.get_global_value( "key_field_strength_north" ) == "3" ); } TEST_CASE( "EOC_math_item", "[eoc][math_parser]" ) @@ -526,11 +526,11 @@ TEST_CASE( "EOC_math_item", "[eoc][math_parser]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key_item_count" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_charge_count" ).empty() ); + REQUIRE( globvars.get_global_value( "key_item_count" ).empty() ); + REQUIRE( globvars.get_global_value( "key_charge_count" ).empty() ); CHECK( effect_on_condition_EOC_math_item_count->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key_item_count" ) == "2" ); - CHECK( globvars.get_global_value( "npctalk_var_key_charge_count" ) == "32" ); + CHECK( globvars.get_global_value( "key_item_count" ) == "2" ); + CHECK( globvars.get_global_value( "key_charge_count" ) == "32" ); } TEST_CASE( "EOC_math_proficiency", "[eoc][math_parser]" ) @@ -542,23 +542,23 @@ TEST_CASE( "EOC_math_proficiency", "[eoc][math_parser]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key_total_time_required" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_time_spent_50" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_percent_50" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_percent_50_turn" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_permille_50" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_permille_50_turn" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_time_left_50" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_time_left_50_turn" ).empty() ); + REQUIRE( globvars.get_global_value( "key_total_time_required" ).empty() ); + REQUIRE( globvars.get_global_value( "key_time_spent_50" ).empty() ); + REQUIRE( globvars.get_global_value( "key_percent_50" ).empty() ); + REQUIRE( globvars.get_global_value( "key_percent_50_turn" ).empty() ); + REQUIRE( globvars.get_global_value( "key_permille_50" ).empty() ); + REQUIRE( globvars.get_global_value( "key_permille_50_turn" ).empty() ); + REQUIRE( globvars.get_global_value( "key_time_left_50" ).empty() ); + REQUIRE( globvars.get_global_value( "key_time_left_50_turn" ).empty() ); CHECK( effect_on_condition_EOC_math_proficiency->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key_total_time_required" ) == "86400" ); - CHECK( globvars.get_global_value( "npctalk_var_key_time_spent_50" ) == "50" ); - CHECK( globvars.get_global_value( "npctalk_var_key_percent_50" ) == "50" ); - CHECK( globvars.get_global_value( "npctalk_var_key_percent_50_turn" ) == "43200" ); - CHECK( globvars.get_global_value( "npctalk_var_key_permille_50" ) == "50" ); - CHECK( globvars.get_global_value( "npctalk_var_key_permille_50_turn" ) == "4320" ); - CHECK( globvars.get_global_value( "npctalk_var_key_time_left_50" ) == "50" ); - CHECK( globvars.get_global_value( "npctalk_var_key_time_left_50_turn" ) == "86350" ); + CHECK( globvars.get_global_value( "key_total_time_required" ) == "86400" ); + CHECK( globvars.get_global_value( "key_time_spent_50" ) == "50" ); + CHECK( globvars.get_global_value( "key_percent_50" ) == "50" ); + CHECK( globvars.get_global_value( "key_percent_50_turn" ) == "43200" ); + CHECK( globvars.get_global_value( "key_permille_50" ) == "50" ); + CHECK( globvars.get_global_value( "key_permille_50_turn" ) == "4320" ); + CHECK( globvars.get_global_value( "key_time_left_50" ) == "50" ); + CHECK( globvars.get_global_value( "key_time_left_50_turn" ) == "86350" ); } TEST_CASE( "EOC_math_spell", "[eoc][math_parser]" ) @@ -570,17 +570,17 @@ TEST_CASE( "EOC_math_spell", "[eoc][math_parser]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key_spell_level" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_highest_spell_level" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_school_level_test_trait" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_spell_count" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key_spell_count_test_trait" ).empty() ); + REQUIRE( globvars.get_global_value( "key_spell_level" ).empty() ); + REQUIRE( globvars.get_global_value( "key_highest_spell_level" ).empty() ); + REQUIRE( globvars.get_global_value( "key_school_level_test_trait" ).empty() ); + REQUIRE( globvars.get_global_value( "key_spell_count" ).empty() ); + REQUIRE( globvars.get_global_value( "key_spell_count_test_trait" ).empty() ); CHECK( effect_on_condition_EOC_math_spell->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key_spell_level" ) == "1" ); - CHECK( globvars.get_global_value( "npctalk_var_key_highest_spell_level" ) == "10" ); - CHECK( globvars.get_global_value( "npctalk_var_key_school_level_test_trait" ) == "1" ); - CHECK( globvars.get_global_value( "npctalk_var_key_spell_count" ) == "2" ); - CHECK( globvars.get_global_value( "npctalk_var_key_spell_count_test_trait" ) == "1" ); + CHECK( globvars.get_global_value( "key_spell_level" ) == "1" ); + CHECK( globvars.get_global_value( "key_highest_spell_level" ) == "10" ); + CHECK( globvars.get_global_value( "key_school_level_test_trait" ) == "1" ); + CHECK( globvars.get_global_value( "key_spell_count" ) == "2" ); + CHECK( globvars.get_global_value( "key_spell_count_test_trait" ) == "1" ); get_avatar().magic->evaluate_opens_spellbook_data(); @@ -601,31 +601,31 @@ TEST_CASE( "EOC_mutation_test", "[eoc][mutations]" ) globvars.clear_global_values(); me.toggle_trait( trait_process_mutation_two ); me.activate_mutation( trait_process_mutation_two ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_test_val" ) ) == Approx( + CHECK( std::stod( globvars.get_global_value( "test_val" ) ) == Approx( 1 ) ); - CHECK( globvars.get_global_value( "npctalk_var_context_test" ) == "process_mutation_two" ); + CHECK( globvars.get_global_value( "context_test" ) == "process_mutation_two" ); // test process globvars.clear_global_values(); me.suffer(); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_test_val" ) ) == Approx( + CHECK( std::stod( globvars.get_global_value( "test_val" ) ) == Approx( 1 ) ); - CHECK( globvars.get_global_value( "npctalk_var_context_test" ) == "process_mutation_two" ); + CHECK( globvars.get_global_value( "context_test" ) == "process_mutation_two" ); // test deactivate globvars.clear_global_values(); me.deactivate_mutation( trait_process_mutation_two ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_test_val" ) ) == Approx( + CHECK( std::stod( globvars.get_global_value( "test_val" ) ) == Approx( 1 ) ); - CHECK( globvars.get_global_value( "npctalk_var_context_test" ) == "process_mutation_two" ); + CHECK( globvars.get_global_value( "context_test" ) == "process_mutation_two" ); // more complex test globvars.clear_global_values(); me.toggle_trait( trait_process_mutation ); effect_on_condition_EOC_activate_mutation_to_start_test->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_test_val" ) ) == Approx( + CHECK( std::stod( globvars.get_global_value( "test_val" ) ) == Approx( 1 ) ); - CHECK( globvars.get_global_value( "npctalk_var_context_test" ) == "process_mutation" ); + CHECK( globvars.get_global_value( "context_test" ) == "process_mutation" ); } TEST_CASE( "EOC_purifiability", "[eoc][mutations]" ) @@ -672,25 +672,25 @@ TEST_CASE( "EOC_monsters_nearby", "[eoc][math_parser]" ) g->place_critter_at( mon_zombie_smoker, a.pos() + tripoint{ 10, 0, 0 } ); g->place_critter_at( mon_zombie_smoker, a.pos() + tripoint{ 11, 0, 0 } ); - REQUIRE( globvars.get_global_value( "npctalk_var_mons" ).empty() ); + REQUIRE( globvars.get_global_value( "mons" ).empty() ); dialogue d( get_talker_for( get_avatar() ), std::make_unique() ); REQUIRE( effect_on_condition_EOC_mon_nearby_test->activate( d ) ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_mons" ) ) == 8 ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_triffs" ) ) == 1 ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_group" ) ) == 4 ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_zombs" ) ) == 2 ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_zombs_friends" ) ) == 0 ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_zombs_both" ) ) == 2 ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_zplust" ) ) == 5 ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_zplust_adj" ) ) == 2 ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_smoks" ) ) == 1 ); + CHECK( std::stoi( globvars.get_global_value( "mons" ) ) == 8 ); + CHECK( std::stoi( globvars.get_global_value( "triffs" ) ) == 1 ); + CHECK( std::stoi( globvars.get_global_value( "group" ) ) == 4 ); + CHECK( std::stoi( globvars.get_global_value( "zombs" ) ) == 2 ); + CHECK( std::stoi( globvars.get_global_value( "zombs_friends" ) ) == 0 ); + CHECK( std::stoi( globvars.get_global_value( "zombs_both" ) ) == 2 ); + CHECK( std::stoi( globvars.get_global_value( "zplust" ) ) == 5 ); + CHECK( std::stoi( globvars.get_global_value( "zplust_adj" ) ) == 2 ); + CHECK( std::stoi( globvars.get_global_value( "smoks" ) ) == 1 ); friendo->make_friendly(); REQUIRE( effect_on_condition_EOC_mon_nearby_test->activate( d ) ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_zombs" ) ) == 1 ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_zombs_friends" ) ) == 1 ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_zombs_both" ) ) == 2 ); + CHECK( std::stoi( globvars.get_global_value( "zombs" ) ) == 1 ); + CHECK( std::stoi( globvars.get_global_value( "zombs_friends" ) ) == 1 ); + CHECK( std::stoi( globvars.get_global_value( "zombs_both" ) ) == 2 ); } TEST_CASE( "EOC_activity_ongoing", "[eoc][timed_event]" ) @@ -702,7 +702,7 @@ TEST_CASE( "EOC_activity_ongoing", "[eoc][timed_event]" ) complete_activity( get_avatar() ); // been going for 3 whole seconds should have incremented 3 times - CHECK( stoi( get_avatar().get_value( "npctalk_var_activitiy_incrementer" ) ) == 3 ); + CHECK( stoi( get_avatar().get_value( "activitiy_incrementer" ) ) == 3 ); } TEST_CASE( "EOC_stored_condition_test", "[eoc]" ) @@ -714,30 +714,30 @@ TEST_CASE( "EOC_stored_condition_test", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); - d.set_value( "npctalk_var_context", "0" ); + d.set_value( "context", "0" ); // running with a value of 0 will have the conditional evaluate to 0 CHECK( effect_on_condition_EOC_stored_condition_test->activate( d ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key1" ) ) == Approx( 0 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key2" ) ) == Approx( 0 ) ); - CHECK( std::stod( d.get_value( "npctalk_var_context" ) ) == Approx( 0 ) ); + CHECK( std::stod( globvars.get_global_value( "key1" ) ) == Approx( 0 ) ); + CHECK( std::stod( globvars.get_global_value( "key2" ) ) == Approx( 0 ) ); + CHECK( std::stod( d.get_value( "context" ) ) == Approx( 0 ) ); // try again with a different value globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); - d.set_value( "npctalk_var_context", "10" ); + d.set_value( "context", "10" ); // running with a value greater than 1 will have the conditional evaluate to 1 CHECK( effect_on_condition_EOC_stored_condition_test->activate( d ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key1" ) ) == Approx( 1 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key2" ) ) == Approx( 1 ) ); - CHECK( std::stod( d.get_value( "npctalk_var_context" ) ) == Approx( 10 ) ); + CHECK( std::stod( globvars.get_global_value( "key1" ) ) == Approx( 1 ) ); + CHECK( std::stod( globvars.get_global_value( "key2" ) ) == Approx( 1 ) ); + CHECK( std::stod( d.get_value( "context" ) ) == Approx( 10 ) ); } @@ -795,52 +795,52 @@ TEST_CASE( "EOC_meta_test", "[eoc]" ) globvars.clear_global_values(); CHECK( effect_on_condition_EOC_meta_test_talker_type->activate( d_avatar ) ); - CHECK( globvars.get_global_value( "npctalk_var_key_avatar" ) == "yes" ); - CHECK( globvars.get_global_value( "npctalk_var_key_npc" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_character" ) == "yes" ); - CHECK( globvars.get_global_value( "npctalk_var_key_monster" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_item" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_furniture" ).empty() ); + CHECK( globvars.get_global_value( "key_avatar" ) == "yes" ); + CHECK( globvars.get_global_value( "key_npc" ).empty() ); + CHECK( globvars.get_global_value( "key_character" ) == "yes" ); + CHECK( globvars.get_global_value( "key_monster" ).empty() ); + CHECK( globvars.get_global_value( "key_item" ).empty() ); + CHECK( globvars.get_global_value( "key_furniture" ).empty() ); globvars.clear_global_values(); CHECK( effect_on_condition_EOC_meta_test_talker_type->activate( d_npc ) ); - CHECK( globvars.get_global_value( "npctalk_var_key_avatar" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_npc" ) == "yes" ); - CHECK( globvars.get_global_value( "npctalk_var_key_character" ) == "yes" ); - CHECK( globvars.get_global_value( "npctalk_var_key_monster" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_item" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_furniture" ).empty() ); + CHECK( globvars.get_global_value( "key_avatar" ).empty() ); + CHECK( globvars.get_global_value( "key_npc" ) == "yes" ); + CHECK( globvars.get_global_value( "key_character" ) == "yes" ); + CHECK( globvars.get_global_value( "key_monster" ).empty() ); + CHECK( globvars.get_global_value( "key_item" ).empty() ); + CHECK( globvars.get_global_value( "key_furniture" ).empty() ); globvars.clear_global_values(); CHECK( effect_on_condition_EOC_meta_test_talker_type->activate( d_monster ) ); - CHECK( globvars.get_global_value( "npctalk_var_key_avatar" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_npc" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_character" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_monster" ) == "yes" ); - CHECK( globvars.get_global_value( "npctalk_var_key_item" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_furniture" ).empty() ); + CHECK( globvars.get_global_value( "key_avatar" ).empty() ); + CHECK( globvars.get_global_value( "key_npc" ).empty() ); + CHECK( globvars.get_global_value( "key_character" ).empty() ); + CHECK( globvars.get_global_value( "key_monster" ) == "yes" ); + CHECK( globvars.get_global_value( "key_item" ).empty() ); + CHECK( globvars.get_global_value( "key_furniture" ).empty() ); globvars.clear_global_values(); CHECK( effect_on_condition_EOC_meta_test_talker_type->activate( d_item ) ); - CHECK( globvars.get_global_value( "npctalk_var_key_avatar" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_npc" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_character" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_monster" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_item" ) == "yes" ); - CHECK( globvars.get_global_value( "npctalk_var_key_furniture" ).empty() ); + CHECK( globvars.get_global_value( "key_avatar" ).empty() ); + CHECK( globvars.get_global_value( "key_npc" ).empty() ); + CHECK( globvars.get_global_value( "key_character" ).empty() ); + CHECK( globvars.get_global_value( "key_monster" ).empty() ); + CHECK( globvars.get_global_value( "key_item" ) == "yes" ); + CHECK( globvars.get_global_value( "key_furniture" ).empty() ); globvars.clear_global_values(); CHECK( effect_on_condition_EOC_meta_test_talker_type->activate( d_furniture ) ); - CHECK( globvars.get_global_value( "npctalk_var_key_avatar" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_npc" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_character" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_monster" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_item" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key_furniture" ) == "yes" ); + CHECK( globvars.get_global_value( "key_avatar" ).empty() ); + CHECK( globvars.get_global_value( "key_npc" ).empty() ); + CHECK( globvars.get_global_value( "key_character" ).empty() ); + CHECK( globvars.get_global_value( "key_monster" ).empty() ); + CHECK( globvars.get_global_value( "key_item" ).empty() ); + CHECK( globvars.get_global_value( "key_furniture" ) == "yes" ); } TEST_CASE( "EOC_increment_var_var", "[eoc]" ) @@ -852,15 +852,15 @@ TEST_CASE( "EOC_increment_var_var", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); CHECK( effect_on_condition_EOC_increment_var_var->activate( d ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key1" ) ) == Approx( 5 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key2" ) ) == Approx( 10 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_global_u" ) ) == Approx( 6 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_global_context" ) ) == Approx( 4 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_global_nested" ) ) == Approx( 2 ) ); + CHECK( std::stod( globvars.get_global_value( "key1" ) ) == Approx( 5 ) ); + CHECK( std::stod( globvars.get_global_value( "key2" ) ) == Approx( 10 ) ); + CHECK( std::stod( globvars.get_global_value( "global_u" ) ) == Approx( 6 ) ); + CHECK( std::stod( globvars.get_global_value( "global_context" ) ) == Approx( 4 ) ); + CHECK( std::stod( globvars.get_global_value( "global_nested" ) ) == Approx( 2 ) ); } TEST_CASE( "EOC_string_var_var", "[eoc]" ) @@ -872,16 +872,16 @@ TEST_CASE( "EOC_string_var_var", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key3" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key4" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key3" ).empty() ); + REQUIRE( globvars.get_global_value( "key4" ).empty() ); CHECK( effect_on_condition_EOC_string_var_var->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key1" ) == "Works_global" ); - CHECK( globvars.get_global_value( "npctalk_var_key2" ) == "Works_context" ); - CHECK( globvars.get_global_value( "npctalk_var_key3" ) == "Works_u" ); - CHECK( globvars.get_global_value( "npctalk_var_key4" ) == "Works_npc" ); + CHECK( globvars.get_global_value( "key1" ) == "Works_global" ); + CHECK( globvars.get_global_value( "key2" ) == "Works_context" ); + CHECK( globvars.get_global_value( "key3" ) == "Works_u" ); + CHECK( globvars.get_global_value( "key4" ) == "Works_npc" ); } TEST_CASE( "EOC_run_with_test", "[eoc]" ) @@ -893,19 +893,19 @@ TEST_CASE( "EOC_run_with_test", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key3" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key3" ).empty() ); CHECK( effect_on_condition_EOC_run_with_test->activate( d ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key1" ) ) == Approx( 1 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key2" ) ) == Approx( 2 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key3" ) ) == Approx( 3 ) ); + CHECK( std::stod( globvars.get_global_value( "key1" ) ) == Approx( 1 ) ); + CHECK( std::stod( globvars.get_global_value( "key2" ) ) == Approx( 2 ) ); + CHECK( std::stod( globvars.get_global_value( "key3" ) ) == Approx( 3 ) ); // value shouldn't exist in the original dialogue - CHECK( d.get_value( "npctalk_var_key" ).empty() ); - CHECK( d.get_value( "npctalk_var_key2" ).empty() ); - CHECK( d.get_value( "npctalk_var_key3" ).empty() ); + CHECK( d.get_value( "key" ).empty() ); + CHECK( d.get_value( "key2" ).empty() ); + CHECK( d.get_value( "key3" ).empty() ); } TEST_CASE( "EOC_run_until_test", "[eoc]" ) @@ -917,10 +917,10 @@ TEST_CASE( "EOC_run_until_test", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); CHECK( effect_on_condition_EOC_run_until_test->activate( d ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key1" ) ) == Approx( 10000 ) ); + CHECK( std::stod( globvars.get_global_value( "key1" ) ) == Approx( 10000 ) ); } TEST_CASE( "EOC_run_with_test_expects", "[eoc]" ) @@ -932,23 +932,23 @@ TEST_CASE( "EOC_run_with_test_expects", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key3" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key3" ).empty() ); CHECK( capture_debugmsg_during( [&]() { effect_on_condition_EOC_run_with_test_expects_fail->activate( d ); } ) == "Missing required variables: key1, key2, key3, " ); - CHECK( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key2" ).empty() ); - CHECK( globvars.get_global_value( "npctalk_var_key3" ).empty() ); + CHECK( globvars.get_global_value( "key1" ).empty() ); + CHECK( globvars.get_global_value( "key2" ).empty() ); + CHECK( globvars.get_global_value( "key3" ).empty() ); globvars.clear_global_values(); effect_on_condition_EOC_run_with_test_expects_pass->activate( d ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key1" ) ) == Approx( 1 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key2" ) ) == Approx( 2 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key3" ) ) == Approx( 3 ) ); + CHECK( std::stod( globvars.get_global_value( "key1" ) ) == Approx( 1 ) ); + CHECK( std::stod( globvars.get_global_value( "key2" ) ) == Approx( 2 ) ); + CHECK( std::stod( globvars.get_global_value( "key3" ) ) == Approx( 3 ) ); } TEST_CASE( "EOC_run_with_test_queue", "[eoc]" ) @@ -960,23 +960,23 @@ TEST_CASE( "EOC_run_with_test_queue", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key3" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key3" ).empty() ); CHECK( effect_on_condition_EOC_run_with_test_queued->activate( d ) ); set_time( calendar::turn + 2_seconds ); effect_on_conditions::process_effect_on_conditions( get_avatar() ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key1" ) ) == Approx( 1 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key2" ) ) == Approx( 2 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_key3" ) ) == Approx( 3 ) ); + CHECK( std::stod( globvars.get_global_value( "key1" ) ) == Approx( 1 ) ); + CHECK( std::stod( globvars.get_global_value( "key2" ) ) == Approx( 2 ) ); + CHECK( std::stod( globvars.get_global_value( "key3" ) ) == Approx( 3 ) ); // value shouldn't exist in the original dialogue - CHECK( d.get_value( "npctalk_var_key" ).empty() ); - CHECK( d.get_value( "npctalk_var_key2" ).empty() ); - CHECK( d.get_value( "npctalk_var_key3" ).empty() ); + CHECK( d.get_value( "key" ).empty() ); + CHECK( d.get_value( "key2" ).empty() ); + CHECK( d.get_value( "key3" ).empty() ); } TEST_CASE( "EOC_run_inv_test", "[eoc]" ) @@ -991,7 +991,7 @@ TEST_CASE( "EOC_run_inv_test", "[eoc]" ) effect_on_condition_EOC_run_inv_prepare->activate( d ); std::vector items_before = get_avatar().items_with( []( const item & it ) { - return it.get_var( "npctalk_var_general_run_inv_test_key1" ).empty(); + return it.get_var( "general_run_inv_test_key1" ).empty(); } ); REQUIRE( items_before.size() == 4 ); @@ -1000,7 +1000,7 @@ TEST_CASE( "EOC_run_inv_test", "[eoc]" ) CHECK( effect_on_condition_EOC_run_inv_test1->activate( d ) ); std::vector items_after = get_avatar().items_with( []( const item & it ) { - return it.get_var( "npctalk_var_general_run_inv_test_key1" ) == "yes"; + return it.get_var( "general_run_inv_test_key1" ) == "yes"; } ); CHECK( items_after.size() == 4 ); @@ -1009,7 +1009,7 @@ TEST_CASE( "EOC_run_inv_test", "[eoc]" ) CHECK( effect_on_condition_EOC_run_inv_test2->activate( d ) ); items_after = get_avatar().items_with( []( const item & it ) { - return it.get_var( "npctalk_var_general_run_inv_test_key2" ) == "yes"; + return it.get_var( "general_run_inv_test_key2" ) == "yes"; } ); CHECK( items_after.size() == 1 ); @@ -1018,7 +1018,7 @@ TEST_CASE( "EOC_run_inv_test", "[eoc]" ) CHECK( effect_on_condition_EOC_run_inv_test3->activate( d ) ); items_after = get_avatar().items_with( []( const item & it ) { - return it.get_var( "npctalk_var_general_run_inv_test_key3" ) == "yes"; + return it.get_var( "general_run_inv_test_key3" ) == "yes"; } ); CHECK( items_after.empty() ); @@ -1030,7 +1030,7 @@ TEST_CASE( "EOC_run_inv_test", "[eoc]" ) CHECK( effect_on_condition_EOC_run_inv_test3->activate( d ) ); items_after = get_avatar().items_with( []( const item & it ) { - return it.get_var( "npctalk_var_general_run_inv_test_key3" ) == "yes"; + return it.get_var( "general_run_inv_test_key3" ) == "yes"; } ); CHECK( items_after.size() == 1 ); @@ -1039,7 +1039,7 @@ TEST_CASE( "EOC_run_inv_test", "[eoc]" ) CHECK( effect_on_condition_EOC_run_inv_test4->activate( d ) ); items_after = get_avatar().items_with( []( const item & it ) { - return it.get_var( "npctalk_var_general_run_inv_test_key4" ) == "yes"; + return it.get_var( "general_run_inv_test_key4" ) == "yes"; } ); CHECK( items_after.size() == 1 ); @@ -1048,7 +1048,7 @@ TEST_CASE( "EOC_run_inv_test", "[eoc]" ) CHECK( effect_on_condition_EOC_run_inv_test5->activate( d ) ); items_after = get_avatar().items_with( []( const item & it ) { - return it.get_var( "npctalk_var_general_run_inv_test_key5" ) == "yes"; + return it.get_var( "general_run_inv_test_key5" ) == "yes"; } ); CHECK( items_after.size() == 3 ); @@ -1057,7 +1057,7 @@ TEST_CASE( "EOC_run_inv_test", "[eoc]" ) CHECK( effect_on_condition_EOC_item_flag_test->activate( d ) ); items_after = get_avatar().items_with( []( const item & it ) { - return it.get_var( "npctalk_var_general_run_inv_test_is_filthy" ) == "yes"; + return it.get_var( "general_run_inv_test_is_filthy" ) == "yes"; } ); CHECK( items_after.size() == 1 ); @@ -1096,10 +1096,10 @@ TEST_CASE( "EOC_run_inv_test", "[eoc]" ) const item &check_item = get_avatar().worn.i_at( 0 ); REQUIRE( check_item.typeId() == itype_backpack ); - CHECK( std::stod( get_avatar().get_value( "npctalk_var_key1" ) ) == Approx( 27 ) ); - CHECK( std::stod( get_avatar().get_value( "npctalk_var_key2" ) ) == Approx( 2 ) ); - CHECK( std::stod( check_item.get_var( "npctalk_var_key1" ) ) == Approx( 27 ) ); - CHECK( std::stod( check_item.get_var( "npctalk_var_key2" ) ) == Approx( 2 ) ); + CHECK( std::stod( get_avatar().get_value( "key1" ) ) == Approx( 27 ) ); + CHECK( std::stod( get_avatar().get_value( "key2" ) ) == Approx( 2 ) ); + CHECK( std::stod( check_item.get_var( "key1" ) ) == Approx( 27 ) ); + CHECK( std::stod( check_item.get_var( "key2" ) ) == Approx( 2 ) ); } TEST_CASE( "math_weapon_damage", "[eoc]" ) @@ -1123,10 +1123,10 @@ TEST_CASE( "math_weapon_damage", "[eoc]" ) int const bullet_damage = myweapon.gun_damage().type_damage( STATIC( damage_type_id( "bullet" ) ) ); CAPTURE( myweapon.typeId().c_str() ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_mymelee" ) ) == total_damage ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_mymelee_bash" ) ) == bash_damage ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_mygun" ) ) == gun_damage ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_mygun_bullet" ) ) == bullet_damage ); + CHECK( std::stoi( globvars.get_global_value( "mymelee" ) ) == total_damage ); + CHECK( std::stoi( globvars.get_global_value( "mymelee_bash" ) ) == bash_damage ); + CHECK( std::stoi( globvars.get_global_value( "mygun" ) ) == gun_damage ); + CHECK( std::stoi( globvars.get_global_value( "mygun_bullet" ) ) == bullet_damage ); } TEST_CASE( "EOC_event_test", "[eoc]" ) @@ -1138,51 +1138,51 @@ TEST_CASE( "EOC_event_test", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key2" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key3" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key2" ).empty() ); + REQUIRE( globvars.get_global_value( "key3" ).empty() ); // character_casts_spell spell temp_spell( spell_test_eoc_spell ); temp_spell.set_level( get_avatar(), 5 ); temp_spell.cast_all_effects( get_avatar(), tripoint_bub_ms() ); - CHECK( globvars.get_global_value( "npctalk_var_key1" ) == "test_eoc_spell" ); - CHECK( globvars.get_global_value( "npctalk_var_key2" ) == "test_trait" ); - CHECK( globvars.get_global_value( "npctalk_var_key3" ) == "5" ); - CHECK( globvars.get_global_value( "npctalk_var_key4" ) == "150" ); - CHECK( globvars.get_global_value( "npctalk_var_key5" ) == "100" ); - CHECK( globvars.get_global_value( "npctalk_var_key6" ) == "45" ); + CHECK( globvars.get_global_value( "key1" ) == "test_eoc_spell" ); + CHECK( globvars.get_global_value( "key2" ) == "test_trait" ); + CHECK( globvars.get_global_value( "key3" ) == "5" ); + CHECK( globvars.get_global_value( "key4" ) == "150" ); + CHECK( globvars.get_global_value( "key5" ) == "100" ); + CHECK( globvars.get_global_value( "key6" ) == "45" ); // character_starts_activity globvars.clear_global_values(); get_avatar().assign_activity( ACT_GENERIC_EOC, 1 ); - CHECK( globvars.get_global_value( "npctalk_var_key1" ) == "ACT_GENERIC_EOC" ); - CHECK( globvars.get_global_value( "npctalk_var_key2" ) == "0" ); - CHECK( globvars.get_global_value( "npctalk_var_key3" ) == "activity start" ); + CHECK( globvars.get_global_value( "key1" ) == "ACT_GENERIC_EOC" ); + CHECK( globvars.get_global_value( "key2" ) == "0" ); + CHECK( globvars.get_global_value( "key3" ) == "activity start" ); // character_finished_activity get_avatar().cancel_activity(); - CHECK( globvars.get_global_value( "npctalk_var_key1" ) == "ACT_GENERIC_EOC" ); - CHECK( globvars.get_global_value( "npctalk_var_key2" ) == "1" ); - CHECK( globvars.get_global_value( "npctalk_var_key3" ) == "activity finished" ); + CHECK( globvars.get_global_value( "key1" ) == "ACT_GENERIC_EOC" ); + CHECK( globvars.get_global_value( "key2" ) == "1" ); + CHECK( globvars.get_global_value( "key3" ) == "activity finished" ); // character_wields_item item weapon_item( itype_test_knife_combat ); get_avatar().wield( weapon_item ); item_location weapon = get_avatar().get_wielded_item(); - CHECK( get_avatar().get_value( "npctalk_var_test_event_last_event" ) == "character_wields_item" ); - CHECK( weapon->get_var( "npctalk_var_test_event_last_event" ) == "character_wields_item" ); + CHECK( get_avatar().get_value( "test_event_last_event" ) == "character_wields_item" ); + CHECK( weapon->get_var( "test_event_last_event" ) == "character_wields_item" ); // character_wears_item std::list::iterator armor = *get_avatar().worn.wear_item( get_avatar(), item( itype_backpack ), false, true, true ); - CHECK( get_avatar().get_value( "npctalk_var_test_event_last_event" ) == "character_wears_item" ); - CHECK( armor->get_var( "npctalk_var_test_event_last_event" ) == "character_wears_item" ); + CHECK( get_avatar().get_value( "test_event_last_event" ) == "character_wears_item" ); + CHECK( armor->get_var( "test_event_last_event" ) == "character_wears_item" ); } TEST_CASE( "EOC_combat_event_test", "[eoc]" ) @@ -1200,24 +1200,24 @@ TEST_CASE( "EOC_combat_event_test", "[eoc]" ) get_avatar().wield( weapon_item ); get_avatar().melee_attack( npc_dst_melee, false ); - CHECK( get_avatar().get_value( "npctalk_var_test_event_last_event" ) == + CHECK( get_avatar().get_value( "test_event_last_event" ) == "character_melee_attacks_character" ); - CHECK( npc_dst_melee.get_value( "npctalk_var_test_event_last_event" ) == + CHECK( npc_dst_melee.get_value( "test_event_last_event" ) == "character_melee_attacks_character" ); - CHECK( globvars.get_global_value( "npctalk_var_weapon" ) == "test_knife_combat" ); - CHECK( globvars.get_global_value( "npctalk_var_victim_name" ) == npc_dst_melee.get_name() ); + CHECK( globvars.get_global_value( "weapon" ) == "test_knife_combat" ); + CHECK( globvars.get_global_value( "victim_name" ) == npc_dst_melee.get_name() ); // character_melee_attacks_monster clear_map(); monster &mon_dst_melee = spawn_test_monster( "mon_zombie", get_avatar().pos_bub() + tripoint_east ); get_avatar().melee_attack( mon_dst_melee, false ); - CHECK( get_avatar().get_value( "npctalk_var_test_event_last_event" ) == + CHECK( get_avatar().get_value( "test_event_last_event" ) == "character_melee_attacks_monster" ); - CHECK( mon_dst_melee.get_value( "npctalk_var_test_event_last_event" ) == + CHECK( mon_dst_melee.get_value( "test_event_last_event" ) == "character_melee_attacks_monster" ); - CHECK( globvars.get_global_value( "npctalk_var_weapon" ) == "test_knife_combat" ); - CHECK( globvars.get_global_value( "npctalk_var_victim_type" ) == "mon_zombie" ); + CHECK( globvars.get_global_value( "weapon" ) == "test_knife_combat" ); + CHECK( globvars.get_global_value( "victim_type" ) == "mon_zombie" ); // character_ranged_attacks_character const tripoint_bub_ms target_pos = get_avatar().pos_bub() + point_east; @@ -1228,17 +1228,17 @@ TEST_CASE( "EOC_combat_event_test", "[eoc]" ) arm_shooter( get_avatar(), "shotgun_s" ); get_avatar().recoil = 0; get_avatar().fire_gun( target_pos, 1, *get_avatar().get_wielded_item() ); - if( !npc_dst_ranged.get_value( "npctalk_var_test_event_last_event" ).empty() ) { + if( !npc_dst_ranged.get_value( "test_event_last_event" ).empty() ) { break; } } - CHECK( get_avatar().get_value( "npctalk_var_test_event_last_event" ) == + CHECK( get_avatar().get_value( "test_event_last_event" ) == "character_ranged_attacks_character" ); - CHECK( npc_dst_ranged.get_value( "npctalk_var_test_event_last_event" ) == + CHECK( npc_dst_ranged.get_value( "test_event_last_event" ) == "character_ranged_attacks_character" ); - CHECK( globvars.get_global_value( "npctalk_var_weapon" ) == "shotgun_s" ); - CHECK( globvars.get_global_value( "npctalk_var_victim_name" ) == npc_dst_ranged.get_name() ); + CHECK( globvars.get_global_value( "weapon" ) == "shotgun_s" ); + CHECK( globvars.get_global_value( "victim_name" ) == npc_dst_ranged.get_name() ); // character_ranged_attacks_monster clear_map(); @@ -1248,26 +1248,26 @@ TEST_CASE( "EOC_combat_event_test", "[eoc]" ) arm_shooter( get_avatar(), "shotgun_s" ); get_avatar().recoil = 0; get_avatar().fire_gun( mon_dst_ranged.pos_bub(), 1, *get_avatar().get_wielded_item() ); - if( !mon_dst_ranged.get_value( "npctalk_var_test_event_last_event" ).empty() ) { + if( !mon_dst_ranged.get_value( "test_event_last_event" ).empty() ) { break; } } - CHECK( get_avatar().get_value( "npctalk_var_test_event_last_event" ) == + CHECK( get_avatar().get_value( "test_event_last_event" ) == "character_ranged_attacks_monster" ); - CHECK( mon_dst_ranged.get_value( "npctalk_var_test_event_last_event" ) == + CHECK( mon_dst_ranged.get_value( "test_event_last_event" ) == "character_ranged_attacks_monster" ); - CHECK( globvars.get_global_value( "npctalk_var_weapon" ) == "shotgun_s" ); - CHECK( globvars.get_global_value( "npctalk_var_victim_type" ) == "mon_zombie" ); + CHECK( globvars.get_global_value( "weapon" ) == "shotgun_s" ); + CHECK( globvars.get_global_value( "victim_type" ) == "mon_zombie" ); // character_kills_monster clear_map(); monster &victim = spawn_test_monster( "mon_zombie", target_pos ); victim.die( &get_avatar() ); - CHECK( get_avatar().get_value( "npctalk_var_test_event_last_event" ) == "character_kills_monster" ); - CHECK( globvars.get_global_value( "npctalk_var_victim_type" ) == "mon_zombie" ); - CHECK( globvars.get_global_value( "npctalk_var_test_exp" ) == "4" ); + CHECK( get_avatar().get_value( "test_event_last_event" ) == "character_kills_monster" ); + CHECK( globvars.get_global_value( "victim_type" ) == "mon_zombie" ); + CHECK( globvars.get_global_value( "test_exp" ) == "4" ); } TEST_CASE( "EOC_spell_exp", "[eoc]" ) @@ -1279,13 +1279,13 @@ TEST_CASE( "EOC_spell_exp", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key1" ).empty() ); + REQUIRE( globvars.get_global_value( "key1" ).empty() ); get_avatar().magic->learn_spell( "test_eoc_spell", get_avatar(), true ); CHECK( effect_on_condition_EOC_math_spell_xp->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key1" ) == "1000" ); + CHECK( globvars.get_global_value( "key1" ) == "1000" ); } TEST_CASE( "EOC_recipe_test", "[eoc]" ) @@ -1321,16 +1321,16 @@ TEST_CASE( "EOC_map_test", "[eoc]" ) m.furn_set( tgt, furn_test_f_eoc ); m.furn( tgt )->examine( get_avatar(), tgt ); - CHECK( globvars.get_global_value( "npctalk_var_this" ) == "test_f_eoc" ); - CHECK( globvars.get_global_value( "npctalk_var_pos" ) == m.getglobal( tgt ).to_string() ); + CHECK( globvars.get_global_value( "this" ) == "test_f_eoc" ); + CHECK( globvars.get_global_value( "pos" ) == m.getglobal( tgt ).to_string() ); const tripoint_bub_ms target_pos = get_avatar().pos_bub() + point_east * 10; npc &npc_dst = spawn_npc( target_pos.xy(), "thug" ); dialogue d( get_talker_for( get_avatar() ), get_talker_for( npc_dst ) ); CHECK( effect_on_condition_EOC_map_test->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key_distance_loc" ) == "14" ); - CHECK( globvars.get_global_value( "npctalk_var_key_distance_npc" ) == "10" ); + CHECK( globvars.get_global_value( "key_distance_loc" ) == "14" ); + CHECK( globvars.get_global_value( "key_distance_npc" ) == "10" ); } TEST_CASE( "EOC_loc_relative_test", "[eoc]" ) @@ -1354,9 +1354,9 @@ TEST_CASE( "EOC_loc_relative_test", "[eoc]" ) CHECK( effect_on_condition_EOC_loc_relative_test->activate( d ) ); tripoint_abs_ms tmp_abs_a = tripoint_abs_ms( tripoint::from_string( - globvars.get_global_value( "npctalk_var_map_test_loc_a" ) ) ); + globvars.get_global_value( "map_test_loc_a" ) ) ); tripoint_abs_ms tmp_abs_b = tripoint_abs_ms( tripoint::from_string( - globvars.get_global_value( "npctalk_var_map_test_loc_b" ) ) ); + globvars.get_global_value( "map_test_loc_b" ) ) ); CHECK( m.bub_from_abs( tmp_abs_a ) == tripoint_bub_ms( 70, 70, 0 ) ); CHECK( m.bub_from_abs( tmp_abs_b ) == tripoint_bub_ms( 70, 60, 0 ) ); @@ -1401,17 +1401,17 @@ TEST_CASE( "EOC_string_test", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_key3" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_key4" ).empty() ); + REQUIRE( globvars.get_global_value( "key3" ).empty() ); + REQUIRE( globvars.get_global_value( "key4" ).empty() ); CHECK( effect_on_condition_EOC_string_test->activate( d ) ); - CHECK( globvars.get_global_value( "npctalk_var_key3" ) == " " ); - CHECK( globvars.get_global_value( "npctalk_var_key4" ) == "test1 test2" ); + CHECK( globvars.get_global_value( "key3" ) == " " ); + CHECK( globvars.get_global_value( "key4" ) == "test1 test2" ); CHECK( effect_on_condition_EOC_string_test_nest->activate( d ) ); - CHECK( get_avatar().get_value( "npctalk_var_key1" ) == "nest2" ); - CHECK( get_avatar().get_value( "npctalk_var_key2" ) == "nest3" ); - CHECK( get_avatar().get_value( "npctalk_var_key3" ) == "nest4" ); + CHECK( get_avatar().get_value( "key1" ) == "nest2" ); + CHECK( get_avatar().get_value( "key2" ) == "nest3" ); + CHECK( get_avatar().get_value( "key3" ) == "nest4" ); } TEST_CASE( "EOC_run_eocs", "[eoc]" ) @@ -1423,12 +1423,12 @@ TEST_CASE( "EOC_run_eocs", "[eoc]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - REQUIRE( globvars.get_global_value( "npctalk_var_run_eocs_1" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_run_eocs_2" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_run_eocs_3" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_run_eocs_5" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_test_global_key_M" ).empty() ); - REQUIRE( globvars.get_global_value( "npctalk_var_test_global_key_N" ).empty() ); + REQUIRE( globvars.get_global_value( "run_eocs_1" ).empty() ); + REQUIRE( globvars.get_global_value( "run_eocs_2" ).empty() ); + REQUIRE( globvars.get_global_value( "run_eocs_3" ).empty() ); + REQUIRE( globvars.get_global_value( "run_eocs_5" ).empty() ); + REQUIRE( globvars.get_global_value( "test_global_key_M" ).empty() ); + REQUIRE( globvars.get_global_value( "test_global_key_N" ).empty() ); CHECK( effect_on_condition_run_eocs_1->activate( d ) ); CHECK( effect_on_condition_run_eocs_2->activate( d ) ); @@ -1436,21 +1436,21 @@ TEST_CASE( "EOC_run_eocs", "[eoc]" ) CHECK( effect_on_condition_run_eocs_5->activate( d ) ); CHECK( effect_on_condition_run_eocs_7->activate( d ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_run_eocs_1" ) ) == Approx( 2 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_run_eocs_2" ) ) == Approx( 20 ) ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_run_eocs_5" ) ) == Approx( 4 ) ); + CHECK( std::stod( globvars.get_global_value( "run_eocs_1" ) ) == Approx( 2 ) ); + CHECK( std::stod( globvars.get_global_value( "run_eocs_2" ) ) == Approx( 20 ) ); + CHECK( std::stod( globvars.get_global_value( "run_eocs_5" ) ) == Approx( 4 ) ); set_time( calendar::turn + 1_seconds ); effect_on_conditions::process_effect_on_conditions( get_avatar() ); - REQUIRE( globvars.get_global_value( "npctalk_var_run_eocs_3" ).empty() ); + REQUIRE( globvars.get_global_value( "run_eocs_3" ).empty() ); set_time( calendar::turn + 1_seconds ); effect_on_conditions::process_effect_on_conditions( get_avatar() ); - CHECK( std::stod( globvars.get_global_value( "npctalk_var_run_eocs_3" ) ) == Approx( 2 ) ); + CHECK( std::stod( globvars.get_global_value( "run_eocs_3" ) ) == Approx( 2 ) ); set_time( calendar::turn + 8_seconds ); effect_on_conditions::process_effect_on_conditions( get_avatar() ); - CHECK( globvars.get_global_value( "npctalk_var_test_global_key_M" ) == "test_context_value_M" ); - CHECK( globvars.get_global_value( "npctalk_var_test_global_key_N" ) == "test_context_value_N" ); + CHECK( globvars.get_global_value( "test_global_key_M" ) == "test_context_value_M" ); + CHECK( globvars.get_global_value( "test_global_key_N" ) == "test_context_value_N" ); globvars.clear_global_values(); avatar &u = get_avatar(); @@ -1472,31 +1472,31 @@ TEST_CASE( "EOC_run_eocs", "[eoc]" ) talker *alpha_talker = d2.actor( false ); talker *beta_talker = d2.actor( true ); - d2.set_value( "npctalk_var_alpha_var", "u" ); - d2.set_value( "npctalk_var_beta_var", "npc" ); + d2.set_value( "alpha_var", "u" ); + d2.set_value( "beta_var", "npc" ); CHECK( effect_on_condition_run_eocs_talker_mixes->activate( d2 ) ); - CHECK( globvars.get_global_value( "npctalk_var_alpha_name" ) == alpha_talker->get_name() ); - CHECK( globvars.get_global_value( "npctalk_var_beta_name" ) == beta_talker->get_name() ); + CHECK( globvars.get_global_value( "alpha_name" ) == alpha_talker->get_name() ); + CHECK( globvars.get_global_value( "beta_name" ) == beta_talker->get_name() ); - d2.set_value( "npctalk_var_alpha_var", "npc" ); - d2.set_value( "npctalk_var_beta_var", "u" ); + d2.set_value( "alpha_var", "npc" ); + d2.set_value( "beta_var", "u" ); CHECK( effect_on_condition_run_eocs_talker_mixes->activate( d2 ) ); - CHECK( globvars.get_global_value( "npctalk_var_alpha_name" ) == beta_talker->get_name() ); - CHECK( globvars.get_global_value( "npctalk_var_beta_name" ) == alpha_talker->get_name() ); + CHECK( globvars.get_global_value( "alpha_name" ) == beta_talker->get_name() ); + CHECK( globvars.get_global_value( "beta_name" ) == alpha_talker->get_name() ); - d2.set_value( "npctalk_var_alpha_var", "avatar" ); - d2.set_value( "npctalk_var_beta_var", std::to_string( guy->getID().get_value() ) ); + d2.set_value( "alpha_var", "avatar" ); + d2.set_value( "beta_var", std::to_string( guy->getID().get_value() ) ); CHECK( effect_on_condition_run_eocs_talker_mixes->activate( d2 ) ); - CHECK( globvars.get_global_value( "npctalk_var_alpha_name" ) == get_avatar().get_name() ); - CHECK( globvars.get_global_value( "npctalk_var_beta_name" ) == guy->get_name() ); + CHECK( globvars.get_global_value( "alpha_name" ) == get_avatar().get_name() ); + CHECK( globvars.get_global_value( "beta_name" ) == guy->get_name() ); - d2.set_value( "npctalk_var_alpha_var", std::string{} ); - d2.set_value( "npctalk_var_beta_var", std::string{} ); + d2.set_value( "alpha_var", std::string{} ); + d2.set_value( "beta_var", std::string{} ); CHECK( effect_on_condition_run_eocs_talker_mixes->activate( d2 ) ); - CHECK( globvars.get_global_value( "npctalk_var_alpha_name" ) == "mixin fail alpha" ); - CHECK( globvars.get_global_value( "npctalk_var_beta_name" ) == "mixin fail beta" ); + CHECK( globvars.get_global_value( "alpha_name" ) == "mixin fail alpha" ); + CHECK( globvars.get_global_value( "beta_name" ) == "mixin fail beta" ); - d2.set_value( "npctalk_var_alpha_var", mon_loc.to_string() ); + d2.set_value( "alpha_var", mon_loc.to_string() ); CHECK( effect_on_condition_run_eocs_talker_mixes_loc->activate( d2 ) ); - CHECK( globvars.get_global_value( "npctalk_var_alpha_name" ) == zombie->get_name() ); + CHECK( globvars.get_global_value( "alpha_name" ) == zombie->get_name() ); } diff --git a/tests/faction_price_rules_test.cpp b/tests/faction_price_rules_test.cpp index 7dca30da08d22..7f987668bfba6 100644 --- a/tests/faction_price_rules_test.cpp +++ b/tests/faction_price_rules_test.cpp @@ -126,7 +126,7 @@ TEST_CASE( "faction_price_rules", "[npc][factions][trade]" ) Approx( units::to_cent( carafe.type->price_post ) * 1.25 ).margin( 1 ) ); } WHEN( "condition for price rules satisfied" ) { - guy.set_value( "npctalk_var_bool_allnighter_thirsty", "yes" ); + guy.set_value( "bool_allnighter_thirsty", "yes" ); REQUIRE( fac.get_price_rules( carafe, guy )->markup == 2.0 ); THEN( "NPC selling to avatar includes markup and positive fixed adjustment" ) { REQUIRE( npc_trading::adjusted_price( &carafe, 1, get_avatar(), guy ) == @@ -141,7 +141,7 @@ TEST_CASE( "faction_price_rules", "[npc][factions][trade]" ) double const fmarkup = fac.get_price_rules( pants_fur, guy )->markup; REQUIRE( guy.get_price_rules( pants_fur )->markup == fmarkup ); REQUIRE( fmarkup != - 100 ); - guy.set_value( "npctalk_var_bool_preference_vegan", "yes" ); + guy.set_value( "bool_preference_vegan", "yes" ); REQUIRE( guy.get_price_rules( pants_fur )->markup == -100 ); } WHEN( "price rule affects magazine contents" ) { diff --git a/tests/math_parser_test.cpp b/tests/math_parser_test.cpp index ac07089d7608c..ac821d4a80ec1 100644 --- a/tests/math_parser_test.cpp +++ b/tests/math_parser_test.cpp @@ -270,13 +270,13 @@ TEST_CASE( "math_parser_dialogue_integration", "[math_parser]" ) global_variables &globvars = get_globals(); // reading scoped variables - globvars.set_global_value( "npctalk_var_x", "100" ); + globvars.set_global_value( "x", "100" ); CHECK( testexp.parse( "x" ) ); CHECK( testexp.eval( d ) == Approx( 100 ) ); - get_avatar().set_value( "npctalk_var_x", "92" ); + get_avatar().set_value( "x", "92" ); CHECK( testexp.parse( "u_x" ) ); CHECK( testexp.eval( d ) == Approx( 92 ) ); - dude.set_value( "npctalk_var_x", "21" ); + dude.set_value( "x", "21" ); CHECK( testexp.parse( "n_x" ) ); CHECK( testexp.eval( d ) == Approx( 21 ) ); CHECK( testexp.parse( "x + u_x + n_x" ) ); @@ -290,7 +290,7 @@ TEST_CASE( "math_parser_dialogue_integration", "[math_parser]" ) CHECK( testexp.parse( "has_var(_ctx)?19:20" ) ); CHECK( testexp.eval( d ) == Approx( 20 ) ); - d.set_value( "npctalk_var_ctx", "14" ); + d.set_value( "ctx", "14" ); CHECK( testexp.parse( "_ctx" ) ); CHECK( testexp.eval( d ) == Approx( 14 ) ); @@ -318,7 +318,7 @@ TEST_CASE( "math_parser_dialogue_integration", "[math_parser]" ) CHECK( testexp.eval( d ) == 25000000 ); // evaluating string variables in dialogue functions - globvars.set_global_value( "npctalk_var_someskill", "survival" ); + globvars.set_global_value( "someskill", "survival" ); CHECK( testexp.parse( "u_skill(someskill)" ) ); get_avatar().set_skill_level( skill_survival, 3 ); CHECK( testexp.eval( d ) == 3 ); @@ -326,16 +326,16 @@ TEST_CASE( "math_parser_dialogue_integration", "[math_parser]" ) // assignment to scoped variables CHECK( testexp.parse( "u_testvar", true ) ); testexp.assign( d, 159 ); - CHECK( std::stoi( get_avatar().get_value( "npctalk_var_testvar" ) ) == 159 ); + CHECK( std::stoi( get_avatar().get_value( "testvar" ) ) == 159 ); CHECK( testexp.parse( "testvar", true ) ); testexp.assign( d, 259 ); - CHECK( std::stoi( globvars.get_global_value( "npctalk_var_testvar" ) ) == 259 ); + CHECK( std::stoi( globvars.get_global_value( "testvar" ) ) == 259 ); CHECK( testexp.parse( "n_testvar", true ) ); testexp.assign( d, 359 ); - CHECK( std::stoi( dude.get_value( "npctalk_var_testvar" ) ) == 359 ); + CHECK( std::stoi( dude.get_value( "testvar" ) ) == 359 ); CHECK( testexp.parse( "_testvar", true ) ); testexp.assign( d, 159 ); - CHECK( std::stoi( d.get_value( "npctalk_var_testvar" ) ) == 159 ); + CHECK( std::stoi( d.get_value( "testvar" ) ) == 159 ); // assignment to scoped values with u_val shim CHECK( testexp.parse( "u_val('stamina')", true ) ); diff --git a/tests/melee_test.cpp b/tests/melee_test.cpp index 7967fe6000ba0..41ad5dc7de4d8 100644 --- a/tests/melee_test.cpp +++ b/tests/melee_test.cpp @@ -334,15 +334,15 @@ static void check_damage_from_test_fire( const std::string &mon_id, int expected REQUIRE( mon.get_armor_type( damage_test_fire, body_part_bp_null ) == expected_resist ); REQUIRE( mon.is_immune_damage( damage_test_fire ) == is_immune ); REQUIRE( mon.get_hp() == mon.get_hp_max() ); - REQUIRE( dude.get_value( "npctalk_var_general_dmg_type_test_test_fire" ).empty() ); - REQUIRE( mon.get_value( "npctalk_var_general_dmg_type_test_test_fire" ).empty() ); + REQUIRE( dude.get_value( "general_dmg_type_test_test_fire" ).empty() ); + REQUIRE( mon.get_value( "general_dmg_type_test_test_fire" ).empty() ); dude.set_wielded_item( item( "test_fire_sword" ) ); dude.melee_attack( mon, false ); if( mon.get_hp() < mon.get_hp_max() ) { total_hits++; total_dmg += mon.get_hp_max() - mon.get_hp(); - if( mon.get_value( "npctalk_var_general_dmg_type_test_test_fire" ) == "target" ) { - REQUIRE( dude.get_value( "npctalk_var_general_dmg_type_test_test_fire" ) == "source" ); + if( mon.get_value( "general_dmg_type_test_test_fire" ) == "target" ) { + REQUIRE( dude.get_value( "general_dmg_type_test_test_fire" ) == "source" ); set_on_fire++; } } @@ -361,22 +361,22 @@ static void check_eocs_from_test_fire( const std::string &mon_id ) monster &mon = spawn_test_monster( mon_id, dude.pos_bub() + tripoint_east ); REQUIRE( mon.pos() == dude.pos() + tripoint_east ); REQUIRE( mon.get_hp() == mon.get_hp_max() ); - REQUIRE( dude.get_value( "npctalk_var_general_dmg_type_test_test_fire" ).empty() ); - REQUIRE( mon.get_value( "npctalk_var_general_dmg_type_test_test_fire" ).empty() ); + REQUIRE( dude.get_value( "general_dmg_type_test_test_fire" ).empty() ); + REQUIRE( mon.get_value( "general_dmg_type_test_test_fire" ).empty() ); item firesword( "test_fire_sword" ); dude.set_wielded_item( firesword ); for( int i = 0; i < 1000; ++i ) { - if( dude.melee_attack( mon, false ) && !dude.get_value( "npctalk_var_test_bp" ).empty() ) { + if( dude.melee_attack( mon, false ) && !dude.get_value( "test_bp" ).empty() ) { break; } } - CHECK( !dude.get_value( "npctalk_var_test_bp" ).empty() ); - if( mon.get_value( "npctalk_var_general_dmg_type_test_test_fire" ) == "target" ) { - REQUIRE( dude.get_value( "npctalk_var_general_dmg_type_test_test_fire" ) == "source" ); + CHECK( !dude.get_value( "test_bp" ).empty() ); + if( mon.get_value( "general_dmg_type_test_test_fire" ) == "target" ) { + REQUIRE( dude.get_value( "general_dmg_type_test_test_fire" ) == "source" ); } eoc_total_dmg = std::round( std::stod( - dude.get_value( "npctalk_var_test_damage_taken" ) ) ); + dude.get_value( "test_damage_taken" ) ) ); Messages::clear_messages(); CHECK( eoc_total_dmg == firesword.damage_melee( damage_test_fire ) ); @@ -400,15 +400,15 @@ static void check_damage_from_test_fire( const std::vector &armor_i REQUIRE( dude2.get_armor_type( damage_test_fire, checked_bp ) == expected_resist ); REQUIRE( dude2.is_immune_damage( damage_test_fire ) == is_immune ); REQUIRE( dude2.get_hp() == dude2.get_hp_max() ); - REQUIRE( dude.get_value( "npctalk_var_general_dmg_type_test_test_fire" ).empty() ); - REQUIRE( dude2.get_value( "npctalk_var_general_dmg_type_test_test_fire" ).empty() ); + REQUIRE( dude.get_value( "general_dmg_type_test_test_fire" ).empty() ); + REQUIRE( dude2.get_value( "general_dmg_type_test_test_fire" ).empty() ); dude.set_wielded_item( item( "test_fire_sword" ) ); dude.melee_attack( dude2, false ); if( dude2.get_hp() < dude2.get_hp_max() ) { total_hits++; total_dmg += dude2.get_hp_max() - dude2.get_hp(); - if( dude2.get_value( "npctalk_var_general_dmg_type_test_test_fire" ) == "target" ) { - REQUIRE( dude.get_value( "npctalk_var_general_dmg_type_test_test_fire" ) == "source" ); + if( dude2.get_value( "general_dmg_type_test_test_fire" ) == "target" ) { + REQUIRE( dude.get_value( "general_dmg_type_test_test_fire" ) == "source" ); set_on_fire++; } } diff --git a/tests/npc_blacklist_test.cpp b/tests/npc_blacklist_test.cpp index 1f24bc36a15f1..58b99a81fc05d 100644 --- a/tests/npc_blacklist_test.cpp +++ b/tests/npc_blacklist_test.cpp @@ -9,6 +9,6 @@ TEST_CASE( "npc_blacklist", "[npc][trade]" ) guy.load_npc_template( npc_template_test_npc_trader ); REQUIRE( guy.wants_to_buy( item( "bow_saw" ) ) ); - guy.set_value( "npctalk_var_bool_bigotry_hates_bow_saws", "yes" ); + guy.set_value( "bool_bigotry_hates_bow_saws", "yes" ); REQUIRE( !guy.wants_to_buy( item( "bow_saw" ) ) ); } diff --git a/tests/npc_shop_cons_rates_test.cpp b/tests/npc_shop_cons_rates_test.cpp index 215fc5f64e9e4..6f24a1843ead8 100644 --- a/tests/npc_shop_cons_rates_test.cpp +++ b/tests/npc_shop_cons_rates_test.cpp @@ -23,7 +23,7 @@ TEST_CASE( "npc_shop_cons_rates", "[npc][trade]" ) REQUIRE( myrates.get_rate( item( "bow_saw" ), guy ) == 2 ); } WHEN( "item is matched by typeid and condition is true" ) { - guy.set_value( "npctalk_var_bool_dinner_bow_saw_eater", "yes" ); + guy.set_value( "bool_dinner_bow_saw_eater", "yes" ); REQUIRE( myrates.get_rate( item( "bow_saw" ), guy ) == 99 ); } WHEN( "item is matched by category" ) { diff --git a/tests/npc_shopkeeper_item_groups_test.cpp b/tests/npc_shopkeeper_item_groups_test.cpp index 03be4beb6dbc3..76d05991fd644 100644 --- a/tests/npc_shopkeeper_item_groups_test.cpp +++ b/tests/npc_shopkeeper_item_groups_test.cpp @@ -83,7 +83,7 @@ TEST_CASE( "npc_shopkeeper_item_groups", "[npc][trade]" ) } } WHEN( "condition met" ) { - get_avatar().set_value( "npctalk_var_bool_test_tools_access", "yes" ); + get_avatar().set_value( "bool_test_tools_access", "yes" ); std::pair har_hammer = has_and_can_restock( guy, hammer ); THEN( "item is available for selling and restocking" ) { REQUIRE( har_hammer.first == true ); @@ -105,7 +105,7 @@ TEST_CASE( "npc_shopkeeper_item_groups", "[npc][trade]" ) } } WHEN( "condition met" ) { - get_avatar().set_value( "npctalk_var_bool_test_multitool_access", "yes" ); + get_avatar().set_value( "bool_test_multitool_access", "yes" ); std::pair har_multitool = has_and_can_restock( guy, multitool ); THEN( "item is available for selling and restocking" ) { REQUIRE( har_multitool.first == true ); @@ -133,7 +133,7 @@ TEST_CASE( "npc_shopkeeper_item_groups", "[npc][trade]" ) } } WHEN( "condition for contents met" ) { - get_avatar().set_value( "npctalk_var_bool_test_multitool_access", "yes" ); + get_avatar().set_value( "bool_test_multitool_access", "yes" ); THEN( "container can be sold" ) { REQUIRE( guy.wants_to_sell( loc ) ); } diff --git a/tests/npc_talk_test.cpp b/tests/npc_talk_test.cpp index c6cb8f9bb26da..e99a0d9aadf7f 100644 --- a/tests/npc_talk_test.cpp +++ b/tests/npc_talk_test.cpp @@ -129,7 +129,7 @@ static npc &prep_test( dialogue &d, bool shopkeep = false ) clear_vehicles(); clear_map(); avatar &player_character = get_avatar(); - player_character.set_value( "npctalk_var_test_var", "It's avatar" ); + player_character.set_value( "test_var", "It's avatar" ); player_character.name = "Alpha Avatar"; REQUIRE_FALSE( player_character.in_vehicle ); @@ -139,7 +139,7 @@ static npc &prep_test( dialogue &d, bool shopkeep = false ) g->faction_manager_ptr->create_if_needed(); npc &beta = create_test_talker( shopkeep ); - beta.set_value( "npctalk_var_test_var", "It's npc" ); + beta.set_value( "test_var", "It's npc" ); d = dialogue( get_talker_for( player_character ), get_talker_for( beta ) ); return beta; } @@ -1013,10 +1013,10 @@ TEST_CASE( "npc_test_tags", "[npc_talk]" ) prep_test( d ); global_variables &globvars = get_globals(); - globvars.set_global_value( "npctalk_var_test_var", "It's global" ); + globvars.set_global_value( "test_var", "It's global" ); d.add_topic( "TALK_TEST_TAGS" ); - d.set_value( "npctalk_var_test_var", "It's context" ); + d.set_value( "test_var", "It's context" ); gen_response_lines( d, 8 ); CHECK( d.responses[0].create_option_line( d, input_event() ).text == "Avatar tag is set to It's avatar." ); @@ -1078,7 +1078,7 @@ TEST_CASE( "npc_compare_int", "[npc_talk]" ) it.get_category_shallow().get_id() == item_category_food || it.typeId() == itype_bottle_glass; } ); - player_character.remove_value( "npctalk_var_test_var_time_test_test" ); + player_character.remove_value( "test_var_time_test_test" ); calendar::turn = calendar::turn_zero; int expected_answers = 7; @@ -1215,7 +1215,7 @@ TEST_CASE( "npc_compare_int", "[npc_talk]" ) CHECK( d.responses[ 15 ].text == "This is a time since u_var test response for > 3_days." ); // Teardown - player_character.remove_value( "npctalk_var_test_var_time_test_test" ); + player_character.remove_value( "test_var_time_test_test" ); } TEST_CASE( "npc_arithmetic", "[npc_talk]" ) @@ -1287,7 +1287,7 @@ TEST_CASE( "npc_arithmetic", "[npc_talk]" ) effects.apply( d ); CHECK( player_character.per_max == 9 ); - std::string var_name = "npctalk_var_test_var_time_test_test"; + std::string var_name = "test_var_time_test_test"; player_character.set_value( var_name, std::to_string( 1 ) ); // "Sets custom var to 10." effects = d.responses[ 9 ].success; @@ -1519,5 +1519,5 @@ TEST_CASE( "test_topic_item_mutator", "[npc_talk]" ) gen_response_lines( d, 1 ); chosen = d.responses[0]; chosen.success.apply( d ); - CHECK( globvars.get_global_value( "npctalk_var_key1" ) == "bottle_glass" ); + CHECK( globvars.get_global_value( "key1" ) == "bottle_glass" ); } diff --git a/tests/ranged_balance_test.cpp b/tests/ranged_balance_test.cpp index b577d89593219..c5c714755e06b 100644 --- a/tests/ranged_balance_test.cpp +++ b/tests/ranged_balance_test.cpp @@ -585,8 +585,8 @@ TEST_CASE( "shot_custom_damage_type", "[gun]" "[slow]" ) { clear_map(); auto check_eocs = []( const standard_npc & src, const monster & tgt ) { - return src.get_value( "npctalk_var_general_dmg_type_test_test_fire" ) == "source" && - tgt.get_value( "npctalk_var_general_dmg_type_test_test_fire" ) == "target"; + return src.get_value( "general_dmg_type_test_test_fire" ) == "source" && + tgt.get_value( "general_dmg_type_test_test_fire" ) == "target"; }; // Check that ballistics damage processes weird damage types and on-hit EOCs shoot_monster( "shotgun_s", {}, "test_shot_00_fire_damage", 1, 80, diff --git a/tests/submap_load_test.cpp b/tests/submap_load_test.cpp index 5bdb5be306a89..e426a84dc9278 100644 --- a/tests/submap_load_test.cpp +++ b/tests/submap_load_test.cpp @@ -851,7 +851,7 @@ static JsonValue submap_fd_pre_migration = json_loader::from_string( submap_fd_p static void load_from_jsin( submap &sm, const JsonValue &jsin ) { // Ensure that the JSON is up to date for our savegame version - REQUIRE( savegame_version == 34 ); + REQUIRE( savegame_version == 35 ); int version = 0; JsonObject sm_json = jsin.get_object(); if( sm_json.has_member( "version" ) ) {