メインコンテンツまでスキップ

Luaスクリプティング:ボスとエンティティ

webapp_banner.jpg

このページでは、EliteMobsのLuaパワーにおけるボスおよびエンティティのラッパー(context.bosscontext.playercontext.playerscontext.entities)と、それらが返すエンティティラッパーテーブルについてすべて解説します。Luaパワーが初めての方は、まず入門から始めてください。


エンティティラッパー

Lua APIを通じてエンティティにアクセスする際 -- context.bosscontext.playercontext.players:nearby_players()のようなクエリ結果、またはイベントのフィールドのいずれからでも -- 常にラッパーテーブルを受け取ります。これらは生のBukkitオブジェクトではありません。各ラッパーはフィールド(作成時に取得されたスナップショット値)とメソッド(呼び出すたびにサーバーに問い合わせるライブ呼び出し)のセットを提供します。

覚えておくべき2つのルール:

  • フィールドhealthcurrent_locationmaximum_healthなど)はスナップショットです。ラッパーが作成された瞬間の状態を反映し、自動更新されません。
  • メソッドget_location()get_health()is_alive()など)は呼び出すたびにライブチェックを実行します。

共通のエンティティフィールド

すべてのリビングエンティティラッパーには以下のフィールドが含まれます。

フィールド備考
entity.namestring表示名
entity.uuidstringテキスト形式のUUID
entity.entity_typestringBukkitのEntityType名(例:"ZOMBIE""PLAYER"
entity.is_playerbooleanプレイヤーの場合true
entity.is_elitebooleanEliteMobsがエリートとして追跡している場合true
entity.is_custom_bossbooleanカスタムボス(リージョナル、インスタンスなど)の場合true
entity.is_significant_bossboolean体力倍率が1を超えるカスタムボス(つまり主要ボスで、マイナーな増援ではない)の場合true
entity.is_monsterbooleanモンスタータイプのエンティティの場合true
entity.is_validbooleanスナップショットの有効性フラグ
entity.healthnumber現在の体力(スナップショット)
entity.maximum_healthnumber最大体力(スナップショット)
entity.current_locationlocationテーブルラッパー作成時の位置
entity.elitetableまたはnilエリート専用サブテーブル。entity.is_elitetrueで、EliteMobsがそのエンティティのエリートデータを持っているときのみ存在します。下記のエリートサブテーブルを参照してください。

エリートサブテーブル

エンティティがEliteMobsのエリートである場合、ラッパーには追加でentity.eliteテーブルがあり、エリート固有のフィールドとメソッドが含まれます。非エリートではこのフィールドは存在しません(nil)。

フィールド/メソッド備考
entity.elite.levelnumberエリートのレベル
entity.elite.namestringまたはnilエリートに設定された表示名
entity.elite.healthnumber現在の体力のスナップショット(entity.healthと同じ値)
entity.elite.max_healthnumber最大体力のスナップショット(entity.maximum_healthと同じ値)
entity.elite.is_custom_bossbooleanエリートがカスタムボスかどうか
entity.elite.health_multipliernumberカスタムボスに設定された体力倍率(通常のエリートでは1.0)
entity.elite.damage_multipliernumberカスタムボスに設定されたダメージ倍率(通常のエリートでは1.0)
entity.elite:remove()メソッドエリートを削除します(削除理由としてOTHERを使用)。スクリプトからクリーンにデスポーンさせるために使用してください。
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
}
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
}

共通のエンティティメソッド

すべてのリビングエンティティラッパーは以下のメソッドをサポートします。各メソッドはサーバーへのライブ呼び出しを実行します。


entity:is_alive()

エンティティがまだ有効で死亡していない場合にtrueを返します。

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()

現在のライブ位置をlocationテーブルとして返します。

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()

目線の高さの位置をlocationテーブルとして返します。

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()

ライブで現在の体力または最大体力を返します。

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()

エンティティの現在の速度をvectorテーブルとして返します。

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)

エンティティにチャットメッセージを送信します。EliteMobsのカラーフォーマットをサポートしています。

パラメータ備考
textstringカラーコード付きのメッセージ
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)

エンティティにアクションバーのメッセージを送信します。

パラメータ備考
messagestringカラーコード付きのアクションバーテキスト
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])

エンティティにタイトルとオプションのサブタイトルを送信します。

パラメータデフォルト備考
titlestringタイトルテキスト
subtitlestring""サブタイトルテキスト
fadeInnumber10フェードインのtick数
staynumber40滞在tick数
fadeOutnumber10フェードアウトのtick数
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])

エンティティに一時的なボスバーを表示します。

パラメータデフォルト備考
titlestringバーのタイトルテキスト
colorstring"WHITE"BarColorの値
stylestring"SOLID"BarStyleの値
durationnumber40tick単位の表示時間
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)

エンティティを指定の位置にテレポートさせます。

パラメータ備考
locationlocationテーブル目的地
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)

エンティティの速度を即座に設定します。

パラメータ備考
vectorvectorテーブル{ x, y, z }または{ x = 0, y = 1, z = 0 }
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])

短いディレイ後(デフォルトは1tick)に速度のプッシュを適用します。ノックバックをオーバーライドするのに便利です。

パラメータデフォルト備考
vectorvectorテーブル方向と強度
additivebooleanfalse置き換えではなく既存の速度に加算
delaynumber1適用までのtick単位のディレイ
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)

エンティティを方向ベクトルまたは位置の方向に向けさせます。

パラメータ備考
directionOrLocationvectorまたはlocationテーブル向ける対象
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)

指定した時間、エンティティを炎上させます。

パラメータ備考
ticksnumbertick単位の炎上時間(20tick = 1秒)
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])

エンティティに視覚的な凍結tick(青いオーバーレイ効果)を追加します。

パラメータデフォルト備考
ticksnumber1凍結のtick量
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])

エンティティにポーション効果を適用します。

パラメータデフォルト備考
effectstringPotionEffectTypeの名前
durationnumbertick単位の持続時間
amplifiernumber0効果のレベル(0 = レベルI)
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)はEliteMobsのLuaパワーでは利用できません。これはMagmacore/FMMにのみ存在します。回避策としてapply_potion_effect0の持続時間を指定して呼び出すか、効果を削除する必要のないようにパワーを設計してください。


entity:deal_damage(amount) / entity:deal_custom_damage(amount) / entity:deal_damage_from_boss(amount)

エンティティにダメージを与えます。3種類のバリアントがあります。

メソッド備考
deal_damage(amount)汎用ダメージソース
deal_custom_damage(amount)ボスのBossCustomAttackDamageを使用
deal_damage_from_boss(amount)ボスエンティティが加害者として設定される
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)

エンティティの体力を最大まで回復します。

パラメータ備考
amountnumber回復量
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])

エンティティの無敵状態を切り替えます。任意で指定した時間後に元に戻します。

パラメータデフォルト備考
enabledboolean無敵を有効化する場合はtrue
durationnumbernil指定したtick数後に自動で元に戻す
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])

エンティティのAIを切り替えます。任意で指定した時間後に元に戻します。

パラメータデフォルト備考
enabledbooleanAIを有効化する場合はtrue
durationnumbernil指定したtick数後に自動で元に戻す
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)

エンティティのタグを管理します。タグはEliteMobsによって追跡され、エンティティの生存期間中保持されます。

メソッドパラメータ備考
add_tag(tag[, duration])string、任意のnumberタグを追加。任意で指定tick後に自動削除
remove_tag(tag)stringタグを削除
has_tag(tag)stringタグが存在する場合trueを返す
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)

エンティティにコマンドを実行させます。プレイヤーの場合はプレイヤーとして実行されます。コマンドテキストは先頭の/を付けずに指定してください。

パラメータ備考
commandstring先頭の/を付けないコマンドテキスト
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])

エンティティのgeneric_scale属性を設定します。任意で指定した時間後に1.0に戻します。

パラメータデフォルト備考
scalenumberスケール倍率
durationnumbernil指定したtick数後に自動で元に戻す
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)

エンティティの重力を切り替えます。

パラメータ備考
enabledboolean通常の重力を適用する場合true
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])

エンティティの位置でサウンドを再生します。

パラメータデフォルト備考
soundstringBukkitのSound名
volumenumber1.0音量
pitchnumber1.0ピッチ
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])

play_sound_at_entityのエイリアスです。エンティティの位置でサウンドを再生します。どちらの名前も同じように機能します。


entity:spawn_particle_at_self(particleOrSpec[, count])

エンティティの位置にパーティクルをスポーンさせます。

パラメータデフォルト備考
particleOrSpecstringまたはtableパーティクル名または仕様テーブル
countnumber1パーティクル数
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])

指定した位置にパーティクルをスポーンさせます。

パラメータデフォルト備考
locationlocationテーブル対象位置
particlestringパーティクルタイプ名
countnumber1パーティクル数
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)

エンティティが対応するカスタムモデルを持っている場合、カスタムモデルアニメーションを再生します。

パラメータ備考
namestringアニメーション名
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])

エンティティをソース位置またはエンティティラッパーから離れるようにプッシュします。

パラメータデフォルト備考
sourcelocationまたはwrapperプッシュの起点
strengthnumber1.0プッシュの強度倍率
xOffsetnumber0追加のXオフセット
yOffsetnumber0追加のYオフセット
zOffsetnumber0追加のZオフセット
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()

エンティティのカスタム表示名を設定またはリセットします。カラーコードをサポートします。

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])

エンティティの現在位置に一時的なブロックを設置します。

パラメータデフォルト備考
materialstringブロックの素材名
durationnumber0削除までのtick数
requireAirbooleanfalse現在その場所が空気の場合のみ設置
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()

エンティティの高さをブロック単位で返します。


entity:is_on_ground()

エンティティが現在、固い地面に立っている場合にtrueを返します。


entity:is_frozen()

エンティティ(カスタムボスとして追跡されている場合)にfrozenフラグが設定されている場合にtrueを返します。


entity:set_awareness_enabled(aware[, duration])

Mobの認識(awareness)を切り替えます。Mob系エンティティにのみ影響します。任意で指定した時間後に元に戻します。

パラメータデフォルト備考
awareboolean認識を有効化する場合true
durationnumbernil指定したtick数後に自動で元に戻す

entity:is_healing() / entity:set_healing(enabled)

エリートエンティティの回復状態をチェックまたは切り替えます。


entity:overlaps_box_at_location(center[, halfX][, halfY][, halfZ])

エンティティのバウンディングボックスが、指定位置にある軸方向ボックスと重なっている場合にtrueを返します。

パラメータデフォルト備考
centerlocationテーブルテストボックスの中心
halfXnumber0.5X軸の半幅
halfYnumberhalfXと同じY軸の半高
halfZnumberhalfXと同じZ軸の半幅

entity:remove_elite()

エリートエンティティをEliteMobsの追跡から削除します。エンティティがエリートの場合、EliteMobsを通じて適切にデスポーンさせます。


entity:set_custom_name_visible(visible)

エンティティのカスタム名を常時表示するか、見たときのみ表示するかを設定します。

パラメータ備考
visibleboolean常時表示の場合true

entity:set_equipment(slot, material[, options])

エンティティの装備を設定します。

パラメータデフォルト備考
slotstring装備スロット:"HEAD""CHEST""LEGS""FEET""HAND""OFF_HAND"
materialstring素材名(例:"DIAMOND_SWORD""IRON_HELMET"
optionstable{}任意の設定(下記参照)

Optionsテーブル:

キーデフォルト備考
enchantmentsテーブルの配列nil各エントリ:{ type = "SHARPNESS", level = 2 }
unbreakablebooleanfalseアイテムを破壊不能にするかどうか
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

エンティティに現在AIが有効になっている場合にtrueを返すメソッドです。

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
}

非リビングエンティティの参照ラッパー

スポーンされたエンティティがLivingEntityではない場合 -- 例:落下ブロック、投射物、ファイアボールなど -- より軽量な参照ラッパーが返されます。これらはcontext.world:spawn_falling_block_at_location()context.boss:summon_projectile()のようなメソッドによって返されます。

フィールド: nameuuidentity_typeis_playeris_elitecurrent_location

メソッド:

メソッド備考
is_valid()ライブの有効性チェック
get_location()現在のライブ位置
get_velocity()現在の速度ベクトル
is_on_ground()地面にいるかどうか
teleport_to_location(location)エンティティをテレポートさせる
set_velocity_vector(vector)速度を設定
set_direction_vector(vector)方向を設定(ファイアボールのみ)
set_yield(value)爆発の威力を設定(ファイアボールのみ)
set_gravity(enabled)重力を切り替え
detonate()花火エンティティを爆発させる
remove()ワールドからエンティティを削除
unregister([reason])エンティティトラッカーから登録解除
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

プレイヤーが直接関与するフック(on_boss_damaged_by_playeron_player_damaged_by_bossなど)で利用できます。プレイヤーラッパーは、上記の共通エンティティフィールドとメソッドをすべて含み、さらに以下の追加機能も含みます。

注意

context.playerは、関連するプレイヤーがないフック(on_spawn、スケジュールコールバック、タイマーフックなど)ではnilです。使用前には必ずnilガードを行ってください。

return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
context.player:send_message("&cHello!")
end
}

プレイヤー専用フィールド

フィールド備考
game_modestring現在のゲームモード名(例:"SURVIVAL"

プレイヤー専用メソッド

メソッド備考
send_message(message)EliteMobsカラーフォーマット対応のチャットメッセージ
show_action_bar(message)アクションバーのテキスト
show_title(title[, subtitle][, fadeIn][, stay][, fadeOut])タイトル画面オーバーレイ
show_boss_bar(title[, color][, style][, duration])一時的なボスバー
run_command(command)プレイヤーとしてコマンドを実行(先頭の/なし)
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

このLuaパワーを所有するエリートMobのボスラッパーです。すべてのフックで常に利用可能です。

ヒント

ボスラッパーは、上記に挙げられたすべての共通エンティティメソッド(例:push_relative_toapply_push_vectorset_gravityset_scaleset_invulnerablespawn_particle_at_selfoverlaps_box_at_locationなど)を継承しています。このセクションで記載されているメソッドは、ボス固有か、EliteEntityレイヤーを通じて異なる挙動をするものです。

ボスフィールド

フィールド備考
boss.namestring表示名
boss.uuidstringボスエリートのUUID
boss.entity_typestringBukkitのEntityType名
boss.is_monsterboolean内部のエンティティがMonsterの場合true
boss.levelnumberエリートレベル
boss.healthnumber現在の体力(スナップショット)
boss.maximum_healthnumber最大体力(スナップショット)
boss.damager_countnumber加害者の数(スナップショット)
boss.is_in_combatboolean戦闘状態
boss.existsbooleanエリートがまだ存在するかどうか
boss.current_locationlocationテーブルラッパー作成時の位置(スナップショット)
return {
api_version = 1,
on_spawn = function(context)
context.log:info(context.boss.name .. " level " .. context.boss.level)
end
}

ボスメソッド


boss:is_alive()

ボスエンティティが有効で、死亡しておらず、エリートがまだ存在する場合にtrueを返します。ライブチェックにはexistsフィールドではなくこちらを使用してください。

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()

ボスの現在のライブ位置をlocationテーブルとして返します。

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()

ボスの目線の高さの位置を返します。

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])

ボスのAIを切り替えます。任意で指定した時間後に元に戻します。

パラメータデフォルト備考
enabledbooleanAIを有効化する場合はtrue
durationnumbernil指定したtick数後に自動で元に戻す
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)

ボスを指定の位置にテレポートさせます。

パラメータ備考
locationlocationテーブル目的地
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)

ボスの速度を即座に設定します。

パラメータ備考
vectorvectorテーブル{ x, y, z }または{ x = 0, y = 1, z = 0 }
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)

ボスの体力を最大まで回復します。

パラメータ備考
amountnumber回復量
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])

ボスの位置でサウンドを再生します。

パラメータデフォルト備考
soundstringBukkitのSound名
volumenumber1.0音量
pitchnumber1.0ピッチ
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])

ボスの位置にパーティクルをスポーンさせます。

パラメータデフォルト備考
particleOrSpecstringまたはtableパーティクル名または仕様テーブル
countnumber1パーティクル数
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)

ボスにカスタムモデルアニメーションを再生させます(利用可能な場合)。

パラメータ備考
namestringアニメーション名
return {
api_version = 1,
on_enter_combat = function(context)
context.boss:play_model_animation("slam")
end
}

boss:face_direction_or_location(vectorOrLocation)

ボスを指定の方向または位置に向けさせます。

パラメータ備考
vectorOrLocationvectorまたはlocationテーブル向ける方向
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])

パスファインディングを使って、ボスを指定位置まで歩かせます。

パラメータデフォルト備考
locationlocationテーブル目的地
speednumber1.0移動速度倍率
followbooleanfalse対象を継続的に追跡
timeoutnumbernil指定tick後にナビゲーションをキャンセル
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)

ボスのタグを管理します。

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])

近くにいるすべてのプレイヤーにチャットメッセージを送信します。

パラメータデフォルト備考
messagestringカラーコード付きのメッセージテキスト
rangenumber20ブロック単位の半径
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])

ボスから投射物様のエンティティを発射します。

パラメータデフォルト備考
entityTypestringエンティティタイプ(例:"FIREBALL""ARROW"
originlocationテーブル発射位置
destinationlocationテーブル目標位置
speednumber1.0投射物の速度
optionstable{}下記オプションを参照

Optionsテーブル:

キー備考
durationnumbertick後に自動削除
max_ticksnumber着地検出のために監視する最大tick数
custom_damagenumber衝突時のダメージ
detonation_powerstring衝突時の爆発威力
yieldnumber爆発の威力(ファイアボール)
persistentboolean投射物を残すかどうか(デフォルトtrue
effectstringスポーン時に再生するEntityEffect名
incendiaryboolean爆発が引火性かどうか
gravityboolean投射物に重力を適用するかどうか
glowingboolean発光エフェクト
invulnerableboolean投射物を無敵にするかどうか
trackboolean目標を追尾するかどうか
spawn_at_originbooleanオフセットせず起点でスポーン
direction_onlyboolean方向のみを使用し、目標を無視
on_landfunctionコールバック(landing_location, spawned_entity)
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])

設定ファイルから増援ボスを召喚します。

パラメータ備考
filenamestringボス設定のファイル名
zoneOrLocationlocationテーブルまたはzoneスポーン位置またはゾーン定義
durationnumbertick後に自動デスポーン(任意)
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()

ボスをワールドから削除します。

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)

ボスの範囲内にいるプレイヤーラッパーの配列を返します。

パラメータ備考
rangenumberブロック単位の半径
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()

このボスにダメージを与えたプレイヤーの数をライブで返します。damager_countフィールドとは異なり、ライブチェックを行います。


boss:get_target_player()

ボスの現在のMobターゲットをプレイヤーラッパーとして返します。ターゲットがプレイヤーでない場合や未設定の場合はnilを返します。


ゾーンとパーティクルのメソッド

これらのメソッドは、zonesとパーティクル効果を組み合わせます。入力としてゾーンテーブルが必要です。


boss:get_nearby_players_in_zone(zone)

指定したゾーン内に現在いるすべてのプレイヤーのラッパー配列を返します。

パラメータ備考
zonezoneテーブルゾーン形状の定義

boss:spawn_particles_in_zone(zone, particle, ..., coverage?)

ゾーンの内部をパーティクルで埋めます。

パラメータ備考
zonezoneテーブル埋めるゾーン形状
particlestringパーティクルタイプ名
...追加のパーティクルパラメータ
coveragenumber(任意)パーティクル密度の係数

boss:spawn_particles_in_zone_border(zone, particle, ..., coverage?)

ゾーンの境界をパーティクルで縁取ります。

パラメータ備考
zonezoneテーブル縁取るゾーン形状
particlestringパーティクルタイプ名
...追加のパーティクルパラメータ
coveragenumber(任意)パーティクル密度の係数

boss:get_particles_from_self_toward_zone(zone, particle, speed?)

ボスからゾーンへ向かう方向のパーティクルをスポーンさせます。

パラメータデフォルト備考
zonezoneテーブル目標ゾーン
particlestringパーティクルタイプ名
speednumbernilパーティクルの移動速度

boss:get_particles_toward_self(zone, particle, speed?)

