Kain Nobel
Member
Today, I bring to you a script in progress. I will be posting my code for public review so hopefully somebody with a trained eye will be able to detect any possible error in judgement or conduct on my part, or give me advice on what I am trying to do. Although there maybe no questions at the moment, I will later be posting questions and asking for comments, so I can learn how to better script.
Although this will be first public script here at .org, I have made a few little things here and there, this is my first 'real' full scene script, so I will need some help later on with... whatever the hell I get stumped on, but I'm rockin' steady for the time being. For now, I am pasting the script as-is, meaning it is unfinished and subject to change. Matter of fact, the Window_ stuff isn't even done, so this script is currently useless.
Keep in mind this is a script in progress, and will later be a part of my custom CMS in the (not so...) near future. When I am finally done with this, with all of your help and support, I want this to be my first 'REAL' script to post in the submitted scripts forum :D
So, what does it do?
It is an "Alchemy" script. You will be able to set up Items (with special 'elemental' attributes), and fuse and bind them together to create better, or even rare items. It was inspired by Deke's crafting script, and the Materia Fusion system from Crisis Core. With it you can fuse items, weapons, and different 'armor' types to create new ones. For anybody familiar with Deke's script, it will come with a seperate "Recipe" class which is a public class for you to write your recipes. Each recipe has a Fusion Point cost to it, but you can also Convert your items into FP and... you'll just have to see when its done.
Although this will be first public script here at .org, I have made a few little things here and there, this is my first 'real' full scene script, so I will need some help later on with... whatever the hell I get stumped on, but I'm rockin' steady for the time being. For now, I am pasting the script as-is, meaning it is unfinished and subject to change. Matter of fact, the Window_ stuff isn't even done, so this script is currently useless.
Keep in mind this is a script in progress, and will later be a part of my custom CMS in the (not so...) near future. When I am finally done with this, with all of your help and support, I want this to be my first 'REAL' script to post in the submitted scripts forum :D
So, what does it do?
It is an "Alchemy" script. You will be able to set up Items (with special 'elemental' attributes), and fuse and bind them together to create better, or even rare items. It was inspired by Deke's crafting script, and the Materia Fusion system from Crisis Core. With it you can fuse items, weapons, and different 'armor' types to create new ones. For anybody familiar with Deke's script, it will come with a seperate "Recipe" class which is a public class for you to write your recipes. Each recipe has a Fusion Point cost to it, but you can also Convert your items into FP and... you'll just have to see when its done.
Code:
class Recipe
def initialize
#[Attribute Readers]--------------------------------------------------------
attr_reader :id # Recipe's ID name
attr_reader :ingredients # Different Items used in fusion.
attr_reader :quantity # How Many of Each Item used, required.
attr_reader :fusion_item # New Item created with Alchemy.
attr_reader :fusion_quant # How Many of Each new Item is created.
attr_reader :fp_cost # Fusion Points required to Alchemize.
#---------------------------------------------------------------------------
def initialize
@id = nil
@ingredients = []
@quantity = []
@fusion_item = []
@fusion_quant = []
@fp_cost = 0
end
#--------------------
# * Define Recipe ID
#--------------------
def @id
if id <= -1
id = 0
end
end
#---------------------
# * Define Ingredients
#---------------------
def ingredients
@ingredients = []
end
#----------------------
# * Define Quantity Req
#----------------------
def quantity
@quantity = $data_items[i].quantity
end
#blah
end
end
#===============================================================================
# * Scene_Alchemy
#===============================================================================
# Written by: Kain Nobel
# Version: 0.1
# Last Update: 5/6/2008
# Date Created: 5/6/2008
#===============================================================================
class Scene_Alchemy
#[Attribute Accessors]--------------------------------------------------------
attr_accessor :recipe # ID of recipe on lista
attr_accessor :description # Description of recipe
attr_accessor :ingredients # Items to be used in recipe
attr_accessor :quantities # Number of each ingredient to be used
attr_accessor :result # Item made from alchemy
attr_accessor :result_quant # Quantity of item made
attr_accessor :fp_cost # How much it costs to fuse items
#-----------------------------------------------------------------------------
# * Initialization Method
#------------------------
def initialize#[recipe_index, alchemy_index]
# Recipe and Alchemy index are set to default position
@recipe_index = 0
@alchemy_index = -1
# Gets learned Game Party recipies
@recipes = $game_party.recipes
# Determines your Fusion Points
@fp = $game_party.fusion_points
# Access the 'main' method
main
end
#--------------
# * Main Method
#--------------
def main
# Create Window_Recipe
@window_recipe = Window_Recipe.new
@window_recipe.x = 0
# Create Window Alchemy
@window_alchemy = Window_Alchemy.new
@window_alchemy.x = 321
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@window_recipe.dispose
@window_alchemy.dispose
update
end
#----------------
# * Update Method
#----------------
def update
# Update Window_Recipe
if @window_recipe.active
update_recipe
return
end
# Update Window_Alchemy
if @window_alchemy.active
update_alchemy
return
end
end
#----------------
# * Update Recipe
#----------------
def update_recipe
# Selection: Activates Window_Alchemy
if Input.press?(Input::C)
$game_system.play_se($game_system.decision_se)
@window_recipe.active = false
@window_alchemy.active = true
@window_alchemy.index = 0
end
# Cancel: Exits the menu
if Input.press?(Input::B)
$game_system.play_se($game_system.cancel_se)
@window_recipe.active = false
@window_recipe.index = 0
@window_alchemy.active = false
@window_alchemy.index = 0
$scene = Scene_Map.new
end
end
#-----------------
# * Update Alchemy
#-----------------
def update_alchemy
# Selection: Pick first item
if Input.press?(Input::C) & @alchemy_index >= 0
# If no items exist
if $data_items.index = nil
# Play Buzzer SE
$game_system.se_play($game_system.buzzer_se)
else # If items DO exist
#Play Decision SE
$game_system.se_play($game_system.decision_se)
# If Fuse01 Item hasn't been selected
if @fuse01 == nil
@fuse01 = fusion01.item
elsif @fuse02 == nil
@fuse02 = fusion02.item
else
fuse_items
end #fusion process
end #detecting items
end #picking item
end #of method
#-----------------
# * Update Recipe
#-----------------
def update_recipe
# Selection: Pick a recipe
if Input.press?(Input::C) && @recipe_index >= 0
# If no recipes exist
if $game_party.learned_recipes == nil
# Play Buzzer SE
$game_system.se_play($game_system.buzzer_se)
else
@recipe_index = recipe_index
@fusion01 = @recipe_index.fusion01
@fusion02 = @recipe_index.fusion02
if @recipe_index.fuse01 == @fusion01 && @recipe_index.fuse02 == @fusion02
# Play Decision SE
$game_system.se_play($game_system.decision_se)
# Creates new item
create_new_item
return
else
# Play Buzzer SE
$game_system.se_play($game_system.buzzer_se)
# Print Text String
fusion_invalid_string
return
end
end
end
end
#------------------
# * Create New Item
#------------------
def create_new_item
$game_party.lose_item[@fusion01, @quantity01]
$game_party.lose_item[@fusion02, @quantity02]
$game_party.gain_item[@fusion_item, @fusion_quant]
$game_party.sp_change -= $recipe[i].fp_cost
end
end