TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,244
Reaction score
7,627
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,244
Reaction score
7,627
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,699
Reaction score
2,800
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,244
Reaction score
7,627
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
92
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,244
Reaction score
7,627
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

User of Mv3d/ Mz3d and Rosse engine. New Resource Pack on development "Halloween Stones" . Leave ideas about what you want to see on this package. :)
SetPreview.jpg
Looking at Code abd knowing that it made sense at one time. Ugh..why did I ever stop? Well I guess it will come back to me.
Well, Blizzard... thanks for making it easy to decide what to delete to free up some hard drive space... I guess. Ugh.
So far, I've rated 5 of the games out of the 120 submitted. Competition is fierce! There are a few which I played and thought "Well, at least my submission is better than this one." but there's at least one which is far better than mine (at least by my judgement.) Trying very hard to rate games fairly and only comment when I have something constructive to say. Good luck everyone!

Forum statistics

Threads
113,544
Messages
1,075,734
Members
147,542
Latest member
elsher
Top