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

Fix several pets AI bugs, add player homeostatic effect on pets #2177

Merged
merged 10 commits into from
Nov 26, 2022

Conversation

leoCottret
Copy link
Collaborator

@leoCottret leoCottret commented Nov 8, 2022

Summary

SUMMARY; Bugfixes "Fix several pets AI bugs, add player homeostatic effect on pets"

Purpose of change

Fix some bugs linked to pets AI.
1 - monsters that are not angry flee if they took a single point of damage.
Example where it's annoying: a dog pet fight a bit with a zombie that barely scratched it, after the fight his anger goes down, and then for the next few hours it will run from everything since he's not at full health (and they heal slowly)
2 - the horse is afraid of litterally all the sounds (friendly animals, friendly player/NPCs, his own footsteps when mounted etc.)
3 - when angry or fleeing, but with no hostile targets in sight, pet animals will follow the player smell
4 - a tied horse that was mounted didn't get his tied state removed properly, which made it buggy when dismounted

Describe the solution

1 - reduce the fleeing threshold to 60% of max health
2 - horses are not afraid of sounds anymore (cf detailled explanation in "Describe alternatives you've considered")
3 - I found several solutions to fix the bug, but the most elegant solution I found was to transform this bug to make a feature out of it

  • I thought that it would be nice to add a calming effects on the pets from the player, when there are no targets around
  • this calming effect will make the pets go faster to their natural, default anger and moral values. The player has a homeostatic effect on them.
  • since afraid or angry pets will come to the player, they will get calmed faster (this takes 1/2 minutes maximum) and after will just go back to their normal state.
  • I like the idea of pets coming to the player to be petted a bit because they were afraid, so I developed it like this. Also, the closer the monster is from the player, the stronger the effect.
    4 - Remove the tied state when mounting the horse

Describe alternatives you've considered

I did thought of adding a feature that would allow monsters to have some kind of self preservation, but this will be in an other PR (...maybe).

About 2, my previous solution was "add a check to avoid processing the "sound fear" if it's a friendly monster and the sound comes from the player (barking sounds from friendly dogs could be added too)"
The big problem with this solution was the complexity behind it.
The horse was afraid of:

  • his own footsteps sounds when you mount it (this is obviously a bug, but I don't intend to fix it here to avoid side effects)
  • the player's footsteps
  • NPCs foosteps
  • barking of dogs
  • mooing of cows
  • etc. etc.
    And on top of that, sometimes the horse can't see the sound origin, and in that case it's very hard to say if it should know if it comes from a friendly creature or not.
    So at this complexe solution a simple fix, remove "SOUND" from fear_triggers, so that horses can stop being almost all the time at -100 morale (because yes, that's what happened...). It just doesn't work for pets.

Testing

I added a add_msg line with the moral and anger values of the PETS on the map, to see if the different fix worked (I'll remove it in the last commit).
Everything seemed to work perfectly (I tested it a lot while fixing the bugs).

@github-actions github-actions bot added the src changes related to source code. label Nov 8, 2022
@leoCottret leoCottret changed the title Fix several pets AI bugs Fix several pets AI bugs, add player homeostatic effect on pets Nov 8, 2022
Maleclypse added a commit to Maleclypse/Cataclysm-DDA that referenced this pull request Nov 12, 2022
Co-Authored-By: leoCottret <71428793+leoCottret@users.noreply.github.com>
@github-actions github-actions bot added the JSON related to game datas in JSON format. label Nov 14, 2022
@Coolthulhu Coolthulhu self-assigned this Nov 15, 2022
I-am-Erk pushed a commit to CleverRaven/Cataclysm-DDA that referenced this pull request Nov 24, 2022
* Portions of cataclysmbnteam/Cataclysm-BN#2177

Co-Authored-By: leoCottret <71428793+leoCottret@users.noreply.github.com>

* Update src/monster.cpp

* Update src/monster.cpp

* Update src/monster.cpp

* Update src/monster.cpp

Co-authored-by: David Seguin <davidseguin@live.ca>

Co-authored-by: leoCottret <71428793+leoCottret@users.noreply.github.com>
Co-authored-by: David Seguin <davidseguin@live.ca>
@Coolthulhu Coolthulhu merged commit 76871b7 into cataclysmbnteam:upload Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

2 participants