# SU.Entity.SetHealth

## SU.Entity.SetHealth(entityId, newHealth)

Setzt die Lebenspunkte der angegebenen Entität.

#### Notiz

* Haben Entitäten keine Lebenspunkte (=0), werden sie ignoriert
* Der gegebene Absolutwert (`newHealth`) wird auf die maximalen Lebenspunkte der Entität beschränkt
* `newHealth=0` setzt die Lebenspunkte zwar auf 0, löst aber **nicht** die Kill-Funktion aus (Entität ist danach quasi 1-Hit)
* `newHealth` im negativen Bereich (<0) wird ignoriert und die Funktion nicht ausgeführt (siehe Rückgabewert)

#### Parameter

* `entityId`: ID der Entität
* `newHealth`: neue absoluten Lebenspunkte (siehe Notizen)

#### Rückgabewert

* Neue Lebenspunkte
* -1: sonst / Fehler

#### Beispiel

<pre class="language-lua"><code class="lang-lua">local newHealth = SU.Entity.SetHealth(entityID, health)

local newHealth = SU.Entity.SetHealth(1, 100)
-- Setzt EntityId 1 auf 100 Leben
<strong>dbg.stm(newHealth) -- Neuer Lebenswert
</strong>
</code></pre>


---

# Agent Instructions: 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.settlers-united.com/s4-lua-api-de/su-library-functions/su.entity/su.entity.sethealth.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.
