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

[They Hunger] Friendly cops attack player for killing zombified cops. #134

Closed
malortie opened this issue Aug 12, 2020 · 1 comment
Closed

Comments

@malortie
Copy link
Contributor

In the original They Hunger, normal cops do not attack players for killing zombified cops.

In the crossplatform release of They Hunger, normal cops attack players for killing zombified cops.

A custom level bug_barney.zip is provided to allow for easier testing and debugging. It includes two cops - a normal cop and a zombie cop, as well as a glock at player spawn.

Steps to reproduce

  1. In the console, type the following commands:
map bug_barney
  1. Kill the zombified cop with the glock. Make sure the normal cop can see you.

Expected behavior: Normal cop should remain friendly to the player.
Actual behavior: Normal cop attacks the player.

Possible cause

According to the reverse engineered source code, there is an extra condition at the end of the line. Please, see the following below:

https://github.com/FWGS/hlsdk-xash3d/blob/1ffb009983ec7d36859e559e5dfbf0c478437846/dlls/talkmonster.cpp#L627-L628

This code is in the function EnumFriends, which is responsible for listing all 'friend' entities to this monster. The context in which the function is used is as follows: If a player kills a 'barney' monster, then it searches for every entity whose classname is part of the barney's friend array, and makes them enemy of the player.

The condition from the code snippet above determines if a friend entity must be skipped/ignored.

Normal cops and zombified cops use the same class, so to prevent zombified cops from making normal cops enemies of players whenever a player kills a zombified cop, the code above should probably rather be:

if( pFriend == this || !pFriend->IsAlive()
      // Skip if a zombie cop has been killed and the the target friend is a normal cop.
      || ( FBitSet( pev->spawnflags, SF_MONSTER_ZOMBIECOP )
      && !FBitSet( pFriend->pev->spawnflags, SF_MONSTER_ZOMBIECOP ) ) )
      continue;
nekonomicon added a commit that referenced this issue Oct 11, 2020
@nekonomicon
Copy link
Member

Thanks! Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants