设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 84|回复: 0

[转载发布] Action Sequence Rotation Extension

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7927

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29861
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38682

    灌水之王

    发表于 10 小时前 | 显示全部楼层 |阅读模式
    Action Sequence Rotation
    ATT_Turan


    Introduction
    This plugin adds a command to rotate battlers within action sequences. This allows them to tilt, spin, etc. Thanks to @SGHarlekin for the inspiration!

    I have tested the basic functionality, please let me know if you encounter any errors. I will consider making compatibility patches if the other plugin is free to use (or one I own, such as a Yanfly product) and unobfuscated. Otherwise, other authors are free to modify this code to make it compatible with theirs so long as I am still credited.





    Spoiler: Features
                    Code:       
    1. *=============================================================================
    2. * ROTATE target: args
    3. * ----------------------------------------------------------------------------
    4. * ROTATE target: degrees, (direction), (frames)
    5. * ----------------------------------------------------------------------------
    6. *
    7. * Degrees is an integer value representing how many clockwise degrees to
    8. * rotate the sprite. Entering 0 from no rotation will do a circle.
    9. *
    10. * The direction argument can be RIGHT or LEFT, indicating a clockwise or
    11. * counterclockwise rotation. Omitting it defaults to clockwise (RIGHT).
    12. *
    13. * The frames argument is optional; omitting it will make the rotation
    14. * instantaneous.
    15. *
    16. * Example: rotate user: 90, right, 15
    复制代码


    Rotation is considered to be movement for the purposes of
    1. WAIT FOR MOVEMENT
    复制代码
    .
    Spoiler: How to Use
    This plugin is plug 'n' play. Install it below all Yanfly plugins in your plugin manager and you'll be able to use the above action sequence command.
    Please feel free to offer any suggestions for further target types you'd find useful.

    Terms and Credits
    Free for non-commercial and commercial use. Credit ATT_Turan.

    Spoiler: Plugin Code
                    Code:       
    1. //=============================================================================
    2. // Action Sequence Rotation
    3. // TUR_X_ActSeqRot.js
    4. //=============================================================================
    5. window.Imported = window.Imported || {};
    6. Imported.TUR_X_ActSeqRot = true;
    7. window.TUR = window.TUR || {};
    8. TUR.ActSeqRot = TUR.ActSeqRot || {};
    9. TUR.ActSeqRot.version = 1.3;
    10. /*:
    11. * @plugindesc Provides a rotate command for Yanfly's Action Sequences.
    12. * @author ATT_Turan
    13. * @url https://forums.rpgmakerweb.com/index.php?threads/action-sequence-rotation-extension.166579/
    14. * @version 1.3
    15. * @help
    16. * ============================================================================
    17. * Introduction
    18. * ============================================================================
    19. *
    20. * This plugin provides a command for rotating battlers to users of Yanfly's
    21. * Action Sequences plugins.
    22. *
    23. *=============================================================================
    24. *
    25. *=============================================================================
    26. * ROTATE target: args
    27. * ----------------------------------------------------------------------------
    28. * ROTATE target: degrees, (direction), (frames)
    29. * ----------------------------------------------------------------------------
    30. *
    31. * Degrees is an integer value representing how many clockwise degrees to
    32. * rotate the sprite. Entering 0 from no rotation will do a circle.
    33. *
    34. * The direction argument can be RIGHT or LEFT, indicating a clockwise or
    35. * counterclockwise rotation. Omitting it defaults to clockwise (RIGHT).
    36. *
    37. * The frames argument is optional; omitting it will make the rotation
    38. * instantaneous.
    39. *
    40. * ============================================================================
    41. * Changelog
    42. * ============================================================================
    43. *
    44. * Version 1.3:
    45. * - Fixed more facing and prevented users from breaking their sprites with bad
    46. *   timing.
    47. *
    48. * Version 1.2:
    49. * - Adjusted for facing commands
    50. *
    51. * Version 1.1:
    52. * - Corrected positioning issues
    53. *
    54. * Version 1.0:
    55. * - Release version
    56. *
    57. */
    58. if (Imported.YEP_BattleEngineCore)
    59. {
    60.     TUR.processActionSequence = BattleManager.processActionSequence;
    61.     BattleManager.processActionSequence = function(actionName, actionArgs)
    62.     {
    63.         if (actionName.match(/ROTATE[ ](.*)/i))
    64.         {
    65.             let string = String(RegExp.$1);
    66.             if (this.makeActionTargets(string).length > 0)
    67.                 return this.actionRotate(string, actionArgs);
    68.         }
    69.         return TUR.processActionSequence.call(this, actionName, actionArgs);
    70.     };
    71.     BattleManager.actionRotate = function(name, actionArgs)
    72.     {
    73.         let spinners = this.makeActionTargets(name);
    74.         if (!spinners.length)
    75.             return true;
    76.         if (!spinners[0].battler()._mainSprite)
    77.             return true;
    78.         let degrees = Number(actionArgs[0]);
    79.         if (isNaN(degrees) || degrees < 0)
    80.             return true;
    81.         let frames = 0;
    82.    
    83.         if (actionArgs[1] && isNaN(actionArgs[1]))
    84.         {
    85.             if (actionArgs[1].toUpperCase() == "LEFT")
    86.                 spinners.forEach(spinner => spinner.battler()._mainSprite.rotateDir = "left");
    87.             else if (actionArgs[1].toUpperCase() == "RIGHT")
    88.                 spinners.forEach(spinner => spinner.battler()._mainSprite.rotateDir = "right");
    89.             else
    90.                 return true;
    91.         
    92.             frames = Number(actionArgs[2]) || 0;
    93.         }
    94.         else
    95.         {
    96.             spinners.forEach(spinner => spinner.battler()._mainSprite.rotateDir = "right");
    97.             frames = Number(actionArgs[1]) || 0;
    98.         }
    99.         if (!frames)
    100.             spinners.forEach(spinner => spinner.battler()._mainSprite.rotation = degrees * (Math.PI / 180));
    101.         else
    102.             spinners.forEach(spinner => {let sprite = spinner.battler()._mainSprite;
    103.                 if (sprite.rotateTo == undefined)
    104.                 {
    105.                     sprite.rotateTo = degrees;
    106.                     sprite.rotateFrames = frames;
    107.                     sprite.oldPivot = sprite.pivot.y;
    108.                     sprite.pivot.y = -sprite.height / 2;
    109.                     sprite.y += sprite.pivot.y
    110.                 }});
    111.    
    112.         return true;
    113.     };
    114.     Sprite_Base.prototype._refresh = function()
    115.     {
    116.         var frameX = Math.floor(this._frame.x);
    117.         var frameY = Math.floor(this._frame.y);
    118.         var frameW = Math.floor(this._frame.width);
    119.         var frameH = Math.floor(this._frame.height);
    120.         var bitmapW = this._bitmap ? this._bitmap.width : 0;
    121.         var bitmapH = this._bitmap ? this._bitmap.height : 0;
    122.         var realX = frameX.clamp(0, bitmapW);
    123.         var realY = frameY.clamp(0, bitmapH);
    124.         var realW = (frameW - realX + frameX).clamp(0, bitmapW - realX);
    125.         var realH = (frameH - realY + frameY).clamp(0, bitmapH - realY);
    126.         this._realFrame.x = realX;
    127.         this._realFrame.y = realY;
    128.         this._realFrame.width = realW;
    129.         this._realFrame.height = realH;
    130.         this.pivot.x = frameX - realX;
    131.         if (this.rotateTo == undefined)
    132.             this.pivot.y = frameY - realY;
    133.         if (realW > 0 && realH > 0)
    134.         {
    135.             if (this._needsTint())
    136.             {
    137.                 this._createTinter(realW, realH);
    138.                 this._executeTint(realX, realY, realW, realH);
    139.                 this._tintTexture.update();
    140.                 this.texture.baseTexture = this._tintTexture;
    141.                 this.texture.frame = new Rectangle(0, 0, realW, realH);
    142.             }
    143.             else
    144.             {
    145.                 if (this._bitmap)
    146.                     this.texture.baseTexture = this._bitmap.baseTexture;
    147.                 this.texture.frame = this._realFrame;
    148.             }
    149.         }
    150.         else if (this._bitmap)
    151.             this.texture.frame = Rectangle.emptyRectangle;
    152.         else
    153.         {
    154.             this.texture.baseTexture.width = Math.max(this.texture.baseTexture.width, this._frame.x + this._frame.width);
    155.             this.texture.baseTexture.height = Math.max(this.texture.baseTexture.height, this._frame.y + this._frame.height);
    156.             this.texture.frame = this._frame;
    157.         }
    158.         this.texture._updateID++;
    159.     };
    160.     Sprite_Battler.prototype.updateFloat = function()
    161.     {
    162.         if (!this._battler) return;
    163.         if (this._floatDur > 0) this._floatDur--;
    164.         if (this._jumpDur > 0) this._jumpDur--;
    165.         var baseY = this._battler.anchorY();
    166.         var floatHeight = this.getFloatHeight();
    167.         var jumpHeight = this.getJumpHeight();
    168.         var height = floatHeight + jumpHeight;
    169.         if (this._mainSprite && this._mainSprite.bitmap)
    170.         {
    171.             var rate = this._battler.spriteHeight() / this._mainSprite.height;
    172.             this._mainSprite.anchor.y = (baseY + height * rate);
    173.             if (this._mainSprite.rotateTo != undefined)
    174.             {
    175.                 let oldPivot = this._mainSprite.pivot.y;
    176.                 this._mainSprite.pivot.y = (0.5 - this._mainSprite.anchor.y) * this._mainSprite.height;
    177.                 this._mainSprite.y += this._mainSprite.pivot.y - oldPivot;
    178.             }
    179.         this._weaponSprite.anchor.y = this._mainSprite.anchor.y;
    180.         }
    181.         else
    182.             this.anchor.y = (baseY + height);
    183.     };
    184.     TUR.updateMove = Sprite_Battler.prototype.updateMove;
    185.     Sprite_Battler.prototype.updateMove = function()
    186.     {
    187.         TUR.updateMove.call(this);
    188.         if (this._mainSprite && this._mainSprite.rotateTo != undefined)
    189.         {
    190.             let sprite = this._mainSprite;
    191.             sprite.rotateFrames--;
    192.         
    193.             if (sprite.rotateFrames <= 0)
    194.             {
    195.                 sprite.rotation = sprite.rotateTo * (Math.PI / 180);
    196.                 sprite.y -= sprite.pivot.y;
    197.                 sprite.pivot.y = sprite.oldPivot;
    198.                 delete sprite.oldPivot;
    199.                 delete sprite.rotateTo;
    200.                 delete sprite.rotateFrames;
    201.             }
    202.             else
    203.             {
    204.                 let toDegrees = sprite.rotateTo;
    205.                 let currDegrees = sprite.rotation * (180 / Math.PI);
    206.                 if (sprite.rotateDir == "right" && this.scale.x >= 0 || sprite.rotateDir == "left" && this.scale.x < 0)
    207.                 {
    208.                     let degrees = toDegrees > currDegrees ? toDegrees - currDegrees : 360 + toDegrees - currDegrees;
    209.                     degrees = Math.round(degrees / sprite.rotateFrames);
    210.                     sprite.rotation += degrees * (Math.PI / 180);
    211.                 }
    212.                 else
    213.                 {
    214.                     let degrees = currDegrees > toDegrees ? currDegrees - toDegrees : 360 + toDegrees - currDegrees;
    215.                     degrees = Math.round(degrees / sprite.rotateFrames);
    216.                     sprite.rotation = ((currDegrees > 0 ? currDegrees : 360) - degrees) * (Math.PI / 180);
    217.                 }
    218.             }
    219.         }
    220.         else if (this._mainSprite && this._mainSprite.oldPivot != undefined)
    221.         {
    222.             this._mainSprite.y -= this._mainSprite.pivot.y;
    223.             this._mainSprite.pivot.y = this._mainSprite.oldPivot;
    224.             delete this._mainSprite.oldPivot;
    225.         }
    226.     };
    227.     TUR.isMoving = Sprite_Battler.prototype.isMoving;
    228.     Sprite_Battler.prototype.isMoving = function()
    229.     {
    230.         if (!TUR.isMoving.call(this))
    231.             return !!this._mainSprite && this._mainSprite.oldPivot != undefined;
    232.         else
    233.             return true;
    234.     };
    235. }
    复制代码




    本贴来自国际rpgmaker官方论坛作者:ATT_Turan处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/action-sequence-rotation-extension.166579/

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-31 21:42 , Processed in 0.144076 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表