Open Termineitor244 opened 6 hours ago
AFAICT, the only way this ever worked is if that coordinate randomly landed on a monster or npc.
AFAICT, the only way this ever worked is if that coordinate randomly landed on a monster or npc.
Quick fix attempt
```diff diff --git a/data/json/effects_on_condition/scenario_specific_eocs.json b/data/json/effects_on_condition/scenario_specific_eocs.json index 0b37ba4cc1..479abaf65c 100644 --- a/data/json/effects_on_condition/scenario_specific_eocs.json +++ b/data/json/effects_on_condition/scenario_specific_eocs.json @@ -53,22 +53,23 @@ "//": "EOC_BANISH_MANSION_MONSTERS is not triggering/working at the moment.", "effect": [ { - "u_location_variable": { "u_val": "mansion_centre" }, + "u_location_variable": { "context_val": "mansion_centre" }, "target_params": { "om_terrain": "mansion_+4d", "search_range": 2, "z": -1 }, "min_radius": 0, "max_radius": 0 }, - { "location_variable_adjust": { "u_val": "mansion_centre" }, "x_adjust": 11, "y_adjust": 11 }, - { "run_eoc_with": "EOC_BANISH_MANSION_MONSTERS", "beta_loc": { "u_val": "mansion_centre" } }, + { "location_variable_adjust": { "context_val": "mansion_centre" }, "x_adjust": 11, "y_adjust": 11 }, + { "run_eoc_with": "EOC_BANISH_MANSION_MONSTERS", "variables": { "loc": { "context_val": "mansion_centre" } } }, { "run_eocs": "EOC_SPAWN_MANSION_MONSTERS" }, - { "location_variable_adjust": { "u_val": "mansion_centre" }, "z_adjust": 0, "z_override": true }, - { "run_eoc_with": "EOC_BANISH_MANSION_MONSTERS", "beta_loc": { "u_val": "mansion_centre" } }, + { "location_variable_adjust": { "context_val": "mansion_centre" }, "z_adjust": 0, "z_override": true }, + { "run_eoc_with": "EOC_BANISH_MANSION_MONSTERS", "variables": { "loc": { "context_val": "mansion_centre" } } }, { "run_eocs": "EOC_SPAWN_MANSION_MONSTERS" }, - { "location_variable_adjust": { "u_val": "mansion_centre" }, "z_adjust": 1, "z_override": true }, - { "run_eoc_with": "EOC_BANISH_MANSION_MONSTERS", "beta_loc": { "u_val": "mansion_centre" } }, + { "location_variable_adjust": { "context_val": "mansion_centre" }, "z_adjust": 1, "z_override": true }, + { "run_eoc_with": "EOC_BANISH_MANSION_MONSTERS", "variables": { "loc": { "context_val": "mansion_centre" } } }, { "run_eocs": "EOC_SPAWN_MANSION_MONSTERS" }, { "u_run_monster_eocs": [ { "id": "EOC_BANISH_MONSTERS_AROUND_PLAYER", "effect": { "run_eocs": "EOC_BANISH_SELF" } } ], + "loc": { "context_val": "mansion_centre" }, "monster_range": 12 }, { "run_eocs": "EOC_SPAWN_MANSION_MONSTERS_NEAR_PLAYER" } @@ -85,17 +86,18 @@ "//": "Banish half the mapgen monsters from the mansion to make room for special scenario ferals", "effect": [ { - "npc_run_monster_eocs": [ + "u_run_monster_eocs": [ { "id": "EOC_BANISH_MONSTERS_AROUND_MANSION_CENTER", "condition": { "math": [ "rand(1)", "==", "0" ] }, "effect": { "run_eocs": "EOC_BANISH_SELF" } } ], + "loc": { "context_val": "loc" }, "monster_range": 36 }, { - "npc_run_monster_eocs": [ { "id": "EOC_BANISH_MANSION_CIVILIANS", "effect": { "run_eocs": "EOC_BANISH_SELF" } } ], + "u_run_monster_eocs": [ { "id": "EOC_BANISH_MANSION_CIVILIANS", "effect": { "run_eocs": "EOC_BANISH_SELF" } } ], "mtype_ids": [ "mon_civilian_panic", "mon_civilian_parent", @@ -103,6 +105,7 @@ "mon_civilian_stationary", "mon_civilian_zombiefighter" ], + "loc": { "context_val": "loc" }, "monster_range": 50 } ] diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 7be0dcde72..8eaeaa475b 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -5936,14 +5936,24 @@ talk_effect_fun_t::func f_run_monster_eocs( const JsonObject &jo, if( jo.has_int( "monster_range" ) ) { monster_range = jo.get_int( "monster_range" ); } + std::optionalcenter; + if( jo.has_member( "loc" ) ) { + center = read_var_info( jo.get_object( "loc" ) ); + } bool monster_must_see = jo.get_bool( "monster_must_see", false ); - return [eocs, mtype_ids, monster_must_see, monster_range, is_npc]( dialogue const & d ) { + return [eocs, mtype_ids, monster_must_see, monster_range, is_npc, center]( dialogue const & d ) { std::vector ids; ids.reserve( mtype_ids.size() ); for( const str_or_var &id : mtype_ids ) { ids.emplace_back( id.evaluate( d ) ); } - tripoint actor_pos = d.actor( is_npc )->pos(); + tripoint_abs_ms center_abs_ms; + if( center ) { + center_abs_ms = get_tripoint_from_var( center, d, is_npc ); + } else { + center_abs_ms = d.actor( is_npc )->global_pos(); + } + tripoint_bub_ms actor_pos = get_map().bub_from_abs( center_abs_ms ); const std::vector available = g->get_creatures_if( [ ids, monster_must_see, monster_range, actor_pos ]( const Creature & critter ) { bool id_valid = ids.empty(); @@ -5957,10 +5967,10 @@ talk_effect_fun_t::func f_run_monster_eocs( const JsonObject &jo, } } return creature_is_monster && id_valid && ( !monster_range.has_value() || - actor_pos.z == critter.posz() ) && + actor_pos.z() == critter.posz() ) && ( !monster_must_see || critter.sees( actor_pos ) ) && - ( !monster_range.has_value() || rl_dist( actor_pos, critter.pos() ) <= monster_range.value() ); + ( !monster_range.has_value() || rl_dist( actor_pos, critter.pos_bub() ) <= monster_range.value() ); } ); for( Creature *target : available ) { for( const effect_on_condition_id &eoc : eocs ) { ```
Huh, weird, but maybe that did happen when this was initially implemented, that on a normal oversight, I just know I never managed to make it work.
And thanks! I will try the fix later when I return to my computer.
Describe the bug
There are 2 new error messages when starting a new game with the Mansion Escape scenario, given the EOC mentioned in the error messages, I suppose this is an old problem with this EOC (
EOC_BANISH_MANSION_MONSTERS
), since last time I checked it some months ago it wasn't working properly for me, but nobody seemed to know why, or how to solve it, I tried with several different ways and couldn't, so I just left a note since I was told it was working just one month prior when introduced...I guess we finally have an error message for it indicating the problem, since previously it just failed silently.
Attach save file
N/A
Steps to reproduce
Expected behavior
To start a new game without error messages.
Screenshots
No response
Versions and configuration
Additional context