Jump to content
Sign in to follow this  
Placebo

Need help with a system for spell/weapon synergy skills

Recommended Posts

You're in a dungeon and you find a book, it'll teach one of your party members the skill "ignite".
However, if you use it on a party member, and then equip them with a sword, they'll also be able to use a skill called "blazing sword"
Same goes for if they equip an axe, spear, and so-on, each of these synergy skills having a distinct effect and damage formula.
If you do not have both the weapon and the spell, the synergy skills will not be visible.

What is the most efficient way to implement such a system?

Share this post


Link to post
Share on other sites

I found a combination of Masked Equipment skills with Yanfly Hide Menu Skills works.

Spoiler

#==============================================================================
# MBS - Learn Equipment Skills
#------------------------------------------------------------------------------
# by Masked # mod by Roninator2
#==============================================================================
# Only the actor stated will learn the skill if that actor has the item equiped
# equipment notetags
# <Actor1 LearnSkills: 21>	# temporary until item is removed
# <Actor5 LearnSkills: 21>	# temporary until item is removed
# <Actor1 LearnPSkills: 21>  # permanent
($imported ||= {})[:mbs_equipment_skills] = true
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  attr_accessor :perm_skills
  alias mbs_chngeqp change_equip
  alias mbs_inteqps init_equips
  #--------------------------------------------------------------------------
  # * Equipment initialization
  #   equips: initial equipment
  #--------------------------------------------------------------------------
  def init_equips(equips)
    @perm_skills = []
    mbs_inteqps(equips)
    @equips.each {|i|
      equip_skills(i.object).each {|skill| learn_skill(skill)}
    }
  end
  #--------------------------------------------------------------------------
  # * Equipment change
  #   slot_id: slot ID
  #   item: Weapons / Matures (nil if empty)
  #--------------------------------------------------------------------------
  def change_equip(slot_id, item)
    equip_skills(@equips[slot_id].object).each {|skill| forget_skill(skill) unless @perm_skills.include?(skill)}
    mbs_chngeqp(slot_id,item)
    equip_skills(item).each {|skill| learn_skill(skill)}
  end
  #--------------------------------------------------------------------------
  # * Acquisition of equipment skills
  #   item: the equipment in question  
  #--------------------------------------------------------------------------
  def equip_skills(item)
    return [] if item.nil?
    s = ""
    skills = []
    item.note.split(/[\r\n]+/).each { |line|
      case line
      when /<Actor#{self.id}\s*LearnSkills:\s*(.+>)/im
      unless $1.nil?
        $1.each_char {|char|
          next if char == " "
          if char == "," || char == ">"
            skills << s.to_i
            s = ""
            next
          end
          s += char
        }
      end
    end }
    item.note.split(/[\r\n]+/).each { |line|
      case line
      when /<Actor#{self.id}\s*LearnPSkills:\s*(.+>)/im
      @perm_skills ||= []
      return skills if $1.nil?
      $1.each_char {|char|
        next if char == " "
        if char == "," || char == ">"
          skills << s.to_i
          @perm_skills << s.to_i
          s = ""
          next
        end
        s += char
      }
      end }
    return skills
  end
end

 

Spoiler

