-
Notifications
You must be signed in to change notification settings - Fork 0
/
NRP_CounterExtension.js
167 lines (155 loc) · 6.73 KB
/
NRP_CounterExtension.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
//=============================================================================
// NRP_CounterExtension.js
//=============================================================================
/*:
* @target MV MZ
* @plugindesc v1.01 Extend the functionality of the counter attribute.
* @author Takeshi Sunagawa (http://newrpg.seesaa.net/)
* @url http://newrpg.seesaa.net/article/483969944.html
*
* @help Extend the functionality of the counter attribute.
*
* In RPG Maker MV or MZ, even if you add the counter attribute to a tile,
* the player can only talk to someone one square away.
* In the old Maker, such as RPG Maker 2000,
* players could talk to someone much further away...
*
* So, I extended the effective range of the counter attribute.
*
* It can also disable Maker's specification that an A2 tile
* and a tile with a counter attribute is determined as a table
* and extended by 12 dots in length.
*
* -------------------------------------------------------------------
* [Usage]
* -------------------------------------------------------------------
* Turn on the required functionality with the plugin parameters.
*
* -------------------------------------------------------------------
* [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.
*
* @------------------------------------------------------------------
* @ Plugin Parameters
* @------------------------------------------------------------------
*
* @param CounterExtension
* @type boolean
* @default true
* @desc Extend the effective range of the counter attribute so that events more than 2 squares away can be activated.
*
* @param TableImageNotExtension
* @type boolean
* @default false
* @desc Disable the specification to extend table tiles by 12 dots.
*/
/*:ja
* @target MV MZ
* @plugindesc v1.01 カウンター属性の機能を拡張する。
* @author 砂川赳(http://newrpg.seesaa.net/)
* @url http://newrpg.seesaa.net/article/483969944.html
*
* @help カウンター属性の機能を拡張します。
*
* ツクールMV~MZではタイルにカウンター属性を付加しても、
* 1マス離れた相手にしか話しかけられません。
* ツクール2000など昔のツクールでは、
* もっと遠くの相手とも会話できたのになぜ……。
*
* というわけで、カウンター属性の有効範囲を延長します。
*
* また、A2タイルかつカウンター属性のタイルがテーブルとして判定され、
* 12ドット長さが延長されるツクールの仕様を無効化できます。
*
* -------------------------------------------------------------------
* ■使用方法
* -------------------------------------------------------------------
* 必要な機能をプラグインパラメータでオンにしてください。
*
* -------------------------------------------------------------------
* ■利用規約
* -------------------------------------------------------------------
* 特に制約はありません。
* 改変、再配布自由、商用可、権利表示も任意です。
* 作者は責任を負いませんが、不具合については可能な範囲で対応します。
*
* @------------------------------------------------------------------
* @ プラグインパラメータ
* @------------------------------------------------------------------
*
* @param CounterExtension
* @text カウンターの範囲延長
* @type boolean
* @default true
* @desc カウンター属性の有効範囲を延長し、2マス以上離れたイベントを起動できるようにします。
*
* @param TableImageNotExtension
* @text テーブル画像を延長しない
* @type boolean
* @default false
* @desc テーブルタイルを12ドット延長する仕様を無効化します。
*/
(function() {
"use strict";
function toBoolean(str, def) {
if (str === true || str === "true") {
return true;
} else if (str === false || str === "false") {
return false;
}
return def;
}
const PLUGIN_NAME = "NRP_CounterExtension";
const parameters = PluginManager.parameters(PLUGIN_NAME);
const pCounterExtension = toBoolean(parameters["CounterExtension"], true);
const pTableImageNotExtension = toBoolean(parameters["TableImageNotExtension"], false);
//-----------------------------------------------------------------------------
// Game_Player
//-----------------------------------------------------------------------------
if (pCounterExtension) {
const _Game_Player_checkEventTriggerThere = Game_Player.prototype.checkEventTriggerThere;
Game_Player.prototype.checkEventTriggerThere = function(triggers) {
_Game_Player_checkEventTriggerThere.apply(this, arguments);
// イベントを起動できる、かつイベントを開始していない。
if (this.canStartLocalEvents() && !$gameMap.isAnyEventStarting()) {
const direction = this.direction();
const x1 = this.x;
const y1 = this.y;
// プレイヤーの1マス先の座標を確認
let tmpX = $gameMap.roundXWithDirection(x1, direction);
let tmpY = $gameMap.roundYWithDirection(y1, direction);
// 元の処理で既に1マス先は確認済みのため、
// さらに1マス先の座標を確認
tmpX = $gameMap.roundXWithDirection(tmpX, direction);
tmpY = $gameMap.roundYWithDirection(tmpY, direction);
// カウンター属性が続く限りループ
while ($gameMap.isCounter(tmpX, tmpY)) {
tmpX = $gameMap.roundXWithDirection(tmpX, direction);
tmpY = $gameMap.roundYWithDirection(tmpY, direction);
this.startMapEvent(tmpX, tmpY, triggers, true);
// イベントが起動されたなら終了
if ($gameMap.isAnyEventStarting()) {
return;
}
}
}
};
}
//-----------------------------------------------------------------------------
// Tilemap
//-----------------------------------------------------------------------------
if (pTableImageNotExtension) {
/**
* ●テーブルタイルの判定
*/
Tilemap.prototype._isTableTile = function(tileId) {
// 12ドット下に伸ばす仕様を解除する。
return false;
};
}
})();