| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| const DotMoveSystem_FunctionExPluginName = document.currentScript.src.match(/^.*\/(.+)\.js$/)[1];
|
|
|
| (() => {
|
| "use strict";
|
|
|
| for (const className in DotMoveSystemClassAlias) {
|
| this[className] = DotMoveSystemClassAlias[className];
|
| }
|
|
|
|
|
| class PluginParamsParser {
|
| static parse(params, typeData, predictEnable = true) {
|
| return new PluginParamsParser(predictEnable).parse(params, typeData);
|
| }
|
|
|
| constructor(predictEnable = true) {
|
| this._predictEnable = predictEnable;
|
| }
|
|
|
| parse(params, typeData, loopCount = 0) {
|
| if (++loopCount > 255) throw new Error("endless loop error");
|
| const result = {};
|
| for (const name in typeData) {
|
| if (params[name] === "" || params[name] === undefined) {
|
| result[name] = null;
|
| } else {
|
| result[name] = this.convertParam(params[name], typeData[name], loopCount);
|
| }
|
| }
|
| if (!this._predictEnable) return result;
|
| if (typeof params === "object" && !(params instanceof Array)) {
|
| for (const name in params) {
|
| if (result[name]) continue;
|
| const param = params[name];
|
| const type = this.predict(param);
|
| result[name] = this.convertParam(param, type, loopCount);
|
| }
|
| }
|
| return result;
|
| }
|
|
|
| convertParam(param, type, loopCount) {
|
| if (typeof type === "string") {
|
| return this.cast(param, type);
|
| } else if (typeof type === "object" && type instanceof Array) {
|
| const aryParam = JSON.parse(param);
|
| if (type[0] === "string") {
|
| return aryParam.map(strParam => this.cast(strParam, type[0]));
|
| } else {
|
| return aryParam.map(strParam => this.parse(JSON.parse(strParam), type[0]), loopCount);
|
| }
|
| } else if (typeof type === "object") {
|
| return this.parse(JSON.parse(param), type, loopCount);
|
| } else {
|
| throw new Error(`${type} is not string or object`);
|
| }
|
| }
|
|
|
| cast(param, type) {
|
| switch(type) {
|
| case "any":
|
| if (!this._predictEnable) throw new Error("Predict mode is disable");
|
| return this.cast(param, this.predict(param));
|
| case "string":
|
| return param;
|
| case "number":
|
| if (param.match(/^\-?\d+\.\d+$/)) return parseFloat(param);
|
| return parseInt(param);
|
| case "boolean":
|
| return param === "true";
|
| default:
|
| throw new Error(`Unknow type: ${type}`);
|
| }
|
| }
|
|
|
| predict(param) {
|
| if (param.match(/^\-?\d+$/) || param.match(/^\-?\d+\.\d+$/)) {
|
| return "number";
|
| } else if (param === "true" || param === "false") {
|
| return "boolean";
|
| } else {
|
| return "string";
|
| }
|
| }
|
| }
|
|
|
|
|
| const typeDefine = {
|
| PlayerInfo: {},
|
| FollowerInfo: {},
|
| HalfCollisionMassInfo: {},
|
| };
|
| const PP = PluginParamsParser.parse(PluginManager.parameters(DotMoveSystem_FunctionExPluginName), typeDefine);
|
|
|
|
|
| |
| |
|
|
| const _CharacterMover_initialize = CharacterMover.prototype.initialize;
|
| CharacterMover.prototype.initialize = function(character) {
|
| _CharacterMover_initialize.call(this, character);
|
| this._lastDirection = character.direction();
|
| this._changeDirectionCount = 0;
|
| this._direction8 = this._character.direction();
|
| };
|
|
|
| const _Game_CharacterBase_initMembers = Game_CharacterBase.prototype.initMembers;
|
| Game_CharacterBase.prototype.initMembers = function() {
|
| _Game_CharacterBase_initMembers.call(this);
|
| this._dpf = null;
|
| this._acceleration = 0;
|
| this._inertia = 1;
|
| this._accelerationPlus = null;
|
| this._maxAcceleration = null;
|
| this._jumpXPlus = null;
|
| this._jumpYPlus = null;
|
| };
|
|
|
|
|
| const _Game_Player_initMembers = Game_Player.prototype.initMembers;
|
| Game_Player.prototype.initMembers = function() {
|
| _Game_Player_initMembers.call(this);
|
| this._width = PP.PlayerInfo.Width;
|
| this._height = PP.PlayerInfo.Height;
|
| this._offsetX = PP.PlayerInfo.OffsetX;
|
| this._offsetY = PP.PlayerInfo.OffsetY;
|
| this._slideLengthX = PP.PlayerInfo.SlideLengthX;
|
| this._slideLengthY = PP.PlayerInfo.SlideLengthY;
|
| };
|
|
|
|
|
| const _Game_Follower_initMembers = Game_Follower.prototype.initMembers;
|
| Game_Follower.prototype.initMembers = function() {
|
| _Game_Follower_initMembers.call(this);
|
| this._width = PP.FollowerInfo.Width;
|
| this._height = PP.FollowerInfo.Height;
|
| this._offsetX = PP.FollowerInfo.OffsetX;
|
| this._offsetY = PP.FollowerInfo.OffsetY;
|
| this._slideLengthX = PP.FollowerInfo.SlideLengthX;
|
| this._slideLengthY = PP.FollowerInfo.SlideLengthY;
|
| };
|
|
|
| |
| |
|
|
| const _CharacterMover_update = CharacterMover.prototype.update;
|
| CharacterMover.prototype.update = function() {
|
| _CharacterMover_update.call(this);
|
|
|
|
|
| };
|
|
|
| const _Game_CharacterBase_update = Game_CharacterBase.prototype.update;
|
| Game_CharacterBase.prototype.update = function() {
|
| if (this.isJumping() && this.isSmartJumping()) this.updateSmartJump();
|
| if (this.isNeedUpdateAcceleration()) this.updateAcceleration();
|
| _Game_CharacterBase_update.call(this);
|
| };
|
|
|
| |
| |
|
|
| const CharacterInfo = {
|
| width() {
|
| return this._width;
|
| },
|
|
|
| height() {
|
| return this._height;
|
| },
|
|
|
| offsetX() {
|
| return this._offsetX;
|
| },
|
|
|
| offsetY() {
|
| return this._offsetY;
|
| },
|
|
|
| slideLengthX() {
|
| return this._slideLengthX;
|
| },
|
|
|
| slideLengthY() {
|
| return this._slideLengthY;
|
| },
|
| };
|
|
|
| Object.assign(Game_Player.prototype, CharacterInfo);
|
| Object.assign(Game_Follower.prototype, CharacterInfo);
|
|
|
| |
| |
|
|
| CharacterMover.prototype.updateChangeDirection = function() {
|
| if (!this._reserveChangeDirection) return;
|
| const direction = this._lastDirection;
|
| if (direction !== this._character.direction()) {
|
| this._changeDirectionCount++;
|
| if (this._changeDirectionCount >= 3) {
|
| this._reserveChangeDirection = false;
|
| const deg = DotMoveUtils.direction2deg(direction);
|
| const direction4 = DotMoveUtils.deg2direction4(deg, this._character.direction());
|
| this.setDirection8(direction);
|
| this.setDirection(direction4);
|
| this._reserveSetDirection = null;
|
| }
|
| }
|
| };
|
|
|
|
|
| CharacterMover.prototype.setDirection8 = function(direction8) {
|
| this._direction8 = direction8;
|
| };
|
|
|
| CharacterMover.prototype.direction8 = function() {
|
| return this._direction8;
|
| };
|
|
|
| const _CharacterMover_dotMoveByDeg = CharacterMover.prototype.dotMoveByDeg;
|
| CharacterMover.prototype.dotMoveByDeg = function(deg, opt = { changeDir: true }) {
|
| if (opt.changeDir) {
|
| const direction = DotMoveUtils.deg2direction(deg);
|
| this.changeDirectionWhenDotMove(direction);
|
| }
|
| _CharacterMover_dotMoveByDeg.call(this, deg);
|
| };
|
|
|
| const _CharacterMover_dotMoveByDirection = CharacterMover.prototype.dotMoveByDirection;
|
| CharacterMover.prototype.dotMoveByDirection = function(direction, opt = { changeDir: true }) {
|
| if (opt.changeDir) {
|
| this.changeDirectionWhenDotMove(direction);
|
| }
|
| _CharacterMover_dotMoveByDirection.call(this, direction);
|
| };
|
|
|
| CharacterMover.prototype.changeDirectionWhenDotMove = function(direction) {
|
| if (this._lastDirection !== direction) {
|
| this._lastDirection = direction;
|
| this._changeDirectionCount = 0;
|
| this._reserveChangeDirection = true;
|
| this.setDirection8(direction);
|
| const deg = DotMoveUtils.direction2deg(direction);
|
| const direction4 = DotMoveUtils.deg2direction4(deg, this._character.direction());
|
| this.setDirection(direction4);
|
| }
|
| };
|
|
|
|
|
| Game_CharacterBase.prototype.originDistancePerFrame = Game_CharacterBase.prototype.distancePerFrame;
|
|
|
| Game_CharacterBase.prototype.distancePerFrame = function() {
|
| const isNeedUpdateAcceleration = this.isNeedUpdateAcceleration();
|
| if (this._dpf == null) return this.originDistancePerFrame();
|
| if (isNeedUpdateAcceleration && this._moverData.targetCount > 1) return this.originDistancePerFrame();
|
| const dashMul = this._dashing ? 2 : 1;
|
| if (isNeedUpdateAcceleration) {
|
| const acc = 1 + this._acceleration / this._maxAcceleration * this._accelerationPlus;
|
| return this._dpf * acc * dashMul;
|
| } else {
|
| return this._dpf * dashMul;
|
| }
|
| };
|
|
|
| Game_CharacterBase.prototype.setDpf = function(dpf) {
|
| this._dpf = dpf;
|
| };
|
|
|
| Game_CharacterBase.prototype.setAcc = function(maxAcc, accPlus) {
|
| this._maxAcceleration = maxAcc;
|
| this._accelerationPlus = accPlus;
|
| };
|
|
|
| Game_CharacterBase.prototype.setInertia = function(inertia) {
|
| this._inertia = inertia;
|
| };
|
|
|
| Game_CharacterBase.prototype.isNeedUpdateAcceleration = function() {
|
| return this._dpf != null && this._maxAcceleration != null && this._accelerationPlus != null;
|
| };
|
|
|
| Game_CharacterBase.prototype.updateAcceleration = function() {
|
| if ($gameMap.isEventRunning()) {
|
| this.cancelAcceleration();
|
| } else {
|
| if (this.isMoved()) {
|
| if (this._acceleration < this._maxAcceleration) {
|
| this._acceleration++;
|
| }
|
| } else {
|
| if (this._acceleration > 0) {
|
| this._acceleration -= this._inertia;
|
| if (this._acceleration < 0) this._acceleration = 0;
|
| this.mover().dotMoveByDirection(this.mover().direction8(), { changeDir: false });
|
| }
|
| }
|
| }
|
| };
|
|
|
| Game_CharacterBase.prototype.cancelAcceleration = function() {
|
| this._acceleration = 0;
|
| };
|
|
|
|
|
| Game_Player.prototype.distancePerFrame = function() {
|
| if (this.isInVehicle()) return this.originDistancePerFrame();
|
| return Game_CharacterBase.prototype.distancePerFrame.call(this);
|
| };
|
|
|
| Game_Player.prototype.isNeedUpdateAcceleration = function() {
|
| if (this.isInVehicle()) return false;
|
| return Game_CharacterBase.prototype.isNeedUpdateAcceleration.call(this);
|
| };
|
|
|
|
|
| Game_Follower.prototype.distancePerFrame = function() {
|
| if ($gamePlayer.isInVehicle()) return this.originDistancePerFrame();
|
| return Game_CharacterBase.prototype.distancePerFrame.call(this);
|
| };
|
|
|
| Game_Follower.prototype.isNeedUpdateAcceleration = function() {
|
| if ($gamePlayer.isInVehicle()) return false;
|
| return Game_CharacterBase.prototype.isNeedUpdateAcceleration.call(this);
|
| };
|
|
|
| Game_Follower.prototype.changeFollowerSpeed = function(precedingCharacterFar) {
|
| if ($gamePlayer._dpf) {
|
| this.setDpf(this.calcFollowerDpf(precedingCharacterFar));
|
| } else {
|
| this.setDpf(null);
|
| this.setMoveSpeed(this.calcFollowerSpeed(precedingCharacterFar));
|
| }
|
| };
|
|
|
| Game_Follower.prototype.calcFollowerDpf = function(precedingCharacterFar) {
|
| if (precedingCharacterFar >= 2) {
|
| return $gamePlayer.distancePerFrame() * 2;
|
| } else if (precedingCharacterFar >= 1.5) {
|
| return $gamePlayer.distancePerFrame();
|
| } else if (precedingCharacterFar >= 1) {
|
| return $gamePlayer.distancePerFrame() / 2;
|
| } else {
|
| return 0;
|
| }
|
| };
|
|
|
|
|
| const _Scene_Map_callMenu = Scene_Map.prototype.callMenu;
|
| Scene_Map.prototype.callMenu = function() {
|
| _Scene_Map_callMenu.call(this);
|
| $gamePlayer.cancelAcceleration();
|
| };
|
|
|
| |
| |
|
|
| const _PlayerMover_moveProcess = PlayerMover.prototype.moveProcess;
|
| PlayerMover.prototype.moveProcess = function() {
|
|
|
| this.eventPushProcess();
|
| _PlayerMover_moveProcess.call(this);
|
| };
|
|
|
| PlayerMover.prototype.eventPushProcess = function() {
|
| const x = this._character._realX;
|
| const y = this._character._realY;
|
| const width = this._character.width();
|
| const height = this._character.height();
|
| const dpf = this._character.distancePerFrame();
|
| const margin = dpf / 2;
|
| const dir = this._character.direction();
|
| const dis = DotMoveUtils.calcDistance(DotMoveUtils.direction2deg(dir), dpf);
|
| const x2 = x + dis.x;
|
| const y2 = y + dis.y;
|
| for (const event of DotMoveUtils.enteringMassesEvents(x2, y2, width, height)) {
|
| if (!event.event().meta.PushableEvent) continue;
|
| const result = this.checkCharacter(x2, y2, dir, event);
|
| if (!(result && result.collisionLengthX() >= margin && result.collisionLengthY() >= margin)) continue;
|
| event.mover().dotMoveByDirection(dir);
|
| }
|
| };
|
|
|
| |
| |
|
|
| CharacterCollisionChecker.prototype.checkEventsPrepare = function(notCollisionEventIds) {
|
| const collidedEvents = [];
|
| const x = this._character._realX;
|
| const y = this._character._realY;
|
| const width = this._character.width();
|
| const height = this._character.height();
|
| const margin = this._character.distancePerFrame();
|
| const events = DotMoveUtils.enteringMassesEvents(x, y, width, height);
|
| for (const event of events) {
|
| if (event.isNormalPriority() && !event.isThrough() && !notCollisionEventIds.includes(event.eventId())) {
|
| const result = this.checkCharacter(x, y, this._character.direction(), event);
|
| if (result && result.collisionLengthX() >= margin && result.collisionLengthY() >= margin) collidedEvents.push(event);
|
| }
|
| }
|
| return collidedEvents.map(event => event.eventId());
|
| };
|
|
|
| const _CharacterCollisionChecker_checkEvents = CharacterCollisionChecker.prototype.checkEvents;
|
| CharacterCollisionChecker.prototype.checkEvents = function(x, y, d, notCollisionEventIds = []) {
|
| if (PP.ThroughIfCollided) {
|
| const collidedEventIds = this.checkEventsPrepare(notCollisionEventIds);
|
| notCollisionEventIds = notCollisionEventIds.concat(collidedEventIds);
|
| }
|
| return _CharacterCollisionChecker_checkEvents.call(this, x, y, d, notCollisionEventIds)
|
| };
|
|
|
| FollowerCollisionChecker.prototype.checkEventsPrepare = function(notCollisionEventIds) {
|
| return [];
|
| };
|
|
|
| |
| |
|
|
| Game_CharacterBase.prototype.smartJump = function(xPlus, yPlus, baseJumpPeak = 10) {
|
| this._jumpXPlus = xPlus;
|
| this._jumpYPlus = yPlus;
|
| if (Math.abs(xPlus) > Math.abs(yPlus)) {
|
| if (xPlus !== 0) {
|
| this.setDirection(xPlus < 0 ? 4 : 6);
|
| }
|
| } else {
|
| if (yPlus !== 0) {
|
| this.setDirection(yPlus < 0 ? 8 : 2);
|
| }
|
| }
|
| const distance = Math.round(Math.sqrt(xPlus**2 + yPlus**2));
|
| this._jumpPeak = baseJumpPeak + distance - this._moveSpeed;
|
| this._jumpCount = this._jumpPeak * 2;
|
| this.resetStopCount();
|
| this.straighten();
|
| };
|
|
|
| Game_CharacterBase.prototype.isSmartJumping = function() {
|
| return this._jumpXPlus != null && this._jumpYPlus != null;
|
| };
|
|
|
| const _Game_CharacterBase_updateJump = Game_CharacterBase.prototype.updateJump;
|
| Game_CharacterBase.prototype.updateJump = function() {
|
| if (!this.isSmartJumping()) _Game_CharacterBase_updateJump.call(this);
|
| };
|
|
|
| Game_CharacterBase.prototype.updateSmartJump = function() {
|
| this._jumpCount--;
|
| const x = this._realX + this._jumpXPlus / (this._jumpPeak * 2);
|
| const y = this._realY + this._jumpYPlus / (this._jumpPeak * 2);
|
| const dis = { x: x - this._realX, y: y - this._realY };
|
| this.mover()._controller.dotMoveByDistance(this.direction(), dis);
|
| if (this._jumpCount === 0) {
|
| this._jumpXPlus = null;
|
| this._jumpYPlus = null;
|
| this.setPosition(this._realX, this._realY);
|
| }
|
| };
|
|
|
|
|
| |
| |
|
|
| CharacterCollisionChecker.prototype.getMassRects = function(x, y) {
|
| switch (this.getMassCollisionType(x, y)) {
|
| case 1:
|
| return [{ x: x, y: y, width: 1, height: 0.5 }];
|
| case 2:
|
| return [{ x: x + 0.5, y: y, width: 0.5, height: 1 }];
|
| case 3:
|
| return [{ x: x, y: y + 0.5, width: 1, height: 0.5 }];
|
| case 4:
|
| return [{ x: x, y: y, width: 0.5, height: 1 }];
|
| case 5:
|
| return [{ x: x + 0.5, y: y, width: 0.5, height: 0.5 }];
|
| case 6:
|
| return [{ x: x + 0.5, y: y + 0.5, width: 0.5, height: 0.5 }];
|
| case 7:
|
| return [{ x: x, y: y + 0.5, width: 0.5, height: 0.5 }];
|
| case 8:
|
| return [{ x: x, y: y, width: 0.5, height: 0.5 }];
|
| case 9:
|
| return [{ x: x, y: y, width: 0.5, height: 1 }, { x: x + 0.5, y: y + 0.5, width: 0.5, height: 0.5 }];
|
| case 10:
|
| return [{ x: x, y: y, width: 0.5, height: 1 }, { x: x + 0.5, y: y, width: 0.5, height: 0.5 }];
|
| case 11:
|
| return [{ x: x + 0.5, y: y, width: 0.5, height: 1 }, { x: x, y: y, width: 0.5, height: 0.5 }];
|
| case 12:
|
| return [{ x: x + 0.5, y: y, width: 0.5, height: 1 }, { x: x, y: y + 0.5, width: 0.5, height: 0.5 }];
|
| }
|
| return [{ x: x, y: y, width: 1, height: 1 }];
|
| };
|
|
|
| CharacterCollisionChecker.prototype.getMassCollisionType = function(x, y) {
|
| const regionId = $gameMap.regionId(x, y);
|
| const terrainTag = $gameMap.terrainTag(x, y);
|
| if (regionId > 0) {
|
| switch (regionId) {
|
| case PP.HalfCollisionMassInfo.UpCollisionRegionId:
|
| return 1;
|
| case PP.HalfCollisionMassInfo.RightCollisionRegionId:
|
| return 2;
|
| case PP.HalfCollisionMassInfo.DownCollisionRegionId:
|
| return 3;
|
| case PP.HalfCollisionMassInfo.LeftCollisionRegionId:
|
| return 4;
|
| case PP.HalfCollisionMassInfo.UpRightCollisionRegionId:
|
| return 5;
|
| case PP.HalfCollisionMassInfo.RightDownCollisionRegionId:
|
| return 6;
|
| case PP.HalfCollisionMassInfo.DownLeftCollisionRegionId:
|
| return 7;
|
| case PP.HalfCollisionMassInfo.LeftUpCollisionRegionId:
|
| return 8;
|
| case PP.HalfCollisionMassInfo.UpRightOpenCollisionRegionId:
|
| return 9;
|
| case PP.HalfCollisionMassInfo.RightDownOpenCollisionRegionId:
|
| return 10;
|
| case PP.HalfCollisionMassInfo.DownLeftOpenCollisionRegionId:
|
| return 11;
|
| case PP.HalfCollisionMassInfo.LeftUpOpenCollisionRegionId:
|
| return 12;
|
| }
|
| }
|
| if (terrainTag > 0) {
|
| switch (terrainTag) {
|
| case PP.HalfCollisionMassInfo.UpCollisionTerrainTagId:
|
| return 1;
|
| case PP.HalfCollisionMassInfo.RightCollisionTerrainTagId:
|
| return 2;
|
| case PP.HalfCollisionMassInfo.DownCollisionTerrainTagId:
|
| return 3;
|
| case PP.HalfCollisionMassInfo.LeftCollisionTerrainTagId:
|
| return 4;
|
| case PP.HalfCollisionMassInfo.UpRightCollisionTerrainTagId:
|
| return 5;
|
| case PP.HalfCollisionMassInfo.RightDownCollisionTerrainTagId:
|
| return 6;
|
| case PP.HalfCollisionMassInfo.DownLeftCollisionTerrainTagId:
|
| return 7;
|
| case PP.HalfCollisionMassInfo.LeftUpCollisionTerrainTagId:
|
| return 8;
|
| case PP.HalfCollisionMassInfo.UpRightOpenCollisionTerrainTagId:
|
| return 9;
|
| case PP.HalfCollisionMassInfo.RightDownOpenCollisionTerrainTagId:
|
| return 10;
|
| case PP.HalfCollisionMassInfo.DownLeftOpenCollisionTerrainTagId:
|
| return 11;
|
| case PP.HalfCollisionMassInfo.LeftUpOpenCollisionTerrainTagId:
|
| return 12;
|
| }
|
| }
|
| return 0;
|
| };
|
|
|
| CharacterCollisionChecker.prototype.checkCollisionMass = function(targetRect, d, ix, iy) {
|
| const results = [];
|
| const massRects = this.getMassRects(ix, iy);
|
| if (!this.checkPassMass(ix, iy, d)) {
|
| for (const massRect of massRects) {
|
| const result = this.checkCollidedRectOverComplement(this._character._realX, this._character._realY, d, targetRect, massRect);
|
| if (result) results.push(result);
|
| }
|
| }
|
| return results;
|
| }
|
|
|
| CharacterCollisionChecker.prototype.checkPassMass = function(x, y, d) {
|
| const x2 = $gameMap.roundX(x);
|
| const y2 = $gameMap.roundY(y);
|
| if (!$gameMap.isValid(x2, y2)) {
|
| return false;
|
| }
|
| if (this._character.isThrough() || this._character.isDebugThrough()) {
|
| return true;
|
| }
|
|
|
| if (this.getMassCollisionType(x2, y2) >= 1 && this.getMassCollisionType(x2, y2) <= 12) {
|
| return false;
|
| }
|
| const prevPoint = DotMoveUtils.prevPointWithDirection({ x: x2, y: y2 }, d);
|
| if (this.getMassCollisionType(prevPoint.x, prevPoint.y) >= 1 && this.getMassCollisionType(prevPoint.x, prevPoint.y) <= 12) {
|
| return true;
|
| }
|
|
|
| if (this.isMassCollisionNoTarget(x, y, d)) return true;
|
| if (!this._character.isMapPassable(prevPoint.x, prevPoint.y, d)) {
|
| return false;
|
| }
|
| return true;
|
| };
|
|
|
| const _CharacterCollisionChecker_checkCollisionXCliff = CharacterCollisionChecker.prototype.checkCollisionXCliff;
|
| CharacterCollisionChecker.prototype.checkCollisionXCliff = function(targetRect, x, x1, x2, y1, d) {
|
| if (this.getMassCollisionType(x1, y1) >= 1 && this.getMassCollisionType(x1, y1) <= 12 && this.getMassCollisionType(x2, y1) >= 1 && this.getMassCollisionType(x2, y1) <= 12) {
|
| return [];
|
| }
|
| return _CharacterCollisionChecker_checkCollisionXCliff.call(this, targetRect, x, x1, x2, y1, d);
|
| };
|
|
|
| const _CharacterCollisionChecker_checkCollisionYCliff = CharacterCollisionChecker.prototype.checkCollisionYCliff;
|
| CharacterCollisionChecker.prototype.checkCollisionYCliff = function(targetRect, y, y1, y2, x1, d) {
|
| if (this.getMassCollisionType(x1, y1) >= 1 && this.getMassCollisionType(x1, y1) <= 12 && this.getMassCollisionType(x1, y2) >= 1 && this.getMassCollisionType(x1, y2) <= 12) {
|
| return [];
|
| }
|
| return _CharacterCollisionChecker_checkCollisionYCliff.call(this, targetRect, y, y1, y2, x1, d);
|
| };
|
|
|
| })();
|
|
|