I have been banging my head against the code long enough. I don't know JS well enough to figure this out on my own.
I have diagonal movement working. In this instance the player should be able to jump across to the NW platform using the pillar (move route event). I was able to do this with 'helper events' but I want to learn more about how the engine works and to do it elegantly with JS. I want to trigger events that are diagonal to the player character with keyboard and touch/mouse inputs.
I found some help in discovering leads to a solution in rmmz_core.js:
AND
These also looked related:
Can anyone explain how the engine pocesses event triggers? and direct me toward implementing diagonal event triggers?
I have diagonal movement working. In this instance the player should be able to jump across to the NW platform using the pillar (move route event). I was able to do this with 'helper events' but I want to learn more about how the engine works and to do it elegantly with JS. I want to trigger events that are diagonal to the player character with keyboard and touch/mouse inputs.
I found some help in discovering leads to a solution in rmmz_core.js:
Game_CharacterBase.prototype.checkEventTriggerTouchFront = function(d) { const x2 = $gameMap.roundXWithDirection(this._x, d); const y2 = $gameMap.roundYWithDirection(this._y, d); this.checkEventTriggerTouch(x2, y2);};Game_CharacterBase.prototype.checkEventTriggerTouch = function(/*x, y*/) { return false;};AND
Game_CharacterBase.prototype.moveStraight = function(d) { this.setMovementSuccess(this.canPass(this._x, this._y, d)); if (this.isMovementSucceeded()) { this.setDirection(d); this._x = $gameMap.roundXWithDirection(this._x, d); this._y = $gameMap.roundYWithDirection(this._y, d); this._realX = $gameMap.xWithDirection(this._x, this.reverseDir(d)); this._realY = $gameMap.yWithDirection(this._y, this.reverseDir(d)); this.increaseSteps(); } else { this.setDirection(d); this.checkEventTriggerTouchFront(d); }};Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) { this.setMovementSuccess( this.canPassDiagonally(this._x, this._y, horz, vert) ); if (this.isMovementSucceeded()) { this._x = $gameMap.roundXWithDirection(this._x, horz); this._y = $gameMap.roundYWithDirection(this._y, vert); this._realX = $gameMap.xWithDirection(this._x, this.reverseDir(horz)); this._realY = $gameMap.yWithDirection(this._y, this.reverseDir(vert)); this.increaseSteps(); } if (this._direction === this.reverseDir(horz)) { this.setDirection(horz); } if (this._direction === this.reverseDir(vert)) { this.setDirection(vert); }};These also looked related:
Game_CharacterBase.prototype.canPass = function(x, y, d) { const x2 = $gameMap.roundXWithDirection(x, d); const y2 = $gameMap.roundYWithDirection(y, d); if (!$gameMap.isValid(x2, y2)) { return false; } if (this.isThrough() || this.isDebugThrough()) { return true; } if (!this.isMapPassable(x, y, d)) { return false; } if (this.isCollidedWithCharacters(x2, y2)) { return false; } return true;};Game_CharacterBase.prototype.canPassDiagonally = function(x, y, horz, vert) { const x2 = $gameMap.roundXWithDirection(x, horz); const y2 = $gameMap.roundYWithDirection(y, vert); if (this.canPass(x, y, vert) && this.canPass(x, y2, horz)) { return true; } if (this.canPass(x, y, horz) && this.canPass(x2, y, vert)) { return true; } return false;};Can anyone explain how the engine pocesses event triggers? and direct me toward implementing diagonal event triggers?