-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRDM_MultiTarget.js
205 lines (184 loc) · 7.23 KB
/
RDM_MultiTarget.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
//=============================================================================
// RDM_MultiTarget.js
//=============================================================================
var Imported = Imported || {};
Imported.RDM_MultiTarget = true;
var Radium = Radium || {};
Radium.MT = Radium.MT || {};
Radium.MT.version = 1.00;
//=============================================================================
/*:
* @plugindesc v1.00 敵選択を複数化できるようにします。
* @author Radian Kakudo
*
* @help
* ============================================================================
* Introduction
* ============================================================================
*
* このプラグインはターゲット選択時に複数(重複可能)の対象を指定することを可能にします。
*
* ============================================================================
* Battle Messages
* ============================================================================
*
* Skill and Item Notetags:
*
* <MultiTarget: x>
* x体を対象とします。記載しなかった場合は1体になります。
*
* ============================================================================
* Changelog
* ============================================================================
*
* Version 1.00:
* - 初版
*/
//=============================================================================
//=============================================================================
// DataManager
//=============================================================================
Radium.MT.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!Radium.MT.DataManager_isDatabaseLoaded.call(this)) return false;
if (!Radium._loaded_RDM_MultiTarget) {
this.processGetNoteTargetNum($dataSkills);
this.processGetNoteTargetNum($dataItems);
Radium._loaded_RDM_MultiTarget = true;
}
return true;
};
DataManager.processGetNoteTargetNum = function(group) {
var noteMt = /<(?:MultiTarget):[ ](\d+)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group[n];
obj.targetNum = 1;
var notedata = obj.note.split(/[\r\n]+/);
for (var i = 0; i < notedata.length; i++) {
var line = notedata[i];
if (line.match(noteMt)) {
obj.targetNum = parseInt(RegExp.$1);
}
}
}
};
//=============================================================================
// Game_Action
//=============================================================================
Radium.MT.Game_Action_initialize = Game_Action.prototype.initialize;
Game_Action.prototype.initialize = function(subject, forcing) {
this._multiTargets = [];
this._selectedNum = 0;
Radium.MT.Game_Action_initialize.call(this, subject, forcing);
};
Radium.MT.Game_Action_targetsForFriends = Game_Action.prototype.targetsForFriends;
Game_Action.prototype.targetsForFriends = function() {
if (this._multiTargets != null && this._multiTargets.length > 1) {
var targets = [];
var unit = this.friendsUnit();
for (i=0; i<this._multiTargets.length; i++) {
targets.push(unit.smoothTarget(this._multiTargets[i]));
}
return targets;
}
return Radium.MT.Game_Action_targetsForFriends.call(this);
};
Radium.MT.Game_Action_targetsForOpponents = Game_Action.prototype.targetsForOpponents;
Game_Action.prototype.targetsForOpponents = function() {
if (this._multiTargets != null && this._multiTargets.length > 1) {
var targets = [];
var unit = this.opponentsUnit();
for (i=0; i<this._multiTargets.length; i++) {
targets.push(unit.smoothTarget(this._multiTargets[i]));
}
return targets;
}
return Radium.MT.Game_Action_targetsForOpponents.call(this);
};
Game_Action.prototype.addTarget = function(targetIndex) {
this._multiTargets.push(targetIndex);
};
Game_Action.prototype.clearTarget = function(targetIndex) {
this._multiTargets = [];
};
//=============================================================================
// Scene_Battle
//=============================================================================
Radium.MT.Scene_Battle_onActorOk = Scene_Battle.prototype.onActorOk;
Scene_Battle.prototype.onActorOk = function() {
var action = BattleManager.inputtingAction();
var tIndex = this._actorWindow.index();
action.addTarget(tIndex);
action._selectedNum += 1;
var targetNum = action._item.object().targetNum;
if (targetNum <= action._selectedNum) {
Radium.MT.Scene_Battle_onActorOk.call(this);
this._multiSelectTargetWindow.hide();
} else {
var rebuildIndex = this._enemyWindow.index();
this._actorWindow.refresh();
this._actorWindow.show();
this._actorWindow.select(rebuildIndex);
this._actorWindow.activate();
this.RDM_refreshMultiTargetWindow(action);
}
};
Radium.MT.Scene_Battle_onEnemyOk = Scene_Battle.prototype.onEnemyOk;
Scene_Battle.prototype.onEnemyOk = function() {
var action = BattleManager.inputtingAction();
var tIndex = this._enemyWindow.enemyIndex();
action.addTarget(tIndex);
action._selectedNum += 1;
var targetNum = action._item.object().targetNum;
if (targetNum <= action._selectedNum) {
Radium.MT.Scene_Battle_onEnemyOk.call(this);
this._multiSelectTargetWindow.hide();
} else {
var rebuildIndex = this._enemyWindow.index();
this._enemyWindow.refresh();
this._enemyWindow.show();
this._enemyWindow.select(rebuildIndex);
this._enemyWindow.activate();
this.RDM_refreshMultiTargetWindow(action);
}
};
Radium.MT.Scene_Battle_onActorCancel = Scene_Battle.prototype.onActorCancel;
Scene_Battle.prototype.onActorCancel = function() {
Radium.MT.Scene_Battle_onActorCancel.call(this);
this._multiSelectTargetWindow.hide();
};
Radium.MT.Scene_Battle_onEnemyCancel = Scene_Battle.prototype.onEnemyCancel;
Scene_Battle.prototype.onEnemyCancel = function() {
Radium.MT.Scene_Battle_onEnemyCancel.call(this);
this._multiSelectTargetWindow.hide();
};
Radium.MT.Scene_Battle_selectActorSelection = Scene_Battle.prototype.selectActorSelection;
Scene_Battle.prototype.selectActorSelection = function() {
Radium.MT.Scene_Battle_selectActorSelection.call(this);
this.RDM_createMultiTargetWindow();
};
Radium.MT.Scene_Battle_selectEnemySelection = Scene_Battle.prototype.selectEnemySelection;
Scene_Battle.prototype.selectEnemySelection = function() {
Radium.MT.Scene_Battle_selectEnemySelection.call(this);
this.RDM_createMultiTargetWindow();
};
Scene_Battle.prototype.RDM_createMultiTargetWindow = function() {
var wy = 300;
var ww = 150;
var wh = 70;
var wx = 1000 - ww;
this._multiSelectTargetWindow = new Window_Base(wx, wy, ww, wh);
var action = BattleManager.inputtingAction();
action.clearTarget();
action._selectedNum = 0;
this.RDM_refreshMultiTargetWindow(action);
this.addWindow(this._multiSelectTargetWindow);
};
Scene_Battle.prototype.RDM_refreshMultiTargetWindow = function(action) {
var targetNum = action._item.object().targetNum;
this._multiSelectTargetWindow.contents.clear();
this._multiSelectTargetWindow.drawText(action._selectedNum + " / " + targetNum, 0, 0, 100, "right");
};
//=============================================================================
// End of File
//=============================================================================