Game_Player.prototype.triggerAction = function() {
if (this.canMove()) {
if (this.triggerButtonAction()) {
return true;
}
if (this.triggerTouchAction()) {
return true;
}
}
return false;
};
Game_Player.prototype.triggerButtonAction = function() {
if (Input.isTriggered("ok")) {
if (this.getOnOffVehicle()) {
return true;
}
this.checkEventTriggerHere([0]);
if ($gameMap.setupStartingEvent()) {
return true;
}
this.checkEventTriggerThere([0, 1, 2]);
if ($gameMap.setupStartingEvent()) {
return true;
}
}
return false;
};
Game_Player.prototype.triggerTouchAction = function() {
if ($gameTemp.isDestinationValid()) {
const direction = this.direction();
const x1 = this.x;
const y1 = this.y;
const x2 = $gameMap.roundXWithDirection(x1, direction);
const y2 = $gameMap.roundYWithDirection(y1, direction);
const x3 = $gameMap.roundXWithDirection(x2, direction);
const y3 = $gameMap.roundYWithDirection(y2, direction);
const destX = $gameTemp.destinationX();
const destY = $gameTemp.destinationY();
if (destX === x1 && destY === y1) {
return this.triggerTouchActionD1(x1, y1);
} else if (destX === x2 && destY === y2) {
return this.triggerTouchActionD2(x2, y2);
} else if (destX === x3 && destY === y3) {
return this.triggerTouchActionD3(x2, y2);
}
}
return false;
};
Game_Player.prototype.triggerTouchActionD1 = function(x1, y1) {
if ($gameMap.airship().pos(x1, y1)) {
if (TouchInput.isTriggered() && this.getOnOffVehicle()) {
return true;
}
}
this.checkEventTriggerHere([0]);
return $gameMap.setupStartingEvent();
};
Game_Player.prototype.triggerTouchActionD2 = function(x2, y2) {
if ($gameMap.boat().pos(x2, y2) || $gameMap.ship().pos(x2, y2)) {
if (TouchInput.isTriggered() && this.getOnVehicle()) {
return true;
}
}
if (this.isInBoat() || this.isInShip()) {
if (TouchInput.isTriggered() && this.getOffVehicle()) {
return true;
}
}
this.checkEventTriggerThere([0, 1, 2]);
return $gameMap.setupStartingEvent();
};
Game_Player.prototype.triggerTouchActionD3 = function(x2, y2) {
if ($gameMap.isCounter(x2, y2)) {
this.checkEventTriggerThere([0, 1, 2]);
}
return $gameMap.setupStartingEvent();
};
Game_Player.prototype.checkEventTriggerHere = function(triggers) {
if (this.canStartLocalEvents()) {
this.startMapEvent(this.x, this.y, triggers, false);
}
};
Game_Player.prototype.checkEventTriggerThere = function(triggers) {
if (this.canStartLocalEvents()) {
const direction = this.direction();
const x1 = this.x;
const y1 = this.y;
const x2 = $gameMap.roundXWithDirection(x1, direction);
const y2 = $gameMap.roundYWithDirection(y1, direction);
this.startMapEvent(x2, y2, triggers, true);
if (!$gameMap.isAnyEventStarting() && $gameMap.isCounter(x2, y2)) {
const x3 = $gameMap.roundXWithDirection(x2, direction);
const y3 = $gameMap.roundYWithDirection(y2, direction);
this.startMapEvent(x3, y3, triggers, true);
}
}
};