Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Materia System: Need a few edits.

I am using the Materia system posted here. But I dont want to actually use the ENTIRE system.

Basically...

Is there anyway to equip materia and lock it on a character through an event? As in, I can equip each character with a specific materia. And the player will not be able to remove it. When I use this in my game, I dont want to use the 'materia' part of it. Instead, it fit my 'class system'. Everyone has a specific element, and as it levels up, they gain spells. Also, pending on their element, they will gain bonus' and negatives. Which is perfect for this. So i really dont want the player to be able to touch anything. Merely look at their progress on their element and see how it effects the player. IF anything, I'd LOVE to have the equip part of the menu disabled, or even removed.

In the long run, I'd love that side to show the effects on their other stats (since you only really see the effects on their HP and MP). But if anyone knows how to edit this script so it removes their ability to equip, let me know what to delete, or whatever.

Script Link: viewtopic.php?f=11&t=59972&start=0

Code:
#==============================================================================

# Materia System (FF:VII)

#==============================================================================

# Original Script from XP by SephirothSpawn

# and Converted for VX by Atoa

#------------------------------------------------------------------------------

# Traslated by: Carbajosa... (Is this credit needed? lol)

# Thaks Kain Nobel for the help in translation

#------------------------------------------------------------------------------

# Sorry if these translations are a bit messy, its because

# this is a direct translation but the instructions provided

# here is originaly made by Atoa (copied and pasted)

#==============================================================================

=begin

===================================================

Materia Icons

===================================================

 

You can set individual icons for each materia, the icon must be on the Incon 

folder.

The name of the icon must be the same of the Materia + "_m"

 

E.g

Cure materia icon must be named "Cure_m"

Ultima materia icon must be named "Ultima_m"

 

Materias without individual icons will have the default materia icon, the color 

of defaut icon depends on the materia type

 

===================================================

Configurating Materias

===================================================

 

To configure the materias, look for lines like these in the "module 

Materia_Config"

 

MATERIA_LIST << [ID, name, type, status, elements, status effects, price, 

master price, ap, skill, special effect]

 

    * ID = Materia ID

    * name = materia Name

    * type = materia type (can be "Magic", "Command", "Summon", "Support" 

    and "Independent")

    * status = status change of the materia.[hp, sp, str, dex, agi, int] in 

    XP, [hp, mp, atk, def, spi, agi] in VX

    * elements = element id of materia. used when paired with elemental 

    spuport materia. must be an array

    * status effect = status effect id of materia. used when paired with 

    added effect spuport materia must. be an array

    * price = Price of materia with 0 AP

    * master price = Price of an level max materia

    * ap = ap nedded to level up. must be an array. the first value is the 

    ap to level 2. Here is the place where you set the max level of materia, 

    depending on how many values yoi add on the array.

 

E.G

[1000, 2000 ,3000] = the materia will have 4 levels

[2500, 5000, 10000, 20000, 40000] = the materia will have 6 levels

 

    * skills = skills of the materia. must be an array. you can make an 

    instace of this array = nil, so materia will "skip" this level

 

E.G

[2,7,20] = materia gain skill ID 2 in level 1, skill ID 7 in level 2, and 

skill ID 20 in level 3.

[nil,6,nil,13] = materia gain no skill in level 1, skill ID in level 2, no 

skill in level 3, and skill ID 13 in level 4.

 

    * special effects = special effects of materia. one of these: "All", 

    "Elemental", "Added Effect", "HP Absorb", "MP Absorb", "MP Turbo", 

    "MP Cost Cut", "EXP plus", "Gil Plus", "Luck Plus"(only for XP), 

    "HP Plus", "MP Plus", "Strength Plus", "Defense Plus", "Magic Plus", 

    "Speed Plus", "Flee Plus", "Critical Rate Plus", "Critical Damage Plus", 

    "Escape Plus", "Unnarmed Attack Plus" (only for XP), "HP <> MP"

 

 

===================================================    

Gain new Materia

===================================================

 

Use the Script Call event and add this code:

$game_party.gain_materia(ID)

where ID = the ID of materia

 

===================================================

Materia Shop

===================================================

 

to open an materia shop use the Script Call event and add this code:

materia_avaliable = [ X, Y, Z]

$scene = Scene_MateriaShop.new(materia_avaliable)

 

X,Y,Z = the ID of Materias

You can add how many IDs you want.

 

===================================================

Set Enemy AP

===================================================

 

to set enemy AP, look for lines like these in the "module Materia_Config"

 

ENEMY_AP[ID] = X

 

ID = Enemy ID

X = AP given by enemy

 

Enemys that don't have their IDs added to the list will give AP = their EXP/10

 

#==============================================================================

=end

unless $BTEST

module Materia_Config

  

  # Do not Erase the lines

  WEAPON_MATERIA_SLOTS = []

  ARMORS_MATERIA_SLOTS = []

  MATERIA_LIST = []

  ENEMY_AP = []

  # Do not Erase the lines

  

  # Show Faces in the Materia Equip Window?

  Show_Faces = false

  # Faces must be in an folder named "Faces" in the Graphics/Character foder

  # and must have the same name as the charset graphic

  

  # If true, when a materia reach a maximum level, you gain another

  # Stat in level 1, if false, nothing will happen

  Materia_Breeding = true

  

  # Configuration of attributes IDs with special effects

  Negate_Absorb_ID = 17 # ID attribute to the effect "Negate Absorption"

  Negate_Turbo_ID  = 18 # ID attribute to the effect "Negate MP Turbo"

  Negate_All_ID    = 19 # ID attribute to the effect "Negate All"

 

  # Materia Shop Message Configuration

  Shop_Message = 'How can I help you?'                  # ShoP Message

  Buy_Message = 'What Materia would you like to buy?' # Buy Message

  Sell_Message = 'Which materia you want to sell?' # Selling Message

  Buy_Command = 'Buy Materia' # Name of Option to purchase the store Materias

  Sell_Command = 'Sell Materia' # Name of Option to sell the store Materias

  Empty_Message = 'None'          # Message when Equiped...?

  Master_Text = 'Master'     # Text that indicates a Materia in High Level

  AP_Total = 'Total AP:'  # AP Attribute name (in the window of materials)

  AP_Name  = 'AP'  # AP Attribute name (shown ih the Battle Result Window)

  Hp_Text  = 'HP'  # HP Attribute name (in materia window)

  Sp_Text  = 'SP'  # SP Attribute name (in materia window)

  Str_Text = 'STR' # STR Attribute name (in materia window)

  Vit_Text = 'VIT' # VIT Attribute name (in *ALL* windows)

  Agi_Text = 'AGI' # AGI Attribute name (in materia window)

  Int_Text = 'INT' # INT Attribute name (in materia window)

 

  

  Default_Icon = 'Materia Icon'              # Default Materia Icon

  Materia_Cursor = 'Materia Cursor'          # Cursor Graphic Icon

  Single_Slot = 'Materia Single'             # Single-Slot Icon

  Paired_Slot_Left = 'Materia Paired Left'   # Paired-Slot Icon (Left)

  Paired_Slot_Right = 'Materia Paired Right' # Paired-Slot Icon (Right)

  Materia_Level = 'Star - Icon'              # Level Icon

 

  # Graphich Icon name when equip slot is empty

  Empty_Weapon = '001-Weapon01'

  Empty_Armor1 = '009-Shield01'

  Empty_Armor2 = '010-Head01'

  Empty_Armor3 = '014-Body02'

  Empty_Armor4 = '016-Accessory01'

    

#===============================================================================

=begin

===================================================

Equipment Slots

===================================================

 

To set the slots of equipment, look for lines like these in the 

"module Materia_Config"

 

WEAPON_MATERIA_SLOTS[ID] = [X , Y] for weapons

ARMORS_MATERIA_SLOTS[ID] = [X , Y] for armors

 

ID = Equipment ID

X = number of paired slots (count as 2 single slots)

Y = nuber of single slots

 

The total slots will never be greater than 8, if you set more than 8 slots, 

the extra slots will be ignored

 

E.g

ARMORS_MATERIA_SLOTS[5] = [2, 2]

The armor ID 5 will have 6 slots

(2 * 2) + 2 = 6

 

WEAPON_MATERIA_SLOTS[3] = [1, 5]

The weapon ID 5 will have 7 slots

(1 * 2) + 5 = 7

 

If you don't add an equipment ID on the list, the equip of this ID will have 

0 slots

=end

