查看: 43026|回复: 76

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

[复制链接]

无限の剣制

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

开拓者贵宾

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

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

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

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

1.5新版本 (使用多文件以后缀名区分姿势)
  1. //=============================================================================
  2. // VIPArcher_CharacterPoses.js
  3. //=============================================================================
  4. /*:
  5. * @plugindesc 行走图多姿势动画扩展,多帧|八方向|奔跑|待机
  6. * @author VIPArcher
  7. *
  8. * @param MoveDir8
  9. * @desc 是否启用 8 方向移动
  10. * Default: true (启用: true / 不启用: false)
  11. * @default true
  12. * @type boolean
  13. *
  14. * @param AnimationSpeed
  15. * @desc 加快帧动画速度程度
  16. * 1 到 10 之间的数字
  17. * @default 0
  18. * @type number
  19. *
  20. * @param GapTime
  21. * @desc 两次待机之间等待的帧数
  22. * @default 120
  23. * @type number
  24. *
  25. * @param MinTime
  26. * @desc 进入待机前最短要等待的帧数
  27. * @default 120
  28. * @type number
  29. *
  30. * @param RandTime
  31. * @desc 在最短时间上额外随机等待的帧数范围
  32. * @default 120
  33. * @type number
  34. *
  35. * @param IdleTimes
  36. * @desc 一次待机动画循环的次数
  37. * @default 1
  38. * @type number
  39. *
  40. * @param NoteIdle
  41. * @desc 事件使用待机动画的注释
  42. * @default <idleAnime>
  43. * @type string
  44. *
  45. * @help 使用该脚本的行走图素材文件名前面添加一个标志 @(英文半角)
  46. * 文件名的命名规范如下:
  47. * @VIPArcher.png 或者 $@VIPArcher.png
  48. *   ◆ 然后必须提供配套的不同姿势素材,各姿势素材命名如下:
  49. * · (普通姿势斜方向):FILE_NAME + _8D.png
  50. * · (奔跑姿势四方向):FILE_NAME + _DASH.png
  51. * · (奔跑姿势斜方向):FILE_NAME + _DASH_8D.png
  52. * · (待机姿势四方向):FILE_NAME + _IDLE.png
  53. * · (待机姿势斜方向):FILE_NAME + _IDLE_8D.png
  54. *   ◆ 使用多帧则名为(默认设置): @文件名[f帧数h静止帧].png
  55. *   例如 @VIPArcher[f8h1].png
  56. */
  57. var VIPArcher = VIPArcher || {};
  58. VIPArcher.CharAnime = {};
  59. VIPArcher.CharAnime.version = '1.5.0';
  60. void function() {
  61.     var _CharAnime = VIPArcher.CharAnime;
  62.     _CharAnime.Parameters = PluginManager.parameters('VIPArcher_CharacterPoses');
  63.     _CharAnime.MoveDir8   = Boolean(_CharAnime.Parameters['MoveDir8'] === 'true' || false);
  64.     _CharAnime.AnimationSpeed = Number(_CharAnime.Parameters['AnimationSpeed'] || 0);
  65.     _CharAnime.GapTime   = Number(_CharAnime.Parameters['GapTime']   || 120);
  66.     _CharAnime.MinTime   = Number(_CharAnime.Parameters['MinTime']   || 120);
  67.     _CharAnime.RandTime  = Number(_CharAnime.Parameters['RandTime']  || 120);
  68.     _CharAnime.IdleTimes = Number(_CharAnime.Parameters['IdleTimes'] || 1);
  69.     _CharAnime.NoteIdle  = String(_CharAnime.Parameters['NoteIdle']  || '<idleAnime>');
  70.     ImageManager.isDir8Character = function(filename) {
  71.         var sign = filename.match(/^[\!\$\@]+/);
  72.         return sign && sign[0].contains('@');
  73.     };
  74.     ImageManager.isMultiFrames = function(filename) {
  75.         return /\[f\d+h?\d*\]/i.test(filename);
  76.     };
  77.     ImageManager.getMaxFrame = function(filename) {
  78.         var match = /\[f(\d+)h?\d*\]/i.exec(filename);
  79.         return match ? parseInt(match[1]) : 3;
  80.     };
  81.     ImageManager.getHaltFrame = function(filename) {
  82.         var match = /\[f\d+h(\d+)\]/i.exec(filename);
  83.         return match ? parseInt(match[1]) : 1;
  84.     };
  85.     var _Game_CharacterBaseinitMembers = Game_CharacterBase.prototype.initMembers;
  86.     Game_CharacterBase.prototype.initMembers = function() {
  87.         _Game_CharacterBaseinitMembers.call(this);
  88.         this._idleCount = 0;
  89.         this._isIdle = false;
  90.     };
  91.     var _Game_CharacterBasesetImage = Game_CharacterBase.prototype.setImage;
  92.     Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
  93.         _Game_CharacterBasesetImage.call(this, characterName, characterIndex);
  94.         this._pattern = this._originalPattern = ImageManager.getHaltFrame(characterName);
  95.         if (!this._characterName) {this._characterName = ''};
  96.         if (!this._characterIndex) {this._characterIndex = 0};
  97.         this._originalName = this._characterName;
  98.         if (this.isDir8Character()) {this.setCachePoses()};
  99.     };
  100.     Game_CharacterBase.prototype.setCachePoses = function() {
  101.         this._posesName = {};
  102.         this._posesName["dash"] = ImageManager.loadCharacter(this._originalName + "_DASH");
  103.         this._posesName["idle"] = ImageManager.loadCharacter(this._originalName + "_IDLE");
  104.         if (!_CharAnime.MoveDir8) { return; };
  105.         this._posesName["dir8"] = ImageManager.loadCharacter(this._originalName + "_8D");
  106.         this._posesName["dash_dir8"] = ImageManager.loadCharacter(this._originalName + "_DASH_8D");
  107.         this._posesName["idle_dir8"] = ImageManager.loadCharacter(this._originalName + "_IDLE_8D");
  108.     };
  109.     Game_CharacterBase.prototype.isMultiFrames = function() {
  110.         return ImageManager.isMultiFrames(this._characterName);
  111.     };
  112.     Game_CharacterBase.prototype.maxFrame = function() {
  113.         return ImageManager.getMaxFrame(this._characterName);
  114.     };
  115.     Game_CharacterBase.prototype.isDir8Character = function() {
  116.         return ImageManager.isDir8Character(this._characterName);
  117.     };
  118.     var _Game_CharacterBaseupdate = Game_CharacterBase.prototype.update;
  119.     Game_CharacterBase.prototype.update = function() {
  120.         _Game_CharacterBaseupdate.call(this);
  121.         if (this.needUpdatePoses()) {this.updatePoses()};
  122.         if (this.isDir8Character()) this.updateIdlePoses();
  123.     };
  124.     Game_CharacterBase.prototype.updatePoses = function() {
  125.         this._characterName = this._originalName + this.poses();
  126.     };
  127.     Game_CharacterBase.prototype.needUpdatePoses = function() {
  128.         if (!this.isDir8Character()) {return false};
  129.         if (this._poses == this.poses()) {return false};
  130.         this._poses = this.poses();
  131.         return true;
  132.     };
  133.     Game_CharacterBase.prototype.poses = function() {
  134.         return (this.isIdle() ? '_IDLE' : this.isDash() ? '_DASH' : '') +
  135.             (this.isDir8() && _CharAnime.MoveDir8 ? '_8D' : '');
  136.     };
  137.     var _Game_CharacterBaseupdateStop = Game_CharacterBase.prototype.updateStop;
  138.     Game_CharacterBase.prototype.updateStop = function() {
  139.         _Game_CharacterBaseupdateStop.call(this);
  140.         this._idleCount++;
  141.     };
  142.     var _Game_CharacterBaseresetStopCount = Game_CharacterBase.prototype.resetStopCount;
  143.     Game_CharacterBase.prototype.resetStopCount = function() {
  144.         _Game_CharacterBaseresetStopCount.call(this);
  145.         this._idleCount = 0;
  146.     };
  147.     Game_CharacterBase.prototype.updateIdlePoses = function() {
  148.         if (this._idleCount == this.startIdleTime()) {
  149.             this.setIdleAnime(true);
  150.         } else if (this._idleCount == this.startIdleTime() + this.idleAnimeTime() - 1) {
  151.             this._idleCount = this.startIdleTime() - this.idleIntervalTime();
  152.             this.setIdleAnime(false);
  153.         } else if (this._idleCount < this.startIdleTime()){
  154.             if (this._isIdle) this.setIdleAnime(false);
  155.         }
  156.     };
  157.     // 进入待机前需要的时间
  158.     Game_CharacterBase.prototype.startIdleTime = function() {
  159.         if (!this._startIdleTime) {
  160.             this._startIdleTime = parseInt(Math.random() * (_CharAnime.RandTime + 1));
  161.             this._startIdleTime += _CharAnime.MinTime;
  162.         }
  163.         return this._startIdleTime;
  164.     };
  165.     // 一次待机需要的时间
  166.     Game_CharacterBase.prototype.idleAnimeTime = function() {
  167.         return this.animationWait() * this.maxPattern() * _CharAnime.IdleTimes;
  168.     };
  169.     // 两次待机之间的时间间隔
  170.     Game_CharacterBase.prototype.idleIntervalTime = function() {
  171.         return _CharAnime.GapTime;
  172.     };
  173.     // 设置待机动画
  174.     Game_CharacterBase.prototype.setIdleAnime = function(idleAnime) {
  175.         this._isIdle = idleAnime;
  176.         this.setStepAnime(idleAnime);
  177.     };
  178.     Game_CharacterBase.prototype.animationWait = function() {
  179.         return (9 - this.realMoveSpeed()) * 3;
  180.     };
  181.     var _Game_CharacterBaseanimationWait = Game_CharacterBase.prototype.animationWait;
  182.     Game_CharacterBase.prototype.animationWait = function() {
  183.         var wait = _Game_CharacterBaseanimationWait.call(this);
  184.         return Math.max(wait * this.animationWaitSpeed() / 10, 2);
  185.     };
  186.     Game_CharacterBase.prototype.animationWaitSpeed = function() {
  187.         return Math.max(10 - _CharAnime.AnimationSpeed, 0);
  188.     };
  189.     var _Game_CharacterBasemoveDiagonally = Game_CharacterBase.prototype.moveDiagonally;
  190.     Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) {
  191.         _Game_CharacterBasemoveDiagonally.call(this, horz, vert);
  192.         if (horz > 5) {
  193.             vert > 5 ? this.setDirection(9) : this.setDirection(7);
  194.         } else {
  195.             vert > 5 ? this.setDirection(3) : this.setDirection(1);
  196.         };
  197.     };
  198.     Game_CharacterBase.prototype.pattern = function() {
  199.         return this._pattern < this.maxFrame() ? this._pattern : this.isMultiFrames() ? 0 : 1;
  200.     };
  201.     Game_CharacterBase.prototype.maxPattern = function() {
  202.         return this.maxFrame() === 3 ? 4 : this.maxFrame();
  203.     };
  204.     var _Game_CharacterBasestraighten = Game_CharacterBase.prototype.straighten;
  205.     Game_CharacterBase.prototype.straighten = function() {
  206.         if (this.isMultiFrames()) {
  207.             if (this.hasWalkAnime() || this.hasStepAnime()) this._pattern = this._originalPattern;
  208.             this._animationCount = 0;
  209.         } else {
  210.             _Game_CharacterBasestraighten.call(this);
  211.         }
  212.     };
  213.     Game_CharacterBase.prototype.isOriginalPattern = function() {
  214.         return this.pattern() === this._originalPattern;
  215.     };
  216.     var _Game_CharacterBaseresetPattern = Game_CharacterBase.prototype.resetPattern;
  217.     Game_CharacterBase.prototype.resetPattern = function() {
  218.         if (this.isMultiFrames()) {
  219.             this.setPattern(this._originalPattern);
  220.         } else {
  221.             _Game_CharacterBaseresetPattern.call(this);
  222.         }
  223.     };
  224.     Game_CharacterBase.prototype.isDash = function() {
  225.         return this._idleCount == 0 && (this.isDashing() || this._moveSpeed > 4);
  226.     };
  227.     Game_CharacterBase.prototype.isIdle = function() {
  228.         return this._isIdle;
  229.     };
  230.     Game_CharacterBase.prototype.isDir8 = function() {
  231.         return this.direction() % 2 != 0;
  232.     };
  233.     var _Game_PlayermoveByInput = Game_Player.prototype.moveByInput;
  234.     Game_Player.prototype.moveByInput = function() {
  235.         if (_CharAnime.MoveDir8) {
  236.             if (!this.isMoving() && this.canMove()) {
  237.                 var direction = Input.dir8;
  238.                 if (direction > 0) {
  239.                     $gameTemp.clearDestination();
  240.                 } else if ($gameTemp.isDestinationValid()){
  241.                     var x = $gameTemp.destinationX();
  242.                     var y = $gameTemp.destinationY();
  243.                     direction = this.findDirectionTo(x, y);
  244.                 };
  245.                 if (direction > 0) {
  246.                     if (direction % 2 == 0){
  247.                         this.executeMove(direction);
  248.                         return;
  249.                     }
  250.                     if (direction < 5){
  251.                         this.moveDiagonally(direction + 3 , 2);
  252.                     } else {
  253.                         this.moveDiagonally(direction - 3 , 8);
  254.                     }
  255.                 }
  256.             }
  257.         } else {
  258.             _Game_PlayermoveByInput.call(this);
  259.         }
  260.     };
  261.     var _Game_PlayermoveDiagonally = Game_Player.prototype.moveDiagonally;
  262.     Game_Player.prototype.moveDiagonally = function(horz, vert) {
  263.         if (!this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
  264.             this.setMovementSuccess(false);
  265.             return;
  266.         }
  267.         if (this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
  268.             this.moveStraight(horz);
  269.             return;
  270.         }
  271.         if (this.canPass(this._x, this._y, vert) && !this.canPass(this._x, this._y, horz)){
  272.             this.moveStraight(vert);
  273.             return;
  274.         }
  275.         if (!this.canPassDiagonally(this._x, this._y, horz, vert)) {
  276.             if (Math.random() > 0.5){
  277.                 this.setDirection(vert); this.moveStraight(vert);
  278.             } else {
  279.                 this.setDirection(horz); this.moveStraight(horz);
  280.             }
  281.             return;
  282.         }
  283.         _Game_PlayermoveDiagonally.call(this, horz, vert);
  284.     };
  285.     var _Game_Followerupdate = Game_Follower.prototype.update
  286.     Game_Follower.prototype.update = function() {
  287.         _Game_Followerupdate.call(this);
  288.         this._stepAnime = this.isIdle();
  289.     };
  290.     Game_Event.prototype.updateIdlePoses = function() {
  291.         if (this.noteIsIdle()) Game_CharacterBase.prototype.updateIdlePoses.call(this);
  292.     };
  293.     Game_Event.prototype.noteIsIdle = function() {
  294.         var _list = this.list();
  295.         for(var event of _list){
  296.             if (event.code == 108 || event.code == 408) {
  297.                 if ((new RegExp(_CharAnime.IdleAnime)).test(event.parameters[0])) {return true}
  298.             }
  299.         }
  300.         return false;
  301.     };
  302.     Sprite_Character.prototype.characterPatternY = function() {
  303.         if (this._character.direction() % 2 == 0){
  304.             return (this._character.direction() - 2) / 2;
  305.         } else {
  306.             var _dir = this._character.direction();
  307.             if (this._character.isDir8Character()){
  308.                 _dir = (_dir == 3 || _dir == 7) ? 10 - _dir : _dir;
  309.             };
  310.             return parseInt((_dir + 1) / 3);
  311.         }
  312.     };
  313.     Sprite_Character.prototype.patternWidth = function() {
  314.         if (this._tileId > 0) {
  315.             return $gameMap.tileWidth();
  316.         } else if (this._isBigCharacter) {
  317.             return this.bitmap.width / this._character.maxFrame();
  318.         } else {
  319.             return this.bitmap.width / (this._character.maxFrame() * 4);
  320.         }
  321.     };
  322.     Sprite_Character.prototype.characterBlockX = function() {
  323.         if (this._isBigCharacter) {
  324.             return 0;
  325.         } else {
  326.             var index = this._character.characterIndex();
  327.             return (index % 4) * this._character.maxFrame();
  328.         }
  329.     };
  330. }();
  331. void function(){
  332.     var _Window_BasedrawCharacter = Window_Base.prototype.drawCharacter;
  333.     Window_Base.prototype.drawCharacter = function(characterName, characterIndex, x, y) {
  334.         if (ImageManager.isMultiFrames(characterName)) {
  335.             var frames = ImageManager.getMaxFrame(characterName);
  336.             var bitmap = ImageManager.loadCharacter(characterName);
  337.             var big = ImageManager.isBigCharacter(characterName);
  338.             var pw = bitmap.width / (big ? frames : frames * 4);
  339.             var ph = bitmap.height / (big ? 4 : 8);
  340.             var n = characterIndex;
  341.             var sx = (n % 4 * 3 + 1) * pw;
  342.             var sy = (Math.floor(n / 4) * 4) * ph;
  343.             this.contents.blt(bitmap, sx, sy, pw, ph, x - pw / 2, y - ph);
  344.         } else {
  345.             _Window_BasedrawCharacter.call(this, characterName, characterIndex, x, y)
  346.         }
  347.     };
  348. }();
复制代码
1.0旧版本 (各姿势素材在同一张行走图上)
  1. //=============================================================================
  2. // VIPArcher_Character_Animations.js
  3. //=============================================================================
  4. /*:
  5. * @plugindesc 行走图动画扩展,八方向|奔跑|待机|多帧
  6. * @author VIPArcher
  7. *
  8. * @param Dir8_Flag
  9. * @desc 素材使用该脚本的标志
  10. * @default %
  11. *
  12. * @param Frames_Flag
  13. * @desc 设置帧数的标志
  14. * @default #
  15. *
  16. * @param Stand_Wait
  17. * @desc 站立等待时长(帧)
  18. * @default 60
  19. *
  20. * @help 使用该脚本的行走图素材文件名前面添加一个标志:默认为 %
  21. * 文件名的名为规范(默认设置)如下:
  22. * %VIPArcher.png , 素材为2*4的标志素材
  23. * 第一行:第一个格子是四方向,第二个格子是四方向奔跑,第三个是四方向待机;
  24. * 第二行:第一个格子是八方向,第二个格子是八方向奔跑,第三个是八方向待机;
  25. *
  26. * 使用多帧则名为(默认设置): 文件名#帧数,默认帧.png
  27. * 例如 %VIPArcher#6,3.png
  28. */
  29. (function() {
  30.     var parameters = PluginManager.parameters('VIPArcher_Character_Animations');
  31.     var dir8_flag  = String(parameters['Dir8_Flag']   || '%');
  32.     var frame_flag = String(parameters['Frames_Flag'] || '#');
  33.     var stand_wait = String(parameters['Stand_Wait']  || '60');
  34.     ImageManager.isDir8Character = function(filename) {
  35.         var reg = new RegExp("^\[\\!\\$\" + dir8_flag + ']+');
  36.         var sign = filename.match(reg);
  37.         return sign && sign[0].contains(dir8_flag);
  38.     };
  39.     var _Game_CharacterBaseinitMembers = Game_CharacterBase.prototype.initMembers;
  40.     Game_CharacterBase.prototype.initMembers = function() {
  41.         _Game_CharacterBaseinitMembers.call(this);
  42.         this._standWait = 0;
  43.         this._isStand = false;
  44.         this._isDir8Character = false;
  45.     };
  46.     var _Game_CharacterBasesetImage = Game_CharacterBase.prototype.setImage;
  47.     Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
  48.         _Game_CharacterBasesetImage.call(this, characterName, characterIndex);
  49.         this.getCharacterMaxFrame(characterName);
  50.         if (ImageManager.isDir8Character(characterName)) {
  51.             this._characterIndex  = 0;
  52.             this._isDir8Character = true;
  53.         };
  54.     };
  55.     var _Game_CharacterBaseupdate = Game_CharacterBase.prototype.update;
  56.     Game_CharacterBase.prototype.update = function() {
  57.         _Game_CharacterBaseupdate.call(this);
  58.         if (this.isMoving()) {
  59.             this._standWait = 0;
  60.             this._isStand = false;
  61.             if (this._isDir8Character) { this._stepAnime = false };
  62.         } else {
  63.             this._standWait += 1;
  64.             if (this._standWait > parseInt(stand_wait)) {
  65.                 this._isStand = true;
  66.                 if (this._isDir8Character) { this._stepAnime = true };
  67.             };
  68.         };
  69.     };
  70.     var _Game_CharacterBasemoveDiagonally = Game_CharacterBase.prototype.moveDiagonally;
  71.     Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) {
  72.         _Game_CharacterBasemoveDiagonally.call(this, horz, vert);
  73.         if (horz > 5) {
  74.             vert > 5 ? this.setDirection(9) : this.setDirection(7);
  75.         } else {
  76.             vert > 5 ? this.setDirection(3) : this.setDirection(1);
  77.         };
  78.     };
  79.     Game_CharacterBase.prototype.getCharacterMaxFrame = function(characterName) {
  80.         var framedate = characterName.match(new RegExp(frame_flag + "(\\d+),(\\d+)"));
  81.         if (framedate) {
  82.             this._maxFrame = parseInt(framedate[1]);
  83.             this._formerPattern = parseInt(framedate[2]);
  84.         } else{
  85.             this._maxFrame = 3;
  86.             this._formerPattern = 1;
  87.         };
  88.     };
  89.     Game_CharacterBase.prototype.pattern = function() {
  90.         return this._pattern < this.maxFrame() ? this._pattern : 1;
  91.     };
  92.     Game_CharacterBase.prototype.maxFrame = function() {
  93.         return this._maxFrame;
  94.     };
  95.     Game_CharacterBase.prototype.maxPattern = function() {
  96.         if (this._maxFrame === 3) {
  97.             return 4;
  98.         } else {
  99.             return this._maxFrame;
  100.         };
  101.     };
  102.     Game_CharacterBase.prototype.isOriginalPattern = function() {
  103.         return this.pattern() === this._formerPattern;
  104.     };
  105.     Game_CharacterBase.prototype.resetPattern = function() {
  106.         this.setPattern(this._formerPattern);
  107.     };
  108.     Game_CharacterBase.prototype.isFast = function() {
  109.         return this._standWait < 2 && (this.isDashing() || this._moveSpeed > 4);
  110.     };
  111.     Game_CharacterBase.prototype.isStand = function() {
  112.         return this._isStand;
  113.     };
  114.     Game_CharacterBase.prototype.setCharacterIndex = function(index) {
  115.         this._characterIndex = index;
  116.     };
  117.     Game_Player.prototype.moveByInput = function() {
  118.         if (!this.isMoving() && this.canMove()) {
  119.             var direction = Input.dir8;
  120.             if (direction > 0) {
  121.                 $gameTemp.clearDestination();
  122.             } else if ($gameTemp.isDestinationValid()){
  123.                 var x = $gameTemp.destinationX();
  124.                 var y = $gameTemp.destinationY();
  125.                 direction = this.findDirectionTo(x, y);
  126.             }
  127.             if (direction > 0) {
  128.                 if (direction % 2 == 0){
  129.                     this.moveStraight(direction);
  130.                     return;
  131.                 }
  132.                 if (direction < 5){
  133.                     this.moveDiagonally(direction + 3 , 2);
  134.                 } else {
  135.                     this.moveDiagonally(direction - 3 , 8);
  136.                 }
  137.             }
  138.         }
  139.     };
  140.     var _Game_PlayermoveDiagonally = Game_Player.prototype.moveDiagonally;
  141.     Game_Player.prototype.moveDiagonally = function(horz, vert) {
  142.         if (!this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
  143.             this.setMovementSuccess(false);
  144.             return;
  145.         }
  146.         if (this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
  147.             this.moveStraight(horz);
  148.             return;
  149.         }
  150.         if (this.canPass(this._x, this._y, vert) && !this.canPass(this._x, this._y, horz)){
  151.             this.moveStraight(vert);
  152.             return;
  153.         }
  154.         if (!this.canPassDiagonally(this._x, this._y, horz, vert)) {
  155.             if (Math.random() > 0.5){
  156.                 this.setDirection(vert); this.moveStraight(vert);
  157.             } else {
  158.                 this.setDirection(horz); this.moveStraight(horz);
  159.             }
  160.             return;
  161.         }
  162.         _Game_PlayermoveDiagonally.call(this, horz, vert);
  163.     };
  164.     Sprite_Character.prototype.characterPatternY = function() {
  165.         if (this._character.direction() % 2 == 0){
  166.             if (this._character._isDir8Character){
  167.                 this._character.setCharacterIndex(this._character.isFast() ? 1 : this._character.isStand() ? 2 : 0);
  168.             };
  169.             return (this._character.direction() - 2) / 2;
  170.         } else {
  171.             if (this._character._isDir8Character){
  172.                 this._character.setCharacterIndex(this._character.isFast() ? 5 : this._character.isStand() ? 6 : 4);
  173.             };
  174.             return parseInt((this._character.direction() + 1) / 3);
  175.         }
  176.     };
  177.     Sprite_Character.prototype.patternWidth = function() {
  178.         if (this._tileId > 0) {
  179.             return $gameMap.tileWidth();
  180.         } else if (this._isBigCharacter) {
  181.             return this.bitmap.width / this._character.maxFrame();
  182.         } else {
  183.             return this.bitmap.width / (this._character.maxFrame() * 4);
  184.         }
  185.     };
  186.     Sprite_Character.prototype.characterBlockX = function() {
  187.         if (this._isBigCharacter) {
  188.             return 0;
  189.         } else {
  190.             var index = this._character.characterIndex();
  191.             return (index % 4) * this._character.maxFrame();
  192.         }
  193.     };
  194. })();
