cataclysmbnteam / Cataclysm-BN

Cataclysm: Bright Nights, A fork/variant of Cataclysm:DDA by CleverRaven.
https://docs.cataclysmbn.org
Other
681 stars 267 forks source link

Autodoc instantly kills NPCs during CBM installation #3346

Open cinornu opened 1 year ago

cinornu commented 1 year ago

Describe the bug

Just a heads up that I used a translator first. I don't speak English very well :(

After several rounds of testing, we finalized the conditions under which the bug occurs. But other than that, the conditions under which bug occurs (mods, env...) are still unknown.

This bug causes Autodoc to install CBMs on NPCs, and when they leave the reality bubble, it throws an error and insta kills the NPC. I've implemented that exact condition in the attached save file, so you can check it out for yourself.

Steps To Reproduce

  1. Install CBM with a probability of failure to the NPC using vh_autodoc. However, it appears that vehicle must be similar to #3315 to trigger the bug.
  2. move to a location outside reality bubble, but with a different z-axis at the same time
  3. wait for the total installation time of the CBM
  4. return to the vehicle
  5. move out of reality bubble
  6. error occurs and NPC dies instantly.

Screenshots

2023-10-02 (18)

Versions and configuration

Additional context

ERROR DEBUGMSG : D:\a\Cataclysm-BN\Cataclysm-BN\src\map.cpp:1170 [unboard_vehicle] map::unboard_vehicle: vehicle not found

See the attached save file for details. I've made it so that after loading, moving straight up will cause an error.

mods : https://www.dropbox.com/scl/fi/ik9nifluyaoc1i4hmcpzd/report_mods.zip?rlkey=j6wk2zbdg7vmv0q6x8cgq12lp&dl=0 save : https://www.dropbox.com/scl/fi/sczdos312jz2ihmewee4p/npc_instadeath.zip?rlkey=bmru4yzb0lickmuuca184b5i8&dl=0

scarf005 commented 1 year ago

did the bug happen without additional mods?

혹시 모드 없이도 동일한 버그가 발생한 경우가 있나요?

cinornu commented 1 year ago

did the bug happen without additional mods?

혹시 모드 없이도 동일한 버그가 발생한 경우가 있나요?

모드가 없는 상태에선 동일한 조건을 확보할 수가 없어서 테스트해도 같은 결과가 나오지 않았습니다. 아마 커다랗고 물건이 꽉꽉 차있는 차량에서 발생하는 것 같아요. 오히려 다른 버그를 발견해서 이것도 제보할 예정입니다. 또한 방금 세이브 파일 최신화했습니다. 버그가 발생한 직후로 자동 세이브가 되는 바람에 다시 조건을 맞춰놨어요

olanti-p commented 1 year ago

I think I've tracked down what's going on here.

It all comes down to how the vehicle is positioned within a different submap from the NPC that's being operated on.

Red circle is the vehicle pivot point (should match its position on map), orange is the NPC that dies. image

When you move north, the vehicle leaves the reality bubble first and gets unloaded. However, the NPC remains within the reality bubble because they're on a different submap, so operation_do_turn sees that NPC is inside the bubble and tries to check for the autodoc. There is no autodoc (the vehicle's gone), so it incurs "autodoc failure" which ends up bringing NPC's torso health to 0 and kills them.

https://github.com/cataclysmbnteam/Cataclysm-BN/blob/e82ebec7734021ad2ba56208a0bae5030ee15bfc/src/activity_handlers.cpp#L3565-L3584

The following "failed to unboard vehicle" error is of similar nature: NPC used to be seated within the loaded vehicle when it died, but the vehicle's gone, so it can't "unseat" from it on death.