//============================================================================= // ShakeOnDamage.js // ---------------------------------------------------------------------------- // (C)2017 Triacontane // This software is released under the MIT License. // http://opensource.org/licenses/mit-license.php // ---------------------------------------------------------------------------- // Version // 1.2.0 2019/05/02 敵キャラのダメージ時にもシェイクさせる機能、弱点攻撃時にシェイクさせる機能を追加 // 1.1.1 2018/03/04 YEP_BattleEngineCore.jsとの競合を解消 // 1.1.0 2017/08/19 パラメータに計算式を使用できる機能を追加 // 1.0.0 2017/08/13 初版 // ---------------------------------------------------------------------------- // [Blog] : https://triacontane.blogspot.jp/ // [Twitter]: https://twitter.com/triacontane/ // [GitHub] : https://github.com/triacontane/ //============================================================================= /*: @url https://triacontane.blogspot.com/ @plugindesc Vibration plugin when damaged @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 ----- ShakeOnDamage.js Vibrates the screen when an actor takes damage in battle. You can vary the strength of the vibration between critical and normal damage. You can apply a calculation formula to each parameter. The following can also be used as local variables: a: The actor that received the damage. r: The remaining HP percentage of the actor that received the damage (0-100). To enter a calculation formula, select the "Text" tab in the parameter settings dialog. This plugin does not have a plugin command. 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 シェイク強さ @text Shake Strength @desc This is the strength of the shake when normal damage is received. @type number @default 5 @min 1 @max 9 @param クリティカルシェイク強さ @text Critical Shake Strength @desc The strength of the shake when receiving critical damage. @type number @default 9 @min 1 @max 9 @param 弱点シェイク強さ @text Weakness Shake Strength @desc The strength of the shake when receiving weak point damage. @type number @default 9 @min 1 @max 9 @param シェイク速さ @text Shake speed @desc It's the speed of the shake. @type number @default 9 @min 1 @max 9 @param シェイク時間 @text Shake Time @desc Shake time (frames). @type number @default 30 @param アクターに適用 @text Applies to Actors @desc Shake when actor takes damage. @type boolean @default true @param 敵キャラに適用 @text Applies to enemy characters @desc Shake when enemy characters take damage. @type boolean @default false */ /*:ja @plugindesc ダメージ時の振動プラグイン @author トリアコンタン @param シェイク強さ @desc 通常ダメージを受けたときのシェイク強さです。 @default 5 @type number @min 1 @max 9 @param クリティカルシェイク強さ @desc クリティカルダメージを受けたときのシェイク強さです。 @default 9 @type number @min 1 @max 9 @param 弱点シェイク強さ @desc 弱点ダメージを受けたときのシェイク強さです。 @default 9 @type number @min 1 @max 9 @param シェイク速さ @desc シェイク速さです。 @default 9 @type number @min 1 @max 9 @param シェイク時間 @desc シェイク時間(フレーム)です。 @default 30 @type number @param アクターに適用 @desc アクターのダメージ時にシェイクします。 @default true @type boolean @param 敵キャラに適用 @desc 敵キャラのダメージ時にシェイクします。 @default false @type boolean @help ShakeOnDamage.js 戦闘でアクターがダメージを受けたときに画面を振動させます。 クリティカル時と通常時とで強さを変えることができます。 各パラメータには計算式を適用できます。 さらにローカル変数として以下が使用可能です。 a : ダメージを受けた対象のアクターです。 r : ダメージを受けた対象のアクターの残りHP率(0-100)です。 計算式を入力する場合はパラメータ設定ダイアログで「テキスト」タブを 選択してから入力してください。 このプラグインにはプラグインコマンドはありません。 利用規約: 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等) についても制限はありません。 このプラグインはもうあなたのものです。 */ (function () { 'use strict'; var pluginName = 'ShakeOnDamage'; //============================================================================= // ローカル関数 // プラグインパラメータやプラグインコマンドパラメータの整形やチェックをします //============================================================================= 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; } return ''; }; var getParamBoolean = function (paramNames) { var value = getParamString(paramNames).toUpperCase(); return value === 'TRUE'; }; var convertEscapeCharacters = function (text) { if (isNotAString(text)) text = ''; var windowLayer = SceneManager._scene._windowLayer; return windowLayer ? windowLayer.children[0].convertEscapeCharacters(text) : text; }; var isNotAString = function (args) { return String(args) !== args; }; //============================================================================= // パラメータの取得と整形 //============================================================================= var param = {}; param.shakePower = getParamString(['ShakePower', 'シェイク強さ']); param.criticalShakePower = getParamString(['CriticalShakePower', 'クリティカルシェイク強さ']); param.effectiveShakePower = getParamString(['EffectiveShakePower', '弱点シェイク強さ']); param.shakeSpeed = getParamString(['ShakeSpeed', 'シェイク速さ']); param.shakeDuration = getParamString(['ShakeDuration', 'シェイク時間']); param.applyActor = getParamBoolean(['ApplyActor', 'アクターに適用']); param.applyEnemy = getParamBoolean(['ApplyEnemy', '敵キャラに適用']); //============================================================================= // Game_Battler // クリティカル判定を記憶します。 //============================================================================= Game_Battler.prototype.setCriticalForShake = function (value) { this._criticalForShake = value; }; Game_Battler.prototype.isCriticalForShake = function () { return this._criticalForShake; }; Game_Battler.prototype.setEffectiveForShake = function (value) { this._effectiveForShake = value; }; Game_Battler.prototype.isEffectiveForShake = function () { return this._effectiveForShake; }; var _Game_Battler_performDamage = Game_Battler.prototype.performDamage; Game_Battler.prototype.performDamage = function () { _Game_Battler_performDamage.apply(this, arguments); if (this.isShakeOnDamage()) { this.shakeOnDamage(); } }; Game_Battler.prototype.shakeOnDamage = function () { var power = this.getDamageShakePower(); var speed = this.convertShakeParameter(param.shakeSpeed); var duration = this.convertShakeParameter(param.shakeDuration); $gameScreen.startShake(power, speed, duration); this.setCriticalForShake(false); }; Game_Battler.prototype.getDamageShakePower = function () { var power = param.shakePower; if (param.criticalShakePower && this.isCriticalForShake()) { power = param.criticalShakePower; } else if (param.effectiveShakePower && this.isEffectiveForShake()) { power = param.effectiveShakePower; } return this.convertShakeParameter(power); }; Game_Battler.prototype.convertShakeParameter = function (param) { var convertParam = convertEscapeCharacters(param); // use in eval var a = this; var r = a.hpRate() * 100; return isNaN(Number(convertParam)) ? eval(convertParam) : parseInt(convertParam); }; Game_Battler.prototype.isShakeOnDamage = function () { return false; }; Game_Actor.prototype.isShakeOnDamage = function () { return param.applyActor; }; Game_Enemy.prototype.isShakeOnDamage = function () { return param.applyEnemy; }; //============================================================================= // Game_Action // クリティカル判定を記憶します。 //============================================================================= var _Game_Action_makeDamageValue = Game_Action.prototype.makeDamageValue; Game_Action.prototype.makeDamageValue = function (target, critical) { target.setCriticalForShake(critical); return _Game_Action_makeDamageValue.apply(this, arguments); }; var _Game_Action_calcElementRate = Game_Action.prototype.calcElementRate; Game_Action.prototype.calcElementRate = function (target) { var result = _Game_Action_calcElementRate.apply(this, arguments); target.setEffectiveForShake(result > 1.0); return result; }; })();