class Game_Actor < Game_Battler
def set_best_equip
weapons = []
shields = []
helms = []
armors = []
#get available weapons
if @extra_armor != nil
if @extra_armor[1] == 0
weapon_set = $data_classes[self.class_id].weapon_set + @extra_armor[0].weapon_set
else
weapon_set = $data_classes[self.class_id].weapon_set
end
else
weapon_set = $data_classes[self.class_id].weapon_set
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
weapons.push($data_weapons[i])
end
end
if self.weapon_id != 0
if !weapon_set.include?(self.weapon_id)
self.equip(0,0)
end
end
#get available shields, helms, armors
if @extra_armor != nil
if @extra_armor[1] == 1
armor_set = $data_classes[self.class_id].armor_set + @extra_armor[0].armor_set
else
armor_set = $data_classes[self.class_id].armor_set
end
else
armor_set = $data_classes[self.class_id].armor_set
end
for j in 1..3
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors[i].kind == j-1
case j
when 2 #helms
helms.push($data_armors[i])
when 3 #armors
armors.push($data_armors[i])
end
end
end
end
case j
when 2
if self.armor2_id != 0
if !armor_set.include?(self.armor2_id)
self.equip(2,0)
end
end
when 3
if self.armor3_id != 0
if !armor_set.include?(self.armor3_id)
self.equip(3,0)
end
end
end
end
if @extra_armor != nil
if @extra_armor[1] == 2
shield_set = $data_classes[self.class_id].armor_set + @extra_armor[0].armor_set
else
shield_set = $data_classes[self.class_id].armor_set
end
else
shield_set = $data_classes[self.class_id].armor_set
end
for j in 1..3
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and shield_set.include?(i)
if $data_armors[i].kind == j-1
case j
when 1 #sheilds
shields.push($data_armors[i])
end
end
end
end
case j
when 1
if self.armor1_id != 0
if !shield_set.include?(self.armor1_id)
self.equip(1,0)
end
end
end
end
#now find best equip of each
if self.weapon_id == 0
max_wep = 0
else
max_wep = $data_weapons[self.weapon_id].atk
end
for j in 1..3
if j == 1
if self.armor1_id == 0
max_shield = 0
else
max_shield = $data_armors[self.armor1_id].pdef
end
elsif j == 2
if self.armor2_id == 0
max_helm = 0
else
max_helm = $data_armors[self.armor2_id].pdef
end
elsif j == 3
if self.armor3_id == 0
max_armor = 0
else
max_armor = $data_armors[self.armor3_id].pdef
end
end
end
equip_types = [weapons, shields, helms, armors]
for k in 0...equip_types.size
type = k
data = equip_types[k]
for i in 0...data.size
if type == 0
if max_wep <= $data_weapons[data[i].id].atk
max_wep = $data_weapons[data[i].id].atk
wep_id = data[i].id
end
elsif type >= 1
case type
when 1
if max_shield <= $data_armors[data[i].id].pdef
max_shield = $data_armors[data[i].id].pdef
shield_id = data[i].id
end
when 2
if max_helm <= $data_armors[data[i].id].pdef
max_helm = $data_armors[data[i].id].pdef
helm_id = data[i].id
end
when 3
if max_armor <= $data_armors[data[i].id].pdef
max_armor = $data_armors[data[i].id].pdef
armor_id = data[i].id
end
end
end
end
end
self.equip(0,(wep_id.nil? ? self.weapon_id : wep_id)) #equip best weapon
self.equip(1,(shield_id.nil? ? self.armor1_id : shield_id)) #equip best shield
self.equip(2,(helm_id.nil? ? self.armor2_id : helm_id)) #equip best helm
self.equip(3,(armor_id.nil? ? self.armor3_id : armor_id)) #equip best armor
#reset hp and sp according to new equip
self.hp = maxhp
self.sp = maxsp
end
end