-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnemySpecialActionSwitch.js
89 lines (84 loc) · 2.66 KB
/
EnemySpecialActionSwitch.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
//=============================================================================
// RPG Maker MZ - Switches to let enemy characters do a specific action
//=============================================================================
/*:
* @target MZ
* @plugindesc Switches to let enemy characters do a specific action
* @author MihailJP
* @url https://github.com/MihailJP/mihamzplugin/blob/master/EnemySpecialActionSwitch.js
*
* @help EnemySpecialActionSwitch.js
*
* This plugin implements switches to let enemy characters do a specific action.
* They are updated each time before an action (regardless of an enemy or an ally).
*
* It does not provide plugin commands.
*
* @param switchList
* @text List of switches
* @desc List of switches corresponding conditions.
* @default []
* @type struct<ConditionSwitch>[]
*
*/
/*~struct~ConditionSwitch:
*
* @param switchId
* @text Switch
* @desc Specify a switch to be paired with a condition.
* @type switch
*
* @param condition
* @text Condition
* @desc Specify a Javascript code to be paired with a switch. The code must be evaluated to boolean.
* @type string
*
*/
/*:ja
* @target MZ
* @plugindesc 敵キャラクターに特定の行動を取らせるスイッチ
* @author MihailJP
* @url https://github.com/MihailJP/mihamzplugin/blob/master/EnemySpecialActionSwitch.js
*
* @help EnemySpecialActionSwitch.js
*
* このプラグインは、敵キャラクターに特定の行動を取らせるスイッチを実装します。
* (敵味方関係なく)行動の前に更新されます。
*
* プラグインコマンドはありません。
*
* @param switchList
* @text スイッチリスト
* @desc 条件に対応付けられたスイッチのリストです。
* @default []
* @type struct<ConditionSwitch>[]
*
*/
/*~struct~ConditionSwitch:ja
*
* @param switchId
* @text スイッチ
* @desc 条件に対応させるスイッチを指定します。
* @type switch
*
* @param condition
* @text 条件
* @desc スイッチに対応させる条件をJavascriptのコードで指定します。
* @type string
*
*/
(() => {
const pluginName = "EnemySpecialActionSwitch";
const param = PluginManager.parameters(pluginName);
const switches = JSON.parse(param.switchList)
.map(sw => JSON.parse(sw))
.map(sw => {sw.switchId = parseInt(sw.switchId); return sw;});
const updateSwitches = function() {
switches.forEach(sw => $gameSwitches.setValue(sw.switchId, Boolean(eval(sw.condition))));
};
const orig_Game_Battler_makeActions = Game_Battler.prototype.makeActions;
Game_Battler.prototype.makeActions = function() {
updateSwitches();
orig_Game_Battler_makeActions.call(this);
};
})();