> For the complete documentation index, see [llms.txt](https://docs.streamavatars.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/events/boss-battle-outcome.md).

# Boss Battle Outcome

```lua
function yourEvent(users, boss_name, difficulty, result)
    if result == 'cancelled' or users == nil or boss_name == nil or difficulty == 'none' then
        return;
    end

    if result == 'players' then
        local str = 'players won... ';
        for i,user in pairs(users) do
            str = str .. ' ' .. user.displayName;
        end
        log(str);
    end

    if result == 'boss' then
        log('boss: ' .. boss_name .. ' won.');
    end

    log('boss difficulty was: ' .. difficulty); --difficulty can be: easy, normal, hard, none
end

return function()
    addEvent('bossBattleOutcome', 'yourEvent');
    keepAlive();
end
```

{% hint style="info" %}
Events are asynchronous coroutines.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/events/boss-battle-outcome.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
