Best way to position event a certain distance from player

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
I am trying to make a little script in Ace that will position an event a certain number of tiles away from the player, in a random direction, such that it could be given a "move toward player" move route that would eventually put it on the player's tile (or right next to).


So it's not really a pathfinding script - if there's an obstacle or passage issue that would force the event to move away from the player to get around it, that would be an invalid starting point. 


The two approaches I can come up with are to start with all tiles that are X distance away, and simulate a 'move toward player' repeated route and see which ones don't get blocked, or to start at the player's position and spread out in all directions until I end up X tiles away.  I think both options have drawbacks.  Looking for some suggestions on how to best handle this.
 

JosephSeraph

White Mage
Restaff
Joined
Mar 7, 2014
Messages
1,186
Reaction score
1,444
First Language
Portuguese
Oh, so it spawns events and the player attracts them much like a magnet?


I would consider checking it from the nearest tile to the player to the furthrest tile. Once the checker finds an obstacle, it returns to the last tile checked and spawns the event.





this would ensue a clean path between the spawned event and the player -- with the drawback that it could spawn the event far too close to the player, which could or could not be a bad thing.


If it is a bad thing, then a simple possible fix would be to not allow the script to spawn an event if it's too close!


Hope it helps.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
It's close to what you describe.  Just one event that already exists on the map but is not visible until the player uses an item.  At that time, the event will jump to a location X tiles away from the player, become visible, and start moving toward the player using the Move Toward Player event command.  It doesn't have to be directly above or to the side of the player - could be a zig-zag path that it follows - as long as the Move Toward Player can get it there (which means it's only allowed to move in two directions).


Edit: I think I know what I need to do ... it's amazing how much simpler things become when you use a diagram to explain the possibilities.


Thanks for your input :)
 
Last edited by a moderator:

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

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,837
Latest member
Dabi
Top