查看: 42161|回复: 76

[原创发布] 【行走图动画扩展】八方向|奔跑|待机|多帧

[复制链接]

无限の剣制

梦石
0
星屑
10445
在线时间
5019 小时
注册时间
2013-2-28
回帖
4942

开拓者贵宾

发表于 2015-11-30 01:25:18 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 VIPArcher 于 2019-7-29 10:04 编辑

[fold=1.5新版本 (使用多文件以后缀名区分姿势)][pre lang="javascript"]//=============================================================================
// VIPArcher_CharacterPoses.js
//=============================================================================
/*:
* @plugindesc 行走图多姿势动画扩展,多帧|八方向|奔跑|待机
* @author VIPArcher
*
* @param MoveDir8
* @desc 是否启用 8 方向移动
* Default: true (启用: true / 不启用: false)
* @default true
* @type boolean
*
* @param AnimationSpeed
* @desc 加快帧动画速度程度
* 1 到 10 之间的数字
* @default 0
* @type number
*
* @param GapTime
* @desc 两次待机之间等待的帧数
* @default 120
* @type number
*
* @param MinTime
* @desc 进入待机前最短要等待的帧数
* @default 120
* @type number
*
* @param RandTime
* @desc 在最短时间上额外随机等待的帧数范围
* @default 120
* @type number
*
* @param IdleTimes
* @desc 一次待机动画循环的次数
* @default 1
* @type number
*
* @param NoteIdle
* @desc 事件使用待机动画的注释
* @default <idleAnime>
* @type string
*
* @help 使用该脚本的行走图素材文件名前面添加一个标志 @(英文半角)
* 文件名的命名规范如下:
* @VIPArcher.png 或者 $@VIPArcher.png
*   ◆ 然后必须提供配套的不同姿势素材,各姿势素材命名如下:
* · (普通姿势斜方向):FILE_NAME + _8D.png
* · (奔跑姿势四方向):FILE_NAME + _DASH.png
* · (奔跑姿势斜方向):FILE_NAME + _DASH_8D.png
* · (待机姿势四方向):FILE_NAME + _IDLE.png
* · (待机姿势斜方向):FILE_NAME + _IDLE_8D.png
*   ◆ 使用多帧则名为(默认设置): @文件名[f帧数h静止帧].png
*   例如 @VIPArcher[f8h1].png
*/
var VIPArcher = VIPArcher || {};
VIPArcher.CharAnime = {};
VIPArcher.CharAnime.version = '1.5.0';
void function() {
    var _CharAnime = VIPArcher.CharAnime;
    _CharAnime.Parameters = PluginManager.parameters('VIPArcher_CharacterPoses');
    _CharAnime.MoveDir8   = Boolean(_CharAnime.Parameters['MoveDir8'] === 'true' || false);
    _CharAnime.AnimationSpeed = Number(_CharAnime.Parameters['AnimationSpeed'] || 0);
    _CharAnime.GapTime   = Number(_CharAnime.Parameters['GapTime']   || 120);
    _CharAnime.MinTime   = Number(_CharAnime.Parameters['MinTime']   || 120);
    _CharAnime.RandTime  = Number(_CharAnime.Parameters['RandTime']  || 120);
    _CharAnime.IdleTimes = Number(_CharAnime.Parameters['IdleTimes'] || 1);
    _CharAnime.NoteIdle  = String(_CharAnime.Parameters['NoteIdle']  || '<idleAnime>');
    ImageManager.isDir8Character = function(filename) {
        var sign = filename.match(/^[\!\$\@]+/);
        return sign && sign[0].contains('@');
    };
    ImageManager.isMultiFrames = function(filename) {
        return /\[f\d+h?\d*\]/i.test(filename);
    };
    ImageManager.getMaxFrame = function(filename) {
        var match = /\[f(\d+)h?\d*\]/i.exec(filename);
        return match ? parseInt(match[1]) : 3;
    };
    ImageManager.getHaltFrame = function(filename) {
        var match = /\[f\d+h(\d+)\]/i.exec(filename);
        return match ? parseInt(match[1]) : 1;
    };
    var _Game_CharacterBaseinitMembers = Game_CharacterBase.prototype.initMembers;
    Game_CharacterBase.prototype.initMembers = function() {
        _Game_CharacterBaseinitMembers.call(this);
        this._idleCount = 0;
        this._isIdle = false;
    };
    var _Game_CharacterBasesetImage = Game_CharacterBase.prototype.setImage;
    Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
        _Game_CharacterBasesetImage.call(this, characterName, characterIndex);
        this._pattern = this._originalPattern = ImageManager.getHaltFrame(characterName);
        if (!this._characterName) {this._characterName = ''};
        if (!this._characterIndex) {this._characterIndex = 0};
        this._originalName = this._characterName;
        if (this.isDir8Character()) {this.setCachePoses()};
    };
    Game_CharacterBase.prototype.setCachePoses = function() {
        this._posesName = {};
        this._posesName["dash"] = ImageManager.loadCharacter(this._originalName + "_DASH");
        this._posesName["idle"] = ImageManager.loadCharacter(this._originalName + "_IDLE");
        if (!_CharAnime.MoveDir8) { return; };
        this._posesName["dir8"] = ImageManager.loadCharacter(this._originalName + "_8D");
        this._posesName["dash_dir8"] = ImageManager.loadCharacter(this._originalName + "_DASH_8D");
        this._posesName["idle_dir8"] = ImageManager.loadCharacter(this._originalName + "_IDLE_8D");
    };
    Game_CharacterBase.prototype.isMultiFrames = function() {
        return ImageManager.isMultiFrames(this._characterName);
    };
    Game_CharacterBase.prototype.maxFrame = function() {
        return ImageManager.getMaxFrame(this._characterName);
    };
    Game_CharacterBase.prototype.isDir8Character = function() {
        return ImageManager.isDir8Character(this._characterName);
    };
    var _Game_CharacterBaseupdate = Game_CharacterBase.prototype.update;
    Game_CharacterBase.prototype.update = function() {
        _Game_CharacterBaseupdate.call(this);
        if (this.needUpdatePoses()) {this.updatePoses()};
        if (this.isDir8Character()) this.updateIdlePoses();
    };
    Game_CharacterBase.prototype.updatePoses = function() {
        this._characterName = this._originalName + this.poses();
    };
    Game_CharacterBase.prototype.needUpdatePoses = function() {
        if (!this.isDir8Character()) {return false};
        if (this._poses == this.poses()) {return false};
        this._poses = this.poses();
        return true;
    };
    Game_CharacterBase.prototype.poses = function() {
        return (this.isIdle() ? '_IDLE' : this.isDash() ? '_DASH' : '') +
            (this.isDir8() && _CharAnime.MoveDir8 ? '_8D' : '');
    };
    var _Game_CharacterBaseupdateStop = Game_CharacterBase.prototype.updateStop;
    Game_CharacterBase.prototype.updateStop = function() {
        _Game_CharacterBaseupdateStop.call(this);
        this._idleCount++;
    };
    var _Game_CharacterBaseresetStopCount = Game_CharacterBase.prototype.resetStopCount;
    Game_CharacterBase.prototype.resetStopCount = function() {
        _Game_CharacterBaseresetStopCount.call(this);
        this._idleCount = 0;
    };
    Game_CharacterBase.prototype.updateIdlePoses = function() {
        if (this._idleCount == this.startIdleTime()) {
            this.setIdleAnime(true);
        } else if (this._idleCount == this.startIdleTime() + this.idleAnimeTime() - 1) {
            this._idleCount = this.startIdleTime() - this.idleIntervalTime();
            this.setIdleAnime(false);
        } else if (this._idleCount < this.startIdleTime()){
            if (this._isIdle) this.setIdleAnime(false);
        }
    };
    // 进入待机前需要的时间
    Game_CharacterBase.prototype.startIdleTime = function() {
        if (!this._startIdleTime) {
            this._startIdleTime = parseInt(Math.random() * (_CharAnime.RandTime + 1));
            this._startIdleTime += _CharAnime.MinTime;
        }
        return this._startIdleTime;
    };
    // 一次待机需要的时间
    Game_CharacterBase.prototype.idleAnimeTime = function() {
        return this.animationWait() * this.maxPattern() * _CharAnime.IdleTimes;
    };
    // 两次待机之间的时间间隔
    Game_CharacterBase.prototype.idleIntervalTime = function() {
        return _CharAnime.GapTime;
    };
    // 设置待机动画
    Game_CharacterBase.prototype.setIdleAnime = function(idleAnime) {
        this._isIdle = idleAnime;
        this.setStepAnime(idleAnime);
    };
    Game_CharacterBase.prototype.animationWait = function() {
        return (9 - this.realMoveSpeed()) * 3;
    };
    var _Game_CharacterBaseanimationWait = Game_CharacterBase.prototype.animationWait;
    Game_CharacterBase.prototype.animationWait = function() {
        var wait = _Game_CharacterBaseanimationWait.call(this);
        return Math.max(wait * this.animationWaitSpeed() / 10, 2);
    };
    Game_CharacterBase.prototype.animationWaitSpeed = function() {
        return Math.max(10 - _CharAnime.AnimationSpeed, 0);
    };
    var _Game_CharacterBasemoveDiagonally = Game_CharacterBase.prototype.moveDiagonally;
    Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) {
        _Game_CharacterBasemoveDiagonally.call(this, horz, vert);
        if (horz > 5) {
            vert > 5 ? this.setDirection(9) : this.setDirection(7);
        } else {
            vert > 5 ? this.setDirection(3) : this.setDirection(1);
        };
    };
    Game_CharacterBase.prototype.pattern = function() {
        return this._pattern < this.maxFrame() ? this._pattern : this.isMultiFrames() ? 0 : 1;
    };
    Game_CharacterBase.prototype.maxPattern = function() {
        return this.maxFrame() === 3 ? 4 : this.maxFrame();
    };
    var _Game_CharacterBasestraighten = Game_CharacterBase.prototype.straighten;
    Game_CharacterBase.prototype.straighten = function() {
        if (this.isMultiFrames()) {
            if (this.hasWalkAnime() || this.hasStepAnime()) this._pattern = this._originalPattern;
            this._animationCount = 0;
        } else {
            _Game_CharacterBasestraighten.call(this);
        }
    };
    Game_CharacterBase.prototype.isOriginalPattern = function() {
        return this.pattern() === this._originalPattern;
    };
    var _Game_CharacterBaseresetPattern = Game_CharacterBase.prototype.resetPattern;
    Game_CharacterBase.prototype.resetPattern = function() {
        if (this.isMultiFrames()) {
            this.setPattern(this._originalPattern);
        } else {
            _Game_CharacterBaseresetPattern.call(this);
        }
    };
    Game_CharacterBase.prototype.isDash = function() {
        return this._idleCount == 0 && (this.isDashing() || this._moveSpeed > 4);
    };
    Game_CharacterBase.prototype.isIdle = function() {
        return this._isIdle;
    };
    Game_CharacterBase.prototype.isDir8 = function() {
        return this.direction() % 2 != 0;
    };
    var _Game_PlayermoveByInput = Game_Player.prototype.moveByInput;
    Game_Player.prototype.moveByInput = function() {
        if (_CharAnime.MoveDir8) {
            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.executeMove(direction);
                        return;
                    }
                    if (direction < 5){
                        this.moveDiagonally(direction + 3 , 2);
                    } else {
                        this.moveDiagonally(direction - 3 , 8);
                    }
                }
            }
        } else {
            _Game_PlayermoveByInput.call(this);
        }
    };
    var _Game_PlayermoveDiagonally = 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;
        }
        _Game_PlayermoveDiagonally.call(this, horz, vert);
    };
    var _Game_Followerupdate = Game_Follower.prototype.update
    Game_Follower.prototype.update = function() {
        _Game_Followerupdate.call(this);
        this._stepAnime = this.isIdle();
    };
    Game_Event.prototype.updateIdlePoses = function() {
        if (this.noteIsIdle()) Game_CharacterBase.prototype.updateIdlePoses.call(this);
    };
    Game_Event.prototype.noteIsIdle = function() {
        var _list = this.list();
        for(var event of _list){
            if (event.code == 108 || event.code == 408) {
                if ((new RegExp(_CharAnime.IdleAnime)).test(event.parameters[0])) {return true}
            }
        }
        return false;
    };
    Sprite_Character.prototype.characterPatternY = function() {
        if (this._character.direction() % 2 == 0){
            return (this._character.direction() - 2) / 2;
        } else {
            var _dir = this._character.direction();
            if (this._character.isDir8Character()){
                _dir = (_dir == 3 || _dir == 7) ? 10 - _dir : _dir;
            };
            return parseInt((_dir + 1) / 3);
        }
    };
    Sprite_Character.prototype.patternWidth = function() {
        if (this._tileId > 0) {
            return $gameMap.tileWidth();
        } else if (this._isBigCharacter) {
            return this.bitmap.width / this._character.maxFrame();
        } else {
            return this.bitmap.width / (this._character.maxFrame() * 4);
        }
    };
    Sprite_Character.prototype.characterBlockX = function() {
        if (this._isBigCharacter) {
            return 0;
        } else {
            var index = this._character.characterIndex();
            return (index % 4) * this._character.maxFrame();
        }
    };
}();
void function(){
    var _Window_BasedrawCharacter = Window_Base.prototype.drawCharacter;
    Window_Base.prototype.drawCharacter = function(characterName, characterIndex, x, y) {
        if (ImageManager.isMultiFrames(characterName)) {
            var frames = ImageManager.getMaxFrame(characterName);
            var bitmap = ImageManager.loadCharacter(characterName);
            var big = ImageManager.isBigCharacter(characterName);
            var pw = bitmap.width / (big ? frames : frames * 4);
            var ph = bitmap.height / (big ? 4 : 8);
            var n = characterIndex;
            var sx = (n % 4 * 3 + 1) * pw;
            var sy = (Math.floor(n / 4) * 4) * ph;
            this.contents.blt(bitmap, sx, sy, pw, ph, x - pw / 2, y - ph);
        } else {
            _Window_BasedrawCharacter.call(this, characterName, characterIndex, x, y)
        }
    };
}();[/pre][/fold][fold=1.0旧版本 (各姿势素材在同一张行走图上)]
[pre lang="JAVASCRIPT"]//=============================================================================
// VIPArcher_Character_Animations.js
//=============================================================================
/*:
* @plugindesc 行走图动画扩展,八方向|奔跑|待机|多帧
* @author VIPArcher
*
* @param Dir8_Flag
* @desc 素材使用该脚本的标志
* @default %
*
* @param Frames_Flag
* @desc 设置帧数的标志
* @default #
*
* @param Stand_Wait
* @desc 站立等待时长(帧)
* @default 60
*
* @help 使用该脚本的行走图素材文件名前面添加一个标志:默认为 %
* 文件名的名为规范(默认设置)如下:
* %VIPArcher.png , 素材为2*4的标志素材
* 第一行:第一个格子是四方向,第二个格子是四方向奔跑,第三个是四方向待机;
* 第二行:第一个格子是八方向,第二个格子是八方向奔跑,第三个是八方向待机;
*
* 使用多帧则名为(默认设置): 文件名#帧数,默认帧.png
* 例如 %VIPArcher#6,3.png
*/
(function() {
    var parameters = PluginManager.parameters('VIPArcher_Character_Animations');
    var dir8_flag  = String(parameters['Dir8_Flag']   || '%');
    var frame_flag = String(parameters['Frames_Flag'] || '#');
    var stand_wait = String(parameters['Stand_Wait']  || '60');
    ImageManager.isDir8Character = function(filename) {
        var reg = new RegExp("^\[\\!\\$\\" + dir8_flag + ']+');
        var sign = filename.match(reg);
        return sign && sign[0].contains(dir8_flag);
    };
    var _Game_CharacterBaseinitMembers = Game_CharacterBase.prototype.initMembers;
    Game_CharacterBase.prototype.initMembers = function() {
        _Game_CharacterBaseinitMembers.call(this);
        this._standWait = 0;
        this._isStand = false;
        this._isDir8Character = false;
    };
    var _Game_CharacterBasesetImage = Game_CharacterBase.prototype.setImage;
    Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
        _Game_CharacterBasesetImage.call(this, characterName, characterIndex);
        this.getCharacterMaxFrame(characterName);
        if (ImageManager.isDir8Character(characterName)) {
            this._characterIndex  = 0;
            this._isDir8Character = true;
        };
    };
    var _Game_CharacterBaseupdate = Game_CharacterBase.prototype.update;
    Game_CharacterBase.prototype.update = function() {
        _Game_CharacterBaseupdate.call(this);
        if (this.isMoving()) {
            this._standWait = 0;
            this._isStand = false;
            if (this._isDir8Character) { this._stepAnime = false };
        } else {
            this._standWait += 1;
            if (this._standWait > parseInt(stand_wait)) {
                this._isStand = true;
                if (this._isDir8Character) { this._stepAnime = true };
            };
        };
    };
    var _Game_CharacterBasemoveDiagonally = Game_CharacterBase.prototype.moveDiagonally;
    Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) {
        _Game_CharacterBasemoveDiagonally.call(this, horz, vert);
        if (horz > 5) {
            vert > 5 ? this.setDirection(9) : this.setDirection(7);
        } else {
            vert > 5 ? this.setDirection(3) : this.setDirection(1);
        };
    };
    Game_CharacterBase.prototype.getCharacterMaxFrame = function(characterName) {
        var framedate = characterName.match(new RegExp(frame_flag + "(\\d+),(\\d+)"));
        if (framedate) {
            this._maxFrame = parseInt(framedate[1]);
            this._formerPattern = parseInt(framedate[2]);
        } else{
            this._maxFrame = 3;
            this._formerPattern = 1;
        };
    };
    Game_CharacterBase.prototype.pattern = function() {
        return this._pattern < this.maxFrame() ? this._pattern : 1;
    };
    Game_CharacterBase.prototype.maxFrame = function() {
        return this._maxFrame;
    };
    Game_CharacterBase.prototype.maxPattern = function() {
        if (this._maxFrame === 3) {
            return 4;
        } else {
            return this._maxFrame;
        };
    };
    Game_CharacterBase.prototype.isOriginalPattern = function() {
        return this.pattern() === this._formerPattern;
    };
    Game_CharacterBase.prototype.resetPattern = function() {
        this.setPattern(this._formerPattern);
    };
    Game_CharacterBase.prototype.isFast = function() {
        return this._standWait < 2 && (this.isDashing() || this._moveSpeed > 4);
    };
    Game_CharacterBase.prototype.isStand = function() {
        return this._isStand;
    };
    Game_CharacterBase.prototype.setCharacterIndex = function(index) {
        this._characterIndex = index;
    };
    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 _Game_PlayermoveDiagonally = 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;
        }
        _Game_PlayermoveDiagonally.call(this, horz, vert);
    };
    Sprite_Character.prototype.characterPatternY = function() {
        if (this._character.direction() % 2 == 0){
            if (this._character._isDir8Character){
                this._character.setCharacterIndex(this._character.isFast() ? 1 : this._character.isStand() ? 2 : 0);
            };
            return (this._character.direction() - 2) / 2;
        } else {
            if (this._character._isDir8Character){
                this._character.setCharacterIndex(this._character.isFast() ? 5 : this._character.isStand() ? 6 : 4);
            };
            return parseInt((this._character.direction() + 1) / 3);
        }
    };
    Sprite_Character.prototype.patternWidth = function() {
        if (this._tileId > 0) {
            return $gameMap.tileWidth();
        } else if (this._isBigCharacter) {
            return this.bitmap.width / this._character.maxFrame();
        } else {
            return this.bitmap.width / (this._character.maxFrame() * 4);
        }
    };
    Sprite_Character.prototype.characterBlockX = function() {
        if (this._isBigCharacter) {
            return 0;
        } else {
            var index = this._character.characterIndex();
            return (index % 4) * this._character.maxFrame();
        }
    };
})();[/pre][/fold]
有啥问题就直接回帖子反馈吧,我没素材进行测试,理论上应该是可以玩了。
[fold=配一张瞎糊的测试用素材(1.0版本使用)]

%Actor1.png

%Actor1.png
[/fold]
1.5版本素材规格参考这个帖子:
https://rpg.blue/thread-411249-1-1.html

VIPArcher_Character_Animations.zip

2.05 KB, 下载次数: 1755

js文件

点评

说版本太旧用不了了, 大大要不有空更新一下~~  发表于 2021-11-26 18:31
https://rpg.blue/forum.php?mod=redirect&goto=findpost&ptid=487885&pid=2936642&fromuid=2652223  发表于 2021-11-26 18:30

评分

参与人数 2星屑 +60 梦石 +2 收起 理由
余烬之中 + 2 图 书 馆
doranikofu + 60 塞糖

查看全部评分

梦石
0
星屑
676
在线时间
224 小时
注册时间
2006-12-7
回帖
780
发表于 2015-11-30 01:39:40 | 显示全部楼层
那啥文件名前缀特殊符号好像挺多内置设定的
用%前缀 貌似跟随人物关闭之后还是会显示而且显示出错 都改成数字前缀了不敢随便用特殊符号了

点评

用多帧的话需要细节改进,哥目前是待机-行走-跑步。待机动作默认第一帧不step,等待时间满了以后再step,而且只放一次,打算改一下这个  发表于 2015-11-30 02:02
汝这个没问题 之前不知道改了啥 死活找不到问题在哪 隐藏跟随的话就找到一个函数吧visible变量设置成false 不知道为啥读取错误 后来把前缀改了就好了  发表于 2015-11-30 01:59
显示啥出错?我测试貌似没啥问题【不过我也没怎么测试过  发表于 2015-11-30 01:42
回复

使用道具 举报

梦石
0
星屑
676
在线时间
224 小时
注册时间
2006-12-7
回帖
780
发表于 2015-11-30 03:14:06 | 显示全部楼层
改了一下适应不同需求
改动:
1.图片顺序改成:待机-行走-跑步
2.增加待机动画播放等待时间。移动停止之后,插件原始变量等待时间到达之后会切换到待机动画默认帧(插件里frames flag变量)的那一帧。继续等待Idle_Wait之后才开始播放待机动画
3.待机动画播放到最大帧之后会停留在这一帧,不会循环播放(需要的话可以加变量设置是否需要循环)
4.微调整显示。从行走动作切换到待机动作之后,直接切换回待机动作的初始帧。

如果做多帧的话动作衔接细节要复杂一些,比如行走动画循环里面不能插入待机动作的帧,所以需要分开设置。共享两个10帧的行走图可以体验一下
已经测试了npc,跟随人物和主角都没有问题。唯一的麻烦点的就是目前跑步动作判定似乎是按照速度,这样如果主角行走速度低的话,跑起来跟随人物还是行走动作。因为跟随人物的数值基本都是主角抄过来的。

修改过的代码
[pre lang="javascript"]//=============================================================================
// VIPArcher_Character_Animations.js edited by doranikofu
//=============================================================================
/*:
* @plugindesc 行走图动画扩展,八方向|奔跑|待机|多帧
* @author VIPArcher
*
* @param Dir8_Flag
* @desc 素材使用该脚本的标志
* @default %
*
* @param Frames_Flag
* @desc 设置帧数的标志
* @default #
*
* @param Stand_Wait
* @desc 站立等待时长(帧)
* @default 5
*
* @param Idle_Wait
* @desc 待机动画开始等待时长(帧) 从站立等待之后开始计算
* @default 120
*
* @help 使用该脚本的行走图素材文件名前面添加一个标志:默认为 %
* 文件名的名为规范(默认设置)如下:
* %VIPArcher.png , 素材为2*4的标志素材
* 第一行:第一个格子是四方向,第二个格子是四方向奔跑,第三个是四方向待机;//doranikofu edit 顺序改成:待机-行走-奔跑
* 第二行:第一个格子是八方向,第二个格子是八方向奔跑,第三个是八方向待机;
*
* 使用多帧则名为(默认设置): 文件名#帧数,默认帧.png
* 例如 %VIPArcher#6,3.png
*/
(function() {
    var parameters = PluginManager.parameters('VIPArcher_Character_Animations');
    var dir8_flag  = String(parameters['Dir8_Flag']   || '%');
    var frame_flag = String(parameters['Frames_Flag'] || '#');
    var stand_wait = String(parameters['Stand_Wait']  || '5');
    var idle_wait = String(parameters['Idle_Wait']  || '120');
    ImageManager.isDir8Character = function(filename) {
        var reg = new RegExp("^\[\\!\\$\\" + dir8_flag + ']+');
        var sign = filename.match(reg);
        return sign && sign[0].contains(dir8_flag);
    };
    var _Game_CharacterBaseinitMembers = Game_CharacterBase.prototype.initMembers;
    Game_CharacterBase.prototype.initMembers = function() {
        _Game_CharacterBaseinitMembers.call(this);
        this._standWait = 0;
                this._stepstop = false;        //doranikofu stop cylcing idle anime flag
       //doranikofu                this._isStand = false;
                this._isStand = true;
        this._isDir8Character = false;
    };
    var _Game_CharacterBasesetImage = Game_CharacterBase.prototype.setImage;
    Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
        _Game_CharacterBasesetImage.call(this, characterName, characterIndex);
        this.getCharacterMaxFrame(characterName);
        if (ImageManager.isDir8Character(characterName)) {
            this._characterIndex  = 0;
            this._isDir8Character = true;
        };
    };
    var _Game_CharacterBaseupdate = Game_CharacterBase.prototype.update;
    Game_CharacterBase.prototype.update = function() {
        _Game_CharacterBaseupdate.call(this);
        if (this.isMoving()) {
            this._standWait = 0;
            this._isStand = false;
            if (this._isDir8Character) { this._stepAnime = false };
        } else {
            this._standWait += 1;
                        if (this._standWait == parseInt(stand_wait)) {                //doranikofu
                this._isStand = true;                                                        //
                                this._pattern = 0;                                                                //reset to default frame after switching to idle to avoid big pose jumps
                                this._stepstop = false;                                                        // reset flag
                        };                                                                                                        //
                if (this._standWait > parseInt(stand_wait)) {
                            if ((this._isDir8Character) && (this._standWait > (parseInt(stand_wait) + parseInt(idle_wait)))) {        //doranikofu add idle wait
                                                this._stepAnime = true;
                                                if (this._pattern == this._maxFrame - 1) this._stepstop = true;
                                                if (this._stepstop) this._pattern = this._maxFrame - 1;
                                                };
            };
        };
    };
    var _Game_CharacterBasemoveDiagonally = Game_CharacterBase.prototype.moveDiagonally;
    Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) {
        _Game_CharacterBasemoveDiagonally.call(this, horz, vert);
        if (horz > 5) {
            vert > 5 ? this.setDirection(9) : this.setDirection(7);
        } else {
            vert > 5 ? this.setDirection(3) : this.setDirection(1);
        };
    };
    Game_CharacterBase.prototype.getCharacterMaxFrame = function(characterName) {
        var framedate = characterName.match(new RegExp(frame_flag + "(\\d+),(\\d+)"));
        if (framedate) {
            this._maxFrame = parseInt(framedate[1]);
            this._formerPattern = parseInt(framedate[2]);
        } else{
            this._maxFrame = 3;
            this._formerPattern = 1;
        };
    };
    Game_CharacterBase.prototype.pattern = function() {
        return this._pattern < this.maxFrame() ? this._pattern : 1;
    };
    Game_CharacterBase.prototype.maxFrame = function() {
        return this._maxFrame;
    };
    Game_CharacterBase.prototype.maxPattern = function() {
        if (this._maxFrame === 3) {
            return 4;
        } else {
            return this._maxFrame;
        };
    };
    Game_CharacterBase.prototype.isOriginalPattern = function() {
        return this.pattern() === this._formerPattern;
    };
    Game_CharacterBase.prototype.resetPattern = function() {
        this.setPattern(this._formerPattern);
    };
    Game_CharacterBase.prototype.isFast = function() {
        return this._standWait < 2 && (this.isDashing() || this._moveSpeed > 4);
    };
    Game_CharacterBase.prototype.isStand = function() {
        return this._isStand;
    };
    Game_CharacterBase.prototype.setCharacterIndex = function(index) {
        this._characterIndex = index;
    };
    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 _Game_PlayermoveDiagonally = 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;
        }
        _Game_PlayermoveDiagonally.call(this, horz, vert);
    };
    Sprite_Character.prototype.characterPatternY = function() {
        if (this._character.direction() % 2 == 0){
            if (this._character._isDir8Character){
                this._character.setCharacterIndex(this._character.isFast() ? 2 : this._character.isStand() ? 0 : 1);        //doranikofu changed index
            };
            return (this._character.direction() - 2) / 2;
        } else {
            if (this._character._isDir8Character){
                this._character.setCharacterIndex(this._character.isFast() ? 6 : this._character.isStand() ? 4 : 5);        //doranikofu changed index
            };
            return parseInt((this._character.direction() + 1) / 3);
        }
    };
    Sprite_Character.prototype.patternWidth = function() {
        if (this._tileId > 0) {
            return $gameMap.tileWidth();
        } else if (this._isBigCharacter) {
            return this.bitmap.width / this._character.maxFrame();
        } else {
            return this.bitmap.width / (this._character.maxFrame() * 4);
        }
    };
    Sprite_Character.prototype.characterBlockX = function() {
        if (this._isBigCharacter) {
            return 0;
        } else {
            var index = this._character.characterIndex();
            return (index % 4) * this._character.maxFrame();
        }
    };
})();[/pre]

