Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You can be shot and killed by hallucination NPCs #53510

Closed
Inglonias opened this issue Dec 17, 2021 · 6 comments · Fixed by #53538
Closed

You can be shot and killed by hallucination NPCs #53510

Inglonias opened this issue Dec 17, 2021 · 6 comments · Fixed by #53538
Labels
<Bug> This needs to be fixed NPC / Factions NPCs, AI, Speech, Factions, Ownership

Comments

@Inglonias
Copy link
Contributor

Describe the bug

Hallucinatory NPCs can shoot and kill you.

Steps to reproduce

  1. Make a character with Kaluptic Psychosis
  2. Wait for them to hallucinate an NPC with a gun.
  3. Make that NPC angry.
  4. They shoot you and you get hurt.

Here's a savegame you can use. There is an armed hallucination inside the cabin directly to the east. Make them angry and they can shoot you!
Alfred.zip

Expected behavior

I would expect hallucinatory NPCs to NOT be able to shoot me.

Screenshots

image
image

Versions and configuration

  • OS: Windows
    • OS Version: 10.0 2009
  • Game Version: cfc00fa [64-bit]
  • Graphics Version: Tiles
  • Game Language: System language []
  • Mods loaded: [
    Dark Days Ahead [dda],
    Bionic Slots [cbm_slots],
    Disable NPC Needs [no_npc_food],
    No Fungal Growth [no_fungal_growth],
    Bionic Professions [package_bionic_professions],
    No Rail Stations [No_Rail_Stations],
    sees-player, run, crouch, bleed icons, retrodays [sees_player_retro],
    Fewer Soldier Extras [Fewer_Soldiers]
    ]

Additional context

No response

@Inglonias
Copy link
Contributor Author

Inglonias commented Dec 17, 2021

image
This is nonsense and almost makes me want to debug away the psychosis.

@wapcaplet wapcaplet added the <Bug> This needs to be fixed label Dec 17, 2021
@Night-Pryanik Night-Pryanik added the NPC / Factions NPCs, AI, Speech, Factions, Ownership label Dec 17, 2021
@Inglonias
Copy link
Contributor Author

Oddly enough, we have a pretend_fire() method in ranged.cpp. Either that method is working improperly or is not being called correctly.

@Michael1993
Copy link
Contributor

Michael1993 commented Dec 17, 2021

I don't know how to test this but I think the fix could be this:

if ( source.is_hallucination() ) {
    gun_mode mode = source.get_wielded_item().gun_current_mode();
    source.pretend_fire( source, mode.qty, *mode );
} else {
    source.fire_gun( location );
}

in here: npc_attack.cpp

This piece of code is immediately followed by a debugmsg so seeing if this is indeed the code that gets called instead of the other one should be just loading in the save file and enabling debug messages (npcmove.cpp doesn't have a debugmsg call).

@Inglonias
Copy link
Contributor Author

Inglonias commented Dec 17, 2021

I'm at work and can't compile anything right now, but the best way to test this would be to do just that. Compile the project with that code added in, and run it. See if it works as you expect. If it doesn't, make a test procedure and repeat it in the debugger, though playing Cataclysm through a debugger is like walking while neck deep in quicksand. The game slows down to the point of being damn near unplayable.

@Inglonias
Copy link
Contributor Author

For what it's worth, this looks like the correct answer, but I have a busy day today and can't implement it myself. If nobody does this by tomorrow, and assuming the COVID booster doesn't kick my ass, I'll try it.

@Inglonias
Copy link
Contributor Author

Inglonias commented Dec 17, 2021

I don't know how to test this but I think the fix could be this:

if ( source.is_hallucination() ) {
    gun_mode mode = source.get_wielded_item().gun_current_mode();
    source.pretend_fire( source, mode.qty, *mode );
} else {
    source.fire_gun( location );
}

in here: npc_attack.cpp

This piece of code is immediately followed by a debugmsg so seeing if this is indeed the code that gets called instead of the other one should be just loading in the save file and enabling debug messages (npcmove.cpp doesn't have a debugmsg call).

Congratulations sir. You were almost 100% correct. The only incorrect thing in your fix was the if statement you provided was inverted. Otherwise, it works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bug> This needs to be fixed NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants