Lua-Scripting: Boss & Entitäten
Diese Seite behandelt alles rund um Boss- und Entitäts-Wrapper in EliteMobs-Lua-Powers: context.boss, context.player, context.players, context.entities und die Entitäts-Wrapper-Tabellen, die sie zurückgeben. Wenn Sie neu bei Lua-Powers sind, beginnen Sie zuerst mit Erste Schritte.
Entitäts-Wrapper
Wenn Sie über die Lua-API auf Entitäten zugreifen — sei es über context.boss, context.player, Abfrageergebnisse wie context.players:nearby_players() oder Event-Felder — erhalten Sie immer Wrapper-Tabellen. Dies sind keine rohen Bukkit-Objekte. Jeder Wrapper stellt eine Reihe von Feldern (Snapshot-Werte, die zum Erstellungszeitpunkt erfasst werden) und Methoden (Live-Aufrufe, die auf den Server zugreifen) bereit.
Zwei Regeln zum Merken:
- Felder wie
health,current_locationundmaximum_healthsind Snapshots. Sie spiegeln den Zustand zum Zeitpunkt der Wrapper-Erstellung wider und aktualisieren sich nicht automatisch. - Methoden wie
get_location(),get_health()undis_alive()führen bei jedem Aufruf eine Live-Überprüfung durch.
Gemeinsame Entitätsfelder
Jeder Living-Entity-Wrapper enthält diese Felder.
| Feld | Typ | Hinweise |
|---|---|---|
entity.name | string | Anzeigename |
entity.uuid | string | UUID als Text |
entity.entity_type | string | Bukkit-EntityType-Name (z. B. "ZOMBIE", "PLAYER") |
entity.is_player | boolean | true für Spieler |
entity.is_elite | boolean | true, wenn EliteMobs diese Entität als Elite verfolgt |
entity.is_custom_boss | boolean | true, wenn die Entität ein Custom Boss ist (regional, instanziert usw.) |
entity.is_significant_boss | boolean | true für Custom Bosses mit einem Health-Multiplier über 1 (d. h. große Bosse, keine kleineren Reinforcements) |
entity.is_monster | boolean | true für Monster-Entitäten |
entity.is_valid | boolean | Snapshot-Gültigkeitsflag |
entity.health | number | Aktuelle Gesundheit (Snapshot) |
entity.maximum_health | number | Maximale Gesundheit (Snapshot) |
entity.current_location | location-Tabelle | Position zum Zeitpunkt der Wrapper-Erstellung |
entity.elite | Tabelle oder nil | Elite-spezifische Sub-Tabelle; nur vorhanden, wenn entity.is_elite true ist und EliteMobs Elite-Daten zur Entität hat. Siehe Elite-Sub-Tabelle unten. |
Elite-Sub-Tabelle
Wenn eine Entität ein EliteMobs-Elite ist, hat der Wrapper eine zusätzliche Tabelle entity.elite mit Elite-spezifischen Feldern und Methoden. Bei Nicht-Elites fehlt dieses Feld (nil).
| Feld / Methode | Typ | Hinweise |
|---|---|---|
entity.elite.level | number | Das Level des Elites |
entity.elite.name | string oder nil | Der konfigurierte Anzeigename des Elites |
entity.elite.health | number | Snapshot der aktuellen Gesundheit (gleicher Wert wie entity.health) |
entity.elite.max_health | number | Snapshot der maximalen Gesundheit (gleicher Wert wie entity.maximum_health) |
entity.elite.is_custom_boss | boolean | Ob der Elite ein Custom Boss ist |
entity.elite.health_multiplier | number | Am Custom Boss konfigurierter Health-Multiplier (1.0 für reguläre Elites) |
entity.elite.damage_multiplier | number | Am Custom Boss konfigurierter Damage-Multiplier (1.0 für reguläre Elites) |
entity.elite:remove() | Methode | Entfernt den Elite (mit dem Entfernungsgrund OTHER). Verwenden Sie dies für saubere Despawns aus Skripten. |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
if context.boss.elite ~= nil then
context.log:info("Boss level: " .. context.boss.elite.level)
context.log:info("Health x" .. context.boss.elite.health_multiplier)
end
end
}
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local target = context.players:current_target()
if target ~= nil then
context.log:info("Target: " .. target.name .. " HP: " .. target.health)
end
end
}
Gemeinsame Entitätsmethoden
Jeder Living-Entity-Wrapper unterstützt diese Methoden. Jede Methode führt einen Live-Aufruf an den Server aus.
entity:is_alive()
Gibt true zurück, wenn die Entität noch gültig und nicht tot ist.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if context.player:is_alive() then
context.player:send_message("&aYou're still standing!")
end
end
}
entity:get_location()
Gibt den aktuellen Live-Standort als location-Tabelle zurück.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
local loc = context.player:get_location()
context.world:play_sound_at_location(loc, "entity.experience_orb.pickup")
end
}
entity:get_eye_location()
Gibt den Standort auf Augenhöhe als location-Tabelle zurück.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
local eye = context.player:get_eye_location()
context.world:spawn_particle_at_location(eye, "FLAME")
end
}
entity:get_health() / entity:get_maximum_health()
Gibt die aktuelle bzw. maximale Gesundheit live zurück.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
local pct = context.player:get_health() / context.player:get_maximum_health()
if pct < 0.25 then
context.player:send_message("&cYou're running low!")
end
end
}
entity:get_velocity()
Gibt die aktuelle Geschwindigkeit der Entität als Vektor-Tabelle zurück.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
local vel = context.player:get_velocity()
context.log:info("Player speed Y: " .. vel.y)
end
}
entity:send_message(text)
Sendet eine Chat-Nachricht an die Entität. Unterstützt EliteMobs-Farbformatierung.
| Parameter | Typ | Hinweise |
|---|---|---|
text | string | Nachricht mit Farbcodes |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
context.player:send_message("&6[Boss] &fPrepare yourself!")
end
}
entity:show_action_bar(message)
Sendet eine Action-Bar-Nachricht an die Entität.
| Parameter | Typ | Hinweise |
|---|---|---|
message | string | Action-Bar-Text mit Farbcodes |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
context.player:show_action_bar("&c&lDANGER ZONE")
end
}
entity:show_title(title[, subtitle][, fadeIn][, stay][, fadeOut])
Sendet einen Titel und optionalen Untertitel an die Entität.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
title | string | Titeltext | |
subtitle | string | "" | Untertiteltext |
fadeIn | number | 10 | Einblend-Ticks |
stay | number | 40 | Verweildauer-Ticks |
fadeOut | number | 10 | Ausblend-Ticks |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local nearby = context.players:nearby_players(20)
for _, p in ipairs(nearby) do
p:show_title("&4PHASE 2", "&7The boss is enraged!", 10, 40, 10)
end
end
}
entity:show_boss_bar(title[, color][, style][, duration])
Zeigt der Entität eine temporäre Boss-Bar an.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
title | string | Titeltext der Bar | |
color | string | "WHITE" | BarColor-Wert |
style | string | "SOLID" | BarStyle-Wert |
duration | number | 40 | Dauer in Ticks |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local nearby = context.players:nearby_players(20)
for _, p in ipairs(nearby) do
p:show_boss_bar("&cIncoming Attack!", "RED", "SOLID", 100)
end
end
}
entity:teleport_to_location(location)
Teleportiert die Entität zu einem Standort.
| Parameter | Typ | Hinweise |
|---|---|---|
location | location-Tabelle | Ziel |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("teleport_pull", 200) then return end
context.player:teleport_to_location(context.boss:get_location())
context.player:send_message("&cThe boss pulls you in!")
end
}
entity:set_velocity_vector(vector)
Setzt die Geschwindigkeit der Entität sofort.
| Parameter | Typ | Hinweise |
|---|---|---|
vector | Vektor-Tabelle | { x, y, z } oder { x = 0, y = 1, z = 0 } |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("launch", 100) then return end
context.player:set_velocity_vector({ x = 0, y = 1.5, z = 0 })
context.player:send_message("&cYou are launched into the air!")
end
}
entity:apply_push_vector(vector[, additive][, delay])
Wendet nach einer kurzen Verzögerung (Standard 1 Tick) einen Velocity-Push an. Nützlich, um Knockback zu überschreiben.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
vector | Vektor-Tabelle | Richtung und Stärke | |
additive | boolean | false | Zur bestehenden Geschwindigkeit addieren statt ersetzen |
delay | number | 1 | Verzögerung in Ticks bis zur Anwendung |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("push_up", 100) then return end
context.player:apply_push_vector({ x = 0, y = 2.0, z = 0 })
context.player:send_message("&cUpward blast!")
end
}
entity:face_direction_or_location(directionOrLocation)
Lässt die Entität in Richtung eines Richtungsvektors oder Standorts blicken.
| Parameter | Typ | Hinweise |
|---|---|---|
directionOrLocation | Vektor- oder location-Tabelle | Ziel, in dessen Richtung geblickt werden soll |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
context.player:face_direction_or_location(context.boss:get_location())
context.player:send_message("&cThe boss forces you to look at it!")
end
}
entity:set_fire_ticks(ticks)
Setzt die Entität für die angegebene Dauer in Brand.
| Parameter | Typ | Hinweise |
|---|---|---|
ticks | number | Branddauer in Ticks (20 Ticks = 1 Sekunde) |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("ignite", 100) then return end
context.player:set_fire_ticks(60)
context.player:send_message("&cYou catch fire!")
end
}
entity:add_visual_freeze_ticks([ticks])
Fügt der Entität visuelle Freeze-Ticks hinzu (der blaue Overlay-Effekt).
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
ticks | number | 1 | Anzahl der Freeze-Ticks |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("freeze", 200) then return end
context.player:add_visual_freeze_ticks(100)
context.player:send_message("&bYou feel a chilling frost!")
end
}
entity:apply_potion_effect(effect, duration[, amplifier])
Wendet einen Trankeffekt auf die Entität an.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
effect | string | PotionEffectType-Name | |
duration | number | Dauer in Ticks | |
amplifier | number | 0 | Effektlevel (0 = Level I) |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("slow", 200) then return end
context.player:apply_potion_effect("SLOWNESS", 60, 1)
context.player:send_message("&7You feel sluggish...")
end
}
remove_potion_effect(effect) ist in EliteMobs-Lua-Powers nicht verfügbar. Es existiert nur in Magmacore/FMM. Verwenden Sie als Workaround apply_potion_effect mit einer Dauer von 0 oder entwerfen Sie Ihre Power so, dass das Entfernen von Effekten nicht erforderlich ist.
entity:deal_damage(amount) / entity:deal_custom_damage(amount) / entity:deal_damage_from_boss(amount)
Fügt der Entität Schaden zu. Drei Varianten sind verfügbar.
| Methode | Hinweise |
|---|---|
deal_damage(amount) | Generische Schadensquelle |
deal_custom_damage(amount) | Verwendet BossCustomAttackDamage vom Boss |
deal_damage_from_boss(amount) | Die Boss-Entität wird als Verursacher gesetzt |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local nearby = context.players:nearby_players(10)
for _, p in ipairs(nearby) do
p:deal_custom_damage(10)
p:send_message("&cThe boss unleashes a shockwave!")
end
end
}
entity:restore_health(amount)
Heilt die Entität bis maximal zu ihrer maximalen Gesundheit.
| Parameter | Typ | Hinweise |
|---|---|---|
amount | number | Zu heilende Menge |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
-- Heal the player slightly when they hit the boss
context.player:restore_health(5)
context.player:send_message("&aYou drain life from the boss!")
end
}
entity:set_invulnerable(enabled[, duration])
Schaltet die Unverwundbarkeit der Entität um. Optional wird der Zustand nach einer Dauer zurückgesetzt.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
enabled | boolean | true, um Unverwundbarkeit zu aktivieren | |
duration | number | nil | Automatisch nach dieser Anzahl von Ticks zurücksetzen |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("shield", 200) then return end
context.player:set_invulnerable(true, 40)
context.player:send_message("&6A brief shield protects you!")
end
}
entity:set_ai_enabled(enabled[, duration])
Schaltet die KI der Entität um. Optional wird der Zustand nach einer Dauer zurückgesetzt.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
enabled | boolean | true, um die KI zu aktivieren | |
duration | number | nil | Automatisch nach dieser Anzahl von Ticks zurücksetzen |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Disable boss AI for 3 seconds at combat start
context.boss:set_ai_enabled(false, 60)
context.boss:send_message("&7The boss is stunned!")
end
}
entity:add_tag(tag[, duration]) / entity:remove_tag(tag) / entity:has_tag(tag)
Verwaltet Tags an der Entität. Tags werden von EliteMobs verfolgt und bleiben für die Lebensdauer der Entität bestehen.
| Methode | Parameter | Hinweise |
|---|---|---|
add_tag(tag[, duration]) | string, optional number | Fügt Tag hinzu, optional automatisches Entfernen nach Ticks |
remove_tag(tag) | string | Entfernt den Tag |
has_tag(tag) | string | Gibt true zurück, wenn der Tag vorhanden ist |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.player:has_tag("marked") then
context.player:add_tag("marked", 200)
context.player:send_message("&cYou have been marked!")
end
end
}
entity:run_command(command)
Lässt die Entität einen Befehl ausführen. Bei Spielern wird der Befehl als der Spieler ausgeführt; verwenden Sie den Befehlstext ohne führenden /.
| Parameter | Typ | Hinweise |
|---|---|---|
command | string | Befehlstext ohne führenden / |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("curse_cmd", 200) then return end
context.player:run_command("say I have been cursed!")
end
}
entity:set_scale(scale[, duration])
Setzt das Attribut generic_scale der Entität. Setzt es optional nach einer Dauer auf 1.0 zurück.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
scale | number | Skalierungsmultiplikator | |
duration | number | nil | Automatisch nach dieser Anzahl von Ticks zurücksetzen |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Boss grows to double size for 5 seconds
context.boss:set_scale(2.0, 100)
context.boss:send_message("&4The boss grows in size!")
end
}
entity:set_gravity(enabled)
Schaltet die Schwerkraft der Entität um.
| Parameter | Typ | Hinweise |
|---|---|---|
enabled | boolean | true für normale Schwerkraft |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("levitate", 200) then return end
-- Disable player gravity briefly and re-enable after 3 seconds
context.player:set_gravity(false)
context.player:send_message("&dYou begin to float!")
context.scheduler:run_after(60, function()
if context.player ~= nil and context.player:is_alive() then
context.player:set_gravity(true)
end
end)
end
}
entity:play_sound_at_entity(sound[, volume][, pitch])
Spielt einen Sound am Standort der Entität ab.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
sound | string | Bukkit-Sound-Name | |
volume | number | 1.0 | Lautstärke |
pitch | number | 1.0 | Tonhöhe |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
context.player:play_sound_at_entity("entity.ender_dragon.growl", 1.0, 0.5)
end
}
entity:play_sound_at_self(sound[, volume][, pitch])
Alias für play_sound_at_entity. Spielt einen Sound am Standort der Entität ab. Beide Namen funktionieren identisch.
entity:spawn_particle_at_self(particleOrSpec[, count])
Spawnt Partikel am Standort der Entität.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
particleOrSpec | string oder Tabelle | Partikelname oder Spec-Tabelle | |
count | number | 1 | Anzahl der Partikel |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
context.player:spawn_particle_at_self("HEART", 5)
end
}
entity:spawn_particles_at_location(location, particle[, count])
Spawnt Partikel an einem bestimmten Standort.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
location | location-Tabelle | Zielstandort | |
particle | string | Name des Partikeltyps | |
count | number | 1 | Anzahl der Partikel |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
local loc = context.player:get_location()
context.player:spawn_particles_at_location(loc, "FLAME", 10)
end
}
entity:play_model_animation(name)
Spielt eine Custom-Model-Animation ab, falls die Entität ein Custom Model besitzt, das dies unterstützt.
| Parameter | Typ | Hinweise |
|---|---|---|
name | string | Animationsname |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
context.boss:play_model_animation("attack_swing")
end
}
entity:push_relative_to(source[, strength][, xOffset][, yOffset][, zOffset])
Stößt die Entität von einem Quell-Standort oder Entity-Wrapper weg.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
source | Location oder Wrapper | Ursprung des Stoßes | |
strength | number | 1.0 | Multiplikator für die Stoßkraft |
xOffset | number | 0 | Zusätzlicher X-Offset |
yOffset | number | 0 | Zusätzlicher Y-Offset |
zOffset | number | 0 | Zusätzlicher Z-Offset |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("knockback", 60) then return end
context.player:push_relative_to(context.boss:get_location(), 2.0, 0, 0.5, 0)
context.player:send_message("&cThe boss knocks you back!")
end
}
entity:set_custom_name(name) / entity:reset_custom_name()
Setzt oder setzt den benutzerdefinierten Anzeigenamen der Entität zurück. Unterstützt Farbcodes.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("mark", 200) then return end
context.player:set_custom_name("&c&lMarked Target")
context.player:send_message("&cYou have been marked!")
-- Reset after 5 seconds
context.scheduler:run_after(100, function()
if context.player ~= nil and context.player:is_alive() then
context.player:reset_custom_name()
end
end)
end
}
entity:place_temporary_block(material[, duration][, requireAir])
Platziert einen temporären Block am aktuellen Standort der Entität.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
material | string | Name des Blockmaterials | |
duration | number | 0 | Ticks bis zur Entfernung |
requireAir | boolean | false | Nur platzieren, wenn der Block aktuell Luft ist |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("ice_trap", 200) then return end
context.player:place_temporary_block("ICE", 60, true)
context.player:send_message("&bIce forms at your feet!")
end
}
entity:get_height()
Gibt die Höhe der Entität in Blöcken zurück.
entity:is_on_ground()
Gibt true zurück, wenn die Entität aktuell auf festem Boden steht.
entity:is_frozen()
Gibt true zurück, wenn die Entität (sofern als Custom Boss verfolgt) das Frozen-Flag gesetzt hat.
entity:set_awareness_enabled(aware[, duration])
Schaltet die Mob-Awareness um. Wirkt nur auf Mob-Entitäten. Optional wird der Zustand nach einer Dauer zurückgesetzt.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
aware | boolean | true, um Awareness zu aktivieren | |
duration | number | nil | Automatisch nach dieser Anzahl von Ticks zurücksetzen |
entity:is_healing() / entity:set_healing(enabled)
Prüft oder schaltet den Healing-Zustand einer Elite-Entität um.
entity:overlaps_box_at_location(center[, halfX][, halfY][, halfZ])
Gibt true zurück, wenn die Bounding-Box der Entität eine achsenparallele Box am angegebenen Standort überlappt.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
center | location-Tabelle | Mittelpunkt der Test-Box | |
halfX | number | 0.5 | Halbe Breite auf der X-Achse |
halfY | number | wie halfX | Halbe Höhe auf der Y-Achse |
halfZ | number | wie halfX | Halbe Breite auf der Z-Achse |
entity:remove_elite()
Entfernt die Elite-Entität aus dem EliteMobs-Tracking. Wenn die Entität ein Elite ist, despawnt sie ordnungsgemäß über EliteMobs.
entity:set_custom_name_visible(visible)
Legt fest, ob der benutzerdefinierte Name der Entität immer sichtbar ist oder nur beim Anvisieren.
| Parameter | Typ | Hinweise |
|---|---|---|
visible | boolean | true für immer sichtbar |
entity:set_equipment(slot, material[, options])
Setzt Ausrüstung an der Entität.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
slot | string | Ausrüstungs-Slot: "HEAD", "CHEST", "LEGS", "FEET", "HAND", "OFF_HAND" | |
material | string | Materialname (z. B. "DIAMOND_SWORD", "IRON_HELMET") | |
options | Tabelle | {} | Optionale Einstellungen (siehe unten) |
Options-Tabelle:
| Schlüssel | Typ | Standard | Hinweise |
|---|---|---|---|
enchantments | Array von Tabellen | nil | Jeder Eintrag: { type = "SHARPNESS", level = 2 } |
unbreakable | boolean | false | Ob das Item unzerbrechlich ist |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Give the boss a glowing diamond sword
context.boss:set_equipment("HAND", "DIAMOND_SWORD", {
unbreakable = true,
enchantments = {
{ type = "SHARPNESS", level = 5 }
}
})
end
}
entity.is_ai_enabled
Eine Methode, die true zurückgibt, wenn die Entität aktuell aktivierte KI hat.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.boss:is_ai_enabled() then
context.log:info("Boss AI is active")
else
context.log:info("Boss AI is disabled (stunned?)")
end
end
}
Referenz-Wrapper für nicht-lebende Entitäten
Wenn eine gespawnte Entität keine LivingEntity ist — zum Beispiel ein fallender Block, ein Projektil oder ein Feuerball — erhalten Sie einen leichteren Referenz-Wrapper. Diese werden von Methoden wie context.world:spawn_falling_block_at_location() oder context.boss:summon_projectile() zurückgegeben.
Felder: name, uuid, entity_type, is_player, is_elite, current_location
Methoden:
| Methode | Hinweise |
|---|---|
is_valid() | Live-Gültigkeitsprüfung |
get_location() | Aktueller Live-Standort |
get_velocity() | Aktueller Geschwindigkeitsvektor |
is_on_ground() | Ob am Boden |
teleport_to_location(location) | Teleportiert die Entität |
set_velocity_vector(vector) | Setzt Geschwindigkeit |
set_direction_vector(vector) | Setzt Richtung (nur Fireball) |
set_yield(value) | Setzt Explosions-Yield (nur Fireball) |
set_gravity(enabled) | Schaltet Schwerkraft um |
detonate() | Zündet Firework-Entitäten |
remove() | Entfernt die Entität aus der Welt |
unregister([reason]) | Meldet sie vom Entity-Tracker ab |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("fireball", 100) then return end
local fb = context.boss:summon_projectile("FIREBALL",
context.boss:get_eye_location(),
context.player:get_location(),
1.5
)
-- fb is a non-living reference wrapper; remove it after 5 seconds if still alive
context.scheduler:run_after(100, function()
if fb:is_valid() then
fb:remove()
end
end)
end
}
context.player
Verfügbar in Hooks, in denen ein Spieler direkt beteiligt ist (on_boss_damaged_by_player, on_player_damaged_by_boss usw.). Player-Wrapper enthalten jedes oben aufgeführte gemeinsame Entitätsfeld und jede Methode sowie zusätzlich die unten genannten Extras.
context.player ist nil in Hooks, die keinen zugehörigen Spieler haben, etwa on_spawn, geplanten Callbacks und Timer-Hooks. Prüfen Sie vor der Verwendung stets auf nil.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
context.player:send_message("&cHello!")
end
}
Spieler-spezifische Felder
| Feld | Typ | Hinweise |
|---|---|---|
game_mode | string | Aktueller Spielmodus-Name (z. B. "SURVIVAL") |
Spieler-spezifische Methoden
| Methode | Hinweise |
|---|---|
send_message(message) | Chat-Nachricht mit EliteMobs-Farbformatierung |
show_action_bar(message) | Action-Bar-Text |
show_title(title[, subtitle][, fadeIn][, stay][, fadeOut]) | Titel-Overlay |
show_boss_bar(title[, color][, style][, duration]) | Temporäre Boss-Bar |
run_command(command) | Befehl als der Spieler ausführen (ohne führenden /) |
Beispiel
return {
api_version = 1,
on_player_damaged_by_boss = function(context)
if context.player == nil then return end
local hp_pct = context.player:get_health() / context.player:get_maximum_health()
if hp_pct < 0.3 then
context.player:show_title("&4LOW HEALTH", "&7Find cover!", 5, 30, 10)
context.player:show_boss_bar("&cBoss Enrage Incoming", "RED", "SEGMENTED_6", 80)
end
end
}
context.boss
Der Boss-Wrapper für den Elite-Mob, der diese Lua-Power besitzt. Immer in jedem Hook verfügbar.
Der Boss-Wrapper erbt jede der oben aufgeführten gemeinsamen Entitätsmethoden (z. B. push_relative_to, apply_push_vector, set_gravity, set_scale, set_invulnerable, spawn_particle_at_self, overlaps_box_at_location usw.). Die in diesem Abschnitt dokumentierten Methoden sind entweder boss-spezifisch oder verhalten sich über den EliteEntity-Layer anders.
Boss-Felder
| Feld | Typ | Hinweise |
|---|---|---|
boss.name | string | Anzeigename |
boss.uuid | string | UUID des Boss-Elites |
boss.entity_type | string | Bukkit-EntityType-Name |
boss.is_monster | boolean | true, wenn die zugrundeliegende Entität ein Monster ist |
boss.level | number | Elite-Level |
boss.health | number | Aktuelle Gesundheit (Snapshot) |
boss.maximum_health | number | Maximale Gesundheit (Snapshot) |
boss.damager_count | number | Anzahl der Damager (Snapshot) |
boss.is_in_combat | boolean | Kampfzustand |
boss.exists | boolean | Ob der Elite noch existiert |
boss.current_location | location-Tabelle | Position zur Wrapper-Erstellung (Snapshot) |
Beispiel
return {
api_version = 1,
on_spawn = function(context)
context.log:info(context.boss.name .. " level " .. context.boss.level)
end
}
Boss-Methoden
boss:is_alive()
Gibt true zurück, wenn die Boss-Entität gültig ist, nicht tot ist und der Elite noch existiert. Verwenden Sie dies anstelle des exists-Felds für Live-Prüfungen.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if not context.boss:is_alive() then return end
context.boss:send_message("&cI still live!")
end
}
boss:get_location()
Gibt den aktuellen Live-Standort des Bosses als location-Tabelle zurück.
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local loc = context.boss:get_location()
context.world:spawn_particle_at_location(loc, "FLAME")
end
}
boss:get_eye_location()
Gibt den Standort des Bosses auf Augenhöhe zurück.
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local eye = context.boss:get_eye_location()
context.world:spawn_particle_at_location(eye, "SMOKE")
end
}
boss:set_ai_enabled(enabled[, duration])
Schaltet die KI des Bosses um. Optional wird der Zustand nach einer Dauer zurückgesetzt.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
enabled | boolean | true, um die KI zu aktivieren | |
duration | number | nil | Automatisch nach dieser Anzahl von Ticks zurücksetzen |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if not context.cooldowns:check_local("stun", 200) then return end
context.boss:set_ai_enabled(false, 60)
context.boss:send_message("&7The boss is stunned for 3 seconds!")
end
}
boss:teleport_to_location(location)
Teleportiert den Boss zu einem Standort.
| Parameter | Typ | Hinweise |
|---|---|---|
location | location-Tabelle | Ziel |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if not context.cooldowns:check_local("retreat", 300) then return end
local spawn = context.entities:get_boss_spawn_location()
context.boss:teleport_to_location(spawn)
context.boss:send_message("&7The boss retreats to its lair!")
end
}
boss:set_velocity_vector(vector)
Setzt die Geschwindigkeit des Bosses sofort.
| Parameter | Typ | Hinweise |
|---|---|---|
vector | Vektor-Tabelle | { x, y, z } oder { x = 0, y = 1, z = 0 } |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Boss leaps into the air at combat start
context.boss:set_velocity_vector({ x = 0, y = 2.0, z = 0 })
context.boss:send_message("&cThe boss leaps!")
end
}
boss:restore_health(amount)
Heilt den Boss bis maximal zu seiner maximalen Gesundheit.
| Parameter | Typ | Hinweise |
|---|---|---|
amount | number | Zu heilende Menge |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if not context.cooldowns:check_local("heal", 200) then return end
context.boss:restore_health(20)
context.boss:send_message("&aThe boss regenerates!")
context.boss:spawn_particle_at_self("HEART")
end
}
boss:play_sound_at_self(sound[, volume][, pitch])
Spielt einen Sound am Standort des Bosses ab.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
sound | string | Bukkit-Sound-Name | |
volume | number | 1.0 | Lautstärke |
pitch | number | 1.0 | Tonhöhe |
Beispiel
return {
api_version = 1,
on_spawn = function(context)
context.boss:play_sound_at_self("entity.wither.spawn", 1.0, 0.8)
end
}
boss:spawn_particle_at_self(particleOrSpec[, count])
Spawnt Partikel am Standort des Bosses.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
particleOrSpec | string oder Tabelle | Partikelname oder Spec-Tabelle | |
count | number | 1 | Anzahl der Partikel |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
context.boss:spawn_particle_at_self("SMOKE", 20)
context.boss:send_message("&8Smoke billows from the boss!")
end
}
boss:play_model_animation(name)
Spielt eine Custom-Model-Animation auf dem Boss ab, falls verfügbar.
| Parameter | Typ | Hinweise |
|---|---|---|
name | string | Animationsname |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
context.boss:play_model_animation("slam")
end
}
boss:face_direction_or_location(vectorOrLocation)
Lässt den Boss eine Richtung oder einen Standort anvisieren.
| Parameter | Typ | Hinweise |
|---|---|---|
vectorOrLocation | Vektor- oder location-Tabelle | Richtung, in die geblickt werden soll |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
context.boss:face_direction_or_location(context.player:get_location())
end
}
boss:navigate_to_location(location[, speed][, follow][, timeout])
Verwendet Pathfinding, um den Boss zu einem Standort laufen zu lassen.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
location | location-Tabelle | Ziel | |
speed | number | 1.0 | Multiplikator für die Bewegungsgeschwindigkeit |
follow | boolean | false | Dem Ziel kontinuierlich folgen |
timeout | number | nil | Navigation nach dieser Anzahl von Ticks abbrechen |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("charge", 200) then return end
context.boss:navigate_to_location(context.player:get_location(), 1.5)
context.boss:send_message("&cThe boss charges at you!")
end
}
boss:add_tag(tag[, duration]) / boss:remove_tag(tag) / boss:has_tag(tag)
Verwaltet Tags am Boss.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
local pct = context.boss:get_health() / context.boss:get_maximum_health()
if pct < 0.5 and not context.boss:has_tag("phase2") then
context.boss:add_tag("phase2")
context.boss:send_message("&4Entering Phase 2!")
end
end
}
boss:send_message(message[, range])
Sendet eine Chat-Nachricht an alle Spieler in der Nähe.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
message | string | Nachrichtentext mit Farbcodes | |
range | number | 20 | Radius in Blöcken |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
context.boss:send_message("&4You dare challenge me?!")
end
}
boss:summon_projectile(entityType, origin, destination[, speed][, options])
Schleudert eine projektilartige Entität vom Boss ab.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
entityType | string | Entitätstyp (z. B. "FIREBALL", "ARROW") | |
origin | location-Tabelle | Startposition | |
destination | location-Tabelle | Zielposition | |
speed | number | 1.0 | Projektilgeschwindigkeit |
options | Tabelle | {} | Siehe Optionen unten |
Options-Tabelle:
| Schlüssel | Typ | Hinweise |
|---|---|---|
duration | number | Automatisches Entfernen nach Ticks |
max_ticks | number | Maximale Ticks zur Überwachung der Landung |
custom_damage | number | Schaden beim Aufprall |
detonation_power | string | Explosionsstärke beim Aufprall |
yield | number | Explosions-Yield (Fireball) |
persistent | boolean | Ob das Projektil persistent ist (Standard true) |
effect | string | EntityEffect-Name, der beim Spawn abgespielt wird |
incendiary | boolean | Ob die Explosion brandstiftend ist |
gravity | boolean | Ob das Projektil der Schwerkraft unterliegt |
glowing | boolean | Glüh-Effekt |
invulnerable | boolean | Ob das Projektil unverwundbar ist |
track | boolean | Ob das Ziel verfolgt werden soll |
spawn_at_origin | boolean | Am Ursprung statt mit Offset spawnen |
direction_only | boolean | Nur Richtung verwenden, Ziel ignorieren |
on_land | function | Callback (landing_location, spawned_entity) |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("fireball", 100) then return end
context.boss:summon_projectile(
"FIREBALL",
context.boss:get_eye_location(),
context.player:get_location(),
1.5,
{
custom_damage = 10,
on_land = function(loc, entity)
context.world:spawn_particle_at_location(loc, "EXPLOSION")
end
}
)
end
}
boss:summon_reinforcement(filename, zoneOrLocation[, duration])
Beschwört einen Reinforcement-Boss aus einer Konfigurationsdatei.
| Parameter | Typ | Hinweise |
|---|---|---|
filename | string | Dateiname der Boss-Konfiguration |
zoneOrLocation | location-Tabelle oder Zone | Spawn-Standort oder Zonendefinition |
duration | number | Optionales automatisches Despawn nach Ticks |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
context.boss:summon_reinforcement("my_minion.yml", context.boss:get_location(), 200)
context.boss:send_message("&cMinions, come to my aid!")
end
}
boss:despawn()
Entfernt den Boss aus der Welt.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
local pct = context.boss:get_health() / context.boss:get_maximum_health()
if pct < 0.1 then
context.boss:send_message("&7The boss vanishes into thin air!")
context.boss:despawn()
end
end
}
boss:get_nearby_players(range)
Gibt ein Array von Spieler-Wrappern innerhalb der angegebenen Reichweite des Bosses zurück.
| Parameter | Typ | Hinweise |
|---|---|---|
range | number | Radius in Blöcken |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local players = context.boss:get_nearby_players(30)
for _, p in ipairs(players) do
p:show_action_bar("&cThe boss sees you!")
end
end
}
boss:get_damager_count()
Gibt live die Anzahl der Spieler zurück, die diesen Boss beschädigt haben. Anders als das Feld damager_count führt diese Methode eine Live-Prüfung durch.
boss:get_target_player()
Gibt das aktuelle Mob-Ziel des Bosses als Spieler-Wrapper zurück, oder nil, falls das Ziel kein Spieler ist oder keines gesetzt ist.
Zonen- und Partikelmethoden
Diese Methoden kombinieren Zonen mit Partikeleffekten. Sie erfordern eine Zonentabelle als Eingabe.
boss:get_nearby_players_in_zone(zone)
Gibt ein Array von Spieler-Wrappern für alle Spieler zurück, die sich aktuell innerhalb der angegebenen Zone befinden.
| Parameter | Typ | Hinweise |
|---|---|---|
zone | Zonen-Tabelle | Eine Zonenform-Definition |
boss:spawn_particles_in_zone(zone, particle, ..., coverage?)
Füllt das Innere einer Zone mit Partikeln.
| Parameter | Typ | Hinweise |
|---|---|---|
zone | Zonen-Tabelle | Auszufüllende Zonenform |
particle | string | Name des Partikeltyps |
... | Weitere Partikelparameter | |
coverage | number (optional) | Faktor für die Partikeldichte |
boss:spawn_particles_in_zone_border(zone, particle, ..., coverage?)
Zeichnet den Rand einer Zone mit Partikeln nach.
| Parameter | Typ | Hinweise |
|---|---|---|
zone | Zonen-Tabelle | Nachzuzeichnende Zonenform |
particle | string | Name des Partikeltyps |
... | Weitere Partikelparameter | |
coverage | number (optional) | Faktor für die Partikeldichte |
boss:get_particles_from_self_toward_zone(zone, particle, speed?)
Spawnt gerichtete Partikel, die vom Boss in Richtung einer Zone wandern.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
zone | Zonen-Tabelle | Zielzone | |
particle | string | Name des Partikeltyps | |
speed | number | nil | Wanderungsgeschwindigkeit der Partikel |
boss:get_particles_toward_self(zone, particle, speed?)
Spawnt gerichtete Partikel, die von einer Zone in Richtung des Bosses wandern.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
zone | Zonen-Tabelle | Quellzone | |
particle | string | Name des Partikeltyps | |
speed | number | nil | Wanderungsgeschwindigkeit der Partikel |
boss:spawn_particles_with_vector(particles)
Spawnt ein Array gerichteter Partikel, jeweils mit eigener Position und Geschwindigkeitsvektor.
| Parameter | Typ | Hinweise |
|---|---|---|
particles | Array von Tabellen | Jeder Eintrag definiert ein Partikel mit Position und Richtung |
Ender-Dragon-Methoden
Diese Methoden gelten nur, wenn die Boss-Entität ein Ender Dragon ist.
boss:get_ender_dragon_phase()
Gibt den aktuellen EnderDragon.Phase-Namen als String zurück, oder nil, falls der Boss kein Ender Dragon ist.
boss:set_ender_dragon_phase(phase)
Setzt die Phase des Ender Dragons.
| Parameter | Typ | Hinweise |
|---|---|---|
phase | string | EnderDragon.Phase-Name (z. B. "CIRCLING", "CHARGE_PLAYER") |
Methoden zur Unterstützung spezieller Powers
Diese Methoden unterstützen integrierte EliteMobs-Power-Mechaniken aus Lua-Skripten.
boss:start_tracking_fireball_system(speed?)
Startet das Tracking-Fireball-KI-System am Boss. Der Boss schleudert in regelmäßigen Abständen Feuerbälle, die sein Ziel verfolgen.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
speed | number | 0.5 | Geschwindigkeit der Feuerbälle |
boss:handle_spirit_walk_damage(cause)
Behandelt das Spirit-Walk-Verhalten für die angegebene Schadensursache. Spirit Walk macht den Boss gegen bestimmte Schadensarten immun und teleportiert ihn hinter den Angreifer.
| Parameter | Typ | Hinweise |
|---|---|---|
cause | string | Bukkit-DamageCause-Name (z. B. "ENTITY_ATTACK", "PROJECTILE") |
boss:shield_wall_is_active()
Gibt true zurück, wenn der Boss aktuell eine aktive Shield Wall hat.
boss:initialize_shield_wall(charges?)
Aktiviert eine Shield Wall am Boss, die eingehenden Schaden absorbieren kann.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
charges | number | 1 | Anzahl der Treffer, die der Schild absorbieren kann |
boss:shield_wall_absorb_damage(player, damage)
Versucht, Schaden mit der Shield Wall zu absorbieren. Gibt true zurück, wenn der Schaden absorbiert wurde, false, wenn der Schild inaktiv oder erschöpft ist.
| Parameter | Typ | Hinweise |
|---|---|---|
player | Spieler-Wrapper | Der angreifende Spieler |
damage | number | Zu absorbierende Schadensmenge |
boss:deactivate_shield_wall()
Deaktiviert die Shield Wall des Bosses und entfernt verbleibende Ladungen.
boss:start_zombie_necronomicon(target, file)
Startet die Zombie-Necronomicon-Power auf einem Ziel und spawnt Untoten-Reinforcements aus einer Konfigurationsdatei.
| Parameter | Typ | Hinweise |
|---|---|---|
target | Entity-Wrapper | Zielentität für das Necronomicon |
file | string | Dateiname der Boss-Konfiguration für die beschworenen Untoten |
context.players
Hilfsmethoden für Spieler-Abfragen, zentriert um den Boss. Verwenden Sie diese, um Spieler zu finden, ohne dass ein bestimmter Spieler aus dem Event benötigt wird.
| Methode | Rückgabe | Hinweise |
|---|---|---|
players:current_target() | Spieler-Wrapper oder nil | Der Event-Spieler oder das Mob-Ziel des Bosses, sofern es ein Spieler ist |
players:nearby_players(radius) | Array von Spieler-Wrappern | Alle Spieler innerhalb des Radius um den Boss |
players:all_players_in_world() | Array von Spieler-Wrappern | Alle Spieler in der Welt des Bosses |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local nearby = context.players:nearby_players(20)
for _, player in ipairs(nearby) do
player:send_message("&cThe boss is enraged!")
player:apply_potion_effect("GLOWING", 60, 0)
end
end
}
Beispiel
return {
api_version = 1,
on_spawn = function(context)
-- Warn everyone in the world
local everyone = context.players:all_players_in_world()
for _, p in ipairs(everyone) do
p:show_title("&4WARNING", "&7A world boss has spawned!", 10, 60, 20)
end
end
}
context.entities
Allgemeine Hilfsmethoden zur Entitäts-Abfrage, zentriert um den Boss.
| Methode | Rückgabe | Hinweise |
|---|---|---|
entities:get_nearby_entities(radius[, filter]) | Array von Entity-Wrappern | Entitäten in der Nähe des Bosses |
entities:get_entities_in_box(center, halfX, halfY, halfZ[, filter]) | Array von Entity-Wrappern | Entitäten innerhalb einer achsenparallelen Box |
entities:get_all_entities([filter]) | Array von Entity-Wrappern | Alle passenden Entitäten in der Boss-Welt |
entities:get_direct_target_entity() | Entity-Wrapper oder nil | Direktes Ziel für das aktuelle Event |
entities:get_boss_spawn_location() | location-Tabelle | Der ursprüngliche Spawn-Standort des Bosses |
Gültige Filter: living (Standard), player / players, elite / elites, mob / mobs, all / entities
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Damage all nearby elites
local elites = context.entities:get_nearby_entities(10, "elites")
for _, elite in ipairs(elites) do
elite:deal_damage(5)
end
end
}
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Find players in a box area
local center = context.boss:get_location()
local players = context.entities:get_entities_in_box(center, 10, 5, 10, "players")
for _, p in ipairs(players) do
p:send_message("&eYou are in the danger zone!")
end
end
}
