RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Sprite Reflection

0 Members and 1 Guest are viewing this topic.

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
TDS Sprite Reflection
Version: 2.4
Author: TDS
Date:Mar 30 2008

Version History


  • <Version 1.0> 03.30.2008 Release
  • <Version 2.0> 05.02.2008 Fixed some bugs removed some lag
    • <Version 2.4> 05.12.2008 Started using  DerVVulfman Tileset Reader VX for terrain tags
    Description


    Reflects the characters sprite on the water or other reflective surfaces chosen in the tileset editor.

    Features

    It reflects a sprite and also allows to set offsets in the reflections distance from the sprite.

    Screenshots



    Instructions

    Using DerVVulfman's Tileset Reader VX create a tileset file adding terrain tags of 1 to the places where you would like the reflect effect to happen.

    If you would like the terrain of the reflect effect to be another one go to this line of the script

    Code: [Select]
    REFLECT_TERRAIN_TAG = 1

    And change the 1 to the ID of the reflective terrain tag.

    All characters must have Reflect as part of it's name in order to reflect.

    Another small add on is the "/OFFSET that I added into event names.

    Using "/OFFSET Will change how far is the reflection is displayed from it's original starting point.

    Example: NPC Name Reflect /OFFSET[15]

    That will display the NPCs reflection 15 pixels below it.


    Using this "$game_player.reflect_offset = #" you will be able to change the main characters offset.

    Example:

    Using a call script you will be able to change the value of this variable.

    $game_player.reflect_offset = 15

    That will display the characters reflection 15 pixels below the original standing point.

    If you wish to use the small wave effect on the water simple go this line on the script.

    Code: [Select]
    WATER_WAVE_EFFECT

    And switch it's value to true or false

    Example:

    Code: [Select]
    WATER_WAVE_EFFECT = true

    Script


    Requires:

    DerVVulfman Tileset Reader VX

    Code: [Select]
    #==============================================================================
    # ** 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

    Credit


    • TDS

    Support


    On this topic.

    Known Compatibility Issues

    None that I'm aware of although there is a small bug/problem with it, but not that many people notice it.

    Demo


    TDS Sprite Reflect 2.4 Demo

    Author's Notes


    I'm hoping to be able to remake this script to add a more believable display to reflections instead of popping up as you reach the water.

    Restrictions

    Pretty much free to use in any games as long as I'm credited for it.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
It looks like another very nice scrpt. Excellent work TDS! Best New Member of the Year for sure. That's not a huge compliment since it hasn't been a month yet, but I have faith that it will hold for the next 11 months.

And the additional wave effect is a beautiful feature. I never would've thought to include something like that.


EDIT::

Should I assume that:
# Do not release, distribute or change my work without my expressed written
# consent, doing so violates the terms of use of this work.

applies to all of your work? Because I know someone posted a couple of your scripts - an old version of Alchemy and Game Logo - a little while ago. I could remove them if you do not want them to have been posted by random guy.
« Last Edit: January 27, 2009, 03:30:41 AM by Modern Algebra »

**
Rep:
Level 84
So. I ran into this problem. Here's the screenshot:

Can you tell me what's wrong?

**
Rep: +0/-0Level 84
Current Project: RoSL
Looking at your screenshot and then glancing at the Tileset Reader script from DerVVulfman, I noticed that line 55 of his script is part of a massive "commented-out" section..

So, I don't know how you could be having a problem at line 55. That and I have no RGSS2 knowledge..

"How can I be expected to save the world, when I can't even save myself?" --Sysolos(Return of a Shadow Lord)

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
@SpriteKing:

Line 55 of the script is an alias "alias ts_load load_database".

My only guess as for what the problem could be is that you are using a custom title screen script or the original method "load_database" for some reason no longer exist and therefore you cannot alias it which is causing the error.

@Modern Algebra:

Thank very much you for your comment it's greatly appreciated, and I'm very sorry for the late reply.

# Do not release, distribute or change my work without my expressed written
# consent, doing so violates the terms of use of this work.

Yes that would apply to all of my scripts although most when they are posted by other people they usually remove it. I don't really mind that other people post it, but they always seem to find the oldest version they can instead of contacting me for a current version of the script.

And as for the scripts only the alchemy one was supposed to be public. The logo one was a test of VX new bitmap features and if used in any games will cause a couple of errors because it was not really intended to work as a public logo. If the scripts are deleted I would gladly post them again and offer support for them here.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
OK, I'll delete them then. Don't feel obligated to repost them if you do not want to though ~ it's up to you.

**
Rep: +0/-0Level 71
RMRK Junior
I keep getting the error

'Script 'Reflecting Water' line 298: NoMethodError occurred.
undefined method 'terrain_tag' for #<Game_Map:0x3515c00>

Any help, please?

*
Rep:
Level 82
Have you included DerVVulfman's Tileset Reader VX Script as well?

That method exists in that script, not TDS', so without it it will not work. It is mentioned in the OP that it requires another script which you need to download by clicking the link provided above the script TDS wrote.
(Why do I always feel like it's the end of the world and I'm the last man standing?)

**
Rep: +0/-0Level 76
RMRK Junior
I was wondering if anyone could make this compatible with Tricker's Caterpillar script?

http://www.rpgrevolution.com/forums/?showtopic=8040

I found other reflection script that is compatible with Trickster Caterpillar, but it was made for XP and I'm having trouble using it:
http://save-point.org/showthread.php?tid=2766

If that helps.
« Last Edit: April 20, 2011, 04:27:54 PM by kriemhilde00 »

**
Rep: +0/-0Level 72
RMRK Junior
I have a ?n, i want to make it so the sprites reflection does not show when i am using a boat or ship, it seems that when i call the boat or ship and then ride in it the characters image still shows on the water. How do i fix this? Is it that i simply have to use a different tile?

Here is a screenshot:


Thanks!
~~Dizzy Media Inc.~~

**
Rep:
Level 73
Teaser
Is there away to make it show on different tiles. It will not show on my custom tiles.
It can't be wrong if it feels right...