Notes to Self: Little tweaks, mostly chrono engine

● ARCHIVED · READ-ONLY
Started by Restart 79 posts Page 4 of 4 View original ↗
  1. Restart said:
    Unlocking Character Poses
    One thing that was annoying about chrono engine was the limitation on character poses. By default it parses the first of a given tag in a character image filename, so having a character with nonstandard frames locks all the poses to be identical.

    For instance, if you had $Harold(f6)(f2) as your protagonist, your idle pose can ONLY be named $Harold(f6)(f2)_idle, and so is forced to be a 6 frame pose going at 2x speed


    These three functions, combined, remove that limit. Now you can put $Harold(f6)(f2)_idle(f4)(s1) into your folder, and harold will settle down to 1x speed when doing a 4-frame idle pose.


    How does it work?

    First, the initialize tweak means that we create a full list of character names when the game first starts up.

    The setPose tweak uses that character name list. It will still default to whatever exact pose you select, but if it doesn't find that EXACT pose, it will check to see if there's a character image which is that pose followed by some suffixes.

    Finally, the setCharacterFrames tweaks the parsing on the filename tags, so it always picks the LAST one instead of the first one. So the pose's tags will override the main image name. As a bonus, it will also parse negative direction shifts as well as positive.

    Code:
    var _crossengine_game_sys_init = Game_System.prototype.initialize
    Game_System.prototype.initialize = function() {
         _crossengine_game_sys_init.call(this);
        this.crossEngine={};
        this.rebuildFileList();
      
    };
    
    Game_System.prototype.rebuildFileList = function () {
        //create a list of image files in our character directory.
        // This is necessary for the automatic pose recognition
        // so for example you can have $Character(f6).png and $Character(f6)_idle(f3).png
        // and the default pose code to apply _idle will detect the right character name
        //
      
        var fs = require ("fs");
        var path = require('path');
        var base = path.dirname(process.mainModule.filename);
        //let dir = fs.readdirSync( './img/characters/' );
        let dir = fs.readdirSync( path.join(base, '/img/characters/'));
        this.crossEngine.characterNameList = dir.filter( elm => elm.match(new RegExp(`.*\.(png)`, 'ig')));
        this.crossEngine.characterNameListLC=['hello world'];//this should never appear in game.
        //slice off the .png extension
        for (var index =0; index<this.crossEngine.characterNameList.length;index++)
        {
            this.crossEngine.characterNameList[index]=this.crossEngine.characterNameList[index].slice(0, -4);
            //create a lower case version of it so that we can do case matching for poses
            this.crossEngine.characterNameListLC[index]=this.crossEngine.characterNameList[index].toLowerCase();
        }
    }
    
    //rebuild our file list whenever we load a save game (to make testing easier)
    
    var _cross_onLoadSuccess = Scene_Load.prototype.onLoadSuccess;
    Scene_Load.prototype.onLoadSuccess=function(){
            _cross_onLoadSuccess.call(this)
            $gameSystem.rebuildFileList();
    }
    
    
    //==============================
    // * From Mog_CharPoses.js
    //==============================
    // I have altered this with a fallback that CHECKS to see if a pose exists.
    //if it DOES exist, then we proceed as normal.
    //if it does NOT exist, then we first check to see if there's a pose with different
    //parameters (like _idle(f3) instead of just _idle
    //if that exists, then we use that one instead
    //if it does not exist, we don't load anything
    //and whine in the console about it
    
    //BASICALLY:
    // set your frames and speed and y offset and all that jazz
    // at the end of your original image name
    // AND at the end of any poses
    // and everything will be fine and dandy
    // if you have multiple versions of a pose file I think it PROBABLY just picks
    // whichever is alphabetically first if you don't specify the exact file name
    // but honestly that's a weird edge case and if you REALLY want to get that effect
    // you're better off manipulating the framerate or y offset or whatever dynamically
    // instead of having seperate files
    
    // ALSO: since this scans once when the game initializes
    // if your image files change midgame the list will get stale
    // but like
    // don't do that, alright?  That's weird, and if you have something that complex
    // you should just code your own system.
    Game_CharacterBase.prototype.setPose = function() {
         this._poses.idle[3] = false;
         //default to keeping the same pose
         var newPose=this._originalName.name;
         if (this.isFaintPose()) {
             newPose = this.setFaintPose();
         } else if (this.isKnockbackPose()) {
             newPose = this.setKnockbackPose();
         } else if (this.isGuardPose()) {
             newPose = this.setGuardingPose();       
         } else if (this.isActionPose()) {
             newPose = this.setActionPose();
         } else if (this.isVictoryPose()) {
             newPose = this.setVictoryPose();  
         } else if (this.isCastingPose()) {
             newPose = this.setCastingPose();  
         } else if (this.isAttackingPose()) {
             newPose = this.setAttackingPose();                     
         } else if (this.isPickUPPose()) {
             newPose = this.setPickUPPose();
         } else if (this.isPushPullPose()) {
             newPose = this.setPushPullPose();   
         } else if (this.isDashingPose()) {
             newPose = this.setDashPose();
         } else if (this.isJumpingPose()) {
             newPose = this.setJumpPose();
         } else if (this.isIdlePose()) {
             newPose = this.setIdlePose();   
         };
         // this code didn't do anything in stock chrono engine.  Mog was probably
         // planning to expand this.  Commented out for now
         /* if (this.isDiagonalDefaultPose()) {
             newPose = this.setDiagonalDefaultPose();
         } else {
             newPose = this._originalName.name;
         }; */
      
    
        //if the pose exists, return with it.  Otherwise we will have to see if the
        //parameters are different
        var fs = require ("fs");
        if ( fs.existsSync("./img/characters/" + newPose+'.png'))
        {
            //console.log(newPose)
            return newPose
        }else{
            for (var index =0; index<$gameSystem.crossEngine.characterNameList.length;index++)
            {
                if ($gameSystem.crossEngine.characterNameList[index].startsWith (newPose))
                {
                    return $gameSystem.crossEngine.characterNameList[index];
                }
            }
            console.log('Could not find '+newPose+', using base image.')
            return this._originalName.name
        }
          
    };
    
    //From MOG_CharPoses
    //==============================
    // * Set Character Frames
    //==============================
    // I have edited this so you can have both negative offsets for x and y
    // AND it now checks the LAST offset, not the first one.
    // this means that if you have a pose with a different number of frames
    // than the default, it'll pick up on that!
    // for example, if the base character is Bob(f3), you can now have
    // Bob(f3)_punch(f12)
    Game_Character.prototype.setCharacterFrames = function() {
        this.clearCharacterFrames();
        var frames = this._characterName.match(/(\(F(\d+\.*\d*))/gi)
        if (frames) {
           this._frames.enabled = true;
           this._frames.index = 0;
           this._frames.max = Number(frames[frames.length-1].match(/\d+/i));
        }
            //edited to include support for negative offsets
        var ex = this._characterName.match(/(X(-?\d+\.*\d*))/gi)
        if (ex) {this._frames.x = Number(ex[ex.length-1].match(/-?\d+/i))};
        var ey = this._characterName.match(/(Y(-?\d+\.*\d*))/gi)
        if (ey) {this._frames.y = Number(ey[ey.length-1].match(/-?\d+/i))};
        var sp = this._characterName.match(/(S(\d+\.*\d*))/gi)
        if (sp) {this._frames.speed = Number(sp[sp.length-1].match(/\d+/i))};
        if (this._frames.enabled) {this._pattern = 0};
        this._pattern = this._frames.enabled ? 0 : 1;
    };
    Edit: I got it working! Thanks Restart! :D Question: Do you think I could add more poses to the list easily?
  2. Hi, I'm posting this question to this thread specifically because I think in spite of just being "Restart's notes to self" it's actually the biggest single general repository of useful info/speculation/tweaking to the Crono Engine on this site (speaking of 'notes to self' I have four projects that technically aren't cancelled, two of them including my present hardcore crunch spooky season project use the Chrono engine, and two don't).

    So anyway, right now I think I have discovered that if you create a new tool event on the tool map, when you load a save game, the weapon/tool/presumably skill (have only tested 'weapon') associated with that tool event won't function AT ALL, and you actually need to start a new game to see that tool work (like, it kind of "initializes" it from the tool map at game start?). I am looking primarily for confirmation on this and I'm curious if anyone has figured out a workaround. If not, I'm going to need to adjust my workflow dramatically to get all of my weapons/tools set up correctly in the editor before continuing to lay down events/story in a linear fashion.
  3. TheGentlemanLoser said:
    So anyway, right now I think I have discovered that if you create a new tool event on the tool map, when you load a save game, the weapon/tool/presumably skill (have only tested 'weapon') associated with that tool event won't function AT ALL, and you actually need to start a new game to see that tool work (like, it kind of "initializes" it from the tool map at game start?). I am looking primarily for confirmation on this and I'm curious if anyone has figured out a workaround.
    That's how RPG Maker functions. The state of maps is saved in the save game, so any alterations require you to leave and reload the map. Since it sounds like this is not a map your character can actually go to, you won't have a way to do that.

    This is also true, but more so, with anything specified in the database. Additions that you make will show up when loading a save game, but changes will not. Changing anything to do with plugins also won't load from a save. So there's a lot of stuff that can only be tested by starting a new game.
  4. Thanks @ATT_Turan.

    Fellow Chrono Engine users, have any of you found a gamepad/controller plugin that works with Moghunter's stuff? I haven't seen one where I can actually map 'D', 'A', 'Q', and 'E' to face buttons, or at least, I can't figure out how to do that with the YEP Gamepad Config plugin, and the other popular Gamepad plugin I've seen seems to need to remap keyboard controls to W,A,S,D for movement instead of arrow keys which is not desirable for me for this project.

    Has anyone ever implemented clips/reloading for weapons into Chrono Engine? Probably a long shot, I know.
  5. TheGentlemanLoser said:
    Thanks @ATT_Turan.

    Fellow Chrono Engine users, have any of you found a gamepad/controller plugin that works with Moghunter's stuff? I haven't seen one where I can actually map 'D', 'A', 'Q', and 'E' to face buttons, or at least, I can't figure out how to do that with the YEP Gamepad Config plugin, and the other popular Gamepad plugin I've seen seems to need to remap keyboard controls to W,A,S,D for movement instead of arrow keys which is not desirable for me for this project.

    Has anyone ever implemented clips/reloading for weapons into Chrono Engine? Probably a long shot, I know.
    First off, I want to thank Restart for this handy little repository of (mostly) Moghunter stuff. I've been up to my armpits lately in both chrono and lmbs code, which is how I stumbled across this post. I know you're not looking to take requests... but if you happen to come across a way for other events (ie/ enemies) to switch to idle poses without the use of move route trickery, I'd love to know!

    To the above post, I do have a few lines of code and parameter changes I could send you, so you can use a gamepad. I just don't want to hijack this thread. Send me a DM if you're still looking for a solution.
  6. So, I've run into another issue, much less important but still annoying, and I'm not entirely sure what's happening but it seems to be that while the hookshot tool exists, other tools can't be created/"fired"?
    One of my enemies, the Chainer, uses a hookshot to attack--this is purely aesthetic and so if there's no better fix I can easily change it to a regular ranged attack--and while its hookshot is out, I can't shoot at it, when I press the attack/item buttons nothing happens until the hookshot is gone and then I can counterattack. as a player it's very annoying being unable to fire your weapon because a quite slow enemy projectile is coming towards you, definitely not an experience I want to inflict on my players.

    I *think* it *might* have something to do with the hookshot being the only tool on the tool map with

    Code:
    tool_unique
    - A ação é ativada apenas uma vez.

    in its comment code block. As ever, I wish I was fluent in Portuguese. I should return to this after trial and error if I figure anything out.
  7. Sorry but I wanted to ask if you can crack a patch to use a battle hud and command hud battle different from those of mog, since I plan to buy the Luna engine,And I hoped if it was possible to do such an act I would greatly appreciate it :'D
  8. You're the man, Restart. FOSSIL is awesome and your Yanfly/MOG spawn compatibility patch was a life saver.

    o7
  9. Hello! (My English may be strange because I am using automatic translation)

    I'm having trouble with Yanfly Event Spawner and Chrono Engine bugs (processing becomes heavy).
    How do I use the "Mr. Restart" patch?

    I have one more question
    At the moment the event is spawned using YEP's spawn plugin,
    There is a bug that the Chrono Engine tool image does not disappear (or the shoot is canceled).

    Other Spawn plug-ins other than YEP
    For example, "GALV_EventSpawner", Mr. Triacontane's "EventReSpawn" have the same problem.

    It seems to be a trouble that occurs when the timing of calling the tool map of Chrono Engine and spawning overlaps.

    Is there any way to solve this?
  10. Maybe is a dumb questions, but. How i make the item core fix? I´m changing the code and is exactly the same, I can´t attack. What i have to do exactly?
  11. Restart said:
    Glad I could be helpful

    I have a more robust implementation of a machinegun effect in my personal project using cross engine, but I can't guarantee that it'll be easy to back-port to baseline chrono, since I also ended up doing a full split between whether a character was casting and whether they were acting, and that got tied in.


    This isn't all the functions needed (you still need to pass stuff into the actual firing etc, and I do weird stuff with that that's too much to get into), but it might be helpful if you want a timed reload or something
    Code:
    oldToolNotes = ToolEvent.prototype.checkToolNotes
    ToolEvent.prototype.checkToolNotes = function() {
        oldToolNotes.call(this)
    
        this.fireCount=0;//number of times it was fired.
        this.fireMax=9999;//set a high maximum so it isn't NaN
    }
    
    
    Game_CharacterBase.prototype.updateCooldownDuration = function() {
         this.battler()._ras.cooldownDuration--;
         //play reload sound when player can fire again
         if ( (this == $gamePlayer ) && (this.battler()._ras.cooldownDuration==0))
             {
                 AudioManager.playSe({name: 'reload', pan: 0, pitch: 100, volume: 40});
                
                 SceneManager._scene._toolHud[0].refreshHud();
                 SceneManager._scene._toolHud[1].refreshHud();
                 SceneManager._scene._toolHud[2].refreshHud();
                 SceneManager._scene._toolHud[3].refreshHud();
             }
         };
    
    // You'll need the whole cooldown system with isInCooldown() and updateCooldownDuration() wrapped into the battler update, etc, that's all in cross engine
    
    //handler for multihit weapons
    Game_CharacterBase.prototype.autoWeaponFire = function()
    {
        var weaponPrimary=this.user().battler().equips()[0]//$gameParty.members()[0].equips()[0]
        var fireRate=weaponPrimary.fireRate;
        var fireMax=weaponPrimary.fireMax;
        var actfire=weaponPrimary.actfire;
        var bulletType=weaponPrimary.customBullet || 161;
        var wiggle=weaponPrimary.wiggle  || false; //for automatic weapons, instead of random fire, wiggle back and forth
        var scalingInaccuracy=weaponPrimary.scalingInaccuracy || false; //if 'true', starts accurate and scales up to 2x inaccuracy level
        var shotCost=weaponPrimary.shotCost || 0; //default to free
        var extraCooldown=weaponPrimary.cooldown;
       
        this.chargeup=weaponPrimary.chargeup;
        this.actCharge=weaponPrimary.chargeup||false;
        if (this.chargeup){this.fireMax+=1}
       
        if (wiggle)
        {
            //full wiggle once (so left->right=>left)
            // or 1 -> -1 -> 1
            $gamePlayer.wiggleStep = 2*Math.abs(1-2*(this.fireCount/(fireMax)))-1;
        }else{
            $gamePlayer.wiggleStep=undefined
        }
       
        if ((this.fireCount==0) &&(this.chargeup))
        {
            if (this.chargeup<35)
            {
                AudioManager.playSe({name: 'sn_windup005', pan: 0, pitch: 100, volume: 90});
                //half a second
            }else{
                AudioManager.playSe({name: 'sn_windup01', pan: 0, pitch: 100, volume: 90});
                //full second
            }
            this._waitCount+=this.chargeup;
            $gamePlayer.battler()._ras.cooldownDuration+=this.chargeup;
            $gamePlayer.battler()._ras.poseDuration+=this.chargeup;
            if (this.actCharge)
            {
                $gamePlayer.battler()._ras.actDuration+=this.chargeup;
            }
        }else{
            if(Input.isPressed(Moghunter.ras_buttonWeapon) && (this.fireCount<fireMax) &&($gamePlayer.battler().mp>shotCost))
            {
                $gamePlayer.battler()._mp -= shotCost;
                $gamePlayer.act(bulletType)//our generic multibullet
            }else{
                $gamePlayer.battler()._ras.cooldownDuration+=extraCooldown
                this.erase();
            }
           
            if(actfire)
            {
                $gamePlayer.battler()._ras.actDuration+=fireRate;
            }
            this._waitCount+=fireRate;
        }
        this.fireCount++;
       
        if($gamePlayer.battler()._ras.poseDuration>0)
        {
            $gamePlayer.battler()._ras.poseDuration+=fireRate+1;
        }
       
        if($gamePlayer.battler()._ras.cooldownDuration>0)
        {
            $gamePlayer.battler()._ras.cooldownDuration+=fireRate+1;
        }
    
    }

    and then had something in the weapon notes like this to set custom params
    Code:
    Tool Id : 162
    
      <On Creation Eval>
       item.fireMax= 10; //maximum bullets fired
       item.inaccuracy=25; //amount of inaccuracy
       item.fireRate=4;//frames between shots
      </On Creation Eval>

    anyway dunno if that'll be helpful or not, but figured I might as well dump some code in my code dump thread
    Restart, i really need your help! I don't use cross engine, i use default Mog's chrono. I need to change diagonal movement speed for characters, and i don't really know how to do it. Chat GPT said that everything in the engine is tied to diagonal movement, I tried to integrate the Pythagorean theorem, but nothing worked...
  12. Vladar458 said:
    Maybe is a dumb questions, but. How i make the item core fix? I´m changing the code and is exactly the same, I can´t attack. What i have to do exactly?
    This was answered in another thread but for the lurkers: you need to enable mid-game note parsing in YEP Item Core.

    wecanfayo said:
    Restart, i really need your help! I don't use cross engine, i use default Mog's chrono. I need to change diagonal movement speed for characters, and i don't really know how to do it. Chat GPT said that everything in the engine is tied to diagonal movement, I tried to integrate the Pythagorean theorem, but nothing worked...
    Restart doesn't come here anymore, but you would have to either adapt Restart's patch or modify the diagonal movement functions in ChronoEngine yourself. It's not clear how you want to change it
  13. AquaEcho said:
    This was answered in another thread but for the lurkers: you need to enable mid-game note parsing in YEP Item Core.


    Restart doesn't come here anymore, but you would have to either adapt Restart's patch or modify the diagonal movement functions in ChronoEngine yourself. It's not clear how you want to change it
    If I knew, I wouldn't ask... The chrono engine has 20 thousand lines of code and it is not clear on which line there is at least something responsible for speed, all I found was the general speed of the character.
  14. wecanfayo said:
    If I knew, I wouldn't ask... The chrono engine has 20 thousand lines of code and it is not clear on which line there is at least something responsible for speed, all I found was the general speed of the character.
    Diagonal movement is going to be handled by moving directions in odd numbers so you would look for code that involves that, like the move random functions. I'm pretty sure Restart already addressed it so you could just edit the same function he did. It's still not clear HOW you want to edit it.
  15. AquaEcho said:
    Diagonal movement is going to be handled by moving directions in odd numbers so you would look for code that involves that, like the move random functions. I'm pretty sure Restart already addressed it so you could just edit the same function he did. It's still not clear HOW you want to edit it.

    I want to reduce the diagonal movement speed. I tried to kill the chrono diagonal movement using the galv diagonal plugin, it actually worked for the character, but caused random teleports for enemies. This didn't seem like a solution to the problem.
    Then I let Chat GPT study the chrono code. He explained to me that diagonal movement most likely works by adding movement along the x - y axes and because of this, the speed of diagonal movement is different. Chat gpt checked 12k lines and did not find anything similar to what I needed, and he immediately realized that it was an rpg maker and he said that he had already been fed the chrono engine. I don’t know anything about Java at all, so I asked a programmer friend to take a look. He said that perhaps all diagonal movement works by addition and that you can't just change some number to change the diagonal movement. He tried to implement the Pythagorean theorem into the chrono, but it broke all the magic and attack. I couldn’t bother my programmer friend any further; after all, he has his own things to do, so I’m trying to find out at least some information. If you don't want to help, don't give empty advice.
  16. wecanfayo said:
    If you don't want to help, don't give empty advice
    It wasnt empty advice, I pointed you to the functions to look at. But hey, no problem, I'll stop here and won't answer any of your other questions either. Good luck.
  17. AquaEcho said:
    It wasnt empty advice, I pointed you to the functions to look at. But hey, no problem, I'll stop here and won't answer any of your other questions either. Good luck.
    Maybe I sounded rude, I'm not that good at English. But I don't see you pointing me to anything...
  18. Vladar458 said:
    Maybe is a dumb questions, but. How i make the item core fix? I´m changing the code and is exactly the same, I can´t attack. What i have to do exactly?
    Since this is a great place to fix things with the MOG_ChronoEngine up, here is a little hint that - prevent - you from using the whole "Demo" to get the ChronoEngine to run as YOU want to set it up in your game. No tutorial I saw was able to explain why an Enemy does not get hurt, does not attack and so on. Multiple tutorials are in fact just outdated, so it's clear why something cannot work at some point. Also most of the comments did run more into nothing, so reading them was a big waste of time. The easiest AND fastest way to troubleshoot YOUR game, without cloning the whole thing, would be to put the different .json files from the data folder of Mog_ChronoEngines one by one into YOUR project data folder. (That should be a test version or the start of your game base!)

    I assume you have at least the first tools and items set up like in the MOG_ChronoEngine onto the tools map, that would be needed to "clone" new skills, items or "tools" in general. I'd recommend that for sure to start with. A tool map, the first 15 tools/items (just to be sure till everything works, later you can delete or change them). Now, set up the enemy you want to test with as you should and mind the movement routes and settings that come with it. Yes, also the little enemy settings that are made! Everything not related to the ChronoEngine with a slight change can create a bug. If you start to see there is something NOT working at this point, then stop your trial and error process right there. Think about what file is logically responsible for the bug you seem to experience. Open both data folders Yours and Mog_ChronoEngine, start switching one file after the other, test the game, see what changes.
    Attention: Backup YOUR files first!

    IF something has changed, open the Editor for the MOG Demo version, take your backup file back into your own data folder and start to look deeper onto the different settings you have to make so things would work as intended. It can be a typo, it can be a list of "things" that should not even be necessary or lets say, that should be more likely optional, but seem to be like hardcoded into the functionality of the engine. If you ask me, there are thousands of lines of code not necessary for the simple ABS system without any kind of turn based action. Anyways...


    Example that has happened to me:
    Enemy fix:
    Let's assume your enemy does not attack you, or attacks you but cannot hurt you or the other way around and you are in fact sure you set the tools and the enemy event (also event page two) right up as it should be, then copy the "Enemies.json", then later on the "Classes.json", then the Skills.json and so on into the data folder. One by one, testing the game, taking the next, testing again. If it works mysteriously, it was the file you made a mistake in and this file you'd have to change. For me it was the enemies, troops and classes, which prevented me from hurting the enemy or the other way around. And there it was for example the enemy I CHOOSE to test with. All of the enemies have in fact as a vanilla setup a by far to high rate of luck, defense settings and so on. So you are not able to hurt them! And with the standard settings in your fresh setup game or a standard setup you know should just work fine with the ordinary battle system of MV, will NOT work with the chronoEngine and create these bugs. You will not have an error message and you will go crazy by checking every setting for the ChronoEngine, leaving out the most simple things. The standard game setup...

    I also had trouble seeing the Items and skills in the menu OR that these skills would not fire and so on. Every problem of this kind I solved just by checking with the original files in my own project. It is a clean test project and for a plugin like that it should be, to prevent anything from interfering. So it's in my opinion the best way to understand the mistakes.


    I also have to say Thank you @Restart ... I hope your topic will help me prevent a lot of experimenting on my own and will fix bugs I may experience.
  19. gniiial said:
    put the different .json files from the data folder of Mog_ChronoEngines one by one into YOUR project data folder.
    You don't need to touch the json files. What you do need to do is copy the tool map events and the database entries for the skills, items and weapons you want from the demo project to your project. The database data is stored in the json files which is why that worked for you but it's a roundabout way of just copying and pasting entries between projects in the editor.

    You also need to update the id pointers in the comments of the tool map events and the noteboxes of the database entries if the ids are not the same in your project. If fireball is no longer tool event 53 and database skill 54 in your project you need to update the comments and notebox to what it is in your project for it to work.