#================================================================================

  # Weapon Slots

  WEAPON_MATERIA_SLOTS[1] = [1 , 1]

  WEAPON_MATERIA_SLOTS[2] = [1 , 2]

  WEAPON_MATERIA_SLOTS[3] = [2 , 2]

  WEAPON_MATERIA_SLOTS[4] = [4 , 0]

  WEAPON_MATERIA_SLOTS[5] = [1 , 1]

  WEAPON_MATERIA_SLOTS[6] = [1 , 2]

  WEAPON_MATERIA_SLOTS[7] = [2 , 2]

  WEAPON_MATERIA_SLOTS[8] = [4 , 0]

  WEAPON_MATERIA_SLOTS[9] = [1 , 1]

  WEAPON_MATERIA_SLOTS[10] = [1 , 2]

  WEAPON_MATERIA_SLOTS[11] = [2 , 2]

  WEAPON_MATERIA_SLOTS[12] = [4 , 0]

  WEAPON_MATERIA_SLOTS[13] = [1 , 1]

  WEAPON_MATERIA_SLOTS[14] = [1 , 2]

  WEAPON_MATERIA_SLOTS[15] = [2 , 2]

  WEAPON_MATERIA_SLOTS[16] = [4 , 0]

  WEAPON_MATERIA_SLOTS[17] = [1 , 1]

  WEAPON_MATERIA_SLOTS[18] = [1 , 2]

  WEAPON_MATERIA_SLOTS[19] = [2 , 2]

  WEAPON_MATERIA_SLOTS[20] = [4 , 0]

  WEAPON_MATERIA_SLOTS[21] = [1 , 1]

  WEAPON_MATERIA_SLOTS[22] = [1 , 2]

  WEAPON_MATERIA_SLOTS[23] = [2 , 2]

  WEAPON_MATERIA_SLOTS[24] = [4 , 0]

  WEAPON_MATERIA_SLOTS[25] = [1 , 1]

  WEAPON_MATERIA_SLOTS[26] = [1 , 2]

  WEAPON_MATERIA_SLOTS[27] = [2 , 2]

  WEAPON_MATERIA_SLOTS[28] = [4 , 0]

  WEAPON_MATERIA_SLOTS[29] = [1 , 1]

  WEAPON_MATERIA_SLOTS[30] = [1 , 2]

  WEAPON_MATERIA_SLOTS[31] = [2 , 2]

  WEAPON_MATERIA_SLOTS[32] = [4 , 0]

  

  # Armor Slots

  ARMORS_MATERIA_SLOTS[1] = [1 , 1]

  ARMORS_MATERIA_SLOTS[2] = [1 , 2]

  ARMORS_MATERIA_SLOTS[3] = [2 , 2]

  ARMORS_MATERIA_SLOTS[4] = [4 , 0]

  ARMORS_MATERIA_SLOTS[5] = [1 , 1]

  ARMORS_MATERIA_SLOTS[6] = [1 , 2]

  ARMORS_MATERIA_SLOTS[7] = [2 , 2]

  ARMORS_MATERIA_SLOTS[8] = [4 , 0]

  ARMORS_MATERIA_SLOTS[9] = [1 , 1]

  ARMORS_MATERIA_SLOTS[10] = [1 , 2]

  ARMORS_MATERIA_SLOTS[11] = [2 , 2]

  ARMORS_MATERIA_SLOTS[12] = [4 , 0]

  ARMORS_MATERIA_SLOTS[13] = [1 , 1]

  ARMORS_MATERIA_SLOTS[14] = [1 , 2]

  ARMORS_MATERIA_SLOTS[15] = [2 , 2]

  ARMORS_MATERIA_SLOTS[16] = [4 , 0]

  ARMORS_MATERIA_SLOTS[17] = [1 , 1]

  ARMORS_MATERIA_SLOTS[18] = [1 , 2]

  ARMORS_MATERIA_SLOTS[19] = [2 , 2]

  ARMORS_MATERIA_SLOTS[20] = [4 , 0]

  ARMORS_MATERIA_SLOTS[21] = [1 , 1]

  ARMORS_MATERIA_SLOTS[22] = [1 , 2]

  ARMORS_MATERIA_SLOTS[23] = [2 , 2]

  ARMORS_MATERIA_SLOTS[24] = [4 , 0]

  ARMORS_MATERIA_SLOTS[25] = [1 , 1]

  ARMORS_MATERIA_SLOTS[26] = [1 , 2]

  ARMORS_MATERIA_SLOTS[27] = [2 , 2]

  ARMORS_MATERIA_SLOTS[28] = [4 , 0]

  ARMORS_MATERIA_SLOTS[29] = [1 , 1]

  ARMORS_MATERIA_SLOTS[30] = [1 , 2]

  ARMORS_MATERIA_SLOTS[31] = [2 , 2]

  ARMORS_MATERIA_SLOTS[32] = [4 , 0]

  ARMORS_MATERIA_SLOTS[33] = [1 , 1]

  ARMORS_MATERIA_SLOTS[34] = [1 , 2]

  ARMORS_MATERIA_SLOTS[35] = [2 , 2]

  ARMORS_MATERIA_SLOTS[36] = [4 , 0]

  ARMORS_MATERIA_SLOTS[37] = [1 , 1]

  ARMORS_MATERIA_SLOTS[38] = [1 , 2]

  ARMORS_MATERIA_SLOTS[39] = [2 , 2]

  ARMORS_MATERIA_SLOTS[40] = [4 , 0]

  

  #=#================================================================#=#

  #=#                          Enemy APs                             #=#

  #=#================================================================#=#

  #=# ENEMY_AP[ID] = x                                               #=#

  #=# where ID = Enemy ID in the database                            #=#

  #=# and                                                            #=#

  #=# X is the AP that you will get from them.                       #=#

  #=# ex: ENEMY_AP[1] = 2                                            #=#

  #=# You will get 2 AP from a slime[ID] in the database         #=#

  #=#================================================================#=#

  ENEMY_AP[1] = 2

  ENEMY_AP[2] = 3

  ENEMY_AP[3] = 5

  ENEMY_AP[4] = 9

  ENEMY_AP[5] = 11

  ENEMY_AP[6] = 16

  ENEMY_AP[7] = 21

  ENEMY_AP[8] = 28

  ENEMY_AP[9] = 32

  ENEMY_AP[10] = 37

  ENEMY_AP[11] = 42

  ENEMY_AP[12] = 46

  ENEMY_AP[13] = 51

  ENEMY_AP[14] = 57

  ENEMY_AP[15] = 64

  ENEMY_AP[16] = 72

  ENEMY_AP[17] = 80

  ENEMY_AP[18] = 93

  ENEMY_AP[19] = 175

  ENEMY_AP[20] = 214

  ENEMY_AP[21] = 126

  ENEMY_AP[22] = 153

  ENEMY_AP[23] = 344

  ENEMY_AP[24] = 198

  ENEMY_AP[25] = 415

  ENEMY_AP[26] = 530

  ENEMY_AP[27] = 725

  ENEMY_AP[28] = 986

  ENEMY_AP[29] = 1200

  ENEMY_AP[30] = 3000

  

  # List of Materias

  #[id, name, type, attribute = [], elements = [], effects = [], 

  # AP needed = min.500, Mastered AP Needed = min.1000, 

  # skills = [], exp = [], special = nil]

  

  # Magic Materias

                  #ID  Name      Type     HP MP STR VIT AGI INT element Effect AP MasterAP          EXP               SKILLS

  MATERIA_LIST << [0, 'Cure', 'Magic', [ -5, 5, -3, 0, 0, 3 ], [], [], 1000, 10000, [1000, 3000, 6000, 10000], [1, 2, 3, 6]]

  MATERIA_LIST << [1, 'Remedy', 'Magic', [ -4, 4, -3, 0, 0, 3 ], [], [], 750, 5000, [2500, 5000], [4, 5]]

  MATERIA_LIST << [2, 'Fire', 'Magic', [ -3, 3, -1, 0, 0, 1 ], [1], [], 1000, 7500, [1000, 3000, 7500], [7, 8, 9]]

  MATERIA_LIST << [3, 'Ice', 'Magic', [ -3, 3, -1, 0, 0, 1 ], [2], [], 1000, 7500, [1000, 3000, 7500], [10, 11, 12]]

  MATERIA_LIST << [4, 'Thunder', 'Magic', [ -3, 3, -1, 0, 0, 1 ], [3], [], 1000, 7500, [1000, 3000, 7500], [13, 14, 15]]

  MATERIA_LIST << [5, 'Water', 'Magic', [ -3, 3, -1, 0, 0, 1 ], [4], [], 1000, 7500, [1000, 3000, 7500], [16, 17, 18]]

  MATERIA_LIST << [6, 'Earth', 'Magic', [ -3, 3, -1, 0, 0, 1 ], [5], [], 1000, 7500, [1000, 3000, 7500], [19, 20, 21]]

  MATERIA_LIST << [7, 'Wind', 'Magic', [ -3, 3, -1, 0, 0, 1 ], [6], [], 1000, 7500, [1000, 3000, 7500], [22, 23, 24]]

  MATERIA_LIST << [8, 'Light', 'Magic', [ -4, 4, -2, 0, 0, 2 ], [7], [], 1000, 7500, [1000, 3000, 7500], [25, 26, 27]]

  MATERIA_LIST << [9, 'Darkness', 'Magic', [ -4, 4, -2, 0, 0, 2 ], [8], [], 1000, 7500, [1000, 3000, 7500], [28, 29, 30]]

  MATERIA_LIST << [10, 'Ultima', 'Magic', [ -5, 5, -3, 0, 0, 3 ], [], [], 10000, 100000, [10000, 50000], [nil, 31, 32]]

  MATERIA_LIST << [11, 'Poison', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [3], 750, 4500, [1500, 4500], [33, 34]]

  MATERIA_LIST << [12, 'Blind', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [4], 750, 4500, [1500, 4500], [35, 36]]

  MATERIA_LIST << [13, 'Silence', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [5], 750, 4500, [1500, 4500], [37, 38]]

  MATERIA_LIST << [14, 'Confusion', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [6], 750, 4500, [1500, 4500], [39, 40]]

  MATERIA_LIST << [15, 'Sleep', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [7], 750, 4500, [1500, 4500], [41, 42]]

  MATERIA_LIST << [16, 'Paralize', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [8], 750, 4500, [1500, 4500], [43, 44]] 

  MATERIA_LIST << [17, 'Weakness', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [9], 750, 4500, [1500, 4500], [45, 46]] 

  MATERIA_LIST << [18, 'Tiredness', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [10], 750, 4500, [1500, 4500], [47, 48]]

  MATERIA_LIST << [19, 'Slow', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [11], 750, 4500, [1500, 4500], [49, 50]]

  MATERIA_LIST << [20, 'Fever', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [12], 750, 4500, [1500, 4500], [51, 52]]

  MATERIA_LIST << [21, 'Strength', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [13], 750, 4500, [3000], [nil, 53]]

  MATERIA_LIST << [22, 'Protect', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [14], 750, 4500, [3000], [nil, 54]]

  MATERIA_LIST << [23, 'Barrier', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [15], 750, 4500, [3000], [nil, 55]]

  MATERIA_LIST << [24, 'Speed', 'Magic', [ -2, 2, 0, 0, 0, 0 ], [], [16], 750, 4500, [3000], [nil, 56]]

  # Command Materias

  MATERIA_LIST << [25, 'Fighter',  'Command', [0, 0, 5, 3, - 3, - 5], [], [], 3000, 20000, [2500, 5000, 9000, 14000], [57, 58, 59, 60]]

  MATERIA_LIST << [26, 'Lancer', 'Command', [2, -2, 4, 4, -2, -6], [], [], 3000, 20000, [2500, 5000, 9000, 14000], [61, 62, 63, 64]]

  MATERIA_LIST << [27, 'Warrior', 'Command', [4, -2, 6, 4, -4, -8], [], [], 3000, 20000, [2500, 5000, 9000, 14000], [65, 66, 67, 68]]

  MATERIA_LIST << [28, 'Thief', 'Command', [0, -2, 2, -2, 8, -2], [], [], 3000, 20000, [2500, 5000, 9000, 14000], [69, 70, 71, 72]]

  MATERIA_LIST << [29, 'Hunter', 'Command', [-3, 2, -3, -2, 4, 4], [], [], 3000, 20000, [2500, 5000, 9000, 14000], [73, 74, 75, 76]]

  MATERIA_LIST << [30, 'Gunner', 'Command', [-2, 0, 3, -4, 5, 2], [], [], 3000, 20000, [2500, 5000, 9000, 14000], [77, 78, 79, 80]]

  # Summon Materias

  MATERIA_LIST << [31, 'Invocation 1', 'Summon', [-10, 10, -5, -5, 0, 10], [], [], 5000, 25000, [6500, 15000, 25000, 50000], [81]]

  MATERIA_LIST << [32, 'Invocation 2', 'Summon', [-10, 10, -5, -5, 0, 10], [], [], 5000, 25000, [6500, 15000, 25000, 50000], [82]]

  MATERIA_LIST << [33, 'Invocation 3', 'Summon', [-10, 10, -5, -5, 0, 10], [], [], 5000, 25000, [6500, 15000, 25000, 50000], [83]]

  # Support Materia

  MATERIA_LIST << [34, 'All', 'Support', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'All']

  MATERIA_LIST << [35, 'Elemental', 'Support', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Elemental']

  MATERIA_LIST << [36, 'Addef Effect', 'Support', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Added Effect']

  MATERIA_LIST << [37, 'Absorb HP', 'Support', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Absorb HP']

  MATERIA_LIST << [38, 'Absorb MP', 'Support', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Absorb MP']

  MATERIA_LIST << [39, 'MP Turbo', 'Support', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'MP Turbo']

  MATERIA_LIST << [40, 'Reduce Cost', 'Support', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Reduce Cost']

  # Independent Materia

  MATERIA_LIST << [41, 'Exp Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [30000], [], 'Exp Plus']

  MATERIA_LIST << [42, 'Gil Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Gil Plus']

  MATERIA_LIST << [43, 'Luck Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Luck Plus']

  MATERIA_LIST << [44, 'HP Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'HP Plus']

  MATERIA_LIST << [45, 'MP Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'MP Plus']

  MATERIA_LIST << [46, 'Strength Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Strength Plus']

  MATERIA_LIST << [47, 'Defense Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Defense Plus']

  MATERIA_LIST << [48, 'Agility Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Agility Plus']

  MATERIA_LIST << [49, 'Magic Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Magic Plus']

  MATERIA_LIST << [50, 'Evasion Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Evasion Plus']

  MATERIA_LIST << [51, 'Critical Chance Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Critical Chance Plus']

  MATERIA_LIST << [52, 'Critical Damage Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Critical Damage Plus']

  MATERIA_LIST << [53, 'Escape Plus', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Escape Plus']

  MATERIA_LIST << [54, 'Unnarmed Attack', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'Unnarmed Attack']

  MATERIA_LIST << [55, 'HP <> MP', 'Independent', [0, 0, 0, 0, 0, 0], [], [], 2000, 10000, [2000, 4000, 7000, 11000], [], 'HP <> MP']

end

 

#==============================================================================

# ** RPG

#==============================================================================

module RPG

  #============================================================================

  # ** Weapon

  #============================================================================

  class Weapon    

    #--------------------------------------------------------------------------

    attr_accessor :paired_materia

    attr_accessor :single_materia

    #--------------------------------------------------------------------------

    def set_materia_slots(slots)

      @paired_materia, @single_materia = slots[0], slots[1]

    end

  end

  #============================================================================

  # ** Armor

  #============================================================================

  class Armor

    #--------------------------------------------------------------------------

    attr_accessor :paired_materia

    attr_accessor :single_materia

    #--------------------------------------------------------------------------

    def set_materia_slots(slots)

      @paired_materia, @single_materia = slots[0], slots[1]

    end

  end

end

 

#==============================================================================

# ** Materia

#==============================================================================

class Materia

  #--------------------------------------------------------------------------

  attr_reader     :id

  attr_accessor   :name

  attr_accessor   :type

  attr_accessor   :stat_effects

  attr_accessor   :elements

  attr_accessor   :states

  attr_accessor   :new_value

  attr_accessor   :master_value

  attr_accessor   :skills

  attr_accessor   :exp_levels

  attr_accessor   :special_effect

  #--------------------------------------------------------------------------

  def initialize(id, name, type, stat_effects = [], elements = [], states = [], 

    n_value = 500, m_value = 1000, skills = [], exp_levels = [], s_effect = nil)

    @id, @name, @type, @stat_effects, @elements, @states,

    @new_value, @master_value, @exp_levels, @skills, @special_effect =

    id, name, type, stat_effects, elements, states,

    n_value, m_value, skills, exp_levels, s_effect

    @experience = 0

  end

  #--------------------------------------------------------------------------

  def experience

    return @experience

  end

  #--------------------------------------------------------------------------

  def experience=(num)

    @experience = [num, @exp_levels[@exp_levels.size - 1]].min

  end

  #--------------------------------------------------------------------------

  def level

    for i in 0...@exp_levels.size

      if @experience >= @exp_levels[@exp_levels.size - (1 + i)]

        return @exp_levels.size - i + 1

      end

    end

    return 1

  end

  #--------------------------------------------------------------------------

  def buy_value

    return @new_value

  end

  #--------------------------------------------------------------------------

  def base_sell_value

    return @new_value / 2

  end

  #--------------------------------------------------------------------------

  def sell_value

    variation = @master_value - (@new_value / 2)

    price_rate = [@experience * 100 / @exp_levels[@exp_levels.size - 1], 100].min

    return [((variation * price_rate) / 100) + (@new_value / 2) ,0].max

  end

  #--------------------------------------------------------------------------

  def get_hue

    case @type

    when 'Magic'

      hue = 130

    when 'Command'

      hue = 60

    when 'Summon'

      hue = 10

    when 'Support'

      hue = 180

    when 'Independent'

      hue = 300

    end

    return hue

  end

end

 

#==============================================================================

# ** Materia_System

#==============================================================================

class Materia_System

  #--------------------------------------------------------------------------

  include Materia_Config

  #--------------------------------------------------------------------------

  attr_accessor :set_up_materias

  #--------------------------------------------------------------------------

  def set_up_materias

    materias = []

    for m in MATERIA_LIST

      materias[m[0]] = Materia.new(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],m[8],m[9],m[10]) if m != nil

    end

    materias.sort! {|a, b| a.id <=> b.id}

    materias = materias.compact

    return materias

  end

end

 

#==============================================================================

# ** Game_Battler

#==============================================================================

class Game_Battler

  #--------------------------------------------------------------------------

  def skill_effect(user, skill)

    self.critical = false

    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or

       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)

      return false

    end

    effective = false

    effective |= skill.common_event_id > 0

    hit = skill.hit

    if skill.atk_f > 0

      hit *= user.hit / 100

    end

    hit_result = (rand(100) < hit)

    effective |= hit < 100

    if hit_result == true

      power = skill.power + ((user.atk + 20) * skill.atk_f / 100)

      if power > 0

        power -= self.pdef * skill.pdef_f / 200

        power -= self.mdef * skill.mdef_f / 200

        power = [power, 0].max

      end

      rate = 50

      rate -= (self.dex / 2 * skill.pdef_f / 200)

      rate -= ((self.dex + self.int)/ 4 * skill.mdef_f / 200)

      rate += (user.str * skill.str_f / 100)

      rate += (user.dex * skill.dex_f / 100)

      rate += (user.agi * skill.agi_f / 100)

      rate += (user.int * skill.int_f / 100)

      self.damage = power * rate / 20

      self.damage *= elements_correct(skill.element_set)

      self.damage /= 100

      if self.damage > 0

        if self.guarding?

          self.damage /= 2

        end

      end

      if self.damage == 0

        dmg1 = (rand(100) < 40)

        self.damage = 1 if dmg1

      end

      if skill.variance > 0 and self.damage.abs > 0

        amp = [self.damage.abs * skill.variance / 100, 1].max

        self.damage += rand(amp+1) + rand(amp+1) - amp

      end

      eva = 8 * self.agi / user.agi + self.eva

      hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100

      hit = self.cant_evade? ? 100 : hit

      hit_result = (rand(100) < hit)

      effective |= hit < 100

    end

    if hit_result == true

      if user.is_a?(Game_Actor)

        for materia in user.weapon_materia + user.armor1_materia + user.armor2_materia + user.armor3_materia + user.armor4_materia

          unless materia.nil?

            self.damage += (self.damage * materia.level * 0.2).to_i if self.damage != 0 and materia.type == 'Summon'

          end

        end

        materia_set = user.return_paired_materia

        for paired_set in materia_set

          materia = paired_set[2]

          other_materia = paired_set[3]

          if materia.special_effect == 'MP Turbo'

            for skill_id in other_materia.skills

              unless skill_id == 0

                m_skill = $data_skills[skill_id]

                if skill == m_skill

                  unless skill.element_set.include?(Materia_Config::Negate_Turbo_ID)

                    self.damage += (self.damage * materia.level * 0.2).to_i if self.damage != 0

                  end

                end

              end

            end

          end

          if materia.special_effect =='Absorb HP'

            for skill_id in other_materia.skills

              unless skill_id == 0

                m_skill = $data_skills[skill_id]

                if skill == m_skill and $game_temp.in_battle

                  unless skill.element_set.include?(Materia_Config::Negate_Absorb_ID)

                    if self.damage > 0

                      dreno = materia.level * 2

                      hp = (self.damage * dreno / 100).to_i

                      user.hp += [hp, user.maxhp - hp].min

                    end

                  end

                end

              end

            end

          end

          if materia.special_effect  =='Absorb MP'

            for skill_id in other_materia.skills

              unless skill_id == 0

                m_skill = $data_skills[skill_id]

                if skill == m_skill and $game_temp.in_battle

                  unless skill.element_set.include?(Materia_Config::Negate_Absorb_ID)

                    if self.damage > 0

                      dreno = materia.level

                      sp = (self.damage * dreno / 100).to_i

                      user.sp += [sp, user.maxsp - sp].min

                    end

                  end

                end

              end

            end

          end

        end  

      end

      if skill.power != 0 and skill.atk_f > 0

        remove_states_shock

        effective = true

      end

      last_hp = self.hp

      self.hp -= self.damage

      effective |= self.hp != last_hp

      @state_changed = false

      effective |= states_plus(skill.plus_state_set)

      effective |= states_minus(skill.minus_state_set)

      if skill.power == 0

        self.damage = ""

        unless @state_changed

          self.damage = "Miss"

        end

      end

    else

      self.damage = "Miss"

    end

    unless $game_temp.in_battle

      self.damage = nil

    end

    return effective

  end

  #--------------------------------------------------------------------------

  def attack_effect(attacker)

    self.critical = false

    hit_result = (rand(100) < attacker.hit)

    if hit_result == true

      atk = [20 + attacker.atk - self.pdef / 2, 1].max

      str = [40 + attacker.str - self.dex / 2, 1].max

      self.damage = atk * str / 20

      self.damage *= elements_correct(attacker.element_set)

      self.damage /= 100

      if self.damage == 0

        dmg1 = (rand(100) < 40)

        self.damage = 1 if dmg1

      end

      if self.damage > 0

        if rand(100) < ((4 * attacker.agi / self.agi) + attacker.critrateplus)

          self.damage += ((self.damage * (100 + attacker.critdmgplus)) / 100)

          self.critical = true

        end

        if self.guarding?

          self.damage /= 2

        end

      end

      if self.damage.abs > 0

        amp = [self.damage.abs * 15 / 100, 1].max

        self.damage += rand(amp+1) + rand(amp+1) - amp

      end

      eva = 8 * self.agi / attacker.agi + self.eva

      hit = self.damage < 0 ? 100 : 100 - eva

      hit = self.cant_evade? ? 100 : hit

      hit_result = (rand(100) < hit)

    end

    if hit_result == true

      remove_states_shock

      self.hp -= self.damage

      @state_changed = false

      states_plus(attacker.plus_state_set)

      states_minus(attacker.minus_state_set)

    else

      self.damage = "Miss"

      self.critical = false

    end

    return true

  end

  #--------------------------------------------------------------------------

  def skill_can_use?(skill_id)

    skill = $data_skills[skill_id]

    return false if calc_sp_cost(self, skill) > self.sp

    return false if dead?

    return false if skill.atk_f == 0 and self.restriction == 1

    occasion = skill.occasion

    return (occasion == 0 or occasion == 1) if $game_temp.in_battle

    return (occasion == 0 or occasion == 2)

  end  

  #--------------------------------------------------------------------------

  def calc_sp_cost(user, skill)

    cost = skill.sp_cost

    if user.is_a?(Game_Actor)

      materia_set = user.return_paired_materia

      for paired_set in materia_set

        materia = paired_set[2]

        other_materia = paired_set[3]

        if materia.special_effect == 'MP Turbo'

          for skill_id in other_materia.skills

            unless skill_id == 0

              m_skill = $data_skills[skill_id]

              if skill == m_skill and !skill.element_set.include?(Materia_Config::Negate_Turbo_ID)

                cost = (cost + (cost * materia.level * 0.2)).to_i

              end

            end

          end

        end

        if materia.special_effect == 'Reduce Cost'

          for skill_id in other_materia.skills

            unless skill_id == 0

              m_skill = $data_skills[skill_id]

              if skill == m_skill

                cost = (cost - (cost * materia.level * 0.1)).to_i

              end

            end

          end

        end

      end

    end

    return cost

  end 

  #--------------------------------------------------------------------------

  def consum_skill_cost(skill)

    return false unless skill_can_use?(skill.id)

    cost = calc_sp_cost(self, skill)

    return self.sp -= cost

  end 

end

 

#==============================================================================

# ** Game_Actor

#==============================================================================

class Game_Actor

  #--------------------------------------------------------------------------

  attr_accessor :weapon_materia

  attr_accessor :armor1_materia

  attr_accessor :armor2_materia

  attr_accessor :armor3_materia

  attr_accessor :armor4_materia

  attr_reader   :ap

  #--------------------------------------------------------------------------

  alias seph_materiasystem_gameactor_init initialize

  alias seph_materiasystem_gameactor_setup setup

  alias seph_materiasystem_gameactor_skills skills

  alias seph_materiasystem_gameactor_equip equip

  alias seph_materiasystem_gameactor_exp exp

  alias seph_materiasystem_gameactor_elementrate element_rate

  alias seph_materiasystem_gameactor_stateguard? state_guard?

  alias seph_materiasystem_gameactor_elementset element_set

  alias seph_materiasystem_gameactor_plusstateset plus_state_set

  #--------------------------------------------------------------------------

  def initialize(actor_id)

    @weapon_materia = Array.new

    @armor1_materia = Array.new

    @armor2_materia = Array.new

    @armor3_materia = Array.new

    @armor4_materia = Array.new

    seph_materiasystem_gameactor_init(actor_id)

  end

  #--------------------------------------------------------------------------

  def setup(actor_id)

    seph_materiasystem_gameactor_setup(actor_id)

    @materia_skills = []

    sn = [$data_weapons[@weapon_id].paired_materia * 2 + $data_weapons[@weapon_id].single_materia, 8].min unless @weapon_id == 0

    @weapon_materia = @weapon_id == 0 ? [] : Array.new(sn, nil)

    sn = [$data_armors[@armor1_id].paired_materia * 2 + $data_armors[@armor1_id].single_materia, 8].min  unless @armor1_id == 0

    @armor1_materia = @armor1_id == 0 ? [] : Array.new(sn, nil)

    sn = [$data_armors[@armor2_id].paired_materia * 2 + $data_armors[@armor2_id].single_materia, 8].min  unless @armor2_id == 0

    @armor2_materia = @armor2_id == 0 ? [] : Array.new(sn, nil)

    sn = [$data_armors[@armor3_id].paired_materia * 2 + $data_armors[@armor3_id].single_materia, 8].min  unless @armor3_id == 0

    @armor3_materia = @armor3_id == 0 ? [] : Array.new(sn, nil)

    sn = [$data_armors[@armor4_id].paired_materia * 2 + $data_armors[@armor4_id].single_materia, 8].min  unless @armor4_id == 0

    @armor4_materia = @armor4_id == 0 ? [] : Array.new(sn, nil)

  end

  #--------------------------------------------------------------------------

  def weapons

    result = []

    result.push($data_weapons[@weapon_id])

    return result

  end

  #--------------------------------------------------------------------------

  def armors

    result = []

    result.push($data_armors[@armor1_id])

    result.push($data_armors[@armor2_id])

    result.push($data_armors[@armor3_id])

    result.push($data_armors[@armor4_id])

    return result

  end

  #--------------------------------------------------------------------------

  def equips

    return weapons + armors

  end

  #--------------------------------------------------------------------------

  def skills

    for skill_id in @materia_skills

      self.forget_skill(skill_id)

    end

    @skills = seph_materiasystem_gameactor_skills

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      self.learn_materia_skill(materia) unless materia.nil?

    end

    return @skills

  end

  #--------------------------------------------------------------------------

  def learn_materia_skill(materia)

    materia_level = materia.level == materia.exp_levels.size + 1 ? materia.level - 1 : materia.level

    for i in 0...materia_level

      if materia.skills[i] != nil and !skill_learn?(materia.skills[i])

        skill_id = materia.skills[i]

        self.learn_skill(skill_id)

        @materia_skills << skill_id

      end

    end

  end

  #--------------------------------------------------------------------------

  def base_maxhp

    n = $data_actors[@actor_id].parameters[0, @level]

    variance = 0

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        variance += materia.stat_effects[0]

        variance += (materia.level * 10) if materia.special_effect == 'HP Plus'

        n = $data_actors[@actor_id].parameters[1, @level] if materia.special_effect == 'HP <> MP'

      end

    end

    n *= ((100 + variance) / 100.0)

    return [[n, 1].max, 9999].min

  end

  #--------------------------------------------------------------------------

  def hp

    @hp = [@hp, maxhp].min

    return @hp

  end

  #--------------------------------------------------------------------------

  def base_maxsp

    n = $data_actors[@actor_id].parameters[1, @level]

    variance = 0

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        variance += materia.stat_effects[1]

        variance += (materia.level * 10) if materia.special_effect == 'MP Plus'

        n = $data_actors[@actor_id].parameters[0, @level] if materia.special_effect == 'HP <> MP'

      end

    end

    n *= ((100 + variance) / 100.0)

    return [[n, 1].max, 9999].min

  end

  #--------------------------------------------------------------------------

  def sp

    @sp = [@sp, maxsp].min

    return @sp

  end

  #--------------------------------------------------------------------------

  def base_str

    n = $data_actors[@actor_id].parameters[2, @level]

    for item in equips.compact do n += item.str_plus end

    variance = 0

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        variance += materia.stat_effects[2]

        variance += (materia.level * 5) if materia.special_effect == 'Strength Plus'

      end

    end

    n *= ((100 + variance) / 100.0)

    return [[n, 1].max, 999].min

  end

  #--------------------------------------------------------------------------

  def base_dex

    n = $data_actors[@actor_id].parameters[3, @level]

    for item in equips.compact do n += item.dex_plus end

    variance = 0

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        variance += materia.stat_effects[3]

        variance += (materia.level * 5) if materia.special_effect == 'Defense Plus'

      end

    end

    n *= ((100 + variance) / 100.0)

    return [[n, 1].max, 999].min

  end

  #--------------------------------------------------------------------------

  def base_agi

    n = $data_actors[@actor_id].parameters[4, @level]

    for item in equips.compact do n += item.agi_plus end

    variance = 0

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        variance += materia.stat_effects[4]

        variance += (materia.level * 5) if materia.special_effect == 'Agility Plus'

      end

    end

    n *= ((100 + variance) / 100.0)

    return [[n, 1].max, 999].min

  end

  #--------------------------------------------------------------------------

  def base_int

    n = $data_actors[@actor_id].parameters[5, @level]

    for item in equips.compact do n += item.int_plus end

    variance = 0

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        variance += materia.stat_effects[5]

        variance += (materia.level * 5) if materia.special_effect == 'Magic Plus'

      end

    end

    n *= ((100 + variance) / 100.0)

    return [[n, 1].max, 999].min

  end

  #--------------------------------------------------------------------------

  def base_eva

    n = 0

    for item in armors.compact do n += item.eva end

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        n += (materia.level * 2) if materia.special_effect == 'Evasion Plus'

      end

    end

    return n = [[Integer(n), 0].max, 100].min

  end

  #--------------------------------------------------------------------------

  def critrateplus

    variance = 0

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        variance += (materia.level * 5) if materia.special_effect == 'Critical Chance Plus'

      end

    end

    return variance

  end 

  #--------------------------------------------------------------------------

  def critdmgplus

    variance = 0

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        variance += (materia.level * 20) if materia.special_effect == 'Critical Damage Plus'

      end

    end

    return variance

  end 

  #--------------------------------------------------------------------------

  def escapeplus

    variance = 0

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        variance += (materia.level * 2) if materia.special_effect == 'Escape Plus'

      end

    end

    return variance

  end  

  #--------------------------------------------------------------------------

  def itemdropup

    variance = 0

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        variance += (materia.level * 2) if materia.special_effect == 'Luck Plus'

      end

    end

    return variance

  end

  #--------------------------------------------------------------------------

  def base_atk

    n = 0

    variance = 0

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        variance += (materia.level * 20) if materia.special_effect == 'Unnarmed Attack'

      end

    end

    for item in weapons.compact do n += item.atk end

    weapon = $data_weapons[@weapon_id]

    n = 20 + ((20 * variance) /100) if weapons[0] == nil

    return n

  end

  #--------------------------------------------------------------------------

  def animation2_id

    weapon = $data_weapons[@weapon_id]

    return weapon != nil ? weapon.animation2_id : 4

  end

  #--------------------------------------------------------------------------

  def exp=(exp)

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      self.forget_skill(materia.id) unless materia.nil?

    end

    @materia_skills = []

    if exp > @exp

      new_exp = exp - @exp

      exp_plus = 0

      for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

        unless materia.nil?

          if materia.special_effect == 'Exp Plus'

            exp_plus += (materia.level * 10)

          end

        end

      end

      new_exp *= ((100 + exp_plus) / 100.0)

      exp = new_exp.to_i + @exp

    end

    @exp = [[exp, 999999999999999].min, 0].max

    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0

      @level += 1

      for j in $data_classes[@class_id].learnings

        if j.level == @level

          learn_skill(j.skill_id)

        end

      end

    end

    while @exp < @exp_list[@level]

      @level -= 1

    end

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      self.learn_materia_skill(materia) unless materia.nil?

    end

    @hp = [@hp, self.maxhp].min

    @sp = [@sp, self.maxsp].min

  end

  #--------------------------------------------------------------------------

  def ap

    return @ap == nil ? 0 : @ap

  end

  #--------------------------------------------------------------------------

  def ap=(ap)

    @ap = ap

    for materia in @weapon_materia + @armor1_materia + @armor2_materia + @armor3_materia + @armor4_materia 

      unless materia.nil?

        initial_level = materia.level

        materia.experience += @ap

        final_level = materia.level

        if initial_level < (materia.exp_levels.size + 1) and final_level ==  (materia.exp_levels.size + 1)

          $game_party.gain_materia(materia.id)

        end

      end

    end

    @ap = 0

  end

  #--------------------------------------------------------------------------

  def element_rate(element_id)

    result = seph_materiasystem_gameactor_elementrate(element_id)

    paired = return_paired_materia

    for set in paired

      if set[0] > 0

        materia = set[2]

        if materia.special_effect == 'Elemental'

          other_materia = set[3]

          if other_materia.elements.include?(element_id)

            result /= 2

          end

        end

      end

    end

    return result

  end

  #--------------------------------------------------------------------------

  def state_guard?(state_id)

    result = seph_materiasystem_gameactor_stateguard?(state_id)

    unless result

      paired = return_paired_materia

      for set in paired

        if set[0] > 0

          materia = set[2]

          if materia.special_effect == 'Added Effect'

            other_materia = set[3]

            if other_materia.states.include?(state_id)

              result = true

            end

          end

        end

      end

    end

    return result

  end

  #--------------------------------------------------------------------------

  def element_set

    result = seph_materiasystem_gameactor_elementset

    paired = return_paired_materia

    for set in paired

      if set[0] == 0

        materia = set[2]

        if materia.special_effect == 'Elemental'

          other_materia = set[3]

          for elem_id in other_materia.elements

            result << elem_id unless set.include?(elem_id)

          end

        end

      end

    end

    return result

  end

  #--------------------------------------------------------------------------

  def plus_state_set

    result = seph_materiasystem_gameactor_plusstateset

    paired = return_paired_materia

    for set in paired

      if set[0] == 0

        materia = set[2]

        if materia.special_effect == 'Added Effect'

          other_materia = set[3]

          for state_id in other_materia.states

            result << state_id unless set.include?(state_id)

          end

        end

      end

    end

    return result

  end

  #------------------------------------------------------------------------------

  def check_old_equip

    @old_weapon_id = @weapon_id

    @old_armor1_id = @armor1_id

    @old_armor2_id = @armor2_id

    @old_armor3_id = @armor3_id

    @old_armor4_id = @armor4_id

  end

  #------------------------------------------------------------------------------

  def check_equip_change

    if  @old_weapon_id != @weapon_id

      for materia in @weapon_materia

        $game_party.materia << materia unless materia.nil?

      end

      sn = [$data_weapons[@weapon_id].paired_materia * 2 +  $data_weapons[@weapon_id].single_materia, 8].min  unless @weapon_id == 0

      @weapon_materia = @weapon_id == 0 ? [] : Array.new(sn, nil)

    end

    if  @old_armor1_id != @armor1_id

      for materia in @armor1_materia

        $game_party.materia << materia unless materia.nil?

      end

      sn = [$data_armors[@armor1_id].paired_materia * 2 +  $data_armors[@armor1_id].single_materia, 8].min  unless @armor1_id == 0

      @armor1_materia = @armor1_id == 0 ? [] : Array.new(sn, nil)

    end

    if  @old_armor2_id != @armor2_id

      for materia in @armor2_materia

        $game_party.materia << materia unless materia.nil?

      end

      sn = [$data_armors[@armor2_id].paired_materia * 2 +  $data_armors[@armor2_id].single_materia, 8].min  unless @armor2_id == 0

      @armor2_materia = @armor2_id == 0 ? [] : Array.new(sn, nil)

    end

    if  @old_armor3_id != @armor3_id

      for materia in @armor3_materia

        $game_party.materia << materia unless materia.nil?

      end

      sn = [$data_armors[@armor3_id].paired_materia * 2 +  $data_armors[@armor3_id].single_materia, 8].min  unless @armor3_id == 0

      @armor3_materia = @armor3_id == 0 ? [] : Array.new(sn, nil)

    end

    if  @old_armor4_id != @armor4_id

      for materia in @armor4_materia

        $game_party.materia << materia unless materia.nil?

      end

      sn = [$data_armors[@armor4_id].paired_materia * 2 +  $data_armors[@armor4_id].single_materia, 8].min  unless @armor4_id == 0

      @armor4_materia = @armor4_id == 0 ? [] : Array.new(sn, nil)

    end

  end

  #--------------------------------------------------------------------------

  def equip_materia(equip_type, slot_index, index)

    new_materia = $game_party.materia[index]

    materia = equip_type == 0 ?  @weapon_materia[slot_index] : (eval "@armor#{equip_type}_materia")[slot_index]

    $game_party.materia << materia unless materia.nil?

    case equip_type

    when 0

      return if @weapon_materia.size == 0

      @weapon_materia[slot_index] = new_materia

    when 1  

      return if @armor1_materia.size == 0

      @armor1_materia[slot_index] = new_materia

    when 2  

      return if @armor2_materia.size == 0

      @armor2_materia[slot_index] = new_materia

    when 3  

      return if @armor3_materia.size == 0

      @armor3_materia[slot_index] = new_materia

    when 4  

      return if @armor4_materia.size == 0

      @armor4_materia[slot_index] = new_materia

    end

    $game_party.materia.delete_at(index)

  end

  #--------------------------------------------------------------------------

  def unequip_materia(equip_type, slot_index)

    materia = equip_type == 0 ? @weapon_materia[slot_index] : (eval "@armor#{equip_type}_materia")[slot_index]

    $game_party.materia << materia unless materia.nil?

    equip_type == 0 ? @weapon_materia[slot_index] = nil : (eval "@armor#{equip_type}_materia")[slot_index] = nil

  end

  #--------------------------------------------------------------------------

  def return_paired_materia

    paired = []

    unless @weapon_id == 0

      if $data_weapons[@weapon_id].paired_materia > 0

        for i in 0...($data_weapons[@weapon_id].paired_materia * 2)

          materia = @weapon_materia[i]

          if materia.type == 'Support'

            o_i = i + ([0, 2, 4, 6].include?(i) ? 1 : - 1)

            other_materia = @weapon_materia[o_i]

            paired << [0, [i, o_i].min, materia, other_materia] unless other_materia.nil?

          end

        end

      end

    end

    for a in 1..4

      unless (eval "@armor#{a}_id") == 0

        if (eval "$data_armors[@armor#{a}_id].paired_materia") > 0

          for i in 0...((eval "$data_armors[@armor#{a}_id].paired_materia") * 2)

            materia = (eval "@armor#{a}_materia")[i]

            if materia.type == 'Support'

              o_i = i + ([0, 2, 4, 6].include?(i) ? 1 : - 1)

              other_materia = (eval "@armor#{a}_materia")[o_i]

              paired << [a, [i, o_i].min, materia, other_materia] unless other_materia.nil?

            end

          end

        end

      end

    end

    return paired

  end

  #--------------------------------------------------------------------------

  def return_paired_materia_type

    unless @weapon_id == 0

      if $data_weapons[@weapon_id].paired_materia > 0

        for i in 0...($data_weapons[@weapon_id].paired_materia)

          materia = @weapon_materia[i]

        end

      end

      if $data_weapons[@weapon_id].single_materia > 0

        for i in 0...($data_weapons[@weapon_id].single_materia)

          materia = @weapon_materia[i]

        end

      end

    end

    for a in 1..4

      unless (eval "@armor#{a}_id") == 0

        if (eval "$data_armors[@armor#{a}_id].paired_materia") > 0

          for i in 0...((eval "$data_armors[@armor#{a}_id].paired_materia"))

            materia = (eval "@armor#{a}_materia")[i]

          end

        end

        if (eval "$data_armors[@armor#{a}_id].single_materia") > 0

          for i in 0...((eval "$data_armors[@armor#{a}_id].single_materia"))

            materia = (eval "@armor#{a}_materia")[i]

          end

        end

      end

    end

    return

  end

end

 

#==============================================================================

# ** Game_Enemy

#==============================================================================

class Game_Enemy < Game_Battler

  #------------------------------------------------------------------------------

  attr_accessor   :ap

  #------------------------------------------------------------------------------

  alias old_initialize initialize

  def initialize(troop_id, member_index)

    old_initialize(troop_id, member_index)

    @enemy = $data_enemies[@enemy_id]

    @ap = get_ap

  end

  #------------------------------------------------------------------------------

  def get_ap

    for i in 0...Materia_Config::ENEMY_AP.size

      ap = Materia_Config::ENEMY_AP[i] if @enemy_id == i

    end

    return ap == nil ? (@enemy.exp / 10).to_i : ap

  end

  #------------------------------------------------------------------------------

  def ap

    return @ap == nil ? (@enemy.exp / 10).to_i : @ap

  end

  #------------------------------------------------------------------------------

  def critrateplus

    return 0

  end 

  #--------------------------------------------------------------------------

  def critdmgplus

    return 0

  end 

end

 

#==============================================================================

# ** Game_Party

#==============================================================================

class Game_Party

  #--------------------------------------------------------------------------

  attr_accessor   :materia

  #--------------------------------------------------------------------------

  alias seph_materiasystem_gameparty_init initialize

  alias seph_materiasystem_gameparty_gaingold gain_gold

  #--------------------------------------------------------------------------

  def initialize

    seph_materiasystem_gameparty_init

    @materia = []

  end

  #--------------------------------------------------------------------------

  def gain_materia(materia_index)

    @materia << $data_materia[materia_index].dup

  end

  #--------------------------------------------------------------------------

  def gain_gold(n)

    gil_plus = 0

    for actor in @actors

      for materia in actor.weapon_materia + actor.armor1_materia + 

        actor.armor2_materia + actor.armor3_materia + actor.armor4_materia

        unless materia.nil?

          if materia.special_effect == 'Gil Plus'

            gil_plus += (materia.level * 5)

          end

        end

      end

    end

    n *= (100 + gil_plus) / 100.0

    seph_materiasystem_gameparty_gaingold(n.to_i)

  end

end

 

#==============================================================================

# Window Horizontal Command

#==============================================================================

class Window_HorizCommand < Window_Selectable

  #--------------------------------------------------------------------------

  def initialize(commands, width = 640, height = 64)

    super(0, 0, width, height)

    self.contents = Bitmap.new(width - 32, height - 32)

    @commands = commands

    @item_max = @commands.size

    @column_max = @commands.size

    refresh

    self.index = 0

  end

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    for i in 0...@item_max

      draw_item(i, normal_color)

    end

  end

  #--------------------------------------------------------------------------

  def draw_item(index, color)

    self.contents.font.color = color

    x = width / @item_max * index

    off = width / @item_max - 32

    self.contents.draw_text(x, 0, off, 32, @commands[index], 1)

  end

  #--------------------------------------------------------------------------

  def disable_item(index)

    draw_item(index, disabled_color)

  end

end

 

#==============================================================================

# ** Window_MateriaBio

#==============================================================================

class Window_MateriaBio < Window_Base

  #--------------------------------------------------------------------------

  def initialize

    super(240, 128, 400, 352)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.visible = false

  end

  #--------------------------------------------------------------------------

  def refresh(materia)

    self.contents.clear

    return if materia.nil?

    hue = materia.get_hue

    begin

      bitmap = RPG::Cache.icon(materia.name + "_m").dup

    rescue

      bitmap = RPG::Cache.icon(Materia_Config::Default_Icon).dup

      bitmap.hue_change(hue)

    end

    self.contents.blt(4, 0, bitmap, Rect.new(0, 0, 24, 24))

    self.contents.font.size = 22

    self.contents.font.color = normal_color

    self.contents.font.bold = false

    self.contents.draw_text(32, 0, contents.width, 24, materia.name)

    bitmap = RPG::Cache.icon(Materia_Config::Materia_Level).dup

    bitmap.hue_change(hue)

    start_x = contents.width / 2 - 20

    materia.level.times do

      self.contents.blt(start_x += 24, 0, bitmap, Rect.new(0, 0, 24, 24))

    end

    (materia.exp_levels.size + 1 - materia.level).times do

      self.contents.blt(start_x += 24, 0, bitmap, Rect.new(0, 0, 24, 24), 100)

    end

    self.contents.font.size = 16

    self.contents.font.bold = true

    self.contents.draw_text(172, 44, 172, 16, 'Level:')

    lev = materia.level == materia.exp_levels.size + 1 ? Materia_Config::Master_Text : materia.level.to_s

    self.contents.draw_text(172, 44, 172, 16, lev, 2)

    self.contents.draw_text(172, 60, 172, 16, Materia_Config::AP_Total)

    self.contents.draw_text(172, 60, 172, 16, materia.experience.to_s, 2)

    self.contents.draw_text(172, 76, 172, 16, 'Next Level:')

    nxt = lev == Materia_Config::Master_Text ? '----------' : materia.exp_levels[materia.level - 1] - materia.experience

    self.contents.draw_text(172, 76, 172, 16, nxt.to_s, 2)

    self.contents.draw_text(4, 28, contents.width, 24, 'Skills:')

    materia_y = 0

    for i in 0...(materia.level)

      self.contents.font.color = normal_color

      unless materia.skills[i].nil?

        self.contents.draw_text(16, 44 + materia_y, contents.width / 2 - 8, 16, $data_skills[materia.skills[i]].name)

        materia_y += 16

      end

    end

    for i in (materia.level)...materia.skills.size

      self.contents.font.color = disabled_color

      unless materia.skills[i].nil?

        self.contents.draw_text(16, 44 + materia_y, contents.width / 2 - 8, 16, $data_skills[materia.skills[i]].name)

        materia_y += 16

      end

    end

    if materia.skills.size == 0

      self.contents.draw_text(8, 52, contents.width / 2 - 8, 24, '')

    end

    self.contents.font.color = normal_color

    se = materia.special_effect.nil? ? '----------' : materia.special_effect

    self.contents.draw_text(8, 172, contents.width, 24, "Special Effect: #{se}")

    self.contents.font.size = 16

    self.contents.font.bold = true

    self.contents.draw_text(8, 200, 160, 16, "Buy: #{materia.new_value}")

    self.contents.draw_text(132, 200, 160, 16, "Sell: #{materia.base_sell_value}")

    self.contents.draw_text(236, 200, 160, 16, Materia_Config::Master_Text + ": #{materia.master_value}")

    self.contents.font.size = 14

    self.contents.draw_text(8, 222, contents.width / 2, 14, 'Status:')

    stat_names = [Materia_Config::Hp_Text, Materia_Config::Sp_Text, Materia_Config::Str_Text,Materia_Config::Vit_Text, Materia_Config::Agi_Text, Materia_Config::Int_Text]

    for i in 0...materia.stat_effects.size

      self.contents.draw_text(8, 222 + (i + 1) * 14, contents.width / 2, 14, stat_names[i])

      self.contents.draw_text(- 8, 222 + (i + 1)  * 14, contents.width / 2, 14, "#{materia.stat_effects[i]} %", 2)

    end

    self.contents.font.size = 14

    x, y = contents.width / 2 + 4, 222

    self.contents.draw_text(x, y, contents.width / 2, 14, 'Elements/Effects:')

    if materia.elements.size + materia.states.size == 0

      self.contents.draw_text(x + 4, y + 14, contents.width / 2, 14, '')

    else

      total = 1

      for i in 0...materia.elements.size

        total += 1

        ox = 4 + total % 2 * (contents.width / 4)

        oy = total / 2 * 14

        self.contents.draw_text(x + ox, y + oy, contents.width / 2, 14, $data_system.elements[materia.elements[i]])

      end

      for i in 0...materia.states.size

        total += 1

        ox = 4 + total % 2 * (contents.width / 4)

        oy = total / 2 * 14

        self.contents.draw_text(x + ox, y + oy, contents.width / 2, 14, $data_states[materia.states[i]].name)

      end

    end

  end

end

 

#==============================================================================

# ** Window_MateriaList

#==============================================================================

class Window_MateriaList < Window_Selectable

  #--------------------------------------------------------------------------

  def initialize(buying, materia_list = nil, show_cost = true)

    super(0, 128, 240, 352)

    self.visible = self.active = false

    if buying

      @materia = []

      for index in materia_list

        for materia in $data_materia

          @materia << materia if index == materia.id

        end

      end

    else

      @materia = $game_party.materia.sort! {|a, b| a.id <=> b.id}

    end

    @buying, @show_cost = buying, show_cost

    refresh

    self.index = 0

  end

  #--------------------------------------------------------------------------

  def materia

    return @materia[self.index]

  end

  #--------------------------------------------------------------------------

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @materia.sort! {|a, b| a.id <=> b.id}

    @item_max = @materia.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

  #--------------------------------------------------------------------------

  def draw_item(index)

    if @buying

      self.contents.font.color = materia.buy_value > $game_party.gold ? disabled_color : normal_color

    end

    materia = @materia[index]

    hue = materia.get_hue

    self.contents.fill_rect(Rect.new(0, index * 32, contents.width, 32), Color.new(0, 0, 0, 0))

    begin

      bitmap = RPG::Cache.icon(materia.name + "_m").dup

    rescue

      bitmap = RPG::Cache.icon(Materia_Config::Default_Icon).dup

      bitmap.hue_change(hue)

    end

    self.contents.blt(4, index * 32 + 4, bitmap, Rect.new(0, 0, 24, 24))

    self.contents.draw_text(28, index * 32, 128, 32, materia.name)

    if @show_cost

      value = @buying ? materia.buy_value : materia.sell_value

      self.contents.draw_text(132, index * 32, 72, 32, ":#{value}", 2)

    end

  end

end

 

#==============================================================================

# ** Window_MateriaStatus

#==============================================================================

class Window_MateriaStatus < Window_Base

  #--------------------------------------------------------------------------

  def initialize(actor)

    super(0, 0, 640, 152)

    self.contents = Bitmap.new(width - 32, height - 32)

    @actor = actor

    @frame = 0

    refresh

  end

  #--------------------------------------------------------------------------

  def refresh(actor = @actor)

    self.contents.clear

    draw_actor_face(actor, 4, 96) if Materia_Config::Show_Faces

    draw_actor_graphic(actor, 40, 80)unless Materia_Config::Show_Faces

    draw_actor_name(actor, 92, 0)

    draw_actor_level(actor, 92, 24)

    draw_actor_hp(actor, 92, 52)

    draw_actor_sp(actor, 92, 80)

  end

  #--------------------------------------------------------------------------

  def update

    super

  end

end

 

#==============================================================================

# ** Window_MateriaActor

#==============================================================================

class Window_MateriaActor < Window_Base

  #--------------------------------------------------------------------------

  def initialize(actor)

    super(0, 0, 640, 152)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.opacity = 0

    @actor = actor

    @frame = 0

    refresh

  end

  #--------------------------------------------------------------------------

  def refresh(actor = @actor)

    self.contents.clear

    draw_actor_equipment

    draw_actor_materia

  end

  #--------------------------------------------------------------------------

  def draw_actor_equipment

    draw_equipment(240, 0, $data_weapons[@actor.weapon_id], 0)

    draw_equipment(240, 24, $data_armors[@actor.armor1_id], 1)

    draw_equipment(240, 48, $data_armors[@actor.armor2_id], 2)

    draw_equipment(240, 72, $data_armors[@actor.armor3_id], 3)

    draw_equipment(240, 96, $data_armors[@actor.armor4_id], 4)

  end

  #--------------------------------------------------------------------------

  def draw_actor_materia

    self.contents.fill_rect(416, 0, 192, 120, Color.new(0, 0, 0, 0))

    for i in 0..4

      self.contents.fill_rect(416, i * 24 + 2, 192, 22, Color.new(0, 0, 0, 50))

    end

    for i in 0..4

      slots_x, y = 416 - 24, i * 24

      if i == 0

        if @actor.weapon_id == 0

          p_times, s_times = 0, 0

        else

          p_times = $data_weapons[@actor.weapon_id].paired_materia

          s_times = $data_weapons[@actor.weapon_id].single_materia

        end

      else

        if (eval "@actor.armor#{i}_id") == 0

          p_times, s_times = 0, 0

        else

          p_times = eval "$data_armors[@actor.armor#{i}_id].paired_materia"

          s_times = eval "$data_armors[@actor.armor#{i}_id].single_materia"

        end

      end

      p_times.times do

        bitmap = RPG::Cache.icon(Materia_Config::Paired_Slot_Left)

        self.contents.blt(slots_x += 24, y, bitmap, Rect.new(0, 0, 24, 24))

        bitmap = RPG::Cache.icon(Materia_Config::Paired_Slot_Right)

        self.contents.blt(slots_x += 24, y, bitmap, Rect.new(0, 0, 24, 24))

      end

      s_times.times do

        bitmap = RPG::Cache.icon(Materia_Config::Single_Slot)

        self.contents.blt(slots_x += 24, y, bitmap, Rect.new(0, 0, 24, 24))

      end

    end

    for i in [email=0...@actor.weapon]0...@actor.weapon[/email]_materia.size

      materia = @actor.weapon_materia[i]

      unless materia.nil?

        hue = materia.get_hue

        begin

          bitmap = RPG::Cache.icon(materia.name + "_m").dup

        rescue

          bitmap = RPG::Cache.icon(Materia_Config::Default_Icon).dup

          bitmap.hue_change(hue)

        end

        self.contents.blt(416 + i * 24, 0, bitmap, Rect.new(0, 0, 24, 24))

      end

    end

    for h in 1..4

      size = eval "@actor.armor#{h}_materia.size"

      for i in 0...size

        list = eval "@actor.armor#{h}_materia"

        materia = list[i]

        unless materia.nil?

          hue = materia.get_hue

          begin

            bitmap = RPG::Cache.icon(materia.name + "_m").dup

          rescue

            bitmap = RPG::Cache.icon(Materia_Config::Default_Icon).dup

            bitmap.hue_change(hue)

          end

          self.contents.blt(416 + i * 24, 24 * h, bitmap, Rect.new(0, 0, 24, 24))

        end

      end

    end

  end

  #--------------------------------------------------------------------------

  def update

    super

  end

  #--------------------------------------------------------------------------

  def draw_equipment(x, y, item, type)

    if item.nil?

      case type

      when 0  

        bitmap = RPG::Cache.icon(Materia_Config::Empty_Weapon)

      when 1 

        bitmap = RPG::Cache.icon(Materia_Config::Empty_Armor1)

      when 2 

        bitmap = RPG::Cache.icon(Materia_Config::Empty_Armor2)

      when 3 

        bitmap = RPG::Cache.icon(Materia_Config::Empty_Armor3)

      when 4 

        bitmap = RPG::Cache.icon(Materia_Config::Empty_Armor4)

      end

      contents.font.color, text, opacity = disabled_color, Materia_Config::Empty_Message, disabled_color.alpha

    else

      bitmap = RPG::Cache.icon(item.icon_name)

      contents.font.color, text, opacity = normal_color, item.name, 255

    end

    self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24), opacity)

    self.contents.draw_text(x + 28, y, 148, 24, text, 1)

  end

end

 

#==============================================================================

# ** Window_MateriaEquipBio

#==============================================================================

class Window_MateriaEquipBio < Window_Base

  #--------------------------------------------------------------------------

  def initialize

    super(0, 152, 400, 328)

    self.contents = Bitmap.new(width - 32, height - 32)

  end

  #--------------------------------------------------------------------------

  def refresh(materia)

    self.contents.clear

    return if materia.nil?

    hue = materia.get_hue

    begin

      bitmap = RPG::Cache.icon(materia.name + "_m").dup

    rescue

      bitmap = RPG::Cache.icon(Materia_Config::Default_Icon).dup

      bitmap.hue_change(hue)

    end

    self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 24, 24))

    self.contents.font.color = normal_color

    self.contents.font.size = 22

    self.contents.font.bold = false

    self.contents.draw_text(32, 0, contents.width, 24, materia.name)

    bitmap = RPG::Cache.icon(Materia_Config::Materia_Level).dup

    bitmap.hue_change(hue)

    start_x = contents.width / 2 - 20

    materia.level.times do

      self.contents.blt(start_x += 24, 0, bitmap, Rect.new(0, 0, 24, 24))

    end

    (materia.exp_levels.size + 1 - materia.level).times do

      self.contents.blt(start_x += 24, 0, bitmap, Rect.new(0, 0, 24, 24), 100)

    end

    self.contents.font.size = 16

    self.contents.font.bold = true

    self.contents.draw_text(4, 28, contents.width, 16, 'Skills:')

    materia_y = 0

    for i in 0...(materia.level)

      self.contents.font.color = normal_color

      unless materia.skills[i].nil?

        self.contents.draw_text(16, 44 + materia_y, contents.width / 2 - 8, 16, $data_skills[materia.skills[i]].name)

        materia_y += 16

      end

    end

    for i in (materia.level)...materia.skills.size

      self.contents.font.color = disabled_color

      unless materia.skills[i].nil?

        self.contents.draw_text(16, 44 + materia_y, contents.width / 2 - 8, 16, $data_skills[materia.skills[i]].name)

        materia_y += 16

      end

    end

    self.contents.font.color = normal_color

    self.contents.draw_text(172, 44, 172, 16, 'Level:')

    lev = materia.level == materia.exp_levels.size + 1 ? Materia_Config::Master_Text : materia.level.to_s

    self.contents.draw_text(172, 44, 172, 16, lev, 2)

    self.contents.draw_text(172, 60, 172, 16, Materia_Config::AP_Total)

    self.contents.draw_text(172, 60, 172, 16, materia.experience.to_s, 2)

    self.contents.draw_text(172, 76, 172, 16, 'Next Level:')

    nxt = lev == Materia_Config::Master_Text ? '----------' : materia.exp_levels[materia.level - 1] - materia.experience

    self.contents.draw_text(172, 76, 172, 16, nxt.to_s, 2)

    se = materia.special_effect.nil? ? '----------' : materia.special_effect

    self.contents.draw_text(8, 164, contents.width, 16, "Special Effect: #{se}")

    self.contents.draw_text(8, 188, contents.width / 2, 16, 'Status:')

    stat_names = [Materia_Config::Hp_Text, Materia_Config::Sp_Text, Materia_Config::Str_Text,Materia_Config::Vit_Text, Materia_Config::Agi_Text, Materia_Config::Int_Text]

    for i in 0...materia.stat_effects.size

      self.contents.draw_text(8, 188 + (i + 1) * 14, contents.width / 2, 16, stat_names[i])

      self.contents.draw_text(- 8, 188 + (i + 1)  * 14, contents.width / 2, 16, "#{materia.stat_effects[i]} %", 2)

    end

    x, y = contents.width / 2 + 4, 188

    self.contents.draw_text(x, y, contents.width / 2, 16, 'Elements/Effects')

    if materia.elements.size + materia.states.size == 0

      self.contents.draw_text(x + 4, y + 14, contents.width / 2, 16, '')

    else

      total = 1

      for i in 0...materia.elements.size

        total += 1

        ox = 4 + total % 2 * (contents.width / 4)

        oy = total / 2 * 16

        self.contents.draw_text(x + ox, y + oy, contents.width / 2, 16, $data_system.elements[materia.elements[i]])

      end

      for i in 0...materia.states.size

        total += 1

        ox = 4 + total % 2 * (contents.width / 4)

        oy = total / 2 * 16

        self.contents.draw_text(x + ox, y + oy, contents.width / 2, 16, $data_states[materia.states[i]].name)

      end

    end

  end

end

 

#==============================================================================

# ** Window_Base

#==============================================================================

class Window_Base < Window

  #--------------------------------------------------------------------------

  def draw_actor_face(actor, x, y)

    face = RPG::Cache.character("Faces/" + actor.character_name, actor.character_hue)

    fw = face.width

    fh = face.height

    src_rect = Rect.new(0, 0, fw, fh)

    self.contents.blt(x - fw / 23, y - fh, face, src_rect)

  end

  #--------------------------------------------------------------------------

  def draw_actor_parameter(actor, x, y, type)

    case type

    when 0

      parameter_name = $data_system.words.atk

      parameter_value = actor.atk

    when 1

      parameter_name = $data_system.words.pdef

      parameter_value = actor.pdef

    when 2

      parameter_name = $data_system.words.mdef

      parameter_value = actor.mdef

    when 3

      parameter_name = $data_system.words.str

      parameter_value = actor.str

    when 4

      parameter_name = Materia_Config::Vit_Text

      parameter_value = actor.dex

    when 5

      parameter_name = $data_system.words.agi

      parameter_value = actor.agi

    when 6

      parameter_name = $data_system.words.int

      parameter_value = actor.int

    end

    self.contents.font.color = system_color

    self.contents.draw_text(x, y, 120, 32, parameter_name)

    self.contents.font.color = normal_color

    self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)

  end

end

 

#==============================================================================

# Window_Command

#==============================================================================

class Window_Command_Materia < Window_Selectable

  #--------------------------------------------------------------------------

  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

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    for i in 0...@item_max

      draw_item(i, normal_color)

    end

  end

  #--------------------------------------------------------------------------

  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

  #--------------------------------------------------------------------------

  def disable_item(index)

    draw_item(index, disabled_color)

  end

end

 

#==============================================================================

# ** Window_Skill

#==============================================================================

class Window_Skill < Window_Selectable

  #--------------------------------------------------------------------------

  def draw_item(index)

    skill = @data[index]

    if @actor.skill_can_use?(skill.id)

      self.contents.font.color = normal_color

    else

      self.contents.font.color = disabled_color

    end

    x = 4 + index % 2 * (288 + 32)

    y = index / 2 * 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(skill.icon_name)

    opacity = self.contents.font.color == normal_color ? 255 : 128

    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)

    cost = @actor.calc_sp_cost(@actor, skill)

    self.contents.draw_text(x + 232, y, 48, 32, cost.to_s, 2)

  end

end

 

#==============================================================================

# ** Window_BattleResult

#==============================================================================

class Window_BattleResult < Window_Base

  #------------------------------------------------------------------------------

  def initialize(exp, gold, treasures, ap=0)

    @ap = ap

    @exp = exp

    @gold = gold

    @treasures = treasures

    super(140, 0, 360, @treasures.size * 32 + 64)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.contents.font.name = $fontface

    self.contents.font.size = $fontsize

    self.y = 160 - height / 2

    self.back_opacity = 160

    self.visible = false

    refresh

  end

  #------------------------------------------------------------------------------

  def refresh

    self.contents.clear

    x = 4

    self.contents.font.color = normal_color

    cx = contents.text_size(@exp.to_s).width

    self.contents.draw_text(x, 0, cx, 32, @exp.to_s)

    x += cx + 4

    self.contents.font.color = system_color

    cx = contents.text_size("EXP").width

    self.contents.draw_text(x, 0, 64, 32, "EXP")

    x += cx + 16

    self.contents.font.color = normal_color

    cx = contents.text_size(@gold.to_s).width

    self.contents.draw_text(x, 0, cx, 32, @gold.to_s)

    x += cx + 4

    self.contents.font.color = system_color

    self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)

    x += cx + 16

    self.contents.font.color = normal_color

    cx = contents.text_size(@ap.to_s).width

    self.contents.draw_text(x, 0, cx, 32, @ap.to_s)

    x += cx + 4

    self.contents.font.color = system_color

    cx = contents.text_size(Materia_Config::AP_Name).width

    self.contents.draw_text(x, 0, 64, 32, Materia_Config::AP_Name)

    y = 32

    for item in @treasures

      draw_item_name(item, 4, y)

      y += 32

    end

  end

