ignah1-TargetToggleandBosstargetting icon

TargetToggleandBosstargetting

Adds a configurable hotkey to switch between Closest Enemy, Smart Aim in real time and Boss projectile targeting support , with a visible indicator on the HUD at the bottom right.

By ignah1
Last updated 13 hours ago
Total downloads 5
Total rating 0 
Categories Mods Tools
Dependency string ignah1-TargetToggleandBosstargetting-1.0.2
Dependants 0 other packages depend on this package

This mod requires the following mods to function

BepInEx-BepInExPack_IL2CPP-6.0.738 icon
BepInEx-BepInExPack_IL2CPP

BepInEx pack for IL2CPP x64 Unity games. Preconfigured and ready to use.

Preferred version: 6.0.738

README

TargetToggle — Megabonk Mod

A BepInEx (IL2CPP) mod that adds two configurable hotkeys to toggle targeting behavior in real time, with a HUD indicator in the bottom-right corner that only appears during a run.


Features

  • Targeting mode toggle — switch between Closest Enemy and Smart Aim on the fly
  • Boss Focus toggle — when active, prioritizes any boss over regular enemies. Falls back to your chosen targeting mode if no boss is in range
  • In-game HUD — shows current state in the bottom-right corner, only visible during a run
  • Fully configurable hotkeys — edit the BepInEx config file to use any key you want

Requirements

Dependency Version
BepInEx IL2CPP Pack 6.0.738+
.NET SDK (to compile) 6.0+
Megabonk latest

Installation

  1. Make sure BepInEx IL2CPP is installed in your Megabonk folder.
  2. Compile the project or download the release .dll.
  3. Place TargetToggleMod.dll in BepInEx/plugins/.
  4. Launch the game once — BepInEx will generate the config file automatically.

Default Hotkeys

Key Action
T Toggle between Closest Enemy and Smart Aim
Y Toggle Boss Focus mode

Configuration

Edit the generated config file at:

BepInEx/config/com.tuusuario.targettoggle.cfg
[Hotkeys]
ToggleTargetingMode = T
ToggleBossFocus = Y

Any Unity KeyCode value is valid — see the full list at: https://docs.unity3d.com/ScriptReference/KeyCode.html


HUD

  • Appears only during a run (hidden in menus and loading screens)
  • Displays the current targeting mode and boss focus state:
    • TARGET: Closest / TARGET: Smart Aim
    • TARGET: Closest | BOSS when Boss Focus is active
  • Text turns yellow when Boss Focus is enabled
  • Flashes briefly when you press a hotkey to confirm the change

How It Works

This mod uses a Harmony patch on EnemyTargeting.GetTargetedEnemy() to intercept targeting in real time — no save file modification needed.

  • Closest Enemy: directly calls GetClosestEnemy(), skipping the default logic
  • Smart Aim: lets the original method run normally
  • Boss Focus: scans colliders for any enemy with EEnemyFlag.AnyBoss and targets the closest one. If no boss is found, falls back to the active targeting mode

Project Structure

TargetToggleMod/
├── TargetTogglePlugin.cs   — main plugin (hotkeys, HUD, Harmony patch)
├── MyPluginInfo.cs         — GUID, name, version
├── TargetToggleMod.csproj  — C# project with BepInEx references
├── manifest.json           — Thunderstore package manifest
├── icon.png                — 256x256 mod icon
└── README.md               — this file

License

MIT — do whatever you want with the code.