Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if true # << Make true to use this script, false to disable.
- #===============================================================================
- #
- # ☆ $D13x - Character Lanterns
- # -- Author : Dekita
- # -- Version : 1.0
- # -- Level : Easy / Normal
- # -- Requires : N/A
- # -- Engine : RPG Maker VX Ace.
- #
- #===============================================================================
- # ☆ Import
- #-------------------------------------------------------------------------------
- $D13x={}if$D13x==nil
- $D13x[:Character_Lanterns]=true
- #===============================================================================
- # ☆ Updates
- #-------------------------------------------------------------------------------
- # D /M /Y
- # 11/o3/2014 - Small Efficieny Update,
- # o9/o3/2o14 - Started, Finished
- #
- #===============================================================================
- # ☆ Introduction
- #-------------------------------------------------------------------------------
- # This script allows for all characters to have a lantern graphic 'attached'
- # to their sprite. You can easily show/hide the lantern image using simple
- # script calls.
- #
- # Remember to copy the Graphics/$D13x/Lights folder/images into your project.
- #
- #===============================================================================
- # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
- #===============================================================================
- # 1. You MUST give credit to "Dekita" !!
- # 2. You are NOT allowed to repost this script.(or modified versions)
- # 3. You are NOT allowed to convert this script.
- # 4. You are NOT allowed to use this script for Commercial games.
- # 5. ENJOY!
- #
- # "FINE PRINT"
- # By using this script you hereby agree to the above terms and conditions,
- # if any violation of the above terms occurs "legal action" may be taken.
- # Not understanding the above terms and conditions does NOT mean that
- # they do not apply to you.
- # If you wish to discuss the terms and conditions in further detail you can
- # contact me at http://dekitarpg.wordpress.com/
- #
- #===============================================================================
- # ☆ Instructions
- #-------------------------------------------------------------------------------
- # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
- #
- #===============================================================================
- # ☆ Script Calls
- #-------------------------------------------------------------------------------
- # char.lantern_on?
- # returns true / false depending on whether char's lantern is on.
- #
- #-------------------------------------------------------------------------------
- # char.show_lantern
- # shows lantern image for char
- #
- #-------------------------------------------------------------------------------
- # char.hide_lantern
- # hides lantern image for char
- #
- #-------------------------------------------------------------------------------
- # char.alt_lantern
- # alternates show/hide lantern for char
- #
- #-------------------------------------------------------------------------------
- # IMPORTANT:
- # char = $game_map.events[x] OR $game_player OR this_Event
- #
- # eg.
- # $game_player.alt_lantern
- # will change the lantern visibility, if its on, it will go off and vice versa..
- #
- # NOTE: this_event can only be used if you have my core script (v2.3+)
- # this_event will gain the id of the event using the script call.
- #
- #===============================================================================
- # ☆ HELP
- #-------------------------------------------------------------------------------
- # N/A
- #===============================================================================
- module Easy_Lantern
- #===============================================================================
- #-----------------------------------------------------------------------------
- # The folder your lantern graphics are stored in
- #-----------------------------------------------------------------------------
- Folder = "Graphics/$D13x/Lights/"
- #-----------------------------------------------------------------------------
- # The graphic settings for your lantern.
- #-----------------------------------------------------------------------------
- Graphic = ["$lantern_left", 0] # ['image name', hue]
- #-----------------------------------------------------------------------------
- # The hand your char's hold the lantern in.
- #-----------------------------------------------------------------------------
- Facing = :left
- #####################
- # CUSTOMISATION END #
- end #####################
- #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
- # #
- # http://dekitarpg.wordpress.com/ #
- # #
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
- #===============================================================================#
- # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
- # YES?\.\. #
- # OMG, REALLY? \| #
- # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
- # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
- #===============================================================================#
- module Cache
- #===============================================================================
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.lantern(filename, hue = 0)
- load_bitmap(Easy_Lantern::Folder, filename, hue)
- end
- end
- #===============================================================================
- class Game_CharacterBase
- #===============================================================================
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- alias :init_ezaylantern :initialize
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def initialize
- @lantern = false
- @lant_in = 0
- init_ezaylantern
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def lantern_on?
- @lantern
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def show_lantern
- @lantern = true
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def hide_lantern
- @lantern = false
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def alt_lantern
- @lantern = !@lantern
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def lantern_index
- @lant_in
- end
- end
- #===============================================================================
- class Sprite_Character < Sprite_Base
- #===============================================================================
- #-----------------------------------------------------------------------------
- # Alias List
- #-----------------------------------------------------------------------------
- alias :init_spr_char_la :initialize
- alias :disp_spr_char_la :dispose
- alias :updt_spr_char_la :update
- alias :set_char_lantern :set_character_bitmap
- #-----------------------------------------------------------------------------
- # Object Initialization
- #-----------------------------------------------------------------------------
- def initialize(viewport, character = nil)
- @char_viewport = viewport
- @char_setup = character
- init_spr_char_la(viewport, character)
- init_lantern
- end
- #-----------------------------------------------------------------------------
- # Set Char Bitmap
- #-----------------------------------------------------------------------------
- def set_character_bitmap
- set_char_lantern
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def init_lantern
- disp_lantern
- vp = @char_viewport
- ch = @char_setup
- if ch && ch.lantern_on?
- @lantern_image = Sprite_Lantern.new(vp,ch)
- end
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def dispose
- disp_lantern
- disp_spr_char_la
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def disp_lantern
- return unless @lantern_image
- return if @lantern_image.disposed?
- @lantern_image.dispose
- @lantern_image = nil
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def update
- updt_lantern
- updt_spr_char_la
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def updt_lantern
- return init_lantern unless @lantern_image
- return disp_lantern unless @char_setup.lantern_on?
- @lantern_image.update unless @lantern_image.disposed?
- end
- end
- #===============================================================================
- class Sprite_Lantern < Sprite
- #===============================================================================
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def initialize(viewport,character = nil)
- super(viewport)
- @character = character
- @character_name = Easy_Lantern::Graphic[0]
- @character_hue = Easy_Lantern::Graphic[1]
- @character_index = @character.lantern_index
- self.bitmap = Cache.lantern(@character_name,@character_hue)
- sign = @character_name[/^[\!\$]./]
- if sign && 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
- update_src_rect
- update_position
- update_other
- update_z
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def dispose
- super
- if self.bitmap != nil
- self.bitmap.dispose
- end
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def update
- super
- update_src_rect
- update_position
- update_other
- update_z
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def update_src_rect
- 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)
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def update_position
- self.x = @character.screen_x
- self.y = @character.screen_y
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def update_other
- self.opacity = @character.opacity
- self.blend_type = @character.blend_type
- self.bush_depth = @character.bush_depth
- self.visible = !@character.transparent
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def update_z
- ch = @character
- case Easy_Lantern::Facing
- when :left then z = [ch.screen_z,ch.screen_z,ch.screen_z-1,ch.screen_z-1]
- when :right then z = [ch.screen_z,ch.screen_z-1,ch.screen_z,ch.screen_z-1]
- else ; return self.z = ch.screen_z
- end
- case ch.direction
- when 2 then self.z = z[0]
- when 4 then self.z = z[1]
- when 6 then self.z = z[2]
- when 8 then self.z = z[3]
- end
- end
- end
- #==============================================================================#
- # http://dekitarpg.wordpress.com/ #
- #==============================================================================#
- end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement