O TEMA DO FÓRUM ESTÁ EM MANUTENÇÃO. FEEDBACKS AQUI: ACESSAR

TDS Sprite Reflect

Iniciado por LoboShow, 02/02/2013 às 20:32

TDS Sprite Reflect

Compativel com: RMVX
Compatibilidade: ?
Facilidade de uso: ?
Lag gerado: ?

[box class=titlebg]
Para que serve o script
[/box]
Adiciona o reflexo na água de char e objetos;
É possível aumentar a distância do reflexo;
Escolha quais eventos terão reflexo.

[box class=titlebg]
Para que serve o script
[/box]
Copie o script e cole-o acima do main. O evento precisa ter o nome Reflect no início para que o efeito funcione.
Para adicionar uma distâncnia do char para o reflexo, use os seguintes comandos:
$game_player.reflect_offset = P
$game_player.refresh

onde P deve ser a quantidade de pixels em distância que aparecerá o reflexo e...
$game_player.reflect_offset = 0
$game_player.refresh

para dar o efeito padrão do reflexo, ou seja, próximo ao char.

[box class=titlebg]
Imagens
[/box]

[box class=titlebg]
Script
[/box]
#==============================================================================
# ** TDS Sprite Reflect
# Version: 2.4
# Special Thanks: DerVVulfman for his Tileset Read and Tile Drawer.
#------------------------------------------------------------------------------
# This script will give a reflection effect to map sprites when they step in
# front of water or special places with a certain terrain.
#==============================================================================
# WARNING:
#
# Do not release, distribute or change my work without my expressed written
# consent, doing so violates the terms of use of this work.
#
# * Not Knowing English or understanding these terms will not excuse you in any
#   way from the consequenses.
#
# Contact Email: Sephirothtds@hotmail.com
#==============================================================================
# Instructions:
#
# For terrain editing please reffer to DerVVulfman Tileset Reader and
# Tile Drawer.
#
# For events you can use these two commands in part of their name.
#
# Reflect
#
# Any event with "Reflect" as part of it's name will have the reflect effect on
# the special areas of the map.
#
#
# /OFFSET[#]
#
#  [#] = Numerical value of the offset.
#
#  Example:
#   /OFFSET[10]
#
# Offset changes the Y offset of the sprite in the water.(How far is the
# Reflection from the characters original standing point)
#
#
# $game_player.reflect_offset = #
#
#  # = Value of the character offset.
#
# Just the same as the event offset except this one handles the characters
# offset reflection.
#==============================================================================

  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------
  # Activate the wave effect on the water
  WATER_WAVE_EFFECT = true
  # Number of the reflect terrain tag
  REFLECT_TERRAIN_TAG = 1

 
#==============================================================================
# ** 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
    graphical_update   
  end
  #--------------------------------------------------------------------------
  # * Sprite Setup
  #--------------------------------------------------------------------------
  def sprite_setup 
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_index != @character.character_index
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_index = @character.character_index
      self.angle = 180
      self.mirror = true   
      self.opacity = 120             
      if @tile_id > 0
        sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
        sy = @tile_id % 256 / 8 % 16 * 32;
        self.bitmap = tileset_bitmap(@tile_id)
        self.src_rect.set(sx, sy, 32, 32)
        self.ox = 16
        self.oy = 32
      else
        self.bitmap = Cache.character(@character_name)
        sign = @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
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
  end 
  #--------------------------------------------------------------------------
  # * Get tile set image that includes the designated tile
  #     tile_id : Tile ID
  #--------------------------------------------------------------------------
  def tileset_bitmap(tile_id)
    set_number = tile_id / 256
    return Cache.system("TileB") if set_number == 0
    return Cache.system("TileC") if set_number == 1
    return Cache.system("TileD") if set_number == 2
    return Cache.system("TileE") if set_number == 3
    return nil
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super       
     # If visible update Graphics
     if self.visible
       graphical_update
     end
     
     self.x = @character.screen_x
     self.y = @character.screen_y
     if @tile_id == 0         
       self.z = @character.screen_z-90
      else
       self.z = @character.screen_z-25     
     end

    if WATER_WAVE_EFFECT == true   
      self.wave_amp = 1
      self.wave_length = 1
      self.wave_speed = 3
    end       
  end
  #--------------------------------------------------------------------------
  # * Graphical Update
  #--------------------------------------------------------------------------
  def graphical_update 
    if @tile_id == 0   
     index = @character.character_index
     pattern = @character.pattern < 3 ? @character.pattern : 1
     sx = (index % 4 * 3 + pattern) * @cw
     sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch           
     self.src_rect.set(sx, sy, @cw, @ch)     
     if @character.is_a?(Game_Player)
        self.ox = @cw / 2       
        self.oy = 8 + @ch + $game_player.reflect_offset       
      else       
        self.ox = @cw / 2               
        self.oy = 8 + @ch + @offset
       end     
     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
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias tds_sprite_reflection_initialize initialize
  def initialize
    create_reflection_sprites       
    tds_sprite_reflection_initialize       
  end 
  #--------------------------------------------------------------------------
  # * Create Reflection Sprites
  #--------------------------------------------------------------------------
  def create_reflection_sprites
    @event_reflection_sprite = []
    @reflecting_events = []       
    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.reflect_terrain_tag == REFLECT_TERRAIN_TAG
      if $game_player.moving? == false
        @reflection_sprite.visible = true         
      end
    else         
     @reflection_sprite.visible = false                 
    end

    for i in 0...@reflecting_events.size
     @event_reflection_sprite[i].update
      if @reflecting_events[i].visible_on_screen?(@reflecting_events[i].x, @reflecting_events[i].y) == false     
        next @event_reflection_sprite[i].visible = false 
      end       
      if @reflecting_events[i].visible_on_screen?(@reflecting_events[i].x, @reflecting_events[i].y) and
         @reflecting_events[i].reflect_terrain_tag == REFLECT_TERRAIN_TAG                   
         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   
  end   
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  alias tds_sprite_reflection_dispose dispose
  def dispose
      for i in 0...@reflecting_events.size
        @event_reflection_sprite[i].dispose
      end   
    @reflection_sprite.dispose
    tds_sprite_reflection_dispose           
  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
    @reflect_offset = 0
    tds_sprite_reflection_initialize       
  end
  #--------------------------------------------------------------------------
  # * Visible on Screen?
  #-------------------------------------------------------------------------- 
  def visible_on_screen?(x,y)
    visible_screen_x = $game_map.display_x / 256
    visible_screen_y = $game_map.display_y / 256
    if x >= visible_screen_x - 2 && visible_screen_x <= visible_screen_x  + 17 &&
       y >= visible_screen_y - 2 && visible_screen_y + 2 <= visible_screen_y  + 13                     
      return true
    end
    return false
  end 
  #--------------------------------------------------------------------------
  # * Return Reflect Terrain Tag
  #--------------------------------------------------------------------------
  def reflect_terrain_tag
    return $game_map.terrain_tag(@x, @y + 1)
  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
 
  #--------------------------------------------------------------------------
  # * Return Even Name
  #--------------------------------------------------------------------------
  def name
    return @event.name
  end
end


[box class=titlebg]
Créditos e Avisos
[/box]
Criador: TDS