-
Notifications
You must be signed in to change notification settings - Fork 1
/
EncountController.js
131 lines (128 loc) · 5.08 KB
/
EncountController.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//=============================================================================
// EncountController.js
//=============================================================================
/*:
* @plugindesc Tuning encount rate
* @author Tamaki Awana
* @help Depending on the value assigned to the set variable,
* and adjust the encounter rate automatically.
* The standard formula has a lower encounter frequency
* than the RPG Maker default,
* -- 0 to Maximum value of random number
* + Appearance number of steps of the enemy on the map.
*
*
* How to use:
* Input these values into variable setted at EncountVariable,
* change a formula for encount rate soon.
* 0:default
* (0 to Maximum value of random number
* + Appearance number of steps of the enemy on the map)
* 1:Few
* ((0 to Maximum value of random number)*2
* + Appearance number of steps of the enemy on the map)
* 2:Many(RPG Maker default)
* If you want to fine-tune the calculation formula or
* increase the setting items, modify the source code of this plugin.
*
* Plugin Commands:
* This plugin does not provide plugin commands.
*
* Update History:
* ver.1.1.1 English Supported
* ver.1.1 Bug fix : Encounter endlessly if no EncountVariable is set
* ver.1.0.2 Code optimize
* ver.1.0.1 Paramater Settings optimize
* ver.1.0 Release
*
* ---
*
* This plugin is released under MIT license.
* https://opensource.org/licenses/mit-license.php
*
* This plugin is based on a "RPGツクールMVで感動ものを作る。"
* that kotonoha*'s blog article
* "ストレスフリーなランダムエンカウントを目指す"
* (http://ktnhmv.jugem.jp/?eid=8).
* Thanks to kotonoha*.
*
*
* @param EncountVariable
* @desc Setting variable for encount rate judging.
* @type variable
* @default 0
*
* @param EncountRate
* @desc Maximum value of random number for tuning encount rate.
* @type number
* @min 0
* @default 5
*/
/*:ja
* @plugindesc エンカウント率を調整します。
* @author 沫那環
* @help 設定した変数に代入された値に応じて、自動でエンカウント率を調整します。
* 標準の計算式は、ツクール標準のものよりエンカウントの頻度が抑えられた、
* 0~乱数の最大値 + マップに設定された敵出現歩数
* となります。
*
* 【使い方】
* EncountVariableで設定した変数に、以下の値を代入すると、
* エンカウント率を算出する式をその場で変更することができます。
* 0:標準(0~乱数の最大値 + マップに設定された敵出現歩数)
* 1:少な目(0~乱数の最大値*2 + マップに設定された敵出現歩数)
* 2:多め(ツクール標準)
* 計算式をもっと細かく調節したい場合や、
* もっと設定項目を増やしたい場合は、このプラグインのソースコードを
* 改変してください。
*
* 【プラグインコマンドについて】
* このプラグインには、プラグインコマンドはありません。
*
* 【更新履歴】
* ver.1.1.1 英語に対応
* ver.1.1 EncountVariableが設定されていないと勝手にエンカウントするバグを修正
* ver.1.0.2 コードを最適化
* ver.1.0.1 パラメータの設定を最適化
* ver.1.0 公開
*
* ---
* このプラグインは MIT License にもとづいて提供されます。
* https://opensource.org/licenses/mit-license.php
*
* このプラグインを制作するにあたり、kotonoha*さんのブログ
* 「RPGツクールMVで感動ものを作る。」の記事
* 「ストレスフリーなランダムエンカウントを目指す」を参考にしました。
* http://ktnhmv.jugem.jp/?eid=8
* この場を借りて、御礼を申し上げます。
*
*
* @param EncountVariable
* @desc エンカウント率の調整を判定する変数を設定します。
* @type variable
* @default 0
*
* @param EncountRate
* @desc エンカウント率を調整する乱数の最大値
* @type number
* @min 0
* @default 5
*/
(function() {
var pluginName = decodeURIComponent(document.currentScript.src).match(/([^\/]+)\.js$/)[1];
var parameters = PluginManager.parameters(pluginName);
var EncountVariable = Number(parameters['EncountVariable'] || 0);
var EncountRate = Number(parameters['EncountRate'] || 5);
if (EncountVariable) {
Game_Player.prototype.makeEncounterCount = function() {
var n = $gameMap.encounterStep();
if ($gameVariables.value(EncountVariable) === 0) {
this._encounterCount = Math.randomInt(EncountRate) + n;
} else if ($gameVariables.value(EncountVariable) === 1) {
this._encounterCount = (Math.randomInt(EncountRate) * 2) + n;
} else if ($gameVariables.value(EncountVariable) === 2) {
this._encounterCount = Math.randomInt(EncountRate) + Math.randomInt(EncountRate) + 1;
}
};
};
})();