MOG_ChronoEngine Adjustments

So I've made a few more alterations as time allows and I wanted to post a quick one. One issue I knew would result from the way I handled the camera in my prior posts was having intended targets off screen and the like. Especially an issue if you were trying to select said target. This post will cover my personal fix to that and is based off the other modifications I've shown already. The only prior required modification is the one I made to Galv's Camera Control to add followers into the plugin's ability to focus the camera on something. All variable and switch numbers can be whatever as long as they all are used accordingly in that project. Now off to the races...

JavaScript:
//==============================
// * refresh Position
//==============================
ToolCursor.prototype.refreshPosition = function() {
    this._active = $gameTemp._autoTarget.enabled;
    $gameTemp._autoTarget.refresh = false;   
    if (this.battlers().length === 0) {
        this.executeCancel();
        return;
    }

    $gameTemp._autoTarget.index = this._index;
    for (var i = 0; i < this.battlers().length; i++) {
        if (this._index === i) {
            var target = this.battlers()[i];
            if (target) {
                this._target = target;
                $gameTemp._autoTarget.target = target;
                this._nx = target.screenX();
                this._ny = target.screenY();
                this.refreshName(target);

                // Kalian: ultra mode seven didn't like this method and I assume its because it expects
                // map coords? I'll look into it later. Leaving this here as a reminder.
                var cameraX = Graphics.width / 2 - this._nx;
                var cameraY = Graphics.height / 2 - this._ny;
                $gameVariables.setValue(51, cameraX);
                $gameVariables.setValue(52, cameraY);

                // Kalian: Workaround to prior issue, just grabbing the cursor's target's
                //event Id
                if (target.eventId) {
                    var eventId = target.eventId();
                    $gameVariables.setValue(53, eventId);
                    console.log("Event ID stored in game variable 53: " + eventId);
                }

                // Kalian: Checking if the target is an actor and handling it as such
                if (target.battler() && target.battler().actorId) {
                    var actorId = target.battler().actorId();
                    var actorIndex = $gameParty.battleMembers().indexOf(target.battler());
                    $gameVariables.setValue(54, actorId);
                    $gameVariables.setValue(55, actorIndex);
                    console.log("Actor ID stored in game variable 54: " + actorId);
                    console.log("Actor Index stored in game variable 55: " + actorIndex);
                    // Kalian: turn on switch 118 if it is an actor.
                    // this calls a common event that handles camera focus etc.
                    $gameSwitches.setValue(118, true);
                }

                if ($gameTemp._chronoCom.user) {
                    this.refreshDirection(target);
                }
            }
        }
    }
    if (this._hpGauge && this._target) {
        this._hpLayout.x = this._hpLayout.org[0] - (this._hpLayout.width / 2);
        this._hpLayout.y = this._hpLayout.org[1];
        this._hpGauge.x = this._hpGauge.org[0] - (this._hpGaugeImg.width / 2);
        this._hpGauge.y = this._hpGauge.org[1];       
        this.refreshHpGauge();
    }
    $gameSwitches.setValue(117, true); //Kalian: calls switch 117 common event
                                       //to process cursor cam on enemy target
};

Inside chrono engine you'll need to find the "refresh Position" function. This is where the magic happens. I've commented relevant parts of the code that I added. the part where I store two variables name cameraX and Y are not needed. It's a method I'm going to approach at a later date as its going to require me digging in to ultra mode 7 as well and understanding it how it does things. I assume I simply need to store just the Map coordinates there instead of the returned "screen" but I digress.

Anyway, add the relevant portions or just overwrite the function with mine, the changes are self contained so it won't change its original functionality. Then we need to make one more small change to the way I handled the followers addition to galv's cam plugin.

