Simple Magic System
By: FamilyGamer7
IntroductionBy: FamilyGamer7
Features
Screenshots
Demo
Script
Ruby:
#==============================================================================
# Title: Simple Magic System
# Author: FamilyGamer7 (FG7)
# Version: 1.7
# Engine: RPG Maker VX Ace
#==============================================================================
# ** Change Log |
# ---------------
# 1.0 => Created script
# 1.1 => Added Skilltype limit for all actors
# 1.2 => Added in cost to remove skilltype on actor (optional)
# 1.3 => Added in cost when adding magic item on actor (optional)
# 1.4 => Added in shop-like effect (Disables magic consumption & skill removal)
# 1.5 => Rewrote script geared towards shop-like effect for efficiency
# (You can no longer add or remove magic outside of shop script call)
# 1.6 => Complete overhaul to script that builds on v1.5 with a true shop feel
# 1.7 => Entire script has been aliased for compatibility purposes
#==============================================================================
# ** Description |
# ----------------
# Easy way to build onto the existing magic system VX Ace engine uses. This
# script introduces the concept of magic items that are consumable which add
# skilltype(s) onto the actor and the ability to remove the skilltype(s). This
# is all done through the Magic Item Shop window (Add/Remove).
#
# * This is all controlled by "states".
#==============================================================================
# ** Terms of Use |
# -----------------
# * Free to use in non-commercial projects and commercial projects
# * Feel free to modify and improve the script. Credit is still required.
# * Credit FamilyGamer7
#==============================================================================
# ** Usage |
# ----------
# * NOT Plug & Play (See "Setup" section to properly use this script)
#==============================================================================
# ** Setup |
# ---------
# - See Demo for a better representation/understanding on how the script works.
#
# This script does require a small setup up front. The most important thing to
# note is the skilltype/state/item id number will all need to be the same for
# this script to function properly (Ideally keep the naming consistent as well).
#
# - Ex: Fire / skilltype id = 50
# - Ex: Fire / item id = 50
# - Ex: SMS: Fire / state id = 50
# (Note: The "state" name needs to have "SMS:" before the state name)
#
# * Note: Since all of the id's are the same, this allows the script to do all
# of the heavy lifting when adding and removing the skilltype per actor.
#
# -----------------------------------------------------------------------------
#
# For the "Magic Item" setup:
#
# - A magic item is simply just a normal item that is "consumable" and with an
# added state on it. Using the example of a [SMS: Fire] state that has been
# already made, the illustration below is how yours should look on the effects
# box.
#
# Effects
# -----------------------------------
# | Kind | Content |
# -----------------------------------
# | Add State [SMS: Fire] 100% |
# -----------------------------------
# | |
# -----------------------------------
# | |
# -----------------------------------
#
# General Settings:
# - Item Type: Normal
# - Consume: Yes
# - Scope: One Ally
# - Occasion: Only from the Menu
#
# -----------------------------------------------------------------------------
#
# For the magic "State" setup:
#
# - A magic "state" is essentially a duplicate of the skilltype that you add
# the skilltype through the features box area. Using the example of a [Fire]
# skilltype that has been already made, the illustration below is how yours
# should look look on the features box.
#
# * Note: As stated above, the "state" name needs to have "SMS:" before the
# state name. See example below how the state name should look.
# - Ex: SMS: Fire
#
# Features
# --------------------------------
# | Kind | Content |
# --------------------------------
# | Add Skill Type [Fire] |
# --------------------------------
# | |
# --------------------------------
# | |
# --------------------------------
#
# For the state icons, you can choose to have icons that show by the actor or
# leave it blank. The choose is yours depending upon your game. If you choose to
# allow state icons, then be sure to set priority to "100" on state for visual
# purposes. This script is designed with the state icons in mind.
#
# * The rest of the setup is your "normal" attach skill(s) to your newly created
# skilltype and ensure the actor can learn those skills at a certain level.
#
# -----------------------------------------------------------------------------
#
# When you want to add or remove a magic item from an actor, you will need to
# do a script call to enter a shop-like effect mode. This can easily be done by
# following below.
#
# Script calls:
#
# - To add/embed new magic items on actor:
# $game_system.call_simple_magic_system_embed
#
# - To remove magic items on actor:
# $game_system.call_simple_magic_system_remove
#
#==============================================================================
# ** Script Intention |
# --------------------
# This script tries to emulate a magic system where you place a magic item into
# a character slot - without the slot factor. Since we are just building on top
# of the existing default magic system, a slot concept does not exist.
#
# This script also takes inspiration from Suikoden 2's magic rune system.
#==============================================================================
#==============================================================================
# ** Module: FG7::Simple_Magic_System
#------------------------------------------------------------------------------
# This modules creates a static variable to be used within the script.
#==============================================================================
module FG7
module Simple_Magic_System
#==============================================================================
# -------------------- ALLOWED TO EDIT BELOW THIS LINE ---------------------- #
#==============================================================================
# --------------------------------------
# REQUIRED - Game Switch Configuration |
# --------------------------------------
# Sets the value for the $game_switch used for the simple magic system
# This is to give the system a shop-like effect when using a script call
# (- REQUIRED -)
Simple_Magic_System_Shop_Effect_Switch = 40
# Sets the value for the $game_switch used for the simple magic system
# (- REQUIRED -)
Simple_Magic_System_Switch = 41
# Sets the value for the magic item icon index that is used for the script
# (Please ensure no other item uses this item icon index number)
# (- REQUIRED -)
Magic_Item_Icon_Match = 359
# ---------------------------------------------
# Optional - Magic Limit & Cost Configuration |
# ---------------------------------------------
# Sets the value for the total magic items that can be applied to an actor
# (This is in the shop-like effect script call)
Skilltype_Magic_Limit = 3
# Sets the value for how much it cost to add/remove magic item on actor
# (This is in the shop-like effect script call)
Cost_To_Add_And_Remove_Amount = 1000
# --------------------------------------
# Optional - Text String Configuration |
# --------------------------------------
# Sets the text string when magic item limit on actor has been reached
Magic_Limit_Reached = "Magic item limit has been reached."
# Sets the text string when not enough currency is available for magic removal
# (This is used if Skilltype switch is set to "True")
Not_Enough_Currency = "Not enough currency to add/remove magic."
# Sets the text string when an already existing magic item is on actor
Existing_Magic_Embedded = "Already have existing magic embedded."
# -------------------------------------------
# Optional - Scene Title Text Configuration |
# -------------------------------------------
# Sets the text string for the title text of the scene (For add/embed)
Magic_Item_Shop_Add_Title = "Magic Item - Add"
# Sets the text string for the title text of the scene (For remove)
Magic_Item_Shop_Remove_Title = "Magic Item - Remove"
#==============================================================================
# ---------- DO NOT EDIT BELOW THIS LINE (FOR ADVANCED USERS) --------------- #
#==============================================================================
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system data. It saves the disable state of saving and
# menus. Instances of this class are referenced by $game_system.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * New Method: Checks Magic Shop-Like Effect Switch Is "On" (True)
#--------------------------------------------------------------------------
def check_magic_shop_switch
$game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Shop_Effect_Switch] == true
end
#--------------------------------------------------------------------------
# * New Method: Checks If Current Currency Is Lower Than Magic Cost Amount
#--------------------------------------------------------------------------
def check_currency_compare
$game_party.gold < FG7::Simple_Magic_System::Cost_To_Add_And_Remove_Amount
end
#--------------------------------------------------------------------------
# * New Method: simple_magic_system_embed (Calls Item scene with game switch)
#--------------------------------------------------------------------------
def call_simple_magic_system_embed
$game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Shop_Effect_Switch] = true
SceneManager.call(Scene_Item)
end
#--------------------------------------------------------------------------
# * New Method: simple_magic_system_remove (Calls Skill scene with game switch)
#--------------------------------------------------------------------------
def call_simple_magic_system_remove
$game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Shop_Effect_Switch] = true
SceneManager.call(Scene_Skill)
end
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# A battler class with methods for sprites and actions added. This class
# is used as a super class of the Game_Actor class and Game_Enemy class.
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# * Alias Method: Remove State
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_remove_state :remove_state
def remove_state(state_id)
fg7_simple_magic_system_remove_state(state_id)
# When state (magic) is removed - add back into inventory
# (Odd issue where item 1 in the database is added - Worked around issue)
$game_party.gain_item($data_items[state_id], 1) && $game_party.gain_item($data_items[1], -1) if $game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Switch] == true
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This is a super class of all windows within the game.
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# * Alias Method: Draw Face Graphic
# enabled : Enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_draw_face :draw_face
def draw_face(face_name, face_index, x, y, enabled = true)
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
bitmap = Cache.face(face_name)
# Adjust face height to fit in add/remove shop scene windows
rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 60)
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
bitmap.dispose
else
fg7_simple_magic_system_draw_face(face_name, face_index, x, y, enabled)
end
end
#--------------------------------------------------------------------------
# * Alias Method: Draw Name
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_draw_actor_name :draw_actor_name
def draw_actor_name(actor, x, y, width = 112)
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
change_color(hp_color(actor))
# Adjusted the actor name up in add/remove shop scene windows
draw_text(x, y - 8, width, line_height, actor.name)
else
fg7_simple_magic_system_draw_actor_name(actor, x, y, width)
end
end
#--------------------------------------------------------------------------
# * Alias Method: Draw Level
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_draw_actor_level :draw_actor_level
def draw_actor_level(actor, x, y)
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
# Draws no level parameter at all
else
fg7_simple_magic_system_draw_actor_level(actor, x, y)
end
end
#--------------------------------------------------------------------------
# * Alias Method: Draw State and Buff/Debuff Icons
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_draw_actor_icons :draw_actor_icons
def draw_actor_icons(actor, x, y, width = 96)
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
# Remove Buff/Debuff Icons from showing
icons = (actor.state_icons)[0, width / 24]
icons.each_with_index {|n, i| draw_icon(n, x + 24 * i, y - 30) }
else
fg7_simple_magic_system_draw_actor_icons(actor, x, y, width)
end
end
end
#==============================================================================
# ** Window_SMS_Title
#------------------------------------------------------------------------------
# Window to show the title of the current scene - Item or Skill.
#==============================================================================
class Window_SMS_Title < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super
self.openness = 255
refresh
end
#--------------------------------------------------------------------------
# * Refresh (With additonal Information - Title Text)
#--------------------------------------------------------------------------
def refresh
change_color(system_color)
draw_text(x - 6, y - 22, 200, 50, "Shop:")
# Checks if in Item Scene - Magic Shop
if SceneManager.scene_is?(Scene_Item)
change_color(text_color(0))
draw_text(x + 50, y - 22, 200, 50, FG7::Simple_Magic_System::Magic_Item_Shop_Add_Title)
# Checks if in Skill Scene - Magic Shop
elsif SceneManager.scene_is?(Scene_Skill)
change_color(text_color(0))
draw_text(x + 50, y - 22, 200, 50, FG7::Simple_Magic_System::Magic_Item_Shop_Remove_Title)
end
end
#--------------------------------------------------------------------------
# * Open Window
#--------------------------------------------------------------------------
def open
refresh
super
end
end
#==============================================================================
# ** Window_Help
#------------------------------------------------------------------------------
# This window shows skill and item explanations along with actor status.
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# * Added Method: Get Window Width
#--------------------------------------------------------------------------
def contents_width
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
Graphics.width - 50
else
Graphics.width - 35
end
end
end
#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
# This window displays party member status on the menu screen.
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Alias Method: Get Window Height
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_window_height :window_height
def window_height
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
Graphics.height - 144
else
fg7_simple_magic_system_window_height
end
end
#--------------------------------------------------------------------------
# * Alias Method: Get Window Width
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_window_width :window_width
def window_width
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
Graphics.width - 310
else
fg7_simple_magic_system_window_width
end
end
end
#==============================================================================
# ** Window_ItemCategory
#------------------------------------------------------------------------------
# This window is for selecting a category of normal items and equipment
# on the item screen or shop screen.
#==============================================================================
class Window_ItemCategory < Window_HorzCommand
#--------------------------------------------------------------------------
# * Alias Method: Create Command List
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_make_command_list :make_command_list
def make_command_list
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
add_command(Vocab::item, :item)
else
fg7_simple_magic_system_make_command_list
end
end
end
#==============================================================================
# ** Window_ItemList
#------------------------------------------------------------------------------
# This window displays a list of party items on the item screen.
#==============================================================================
class Window_ItemList < Window_Selectable
#--------------------------------------------------------------------------
# * Alias Method: Get Digit Count
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_col_max :col_max
def col_max
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
return 1
else
fg7_simple_magic_system_col_max
end
end
#--------------------------------------------------------------------------
# * Alias Method: Include in Item List?
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_include? :include?
def include?(item)
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
return item.is_a?(RPG::Item) && item.icon_index == FG7::Simple_Magic_System::Magic_Item_Icon_Match && !item.key_item?
else
fg7_simple_magic_system_include?(item)
end
end
end
#==============================================================================
# ** Window_SkillList
#------------------------------------------------------------------------------
# This window is for displaying a list of available skills on the skill window.
#==============================================================================
class Window_SkillList < Window_Selectable
#--------------------------------------------------------------------------
# * Alias Method: Get Digit Count
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_col_max :col_max
def col_max
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
return 1
else
fg7_simple_magic_system_col_max
end
end
#--------------------------------------------------------------------------
# * Alias Method: Get Activation State of Selection Item
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_current_item_enabled? :current_item_enabled?
def current_item_enabled?
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch && SceneManager.scene_is?(Scene_Skill)
# Ensures the skill(s) are not selectable within the magic item remove
else
fg7_simple_magic_system_current_item_enabled?
end
end
#--------------------------------------------------------------------------
# * Alias Method: Display Skill in Active State?
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_enable? :enable?
def enable?(item)
if $game_system.check_magic_shop_switch && SceneManager.scene_is?(Scene_Skill)
# Ensures the skill(s) are inactive looking within the magic item remove
else
fg7_simple_magic_system_enable?(item)
end
end
end
#==============================================================================
# ** Window_SkillCommand
#------------------------------------------------------------------------------
# This window is for selecting commands (special attacks, magic, etc.) on the
# skill screen.
#==============================================================================
class Window_SkillCommand < Window_Command
#--------------------------------------------------------------------------
# * Alias Method: Get Window Width
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_window_width :window_width
def window_width
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
Graphics.width - 254
else
fg7_simple_magic_system_window_width
end
end
#--------------------------------------------------------------------------
# * New Method: Grabs current skilltype id command
#--------------------------------------------------------------------------
def current_selection
select(current_ext)
end
end
#==============================================================================
# ** Window_SkillSMSCommand
#------------------------------------------------------------------------------
# This window is for selecting skilltype command on the skill screen.
#==============================================================================
class Window_SkillSMSCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y)
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
return 4
end
#--------------------------------------------------------------------------
# * Get Item Height
#--------------------------------------------------------------------------
def item_height
32
end
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
add_command("View", :view)
add_command("Remove", :remove)
add_command("Cancel", :cancel)
end
end
#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
# This window is for displaying the status of party members on the battle
# screen.
#==============================================================================
class Window_BattleStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Alias Method: Draw Basic Area
# (Techincally an alias method - but really just an override method)
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_draw_basic_area :draw_basic_area
def draw_basic_area(rect, actor)
# Checks if magic shop-like effect is turned on
if SceneManager.scene_is?(Scene_Battle)
draw_actor_name(actor, rect.x + 0, rect.y, 100)
# Adjust the state icons to display 1 more than usual
draw_actor_icons(actor, rect.x + 84, rect.y, rect.width - 64)
else
fg7_simple_magic_system_draw_basic_area
end
end
end
#==============================================================================
# ** Scene_ItemBase
#------------------------------------------------------------------------------
# This class performs common processing for the item screen and skill screen.
#==============================================================================
class Scene_ItemBase < Scene_MenuBase
#--------------------------------------------------------------------------
# * New Method: Checks If Current Actor Skillytpe Limit Has Been Reached
#--------------------------------------------------------------------------
def check_skilltype_limit
$game_party.members[@actor_window.select_for_item(item)].states.collect { |state| state.name }.to_s.count(':') == FG7::Simple_Magic_System::Skilltype_Magic_Limit
end
#--------------------------------------------------------------------------
# * New Method: Checks If Current Magic Item Equals Script Icon Match
#--------------------------------------------------------------------------
def check_magic_item_icon
item.icon_index == FG7::Simple_Magic_System::Magic_Item_Icon_Match
end
#--------------------------------------------------------------------------
# * Alias Method: Create Actor Window
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_create_actor_window :create_actor_window
def create_actor_window
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch && SceneManager.scene_is?(Scene_Item)
x_width = 250
@actor_window = Window_MenuActor.new
@actor_window.set_handler(:ok, method(:on_actor_ok))
@actor_window.set_handler(:cancel, method(:on_actor_cancel))
@actor_window.x = 10
@actor_window.y = Graphics.height - x_width - 108
@actor_window.show
@actor_window.refresh
else
fg7_simple_magic_system_create_actor_window
end
end
#--------------------------------------------------------------------------
# * Alias Method: Actor [Cancel]
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_on_actor_cancel :on_actor_cancel
def on_actor_cancel
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
@actor_window.unselect
activate_item_window
# Properly handles what the default game engine does not
# (Moves item slection up by 1 if item selection is nil)
@item_window.select(0) if item == nil
else
fg7_simple_magic_system_on_actor_cancel
end
end
#--------------------------------------------------------------------------
# * Alias Method: Confirm Item
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_determine_item :determine_item
def determine_item
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
if item.for_friend?
@actor_window.show.activate
@actor_window.select_for_item(item)
else
use_item
activate_item_window
end
else
fg7_simple_magic_system_determine_item
end
end
#--------------------------------------------------------------------------
# * Alias Method: Actor [OK]
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_on_actor_ok :on_actor_ok
def on_actor_ok
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
# Checks if item is not usable and matches magic item icon
if !item_usable? && check_magic_item_icon
Sound.play_buzzer
@help_window.contents.clear
@help_window.draw_text_ex(4, 0, FG7::Simple_Magic_System::Existing_Magic_Embedded)
# Checks is item is usable and matches magic item icon and if skilltype limit is reached
elsif item_usable? && check_magic_item_icon && check_skilltype_limit
Sound.play_buzzer
@help_window.contents.clear
@help_window.draw_text_ex(4, 0, FG7::Simple_Magic_System::Magic_Limit_Reached)
# Checks if item is usable and matches magic item icon and if enough currency
elsif item_usable? && check_magic_item_icon && $game_system.check_currency_compare
Sound.play_buzzer
@help_window.contents.clear
@help_window.draw_text_ex(4, 0, FG7::Simple_Magic_System::Not_Enough_Currency)
# If checks above are not met - use item
else
use_item
# Checks if magic item icon matches + magic shop-like effect and reduces current currency
if item.icon_index == FG7::Simple_Magic_System::Magic_Item_Icon_Match && $game_system.check_magic_shop_switch
$game_party.lose_gold(FG7::Simple_Magic_System::Cost_To_Add_And_Remove_Amount)
@gold_window.refresh
@help_window.contents.clear
@help_window.draw_text_ex(4, 0, FG7::Simple_Magic_System::Cost_To_Add_And_Remove_Amount.to_s + Vocab::currency_unit + " has been removed")
end
end
# Checks if magic shop-like effect is turned off
elsif !$game_system.check_magic_shop_switch && check_magic_item_icon
# Checks if magic item icon matches && if skilltype limit is not reached
if check_magic_item_icon && !check_skilltype_limit
Sound.play_buzzer
else
use_item
end
# If all conditions not met - run original condition (For normal items)
else
fg7_simple_magic_system_on_actor_ok
end
# Refreshes actor window if/when state icons are present
@actor_window.refresh
end
#--------------------------------------------------------------------------
# * New Method: Grabs current total skilltype(s) added on actor
#--------------------------------------------------------------------------
def current_selection
select(current_ext)
end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
# This class performs the item screen processing.
#==============================================================================
class Scene_Item < Scene_ItemBase
#--------------------------------------------------------------------------
# * Alias Method: Start Processing
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_start :start
def start
fg7_simple_magic_system_start
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
create_gold_window
create_scene_title_window
end
end
#--------------------------------------------------------------------------
# * New Method: Create Scene Title Window
#--------------------------------------------------------------------------
def create_scene_title_window
@scene_title_window = Window_SMS_Title.new(10, 10, 363, 48)
end
#--------------------------------------------------------------------------
# * Alias Method: Create Category Window
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_create_category_window :create_category_window
def create_category_window
fg7_simple_magic_system_create_category_window
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
@category_window.hide
@category_window.deactivate
end
end
#--------------------------------------------------------------------------
# * Alias Method: Create Item Window
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_create_item_window :create_item_window
def create_item_window
fg7_simple_magic_system_create_item_window
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
x_width = 250
@item_window.x += x_width - 6
@item_window.width = Graphics.width - x_width - 4
@item_window.height = Graphics.height - x_width + 106
@item_window.y = Graphics.height - x_width - 108
@item_window.activate.select(0)
@item_window.refresh
end
end
#--------------------------------------------------------------------------
# * Alias Method: Create Help Window
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_create_help_window :create_help_window
def create_help_window
fg7_simple_magic_system_create_help_window
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
x_width = 250
@help_window.x = 10
@help_window.y = x_width + 80
@help_window.height = Graphics.height - x_width - 90
@help_window.width = Graphics.width - 20
@help_window.refresh
end
end
#--------------------------------------------------------------------------
# * Added Method: Create Gold Window
#--------------------------------------------------------------------------
def create_gold_window
x_width = 250
spacer = 123
@gold_window = Window_Gold.new
@gold_window.width = Graphics.width - x_width - spacer - 10
@gold_window.x += x_width + spacer
@gold_window.y = 10
end
#--------------------------------------------------------------------------
# * Alias Method: Return to Calling Scene
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_return_scene :return_scene
def return_scene
fg7_simple_magic_system_return_scene
$game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Shop_Effect_Switch] = false
end
end
#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
# This class performs skill screen processing. Skills are handled as items for
# the sake of process sharing.
#==============================================================================
class Scene_Skill < Scene_ItemBase
#--------------------------------------------------------------------------
# * Alias Method: Start Processing
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_start :start
def start
fg7_simple_magic_system_start
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
create_skill_sms_command_window
create_actor_status_window
create_gold_window
create_scene_title_window
end
end
#--------------------------------------------------------------------------
# * New Method: Create Scene Title Window
#--------------------------------------------------------------------------
def create_scene_title_window
@scene_title_window = Window_SMS_Title.new(10, 10, 363, 48)
end
#--------------------------------------------------------------------------
# * Added Method: Create Status Window
#--------------------------------------------------------------------------
def create_actor_status_window
x_width = 250
x = 10
y = Graphics.height - x_width - 108
@actor_status_window = Window_MenuStatus.new(x, y)
@actor_status_window.show
@actor_status_window.select_last
@actor_status_window.show
@actor_status_window.refresh
end
#--------------------------------------------------------------------------
# * Alias Method: Create Command Window
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_create_command_window :create_command_window
def create_command_window
fg7_simple_magic_system_create_command_window
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
x_width = 250
@command_window.width = Graphics.width - x_width - 4
@command_window.x += x_width - 6
@command_window.y -= 18
@command_window.refresh
end
end
#--------------------------------------------------------------------------
# * New Method: Window_SkillSMSCommand - Command Window
#--------------------------------------------------------------------------
def create_skill_sms_command_window
wy = @help_window.height
@skill_sms_command_window = Window_SkillSMSCommand.new(0, wy)
@skill_sms_command_window.deactivate
@skill_sms_command_window.hide
@skill_sms_command_window.set_handler(:view, method(:skill_view))
@skill_sms_command_window.set_handler(:remove, method(:skill_remove))
@skill_sms_command_window.set_handler(:cancel, method(:skill_cancel))
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
x_width = 250
@skill_sms_command_window.width = Graphics.width - x_width - 4
@skill_sms_command_window.x += x_width - 6
@skill_sms_command_window.y -= 18
@skill_sms_command_window.refresh
end
end
#--------------------------------------------------------------------------
# * Alias Method: Create Status Window
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_create_status_window :create_status_window
def create_status_window
fg7_simple_magic_system_create_status_window
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
@status_window.hide
end
end
#--------------------------------------------------------------------------
# * Alias Method: Create Help Window
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_create_help_window :create_help_window
def create_help_window
fg7_simple_magic_system_create_help_window
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
x_width = 250
@help_window.x = 10
@help_window.y = x_width + 80
@help_window.height = Graphics.height - x_width - 90
@help_window.width = Graphics.width - 20
@help_window.refresh
end
end
#--------------------------------------------------------------------------
# * Alias Method: Create Item Window
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_create_item_window :create_item_window
def create_item_window
fg7_simple_magic_system_create_item_window
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
x_width = 250
@item_window.x += x_width - 6
@item_window.width = Graphics.width - x_width - 4
@item_window.height = Graphics.height - x_width - 14
@item_window.y = Graphics.height - x_width + 12
@item_window.refresh
end
end
#--------------------------------------------------------------------------
# * Added Method: Create Gold Window
#--------------------------------------------------------------------------
def create_gold_window
x_width = 250
spacer = 123
@gold_window = Window_Gold.new
@gold_window.width = Graphics.width - x_width - spacer - 10
@gold_window.x += x_width + spacer
@gold_window.y = 10
end
#--------------------------------------------------------------------------
# * New Method: Skill [View]
#--------------------------------------------------------------------------
def skill_view
@item_window.activate
@item_window.select_last
end
#--------------------------------------------------------------------------
# * New Method: Skill [Remove]
#--------------------------------------------------------------------------
def skill_remove
# Checks current gold amount vs amount of gold to lose per module
if $game_system.check_currency_compare == false
RPG::SE.stop
# Lose gold if flag is set "true"
$game_party.lose_gold(FG7::Simple_Magic_System::Cost_To_Add_And_Remove_Amount)
# Remove Skill Type (Skill State - Both have same ID)
$game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Switch] = true
@actor.remove_state(@command_window.current_selection)
$game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Switch] = false
# Reposition hover selection + plays use item sound
@command_window.select(0)
Sound.play_use_item
@help_window.draw_text_ex(4, 0, FG7::Simple_Magic_System::Cost_To_Add_And_Remove_Amount.to_s + Vocab::currency_unit + " has been removed")
# Reactivates correct command window(s)
@skill_sms_command_window.deactivate
@skill_sms_command_window.hide
@command_window.activate
@command_window.show
# Play buzzer sound + add text to help window when switch is not met
else
RPG::SE.stop
@skill_sms_command_window.activate
@help_window.draw_text_ex(4, 0, FG7::Simple_Magic_System::Not_Enough_Currency)
Sound.play_buzzer
end
# Refresh windows
@gold_window.refresh
@actor_status_window.refresh
@status_window.refresh
@command_window.refresh
@item_window.refresh
end
#--------------------------------------------------------------------------
# * New Method: Skill [Cancel]
#--------------------------------------------------------------------------
def skill_cancel
@help_window.draw_text_ex(4, 0, "") # Resets text for help window = blank
@help_window.refresh
@skill_sms_command_window.deactivate
@skill_sms_command_window.hide
@item_window.deactivate
@item_window.unselect
@command_window.select(0)
@command_window.activate
@command_window.show
end
#--------------------------------------------------------------------------
# * Alias Method: Item [Cancel]
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_on_item_cancel :on_item_cancel
def on_item_cancel
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
@skill_sms_command_window.deactivate
@skill_sms_command_window.hide
@item_window.unselect
@command_window.select(0)
@command_window.activate
@command_window.show
else
fg7_simple_magic_system_on_item_cancel
end
end
#--------------------------------------------------------------------------
# * Alias Method: [Skill] Command
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_command_skill :command_skill
def command_skill
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
@help_window.draw_text_ex(4, 0, "") # Resets text for help window = blank
@command_window.deactivate
@command_window.hide
@skill_sms_command_window.activate
@skill_sms_command_window.show
@help_window.refresh
else
fg7_simple_magic_system_command_skill
end
end
#--------------------------------------------------------------------------
# * Alias Method: Change Actors
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_on_actor_change :on_actor_change
def on_actor_change
# Checks if magic shop-like effect is turned on
if $game_system.check_magic_shop_switch
@help_window.draw_text_ex(4, 0, "") # Resets text for help window = blank
@help_window.refresh
@actor_status_window.select_last
@actor_status_window.refresh
@command_window.actor = @actor
@status_window.actor = @actor
@item_window.actor = @actor
@command_window.activate
else
fg7_simple_magic_system_on_actor_change
end
end
#--------------------------------------------------------------------------
# * Alias Method: Return to Calling Scene
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_return_scene :return_scene
def return_scene
fg7_simple_magic_system_return_scene
$game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Shop_Effect_Switch] = false
end
end
Ruby:
#==============================================================================
# Title: Simple Magic System
# Author: FamilyGamer7 (FG7)
# Version: 1.2
# Engine: RPG Maker VX Ace
#==============================================================================
# ** Change Log |
# ---------------
# 1.0 => Created script
# 1.1 => Added Skilltype limit for all actors
# 1.2 => Added in cost to remove skilltype on actor (optional)
#==============================================================================
# ** Description |
# ----------------
# Easy way to build onto the existing magic system VX Ace engine uses. This
# script introduces the concept of magic items that are consumable which add
# skilltype(s) onto the actor and the ability to remove the skilltype(s) on
# the skill window. This is all controlled by "states".
#==============================================================================
# ** Terms of Use |
# -----------------
# * Free to use in non-commercial projects and commercial projects
# * Feel free to modify and improve the script. Credit is still required.
# * Credit FamilyGamer7
#==============================================================================
# ** Usage |
# ----------
# * NOT Plug & Play (See "Setup" section to properly use this script)
#==============================================================================
# ** Setup |
# ---------
# - See Demo for a better representation/understanding on how the script works.
#
# This script does require a small setup up front. The most important thing to
# note is the skilltype/state/item id number will all need to be the same for
# this script to function properly (Ideally keep the naming consistent as well).
#
# - Ex: Fire / skilltype id = 50
# - Ex: Fire / item id = 50
# - Ex: SMS: Fire / state id = 50
# (Note: The "state" name needs to have "SMS:" before the state name)
#
# * Note: Since all of the id's are the same, this allows the script to do all
# of the heavy lifting when adding and removing the skilltype per actor.
#
# -----------------------------------------------------------------------------
#
# For the "Magic Item" setup:
#
# - A magic item is simply just a normal item that is "consumable" and with an
# added state on it. Using the example of a [SMS: Fire] state that has been
# already made, the illustration below is how yours should look on the effects
# box.
#
# Effects
# -----------------------------------
# | Kind | Content |
# -----------------------------------
# | Add State [SMS: Fire] 100% |
# -----------------------------------
# | |
# -----------------------------------
# | |
# -----------------------------------
#
# General Settings:
# - Item Type: Normal
# - Consume: Yes
# - Scope: One Ally
# - Occasion: Only from the Menu
#
# -----------------------------------------------------------------------------
#
# For the magic "State" setup:
#
# - A magic "state" is essentially a duplicate of the skilltype that you add
# the skilltype through the features box area. Using the example of a [Fire]
# skilltype that has been already made, the illustration below is how yours
# should look look on the features box.
#
# * Note: As stated above, the "state" name needs to have "SMS:" before the
# state name. See example below how the state name should look.
# - Ex: SMS: Fire
#
# Features
# --------------------------------
# | Kind | Content |
# --------------------------------
# | Add Skill Type [Fire] |
# --------------------------------
# | |
# --------------------------------
# | |
# --------------------------------
#
# For the state icons, you can choose to have icons that show by the actor or
# leave it blank. The choose is yours depending upon your game.
#
# * The rest of the setup is your "normal" attach skill(s) to your newly created
# skilltype and ensure the actor can learn those skills at a certain level.
#
#==============================================================================
# ** Script Intention |
# --------------------
# This script tries to emulate a magic system where you place a magic item into
# a character slot - without the slot factor. Since we are just building on top
# of the existing default magic system, a slot concept does not exist.
#==============================================================================
#==============================================================================
# ** Module: FG7::Simple_Magic_System
#------------------------------------------------------------------------------
# This modules creates a static variable to be used within the script.
#==============================================================================
module FG7
module Simple_Magic_System
#==============================================================================
# -------------------- ALLOWED TO EDIT BELOW THIS LINE ---------------------- #
#==============================================================================
# Sets the value for the $game_switch used for the simple magic system
# (- REQUIRED -)
Simple_Magic_System_Switch = 33
# Sets the value for the magic item icon index that is used for the script
# (Please ensure no other item uses this item icon index number)
# (- REQUIRED -)
Magic_Item_Icon_Match = 359
# Sets the value for the total magic items that can be applied to an actor
Skilltype_Magic_Limit = 3
# Sets the switch to add the ability to remove "gold" on skilltype removal
# (Default is false)
Cost_To_Remove_Skilltype_Switch = false
# Sets the value for how much it cost to remove a skilltype from actor
# (This is used if Skilltype switch is set to "True")
Cost_To_Remove_Skilltype = 1000
# Sets the text string when not enough currency is available for magic removal
# (This is used if Skilltype switch is set to "True")
Not_Enough_Currency = "Not enough currency to remove magic."
#==============================================================================
# ---------- DO NOT EDIT BELOW THIS LINE (FOR ADVANCED USERS) --------------- #
#==============================================================================
end
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# A battler class with methods for sprites and actions added. This class
# is used as a super class of the Game_Actor class and Game_Enemy class.
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# * Alias Method: Remove State
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_remove_state :remove_state
def remove_state(state_id)
fg7_simple_magic_system_remove_state(state_id)
# When state (magic) is removed - add back into inventory
# (Odd issue where item 1 in the database is added - Worked around issue)
$game_party.gain_item($data_items[state_id], 1) && $game_party.gain_item($data_items[1], -1) if $game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Switch] == true
end
end
#==============================================================================
# ** Window_SkillCommand
#------------------------------------------------------------------------------
# This window is for selecting commands (special attacks, magic, etc.) on the
# skill screen.
#==============================================================================
class Window_SkillCommand < Window_Command
#--------------------------------------------------------------------------
# * New Method: Grabs current skilltype id command
#--------------------------------------------------------------------------
def current_selection
select(current_ext)
end
end
#==============================================================================
# ** Window_SkillSMSCommand
#------------------------------------------------------------------------------
# This window is for selecting skilltype command on the skill screen.
#==============================================================================
class Window_SkillSMSCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y)
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
return 4
end
#--------------------------------------------------------------------------
# * Get Item Height
#--------------------------------------------------------------------------
def item_height
32
end
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
add_command("View", :view)
add_command("Remove", :remove)
add_command("Cancel", :cancel)
end
end
#==============================================================================
# ** Scene_ItemBase
#------------------------------------------------------------------------------
# This class performs common processing for the item screen and skill screen.
#==============================================================================
class Scene_ItemBase < Scene_MenuBase
#--------------------------------------------------------------------------
# * Override Method: Actor [OK]
#--------------------------------------------------------------------------
def on_actor_ok
# Checks for new skilltype/state on selected actor
if item_usable? && item.icon_index == FG7::Simple_Magic_System::Magic_Item_Icon_Match && $game_party.members[@actor_window.select_for_item(item)].states.collect { |state| state.name }.to_s.count(':') == FG7::Simple_Magic_System::Skilltype_Magic_Limit
Sound.play_buzzer
# Perform the normal check for item usage consumption
elsif item_usable?
use_item
else
Sound.play_buzzer
end
@actor_window.refresh
end
#--------------------------------------------------------------------------
# * New Method: Grabs current total skilltype(s) added on actor
#--------------------------------------------------------------------------
def current_selection
select(current_ext)
end
end
#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
# This class performs skill screen processing. Skills are handled as items for
# the sake of process sharing.
#==============================================================================
class Scene_Skill < Scene_ItemBase
#--------------------------------------------------------------------------
# * Alias Method: Start Processing
#--------------------------------------------------------------------------
alias :fg7_simple_magic_system_start :start
def start
fg7_simple_magic_system_start
create_skill_sms_command_window
end
#--------------------------------------------------------------------------
# * New Method: Window_SkillSMSCommand - Command Window
#--------------------------------------------------------------------------
def create_skill_sms_command_window
wy = @help_window.height
@skill_sms_command_window = Window_SkillSMSCommand.new(0, wy)
@skill_sms_command_window.deactivate
@skill_sms_command_window.hide
@skill_sms_command_window.set_handler(:view, method(:skill_view))
@skill_sms_command_window.set_handler(:remove, method(:skill_remove))
@skill_sms_command_window.set_handler(:cancel, method(:skill_cancel))
end
#--------------------------------------------------------------------------
# * New Method: Skill [View]
#--------------------------------------------------------------------------
def skill_view
@item_window.activate
@item_window.select_last
end
#--------------------------------------------------------------------------
# * New Method: Skill [Remove]
#--------------------------------------------------------------------------
def skill_remove
# Checks Skilltype switch if "true"
if FG7::Simple_Magic_System::Cost_To_Remove_Skilltype_Switch == true
# Checks current gold amount vs amount of gold to lose per module
if $game_party.gold > $game_party.lose_gold(FG7::Simple_Magic_System::Cost_To_Remove_Skilltype)
RPG::SE.stop
# Lose gold if flag is set "true"
$game_party.lose_gold(FG7::Simple_Magic_System::Cost_To_Remove_Skilltype) if FG7::Simple_Magic_System::Cost_To_Remove_Skilltype_Switch == true
# Remove Skill Type (Skill State - Both have same ID)
$game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Switch] = true
@actor.remove_state(@command_window.current_selection)
$game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Switch] = false
# Reposition hover selection + plays use item sound
@command_window.select(0)
Sound.play_use_item
@help_window.draw_text_ex(4, 0, FG7::Simple_Magic_System::Cost_To_Remove_Skilltype.to_s + Vocab::currency_unit + " has been removed")
# Reactivates correct command window(s)
@skill_sms_command_window.deactivate
@skill_sms_command_window.hide
@command_window.activate
@command_window.show
# Play buzzer sound + add text to help window when switch is not met
else
RPG::SE.stop
@skill_sms_command_window.activate
@help_window.draw_text_ex(4, 0, FG7::Simple_Magic_System::Not_Enough_Currency)
Sound.play_buzzer
end
else
RPG::SE.stop
# Remove Skill Type (Skill State - Both have same ID)
$game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Switch] = true
@actor.remove_state(@command_window.current_selection)
$game_switches[FG7::Simple_Magic_System::Simple_Magic_System_Switch] = false
# Reposition hover selection + plays use item sound
@command_window.select(0)
Sound.play_use_item
# Reactivates correct command window(s)
@skill_sms_command_window.deactivate
@skill_sms_command_window.hide
@command_window.activate
@command_window.show
end
# Refresh windows
@status_window.refresh
@command_window.refresh
@item_window.refresh
end
#--------------------------------------------------------------------------
# * New Method: Skill [Cancel]
#--------------------------------------------------------------------------
def skill_cancel
@help_window.draw_text_ex(4, 0, "") # Resets text for help window = blank
@help_window.refresh
@skill_sms_command_window.deactivate
@skill_sms_command_window.hide
@item_window.deactivate
@item_window.unselect
@command_window.select(0)
@command_window.activate
@command_window.show
end
#--------------------------------------------------------------------------
# * Override Method: Item [Cancel]
#--------------------------------------------------------------------------
def on_item_cancel
@skill_sms_command_window.deactivate
@skill_sms_command_window.hide
@item_window.unselect
@command_window.select(0)
@command_window.activate
@command_window.show
end
#--------------------------------------------------------------------------
# * Override Method: [Skill] Command
#--------------------------------------------------------------------------
def command_skill
@help_window.draw_text_ex(4, 0, "") # Resets text for help window = blank
@command_window.deactivate
@command_window.hide
@skill_sms_command_window.activate
@skill_sms_command_window.show
@help_window.refresh
end
end
How to Use
Terms of Use