| 赞 | 168 |
| VIP | |
| 好人卡 | |
| 积分 | 229 |
| 经验 | |
| 最后登录 | 2025-4-1 |
| 在线时间 | 8598 小时 |
- 梦石
- 0
- 星屑
- 22879
- 在线时间
- 8598 小时
- 注册时间
- 2011-12-31
- 回帖
- 3270
|
发表于 2023-1-17 22:09:56
|
显示全部楼层
[fold=SupponChangeTileId.js][pre lang="ruby"]//=============================================================================
// SupponChangeTileId.js
//=============================================================================
/*:
* @target MZ
* @base PluginCommonBase
* @plugindesc マップタイルIDのコピー&ペーストを行います。
* @author Suppon
* @help
* !!プラグインコマンドを変更しました by good
*
* このプラグインを使用するときは以下のようにプラグインコマンドを入力してください。
*
* プラグインコマンド例1
* -------------------------------------
* SupponCTI add abc 1 2 3 4 5 11 12 13
* -------------------------------------
* この場合、データIDがabc、
* コピー元のマップIDが1、
* コピー元のX座標が2、
* コピー元のY座標が3、
* コピー元の幅が4、
* コピー元の高さが5、
* コピー先のマップIDが11、
* コピー先のX座標が12、
* コピー先のY座標が13、を意味します。
* コピー元にリージョンが設定してあるとリージョンもコピーされます。
* IDにはabcのような文字も使えます。
* コピー元にB~Eタイルが無く、コピー先にB~Eタイルがある場合、
* コピー先にあるB~Eはそのまま残ります。
*
*
* プラグインコマンド例2
* -------------------------------------
* SupponCTI add abc 2 3 4 5 12 13
* -------------------------------------
* このようにマップIDを省略した場合、同じマップ間でのコピーとなります。
*
*
* コピー先にB~Eタイルが無い状態を作りたい場合は以下のようにaddをchangeに
* 置き換えてください。
* プラグインコマンド例3
* ----------------------------------------
* SupponCTI change abc 1 2 3 4 5 11 12 13
* ----------------------------------------
*
*
* Aタイルのオートタイルを反映させたいときは
* 以下のように入力してください。
* プラグインコマンド例4
* ----------------------------------------
* SupponCTI auto abc 1 2 3 4 5 11 12 13
* ----------------------------------------
*
*
* コピーのデータを削除したいときは以下のようにIDを指定してください。
* プラグインコマンド例5
* ----------------------------------------
* SupponCTI remove abc
* ----------------------------------------
* この場合、IDがabcのデータを削除します。
* 同じIDのデータが複数ある場合には、一度に全て削除されます。
*
* プラグインコマンド例6
* パターンを繰り返したい場合は以下のようにしてください。
* -------------------------------------
* SupponCTI add-r abc 1 2 3 4 5 11 12 13 21 22
* -------------------------------------
* この場合、データIDがabc、
* コピー元のマップIDが1、
* コピー元のX座標が2、
* コピー元のY座標が3、
* コピー元の幅が4、
* コピー元の高さが5、
* コピー先のマップIDが11、
* コピー先のX座標が12、
* コピー先のY座標が13、
* X方向に21回繰り返し、
* Y方向に22回繰り返すという形になります。
* 以下のように同マップ内でのコピーではマップIDを省略することもできます。
* -------------------------------------
* SupponCTI add-r abc 2 3 4 5 12 13 21 22
* -------------------------------------
* B~Eタイルを完全に置き換える場合は、add-rをchange-rに,
* オートタイルに対応させたいときは、add-rをauto-rに変更してください。
*
* 変数を使用したい場合は、\v[1], \v[100]のように入力してください。
*
*
* @command tiling
* @text タイルを追加
* @desc タイルを追加
*
* @arg command
* @text コマンドを選ぶ
* @desc
* @default 追加
* @type select
* @option 追加
* @value 0
* @option 交換
* @value 1
* @option オートタイル
* @value 2
* @option 追加(リピート)
* @value 3
* @option 交換(リピート)
* @value 4
* @option オートタイル(リピート)
* @value 5
*
* @arg id
* @text コピーするタイルのIDを決める
* @desc コピーするタイルのIDを決める
* @default abc
* @type string
*
* @arg copy_map
* @text コピー元マップID
* @desc コピー元マップID
* @default 1
* @type number
*
* @arg copyX
* @text コピー元 座標X
* @desc コピー元 座標X
* @default 0
* @type number
*
* @arg copyY
* @text コピー元 座標Y
* @desc コピー元 座標Y
* @default 0
* @type number
*
* @arg copyW
* @text コピー元 横幅
* @desc コピー元 横幅
* @default 1
* @type number
*
* @arg copyH
* @text コピー元 縦幅
* @desc コピー元 縦幅
* @default 1
* @type number
*
* @arg paste_map
* @text 貼り付けるマップID
* @desc 貼り付けるマップID
* @default 1
* @type number
*
* @arg pasteX
* @text 貼り付ける 座標X
* @desc 貼り付ける 座標X
* @default 0
* @type number
*
* @arg pasteY
* @text 貼り付ける 座標Y
* @desc 貼り付ける 座標Y
* @default 0
* @type number
*
* @arg reX
* @text 横方向リピート回数
* @desc 横方向リピート回数
* @default 1
* @type number
*
* @arg reY
* @text 縦方向リピート回数
* @desc 縦方向リピート回数
* @default 1
* @type number
*
*
*
* @command remove
* @text タイルを削除
* @desc ID指定でタイルを削除する
*
* @arg id
* @text 削除するタイルのID
* @desc
* @default abc
* @type string
*/
(function() {
var AutoTilePattern = [
[1, 1, 1,
1, 1, 1,
1, 1, 1],//0
[0, 1, 1,
1, 1, 1,
1, 1, 1],//1
[1, 1, 0,
1, 1, 1,
1, 1, 1],//2
[0, 1, 0,
1, 1, 1,
1, 1, 1],//3
[1, 1, 1,
1, 1, 1,
1, 1, 0],//4
[0, 1, 1,
1, 1, 1,
1, 1, 0],//5
[1, 1, 0,
1, 1, 1,
1, 1, 0],//6
[0, 1, 0,
1, 1, 1,
1, 1, 0],//7
[1, 1, 1,
1, 1, 1,
0, 1, 1],//8
[0, 1, 1,
1, 1, 1,
0, 1, 1],//9
[1, 1, 0,
1, 1, 1,
0, 1, 1],//10
[0, 1, 0,
1, 1, 1,
0, 1, 1],//11
[1, 1, 1,
1, 1, 1,
0, 1, 0],//12
[0, 1, 1,
1, 1, 1,
0, 1, 0],//13
[1, 1, 0,
1, 1, 1,
0, 1, 0],//14
[0, 1, 0,
1, 1, 1,
0, 1, 0],//15
[0, 1, 1,
0, 1, 1,
0, 1, 1],//16
[0, 1, 0,
0, 1, 1,
0, 1, 1],//17
[0, 1, 1,
0, 1, 1,
0, 1, 0],//18
[0, 1, 0,
0, 1, 1,
0, 1, 0],//19
[0, 0, 0,
1, 1, 1,
1, 1, 1],//20
[0, 0, 0,
1, 1, 1,
1, 1, 0],//21
[0, 0, 0,
1, 1, 1,
0, 1, 1],//22
[0, 0, 0,
1, 1, 1,
0, 1, 0],//23
[1, 1, 0,
1, 1, 0,
1, 1, 0],//24
[1, 1, 0,
1, 1, 0,
0, 1, 0],//25
[0, 1, 0,
1, 1, 0,
1, 1, 0],//26
[0, 1, 0,
1, 1, 0,
0, 1, 0],//27
[1, 1, 1,
1, 1, 1,
0, 0, 0],//28
[0, 1, 1,
1, 1, 1,
0, 0, 0],//29
[1, 1, 0,
1, 1, 1,
0, 0, 0],//30
[0, 1, 0,
1, 1, 1,
0, 0, 0],//31
[0, 1, 0,
0, 1, 0,
0, 1, 0],//32
[0, 0, 0,
1, 1, 1,
0, 0, 0],//33
[0, 0, 0,
0, 1, 1,
0, 1, 1],//34
[0, 0, 0,
0, 1, 1,
0, 1, 0],//35
[0, 0, 0,
1, 1, 0,
1, 1, 0],//36
[0, 0, 0,
1, 1, 0,
0, 1, 0],//37
[1, 1, 0,
1, 1, 0,
0, 0, 0],//38
[0, 1, 0,
1, 1, 0,
0, 0, 0],//39
[0, 1, 1,
0, 1, 1,
0, 0, 0],//40
[0, 1, 0,
0, 1, 1,
0, 0, 0],//41
[0, 0, 0,
0, 1, 0,
0, 1, 0],//42
[0, 0, 0,
0, 1, 1,
0, 0, 0],//43
[0, 1, 0,
0, 1, 0,
0, 0, 0],//44
[0, 0, 0,
1, 1, 0,
0, 0, 0],//45
[0, 0, 0,
0, 1, 0,
0, 0, 0]//46
];
var AutoTilePattern2 = [
[0, 1, 0,
1, 1, 1,
0, 1, 0],//0
[0, 1, 0,
0, 1, 1,
0, 1, 0],//1
[0, 0, 0,
1, 1, 1,
0, 1, 0],//2
[0, 0, 0,
0, 1, 1,
0, 1, 0],//3
[0, 1, 0,
1, 1, 0,
0, 1, 0],//4
[0, 1, 0,
0, 1, 0,
0, 1, 0],//5
[0, 0, 0,
1, 1, 0,
0, 1, 0],//6
[0, 0, 0,
0, 1, 0,
0, 1, 0],//7
[0, 1, 0,
1, 1, 1,
0, 0, 0],//8
[0, 1, 0,
0, 1, 1,
0, 0, 0],//9
[0, 0, 0,
1, 1, 1,
0, 0, 0],//10
[0, 0, 0,
0, 1, 1,
0, 0, 0],//11
[0, 1, 0,
1, 1, 0,
0, 0, 0],//12
[0, 1, 0,
0, 1, 0,
0, 0, 0],//13
[0, 0, 0,
1, 1, 0,
0, 0, 0],//14
[0, 0, 0,
0, 1, 0,
0, 0, 0],//15
[0, 0, 0,
0, 0, 0,
0, 0, 0]//16
];
var AutoTilePattern3 = [
[0, 0, 0,
1, 1, 1,
0, 0, 0],//0
[0, 0, 0,
0, 1, 1,
0, 0, 0],//1
[0, 0, 0,
1, 1, 0,
0, 0, 0],//2
[0, 0, 0,
0, 1, 0,
0, 0, 0]//3
]
PluginManagerEx.registerCommand(document.currentScript, "remove", args => {
$gameParty.removeSupponCTI(args.id);
});
PluginManagerEx.registerCommand(document.currentScript, "tiling", args => {
let len = [
args.id, args.copy_map, args.copyX, args.copyY, args.copyW, args.copyH,
args.paste_map, args.pasteX, args.pasteY, args.command,
args.reX,args.reY]
$gameParty.addSupponCTI(len);
});
var _Game_Party_initialize = Game_Party.prototype.initialize
Game_Party.prototype.initialize = function() {
_Game_Party_initialize.call(this);
this._supponCTI = [];
};
Game_Party.prototype.addSupponCTI = function (args) {
var len = [args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[11] - 3, args[9], args[10]];
if (0 <= args[9] && args[9] >= 2) { //リピートしない場合
len = [args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9],1, 1];
}
this._supponCTI.push(len);
if(args[6] == $gameMap.mapId()){
$gameMap._supponCTI.push(len);
}
}
Game_Party.prototype.removeSupponCTI = function(id){
this._supponCTI = this._supponCTI.filter(function(args){
return args[0] !== id;
})
$gamePlayer._fadeType = null;
SceneManager.goto(Scene_Map);
}
var _Game_Temp_initialize = Game_Temp.prototype.initialize
Game_Temp.prototype.initialize = function() {
_Game_Temp_initialize.call(this);
this._supponCTINextMapId = 0;
};
var _Game_Map_initialize = Game_Map.prototype.initialize;
Game_Map.prototype.initialize = function() {
_Game_Map_initialize.call(this);
this._supponCTI = [];
};
var _Game_Map_update = Game_Map.prototype.update;
Game_Map.prototype.update = function(sceneActive) {
if(this._supponCTI.length > 0){
this.updateSupponCTI();
} else {
_Game_Map_update.call(this, sceneActive);
}
};
Game_Map.prototype.updateSupponCTI = function(){
while(this._supponCTI.length > 0){
var a = this._supponCTI[0]
if(this.mapId() == a[1]){
//転送元のマップIDが現在のマップIDと同じなら
var args = this._supponCTI.shift();
DataManager.applySupponCTI(args, $dataMap);
} else {
//転送元のマップIDが現在のマップIDと違う場合
if($gameTemp._supponCTINextMapId != a[1]){
//ロードが必要
$dataMapForSupponCTI = null;
var filename = 'Map%1.json'.format(a[1].padZero(3));
DataManager.loadDataFile('$dataMapForSupponCTI', filename);
$gameTemp._supponCTINextMapId = a[1];
}
if($dataMapForSupponCTI){
//転送元のマップがロードされたら
var args = this._supponCTI.shift();
DataManager.applySupponCTI(args, $dataMapForSupponCTI);
}
if(!$dataMapForSupponCTI){
return;
}
}
}
}
$dataMapForSupponCTI = null;
DataManager.applyAllSupponCTI = function(){
if(!$gameParty._supponCTI){$gameParty._supponCTI=[]};
$gameParty._supponCTI.forEach(function(args){
if(args[6]==$gameMap.mapId()){
$gameMap._supponCTI.push(args);
}
},this);
}
DataManager.applySupponCTI = function(args, sender){
if(args.length == 10){
var repeatX = 1;
var repeatY = 1;
var mode = Number(args[9]);
} else {
var repeatX = Number(args[10]);
var repeatY = Number(args[11]);
var mode = Number(args[9]);
}
//var repeatX = (args.length != 12) ? 0: Number(args[10]);
//var repeatY = (args.length != 12) ? 0: Number(args[11]);
var id = Number(args[0]);
var s = Number(args[1]);//送り元のマップID
var x1 = Number(args[2]);
var y1 = Number(args[3]);
var w = Number(args[4]);
var h = Number(args[5]);
var d = Number(args[6]);//送り先のマップID
var x2o = Number(args[7]);
var y2o = Number(args[8]);
//var mode = Number(args[9]);
var width = $dataMap.width;
var height = $dataMap.height;
var width0 = sender.width;
var height0 = sender.height;
var autoAdj = 0;
for(var ry=0 ; ry<repeatY ; ry++){
var y2 = y2o + ry*h;
for(var rx=0 ; rx<repeatX ; rx++){
var x2 = x2o + rx*w;
for (var i=0; i<h; i++){
if (0>y2+i || y2+i >= height){continue};
for (var j=0; j<w; j++){
if (0>x2+j || x2+j >= width){continue};
for (var z=0; z<6; z++){
var id0 = sender.data[(z * height0 + (y1+i)) * width0 + (x1+j)];
var id1 = $dataMap.data[(z * height + (y2+i)) * width + (x2+j)];
var id2 = sender.data[(0 * height0 + (y1+i)) * width0 + (x1+j)];
var isWall = 4351<id2 && id2<8192;
if ($gameMap.tileset().mode==0 && id0 == 2720) {continue};
var c = ( mode == 0 && id0 != 0 || mode >= 1);
if( c || (z==4 && isWall)){
//var under = $dataMap.data[(2 * height + (y2+i)) * width + (x2+j)];
//if(z==3 && under==0){
//$dataMap.data[(2 * height + (y2+i)) * width + (x2+j)] =
//$dataMap.data[(z * height + (y2+i)) * width + (x2+j)]
//}
//var id3 = sender.data[(z * height0 + (y1+i)) * width0 + (x1+j)];
if(z==3 && mode == 0 && id0 != 0){
$dataMap.data[((z-1) * height + (y2+i)) * width + (x2+j)] =
$dataMap.data[(z * height + (y2+i)) * width + (x2+j)];
}
$dataMap.data[(z * height + (y2+i)) * width + (x2+j)] =
sender.data[(z * height0 + (y1+i)) * width0 + (x1+j)];
}
if (mode == 2 && (z == 0||z ==1)){
this.refreshAutoTiles(x2+j, y2+i, z);
//autoAdj = this.calcAutoAdj(x2, y2, z);
//$dataMap.data[(z * height + (y2+i)) * width + (x2+j)] += autoAdj;
}
}
}
}
}
}
SceneManager._scene._spriteset._tilemap.refresh();
}
DataManager.refreshAutoTiles = function(x, y, z){
for (var i=-1; i<2; i++){
for (var j=-1; j<2; j++){
if (!$gameMap.isValid(x+j,y+i)){continue};
this.refreshAutoTile(x + j, y + i, z);
//var tileId = $gameMap.tileId(x+j, y+i, z);
//match.push(Tilemap.isSameKindTile(centerTileId,tileId) ? 1 : 0)
}
}
}
DataManager.refreshAutoTile = function(x, y, z){
var match = [];
var width = $dataMap.width;
var height = $dataMap.height;
var centerId = $gameMap.tileId(x, y, z);
var centerKind = Tilemap.getAutotileKind(centerId);
for (var i=-1; i<2; i++){
for (var j=-1; j<2; j++){
var tileId = $gameMap.tileId(x+j, y+i, z);
var kind = Tilemap.getAutotileKind(tileId)
if (!$gameMap.isValid(x+j,y+i)){
match.push(1)
}
else if (i!=0 && Tilemap.isWaterTile(centerId) && Tilemap.isWaterfallTile(tileId)){
match.push(1);
} else {
match.push(Tilemap.isSameKindTile(centerId,tileId) ? 1 : 0)
}
}
}
if (Tilemap.isFloorTypeAutotile(centerId)){
var shape = this.getShapeFloorType(match);
} else if (Tilemap.isWallTile(centerId) || Tilemap.isRoofTile(centerId)){
//console.log('wall')
var shape = this.getShapeWallTile(match);
} else {
var shape = this.getShapeWaterfall(match);
}
var newId = Tilemap.makeAutotileId(centerKind, shape);
// if (Tilemap.isTileA1(centerId)){
// var newId = Tilemap.makeAutotileId(centerKind, shape);
// }
// if (Tilemap.isTileA2(centerId)){
// var newId = Tilemap.makeAutotileId(centerKind, shape);
// }
//var newId = Tilemap.makeAutotileId(centerKind, shape);
if(centerKind >= 0){
//console.log('aaaa', centerKind, shape, newId)
$dataMap.data[(z * height + y) * width + x] = newId;
}
}
// Tilemap.makeAutotileIdA2 = function(kind, shape) {
// return this.TILE_ID_A2 + kind * 48 + shape;
// };
DataManager.getShapeFloorType = function(match){
if (match[1]==0){
match[0] = 0 ; match[2] = 0;
}
if (match[3]==0){
match[0] = 0 ; match[6] = 0;
}
if (match[5]==0){
match[2] = 0 ; match[8] = 0;
}
if (match[7]==0){
match[6] = 0 ; match[8] = 0;
}
return AutoTilePattern.indexOfArray(match);
}
DataManager.getShapeWallTile = function(match){
match[0] = 0;
match[2] = 0;
match[6] = 0;
match[8] = 0;
return AutoTilePattern2.indexOfArray(match);
}
DataManager.getShapeWaterfall = function(match){
match[0] = 0;
match[1] = 0;
match[2] = 0;
match[6] = 0;
match[7] = 0;
match[8] = 0;
return AutoTilePattern3.indexOfArray(match);
}
Array.prototype.indexOfArray = function(element){
for (var i=0; i<this.length; i++){
if (this.equals(element)){
return i;
}
}
return -1;
}
var _Scene_Map_start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
_Scene_Map_start.call(this)
DataManager.applyAllSupponCTI();
};
Tilemap.isWallSideTile = function(tileId) {
return (this.isTileA3(tileId) || this.isTileA4(tileId)) &&
this.getAutotileKind(tileId) % 16 >= 8;
};
// var _Game_Player_updateNonmoving = Game_Player.prototype.updateNonmoving;
// Game_Player.prototype.updateNonmoving = function(wasMoving) {
// _Game_Player_updateNonmoving.call(this, wasMoving);
// if(wasMoving){
// for (var i=0; i<6; i++){
// var tileId = $gameMap.tileId(this._x, this._y, i);
// var kind = Tilemap.getAutotileKind(tileId);
// var shape = Tilemap.getAutotileShape(tileId);
// console.log(i, ' ', tileId, ' kind', kind, 'shape', shape)
// }
// console.log(' ')
// }
// };
})();
[/pre][/fold]
|
评分
-
查看全部评分
|