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
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg216.imageshack.us%2Fimg216%2F5311%2Ftdsspritereflectionskilqc2.png&hash=e90f8a582d3ba19dabdeff1334229106d2bdc7fe)
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
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.
WATER_WAVE_EFFECT
And switch it's value to true or false
Example:
WATER_WAVE_EFFECT = true
Script
Requires:
DerVVulfman Tileset Reader VX (http://www.creationasylum.net/index.php?showtopic=22184)
#==============================================================================
# ** 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
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 (http://www.mediafire.com/?yenmzgmjmid)
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.
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.
So. I ran into this problem. Here's the screenshot:
Can you tell me what's wrong?
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..
@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.
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.
I keep getting the error
'Script 'Reflecting Water' line 298: NoMethodError occurred.
undefined method 'terrain_tag' for #<Game_Map:0x3515c00>
Any help, please?
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.
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.
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:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi749.photobucket.com%2Falbums%2Fxx139%2Fjdizzyflpro2%2F7-12-201110-10-10PM.png&hash=6b15b942fde0ec390e0b43d0c0a94f834f320cc6)
Thanks!
Is there away to make it show on different tiles. It will not show on my custom tiles.