Code:
# * KPartners VXP
# Scripter : Kyonides Arkanthes
# v 0.1.5 - 2020-07-13
# This scriptlet allows a hero to get access to extra skills if he currently
# has a partner or he has already lost one.
# The chosen hero should have enough mana to perform the skill.
# They should never share the same class.
# If the game developer or the player removes a hero and he had a partner, both
# of them will get their PartnerID's reset to zero.
# Heroes might share the same skill set if you want to.
# PARTNER_SKILLS[ [ActorID, PartnerID] ] = [SkillID1, SkillID2, etc.]
# Examples:
# PARTNER_SKILLS[[1, 2]] = [1, 4, 5]
# PARTNER_SKILLS[[2, 1]] = [3, 7, 9] #-> Here they don't share them!
# The same is valid for the LOST_PARTNER_SKILLS.
# * Script Calls * #
# First Step: Pick a specific teammate (Starting from Zero! 0!)
# actor = $game_party.actors[Actor's Current Position in Your Team]
# To set a partner
# actor.partner_id = ActorID
# To set a lost partner
# actor.lost_partner_id = ActorID
# To remove any partner
# actor.no_partner!
# To remove any lost partner
# actor.no_lost_partner!
# To check whether or not a hero is a current teammate
# $game_party.has_actor?(actor)
# $game_party.has_member?(actor)
module KPartners
PARTNER_SKILLS = {}
PARTNER_SKILLS.default = [] # Do Not Edit This Line!
LOST_PARTNER_SKILLS = {}
LOST_PARTNER_SKILLS.default = [] # Do Not Edit This Line!
# Add as many Partner and Lost Partner Skills below as you see fit
# End of Setup
def has_partner_skill?(partner_key, skill_id)
PARTNER_SKILLS[partner_key].include?(skill_id)
end
def has_lost_partner_skill?(lost_key, skill_id)
LOST_PARTNER_SKILLS[lost_key].include?(skill_id)
end
end
class Game_Actor
alias kyon_bond_gm_actor_init initialize
alias kyon_bond_gm_actor_scu? skill_can_use?
def initialize
kyon_bond_gm_actor_init
@partner_id = 0
@lost_partner_id = 0
end
def skills
xskills = []
if $game_temp.in_battle
if @partner_id > 0
xskills = KPartners::PARTNER_SKILLS[partner_key]
elsif @lost_partner_id > 0
xskills = KPartners::LOST_PARTNER_SKILLS[lost_partner_key]
end
end
@skills + xskills
end
def skill_can_use?(skill)
result = kyon_bond_gm_actor_scu?(skill)
if $game_temp.in_battle
skill = skill.id if skill.is_a?(RPG::Skill)
if @partner_id > 0 and $game_actors[@partner_id].hp > 0
return KPartners.has_partner_skill?(partner_key, skill)
elsif @lost_partner_id > 0
return false if $game_party.has_actor?($game_actors[@lost_partner_id])
return KPartners.has_lost_partner_skill?(lost_partner_key, skill)
end
end
result
end
def partner_id=(actor_id)
return @partner_id if actor_id < 1
actor = $game_actors[actor_id]
return @partner_id unless $game_party.has_actor?(actor)
return @partner_id if actor.class_id == @class_id
@partner_id = actor_id
end
def lost_partner_id=(actor_id)
return @lost_partner_id if actor_id < 1
actor = $game_actors[actor_id]
return @lost_partner_id if $game_party.has_actor?(actor)
return @lost_partner_id if actor.class_id == @class_id
@lost_partner_id = actor_id
end
def partner_key() [@actor_id, @partner_id] end
def lost_partner_key() [@actor_id, @lost_partner_id] end
def no_partner!() @partner_id = 0 end
def no_lost_partner!() @lost_partner_id = 0 end
attr_reader :partner_id, :lost_partner_id
end
class Game_Party
alias kyon_bond_gm_party_aa add_actor
alias kyon_bond_gm_party_ra remove_actor
def add_actor(actord_id)
kyon_bond_gm_party_aa(actor_id)
@actors.each{|a| a.no_lost_partner! if a.lost_partner_id == actor_id }
end
def remove_actor(actor_id)
actor = $game_actors[actor_id]
had_actor = @actors.include?(actor)
kyon_bond_gm_party_ra(actor_id)
return unless had_actor
@actors.each{|a| a.no_partner! if a.partner_id == actor_id }
actor.no_partner!
end
def has_actor?(actor) @actors.include?(actor) end
alias :has_member? :has_actor?
end