09-26-2005, 01:00 PM
(This post was last modified: 08-01-2017, 03:47 AM by DerVVulfman.)
Made from Four posts chained together
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......
The scripts:
There's more coming. My internet keeps dropping.
Still More.....
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.
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:
Now my pic host is down. What a night.
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.
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......
The scripts:
Scene_Forge_Weapon
Code:
#*************************************
******************************************
# Scene_Forge
#*******************************************************************************
# Forge System by Spiritus
#*******************************************************************************
class Scene_Forge_Weapon
#*******************************************************************************
# Initialize
#*******************************************************************************
def initialize(menu_index = 0)
@menu_index = menu_index
@window = 1
@shift = 0
@actor = $game_party.actors[0]
end
#*******************************************************************************
# Main
#*******************************************************************************
def main
@spriteset = Spriteset_Map.new # shows map behind
#*******************************************************************************
@bg = Sprite.new
@bg.bitmap = RPG::Cache.picture("mnu_forge.png")
@bg.x = 10
@bg.y = 10
@bg.z = 100
@bg.opacity = 224 # main forge background
#*******************************************************************************
@cursor = Sprite.new
@cursor.bitmap = RPG::Cache.picture("mnu_cursor.png")
@cursor.x = 318
@cursor.y = 276
@cursor.z = 200 # active workspace cursor
#*******************************************************************************
@help_window = Window_Menu_Help.new
@help_window.x = 4
@help_window.y = 226
@help_window.opacity = 0
#*******************************************************************************
@metals_window = Window_Forge.new(0)
@metals_window.x = -3
@metals_window.y = 49
@metals_window.opacity = 0
@metals_window.index = @menu_index
@metals_window.help_window = @help_window
#*******************************************************************************
@gems_window = Window_Forge.new(1)
@gems_window.x = 307
@gems_window.y = 49
@gems_window.opacity = 0
@gems_window.active = false
@gems_window.help_window = @help_window
#*******************************************************************************
@stats_window = Window_Forge_Stats.new
@stats_window.x = 4
@stats_window.y = 254
@stats_window.opacity = 0
#*******************************************************************************
@headers_window = Window_Forge_Headers.new("Weapon Forging", "Raw Metals", "Raw Gems")
@headers_window.x = 4
@headers_window.y = 0
@headers_window.opacity = 0
#*******************************************************************************
@component_windows = Window_Forge_Components.new("Blade", "Hilt", "Encrusted Gems")
@component_windows.x = 307
@component_windows.y = 254
@component_windows.opacity = 0
#*******************************************************************************
@input_window = Window_Input.new("Name :")
@input_window.x = 54
@input_window.y = 122
@input_window.z = 301
@input_window.opacity = 0
@input_window.active = false
@input_window.visible = false
@type = 1 # hidden input window
#*******************************************************************************
@input_bg = Sprite.new
@input_bg.bitmap = RPG::Cache.picture("mnu_input.png")
@input_bg.x = 60
@input_bg.y = 120
@input_bg.z = 300
@input_bg.opacity = 0 # hidden input window background
#*******************************************************************************
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@spriteset.dispose
@bg.dispose
@help_window.dispose
@metals_window.dispose
@gems_window.dispose
@stats_window.dispose
@headers_window.dispose
@component_windows.dispose
@cursor.dispose
@input_window.dispose
@input_bg.dispose
end
#*******************************************************************************
# Update
#*******************************************************************************
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
#*******************************************************************************
# Update Metals
#*******************************************************************************
def update_metals
if Input.trigger?(Input::cool.gif
comp1 = @component_windows.comp1
comp2 = @component_windows.comp2
comp3 = @component_windows.comp3
@component_windows.item_recovery(comp1, comp2, comp3)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
if Input.trigger?(Input::C)
if @window == 1
update_stats(0)
@metals_window.refresh
return
end
if @window == 2
update_stats(0)
@metals_window.refresh
return
end
end
if Reeble_Deeble.input($V_TAB) # Reeble_Deeble is a custom input module
@window += 1
$game_system.se_play($data_system.cursor_se)
if @window == 3
@gems_window.active = true
@metals_window.active = false
end
update_cursor
return
end
if Reeble_Deeble.input($V_L_SHIFT) or Reeble_Deeble.input($V_R_SHIFT)
comp1 = @component_windows.comp1
comp2 = @component_windows.comp2
unless comp1.size > 0 and comp2.size > 0
$game_system.se_play($data_system.cancel_se)
return
end
unless @schlichy[4] < @actor.sp
$game_system.se_play($data_system.buzzer_se)
if $game_temp.message_text != nil
return false
end
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
$game_temp.message_text = "You don't have enough SP to forge this weapon."
$scene = Scene_Map.new
end
@input_window.active = true
@input_window.visible = true
@metals_window.active = false
@input_bg.opacity = 255
return
end
if Reeble_Deeble.input($V_BKSPC)
if @window == 1
update_stats(nil)
@metals_window.refresh
else
update_stats(nil)
@metals_window.refresh
end
end
end
#*******************************************************************************
# Update Gems
#*******************************************************************************
def update_gems
if Input.trigger?(Input::cool.gif
comp1 = @component_windows.comp1
comp2 = @component_windows.comp2
comp3 = @component_windows.comp3
@component_windows.item_recovery(comp1, comp2, comp3)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
if Input.trigger?(Input::C)
update_attr(0)
@gems_window.refresh
return
end
if Reeble_Deeble.input($V_TAB)
@window = 1
$game_system.se_play($data_system.cursor_se)
@metals_window.active = true
@gems_window.active = false
update_cursor
return
end
if Reeble_Deeble.input($V_L_SHIFT) or Reeble_Deeble.input($V_R_SHIFT)
comp1 = @component_windows.comp1
comp2 = @component_windows.comp2
unless comp1.size > 0 and comp2.size > 0
$game_system.se_play($data_system.cancel_se)
return
end
unless @schlichy[4] < @actor.sp
$game_system.se_play($data_system.buzzer_se)
if $game_temp.message_text != nil
return false
end
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
$game_temp.message_text = "You don't have enough SP to forge this weapon."
$scene = Scene_Map.new
end
@input_window.active = true
@input_window.visible = true
@gems_window.active = false
@input_bg.opacity = 255
return
end
if Reeble_Deeble.input($V_BKSPC)
update_attr(nil)
@gems_window.refresh
end
end
#*******************************************************************************
# Update Stats
#*******************************************************************************
def update_stats(check)
item = @metals_window.item
stats = @stats_window.stats
if check != nil
if @window == 1
array = @component_windows.comp1
if array.size == 3
$game_system.se_play($data_system.cancel_se)
return
else
if item != nil
@component_windows.add_comp1(item)
else
$game_system.se_play($data_system.cancel_se)
return
end
end
end
if @window == 2
array = @component_windows.comp2
if array.size == 3
$game_system.se_play($data_system.cancel_se)
return
else
if item != nil
@component_windows.add_comp2(item)
else
$game_system.se_play($data_system.cancel_se)
return
end
end
end
#Durability
if @window == 1
stats[0] += item.hit
else
stats[0] += item.mdef_f
end
#Weight
stats[1] += item.pdef_f
#Encrust Points
if @window == 2
stats[2] += item.variance
end
#Price
stats[3] += item.price
#Forge Cost
stats[4] += item.recover_sp
else
if @window == 1
unless @component_windows.comp1.size > 0
$game_system.se_play($data_system.buzzer_se)
return
end
item = @component_windows.comp1[-1]
@component_windows.rem_comp1
else
unless @component_windows.comp2.size > 0
$game_system.se_play($data_system.buzzer_se)
return
end
item = @component_windows.comp2[-1]
@component_windows.rem_comp2
end
if @window == 1
stats[0] -= item.hit
else
stats[0] -= item.mdef_f
end
stats[1] -= item.pdef_f
if @window == 2
stats[2] -= item.variance
end
stats[3] -= item.price
stats[4] -= item.recover_sp
end
@stats_window.update_stats(stats)
@schlichy = stats
end
#*******************************************************************************
# Update Attributes
#*******************************************************************************
def update_attr(check)
item = @gems_window.item
stats = @stats_window.stats
if check != nil
array = @component_windows.comp3
if array.size == 7
$game_system.se_play($data_system.cancel_se)
return
end
if item != nil
@component_windows.add_comp3(item)
else
$game_system.se_play($data_system.cancel_se)
return
end
#Encrust Pts
stats[2] -= item.hit
if stats[2] < 0
$game_system.se_play($data_system.cancel_se)
stats[2] = 0
return
end
#Price
stats[3] += item.price
#Cast Cost
stats[4] += item.parameter_points
#Fire
stats[5] += item.recover_hp_rate
#Water
stats[6] += item.recover_sp_rate
#Air
stats[7] += item.recover_sp
#Earth
stats[8] += item.pdef_f
#Light
stats[9] += item.mdef_f
#Darkness
stats[10] += item.variance
#Ethereal
stats[11] += item.recover_hp
else
unless @component_windows.comp3.size > 0
$game_system.se_play($data_system.buzzer_se)
return
end
item = @component_windows.comp3[-1]
@component_windows.rem_comp3
stats[2] += item.hit
stats[3] -= item.price
stats[4] -= item.parameter_points
if item.recover_hp_rate > 0
stats[5] -= item.recover_hp_rate
else
stats[5] += item.recover_hp_rate
end
if item.recover_sp_rate > 0
stats[6] -= item.recover_sp_rate
else
stats[6] += item.recover_sp_rate
end
if item.recover_sp > 0
stats[7] -= item.recover_sp
else
stats[7] += item.recover_sp
end
if item.pdef_f > 0
stats[8] -= item.pdef_f
else
stats[8] += item.pdef_f
end
if item.mdef_f > 0
stats[9] -= item.mdef_f
else
stats[9] += item.mdef_f
end
if item.variance > 0
stats[10] -= item.variance
else
stats[10] += item.variance
end
if item.recover_hp > 0
stats[11] -= item.recover_hp
else
stats[11] += item.recover_hp
end
end
@stats_window.update_stats(stats)
@schlichy = stats
end
#*******************************************************************************
# Update Cursor
#*******************************************************************************
def update_cursor
case @window
when 1
@cursor.x =318
@cursor.y =276
when 2
@cursor.y = 362
when 3
@cursor.x = 474
@cursor.y = 276
end
end
#*******************************************************************************
# Update Input
#*******************************************************************************
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
#*******************************************************************************
# Factor
#*******************************************************************************
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
#*******************************************************************************
# Score
#*******************************************************************************
def score
ingywat = 1
for i in 1...$data_weapons.size
if $data_weapons[i].name != ""
ingywat +=1
end
end
if ingywat <= $data_weapons.size - 1
$data_weapons[ingywat].name = @name
$data_weapons[ingywat].icon_name = ""
$data_weapons[ingywat].description = @description
$data_weapons[ingywat].animation1_id = 0
$data_weapons[ingywat].animation2_id = 0
$data_weapons[ingywat].price = @schlichy[3]
$data_weapons[ingywat].atk = @schlichy[0]
$data_weapons[ingywat].agi_plus = 0 - @schlichy[1]
$data_weapons[ingywat].element_set = @piffle
$data_weapons[ingywat].plus_state_set = []
$data_weapons[ingywat].minus_state_set = []
$game_party.gain_weapon(ingywat, 1)
for i in 1...$data_classes.size
$data_classes[i].weapon_set.push(ingywat)
end
$game_party.actors[0].sp -= @schlichy[4]
$scene = Scene_Map.new
else
if $game_temp.message_text != nil
return false
end
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
$game_temp.message_text = "You cannot create any more weapons."
@component_windows.item_recovery(comp1, comp2, comp3)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
end
#*******************************************************************************
# Fail
#*******************************************************************************
def fail
if $game_temp.message_text != nil
return false
end
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
$game_temp.message_text = "You were unable to create the weapon."
$scene = Scene_Map.new
end
end
Reeble_Deeble
This is the input module. Place it at the TOP of your scripts.
Code:
#*****************************************************************
**************
# Reeble_Deeble
#*******************************************************************************
module Reeble_Deeble
#*******************************************************************************
# Virtual KeyCode
#*******************************************************************************
$V_0 = 0x30 # Numbers
$V_1 = 0x31 #*******************************************************
$V_2 = 0x32
$V_3 = 0x33
$V_4 = 0x34
$V_5 = 0x35
$V_6 = 0x36
$V_7 = 0x37
$V_8 = 0x38
$V_9 = 0x39
#*******************************************************************************
$V_A = 0x41 # Letters
$V_B = 0x42 #*******************************************************
$V_C = 0x43
$V_D = 0x44
$V_E = 0x45
$V_F = 0x46
$V_G = 0x47
$V_H = 0x48
$V_I = 0x49
$V_J = 0x4A
$V_K = 0x4B
$V_L = 0x4C
$V_M = 0x4D
$V_N = 0x4E
$V_O = 0x4F
$V_P = 0x50
$V_Q = 0x51
$V_R = 0x52
$V_S = 0x53
$V_T = 0x54
$V_U = 0x55
$V_V = 0x56
$V_W = 0x57
$V_X = 0x58
$V_Y = 0x59
$V_Z = 0x5A
#*******************************************************************************
$V_F1 = 0x70 # Functions
$V_F2 = 0x71 #*******************************************************
$V_F3 = 0x72
$V_F4 = 0x73
$V_F5 = 0x74
$V_F6 = 0x75
$V_F7 = 0x76
$V_F8 = 0x77
$V_F9 = 0x78
$V_F10 = 0x79
$V_F11 = 0x7A
$V_F12 = 0x7B
#*******************************************************************************
$V_BKSPC = 0x08 # Others
$V_TAB = 0x09 #*******************************************************
$V_ENTER = 0x0D
$V_SHIFT = 0x10
$V_ESCAPE = 0x1B
$V_SPACE = 0x20
$V_LEFT = 0x25
$V_UP = 0x26
$V_RIGHT = 0x27
$V_DOWN = 0x28
$V_INSERT = 0x2D
$V_DELETE = 0x2E
$V_L_SHIFT = 0xA0
$V_R_SHIFT = 0xA1
$V_L_CONTROL = 0xA2
$V_R_CONTROL = 0xA3
$V_L_ALT = 0xA4
$V_R_ALT = 0xA5
$V_COMMA = 0xBC
$V_DASH = 0xBD
$V_PERIOD = 0xBE
#*******************************************************************************
# Keystates
#*******************************************************************************
GetKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
GetKeyboardState = Win32API.new("user32","GetKeyState",['i'],'i')
GetSetKeyState = Win32API.new("user32","SetKeyboardState",['i'],'i')
module_function
#*******************************************************************************
# Keyboard
#*******************************************************************************
def input(v_key)
if v_key == nil
return
else
GetKeyState.call(v_key) & 0x01 == 1
end
end
#*******************************************************************************
# Key
#*******************************************************************************
def key(v_key, key = 0)
GetKeyboardState.call(v_key) & 0x01 == key
end
end
Window_Forge_Items
Code:
#*********************************************
**********************************
# Window_Forge
#*******************************************************************************
class Window_Forge < Window_Selectable
#*******************************************************************************
# Initialize
#*******************************************************************************
def initialize(itemtype)
super(0, 0, 336, 190)
self.contents = Bitmap.new( width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@itemtype = itemtype
@column_max = 1
refresh
self.index = 0
end
#*******************************************************************************
# Item
#*******************************************************************************
def item
return @data[self.index]
end
#*******************************************************************************
# Refresh
#*******************************************************************************
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
#*******************************************************************************
# Draw Item
#*******************************************************************************
def draw_item(index)
item = @data[index]
number = $game_party.item_number(item.id)
self.contents.font.color = normal_color
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+24, y+6, 212, 20, item.name, 0)
self.contents.draw_text(x + 160, y+6, 16, 20, ":", 1)
self.contents.draw_text(x + 176, y+6, 24, 20, number.to_s, 2)
end
#*******************************************************************************
# Update Help
#*******************************************************************************
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
Window_Forge_Headers
I made this a separate window so that I can expand the system later:
Code:
]#*******************************************************************************
# Window_Forge_Headers
#*******************************************************************************
class Window_Forge_Headers < Window_Base
#*******************************************************************************
# Initialize
#*******************************************************************************
def initialize(header1, header2, header3)
super(0, 0, 640, 200)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = 16
@text1 = header1
@text2 = header2
@text3 = header3
refresh
end
#*******************************************************************************
# Refresh
#*******************************************************************************
def refresh
self.contents.clear
self.contents.font.color = text_color(6)
self.contents.draw_text(-20, 0, 640, 20, @text1, 1)
self.contents.font.size = 14
self.contents.draw_text(-10, 28, 320, 20, @text2, 1)
self.contents.draw_text(300, 28, 320, 20, @text3, 1)
end
end
Window_Menu_Help
Custom Help Window for later changes:
Code:
#*****************************************************************
**************
# Window_Menu_Help
#*******************************************************************************
class Window_Menu_Help < Window_Base
#*******************************************************************************
# Initialize
#*******************************************************************************
def initialize
super(0, 0, 640, 100)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = 14
end
#*******************************************************************************
# Set Text
#*******************************************************************************
def set_text(text, align = 0)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 600, 20, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
#*******************************************************************************
# Set Actor
#*******************************************************************************
def set_actor(actor)
if actor != @actor
self.contents.clear
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
draw_actor_hp(actor, 284, 0)
draw_actor_sp(actor, 460, 0)
@actor = actor
@text = nil
self.visible = true
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
Window_Input
The Name and Description input window:
Code:
#*******************************************************************************
# Window_Input
#*******************************************************************************
class Window_Input < Window_Base
attr_reader :type
#*******************************************************************************
# Initialize
#*******************************************************************************
def initialize(type)
super(0, 0, 640, 100)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = 16
@type = type
@caps = 0
refresh("")
end
#*******************************************************************************
# Refresh
#*******************************************************************************
def refresh(input)
@input = input
self.contents.clear
self.contents.font.color = system_color
self.contents.font.size = 16
self.contents.draw_text(0, 0, 100, 20, @type, 2)
input += "_"
self.contents.draw_text(104, 0,500, 20, input.to_s)
end
#*******************************************************************************
# Input
#*******************************************************************************
def input
return @input
end
end
Still More.....
Window_Forge_Components
Forge Workspace windows:
Code:
#*******************************************************************************
# Window_Forge_Components
#*******************************************************************************
class Window_Forge_Components < Window_Base
#*******************************************************************************
# Readers
#*******************************************************************************
attr_reader :comp1
attr_reader :comp2
attr_reader :comp3
#*******************************************************************************
# Initialize
#*******************************************************************************
def initialize (header1, header2, header3)
super(0, 0, 360, 300)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = 14
@text1 = header1
@text2 = header2
@text3 = header3
@comp1 = []
@comp2 = []
@comp3 = []
refresh
end
#*******************************************************************************
# Component 1
#*******************************************************************************
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
#*******************************************************************************
# Component 2
#*******************************************************************************
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
#*******************************************************************************
# Component 3
#*******************************************************************************
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
#*******************************************************************************
# Refresh
#*******************************************************************************
def refresh
self.contents.clear
self.contents.font.color = text_color(6)
self.contents.font.size = 16
self.contents.draw_text(0, 2, 155, 20, @text1, 1)
self.contents.draw_text(0, 86, 155, 20, @text2, 1)
self.contents.draw_text(155, 2, 155, 20, @text3, 1)
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
#*******************************************************************************
# Item Recovery
#*******************************************************************************
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
#*******************************************************************************
# Remove Components
#*******************************************************************************
def rem_comp1
if @comp1.size > 0
$game_party.gain_item(@comp1[-1].id, 1)
@comp1.pop
refresh
else
$game_system.se_play($data_system.buzzer_se)
end
end
def rem_comp2
if @comp2.size > 0
$game_party.gain_item(@comp2[-1].id, 1)
@comp2.pop
refresh
else
@game_system.se_play($data_system.buzzer_se)
end
end
def rem_comp3
if @comp3.size > 0
$game_party.gain_item(@comp3[-1].id, 1)
@comp3.pop
refresh
else
@game_system.se_play($data_system.buzzer_se)
end
end
def comp1
return @comp1
end
def comp2
return @comp2
end
def comp3
return @comp3
end
end
Window_Forge_Stats
Code:
#*******************************************************************************
# Window_Forge_Stats
#*******************************************************************************
class Window_Forge_Stats < Window_Base
#*******************************************************************************
# Readers
#*******************************************************************************
attr_reader :stats
#*******************************************************************************
# Initialize
#*******************************************************************************
def initialize
super(0, 0, 640, 260)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = 14
@stats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
refresh
end
#*******************************************************************************
# Update Stats
#*******************************************************************************
def update_stats(ary)
@stats = ary
refresh
end
#*******************************************************************************
# Refresh
#*******************************************************************************
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, 12, 140, 20, "Forge Stats", 1)
text = ["Durability :", "Weight :", "Encrust Pts. :", "Value :",
"Forge Cost(SP) :", "Fire :", "Water :", "Air :", "Earth :",
"Light :", "Darkness :", "Ethereal :"]
@y = 40
for i in 0...5
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 += 30
end
self.contents.font.color = text_color(6)
self.contents.draw_text(154, 12, 140, 20, "Attributes", 1)
@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
draw_exp(310, 13 + 177, 282, $game_variables[529], 10000, 5, 135, 25, "BLACKSMITHING", 150)
end
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
Scene_Load
Code:
def on_decision(filename, weaponfile, classfile)
# ファイルが存在しない場合
unless FileTest.exist?(filename)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# ロード SE を演奏
$game_system.se_play($data_system.load_se)
# セーブデータの書き込み
file = File.open(filename, "rb")
read_save_data(file)
file.close
$data_weapons = load_data("#{weaponfile}")
$data_weapons = load_data("#{classfile}")
# BGM、BGS を復帰
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# マップを更新 (並列イベント実行)
$game_map.update
# マップ画面に切り替え
$scene = Scene_Map.new
end
Scene_Save
Code:
def on_decision(filename, weaponfile, classfile) # セーブ SE を演奏
$game_system.se_play($data_system.save_se)
# セーブデータの書き込み
file = File.open(filename, "wb")
weapons = File.open(weaponfile, "w+")
classes = File.open(classfile, "w+")
write_save_data(file, weapons, classes)
weapons.close
classes.close
file.close
# イベントから呼び出されている場合
if $game_temp.save_calling
# セーブ呼び出しフラグをクリア
$game_temp.save_calling = false
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
# メニュー画面に切り替え
$scene = Scene_Menu.new(4)
end
def write_save_data(file, weapons, classes)
# セーブファイル描画用のキャラクターデータを作成
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
# セーブファイル描画用のキャラクターデータを書き込む
Marshal.dump(characters, file)
# プレイ時間計測用のフレームカウントを書き込む
Marshal.dump(Graphics.frame_count, file)
# セーブ回数を 1 増やす
$game_system.save_count += 1
# マジックナンバーを保存する
# (エディタで保存するたびにランダムな値に書き換えられる)
$game_system.magic_number = $data_system.magic_number
# 各種ゲームオブジェクトを書き込む
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
Marshal.dump($data_weapons, weapons)
Marshal.dump($data_classes, classes)
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:
Now my pic host is down. What a night.