Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ($imported ||= {})[:Theo_Smithing] = true
- module THEO
- module Smith
- MenuActor_Size = 140
- GoldWindow_Size = 120
- PriceBase = 10
- PriceFormula = ""
- module Colour
- Level = 6
- Maxout = 21
- Upgradable = 24
- end
- module SVocab
- Cost = "Cost: "
- Level = "Lv.%d"
- Upgradable = "Upgradable"
- Maxout = "Maxed Out"
- Yes_Confirm = "Yes"
- No_Confirm = "No"
- Select_Weapon = "Whose weapon will be upgraded?"
- Decide_Weapon = "Upgrade this weapon?"
- Upgraded_Quote = "Upgrade complete"
- Refuse_Upgrade = "Not enough money"
- NotifNameChange = "Weapon changed to %s"
- NotifNormal = "Weapon Improved"
- end
- # --------------------------------------------------------------------------
- # Weapon Upgrade Table
- # --------------------------------------------------------------------------
- W_Upgrade_Table = {
- 1 => [
- [{:atk => 2,:def => 2, :mat => 2,
- :mdf => 2,:agi => 2, :luk => 2},1,"Wodden Ax",""],
- [{:atk => 2},0,"Iron Ax",""],
- [{:atk => 2},0,"Silver Ax",""],
- ],
- }
- # ============================================================================
- # Do not ever touch anything pass this line. Or nightmare will come to u
- # ============================================================================
- Key = {
- :mhp => 0,
- :mmp => 1,
- :atk => 2,
- :def => 3,
- :mat => 4,
- :mdf => 5,
- :agi => 6,
- :luk => 7,
- }
- end
- end
- class RPG::EquipItem < RPG::BaseItem
- attr_accessor :level
- alias theo_smith_upgrade_init initialize
- def initialize
- theo_smith_upgrade_init
- @level = 1
- end
- def clone_data
- original = self
- cloned = RPG::UpgradedWeapon.new
- self.instance_variables.each do |varsym|
- ivar_name = varsym.to_s.gsub(/@/) {""}
- eval("
- begin
- cloned.#{ivar_name} = original.#{ivar_name}.clone
- rescue
- cloned.#{ivar_name} = original.#{ivar_name}
- end")
- end
- return cloned
- end
- def next_weapon
- next_weapon_exist? ? $upgraded_weapons[upgrade_key] : nil
- end
- def next_weapon_exist?
- !$upgraded_weapons[upgrade_key].nil?
- end
- def upgrade_key
- self.id * 100 + (level+1)
- end
- def level
- @level ||= 1
- end
- end
- class RPG::UpgradedWeapon < RPG::Weapon
- attr_accessor :ori_id
- def upgrade_key
- self.ori_id * 100 + (level+1)
- end
- end
- class << DataManager
- alias theo_upgrade_smith_game_obj create_game_objects
- def create_game_objects
- theo_upgrade_smith_game_obj
- init_upgraded_weapons
- end
- def init_upgraded_weapons
- $upgraded_weapons = {}
- THEO::Smith::W_Upgrade_Table.each do |id, table|
- table.each_with_index do |data,level|
- gen_id = (id*100) + (level+1)
- weapon_check = $upgraded_weapons[gen_id]
- result = nil
- if (level + 1) != 1 && !weapon_check.nil?
- result = weapon_check.clone_data
- else
- result = $data_weapons[id].clone_data
- end
- result.level = level+2
- data[0].each do |param,value|
- param_id = THEO::Smith::Key[param]
- result.params[param_id] += value
- end
- if data[1] > -1
- result.icon_index = data[1]
- end
- result.name = data[2].empty? ? result.name : data[2]
- result.description = data[3].empty? ? result.description : data[3]
- result.ori_id = id
- gen_id = (id*100) + (level+2)
- result.id = gen_id
- $upgraded_weapons[gen_id] = result
- end
- end
- end
- end
- class Game_BaseItem
- def upgraded_weapon?
- @class == RPG::UpgradedWeapon
- end
- alias theo_smt_upgrade_object object
- def object
- return $upgraded_weapons[@item_id] if upgraded_weapon?
- return theo_smt_upgrade_object
- end
- end
- class Game_Party < Game_Unit
- alias theo_smith_init_item init_all_items
- def init_all_items
- theo_smith_init_item
- @upgraded_weapons = {}
- end
- alias theo_smith_item_container item_container
- def item_container(item_class)
- return @upgraded_weapons if item_class == RPG::UpgradedWeapon
- return theo_smith_item_container(item_class)
- end
- alias theo_smith_weapon weapons
- def weapons
- theo_smith_weapon + upgraded_weapons
- end
- def upgraded_weapons
- @upgraded_weapons.keys.sort.collect {|id| $upgraded_weapons[id]}
- end
- end
- class Window_Base < Window
- SText_Format = "\\C[16]%s\\C[0] : %d → \\C[24]%d\\C[0]"
- def obtain_params_change
- result = []
- @weapon.params.each_with_index do |param,id|
- next_param = @weapon.next_weapon.params[id]
- next if param == next_param
- text = sprintf(SText_Format,Vocab.param(id),param,next_param)
- result.push(text)
- end if @weapon
- return result
- end
- end
- class Window_SmithGold < Window_Gold
- def window_width
- return THEO::Smith::GoldWindow_Size
- end
- end
- class Window_SmithMenu < Window_Selectable
- def initialize(x,y)
- super(x,y,window_width,window_height)
- refresh
- end
- def window_width
- THEO::Smith::MenuActor_Size
- end
- def window_height
- fitting_height(item_max)
- end
- def item_max
- $game_party.members.size
- end
- def draw_item(index)
- actor = $game_party.members[index]
- draw_text(item_rect(index),actor.name,alignment)
- end
- def alignment
- return 0
- end
- def weapon
- $game_party.members[index].equips[0]
- end
- def update_help
- @help_window.refresh(weapon)
- end
- def current_item_enable?
- actor = $game_party.members[index]
- return false if actor.equips[0].nil?
- return actor.equips[0].next_weapon_exist?
- end
- end
- class Window_SmithResult < Window_Base
- include THEO::Smith
- def next_weapon
- @weapon.next_weapon
- end
- def refresh(weapon)
- contents.clear
- @weapon = weapon
- return unless @weapon
- reset_font_settings
- draw_weapon_name
- if @weapon.next_weapon_exist?
- draw_next_weapon
- else
- draw_maxed_out
- end
- end
- def draw_weapon_name
- draw_item_name(@weapon,0,0)
- level = sprintf(SVocab::Level,@weapon.level)
- change_color(text_color(Colour::Level))
- draw_text(0,0,contents.width,line_height,level,2)
- contents.fill_rect(0,24,contents.width,1,Color.new(255,255,255,128))
- end
- def draw_next_weapon
- ypos = 28
- rect = Rect.new(0,ypos,contents.width,line_height)
- contents.font.size -= 4
- change_color(system_color)
- draw_text(rect,SVocab::Cost)
- change_color(text_color(Colour::Upgradable))
- draw_text(rect,SVocab::Upgradable,2)
- texts = obtain_params_change
- ypos += line_height
- texts.each do |txt|
- draw_text_ex(0,ypos,txt)
- ypos += line_height
- end
- end
- def draw_maxed_out
- ypos = 28
- rect = Rect.new(0,ypos,contents.width,line_height)
- contents.font.size -= 4
- change_color(text_color(Colour::Maxout))
- draw_text(rect,SVocab::Maxout,2)
- end
- end
- class Window_SmithNotif < Window_Base
- def initialize(width)
- super(0,0,width,0)
- self.openness = 0
- update_placement
- @show_count = 0
- end
- def update_placement
- self.x = Graphics.width/2 - self.width/2
- self.y = Graphics.height/2 - self.height/2
- end
- def height=(height)
- super
- update_placement
- create_contents
- end
- def show_weapon(weapon)
- @weapon = weapon
- @texts = obtain_params_change
- update_height
- refresh
- @show_count = 120
- end
- def update_height
- self.height = fitting_height(@texts.size + 1)
- end
- def refresh
- contents.clear
- rect = Rect.new(0,0,contents.width,line_height)
- next_name = @weapon.next_weapon.name
- if next_name != @weapon.name
- text = sprintf(THEO::Smith::SVocab::NotifNameChange,next_name)
- draw_text(rect,text)
- else
- text = THEO::Smith::SVocab::NotifNormal
- draw_text(rect,text)
- end
- ypos = line_height
- @texts.each do |txt|
- draw_text_ex(0,ypos,txt)
- ypos += line_height
- end
- end
- def update
- super
- update_close_input
- if @show_count > 0
- open
- else
- close
- end
- end
- def update_close_input
- @show_count -= 1
- @show_count = 0 if Input.trigger?(:C)
- end
- end
- class Window_SmithConfirm < Window_Command
- def initialize(x,y)
- super(x,y)
- self.openness = 0
- end
- def make_command_list
- vocab = THEO::Smith::SVocab
- add_command(Yes_Confirm, :yes)
- add_command(No_Confirm, :no)
- end
- def window_width
- return 80
- end
- end
- class Scene_Smith < Scene_MenuBase
- def start
- super
- create_help_window
- create_actor_menu
- create_gold_window
- create_smith_result
- create_notif_smith
- end
- def create_help_window
- @help_window = Window_Help.new(1)
- end
- def create_actor_menu
- y = @help_window.height
- @menu_actor = Window_SmithMenu.new(0,y)
- @menu_actor.set_handler(:cancel, method(:return_scene))
- @menu_actor.set_handler(:ok, method(:on_actor_ok))
- @menu_actor.activate
- @menu_actor.select(0)
- end
- def create_smith_result
- x = @menu_actor.width
- y = @help_window.height
- w = Graphics.width - @menu_actor.width - @gold_window.width
- h = 24 * 9 + 4
- @smith_result = Window_SmithResult.new(x,y,w,h)
- @menu_actor.help_window = @smith_result
- end
- def create_gold_window
- @gold_window = Window_SmithGold.new
- @gold_window.x = Graphics.width - @gold_window.width
- @gold_window.y = @help_window.height
- end
- def create_notif_smith
- @notif_smith = Window_SmithNotif.new(300)
- end
- def on_actor_ok
- if next_weapon.nil?
- Sound.play_buzzer
- @menu_actor.activate
- return
- end
- craft_weapon
- end
- def craft_weapon
- $game_party.gain_item(next_weapon,1)
- last_equip = item_to_lose
- @notif_smith.show_weapon(last_equip)
- actor.change_equip(0,next_weapon)
- $game_party.lose_item(last_equip,1)
- @menu_actor.update_help
- @menu_actor.activate
- end
- def next_weapon
- @smith_result.next_weapon
- end
- def actor
- $game_party.members[@menu_actor.index]
- end
- def item_to_lose
- actor.equips[0]
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment