MOG_ChronoEngine - Help with the Chrono Engine (Battle Spacing, TP, Guard,)

I am trying to achieve Adding TP when using guard in the chrono engine battle. By default it seems to do a random low variant.

Another issue I am trying to resolve is making hero start battle with 0 TP.

It would be nice to know where this battle system is getting its TP parameters for when being hit, attacking etc.

I have tried editing Game_Battler.js but it doesn't effect battles when using chrono engine. Anyone can help me?
do you mean in ABS mode or in chrono mode fights?

Is the TP gain at all effected by the guard skill (like, if you increase it to 100, does that change anything)?
For your tp gain on guard issue Restart is likely correct, in your games database go to Skills then find Guard. In there you should see by default Guard skill gains 10 tp. Change this value to whatever you desire your tp gain to be.

for your start battle at 0 tp issue i would try something like this, unfortunately I do not have a project set up for chrono mode battles I only use Chrono Engine ABS myself.

Locate the code below in MOG_ChronoEngine.js and add that line. $gameParty.allMembers().setTp(0); <--- as shown below not here, this one is missing the index due to forums thinking i want italics i guess rofl.

Let me know how it goes, if it doesn't work maybe I can dig deeper. Another method that comes to mind would be removing the tp at the end of each battle, this current method would remove it at the start of each battle assuming it works as I think it should.

For your other issue of knowing where tp gain comes from when attacking, getting hit etc I assume it would be the same place rpg maker mv handles that by default battle engine. I'm not sure but it probably wouldn't take me long to figure out.


JavaScript:
Game_Chrono.prototype.prepareInitialATB = function() {
    for (var i = 0; i < $gameMap.players().length; i++) {
         var battler = $gameMap.players()[i].battler();
         if (battler) {
             battler.atbClearCN();
             battler.clearRasCast();         
             var randPer = Math.randomInt(50);
             var perc = battler._chrono.maxAtb * randPer / 100;
             battler._chrono.atb = perc;
             $gameParty.allMembers()[i].setTp(0);
         };
    };
    for (var i = 0; i < $gameMap.enemiesF().length; i++) {
         var battler = $gameMap.enemiesF()[i].battler();
         if (battler) {
             battler.atbClearCN();
             battler.clearRasCast();         
             var randPer = Math.randomInt(50);
             var perc = battler._chrono.maxAtb * randPer / 100;
             battler._chrono.atb = perc;
         };
    };   
};
I have tried changing the Guard skill and it doesn't effect the chrono mode battles guard function. I will try again.

I tired entering that bit of code into the MOG_ChronoEngine and it didnt have an effect when entered battle.
I will try again.

Its not a huge game breaking issue. It would just be nice to find a way to change the effects the guard function. I am going to download fresh Chono Engine Demo file and try it there. I will post progress.
This is the code that plays when you select guard
Code:
Game_Chrono.prototype.commandGuard = function() {	
    SoundManager.playOk();
	this.actor().atbClearCN();
	this.actor()._ras.guard.chrono = true;
	$gameTemp.clearChronoCommand();
	$gameTemp.clearToolCursor();	
};

I'd suggest trying something like
Code:
Game_Chrono.prototype.commandGuard = function() {	
    SoundManager.playOk();
	this.actor().atbClearCN();
	this.actor()._ras.guard.chrono = true;
	$gameTemp.clearChronoCommand();
	$gameTemp.clearToolCursor();	
        this.actor().gainTp(10)
};
Try throwing this for loop in this function and see if there is any better luck, hopefully this solves that problem for you at least. if this doesn't work out maybe I just gotta set up a chrono mode test project lol.

its odd that the previous spot didn't work because you can see it being called in this function which appears to prepare a chrono battle.


Edit:

So i created a test project for this and the code i told you to use works in both places, i set the tp to 0 for the entire party using the first method, was also able to set the starting tp to 70 as another test using the first method, also had the same result with this method. So I'd double check to make sure you did it properly. 😀

The first method is probably the ideal placement so you're not creating another for loop for such a simple task, just tossing one line into an already existing loop which runs at every battle start is best imo. Make sure you are putting the line of code in the proper loop, the first loop is for players the second loop is for enemies. Throw it in the players loop.