end

 

#==============================================================================

# ** Interpreter

#==============================================================================

class Interpreter

  #------------------------------------------------------------------------------

  def command_319

    actor = $game_actors[@parameters[0]]

    actor.check_old_equip

    if actor != nil

      actor.equip(@parameters[1], @parameters[2])

    end

    actor.check_equip_change

    return true

  end

end

 

#==============================================================================

# ** Scene_Title

#==============================================================================

class Scene_Title

  #--------------------------------------------------------------------------

  include Materia_Config

  #--------------------------------------------------------------------------

  alias seph_materiasystem_scenetitle_main main

  alias seph_materiasystem_scenetitle_newgame command_new_game

  alias seph_materiasystem_scenetitle_continue command_continue

  #--------------------------------------------------------------------------

  def main

    seph_materiasystem_scenetitle_main

    materias = Materia_System.new

    $data_materia = materias.set_up_materias

  end

  #--------------------------------------------------------------------------

  def command_new_game

    materias = Materia_System.new

    $data_materia = materias.set_up_materias

    for i in 1...$data_weapons.size

      if WEAPON_MATERIA_SLOTS[i] != nil

        $data_weapons[i].set_materia_slots(WEAPON_MATERIA_SLOTS[i])

      else

        $data_weapons[i].set_materia_slots([0,0])

      end

    end

    for i in 1...$data_armors.size

      if ARMORS_MATERIA_SLOTS[i] != nil

        $data_armors[i].set_materia_slots(ARMORS_MATERIA_SLOTS[i])

      else

        $data_armors[i].set_materia_slots([0,0])

      end

    end

    seph_materiasystem_scenetitle_newgame

  end

  #--------------------------------------------------------------------------

  def command_continue

    materias = Materia_System.new

    $data_materia = materias.set_up_materias

    for i in 1...$data_weapons.size

      if WEAPON_MATERIA_SLOTS[i] != nil

        $data_weapons[i].set_materia_slots(WEAPON_MATERIA_SLOTS[i])

      else

        $data_weapons[i].set_materia_slots([0,0])

      end

    end

    for i in 1...$data_armors.size

      if ARMORS_MATERIA_SLOTS[i] != nil

        $data_armors[i].set_materia_slots(ARMORS_MATERIA_SLOTS[i])

      else

        $data_armors[i].set_materia_slots([0,0])

      end

    end

    seph_materiasystem_scenetitle_continue

  end

end

 

#==============================================================================

# ** Scene_Equip

#==============================================================================

class Scene_Equip

  #------------------------------------------------------------------------------

  alias  seph_materiasystem_sceneequip_main main

  def main

    @actor = $game_party.actors[@actor_index]

    @actor.check_old_equip

    seph_materiasystem_sceneequip_main

    @actor.check_equip_change

  end

end

 

#==============================================================================

# ** Scene_MateriaShop

#==============================================================================

class Scene_MateriaShop

  #--------------------------------------------------------------------------

  def initialize(materia_avialable = [])

    @materia_avialable = materia_avialable

  end

  #--------------------------------------------------------------------------

  def main

    @help_window = Window_Help.new

    @help_window.set_text(Materia_Config::Shop_Message)

    @shop_options_window = Window_HorizCommand.new(

     [Materia_Config::Buy_Command, Materia_Config::Sell_Command, 'Sair'], 480)

    @shop_options_window.y = 64

    @gold_window = Window_Gold.new

    @gold_window.x, @gold_window.y = 480, 64

    @dummy_window = Window_Base.new(0, 128, 640, 352)

    @buy_items = Window_MateriaList.new(true, @materia_avialable)

    @sell_items = Window_MateriaList.new(false)

    @materia_bio = Window_MateriaBio.new

    @objects = [@help_window, @shop_options_window, @gold_window, @buy_items,

      @sell_items, @dummy_window, @materia_bio]

    Graphics.transition

    while $scene == self

      Graphics.update

      Input.update

      @objects.each {|x| x.update}

      update

    end

    Graphics.freeze

    @objects.each {|x| x.dispose}

  end

  #--------------------------------------------------------------------------

  def update

    if @shop_options_window.active

      update_shop_commands

    elsif @buy_items.active

      update_buy_materia

    elsif @sell_items.active

      update_sell_materia

    end

  end

  #--------------------------------------------------------------------------

  def update_shop_commands

    @help_window.set_text(Materia_Config::Shop_Message)

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Map.new

    end

    if Input.trigger?(Input::C)

      $game_system.se_play($data_system.decision_se)

      case @shop_options_window.index

      when 0 

        @shop_options_window.active = false

        @materia_bio.visible = true

        @materia_bio.refresh(@buy_items.materia)

        @buy_items.visible = @buy_items.active = true

      when 1 

        @shop_options_window.active = false

        @materia_bio.visible = true

        @materia_bio.refresh(@sell_items.materia)

        @sell_items.visible = @sell_items.active = true

      when 2 

        $scene = Scene_Map.new

      end

    end

  end

  #--------------------------------------------------------------------------

  def update_buy_materia

    @help_window.set_text(Materia_Config::Buy_Message)

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      @buy_items.visible = @buy_items.active = false

      @buy_items.index = 0

      @materia_bio.visible = false

      @shop_options_window.active = true

    end

    if Input.trigger?(Input::C)

      materia = @buy_items.materia

      if $game_party.gold < materia.buy_value

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      $game_system.se_play($data_system.shop_se)

      $game_party.gain_materia(materia.id)

      $game_party.lose_gold(materia.buy_value)

      @gold_window.refresh

      @buy_items.refresh

      @sell_items.refresh

      @materia_bio.refresh(@buy_items.materia)

    end

    if Input.trigger?(Input::UP) || Input.trigger?(Input::DOWN) ||

      Input.press?(Input::UP) || Input.press?(Input::DOWN) ||

      Input.trigger?(Input::R) || Input.trigger?(Input::L) ||

      Input.press?(Input::R) || Input.press?(Input::L)

      @materia_bio.refresh(@buy_items.materia)

    end

  end

  #--------------------------------------------------------------------------

  def update_sell_materia

    @help_window.set_text(Materia_Config::Sell_Message)

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      @sell_items.visible = @sell_items.active = false

      @sell_items.index = 0

      @materia_bio.visible = false

      @shop_options_window.active = true

    end

    if Input.trigger?(Input::C)

      if @sell_items.materia.nil?

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      $game_system.se_play($data_system.shop_se)

      $game_party.gain_gold(@sell_items.materia.sell_value)

      @gold_window.refresh

      $game_party.materia.delete_at(@sell_items.index)

      @sell_items.refresh

      @sell_items.index = 0

      @materia_bio.refresh(@sell_items.materia)

    end

    if Input.trigger?(Input::UP) || Input.trigger?(Input::DOWN) ||

      Input.press?(Input::UP) || Input.press?(Input::DOWN) ||

      Input.trigger?(Input::R) || Input.trigger?(Input::L) ||

      Input.press?(Input::R) || Input.press?(Input::L)

      @materia_bio.refresh(@sell_items.materia)

    end

  end

