| 赞 | 37 |
| VIP | |
| 好人卡 | |
| 积分 | 105 |
| 经验 | |
| 最后登录 | 2026-1-6 |
| 在线时间 | 463 小时 |
- 梦石
- 2
- 星屑
- 8479
- 在线时间
- 463 小时
- 注册时间
- 2021-12-4
- 回帖
- 486

|
楼主 |
发表于 2022-12-14 17:01:06
|
显示全部楼层
[pre lang="js" line="8470" file="triggerAction.js"]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);
}
}
};[/pre]
翻了一下MZ源码,虽然不知道RGSS几代纯键盘操作是怎么样的,但应该和MZ去掉点击操作以后剩余的逻辑差不多,MV的源码估计也差不多。
那么简单梳理一下,在MZ中「确定键」(triggerButtonAction)和「点击屏幕」(triggerTouchAction)都可以触发非B型事件(triggerAction),且一旦前者成功触发就不再同时触发后者。
「确定键」的触发优先级是:乘降载具(没用到载具系统的可以不管)、脚下的A型事件(checkEventTriggerHere)、面前1格的不可通行事件(CD型)、(面前1格为柜台时)面前2格的不可通行事件,一旦有一个成功触发就不再同时触发后者。
「点击屏幕」的触发则取决于「寻路目标点」的坐标,优先级顺序按照这个坐标分为三种情况(triggerTouchActionD1到D3),三种情况彼此没有交集,每一种情况内部一旦有一个成功触发就不再同时触发后者。
(1) 主角脚下:乘降飞艇、该点A型事件。
(2) 主角面前1格:乘降小舟或大船、该点不可通行事件、(该点为柜台时)面前2格不可通行事件。
(3) 主角面前2格:(面前1格为柜台时)该点不可通行事件。
这样就完美解释了「为什么只用键盘无法踩着A触发面前的C,而用点击却可以」。
接下来只要给玩家提供「自由行动时原地无代价转身」的功能就能解决「只用点击如何转身面向C而不触发」,于是最后一个问题就是「只用点击如何停在A上而不触发」。
这个问题刚才研究了好一会也没找到好办法,triggerTouchActionD1中的判定条件是「主角恰好位于寻路目标点」,没办法区分是「从别处走来的」还是「静止时玩家点击了主角」,我希望只有后一种情况触发A而前一种不触发,有人能帮帮我吗? |
|