[Plugin] IntelliPatch — Dynamic Reactive A* Pathfinding for RPG Maker MZ


IntelliPatch — Dynamic Reactive A* Pathfinding for RPG Maker MZ

GALLERY FIRST

g1
g2
g3
g4

Version: 2.0.6
Author: Rpx & Just Dev
GitHub: https://github.com/Rp-ics/RMMZ_IntelliPatch_Plugin
Discord: https://discord.gg/fXcK6u22gQ
**Itchio: ** https://r-px.itch.io/


What is IntelliPatch?

IntelliPatch is a tile-based A* pathfinding plugin for RPG Maker MZ with a focus on reactive, dynamic navigation. It’s not just “walk from A to B” — it recalculates on the fly, handles moving targets, and gives you full control over when and how paths are computed.

Built for projects that need smart NPCs without melting the CPU.


Features

  • Tile-based A* with binary heap (fast, no dependencies)
  • Programmable navigation patches — cost, block, force, portal, conditional
  • Per-frame round-robin recalc scheduler — bounded, prioritized, token-bucketed
  • Path smoothing (string-pulling with Bresenham line-of-sight)
  • Debug overlay — green path, red blocked, yellow patched, gray visited
  • Stuck policies — recalc, origin, back_retry, random, ghost, giveup
  • Goal system — composable multi-target goals (any, all, sequence, closest, weighted, conditional, and more)
  • Extensible — register custom heuristics, cost functions, patch types, goal modes, wait conditions, steering behaviors
  • VisuStella-safe — hooks the base class, no conflicts with Events & Movement Core

Quick Start

  1. Copy IntelliPatch.js into js/plugins/
  2. Enable it in the Plugin Manager
  3. Load order: AFTER VisuStella Events/Movement Core, BEFORE any plugin that overrides Game_CharacterBase.update

Then from a Script call or Move Route:

IntelliPatch.moveTo(this, 15, 20);

Or use Plugin Commands (MoveTo, FollowTarget, WanderArea, …).


Example: NPC Chases the Player

IntelliPatch.moveTo(this, $gamePlayer.x, $gamePlayer.y, {
  avoidEvents: true,
  allowTouch: true,
  diagonal: true,
  stuckPolicy: "recalc",
  onArrive: function() { $gameMessage.add("Caught!"); }
});

Example: Slow Zone with a Cost Patch

IntelliPatch.addPatch({
  id: "mud",
  type: "cost",
  area: { x: 3, y: 3, w: 5, h: 5 },
  data: { multiplier: 3.0 }
});
IntelliPatch.wander(this, { x1: 1, y1: 1, x2: 10, y2: 10 });

Example: Door That Opens with a Switch

IntelliPatch.addPatch({
  id: "door",
  type: "block",
  area: { x: 12, y: 8, w: 1, h: 1 },
  condition: function() { return !$gameSwitches.value(5); }
});
IntelliPatch.moveTo(this, 15, 8);

Patch Types

Type What it does
cost Multiplies movement cost (mud, rough terrain)
block Makes tiles impassable
force Pushes in a direction (wind, currents)
portal Teleports from tile A to tile B
conditional Custom callback decides cost or block

Stuck Policies

When no alternative road exists, IntelliPatch runs the configured policy:

  • recalc — keep retrying (default, never gives up)
  • origin — walk back to start, then fail
  • back_retry — step back along the trail and retry
  • random — wander to a random tile, then retry
  • ghost — collision off for N tiles (patches still apply)
  • giveup — stay still, fire onFail

Goal System

Composable goals let you order NPCs toward complex targets:

IntelliPatch.moveToGoal(this, {
  mode: "sequence",
  points: [{x: 5, y: 5}, {x: 10, y: 10}, {x: 15, y: 15}]
});

Supported modes: any, all, sequence, closest, farthest, random, weighted, conditional, sequenceThenLoop, sequenceThenReverse, eventAt, eventAtAny, guardPost, twoEventsMeet, simultaneous, swap, and more.


Debug Overlay

Set DebugMode to true or call IntelliPatch.debug().

  • Green = active path
  • Red = blocked / failed target
  • Yellow = patched tile
  • Gray = visited nodes
  • Purple = goal points
  • Cyan = character → target line

Click a tile (DebugMode on) or call IntelliPatch.debugTile(x, y) to log every patch modifier on that tile.


Extending IntelliPatch

No file edits needed. Register custom behavior at runtime:

IntelliPatch.registerHeuristic("biased", function(x0, y0, x1, y1) {
  var base = Math.abs(x0 - x1) + Math.abs(y0 - y1);
  if ($gamePlayer.direction() === 6 && x1 > x0) base *= 0.7;
  if ($gamePlayer.direction() === 4 && x1 < x0) base *= 0.7;
  return base;
});
IntelliPatch.setGlobalConfig("defaultHeuristic", "biased");

Available registries:

  • registerHeuristic(name, fn)
  • registerCostFunction(name, fn)
  • registerPatchType(name, handlers)
  • registerGoalMode(name, resolver)
  • registerWaitCondition(name, fn)
  • registerSteeringBehavior(name, fn)
  • registerCallback(hook, fn)
  • registerPreRecalc(fn) / registerPostRecalc(fn)
  • registerOnMapChange(fn) / registerOnArrival(fn)

Video Series

I’m making a full video series on IntelliPatch:

  • Ep. 1 — Intro
  • Ep. 2 — Problem vs Solution
  • Ep. 3 — Setup & Parameters
  • Ep. 4 — Script Calls & Plugin Commands
  • …and more
    https://youtu.be/BQJ8TGwz_Bc

Feedback & Bug Reports

Please post bugs, suggestions, and feedback in this thread or open an issue on GitHub.

If you use IntelliPatch in your project, I’d love to see it — share a screenshot or a clip!


Credits

  • Rpx & Just Dev • plugin authors (only if you want)
  • Built for the RPG Maker MZ community

License: See GitHub repository for details.