Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Script edit

I need the coordinate checking methods changed so they look for pixel coordinates instead of tile coordinates. Maybe it just needs a bunch of * 32s at the end of the lines, I'm not sure, but I cant figure it out.

Code:
#==============================================================================
#   Veiw Range Script
#------------------------------------------------------------------------------
#    By: Near Fantastica
#    Date: 25/11/04
#==============================================================================

class View_Range
#--------------------------------------------------------------------------
# ??? Range system works by sereching the area of a circle for the Player's xy
#    The Veiw is set in each event and is the radius of the circle
#    The Eaquation used is (Px-EX)^2 + (Py-Ey)^2 = radius^2
#    If the Radius is less than or equal to the View the Player is inside the circle
#--------------------------------------------------------------------------
attr_accessor :event_num
attr_accessor :view_range
#--------------------------------------------------------------------------
# ??? Initialization
#--------------------------------------------------------------------------
def initialize(event_num,veiw_range,els)
  @event_num = event_num
  @event_locial_switch = els
  @view_range = veiw_range
  @playerx = $game_player.x
  @playery = $game_player.y
  @eventx = $game_map.events[@event_num].x
  @eventy = $game_map.events[@event_num].y
  @event_direction = $game_map.events[@event_num].direction
end
#--------------------------------------------------------------------------
# ??? Event Veiw
#--------------------------------------------------------------------------
def event_view
  @playerx-=@eventx
  @playerx*=@playerx
  @playery-=@eventy
  @playery*=@playery
  @playerx+=@playery
  @view_range*=@view_range
  if @playerx <= @view_range
    $game_self_switches = {[$game_map.map_id, @event_num, @event_locial_switch] => true}
    $game_map.need_refresh = true
  end
end
#--------------------------------------------------------------------------
# ??? Enemies veiw
#--------------------------------------------------------------------------
def enemies_view    
  if @event_direction == 2
    if @playery >= @eventy
      @playerx-=@eventx
      @playerx*=@playerx
      @playery-=@eventy
      @playery*=@playery
      @playerx+=@playery
      @view_range*=@view_range
      if @playerx <= @view_range
        $game_self_switches = {[$game_map.map_id, @event_num, @event_locial_switch] => true}
        $game_system.timer = 420
        $game_system.timer_working = true
        $game_map.need_refresh = true
      end
    end
  end
  if @event_direction == 4
    if @playerx <= @eventx
      @playerx-=@eventx
      @playerx*=@playerx
      @playery-=@eventy
      @playery*=@playery
      @playerx+=@playery
      @view_range*=@view_range
      if @playerx <= @view_range
        $game_self_switches = {[$game_map.map_id, @event_num, @event_locial_switch] => true}
        $game_system.timer = 420
        $game_system.timer_working = true
        $game_map.need_refresh = true
      end
    end
  end
  if @event_direction == 6
    if @playerx >= @eventx
      @playerx-=@eventx
      @playerx*=@playerx
      @playery-=@eventy
      @playery*=@playery
      @playerx+=@playery
      @view_range*=@view_range
      if @playerx <= @view_range
        $game_self_switches = {[$game_map.map_id, @event_num, @event_locial_switch] => true}
        $game_system.timer = 420
        $game_system.timer_working = true
        $game_map.need_refresh = true
      end
    end
  end
  if @event_direction == 8
    if @playery <= @eventy
      @playerx-=@eventx
      @playerx*=@playerx
      @playery-=@eventy
      @playery*=@playery
      @playerx+=@playery
      @view_range*=@view_range
      if @playerx <= @view_range
        $game_self_switches = {[$game_map.map_id, @event_num, @event_locial_switch] => true}
        $game_system.timer = 420
        $game_system.timer_working = true
        $game_map.need_refresh = true
      end
    end
  end
end
#--------------------------------------------------------------------------
# ??? check = View_Range.new(EventID, Veiw Range, Local Switch)
#    check.enemies_straight_view
#--------------------------------------------------------------------------
def enemies_straight_view
 # checks the x direction
 if @playerx == @eventx
   $game_self_switches = {[$game_map.map_id, @event_num, @event_locial_switch] => true}
   $game_map.need_refresh = true
 end
 # checks the y direction
 if @playery == @eventy
   $game_self_switches = {[$game_map.map_id, @event_num, @event_locial_switch] => true}
   $game_map.need_refresh = true
 end
end
end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top