Event (Move Route) when Player is near it

● ARCHIVED · READ-ONLY
Started by mylazyafternoon 3 posts View original ↗
  1. So I want to create an event when the player gets near a ghost it's transparency changes. For example, the player is exploring an empty map and he walks towards Event1, the closer the player gets to it, the less transparent it becomes. Walking towards the event will make it less transparent. While walking away from the event will make it more transparent, eventually becoming invisible.

    Or an easier way to ask, I've seen games when the player would get near an event, and it would automatically change it's 'move route'. For example, walking towards a bird will alert it to fly away from the player. Trigger commands 'Touching' or 'Action' does not make the bird fly away from the player. The bird moves away only when the player is near it.

    I hope this made sense.
  2. You need a parallel process event to calculate player distance. You can store it in a variable if you want. The code to calculate distance from player is:
    Code:
    ($game_player.x - $game_map.events[id].x).abs + ($game_player.x - $game_map.events[id].y).abs
    I don't remember if .abs works in RGSS3. If it does not then you have to do it the long way. In any case "id" is always your event id.
    if .abs does not work you have to do it the long way.
    long way around
    dx = $game_player.x - $game_map.events[id].x
    dx *= -1 if dx < 0
    dy = $game_player.y - $game_map.events[id].y
    dy *= -1 if dy < 0
    $game_variables[var_id] = dx + dy
    In this case "id" is your event id and "var_id" is your variable id. Once you stored player distance in a variable you can use it to change event opacity. It is up to you when you want to change it. I'll just put an example here.
    Code:
    op_change = 25
    op_dist = ((11 - $game_variables[var_id]) < 0 ? 0 : (11 - $game_variables[var_id]))
    $game_map.events[id].opacity = ((op_change * op_dist > 255) ? 255 : (op_change * op_dist))
    This increases event opacity by 25 every times the player steps closer to it and decreases it by 25 every time the player walks away from it making it invisible when distance is 11 or greater.
  3. Or just use Mog's event sensor for VX Ace.