Opis:
Skrypt pozwala nam utworzyć obszary które będą odbijały bohatera, czy zdarzenie. Jedynym mankamentem może być to, że obszary nie sprawdzają się przy skomplikowanych kształtach zbiorników wodnych...
Info:
Autor: Sephirothtds
Tłumaczenie: Angius Skrypt:
Spoiler:
Kod:
#==============================================================================
# ** TDS Sprite Reflect
# Version: 1.7
#------------------------------------------------------------------------------
# Ten skrypt odbija grafikę zdarzeń/bohaterów w określonych obszarach
#==============================================================================
# Instrukcje:
#
# Stwórz obszary mapy i nazwij je "Reflect".
#
# Dla eventów możemy użyć poniższych tagów w ich nazwie.
#
# Reflect
#
# Każdy event z "Reflect" w nazwie będzie się odbijał w ustawionych obszarach
#
# /OFFSET[#]
#
# [#] = Wartość przesunięcia.
#
# Przykład:
# /OFFSET[10]
#
# Offset zmienia położenie Y odbicia w pikselach. (Jak daleko
# odbicie będzie od źródła - grafiki odbijającej się)
#
# $game_player.reflect_offset = #
#
# # = Przesunięcie odbicia gracza.
#
# Tak samo jak /OFFSET[#], ale dla bohaterów.
#==============================================================================
#=======================================================================
# POTĘŻNA KONFIGURACJA!
#=======================================================================
# Nie zgubcie się w tym gąszczu opcji!
#--------------------------------------------------------------------------
# * Efekt falowania wody?
#--------------------------------------------------------------------------
WATER_WAVE_EFFECT = true
#=======================================================================
# KONIEC POTĘŻNEJ KONFIGURACJI!
#=======================================================================
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# This sprite is used to display characters. It observes a instance of the
# Game_Character class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Reflect < Sprite_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :character
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
# character : character (Game_Character)
# offset : offset value from the characters starting point.
#--------------------------------------------------------------------------
def initialize(viewport = nil, character = nil, offset = nil)
super(viewport)
self.visible = false
@character = character
@player_offset = $game_player.reflect_offset
@offset = (@character.is_a?(Game_Player) ? @player_offset : offset)
sprite_setup
update
end
#--------------------------------------------------------------------------
# * Sprite Setup
#--------------------------------------------------------------------------
def sprite_setup
self.bitmap = Cache.character(@character.character_name)
self.angle = 180
self.mirror = true
self.opacity = 120
sign = @character.character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
@cw = bitmap.width / 3
@ch = bitmap.height / 4
else
@cw = bitmap.width / 12
@ch = bitmap.height / 8
end
end
if WATER_WAVE_EFFECT == true
self.wave_amp = 1
self.wave_length = 1
self.wave_speed = 3
end
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Create Character Sprite
#--------------------------------------------------------------------------
alias tds_sprite_reflection_create_characters create_characters
def create_characters
tds_sprite_reflection_create_characters
@character_sprites = []
@event_reflection_sprite = []
@reflecting_events = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
for vehicle in $game_map.vehicles
sprite = Sprite_Character.new(@viewport1, vehicle)
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
for i in $game_map.events.keys.sort
@event_name_offset = $game_map.events[i].name
@event_name_offset[ /\/OFFSET\[(.*?)\]/ ]
sprite = Sprite_Reflect.new(@viewport1, $game_map.events[i], $1 != nil ? $1.to_i : 0)
if $game_map.events[i].name.include?("Reflect")
@event_reflection_sprite.push(sprite)
@reflecting_events.push($game_map.events[i])
end
end
@reflection_sprite = Sprite_Reflect.new(@viewport1, $game_player, 0)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias tds_sprite_reflection_update update
def update
tds_sprite_reflection_update
if $game_player.current_area_name == "Reflect"
if $game_player.moving? == false
@reflection_sprite.visible = true
end
else
@reflection_sprite.visible = false
end
for i in 0...@reflecting_events.size
if @reflecting_events[i].current_area_name == "Reflect"
if @reflecting_events[i].moving? == false
@event_reflection_sprite[i].visible = true
end
else
@event_reflection_sprite[i].visible = false
end
end
if @reflection_sprite.visible == true
@reflection_sprite.update
end
for i in 0...@event_reflection_sprite.size
if @event_reflection_sprite[i].visible == true
@event_reflection_sprite[i].update
end
end
end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass of the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :reflect_offset # Character Reflection Offset
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias tds_sprite_reflection_initialize initialize
def initialize
tds_sprite_reflection_initialize
@reflect_offset = 0
end
#--------------------------------------------------------------------------
# * Determine if in Area
# area : Area data (RPG::Area)
#--------------------------------------------------------------------------
def in_area?(area)
return false if area == nil
return false if $game_map.map_id != area.map_id
return false if @x < area.rect.x
return false if @y < area.rect.y
return false if @x >= area.rect.x + area.rect.width
return false if @y >= area.rect.y + area.rect.height
return true
end
#--------------------------------------------------------------------------
# * Current Area Name
#--------------------------------------------------------------------------
def current_area_name
# Checks the areas in the maps
for area in $data_areas.values
# If the character is currently on an area
if in_area?(area) == true
# Give the value of the name of the area to the return variable
return_area_name = area.name
# Break loop
break
end
end
return return_area_name
end
end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# * Clear Starting Flag
#--------------------------------------------------------------------------
def name
return @event.name
end
end
Screen:
Użycie:
Opisane w nagłówku skryptu. Znajduje się tam też potężna konfiguracja.
________________________
"Na trolla pewne są tylko dwie pewne metody, jedna samopowtarzalna i druga, wymagająca przeładowania ręcznego."
Siemka . Mam pytanko co do skryptu . Dodałem go nad main , narysowałem na mapie zbiornik wodny i klikając prawym na nazwę mapy stworzyłem obszar nazwany Reflcet . Włączyłem grę , podchodzę do jeziorka a tu nic , żadnego odbicia . Wie ktoś dlaczego tak się dzieje ?
to jakim cudem zrobiłeś screena ? skrypt jest mi trochę potrzebny bo zamierzam zrobić coś na styl gry gothic tyle że w 2D , i chciałem jak najbardziej urealnić świat gry ( w tym zmienić grafikę [ całkowicie ! { buhahahahahahahahahahaha }]) .
Pomogła: 232 razy Dołączyła: 18 Wrz 2007 Posty: 2424
Wysłany: Sro 31 Sie, 2011 09:46
Skrypt nie działa, gdyż wymaga użycia dodatkowego skryptu jakim jest 'Tileset Expansion VX'.
Spoiler:
Kod:
#==============================================================================
# ** Tileset Expansion VX
#------------------------------------------------------------------------------
# This script re-introduces terrain tags to your projects.
#
# Just use: $game_map.terrain_tag(x, y)
# ...to obtain the terrain tag of a tile using x & y coordinates.
#
# You can also bring up a 'pop-up' debug window by pressing a predefined
# key (that can be changed) in the single configurable line below.
#
#==============================================================================
# YOUR ONE CONFIGURABLE
# Identify/set the button used in test mode
TILESET_DEBUG_KEY = Input::F8
#==============================================================================
# ** RPG::Tileset
#------------------------------------------------------------------------------
# Data class for imported tileset information.
#==============================================================================
class RPG::Tileset
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :passages # 4-Directional Passage Flags
attr_accessor :terrain_tags # Terrain Tags
#--------------------------------------------------------------------------
# * Object initialization
#--------------------------------------------------------------------------
def initialize
@passages = Table.new(8192)
@terrain_tags = Table.new(8192)
end
end
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs the title screen processing.
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * Load Database
#--------------------------------------------------------------------------
alias ts_load load_database
def load_database
# Perform the original call
ts_load
# Add the tileset data
$data_tileset = load_data("Data/Tilesets.rvdata")
end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias setup_KGC_TilesetExtension setup
#--------------------------------------------------------------------------
# * Obtain Terrain Tag
# x : X Coordinate
# y : Y Coordinate
#--------------------------------------------------------------------------
def terrain_tag(x, y)
for i in [2, 1, 0]
tile_id = @map.data[x, y, i]
return 0 if tile_id == nil
t_tag = $data_tileset.terrain_tags[terrain_tag_index(tile_id)]
return t_tag if t_tag > 0
end
return 0
end
#--------------------------------------------------------------------------
# * Obtain Terrain Tag Index
# tile_id : Tile ID
#--------------------------------------------------------------------------
def terrain_tag_index(tile_id)
# Branch on Tile
case tile_id
# Multi-tiled id sets in 'A'
when 2048..8191 ; return ((tile_id - 2000) / 48) - 1
# Individual tile ids in 'A'
when 1536..1663 ; return(tile_id - 1408)
# 0 to 255 is tileset 'B'
# 256 to 511 is tileset 'C'
# 512 to 767 is tileset 'D'
# 768 to 1023 is tileset 'E' (optional)
end
return 0
end
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles maps. It includes event starting determinants and map
# scrolling functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias ts_update update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Perform the original call
ts_update
# If in debug mode and Info Button pressed
if $TEST && TILESET_DEBUG_KEY != nil
if Input.trigger?(TILESET_DEBUG_KEY)
# Show information on tile
tile_debug_popup
end
end
end
#--------------------------------------------------------------------------
# * Show Information on Tile
#--------------------------------------------------------------------------
def tile_debug_popup
t_tag = $game_map.terrain_tag(x, y + 1)
print " Terrain Tag: #{t_tag}"
end
end
Ponadto w folderze Data należy umieścić plik Tilesets.rvdata. Co zaś tyczy się konfiguracji... By zdarzenie miało odbicie w jego nazwie musi pojawić się słowo 'Reflect'. Dodatkowo, by odbicie przesunąć względem osi OY wystarczy w nazwie zdarzenia wpisać '/OFFSET[Y]', gdzie Y to podana wartość, np. '/OFFSET[40]'
Wiesz talent .
Ha wykombinowałem jak pogodzić odbicia lustrzane ze skryptem wyświetlania się nazw zdarzeń . To bardzo proste . Po prostu trzeba zmienić tą linijkę :
Cytat:
if $game_map.events[i].name.include?("Revlect")
na tą linijkę :
Cytat:
if $game_map.events[i].name.include?("[FS]")
Taki trik dla osób które chcą to połączyć :) Niestety raczej nie ma takiego rozwiazania dla oddalenia odbicia :(
Nie, żebym się czepiał ale mi skrypt działał od początku bez żadnych poprawek.
Ogółem jest super i git, ale przy skomplikowanych kształtach są problemy z wielką ilością obszarów. Ja na ten przykład miałem na jednej mapie z miastem (tak 40x40) 17 obszarów, w czym niekture po jednej/dwóch kratkach.
________________________ Obecny projekt - Chwilowo brak
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum