-
Notifications
You must be signed in to change notification settings - Fork 0
Custom Targeters
Custom Targeters allow you to use Skript logic to dynamically select or filter target entities and locations, and then pass them back to MythicMobs. This enables you to create advanced target patterns that are natively impossible in MythicMobs, such as targeting players with specific permissions, members of a specific scoreboard team, or blocks within a unique geometric shape.
To use a Skript function as a targeter, use @skfunction{name=FUNCTION_NAME} in your MythicMobs configuration files:
TargeterSkillExample:
Skills:
- setblock{material=STONE} @skfunction{name=my_custom_targeter} ~onInteract- name (or n): The exact name of the Skript function that handles the target selection.
The addon automatically determines whether your targeter selects Entities or Locations based on the return type of your Skript function (:: entities or :: locations).
The skilldata parameter is required as the first argument so you can fetch contextual data (like the caster or origin) to calculate your targets.
This targeter will find and return a list of all entities within a certain radius, but only if they are wearing a specific item or match a custom condition.
# The function MUST return 'entities' to be registered as an Entity Selector
function my_custom_targeter(data: skilldata) :: entities:
set {_caster} to caster of {_data}
set {_center} to location of {_caster}
# Loop through nearby entities and apply custom filtering
loop entities in radius 15 around {_center}:
# Example condition: Only target players holding a Diamond
if loop-entity is a player:
if loop-player's tool is diamond:
add loop-player to {_targets::*}
# Return the compiled list of entity targets back to MythicMobs
return {_targets::*}This targeter creates a straight path of locations between the skill caster and its trigger entity (e.g., a straight line of blocks between a boss and a player).
# The function MUST return 'locations' to be registered as a Location Selector
function line_path_targeter(data: skilldata) :: locations:
set {_source} to block at location of caster of {_data}
set {_trigger} to block at location of trigger of {_data}
# Calculate a path of block locations between the two points
loop blocks between {_source} and {_trigger}:
add location of loop-block to {_path::*}
# Return the list of locations back to MythicMobs (e.g., for block manipulation or particles)
return {_path::*}-
Function Return Type: Ensure your function explicitly ends with
:: entitiesor:: locations. If the return type is missing or incorrect, the targeter will fail to load and register inside MythicMobs. -
Empty Collections: If no valid targets are found matching your conditions, simply return an empty list (
return (empty list variable)). MythicMobs will safely ignore the execution without throwing errors. - Internal API Warning: Custom targeters rely on Skript's modern internal function signature API. Ensure you do not suppress or ignore initialization warnings during server startup.
Home
Documentation
Advanced Integrations