Autofighter
On this page(16)
With autofighter time, a player spawns their autofighter from /autofighter. An NPC wearing their skin, armor and sword appears, and the player rides it. The NPC walks between the mobs of their zone while the player's own fight hits them. You use it as a timed reward that lets players grind hands-free, with a daily cap.
| Files | modules/autofighter/config.yml, modules/autofighter/guis/, modules/autofighter/lang/messages_en.yml |
| Player command | /autofighter (alias /autofight) |
| Admin commands | /dungeons admin autofighter ... |
| Switch | enabled: (first key of modules/autofighter/config.yml) + /dungeons reload |
How it works
- Get time. Time comes only from
/dungeons admin autofighter timeand the API. Crates, vouchers, milestones and shops run that command. There is no time item. - Spawn. In the menu, the player spawns the NPC and rides it, seated
npc.seat-offsetblocks above it. - Fight. The NPC walks to the next mob, and the player's own swings hit it. The player must hold their sword, or they are told to.
- Spend. Every second of the run takes one second of the balance and adds it to the use of today.
- Stand down. The run ends on any stop reason below. The player is set down where the NPC stood, without fall damage.
It is the player's own fight
Every hit uses the player's swings per second, damage, enchants and boosters. So every hit and kill is theirs for the whole plugin: rewards, stats, milestones, auras and totem experience. The autofighter has no booster of its own: the player's boosters apply as usual (see Boosters).
Spawning needs
- Standing in the mob area of the player's zone (see Mob Areas).
- Time left, and use of today under the daily limit.
- Not riding anything else.
What stops it
- The time runs out, or the daily limit is reached (the message gives the time to the reset).
- The player leaves the mob area of their zone: a teleport,
/zone goor another stage. - The player attacks a mob on their own, gets off with sneak, or clicks Despawn.
- The player quits or dies.
- The autofighter module or the zones module goes off.
Nothing survives a restart: the vehicle is never saved. A vehicle that a crash left behind is removed when its chunk loads, and at the module's start.
The daily limit
The use of today goes back to 0 at daily.reset-at, in daily.timezone. A player's daily limit is the sum of:
daily.limit,- the minutes of the highest
sndungeons.autofighter.daily.<minutes>permission they hold, - the daily upgrade.
For example, a player with sndungeons.autofighter.daily.60 and 2 levels of the daily upgrade gets 4h + 60m + 30m = 5h30m.
Who sees it
The player sees their own NPC. Others see it only if they can see the player. The island and solo modes of the zones still apply (see Isolated Zone Worlds). Each player can hide other players' autofighters with the setting autofighter.view-others.
Target mode
The NPC walks to the nearest mob, by target.default. Once a player buys the target upgrade, the target button of the menu cycles three modes:
| Mode | The next mob is |
|---|---|
nearest | The closest one. |
lowest-health | The one with the least health. |
highest-rarity | The rarest one, by the order of mobs.rarities of the zones config. |
Configuration
| Key | Default | What it does |
|---|---|---|
enabled | true | The module switch. Off: /autofighter disappears and every running autofighter stands down. Time, use of today and upgrades stay stored. |
display-name | '&cAutofighter' | The module's name in /dungeons admin modules. |
daily.limit | 4h | The most time a player can use per day (like 4h, 90m, 1h30m). |
daily.reset-at | '16:00' | The hour the use of today goes back to 0 (24 hour clock). |
daily.timezone | 'UTC' | The time zone of reset-at (UTC, Europe/Madrid, America/New_York...). |
npc.name | '&7{player}''s &cAutofighter' | The name over the NPC. {player} is its owner. |
npc.speed | 4.0 | How fast the NPC walks, in blocks per second (0.1 to 20). The speed upgrade adds on top. |
npc.stop-distance | 2.0 | How near, in blocks, the rider stops from the mob they fight. Never more than combat.hit-distance of the sword config (cut to it, with a warning). |
npc.seat-offset | 1.8 | The seat's height above the NPC's feet. |
npc.name-height | 4.1 | The name's height above the NPC's feet. |
npc.view-range | 48 | How far, in blocks, other players see an autofighter (8 to 128). |
target.default | nearest | The target mode without the upgrade: nearest, lowest-health or highest-rarity. |
upgrade-amounts | [1, 10, 'max'] | The levels a left, right and shift click buy on the daily and speed upgrades. max = every level the balance covers. |
upgrades
| Upgrade | What it does | per-level | max-level | Cost (souls) |
|---|---|---|---|---|
target | One purchase: unlocks the choice of the target mode. | none | one purchase | 5000000 (a plain amount) |
daily | Adds time to the daily limit per level. | 15m | 10 | 1000000 x 1.4^L |
speed | Adds blocks per second to the walk, from npc.speed. | 0.5 | 10 | 500000 x 1.3^L |
cost is the price of level L to L + 1. It can be a curve: exponential (starting-cost x growth^L) or linear (starting-cost + increase-cost-by x L). It can also be a plain amount, the same price for every level.
commands
| Key | Default | What it does |
|---|---|---|
commands.main.command | autofighter | The command name. '' = no /autofighter (the API keeps working). |
commands.main.aliases | [autofight] | Other names of the command. |
commands.main.permission | '' | Needed for the command and every button of both menus ('' = everyone). |
commands.main.menu | autofighter | The menu /autofighter opens (a file of modules/autofighter/guis/). '' = your autofighter in chat. |
Menus
| Menu id | File | What it shows |
|---|---|---|
autofighter:autofighter | modules/autofighter/guis/autofighter.yml | "Autofighter" |
autofighter:upgrades | modules/autofighter/guis/upgrades.yml | "Autofighter Upgrades" |
Autofighter (autofighter.yml):
| Letter | Tile |
|---|---|
T | Your time: balance, use of today, daily limit and time to the reset. |
S | Spawn, or Despawn while your autofighter runs. |
I | Information: a text that explains the autofighter to players. |
G | The target mode: target-locked (buys the upgrade) until you own it, then target (cycles the mode). |
U | Opens the upgrades menu. |
# R P | Glass fillers. |
Autofighter Upgrades (upgrades.yml): T is the target upgrade, D the daily limit upgrade, S the speed upgrade, B goes back. Each upgrade has a normal tile and a max tile.
The actions are [autofighter] toggle, [autofighter] target, [autofighter] open upgrades and [autofighter] upgrade <id>. They need the permission of /autofighter. See Menus and Action Tags.
Player settings
| Setting | Default | What it switches |
|---|---|---|
autofighter.view-others | on | The autofighters (NPCs and names) of other players. Your own always shows, and the fights stay the same. |
See Player Settings.
Commands
| Command | Permission | Description |
|---|---|---|
/autofighter (alias /autofight) | commands.main.permission ('') | Opens the autofighter menu: spawn or despawn, target mode, upgrades. |
/dungeons admin autofighter time <player> <add|set|take> <time> | sndungeons.admin.autofighter.time | Changes the autofighter time of a player, also offline. |
/dungeons admin autofighter daily <player> reset | sndungeons.admin.autofighter.daily | Resets the autofighter use of today of a player, also offline. |
/dungeons admin autofighter upgrade <player> <target|daily|speed> <level> | sndungeons.admin.autofighter.upgrade | Sets an autofighter upgrade level of a player, free, also offline. |
/dungeons admin autofighter stop <player> | sndungeons.admin.autofighter.stop | Stops the running autofighter of an online player. |
/dungeons admin autofighter info <player> | sndungeons.admin.autofighter.info | Shows the autofighter time, limit, upgrades and run of an online player. |
<time> is written like 30m or 1h30m. To sell time in a crate or a shop, run the time command from it:
dungeons admin autofighter time {player} add 1hThe sndungeons.autofighter.daily.<minutes> nodes are not declared in plugin.yml: grant any number you want (see Permissions).
Full lists: Commands and Permissions.
Placeholders
The autofighter exposes your time, your daily use and the upgrades. Each time has an _ms form in milliseconds. Full list: Placeholders.
| Placeholder | Description |
|---|---|
%sndungeons_autofighter_balance% | Your autofighter time |
%sndungeons_autofighter_daily_left% | What is left of your daily limit today |
%sndungeons_autofighter_resets_in% | Time to the daily reset (like 1h 30m) |
%sndungeons_autofighter_active% | true while your autofighter runs |
%sndungeons_autofighter_target_mode_name% | Your target mode's word |
%sndungeons_autofighter_upgrade_<id>_level%, _cost | An upgrade's level and next price |
Tips
- Set
daily.reset-atanddaily.timezoneto the hour your players expect, like your server's daily reset. - The
{player}placeholder in the example above depends on the plugin that runs the command. Check its own placeholder for the player name. npc.stop-distanceis cut to the sword'scombat.hit-distance, so the rider always reaches the mob.- Test with
/dungeons admin autofighter time <you> add 10m, then stand in your zone's mob area and open/autofighter.
Default modules/autofighter/config.yml
enabled: true
# ============================================================
# SnDungeons - autofighter module
# Managed by SnLib: new keys are auto-merged on boot; your values and
# comments are preserved. Re-read on /dungeons reload.
# ============================================================
# Switch of the module (the key above): false turns the autofighter off on
# /dungeons reload; /autofighter disappears and every running autofighter
# stands down (its rider is set on the ground). The time, the use of today
# and the upgrades of every player stay stored.
# With autofighter time a player spawns an NPC wearing their skin from
# /autofighter and rides it: it walks to the mobs of their zone and THEIR
# OWN fight hits them (their swings, damage, enchants and boosters; every hit
# and kill is theirs). Time is given only with /dungeons admin autofighter
# time (crates, vouchers, milestones and shops run that command) or the API.
# Name of the module in /dungeons admin modules (color codes allowed).
display-name: '&cAutofighter'
daily:
# The most autofighter time a player can use per day (like 4h, 90m,
# 1h30m). A player also gets the minutes of the highest
# sndungeons.autofighter.daily.<minutes> permission they hold, and the
# daily upgrade adds on top.
limit: 4h
# The hour the use of today goes back to 0 (24 hour clock).
reset-at: '16:00'
# The time zone of reset-at (UTC, Europe/Madrid, America/New_York...).
timezone: 'UTC'
npc:
# The name over the NPC; {player} is its owner's name.
name: '&7{player}''s &cAutofighter'
# How fast the NPC walks between the mobs, in blocks per second (0.1 to
# 20); the speed upgrade adds on top.
speed: 4.0
# How near (in blocks) the rider stops from the mob they fight. Never more
# than combat.hit-distance of the sword config (cut to it with a warning).
stop-distance: 2.0
# The height of the seat above the NPC's feet: the rider sits there.
seat-offset: 1.8
# The height of the name above the NPC's feet.
name-height: 4.1
# How far, in blocks, the other players see an autofighter (8 to 128).
view-range: 48
target:
# The mob the autofighter walks to next: nearest, lowest-health or
# highest-rarity (the order of mobs.rarities of the zones config). A player
# who bought the target upgrade chooses it in /autofighter.
default: nearest
# The upgrades (the autofighter menus). currency: what they are bought with;
# max-level: their highest level (target is one purchase); per-level: what
# one level adds (daily: a time; speed: blocks per second); cost: the price
# of the level L -> L + 1, starting-cost x growth^L (type: exponential) or
# starting-cost + increase-cost-by x L (type: linear); a plain amount is the
# same price for every level.
upgrades:
target:
currency: souls
cost: 5000000
daily:
currency: souls
max-level: 10
per-level: 15m
cost:
type: exponential
starting-cost: 1000000
growth: 1.4
increase-cost-by: 0
speed:
currency: souls
max-level: 10
per-level: 0.5
cost:
type: exponential
starting-cost: 500000
growth: 1.3
increase-cost-by: 0
# The levels a click on the daily or speed upgrade buys: a left click the
# first, a right click the second, a shift click the third (max = every level
# the balance covers, up to the max-level).
upgrade-amounts: [1, 10, 'max']
commands:
# /autofighter opens the autofighter menu. If another plugin already has
# this name or an alias, SnDungeons takes it (command priority).
main:
# Command name; '' = no /autofighter command (the API keeps working).
command: autofighter
# Other names of the command.
aliases:
- autofight
# Permission needed to use the command, and every button of the
# autofighter menus. '' = everyone.
permission: ''
# The menu /autofighter opens: a file of modules/autofighter/guis/
# without .yml. '' = no menu: /autofighter shows your autofighter in chat.
menu: autofighter