//============================================================================= // SnakeFollower.js // ---------------------------------------------------------------------------- // Copyright (c) 2015-2017 Triacontane // This software is released under the MIT License. // http://opensource.org/licenses/mit-license.php // ---------------------------------------------------------------------------- // Version // 1.0.0 2017/09/26 初版 // ---------------------------------------------------------------------------- // [Blog] : https://triacontane.blogspot.jp/ // [Twitter]: https://twitter.com/triacontane/ // [GitHub] : https://github.com/triacontane/ //============================================================================= /*: @url https://triacontane.blogspot.com/ @plugindesc Snake Follower Plugin @author Triacontane @license MIT License @help English Help Translator: munokura This is an unofficial English translation of the plugin help, created to support global RPG Maker users. Feedback is welcome to improve translation quality (see: https://github.com/munokura/triacontane-MV-plugins ). Original plugin by Triacontane. Please check the latest official version at: https://triacontane.blogspot.com ----- SnakeFollower.js Prevents followers and players from overlapping. Can be used to implement snake games. This plugin does not have any plugin commands. Terms of Use: You may modify and redistribute this plugin without permission from the author, and there are no restrictions on its use (commercial, 18+, etc.). This plugin is now yours. @param 有効スイッチID @text Valid Switch ID @desc The switch number that enables the plugin function. If you specify 0, it will always be enabled. @type switch @default 0 */ /*:ja @plugindesc スネークフォロワープラグイン @author トリアコンタン @param 有効スイッチID @desc プラグインの機能が有効になるスイッチ番号です。0を指定すると常に有効となります。 @default 0 @type switch @help SnakeFollower.js フォロワーとプレイヤーが重なることができなくなります。 スネークゲームの実装に使えます。 このプラグインにはプラグインコマンドはありません。 利用規約: 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等) についても制限はありません。 このプラグインはもうあなたのものです。 */ (function () { 'use strict'; var pluginName = 'SnakeFollower'; //============================================================================= // ローカル関数 // プラグインパラメータやプラグインコマンドパラメータの整形やチェックをします //============================================================================= var getParamString = 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; } alert('Fail to load plugin parameter of ' + pluginName); return null; }; var getParamNumber = function (paramNames, min, max) { var value = getParamString(paramNames); if (arguments.length < 2) min = -Infinity; if (arguments.length < 3) max = Infinity; return (parseInt(value) || 0).clamp(min, max); }; //============================================================================= // パラメータの取得と整形 //============================================================================= var param = {}; param.validateSwitchId = getParamNumber(['ValidateSwitchId', '有効スイッチID'], 0); var _Game_Player_isCollidedWithCharacters = Game_Player.prototype.isCollidedWithCharacters; Game_Player.prototype.isCollidedWithCharacters = function (x, y) { return _Game_Player_isCollidedWithCharacters.apply(this, arguments) || this.isCollidedWithFollowers(x, y); }; Game_Player.prototype.isCollidedWithFollowers = function (x, y) { return this.isValidSnake() && this._followers.isSomeoneCollided(x, y) && !this.isThrough(); }; Game_Player.prototype.isValidSnake = function (x, y) { return param.validateSwitchId === 0 || $gameSwitches.value(param.validateSwitchId); }; })();