CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.01k stars 4.09k forks source link

`map_in_city` says you're not in a city when you very clearly are #74177

Open Standing-Storm opened 2 months ago

Standing-Storm commented 2 months ago

Describe the bug

When working on #74175, I noticed that map_in_city would repeatedly return false even when I was clearly inside the city limits.

Attach save file

Darfur-trimmed.tar.gz

Steps to reproduce

1) Place the following JSON somewhere where it loads: { "type": "effect_on_condition", "id": "EOC_CONDITION_CHECK_HOMULLUS_IN_CIVILIZATION_ON_OMT_ENTER", "eoc_type": "EVENT", "required_event": "avatar_enters_omt", "condition": { "u_has_trait": "HOMULLUS" }, "effect": [ { "run_eocs": [ { "id": "EOC_CONDITION_CHECK_HOMULLUS_IN_CIVILIZATION_ON_OMT_ENTER_2", "condition": { "or": [ { "test_eoc": "EOC_CONDITION_HOMULLUS_NEAR_FACTION" }, { "map_in_city": { "mutator": "loc_relative_u", "target": "(0,0,0)" } } ] }, "effect": [ { "math": [ "u_homullus_is_in_civilization", "=", "1" ] }, { "u_message": "You are in a civilized OMT." } ], "false_effect": [ { "math": [ "u_homullus_is_in_civilization", "=", "0" ] }, { "u_message": "You are NOT in a civilized OMT." } ] } ] } ] }

2) Load game.

3) Run west. Check when you start receiving the "You are NOT in a civilized OMT" and compare it to the city area on the map.

Expected behavior

map_in_city matches the city limits that are visible on your map.

Screenshots

map_in_city returned false for this location:

image

Once I moved north to here, it returned true:

image

Similarly, over here on the edge of town returns true:

image

But this spot returns false:

image

it's not until two OMTs to the east of that picture that it begins returning true.

Versions and configuration

Additional context

No response

Procyonae commented 2 months ago

If I get the time I'll make the new city check from #71822 it's own PR and hook up everything to that, other than maybe non 0 city distance bc idk if that would be performance efficient or not

Procyonae commented 2 months ago

If you're not on z0 how do you think it would be best to work?

Standing-Storm commented 2 months ago

If you're not on z0 how do you think it would be best to work?

Hmm. I would count any distance up (I think skyscrapers go up to Z: 9), and down to -1 at least for basements and the sewers. A cylinder would be easier but you'd end up with circumstances where some labs were partially in a city and partially not--not sure if subterranean labs should count as in the city or not.

Brambor commented 2 months ago

Edit: pretty much the above comment

I would argue against it, since you can run around the underground, not knowing there is a city above you.

On the other hand, if you are in a cellar in a building, you still are in a city... So leaking that information isn't that bad. But then maybe mark it as a city only from z=-1 (deepest cellar) up as a compromise.