> For the complete documentation index, see [llms.txt](https://realisticnode.gitbook.io/rnsetups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://realisticnode.gitbook.io/rnsetups/rncombatpvp/guides/combat-log.md).

# Combat log and NPCs

The NPC with the player's skin, the other punishments and who is never punished.

A player who leaves the server while in combat **combat logs**. `combat-log.punishment` decides what happens:

| Punishment       | What happens                                                                                |
| ---------------- | ------------------------------------------------------------------------------------------- |
| `NPC`            | A copy of the player stays where they left. Kill it in time and the player loses everything |
| `KILL` (default) | The player dies when leaving and drops everything                                           |
| `NOTHING`        | Only the money penalty, commands and message below                                          |

## Every combat log

Whatever the punishment:

* The combat log is counted in the player's stats (**Combat logs**, `%rncombat_logs%`).
* `combat-log.money-penalty` takes money (needs Vault): an amount (`500`) or a percent of the player's money (`"10%"`). `0` = off.
* `combat-log.commands` run from the console. `{player}` is who left and `{enemy}` the last enemy. Lines can also be [actions](/rnsetups/rncombatpvp/guides/kills-and-rewards.md#reward-actions) such as `[broadcast] ...`.
* Everyone online gets the message `combat-log.broadcast` ("Steve logged out in combat!").
* With a Discord webhook and `discord.combat-log: true`, it is posted on Discord.

```yaml
combat-log:
  punishment: NPC
  money-penalty: "5%"
  commands:
    - "eco take {player} 100"
```

## The NPC

<figure><img src="https://i.imgur.com/jEkiNkR.png" alt="The NPC of a player who logged out in combat, with their skin and armor"><figcaption><p>The NPC of a player who logged out in combat, with their skin and armor</p></figcaption></figure>

With `punishment: NPC`, the NPC appears where the player left:

* On **1.21.9 and newer** it is a mannequin with the **player's skin**, their armor, the items in their hands, and their health and max health.
* Over its head: `&c{player} &7(logged out)` (`combat-log.npc-name` in the language files).
* It doesn't move and doesn't burn in daylight. The chunk stays loaded while it is there.
* It stays for `combat-log.npc.seconds` (20).
* Hitting it puts the attacker in combat. Players who couldn't hit its owner can't hurt it either: if the owner has PvP off or newbie protection, or the attacker has PvP off or is a newbie, the hit is stopped.

Then one of three things happens:

1. **Someone kills it.** It drops **everything the player carried** and some experience, as a real death would. Items with curse of vanishing vanish. The drops follow `kills.drops` (`KEEP`, `CLEAR` and `TRANSFER` work as for a real death) and the killer's [loot protection](/rnsetups/rncombatpvp/guides/kills-and-rewards.md#loot-protection). The killer gets the kill like any other: stats, rating, rewards, assists and bounties. Everyone is told who killed the body. When the player joins again, their inventory and experience are gone and they die at once, with the message `combat-log.killed-away-by` ("You logged out in combat and Alex killed your body. You lost your items.").
2. **It survives.** It goes away and nothing else happens: the player keeps everything.
3. **The player comes back while it is there.** The NPC goes away and the player **takes its place**: they appear where it stands, with its health if it was hurt, and they are **still in combat** (at least the normal combat time).

{% hint style="info" %}
With the `keepInventory` game rule on in that world, or with `kills.drops: KEEP`, a killed NPC drops nothing and the player keeps their items, but they still die when they join again.
{% endhint %}

{% hint style="warning" %}
The NPC needs a working database to remember the punishment until the player comes back. If the database is not working, the player is killed instead (as with `KILL`).
{% endhint %}

### Servers before 1.21.9

Mannequins don't exist before Minecraft 1.21.9. `combat-log.npc.fallback` decides what to do there:

| Fallback           | What happens                                                                                                                                                                                                               |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ZOMBIE` (default) | The NPC is a husk (a zombie that doesn't burn in daylight) wearing the player's head and armor. In peaceful worlds, where monsters can't exist, it is a villager wearing the player's head. Everything else works the same |
| `KILL`             | The player dies when leaving, as with `punishment: KILL`                                                                                                                                                                   |
| `NOTHING`          | No NPC and no death: only the money penalty, commands and message                                                                                                                                                          |

## KILL

The player dies the moment they leave and drops their items as set in `kills.drops`. The kill goes to the last player who hit them, so it gives stats, rewards and bounties like a normal kill.

## Who is not punished

* **When the server stops.** Players who leave in the minute after someone types `/stop` or `/restart` (the bare command), or while the plugin is shutting down, are only taken out of combat. NPCs that are still in the world when the server stops are removed and their owners are not punished.
* **Kicks by staff or by other plugins.** Kicks that are not the player's doing are not punished:
  * On **Paper** (and its forks) the plugin knows the cause of each kick. Kicks by `/kick`, bans, the whitelist, a restart or the resource pack are not punished. **Logging in again from another place, timeouts, spam and the server's own kicks for flying or illegal actions are punished.** Kicks by plugins (anti-cheats, staff tools) and kicks with an unknown cause follow the word list below, so an anti-cheat kick that says "flying", "cheat" or "hack" is punished.
  * On **Spigot** there is no cause, so only kicks whose reason has one of the words of `combat-log.kick-reasons-that-punish` are punished:

```yaml
combat-log:
  kick-reasons-that-punish: ["another location", "timed out", "spam", "illegal", "flying", "invalid", "cheat", "hack", "disconnect.spam"]
```

* Players with `rncombat.bypass.combatlog`.
* Players who were already dead when they left.

## Pending punishments

The punishment of a killed NPC is saved in the database, so it is applied the next time the player joins, even after a restart. With `combat-log.tell-on-join: true` (default) the player is told why they died.

### Networks with one MySQL database

When several servers share one MySQL database, give each server its own name in `storage.server-id` (for example `survival` and `factions`). A combat log punishment is then applied on the server where it happened: a player whose NPC was killed on `survival` is not killed when they join the lobby, only when they go back to `survival`. Leave it `""` for a single server.