复制代码

有啥问题就直接回帖子反馈吧,我没素材进行测试,理论上应该是可以玩了。
配一张瞎糊的测试用素材(1.0版本使用)

%Actor1.png

%Actor1.png

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,跟随人物和主角都没有问题。唯一的麻烦点的就是目前跑步动作判定似乎是按照速度,这样如果主角行走速度低的话,跑起来跟随人物还是行走动作。因为跟随人物的数值基本都是主角抄过来的。

修改过的代码
  1. //=============================================================================
  2. // VIPArcher_Character_Animations.js edited by doranikofu
  3. //=============================================================================
  4. /*:
  5. * @plugindesc 行走图动画扩展,八方向|奔跑|待机|多帧
  6. * @author VIPArcher
  7. *
  8. * @param Dir8_Flag
  9. * @desc 素材使用该脚本的标志
  10. * @default %
  11. *
  12. * @param Frames_Flag
  13. * @desc 设置帧数的标志
  14. * @default #
  15. *
  16. * @param Stand_Wait
  17. * @desc 站立等待时长(帧)
  18. * @default 5
  19. *
  20. * @param Idle_Wait
  21. * @desc 待机动画开始等待时长(帧) 从站立等待之后开始计算
  22. * @default 120
  23. *
  24. * @help 使用该脚本的行走图素材文件名前面添加一个标志:默认为 %
  25. * 文件名的名为规范(默认设置)如下:
  26. * %VIPArcher.png , 素材为2*4的标志素材
  27. * 第一行:第一个格子是四方向,第二个格子是四方向奔跑,第三个是四方向待机;//doranikofu edit 顺序改成:待机-行走-奔跑
  28. * 第二行:第一个格子是八方向,第二个格子是八方向奔跑,第三个是八方向待机;
  29. *
  30. * 使用多帧则名为(默认设置): 文件名#帧数,默认帧.png
  31. * 例如 %VIPArcher#6,3.png
  32. */
  33. (function() {
  34.     var parameters = PluginManager.parameters('VIPArcher_Character_Animations');
  35.     var dir8_flag  = String(parameters['Dir8_Flag']   || '%');
  36.     var frame_flag = String(parameters['Frames_Flag'] || '#');
  37.     var stand_wait = String(parameters['Stand_Wait']  || '5');
  38.     var idle_wait = String(parameters['Idle_Wait']  || '120');
  39.     ImageManager.isDir8Character = function(filename) {
  40.         var reg = new RegExp("^\[\\!\\$\" + dir8_flag + ']+');
  41.         var sign = filename.match(reg);
  42.         return sign && sign[0].contains(dir8_flag);
  43.     };
  44.     var _Game_CharacterBaseinitMembers = Game_CharacterBase.prototype.initMembers;
  45.     Game_CharacterBase.prototype.initMembers = function() {
  46.         _Game_CharacterBaseinitMembers.call(this);
  47.         this._standWait = 0;
  48.                 this._stepstop = false;        //doranikofu stop cylcing idle anime flag
  49.        //doranikofu                this._isStand = false;
  50.                 this._isStand = true;
  51.         this._isDir8Character = false;
  52.     };
  53.     var _Game_CharacterBasesetImage = Game_CharacterBase.prototype.setImage;
  54.     Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
  55.         _Game_CharacterBasesetImage.call(this, characterName, characterIndex);
  56.         this.getCharacterMaxFrame(characterName);
  57.         if (ImageManager.isDir8Character(characterName)) {
  58.             this._characterIndex  = 0;
  59.             this._isDir8Character = true;
  60.         };
  61.     };
  62.     var _Game_CharacterBaseupdate = Game_CharacterBase.prototype.update;
  63.     Game_CharacterBase.prototype.update = function() {
  64.         _Game_CharacterBaseupdate.call(this);
  65.         if (this.isMoving()) {
  66.             this._standWait = 0;
  67.             this._isStand = false;
  68.             if (this._isDir8Character) { this._stepAnime = false };
  69.         } else {
  70.             this._standWait += 1;
  71.                         if (this._standWait == parseInt(stand_wait)) {                //doranikofu
  72.                 this._isStand = true;                                                        //
  73.                                 this._pattern = 0;                                                                //reset to default frame after switching to idle to avoid big pose jumps
  74.                                 this._stepstop = false;                                                        // reset flag
  75.                         };                                                                                                        //
  76.                 if (this._standWait > parseInt(stand_wait)) {
  77.                             if ((this._isDir8Character) && (this._standWait > (parseInt(stand_wait) + parseInt(idle_wait)))) {        //doranikofu add idle wait
  78.                                                 this._stepAnime = true;
  79.                                                 if (this._pattern == this._maxFrame - 1) this._stepstop = true;
  80.                                                 if (this._stepstop) this._pattern = this._maxFrame - 1;
  81.                                                 };
  82.             };
  83.         };
  84.     };
  85.     var _Game_CharacterBasemoveDiagonally = Game_CharacterBase.prototype.moveDiagonally;
  86.     Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) {
  87.         _Game_CharacterBasemoveDiagonally.call(this, horz, vert);
  88.         if (horz > 5) {
  89.             vert > 5 ? this.setDirection(9) : this.setDirection(7);
  90.         } else {
  91.             vert > 5 ? this.setDirection(3) : this.setDirection(1);
  92.         };
  93.     };
  94.     Game_CharacterBase.prototype.getCharacterMaxFrame = function(characterName) {
  95.         var framedate = characterName.match(new RegExp(frame_flag + "(\\d+),(\\d+)"));
  96.         if (framedate) {
  97.             this._maxFrame = parseInt(framedate[1]);
  98.             this._formerPattern = parseInt(framedate[2]);
  99.         } else{
  100.             this._maxFrame = 3;
  101.             this._formerPattern = 1;
  102.         };
  103.     };
  104.     Game_CharacterBase.prototype.pattern = function() {
  105.         return this._pattern < this.maxFrame() ? this._pattern : 1;
  106.     };
  107.     Game_CharacterBase.prototype.maxFrame = function() {
  108.         return this._maxFrame;
  109.     };
  110.     Game_CharacterBase.prototype.maxPattern = function() {
  111.         if (this._maxFrame === 3) {
  112.             return 4;
  113.         } else {
  114.             return this._maxFrame;
  115.         };
  116.     };
  117.     Game_CharacterBase.prototype.isOriginalPattern = function() {
  118.         return this.pattern() === this._formerPattern;
  119.     };
  120.     Game_CharacterBase.prototype.resetPattern = function() {
  121.         this.setPattern(this._formerPattern);
  122.     };
  123.     Game_CharacterBase.prototype.isFast = function() {
  124.         return this._standWait < 2 && (this.isDashing() || this._moveSpeed > 4);
  125.     };
  126.     Game_CharacterBase.prototype.isStand = function() {
  127.         return this._isStand;
  128.     };
  129.     Game_CharacterBase.prototype.setCharacterIndex = function(index) {
  130.         this._characterIndex = index;
  131.     };
  132.     Game_Player.prototype.moveByInput = function() {
  133.         if (!this.isMoving() && this.canMove()) {
  134.             var direction = Input.dir8;
  135.             if (direction > 0) {
  136.                 $gameTemp.clearDestination();
  137.             } else if ($gameTemp.isDestinationValid()){
  138.                 var x = $gameTemp.destinationX();
  139.                 var y = $gameTemp.destinationY();
  140.                 direction = this.findDirectionTo(x, y);
  141.             }
  142.             if (direction > 0) {
  143.                 if (direction % 2 == 0){
  144.                     this.moveStraight(direction);
  145.                     return;
  146.                 }
  147.                 if (direction < 5){
  148.                     this.moveDiagonally(direction + 3 , 2);
  149.                 } else {
  150.                     this.moveDiagonally(direction - 3 , 8);
  151.                 }
  152.             }
  153.         }
  154.     };
  155.     var _Game_PlayermoveDiagonally = Game_Player.prototype.moveDiagonally;
  156.     Game_Player.prototype.moveDiagonally = function(horz, vert) {
  157.         if (!this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
  158.             this.setMovementSuccess(false);
  159.             return;
  160.         }
  161.         if (this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
  162.             this.moveStraight(horz);
  163.             return;
  164.         }
  165.         if (this.canPass(this._x, this._y, vert) && !this.canPass(this._x, this._y, horz)){
  166.             this.moveStraight(vert);
  167.             return;
  168.         }
  169.         if (!this.canPassDiagonally(this._x, this._y, horz, vert)) {
  170.             if (Math.random() > 0.5){
  171.                 this.setDirection(vert); this.moveStraight(vert);
  172.             } else {
  173.                 this.setDirection(horz); this.moveStraight(horz);
  174.             }
  175.             return;
  176.         }
  177.         _Game_PlayermoveDiagonally.call(this, horz, vert);
  178.     };
  179.     Sprite_Character.prototype.characterPatternY = function() {
  180.         if (this._character.direction() % 2 == 0){
  181.             if (this._character._isDir8Character){
  182.                 this._character.setCharacterIndex(this._character.isFast() ? 2 : this._character.isStand() ? 0 : 1);        //doranikofu changed index
  183.             };
  184.             return (this._character.direction() - 2) / 2;
  185.         } else {
  186.             if (this._character._isDir8Character){
  187.                 this._character.setCharacterIndex(this._character.isFast() ? 6 : this._character.isStand() ? 4 : 5);        //doranikofu changed index
  188.             };
  189.             return parseInt((this._character.direction() + 1) / 3);
  190.         }
  191.     };
  192.     Sprite_Character.prototype.patternWidth = function() {
  193.         if (this._tileId > 0) {
  194.             return $gameMap.tileWidth();
  195.         } else if (this._isBigCharacter) {
  196.             return this.bitmap.width / this._character.maxFrame();
  197.         } else {
  198.             return this.bitmap.width / (this._character.maxFrame() * 4);
  199.         }
  200.     };
  201.     Sprite_Character.prototype.characterBlockX = function() {
  202.         if (this._isBigCharacter) {
  203.             return 0;
  204.         } else {
  205.             var index = this._character.characterIndex();
  206.             return (index % 4) * this._character.maxFrame();
  207.         }
  208.     };
  209. })();
复制代码


效果图, 左下是主角和跟随的待机,右上是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.

在本版发帖返回顶部