效果图, 左下是主角和跟随的待机,右上是npc

效果图

效果图


素材图下载-自己做的仙剑奇侠传5前传人物模型渲染拼好的图
characters.rar (3.5 MB, 下载次数: 2825)

评分

参与人数 2星屑 +11 收起 理由
夏末渐离 + 10 我很赞同
西姐 + 1 精品文章

查看全部评分

回复

使用道具 举报

梦石
0
星屑
676
在线时间
224 小时
注册时间
2006-12-7
回帖
780
发表于 2015-12-15 14:01:50 | 显示全部楼层
最近改了一些,往文件名里面塞参数判定是否需要全部3中动作还是只要一部分

不过貌似和npc对话的时候没有8向判定么,菊苣打算做一个么?

点评

待机状态好像不是循环的,你应该是用的@doranikofu 改了之后的版本,你看他写的改动说明就知道了。=。= 拼素材按脚本说明里说的方式拼就可以了  发表于 2015-12-16 23:02
之前试了一下,待机状态好像不是循环的,手抬起来之后就不动了。我只有八帧的行走图,一样格式的拼有用吗  发表于 2015-12-16 17:13
我现在也觉得合并文件好√。还是那句话:拼一下素材又不难。  发表于 2015-12-16 13:13
合并文件比较好,之前分文件的时候,第一次切换动作有明显卡顿,这次mv读文件似乎是比较慢。如果一个文件存的话只会第一次进场景慢一点  发表于 2015-12-16 09:50
是 斜向触发事件的时候如果是八向npc的话要能也斜向回应就好了,目前是触发不了  发表于 2015-12-16 09:49
回复

