Visible NPC vs MOBS on region/world maps

  HEY!! im glad you click on this topic, cause for real, that was the best way i could describe the idea that im trying to pull off.

  Okay, so this is what im trying to make:

  In my game i want to give the impression that my party isnt the only group in the world that is actually trying to go around fighting and killing monsters.

  I'm trying to make a script that will have my NPC characters:

  roam around the world map/ region map in a random fashion (OR) 

  roam around a certain area of the map

  when the NPC 'see's or 'detects' an enemy MOB, he will move towards it

  when the NPC touches the MOB, it is killed

(i will try to add more interesting stuff to that later, like damage, or status effects to the NPC, but for now, i can't even get this simple idea to work for me)

  SO!  

 I've tried a few things already, but DAMN im such a NOOB... i know that there is code for the 'approach' function for bad guys, but it only 'approaches' the main character.  I was thinking of using a script to label the different MOBS on the map as 'prey' and the NPCs as 'hunter's.  Then use the 'approach' script, but have the hunters chase the prey.  then on touch, have the MOB erased.

  From there i can work out the rest (hahahaha.... no i can't, i'll come back and ask for more help, who am i kidding)

  any help would be greatly appreciated, thank you so much guys!!!
One way you could approach this (which would require some scripting, or variables):

Set all the mobs on the map initially.

Set some mobs to be removed after one day passes.

Set some more to be removed after two days pass.

Etc.

If you did this you would need to decide when a day passes, and increase a variable by 1. Probably could be done every time you rested.

This is not quite the same thing as what you want, but from a design standpoint, it is probably the easiest to implement.
There's an "approach character" function in the code that you can reference:

#-------------------------------------------------------------------------- # * Move Toward Character #-------------------------------------------------------------------------- def move_toward_character(character) sx = distance_x_from(character.x) sy = distance_y_from(character.y) if sx.abs > sy.abs move_straight(sx > 0 ? 4 : 6) move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0 elsif sy != 0 move_straight(sy > 0 ? 8 : 2) move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0 end endWhat this means is that (I think) you can add something like move_toward_character($game_map.events[32]) in the Script... function inside a custom Move Route, to have a character move toward Event 32 (which might be a wandering monster).

From there, though, to really get the effect you're looking for, you'll have to figure out a way for NPCs that are moving "randomly" to notice which monsters are near them so you can direct them to move toward that monster.  You can do so with a Parallel Process that consistently looks at each event's x and y coordinate and finds the total difference.  But to actually script this would be fairly complicated.
From there, though, to really get the effect you're looking for, you'll have to figure out a way for NPCs that are moving "randomly" to notice which monsters are near them so you can direct them to move toward that monster.  You can do so with a Parallel Process that consistently looks at each event's x and y coordinate and finds the total difference.  But to actually script this would be fairly complicated.
No, this is fairly easy, just add a distance variable and trigger the move only if the target is close enough. If not, execute random move as usual. I did that in RMXP to code new behaviours for the monsters on the map. The difference here is that you do not compare to the player, but another character. But essentially, it's easier to do it by scirpt, as it avoids parallel process events.

Original thread: https://forums.rpgmakerweb.com/threads/visible-npc-vs-mobs-on-region-world-maps.41594/