Code:
# * EkuipFeatures ACE * #
# Scripter : Kyonides Arkanthes
# 2023-05-10
# This scriptlet will allow you to add or remove Equip Types to
# any given Actor during gameplay at will.
# * Script Calls * #
# - Find an Actor - 2 Methods:
# actor = $game_party.members[Index]
# actor = $game_actors[ActorID]
# - Learn a New Equip Type
# actor.learn_weapon_type(EquipTypeIndex)
# actor.learn_armor_type(EquipTypeIndex)
# - Forget a given Equip Type
# actor.forget_weapon_type(EquipTypeIndex)
# actor.forget_armor_type(EquipTypeIndex)
module Ekuip
class FeaturesContainer
attr_reader :features
def initialize
@features = []
end
def add(type_code, type_id)
@features << RPG::BaseItem::Feature.new(type_code, type_id)
@features = @features.uniq{|f| f.data_id }
end
def remove(type_code, type_id)
@features.delete_if{|f| f.same_data?(type_code, type_id) }
end
end
end
class RPG::BaseItem::Feature
def same_data?(type_code, type_id)
@code == type_code and @data_id == type_id
end
end
class Game_Actor
alias :kyon_learn_ekuip_types_gm_act_init :initialize
alias :kyon_learn_ekuip_types_gm_act_feat_obj :feature_objects
def initialize(actor_id)
@weapon_features = Ekuip::FeaturesContainer.new
@armor_features = Ekuip::FeaturesContainer.new
kyon_learn_ekuip_types_gm_act_init(actor_id)
end
def equip_features
[@weapon_features] + [@armor_features]
end
def feature_objects
kyon_learn_ekuip_types_gm_act_feat_obj + equip_features
end
def learn_weapon_type(type_id)
@weapon_features.add(FEATURE_EQUIP_WTYPE, type_id)
end
def learn_armor_type(type_id)
@armor_features.add(FEATURE_EQUIP_ATYPE, type_id)
end
def forget_weapon_type(type_id)
@weapon_features.remove(FEATURE_EQUIP_WTYPE, type_id)
end
def forget_armor_type(type_id)
@armor_features.remove(FEATURE_EQUIP_ATYPE, type_id)
end
end