CleverRaven / Cataclysm-DDA

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

Inconsistency for NPC and PC to "reach attack" at 2√2 range #65266

Open SurFlurer opened 1 year ago

SurFlurer commented 1 year ago

Describe the bug

When "Circular distances" is turned on, NPC can use "reach attack" weapon ( like a steel spear ) to attack enemies standing 2 tiles away at 1,3,7,9 directions, but the player character cannot.

Attach save file

npcneed-trimmed.tar.gz

Steps to reproduce

  1. Load the save.
  2. See that the NPC can attack the debug monster from where he stands.
  3. Teleport to the NPC's position, and try to use Tab or f to attack.
  4. Find out that you cannot attack the debug monster.

Expected behavior

Consistency. I'd like to see NPC losing this ability, being the same as PC.

Screenshots

图片

Versions and configuration

Additional context

No response

RenechCDDA commented 1 year ago

Ok now this is a weird one... I can confirm it happens in the provided save(thank you!) but I can't get it to happen in another test scenario: image

When on guard he simply pauses. In both this test scenario and the provided save, debug mode reports the range as 2.

I think it may be because the target is being cached and as long as the target is cached it's somehow skipping the option check? (Notice in my image target is none) https://github.com/CleverRaven/Cataclysm-DDA/blob/a2f5875d92995cba39653f3c15a0b2d396258b37/src/npcmove.cpp#L872-L873

SurFlurer commented 1 year ago

@RenechCDDA This line indicates that, for npcs, the distance to that monster is 2. https://github.com/CleverRaven/Cataclysm-DDA/blob/48ed876c6a1ae35d64951d99f672237580345f72/src/npcmove.cpp#L539 And this line uses a different method to calculate distance for character attacking. https://github.com/CleverRaven/Cataclysm-DDA/blob/48ed876c6a1ae35d64951d99f672237580345f72/src/character.cpp#L9547

However, I'm not sure what's happening in your test scenario. Maybe that's a different bug?

DragonWizard23 commented 4 months ago

I discovered this inconsistency today, but what's weird is that while the cunning feral can attempt to make diagonal reach attacks, it seems like they can't hit the player. This character has minimal dodge, but was able to avoid many attacks in a row. I've added the save if anyone is curious. Screenshot (389) Screenshot (390) Screenshot (391) 2024-03-31-trimmed.tar.gz