07-29-2007, 01:00 PM
(This post was last modified: 05-21-2017, 03:32 AM by DerVVulfman.)
Orb Based Skill System
ver 2.0
by El Conductor
Jul 29, 2007
This is my first script for the Creation Asylum. I call it the Orb Based Skill System.
With it, characters can learn new skills by equipping Orbs. Every Orb requires a
specified amount of MP to equip. You can create and define your own Orbs in this
script. Just copy this script and place it above the Main script.
Here is the script. Enjoy!
In this new updated version I've added a shop system to buy and sell Orbs.
ver 2.0
by El Conductor
Jul 29, 2007
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 my first script for the Creation Asylum. I call it the Orb Based Skill System.
With it, characters can learn new skills by equipping Orbs. Every Orb requires a
specified amount of MP to equip. You can create and define your own Orbs in this
script. Just copy this script and place it above the Main script.
Here is the script. Enjoy!
In this new updated version I've added a shop system to buy and sell Orbs.
Orb Skill System
Code:
#***************************************************
# Orb Based Skill System *
#***************************************************
# Author: El Conducter *
# Date: August/02/07 *
# Version: 2.0 *
#***************************************************
#----------------------------------------------------------------------------
# What it Does:
# This script allows characters to learn new skills by equipping magic Orbs.
# Equipping Orbs uses MP, which has been added for the characters. As
# the characters levels increase, so does their MP.
# Update in Version 2.0
# I have now added a shop to buy and sell Orbs. The orbs are also now
# arranged in alphabetical order rather than by ID.
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How it Works: This script is organized into 4 parts. New part in Version 2.0
#
# Part 1 defines Orbs and sets up the Orb database. The main points in Part 1 are:
#
# class Orb defines a new object (the Orb)
# - id: As its name implies it is the Orb's ID Number
# - name: The Name of the Orb
# - mp_cost: The amount of MP required to equip the Orb
# - price: How much the Orb costs
# - skills: An array of learnable skills from Orb
# - info: A discription of what the Orb does
#
# class Orbs_Data is the database where all the games Orbs
# are defined. The orbs are set up in an array and assigned to a Constant.
# - Define your Orbs within the array like so: Orb.new(id, name, mp_cost, skills, info)
#
# Part 2 consists of all the window classes and scene that deals with equipping Orbs.
# The classes that make up Part 2 are:
#
# - Scene_Equip_Orb
# - Window_EquipOrb
# - Window_RemoveOrb
# - Window_Orb_Right
# - Window_MP
# - Window_Command2
# - Window_Command3
# - Window_Help2
#
# Part 3 contains all the altered original code. classes that had to altered are:
#
# - Game_Actor
# - Game_Party
# - Window_Base
# - Scene_Menu
# - Scene_Title
# - Game_Temp New in 2.0
#
# Part 4 has all the classes that handle the buying and selling Orbs:
#
# - Scene_Orb_Shop
# - Window_Orb_Buy
# - Window_Orb_Sell
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How to Use This Script:
# Just copy it and paste it above Main.
#
# To add Orbs to your party's inventory while playing the game, use
# events Call Script function like this:
# - $game_party.gain_orb($data_orbs[X])
# Where X stands, put the id of the orb you want to add.
# Orb ID's in the Orb database start with 0 and up.
#
# To use the Shop function of this script, use events Call Script function
# like this:
# - $game_temp.shop_orbs = [$data_orbs[X], $data_orbs[X]]
# - $scene = Scene_Orb_Shop.new
# Where X stands, put the id of the orb you want to add. Just
# keep adding to the array how many orbs you want to be able
# to buy. The second line actually calls the shop itself; using the
# orbs you specified to buy.
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Modifications:
# The Orb script is fully customizable to fit the users needs. Much can be
# done with it. Possible modifications include:
# - Orbs that can effect characters attributes and elemental & status
# attack and defense.
# - Orbs that level up and gain new skills
# - Orb synthesis shop
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Comments:
# I hope my script is easy for you to use and modify. Use this script to
# learn RGSS better and become a better scriptor yourself.
#----------------------------------------------------------------------------
#******************************************************************************
# I Part One
#------------------------------------------------------------------------------
# This part deals with the construction of Orbs and sets up the Orb Database.
#******************************************************************************
#==============================================================================
# ** Orb
#------------------------------------------------------------------------------
# This class defines the Orb object.
#==============================================================================
module RPG
class Orb
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :id
attr_accessor :name
attr_accessor :mp_cost
attr_accessor :price # New in 2.0
attr_accessor :skills
attr_reader :info
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(id, name, mp_cost, price, skills = [], info = nil)
# Set parameters
@id = id
@name = name
@mp_cost = mp_cost
@price = price # New in 2.0
@skills = skills
@info = info
end
end
#==============================================================================
# ** Orb_Data
#------------------------------------------------------------------------------
# Stores all the games Orb data.
#==============================================================================
class Orbs_Data
# This is the Orb database
# Define new Orbs like so; Orb.new(id, name, mp_cost, price, skills, info)
# Put the skill ID's you want to learn in the skills array
Orb_Database = [
Orb.new(0, 'Heal', 3, 100, [1, 4], 'Bestows Heal and Remedy on user.'),
Orb.new(1, 'Hi Heal', 5, 500, [1, 2, 4, 5], 'Bestows Heal 1 & 2 & Remedy 1 & 2 and on user.'),
Orb.new(2, 'X Heal', 8, 1000, [1, 2, 3, 4, 5, 6], 'Bestows Heal 1 & 2 & Remedy 1 & 2 and Revive on user.'),
Orb.new(3, 'Fire', 2, 100, [7], 'Bestows Fire on user.'),
Orb.new(4, 'Hi Fire', 4, 500, [7, 8], 'Bestows Fire 1 & 2 on user.'),
Orb.new(5, 'X Fire', 6, 1000, [7, 8, 9], 'Bestows Fire 1, 2 , & 3 on user.'),
Orb.new(6, 'Ice', 2, 100, [10], 'Bestows Ice on user.'),
Orb.new(7, 'Hi Ice', 4, 500, [10, 11], 'Bestows Ice 1 & 2 on user.'),
Orb.new(8, 'X Ice', 6, 1000, [10, 11, 12], 'Bestows Ice 1, 2 , & 3 on user.'),
Orb.new(9, 'Light', 6, 600, [25], 'Bestows Light on user.'),
Orb.new(10, 'Dark', 6, 600, [28], 'Bestows Darkness on user.'),
Orb.new(11, 'Flare', 7, 800, [31], 'Bestows Burst on user.'),
Orb.new(12, 'Ultima', 9, 1200, [32], 'Bestows Ultima on user.'),
Orb.new(13, 'Sword', 2, 500, [57, 58], 'Bestows Sword Skills on user.'),
Orb.new(14, 'Hi Sword', 5, 1000, [57, 58, 59, 60], 'Bestows Advanced Sword Skills on user.'),
Orb.new(15, 'White', 16, 2000, [1, 2, 3, 4, 5, 6, 25, 26, 27, 54, 55], 'Bestows effects of X Heal, Hi Light, Resist Barrier on user.')
]
end
end
#******************************************************************************
# II Part Two
#------------------------------------------------------------------------------
# This part deals with the windows and scene for equipping Orbs.
#******************************************************************************
#==============================================================================
# ** Scene_Equip_Orb
#------------------------------------------------------------------------------
# This class handles equipping & unequipping Orbs.
#==============================================================================
class Scene_Equip_Orb
#--------------------------------------------------------------------------
# * Object Initialization
# actor_index : actor index
#--------------------------------------------------------------------------
def initialize(actor_index = 0)
@actor_index = actor_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get actor
@actor = $game_party.actors[@actor_index]
# Command window
s1 = 'Equip'
s2 = 'Remove'
s3 = 'Discard'
@window_choice = Window_Command3.new([s1, s2, s3])
@window_choice.active = true
# Character attributes window
@orb_right_window = Window_Orb_Right.new(@actor)
@orb_right_window.x = 368
@orb_right_window.y = 64
# Orb equip window
@window_equip_orb = Window_EquipOrb.new(@actor)
@window_equip_orb.x = 0
@window_equip_orb.y = 272
# Orb unequip window
@window_remove_orb = Window_RemoveOrb.new(@actor)
@window_remove_orb.x = 0
@window_remove_orb.y = 64
# MP cost window
@mp_window = Window_MP.new
@mp_window.x = 368
@mp_window.y = 416
# Help Window
@help_window = Window_Help2.new
@help_window.x = 0
@help_window.y = 0
@help_window.visible = false
refresh
# 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
@mp_window.dispose
@window_equip_orb.dispose
@window_remove_orb.dispose
@window_choice.dispose
@orb_right_window.dispose
@help_window.dispose
end
#--------------------------------------------------------------------------
# * Refresh Methods
#--------------------------------------------------------------------------
# Refresh equip window
def refresh
# Get Orb to equip
@gem = @window_equip_orb.gem
# If no Orbs are in stock to select, update MP cost window to nothing
if @gem == nil
# Update MP cost window to nothing
@mp_window.set_new_parameters(nil)
# Set help window text to nothing
@help_window.set_text("")
elsif @gem != nil
# Set help window text to current Orb's info
@help_window.set_text(@gem.info)
if @window_equip_orb.active
# Get currently selected Orbs MP cost
mp_need = @gem.mp_cost
# Update MP cost window
@mp_window.set_new_parameters(mp_need)
end
end
end
# Refresh unequip window
def refresh2
# Get Orb to unequip
@gem2 = @window_remove_orb.gem
# If character has no Orbs to unequip, update MP cost window to nothing
if @gem2 == nil
# Update MP cost window to nothing
@mp_window.set_new_parameters(nil)
# Set help window text to nothing
@help_window.set_text("")
elsif @gem2 != nil
# Set help window text to current Orb's info
@help_window.set_text(@gem2.info)
if @window_remove_orb.active
# Get currently selected Orbs MP cost
mp_need = @gem2.mp_cost
# Update MP cost window
@mp_window.set_new_parameters(-mp_need)
end
end
end
#--------------------------------------------------------------------------
# * Equip, Unequip, & Drop Methods
#--------------------------------------------------------------------------
# Equip Orb
def equip_orb(orb)
# Get Orb position data
index = @window_equip_orb.index
# Equip actor with Orb
@actor.get_orb(orb)
# Actor learn skill(s) from Orb
@actor.learn_orbskill(orb)
# Subtract Orb MP cost from character MP
@actor.mp -= orb.mp_cost
# Clear inventory of equiped Orb at Orb's location
$game_party.orbs.delete_at(index)
# Remake Orb equip, unequip, and attribute window contents
@orb_right_window.refresh
@window_remove_orb.refresh
@window_equip_orb.refresh
end
# Unequip Orb
def unequip_orb(orb)
# Get Orb position data
index = @window_remove_orb.index
# Add Orb back to inventory
$game_party.gain_orb(orb)
# Return actors MP
@actor.mp += orb.mp_cost
# Character will forget unequiped Orb's skill(s)
@actor.drop_orbskill(orb)
# Clear actors inventory at Orb's position
@actor.orbs_equiped.delete_at(index)
# Remake Orb equip, unequip, and attribute window contents
@orb_right_window.refresh
@window_remove_orb.refresh
@window_equip_orb.refresh
end
# Drop Orb
def trash_orb(orb)
# Get Orb position data
index = @window_equip_orb.index
# Clear inventory of equiped Orb at Orb's location
$game_party.orbs.delete_at(index)
# Remake Orb equip, unequip, and attribute window contents
@orb_right_window.refresh
@window_remove_orb.refresh
@window_equip_orb.refresh
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@mp_window.update
@window_remove_orb.update
@window_equip_orb.update
@window_choice.update
@orb_right_window.update
refresh
# If command window is active: call update_choice
if @window_choice.active
update_choice
return
end
# If the unequip Orb window is active: call update_remove_orb
if @window_remove_orb.active
update_remove_orb
return
end
# If the equip Orb window is active: call update_orb
if @window_equip_orb.active
update_orb
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_choice
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
@window_choice.active = false
@window_choice.index = -1
$scene = Scene_Menu.new(4)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play decision SE
$game_system.se_play($data_system.decision_se)
# What actions to take when user selects Equip or Unequip
case @window_choice.index
when 0
# Activate equip Orb window
@window_choice.active = false
@window_choice.visible = false
@window_equip_orb.active = true
@window_equip_orb.index = 0
@help_window.visible = true
when 1
# Activate unequip Orb window
@window_choice.active = false
@window_choice.visible = false
@window_remove_orb.active = true
@window_remove_orb.index = 0
@help_window.visible = true
when 2
# Activate equip window to dump Orb
@window_choice.active = false
@window_equip_orb.active = true
@window_equip_orb.index = 0
return
end
end
# If R button was pressed
if Input.trigger?(Input::R)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To next actor
@actor_index += 1
@actor_index %= $game_party.actors.size
# Switch to different equipment screen
$scene = Scene_Equip_Orb.new(@actor_index)
return
end
# If L button was pressed
if Input.trigger?(Input::L)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To previous actor
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# Switch to different equipment screen
$scene = Scene_Equip_Orb.new(@actor_index)
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when Orb unequip window is active)
#--------------------------------------------------------------------------
def update_remove_orb
refresh2
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Active command window
@window_choice.active = true
@window_choice.visible = true
@window_remove_orb.active = false
@help_window.visible = false
@window_choice.index = 0
for i in 0...@actor.orbs_equiped.size
@actor.learn_orbskill(@actor.orbs_equiped[i])
end
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected orb data on the unequip Orb window
@gem2 = @window_remove_orb.gem
# If character has no Orbs to unequip, play cancel SE
if @gem2 == nil
$game_system.se_play($data_system.cancel_se)
else
# Play equip SE
$game_system.se_play($data_system.equip_se)
# Change equipment
unequip_orb(@gem2)
return
end
end
end
#--------------------------------------------------------------------------
# * Frame Update (when Orb equip window is active)
#--------------------------------------------------------------------------
def update_orb
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Activate command window
@window_choice.active = true
@window_choice.visible = true
@window_equip_orb.active = false
@help_window.visible = false
@window_choice.index = 0
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected orb data on the equip Orb window
@gem = @window_equip_orb.gem
# if the are no equipable orbs in stock, play cancel SE
if @gem == nil
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
else
# If Discard Orb was selected
if @window_choice.index == 2
# Play equip SE
$game_system.se_play($data_system.equip_se)
trash_orb(@gem)
else # Else if Equip Orb was selected
# Character can't equip Orb without enough MP
# Check if currently selected Orb's MP cost is higher than actor's MP
if @gem.mp_cost > @actor.mp
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
else
# Play equip SE
$game_system.se_play($data_system.equip_se)
# Change equipment
equip_orb(@gem)
return
end
end
end
end
end
end
#==============================================================================
# ** Window_EquipOrb
#------------------------------------------------------------------------------
# This window displays Orbs in the party's inventory
#==============================================================================
class Window_EquipOrb < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 368, 208)
@actor = actor
@column_max = 1
self.active = false
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Orb Acquisition
#--------------------------------------------------------------------------
def gem
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# For every Orb in party's inventory, they are sent to @data array
for i in 0...$game_party.orbs.size
@data.push($game_party.orbs[i])
end
# If item count is not 0, make a bitmap and draw all items
@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
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
orb = @data[index]
# if actor doesn't have enough MP to equip Orb, darken its color
if orb.mp_cost > @actor.mp
self.contents.font.color = disabled_color
else
self.contents.font.color = normal_color
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('036-Item05')
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, 204, 32, orb.name, 0)
end
end
#==============================================================================
# ** Window_RemoveOrb
#------------------------------------------------------------------------------
# This window displays the Orbs an actor has currently equiped
#==============================================================================
class Window_RemoveOrb < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 368, 208)
@actor = actor
@column_max = 1
self.active = false
@data = []
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Orb Acquisition
#--------------------------------------------------------------------------
def gem
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# For every Orb the actor has equipped, they are sent to @data array
for i in 0...@actor.orbs_equiped.size
@data.push(@actor.orbs_equiped[i])
end
# If item count is not 0, make a bit map and draw all items
@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
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
orb = @data[index]
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('036-Item05')
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, 204, 32, orb.name, 0)
end
end
#==============================================================================
# ** Window_Orb_Right
#------------------------------------------------------------------------------
# Shows characters attributes.
#==============================================================================
class Window_Orb_Right < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 272, 352)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Draws actors attributes
#--------------------------------------------------------------------------
def draw_stats
draw_actor_battler(@actor, 136, 200)
draw_actor_name(@actor, 4, 152)
draw_actor_level(@actor, 4, 184)
draw_actor_hp(@actor, 4, 216, 172)
draw_actor_sp(@actor, 4, 248, 172)
draw_actor_mp(@actor, 4, 280)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_stats
end
end
#==============================================================================
# ** Window_MP
#------------------------------------------------------------------------------
# This window displays amount of MP a character has.
#==============================================================================
class Window_MP < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 272, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "MP Required", 0)
if @mp_need != nil
self.contents.font.color = normal_color
self.contents.draw_text(124, 0, 32, 32, @mp_need.to_s, 2)
end
end
#--------------------------------------------------------------------------
# * Set parameters for Orb's MP cost
#--------------------------------------------------------------------------
def set_new_parameters(mp_need)
if @mp_need != mp_need
@mp_need = mp_need
refresh
end
end
end
#==============================================================================
# ** Window_Command2
#------------------------------------------------------------------------------
# This version of command window is a set size with scrolling commands.
#==============================================================================
class Window_Command2 < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(width, commands)
super(0, 0, width, 224)
@item_max = commands.size
@commands = commands
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index])
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
#==============================================================================
# ** Window_Command3
#------------------------------------------------------------------------------
# This is a horizontal version of the Command Window.
#==============================================================================
class Window_Command3 < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(commands)
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = commands.size
@commands = commands
@column_max = @item_max
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text character color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
x = self.width / @item_max * index
x2 = self.width / @column_max - 32
rect = Rect.new(x, 0, x2, 32)
self.contents.draw_text(rect, @commands[index], 1)
end
end
#==============================================================================
# ** Window_Help2
#------------------------------------------------------------------------------
# This window shows Orb explanations.
#==============================================================================
class Window_Help2 < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# * Set Text
# text : text string displayed in window
# align : alignment (0..flush left, 1..center, 2..flush right)
#--------------------------------------------------------------------------
def set_text(text, align = 0)
# If at least one part of text and alignment differ from last time
if text != @text or align != @align
# Redraw text
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
end
end
#--------------------------------------------------------------------------
# * Set Actor
# actor : status displaying 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
# enemy : name and status displaying 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
#******************************************************************************
# III Part Three
#------------------------------------------------------------------------------
# This part contains all the changes to the original script.
#******************************************************************************
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
# Added variables
attr_accessor :orbs_equiped
attr_reader :max_mp
attr_reader :mp
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias orb_game_actor_setup setup
alias orb_game_actor_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
# actor_id : actor ID
#--------------------------------------------------------------------------
def initialize(actor_id)
orb_game_actor_init(actor_id)
end
#--------------------------------------------------------------------------
# * Setup
# information for Orbs
#--------------------------------------------------------------------------
def setup(actor_id)
# Added info for Orb system
@orbs_equiped = []
@mp = 1
@max_mp = 1
# Original setup method
orb_game_actor_setup(actor_id)
end
#--------------------------------------------------------------------------
# * Create Maximum MP
#--------------------------------------------------------------------------
def max_mp=(max_mp)
@max_mp = max_mp
end
#--------------------------------------------------------------------------
# * Create MP
#--------------------------------------------------------------------------
def mp=(mp)
@mp = mp
end
#--------------------------------------------------------------------------
# * Change EXP
# exp : new EXP
#--------------------------------------------------------------------------
def exp=(exp)
@exp = [[exp, 9999999].min, 0].max
# Level up
while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
@level += 1
# Max MP and current MP also rise with level
# Max MP will equal actor's level
@mp += 1
@max_mp += 1
# Learn skill
for j in $data_classes[@class_id].learnings
if j.level == @level
learn_skill(j.skill_id)
end
end
end
# Level down
while @exp < @exp_list[@level]
@level -= 1
# Max MP and current MP also decrease with level
# Max MP will equal actor's level
@mp -= 1
@max_mp -= 1
end
# Correction if exceeding current max HP and max SP
@hp = [@hp, self.maxhp].min
@sp = [@sp, self.maxsp].min
end
#--------------------------------------------------------------------------
# * Returns actors orbs_equipped array
#--------------------------------------------------------------------------
def orbs_equip
return @actor.orbs_equiped
end
#--------------------------------------------------------------------------
# * Equip orb method
#--------------------------------------------------------------------------
def get_orb(orb_id)
@orbs_equiped.push(orb_id).dup
end
#--------------------------------------------------------------------------
# * Unequip orb method
#--------------------------------------------------------------------------
def getrid_orb(orb_id)
@orbs_equiped.delete_at(orb_id.index)
end
#--------------------------------------------------------------------------
# * Learn Skill from orb
#--------------------------------------------------------------------------
def learn_orbskill(orb_id)
@orb = orb_id
# For every skill the current orb contains, the actor will learn them
# when equipping it
for i in 0...@orb.skills.size
skill_id = @orb.skills[i]
# Learn Skill
if not skill_learn?(skill_id)
@skills.push(skill_id)
end
end
end
#--------------------------------------------------------------------------
# * Forget Skill from orb
#--------------------------------------------------------------------------
def drop_orbskill(orb_id)
@orbf = orb_id
# For every skill the current orb contains, the actor will forget them
# when unequipping it
for i in 0...@orbf.skills.size
skill_id = @orbf.skills[i]
# Forget Skill
@skills.delete(skill_id)
end
end
end
#==============================================================================
# ** Game_Party
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
# Added variable
attr_accessor :orbs
#--------------------------------------------------------------------------
# * Alias Method
#--------------------------------------------------------------------------
alias orb_game_party_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original initialize method
orb_game_party_init
# Added Orbs array
# This array stores all the Orbs in the party's inventory
@orbs = []
end
#--------------------------------------------------------------------------
# Clear inventory of an Orb
#--------------------------------------------------------------------------
def lose_orb(orb_id)
# Delete Orb at correct location
@orbs.delete_at(orb_id.index)
# Sort Orbs in alphabetical order by name
@orbs.sort! {|a, z| a.id <=> z.id}
end
#--------------------------------------------------------------------------
# Add an Orb to the Party's inventory
#--------------------------------------------------------------------------
def gain_orb(orb_id)
# Duplicate Orbs of the same type that are sent to array
@orbs.push(orb_id).dup
# Sort Orbs in alphabetical order by name
@orbs.sort! {|a, z| a.id <=> z.id}
end
end
#==============================================================================
# ** Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# * Draws actors battler picture
#--------------------------------------------------------------------------
def draw_actor_battler(actor, x, y)
bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
x2 = bitmap.width
y2 = bitmap.height
x3 = 240 - bitmap.width
y3 = 320 - bitmap.height
src_rect = Rect.new(0, 0, x2, y2)
if x3 <= y3
new_rect = Rect.new(0, 0, x2 + x3, y2 + x3)
else
new_rect = Rect.new(0, 0, x2 + y3, y2 + y3)
end
self.contents.stretch_blt(new_rect, bitmap, src_rect, 100)
end
#--------------------------------------------------------------------------
# * Draws actors MP
#--------------------------------------------------------------------------
def draw_actor_mp(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, "MP")
self.contents.font.color = normal_color
self.contents.draw_text(x + 24, y, 84, 32, actor.mp.to_s, 2)
self.contents.draw_text(x + 112, y, 12, 32, "/ ", 1)
self.contents.draw_text(x + 120, y, 84, 32, actor.max_mp.to_s)
end
end
#==============================================================================
# ** Scene_Menu
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "Orbs"
s5 = "Status"
s6 = "Save"
s7 = "End Game"
@command_window = Window_Command2.new(160, [s1, s2, s3, s4, s5, s6, s7])
@command_window.index = @menu_index
# If number of party members is 0
if $game_party.actors.size == 0
# Disable items, skills, equipment, orbs, and status
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
@command_window.disable_item(4)
end
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(5)
end
# Make play time window
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 224
# Make steps window
@steps_window = Window_Steps.new
@steps_window.x = 0
@steps_window.y = 320
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 416
# Make status window
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
# 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
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # Orbs
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 5 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 6 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 1 # skill
# If this actor's action limit is 2 or more
if $game_party.actors[@status_window.index].restriction >= 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@status_window.index)
when 3 # Orbs
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Orbs Screen
$scene = Scene_Equip_Orb.new(@status_window.index)
when 4 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
#==============================================================================
# ** Scene_Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# Alias Methods
#--------------------------------------------------------------------------
alias orb_scene_title_main main
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Load Orb database
$data_orbs = RPG::Orbs_Data::Orb_Database
# Original script
orb_scene_title_main
end
end
#==============================================================================
# ** Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
# Added variable
attr_accessor :shop_orbs
#--------------------------------------------------------------------------
# * Alias Method
#--------------------------------------------------------------------------
alias orb_game_temp_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original method
orb_game_temp_init
# Added array for Orbs that the shop will sell
@shop_orbs = []
end
end
#******************************************************************************
# IV Part Four
#------------------------------------------------------------------------------
# This part is contains the windows and scene that enable buying and selling Orbs.
#******************************************************************************
#==============================================================================
# ** Scene_Orb_Shop
#------------------------------------------------------------------------------
# This class handles buying and selling Orbs.
#==============================================================================
class Scene_Orb_Shop
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get orbs for sale from $game_temp array
@orbs_for_sale = $game_temp.shop_orbs
# Make help window
@help_window = Window_Help.new
# Make command window
@command_window = Window_ShopCommand.new
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 64
# Make blank window
@blank_window = Window_Base.new(0, 128, 640, 352)
# Make buy window
@orb_buy_window = Window_Orb_Buy.new(@orbs_for_sale)
@orb_buy_window.active = false
@orb_buy_window.visible = false
@orb_buy_window.help_window = @help_window
# Make sell window
@orb_sell_window = Window_Orb_Sell.new
@orb_sell_window.active = false
@orb_sell_window.visible = false
@orb_sell_window.help_window = @help_window
# 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
@help_window.dispose
@command_window.dispose
@gold_window.dispose
@blank_window.dispose
@orb_buy_window.dispose
@orb_sell_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@help_window.update
@command_window.update
@gold_window.update
@blank_window.update
@orb_buy_window.update
@orb_sell_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If buy window is active: call update_orb_buy
if @orb_buy_window.active
update_orb_buy
return
end
# If sell window is active: call update_orb_sell
if @orb_sell_window.active
update_orb_sell
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # buy
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Change windows to buy mode
@command_window.active = false
@blank_window.visible = false
@orb_buy_window.active = true
@orb_buy_window.visible = true
@orb_buy_window.refresh
when 1 # sell
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Change windows to sell mode
@command_window.active = false
@blank_window.visible = false
@orb_sell_window.active = true
@orb_sell_window.visible = true
@orb_sell_window.refresh
when 2 # quit
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to map screen
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when buy window is active)
#--------------------------------------------------------------------------
def update_orb_buy
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Go back to command window
@command_window.active = true
@blank_window.visible = true
@orb_buy_window.active = false
@orb_buy_window.visible = false
# Set help text to nothing
@help_window.set_text("")
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get orb to buy
@orb = @orb_buy_window.orb
# If orb is nothing, or the if it costs more money than the player has
if @orb == nil or @orb.price > $game_party.gold
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play shop SE
$game_system.se_play($data_system.shop_se)
# Add orb to players inventory
$game_party.gain_orb(@orb)
# Subtract money for purchase
$game_party.lose_gold(@orb.price)
# Remake gold and sell window contents
@gold_window.refresh
@orb_buy_window.refresh
end
end
#--------------------------------------------------------------------------
# * Frame Update (when sell window is active)
#--------------------------------------------------------------------------
def update_orb_sell
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Go back to command window
@command_window.active = true
@blank_window.visible = true
@orb_sell_window.active = false
@orb_sell_window.visible = false
# Set help text to nothing
@help_window.set_text("")
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get orb to sell
@orb = @orb_sell_window.orb
@index = @orb_sell_window.index
# If item is invalid, or item price is 0 (unable to sell)
if @orb == nil or @orb.price == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play shop SE
$game_system.se_play($data_system.shop_se)
# Add money from orb sale
$game_party.gain_gold(@orb.price / 2)
# Get rid of orb from players inventory
$game_party.orbs.delete_at(@index)
# Remake gold and sell window contents
@gold_window.refresh
@orb_sell_window.refresh
end
end
end
#==============================================================================
# ** Window_Orb_Buy
#------------------------------------------------------------------------------
# This window displays buyable Orbs on the shop screen.
#==============================================================================
class Window_Orb_Buy < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(orbs_for_sale)
super(0, 128, 368, 352)
@orbs_for_sale = orbs_for_sale
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Orb Acquisition
#--------------------------------------------------------------------------
def orb
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# For every orb in @orbs_for_sale array send them to window array
for i in 0..@orbs_for_sale.size
orb = @orbs_for_sale[i]
if orb != nil
@data.push(orb)
end
end
# Sort Orbs in alphabetical order by name
@data.sort! {|a, z| a.id <=> z.id}
# If item count is not 0, make a bit map and draw all items
@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
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
orb = @data[index]
# If price is less than money in possession,
if orb.price <= $game_party.gold
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon('036-Item05')
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, orb.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, orb.price.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.orb == nil ? "" : self.orb.info)
end
end
#==============================================================================
# ** Window_Orb_Sell
#------------------------------------------------------------------------------
# This window displays sellable Orbs on the shop screen.
#==============================================================================
class Window_Orb_Sell < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(272, 128, 368, 352)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Orb Acquisition
#--------------------------------------------------------------------------
def orb
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# For every Orb in party's inventory, they are sent to @data array
for i in 0...$game_party.orbs.size
@data.push($game_party.orbs[i])
end
# If item count is not 0, make a bitmap and draw all items
@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
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
orb = @data[index]
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon('036-Item05')
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, orb.name, 0)
sell_price = orb.price / 2
self.contents.draw_text(x + 240, y, 88, 32, sell_price.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.orb == nil ? "" : self.orb.info)
end
end