Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- #
- # ▼ Rycochet - Zoom Sprites v1.0
- # -- Last Updated: 2013.09.15
- # -- License: CC BY-NC 3.0 - https://creativecommons.org/licenses/by-nc/3.0/
- #
- #==============================================================================
- # ▼ Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2013.09.15 - First Version.
- #
- #==============================================================================
- # ▼ Introduction
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Allows you to change the zoom level on sprites depending on what they are on
- # a per-map basis. This can be used to do things like making the character
- # smaller on the main map, or creating a Lilliput village where the character
- # is twice the size of the villagers.
- #
- #==============================================================================
- # ▼ Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
- #
- # All zoom values are percentages, so 100 is "no change".
- #
- # You can have multiple tags within single notetag, order is unimportant.
- #
- # -----------------------------------------------------------------------------
- # Map Notetags - These notetags go in the map notebox in a map's properties.
- # -----------------------------------------------------------------------------
- # <zoom all=x ...>
- # Set the zoom level for all sprites.
- #
- # <zoom player=x ...>
- # Set the zoom level for the player *and* followers.
- #
- # <zoom follower=x ...>
- # Set the zoom level for followers only.
- #
- # <zoom vehicle=x ...>
- # Set the zoom level for any vehicles.
- #
- # <zoom npc=x ...>
- # Set the zoom level for npcs, these are classed as any event that can move.
- #
- # <zoom event=x ...>
- # Set the zoom level for any event that has a fixed position.
- #
- # -----------------------------------------------------------------------------
- # Event Comments - These comments must be in the active page and are global.
- # -----------------------------------------------------------------------------
- # "ZOOM x"
- # Set the zoom for this specific event (overrides map notetags).
- #
- #==============================================================================
- #==============================================================================
- # ▼ Editting anything past this point may potentially result in causing
- # computer damage, incontinence, explosion of user's head, coma, death, and/or
- # halitosis so edit at your own risk.
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["Rycochet-ZoomSprites"] = true
- #==============================================================================
- # ■ RYCO::REGEXP
- #==============================================================================
- module RYCO
- module REGEXP
- ZOOM_ALL = /<zoom\s[^>]*all=(\d+)/i
- ZOOM_PLAYER = /<zoom\s[^>]*player=(\d+)/i
- ZOOM_FOLLOWER = /<zoom\s[^>]*follower=(\d+)/i
- ZOOM_VEHICLE = /<zoom\s[^>]*vehicle=(\d+)/i
- ZOOM_EVENT = /<zoom\s[^>]*event=(\d+)/i
- ZOOM_NPC = /<zoom\s[^>]*npc=(\d+)/i
- COMMENT_ZOOM = /ZOOM\s+(\d+)/i
- end # REGEXP
- end # RYCO
- #==============================================================================
- # ■ Game_Map
- #==============================================================================
- class Game_Map
- attr_accessor :zoom_event
- attr_accessor :zoom_npc
- attr_accessor :zoom_player
- attr_accessor :zoom_follower
- attr_accessor :zoom_vehicle
- #--------------------------------------------------------------------------
- # * Alias method: setup
- #--------------------------------------------------------------------------
- alias game_map_setup_old setup
- def setup(map_id)
- game_map_setup_old(map_id)
- @zoom_event = @zoom_npc = @zoom_player = @zoom_follower = @zoom_vehicle = ($1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_ALL) || 1.0
- @zoom_player = @zoom_follower = $1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_PLAYER
- @zoom_follower = $1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_FOLLOWER
- @zoom_vehicle = $1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_VEHICLE
- @zoom_event = $1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_EVENT
- @zoom_npc = $1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_NPC
- end # setup
- end # Game_Map
- #==============================================================================
- # ■ Game_Event < Game_Character
- #==============================================================================
- class Game_Event < Game_Character
- attr_accessor :zoom_value
- #--------------------------------------------------------------------------
- # * Alias method: clear_starting_flag
- #--------------------------------------------------------------------------
- alias clear_starting_flag_old clear_starting_flag
- def clear_starting_flag
- clear_starting_flag_old
- @zoom_value = nil
- return if empty?
- for item in @list
- if item.code == 108 or item.code == 408
- if item.parameters[0] =~ RYCO::REGEXP::COMMENT_ZOOM
- @zoom_value = $1.to_f / 100.0
- return
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * New method: is_moving?
- #--------------------------------------------------------------------------
- def is_moving?
- return @move_type != 0
- end
- end
- #==============================================================================
- # ■ Sprite_Character < Sprite_Base
- #==============================================================================
- class Sprite_Character < Sprite_Base
- #--------------------------------------------------------------------------
- # * Alias method: update
- #--------------------------------------------------------------------------
- alias sprite_character_update_old update
- def update
- sprite_character_update_old
- zoom = 1.0
- if @character.is_a?(Game_Player)
- zoom = $game_map.zoom_player
- elsif @character.is_a?(Game_Follower)
- zoom = $game_map.zoom_follower
- elsif @character.is_a?(Game_Event)
- if @character.zoom_value.nil?
- zoom = @character.is_moving? ? $game_map.zoom_npc : $game_map.zoom_event
- elsif
- zoom = @character.zoom_value
- end
- elsif @character.is_a?(Game_Vehicle)
- zoom = $game_map.zoom_vehicle
- else
- return
- end
- # Backup the old zoom values in case other scripts change them
- @ryco_zoom_x = @ryco_zoom_x || self.zoom_x
- @ryco_zoom_y = @ryco_zoom_y || self.zoom_y
- self.zoom_x = @ryco_zoom_x * zoom
- self.zoom_y = @ryco_zoom_y * zoom
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment