Move after player?

leoroura

Veteran
Veteran
Joined
Feb 14, 2017
Messages
32
Reaction score
4
First Language
English
Primarily Uses
RMMV
Hello! I'm new to these forums ^^
The truth is i've been struggling with this for a good time now... I started a roguelike proyect on my RMMV and i made it to generate random maps with monsters and items. What i want now, is to make the monsters move every time my character does.
I don't want them to chase me if i'm still, i want them to chase me every step i take, making some kind of turn-based map movement. (More like Pokemon Mistery Dungeon or Pixel Dungeon system) My problem is that i don't find any "If player is moving" or "Move after player" conditional, so i don't know what to do :(
So far i tried playing with Yanfly's input and stop movement plugins but i couldn't manage to find a way to do what i want x.x
So if any of you guys knows a way, even if its with a build mechanic or a plugin, i don't care, please let me know, i'd be reaaally grateful!

Here's a video of Pixel Dungeon's movement system so you can catch what i'm talking about:
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
I feel like a dummy suggesting this, but did you know about "approach"?

Screen Shot 2017-02-13 at 11.20.55 PM.png

One might possibly hybrid some conditions with it, to make it smoother, but I can't write any better than default.
 

leoroura

Veteran
Veteran
Joined
Feb 14, 2017
Messages
32
Reaction score
4
First Language
English
Primarily Uses
RMMV
Yeah that's what i'm using right now, but if i stand still they keep approaching me, i want them to move only when i do, like a turn based movement system. If i could find a way to trigger the approach behavior only when i'm moving, then my problem would be solved, but no idea Dx
Thanks for the answer tho!
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
PHP:
if($gamePlayer.moveByInputOld === undefined){
 $gamePlayer.moveByInputOld = $gamePlayer.moveByInput;
 $gamePlayer.moveByInput = function(){
  var move = $gamePlayer.isMoving() ? 2 : 0;
  for(var i = 0; i < $gameMap._events.length; i++){
    if($gameMap._events[i] === undefined)
      continue;
    if($gameMap._events[i]._moveType !== move)
      $gameMap._events[i]._moveType = move;
 }
 return $gamePlayer.moveByInputOld.apply(this, arguments);
 } } // < last line so an extra end for you
Try calling something like this by event script. The is move = 2 is the approach for when moving. The 0 is a stop for when stopped, but it can also be 1 for random or something.

(this script is the max height of lines for event script. If you're going to add stuff, you'll have to minify it. I learned that by making an eval error when my end of input got clipped.
 
Last edited:

leoroura

Veteran
Veteran
Joined
Feb 14, 2017
Messages
32
Reaction score
4
First Language
English
Primarily Uses
RMMV
Oh my god! That's actually really cool! I have almost 0 skill at scripting, i couldn't have done something like that xD
My only problem is that now even the chests move lmao I see that you wrote "events" and that must affect all of them.
Im currently calling the script with a paralel event, what if i tried calling it directly from each monster but replace the "events" word with "this event"? Is there even a tag for that? xD
Thank you very much!

EDIT: So far i tried this but it says "a" is not defined. ("a" is how i named the monster events) I'm so sorry i butchered your code but as i said i have no knowledge :,)


if($gamePlayer.moveByInputOld === undefined){

$gamePlayer.moveByInputOld = $gamePlayer.moveByInput;

$gamePlayer.moveByInput = function(){

var move = $gamePlayer.isMoving() ? 2 : 0;

for(var i = 0; i < $gameMap._eventId(a).length; i++){

if($gameMap._eventId(a) === undefined)

continue;

if($gameMap._eventId(a)._moveType !== move)

$gameMap._eventId(a)._moveType = move;

}

return $gamePlayer.moveByInputOld.apply(this, arguments);

} } // <
 
Last edited:

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
Ok. If you refer to the _characterName which is the image file of the event without the ".png", you can make this event script effect only those certain characters.
PHP:
if($gamePlayer.moveByInputOld === undefined){
 $gamePlayer.moveByInputOld = $gamePlayer.moveByInput;
 $gamePlayer.moveByInput = function(){
  var move = $gamePlayer.isMoving() ? 2 : 0;
  for(var i = 0; i < $gameMap._events.length; i++){
    if($gameMap._events[i] === undefined || $gameMap._events[i]._characterName.match(/Nature|Monster/) === null) // only Monster.png and Nature.png
      continue;
    if($gameMap._events[i]._moveType !== move)
      $gameMap._events[i]._moveType = move;
 }
 return $gamePlayer.moveByInputOld.apply(this, arguments);
 } }
That will match all events with Nature.png or Monster.png and you can add |Other|Other2|Etc if you need more or less.

If your chest is on the same charset as the monsters, then I may need to figure out how to refer to event names instead of character names.
 

leoroura

Veteran
Veteran
Joined
Feb 14, 2017
Messages
32
Reaction score
4
First Language
English
Primarily Uses
RMMV
You're a genious. Now i can add all the monster sprites i want and add them to the script :D
Thank you very much <3 I will add you to my project credits if i ever finish it :,)
This thread can be closed now i guess, this is exactly what i needed c:
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just for the lols I have taken the Szondi test. That test looked like a load of bull. But for whatever reason it was incredibly accurate.
How can a society function with an entire media establishment that is complicit in publishing partisan slander and easily disprovable lies right alongside each other with no accountability whatsoever? After I live through it, maybe I'll make a game based on it. The level of dishonesty at this point just astounds me though.
If you download a resource, be it art or plugin, please thank the creator for their time. We are all guilty sometimes of just grabbing something without commenting. Now is the time to go through your credit list and visit the threads/site where you got the resource from and leave a heartfelt thank you!
October is officially here. I'm hoping to get a call from Spirit Halloween soon. It didn't happen today, but I've got to keep my head high.
So, what is this "Inktober" everyone's speaking about? Because apparently, I have no idea what happens on this site...

Forum statistics

Threads
103,490
Messages
999,745
Members
135,038
Latest member
CStrife912
Top