As shown in bird script you can get z value inside a movement route plugin by
Code:
Game_Character.prototype.flyRandom = function() {
switch (Math.randomInt(8)) {
case 0: case 1:
if (this.z <= $gamePlayer.z) {
this.ascend();
break;
}
this.descend();
break;
case 2: case 3: case 4: case 5: case 6: case 7:
if (this.z >= $gamePlayer.z + 5) {
this.descend();
break;
}
this.ascend();
break;
}
};
this.z, if you want to make it equal to player you could do like if (this.z != $gamePlayer.z)
this.equalize();
Code:
Game_Character.prototype.equalize = function() {
var fly = new Game_Interpreter()
var z = $gamePlayer.z
fly.pluginCommand('mv3d', ['@e' + this.eventId(), 'elevation', '' + z, '0']);
};
then it would always be equal to player, change var z to be equal to $gameVariables.value() to make it equal to a variable. To make it check regions z you could check after every movement the region with
if (this.regionId()) { and compare it to an array of each regions you would make at the beginning of game and store and a height of each region, might be an easier way if there's a way to check the tiles collision height. Checking events z you would first need to know what event is being shot at, then you can get it with $gameMap.event().z === $gameMap.event(this._eventId).z).
Actually even better might be yanfly event chases stagger, if it tries to move into a square it can't move to
Code:
Game_Event.prototype.updateChaseMovement = function() {
if (this._staggerCount > 0) {
return this._staggerCount--;
}
if (this._stopCount > 0 && this._chasePlayer) {
var direction = this.findDirectionTo($gamePlayer.x, $gamePlayer.y);
if (direction > 0) {
var x = this._x;
var y = this._y;
this.moveStraight(direction);
if (x === this._x && y === this._y) this._staggerCount = 20;
}
} else if (this._stopCount > 0 && this._fleePlayer) {
this.updateFleeMovement();
} else if (this._returnPhase) {
this.updateMoveReturnAfter();
} else {
Yanfly.ECP.Game_Event_updateSelfMovement.call(this);
}
};
so if its x and y are equal to its previous x y it would be staggered since it didn't move, so if the x y of bullet is the same then it's obviously hit something, if it's not set to through, if you put the bullet to player.z height minus stair threshold height then if its x and y are the same after movement just erase it.