Skip to main content

Fight mobs

Use combat.fire for one ranged submission. Use combat.engage when Hexis should own pursuit, spacing, aim, repeated attacks, health checks, and cleanup.

Your bundle needs combat. Add world.entities.read when Lua finds targets before starting combat.

Fire once

local observed = hexis.world.entities.find({
area = {kind = "radius", radius = 32.0},
selector = {type_ids = {"minecraft:enderman"}, exclude_self = true},
limit = 16,
})

local target = observed.entities[1]
if not target then return end

local result = hexis.await(hexis.combat.fire({
target = {ref = target.ref},
held = {name_patterns = {"Shortbow"}},
projectile = "shortbow_arrow",
timing = {reaction_ms = 120, dwell_ms = 80, cooldown_ms = 250},
}), {timeout = 5})

Success means one shot was submitted and the result reports outcome = "fired". It does not prove a hit or kill.

Engage one target

local result = hexis.await(hexis.combat.engage({
target = {ref = target.ref},
behavior = {
kind = "melee_kite",
attack_range = 3.0,
minimum_distance = 1.5,
preferred_distance = 2.1,
maximum_distance = 2.8,
maximum_pursuit_distance = 64,
attacks_per_second = 7,
},
timeout_seconds = 30,
stop_below_health_percent = 20,
}), {timeout = 32})

Engage a fixed list or live query

combat.engage requires exactly one target source:

  • target for one observed entity reference.
  • targets for 1 through 16 fixed references.
  • target_query to let Hexis reacquire matching entities during the action.
target_query = {
area = {kind = "radius", radius = 64.0},
selector = {
type_ids = {"minecraft:zombie", "minecraft:zombie_villager"},
exclude_self = true,
},
limit = 16,
}

Stop on player_low_health, player_dead, authority_lost, world_changed, or cancelled. A successful engagement must report the documented defeated outcome. See the Graveyard and Sven sources.