JavaScript:
Galv.pCmd.CAM = function(arguments) {
    var key = arguments[0].toLowerCase();
    var speed = 800;
    switch (key) {
        case "player":
            var target = $gamePlayer;
            if (arguments[1]) speed = Galv.CC.getValue(arguments[1]);
            break;
        case "event":
            var eId = Galv.CC.getValue(arguments[1]);
            var target = $gameMap.event(eId);
            if (arguments[2]) speed = Galv.CC.getValue(arguments[2]);
            break;
        case "follower":
            var followerIndex = $gameSwitches.value(118) ? $gameVariables.value(55) : $gameVariables.value(42);
            var follower = $gamePlayer.followers().follower(followerIndex - 1);
            var target = follower ? follower : $gamePlayer;
            if (arguments[1]) speed = Galv.CC.getValue(arguments[1]);
            break;

        case "disable":
            $gameMap.camTarget = $gamePlayer;
            $gameMap.camNorm = true;
            $gameMap.savedCamTarget = null;
            return;
        default:
            var px = Galv.CC.getValue(arguments[0]);
            var py = Galv.CC.getValue(arguments[1]);
            if (arguments[2]) speed = Galv.CC.getValue(arguments[2]);
            var target = {
                x: px,
                y: py,
                _realX: px,
                _realY: py,
                screenX: Game_CharacterBase.prototype.screenX,
                screenY: function() {
                    var th = $gameMap.tileHeight();
                    return Math.round(this.scrolledY() * th + th);
                },
                scrolledX: Game_CharacterBase.prototype.scrolledX,
                scrolledY: Game_CharacterBase.prototype.scrolledY
            };
    };

I made a slight alteration to how I was already handling the actor index here so if you used my prior mod on this you'll need this as well. All we do here is check if switch 118 is on. if it is we are going to get our index from the variable that was loaded with it in the refresh Position function.

So let me explain a bit more for context. In my setup, 117 calls a common event that governs camera behavior when an enemy is a target. 118 is for the actors and tied to it's own common event.

Spoiler: Cursor enemy
1714060213864.png

Spoiler: Cursor Actor
1714060256222.png

Here, variable 55 is being used for the actor index.

Well that about covers this. Here's a video showing it off for those curious on how it looks and not wanting to have to go through the trouble of setting it up just to see it. I also show off having maps that ignore pitch commands from mode 7. The first map accepts the pitch commands while the second doesn't. This is just simple conditional statements inside common events so unless someone needs explicit help setting something up I doubt it's worth posting in this. Anyways, have a good day everyone!

I shared your video in another thread

I'll have an Chrono Engine Advance features thread up tomorrow. I'm wrapping up my beginner guide. It's going to include how to set up a controller to use with Chrono Engine using Hakuen Studio Button Common Events but I need help figuring out how to get the shield to stay up when you hold the button as that's the only thing that eludes me.

This is what I'm using but either how the Hakuen plugin handles button triggers or something in Chrono Engine immediately sets ._ras.guard.active to false
Roger that. I haven't messed with Hakuen before. I haven't got around to even trying to implement any sort of controller support as of yet. I remember you saying you were using the ABS side of chrono engine mostly. I took a quick look but I don't see anything that would be hindering it on chrono engine's side of things but thats from a REALLY quick look. In the process of getting the crock-pot loaded for what is going to amount to a really late night dinner lol. Once I get seated back in front of the machine and if you haven't solved the issue already I'll see if I can't lend a hand if ya need.


This is what I'm using but either how the Hakuen plugin handles button triggers or something in Chrono Engine immediately sets guardActive to false
EDIT: What if you assign it to something other than RT, does it seem to function correctly then? if I recall Trigger inputs on controller can vary from analog to digital. If its an analog input it might be the issue. I can't be certain until I get to test it.
I haven't messed with Hakuen before
It's the only plugin I've found that lets you call common events on button press for all the different controller buttons, e.g. Start, Select, RT, LT, etc. Mano InputConfig might do it too but since that's in Japanese I figure most people would prefer the English option.

It's the only plugin I've found that lets you call common events on button press for all the different controller buttons, e.g. Start, Select, RT, LT, etc. Mano InputConfig might do it too but since that's in Japanese I figure most people would prefer the English option.

Well I've done some test and I am leaning towards Eli's to be the primary issue here though I'm still not exactly sure as to why yet. Using your common event setup I can confirm that what you described is the case. So I tried forcing the d key input in the common event instead to test what happens that way. It's reaction then was that guard would activate but never deactivate as if the release of the trigger is never detected. Adding a message to the common event shows I can still call it by pressing it but for some reason it just keeps me in the guard state. so I tested my controller by disabling eli's and going straight forward at it.

JavaScript:
const isPS4ControllerPresent = navigator.getGamepads && navigator.getGamepads()[0] && navigator.getGamepads()[0].id.includes("Wireless Controller");

if (isPS4ControllerPresent) {
    const gamepad = navigator.getGamepads()[0];
    const isR2Pressed = gamepad.buttons[7].pressed;

    if (isR2Pressed) {
        Input._currentState['d'] = true;
    } else {
        Input._currentState['d'] = false;
    }
}

Without Eli's I attempted to recreate this (albiet for testing purposes so it detects only for my ps4 controller) and I get the expected result (in this instance guard works as intended) so long is as a shield is equipped on the character. I'll look more into how eli's plugin operates if I can today and see if I can figure out where things are kind of dropping off as long as time permits.

Edit for Update: This will probably be my last chance I get to look at it tonight but while I was doing other stuff I thought of something and made a quick adjustment to the common event. Try this and let me know what it does on your end.

Spoiler: Common event
1714084649364.png

you'll need to activate 121 switch outside of the common event somewhere, it'll need to be assumed it's active at all times in the context of what we are doing here. This common event needs to be set to parallel. This seemingly activated and maintained the guard state for me at a glance but we're kind of having to force check ourselves here whether the RT is pressed or not and RT simply calls the common event to start up. I now believe its kind of half and half as far as which code base is to blame here as it really seems they are expecting different things from each other. I havent really had time to test it. its not calling the function directly just simulating the key press on the keyboard for it. I haven't been able to call the right part of the guarding logic to get it to maintain and hold guard as of yet. that said there is a sprite animation error where the pose seems to terminate prematurely this way, I'm not sure whether or not it's terminating the actual guard logic with it however since I haven't tested it.
Morning to ya 🙂.
It's the only plugin I've found that lets you call common events on button press for all the different controller buttons, e.g. Start, Select, RT, LT, etc. Mano InputConfig might do it too but since that's in Japanese I figure most people would prefer the English option.


EDITED for correct handling: Just tested this Aqua, and it works as is like this. Was making some more pixel art for what I've been doing and it just hit me like a truck that I was way overthinking things lol. Eli's button plugin for this is button is assigned to parallel. We'll need a switch to govern this common event outside of it so that we can turn it on at the beginning of the game. Just tie this to that switch and have the common event set up like this and it should be golden.
Spoiler: Common Event Guard
1714226413957.png

Looking further on this it would appear you could do this for each of the commands I believe. I don't see any reason why, right off the bat anyhow, it wouldn't just work in the same manner.
JavaScript:
Moghunter.ras_buttonWeapon = String(Moghunter.parameters['Attack Button'] || 'ok');
    Moghunter.ras_buttonItem = String(Moghunter.parameters['Item Button'] || 'a');
    Moghunter.ras_buttonSkill = String(Moghunter.parameters['Skill Button'] || 's');
    Moghunter.ras_buttonGuard = String(Moghunter.parameters['Shield Button'] || 'd');
    Moghunter.ras_buttonSkillW = String(Moghunter.parameters['Skill Menu Button'] || 'pagedown');
    Moghunter.ras_buttonItemW = String(Moghunter.parameters['Item Menu Button'] || 'pageup');
    Moghunter.ras_buttonDash = String(Moghunter.parameters['Dash Button'] || 'shift');

any of these should be able to be summoned in the exact same manner as I did with the guard button. Haven't tried it but logic suggests it should work which would make a nice comfortable way of calling each of these as you need them.
Thank you very much! I just created the Advanced Features and Scripts Thread so I'll test this out in a bit.
Not a problem 🙂. You've been busy I see lol. So much stuff going on lately around the house I haven't had a chance to check up on your progress with the Chrono Engine related threads. Welp, this should be a good morning read then lol. Cheers to ya! If ya run into any troubles and think I may be of assistance feel free to ask. As long as time permits I'm always up for a good puzzle.
Alright so I believe I've nailed this issue down to some extent at least. If you are having this issue as I am we need to look back inside FlintX Custom-CrossEngine.js again.
Spoiler: Party leader dead stops stepping animations for party members fix
This is my altered update Animation function within that plugin.

I started focusing on the update portions of the different plugins and seems like this particular function overwrites the original contained within Mog's Chrono engine. It seems the primary change here that was made by Restart I think was changing the original's isActing to isPosing. Not knowing what all either of these is tied to quite yet I tried to poke as little at it as possible by accounting for either or as they should only be an active state when taking an action of some sort, I think anyway. I know isPosing is definitely used for that purpose but I'm not sure if there is more that it encompasses other than one function of note in the code that is a literal Jojo reference lol. Hats off to whoever did that one, it caught me off guard and gave me a good chuckle.

Anyway in all instances I did check it seemed to be used for specifically actions. So its safe to assume that I can check for it OR isActing to determine whether the battler is doing something with his time or sitting in place like the lay about I know he is. If we know he's just sitting there we tell him you could at least breath some. That's important... Thus stepAnime = true gets set here now. If they are acting it'll just follow the original lines of the function. I'll check up on it more when I have more time and if he's still sitting there holding his breath when I'm not looking I'll try and figure out why and post an update if I manage to make headway on the issue.

Take care all!
these updates are amazing kalian, but when I add these lines, the characters perform a walking animation even when standing still, although if we don't add these lines they stop the animations when the party leader is dead.

Or maybe it's me doing something wrong.
these updates are amazing kalian, but when I add these lines, the characters perform a walking animation even when standing still, although if we don't add these lines they stop the animations when the party leader is dead.

Or maybe it's me doing something wrong.
Hey sorry it took so long for me to respond or see this. I've been caught up with dealing with life stuff for a bit and had to focus my attentions there. Hmm.
Can you show me the alterations you've added into your setup thus far? I know it's a bit of a hassle as far as requests go but just want to check over what ya got. All I need is just the sections of code you've added. Its also totally possible there may be an issue here I'm forgetting as well that I accounted for at a later date and never got around to posting.
Edit: Or if you want to upload your version of that .js file for me to look over that would work too. whichever is easier for ya. I have an idea of whats going on here but I need to make sure if it truly is the case. We may end up taking this to PM on further thought until this is resolves so we dont clutter up this thread until we've made a solution to the issue.
Well, in mog char poses i added these lines
Captura de tela 2024-07-23 215933.png
Captura de tela 2024-07-23 220007.png


and in FlintX Custom-CrossEngine i added this

Captura de tela 2024-07-23 215736.png


i only added these lines.

basically, the character has the animation of walking, even when standing still, its a shame, but i don't undestand well of rpg maker mv, so i don't manage to figure out what is happening.

Original thread: https://forums.rpgmakerweb.com/threads/mog_chronoengine-adjustments.137635/