目次
昨日探してきたアクションゲームに使えそうなプラグインを、自分好みになるようにカスタマイズしました。
多機能フックローププラグイン
フックロープが壁を突き抜けるように変更
デフォルトの動作だと壁の手前でフックロープが止まってしまうため、壁の上にあるレバーをフックロープで起動させることができません。
壁上のレバーも起動できた方がアクションに幅が広がるため、壁を突き抜けるようにします。
でも突き抜けて欲しくない壁もあるので、壁をプレイヤー探索プラグイン(MKR_PlayerSensor.js)のようにリージョンで指定するようにしました。
// ★壁の定義を変更★
// A3・A4タイル→リージョンで指定
var isPassableLowerTileThere = function (x, y) {
const REASION_WALL = 1;
return $gameMap.regionId(x,y) !== REASION_WALL;
};
isPassableLowerTileThere関数の内容を上記のように変更。
プレイヤー探索プラグインで壁扱いするリージョン番号が1なので、フックローププラグインもあわせてリージョン番号1なら壁扱いという風にしています。
屋根の上でもフックロープが使えるように変更
屋根の上だとフックロープが使用できない仕様ですが、こちらも屋根の上から地上のものを動かせるといいなと思ったのでカスタマイズ。
// ★壁の上でも使えるように修正★
var performHookRopeAnimation = function () {
/*
if ($gamePlayer.isOverTheWall()) {
return;
}
*/
var dir = $gamePlayer.direction();
var idAndLength = distanceFromPlayerAndId(dir);
var distance = idAndLength.len;
var type = $gameTemp._hookRopeType = idAndLength.id;
if (type === 0) {
$gamePlayer.requestHookRopeAnime(hookRopeAnimation(dir, distance));
$gamePlayer.setWaitForHookRope(distance);
} else {
$gamePlayer.requestHookRopeAnime(hookRopeAnimation(dir, distance));
switch (type) {
case Game_Event._PICKET:
$gamePlayer.setHookRopeRoute(dir, distance);
break;
case Game_Event._INVOKE:
var coord = _directionToCoord(dir, distance);
$gameMap.eventsXy(coord.x, coord.y).forEach(function (event) {
event.setWaitWithScript(distance);
});
break;
case Game_Event._FETCH:
var needsBackward = $gamePlayer._needsBackwardForFetch();
if ((!goBackwardForFetch && needsBackward) ||
(notBackwardAdjacent && needsBackward && distance <= 1)) {
// do the same as type === 0
$gamePlayer.requestHookRopeAnime(hookRopeAnimation(dir, distance));
$gamePlayer.setWaitForHookRope(distance);
} else {
$gamePlayer.setBackwardForFetch(distance);
var coord = _directionToCoord(dir, distance);
distance += needsBackward ? 1 : 0;
$gameMap.eventsXy(coord.x, coord.y).forEach(function (event) {
event.setHookRopeRoute(event.reverseDir(dir), distance);
});
}
break;
}
}
if (distance > 0) {
SoundManager.shotHookRope();
}
};
元の処理の
if ($gamePlayer.isOverTheWall()) {
return;
}
の部分をコメント化し、実行しないようにします。
これで「屋根の上から壁にあるレバーを操作」といったアクションもできるようになります。
マップアイテムスロットプラグイン
消費しないアイテム、所持数0のアイテムは個数表示を消す
マップアイテムスロットプラグインはプラグインパラメータでアイテムの個数を表示できるのですが、消耗しないアイテムの場合でも個数が表示されてしまいます。

動作に影響はないのですが、見た目が気になったので修正。
また、所持数が0のものについても、個数表示をしないようにカスタマイズしました。
Window_ItemSlotBase.prototype.drawItemEx = function (index) {
let item, rect, num, type, id, itemSlot, equipFlg, actor, fontSize, x, y,
sizeRate;
itemSlot = $gameParty.getItemSlot(index);
actor = $gameParty.leader();
sizeRate = this._kind ? Params.MapSlotWindow.SizeRate[0] : Params.MenuSlotWindow.SizeRate[0];
if (itemSlot) {
type = itemSlot.type;
id = itemSlot.id;
item = this.item(index);
if (item) {
rect = this.itemRect(index);
if(type == SKILL) {
num = 0;
} else {
num = $gameParty.numItems(item);
}
if ((type == WEAPON || type == ARMOR) && actor.isEquipped(item)) {
this.changePaintOpacity(true);
} else if(type == SKILL) {
this.changePaintOpacity(actor.canPaySkillCost(item));
} else {
this.changePaintOpacity(num > 0);
}
x = rect.x + rect.width / 2 - Window_Base._iconWidth * sizeRate / 2;
y = rect.y + rect.height / 2 - Window_Base._iconHeight * sizeRate / 2;
this.drawIconEx(item.iconIndex, x, y, sizeRate);
if (type == ITEM && Params.ItemCountVisible[0] && item.consumable && $gameParty.numItems(item) > 0) {
fontSize = this.contents.fontSize;
this.contents.fontSize = Params.MapSlotWindow.FontSize[0];
this.contents.drawText("" + num, rect.x, rect.height - 20, rect.width - 2, 24, 'right');
this.contents.fontSize = fontSize;
this._type[index] = ITEM;
} else if (type == WEAPON) {
equipFlg = actor.isEquipped(item);
if (equipFlg) {
fontSize = this.contents.fontSize;
this.contents.fontSize = Params.MapSlotWindow.FontSize[0];
this.contents.drawText("E", rect.x, rect.y, rect.width - 2, 24, 'right');
this.contents.fontSize = fontSize;
}
this._type[index] = WEAPON;
} else if (type == ARMOR) {
equipFlg = actor.isEquipped(item);
if (equipFlg) {
fontSize = this.contents.fontSize;
this.contents.fontSize = Params.MapSlotWindow.FontSize[0];
this.contents.drawText("E", rect.x, rect.y, rect.width - 2, 24, 'right');
this.contents.fontSize = fontSize;
}
this._type[index] = ARMOR;
} else if (type == SKILL) {
this._type[index] = SKILL;
}
this._num[index] = num;
} else {
this._type[index] = "";
this._num[index] = 0;
}
}
};
if (type == ITEM && Params.ItemCountVisible[0]) { の部分を if (type == ITEM && Params.ItemCountVisible[0] && item.consumable && $gameParty.numItems(item) > 0) {に書き換え。
item.consumableでアイテムが消耗するかどうか、 $gameParty.numItems(item)でアイテムの個数を取得しています。
ちょっとスッキリした感じになりました。
