Skip to content

Conversation

Copy link

Copilot AI commented Oct 16, 2025

Issue

The idle conversation trigger had a critical bug on line 21 that prevented it from working correctly:

local result = cooldown_ready() and queries.is_player_in_combat()

This code had two problems:

  1. Runtime Error: The function queries.is_player_in_combat() doesn't exist in the codebase, causing the mod to fail when attempting to trigger idle conversations
  2. Inverted Logic: Even if the function existed, the condition was backwards - idle conversations would trigger during combat instead of during peaceful moments

Solution

Changed line 21 to use the existing is_in_combat() function with proper logic:

local result = cooldown_ready() and not queries.is_in_combat(queries.get_player())

This fix:

  • Uses the existing queries.is_in_combat(npc) function from talker_game_queries.script
  • Passes queries.get_player() as the NPC parameter to check the player's combat status
  • Adds not to invert the check so idle conversations only trigger when the player is NOT in combat

Validation

The fix follows established patterns in the codebase:

  • talker_trigger_callout.script (line 31) uses not queries.is_in_combat(npc_obj) for non-combat callouts
  • talker_trigger_taunt.script (line 25) uses queries.is_in_combat(npc_obj) for combat taunts
  • Line 36 in the same file also prevents speakers who are in combat from talking

The logic now correctly ensures NPCs only make idle conversation to "pass the time" when both the player and the speaking NPC are not engaged in combat, which aligns with the function's intended purpose.

Fixes the issue reported in #[issue_number] where @Mirrowel identified the inverted condition.

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
    • Triggering command: /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

This section details on the original issue you should resolve

<issue_title>Idle conversation condition reversed?</issue_title>
<issue_description>

local result = cooldown_ready() and queries.is_player_in_combat()

Shouldn't this be

    local result = cooldown_ready() and not queries.is_player_in_combat()
```</issue_description>

<agent_instructions>Explore and verify if this is an issue and if an action is needed.</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@Mirrowel</author><body>
Issues like this make me wish @danclave would allow me to add opencode agent with secrets, so i could just give it this job to work on.</body></comment_new>
</comments>

Fixes #35


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Fix reversed condition for idle conversation Fix idle conversation combat condition - inverted logic and undefined function call Oct 16, 2025
Copilot AI requested a review from Mirrowel October 16, 2025 02:55
@Mirrowel Mirrowel marked this pull request as ready for review October 16, 2025 02:58
@Mirrowel
Copy link
Collaborator

@copilot verify queries.is_player_in_combat() is not a valid call. Explain your position and detail your findings for this point:
Runtime Error: The function queries.is_player_in_combat() doesn't exist in the codebase, causing the mod to fail when attempting to trigger idle conversations

Copy link
Author

Copilot AI commented Oct 16, 2025

@copilot verify queries.is_player_in_combat() is not a valid call. Explain your position and detail your findings for this point:
Runtime Error: The function queries.is_player_in_combat() doesn't exi...

Verification of queries.is_player_in_combat() Not Existing

I've conducted a thorough search of the codebase to verify this claim. Here are my findings:

1. Function Does Not Exist

Searched the entire codebase for is_player_in_combat:

  • Function definition search: grep -r "function is_player_in_combat" → No results
  • Function assignment search: grep -r "is_player_in_combat\s*=" → No results
  • All references: Zero references found except in the buggy code

2. Functions That DO Exist in talker_game_queries.script

The combat-related functions that are actually defined:

  • Line 186: function get_enemies_fighting_player()
  • Line 190: function is_enemy_fighting_player(enemy)
  • Line 195: function is_npc_in_combat(npc)
  • Line 199: function is_in_combat(npc) ✓ (This is what should be used)

3. Original Buggy Code

From commit 6a009f9, line 21 was:

local result = cooldown_ready() and queries.is_player_in_combat()

4. Why This Would Fail

In Lua, calling a non-existent function results in:

attempt to call a nil value (field 'is_player_in_combat')

Since talker_game_queries is a global module reference (line 9: local queries = talker_game_queries) and has no metatable/__index fallback, accessing queries.is_player_in_combat() would attempt to call nil, causing a runtime error.

5. The Correct Pattern

Line 199-208 shows is_in_combat(npc) accepts any NPC and internally checks if is_player(npc) to handle player combat status appropriately. This is why the fix uses queries.is_in_combat(queries.get_player()).

@Mirrowel
Copy link
Collaborator

Well, they did decent work on Copilot i guess. I bet it is very good at making shit up.
Have to manually check anyway with no good way to test lmao.

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

Successfully merging this pull request may close these issues.

Idle conversation condition reversed?

2 participants