Skip to content

Custom Targeters

Yevhen Harasymchuk edited this page May 23, 2026 · 1 revision

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.

MythicMobs Syntax

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.

Skript Syntax

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.


Example 1: Custom Entity Targeter (Selecting Entities)

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

Example 2: Custom Location Targeter (Selecting Locations)

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

Important Rules & Notes

  1. Function Return Type: Ensure your function explicitly ends with :: entities or :: locations. If the return type is missing or incorrect, the targeter will fail to load and register inside MythicMobs.
  2. 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.
  3. 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.

Clone this wiki locally