使用道具 举报

梦石
0
星屑
60
在线时间
77 小时
注册时间
2015-12-10
回帖
14
发表于 2015-12-15 15:08:43 | 显示全部楼层
搞大量行走图存在的意义?  公共事件如果C被按下加速+1,换主角奔跑行走图 不就实现了吗

点评

请问如何设置C或者别的什么键被按下,事件脚本还是别的?  发表于 2019-1-18 09:30
回复 0 2

使用道具 举报

梦石
0
星屑
676
在线时间
224 小时
注册时间
2006-12-7
回帖
780
发表于 2015-12-18 06:19:53 | 显示全部楼层
还有一个问题
最近用那个analog move插件 SAN_AnalogMove
那个里面方向3是右下,方向7是左上,是他搞错了么
默认脚本里面有奇数的方向定义么
用这个插件的话鼠标移动会流畅好多,不过方向3/7会抽,还没彻底解决
改这两个替换3/7只后显示正常了
Game_AnalogMove.prototype.dir8ToRadian
Game_AnalogMove.prototype.radianToDir8

但是
Game_AnalogMove.prototype.dir8ToRadian
改了以后键盘如果右下的话人物左上移动
键盘左上人物右下移动。。。鼠标移动不影响

不改的话控制正常,但是切换场景的时候如果保留方向,左上移动切换场景就自动变成右下方向了。。。
回复

