TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,259
Reaction score
7,664
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,259
Reaction score
7,664
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,713
Reaction score
2,830
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,259
Reaction score
7,664
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
82
Reaction score
94
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,259
Reaction score
7,664
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

having anxiety during all this virus stuff is the absolute worst. I'm the only one missing out on my friend's wedding in Sept. because I can't be in large groups of people anymore due to anxiety.
Well... I just spent most of the day making something I cant even use xD

Hero_1.png
The idea was to look at the original but at a medium distance.
In hindsight, I might as well have just edited the original lol... I didn't intend for it to end up so similar.
does anyone else feel tired after completing a sprite?
Fun fact: I always lower every tileset saturation (about 15%-25% of it) in my projects.

Forum statistics

Threads
113,903
Messages
1,078,315
Members
148,001
Latest member
onurgungor
Top