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

NPCs: fix NPC fleeing and allow NPCs to stop fleeing the player #29084

Merged
merged 3 commits into from Mar 29, 2019

Conversation

2 participants
@mlangsdorf
Copy link
Contributor

commented Mar 28, 2019

Summary

SUMMARY: Bugfixes "NPCs: fix NPC fleeing and allow NPCs to stop fleeing the player"

Purpose of change

Fix an issue where NPCs fleeing from the player could melee attack the player at a great distance.

Fix an issue where an NPC, once they became scared of the player, became scared of the player forever.

Fix a warning message regarding the snippet and warning messages when setting NPC attitudes in the debug menu.

Describe the solution

Due to a bug in the NPC flight code, NPCs that were fleeing from the player could punch him at a distance. Change the logic for calling good_escape_direction from npc_has_effect( effect_npc_run_away) to npc_action == npc_flee. Now NPCs that are fleeing move_to a tile away from the NPC, instead of trying to move to the PC and being unable and punching him instead.

NPCs get a new attitude, NPCATT_FLEE_TEMP, whenever they would get NPCATT_FLEE. When an NPC's attitude is set to NPCATT_FLEE_TEMP, they also get a 24 hour effect "npc_flee_player." When the NPC AI starts its routine each turn, NPCATT_FLEE is turned to NPCATT_FLEE_TEMP and then if the NPC has NPCATT_FLEE_TEMP but not "npc_flee_player" they revert to NPCATT_NULL.

Change the color of fleeing NPCs to light_red to distinguish them from actual hostiles.

isn't a valid snippet, so replace it in talk_tags.json.

Give descriptions to the legacy NPC attitudes so that the new debug menu option to set an NPC attitude stops spewing error messages.

Describe alternatives you've considered

This could technically be 3 PRs but only the second commit is large enough to break out on its own.

npcmove: stop fleeing NPCs from attacking the player at a distance
Due to a bug in the NPC flight code, NPCs that were fleeing from
the player could punch him at a distance.  Change the logic for
calling good_escape_direction from npc_has_effect( effect_npc_run_away)
to npc_action == npc_flee.

mlangsdorf added some commits Mar 28, 2019

npc: expire NPCACT_FLEE after 24 hours
NPCs get a new attitude, NPCATT_FLEE_TEMP, whenever they would get
NPCATT_FLEE.  When an NPC's attitude is set to NPCATT_FLEE_TEMP, they also
get a 24 hour effect "npc_flee_player."  When the NPC AI starts its
routine each turn, NPCATT_FLEE is turned to NPCATT_FLEE_TEMP and then if
the NPC has NPCATT_FLEE_TEMP but not "npc_flee_player" they revert to
NPCATT_NULL.

Change the color of fleeing NPCs to light_red to distinguish them from
actual hostiles.
npc: fix minor bugs
<man> isn't a valid snippet, so replace it in talk_tags.json.

Give descriptions to the legacy NPC attitudes so that the new debug
menu option to set an NPC attitude stops spewing error messages.

@mlangsdorf mlangsdorf force-pushed the mlangsdorf:npc_flee_fix branch from 701e784 to 4482a38 Mar 28, 2019

@mlangsdorf mlangsdorf added this to In progress in NPC dialog overhaul via automation Mar 28, 2019

@kevingranade

This comment has been minimized.

Copy link
Member

commented Mar 28, 2019

This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

https://discourse.cataclysmdda.org/t/npcs-shooting-punches/19426/7

@kevingranade kevingranade merged commit 62adf89 into CleverRaven:master Mar 29, 2019

2 of 3 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
gorgon-ghprb Build finished.
Details

NPC dialog overhaul automation moved this from In progress to Done Mar 29, 2019

@mlangsdorf mlangsdorf deleted the mlangsdorf:npc_flee_fix branch Apr 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.