使用道具 举报

梦石
0
星屑
556
在线时间
224 小时
注册时间
2011-8-15
回帖
77
发表于 2015-12-26 11:09:34 | 显示全部楼层
8 帧有问题的,明显在2帧之间晃动
回复

使用道具 举报

梦石
0
星屑
556
在线时间
224 小时
注册时间
2011-8-15
回帖
77
发表于 2015-12-26 11:33:03 | 显示全部楼层
已经找到问题了,但是待机动画的时候不是循环的吗?单独播放一次后就停住了

点评

PS,开切片工具或者网格或者辅助线  发表于 2015-12-28 19:13
我能问你一下,你是怎么拼八方向图的。。我拼出来的老是不对,我的素材比较大  发表于 2015-12-28 19:03
是循环的,主楼的原版插件就是循环的 @doranikofu 改过的版本是不循环的。你可以自己选择使用  发表于 2015-12-26 11:54
回复

使用道具 举报

梦石
0
星屑
275
在线时间
2 小时
注册时间
2010-11-18
回帖
1
发表于 2015-12-28 16:34:56 | 显示全部楼层
我想问一下大大们, 怎样保持四方向然后又能使用多帧的行走图咧?  在下小白 麻烦大大们帮忙解答啦!!拜托啦!!

点评

那你把八方向的部分素材也用四方向的就好了呗。  发表于 2015-12-28 17:04
回复

使用道具 举报

梦石
0
星屑
556
在线时间
224 小时
注册时间
2011-8-15
回帖
77
发表于 2015-12-29 16:13:38 | 显示全部楼层
aaaassss123 发表于 2015-12-26 11:33
已经找到问题了,但是待机动画的时候不是循环的吗?单独播放一次后就停住了 ...

那个拼图上面应该有发出来,原版的应该是行走-待机-跑步,改版的是待机-行走-跑步,第二行则是8方向的,我只用到4方向。所以第二行是和第一行一样的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部