Be sure to copy the line of code from the code snippet and not from the plain text as i was unable to use brackets with an i inside it due to forums thinking i wanted italics lol.

JavaScript:
//==============================
// * prepare Chrono Battle
//==============================
Game_Chrono.prototype.prepareChronoBattle = function() {
    $gameSystem._chronoMode.phase = 1;
    $gameSystem._rasMode = 1;
    $gameSystem._chronoMode.needCreateSprites = true;
    $gameSystem._chronoMode.needCreateHuds = true;
    $gameSystem._chronoMode.battlerActive = null;
    this.clearBaseParameters()
    $gameSystem.onBattleStart();
    $gameParty.onBattleStart();
    $gameTroop.onBattleStart();
    BattleManager.saveBgmAndBgs();
    if (!AudioManager.isCurrentBgm($gameSystem.battleBgm())) {
            AudioManager.fadeOutBgm(4);
    };
    AudioManager.fadeOutBgs(2);
    AudioManager.fadeOutMe(2);      
    this.prepareInitialATB();
    this.setInitialActorsPositionChrono();
    $gameSystem._chronoMode.phaseDuration = 90;
    //test code below
    for (var i = 0; i < $gameMap.players().length; i++) {
        $gameParty.allMembers()[i].setTp(0);
    };
};


I also did some testing on what Restart said and the idea was correct, the placement was a little off, if placed in that location as shown in his post this command here $gameTemp.clearChronoCommand(); messes with this.actor() and only actor #1 would have tp restored on guard instead you want to place this.actor().gainTp(Number) along with the other this.actors before the temp is cleared as shown below. I used 50 tp so the tp gain was really easy to spot in testing, just change that number to whatever you want it to be and you should be good to go 🙂

JavaScript:
//==============================
// * command Guard
//==============================
Game_Chrono.prototype.commandGuard = function() { 
    SoundManager.playOk();
    this.actor().atbClearCN();
    this.actor()._ras.guard.chrono = true;
    this.actor().gainTp(50);
    $gameTemp.clearChronoCommand();
    $gameTemp.clearToolCursor(); 
};
Amazing work @Restart @Ritter !!! You have solved my issue! :ehappy: Before I report this as solved,

Do you know if there is a snip of code to make an specific animation ID play and add it so when I use the guard command it plays said animation?

How would change other effects such as % damage reduced, etc? Would I edit and add code to the same area to achieve this? or is there a way to do it in the RPG maker editor?

Also I am trying to change how much TP actor gains when being hit by an enemy, If you have a idea about that also. Thank you so much for your assistance
Amazing work @Ritter !!! You have solved my issue! :ehappy: Before I report this as solved,

Do you know if there is a snip of code to make an specific animation ID play and add it so when I use the guard command it plays said animation?
this.requestAnimation( whatevertheanimationID is)
I have another question regarding the similar topic. @Ritter @Restart

I am trying to make the battles when using "Chrono Battle System" to look a bit better I don't like how user jumps directly on top of the target enemy when using slightly larger sprites. (Time Fantasy)

Example:
Normal Attack.PNG



I am looking at the MOG_ChronoEngine.js trying to find a way to to make the user move to the target but not on top of the target. So some how move to target but not through, or 1 space away offset in retrospect to the direction actor is facing.

MOG_ChronoEngine.js image:
Offset.PNG
this.requestAnimation( whatevertheanimationID is)

I tried adding this snip of code in the same section of the js where i added the gainTp for the guard but it caused crash once I used the guard move in game test.

Incorrect:
Example: this.requestAnimation(AnimationID);

Correct:
EXAMPLE: $gamePlayer.requestAnimation(AnimationID);

This snip of code works and will pull the animation from database and place on top of player!!

----------------------------------------------------------------------------------------------

**READ THIS ANSWERS HERE**
I thought of a completely better work around and here is the code snip you need to implement into the same "guard" section of the MOG_ChronoEngine.js.. We are going to add a state when using guard, This way I can edit in the rpg maker editor what happens when I used guard!

----------------------------------------------------------------------------------------------
Guarding Issue Solved:

First: Make Guard State in database with parameters you want to be triggered when guarding.
Second: Add Code: $gameActors.actor(ActorID).addState(StateID); to the MOG_ChronoEngine.js alond with other snips from earlier. The only issue here is if you have a follower the animation will only be played on the main actor.
Soleved Guard issues.JPG


Side note: You can change max TP via rpg.object.js - Line 2606 (default is 100)
Max Tp Edit.JPG

----------------------------------------------------------------------------------------------

TP Issues Solved:

As for changing how much TP gained when hit you will find that in the rpg_objects.js
line 3226.. Change the multiplier to what ever you desire (default # is 50)

rpg_objest line 3226.JPG

----------------------------------------------------------------------------------------------
[ Solved Guard Issues ]
[ Solved TP Issues ]

[ Unsolved BattIe Spacing Issue ]
- Trying to achieve 1 space distance between actor and enemy target using chrono battle.
oh you mean specifically inside the guard command? Then you have to grab whatever event you're targeting to be the .requestAnimation target

are you using the jump command in a tool?
oh you mean specifically inside the guard command? Then you have to grab whatever event you're targeting to be the .requestAnimation target

are you using the jump command in a tool?

Thank you for you guidance @Restart

If you could possible help me with the next issue which is battle spacing.

I am using "move_to_target" in the Chrono tool map event: normal attack.
I want actor to move to the closest space to the target, so the actor doesn't land on the enemy directly.

Incorrect Example:
Normal Attack.PNG

I would be best if actor walks up to enemy 1 space away, attacks, and then jumps back to the original position.

I would like actor to be the closet space next to the target while attacking.
fun fact: the move_to_target flag isn't actually detected by the engine, if you put in 'potato' it'd do the same thing.

here's movetotarget original code
Code:
//==============================
// * move to Target
//==============================
Game_Character.prototype.moveToTarget = function(x,y,hPlus,target,through) {  
   if (x === null) {return};
   if (y === null) {return};
   if (!target && !this.battler()) {return}
   if (!target) {var target = this.getTargetCN()};
   if (!target) {return};
   if (!hPlus) {hPlus = 0};
   var prethrough = this._through;
   var predirectionFix = this._directionFix;
   var preDirection = this._direction;
   var through = through != null ? through : false;
   var pos = this.isXYavailableMove(x,y,target,through)
   this._through = false
   this._direction = preDirection
   this._directionFix = true;
   this._x = pos[0];
   this._y = pos[1];
   this.jumpexch(0,0,hPlus);
   this._directionFix = predirectionFix;
   this._through = prethrough;   
};

It looks like if you put these lines after the x===null and y===null

x+= (this.x>target.x)-(this.x<target.x)
and
y+= (this.y>target.y)-(this.y<target.y)

It should work, but honestly I am not really well acquainted with chrono mode.
fun fact: the move_to_target flag isn't actually detected by the engine, if you put in 'potato' it'd do the same thing.

here's movetotarget original code
Code:
//==============================
// * move to Target
//==============================
Game_Character.prototype.moveToTarget = function(x,y,hPlus,target,through) {
   if (x === null) {return};
   if (y === null) {return};
   if (!target && !this.battler()) {return}
   if (!target) {var target = this.getTargetCN()};
   if (!target) {return};
   if (!hPlus) {hPlus = 0};
   var prethrough = this._through;
   var predirectionFix = this._directionFix;
   var preDirection = this._direction;
   var through = through != null ? through : false;
   var pos = this.isXYavailableMove(x,y,target,through)
   this._through = false
   this._direction = preDirection
   this._directionFix = true;
   this._x = pos[0];
   this._y = pos[1];
   this.jumpexch(0,0,hPlus);
   this._directionFix = predirectionFix;
   this._through = prethrough;
};

It looks like if you put these lines after the x===null and y===null

x+= (this.x>target.x)-(this.x<target.x)
and
y+= (this.y>target.y)-(this.y<target.y)

It should work, but honestly I am not really well acquainted with chrono mode.


Haha @Restart Thank you!! It is so funny you say that! Thank you I will try this out and fiddle around! Nice catch on that! Good job! I will edit my post soon as I can with progress!

Edit:

@Restart This not working unless I am going about it wrong it wrong.

//==============================
// * move to Target
//==============================
Game_Character.prototype.moveToTarget = function(x,y,hPlus,target,through) {
if (x === null) {return};
if (y === null) {return};
x+= (this.x>target.x)-(this.x<target.x);
y+= (this.y>target.y)-(this.y<target.y);
if (!target && !this.battler()) {return}
if (!target) {var target = this.getTargetCN()};
if (!target) {return};
if (!hPlus) {hPlus = 0};
var prethrough = this._through;
var predirectionFix = this._directionFix;
var preDirection = this._direction;
var through = through != null ? through : false;
var pos = this.isXYavailableMove(x,y,target,through)
this._through = false
this._direction = preDirection
this._directionFix = true;
this._x = pos[0];
this._y = pos[1];
this.jumpexch(0,0,hPlus);
this._directionFix = predirectionFix;
this._through = prethrough;
};
It looks like some things use the jump to character function instead of movetocharacter, including normal melee attacks

This should fix normal melee attacks - I've only tested it on generic enemies (where it doesn't do anything) and on the succubus boss in mog's demo, so you'll have to test it out a bit. You might want to replace the x+= and y+= with the versions that I use here since it actually should scale for body size

