Hello, back in the day, I found a way to have interesting followers on RPG Maker VX Ace.
Today, I tried to recreate this on MZ, but the result wasn't very convincing.
It might not be obvious in the gif, but the followers move jerkily, and they also walk on tiles that are supposed to be impassable...
As you can see, I don't know how to code.
If a kind soul could help me, I’d really appreciate it.
Thanks in advance 🙂
Today, I tried to recreate this on MZ, but the result wasn't very convincing.
Code:
const formation = [
[-1, 0], // Follower 1 à gauche
[1, 0], // Follower 2 à droite
[0, -1], // Follower 3 en haut
[0, 1], // Follower 4 en bas
];
const dir = $gamePlayer.direction();
for (let i = 0; i < $gamePlayer.followers()._data.length; i++) {
const follower = $gamePlayer.followers().follower(i);
if (!follower._formationTarget) {
follower._formationTarget = {x: $gamePlayer.x, y: $gamePlayer.y};
}
let dx = formation[i][0], dy = formation[i][1];
let offsetX = dx, offsetY = dy;
if (dir === 2) { offsetX = dx; offsetY = dy; }
else if (dir === 4) { offsetX = -dy; offsetY = dx; }
else if (dir === 6) { offsetX = dy; offsetY = -dx; }
else if (dir === 8) { offsetX = -dx; offsetY = -dy; }
const newTargetX = $gamePlayer.x + offsetX;
const newTargetY = $gamePlayer.y + offsetY;
if (follower.x === follower._formationTarget.x && follower.y === follower._formationTarget.y) {
follower._formationTarget = {x: newTargetX, y: newTargetY};
$gamePlayer._followers.updateMove = function() {};
}
let direction = 0;
if (follower.x < follower._formationTarget.x) direction = 6;
else if (follower.x > follower._formationTarget.x) direction = 4;
else if (follower.y < follower._formationTarget.y) direction = 2;
else if (follower.y > follower._formationTarget.y) direction = 8;
if (direction && follower.direction() !== direction) {
follower.setDirection(direction);
} else if (direction) {
follower.moveStraight(direction);
}
}
It might not be obvious in the gif, but the followers move jerkily, and they also walk on tiles that are supposed to be impassable...
As you can see, I don't know how to code.
If a kind soul could help me, I’d really appreciate it.
Thanks in advance 🙂