Der Urheber
Near Fantastice (gefunden hab ich es auf dubealex.com)
Die Hinweise zum Einfügen und Nutzen
- Das Script lässt ein Event die Distanz zum Player berechnen und ermöglicht entsprechende Interaktion je nach Distanz.... (genaueres unter den jeweiligen Call-Script-Befehlen...)
-Was die BGS-Einbindung angeh:
Zitat:
Zitat von Near
� #� � 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
|
-Um das Script einzufügen: Macht im Scripteditor ein neues Script auf, nennt es "View_Range" und fügt das Script ein. Aufrufen könnt ihr es mit dem Befehl Call Script.
Die Demo
Der Call-Script-Befehl
Wenn ein Event einen Sound (dessen Lautstärke von der Distanz zum Helden abhängt) von sich geben soll:
Zitat:
$view_range.event_sound(event_id, bgs_name)
|
Dieser Script-Call checkt die Area innerhalb eiens Kreises um das Event nach der Anwesenheit des Spielers und berechnet daraus die Lautstärke, die der BGS haben soll.
Wenn ein Event einen Switch aktivieren soll sobald der Held in Sichtweite kommt (optimal geeignet für Wachen und ähnlich kurzsichtige Gegner):
Zitat:
$view_range.enemies_view(event_id, view_range, els)
|
Dieser Scriptcall checkt die Area innerhalb eines Halbkreises in Sichtrichtung nach der Anwesenheit des Helden und schaltet einen local-switch nach Wahl auf "on" falls dem so sein sollte.
Die Syntax
- Event ID ist die Id des Events für das der Script-Call gilt
- View Range ist die Sichtweite des Events
- BGS Name ist der Name des BGS den das Event von sich geben soll "010-River01" (und der mit der Distanz leiser wird!)
- els ist welcher Local-switch angeschalten soll falls der Held in Reichweite kommt... Beispiele: "A", "B", "C", "D"
Das Script
Zitat:
#================================================= =============================
# � Veiw 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 = (@[email protected])*(@[email protected]) + (@[email protected])*(@[email protected])
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 = (@[email protected])*(@[email protected]) + (@[email protected])*(@[email protected])
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 = (@[email protected])*(@[email protected]) + (@[email protected])*(@[email protected])
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 = (@[email protected])*(@[email protected]) + (@[email protected])*(@[email protected])
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 = (@[email protected])*(@[email protected]) + (@[email protected])*(@[email protected])
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
|