| 赞 | 91 |
| VIP | |
| 好人卡 | |
| 积分 | 104 |
| 经验 | |
| 最后登录 | 2024-6-24 |
| 在线时间 | 5019 小时 |
无限の剣制
- 梦石
- 0
- 星屑
- 10445
- 在线时间
- 5019 小时
- 注册时间
- 2013-2-28
- 回帖
- 4942
 
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 VIPArcher 于 2015-11-11 09:32 编辑
[pre lang="JAVASCRIPT"]//=============================================================================
// VIPArcher_Dir8.js
//=============================================================================
/*:
* @plugindesc 真 · 八方向移动
* @author VIPArcher
*
* @param Dir8_flag
* @desc 使用八方向素材的标志
* @default %
*
* @param Dir8_Affix
* @desc 八方向素材文件后缀
* @default _8D
*
* @help 使用八方向的行走图素材文件名前面添加一个标志,
* 与之对应的8方向的素材与其同名并在后面添加后缀以区别。
* 例如默认的设置就是使用八方向的素材命名为:
* !$%VIPArcher.png
*
* 那么与之对应的八方向的素材就应命名为:
* !$%VIPArcher_8D.png
*
*/
(function() {
var parameters = PluginManager.parameters('VIPArcher_Dir8');
var dir8_flag = String(parameters['Dir8_flag'] || '%');
var dir8_affix = String(parameters['Dir8_Affix'] || '_8D');
ImageManager.isDir8Character = function(filename) {
var reg = new RegExp("^\[\\!\\$\\" + dir8_flag + "]+")
var sign = filename.match(reg);
return sign && sign[0].contains(dir8_flag);
};
Game_Player.prototype.moveByInput = function() {
if (!this.isMoving() && this.canMove()) {
var direction = Input.dir8
if (direction > 0) {
$gameTemp.clearDestination();
} else if ($gameTemp.isDestinationValid()){
var x = $gameTemp.destinationX();
var y = $gameTemp.destinationY();
direction = this.findDirectionTo(x, y);
}
if (direction > 0) {
if (direction % 2 == 0){
this.moveStraight(direction);
return;
}
if (direction < 5){
this.moveDiagonally(direction + 3 , 2);
} else{
this.moveDiagonally(direction - 3 , 8);
}
}
}
};
var dir8_move_diagonal = Game_Player.prototype.moveDiagonally;
Game_Player.prototype.moveDiagonally = function(horz, vert) {
if (!this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
this.setMovementSuccess(false);
return;
}
if (this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
this.moveStraight(horz);
return;
}
if (this.canPass(this._x, this._y, vert) && !this.canPass(this._x, this._y, horz)){
this.moveStraight(vert);
return;
}
if (!this.canPassDiagonally(this._x, this._y, horz, vert)) {
if (Math.random() > 0.5){
this.setDirection(vert); this.moveStraight(vert)
} else {
this.setDirection(horz); this.moveStraight(horz)
}
return;
}
dir8_move_diagonal.call(this, horz, vert);
if (horz > 5) {
vert > 5 ? this.setDirection(9) : this.setDirection(7);
}
else {
vert > 5 ? this.setDirection(3) : this.setDirection(1);
};
};
Sprite_Character.prototype.characterPatternY = function() {
if (this._character.direction() % 2 == 0){
if (this.dir8_bitmap){ this.bitmap = this.dir4_bitmap; }
return (this._character.direction() - 2) / 2;
} else {
if (this.dir8_bitmap){ this.bitmap = this.dir8_bitmap; }
return parseInt((this._character.direction() + 1) / 3);
}
};
var dir8_set_CharacterBitmap = Sprite_Character.prototype.setCharacterBitmap
Sprite_Character.prototype.setCharacterBitmap = function() {
dir8_set_CharacterBitmap.call(this);
this._isDir8Character = ImageManager.isDir8Character(this._characterName);
if (this._isDir8Character) {
this.dir4_bitmap = this.bitmap;
this.dir8_bitmap = ImageManager.loadCharacter(this._characterName + dir8_affix);
};
};
})();[/pre]
[fold=更新记录]2015.11.11 修正队员在斜向移动遇到障碍会跳格问题[/fold]
对js啥都不懂的萌新瞎玩了一会js。发个插件试试。我自己并没有做过多测试。
有啥问题就直接回帖子反馈吧,反正我也不懂能不能结决
中文注释有点low啊 |
|