TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,204
Reaction score
7,469
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
84
Reaction score
44
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
19
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,204
Reaction score
7,469
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,399
Reaction score
2,500
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,204
Reaction score
7,469
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
74
Reaction score
85
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,204
Reaction score
7,469
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

TMS
It's too bad you can't rename parameters by default. Was thinking it would be neat to do something like change Magic Attack to just "Magic" and Magic Defense to "Spirit."
Ugh why don't I have pixel talent???
Having fun in Orlando! We had a lot of fun at the arcade, even though I didn't win any jackpots this time, and then we went to Outback and got a Blooming Onion. Tomorrow we're driving to Fort Myers to see my stepmom.
Now that I have the XP RTP back, I was looking through the files and found Fighter 7, the inspiration for my first sona! She's evolved since then, but it gave me such nostalgia!
Character sprites are difficult to create so I decided to get/buy some. Got the Pixel Champions from Alexdraws. But It had no walking animation :/ But redid the free ones from the Mighty Pack <3 Turned out pretty good imo.Calistra.PNG
Tempted to come up with a unique spell naming system....But ''Fire Magic'' and ''Fire,Fira,Firaga'' are so easily recognizable :p

Forum statistics

Threads
112,288
Messages
1,067,108
Members
145,911
Latest member
Slaizen
Top