end

 

#==============================================================================

# ** Scene_MateriaEquip

#==============================================================================

class Scene_MateriaEquip

  #--------------------------------------------------------------------------

  def initialize(actor_index = 0, equip_index = 0)

    @actor_index = actor_index

    @equip_index = equip_index

    @materia_index = 0

    @actor = $game_party.actors[@actor_index]

  end

  #--------------------------------------------------------------------------

  def main

    @status_bio_window = Window_MateriaStatus.new(@actor)

    @character_bio_window = Window_MateriaActor.new(@actor)

    @materia_bio_window = Window_MateriaEquipBio.new

    @materia_list_window = Window_MateriaList.new(false, $game_party.materia, false)

    @materia_list_window.x, @materia_list_window.y = 400, 152

    @materia_list_window.height = 328

    @materia_list_window.visible = true

    @materia_bio_window.z = @materia_list_window.z = 1000

    @pointer_sprite = Sprite.new

    @pointer_sprite.x = 416 + (@materia_index + 1) * 24 - 28

    @pointer_sprite.y = @equip_index * 24 + 18

    @pointer_sprite.z = 9999

    @pointer_sprite.bitmap = RPG::Cache.icon(Materia_Config::Materia_Cursor)

    update_materia_bio

    @objects = [@status_bio_window, @character_bio_window, @materia_bio_window, 

     @materia_list_window, @pointer_sprite]

    Graphics.transition

    while $scene == self

      Graphics.update

      Input.update

      @objects.each {|x| x.update}

      update

    end

    Graphics.freeze

    @objects.each {|x| x.dispose}

  end

  #--------------------------------------------------------------------------

  def update

    !@materia_list_window.active ? update_weapon_select : update_materia_select

  end

  #--------------------------------------------------------------------------

  def update_weapon_select

    @pointer_sprite.x = 416 + (@materia_index + 1) * 24 - 28

    @pointer_sprite.y = @equip_index * 24 + 18

    if Input.trigger?(Input::UP)

      $game_system.se_play($data_system.cursor_se)

      @equip_index = @equip_index == 0 ? @equip_index = 4 : @equip_index -= 1

      case @equip_index

      when 0

        max = [@actor.weapon_materia.size - 1, 0].max

      when 1

        max = [@actor.armor1_materia.size - 1, 0].max

      when 2

        max = [@actor.armor2_materia.size - 1, 0].max

      when 3

        max = [@actor.armor3_materia.size - 1, 0].max

      when 4

        max = [@actor.armor4_materia.size - 1, 0].max

      end

      @materia_index = [@materia_index, max].min

      update_materia_bio

    end

    if Input.trigger?(Input::DOWN)

      $game_system.se_play($data_system.cursor_se)

      @equip_index = @equip_index == 4 ? @equip_index = 0 : @equip_index += 1

      case @equip_index

      when 0

        max = [@actor.weapon_materia.size - 1, 0].max

      when 1

        max = [@actor.armor1_materia.size - 1, 0].max

      when 2

        max = [@actor.armor2_materia.size - 1, 0].max

      when 3

        max = [@actor.armor3_materia.size - 1, 0].max

      when 4

        max = [@actor.armor4_materia.size - 1, 0].max

      end

      @materia_index = [@materia_index, max].min

      update_materia_bio

    end

    if Input.trigger?(Input::RIGHT)

      $game_system.se_play($data_system.cursor_se)

      case @equip_index

      when 0

        max = @actor.weapon_materia.size

      when 1

        max = @actor.armor1_materia.size

      when 2

        max = @actor.armor2_materia.size

      when 3

        max = @actor.armor3_materia.size

      when 4

        max = @actor.armor4_materia.size

      end

      return if max == 0

      @materia_index = @materia_index == max - 1 ? @materia_index = 0 : @materia_index += 1

      update_materia_bio

    end

    if Input.trigger?(Input::LEFT)

      $game_system.se_play($data_system.cursor_se)

      case @equip_index

      when 0

        max = @actor.weapon_materia.size 

      when 1

        max = @actor.armor1_materia.size

      when 2

        max = @actor.armor2_materia.size

      when 3

        max = @actor.armor3_materia.size

      when 4

        max = @actor.armor4_materia.size

      end

      return if max == 0

      @materia_index = @materia_index == 0 ? @materia_index = max - 1 : @materia_index -= 1

      update_materia_bio

    end

    if Input.trigger?(Input::L)

      @actor_index = @actor_index == 0 ? 

        @actor_index = $game_party.actors.size - 1 : @actor_index -= 1

      $scene = Scene_MateriaEquip.new(@actor_index, @equip_index)

    end

    if Input.trigger?(Input::R)

      @actor_index = @actor_index == $game_party.actors.size - 1 ? 

        @actor_index =  0: @actor_index += 1

      $scene = Scene_MateriaEquip.new(@actor_index, @equip_index)

    end

    if Input.trigger?(Input::A)

      $game_system.se_play($data_system.equip_se)

      @actor.unequip_materia(@equip_index, @materia_index)

      @materia_list_window.refresh

      @status_bio_window.refresh

      @character_bio_window.draw_actor_materia

      update_materia_bio

    end

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Menu.new(3)

    end

    if Input.trigger?(Input::C)

      case @equip_index

      when 0

        max = @actor.weapon_materia.size 

      when 1

        max = @actor.armor1_materia.size

      when 2

        max = @actor.armor2_materia.size

      when 3

        max = @actor.armor3_materia.size

      when 4

        max = @actor.armor4_materia.size

      end

      if max == 0

        $game_system.se_play($data_system.buzzer_se)

        return

      else

        $game_system.se_play($data_system.decision_se)

        @materia_list_window.active = true

        update_materia_bio

      end

    end

  end

  #--------------------------------------------------------------------------

  def update_materia_select

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      @materia_list_window.active = false

      update_materia_bio

    end

    if Input.trigger?(Input::C)

      if @materia_list_window.materia.nil?

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      $game_system.se_play($data_system.equip_se)

      @actor.equip_materia(@equip_index, @materia_index,

        @materia_list_window.index)

      @materia_list_window.refresh

      @status_bio_window.refresh

      @character_bio_window.draw_actor_materia

      @materia_list_window.active = false

      update_materia_bio

    end

    if Input.trigger?(Input::UP) || Input.trigger?(Input::DOWN) ||

      Input.press?(Input::UP) || Input.press?(Input::DOWN) ||

      Input.trigger?(Input::R) || Input.trigger?(Input::L) ||

      Input.press?(Input::R) || Input.press?(Input::L)

      update_materia_bio

    end

  end

  #--------------------------------------------------------------------------

  def update_materia_bio

    if @materia_list_window.active

      @materia_bio_window.refresh(@materia_list_window.materia)

    else

      case @equip_index

      when 0

        item = @actor.weapon_materia

      when 1

        item = @actor.armor1_materia

      when 2

        item = @actor.armor2_materia

      when 3

        item = @actor.armor3_materia

      when 4

        item = @actor.armor4_materia

      end

      @materia_bio_window.refresh(item[@materia_index])

    end

  end

