Hi everyone,
I'm struggling with a custom chase/escape system in RPG Maker MZ. I'm using two pages, both set to Parallel Process. While the detection and escape logic work perfectly, I cannot get the "touch/collision" to trigger using script calls.
The Setup:
- Page 1 (Patrol/Detection): Trigger: Parallel.This code works fine to detect the player within a 3-tile vision cone and turns on Self Switch A:
JavaScript
var d = 3;
var e = this.character(0);
var p = $gamePlayer;
Math.abs(e.x - p.x) + Math.abs(e.y - p.y) <= d && ((e.direction() == 2 && p.y > e.y) || (e.direction() == 8 && p.y < e.y) || (e.direction() == 4 && p.x < e.x) || (e.direction() == 6 && p.x > e.x))
- Page 2 (Chase/Escape): Trigger: Parallel. Condition: Self Switch A is ON.The escape logic (distance >= 10) works perfectly to turn off Self Switch A:
JavaScript
$gameMap.distance(this.character(0).x, this.character(0).y, $gamePlayer.x, $gamePlayer.y) >= 10
I have tried:
- $gameMap.distance(this.character(0).x, this.character(0).y, $gamePlayer.x, $gamePlayer.y) <= 0.5
- this.character(0).pos($gamePlayer.x, $gamePlayer.y)
- this.character(0).x === $gamePlayer.x && this.character(0).y === $gamePlayer.y