Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # DSI Card Crafting System
- # -- Last Updated: 2017.06.10
- # -- Author: dsiver144
- # -- Level: Normal
- # -- Requires: n/a
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["DSI-CardCraftingSystem"] = true
- #==============================================================================
- # + Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2017.06.10 - 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_crafting_scene -> Open Crafting Scene
- # Notetags:
- # - Skills's Notetags:
- # + <craft show require: none> or <craft show require: [id_of_item_here]>
- # ex: <craft show require: none> : this card won't require any item to
- # be shown on the list
- # <craft show require: 12> : this card will require item 12 to be
- # show on the list
- # + <craft chance: x%>
- # ex: <craft chance: 60%> : Base Success rate equal to 60
- # + <craft materials: ([item_num]+[item_id]i),...>
- # ex: <craft materials: 5+12i,2+19i,4+16i>
- # this will translate to 5 of item 12, 2 of item 19, 4 of item 16.
- # - Items/Weapons/Armors Notetags
- # + <craft chance: x%>
- # ex: <craft chance: 2%> -> Increase 2% to overall success rate
- # ex: <craft chance: -10%> -> Decrease 10% to overall success rate
- #==============================================================================
- module DSIVER144
- module CARD_CRAFTING
- BAR_COLOR1 = Color.new(153,0,0)
- BAR_COLOR2 = Color.new(255,153,51)
- SUCCESS_SE = "Flash2"
- FAIL_SE = "Buzzer1"
- TESTING_MODE = true # Turn on this then you don't need to have require item
- # to unlock card for crafting.
- SHOW_MENU_COMMAND = true
- FILTER_BUTTON_TEXT = "\\i[1609]:Filter"
- CRAFT_BUTTON_TEXT = "\\i[1609]:Craft!"
- OTHER_BUTTONS_TEXT = "\\i[1602]:Cancel"
- OTHER_BUTTONS_MARGIN = 80
- #-------------------------------------------------------------------------
- # * new method: can_craft
- #-------------------------------------------------------------------------
- def self.can_craft(id)
- return false if id.nil?
- return false if !$data_skills[id].craft_materials
- $data_skills[id].craft_materials[:item].each do |item|
- if $game_party.item_number($data_items[item[0]]) < item[1]
- return false
- end
- end
- return true
- end # can_craft DSIVER144::CARD_CRAFTING.can_craft(id)
- #-------------------------------------------------------------------------
- # * new method: lose_craft_item
- #-------------------------------------------------------------------------
- def self.lose_craft_item(id)
- return if id.nil?
- return if !$data_skills[id].craft_materials
- $data_skills[id].craft_materials[:item].each do |item|
- $game_party.lose_item($data_items[item[0]],item[1])
- end
- end # lose_craft_item
- end # CARD_CRAFTING
- end # DSIVER144
- class Scene_CardCrafting < Scene_Base
- #-------------------------------------------------------------------------
- # * method: start
- #-------------------------------------------------------------------------
- def start
- super
- @card_window = Window_CardCraftingList.new(0,0)
- @card_filter = Window_CardFilter.new(100,100)
- @card_filter.z = 101
- @card_filter.x = 0.5*(Graphics.width - @card_filter.width)
- @card_filter.y = 0.5*(Graphics.height - @card_filter.height)
- @card_filter.set_handler(:type, method(:command_filter_1))
- @card_filter.set_handler(:secondary, method(:command_filter_2))
- @card_filter.set_handler(:cancel, method(:cancel_filter))
- @card_window.set_handler(:ok, method(:on_card_ok))
- @card_window.set_handler(:cancel, method(:return_scene))
- @card_filter.deactivate
- @card_filter.openness = 0
- @card_filter.z = 200
- @card_window.filter_window = @card_filter
- @help_window = Window_CardCraftingHelp.new
- @help_window.z = 101
- @card_window.y = @help_window.y - @card_window.height
- ww = @card_window.width; wh = Graphics.height - @card_window.height - @help_window.height
- @window_text1 = Window_Base.new(0,0,ww,wh)
- @window_text1.draw_text(0,0,@window_text1.contents_width,@window_text1.contents_height,"Craftable Card List",1)
- wx = @window_text1.width; wh = Graphics.height - @help_window.height
- ww = Graphics.width - @card_window.width
- @info_window = Window_CardCraftingInfo.new(wx,0,ww,wh)
- @old_index = @card_window.index
- wy = @info_window.height
- @slot_window = Window_CardCraftingItemSlots.new(0,0)
- @slot_window.init_slots
- @slot_window.x = -@slot_window.width
- @slot_window.y = @card_window.y
- @slot_window.set_handler(:ok, method(:on_slot_ok))
- @slot_window.set_handler(:cancel, method(:on_slot_cancel))
- @slot_window.deactivate
- @item_window = Window_AdditionItemList.new(0,0,400,200)
- @item_window.x = 0.5*(Graphics.width - @item_window.width)
- @item_window.y = 0.5*(Graphics.height - @item_window.height)
- @item_window.set_handler(:ok, method(:on_item_ok))
- @item_window.set_handler(:cancel, method(:on_item_cancel))
- @item_window.z = 150
- @item_window.category = :item
- @item_window.openness = 0
- @item_window.deactivate
- ww = @slot_window.width
- wh = @card_window.height - @slot_window.height
- @slot_help_window = Window_SlotHelpWindow.new(0,0,ww,wh)
- @slot_window.help_window = @slot_help_window
- @slot_help_window.y = @slot_window.y + @slot_window.height
- @slot_help_window_origin_y = @slot_help_window.y
- @slot_help_window.set_item(nil,@slot_window.slots)
- @slot_help_window.z = 100
- @slot_help_window.y = Graphics.height
- @can_craft = DSIVER144::CARD_CRAFTING.can_craft(@card_window.current_skill_id)
- @confrim_window = Window_CraftingConfirm.new(0,0)
- @confrim_window.x = 0.5*(Graphics.width - @confrim_window.width)
- @confrim_window.y = 0.5*(Graphics.height - @confrim_window.height)
- @confrim_window.set_handler(:cancel, method(:on_confirm_cancel))
- @confrim_window.set_handler(:ok, method(:on_confirm_ok))
- @confrim_window.openness = 0
- @confrim_window.deactivate
- @confrim_window.z = 300
- @progress_window = Window_CraftingProgess.new(0,0,400,80)
- @progress_window.x = 0.5*(Graphics.width - @progress_window.width)
- @progress_window.y = 0.5*(Graphics.height - @progress_window.height)
- @progress_window.z = 301
- @progress_window.openness = 0
- @progress_window.hide
- refresh_info_window
- @show_mode = 1
- end
- #-------------------------------------------------------------------------
- # * new method: refresh_info_window
- #-------------------------------------------------------------------------
- def refresh_info_window
- if @card_window.current_skill_id
- @slot_help_window.set_item(@slot_window.current_item,@slot_window.slots)
- @info_window.draw_info(@card_window.current_skill_id, @slot_window.slots)
- else
- @info_window.draw_info(nil)
- end
- end
- #-------------------------------------------------------------------------
- # * new method: on_card_ok
- #-------------------------------------------------------------------------
- def on_card_ok
- update_moving_sprite
- end
- #-------------------------------------------------------------------------
- # * new method: on_item_cancel
- #-------------------------------------------------------------------------
- def on_item_cancel
- @item_window.deactivate
- @item_window.close
- @slot_window.activate
- end
- #-------------------------------------------------------------------------
- # * new method: on_item_ok
- #-------------------------------------------------------------------------
- def on_item_ok
- if @slot_window.current_item
- $game_party.gain_item(@slot_window.current_item,1)
- end
- @item_window.deactivate
- @item_window.close
- $game_party.lose_item(@item_window.item,1)
- @slot_window.set_item(@item_window.item)
- @slot_window.activate
- refresh_info_window
- @can_craft = DSIVER144::CARD_CRAFTING.can_craft(@card_window.current_skill_id)
- @help_window.refresh(@can_craft,2)
- end
- #-------------------------------------------------------------------------
- # * new method: on_slot_ok
- #-------------------------------------------------------------------------
- def on_slot_ok
- @item_window.refresh
- @item_window.open
- @item_window.activate
- @item_window.select(0)
- end
- #-------------------------------------------------------------------------
- # * new method: on_slot_cancel
- #-------------------------------------------------------------------------
- def on_slot_cancel
- @slot_window.refund_items
- update_moving_sprite
- end
- #-------------------------------------------------------------------------
- # * new method: easeInOutQuad
- #-------------------------------------------------------------------------
- def easeInOutQuad(t, b, c, d)
- t = t / (d/2.0)
- if (t < 1)
- return c/2*t*t + b
- end
- t -= 1
- return -c/2.0 * (t*(t-2) - 1) + b
- end
- #-------------------------------------------------------------------------
- # * new method: update_moving_sprite
- #-------------------------------------------------------------------------
- def update_moving_sprite
- Sound.play_ok
- @moving = true
- if @show_mode == 1
- @slot_window.refresh
- @can_craft = DSIVER144::CARD_CRAFTING.can_craft(@card_window.current_skill_id)
- @help_window.refresh(@can_craft,2)
- @window_text1.contents.clear
- @window_text1.draw_text(0,0,@window_text1.contents_width,@window_text1.contents_height,"Addtion Item List",1)
- start_time = Graphics.frame_count
- start_x = @card_window.x
- change_x = -@card_window.width
- start_x2 = @slot_window.x
- change_x2 = 0 - start_x2
- start_y = @slot_help_window.y
- change_y = @slot_help_window_origin_y - start_y
- while (current_time = Graphics.frame_count - start_time) < 60
- @card_window.x = easeInOutQuad(current_time, start_x, change_x, 60)
- @slot_window.x = easeInOutQuad(current_time, start_x2, change_x2, 60)
- @slot_help_window.y = easeInOutQuad(current_time, start_y, change_y, 60)
- Graphics.update
- end
- @slot_window.activate
- @show_mode = 0
- else
- @help_window.refresh(true,1)
- @window_text1.contents.clear
- @window_text1.draw_text(0,0,@window_text1.contents_width,@window_text1.contents_height,"Craftable Card List",1)
- start_time = Graphics.frame_count
- start_x = @card_window.x
- change_x = 0 - start_x
- start_x2 = @slot_window.x
- change_x2 = -@slot_window.width - start_x2
- start_y = @slot_help_window.y
- change_y = Graphics.height - start_y
- while (current_time = Graphics.frame_count - start_time) < 60
- @card_window.x = easeInOutQuad(current_time, start_x, change_x, 60)
- @slot_window.x = easeInOutQuad(current_time, start_x2, change_x2, 60)
- @slot_help_window.y = easeInOutQuad(current_time, start_y, change_y, 60)
- Graphics.update
- end
- @card_window.activate
- @show_mode = 1
- @help_window.refresh(true,1)
- end
- @moving = false
- refresh_info_window
- end
- #-------------------------------------------------------------------------
- # * new method: open_filter
- #-------------------------------------------------------------------------
- def open_filter
- @help_window.refresh(false)
- @card_window.deactivate
- @card_filter.open
- @card_filter.activate
- end
- #-------------------------------------------------------------------------
- # * new method: cancel_filter
- #-------------------------------------------------------------------------
- def cancel_filter
- @help_window.refresh
- @card_filter.close
- @card_filter.deactivate
- @card_window.activate
- end
- #-------------------------------------------------------------------------
- # * new method: command_filter_1
- #-------------------------------------------------------------------------
- def command_filter_1
- @card_filter.increase_filter_1
- @card_filter.refresh
- @card_filter.activate
- @card_window.refresh
- @card_window.select(0)
- refresh_info_window
- end
- #-------------------------------------------------------------------------
- # * new method: command_filter_2
- #-------------------------------------------------------------------------
- def command_filter_2
- @card_filter.increase_filter_2
- @card_filter.refresh
- @card_filter.activate
- @card_window.refresh
- @card_window.select(0)
- refresh_info_window
- end
- #-------------------------------------------------------------------------
- # * new method: on_confirm_cancel
- #-------------------------------------------------------------------------
- def on_confirm_cancel
- @confrim_window.deactivate
- @confrim_window.close
- @slot_window.activate
- end
- #-------------------------------------------------------------------------
- # * new method: on_confirm_ok
- #-------------------------------------------------------------------------
- def on_confirm_ok
- @confrim_window.close
- while @confrim_window.openness > 0
- @confrim_window.update
- Graphics.update
- end
- @progress_window.show
- @progress_window.open
- while @progress_window.openness < 255
- @progress_window.update
- Graphics.update
- end
- ss_rate = @info_window.total_success_rate
- card_id = @card_window.current_skill_id
- @progress_window.play_progress(card_id,ss_rate)
- @slot_window.slots.clear
- refresh_info_window
- @slot_window.refresh
- while !Input.trigger?(:B) and !Input.trigger?(:C)
- Graphics.update
- Input.update
- end
- @progress_window.close
- while @progress_window.openness > 0
- @progress_window.update
- Graphics.update
- end
- update_moving_sprite
- end
- #-------------------------------------------------------------------------
- # * new method: command_filter_2
- #-------------------------------------------------------------------------
- def update
- super
- if Input.trigger?(:X)
- if @show_mode == 1
- Sound.play_ok
- open_filter
- elsif @can_craft && !@item_window.active
- Sound.play_ok
- @confrim_window.open
- @slot_window.deactivate
- @confrim_window.activate
- end
- end
- if @old_index != @card_window.index
- refresh_info_window
- @old_index = @card_window.index
- end
- end
- #-------------------------------------------------------------------------
- # * new method: command_filter_2
- #-------------------------------------------------------------------------
- def terminate
- super
- end
- end
- class Window_AdditionItemList < Window_ItemList
- #--------------------------------------------------------------------------
- # * Display in Enabled State?
- #--------------------------------------------------------------------------
- def enable?(item)
- return true
- end
- #--------------------------------------------------------------------------
- # * Include in Item List?
- #--------------------------------------------------------------------------
- def include?(item)
- case @category
- when :item
- item.is_a?(RPG::Item) && !item.key_item? && item.craft_rate != 0
- else
- false
- end
- end
- #--------------------------------------------------------------------------
- # * Create Item List
- #--------------------------------------------------------------------------
- def make_item_list
- @data = $game_party.all_items.select {|item| include?(item) }
- @data.push(nil) #if include?(nil)
- 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)
- else
- rect = item_rect(index)
- rect.width -= 4
- change_color(system_color)
- draw_text(rect, "Remove Item",1)
- change_color(normal_color)
- end
- end
- #--------------------------------------------------------------------------
- # * Update Help Text
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_item(item)
- end
- end # Window_AdditionItemList
- class Window_MenuCommand < Window_Command
- #---------------------------------------------------------------------------
- # overwritten method: add_main_commands
- #---------------------------------------------------------------------------
- alias_method(:dsi_card_crafting_add_main_commands, :add_main_commands)
- def add_main_commands
- dsi_card_crafting_add_main_commands
- if DSIVER144::CARD_CRAFTING::SHOW_MENU_COMMAND
- add_command("Card Crafting", :card_crafting, main_commands_enabled)
- end
- end
- end # Window_MenuCommand
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # Adds a handler to access the card crafting system
- #--------------------------------------------------------------------------
- alias :dsiver144_create_command_window_dsi_card_crafting :create_command_window
- def create_command_window
- dsiver144_create_command_window_dsi_card_crafting
- if DSIVER144::CARD_CRAFTING::SHOW_MENU_COMMAND
- @command_window.set_handler(:card_crafting, method(:command_card_crafting))
- end
- end
- #--------------------------------------------------------------------------
- # * new method: command_card_crafting
- #--------------------------------------------------------------------------
- def command_card_crafting
- SceneManager.call(Scene_CardCrafting)
- end
- end # Scene_Menu
- class Window_CraftingProgess < Window_Base
- #-------------------------------------------------------------------------
- # * new method: easeInOutQuad
- #-------------------------------------------------------------------------
- def easeInOutQuad(t, b, c, d)
- t = t / (d/2.0)
- if (t < 1)
- return c/2*t*t + b
- end
- t -= 1
- return -c/2.0 * (t*(t-2) - 1) + b
- end
- #-------------------------------------------------------------------------
- # * new method: play_progress
- #-------------------------------------------------------------------------
- def play_progress(id, success_rate)
- start_time = Graphics.frame_count
- progress = 0
- start_value = 0
- change_value = 100
- color1 = DSIVER144::CARD_CRAFTING::BAR_COLOR1
- color2 = DSIVER144::CARD_CRAFTING::BAR_COLOR2
- x = 0; y = 0; cw = contents_width
- rate = 0
- change_color(normal_color)
- while (current_time = Graphics.frame_count - start_time) < 120
- cur_value = easeInOutQuad(current_time, start_value, change_value, 120)
- contents.clear
- draw_text(x,y,cw,24,"Crafting...",1)
- rate = (cur_value.to_f / 100.0)
- draw_gauge(x + 4,y + 24,cw - 8, rate, color1, color2)
- self.x += 1 # Just for update -.-
- self.x -= 1 # Just for update -.-
- Graphics.update
- end
- if (t = rand(100)+1) <= success_rate
- contents.clear
- RPG::SE.new(DSIVER144::CARD_CRAFTING::SUCCESS_SE).play
- change_color(text_color(11))
- draw_text(x,y,cw,24,"Successful!",1)
- rate = 1.0
- change_color(normal_color)
- draw_text(x,y + 24,cw,24,"You got a new: #{$data_skills[id].name}",1)
- interpreter = Game_Interpreter2.new
- interpreter.add_card_to_coll(id)
- else
- contents.clear
- RPG::SE.new(DSIVER144::CARD_CRAFTING::FAIL_SE).play
- change_color(text_color(10))
- draw_text(x,y,cw,24,"Failed!",1)
- rate = 1.0
- change_color(normal_color)
- draw_text(x,y + 24,cw,24,"Oh, good luck next time!",1)
- end
- DSIVER144::CARD_CRAFTING.lose_craft_item(id)
- end
- end
- class Window_SlotHelpWindow < Window_Base
- #-------------------------------------------------------------------------
- # * new method: set_item
- #-------------------------------------------------------------------------
- def set_item(item,all_items)
- contents.clear
- x = 0; y = 0; cw = contents_width
- if item
- draw_text(x,y,cw,24,"Item Bonus chance:")
- y += 24
- contents.fill_rect(x,y,cw,24,Color.new(0,0,0,200))
- draw_text(x,y,cw,24,"#{item.craft_rate}%",2)
- else
- draw_text(x,y,cw,24,"Item Bonus chance:")
- y += 24
- contents.fill_rect(x,y,cw,24,Color.new(0,0,0,200))
- draw_text(x,y,cw,24,"????%",2)
- end
- chance = 0
- all_items.each do |item|
- next unless item
- chance += item.craft_rate
- end
- y += 24
- draw_text(x,y,cw,24,"Total Item Chance:")
- y += 24
- contents.fill_rect(x,y,cw,24,Color.new(0,0,0,200))
- draw_text(x,y,cw,24,"#{chance}%",2)
- chance = 0
- $game_party.menu_actor.equips.each do |equip|
- next if equip.nil?
- chance += equip.craft_rate
- end
- y += 24
- draw_text(x,y,cw,24,"Equipment Chance:")
- y += 24
- contents.fill_rect(x,y,cw,24,Color.new(0,0,0,200))
- draw_text(x,y,cw,24,"#{chance}%",2)
- end
- end
- class Window_CraftingConfirm < Window_Command
- #-------------------------------------------------------------------------
- # * new method: make_command_list
- #-------------------------------------------------------------------------
- def make_command_list
- add_command("Craft this card!", :ok)
- add_command("No", :cancel)
- end
- #-------------------------------------------------------------------------
- # * new method: window_width
- #-------------------------------------------------------------------------
- def window_width
- return 210
- end
- #--------------------------------------------------------------------------
- # * Get Alignment
- #--------------------------------------------------------------------------
- def alignment
- return 1
- end
- end
- class Window_CardCraftingItemSlots < Window_Command
- attr_accessor :slots
- attr_accessor :help_window
- #-------------------------------------------------------------------------
- # * new method: init_slots
- #-------------------------------------------------------------------------
- def init_slots
- @slots = []
- end
- #-------------------------------------------------------------------------
- # * new method: update_help
- #-------------------------------------------------------------------------
- def update_help
- @help_window.set_item(current_item, @slots) if @help_window
- end
- #-------------------------------------------------------------------------
- # * new method: refund_items
- #-------------------------------------------------------------------------
- def refund_items
- @slots.each do |item|
- $game_party.gain_item(item, 1)
- end
- @slots.clear
- end
- #-------------------------------------------------------------------------
- # * new method: set_item
- #-------------------------------------------------------------------------
- def set_item(item)
- @slots[current_slot_id] = item
- refresh
- end
- #-------------------------------------------------------------------------
- # * new method: current_item
- #-------------------------------------------------------------------------
- def current_item
- @slots[current_slot_id]
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- change_color(normal_color, command_enabled?(index))
- if @slots && @slots[index]
- rect = item_rect_for_text(index)
- draw_text(rect, "S#{index+1}:", alignment)
- rect.x += 24
- draw_icon(@slots[index].icon_index, rect.x, rect.y)
- rect.x += 25; rect.width -= 24
- draw_text(rect, @slots[index].name, alignment)
- else
- draw_text(item_rect_for_text(index), command_name(index), alignment)
- end
- end
- #-------------------------------------------------------------------------
- # * overwrite method: add_command
- #-------------------------------------------------------------------------
- def add_command(name, symbol, enabled = true, ext = nil, slot_id)
- @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext, :slot_id=>slot_id})
- end
- #--------------------------------------------------------------------------
- # * Get Symbol of Selection Item
- #--------------------------------------------------------------------------
- def current_slot_id
- current_data ? current_data[:slot_id] : nil
- end
- #-------------------------------------------------------------------------
- # * new method: set_item
- #-------------------------------------------------------------------------
- def make_command_list
- for i in 0..4 do
- add_command("S#{i+1}: Empty", "slot_#{i}".to_sym, true, nil, i)
- end
- end
- #-------------------------------------------------------------------------
- # * new method: window_width
- #-------------------------------------------------------------------------
- def window_width
- return 185
- end
- end
- class Window_CardCraftingInfo < Window_Base
- attr_accessor :total_success_rate
- #-------------------------------------------------------------------------
- # * new method: dispose
- #-------------------------------------------------------------------------
- def dispose
- @card_sprite.dispose if @card_sprite
- super
- end
- #-------------------------------------------------------------------------
- # * new method: card_number_deckcol
- #-------------------------------------------------------------------------
- def card_number_deckcol(id)
- player_cards = $game_party.menu_actor.deck + $game_party.coll
- card_ids = player_cards.map {|card| card.id}.select {|card_id| card_id == id}
- return card_ids.size
- end
- #-------------------------------------------------------------------------
- # * new method: draw_info
- #-------------------------------------------------------------------------
- def draw_info(id, addition_items=nil)
- contents.clear
- if id
- card_data = $data_skills[id]
- card_bitmap = Cache.picture("Card#{id}")
- @card_sprite ||= Sprite.new
- @card_sprite.bitmap = card_bitmap
- @card_sprite.x = 150 + self.x + 12
- @card_sprite.y = 48 + self.y + 12
- @card_sprite.z = 130
- card_num = card_number_deckcol(id)
- if card_num == 0
- @card_sprite.tone = Tone.new(0,0,0,220)
- else
- @card_sprite.tone = Tone.new(0,0,0,0)
- end
- x = 0
- width = contents.width - card_bitmap.width
- contents.fill_rect(x,y + 4,width,42,Color.new(0,0,0,200))
- x = 150
- contents.fill_rect(x,y + 4,card_bitmap.width,42,Color.new(0,0,0,200))
- draw_text(x,y,card_bitmap.width,48,card_data.name,1)
- y = card_bitmap.height + 5
- ss_chance = card_data.craft_rate
- $game_party.menu_actor.equips.each do |equip|
- next if equip.nil?
- ss_chance += equip.craft_rate if ss_chance
- end
- if addition_items
- addition_items.each do |item|
- next if item.nil?
- ss_chance += item.craft_rate if ss_chance
- end
- end
- ss_chance = [[0,ss_chance].max,100].min
- @total_success_rate = ss_chance
- change_color(text_color(5))
- y += 48
- contents.fill_rect(x,y - 2,card_bitmap.width,40,Color.new(0,0,0,200))
- draw_text(x,y+2,card_bitmap.width,24,"Success Chance: #{ss_chance}%",1)
- change_color(text_color(0))
- x = 0; y = 24
- width = contents.width - card_bitmap.width
- draw_text(x,y-24,width,48,"Materials",1)
- y += 24
- change_color(normal_color,false)
- 8.times do |i|
- contents.fill_rect(x,y,width,24,Color.new(0,0,0,200))
- draw_text(x,y,width,24,"Empty",1)
- y += 27
- end
- change_color(normal_color,true)
- contents.fill_rect(x,y,width,24,Color.new(0,0,0,200))
- draw_text(x + 3,y,width,24,"You owned:",0)
- draw_text(x + 3,y,width - 2,24,"#{card_num}",2)
- y += 28
- contents.fill_rect(x,y,width,50,Color.new(0,0,0,200))
- if DSIVER144::CARD_CRAFTING.can_craft(id)
- change_color(text_color(11))
- draw_text(x,y + 14,width,24,"Can craft!",1)
- else
- change_color(text_color(10))
- draw_text(x,y + 14,width,24,"Can't craft!",1)
- end
- y = 24 + 24
- card_data.craft_materials[:item].each do |material|
- name = $data_items[material[0]].name; icon_index = $data_items[material[0]].icon_index
- contents.clear_rect(x,y,width,24)
- contents.fill_rect(x,y,width,24,Color.new(0,0,0,200))
- if $game_party.item_number($data_items[material[0]]) < material[1]
- change_color(normal_color,false)
- else
- change_color(text_color(11))
- end
- draw_icon(icon_index,x+1,y)
- draw_text(x+26,y,width,24,name)
- draw_text(x,y,width,24,"x#{material[1]}",2)
- y += 27
- end
- change_color(normal_color, true)
- else
- if @card_sprite
- @card_sprite.dispose
- @card_sprite = nil
- end
- draw_text(0,0,contents_width,contents_height,"Please select a card",1)
- end
- end
- end
- class Window_CardCraftingHelp < Window_Base
- #-------------------------------------------------------------------------
- # * method: initialize
- #-------------------------------------------------------------------------
- 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_filter=true, mode=1)
- contents.clear
- change_color(normal_color,enable_filter)
- if mode == 1
- draw_text_ex(0,0,DSIVER144::CARD_CRAFTING::FILTER_BUTTON_TEXT)
- else
- draw_text_ex(0,0,DSIVER144::CARD_CRAFTING::CRAFT_BUTTON_TEXT)
- end
- change_color(normal_color,true)
- draw_text_ex(contents_width - DSIVER144::CARD_CRAFTING::OTHER_BUTTONS_MARGIN,0,DSIVER144::CARD_CRAFTING::OTHER_BUTTONS_TEXT)
- end
- end # Window_CardLibraryHelp
- class Window_CardCraftingList < Window_Command
- include DSIVER144::CARD_LIBRARY
- attr_accessor :list
- attr_accessor :card_data
- attr_accessor :filter_window
- #-------------------------------------------------------------------------
- # * new method: current_card_data
- #-------------------------------------------------------------------------
- def current_card_data
- @card_data ? @card_data[index] : nil
- end
- #-------------------------------------------------------------------------
- # * new method: match_filter?
- #-------------------------------------------------------------------------
- def match_filter?(card,card2)
- return true if !@filter_window
- filter_1_type = @filter_window.current_type
- filter_2_type = @filter_window.current_type2
- type1 = card ? card[:type] : 0
- type2 = card2.type
- return false unless (type1 == filter_1_type) || filter_1_type == 0
- return false unless (type2 == filter_2_type) || filter_2_type == 0
- return true
- end
- #-------------------------------------------------------------------------
- # * new method: no_filter?
- #-------------------------------------------------------------------------
- def no_filter?
- return true if !@filter_window
- return true if @filter_window.current_type == 0 && @filter_window.current_type2 == 0
- return false
- end
- #-------------------------------------------------------------------------
- # * method: has_card_deckcoll?
- #-------------------------------------------------------------------------
- def has_card_deckcoll?(id)
- for card in $game_party.coll
- return true if card.id == id
- end
- for actor in $game_party.members
- for card in actor.deck
- return true if card.id == id
- end
- end
- return false
- end
- #-------------------------------------------------------------------------
- # * overwrite method: add_command
- #-------------------------------------------------------------------------
- def add_command(name, symbol, enabled = true, ext = nil, skill_id)
- @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext, :skill_id=>skill_id})
- end
- #--------------------------------------------------------------------------
- # * Get Symbol of Selection Item
- #--------------------------------------------------------------------------
- def current_skill_id
- current_data ? current_data[:skill_id] : nil
- end
- #-------------------------------------------------------------------------
- # * new method: make_command_list
- #-------------------------------------------------------------------------
- def make_command_list
- @card_data ||= []
- @card_data.clear
- card_list = DSIVER144::CARD_LIBRARY.get_all_card
- card_list = card_list.select {|card| card.craft_show }
- if !DSIVER144::CARD_CRAFTING::TESTING_MODE
- card_list = card_list.select do |card|
- card.craft_show == 0 || $game_party.has_item?($data_items[card.craft_show])
- end
- end
- card_list.sort! {|a,b| a.card_id <=> b.card_id}
- card_list.each do |card|
- check = match_filter?(CARD_CONFIG[card.id],card)
- if check
- name = card.name
- add_command(name, "#{card.card_id}".to_sym, true, nil, card.id)
- @card_data.push(card)
- elsif no_filter?
- name = "????????????????????"
- add_command(name, :empty_card, false, nil, card.id)
- @card_data.push(nil)
- end
- end
- end
- #-------------------------------------------------------------------------
- # * new method: window_width
- #-------------------------------------------------------------------------
- def window_width
- return 185
- end
- #-------------------------------------------------------------------------
- # * new method: window_height
- #-------------------------------------------------------------------------
- def window_height
- return 320
- end
- end # Window_CardList
- class Window_CardFilter < Window_Command
- attr_accessor :filter_1
- attr_accessor :filter_2
- attr_accessor :card_types
- attr_accessor :card_2ndtypes
- #-------------------------------------------------------------------------
- # * new method: current_type
- #-------------------------------------------------------------------------
- def current_type
- @card_types[@filter_1] - 1
- end
- #-------------------------------------------------------------------------
- # * new method: current_type2
- #-------------------------------------------------------------------------
- def current_type2
- @card_2ndtypes[@filter_2] - 1
- end
- #-------------------------------------------------------------------------
- # * new method: increase_filter_1
- #-------------------------------------------------------------------------
- def increase_filter_1
- @filter_1 += 1
- if @filter_1 > @card_types.size - 1
- @filter_1 = 0
- end
- end
- #-------------------------------------------------------------------------
- # * new method: increase_filter_2
- #-------------------------------------------------------------------------
- def increase_filter_2
- @filter_2 += 1
- if @filter_2 > @card_2ndtypes.size - 1
- @filter_2 = 0
- end
- end
- #-------------------------------------------------------------------------
- # * new method: make_command_list
- #-------------------------------------------------------------------------
- def make_command_list
- @filter_1 ||= 0
- @filter_2 ||= 0
- @card_types ||= CARD_TYPE.keys
- @card_2ndtypes ||= TYPE.keys
- if @filter_1 == 0
- name = "---------------"
- else
- name = CARD_TYPE[@card_types[@filter_1]-1]
- end
- if @filter_2 == 0
- name2 = "---------------"
- else
- name2 = TYPE[@card_2ndtypes[@filter_2]-1]
- end
- add_command("Filter by Type: " + name, :type)
- add_command("Filter by 2nd Type: " + name2, :secondary)
- end
- #-------------------------------------------------------------------------
- # * new method: window_width
- #-------------------------------------------------------------------------
- def window_width
- return 300
- end
- end # Window_CardFilter
- #==============================================================================
- # ** DataManager
- #==============================================================================
- module DataManager
- class << self
- alias crafting_system_load_database load_database
- alias crafting_system_init init
- end
- #----------------------------------------------------------------------------
- # * alias method: init
- #----------------------------------------------------------------------------
- def self.init
- crafting_system_init
- load_notetags_crafting_system
- end
- #----------------------------------------------------------------------------
- # * alias method: load_database
- #----------------------------------------------------------------------------
- def self.load_database
- crafting_system_load_database
- end
- #----------------------------------------------------------------------------
- # * new method: load_notetags_hp_shield
- #----------------------------------------------------------------------------
- def self.load_notetags_crafting_system
- groups = [$data_skills, $data_weapons, $data_armors, $data_items]
- for group in groups
- for obj in group
- next if obj.nil?
- next if obj.name == ""
- obj.load_notetags_crafting
- end
- end
- end
- end # DataManager
- class RPG::EquipItem
- attr_accessor :craft_rate
- def load_notetags_crafting
- @craft_rate = 0
- self.note.split(/[\r\n]+/).each do |line|
- if line =~ /<craft chance:\s*(.+)\%>/i
- @craft_rate = $1.to_f
- end
- end
- end
- end # RPG::EquipItem
- class RPG::Item
- attr_accessor :craft_rate
- def load_notetags_crafting
- @craft_rate = 0
- self.note.split(/[\r\n]+/).each do |line|
- if line =~ /<craft chance:\s*(.+)\%>/i
- @craft_rate = $1.to_f
- end
- end
- end
- end # RPG::EquipItem
- #==============================================================================
- # ** RPG::Skill
- #==============================================================================
- class RPG::Skill
- attr_accessor :craft_show
- attr_accessor :craft_materials
- attr_accessor :craft_rate
- #----------------------------------------------------------------------------
- # * new method: load_notetags_hp_shield
- #----------------------------------------------------------------------------
- def load_notetags_crafting
- @craft_show = nil
- @craft_rate = 0
- @craft_materials = nil
- self.note.split(/[\r\n]+/).each do |line|
- if line =~ /<craft show require:\s*(none|\d+)>/i
- @craft_show = 0 if $1 == "none"
- @craft_show = $1.to_i if $1 != "none"
- end
- if line =~ /<craft chance:\s*(.+)\%>/i
- @craft_rate = $1.to_f
- end
- if line =~ /<craft materials:\s*(.+)>/i
- @craft_materials ||= {}
- @craft_materials[:item] ||= []
- text = $1.clone
- text.split(",").each do |item|
- if item =~ /(\d+)\+(\d+)i/i
- @craft_materials[:item] << [$2.to_i,$1.to_i]
- end
- end
- end
- end
- p @craft_materials[:item] if @craft_materials
- end
- end # RPG::Skill
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement