move event towards another event help?

Started by Susanm, August 10, 2011, 01:25:50 am

Previous topic - Next topic

Susanm

August 10, 2011, 04:22:49 am #20 Last Edit: August 10, 2011, 04:37:11 am by Susanm
yea exactly  how do u do that? how can i figure out Jake is 4 tiles away from shawn as a conditional branch key so Jake can say Hi to shawn

jailuis

Ok now this seems harder >< and don't know if it is posible without scripting (Something that im useless at :3) but I'll keep on trying. Altough it seems to be  really difficult as the final position to both is unknown, so there must be a way to relate the distance between them... I'll figure it out xD somehow :3

Susanm

Heres a script from foreverzero called event range conditions... only problem with this one is it only checks players distance to events... does not check distance from event to event and thats what im looking for


#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Event Range Conditions
# Author: ForeverZer0
# Date: 5.1.2011
# Version: 1.1
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   Allows you to set up conditional branches in events that will be based off
#   the event's coordinates in relation to the player's coordinates without
#   having to create any variables for the X and Y of each.
#
#   Here are the new features you can use a conditional branch. Just type these
#   into the script box for the branch.
#
#   range?(RANGE, EVENT_ID) - Will be true if player is anywhere in the radius
#                             defined by RANGE from the event with EVENT_ID
#
#   on_screen?(EVENT_ID)    - Will be true if the event with EVENT_ID is within
#                             the visible screen
#
#   x_dist?(DIST, EVENT_ID) - Returns true if the player's x/y is within DIST
#            OR               of event's x/y with EVENT_ID. These are absolute
#   y_dist?(DIST, EVENT_ID)   values, meaning it doesn't matter which direction,
#                             it just uses the total distance in tiles for that
#                             axis. Use a DIST of 0 to check if that axis is
#                             equal.
#
#   player_above?(EVENT_ID) - Returns true when player is above event.
#   player_below?(EVENT_ID) - Returns true when player is below event.
#   player_right?(EVENT_ID) - Returns true when player is right of the event.
#   player_left?(EVENT_ID)  - Returns true when player is left of the event.
#
#   For all of these, if the conditional branch that is using them is within
#   the event that it applies to, you do not have to include the EVENT_ID, it
#   is assumed to be that event's ID unless otherwise defined.
#
#   You can use these as a condition for just about anything, such as having
#   an event say something, run away, or run toward the player if it is within a
#   specific distance, and it's much easier than using multiple branches and
#   game variables to set it up.
#
#   Remember that if you use a range condition with a parallel trigger, it will
#   continue to execute as long as the condition is met and if the player cannot
#   move during the event's code, the game will effectively be stuck.
#
# Compatability:
#
#   - You may encounter issues if using a Pixel Movement script, though it
#     should still work fine with an 8-Way Movement script. (Not tested)
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:

class Interpreter
 
  def range?(range = 4, id = @event_id)
    e = $game_map.events[id]
    radius = (Math.hypot((e.x - $game_player.x), (e.y - $game_player.y))).abs
    return (radius <= range)
  end
 
  def on_screen?(id = @event_id)
    x, y = $game_map.events[id].real_x, $game_map.events[id].real_y
    return ((x - $game_map.display_x + 64) / 4).between?(0, 640) &&
      ((y - $game_map.display_y) / 4).between?(0, 480)
  end
 
  def x_dist?(distance = 0, id = @event_id)
    x_dif = ($game_map.events[id].x - $game_player.x).abs
    return (x_dif <= distance)
  end
 
  def y_dist?(distance = 0, id = @event_id)
    y_dif = ($game_map.events[id].y - $game_player.y).abs
    return (y_dif <= distance)
  end
 
  def player_above?(id = @event_id)
    return ($game_map.events[id].y > $game_player.y)
  end
 
  def player_below?(id = @event_id)
    return ($game_map.events[id].y < $game_player.y)
  end
 
  def player_right?(id = @event_id)
    return ($game_map.events[id].x < $game_player.x)
  end
 
  def player_left?(id = @event_id)
    return ($game_map.events[id].x > $game_player.x)
  end
end

jailuis

i know absolutly nothing about scripts BUT i can see that one is kind of simple... so it shouldn't be hard for someone to actually modify it. Im trying to, but i would recomend you to post what you need on the script request board, srry i cant be more helpful :/

Susanm

well thank you for trying anyhow will post in the board thank you =)  :-*