Project1
标题:
如何把在战斗中使用道具做成一个技能?
[打印本页]
作者:
靖康之变KK100
时间:
2020-7-27 21:02
标题:
如何把在战斗中使用道具做成一个技能?
想做一个在战斗中使用的“使用道具”的技能,使用后直接调出战斗中的道具选择界面
因为删掉战斗前两级菜单的时候就把原来的道具按钮也删掉了,道具使用就只能依靠技能来实现
但是普通地来做貌似做不到,得依靠事件脚本或插件。
而且不知道事件的插入脚本是什么原理,写上Scene_Battle里的函数会报错……
虽然考虑过技能消耗道具的插件,但也只能一个个技能绑定道具而且会大量占用技能栏巴拉巴拉……
请教:
1、大佬们有没有能够直接实现功能(设置一个“使用道具”的技能)的纯事件的奇技淫巧?
2、有没有插件能实现功能或能够直接代替使用道具的按钮(比如外置一个道具按钮)?
作者:
kano521241
时间:
2020-7-29 20:45
感觉有点像是八方旅人里面的效果。
推荐一下这个插件,图片公共事件,据说能在战斗中使用公共事件(我没有应用过这方面的功能,也许可以用这个重新做一个战斗系统?),不过这个也只能一个一个事件去做……
//=============================================================================
// PictureCallCommon.js
// ----------------------------------------------------------------------------
// (C)2015 Triacontane
// This plugin is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
//版本
// 1.14.2 2020/06/05 在帮助的按键绑定中添加pagedown和pageup
// 1.14.1 2020/05/16 修改了帮助命令中部分容易混淆的描述
// 1.14.0 2020/05/13 添加了只有在指定的开关为ON时才能使“触摸操作抑制”有效的设定
// 1.13.1 2020/05/06 修正执行地图变焦时坐标获取计算错误的问题
// 1.13.0 2019/12/22添加了设置以执行常见的并行处理图片。
// 1.12.2 2019/03/31更改了当通过键绑定指定附加键时按钮名称不是小写字母时不响应的规范
// 1.12.1 2019/03/19修复了从社区版本核心脚本1.3或更高版本共有的图片设置移动路径时发生错误的问题
// 1.12.0 2018/11/02添加了禁用所有图片触摸的开关
// 1.11.0 2018/08/10解决了透明度设置未正确应用于Napatana函数的问题
// 添加了将透明度设置从插件命令更改为pattens函数的功能
// 1.10.8 2018/06/16解决了无法正常获取某些布尔类型参数的问题
// 1.10.7 2018/06/01修复了在“过程战斗”事件中无法使用“在战斗中始终运行”功能的问题
// 1.10.6 2018/04/12修改了帮助说明
// 1.10.5 2017/12/17将执行常见事件的按钮的规范更改为在事件执行期间无效
// 1.10.4 2017/11/01更改为在调用通用图片时未显示目标图片时不调用事件的规范
// 1.10.3 2017/10/28解决了以下问题:如果您在等待图片触摸事件调用的同时进入战斗,则会在显示战斗屏幕后执行该战斗
// 1.10.2 2017/10/21修复了进入战斗屏幕时鼠标悬停事件可能意外发生的问题
// 1.10.1 2017/05/27动态字符图片插件的窗口字符串单击现在支持图片单击
// 1.9.3 2017/05/27重构描述(将属性添加到Object类)(可能会引起衝突)
// 1.9.2 2017/03/16修复了1.9.0战斗中常见事件执行无法正常运行的问题
// 1.9.1 2017/03/16更改了规格,以使不透明度为0的图片在考虑透明颜色时完全不响应
// 1.9.0 2017/03/13添加了在战斗中执行图片点击事件的功能
// 1.8.2 2017/02/14修正了在单击图片时将值存储在变量中的功能,但由于1.8.0的修正而无效
// 1.8.1 2017/02/07删除了与终端有关的描述
// 1.8.0 2017/02/03添加了将图片点击绑定到任何按钮的功能
// 1.7.0 2017/02/02现在,您可以在缩放和摇动地图时准确单击图片。
// 添加了一个函数,该函数允许脚本确定鼠标指针是否在图片内。
// 1.6.0 2016/12/29规格修改,当图片点击发生事件时使地图触摸无效
// 1.5.1 2016/11/20删除了混合在1.5.0中的不必要代码
// 1.5.0 2016/11/19添加了单击图片时打开开关的功能,而不是常见事件
// 1.4.0 2016/08/20添加了用于设置是否为每张图片考虑透明色的功能
// 修复了在不使用插件的情况下加载保存数据时的错误
// 1.3.5 2016/04/20已还原图片优先级已通过重构反转
// 1.3.4 2016/04/08解决了图片相邻时鼠标悬停和鼠标悬停可能无法正常工作的问题。
// 1.3.3 2016/03/19添加了一个参数,用于在满足触发条件时抑制后续的触摸处理
// 1.3.2 2016/02/28稍微减轻处理负担
// 1.3.1 2016/02/21将鼠标移动添加到触发器
// 1.3.0 2016/01/24添加了拍拍照片的功能
// 添加鼠标移动以触发
// 固定图片旋转时的正确位置
// 1.2.1 2016/01/21固定了将常见事件的上限从100调至1000(DB的最大值)
// 竞争性措施(YEP_MessageCore.js)
// 1.2.0 2016/01/14滚轮触发器,双击和更多触发器被扩展为10种类型
// 1.1.3 2016/01/02衝突度量(TDDP_BindPicturesToMap.js)
// 1.1.2 2015/12/20更改规格以在发生长按事件时设置1秒间隔
// 1.1.1 2015/12/10纠正了删除图片后将鼠标悬停在鼠标上的错误
// 1.1.0 2015/11/23添加了用于指定调用公共事件的目标的图片编号的功能
// 添加了在设置中考虑透明颜色的功能
// 添加“右键”或“长按”作为触发器
// 1.0.0 2015/11/14第一版
// ----------------------------------------------------------------------------
// [Blog] : https://triacontane.blogspot.jp/
// [Twitter]: https://twitter.com/triacontane/
// [GitHub] : https://github.com/triacontane/
//=============================================================================
/*:
* @plugindesc 图片点击公共事件
* @author triacontane
*
* @param TransparentConsideration
* @desc 如果单击位置是透明的,则禁用单击。
* @default true
* @type boolean
*
* @param GameVariablePictureNum
* @desc 在调用公共事件时存储图片号的游戏变量号。
* @default 0
* @type variable
*
* @param GameVariableTouchX
* @desc 存储触碰x位置的游戏变量号
* @default 0
* @type variable
*
* @param GameVariableTouchY
* @desc 存储触碰y位置的游戏变量号
* @default 0
* @type variable
*
* @param SuppressTouch
* @desc 禁止他人触摸事件(ON/OFF)
* @default false
* @type boolean
*
* @param SuppressTouchSwitch
* @desc 如果指定了此选项,“触控”仅在目标开关打开时启用。
* @default 0
* @type switch
*
* @param AlwaysCommonInBattle
* @desc 总是在战斗中执行公共事件(ON/OFF)
* @default false
* @type boolean
*
* @param AsParallelCommon
* @desc 以并行处理方式执行通过点击图片执行的公共事件。
* @default false
* @type boolean
*
* @param InvalidSwitchId
* @desc 指定编号的开关为ON时,所有画面触摸都无效。
* @default 0
* @type switch
*
* @help
* 点击图片后,指定的公共事件
* 提供调用或打开任意开关的插件命令。
* 如果使用该插件,即使不知道JavaScript
* 谁都可以简单地制作以点击和触摸为主体的游戏。
*
* 虽然在战斗中也可以实行,但只有在限定的时间内才能使用
* 事件不执行。参数“战斗中经常运行公共端”生效后
* 总是执行事件,
* 部分事件命令有不正确动作的限制。
*
* 注意!
* 一旦关联图片和共模事件删除图片也有效。
* 如果图片不存在,点击哪里都不会有反应,
* 再次以相同编号显示图片时会发生反应。
*
* 插件命令详情
* 从事件命令“插件命令”执行。
* (参数之间用半角空间隔开)
*
* 图片按钮化或
* P_CALL_CE [图片编号] [公共事件 ID] [触发] [透明度考虑]:
* (透明度考虑需要的是一个布尔类型,输入ON或者OFF)
* 单击图片时,调用公共事件id。
* 触发器如下所示(如果省略,则将其指定为1)
* 1 : 左键点击
* 2 : 右键点击
* 3 : 长按
* 4 : 悬停
* 5 : 移出
* 6 : 鼠标释放
* 7 : 重复点击鼠标
* 8 : 鼠标点击
* 9 : 滑轮点击
* 10 : 双击
* 11 : 移动鼠标
* 12 : 鼠标移动并按下
*
* 如果指定了考虑透明色的参数(ON/OFF),则会考虑每个图片的透明色
* 可以设置。如果不进行任何设置,将应用插件参数设置。(以往的规格)
*
* 例:P_CALL_CE 1 3 7 ON
* :ピクチャのボタン化 \v[1] \v[2] \v[3] OFF
*
* 图片切换或
* P_CALL_SWITCH [图片编号][开关ID][触发][考虑透明色]
* 在图片区域内满足触发条件时,将任意开关设为ON。
* 触发设置等与图片按钮化相同。
*
* 图片按键绑定或
* P_CALL_KEY_BIND [图片编号][按钮名称][触发][考虑透明色]
* 在图片区域内满足触发条件时,按下任意按钮。
* 按钮名称的设定如下所示。(Windows标准)
* ok : Enter,Z
* shift : Shift
* control : Ctrl,Alt
* escape : Esc,X
* left : ←
* up : ↑
* right : →
* down : ↓
* pageup : PageUp
* pagedown : PageDown
*
* 删除图片按钮 or
* P_CALL_CE_REMOVE [图片编号]
* 解除图片和公共事件或开关的关联。
* 所有触发器均为删除对象。
*
* 例:P_CALL_CE_REMOVE 1
* :ピクチャのボタン化解除 \v[1]
*
* 以图片的方式设置 or
* P_STROKE [图片编号] [变量编号] [是否考虑透明色]
* 如果在指定的图片上移动鼠标或触摸,
* 根据速度值将数值与指定变量相加。
* 此设置也可用于替换图片或暂时隐藏图片。
* 10秒大约能积累到1000左右。
*
* 例:P_STROKE 1 2 ON
* :ピクチャのなでなで設定 \v[1] \v[2] OFF
*
* 通过图片的触碰解除 or
* P_STROKE_REMOVE [图片编号]
* 通过触碰指定图片来取消设置。
*
* 例:P_STROKE_REMOVE 1
* :ピクチャのなでなで解除 \v[1]
*
* 图片指针化 or
* P_POINTER [图片编号]
* 指定的图片会自动追踪触摸坐标。
* 没有触摸的话会自动隐藏。
*
* 例:P_POINTER 1
* :ピクチャのポインタ化 \v[1]
*
* 图片指针化解除 or
* P_POINTER_REMOVE [图片编号]
* 取消指定图片的指针化。
*
* 例:P_POINTER_REMOVE 1
* :ピクチャのポインタ化解除 \v[1]
*
* ・脚本(面向上级)
* $gameScreen.isPointerInnerPicture([ID]);
* 在指定的[ID]图片中存在鼠标指针或触摸坐标时
* 返回true。此脚本即使没有使用[P_CALL_CE]也有效。
*
* 例:$gameScreen.isPointerInnerPicture(5);
*
* P_CALL_CE[图片编号][公共事件ID][触发器][透明机密]:
* 单击图片时,分配公共事件id。
* 触发器如下(如果省略,则指定为1)
* 1:左键单击
* 2:右键单击
* 3:长按
* 4:鼠标悬停
* 5:鼠标移出
* 6:鼠标释放
* 7:鼠标重复单击
* 8:鼠标按下
* 9:滑轮点击
* 10:双击
* 11:鼠标移动
* 12:鼠标移动并按下
* P_CALL_CE_REMOVE[图片编号]:
* 打破从画面到普通事件的关系。
* -脚本
* $gameScreen.isPointerInnerPicture([ID]);
* 如果鼠标指针在图片内部,则返回true。
* 例如:$gameScreen.isPointerInnerPicture(5) ;
* 这个插件是在麻省理工学院许可下发布的。
*
* 使用规约:
* 可擅自更改作者,再次发布,使用形式(商务、18禁使用等)
* 对此也没有限制。
* 此插件已属于您。
*/
(function() {
'use strict';
var pluginName = 'PictureCallCommon';
var getParamOther = function(paramNames) {
if (!Array.isArray(paramNames)) paramNames = [paramNames];
for (var i = 0; i < paramNames.length; i++) {
var name = PluginManager.parameters(pluginName)[paramNames[i]];
if (name) return name;
}
return null;
};
var getParamBoolean = function(paramNames) {
var value = getParamOther(paramNames);
return (value || '').toUpperCase() === 'ON' || (value || '').toUpperCase() === 'TRUE';
};
var getParamNumber = function(paramNames, min, max) {
var value = getParamOther(paramNames);
if (arguments.length < 2) min = -Infinity;
if (arguments.length < 3) max = Infinity;
return (parseInt(value, 10) || 0).clamp(min, max);
};
var getCommandName = function(command) {
return (command || '').toUpperCase();
};
var getArgNumber = function(arg, min, max) {
if (arguments.length < 2) min = -Infinity;
if (arguments.length < 3) max = Infinity;
return (parseInt(convertEscapeCharacters(arg), 10) || 0).clamp(min, max);
};
var getArgBoolean = function(arg) {
return (arg || '').toUpperCase() === 'ON';
};
var convertEscapeCharacters = function(text) {
if (text == null) text = '';
var window = SceneManager._scene._windowLayer.children[0];
return window ? window.convertEscapeCharacters(text) : text;
};
var iterate = function(that, handler) {
Object.keys(that).forEach(function(key, index) {
handler.call(that, key, that[key], index);
});
};
//=============================================================================
// パラメータの取得とバリデーション
//=============================================================================
var paramGameVariableTouchX = getParamNumber(['GameVariableTouchX', 'ポインタX座標の変数番号'], 0);
var paramGameVariableTouchY = getParamNumber(['GameVariableTouchY', 'ポインタY座標の変数番号'], 0);
var paramGameVariablePictNum = getParamNumber(['GameVariablePictureNum', 'ピクチャ番号の変数番号'], 0);
var paramTransparentConsideration = getParamBoolean(['TransparentConsideration', '透明色を考慮']);
var paramSuppressTouch = getParamBoolean(['SuppressTouch', 'タッチ操作抑制']);
var paramSuppressTouchSwitch = getParamNumber(['SuppressTouchSwitch', 'タッチ操作抑制スイッチ']);
var paramAlwaysCommonInBattle = getParamBoolean(['AlwaysCommonInBattle', '戦闘中常にコモン実行']);
var paramInvalidSwitchId = getParamNumber(['InvalidSwitchId', '無効スイッチ'], 0);
var paramAsParallelCommon = getParamBoolean(['AsParallelCommon', '並列処理として実行']);
//=============================================================================
// Game_Interpreter
// プラグインコマンド[P_CALL_CE]などを追加定義します。
//=============================================================================
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.apply(this, arguments);
var pictureId, touchParam, trigger, variableNum, transparent;
switch (getCommandName(command)) {
case 'P_CALL_CE' :
case 'ピクチャのボタン化':
pictureId = getArgNumber(args[0], 1, $gameScreen.maxPictures());
touchParam = getArgNumber(args[1], 1, $dataCommonEvents.length - 1);
trigger = getArgNumber(args[2], 1);
transparent = (args.length > 3 ? getArgBoolean(args[3]) : null);
$gameScreen.setPictureCallCommon(pictureId, touchParam, trigger, transparent);
break;
case 'P_CALL_SWITCH' :
case 'ピクチャのスイッチ化':
pictureId = getArgNumber(args[0], 1, $gameScreen.maxPictures());
touchParam = getArgNumber(args[1], 1);
trigger = getArgNumber(args[2], 1);
transparent = (args.length > 3 ? getArgBoolean(args[3]) : null);
$gameScreen.setPictureCallCommon(pictureId, touchParam * -1, trigger, transparent);
break;
case 'P_CALL_KEY_BIND' :
case 'ピクチャのキーバインド':
pictureId = getArgNumber(args[0], 1, $gameScreen.maxPictures());
touchParam = convertEscapeCharacters(args[1]);
trigger = getArgNumber(args[2], 1);
transparent = (args.length > 3 ? getArgBoolean(args[3]) : null);
$gameScreen.setPictureCallCommon(pictureId, touchParam, trigger, transparent);
break;
case 'P_CALL_CE_REMOVE' :
case 'ピクチャのボタン化解除':
pictureId = getArgNumber(args[0], 1, $gameScreen.maxPictures());
$gameScreen.setPictureRemoveCommon(pictureId);
break;
case 'P_STROKE' :
case 'ピクチャのなでなで設定':
pictureId = getArgNumber(args[0], 1, $gameScreen.maxPictures());
variableNum = getArgNumber(args[1], 1, $dataSystem.variables.length - 1);
transparent = (args.length > 2 ? getArgBoolean(args[2]) : null);
$gameScreen.setPictureStroke(pictureId, variableNum, transparent);
break;
case 'P_STROKE_REMOVE' :
case 'ピクチャのなでなで解除':
pictureId = getArgNumber(args[0], 1, $gameScreen.maxPictures());
$gameScreen.removePictureStroke(pictureId);
break;
case 'P_POINTER' :
case 'ピクチャのポインタ化':
pictureId = getArgNumber(args[0], 1, $gameScreen.maxPictures());
$gameScreen.setPicturePointer(pictureId);
break;
case 'P_POINTER_REMOVE' :
case 'ピクチャのポインタ化解除':
pictureId = getArgNumber(args[0], 1, $gameScreen.maxPictures());
$gameScreen.removePicturePointer(pictureId);
break;
}
};
var _Game_Interpreter_terminate = Game_Interpreter.prototype.terminate;
Game_Interpreter.prototype.terminate = function() {
_Game_Interpreter_terminate.apply(this, arguments);
this._setupFromPicture = false;
};
Game_Interpreter.prototype.setupFromPicture = function(eventList, commonId) {
this.setup(eventList, null);
if (this.setEventInfo) {
this.setEventInfo({ eventType: 'common_event', commonEventId: commonId });
}
this._setupFromPicture = true;
};
Game_Interpreter.prototype.isSetupFromPicture = function() {
return this._setupFromPicture;
};
//=============================================================================
// Game_Temp
// 呼び出し予定のコモンイベントIDのフィールドを追加定義します。
//=============================================================================
var _Game_Temp_initialize = Game_Temp.prototype.initialize;
Game_Temp.prototype.initialize = function() {
_Game_Temp_initialize.call(this);
this.clearPictureCallInfo();
};
Game_Temp.prototype.clearPictureCallInfo = function() {
this._pictureCommonId = 0;
this._touchPictureId = 0;
};
Game_Temp.prototype.setPictureCallInfo = function(pictureCommonId) {
this._pictureCommonId = pictureCommonId;
};
Game_Temp.prototype.pictureCommonId = function() {
if (!$gameScreen.picture(this._touchPictureId)) {
this.clearPictureCallInfo();
}
return this._pictureCommonId;
};
Game_Temp.prototype.onTouchPicture = function(param, pictureId) {
this._touchPictureParam = param;
if (this.isTouchPictureSetSwitch()) {
$gameSwitches.setValue(param * -1, true);
}
if (this.isTouchPictureCallCommon()) {
if (!paramAsParallelCommon && $gameMap.isEventRunning() && !$gameParty.inBattle()) {
this._touchPictureParam = null;
return;
}
this.setPictureCallInfo(param);
}
if (this.isTouchPictureButtonTrigger()) {
Input.bindKeyState(param);
}
if (paramGameVariablePictNum > 0) {
$gameVariables.setValue(paramGameVariablePictNum, pictureId);
}
this._touchPictureId = pictureId;
};
Game_Temp.prototype.isTouchPictureButtonTrigger = function() {
return isNaN(this._touchPictureParam);
};
Game_Temp.prototype.isTouchPictureSetSwitch = function() {
return !isNaN(this._touchPictureParam) && this._touchPictureParam < 0;
};
Game_Temp.prototype.isTouchPictureCallCommon = function() {
return !isNaN(this._touchPictureParam) && this._touchPictureParam > 0;
};
//=============================================================================
// Game_System
// ロード時にピクチャ関連メンバを初期化します。
//=============================================================================
var _Game_System_onAfterLoad = Game_System.prototype.onAfterLoad;
Game_System.prototype.onAfterLoad = function() {
_Game_System_onAfterLoad.apply(this, arguments);
$gameScreen.initPictureArray();
};
//=============================================================================
// Game_Map
// ピクチャがタッチされたときのコモンイベント呼び出し処理を追加定義します。
//=============================================================================
var _Game_Map_setupStartingEvent = Game_Map.prototype.setupStartingEvent;
Game_Map.prototype.setupStartingEvent = function() {
var result = _Game_Map_setupStartingEvent.call(this);
return result || this.setupPictureCommonEvent();
};
var _Game_Map_updateInterpreter = Game_Map.prototype.updateInterpreter;
Game_Map.prototype.updateInterpreter = function() {
_Game_Map_updateInterpreter.apply(this, arguments);
this.setupPictureParallelCommonEvent();
};
Game_Map.prototype.setupPictureParallelCommonEvent = function() {
if (!paramAsParallelCommon) {
return;
}
var commonId = $gameTemp.pictureCommonId();
var event = $dataCommonEvents[commonId];
if (event) {
if (!this._pictureCommonEvents) {
this._pictureCommonEvents = [];
}
var interpreter = new Game_Interpreter();
interpreter.setupFromPicture(event.list, commonId);
this._pictureCommonEvents.push(interpreter);
$gameTemp.clearPictureCallInfo();
}
};
Game_Map.prototype.setupPictureCommonEvent = function() {
if (paramAsParallelCommon) {
return false;
}
var commonId = $gameTemp.pictureCommonId();
var event = $dataCommonEvents[commonId];
var result = false;
if (!this.isEventRunning() && event) {
this._interpreter.setupFromPicture(event.list, commonId);
result = true;
}
$gameTemp.clearPictureCallInfo();
return result;
};
var _Game_Map_updateEvents = Game_Map.prototype.updateEvents;
Game_Map.prototype.updateEvents = function() {
_Game_Map_updateEvents.apply(this, arguments);
if (this._pictureCommonEvents && this._pictureCommonEvents.length > 0) {
this.updatePictureCommonEvents();
}
};
Game_Map.prototype.updatePictureCommonEvents = function() {
this._pictureCommonEvents.forEach(function(event) {
event.update();
});
this._pictureCommonEvents = this._pictureCommonEvents.filter(function(event) {
return event.isRunning();
})
};
//=============================================================================
// Game_Troop
// ピクチャがタッチされたときのコモンイベント呼び出し処理を追加定義します。
//=============================================================================
Game_Troop.prototype.setupPictureCommonEvent = Game_Map.prototype.setupPictureCommonEvent;
Game_Troop.prototype.isExistPictureCommon = function() {
return this._interpreter.isSetupFromPicture();
};
//=============================================================================
// Game_Screen
// ピクチャに対応するコモンイベント呼び出し用のID配列を追加定義します。
//=============================================================================
var _Game_Screen_initialize = Game_Screen.prototype.initialize;
Game_Screen.prototype.initialize = function() {
_Game_Screen_initialize.apply(this, arguments);
this.initPictureArray();
};
Game_Screen.prototype.initPictureArray = function() {
this._pictureCidArray = this._pictureCidArray || [];
this._pictureSidArray = this._pictureSidArray || [];
this._picturePidArray = this._picturePidArray || [];
this._pictureTransparentArray = this._pictureTransparentArray || [];
};
var _Game_Screen_update = Game_Screen.prototype.update;
Game_Screen.prototype.update = function() {
_Game_Screen_update.apply(this, arguments);
this.updatePointer();
};
Game_Screen.prototype.updatePointer = function() {
if (paramGameVariableTouchX)
$gameVariables._data[paramGameVariableTouchX] = TouchInput.x;
if (paramGameVariableTouchY)
$gameVariables._data[paramGameVariableTouchY] = TouchInput.y;
};
Game_Screen.prototype.setPictureCallCommon = function(pictureId, touchParameter, trigger, transparent) {
var realPictureId = this.realPictureId(pictureId);
if (this._pictureCidArray[realPictureId] == null) this._pictureCidArray[realPictureId] = [];
this._pictureCidArray[realPictureId][trigger] = touchParameter;
this._pictureTransparentArray[realPictureId] = transparent;
};
Game_Screen.prototype.setPictureRemoveCommon = function(pictureId) {
this._pictureCidArray[this.realPictureId(pictureId)] = [];
};
Game_Screen.prototype.setPictureStroke = function(pictureId, variableNum, transparent) {
var realPictureId = this.realPictureId(pictureId);
this._pictureSidArray[realPictureId] = variableNum;
this._pictureTransparentArray[realPictureId] = transparent;
};
Game_Screen.prototype.removePictureStroke = function(pictureId) {
this._pictureSidArray[this.realPictureId(pictureId)] = null;
};
Game_Screen.prototype.setPicturePointer = function(pictureId) {
this._picturePidArray[this.realPictureId(pictureId)] = true;
};
Game_Screen.prototype.removePicturePointer = function(pictureId) {
this._picturePidArray[this.realPictureId(pictureId)] = null;
};
Game_Screen.prototype.getPictureCid = function(pictureId) {
return this._pictureCidArray[this.realPictureId(pictureId)];
};
Game_Screen.prototype.getPictureSid = function(pictureId) {
return this._pictureSidArray[this.realPictureId(pictureId)];
};
Game_Screen.prototype.getPicturePid = function(pictureId) {
return this._picturePidArray[this.realPictureId(pictureId)];
};
Game_Screen.prototype.getPictureTransparent = function(pictureId) {
return this._pictureTransparentArray[this.realPictureId(pictureId)];
};
Game_Screen.prototype.disConvertPositionX = function(x) {
var unshiftX = x - this.zoomX() * (1 - this.zoomScale());
return Math.round(unshiftX / this.zoomScale());
};
Game_Screen.prototype.disConvertPositionY = function(y) {
var unshiftY = y - this.zoomY() * (1 - this.zoomScale());
return Math.round(unshiftY / this.zoomScale());
};
Game_Screen.prototype.isPointerInnerPicture = function(pictureId) {
var picture = SceneManager.getPictureSprite(pictureId);
return picture ? picture.isIncludePointer() : false;
};
//=============================================================================
// SceneManager
// ピクチャスプライトを取得します。
//=============================================================================
SceneManager.getPictureSprite = function(pictureId) {
return this._scene.getPictureSprite(pictureId);
};
//=============================================================================
// BattleManager
// ピクチャコモンを常に実行できるようにします。
//=============================================================================
BattleManager.updatePictureCommon = function() {
if ($gameTroop.isExistPictureCommon() && paramAlwaysCommonInBattle) {
this.updateEventMain();
return true;
}
return false;
};
//=============================================================================
// Scene_Base
// ピクチャに対する繰り返し処理を追加定義します。
//=============================================================================
Scene_Base.prototype.updateTouchPictures = function() {
if (paramInvalidSwitchId && $gameSwitches.value(paramInvalidSwitchId)) {
return;
}
this._spriteset.iteratePictures(function(picture) {
if (typeof picture.callTouch === 'function') picture.callTouch();
return $gameTemp.pictureCommonId() === 0;
});
};
Scene_Base.prototype.getPictureSprite = function(pictureId) {
var result = null;
this._spriteset.iteratePictures(function(picture) {
if (picture.isIdEquals(pictureId)) {
result = picture;
return false;
}
return true;
});
return result;
};
//=============================================================================
// Scene_Map
// ピクチャのタッチ状態からのコモンイベント呼び出し予約を追加定義します。
//=============================================================================
var _Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
this.updateTouchPictures();
_Scene_Map_update.apply(this, arguments);
};
var _Scene_Map_processMapTouch = Scene_Map.prototype.processMapTouch;
Scene_Map.prototype.processMapTouch = function() {
_Scene_Map_processMapTouch.apply(this, arguments);
if ($gameTemp.isDestinationValid() && $gameTemp.pictureCommonId() > 0) {
$gameTemp.clearDestination();
}
};
var _Scene_Map_terminate = Scene_Map.prototype.terminate;
Scene_Map.prototype.terminate = function() {
_Scene_Map_terminate.apply(this, arguments);
$gameTemp.clearPictureCallInfo();
};
//=============================================================================
// Scene_Battle
// ピクチャのタッチ状態からのコモンイベント呼び出し予約を追加定義します。
//=============================================================================
var _Scene_Battle_update = Scene_Battle.prototype.update;
Scene_Battle.prototype.update = function() {
this.updateTouchPictures();
$gameTroop.setupPictureCommonEvent();
_Scene_Battle_update.apply(this, arguments);
};
var _Scene_Battle_updateBattleProcess = Scene_Battle.prototype.updateBattleProcess;
Scene_Battle.prototype.updateBattleProcess = function() {
var result = BattleManager.updatePictureCommon();
if (result) return;
_Scene_Battle_updateBattleProcess.apply(this, arguments);
};
var _Scene_Battle_terminate = Scene_Battle.prototype.terminate;
Scene_Battle.prototype.terminate = function() {
_Scene_Battle_terminate.apply(this, arguments);
$gameTemp.clearPictureCallInfo();
};
//=============================================================================
// Spriteset_Base
// ピクチャに対するイテレータを追加定義します。
//=============================================================================
Spriteset_Base.prototype.iteratePictures = function(callBackFund) {
var containerChildren = this._pictureContainer.children;
if (!Array.isArray(containerChildren)) {
iterate(this._pictureContainer, function(property) {
if (this._pictureContainer[property].hasOwnProperty('children')) {
containerChildren = this._pictureContainer[property].children;
this._iteratePicturesSub(containerChildren, callBackFund);
}
}.bind(this));
} else {
this._iteratePicturesSub(containerChildren, callBackFund);
}
};
Spriteset_Base.prototype._iteratePicturesSub = function(containerChildren, callBackFund) {
for (var i = containerChildren.length - 1; i >= 0; i--) {
if (!callBackFund(containerChildren[i])) {
break;
}
}
};
//=============================================================================
// Sprite_Picture
// ピクチャのタッチ状態からのコモンイベント呼び出し予約を追加定義します。
//=============================================================================
var _Sprite_Picture_initialize = Sprite_Picture.prototype.initialize;
Sprite_Picture.prototype.initialize = function(pictureId) {
_Sprite_Picture_initialize.call(this, pictureId);
this._triggerHandler = [];
this._triggerHandler[1] = this.isTriggered;
this._triggerHandler[2] = this.isCancelled;
this._triggerHandler[3] = this.isLongPressed;
this._triggerHandler[4] = this.isOnFocus;
this._triggerHandler[5] = this.isOutFocus;
this._triggerHandler[6] = this.isReleased;
this._triggerHandler[7] = this.isRepeated;
this._triggerHandler[8] = this.isPressed;
this._triggerHandler[9] = this.isWheelTriggered;
this._triggerHandler[10] = this.isDoubleTriggered;
this._triggerHandler[11] = this.isMoved;
this._triggerHandler[12] = this.isMovedAndPressed;
this._onMouse = false;
this._outMouse = false;
this._wasOnMouse = false;
};
var _Sprite_update = Sprite_Picture.prototype.update;
Sprite_Picture.prototype.update = function() {
_Sprite_update.apply(this, arguments);
this.updateTouch();
};
Sprite_Picture.prototype.updateTouch = function() {
this.updateMouseMove();
this.updateStroke();
this.updatePointer();
};
Sprite_Picture.prototype.updateMouseMove = function() {
if (this.isIncludePointer()) {
if (!this._wasOnMouse) {
this._onMouse = true;
this._wasOnMouse = true;
}
} else if (this._wasOnMouse) {
this._outMouse = true;
this._wasOnMouse = false;
}
};
Sprite_Picture.prototype.isIncludePointer = function() {
return this.isTouchable() && this.isTouchPosInRect() && !this.isTransparent();
};
Sprite_Picture.prototype.updateStroke = function() {
var strokeNum = $gameScreen.getPictureSid(this._pictureId);
if (strokeNum > 0 && TouchInput.isPressed() && this.isIncludePointer()) {
var value = $gameVariables.value(strokeNum);
$gameVariables.setValue(strokeNum, value + TouchInput.pressedDistance);
}
};
Sprite_Picture.prototype.updatePointer = function() {
var strokeNum = $gameScreen.getPicturePid(this._pictureId);
if (strokeNum > 0) {
this.opacity = TouchInput.isPressed() ? 255 : 0;
this.x = TouchInput.x;
this.y = TouchInput.y;
this.anchor.x = 0.5;
this.anchor.y = 0.5;
}
};
Sprite_Picture.prototype.callTouch = function() {
var commandIds = $gameScreen.getPictureCid(this._pictureId);
if (!commandIds || SceneManager.isNextScene(Scene_Battle)) {
return;
}
for (var i = 0, n = this._triggerHandler.length; i < n; i++) {
var handler = this._triggerHandler[i];
if (handler && commandIds[i] && handler.call(this) && (this.triggerIsFocus(i) || !this.isTransparent())) {
this.fireTouchEvent(commandIds, i);
}
}
};
Sprite_Picture.prototype.fireTouchEvent = function(commandIds, i) {
if (this.isTouchSuppress()) {
TouchInput.suppressEvents();
}
if (this.triggerIsLongPressed(i)) TouchInput._pressedTime = -60;
if (this.triggerIsOnFocus(i)) this._onMouse = false;
if (this.triggerIsOutFocus(i)) this._outMouse = false;
$gameTemp.onTouchPicture(commandIds[i], this._pictureId);
};
Sprite_Picture.prototype.isTouchSuppress = function() {
return paramSuppressTouchSwitch > 0 ? $gameSwitches.value(paramSuppressTouchSwitch) : paramSuppressTouch;
};
Sprite_Picture.prototype.triggerIsLongPressed = function(triggerId) {
return triggerId === 3;
};
Sprite_Picture.prototype.triggerIsOnFocus = function(triggerId) {
return triggerId === 4;
};
Sprite_Picture.prototype.triggerIsOutFocus = function(triggerId) {
return triggerId === 5;
};
Sprite_Picture.prototype.triggerIsFocus = function(triggerId) {
return this.triggerIsOnFocus(triggerId) || this.triggerIsOutFocus(triggerId);
};
Sprite_Picture.prototype.isTransparent = function() {
if (this.isTouchPosInFrameWindow()) return false;
if (!this.isValidTransparent()) return false;
if (this.opacity === 0) return true;
var dx = this.getTouchScreenX() - this.x;
var dy = this.getTouchScreenY() - this.y;
var sin = Math.sin(-this.rotation);
var cos = Math.cos(-this.rotation);
var bx = Math.floor(dx * cos + dy * -sin) / this.scale.x + this.anchor.x * this.width;
var by = Math.floor(dx * sin + dy * cos) / this.scale.y + this.anchor.y * this.height;
return this.bitmap.getAlphaPixel(bx, by) === 0;
};
Sprite_Picture.prototype.isValidTransparent = function() {
var transparent = $gameScreen.getPictureTransparent(this._pictureId);
return transparent !== null ? transparent : paramTransparentConsideration;
};
Sprite_Picture.prototype.screenWidth = function() {
return (this.width || 0) * this.scale.x;
};
Sprite_Picture.prototype.screenHeight = function() {
return (this.height || 0) * this.scale.y;
};
Sprite_Picture.prototype.screenX = function() {
return (this.x || 0) - this.anchor.x * this.screenWidth();
};
Sprite_Picture.prototype.screenY = function() {
return (this.y || 0) - this.anchor.y * this.screenHeight();
};
Sprite_Picture.prototype.minX = function() {
return Math.min(this.screenX(), this.screenX() + this.screenWidth());
};
Sprite_Picture.prototype.minY = function() {
return Math.min(this.screenY(), this.screenY() + this.screenHeight());
};
Sprite_Picture.prototype.maxX = function() {
return Math.max(this.screenX(), this.screenX() + this.screenWidth());
};
Sprite_Picture.prototype.maxY = function() {
return Math.max(this.screenY(), this.screenY() + this.screenHeight());
};
Sprite_Picture.prototype.isTouchPosInRect = function() {
if (this.isTouchPosInFrameWindow()) return true;
var dx = this.getTouchScreenX() - this.x;
var dy = this.getTouchScreenY() - this.y;
var sin = Math.sin(-this.rotation);
var cos = Math.cos(-this.rotation);
var rx = this.x + Math.floor(dx * cos + dy * -sin);
var ry = this.y + Math.floor(dx * sin + dy * cos);
return (rx >= this.minX() && rx <= this.maxX() && ry >= this.minY() && ry <= this.maxY());
};
Sprite_Picture.prototype.isTouchPosInFrameWindow = function() {
if (!this._frameWindow) return false;
var frame = this._frameWindow;
var x = this.getTouchScreenX();
var y = this.getTouchScreenY();
return frame.x <= x && frame.x + frame.width >= x && frame.y <= y && frame.y + frame.height >= y;
};
Sprite_Picture.prototype.isTouchable = function() {
return this.bitmap && this.visible && this.scale.x !== 0 && this.scale.y !== 0;
};
Sprite_Picture.prototype.isTriggered = function() {
return this.isTouchEvent(TouchInput.isTriggered);
};
Sprite_Picture.prototype.isCancelled = function() {
return this.isTouchEvent(TouchInput.isCancelled);
};
Sprite_Picture.prototype.isLongPressed = function() {
return this.isTouchEvent(TouchInput.isLongPressed);
};
Sprite_Picture.prototype.isPressed = function() {
return this.isTouchEvent(TouchInput.isPressed);
};
Sprite_Picture.prototype.isReleased = function() {
return this.isTouchEvent(TouchInput.isReleased);
};
Sprite_Picture.prototype.isRepeated = function() {
return this.isTouchEvent(TouchInput.isRepeated);
};
Sprite_Picture.prototype.isOnFocus = function() {
return this._onMouse;
};
Sprite_Picture.prototype.isOutFocus = function() {
return this._outMouse;
};
Sprite_Picture.prototype.isMoved = function() {
return this.isTouchEvent(TouchInput.isMoved);
};
Sprite_Picture.prototype.isMovedAndPressed = function() {
return this.isTouchEvent(TouchInput.isMoved) && TouchInput.isPressed();
};
Sprite_Picture.prototype.isWheelTriggered = function() {
return this.isTouchEvent(TouchInput.isWheelTriggered);
};
Sprite_Picture.prototype.isDoubleTriggered = function() {
return this.isTouchEvent(TouchInput.isDoubleTriggered);
};
Sprite_Picture.prototype.isTouchEvent = function(triggerFunc) {
return this.isTouchable() && triggerFunc.call(TouchInput) && this.isTouchPosInRect();
};
Sprite_Picture.prototype.getTouchScreenX = function() {
return $gameScreen.disConvertPositionX(TouchInput.x);
};
Sprite_Picture.prototype.getTouchScreenY = function() {
return $gameScreen.disConvertPositionY(TouchInput.y);
};
Sprite_Picture.prototype.isIdEquals = function(pictureId) {
return this._pictureId === pictureId;
};
//=============================================================================
// Input
// ピクチャクリックをキー入力に紐付けます。
//=============================================================================
Input._bindKeyStateFrames = new Map();
Input.bindKeyState = function(name) {
this._currentState[name] = true;
this._bindKeyStateFrames.set(name, 5);
};
var _Input_update = Input.update;
Input.update = function() {
_Input_update.apply(this, arguments);
this._updateBindKeyState();
};
Input._updateBindKeyState = function() {
this._bindKeyStateFrames.forEach(function(frame, keyName) {
frame--;
if (frame === 0 || !this._currentState[keyName]) {
this._currentState[keyName] = false;
this._bindKeyStateFrames.delete(keyName);
} else {
this._bindKeyStateFrames.set(keyName, frame);
}
}, this);
};
//=============================================================================
// TouchInput
// ホイールクリック、ダブルクリック等を実装
//=============================================================================
TouchInput.keyDoubleClickInterval = 300;
TouchInput._pressedDistance = 0;
TouchInput._prevX = -1;
TouchInput._prevY = -1;
Object.defineProperty(TouchInput, 'pressedDistance', {
get : function() {
return this._pressedDistance;
},
configurable: true
});
TouchInput.suppressEvents = function() {
this._triggered = false;
this._cancelled = false;
this._released = false;
this._wheelTriggered = false;
this._doubleTriggered = false;
};
TouchInput._onMouseMove = function(event) {
var x = Graphics.pageToCanvasX(event.pageX);
var y = Graphics.pageToCanvasY(event.pageY);
this._onMove(x, y);
};
var _TouchInput_clear = TouchInput.clear;
TouchInput.clear = function() {
_TouchInput_clear.apply(this, arguments);
this._events.wheelTriggered = false;
this._events.doubleTriggered = false;
};
var _TouchInput_update = TouchInput.update;
TouchInput.update = function() {
_TouchInput_update.apply(this, arguments);
this._wheelTriggered = this._events.wheelTriggered;
this._doubleTriggered = this._events.doubleTriggered;
this._events.wheelTriggered = false;
this._events.doubleTriggered = false;
};
TouchInput.isWheelTriggered = function() {
return this._wheelTriggered;
};
TouchInput.isDoubleTriggered = function() {
return this._doubleTriggered;
};
var _TouchInput_onMiddleButtonDown = TouchInput._onMiddleButtonDown;
TouchInput._onMiddleButtonDown = function(event) {
_TouchInput_onMiddleButtonDown.apply(this, arguments);
var x = Graphics.pageToCanvasX(event.pageX);
var y = Graphics.pageToCanvasY(event.pageY);
if (Graphics.isInsideCanvas(x, y)) {
this._onWheelTrigger(x, y);
}
};
TouchInput._onWheelTrigger = function(x, y) {
this._events.wheelTriggered = true;
this._x = x;
this._y = y;
};
var _TouchInput_onTrigger = TouchInput._onTrigger;
TouchInput._onTrigger = function(x, y) {
if (this._date && Date.now() - this._date < this.keyDoubleClickInterval)
this._events.doubleTriggered = true;
this._pressedDistance = 0;
this._prevX = x;
this._prevY = y;
_TouchInput_onTrigger.apply(this, arguments);
};
var _TouchInput_onMove = TouchInput._onMove;
TouchInput._onMove = function(x, y) {
if (this.isPressed()) this._pressedDistance = Math.abs(this._prevX - x) + Math.abs(this._prevY - y);
this._prevX = x;
this._prevY = y;
_TouchInput_onMove.apply(this, arguments);
};
var _TouchInput_onRelease = TouchInput._onRelease;
TouchInput._onRelease = function(x, y) {
this._pressedDistance = 0;
this._prevX = x;
this._prevY = y;
_TouchInput_onRelease.apply(this, arguments);
};
})();
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1