NPCs running into Objects

Sausage_Boi

Game Dev. "Artist."
Veteran
Joined
Sep 10, 2014
Messages
1,733
Reaction score
681
First Language
Americanese
Primarily Uses
RMVXA
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. 
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
 

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?
 

Sausage_Boi

Game Dev. "Artist."
Veteran
Joined
Sep 10, 2014
Messages
1,733
Reaction score
681
First Language
Americanese
Primarily Uses
RMVXA
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?
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
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
 

Sausage_Boi

Game Dev. "Artist."
Veteran
Joined
Sep 10, 2014
Messages
1,733
Reaction score
681
First Language
Americanese
Primarily Uses
RMVXA
This is amazing! Thank you! It is precisely what I needed. Now the elves scatter and santa has to harness them all back up! :p thanks again, man! (or woman)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,019
Members
137,564
Latest member
McFinnaPants
Top