-
Notifications
You must be signed in to change notification settings - Fork 0
/
NRP_DebugTile.js
210 lines (189 loc) · 7.07 KB
/
NRP_DebugTile.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
//=============================================================================
// NRP_DebugTile.js
//=============================================================================
/*:
* @target MV MZ
* @plugindesc v1.01 Displays tile information in debug mode.
* @author Takeshi Sunagawa (http://newrpg.seesaa.net/)
* @url http://newrpg.seesaa.net/article/481013577.html
*
* @help Displays tile information in debug mode.
*
* Displays the TileId and AutotileType,
* which are usually difficult to verify.
*
* In particular, AutotileType is used to determine the background of the battle.
* This item is not usually checked.
* It is useful for setting up other plugins.
*
* ※This plugin is a rush job.
* I may organize it soon.
* ※I have made it so that it does not work in production,
* but just in case, you might want to turn off the plugin
* when you no longer need it.
*
* [Usage]
* After running the game, use F2 to display the FPS.
* Next to it, the TileId and AutotileType
* of the player's current location are displayed.
* Also, the target is the uppermost layer,
* except for tiles with a ☆ traffic rating.
*
* [Terms]
* There are no restrictions.
* Modification, redistribution freedom, commercial availability,
* and rights indication are also optional.
* The author is not responsible,
* but will deal with defects to the extent possible.
*
* @param PassageIgnoreTerrain
* @type string
* @desc Specify the terrain tag (1~7) to ignore the passage judgment. Multiple tags can be specified. (e.g.:1,3)
*/
/*:ja
* @target MV MZ
* @plugindesc v1.01 タイル情報をデバッグ表示します。
* @author 砂川赳(http://newrpg.seesaa.net/)
* @url http://newrpg.seesaa.net/article/481013577.html
*
* @help タイル情報をデバッグ表示します。
*
* 通常、確認が困難なタイルIDとオートタイルタイプを表示します。
*
* 特にオートタイルタイプは戦闘背景の判定に用いられていますが、
* 通常は確認できない項目です。
* 他のプラグインでの設定に役立ててください。
*
* ※このプラグインはやっつけ仕事です。
* そのうち整理するかもしれません。
* ※一応、本番では動作しないようにしていますが、
* 念のため不要になったら、プラグインをオフにしたほうがよいかも?
*
* ■使用方法
* ゲーム実行後、F2でFPSを表示してください。
* その隣に、プレイヤーの現在地のタイルIDとオートタイルタイプが表示されます。
* また、対象となるのは通行判定が☆のタイルを除いた最も上のレイヤーです。
*
* ■利用規約
* 特に制約はありません。
* 改変、再配布自由、商用可、権利表示も任意です。
* 作者は責任を負いませんが、不具合については可能な範囲で対応します。
*/
(function() {
"use strict";
const PLUGIN_NAME = "NRP_DebugTile";
const parameters = PluginManager.parameters(PLUGIN_NAME);
/**
* ●テスト実行かどうか?
*/
function isPlaytest() {
// ブラウザ実行時は常に本番と判定
if (isBrowserMode()) {
return false;
// ※この段階では$gameTemp.isPlaytest()は有効にならないため、こちらで判定。
} else if (Utils.isOptionValid("test")) {
return true;
}
return false;
}
/**
* ●ブラウザ実行かどうか?
*/
function isBrowserMode() {
if (!Utils.isNwjs()) {
return true;
}
return false;
}
/**
* ●MZの場合
*/
if (Utils.RPGMAKER_NAME == "MZ") {
/**
* ●FPSの表示更新
*/
const _Graphics_FPSCounter__update = Graphics.FPSCounter.prototype._update;
Graphics.FPSCounter.prototype._update = function() {
_Graphics_FPSCounter__update.apply(this, arguments);
// テスト時以外は終了
if (!isPlaytest()) {
return;
// 表示中以外は終了
} else if (this._boxDiv.style.display === "none") {
return;
}
// まだ準備できていない場合があるのでチェック
if (this._boxDiv && $dataMap && $gamePlayer && $gameParty) {
// 戦闘中は終了
if ($gameParty.inBattle()) {
return;
}
// 表示領域を拡張
this._boxDiv.style.width = "500px";
// 対象とするレイヤーを取得
const layerNo = getStepLayer($gamePlayer.x, $gamePlayer.y);
if (layerNo >= 0) {
this._numberDiv.textContent +=
" TileID:" + $gameMap.tileId($gamePlayer.x, $gamePlayer.y, layerNo);
this._numberDiv.textContent +=
" AutotileType:" + $gameMap.autotileType($gamePlayer.x, $gamePlayer.y, layerNo);
}
}
};
}
/**
* ●MVの場合
*/
if (Utils.RPGMAKER_NAME == "MV") {
const _Spriteset_Map_update = Spriteset_Map.prototype.update;
Spriteset_Map.prototype.update = function() {
_Spriteset_Map_update.apply(this, arguments);
// テスト時以外は終了
if (!isPlaytest()) {
return;
}
// まだ準備できていない場合があるのでチェック
if ($dataMap && $gamePlayer && $gameParty) {
// 戦闘中は終了
if ($gameParty.inBattle()) {
return;
}
const modeBox = Graphics._modeBox;
// 表示領域を拡張
modeBox.style.width = "170px";
modeBox.style.height = "90px";
// 対象とするレイヤーを取得
const layerNo = getStepLayer($gamePlayer.x, $gamePlayer.y);
if (layerNo >= 0) {
const modeText = document.getElementById('modeText');
modeText.style.fontSize = '20px';
modeText.style.fontWeight = 'bold';
modeText.textContent =
" TileID:" + $gameMap.tileId($gamePlayer.x, $gamePlayer.y, layerNo);
modeText.textContent +=
" AutotileType:" + $gameMap.autotileType($gamePlayer.x, $gamePlayer.y, layerNo);
}
}
};
}
/**
* ●☆を除いた有効な最大レイヤー番号
* ※要するに足を踏みしめるレイヤー
*/
function getStepLayer(x, y) {
// 各タイルが保有するフラグ情報
const flags = $gameMap.tilesetFlags();
// 上のレイヤーから順番にループ
const tiles = $gameMap.layeredTiles(x, y);
for (let i = 0; i < 4; i++) {
const tileId = tiles[i];
const layerNo = 3 - i;
// 通行判定☆(0x10)を除く最初のタイルが対象
if ((flags[tileId] & 0x10) === 0) {
return layerNo;
}
}
// 無効の場合は-1
return -1;
}
})();