end

 

#==============================================================================

# ** Scene_Battle

#==============================================================================

class Scene_Battle

  #--------------------------------------------------------------------------

  alias seph_materiasystem_scenebattle_setupcommandwindow phase3_setup_command_window

  def phase3_setup_command_window

    @update_skills_commands = Window_Skill.new(@active_battler)

    @update_skills_commands.refresh

    @update_skills_commands.update

    @update_skills_commands.dispose

    seph_materiasystem_scenebattle_setupcommandwindow

  end

  #--------------------------------------------------------------------------

  alias seph_materiasystem_scenebattle_skillselect update_phase3_skill_select

  def update_phase3_skill_select

    if Input.trigger?(Input::C)

      @skill = @skill_window.skill

      if @skill == nil or not @active_battler.skill_can_use?(@skill.id)

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      @active_battler.current_action.skill_id = @skill.id

      paired_materia_set = @active_battler.return_paired_materia

      for paired_set in paired_materia_set

        materia = paired_set[2]

        other_materia = paired_set[3]

        if materia.special_effect == 'All'

          for skill_id in other_materia.skills

            if skill_id == @skill.id

              unless @skill.element_set.include?(Materia_Config::Negate_All_ID)

                @skill_window.visible = false

                $game_system.se_play($data_system.decision_se)

                end_skill_select

                phase3_next_actor

                return

              end

            end

          end

        end

      end

    end

    seph_materiasystem_scenebattle_skillselect

  end

  #------------------------------------------------------------------------------

  def make_skill_action_result

    @skill = $data_skills[@active_battler.current_action.skill_id]

    unless @active_battler.current_action.forcing

      unless @active_battler.skill_can_use?(@skill.id)

        $game_temp.forcing_battler = nil

        @phase4_step = 1

        return

      end

    end

    @active_battler.sp -= @skill.sp_cost

    @status_window.refresh

    @help_window.set_text(@skill.name, 1)

    @animation1_id = @skill.animation1_id

    @animation2_id = @skill.animation2_id

    @common_event_id = @skill.common_event_id

    scope = @skill.scope

    paired_materia_set = @active_battler.return_paired_materia

    for paired_set in paired_materia_set

      materia = paired_set[2]

      other_materia = paired_set[3]

      if materia.special_effect == 'All'

        for skill_id in other_materia.skills

          if skill_id == @skill.id

            unless @skill.element_set.include?(Materia_Config::Negate_All_ID)

              scope = 2 if @skill.scope == 1

              scope = 4 if @skill.scope == 3 || @skill.scope == 7

              scope = 6 if @skill.scope == 5

            end

          end

        end

      end

    end

    set_target_battlers(scope)

    for target in @target_battlers

      target.skill_effect(@active_battler, @skill)

    end

  end

  #------------------------------------------------------------------------------

  def update_phase2_escape

    enemies_agi = 0

    enemies_number = 0

    for enemy in $game_troop.enemies

      if enemy.exist?

        enemies_agi += enemy.agi

        enemies_number += 1

      end

    end

    if enemies_number > 0

      enemies_agi /= enemies_number

    end

    actors_agi = 0

    actors_number = 0

    for actor in $game_party.actors

      if actor.exist?

        actors_agi += actor.agi

        actors_number += 1

      end

    end

    if actors_number > 0

      actors_agi /= actors_number

    end

    escapeplus = 0

    for actor in $game_party.actors

      escapeplus += actor.escapeplus if actor.exist?

    end

    success = rand(100) < 50 + escapeplus * actors_agi / enemies_agi

    if success

      $game_system.se_play($data_system.escape_se)

      $game_system.bgm_play($game_temp.map_bgm)

      battle_end(1)

    else

      $game_party.clear_actions

      start_phase4

    end

  end

  #------------------------------------------------------------------------------

  def start_phase5

    @phase = 5

    $game_system.me_play($game_system.battle_end_me)

    $game_system.bgm_play($game_temp.map_bgm)

    exp = 0

    ap = 0

    gold = 0

    treasures = []

    dropup = 0

    for actor in $game_party.actors

      dropup += actor.itemdropup if actor.exist?

    end

    for enemy in $game_troop.enemies

      unless enemy.hidden

        exp += enemy.exp

        gold += enemy.gold

        ap += enemy.ap

        if rand(100) < enemy.treasure_prob + dropup

          if enemy.item_id > 0

            treasures.push($data_items[enemy.item_id])

          end

          if enemy.weapon_id > 0

            treasures.push($data_weapons[enemy.weapon_id])

          end

          if enemy.armor_id > 0

            treasures.push($data_armors[enemy.armor_id])

          end

        end

      end

    end

    treasures = treasures[0..5]

    actors = $game_party.actors

    for i in 0...$game_party.actors.size

      actor = $game_party.actors[i]

      if actor.cant_get_exp? == false

        last_level = actor.level

        actor.exp += exp

        actor.ap += ap

        if actor.level > last_level

          @status_window.level_up(i)

        end

      end

    end

    $game_party.gain_gold(gold)

    for item in treasures

      case item

      when RPG::Item

        $game_party.gain_item(item.id, 1)

      when RPG::Weapon

        $game_party.gain_weapon(item.id, 1)

      when RPG::Armor

        $game_party.gain_armor(item.id, 1)

      end

    end

    @result_window = Window_BattleResult.new(exp, gold, treasures, ap)

    @phase5_wait_count = 100

  end

end

 

#============================================================================== 

# ** Scene_Menu 

#============================================================================== 

class Scene_Menu 

  #--------------------------------------------------------------------------

  def main

    s1 = $data_system.words.item

    s2 = $data_system.words.skill

    s3 = $data_system.words.equip

    s4 = "Materias"

    s5 = "Status"

    s6 = "Save"

    s7 = "End Game"

    @command_window = Window_Command_Materia.new(160, [s1, s2, s3, s4, s5, s6, s7])

    @command_window.index = @menu_index

    if $game_party.actors.size == 0

      @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 $game_system.save_disabled

      @command_window.disable_item(5)

    end

    @playtime_window = Window_PlayTime.new

    @playtime_window.x = 0

    @playtime_window.y = 224

    @steps_window = Window_Steps.new

    @steps_window.x = 0

    @steps_window.y = 320

    @gold_window = Window_Gold.new

    @gold_window.x = 0

    @gold_window.y = 416

    @status_window = Window_MenuStatus.new

    @status_window.x = 160

    @status_window.y = 0

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end

    end

    Graphics.freeze

    @command_window.dispose

    @playtime_window.dispose

    @steps_window.dispose

    @gold_window.dispose

    @status_window.dispose

  end

  #--------------------------------------------------------------------------

  def update_command

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Map.new

      return

    end

    if Input.trigger?(Input::C)

      if $game_party.actors.size == 0 and @command_window.index < 4

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      case @command_window.index

      when 0

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Item.new

      when 1

        $game_system.se_play($data_system.decision_se)

        @command_window.active = false

        @status_window.active = true

        @status_window.index = 0

      when 2

        $game_system.se_play($data_system.decision_se)

        @command_window.active = false

        @status_window.active = true

        @status_window.index = 0

      when 3

        $game_system.se_play($data_system.decision_se)

        @command_window.active = false

        @status_window.active = true

        @status_window.index = 0

      when 4

        $game_system.se_play($data_system.decision_se)

        @command_window.active = false

        @status_window.active = true

        @status_window.index = 0

      when 5

        if $game_system.save_disabled

          $game_system.se_play($data_system.buzzer_se)

          return

        end

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Save.new

      when 6

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_End.new

      end

      return

    end

  end

  #--------------------------------------------------------------------------

  def update_status

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      @command_window.active = true

      @status_window.active = false

      @status_window.index = -1

      return

    end

    if Input.trigger?(Input::C)

      case @command_window.index

      when 1

        if $game_party.actors[@status_window.index].restriction >= 2

          $game_system.se_play($data_system.buzzer_se)

          return

        end

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Skill.new(@status_window.index)

      when 2

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Equip.new(@status_window.index)

      when 3

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_MateriaEquip.new(@status_window.index)

      when 4

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Status.new(@status_window.index)

      end

      return

    end

  end

end

 

#==============================================================================

# ** Scene_Status

#==============================================================================

class Scene_Status

  #--------------------------------------------------------------------------

  def update

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Menu.new(4)

      return

    end

    if Input.trigger?(Input::R)

      $game_system.se_play($data_system.cursor_se)

      @actor_index += 1

      @actor_index %= $game_party.actors.size

      $scene = Scene_Status.new(@actor_index)

      return

    end

    if Input.trigger?(Input::L)

      $game_system.se_play($data_system.cursor_se)

      @actor_index += $game_party.actors.size - 1

      @actor_index %= $game_party.actors.size

      $scene = Scene_Status.new(@actor_index)

      return

    end

  end

end

 

#==============================================================================

# ** Scene_Save

#==============================================================================

class Scene_Save < Scene_File

  #--------------------------------------------------------------------------

  def on_cancel

    $game_system.se_play($data_system.cancel_se)

    if $game_temp.save_calling

      $game_temp.save_calling = false

      $scene = Scene_Map.new

      return

    end

    $scene = Scene_Menu.new(5)

  end

end

 

#==============================================================================

# ** Scene_End

#==============================================================================

class Scene_End

  #--------------------------------------------------------------------------

  def update

    @command_window.update

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Menu.new(6)

      return

    end

    if Input.trigger?(Input::C)

      case @command_window.index

      when 0

        command_to_title

      when 1

        command_shutdown

      when 2

        command_cancel

      end

      return

    end

  end

  #--------------------------------------------------------------------------

  def command_cancel

    $game_system.se_play($data_system.decision_se)

    $scene = Scene_Menu.new(6)

  end

end

end

Thanks!
-Zank
 
John Egbert":2ykdgqka said:
it would be helpful is you posted the whole script up. we are not all familiar with the script and by posting it up, we are able to help a lot more.

Oh? Sorry! I figured it would be a popular enough script that everyone would know what I was talking about, heh. (got to stop assuming things... though, would help if I wasnt always in such a rush, oy!).

I put the link to the script in the first post at the moment. At work, so I cannot download the link to get the script... though, having the download might make it easier anyway since of the images needed.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top