ゾーンからボスへ向かう方向のパーティクルをスポーンさせます。

パラメータデフォルト備考
zonezoneテーブル起点となるゾーン
particlestringパーティクルタイプ名
speednumbernilパーティクルの移動速度

boss:spawn_particles_with_vector(particles)

それぞれが独自の位置と速度ベクトルを持つ、方向付きパーティクルの配列をスポーンさせます。

パラメータ備考
particlesテーブルの配列各エントリは位置と方向を持つパーティクルを定義

エンダードラゴンメソッド

これらのメソッドは、ボスエンティティがエンダードラゴンの場合にのみ適用されます。


boss:get_ender_dragon_phase()

現在のEnderDragon.Phase名を文字列として返します。ボスがエンダードラゴンでない場合はnilを返します。


boss:set_ender_dragon_phase(phase)

エンダードラゴンのフェーズを設定します。

パラメータ備考
phasestringEnderDragon.Phase名(例:"CIRCLING""CHARGE_PLAYER"

特殊パワーサポートメソッド

これらのメソッドは、Luaスクリプトから組み込みのEliteMobsパワーメカニクスをサポートします。


boss:start_tracking_fireball_system(speed?)

ボスに追尾ファイアボールAIシステムを開始します。ボスは定期的に、ターゲットを追尾するファイアボールを発射するようになります。

パラメータデフォルト備考
speednumber0.5ファイアボールの速度

boss:handle_spirit_walk_damage(cause)

指定したダメージ原因に対してスピリットウォークの挙動を処理します。スピリットウォークは、ボスを特定のダメージタイプに対して免疫にし、攻撃者の背後にテレポートさせます。

パラメータ備考
causestringBukkitのDamageCause名(例:"ENTITY_ATTACK""PROJECTILE"

boss:shield_wall_is_active()

ボスに現在有効なシールドウォールがある場合にtrueを返します。


boss:initialize_shield_wall(charges?)

ボスに、来るダメージを吸収できるシールドウォールを発動します。

パラメータデフォルト備考
chargesnumber1シールドが吸収可能なヒット数

boss:shield_wall_absorb_damage(player, damage)

シールドウォールでダメージの吸収を試みます。ダメージが吸収された場合はtrueを、シールドが無効化または使い切られている場合はfalseを返します。

パラメータ備考
playerプレイヤーラッパー攻撃しているプレイヤー
damagenumber吸収するダメージ量

boss:deactivate_shield_wall()

ボスのシールドウォールを無効化し、残っているチャージを削除します。


boss:start_zombie_necronomicon(target, file)

ターゲットに対してゾンビネクロノミコンパワーを開始し、設定ファイルからアンデッドの増援をスポーンさせます。

パラメータ備考
targetエンティティラッパーネクロノミコンの対象エンティティ
filestring召喚されるアンデッドのボス設定ファイル名

context.players

ボスを中心としたプレイヤークエリヘルパー群です。イベントから特定のプレイヤーを取得しなくても、プレイヤーを見つけるのに使えます。

メソッド戻り値備考
players:current_target()プレイヤーラッパーまたはnilイベントプレイヤー、またはボスのMobターゲットがプレイヤーの場合はそれ
players:nearby_players(radius)プレイヤーラッパーの配列ボスの半径内にいるすべてのプレイヤー
players:all_players_in_world()プレイヤーラッパーの配列ボスのワールドにいるすべてのプレイヤー
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
}
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

ボスを中心とした汎用のエンティティクエリヘルパーです。

メソッド戻り値備考
entities:get_nearby_entities(radius[, filter])エンティティラッパーの配列ボスの周りの近接エンティティ
entities:get_entities_in_box(center, halfX, halfY, halfZ[, filter])エンティティラッパーの配列軸方向ボックス内のエンティティ
entities:get_all_entities([filter])エンティティラッパーの配列ボスのワールド内で条件に合うすべてのエンティティ
entities:get_direct_target_entity()エンティティラッパーまたはnil現在のイベントの直接ターゲット
entities:get_boss_spawn_location()locationテーブルボスの元のスポーン位置

有効なフィルタ: living(デフォルト)、player / playerselite / elitesmob / mobsall / entities

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
}
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
}

次のステップ