# Selects our RPG::Item object class so we can add to it
class RPG::Item
# Creates a constant that holds our item data
# each addition adds an item data, which is composed of actor ids and class ids.
# final structure is CCE = item_id => {actor_id => class_id, ...}
Class_Change_Effect = {}
#--------------------------------------------------------------------------
# * Setup
#
# Step 1: Making an item change actor's class
#
# Below # Start Mods Here, add
# - Class_Change_Effect[item_id] = {}
#
# Replace item_id with the idem id from your database
#
# Step 2: Making item change actor x's class to class y
#
# Below your added line, add
# - Class_Change_Effect[item_id][x] = y
#
# Replace x with your actor id and y with item id from your database
#
# Repeat step 2 for desired actors.
#
# Step 3: Default for actors (for non-defined actors from step 2)
#
# Below your lines you added from step 2, add
# - Class_Change_Effect[item_id].default = y
#
# Replace y with item id from your database
#
# Repeat steps 1-3 for all items
#
# * Example:
# Item 1
# Actor 5's class to 6
# Actor 7's class to 1
# All other actors' class to 3
# Item 3
# Only actor 1's class to 4
#
# Class_Change_Effect[1] = {}
# Class_Change_Effect[1][5] = 6
# Class_Change_Effect[1][7] = 1
# Class_Change_Effect[1].default = 3
# Class_Change_Effect[3] = {}
# Class_Change_Effect[3][1] = 4
#--------------------------------------------------------------------------
# Start Mods Here
# End Mods Here
# This just makes all items not defined have an empty list of actor and classes
Class_Change_Effect.default = {}
# This creates a method for retrieving data from our constant
def class_changes
# Returns a list of actor and class based off item id
return Class_Change_Effect[@id]
end
end
# This selects our battler class so we can add to it
class Game_Battler
# This renames the item_effect method, a method called when using an item on an actor
alias_method :seph_itemeffectsclasschange_gmbtlr_ie, :item_effect
# Selects our item_effect method, which we pass an RPG::Item to. item is a local variable in your method
# pointing to our RPG::Item
def item_effect(item)
# This calls our original item_effect method that we renamed. The original method
# returns a result if the item is effective or not. We save the result
result = seph_itemeffectsclasschange_gmbtlr_ie(item)
# This makes a flag to check if class is changed (we use later)
class_changed = false
# If current battler is an actor (not enemy)
if self.is_a?(Game_Actor)
# If the item hits and doesn't miss
if self.damage != 'Miss'
# Calls our method we added in RPG::Item, retrieve our items class changes
class_mods = item.class_changes
# Here we check that list based off our actor_id. If nothing is found, we don't
# do the next line
unless [0, nil].include?(class_mods[@actor_id])
# Change our class id
self.class_id = class_mods[@actor_id]
# Sets our class change flag to true
class_changed = true
end
end
end
# Returns true if result is true or class_changed is true
return result || class_changed
end
end