Is there any way to give the script more processing power?
No, because it is a script. This is the inherent problem with interpreted languages like Ruby. Technically it can be improved but it would take me weeks to figure out how to code that, since it would require referring to objects I don't understand.
I set the game's process to run on a single core only, but it's only uses 40-50% then the lags start.
Is there any way to make the script to use the full power of a single core if neccesary?
I'm confused why you set it to a single core, (are you thinking of low end computers? Because I don't recall the last time I heard a computer that only had a single core).
Regardless, the percentage is an average over a period of time. The reason it lags is because it isn't running all the time, only once a step, so the average processing is not very high, but the actual processing ends up alternating between 100% and 20% or something. So in reality it is actually using all the processing.
My NPC's objective is to catch the player, so the script is on Repeat.
Whenever the player getting too far in the labirinth, the game starts lagging.
Ok, with a bit of smartness you can improve the amount of processing required. Let me explain why first:
When the script is on repeat, every single step it recalculates the entire path to the player. It requires more processing the further it gets from the player.
The benefit of recalculating each step is to find new shorter paths to the player and to update based on the player's new location. However, it takes a heck of a lot of processing.
So the way to solve this is to change the frequency of recalculating based on the distance, that way it will have a roughly smooth amount of recalculations throughout.
This is one way to do it:
Step 1. Create a separate event run by parellel process that is accountable for your chasing event. Give it no image and put it somewhere out of the way.
Step 2. Create some conditional branches in this event and have it check the distance between the chasing event and the player. To do this you can either use eventing and assign variables the x and y coordinates of them and subtract to find out the distance (player.x+player.y - event.x - event.y), or you can use a script query in the conditional branch and write "Point.new(player.x,player.y).distance(Point.new(event.x,event.y)) < 10" for example.
Each conditional branch should check a whether the player is less than a certain distance, for example the first < 10, the second < 20, the third < 30 if you want three.
Step 3. Within the first branch you want to set your chaser event's moveroute to find the player
on repeat. This way it is accurate if it is near the player. After the moveroute event you want to put a wait event for about 60 frames, so that the parallel processing event checks again in a little while.
Step 4. Within the next branches you want to do the same thing except that the moveroute is
not on repeat. Again you want to put a wait event, only for about 120 frames for the second branch, 240 frames for the third etc.
Step 5. Make sure your last branch has an else condition and put your last moveroute and longest wait in there.
If it lags when it gets close to the player, you know to reduce the distance of your first conditional branch, so maybe < 5 instead. Give this a go and let me know how well it works. There is another way of doing it that is probably more reliable to be efficient, but it's more work.