| 赞 | 19 |
| VIP | |
| 好人卡 | |
| 积分 | 70 |
| 经验 | |
| 最后登录 | 2025-3-18 |
| 在线时间 | 1557 小时 |
- 梦石
- 0
- 星屑
- 6963
- 在线时间
- 1557 小时
- 注册时间
- 2011-6-14
- 回帖
- 425
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
智能跳跃脚本在插件管理设置跳跃步数进入游戏实测相差太大
我设置为1 在游戏里面却是跳了4.5步 求设置方法
- //=============================================================================
- // Yanfly Engine Plugins - Smart Jump
- // YEP_SmartJump.js
- //=============================================================================
- var Imported = Imported || {};
- Imported.YEP_SmartJump = true;
- var Yanfly = Yanfly || {};
- Yanfly.Jump = Yanfly.Jump || {};
- //=============================================================================
- /*:
- * @plugindesc v1.00 Adds a plugin command that enables smart jumping
- * where the player cannot jump into illegal areas.
- * @author Yanfly Engine Plugins
- *
- * @param Illegal Regions
- * @desc These are the region ID's the player cannot jump on
- * or past. Separate each region with a space.
- * @default 0
- *
- * @help
- * ============================================================================
- * Introduction
- * ============================================================================
- *
- * For those that may have made their own Jump system before with events, you
- * may have come across the problem of being able to jump off the map, into
- * places you're not supposed to go, or even on top of events that shouldn't be
- * allowed to go on top of. This plugin helps faciliate eventing a Jump system
- * for your RPG Maker game by introducing Smart Jumps.
- *
- * Smart Jumps will allow you to jump over areas, but will limit you from
- * jumping on top of places you can't go, on top of normal priority events, and
- * set up boundaries (such as walls) that you normally cannot jump past.
- *
- * ============================================================================
- * Instructions - Setting Up Smart Jumps
- * ============================================================================
- *
- * Use the Plugin Command 'SmartJump' to make the player character perform a
- * Smart Jump.
- *
- * Inside the plugin parameters, mark the Illegal Regions your player cannot
- * jump past or on and then draw them on the map. Alternatively, you can mark
- * certain tile types within the Database > Tileset tab and use Terrain Tags to
- * restrict where the player cannot jump.
- *
- * ============================================================================
- * Notetags
- * ============================================================================
- *
- * You can use these notetags to set up what Terrain Tags that the player can't
- * jump on or past.
- *
- * Tileset Notetags:
- *
- * <Illegal Jump: x>
- * <Illegal Jump: x, x, x>
- * <Illegal Jump: x to y>
- * Replace x with the terrain tags you want to forbid the player from going
- * past or landing on while doing Smart Jumps.
- *
- * Event Notetag:
- *
- * <Illegal Jump>
- * This will prevent the player from being able to jump on or over this
- * event while doing Smart Jumps. If the event is set to Through mode, then
- * the player can jump through or onto the event.
- */
- //=============================================================================
- //=============================================================================
- // Parameter Variables
- //=============================================================================
- Yanfly.Parameters = PluginManager.parameters('YEP_SmartJump');
- Yanfly.Param = Yanfly.Param || {};
- Yanfly.Param.JumpIllegalRegion = String(Yanfly.Parameters['Illegal Regions']);
- Yanfly.Param.JumpIllegalRegion = Yanfly.Param.JumpIllegalRegion.split(' ');
- if (Yanfly.Param.JumpIllegalRegion === '') Yanfly.Param.JumpIllegalRegion = [];
- Yanfly.max = Yanfly.Param.JumpIllegalRegion.length;
- for (Yanfly.i = 0; Yanfly.i < Yanfly.max; ++Yanfly.i) {
- Yanfly.Param.JumpIllegalRegion[Yanfly.i] =
- parseInt(Yanfly.Param.JumpIllegalRegion[Yanfly.i]);
- };
- //=============================================================================
- // DataManager
- //=============================================================================
- Yanfly.Jump.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
- DataManager.isDatabaseLoaded = function() {
- if (!Yanfly.Jump.DataManager_isDatabaseLoaded.call(this)) return false;
- this.processJumpNotetags1($dataTilesets);
- return true;
- };
- DataManager.processJumpNotetags1 = function(group) {
- var note1a = /<(?:ILLEGAL JUMP):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
- var note1b = /<(?:ILLEGAL JUMP):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i;
- for (var n = 1; n < group.length; n++) {
- var obj = group[n];
- var notedata = obj.note.split(/[\r\n]+/);
- obj.illegalJumpTag = [];
- for (var i = 0; i < notedata.length; i++) {
- var line = notedata[i];
- if (line.match(note1a)) {
- var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
- obj.illegalJumpTag = obj.illegalJumpTag.concat(array);
- } else if (line.match(note1b)) {
- var range = Yanfly.Util.getRange(parseInt(RegExp.$1),
- parseInt(RegExp.$2));
- obj.illegalJumpTag = obj.illegalJumpTag.concat(range);
- }
- }
- }
- };
- DataManager.processJumpNotetags2 = function(obj) {
- var notedata = obj.note.split(/[\r\n]+/);
- obj.illegalJump = false;
- for (var i = 0; i < notedata.length; i++) {
- var line = notedata[i];
- if (line.match(/<(?:ILLEGAL JUMP)>/i)) {
- obj.illegalJump = true;
- }
- }
- };
- //=============================================================================
- // Game_CharacterBase
- //=============================================================================
- Game_CharacterBase.prototype.smartJump = function(distance) {
- if (distance === 0) return this.jump(0, 0);
- this.setupSmartJump(this.getSmartJumpDistance(distance));
- };
- Game_CharacterBase.prototype.setupSmartJump = function(distance) {
- if (this._direction === 2) {
- this.jump(0, distance);
- } else if (this._direction === 4) {
- this.jump(-distance, 0);
- } else if (this._direction === 6) {
- this.jump(distance, 0);
- } else if (this._direction === 8) {
- this.jump(0, -distance);
- }
- };
- Game_CharacterBase.prototype.getSmartJumpDistance = function(distance) {
- if (this._direction === 2) {
- for (var i = 0; i < distance; ++i) {
- if (this.isSmartJumpIllegalRegion(this.x, this.y + i + 1)) {
- distance = i;
- break;
- }
- }
- } else if (this._direction === 4) {
- for (var i = 0; i < distance; ++i) {
- if (this.isSmartJumpIllegalRegion(this.x - i - 1, this.y)) {
- distance = i;
- break;
- }
- }
- } else if (this._direction === 6) {
- for (var i = 0; i < distance; ++i) {
- if (this.isSmartJumpIllegalRegion(this.x + i + 1, this.y)) {
- distance = i;
- break;
- }
- }
- } else if (this._direction === 8) {
- for (var i = 0; i < distance; ++i) {
- if (this.isSmartJumpIllegalRegion(this.x, this.y - i - 1)) {
- distance = i;
- break;
- }
- }
- }
- return this.calcSmartJumpDistance(distance);
- };
- Game_CharacterBase.prototype.isSmartJumpIllegalRegion = function(x, y) {
- if (x < 0 || y < 0) return true;
- if (x > $gameMap.width() - 1 || y > $gameMap.height() - 1) return true;
- if (this.isThrough()) return false;
- var regionId = $gameMap.regionId(x, y);
- if (regionId > 0 && Yanfly.Param.JumpIllegalRegion.contains(regionId)) {
- return true;
- }
- var tileset = $gameMap.tileset();
- if (tileset && tileset.illegalJumpTag.contains($gameMap.terrainTag(x, y))) {
- return true;
- }
- var events = $gameMap.eventsXy(x, y);
- var length = events.length;
- for (var i = 0; i < length; ++i) {
- var ev = events[i];
- if (!ev) continue;
- if (ev.isThrough()) continue;
- if (ev.isSmartJumpBlocked()) return true;
- }
- return false;
- };
- Game_CharacterBase.prototype.calcSmartJumpDistance = function(distance) {
- var max = distance;
- var value = 0;
- if (this._direction === 2) {
- for (var i = 0; i < max; ++i) {
- if (this.isSmartJumpValid(this.x, this.y + max - i)) {
- value = max - i;
- break;
- }
- }
- } else if (this._direction === 4) {
- for (var i = 0; i < max; ++i) {
- if (this.isSmartJumpValid(this.x - max + i, this.y)) {
- value = max - i;
- break;
- }
- }
- } else if (this._direction === 6) {
- for (var i = 0; i < max; ++i) {
- if (this.isSmartJumpValid(this.x + max - i, this.y)) {
- value = max - i;
- break;
- }
- }
- } else if (this._direction === 8) {
- for (var i = 0; i < max; ++i) {
- if (this.isSmartJumpValid(this.x, this.y - max + i)) {
- value = max - i;
- break;
- }
- }
- }
- return value;
- };
- Game_CharacterBase.prototype.isSmartJumpValid = function(x, y) {
- if (this.isThrough()) return true;
- var events = $gameMap.eventsXyNt(x, y);
- var length = events.length;
- for (var i = 0; i < length; ++i) {
- var ev = events[i];
- if (!ev) continue;
- if (ev.isThrough()) continue;
- if (ev.isNormalPriority()) return false;
- if (ev.isSmartJumpBlocked()) return false;
- }
- return $gameMap.isPassable(x, y, this._direction);
- };
- //=============================================================================
- // Game_Event
- //=============================================================================
- Yanfly.Jump.Game_Event_setupPageSettings =
- Game_Event.prototype.setupPageSettings;
- Game_Event.prototype.setupPageSettings = function() {
- Yanfly.Jump.Game_Event_setupPageSettings.call(this);
- DataManager.processJumpNotetags2(this.event());
- };
- Game_Event.prototype.isSmartJumpBlocked = function() {
- if (this.event().illegalJump === undefined) {
- DataManager.processJumpNotetags2(this.event());
- }
- return this.event().illegalJump;
- };
- //=============================================================================
- // Game_Interpreter
- //=============================================================================
- Yanfly.Jump.Game_Interpreter_pluginCommand =
- Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- Yanfly.Jump.Game_Interpreter_pluginCommand.call(this, command, args);
- if (command === 'SmartJump') {
- $gamePlayer.smartJump(parseInt(args[0]));
- }
- };
- //=============================================================================
- // Utilities
- //=============================================================================
- Yanfly.Util = Yanfly.Util || {};
- Yanfly.Util.getRange = function(n, m) {
- var result = [];
- for (var i = n; i <= m; ++i) result.push(i);
- return result;
- };
- //=============================================================================
- // End of File
- //=============================================================================
复制代码 |
|