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

[转载发布] Notes to Self: Little tweaks, mostly chrono engine

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

    连续签到: 2 天

    [LV.7]常住居民III

    7959

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    Every now and then I'm using a plugin and it doesn't work quite the way I want it to, so I put in a little tweak to do what I want.  Sometimes it's a bugfix, sometimes it's just changing things to be easier for me to work with. Since I'm not the only person using these plugins, I figured I'd put up a thread for these so other people can try them if they want.

    I'll be sporadically updating this whenever I have something I think other people might find useful.

    These are not optimized or cleaned up in any way, so it's almost certain there are better ways to do all of these things.  

    Terms of Use: Do whatever you like.

    YEP_X_ExtDoodadPack1: Switching Doodads 'on' puts them at the beginning of their animation cycle.
    Yanfly's extended doodad plugin with switches is great to use, but when you switch an animated doodad on, it's at essentially random part of its animation cycle.  That's because the doodads are silently going through each frame while transparent.

    I wanted animated doodads to be at the start of their animation cycle when switched on.  This tweak does that by resetting the frame to 0 whenever the plugin refreshes a hidden doodad.
    Spoiler                Code:       
    1. //from YEP_X_ExtDoodadPack1
    2. //
    3. Sprite_Doodad.prototype.updateCustomEDP1Z = function() {
    4.   if ($gameTemp._modeGFD) return;
    5.   // Party
    6.   var length = this.partyHave.length;
    7.   for (var i = 0; i < length; ++i) {
    8.     var actorId = this.partyHave[i];
    9.     if (!$gameParty._actors.contains(actorId)) {
    10.       this.opacity = 0;
    11.      this._index = 0;//reset the animation state so long as opacity is off, thus allowing for us to play doodad animations once.
    12.       return;
    13.     }
    14.   }
    15.   var length = this.partyMiss.length;
    16.   for (var i = 0; i < length; ++i) {
    17.     var actorId = this.partyMiss[i];
    18.     if ($gameParty._actors.contains(actorId)) {
    19.       this.opacity = 0;
    20.      this._index = 0;//reset the animation state so long as opacity is off, thus allowing for us to play doodad animations once.
    21.       return;
    22.     }
    23.   }
    24.   // Switches
    25.   var length = this.switchOn.length;
    26.   for (var i = 0; i < length; ++i) {
    27.     var switchId = this.switchOn[i];
    28.     if (!$gameSwitches.value(switchId)) {
    29.       this.opacity = 0;
    30.      this._index = 0;//reset the animation state so long as opacity is off, thus allowing for us to play doodad animations once.
    31.       return;
    32.     }
    33.   }
    34.   var length = this.switchOff.length;
    35.   for (var i = 0; i < length; ++i) {
    36.     var switchId = this.switchOff[i];
    37.     if ($gameSwitches.value(switchId)) {
    38.       this.opacity = 0;
    39.      this._index = 0;//reset the animation state so long as opacity is off, thus allowing for us to play doodad animations once.
    40.       return;
    41.     }
    42.   }
    43. };
    复制代码







    MOG_ChronoEngine Item Core Compatibilty
    Chrono Engine is not compatible with yanfly's item core by default.  This fixes that.
    Spoiler                Code:       
    1. var _mog_toolSys_gmap_setup = Game_Map.prototype.setup;
    2. Game_Map.prototype.setup = function(mapId) {
    3.    //console.log("Game_Map.prototype.setup");
    4.    _mog_toolSys_gmap_setup.call(this,mapId);
    5.    this._treasureEvents = [];
    6.    this._battlersOnScreen = [];
    7.    this._enemiesOnScreen = [];
    8.    this._actorsOnScreen = [];
    9.    $gameSystem._toolsOnMap = [];
    10.    $gameTemp.clearToolCursor();
    11.    //console.log($gameSystem._toolsData);// with itemcore, this always returns an empty array []
    12.    //without itemcore, it returns 'null', then an the proper item  list, so clearly _toolsdata isn't getting set right
    13.    //I assume the 'null' gets overridden by one of yanfly's blanket definitions, and since I can't find that
    14.    // I'm just testing to see if the list is empty.  If it is, grab the tools again
    15.    // it seems to work!
    16.    //if (!$gameSystem._toolsData) {this.dataMapToolClear()};
    17.    if (!$gameSystem._toolsData) {this.dataMapToolClear()
    18.        }else{ if ($gameSystem._toolsData.length == 0) {this.dataMapToolClear()};
    19.        }
    20.    for (var i = 0; i < $gameParty.members().length; i++) {
    21.        var actor = $gameParty.members()[i];
    22.        actor.clearActing();
    23.        $gameSystem._toolHookshotSprite = [null,null,0];
    24.    };
    25. };
    复制代码






    MOG_ActorHud Meter Angle Fix
    Mog's actorhud converts from radians to degrees twice by default, which means if you set an angled bar the background
    won't be at the same angle as the filled bar.  This typo is in all the different meters, but once you see the hp meter fix you can change whatever other ones you want.
    Spoiler                Code:       
    1. //==============================
    2. // * Create HP Meter
    3. //==============================
    4. Actor_Hud.prototype.create_hp_meter = function() {
    5.    if (String(Moghunter.ahud_hp_meter_visible) != "true") {return};
    6.    this.removeChild(this._hp_meter_blue);
    7.    this.removeChild(this._hp_meter_red);
    8.    if (!this._battler) {return};
    9.    this._hp_meter_red = new Sprite(this._hp_meter_img);
    10.    this._hp_meter_red.x = this._pos_x + Moghunter.ahud_hp_meter_pos_x;
    11.    this._hp_meter_red.y = this._pos_y + Moghunter.ahud_hp_meter_pos_y;
    12.    this._hp_meter_red.rotation = Moghunter.ahud_hp_meter_rotation * Math.PI / 180;
    13.    this._hp_meter_red.setFrame(0,0,0,0);
    14.    this.addChild(this._hp_meter_red);   
    15.    this._hp_meter_blue = new Sprite(this._hp_meter_img);
    16.    this._hp_meter_blue.x = this._hp_meter_red.x;
    17.    this._hp_meter_blue.y = this._hp_meter_red.y;
    18.    this._hp_meter_blue.rotation = this._hp_meter_red.rotation; //this was incorrectly converting to radians twice
    19.    this._hp_meter_blue.setFrame(0,0,0,0);
    20.    this.addChild(this._hp_meter_blue);
    21.    this._hp_old_ani[0] = this._battler.hp - 1;
    22.    if (String(Moghunter.ahud_hp_meter_flow) === "true") {this._hp_flow[0] = true;
    23.        this._hp_flow[2] = this._hp_meter_img.width / 3;
    24.        this._hp_flow[3] = this._hp_flow[2] * 2;
    25.        this._hp_flow[1] = Math.floor(Math.random() * this._hp_flow[2]);
    26.    };
    27. };
    复制代码







    MOG_CharacterPoses+Mog_ChronoEngine Rotation Around Center + Set Sprite Rotations
    By default in rpgmaker, sprite rotation is around the base of a sprite.  That's bad if you're rotating projectiles, since you end up with your hitbox being displaced off from where the sprite actually is.

    This function uses trig to identify where the sprite needs to be displaced so that it's rotated around the hitbox.  (This requires that you center your sprite using mog's displacement tools to start with).




    Above: My Version (approximate hitbox in blue)
    Below: Default version

    In addition, I have added a few functions for rotating character sprites smoothly.  Set a target angle and a rotation rate, and it will update each frame until it reaches the target angle.

    If you don't set a target angle, it will rotate at that speed forever.

    You can also set it to go in whichever direction is closer, ignoring the sign on the angle speed.

    Spoiler                Code:       
    1. Game_CharacterBase.prototype.setTargetAngle = function(targetAngle) {
    2.    var ag = targetAngle * Math.PI / 180;
    3.     this._user.targetAngle = [ag,targetAngle];
    4. };
    5. Game_CharacterBase.prototype.setRotationRate = function(rotationSpeed) {
    6.    var ag = rotationSpeed * Math.PI / 180;
    7.     this._user.rotationSpeed = [ag,rotationSpeed];
    8. };
    9. Game_CharacterBase.prototype.setRotationFlexible = function() {
    10.    //flag to say we can go clockwise OR counterclockwise, whichever is closer
    11.     this._user.rotationFlexible= true;
    12. };
    13. Game_CharacterBase.prototype.clearRotationRate = function() {
    14.    this._user.targetAngle =null;
    15.     this._user.rotationSpeed = null;
    16.    this._user.rotationFlexible= false;
    17. };
    18. Sprite_Character.prototype.updateCharPosesPosition = function() {
    19.         //honestly I don't understand what this is supposed to be doing, and a
    20.         //constant offset for the x displacement fits what I want to do,
    21.         //I've removed the x-offset shifting, to make way for my stuff
    22.         //sorry if this breaks stuff for you!
    23.        
    24.         //if (this._character.direction() === 4 || this._character.direction() === 6) {       
    25.         //        var ex = this._character.direction() === 6 ? this._character._frames.x : -this._character._frames.x;
    26.     //} else {
    27.         //        var ex = 0;
    28.         //};
    29.         var ex = this._character._frames.x;
    30.         var ey = this._character._frames.y;       
    31.        
    32.         // add on additional rotation specified in tool
    33.         if (this._character._tool)
    34.         {
    35.                 if(this._character._tool.offsetX)
    36.                 {
    37.                         ex+=this._character._tool.offsetX;
    38.                 }
    39.                 if(this._character._tool.offsetY)
    40.                 {
    41.                         ey+=this._character._tool.offsetY;
    42.                 }
    43.                 if(this._character._tool.diagonalAngle)
    44.                 {
    45.                         this._character._user.rotation = [this._character._tool.diagonalAngle,Math.degrees(this._character._tool.diagonalAngle)];
    46.                 }
    47.         }
    48.        
    49.         ag=0;
    50.         angle=0;
    51.         thisHasRotationUser=false;
    52.         thisHasRotationChar=false;
    53.         //technically this isn't the 'correct' way of checking to see
    54.         //if we have this trait, but there shouldn't be any edge cases that matter
    55.         //since if rotation has a value but it resolves as 'false' we don't want to
    56.         //rotate after all
    57.         if (this._character._user.rotation)
    58.         {
    59.                 thisHasRotationChar=true;
    60.                 [ag,angle] = this._character._user.rotation;
    61.         }else{
    62.                 if ($gameMap.event(3)._user.rotation[0] =undefined)
    63.                 {
    64.                         $gameMap.event(3)._user.rotation[0]=0;
    65.                         $gameMap.event(3)._user.rotation[1]=0;
    66.                 }
    67.                
    68.         }
    69.        
    70.         if (thisHasRotationChar)
    71.         {
    72.                 var isSpinning=false;
    73.                 var hasTargetAngle=false;
    74.                 if(thisHasRotationChar)
    75.                 {
    76.                         if (this._character._user.rotationSpeed)
    77.                         {
    78.                                 [agSpeed,angleSpeed] = this._character._user.rotationSpeed;
    79.                                 isSpinning=true;
    80.                         }
    81.                         if (this._character._user.targetAngle || this._character._user.targetAngle ==0        )
    82.                         {
    83.                                 [agTarget,angleTarget] = this._character._user.targetAngle;
    84.                                 hasTargetAngle=true;
    85.                                
    86.                         }
    87.                         if (isSpinning){
    88.                                 if(hasTargetAngle){
    89.                                         //if our target angle is within a single step, snap to it.
    90.                                         if(Math.abs(((((angleTarget+360) % 360)-((angle+360) % 360))/angleSpeed))<1){
    91.                                                 this._character.setAngle(angleTarget);
    92.                                         }else{
    93.                                                 //if we are allowed to go in either direction, pick the shorter distance
    94.                                                 if(this._character._user.rotationFlexible)
    95.                                                 {
    96.                                                         if (((((angleTarget+360) % 360)-((angle+360) % 360) +360) % 360)>180)
    97.                                                                 this._character.setAngle(angle-Math.abs(angleSpeed));
    98.                                                         else
    99.                                                                 this._character.setAngle(angle+Math.abs(angleSpeed));
    100.                                                 }else{
    101.                                                         this._character.setAngle(angle+angleSpeed);
    102.                                                 }
    103.                                         }
    104.                                 }else{
    105.                                         //if we don't have a target angle, but do have a rotation speed, keep spinning without limit!
    106.                                         this._character.setAngle(angle+angleSpeed);
    107.                                 }
    108.                         }
    109.                 }else if(thisHasRotationUser){
    110.                         if (this._user.rotationSpeed)
    111.                         {
    112.                                 [agSpeed,angleSpeed] = this._user.rotationSpeed;
    113.                                 isSpinning=true;
    114.                         }
    115.                         if (this._user.targetAngle)
    116.                         {
    117.                                 [agTarget,angleTarget] = this._user.targetAngle;
    118.                                 hasTargetAngle=true;
    119.                         }
    120.                         if (isSpinning){
    121.                                 if(hasTargetAngle){
    122.                                         //if our target angle is within a single step, snap to it.
    123.                                         if(Math.abs(((((angleTarget+360) % 360)-((angle+360) % 360))/angleSpeed))<1){
    124.                                                 this.setAngle(angleTarget);
    125.                                         }else{
    126.                                                 if(this._user.rotationFlexible)
    127.                                                 {
    128.                                                         if (((((angleTarget+360) % 360)-((angle+360) % 360) +360) % 360)>180)
    129.                                                                 this.setAngle(angle-Math.abs(angleSpeed));
    130.                                                         else
    131.                                                                 this.setAngle(angle+Math.abs(angleSpeed));
    132.                                                 }else{
    133.                                                         this.setAngle(angle+angleSpeed);
    134.                                                 }
    135.                                         }
    136.                                 }else{
    137.                                         //if we don't have a target angle, but do have a rotation speed, keep spinning without limit!
    138.                                         this.setAngle(angle+angleSpeed);
    139.                                 }
    140.                         }
    141.                 }
    142.                
    143.                 //update ag and angle
    144.                 if (this._character._user.rotation || (this._character._user.rotation==0))
    145.                 {
    146.                         [ag,angle] = this._character._user.rotation;
    147.                 }
    148.         }
    149.         if (ag==0)
    150.         {
    151.         this.x += ex;
    152.         this.y += ey;
    153.        
    154.         }else{
    155.         //I have altered this code to
    156.         //rotate events around the displacement point by default,
    157.         //instead of the base of the sprite       
    158.         //technically this rotation is only off by a pixel or two, but w/e, close enough.
    159.         baselength=Math.sqrt(ex*ex + ey*ey);
    160.        
    161.         this.x += ex*Math.cos(ag) - ey * Math.sin(ag);
    162.         this.y += ex*Math.sin(ag) + ey * Math.cos(ag);
    163.         }
    164.        
    165. };
    166. //one problem with the above is that animations end up vertically displaced
    167. //from their targets!  And animations are attached to a single point on the
    168. //sprite, which means if it spins, they spin!
    169. //this restores normal animation location on rotating objects
    170. _cross_sprite_animation_update_position=Sprite_Animation.prototype.updatePosition;
    171. Sprite_Animation.prototype.updatePosition = function()
    172. {
    173.                 _cross_sprite_animation_update_position.call(this);
    174.                 if (this._target._character)
    175.                 {
    176.                         //if we're targeting a sprite on a character
    177.                         //then
    178.                         var ex =0;
    179.                         var ey =0;
    180.                        
    181.                         if (this._target._character._frames.x)
    182.                         {
    183.                                 ex+=this._target._character._frames.x;
    184.                         }
    185.                         if (this._target._character._frames.y)
    186.                         {
    187.                                 ey+=this._target._character._frames.y;
    188.                         }
    189.                         if (this._target._character._tool)
    190.                         {
    191.                                 if(this._target._character._tool.offsetX)
    192.                                 {
    193.                                         ex+=this._target._character._tool.offsetX;
    194.                                 }
    195.                                 if(this._target._character._tool.offsetY)
    196.                                 {
    197.                                         ey+=this._target._character._tool.offsetY;
    198.                                 }
    199.                         }
    200.                         var ag=0;
    201.                         var angle=0;
    202.                         if (this._target._character._user.rotation || (this._target._character._user.rotation==0))
    203.                         {
    204.                                 [ag,angle] = this._target._character._user.rotation;
    205.                         }
    206.                        
    207.                         this.x -= ex*Math.cos(ag) - ey * Math.sin(ag) -ex;
    208.                         this.y -= ex*Math.sin(ag) + ey * Math.cos(ag) -ey*1.5;
    209.                 }
    210.                
    211. }
    复制代码








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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-1 01:30 , Processed in 0.120844 second(s), 56 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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