Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # DSI Card Altar
- # -- Last Updated: 2017.02.25
- # -- Author: dsiver144
- # -- Level: Normal
- # -- Requires: n/a
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["DSI-CARDALTAR"] = true
- #==============================================================================
- # + Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2017.02.25 - Finish first version.
- #==============================================================================
- # + Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below �� Materials/�f�� but above �� Main. Remember to save.
- # Remember to put this script below: DSI-Bitmap.
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Script Call: open_altar(altar_id) # Open an Altar with specific altar id (See below)
- # Item notetags:
- # <sealed_item> : define an sealed item
- # <sealed_card: x> : where x is the id of skill in Database
- # <sealed_altar: x> : where x is the id of altar in script configuration (See below)
- #==============================================================================
- module DSIVER144
- module ALTAR_UNSEALING
- ALTARS = {}
- #ALTARS[alter_id] = {}
- #ALTARS[alter_id][:name] = "Name of Altar"
- #ALTARS[alter_id][:background] = "Background File Name In Picture Folder"
- ALTARS[1] = {}
- ALTARS[1][:name] = "Altar of Unsealing Earth Mage Cards"
- ALTARS[1][:background] = "Background_Here" # In Picture Folder
- ALTARS[2] = {}
- ALTARS[2][:name] = "Altar of Unsealing Ice Mage Cards"
- ALTARS[2][:background] = "Background_Here" # In Picture Folder
- ALTARS[3] = {}
- ALTARS[3][:name] = "Altar of Unsealing Common And Uncommon Cards"
- ALTARS[3][:background] = "Background_Here" # In Picture Folder
- UNSEAL_COMPLETION_TEXT = "%s has been unsealed! It has been add to your card collection!"
- UNSEAL_COMPLETION_TEXT2 = "There are %2d of %s have been unsealed! They have been add to your card collection!"
- SCENE_BGM = ["Scene5", 100, 100]
- UNSEAL_SE = ["Saint7", 100, 100]
- UNSEAL_COMPLETE_SE = ["PA Announcement (FF7)", 100, 100]
- SEAL_ITEM_TEXT = "\\i[3424]\\c[5]Sealed Item\\c[0]\\i[3424]"
- SEAL_ITEM_TEXT_MARGIN = 40
- UNSEAL_BUTTONS_TEXT = "\\i[1609]:Unseal"
- OTHER_BUTTONS_TEXT = "\\i[1600]:Choose - \\i[1602]:Cancel"
- OTHER_BUTTONS_MARGIN = 170
- #-------------------------------------------------------------------------
- # * Don't touch these please
- #-------------------------------------------------------------------------
- REGEX_1 = /<sealed_item>/i
- REGEX_2 = /<sealed_altar:\s*(\w+)>/i
- REGEX_3 = /<sealed_card:\s*(\w+)>/i
- end # ALTAR_UNSEALING
- end # DSIVER144
- include DSIVER144::ALTAR_UNSEALING
- #==============================================================================
- # DataManager
- #==============================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # alias method: load_database
- #--------------------------------------------------------------------------
- class <<self; alias load_database_seal_item load_database; end
- def self.load_database
- load_database_seal_item
- load_notetags_seal_item
- end
- #--------------------------------------------------------------------------
- # Load Notetag Rental Weapons
- #--------------------------------------------------------------------------
- def self.load_notetags_seal_item
- for item in $data_items
- next if item.nil?
- item.load_notetags_seal_item
- end
- end
- end # DataManager
- #==============================================================================
- # �� RPG::Weapon
- #==============================================================================
- class RPG::Item
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :sealed_item
- attr_accessor :sealed_card
- attr_accessor :sealed_altar
- #--------------------------------------------------------------------------
- # common cache: load_notetags_sani
- #--------------------------------------------------------------------------
- def load_notetags_seal_item
- @sealed_item = false
- @sealed_card = 0
- @sealed_altar = 0
- self.note.split(/[\r\n]+/).each do |line|
- if line =~ REGEX_1
- @sealed_item = true
- end
- if line =~ REGEX_2
- @sealed_altar = $1.to_i
- end
- if line =~ REGEX_3
- @sealed_card = $1.to_i
- end
- end
- end
- end # RPG::Item
- class Scene_CardAltar < Scene_Base
- #-------------------------------------------------------------------------
- # * method: start
- #-------------------------------------------------------------------------
- def prepare(altar_id=1)
- @altar_id = altar_id
- end
- #-------------------------------------------------------------------------
- # * method: start
- #-------------------------------------------------------------------------
- def start
- super
- @altar_id ||= 1
- create_background_image
- play_card_library_bgm
- create_main_windows
- end
- #-------------------------------------------------------------------------
- # * new method: play_card_library_bgm
- #-------------------------------------------------------------------------
- def play_card_library_bgm
- $game_system.save_bgm
- RPG::BGM.new(*SCENE_BGM).play
- end
- #-------------------------------------------------------------------------
- # * new method: stop_card_bgm
- #-------------------------------------------------------------------------
- def stop_card_library_bgm
- RPG::BGM.stop
- $game_system.replay_bgm
- end
- #-------------------------------------------------------------------------
- # * new method: create_background_image
- #-------------------------------------------------------------------------
- def create_background_image
- @background_image = Sprite.new
- if ALTARS[@altar_id][:background] != false
- begin
- @background_image.bitmap = Cache.picture(ALTARS[@altar_id][:background].to_s)
- rescue
- @background_image.bitmap = SceneManager.background_bitmap
- @background_image.color.set(16, 16, 16, 128)
- end
- else
- @background_image.bitmap = SceneManager.background_bitmap
- @background_image.color.set(16, 16, 16, 128)
- end
- end
- #-------------------------------------------------------------------------
- # * method: create_main_windows
- #-------------------------------------------------------------------------
- def create_main_windows
- @altar_title = Window_Base.new(0,0,Graphics.width,48)
- ww = @altar_title.contents_width; hh = @altar_title.contents_height
- @altar_title.draw_text(0,0,ww,hh,ALTARS[@altar_id][:name],1)
- @altar_help_window = Window_AltarHelp.new
- hh = 100
- yy = Graphics.height-hh-@altar_help_window.height
- @item_window = Window_SealItem.new(0,yy,Graphics.width,hh)
- @item_window.category = @altar_id
- @item_window.select(0)
- @item_window.set_handler(:ok, method(:current_item))
- @item_window.activate
- @selected_window = Window_SelectedSeal.new(0,0,220,48*2 - 12)
- @selected_window.x = 0.5*(Graphics.width - @selected_window.width)
- hh = @item_window.height + @altar_help_window.height + @selected_window.height - @altar_title.height
- @selected_window.y = 0.5*(Graphics.height - hh)
- @selected_window.draw_seal_item(nil)
- @stack_item = []
- @sprite_card = Sprite.new
- @sprite_card.opacity = 0
- @sprite_card.z = 200
- @sprite_text = Sprite.new
- @sprite_text.bitmap = Bitmap.new(400,Graphics.height)
- @sprite_text.bitmap.turn_on_wordwraping
- @sprite_text.z = 200
- @confirm_window = Window_UnsealComfirm.new(0,0)
- @confirm_window.x = 0.5*(Graphics.width - @confirm_window.width)
- @confirm_window.y = 0.5*(Graphics.height - @confirm_window.height)
- @confirm_window.openness = 0
- @confirm_window.deactivate
- @confirm_window.set_handler(:ok, method(:command_confirm_ok))
- @confirm_window.set_handler(:cancel, method(:command_confirm_cancel))
- @confirm_text = Window_Base.new(0,0,@confirm_window.width,48)
- cw = @confirm_text.contents_width
- @confirm_text.draw_text(0,0,cw,24,"Are you sure?")
- @confirm_text.x = @confirm_window.x
- @confirm_text.y = @confirm_window.y - @confirm_text.height
- @confirm_text.openness = 0
- end
- #-------------------------------------------------------------------------
- # * method: seal_state
- #-------------------------------------------------------------------------
- def seal_state
- if @stack_item && @stack_item.size > 0
- @altar_help_window.refresh(true)
- return true
- else
- @altar_help_window.refresh(false)
- return false
- end
- end
- #-------------------------------------------------------------------------
- # * method: command_confirm_cancel
- #-------------------------------------------------------------------------
- def command_confirm_cancel
- @confirm_state = true
- @confirm_window.close
- @confirm_window.deactivate
- @confirm_text.close
- @item_window.activate
- end
- #-------------------------------------------------------------------------
- # * method: command_confirm_ok
- #-------------------------------------------------------------------------
- def command_confirm_ok
- @confirm_state = true
- card_skill_id = @stack_item[0].sealed_card
- card_skill = $data_skills[card_skill_id]
- @card_recieve = [card_skill.id,@stack_item.size]
- @stack_item.clear
- hide_seal_item_window
- show_card(card_skill)
- @cancel_card = true
- end
- #-------------------------------------------------------------------------
- # * method: return_stack_item
- #-------------------------------------------------------------------------
- def return_stack_item
- return unless @stack_item
- @stack_item.each do |item|
- $game_party.gain_item(item,1)
- end
- end
- #-------------------------------------------------------------------------
- # * method: refresh_windows
- #-------------------------------------------------------------------------
- def refresh_windows
- @selected_window.draw_seal_item(nil)
- @item_window.refresh
- seal_state
- end
- #-------------------------------------------------------------------------
- # * method: current_item
- #-------------------------------------------------------------------------
- def current_item
- if @stack_item.include?(@item_window.item)
- Sound.play_ok
- @stack_item.push(@item_window.item)
- $game_party.lose_item(@item_window.item,1)
- @item_window.refresh
- else
- return_stack_item
- if @item_window.item.nil?
- Sound.play_buzzer if @stack_item.size == 0
- end
- @stack_item.clear
- if @item_window.item
- @stack_item.push(@item_window.item)
- $game_party.lose_item(@item_window.item,1)
- Sound.play_ok
- else
- Sound.play_ok
- end
- @item_window.refresh
- end
- @selected_window.draw_seal_item(@stack_item[0],@stack_item.size)
- @item_window.activate
- seal_state
- end
- #-------------------------------------------------------------------------
- # * method: hide_seal_item_window
- #-------------------------------------------------------------------------
- def hide_seal_item_window
- @item_window.deactivate
- @altar_help_window.refresh(false)
- while @item_window.openness > 0
- [@selected_window,@item_window,@altar_title,@confirm_window,@confirm_text].each do |window|
- window.openness -= 30
- end
- Graphics.update
- end
- end
- #-------------------------------------------------------------------------
- # * method: open_seal_item_window
- #-------------------------------------------------------------------------
- def open_seal_item_window
- refresh_windows
- while @item_window.openness < 255
- [@selected_window,@item_window,@altar_title].each do |window|
- window.openness += 30
- end
- Graphics.update
- end
- @item_window.activate
- end
- #-------------------------------------------------------------------------
- # * method: hide_card
- #-------------------------------------------------------------------------
- def hide_card
- while @sprite_card.opacity > 0
- @sprite_card.opacity -= 6
- @sprite_text.opacity -= 6
- @sprite_card.zoom_x += 0.003
- @sprite_card.zoom_y += 0.003
- Graphics.update
- end
- @sprite_card.zoom_x = 1
- @sprite_card.zoom_y = 1
- @cancel_card = false
- open_seal_item_window
- end
- #-------------------------------------------------------------------------
- # * method: show_card
- #-------------------------------------------------------------------------
- def show_card(card)
- RPG::SE.new(*UNSEAL_SE).play
- @sprite_card.bitmap = Cache.picture("Card" + card.id.to_s)
- @sprite_card.ox = @sprite_card.bitmap.width / 2
- @sprite_card.oy = @sprite_card.bitmap.height / 2
- @sprite_card.x = 0.5*(Graphics.width - @sprite_card.bitmap.width) + @sprite_card.ox
- hh = @sprite_card.bitmap.height + @altar_help_window.height - @altar_title.height
- @sprite_card.y = 0.5*(Graphics.height - hh) + @sprite_card.oy - 30
- @sprite_text.opacity = 0
- @sprite_text.x = 0.5*(Graphics.width - @sprite_text.bitmap.width)
- @sprite_text.y = 20
- if @card_recieve[1] == 1
- name = $data_skills[@card_recieve[0]].name
- str = sprintf(UNSEAL_COMPLETION_TEXT,name)
- else
- name = $data_skills[@card_recieve[0]].name
- num = @card_recieve[1]
- str = sprintf(UNSEAL_COMPLETION_TEXT2,num,name)
- end
- text_y = @sprite_card.y+@sprite_card.bitmap.height
- @sprite_text.bitmap.clear
- @sprite_text.bitmap.draw_text_ex(0,300,str)
- while @sprite_card.opacity < 255
- @sprite_card.opacity += 5
- @sprite_card.y -= 1 if Graphics.frame_count % 3 == 0
- Graphics.update
- end
- 5.times { Graphics.update }
- RPG::SE.new(*UNSEAL_COMPLETE_SE).play
- while @sprite_text.opacity < 255
- @sprite_text.opacity += 5
- @sprite_text.y -= 1 if Graphics.frame_count % 3 == 0
- Graphics.update
- end
- recieve_cards
- 60.times { Graphics.update }
- hide_card
- end
- #-------------------------------------------------------------------------
- # * method: recieve_cards
- #-------------------------------------------------------------------------
- def recieve_cards
- return unless @card_recieve
- interpreter = Game_Interpreter2.new
- @card_recieve[1].times do
- interpreter.add_card_to_coll(@card_recieve[0])
- end
- end
- #-------------------------------------------------------------------------
- # * method: check_confirm
- #-------------------------------------------------------------------------
- def check_confirm
- @item_window.deactivate
- @confirm_window.open
- @confirm_window.activate
- @confirm_text.open
- @confirm_state = false
- while @confirm_window.openness < 255
- @confirm_window.update
- @confirm_text.update
- Graphics.update
- end
- while !@confirm_state
- @confirm_window.update
- @confirm_text.update
- Graphics.update
- Input.update
- end
- end
- #-------------------------------------------------------------------------
- # * method: update
- #-------------------------------------------------------------------------
- def update
- super
- if Input.trigger?(:B)
- if @cancel_card
- hide_card
- open_seal_item_window
- else
- return_scene
- end
- end
- if Input.trigger?(:X)
- if seal_state
- check_confirm
- else
- Sound.play_buzzer
- end
- end
- end
- #-------------------------------------------------------------------------
- # * method: make_command_list
- #-------------------------------------------------------------------------
- def terminate
- super
- return_stack_item
- if @sprite_card.bitmap
- @sprite_card.bitmap.dispose
- end
- @sprite_card.dispose
- if @sprite_text.bitmap
- @sprite_text.bitmap.dispose
- end
- @sprite_text.dispose
- stop_card_library_bgm
- end
- end # Scene_CardAltar
- class Window_UnsealComfirm < Window_Command
- #-------------------------------------------------------------------------
- # * method: window_width
- #-------------------------------------------------------------------------
- def window_width
- return 200
- end
- #-------------------------------------------------------------------------
- # * method: make_command_list
- #-------------------------------------------------------------------------
- def make_command_list
- add_command("Yes", :ok)
- add_command("No", :cancel)
- end
- end # Window_UnsealComfirm
- class Window_SelectedSeal < Window_Base
- #-------------------------------------------------------------------------
- # * method: draw_seal_item
- #-------------------------------------------------------------------------
- def draw_seal_item(item=nil,item_num=1)
- contents.clear
- x = 0; y = 0;cw = contents_width;ch = contents_height
- draw_text_ex(SEAL_ITEM_TEXT_MARGIN,0,SEAL_ITEM_TEXT)
- y += 26
- contents.fill_rect(x + 3,y,cw - 6,30,Color.new(0,0,0,200))
- return if item.nil?
- draw_icon(item.icon_index,x + 4,y + 2)
- draw_text(x + 29, y + 2, cw, 24, item.name + " x#{item_num}")
- end
- end # Window_SelectedSeal
- class Window_AltarHelp < Window_Base
- #-------------------------------------------------------------------------
- # * method: draw_info
- #-------------------------------------------------------------------------
- def initialize
- super(0,Graphics.height-48,Graphics.width,48)
- refresh
- end
- #--------------------------------------------------------------------------
- # * Draw Text with Control Characters
- #--------------------------------------------------------------------------
- def draw_text_ex(x, y, text)
- text = convert_escape_characters(text)
- pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
- process_character(text.slice!(0, 1), text, pos) until text.empty?
- end
- #-------------------------------------------------------------------------
- # * new method: refresh
- #-------------------------------------------------------------------------
- def refresh(enable_altar=false)
- contents.clear
- change_color(normal_color,enable_altar)
- draw_text_ex(0,0,UNSEAL_BUTTONS_TEXT)
- change_color(normal_color,true)
- draw_text_ex(contents_width - OTHER_BUTTONS_MARGIN,0,OTHER_BUTTONS_TEXT)
- end
- end # Window_CardLibraryHelp
- #==============================================================================
- # ** Window_SealItem
- #------------------------------------------------------------------------------
- # This window displays a list of seal on the item screen.
- #==============================================================================
- class Window_SealItem < Window_ItemList
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @category = 0
- end
- #--------------------------------------------------------------------------
- # * Set Category
- #--------------------------------------------------------------------------
- def category=(category)
- return if @category == category
- @category = category
- refresh
- self.oy = 0
- end
- #--------------------------------------------------------------------------
- # * Get Digit Count
- #--------------------------------------------------------------------------
- def col_max
- return 2
- end
- #--------------------------------------------------------------------------
- # * Get Number of Items
- #--------------------------------------------------------------------------
- def item_max
- @data ? @data.size : 1
- end
- #--------------------------------------------------------------------------
- # * Get Item
- #--------------------------------------------------------------------------
- def item
- @data && index >= 0 ? @data[index] : nil
- end
- #--------------------------------------------------------------------------
- # * Get Activation State of Selection Item
- #--------------------------------------------------------------------------
- def current_item_enabled?
- true
- end
- #--------------------------------------------------------------------------
- # * Include in Item List?
- #--------------------------------------------------------------------------
- def include?(item)
- return item.is_a?(RPG::Item) && item.sealed_altar == @category
- end
- #--------------------------------------------------------------------------
- # * Display in Enabled State?
- #--------------------------------------------------------------------------
- def enable?(item)
- true#$game_party.usable?(item)
- end
- #--------------------------------------------------------------------------
- # * Create Item List
- #--------------------------------------------------------------------------
- def make_item_list
- @data = $game_party.all_items.select {|item| include?(item) }
- @data.push(nil) if include?(nil)
- end
- #--------------------------------------------------------------------------
- # * Restore Previous Selection Position
- #--------------------------------------------------------------------------
- def select_last
- select(@data.index($game_party.last_item.object) || 0)
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- if item
- rect = item_rect(index)
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y, enable?(item))
- draw_item_number(rect, item)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Number of Items
- #--------------------------------------------------------------------------
- def draw_item_number(rect, item)
- draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
- end
- #--------------------------------------------------------------------------
- # * Processing When OK Button Is Pressed
- #--------------------------------------------------------------------------
- def process_ok
- if current_item_enabled?
- Input.update
- deactivate
- call_ok_handler
- else
- Sound.play_buzzer
- end
- end
- #--------------------------------------------------------------------------
- # * Update Help Text
- #--------------------------------------------------------------------------
- def update_help
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- make_item_list
- create_contents
- draw_all_items
- end
- end # Window_SealItem
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # * open_altar
- #--------------------------------------------------------------------------
- def open_altar(altar_id)
- SceneManager.call(Scene_CardAltar)
- SceneManager.scene.prepare(altar_id)
- end
- end # Game_Interpreter
- class Game_Interpreter2 < Game_Interpreter
- def initialize
- end
- end # Game_Interpreter2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement