could somebody fix this script so it doesn't let you enchant an item unless you have the ores
also can you make it so that it costs the player gold to enchant an item?
also can you make it so that it costs the player gold to enchant an item?
Code:
#==============================================================================
# ** Scene_Enchant
#------------------------------------------------------------------------------
# Mike Black
# Version 1.1
# August 7th 2006
#==============================================================================
class Scene_Enchant
def initialize(menu_index = 0)
@menu_index = menu_index #Store the cursor position
@weapon = false
@base_stats = []
@attr_stats = []
@elements_fortext = []
@elements= []
@plus_state = []
@minus_state = []
@ore_list = []
load_ores
end
def load_ores
#----------------------------------------Begin Ore-----------------------------------------------
#default ore settings
new_ore = RPG::Ore.new("Fire Ore") #name
new_ore.set_id(106) #id link to database *** must be the same as the id in the database with the corresponding ore
new_ore.set_icon_name("043-Item12")
new_ore.set_description("A Firey Ore")
new_ore.set_elements([1])
new_ore.set_plus_states([])
new_ore.set_minus_states([])
new_ore.set_price_bonus(500)
#ore settings for weapons
new_ore.set_wep_atk(5)
new_ore.set_wep_pdef(0)
new_ore.set_wep_mdef(0)
new_ore.set_wep_str(5)
new_ore.set_wep_agi(0)
new_ore.set_wep_dex(0)
new_ore.set_wep_int(0)
new_ore.set_wep_prefix("Firey ") #will go before weapon name
new_ore.set_wep_postfix("") #will go after weapon name
new_ore.set_wep_anim(201) #id of animation to use with a weapon forged with this ore
#ore settings for armor
new_ore.set_arm_eva(0)
new_ore.set_arm_pdef(0)
new_ore.set_arm_mdef(0)
new_ore.set_arm_str(10)
new_ore.set_arm_agi(0)
new_ore.set_arm_dex(0)
new_ore.set_arm_int(0)
new_ore.set_arm_prefix("Hot ") #will go before armor name
new_ore.set_arm_postfix("") #will go after armor name
@ore_list.push(new_ore)
#--------------------------------------------end of ore-------------------------------------------
#----------------------------------------Begin Ore-----------------------------------------------
#default ore settings
new_ore = RPG::Ore.new("Earth Ore") #name
new_ore.set_id(107) #id link to database *** must be the same as the id in the database with the corresponding ore
new_ore.set_icon_name("043-Item12")
new_ore.set_description("An Earthly Ore")
new_ore.set_elements([5])
new_ore.set_plus_states([])
new_ore.set_minus_states([])
new_ore.set_price_bonus(500)
#ore settings for weapons
new_ore.set_wep_atk(5)
new_ore.set_wep_pdef(0)
new_ore.set_wep_mdef(0)
new_ore.set_wep_str(0)
new_ore.set_wep_agi(0)
new_ore.set_wep_dex(5)
new_ore.set_wep_int(0)
new_ore.set_wep_prefix("") #will go before weapon name
new_ore.set_wep_postfix(" of Earth") #will go after weapon name
new_ore.set_wep_anim(202) #id of animation to use with a weapon forged with this ore
#ore settings for armor
new_ore.set_arm_eva(0)
new_ore.set_arm_pdef(0)
new_ore.set_arm_mdef(0)
new_ore.set_arm_str(0)
new_ore.set_arm_agi(0)
new_ore.set_arm_dex(10)
new_ore.set_arm_int(0)
new_ore.set_arm_prefix("") #will go before armor name
new_ore.set_arm_postfix(" of Rocks") #will go after armor name
@ore_list.push(new_ore)
#--------------------------------------------end of ore-------------------------------------------
#----------------------------------------Begin Ore-----------------------------------------------
#default ore settings
new_ore = RPG::Ore.new("Ice Ore") #name
new_ore.set_id(108) #id link to database *** must be the same as the id in the database with the corresponding ore
new_ore.set_icon_name("043-Item12")
new_ore.set_description("A Chilling Ore")
new_ore.set_elements([2])
new_ore.set_plus_states([])
new_ore.set_minus_states([])
new_ore.set_price_bonus(500)
#ore settings for weapons
new_ore.set_wep_atk(5)
new_ore.set_wep_pdef(0)
new_ore.set_wep_mdef(0)
new_ore.set_wep_str(0)
new_ore.set_wep_agi(0)
new_ore.set_wep_dex(0)
new_ore.set_wep_int(5)
new_ore.set_wep_prefix("Cold ") #will go before weapon name
new_ore.set_wep_postfix("") #will go after weapon name
new_ore.set_wep_anim(203) #id of animation to use with a weapon forged with this ore
#ore settings for armor
new_ore.set_arm_eva(0)
new_ore.set_arm_pdef(0)
new_ore.set_arm_mdef(0)
new_ore.set_arm_str(0)
new_ore.set_arm_agi(0)
new_ore.set_arm_dex(0)
new_ore.set_arm_int(5)
new_ore.set_arm_prefix("Chilling ") #will go before armor name
new_ore.set_arm_postfix("") #will go after armor name
@ore_list.push(new_ore)
#--------------------------------------------end of ore-------------------------------------------
#----------------------------------------Begin Ore-----------------------------------------------
#default ore settings
new_ore = RPG::Ore.new("Dragon ore") #name
new_ore.set_id(109) #id link to database *** must be the same as the id in the database with the corresponding ore
new_ore.set_icon_name("043-Item12")
new_ore.set_description("Hot to the touch")
new_ore.set_elements([1])
new_ore.set_plus_states([])
new_ore.set_minus_states([])
new_ore.set_price_bonus(500)
#ore settings for weapons
new_ore.set_wep_atk(15)
new_ore.set_wep_pdef(15)
new_ore.set_wep_mdef(15)
new_ore.set_wep_str(15)
new_ore.set_wep_agi(0)
new_ore.set_wep_dex(0)
new_ore.set_wep_int(5)
new_ore.set_wep_prefix("Dragon ") #will go before weapon name
new_ore.set_wep_postfix("") #will go after weapon name
new_ore.set_wep_anim(113) #id of animation to use with a weapon forged with this ore
#ore settings for armor
new_ore.set_arm_eva(0)
new_ore.set_arm_pdef(15)
new_ore.set_arm_mdef(15)
new_ore.set_arm_str(15)
new_ore.set_arm_agi(0)
new_ore.set_arm_dex(0)
new_ore.set_arm_int(0)
new_ore.set_arm_prefix("Dragon ") #will go before armor name
new_ore.set_arm_postfix("") #will go after armor name
@ore_list.push(new_ore)
#--------------------------------------------end of ore-------------------------------------------
end
def main
@help_window = Window_Help.new
@window_2=Window_Enchant_Left.new
@window_2.y=50
@window_2.active = true
@window_2.index = @menu_index
@window_3=Window_Enchant_Right.new(@ore_list)
@window_3.x=320
@window_3.y=50
@window_3.active = false
@window_4=Window_Enchant_Bottom.new
@window_4.x=0
@window_4.y=250
@window_2.help_window = @help_window
@window_3.help_window = @help_window
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@window_2.dispose
@window_3.dispose
@window_4.dispose
end
def update
@window_2.update
@help_window.update
@window_3.update
@window_4.update
if @window_2.active
update_2
return
end
if @window_3
update_3
return
end
end
#For Window_Enchant_Left active:
def update_2
stats = []
item = @window_2.item
case item
when RPG::Weapon
stats[0] = item.atk
stats[1] = item.pdef
stats[2] = item.mdef
stats[3] = (0 - item.agi_plus)
stats[4] = item.str_plus
stats[5] = item.dex_plus
stats[6] = item.int_plus
stats[7] = item.price
stats[8] = "Attack Power :"
stats[9] = "Physical Defense :"
stats[10] = "Magic Defense :"
stats[11] = item.name
stats[12] = item.id
stats[13] = item.icon_name
stats[14] = item.animation1_id
stats[15] = item.animation2_id
@weapon = true
when RPG::Armor
stats[0] = item.pdef
stats[1] = item.mdef
stats[2] = item.eva
stats[3] = (0 - item.agi_plus)
stats[4] = item.str_plus
stats[5] = item.dex_plus
stats[6] = item.int_plus
stats[7] = item.price
stats[8] = "Physical Defense :"
stats[9] = "Magic Defense :"
stats[10] = "Evade :"
stats[11] = item.name
stats[12] = item.id
stats[13] = item.icon_name
stats[14] = item.kind
@weapon = false
end
@base_stats = stats
@window_4.update_stats(stats)
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
@window_2.active = false
@window_3.active = true
return
end
end
#For Window_Enchant_Right active:
def update_3
stats = []
item = @window_3.item
@elements = item.element_set #elements
@plus_state = item.plus_state_set #add state
@minus_state = item.minus_state_set #minus state
stats[0] = item.atk_w #atk
stats[1] = item.pdef_w #def
stats[2] = item.mdef_w #mdef
stats[3] = item.agi_w #agi
stats[4] = item.str_w #str
stats[5] = item.dex_w #vit
stats[6] = item.int_w #int
stats[7] = item.animation_id_w
stats[8] = item.prefix_w
stats[9] = item.postfix_w
stats[10] = item.pdef_a
stats[11] = item.mdef_a
stats[12] = item.eva_a #evade (armor)
stats[13] = item.agi_a #agi
stats[14] = item.str_a #str
stats[15] = item.dex_a #vit
stats[16] = item.int_a #int
stats[17] = item.price_bonus
stats[18] = item.prefix_a
stats[19] = item.postfix_a
@attr_stats = stats
@window_4.draw_improve(stats,@elements,@plus_state,@weapon)
if Input.trigger?(Input::B)
@window_3.active = false
@window_2.active = true
return
end
flag = true
if Input.trigger?(Input::C)
if(@weapon)
@full_name = @attr_stats[8].to_s + @base_stats[11].to_s + @attr_stats[9].to_s
#check for dupe
for i in 1...$data_weapons.size
if(@full_name == $data_weapons[i].name)
flag = false
$game_party.gain_weapon(i, 1)
end
end
if(flag)
forge_weapon
else
$scene = Scene_Map.new
end
else
@full_name = @attr_stats[18].to_s + @base_stats[11].to_s + @attr_stats[19].to_s
#check for dupe
for i in 1...$data_armors.size
if(@full_name == $data_armors[i].name)
flag = false
$game_party.gain_armor(i, 1)
end
end
if(flag)
forge_armor
else
$scene = Scene_Map.new
end
end
end
end
def forge_weapon
newid = $data_weapons.size
newweapon = RPG::Weapon.new
newweapon.name = @full_name
newweapon.icon_name = @base_stats[13]
newweapon.description = "An enchanted Weapon"
newweapon.animation1_id = @base_stats[14]
newweapon.animation2_id = @attr_stats[7]
newweapon.price = (@base_stats[7] + @attr_stats[17])
newweapon.atk = (@base_stats[0] + @attr_stats[0])
newweapon.pdef = (@base_stats[1] + @attr_stats[1])
newweapon.mdef = (@base_stats[2] + @attr_stats[2])
newweapon.agi_plus = (0 - (@base_stats[3] + @attr_stats[3]))
newweapon.str_plus = (@base_stats[4] + @attr_stats[4])
newweapon.dex_plus = (@base_stats[5] + @attr_stats[5])
newweapon.int_plus = (@base_stats[6] + @attr_stats[6])
newweapon.element_set = @elements
newweapon.plus_state_set = @plus_state
newweapon.minus_state_set = @minus_state
newweapon.id = newid
$data_weapons.push(newweapon)
$game_party.gain_weapon(newid, 1)
for i in 1...$data_classes.size
for j in 0...$data_weapons.size
if($data_classes[i].weapon_set[j] == @base_stats[12])
$data_classes[i].weapon_set.push(newid)
end
end
end
$game_party.lose_weapon(@base_stats[12], 1)
$scene = Scene_Map.new
end
def forge_armor
newid = $data_armors.size
newarmor = RPG::Armor.new
newarmor.name = @full_name
newarmor.icon_name = @base_stats[13]
newarmor.description = "an enchanted armor"
newarmor.price = (@base_stats[7] + @attr_stats[17])
newarmor.eva = (@base_stats[2] + @attr_stats[12])
newarmor.pdef = (@base_stats[0] + @attr_stats[10])
newarmor.mdef = (@base_stats[1] + @attr_stats[11])
newarmor.agi_plus = (0 - (@base_stats[3] + @attr_stats[13]))
newarmor.str_plus = (@base_stats[4] + @attr_stats[14])
newarmor.dex_plus = (@base_stats[5] + @attr_stats[15])
newarmor.int_plus = (@base_stats[6] + @attr_stats[16])
newarmor.kind = @base_stats[14]
newarmor.guard_element_set = @elements
newarmor.guard_state_set = @plus_state
newarmor.id = newid
$data_armors.push(newarmor)
$game_party.gain_armor(newid, 1)
for i in 1...$data_classes.size
for j in 0...$data_armors.size
if($data_classes[i].armor_set[j] == @base_stats[12])
$data_classes[i].armor_set.push(newid)
end
end
end
$game_party.lose_armor(@base_stats[12], 1)
$scene = Scene_Map.new
end
end
Code:
class Window_Enchant_Left < Window_Selectable
def initialize
super(0, 0, 320,200)
self.contents = Bitmap.new(width - 32, height - 32)
self.index = 0
@data = []
#--------Remove following block to allow multiple reforging of weapons/armor-----------------------------
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
if($data_weapons[i].description != "A custom made Magical Weapon of Power")
@data.push($data_weapons[i])
end
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
if($data_armors[i].description != "A custom made Magical armor of Power")
@data.push($data_armors[i])
end
end
end
#-----------End Block-----------------------------------------------------------------
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
self.contents.font.name = "Arial"
self.contents.font.size = 22
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def item
return @data[self.index]
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
Code:
class Window_Enchant_Right < Window_Selectable
def initialize(ore_list)
@ore_list = ore_list
super(0, 0, 320,200)
self.contents = Bitmap.new(width - 32, height - 32)
self.index = 0
#@item_first_ore = 101
#@item_last_ore = 130
@data = @ore_list
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
self.contents.font.name = "Arial"
self.contents.font.size = 22
item = @data[index]
number = $game_party.item_number(item.id)
x = 4
y = index * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def item
return @data[self.index]
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
Code:
class Window_Enchant_Bottom < Window_Base
attr_reader :stats
def initialize
super(0, 0, 640,230)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
@stats = []
refresh
end
def update_stats(ary)
@stats = ary
refresh
end
def refresh
self.contents.clear
self.contents.font.color = text_color(6)
self.contents.font.size = 16
self.contents.font.bold = false
self.contents.draw_text(0, 0, 200, 16, stats[11].to_s, 1)
text = [stats[8].to_s, stats[9].to_s, stats[10].to_s, "Weight :",
"Str Bonus :", "Vit Bonus :", "Int Bonus :"]
@y = 20
for i in 0...7
self.contents.font.color = system_color
self.contents.draw_text(-50, @y, 160, 20, text[i], 2)
self.contents.font.color = normal_color
self.contents.draw_text(112, @y, 30, 20, @stats[i].to_s)
@y += 20
end
end
def draw_improve(stats, elements, states,weapon)
self.contents.clear
self.contents.font.color = text_color(6)
self.contents.font.size = 16
refresh
@upgrade = stats
@y = 20
for i in 0...7
self.contents.font.color = system_color
self.contents.draw_text(175,@y,20,20,"->")
if(weapon)
self.contents.draw_text(200,@y,30,20,(@upgrade[i] + @stats[i]).to_s)
else
self.contents.draw_text(200,@y,30,20,(@upgrade[i+10] + @stats[i]).to_s)
end
@y += 20
end
#Attribute drawing should work up to 18 elements
@attr = elements
@y = 20
@x = 250
self.contents.draw_text(250,0,100,16,"Attributes")
self.contents.font.color = text_color(1)
continue = true
for i in 0...$data_system.elements.size
for j in 0...@attr.size
if(@attr[j] == (i+1))
self.contents.font.color = text_color(2)
continue = false
else
if(continue)
self.contents.font.color = text_color(1)
end
end
end
self.contents.draw_text(@x,@y,50,20,$data_system.elements[i+1].to_s)
@y += 20
continue = true
if(@y >= 200)
@x += 75
@y = 20
end
end
#States Drawing should work up to 18 states
self.contents.font.color = system_color
self.contents.draw_text(450,0,100,16,"Status Effects")
self.contents.font.color = text_color(1)
@y = 20
@x = 450
continue = true
for i in 0...($data_states.size - 1)
for j in 0...states.size
if(states[j] == (i+1))
self.contents.font.color = text_color(2)
continue = false
else
if(continue)
self.contents.font.color = text_color(1)
end
end
end
self.contents.draw_text(@x,@y,50,20,$data_states[i + 1].name)
@y += 20
if(@y >= 200)
@x += 75
@y = 20
end
continue = true
end
end
end