Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # TSBS Addon - Realistic Shadow++
- # Version : 1.x (edited)
- # Language : English
- # Requires : Theolized Sideview Battle System
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Contact :
- #------------------------------------------------------------------------------
- # *> http://www.rpgmakerid.com
- # *> http://www.rpgmakervxace.net
- # *> http://theolized.blogspot.com
- #==============================================================================
- ($imported ||= {})[:TSBS_RealShadow] = true
- #==============================================================================
- # Change Logs:
- # -----------------------------------------------------------------------------
- # 2013.08.21 - Finished script
- # 2021.03.21 - flip fix & start fix
- # 2021.05.12 - And offset translation and rotation command
- #==============================================================================
- =begin
- ===================
- || Introduction ||
- -------------------
- This TSBS addon will make the shadow more realistic. It projects the sprite
- and draw it as a shadow. Best used in sideview style (not isometric looks
- battle system) and custom spriteset. Because it won't show icon shadow if you
- plan to use show weapon icon
- =================
- || How to use ||
- -----------------
- This script is plug and play. Just put this below the TSBS implementation
- ===================
- || Terms of use ||
- -------------------
- Credit me, TheoAllen. You are free to edit this script by your own. As long
- as you don't claim it yours. For commercial purpose, don't forget to give me
- a free copy of the game.
- =end
- #==============================================================================
- # Configurations
- #==============================================================================
- module TSBS
- module RShadow
- Opacity = 128 # Shadow opacity. The lesser, the more transparent it will be
- Scale = 0.5 # Shadow scale from the original source
- end
- end
- #==============================================================================
- # End of configuration. Do not edit anything pass this line!
- #==============================================================================
- if $imported[:TSBS] >= '1.4.0'
- #==============================================================================
- # ** Sprite_BattlerShadow
- #------------------------------------------------------------------------------
- # This sprite is used to display battler's shadow.
- #==============================================================================
- class Sprite_BattlerShadow < Sprite
- # --------------------------------------------------------------------------
- # * Initialize
- # --------------------------------------------------------------------------
- def initialize(sprite_battler, viewport = nil)
- @sprite_battler = sprite_battler
- super(viewport)
- update_reference
- self.mirror = enemy_start?
- self.angle = 180
- self.color.set(Color.new(0,0,0))
- if @sprite_battler.battler.class == Game_Enemy
- @sprite_battler.battler.init_shadow_start
- end
- update
- end
- def enemy_start?
- return @sprite_battler.battler.nil?
- end
- def update_shadow
- end
- # --------------------------------------------------------------------------
- # * Update Reference
- # --------------------------------------------------------------------------
- def update_reference
- self.bitmap = @sprite_battler.bitmap
- src_rect.set(@sprite_battler.src_rect)
- end
- # --------------------------------------------------------------------------
- # * Update Size
- # --------------------------------------------------------------------------
- def update_size
- self.zoom_y = TSBS::RShadow::Scale * ($imported[:TSBS_Camera] ?
- $tsbs_camera.zoom : 1.0)
- self.zoom_x = ($imported[:TSBS_Camera] ? $tsbs_camera.zoom : 1.0)
- self.ox = width/2
- self.oy = height
- end
- def update_position
- if @sprite_battler.battler
- self.x = @sprite_battler.battler.shadow_x
- self.y = @sprite_battler.battler.shadow_y + shift_y
- self.angle = 180 + @sprite_battler.battler.srotate
- end
- self.z = @sprite_battler.z #FlipEdit
- end
- # --------------------------------------------------------------------------
- # * Update opacity
- # --------------------------------------------------------------------------
- def update_opacity
- self.opacity = TSBS::RShadow::Opacity * (@sprite_battler.opacity/255.0)
- end
- # --------------------------------------------------------------------------
- # * Update
- # --------------------------------------------------------------------------
- def update
- super
- update_size
- update_position
- update_opacity
- update_visible
- update_reference
- end
- # --------------------------------------------------------------------------
- # * Update
- # --------------------------------------------------------------------------
- def shift_y
- return -data_battler.shadow_y * ($imported[:TSBS_Camera] ?
- $tsbs_camera.zoom : 1.0)
- end
- end
- class Game_Enemy
- def init_shadow_start
- @shadow_point.x = x
- @shadow_point.y = y
- end
- end
- end
- class Game_Battler
- attr_reader :srotate
- alias clear_tsbs_shadow clear_tsbs
- def clear_tsbs
- @sox = 0
- @soy = 0
- @srotate = 0
- clear_tsbs_shadow
- end
- alias sxpos shadow_x
- def shadow_x
- return sxpos + @sox
- end
- alias sypos shadow_y
- def shadow_y
- return sypos + @soy
- end
- alias shadowoffset_custom custom_sequence_handler
- def custom_sequence_handler
- if @acts[0] == :shadow_transform
- @sox = @acts[1] || @sox
- @soy = @acts[2] || @soy
- @srotate = @acts[3] || @srotate
- else
- shadowoffset_custom
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement