I make my NPC character keep jumping to the left (x:-2; y:0). The problem is this character jump to the river or even outside map area. So how do you limiting this jump so if the NPC facing river or wall, they stop jumping ?
Movement route : jump problem
RPG Maker MV SupportHi!
I think you can put a condition to check where the player is.
If it is in X position, he cannot jump.
You have to find a way to check this. Maybe with regions, terrain tags etc.
I also dont know why the code is made like that, without "jump colision".
I think you can put a condition to check where the player is.
If it is in X position, he cannot jump.
You have to find a way to check this. Maybe with regions, terrain tags etc.
I also dont know why the code is made like that, without "jump colision".
For passability checks, here's a quote from another thread:
I think it's because you'd expect to be able to jump over impassable tiles, but if you land on an impassable tile, what should happen? Should the jump just fail to move you at all? Should it backtrack along the jump "line" and land you on the closest passable tile? What about if the passability of the target tile changes mid-jump? Etc. 😅
I think this has to be implemented like any other move route(step forward, backward and other movements). If the dev wants the player to jump across/above unpassable tiles, they can set the through On. At least the dev would have an option.
But the way it is, we don't have a default option for not to land in unpassable tiles.
By the way, a great solution from Silva in the other thread! =O
Sorry im still green in using RPG Maker MV. Where do i put that javascript ?
It's designed for use in a standalone Script command, with a Conditional Branch command after it to check the switch; the move route would then be applied if the switch is on, and not applied if the switch is off. However, I'm guessing your current set-up only involves a repeating move route, right? 😅
Instead you could try putting this script in a move route for your bouncy NPC:
JavaScript:
var jx = -2, jy = 0; this._moveRoute.repeat = [2,4,6,8].some(function(d) { return $gameMap.isPassable(this.x + jx, this.y + jy, d); }, this); if (this._moveRoute.repeat) this.jump(jx, jy);
An alternative would be to have, for instance, a separate Parallel event to make the NPC jump one bounce at a time:
Code:
◆Script:var id = 1; // switch ID
: :var s = 2; // jump distance in tiles
: :var d = 4; // jump direction, 4 = left (see numpad)
: :var ev = this.character(0); // "this event"
: :var x = ev.x, y = ev.y; // current location, now get target...
: :for (var n = s; n--;) x = $gameMap.roundXWithDirection(x, d);
: :var passable = [2,4,6,8].some(function(r) {
: : return $gameMap.isPassable(x, y, r);
: :}, this); // is target tile passable in some direction?
: :$gameSwitches.setValue(id, passable); // toggle switch
◆If:Switch 1 is ON
◆Set Movement Route:This Event (Wait)
: :◇Jump:-2, +0
◆
:Else
◆Comment:Jump blocked! Disable this event until the map is revisited.
◆Erase Event
◆
:End
JavaScript:
var id = 1; // switch ID
var s = 2; // jump distance in tiles
var d = 4; // jump direction, 4 = left (see numpad)
var ev = this.character(0); // "this event"
var x = ev.x, y = ev.y; // current location, now get target...
for (var n = s; n--;) x = $gameMap.roundXWithDirection(x, d);
var passable = [2,4,6,8].some(function(r) {
return $gameMap.isPassable(x, y, r);
}, this); // is target tile passable in some direction?
$gameSwitches.setValue(id, passable); // toggle switch
Sorry for late reply. This script works fine only if the map surrounded by impassable tile but
1. if the map NOT surrounded by impassable tile, the enemy still can jump outside the map.
2. the enemy still can jump to the "non-through" event image like chest or crystal.
Anyways thanks for the script ! 🙂
Oh, yep, that's awkward. 👋
- Unfortunately
isPassablereturns true for tiles outside the map...could add another check in there, though. - Checking for "normal priority" events (i.e. Same as Player) can be done with another check.
JavaScript:
var jx = -2, jy = 0, x = this.x + jx, y = this.x + jy; this._moveRoute.repeat = $gameMap.isValid(x, y) && !this.isCollidedWithEvents(x, y) && [2,4,6,8].some(function(d) { return $gameMap.isPassable(x, y, d); }, this); if (this._moveRoute.repeat) this.jump(jx, jy);
Original thread: https://forums.rpgmakerweb.com/threads/movement-route-jump-problem.118281/