MV Make distance based attack patterns for enemies in Chrono engine ABS

I´m about to finish the game i´m making, and i want to make the final boss special, giving it attack patters based in the distance the player is from it. (I say "it" because is a monster). My idea is that if the player is close, the boss will use melee attacks, and if the player is far away, the boss will try to close the distance, or use ranged attacks. Someone know how to do this?
You're using Cross Engine so use Restart's distanceToPoint function or if you want line of sight use Dahlys Distance Calculator plugin.

From there, there's multiple ways to do this. You put that distance checking script in a conditional in either the autonomous move route or the event page with a parallel trigger. Then put the different attack patterns under the conditionals or have it self switch to different event pages which each have a different attack pattern in the autonomous move route
You're using Cross Engine so use Restart's distanceToPoint function or if you want line of sight use Dahlys Distance Calculator plugin.

From there, there's multiple ways to do this. You put that distance checking script in a conditional in either the autonomous move route or the event page with a parallel trigger. Then put the different attack patterns under the conditionals or have it self switch to different event pages which each have a different attack pattern in the autonomous move route
The idea would be that change the event page. So event page 1 is the melee pattern, and event page 2 is the ranged pattern. But i´m not understanding that very well, could you show an image?
Put in the enemy's move route or autonomous movement for example

"if the distance between this enemy and the player is greater than 4, set this enemy's self switch B to ON"
Code:
if($gamePlayer.distanceToPoint(this.x,this.y)>4){this.setSelf('B',true)}
Put in the enemy's move route or autonomous movement for example

"if the distance between this enemy and the player is greater than 4, set this enemy's self switch B to ON"
Code:
if($gamePlayer.distanceToPoint(this.x,this.y)>4){this.setSelf('B',true)}
I managed to do it, but the issue now is the boss won´t leave its ranged pattern state. There shouldn´t be another check that turn off Switch B if the player is close? So the boss can return to its melee pattern.
I managed to do it, but the issue now is the boss won´t leave its ranged pattern state. There shouldn´t be another check that turn off Switch B if the player is close? So the boss can return to its melee pattern.
Yes, you just edit the script to reflect that. On the self switch B page
Code:
if($gamePlayer.distanceToPoint(this.x,this.y)<4){this.setSelf('B',false)}

Original thread: https://forums.rpgmakerweb.com/threads/make-distance-based-attack-patterns-for-enemies-in-chrono-engine-abs.175393/