diff --git a/data/mods/TEST_DATA/EOC.json b/data/mods/TEST_DATA/EOC.json index d9ef16615d416..b41904f8da30d 100644 --- a/data/mods/TEST_DATA/EOC.json +++ b/data/mods/TEST_DATA/EOC.json @@ -802,6 +802,15 @@ { "type": "effect_on_condition", "id": "EOC_map_test", + "effect": [ + { "set_string_var": { "mutator": "u_loc_relative", "target": "(10,10,0)" }, "target_var": { "context_val": "loc" } }, + { "math": [ "key_distance_loc", "=", "distance('u', _loc)" ] }, + { "math": [ "key_distance_npc", "=", "distance('u', 'npc')" ] } + ] + }, + { + "type": "effect_on_condition", + "id": "EOC_loc_relative_test", "effect": [ { "set_string_var": { "mutator": "u_loc_relative", "target": "(10,10,0)" }, @@ -810,9 +819,7 @@ { "set_string_var": { "mutator": "npc_loc_relative", "target": "(0,0,0)" }, "target_var": { "global_val": "map_test_loc_b" } - }, - { "math": [ "key_distance_loc", "=", "distance('u', map_test_loc_a)" ] }, - { "math": [ "key_distance_npc", "=", "distance('u', 'npc')" ] } + } ] }, { diff --git a/data/mods/Xedra_Evolved/mutations/paraclesians/homullus_spell_learning_eocs.json b/data/mods/Xedra_Evolved/mutations/paraclesians/homullus_spell_learning_eocs.json index 28dc4f98cdd47..9e988a1024b15 100644 --- a/data/mods/Xedra_Evolved/mutations/paraclesians/homullus_spell_learning_eocs.json +++ b/data/mods/Xedra_Evolved/mutations/paraclesians/homullus_spell_learning_eocs.json @@ -33,7 +33,7 @@ "or": [ { "test_eoc": "EOC_CONDITION_HOMULLUS_NEAR_FACTION" }, { "u_near_om_location": "FACTION_CAMP_ANY", "range": 2 }, - { "map_in_city": { "mutator": "loc_relative_u", "target": "(0,0,0)" } } + { "map_in_city": { "mutator": "u_loc_relative", "target": "(0,0,0)" } } ] }, "effect": [ { "run_eocs": "EOC_HOMULLUS_SPELL_EXPERIENCE_INCREASER_SELECTOR" } ] diff --git a/tests/eoc_test.cpp b/tests/eoc_test.cpp index 3f12cf08a8a83..141e26c926693 100644 --- a/tests/eoc_test.cpp +++ b/tests/eoc_test.cpp @@ -39,6 +39,8 @@ static const effect_on_condition_id effect_on_condition_EOC_item_teleport_test( "EOC_item_teleport_test" ); static const effect_on_condition_id effect_on_condition_EOC_jmath_test( "EOC_jmath_test" ); +static const effect_on_condition_id +effect_on_condition_EOC_loc_relative_test( "EOC_loc_relative_test" ); static const effect_on_condition_id effect_on_condition_EOC_map_test( "EOC_map_test" ); static const effect_on_condition_id effect_on_condition_EOC_martial_art_test_1( "EOC_martial_art_test_1" ); @@ -1278,8 +1280,34 @@ TEST_CASE( "EOC_map_test", "[eoc]" ) 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( "npctalk_var_map_test_loc_a" ) == "(70,70,0)"); - CHECK( globvars.get_global_value( "npctalk_var_map_test_loc_b" ) == "(70,60,0)"); +} + +TEST_CASE( "EOC_loc_relative_test", "[eoc]" ) +{ + global_variables &globvars = get_globals(); + globvars.clear_global_values(); + clear_avatar(); + clear_map(); + + map &m = get_map(); + g->place_player( tripoint_zero ); + + const tripoint_abs_ms start = get_avatar().get_location(); + const tripoint tgt = m.getlocal( start + tripoint_north ); + m.furn_set( tgt, furn_test_f_eoc ); + m.furn( tgt )->examine( get_avatar(), tgt ); + + const tripoint target_pos = get_avatar().pos() + 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_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" ) ) ); + tripoint_abs_ms tmp_abs_b = tripoint_abs_ms( tripoint::from_string( + globvars.get_global_value( "npctalk_var_map_test_loc_b" ) ) ); + CHECK( m.getlocal( tmp_abs_a ) == tripoint( 70, 70, 0 ) ); + CHECK( m.getlocal( tmp_abs_b ) == tripoint( 70, 60, 0 ) ); } TEST_CASE( "EOC_martial_art_test", "[eoc]" )