Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
vVTalonVv

[XP]How do I use "View Range Script". By Near Fantastica?

Question

A link to the code here: viewtopic.php?f=12&t=30648&hilit=Near+Fantastica

 

 

I just simply do not understand what to do. I put the script into my database and named it View_Range. From there... I don't really understand what to do.

 

I've tried a few things, but they just resulted in error during a game test.

 

Help would be most appreciated.

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0
A link to the code here: viewtopic.php?f=12&t=30648&hilit=Near+Fantastica

 

 

I just simply do not understand what to do. I put the script into my database and named it View_Range. From there... I don't really understand what to do.

 

I've tried a few things, but they just resulted in error during a game test.

 

Help would be most appreciated.

Can you please give me the full link so i can look over the script and help you?

Share this post


Link to post
Share on other sites
  • 0

Yeah, Unlimited doesn't use viewtopic, so I'm assuiming it is .org...

 

 

Yeah, here it is Polraudio: http://www.rmxp.org/forums/viewtopic.php?f...Near+Fantastica

 

EDIT: Here is the script.

#==============================================================================
#   View Range Script
#------------------------------------------------------------------------------
#	By: Near Fantastica
#	Date: 07/04/05
#==============================================================================

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
#--------------------------------------------------------------------------
def initialize
  @playing_bgs = []
  @bgs = BGS.new
  @bgs.pitch = 100
  @event_id = 0
  @event_locial_switch = ""
  @view_range = 0
  @playerx = 0
  @playery = 0
  @eventx = 0
  @eventy = 0
  @event_direction = 0
end
#--------------------------------------------------------------------------
#	 Max Sound Effect Range is 8 units DO NOT OVER LAP
#	 or it will go into super lag mode you have been warned
#	 This is because you are trying to play 2 different sound
#	 effects and will cycles between them
#
#	 Note : This overrides the maps default sound effect
#--------------------------------------------------------------------------
def event_sound(event_id, bgs_name)
  @bgs.name = bgs_name
  @event_id = event_id
  @playerx = $game_player.x
  @playery = $game_player.y
  @eventx = $game_map.events[@event_id].x
  @eventy = $game_map.events[@event_id].y
  @event_direction = $game_map.events[@event_id].direction
  radius = (@playerx-@eventx)*(@playerx-@eventx) + (@playery-@eventy)*(@playery-@eventy)
  if radius > 64
 if @playing_bgs[event_id] != nil
   @playing_bgs[event_id] = nil
   $game_system.bgs_fade(1)
   return
 end
  elsif radius <= 64 and radius > 49
 if @playing_bgs[event_id] == nil
   @bgs.volume = 30
   @playing_bgs[event_id] = @bgs
   $game_system.bgs_play(@bgs)
   return
 end
 @bgs.volume = 30
 if @bgs.volume != @playing_bgs[event_id].volume or
	 @bgs.name != @playing_bgs[event_id].name
   @playing_bgs[event_id] = @bgs
   $game_system.bgs_play(@bgs)
   return
 end
  elsif radius <= 49 and radius > 36
 @bgs.volume = 40
 @playing_bgs[event_id] = @bgs
 $game_system.bgs_play(@bgs)
 return
  elsif radius <= 36 and radius > 25
 @bgs.volume = 50
 @playing_bgs[event_id] = @bgs
 $game_system.bgs_play(@bgs)
 return
  elsif radius <= 25 and radius > 16
 @bgs.volume = 60
 @playing_bgs[event_id] = @bgs
 $game_system.bgs_play(@bgs)
 return
  elsif radius <= 16 and radius > 9
 @bgs.volume = 70
 @playing_bgs[event_id] = @bgs
 $game_system.bgs_play(@bgs)
 return
  elsif radius <= 9 and radius > 4
 @bgs.volume = 80
 @playing_bgs[event_id] = @bgs
 $game_system.bgs_play(@bgs)
 return
  elsif radius <= 4 and radius > 1
 @bgs.volume = 90
 @playing_bgs[event_id] = @bgs
 $game_system.bgs_play(@bgs)
 return
  elsif radius = 1
 @bgs.volume = 100
 @playing_bgs[event_id] = @bgs
 $game_system.bgs_play(@bgs)
 return
  end
end
#--------------------------------------------------------------------------
def enemies_view(event_id, view_range, els)
  @event_id = event_id
  @view_range = view_range
  @event_locial_switch = els
  @playerx = $game_player.x
  @playery = $game_player.y
  @eventx = $game_map.events[@event_id].x
  @eventy = $game_map.events[@event_id].y
  @event_direction = $game_map.events[@event_id].direction
  if @event_direction == 2
 if @playery >= @eventy
   radius = (@playerx-@eventx)*(@playerx-@eventx) + (@playery-@eventy)*(@playery-@eventy)
   if radius <= @view_range
	 key=[$game_map.map_id, @event_id, @event_locial_switch]
	 $game_self_switches[key] = true
	 $game_map.need_refresh = true
   end
 end
  end
  if @event_direction == 4
 if @playerx <= @eventx
   radius = (@playerx-@eventx)*(@playerx-@eventx) + (@playery-@eventy)*(@playery-@eventy)
   if radius <= @view_range
	 key=[$game_map.map_id, @event_id, @event_locial_switch]
	 $game_self_switches[key] = true
	 $game_map.need_refresh = true
   end
 end
  end
  if @event_direction == 6
 if @playerx >= @eventx
   radius = (@playerx-@eventx)*(@playerx-@eventx) + (@playery-@eventy)*(@playery-@eventy)
   if radius <= @view_range
	 key=[$game_map.map_id, @event_id, @event_locial_switch]
	 $game_self_switches[key] = true
	 $game_map.need_refresh = true
   end
 end
  end
  if @event_direction == 8
 if @playery <= @eventy
   radius = (@playerx-@eventx)*(@playerx-@eventx) + (@playery-@eventy)*(@playery-@eventy)
   if radius <= @view_range
	 key=[$game_map.map_id, @event_id, @event_locial_switch]
	 $game_self_switches[key] = true
	 $game_map.need_refresh = true
   end
 end
  end
end
end
#======================================================
class Scene_Title
#--------------------------------------------------------------------------
alias vr_scene_title_update update
#--------------------------------------------------------------------------
def update
 $view_range = View_Range.new
 vr_scene_title_update
end
end
#======================================================
class Game_System
  attr_accessor :playing_bgs
end
#======================================================
class BGS
#--------------------------------------------------------------------------
attr_accessor :name
attr_accessor :volume
attr_accessor :pitch
#--------------------------------------------------------------------------
def initialize
  @name
  @volume
  @pitch
end
end
#======================================================
class Game_Map
#--------------------------------------------------------------------------
attr_accessor :map
end

Share this post


Link to post
Share on other sites
  • 0

Here is the instructions on how to use it.

Instructions:

 

- To call the events add this script call for other events

CODE

 

check = View_Range.new(Event ID, View Range, Local Switch)
check.event_view

 

 

This script call lets you check within the area of a circle around the event for the player or another event.

 

- To call the enemies add this script call for enemies

CODE

 

check = View_Range.new(Event ID, View Range, Local Switch)
check.enemies_view

 

 

- To call the straight veiw add this script call for enemies

CODE

 

check = View_Range.new(EventID, Veiw Range, Local Switch)
check.enemies_straight_view

 

 

This script call lets you check within the area of a semi circle in front of the event for the player if true the player is in the events view range.

 

The Syntax:

 

- Event ID is the events id which the script call is placed from

- View Range is how far the event can see

- Local Switch is which local switch you want to set on

 

The only problem i have is they didn't give a good example on how to use it.

I dont know how to get the local switch to work.

I tried all of this and i had no luck it just errors out

check = View_Range.new(1, 2, "A")
check.enemies_straight_view

check = View_Range.new(1, 2, 'A')
check.enemies_straight_view

check = View_Range.new(1, 2, A)
check.enemies_straight_view

It should work the first way but it didn't.

No clue what went wrong.

Share this post


Link to post
Share on other sites
  • 0

Why don't you contact the author to find out? Leon will probably save the day later...

Share this post


Link to post
Share on other sites
  • 0
Why don't you contact the author to find out? Leon will probably save the day later...

 

Really sorry that I didn't post the correct link, I just copied and pasted. I apologize.

 

I've sent a message to the writer, but with no response.

Share this post


Link to post
Share on other sites
  • 0

Hmm. Leon will see this and all will be good. I'll send him an IM when he gets on, for ya'.

 

(Leon is the script wiz here)

Share this post


Link to post
Share on other sites
  • 0

Doesn't anyone look at where topics are posted anymore? I'll admit the RGSS Support forum could be a lot easier to find, but regular members? You know where it is...

 

I'll move your topic vVTalonVv, the section you originally posted this topic in is for script submissions only.

 

 

I found something that might help you. Its the view range script, v3Gamma by DerVVulfman.

View_Range_3.doc

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...