[XP] Event Range Conditions

Started by ForeverZer0, May 02, 2011, 12:37:27 am

Previous topic - Next topic

Vexus

Yes and sorry for flooding your thread with something about this script.

I don't really get what you mean and I don't use much variables usually it's from tutorials or something as I kinda get confused on them.
Current Project/s:

Vexus

Sorry foreverzer0 for bugging you again for this script.

The only way to make the conditions is by parallel process for the events to spot you when your near? because I tried making custom movement and adding the line of script but after a second of playtesting I get an error undefined method range? for game_event:0x9288f50.

Having parallel process for every npc would probably lag the game.
Current Project/s:

Poe

February 01, 2012, 03:53:35 pm #22 Last Edit: February 01, 2012, 03:56:21 pm by Poe
Quote from: Vexus on February 01, 2012, 04:20:51 am
Sorry foreverzer0 for bugging you again for this script.

The only way to make the conditions is by parallel process for the events to spot you when your near? because I tried making custom movement and adding the line of script but after a second of playtesting I get an error undefined method range? for game_event:0x9288f50.

Having parallel process for every npc would probably lag the game.

script lines in custom move route don't use interpreter methods.

put it in game_map for instance to call it with $game_map.range?(range,id) like this:
class Game_Map
 
 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
end

just add this below the script, however it won't automatically put in the event's id anymore so you'll always have to add it.

ForeverZer0

class Game_Character
 
  def range?(range = 4, id = @id)
    e = $game_map.events[id]
    radius = (Math.hypot((e.x - $game_player.x), (e.y - $game_player.y))).abs
    return (radius <= range)
  end
end


Add that, and you can should be able to use the method normally in move routes.  * I think *
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Vexus

Thanks will try it out hopefully it works.
Current Project/s:

Zexion

Dang, I was hoping that this was made by someone else :s Well anyone can answer it though.
In the features section of the post, it says
"Conditions based on whether they are above, below, left, or right in relation to player or other event"
But I don't see anything in the script about checking an event's range to x event.

By simply using this script is this possible?

LiTTleDRAgo

Spoiler: ShowHide
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
  #--------------------------------------------------------------------------
  # * New method: character_above?
  #--------------------------------------------------------------------------
  def character_above?(character)
    return (character.y > @y)
  end
  #--------------------------------------------------------------------------
  # * New method: character_below?
  #--------------------------------------------------------------------------
  def character_below?(character)
    return (character.y < @y)
  end
  #--------------------------------------------------------------------------
  # * New method: character_right?
  #--------------------------------------------------------------------------
  def character_right?(character)
    return (character.x < @x)
  end
  #--------------------------------------------------------------------------
  # * New method: character_left?
  #--------------------------------------------------------------------------
  def character_left?(character)
    return (character.x > @x)
  end
end


event1 = get_character(1) # event with ID 1
event2 = get_character(2) # event with ID 2
$game_switches[1] = event1.character_above?(event2)