#==============================================================================
# 
# ▼ Yanfly Engine Ace - Hide Menu Skills v1.01
# -- Last Updated: 2011.12.11
# -- Level: Normal
# -- Requires: n/a
# 
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-HideMenuSkills"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.11 - Started Script and Finished.
#            - Added <hide eval> notetags.
# 
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Have some skills you want hidden until certain conditions are met? Well, now
# you can! This script will only hide the skills from the default skill list
# menus. Anything that displays otherwise may or may not hide them depending on
# the script and what it bases off of.
# 
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
# 
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skills notebox in the database.
# -----------------------------------------------------------------------------
# <hide always>
# This skill will always be hidden from the default skill list windows.
# 
# <hide in battle>
# This skill will always be hidden from the default skill window in battle.
# 
# <hide until usable>
# This will require the skill to be usable before it appears in the window.
# 
# <hide if switch: x>
# This skill will be hidden if switch x is on. The skill will be shown if
# switch x is off. This switch is considered part of the "any" category.
# 
# <hide any switch: x>
# <hide any switch: x, x>
# This skill will be hidden if any of the switches x is on. Use multiple tags
# or separate the switch ID's with commas.
# 
# <hide all switch: x>
# <hide all switch: x, x>
# This skill will be hidden until all of the switches x are on. Use multiple
# tags or separate the switch ID's with commas.
# 
# <hide eval>
#  string
#  string
# </hide eval>
# For the more advanced users, replace string with lines of code to check for
# whether or not to hide the skill. If multiple lines are used, they are all
# considered part of the same line.
# 
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
# 
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module SKILL
    
    HIDE_ALWAYS     = /<(?:HIDE_ALWAYS|hide always)>/i
    HIDE_IN_BATTLE  = /<(?:HIDE_IN_BATTLE|hide in battle)>/i
    HIDE_IF_SWITCH  = /<(?:HIDE_IF_SWITCH|hide if switch):[ ](\d+)>/i
    HIDE_UNTIL_USABLE = /<(?:HIDE_UNTIL_USABLE|hide until usable)>/i
    
    HIDE_ANY_SWITCH = 
      /<(?:HIDE_ANY_SWITCH|hide any switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
    HIDE_ALL_SWITCH = 
      /<(?:HIDE_ALL_SWITCH|hide all switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
    
    HIDE_EVAL_ON  = /<(?:HIDE_EVAL|hide eval)>/i
    HIDE_EVAL_OFF = /<\/(?:HIDE_EVAL|hide eval)>/i
    
  end # SKILL
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_hms load_database; end
  def self.load_database
    load_database_hms
    load_notetags_hms
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_hms
  #--------------------------------------------------------------------------
  def self.load_notetags_hms
    groups = [$data_skills]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_hms
      end
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::Skill
#==============================================================================

class RPG::Skill < RPG::UsableItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :hide_always
  attr_accessor :hide_in_battle
  attr_accessor :hide_any_switch
  attr_accessor :hide_all_switch
  attr_accessor :hide_until_usable
  attr_accessor :hide_eval
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_hms
  #--------------------------------------------------------------------------
  def load_notetags_hms
    @hide_eval = nil
    @hide_any_switch = []
    @hide_all_switch = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::SKILL::HIDE_ALWAYS
        @hide_always = true
      when YEA::REGEXP::SKILL::HIDE_IN_BATTLE
        @hide_in_battle = true
      when YEA::REGEXP::SKILL::HIDE_UNTIL_USABLE
        @hide_until_usable = true
      when YEA::REGEXP::SKILL::HIDE_IF_SWITCH
        @hide_any_switch.push($1.to_i)
      when YEA::REGEXP::SKILL::HIDE_ANY_SWITCH
        $1.scan(/\d+/).each { |num| 
        @hide_any_switch.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::SKILL::HIDE_ALL_SWITCH
        $1.scan(/\d+/).each { |num| 
        @hide_all_switch.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::SKILL::HIDE_EVAL_ON
        @hide_eval_on = true
      when YEA::REGEXP::SKILL::HIDE_EVAL_OFF
        @hide_eval_on = false
      else
        next unless @hide_eval_on
        @hide_eval = "" if @hide_eval.nil?
        @hide_eval += line.to_s
      #---
      end
    } # self.note.split
    #---
  end
  
end # RPG::Skill

#==============================================================================
# ■ Window_SkillList
#==============================================================================

class Window_SkillList < Window_Selectable
  
  #--------------------------------------------------------------------------
  # overwrite method: include?
  #--------------------------------------------------------------------------
  def include?(item)
    return false if hide_eval?(item)
    return false if item.hide_always
    return false if item.hide_in_battle && $game_party.in_battle
    return false if hide_any_switch?(item)
    return false if hide_all_switch?(item)
    unless @actor.nil?
      return false if item.hide_until_usable && !@actor.usable?(item)
    end
    return item && item.stype_id == @stype_id
  end
  
  #--------------------------------------------------------------------------
  # new method: hide_eval?
  #--------------------------------------------------------------------------
  def hide_eval?(item)
    return false if item.hide_eval.nil?
    return eval(item.hide_eval)
  end
  
  #--------------------------------------------------------------------------
  # new method: hide_any_switch?
  #--------------------------------------------------------------------------
  def hide_any_switch?(item)
    for switch_id in item.hide_any_switch
      return true if $game_switches[switch_id]
    end
    return false
  end
  
  #--------------------------------------------------------------------------
  # new method: hide_all_switch?
  #--------------------------------------------------------------------------
  def hide_all_switch?(item)
    return false if item.hide_all_switch == []
    for switch_id in item.hide_all_switch
      return false unless $game_switches[switch_id]
    end
    return true
  end
  
end # Window_SkillList

#==============================================================================
# 
# ▼ End of File
# 
#==============================================================================

 

<hide eval>
!$game_actors[1].skills.include?($data_skills[80]);
</hide eval>
<hide eval>
!$game_actors[5].skills.include?($data_skills[100]);
</hide eval>

Put this onto the skill learned from the weapon and change the id of the skill and actor as needed.

<Actor1 LearnSkills: 26>
<Actor5 LearnSkills: 26>

Add that onto the weapon for the actor and skill to learn when equipped.

Edited by roninator2

Share this post


Link to post
Share on other sites
5 hours ago, roninator2 said:

I found a combination of Masked Equipment skills with Yanfly Hide Menu Skills works.

  Reveal hidden contents


#==============================================================================
# MBS - Learn Equipment Skills
#------------------------------------------------------------------------------
# by Masked
#==============================================================================
# Only the actor stated will learn the skill if that actor has the item equiped
# equipment notetags
# <Actor1 LearnSkills: 21>	# temporary until item is removed
# <Actor1 LearnPSkills: 21>  # permanent
($imported ||= {})[:mbs_equipment_skills] = true
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  alias mbs_chngeqp change_equip
  alias mbs_inteqps init_equips
  #--------------------------------------------------------------------------
  # * Equipment initialization
  #   equips: initial equipment
  #--------------------------------------------------------------------------
  def init_equips(equips)
    mbs_inteqps(equips)
    @equips.each {|i|
      equip_skills(i.object).each {|skill| learn_skill(skill)}
    }
  end
  #--------------------------------------------------------------------------
  # * Equipment change
  #   slot_id: slot ID
  #   item: Weapons / Matures (nil if empty)
  #--------------------------------------------------------------------------
  def change_equip(slot_id, item)
    equip_skills(@equips[slot_id].object).each {|skill| forget_skill(skill) unless @perm_skills.include?(skill)}
    mbs_chngeqp(slot_id,item)
    equip_skills(item).each {|skill| learn_skill(skill)}
  end
  #--------------------------------------------------------------------------
	# * Acquisition of equipment skills
  #   item: the equipment in question  
  #--------------------------------------------------------------------------
  def equip_skills(item)
    return [] if item.nil?
    s = ""
    skills = []
    item.note[/<Actor#{self.id}\s*LearnSkills:\s*(.+>)/im]
    unless $1.nil?
      $1.each_char {|char|
        next if char == " "
        if char == "," || char == ">"
          skills << s.to_i
          s = ""
          next
        end
        s += char
      }
    end
    item.note[/<Actor#{self.id}\s*LearnPSkills:\s*(.+>)/im]
    @perm_skills ||= []
    return skills if $1.nil?
    $1.each_char {|char|
      next if char == " "
      if char == "," || char == ">"
        skills << s.to_i
        @perm_skills << s.to_i
        s = ""
        next
      end
      s += char
    }
    return skills
  end
end
  Reveal hidden contents


#==============================================================================
# 
# ▼ Yanfly Engine Ace - Hide Menu Skills v1.01
# -- Last Updated: 2011.12.11
# -- Level: Normal
# -- Requires: n/a
# 
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-HideMenuSkills"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.11 - Started Script and Finished.
#            - Added <hide eval> notetags.
# 
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Have some skills you want hidden until certain conditions are met? Well, now
# you can! This script will only hide the skills from the default skill list
# menus. Anything that displays otherwise may or may not hide them depending on
# the script and what it bases off of.
# 
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
# 
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skills notebox in the database.
# -----------------------------------------------------------------------------
# <hide always>
# This skill will always be hidden from the default skill list windows.
# 
# <hide in battle>
# This skill will always be hidden from the default skill window in battle.
# 
# <hide until usable>
# This will require the skill to be usable before it appears in the window.
# 
# <hide if switch: x>
# This skill will be hidden if switch x is on. The skill will be shown if
# switch x is off. This switch is considered part of the "any" category.
# 
# <hide any switch: x>
# <hide any switch: x, x>
# This skill will be hidden if any of the switches x is on. Use multiple tags
# or separate the switch ID's with commas.
# 
# <hide all switch: x>
# <hide all switch: x, x>
# This skill will be hidden until all of the switches x are on. Use multiple
# tags or separate the switch ID's with commas.
# 
# <hide eval>
#  string
#  string
# </hide eval>
# For the more advanced users, replace string with lines of code to check for
# whether or not to hide the skill. If multiple lines are used, they are all
# considered part of the same line.
# 
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
# 
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module SKILL
    
    HIDE_ALWAYS     = /<(?:HIDE_ALWAYS|hide always)>/i
    HIDE_IN_BATTLE  = /<(?:HIDE_IN_BATTLE|hide in battle)>/i
    HIDE_IF_SWITCH  = /<(?:HIDE_IF_SWITCH|hide if switch):[ ](\d+)>/i
    HIDE_UNTIL_USABLE = /<(?:HIDE_UNTIL_USABLE|hide until usable)>/i
    
    HIDE_ANY_SWITCH = 
      /<(?:HIDE_ANY_SWITCH|hide any switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
    HIDE_ALL_SWITCH = 
      /<(?:HIDE_ALL_SWITCH|hide all switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
    
    HIDE_EVAL_ON  = /<(?:HIDE_EVAL|hide eval)>/i
    HIDE_EVAL_OFF = /<\/(?:HIDE_EVAL|hide eval)>/i
    
  end # SKILL
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_hms load_database; end
  def self.load_database
    load_database_hms
    load_notetags_hms
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_hms
  #--------------------------------------------------------------------------
  def self.load_notetags_hms
    groups = [$data_skills]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_hms
      end
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::Skill
#==============================================================================

class RPG::Skill < RPG::UsableItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :hide_always
  attr_accessor :hide_in_battle
  attr_accessor :hide_any_switch
  attr_accessor :hide_all_switch
  attr_accessor :hide_until_usable
  attr_accessor :hide_eval
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_hms
  #--------------------------------------------------------------------------
  def load_notetags_hms
    @hide_eval = nil
    @hide_any_switch = []
    @hide_all_switch = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::SKILL::HIDE_ALWAYS
        @hide_always = true
      when YEA::REGEXP::SKILL::HIDE_IN_BATTLE
        @hide_in_battle = true
      when YEA::REGEXP::SKILL::HIDE_UNTIL_USABLE
        @hide_until_usable = true
      when YEA::REGEXP::SKILL::HIDE_IF_SWITCH
        @hide_any_switch.push($1.to_i)
      when YEA::REGEXP::SKILL::HIDE_ANY_SWITCH
        $1.scan(/\d+/).each { |num| 
        @hide_any_switch.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::SKILL::HIDE_ALL_SWITCH
        $1.scan(/\d+/).each { |num| 
        @hide_all_switch.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::SKILL::HIDE_EVAL_ON
        @hide_eval_on = true
      when YEA::REGEXP::SKILL::HIDE_EVAL_OFF
        @hide_eval_on = false
      else
        next unless @hide_eval_on
        @hide_eval = "" if @hide_eval.nil?
        @hide_eval += line.to_s
      #---
      end
    } # self.note.split
    #---
  end
  
end # RPG::Skill

#==============================================================================
# ■ Window_SkillList
#==============================================================================

class Window_SkillList < Window_Selectable
  
  #--------------------------------------------------------------------------
  # overwrite method: include?
  #--------------------------------------------------------------------------
  def include?(item)
    return false if hide_eval?(item)
    return false if item.hide_always
    return false if item.hide_in_battle && $game_party.in_battle
    return false if hide_any_switch?(item)
    return false if hide_all_switch?(item)
    unless @actor.nil?
      return false if item.hide_until_usable && !@actor.usable?(item)
    end
    return item && item.stype_id == @stype_id
  end
  
  #--------------------------------------------------------------------------
  # new method: hide_eval?
  #--------------------------------------------------------------------------
  def hide_eval?(item)
    return false if item.hide_eval.nil?
    return eval(item.hide_eval)
  end
  
  #--------------------------------------------------------------------------
  # new method: hide_any_switch?
  #--------------------------------------------------------------------------
  def hide_any_switch?(item)
    for switch_id in item.hide_any_switch
      return true if $game_switches[switch_id]
    end
    return false
  end
  
  #--------------------------------------------------------------------------
  # new method: hide_all_switch?
  #--------------------------------------------------------------------------
  def hide_all_switch?(item)
    return false if item.hide_all_switch == []
    for switch_id in item.hide_all_switch
      return false unless $game_switches[switch_id]
    end
    return true
  end
  
end # Window_SkillList

#==============================================================================
# 
# ▼ End of File
# 
#==============================================================================

 


<hide eval>
!$game_actors[1].skills.include?($data_skills[80]);
</hide eval>
<hide eval>
!$game_actors[5].skills.include?($data_skills[100]);
</hide eval>

Put this onto the skill learned from the weapon and change the id of the skill and actor as needed.


<Actor1 LearnSkills: 26>
<Actor5 LearnSkills: 26>

Add that onto the weapon for the actor and skill to learn when equipped.

image.png.13238b8100f63848f2cee81c189d1643.png

I get this error when I equip the weapon and then look into the skills menu (even if I haven't taught the actor ignite yet)
 

 

here's what I put in the weapon's notetags

<Actor1 LearnSkills: 149>
<Actor2 LearnSkills: 149>
<Actor3 LearnSkills: 149>
<Actor4 LearnSkills: 149>

 

here's what I put in the skill's notetags

<hide eval>
!$game_actors[1].skills.include?($data_skills[149]);
!$game_actors[2].skills.include?($data_skills[149]);
!$game_actors[3].skills.include?($data_skills[149]);
!$game_actors[4].skills.include?($data_skills[149]);
</hide eval>

 

Edited by Placebo

Share this post


Link to post
Share on other sites

It was actually a lot simpler
all I did was use

<hide until usable>

in the skill's notetags and mark it as requiring a weapon type, then making the book teach it alongside the basic fire skill.

Share this post


Link to post
Share on other sites
5 hours ago, Placebo said:

<hide until usable>

in the skill's notetags and mark it as requiring a weapon type, then making the book teach it alongside the basic fire skill.

That's good as it seems the Masked script does not work if you use multiple note tags. that is what caused the error.

Code above updated

It will allow multiple note tags now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted