Fix NPC callout spam after avoided combat by adding distance and target validation #37
+216
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
NPCs and companions were repeatedly spamming callout messages about specific enemies even after combat had been avoided and the enemies were far away. The
on_enemy_evalcallback would continue triggering for distant enemies, causing companions to spam "spotted enemy" messages for NPCs that were no longer nearby or relevant.Root Cause
The
is_valid_calloutfunction intalker_trigger_callout.scriptwas missing two critical validation checks:Solution
Added two validation checks to
is_valid_callout:Why 30 meters?
The 30-meter distance limit was chosen because it:
Changes
Core Changes
gamedata/scripts/talker_trigger_callout.scriptMAX_CALLOUT_DISTANCE = 30constantis_living_character(target_obj)validationget_distance_between()check with 30m limitTesting
tests/triggers/test_talker_trigger_callout.luatestCalloutWithinDistance()- validates callouts work within 30mtestCalloutBeyondDistance()- validates callouts blocked beyond 30mtestCalloutTargetNotLiving()- validates callouts blocked for dead targetsare_enemies()andget_distance_between()Documentation
docs/callout_spam_fix.md(new file)Testing Results
All test cases passed successfully:
Impact
Positive Effects
No Negative Effects
Configuration
The distance can be adjusted if needed by modifying the constant in
talker_trigger_callout.script:Credits
This fix addresses a user-reported issue where companions would spam callout messages after avoiding combat. The solution has been implemented with minimal changes (only 2 additional validation checks) while maintaining full backward compatibility.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Fixes #32
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.