This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
This is a forging system that actually creates a new weapon rather than mixing ingredients to form item from a predefined list. You'll notice the scripts are somewhat commented. I'm lazy right now and don't feel like commenting the rest. This script is (to the best of my knowledge) bug free. Any errors received are most likely unrelated. :alright: To the best of my knowedge......
def update
@metals_window.update
@gems_window.update
@stats_window.update
@help_window.update
@component_windows.update
if @metals_window.active
update_metals
return
end
if @gems_window.active
update_gems
return
end
if @input_window.active
update_input
return
end
end
def update_input
input = @input_window.input
if Input.trigger?(Input::cool.gif
comp1 = @component_windows.comp1
comp2 = @component_windows.comp2
comp3 = @component_windows.comp3
$game_system.se_play($data_system.cancel_se)
@component_windows.item_recovery(comp1, comp2, comp3)
$scene = Scene_Map.new
return
end
if Reeble_Deeble.input($V_0)
if @shift == 1
input += ")"
else
input += "0"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_1)
if @shift == 1
input += "!"
else
input += "1"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_2)
if @shift == 1
input += "@"
else
input += "2"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_3)
if @shift == 1
input += "#"
else
input += "3"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_4)
if @shift == 1
input += "$"
else
input += "4"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_5)
if @shift == 1
input += "%"
else
input += "5"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_6)
if @shift == 1
input += "^"
else
input += "6"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_7)
if @shift == 1
input += "&"
else
input += "7"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_8)
if @shift == 1
input += "*"
else
input += "8"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_9)
if @shift == 1
input += "("
else
input += "9"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_A)
if @shift == 1
input += "A"
else
input += "a"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_B)
if @shift == 1
input += "B"
else
input += "b"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_C)
if @shift == 1
input += "C"
else
input += "c"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_D)
if @shift == 1
input += "D"
else
input += "d"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_E)
if @shift == 1
input += "E"
else
input += "e"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_F)
if @shift == 1
input += "F"
else
input += "f"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_G)
if @shift == 1
input += "G"
else
input += "g"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_H)
if @shift == 1
input += "H"
else
input += "h"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_I)
if @shift == 1
input += "I"
else
input += "i"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_J)
if @shift == 1
input += "J"
else
input += "j"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_K)
if @shift == 1
input += "K"
else
input += "k"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_L)
if @shift == 1
input += "L"
else
input += "l"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_M)
if @shift == 1
input += "M"
else
input += "m"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_N)
if @shift == 1
input += "N"
else
input += "n"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_O)
if @shift == 1
input += "O"
else
input += "o"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_P)
if @shift == 1
input += "P"
else
input += "p"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_Q)
if @shift == 1
input += "Q"
else
input += "q"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_R)
if @shift == 1
input += "R"
else
input += "r"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_S)
if @shift == 1
input += "S"
else
input += "s"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_T)
if @shift == 1
input += "T"
else
input += "t"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_U)
if @shift == 1
input += "U"
else
input += "u"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_V)
if @shift == 1
input += "V"
else
input += "v"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_W)
if @shift == 1
input += "W"
else
input += "w"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_X)
if @shift == 1
input += "X"
else
input += "x"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_Y)
if @shift == 1
input += "Y"
else
input += "y"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_Z)
if @shift == 1
input += "Z"
else
input += "z"
end
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_SPACE)
input += " "
@shift = 0
@input_window.refresh(input)
return
end
if Reeble_Deeble.input($V_L_SHIFT) or Reeble_Deeble.input($V_R_SHIFT)
if @shift == 0
@shift = 1
else
@shift = 0
end
end
if Reeble_Deeble.input($V_BKSPC)
array = input.scan(/./)
array.pop
input = array.to_s
@shift = 0
@input_window.refresh(input)
end
if Input.trigger?(Input::C)
if @type == 1
unless input != ""
$game_system.se_play($data_system.buzzer_se)
return
end
@name = input
@input_window.dispose
@input_window = Window_Input.new("Description :")
@input_window.x = 54
@input_window.y = 122
@input_window.z = 301
@input_window.opacity = 0
@type = 2
else
@description = input
factor(@schlichy)
if @forge.include?("failure")
fail
else
score
end
end
end
end
def factor(stats)
@forge = []
weapon_success = $game_variables[2]
encrust_success = $game_variables[3]
smith_rate = 100 - (100 * ($game_variables[529] / 10000.to_f)).to_i
if weapon_success < smith_rate
@forge.push("failure")
return
end
for i in 5...11
if stats[i] > 0
encrust_rate = 10000 - ((20 * stats[i]) * ($game_variables[540] * (500 / 50000.to_f)).to_i)
if encrust_success < encrust_rate
@forge.push("failure")
return
end
end
end
@piffle = [] # piffle is setting up the weapon's element set
if stats[5] > 0 #Fire
@piffle.push(1)
end
if stats[6] > 0 #Water
@piffle.push(4)
end
if stats[7] > 0 #Air
@piffle.push(6)
end
if stats[8] > 0 #Earth
@piffle.push(5)
end
if stats[9] > 0 #Light
@piffle.push(7)
end
if stats[10] > 0 #Darkness
@piffle.push(8)
end
if stats[11] > 0 #Ethereal
@piffle.push(3)
end
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
case @itemtype
when 0 # this section set metals
for i in 40...59 # 40 is first metal id, 59 is last
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
when 1 # this section set gems
for i in 60...90 # 60 is first metal id, 90 is last
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = 18
self.contents.font.color = normal_color
self.contents.font.bold = false
for i in 0...@item_max
draw_item(i)
end
end
end
# Set Enemy
#*******************************************************************************
def set_enemy(enemy)
text = enemy.name
state_text = make_battler_state_text(enemy, 112, false)
if state_text != ""
text += " " + state_text
end
set_text(text, 1)
end
end
def add_comp1(item)
@comp1.push(item)
if @comp1.size > 3
@comp1.pop
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
$game_party.lose_item(item.id, 1)
end
refresh
end
def del_comp1
if @comp1.size > 0
$game_system.se_play($data_system.decision_se)
@comp1.pop
else
$game_system.se_play($data_system.buzzer_se)
end
refresh
end
def add_comp2(item)
@comp2.push(item)
if @comp2.size > 3
@comp2.pop
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
$game_party.lose_item(item.id, 1)
end
refresh
end
def del_comp2
if @comp2.size > 0
$game_system.se_play($data_system.decision_se)
@comp2.pop
else
$game_system.se_play($data_system.buzzer_se)
end
refresh
end
def add_comp3(item)
@comp3.push(item)
if @comp3.size > 7
@comp3.pop
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
$game_party.lose_item(item.id, 1)
end
refresh
end
def del_comp3
if @comp3.size > 0
$game_system.se_play($data_system.decision_se)
@comp3.pop
else
$game_system.se_play($data_system.buzzer_se)
end
refresh
end
self.contents.font.size = 16
if @comp1.size > 0
y = 22
n = 1
for i in 0...@comp1.size
num = n.to_s + "."
self.contents.font.color = system_color
self.contents.draw_text(4, y, 10, 20, num)
self.contents.font.color = normal_color
self.contents.draw_text(14, y, 155, 20, @comp1[i].name)
y += 20
n += 1
end
end
if @comp2.size > 0
y = 106
n = 1
for i in 0...@comp2.size
num = n.to_s + "."
self.contents.font.color = system_color
self.contents.draw_text(4, y, 10, 20, num)
self.contents.font.color = normal_color
self.contents.draw_text(14, y, 155, 20, @comp2[i].name)
y += 20
n += 1
end
end
if @comp3.size > 0
y = 22
n = 1
for i in 0...@comp3.size
num = n.to_s + "."
self.contents.font.color = system_color
self.contents.draw_text(159, y, 10, 20, num)
self.contents.font.color = normal_color
self.contents.draw_text(169, y, 155, 20, @comp3[i].name)
y += 20
n += 1
end
end
end
def item_recovery(comp1, comp2, comp3)
@comp1 = comp1
@comp2 = comp2
@comp3 = comp3
if @comp1.size > 0
for i in 0...@comp1.size
$game_party.gain_item(@comp1[i].id, 1)
end
end
if @comp2.size > 0
for i in 0...@comp2.size
$game_party.gain_item(@comp2[i].id, 1)
end
end
if @comp3.size > 0
for i in 0...@comp3.size
$game_party.gain_item(@comp3[i].id, 1)
end
end
end
@y = 40
for i in 5...12
if @stats[i] > 5
@stats[i] = 5
end
if @stats[i] <= 0
@stats[i] = 0
attribute = ""
end
if @stats[i] == 1
attribute = "E"
end
if @stats[i] == 2
attribute = "D"
end
if @stats[i] == 3
attribute = "C"
end
if @stats[i] == 4
attribute = "B"
end
if @stats[i] == 5
attribute = "A"
end
self.contents.font.color = system_color
self.contents.draw_text(70, @y, 160, 20, text[i], 2)
self.contents.font.color = normal_color
self.contents.draw_text(235, @y, 30, 20, attribute)
@y += 20
end
That's it for the system. If you want to be able to save the weapon (which I'm sure you would), read the next post.
Saving Changes
Scene_File
Code:
def update
# ウィンドウを更新
@help_window.update
for i in @savefile_windows
i.update
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# メソッド on_decision (継承先で定義) を呼ぶ
on_decision(make_filename(@file_index), make_weaponfile(@file_index), make_classfile(@file_index))
$game_temp.last_file_index = @file_index
return
end
# B ボタンが押された場合...........blahblahblah
#--------------------------------------------------------------------------
# ● ファイル名の作成
# file_index : セーブファイルのインデックス (0~3)
#--------------------------------------------------------------------------
def make_filename(file_index)
return "Save#{file_index + 1}.rxdata"
end
def make_weaponfile(file_index)
return "Weapons#{file_index + 1}.rxdata"
end
def make_classfile(file_index)
return "Classes#{file_index + 1}.rxdata"
end
end
For the saving changes, you don't need to copy and paste the whole thing. Just make the changes indicated in red.
The coding can be a little cleaner, but this is only v1. I still have a lot I want to add to this, but this is a working (and I'm pretty sure bug-free) sample that does all of the NECESSARY functions. Anything else I add is just gravy.
Yes, you'll notice the file is encrypted. The scripts are right here though. Nothing else you need in there. :alright: