图块遮挡角色半透明 Translucent Character Behind Tile

插件简介:

这个插件能实现被图块遮挡的角色呈现半透明的效果,帮助玩家确认被遮挡的角色的位置。原理很简单,就是为所有的角色(包括主角,跟随队友,事件,交通工具)在与高层图块相同的层级(z = 4)上建立半透明的sprite。

截图:

TCBT01.png

食用方法:

1. 安装:

直接在插件管理器中启用。

2. 设定参数:
  • Default Opacity Rate:
    图块上半透明角色sprite的不透明度将为Opacity Rate与角色原本的不透明度的乘积。此处设定的是默认的Opacity Rate。
    有效参数是[0, 1]之间的小数。
    本参数默认值为0.2。

  • Opacity Percentage Variable ID:
    你也可以使用一个游戏内变量来动态地控制高层角色sprite。本参数接收一个游戏内变量的ID,sprite的不透明度将由该变量的值决定。由于RM中内建游戏变量只能是整数,所以变量里的有效值为百分比的整数部分,即在[0, 100]之间的整数。实际Opacity Rate将为该值除以100。
    如果你使用变量控制不透明度,那么Default Opacity Rate将被忽略。记得调节相应的变量数值以使高层sprite生效。
    该参数设定为0表示不启用这项功能。
    本参数默认值为0。

  • Enable by Default:
    设定高层角色sprite是否默认起效。如果设定为false,那么默认不会显示任何高层角色sprite。你需要使用下面的插件指令或事件注释标签来手动开启。
    本参数默认值为true。

3. 插件指令:

插件指令可以临时调整某角色上是否显示高层sprite。

  • HighLayerCharacterSprite EventID true
    #开启以EventID为ID的事件的高层角色sprite
  • HighLayerCharacterSprite EventID false
    #关闭以EventID为ID的事件的高层角色sprite

    其中EventID为-1时代表主角和跟随队友,0为当前事件,或者其他具体事件ID。

4. 事件注释标签

通过设置事件注释标签可以修改某事件默认是否显示高层角色sprite。
注意这里的事件注释标签不是事件窗口上方的备注(Note)区,而是事件执行内容内通过流程控制->注释(comment)指令加入的注释内容。使用事件注释而非备注可以允许你为同一个事件的不同页面定义不同的高层角色sprite的可见性。你可以在注释指令里使用如下标签(包括尖括号):

  • <Enable High Layer Character Sprite>
    #开启这个事件的高层角色sprite
  • <Disable High Layer Character Sprite>
    #关闭这个事件的高层角色spriteTCBT02.png

注意事项:

  • 对于事件,插件指令和事件注释标签的效果将持续到地图切换,对于主角和队友效果则切换地图后依然持续。
  • 插件指令和事件注释标签的效果会互相覆盖。
  • 当某事件的某一页被激活,该页面的事件注释标签就会被执行,假如该页没有定义标签,那么高层角色sprite的可见性维持不变。
  • 副作用:角色重叠的话半透明的sprite也会重叠在一起…这个目前感觉无解,如果有解决思路可以留言,谢~
  • 配合图块通行增强插件和OverpassTile插件(自带)及其Fix插件一同食用效果更佳~ TCBT03.png TCBT04.png

更新履历:

Version 0.10:
  • 完成插件原型

插件内容:

插件内容AndrewX_TranslucentCharacterBehindTile.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
//=============================================================================
// AndrewX - Translucent Character Behind Tile
// AndrewX_TranslucentCharacterBehindTile.js
//=============================================================================
var AndrewX = AndrewX || {};
AndrewX.TCBT = AndrewX.TCBT || {};
//=============================================================================
/*:
* @plugindesc v0.10 Display a translucent character sprite when the character is behind a tile.
* @author AndrewX
*
* @param Default Opacity Rate
* @desc The default opacity rate for high layer character sprites. (Default: 0.2)
* @default 0.2
*
* @param Opacity Percentage Variable ID
* @desc Set a variable ID to use that variable to control opacity rate. Use 0 if you do not need this feature. (Default: 0)
* The real opacity rate will be the value of that variable divide by 100.
* @default 0
*
* @param Enable by Default
* @desc Set to "false" if you do not want high layer sprite to be displayed by default. (Default: true)
* @default true
*
* @help
* ============================================================================
* Introduction and Instructions
* ============================================================================
*
* This plugin will create high layer translucent sprites for characters
* (player, followers, events, vehicles), which are at the same layer as upper
* tiles (i.e. z = 4), so that when a character is covered by the tile, the
* high layer translucent sprite will indicate where he is.
*
* Usage:
* 1. Installed: Just enable the plugin in the Plugin Manager.
*
* 2. Setup parameters.
* a. Default Opacity Rate:
* The opacity for the high layer character sprites will be the product
* of the character's original opacity and the opacity rate you set in
* this plugin. This parameter is the default opacity rate.
* Valid value will be a number in range [0, 1].
* The default value for this parameter is 0.2.
* b. Opacity Percentage Variable ID:
* You can also use a variable to get dynamic control of the high layer
* sprites' opacity. This parameter takes in a variable ID in your game,
* and the opacity will be determined by the value of that variable.
* Note: As in RM, builtin variables only support integers. Thus, the
* valid value in the variable is a percentage number in range [0, 100].
* The actual opacity rate will be the variable's value divide by 100.
* If you use the variable to control opacity, the Default Opacity Rate
* will be ignored. Remember to adjust the variable you assigned to make
* the sprites to work.
* Use 0 if you do not need this feature.
* The default value for this parameter is 0.
* c. Enable by Default:
* Whether the high layer sprites should work by default. If you set to
* "false", no high layer character sprite will be displayed
* automatically. You need to enable them manually by plugin commands or
* event comment tags.
* The default value for this parameter is true.
*
* 3. Plugin Commands:
* Use plugin commands to modify high layer character sprite's visibility of
* an event temporarily:
*
* HighLayerCharacterSprite EventID true
* # Enable high layer sprite for the event
*
* HighLayerCharacterSprite EventID false
* # Disable high layer sprite for the event
*
* EventID = number for specific event
* EventID = 0 for "this" event
* EventID = -1 for player and followers
*
* 4. Event Comment Tags
* You can use event comment tags to set whether an event should display
* high layer character sprite by default.
* Event Comment Tags are set within comments in event contents of an event
* page. This will enable you to set different translucent sprite visibilities
* in different pages for the same event.
*
* <Enable High Layer Character Sprite>
* # Enable high layer sprite for this event
*
* <Disable High Layer Character Sprite>
* # Disable high layer sprite for this event
*
* To use these tags, in an event page, add Event Commands "Comment" in Flow
* Control, and write the tag.
*
* NOTE:
* 1. For events, the effect of plugin commands and event comment tags will
* last until the map is changed. For player and followers, the effect will
* remain.
* 2. Plugin commands and event comment tags can override each other.
* 3. Every time an event page is triggered, the event comment tag within
* this page will be evaluated. If there is no defined comment tag, the
* visibility of the high layer character sprite will not be changed.
*
* ============================================================================
* Changelog
* ============================================================================
*
* Version 0.10:
* - Finished prototype
*
* ============================================================================
* Term of Use
* ============================================================================
*
* Free for use in non-commercial or commercial RMMV projects
* Please credit AndrewX
*
*/

//=============================================================================

(function() {

var parameters = PluginManager.parameters('AndrewX_TranslucentCharacterBehindTile');
var defaultOpacityRate = Number(parameters['Default Opacity Rate'] || 0);
var opacityVariableId = Number(parameters['Opacity Percentage Variable ID'] || 0);
var enableByDefault = parameters['Enable by Default'];

AndrewX.TCBT.initMembers = Game_CharacterBase.prototype.initMembers;
Game_CharacterBase.prototype.initMembers = function() {
AndrewX.TCBT.initMembers.call(this);
if (enableByDefault.toUpperCase() === 'FALSE') {
this._showHighLayerCharaSprite = false;
} else {
this._showHighLayerCharaSprite = true;
}
};

AndrewX.TCBT.createCharacters = Spriteset_Map.prototype.createCharacters;
Spriteset_Map.prototype.createCharacters = function() {
AndrewX.TCBT.createCharacters.call(this);
this._highLayerCharaSprites = [];
$gameMap.events().forEach(function(event) {
this._highLayerCharaSprites.push(new Sprite_Character(event));
}, this);
$gameMap.vehicles().forEach(function(vehicle) {
this._highLayerCharaSprites.push(new Sprite_Character(vehicle));
}, this);
$gamePlayer.followers().reverseEach(function(follower) {
this._highLayerCharaSprites.push(new Sprite_Character(follower));
}, this);
this._highLayerCharaSprites.push(new Sprite_Character($gamePlayer));
for (var i = 0; i < this._highLayerCharaSprites.length; i++) {
this._tilemap.addChild(this._highLayerCharaSprites[i]);
}
};

AndrewX.TCBT.update = Spriteset_Map.prototype.update;
Spriteset_Map.prototype.update = function() {
AndrewX.TCBT.update.call(this);
var characters = this._characterSprites;
for (var i = 0; i < characters.length; i++) {
if (!this._highLayerCharaSprites[i]) {
continue;
}
this._highLayerCharaSprites[i].z = 4;
var opacityRate;
if (opacityVariableId >= 1) {
opacityRate = $gameVariables.value(opacityVariableId) / 100;
} else {
opacityRate = defaultOpacityRate;
}
this._highLayerCharaSprites[i].opacity = characters[i].opacity * opacityRate;
if (characters[i]._character._showHighLayerCharaSprite === true) {
this._highLayerCharaSprites[i].visible = characters[i].visible;
} else {
this._highLayerCharaSprites[i].visible = false;
}
}
};

AndrewX.TCBT.pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
AndrewX.TCBT.pluginCommand.call(this, command, args);
if (command.toUpperCase() === 'HIGHLAYERCHARACTERSPRITE') {
if (eval(args[0]) < 0) {
if (args[1].toUpperCase() === 'TRUE') {
$gamePlayer._showHighLayerCharaSprite = true;
$gamePlayer.followers().reverseEach(function(follower) {
follower._showHighLayerCharaSprite = true;
}, this);
} else if (args[1].toUpperCase() === 'FALSE') {
$gamePlayer._showHighLayerCharaSprite = false;
$gamePlayer.followers().reverseEach(function(follower) {
follower._showHighLayerCharaSprite = false;
}, this);
}
} else {
subject = this.character(eval(args[0]));
if (args[1].toUpperCase() === 'TRUE') {
subject._showHighLayerCharaSprite = true;
} else if (args[1].toUpperCase() === 'FALSE') {
subject._showHighLayerCharaSprite = false;
}
}
}
};

AndrewX.TCBT.setupPage = Game_Event.prototype.setupPage;
Game_Event.prototype.setupPage = function() {
AndrewX.TCBT.setupPage.call(this, arguments);
if (this._pageIndex >= 0) {
for (var i = 0; i < this.list().length; i++) {
if ([108, 408].indexOf(this.list()[i]['code']) >= 0) {
var note = this.list()[i]['parameters'][0];
if (note.match(/<Disable High Layer Character Sprite>/i)) {
this._showHighLayerCharaSprite = false;
} else if (note.match(/<Enable High Layer Character Sprite>/i)) {
this._showHighLayerCharaSprite = true;
}
}
}
}
}
})();