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

feat(content,port): AGGRO_CHARACTER flag for enemies #5846

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

shmakota
Copy link
Contributor

@shmakota shmakota commented Dec 28, 2024

Checklist

Required

Optional

please remove sections irrelevant to this PR.

  • This PR ports commits from DDA or other cataclysm forks.
    • I have attributed original authors in the commit messages adding Co-Authored-By in the commit message.
    • I have linked the URL of original PR(s) in the description.
  • This is a C++ PR that modifies JSON loading or behavior.
    • I have documented the changes in the appropriate location in the doc/ folder.

Purpose of change

ports change
CleverRaven/Cataclysm-DDA#59795

Add a (rudimentary) selection to monster hostility, optionally filtering out characters until a character actually trips an anger trigger.

Additionally, to allow for the creation of enemies with high aggression that wont attack player until triggered by a flag, which otherwise always would. Enemies which do not have AGGRO_CHARACTER set to false should behave the same as they did before. Monsters that have this tag, when fighting, should now focus on whatever enemy they were already fighting and redirect their anger to the player less often.

also ports the following:
CleverRaven/Cataclysm-DDA#60352
CleverRaven/Cataclysm-DDA#62346
(the above are for fixing bugs with quadrupeds, but will extend to enemies that we implement with similar features, so these commits are being included)
CleverRaven/Cataclysm-DDA#70938

Describe the solution

Add aggro_character (default true) to monster and mtype. false means the monster will be passive towards characters.
Add some logic to anger triggers to allow flipping aggro_character when a character trips the trigger: attacking/killing a friendly critter, hurting the monster and threatening offspring will always do so, the other triggers will have a random chance for each time they trigger
Add a lot of debugmode messages to aggro changes
Add a chance to reset the aggro_character when the monster reached its baseline anger level.

Geese are also now more territorial, and won't like when you get near.

Describe alternatives you've considered

Testing

  • Spawned a 5x5 grid of moose to fight a 5x5 grid of zombie dogs. They fought and the moose eventually started fleeing once enough friends died. They seem to behave exactly the same as they did before the change.

  • Spawned bee, beaver, and giant jumping spider. All seem to behave the same as before.

  • Created a civilian monster that has high aggression and a high melee attack. Spawned it in a city, and it fought zombies until dying but did not target the player. The civilian will not be included in the PR.

  • Changed "mongrel" to have 99 aggression. Mongrel instantly attacks player. When aggro_character is set to false, mongrel no longer attacks player, however follows the player around very closely for a long time. I don't think this following behavior is a result of this change, but rather how aggression already worked.

  • I spawned a group of civilians with 100 aggression in a city. They fought the zombies around until the zombies died. The civilians then attacked me. A group of civilians with 50 aggression do not attack. This is odd, as the DDA equivalent does not seem to have this issue. This should be fixed.

  • I spawned a group of civilians with 100 aggression in a field. Saved and reloaded. Civilians are now aggressive, and won't give up on killing the player. A group spawned with 50 aggression quickly loses interest and goes back to neutral and the expected behavior. This is probably related to the issue above.

As you can see, there is still some unexpected behavior that needs to be sorted out before being merged. These issues most likely wont affect the current player experience as (i think) there are no monsters that would get aggro_character = false and need 100 aggression for some reason, but would prevent a 1:1 port of certain monsters from DDA (namely the civilians) and should be fixed anyways.

After the commits made to implement 70983 and 60352 these issues should all be ironed out. I retested a few of these scenarios and got the expected results this time, which I had not before. Saving and reloading as well as monsters with high aggression attacking the player after a non-monster fight work correctly now from my testing.

Additional context

We probably need to apply this to more monsters as well, as I only ported what DDA animals had aggro_character set to false.

CleverRaven/Cataclysm-DDA#59565 is also relevant to DDA's version of this change

if implemented #1879 would be fixed

This PR will make the moose less likely to attack the player randomly. Should we keep the killer moose?

@github-actions github-actions bot added docs PRs releated to docs page src changes related to source code. JSON related to game datas in JSON format. labels Dec 28, 2024
Copy link
Contributor

autofix-ci bot commented Dec 28, 2024

Autofix has formatted code style violation in this PR.

I edit commits locally (e.g: git, github desktop) and want to keep autofix
  1. Run git pull. this will merge the automated commit into your local copy of the PR branch.
  2. Continue working.
I do not want the automated commit
  1. Format your code locally, then commit it.
  2. Run git push --force to force push your branch. This will overwrite the automated commit on remote with your local one.
  3. Continue working.

If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT.

@shmakota shmakota changed the title feat(content,port): AGGRO_CHARACTER flag for enemies feat(content,port): AGGRO_CHARACTER flag for enemies Dec 28, 2024
@shmakota
Copy link
Contributor Author

shmakota commented Jan 3, 2025

the aggression issues may be mitigated by this DDA PR:
CleverRaven/Cataclysm-DDA#60352
i will test soon if this helps
EDIT: this does solve the issue of mons still attacking player after killing the enemy they are fighting, however quicksaving and quickloading still causes the monsters to aggro on the player (as expected, will need to find the fix for this as well.)
there is also a part 2 to the PR that i implemented: CleverRaven/Cataclysm-DDA#62346

@shmakota
Copy link
Contributor Author

shmakota commented Jan 4, 2025

the save/load aggro behavior should be fixed by this PR:
CleverRaven/Cataclysm-DDA#70938
will test and update this comment once implemented
EDIT: this did solve it, as expected. with this the PR should be almost ready for review and merging.

shmakota and others added 2 commits January 3, 2025 18:25
…_character tracking

Co-Authored-By: Eric <52087122+Ramza13@users.noreply.github.com>
Co-Authored-By: Venera3 <72006894+Venera3@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs PRs releated to docs page JSON related to game datas in JSON format. src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant