NPCs running into Objects

Hey, I have been looking for something simple that will make NPCs move away when they run into a tree or other object when they are set to "Move Away from Player"?
I have a cluster of events that just get caught on the trees when I am chasing them down, but I want them to keep on moving. Any help would be greatly appreciated. 
 

Hey, I have been looking for something simple that will make NPCs move away when they run into a tree or other object when they are set to "Move Away from Player"?
I have a cluster of events that just get caught on the trees when I am chasing them down, but I want them to keep on moving. Any help would be greatly appreciated. 
I don't know if there's a better way of doing that, but in my game I did it this way:

Instead of using the "Move away from player" command, I created a script call that generates a random position away from the player, then using a path finding script to move the event there.

Give me a minute and I'll write this script for you. Do you already use any kind of path finding script in your game?
No, I looked into the pathfinding scripts, but didn't seem to be what I was looking for. Will this script navigate through trees, and will it repeat itself until either turned off or the player leaves the map? I.e. when it reaches the destination, will it move to a new one?
I made something different for you. Try adding this script in your project and see what happens:

Code:
class Game_Character < Game_CharacterBase  alias :hudell_move_away_from_character :move_away_from_character  def move_away_from_character(character)    hudell_move_away_from_character(character)        if !@move_succeed      case character.direction        when 2, 8          move_straight(4)          move_straight(6) if !@move_succeed        when 4, 6          move_straight(2)          move_straight(8) if !@move_succeed        end                move_straight(character.direction) if !@move_succeed    end  end  end
This is amazing! Thank you! It is precisely what I needed. Now the elves scatter and santa has to harness them all back up! 😛 thanks again, man! (or woman)

Original thread: https://forums.rpgmakerweb.com/threads/npcs-running-into-objects.35548/