Skip to content

Commit

Permalink
revert changes in EOC_map_test, implement EOC_loc_relative_test
Browse files Browse the repository at this point in the history
  • Loading branch information
GuardianDll committed Jul 27, 2024
1 parent 3a37f54 commit b445a1a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
13 changes: 10 additions & 3 deletions data/mods/TEST_DATA/EOC.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)" },
Expand All @@ -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')" ] }
}
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" } ]
Expand Down
32 changes: 30 additions & 2 deletions tests/eoc_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down Expand Up @@ -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]" )
Expand Down

0 comments on commit b445a1a

Please sign in to comment.