Can you help me - an attack event

Hey guys. after long time I have returned to make a summerproject. A minigame the summer.
So I have earlier got some help inside this forum.


I will start saying im not good at programming yet. and thats the reason dont use scripts yet.
Okey the reason I type a new post is because the other problem from the link above is solved.

So whats my problem now. Right now when I run my game and go to my enemie this Hornet, it will activate this If setting and begin to go close to me but it looks for me as when it first enter my Set movement Route action it will never exit it again. it will just stand face to face with my "Player" event. Some times if I move away for it it will activate the battle.
1624690996902.png


And now to the fun part. I tried to make a new enemie, a humen. Just to see if it want execute my action because it was a Hornet, same happend, he went to me and just looked scary into my players eyes. And on my Humen I just made him follow me and execute a fight, so the player lvl and player distence was not in his "Contents"

I have also tried to change my Player to Harold just to see if it was the Generater who have made a misplacement in pixels, but no Harold didn't work eather

So it seems I perhaps have to make a code instead of this set movement route. bot tbh, I have no idea how to get this to work?

The only wey I have got a more stable solution out of it is if I remove the "Wait for completion" and when this is checked off it goes one step closer to me and enter the battle, what I want is that he first enter battle with my Player when they collite
1) you never calculate the distance between the event and the player, you just load the x coordinate of the player. so as long as the player staying out of the column on the left of the map, the X-Coordinate = 1 condition will never trigger.
Calling a variable "distance" will not make its content a distance unless you calculate that.

2) next time, please show the full event and not only the contents. The properties and especially the page priority can change a lot in event behaviour.
Im not 100% sure about where you want me to look. But I think you refer to my "If" settnings when you says I havn't made a calculate. Im lost, i mean most of all when I hit play all works until in should enter battle.
Unavngivet.png
I have now made a full screenshot of it. and marked where I think the problem is and I want to try to say then if you want can correct me.

I started making this Hornet event. Who shall be the basic of my combat system when I fight my wildlife. Like in Pokemon its when you hit the grass

Then I used the other post I made to make 3 variables, 2 for my toons to check lvl and one for player distance.

Then I my first "If setning" to say if Garr is lvl 3 or less, then the Hornet will move to him, else it will flee. after that I use my secound "If setning" to sat but if the player Distance us less or equel to 5, it should start move to me.

As I say all of this with the If settnings works fine. It wait until im 5 sqeres to it then it start moving. and if I change my lvl to 4 and move 5 sqeres for it then it will flee.

So im still sure that where my problem is are because I still dont fully understand the "Set Movement Route" function. because everthing else works fine
As I say all of this with the If settnings works fine.
no, they don't - they might look as if they work due to the positions of the player and the event on entering the map, but they won't work at all if you place them differently.
transfer the player to the right bottom of the map and the enemy event will always run away even if you have it starting within two or three steps from that player position.

Your marked set movement route will never work, because the script command is not valid javascript and will always produce an error that will then be skipped.
If you have a plugin that completely rewrites the scrip command this might be redirected, but without such a plugin that "CRASH MOVE TO: PLAYER" is absolute nonsense.


How about you try to get a much simpler event structure by using autonomous movement and event touch trigger? Because the way you have constructed the event even with all bugs remove it will only add to a lot of lag if you use more than one or two on a map.

make the event two pages, one for approach and one for running away.
use the level variable on the page condition to differ between them - you'll need a different event to update the level variable, but level doesn't change that much and should not be updated constantly either.
on the run away page, set autonomous movement to custom:move away
on the attack page, set autonomous movement to approach, trigger to event touch and one single command in the content area: battle processing.

That is only a start as that would still be missing both the distance calculation and how to prevent constant battles (neither your nor this event is disabled on victory), but it will be a better start.
There are plugins that do exactly what you're looking for: http://www.yanfly.moe/wiki/Event_Chase_Player_(YEP)

If you rather want to make this yourself, check out youtube and other sources, I'm sure there are tutorials for that. If not, @Andar knows his stuff, listen to the dude. 😀
no, they don't - they might look as if they work due to the positions of the player and the event on entering the map, but they won't work at all if you place them differently.
transfer the player to the right bottom of the map and the enemy event will always run away even if you have it starting within two or three steps from that player position.

Your marked set movement route will never work, because the script command is not valid javascript and will always produce an error that will then be skipped.
If you have a plugin that completely rewrites the scrip command this might be redirected, but without such a plugin that "CRASH MOVE TO: PLAYER" is absolute nonsense.


How about you try to get a much simpler event structure by using autonomous movement and event touch trigger? Because the way you have constructed the event even with all bugs remove it will only add to a lot of lag if you use more than one or two on a map.

make the event two pages, one for approach and one for running away.
use the level variable on the page condition to differ between them - you'll need a different event to update the level variable, but level doesn't change that much and should not be updated constantly either.
on the run away page, set autonomous movement to custom:move away
on the attack page, set autonomous movement to approach, trigger to event touch and one single command in the content area: battle processing.

That is only a start as that would still be missing both the distance calculation and how to prevent constant battles (neither your nor this event is disabled on victory), but it will be a better start.
To begin with I really appreciate your help

Okay I think I begin to understand now. Sorry for my skilllevel in RPG MAKER.

I have now made a event for the same Hornet so when I hit lvl 3 it will make a Selfswitch to A. And
1624698214909.png
where it moves towerd to me as on the screenshot below
1624698177963.png
Okay I have tried a little. And now I wanna ask if you the time.
So in Selfswitch A I want 2 thing to happen. First I want a distance before the Hornet can see the player. So if im inside its range it will then go for an attack and move towerd the player.

The other thing is when it then collite with the player it will enter the Battle proccessing. How will you do that?
in the last screenshot,
delete the set moveroute command
switch autonomous movement to approach
switch trigger to event touch

finished

don't use parallel for everything - you should only use a parallel process if absolutely neccessary, and as I described above autonomous movement is much better than a set moveroute on parallel
Long post here, sorry, I'll be spoilering stuff to make it less hard on the eyes.

If you're worried about using plugins because you don't understand coding, you can quell your fears. Unless you're actually creating the plugin, all plugins are relatively plug and play unless they say you need to dig into the code and add stuff yourself. Most do not require this and those that do are usually well formatted, haha.

All you do is paste a plugin into the js folder, than add it to your project through the Plugin Manager (click the puzzle piece icon to get to it). You usually have to add/modify values, but it's all very trial and error and there's usually explanations provided by the plugin authors for what each parameter entails. And help documents as well.

You will definitely need a plugin if you want a distance/range between the player and the enemy before chase. Moghunter and Yanfly both have plugins for this.

Disregarding plugins for the moment, I do wanna point out, on this event here, Event Page #2...
1624700055449.png
Spoiler: Event Page #2
This will not work. This will just throw you into a battle every time you enter the map or return to the map after the battle and you will be softlocked. Parallel is not used for events like this, since it basically runs every content in order in the background, every frame it's active. If you set the event to Event Touch, the enemy will start a battle upon collision as you desire, not every frame.

You don't want the set movement route in the event either. There's an autonomous movement box next to the image there, and the movement route you set as Autonomous Movement will run without you needing to set it through contents (the self-switch is what allows this page's movement to be read). In fact, there's an Approach option in autonomous movement.

The reason why you want multiple pages for these events is because this event requires different movement routes and contents depending on different conditions.

Going back to Page #1...
1624703147959.png

Spoiler: Event Page #1
Keep in mind that self switch A is makes it so the event will NEVER check this page again as long as the self switch is on, even if you leave the room. You also don't have autonomous movement set up here either, which would be better than resolving through the contents. There's a random option as well.

However, all of this loops back to requiring the proximity plugin to complete your total vision. The level check needs to be done upon entering a range and needs to be repeatable, then the event needs to switch into either the fight or flee mode depending on the level check's results (these will still have to be separate pages anyway, so you're on the right track). All of this can be done with Moghunter's Event Sensor (found in his master file here) or Yanfly's Event Proximity Activate.

Another thing...
Spoiler: Quick thing I noticed in the OP
And now to the fun part. I tried to make a new enemie, a humen. Just to see if it want execute my action because it was a Hornet, same happend, he went to me and just looked scary into my players eyes. And on my Humen I just made him follow me and execute a fight, so the player lvl and player distence was not in his "Contents"

I have also tried to change my Player to Harold just to see if it was the Generater who have made a misplacement in pixels, but no Harold didn't work eather
Just so you know for the future, the images will not affect the hitbox, especially if you're using the RTP (default) assets, which includes the generator. Events are resolved through events, the images are just graphics drawn on top that don't really interact. Even if there was a pixel discrepancy, it wouldn't effect the collision of your event or anything. There wouldn't even be a pixel discrepancy with the character generator, as it's made to fit a template, the same template that Harold is made from, and sized to fit the MV engine.

I also recommend looking up tutorials on this forum or youtube to understand more about how this engine works and what you can do with it/how to use it.
it seems i have got it to work now. Thanks all for your help. When I run the game now. it will run into me enter battle and then I have used "Erase event after so. I have also tested and if I run into a new map and back again it respawns as intended 🙂
Hey I have found a problem. My Hornet want collide with my player. when it moves random. Can I somehow make so it does not see my player as an obstacle and will then fly into my player
Hey I have found a problem. My Hornet want collide with my player. when it moves random. Can I somehow make so it does not see my player as an obstacle and will then fly into my player
Can you elaborate and share screenshots of the current event pages?

To me, the easiest explanation as to why your event wouldn't be chasing and activating the battle would be that the chase page with the battle isn't being triggered. But nobody will know until the event pages are shared.

Original thread: https://forums.rpgmakerweb.com/threads/can-you-help-me-an-attack-event.137830/