Keep in mind that chrono mode weapons actually have a real range and stuff, so if the enemy doesn't actually get touched they won't take any damage. If a character swings a weapon and nothing happens that could be the problem as well.
Code:
//==============================
// * jump to Character Zero
//==============================
Game_Character.prototype.jumpToCharacterZero = function(target,projectile,d) {  
   var disX = target._x - this._x;
   var disY = target._y - this._y;
//add a body-size based offset
   disX+= target.battler()._ras.bodySize*((this.x>target.x)-(this.x<target.x))/2
   disY+= target.battler()._ras.bodySize*(this.y>target.y)
   if (projectile) {
       this.jumpProjectile(disX,disY);
   } else {
	   this.jump(disX,disY);
   };
};
It looks like some things use the jump to character function instead of movetocharacter, including normal melee attacks

This should fix normal melee attacks - I've only tested it on generic enemies (where it doesn't do anything) and on the succubus boss in mog's demo, so you'll have to test it out a bit. You might want to replace the x+= and y+= with the versions that I use here since it actually should scale for body size

Keep in mind that chrono mode weapons actually have a real range and stuff, so if the enemy doesn't actually get touched they won't take any damage. If a character swings a weapon and nothing happens that could be the problem as well.
Code:
//==============================
// * jump to Character Zero
//==============================
Game_Character.prototype.jumpToCharacterZero = function(target,projectile,d) {
   var disX = target._x - this._x;
   var disY = target._y - this._y;
//add a body-size based offset
   disX+= target.battler()._ras.bodySize*((this.x>target.x)-(this.x<target.x))/2
   disY+= target.battler()._ras.bodySize*(this.y>target.y)
   if (projectile) {
       this.jumpProjectile(disX,disY);
   } else {
       this.jump(disX,disY);
   };
};

@Restart
Okay so I've got this working partially;
When the enemy attacks. He lands just in front of actor and does his damage as wanted no matter what direction facing. YAY! but..

When my main actor attacks he still lands on the target when facing up or down. When facing left or right he lands beside the target as wanted.

Facing down/up Actor still lands on target:

Facing left/right works:
screw around with the
Code:
   disY+= target.battler()._ras.bodySize*(this.y>target.y)
line until you get something that looks right.
screw around with the
Code:
   disY+= target.battler()._ras.bodySize*(this.y>target.y)
line until you get something that looks right.

Thank you @Restart I have found the proper code to finish it off by copying yours on the part
-(this.y<target.y))/2...

Thank you!

@Restart

I am having trouble to projectiles now. When attacking with Bow the projectile doesn't work properly it doesn't hit the enemy when facing certain direction. Ive tried playign with body size and tool range but that isent the issue. Is there anything else I need to add to make the projectiles function accordingly?
1593989542534.png
bump
Necro-post notice: @FlintX

Please do not use blue or red text in your posts - these are reserved for moderator and admin actions so they stand out more. You can find our forum rules via the Help link at the top of the page.

Original thread: https://forums.rpgmakerweb.com/threads/mog_chronoengine-help-with-the-chrono-engine-battle-spacing-tp-guard.121572/