Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###############################################################################
- # SES: MultiPar
- # v1.0
- # 4.14.2012
- # Compatibility: VXAce/RGSS3
- # Author: Enelvon
- #===============================================================================
- # Terms of Use:
- #
- # This script may be used for free in any game, whether it's commercial or not.
- # The only requirement is that I be credited in some visible manner. You may not
- # claim this script as your own work. You are free to modify this script, but
- # may not redistribute it except for in a thread that I have started that relates
- # to it in some way.
- #===============================================================================
- # Changelog:
- # 4.14.2012: v1.0 - Script written.
- #===============================================================================
- # This script adds the ability to have as many Parallaxes as you'd like. Any
- # Parallaxes past the first one are added through the Notes box of the map.
- #===============================================================================
- # Required Scripts: Enelvon Script Core v1.0 or higher
- # Known Incompatibilities: None, though it contains some redefinitions.
- #===============================================================================
- # Installation: Place below Materials and the Enelvon Script Core and above all
- # other custom scripts (just to be safe).
- #===============================================================================
- # Instructions:
- #
- # ***Constants for SES::MultiPar***
- #
- # Parallaxes - this is the RegExp for adding Parallaxes to a map.
- #
- # ***Additional: Map Tags***
- #
- # You can customize this script for each map in your game by adding tags in
- # their Notes boxes. These are the tags available in this script:
- #
- # <Par: !Parallax!, !Z!>
- # Place this in a Notes box to add a Parallax to the map. You can have as many
- # as you would like.
- # Replacements:
- # !Parallax! with the name of the Parallax. Make sure it's short enough that
- # you don't end up going over the line.
- # !Z! with the Z value of the Parallax. A higher Z value causes the Parallax
- # to display over everything with a lower Z value.
- #
- # ***Additional: Script Calls***
- #
- # Enter these in a Script command within an event to cause something to happen.
- #
- # change_parallax(!Name!, !Index!, !Z!)
- # Place this in a Script command to add or change a Parallax on the current map.
- # Replacements:
- # !Name! with the name of the Parallax in Graphics/Parallaxes
- # !Index! with the index of the Parallax you're changing (use a number higher
- # than the current amount of Parallaxes to add a new Parallax)
- # !Z! with the Z value of the changed Parallax
- #
- #===============================================================================
- # Aliases:
- #
- # These are the methods that are aliased by this script. This information is
- # included for the purpose of pinpointing compatibility errors between scripts.
- #
- # NONE
- #
- #===============================================================================
- # Redefinitions:
- #
- # These are the methods that are redefined by this script. This information is
- # included for the purpose of pinpointing compatibility errors between scripts.
- #
- # ***class Spriteset_Map***
- #
- # create_parallax
- #
- # dispose_parallax
- #
- # update_parallax
- #
- ################################################################################
- module SES
- module MultiPar
- # The RegExp that allows you to add a Parallax to a map. You can have more
- # than one.
- Parallax = /^<Par: (\w+),(\s?)(\d+)>/i
- end
- end
- $imported = {} if $imported.nil?
- $imported["SES - MultiPar"] = true
- class RPG::Map
- alias en_mp_m_sn en_scan_notes
- def en_scan_notes(tags = [])
- @parallaxes = []
- tags.push([SES::MultiPar::Parallax, "@parallaxes.push([$1.to_s, $2.to_i])"])
- en_mp_m_sn(tags)
- end
- def parallaxes
- en_scan_notes if @parallaxes.nil?
- return @parallaxes
- end
- end
- class Game_Map
- def parallaxes
- @map.parallaxes
- end
- end
- class Spriteset_Map
- def create_parallax
- i = Plane.new(@viewport1)
- i.z = -100
- @parallaxes = [i]
- for n in $game_map.parallaxes
- i = Plane.new(@viewport1)
- i.z = n[1]
- @parallaxes.push(i)
- end
- end
- def dispose_parallax
- for i in @parallaxes
- i.bitmap.dispose if i.bitmap
- i.dispose
- end
- end
- def change_parallax(name = "", index = 0, z = nil)
- @parallaxes[index] ? @parallaxes[index].bitmap.dispose : @parallaxes[index] = Plane.new(@viewport1)
- @parallaxes[index].bitmap = Cache.parallax(name)
- @parallaxes[index].z = z.nil? ? 0 : z
- end
- def update_parallax
- if @parmap_id.nil? || @parmap_id != $game_map.map_id
- @parmap_id = $game_map.map_id
- @parallaxes.each_index do |i|
- if i == 0
- @parallaxes[i].bitmap = Cache.parallax($game_map.parallax_name)
- else
- b = $game_map.parallaxes[i-1]
- @parallaxes[i].bitmap.dispose if !@parallaxes[i].bitmap.nil?
- @parallaxes[i].bitmap = Cache.parallax(b[0])
- end
- end
- Graphics.frame_reset
- end
- @parallaxes.each_index do |i|
- if @parallaxes[i]
- @parallaxes[i].ox = $game_map.parallax_ox(@parallaxes[i].bitmap)
- @parallaxes[i].oy = $game_map.parallax_oy(@parallaxes[i].bitmap)
- end
- end
- end
- end
- class Game_Interpreter
- def change_parallax(name = "", index = 0, z = nil)
- SceneManager.scene.change_parallax(name, index, z)
- end
- end
- class Scene_Map < Scene_Base
- def change_parallax(name = "", index = 0, z = nil)
- @spriteset.change_parallax(name, index, z)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment