TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,252
Reaction score
7,648
First Language
Indonesian
Primarily Uses
RMVXA
About:
Change the behavior of the "move toward player" move route command to use pathfinding.

Preview:
Screenshot_757.jpg
movetowardplayer.gif

The code:
JavaScript:
Game_Character.prototype.moveTowardPlayer = function() {
    const d = this.findDirectionTo($gamePlayer.x, $gamePlayer.y)
    this.moveStraight(d);
};

Game_Event.prototype.searchLimit = function() {
    return 9999;
};

Terms of Use:
MIT
 

BrentBAM

Veteran
Veteran
Joined
Jul 22, 2020
Messages
90
Reaction score
47
First Language
English
Primarily Uses
RMVXA
Definitely a necessary plugin! Thanks
 

cabanas_ds

Veteran
Veteran
Joined
Aug 13, 2020
Messages
100
Reaction score
26
First Language
english
Primarily Uses
RMMV
Hey sorry for my n00b question.. but do you save this code as a .js file & then put it in your plugins folder?


edit: sorry, the answer to my own question is yes & this plugin works really really well.

thank you.

exactly what I was looking for my police chase system.
 

Gigadragon78

Veteran
Veteran
Joined
Feb 2, 2019
Messages
57
Reaction score
20
First Language
Spanish
Primarily Uses
RMMV
Just paste the code in a text file,save it and change the extension from .txt to js.
 

cabanas_ds

Veteran
Veteran
Joined
Aug 13, 2020
Messages
100
Reaction score
26
First Language
english
Primarily Uses
RMMV
since this works so well (like really well)

are you able to make one that does the same with move away from player?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,252
Reaction score
7,648
First Language
Indonesian
Primarily Uses
RMVXA
Unlike move toward the player, move away from the player does not have a destination. So that can't use pathfinding.
 

cabanas_ds

Veteran
Veteran
Joined
Aug 13, 2020
Messages
100
Reaction score
26
First Language
english
Primarily Uses
RMMV
ah, I get you.

how about path finding to region?

sorry, but pathfinding this is so useful in my game.
 

cabanas_ds

Veteran
Veteran
Joined
Aug 13, 2020
Messages
100
Reaction score
26
First Language
english
Primarily Uses
RMMV
alright man, I got a problem with this plugin.

for some reason although it was working really well on my inside map with a lot of stuff going on.

I started a new map & it causes some extreme lag on events when move towards character is working.

super sad because it works so well for pathfinding but I couldn't even have one NPC using it on my outside map. ;_;
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,708
Reaction score
2,813
First Language
English
Primarily Uses
RMMZ
alright man, I got a problem with this plugin.

for some reason although it was working really well on my inside map with a lot of stuff going on.

I started a new map & it causes some extreme lag on events when move towards character is working.

super sad because it works so well for pathfinding but I couldn't even have one NPC using it on my outside map. ;_;
Instead of using the plugin, try creating a parallel process on the map that uses the same code but called on each moving event rather than being part of the prototype, and put a 1-frame wait after it. See if that helps.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,252
Reaction score
7,648
First Language
Indonesian
Primarily Uses
RMVXA
Pathfinding is expensive. If you use it in a bigger map (with a long path to the player) and also many events using the same move command, it will lag.
 

h0tWalker

Veteran
Veteran
Joined
Jul 7, 2014
Messages
81
Reaction score
93
First Language
Norwegian
Primarily Uses
RMMZ
Awesome! Was gonna look for a system to improve the pathfinding for monster chases. You definitely made my life a lot easier sharing this. Thanks for your hard work, and I can't wait to test this out while setting up the prototype of my project! :D
 

cabanas_ds

Veteran
Veteran
Joined
Aug 13, 2020
Messages
100
Reaction score
26
First Language
english
Primarily Uses
RMMV
this also works as a script & seems to run much lighter since it's an actual RPG Maker script.

$gameMap._events[this._eventId].moveStraight($gameMap._events[this._eventId].findDirectionTo( $gamePlayer.x,$gamePlayer.y ));
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,252
Reaction score
7,648
First Language
Indonesian
Primarily Uses
RMVXA
this also works as a script & seems to run much lighter since it's an actual RPG Maker script.
The difference is that it will use the default search limit, which is 12. So if the path ended up being too long, they don't use a detour. Not because "it is an actual RPG Maker script".
 

cabanas_ds

Veteran
Veteran
Joined
Aug 13, 2020
Messages
100
Reaction score
26
First Language
english
Primarily Uses
RMMV
Sorry bro, I really don't know what I'm talking about. I'm trying to wrap my head around this stuff & it's just making me depressed.
 

Latest Threads

Latest Posts

Latest Profile Posts

Checking out the Judge's Round Table. Really cool getting their perspective in a Q/A environment like this.
I'm heading back to Orlando tomorrow! Dad said he's going to take me to my favorite arcade and maybe Aquatica.
animated message windows <3
or message window that uses background images that can be animated?
Still need to fix some things, but it's going great so far :)
CEPjLJn.gif
just when I thought one of the greatest game of all time couldn't get any better, they announce a new dlc for it.
For anyone interested: there's another huge humble bundle with JRPG assets + a game jam starting next month - it's for a good cause, so check it out <3

Forum statistics

Threads
113,786
Messages
1,077,452
Members
147,821
Latest member
Zabasin
Top