-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathRS_MoreEnemies.js
303 lines (288 loc) · 8.49 KB
/
RS_MoreEnemies.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
//================================================================
// RS_MoreEnemies.js
// ---------------------------------------------------------------
// The MIT License
// Copyright (c) 2018 biud436
// ---------------------------------------------------------------
// Free for commercial and non commercial use.
//================================================================
/*:
* @plugindesc This plugin allows you to add a lot of enemies. <RS_MoreEnemies>
* @author biud436
*
* @param Troop Settings
* @type struct<Troop>[]
* @desc Add the more enemies settings as you want!
* @default []
*
* @help
* ======================================================
* Change Log
* ======================================================
* 2018.08.31 (v1.0.0) - First Release.
* 2018.08.31 (v1.0.1) :
* - Now this plugin will be included the struct named Enemy Reposition in the plugin parameter called Troop Settings.
* 2022.05.08 (v1.0.2) :
* - migrated to ES6
*/
/*~struct~Troop:
*
* @param troopId
* @type troop
* @min 1
* @desc Specify troop's ID.
* @default 1
*
* @param moreEnemies
* @type struct<Enemy>[]
* @desc Add a new enemy in their troop and set up the position.
* @default ["{\"enemyId\":\"1\",\"x\":\"300\",\"y\":\"200\",\"hidden\":\"false\"}"]
*
* @param enemyReposition
* @type struct<EnemyReposition>
* @desc if you need to set up enemies' location automatically? it is here.
* @default {"reposition":"false","width":"4","height":"6","x":"96 + (96 * x);","y":"Graphics.boxHeight / 3 + (96 * y);"}
*
*/
/*~struct~Enemy:
*
* @param enemyId
* @text enemyId
* @type enemy
* @desc Specify the ID for enemy.
* @default 1
*
* @param x
* @text x
* @type number
* @min 0
* @desc Specify the screen x position for enemy
* @default 300
*
* @param y
* @text y
* @type number
* @min 0
* @desc Specify the screen y position for enemy
* @default 200
*
* @param hidden
* @type boolean
* @desc Visible or hidden settings. this sets up as the hiding state basically. This state can be changed later
* @default false
* @on true
* @off false
*
*/
/*~struct~EnemyReposition:
*
* @param reposition
* @type boolean
* @desc if you are added a lot of monsters to your game? to use this, it could set the location automatically.
* @default false
* @on true
* @off false
*
* @param width
* @type number
* @desc The field is represented by a two-dimensional array. I used a double loop to set its location in the entries.
* @default 4
* @min 3
*
* @param height
* @type number
* @desc The field is represented by a two-dimensional array. I used a double loop to set its location in the entries.
* @default 6
* @min 3
*
* @param x
* @desc make it possible for the game to place enemies' x position when initializing the combat.
* @default 96 + (96 * x);
*
* @param y
* @desc make it possible for the game to place enemies' y position when initializing the combat.
* @default Graphics.boxHeight / 3 + (96 * y);
*
*/
/*:ko
* @plugindesc <RS_MoreEnemies>
* @author biud436
*
* @param Troop Settings
* @text 적 그룹 설정
* @type struct<Troop>[]
* @desc 적 그룹을 설정하십시오.
* @default []
*
* @help
* ======================================================
* Change Log
* ======================================================
* 2018.08.31 (v1.0.0) - First Release.
* 2018.08.31 (v1.0.1) - 적 그룹 매개변수 안에 위치 재설정 기능이 포함되게 수정하였습니다.
* 2022.05.08 (v1.0.2) :
* - migrated to ES6
*/
/*~struct~Troop:ko
*
* @param troopId
* @text 적 그룹 ID
* @type troop
* @min 1
* @desc 적 군단(적 그룹)의 ID 값을 선택하십시오.
* @default 1
*
* @param moreEnemies
* @text 새로운 에너미 생성
* @type struct<Enemy>[]
* @desc 새로운 적을 생성하십시오.
* @default ["{\"enemyId\":\"1\",\"x\":\"300\",\"y\":\"200\",\"hidden\":\"false\"}"]
*
* @param enemyReposition
* @text 에너미 위치 설정
* @type struct<EnemyReposition>
* @desc 에너미의 위치를 바둑판 형식으로 재정렬합니다.
* @default {"reposition":"false","width":"4","height":"6","x":"96 + (96 * x);","y":"Graphics.boxHeight / 3 + (96 * y);"}
*
*/
/*~struct~Enemy:ko
*
* @param enemyId
* @text 에너미 ID
* @text enemyId
* @type enemy
* @desc ID 값을 설정합니다
* @default 1
*
* @param x
* @text x
* @type number
* @min 0
* @desc x좌표를 설정합니다.
* @default 300
*
* @param y
* @text y
* @type number
* @min 0
* @desc y좌표를 설정합니다.
* @default 200
*
* @param hidden
* @text 숨김 여부
* @type boolean
* @desc 숨어있다가 중간에 나타날 지 여부를 설정합니다.
* @default false
* @on 숨긴다
* @off 표시한다
*
*/
/*~struct~EnemyReposition:ko
*
* @param reposition
* @text 위치 재설정 여부
* @type boolean
* @desc 위치를 바둑판으로 재설정하는 기능을 사용하시겠습니까? (기본값 = 사용하지 않는다)
* @default false
* @on 사용한다.
* @off 사용하지 않는다.
*
* @param width
* @text 폭
* @type number
* @desc 바둑판 배열 계산에 필요한 폭 값 (바둑판의 폭). 이중 루프를 사용하여 배치합니다.
* @default 4
* @min 3
*
* @param height
* @text 높이
* @type number
* @desc 바둑판 배열 계산에 필요한 높이 값 (바둑판의 높이). 이중 루프를 사용하여 배치합니다.
* @default 6
* @min 3
*
* @param x
* @desc 좌표 계산식을 입력하세요. (x는 이중 루프로 구성한 2차원 셀에서의 인덱스 값입니다)
* @default 96 + (96 * x);
*
* @param y
* @desc 좌표 계산식을 입력하세요. (y는 이중 루프로 구성한 2차원 셀에서의 인덱스 값입니다)
* @default Graphics.boxHeight / 3 + (96 * y);
*
*/
(() => {
"use strict";
let parameters = $plugins.filter((i) => {
return i.description.contains("<RS_MoreEnemies>");
});
parameters = parameters.length > 0 && parameters[0].parameters;
const RS = {};
RS.MoreEnemies = {
jsonParse(str) {
const retData = JSON.parse(str, (k, v) => {
try {
return this.jsonParse(v);
} catch (e) {
return v;
}
});
return retData;
},
};
let troopSettings;
if (parameters["Troop Settings"] !== "") {
troopSettings = RS.MoreEnemies.jsonParse(parameters["Troop Settings"]);
}
Object.assign(RS.MoreEnemies, {
createMoreEnemies() {
troopSettings.forEach((settings) => {
const troopId = settings.troopId;
const troop = $dataTroops && $dataTroops[troopId];
if (troop) {
settings.moreEnemies.forEach((event) => {
if ($dataTroops[troopId].members instanceof Array) {
$dataTroops[troopId].members.push(event);
}
});
}
});
},
});
const alias_Spriteset_Battle_createEnemies =
Spriteset_Battle.prototype.createEnemies;
Spriteset_Battle.prototype.createEnemies = function () {
alias_Spriteset_Battle_createEnemies.call(this);
this.setPositionForEnemies();
};
Spriteset_Battle.prototype.setPositionForEnemies = function () {
const troopId = $gameTroop._troopId;
if (!troopSettings) return;
// if there has troop settings?
let enemyReposition = troopSettings.filter((settings) => {
return settings.troopId === troopId;
});
if (Array.isArray(enemyReposition) && enemyReposition.length <= 0)
return;
enemyReposition = enemyReposition[0].enemyReposition;
// if the reposition is enabled?
if (!enemyReposition.reposition) return;
let id = 0;
const WIDTH = enemyReposition.width || 4;
const HEIGHT = enemyReposition.height || 6;
for (let y = 0; y < HEIGHT; y++) {
for (let x = 0; x < WIDTH; x++) {
let mx = eval(enemyReposition.x) || 96 + 96 * x;
let my =
eval(enemyReposition.y) || Graphics.boxHeight / 3 + 96 * y;
if (this._enemySprites[id])
this._enemySprites[id].setHome(mx, my);
id += 1;
}
}
};
const alias_Scene_Boot_start = Scene_Boot.prototype.start;
Scene_Boot.prototype.start = function () {
RS.MoreEnemies.createMoreEnemies();
alias_Scene_Boot_start.call(this);
};
})();