Save-Point
Bug on a script - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: Bug on a script (/thread-963.html)

Pages: 1 2


Bug on a script - fgsfds - 12-11-2009

I recently found this interesting script, however, there's a serious glitch or I'm not getting this right. If I add this script, it disable my actor's skill EVEN if I set it to target, and usable in battle, in other words, I cannot use any skill. I wanna know if it's just me or there's an error in the script.
(Btw the reason I can't contact the scripter via forums because he might be suddenly inactive or doesn't go to the forum as much, and I don't want to register to a forum where stupidity reigns most of the time)

Edit: Btw I don't think I need to explain which script I'm using because this bug occurred in a new project file as well.

Code:
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Passive Augments by Xelias
# Version: 1.00
# Type: Skill Enhacement
# Date v1.00:   6.12.2009
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #----------------------------------------------------------------------------
#  This script creates "Passive Skills". The "Passive Skills" you list in
#  PASSIVE_SKILLS_IDS = [] are displayed in a separate menu.
#  They are simple skills you can give an Icon, a name, a description...
#  You can change the menu's name in PASSIVE_WORD = "Augments"
#  Replace "Augments" by whatever name you want.
#
#  Passive Skills only work on actors !
#
#  Passive skills effects are listed here :
#
#  GUARD_PLUS will decrease even more the damage taken while defending.
#  MP_SHIELD will allow damage to be inflicted on SP instead of HP until you run out of SP.
#  MARTYR allows the character to gain SP when taking damage
#  INQUISITOR allows the character to gain SP when dealing physical damage.
#  WARMAGE allows the character to gain SP when dealing damage with spells.
#  BLOOD_PRICE allows the character to pay HP instead of SP. HP cost is SP cost*5
#  DEMI_MP allows the character to cast spells for half the SP cost
#  TURBO_MP doubles the SP cost as well as the power of the skills.
#  SPELLBREAKER increases the damage dealt by spells when you have low HP
#  ADRENALINE increases the damage dealt by attacks when you have low HP
#  LAST_STAND decreases the damage taken when you have low HP
#  CHARGED_ATTACKS increases the power of physical attacks for 6 SP a hit until you run out of SP.
#  BRAWLER allows you to inflict more damage when no weapons are equipped. Note that
#  thanks to this script, bare-handed attacks are available. Just modify the BARE_ANIMATION_SELF_ID
#  and BARE_ANIMATION_ID to modify the animations that play on the attacker and on the enemy
#  while attacking without weapons, respectively.
#  CRITICAL_BOOST increases the critical hit ratio
#  FOCUS slightly increases the damage dealt by attacks when at full HP
#  SERENITY slightly increases the damage dealt by spells when at full HP
#  ONCE_MORE allows the actor to survive all hits when his HP are higher than 1 : then his
#  HP will become 1, and next strike will be deadly. Think about Kingdom Hearts for this one.
#  LEARNING allows the actor to learn blue magic. This blue magic is set in BLUE_SKILLS_IDS = []
#  HEALER increases the potency of healing spells and objects on the actor.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

PASSIVE_SKILLS_IDS = [81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99]

PASSIVE_WORD = "Passive"

GUARD_PLUS_ID = 81
MP_SHIELD_ID = 82
MARTYR_ID = 83
INQUISITOR_ID = 84
WARMAGE_ID = 85
BLOOD_PRICE_ID = 86
DEMI_MP_ID = 87
TURBO_MP_ID = 88
SPELLBREAKER_ID = 89
ADRENALINE_ID = 90
LAST_STAND_ID = 91
CHARGED_ATTACKS_ID =  92
BRAWLER_ID = 93
CRITICAL_BOOST_ID = 94
FOCUS_ID = 95
SERENITY_ID = 96
ONCE_MORE_ID = 97
LEARNING_ID = 98
HEALER_ID = 100

BLUE_SKILLS_IDS = [61,62]

BARE_ANIMATION_SELF_ID = 0
BARE_ANIMATION_ID = 4


#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
#  Passive skills can also be used to equip weapons and armors, and to be able to use skills.
#  Configure it like that :
#
#  When [weapon/armor id] then return [passive skill id]
#  When [skill id] then return [passive skill id]
#
#  Note that passive skills overwrite class restrictions : if a warrior gets a "Equip Staffs"
#  passive ability, he will be able to equip staffs.
#
#  On a sad note, all weapons/armors need to be set to a skill in order to be equipped.
#  If you put "nil"  or "0", the game will crash.
#  So set a skill for each different weapon or armor. Default is 100
#  The same applies for skills. Skills won't crash, but won't be able to be used. Which is bad.
#  However if you put "when skill X then return skill X", the skill will be usable if you have it, which
#  means you won't have to learn another passive skill.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:

module Xelias

   def self.ers_config(item)
    # weapon configuration
    if item.is_a?(RPG::Weapon)
      case item.id
      # START Weapon Configuration
      when 2 then return [100]
      # END Weapon Configuration
      end
    elsif item.is_a?(RPG::Armor)
      case item.id
      # START Armor Configuration
      when 2 then return [100]
      # END Armor Configuration
      end
    end
    return [100]
  end

  def self.req_skill(id)
    case id
      # START Skill Configuration
      when 8 then return 101
    end
    return
  end
  
end


#==============================================================================
# ? Game_Battler (???? 3)
#------------------------------------------------------------------------------
# ???????????????????? Game_Actor ???? Game_Enemy ??
# ???????????????????
#==============================================================================

class Game_Battler

def attack_effect(attacker)
    # ?????????????
    self.critical = false
    # ??????
    hit_result = (rand(100) < attacker.hit)
    # ?????
    if hit_result == true
      # ?????????
            atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
    if attacker.is_a?(Game_Actor) && attacker.atk == 0
        atk = [100 + attacker.str/8 - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
      if attacker.skill_learn?(BRAWLER_ID)
          atk = [100 + attacker.str/3 - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
      end
      # ????
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # ????????????
      if self.damage > 0
        # ????????
      if attacker.is_a?(Game_Actor) && attacker.skill_learn?(CRITICAL_BOOST_ID)
        if rand(100) < 6 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        else
              if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
      end
      end
        # ????
        if self.guarding?
          self.damage /= 2
        end
        if self.is_a?(Game_Actor) && self.guarding? && self.skill_learn?(GUARD_PLUS_ID)
          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.dex + 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
      # HP ?????????        
      if self.is_a?(Game_Actor) && self.skill_learn?(MARTYR_ID)
      sp_recovery = self.damage/10
      self.sp += sp_recovery
    end
      if attacker.is_a?(Game_Actor) && attacker.skill_learn?(INQUISITOR_ID)
      sp_recovery = self.damage/10
      attacker.sp += sp_recovery
    end
      if attacker.is_a?(Game_Actor) && attacker.skill_learn?(ADRENALINE_ID) && ((attacker.hp*100)/attacker.maxhp) < 30
      self.damage*= 2
    end
      if attacker.is_a?(Game_Actor) && attacker.skill_learn?(FOCUS_ID) && attacker.hp = attacker.maxhp
      self.damage*= 2
    end
    if self.is_a?(Game_Actor) && self.skill_learn?(LAST_STAND_ID) && ((self.hp*100)/self.maxhp) < 30
      self.damage/= 2
    end
    if attacker.is_a?(Game_Actor) && attacker.skill_learn?(CHARGED_ATTACKS_ID) && attacker.sp > 0
      attacker.sp -= 6
      self.damage += self.damage/3
    end
    if self.is_a?(Game_Actor) && self.skill_learn?(ONCE_MORE_ID) && self.hp > 1 && self.damage > self.hp
    self.damage = self.hp - 1  
    end
     if self.is_a?(Game_Actor) && self.skill_learn?(MP_SHIELD_ID) && self.sp > 0
      self.sp -= self.damage
  else
       self.hp -= self.damage
       end
      # ??????
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # ?????
    else
      # ????? "Miss" ???
      self.damage = "Miss"
      # ?????????????
      self.critical = false
    end
    # ??????
    return true
  end
  #--------------------------------------------------------------------------
  # ? ????????
  #     user  : ??????? (????)
  #     skill : ???
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    # ?????????????
    self.critical = false
    # ????????? HP 1 ?????????? HP ? 0?
    # ???????????? HP 0 ???????? HP ? 1 ?????
    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
    # ??????? ID ????????????????
    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 * 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 = 20
      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
        if self.is_a?(Game_Actor) && self.guarding? && self.skill_learn?(GUARD_PLUS_ID)
          self.damage /= 2
          end
      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.dex + 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
      # ?? 0 ??????????
      if skill.power != 0 and skill.atk_f > 0
        # ????????
        remove_states_shock
        # ?????????
        effective = true
      end
      # HP ?????????
      last_hp = self.hp
        if self.is_a?(Game_Actor) && self.skill_learn?(MARTYR_ID)
      sp_recovery = self.damage/10
      self.sp += sp_recovery
    end
        if user.is_a?(Game_Actor) && user.skill_learn?(WARMAGE_ID)  && self.damage > 0
      sp_recovery = self.damage/10
      user.sp += sp_recovery
    end
      if user.is_a?(Game_Actor) && user.skill_learn?(TURBO_MP_ID) && skill.mdef_f > 0
      self.damage*=2
    end
      if user.is_a?(Game_Actor) && user.skill_learn?(SPELLBREAKER_ID) && skill.mdef_f > 0 && ((user.hp*100)/ user.maxhp) < 30
      self.damage*=2
    end
      if user.is_a?(Game_Actor) && user.skill_learn?(ADRENALINE_ID) && skill.pdef_f > 0 && ((user.hp*100)/ user.maxhp) < 30
      self.damage*=2
    end
      if user.is_a?(Game_Actor) && user.skill_learn?(SERENITY_ID) && skill.mdef_f > 0 && user.hp = user.maxhp
      self.damage += self.damage/3
    end
      if user.is_a?(Game_Actor) && user.skill_learn?(FOCUS_ID) && skill.pdef_f > 0 && user.hp = user.maxhp
      self.damage += self.damage/3
    end
      if self.is_a?(Game_Actor) && self.skill_learn?(LAST_STAND_ID) && ((self.hp*100)/self.maxhp) < 30
      self.damage/= 2
    end
      if self.is_a?(Game_Actor) && self.skill_learn?(ONCE_MORE_ID) && self.hp > 1 && self.damage > self.hp
    self.damage = self.hp - 1  
  end
      if self.is_a?(Game_Actor) && self.skill_learn?(HEALER_ID) && self.damage < 0
        self.damage *= 2
      end
    if self.is_a?(Game_Actor) && self.skill_learn?(LEARNING_ID) && BLUE_SKILLS_IDS.include?(skill.id)
    learn_skill(skill.id)
    end
      if self.is_a?(Game_Actor) && self.skill_learn?(MP_SHIELD_ID) && self.sp > 0
      self.sp -= self.damage
  else
       self.hp -= self.damage
     end
      effective |= self.hp != last_hp
      # ??????
      @state_changed = false
      effective |= states_plus(skill.plus_state_set)
      effective |= states_minus(skill.minus_state_set)
      # ??? 0 ???
      if skill.power == 0
        # ????????????
        self.damage = "Miss"
        # ????????????
        unless @state_changed
          # ????? "Miss" ???
          self.damage = "Miss"
        end
      end
    # ?????
    else
      # ????? "Miss" ???
      self.damage = "Miss"
    end
    # ????????
    unless $game_temp.in_battle
      # ????? nil ???
      self.damage = nil
    end
    # ??????
    return effective
  end
  #--------------------------------------------------------------------------
  # ? ?????????
  #     item : ????
  #--------------------------------------------------------------------------
  def item_effect(item)
    # ?????????????
    self.critical = false
    # ?????????? HP 1 ?????????? HP ? 0?
    # ????????????? HP 0 ???????? HP ? 1 ?????
    if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
       ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
      # ??????
      return false
    end
    # ?????????
    effective = false
    # ??????? ID ????????????????
    effective |= item.common_event_id > 0
    # ????
    hit_result = (rand(100) < item.hit)
    # ????????????????????
    effective |= item.hit < 100
    # ?????
    if hit_result == true
      # ??????
      recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
      recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
      if recover_hp < 0
        recover_hp += self.pdef * item.pdef_f / 20
        recover_hp += self.mdef * item.mdef_f / 20
        recover_hp = [recover_hp, 0].min
      end
      # ????
      recover_hp *= elements_correct(item.element_set)
      recover_hp /= 100
      recover_sp *= elements_correct(item.element_set)
      recover_sp /= 100
      # ??
      if item.variance > 0 and recover_hp.abs > 0
        amp = [recover_hp.abs * item.variance / 100, 1].max
        recover_hp += rand(amp+1) + rand(amp+1) - amp
      end
      if item.variance > 0 and recover_sp.abs > 0
        amp = [recover_sp.abs * item.variance / 100, 1].max
        recover_sp += rand(amp+1) + rand(amp+1) - amp
      end
      # ???????????
      if recover_hp < 0
        # ????
        if self.guarding?
          recover_hp /= 2
        end
      end
      # HP ????????????????????
      if self.is_a?(Game_Actor) && self.skill_learn?(HEALER_ID) && recover.hp > 0
        recover_hp *= 2
        end
      self.damage = -recover_hp
      # HP ??? SP ???
      last_hp = self.hp
      last_sp = self.sp
      self.hp += recover_hp
      self.sp += recover_sp
      effective |= self.hp != last_hp
      effective |= self.sp != last_sp
      # ??????
      @state_changed = false
      effective |= states_plus(item.plus_state_set)
      effective |= states_minus(item.minus_state_set)
      # ??????????????
      if item.parameter_type > 0 and item.parameter_points != 0
        # ????????
        case item.parameter_type
        when 1  # MaxHP
          @maxhp_plus += item.parameter_points
        when 2  # MaxSP
          @maxsp_plus += item.parameter_points
        when 3  # ??
          @str_plus += item.parameter_points
        when 4  # ???
          @dex_plus += item.parameter_points
        when 5  # ???
          @agi_plus += item.parameter_points
        when 6  # ??
          @int_plus += item.parameter_points
        end
        # ?????????
        effective = true
      end
      # HP ???????? 0 ???
      if item.recover_hp_rate == 0 and item.recover_hp == 0
        # ????????????
        self.damage = ""
        # SP ???????? 0???????????????
        if item.recover_sp_rate == 0 and item.recover_sp == 0 and
           (item.parameter_type == 0 or item.parameter_points == 0)
          # ????????????
          unless @state_changed
            # ????? "Miss" ???
            self.damage = "Miss"
          end
        end
      end
    # ?????
    else
      # ????? "Miss" ???
      self.damage = "Miss"
    end
    # ????????
    unless $game_temp.in_battle
      # ????? nil ???
      self.damage = nil
    end
    # ??????
    return effective
  end
  #--------------------------------------------------------------------------
  # ? ?????????????
  #--------------------------------------------------------------------------
  def slip_damage_effect
    # ???????
    self.damage = self.maxhp / 10
    # ??
    if self.damage.abs > 0
      amp = [self.damage.abs * 15 / 100, 1].max
      self.damage += rand(amp+1) + rand(amp+1) - amp
    end
    # HP ?????????
    self.hp -= self.damage
    # ??????
    return true
  end
end

class Scene_Battle
  def make_skill_action_result
    # ??????
    @skill = $data_skills[@active_battler.current_action.skill_id]
    # ????????????
    unless @active_battler.current_action.forcing
      # SP ????????????????
      unless @active_battler.skill_can_use?(@skill.id)
        # ??????????????????
        $game_temp.forcing_battler = nil
        # ???? 1 ???
        @phase4_step = 1
        return
      end
    end
      if @active_battler.is_a?(Game_Actor) && @active_battler.skill_learn?(DEMI_MP_ID)
        @skill.sp_cost/=2
      end    
            if @active_battler.is_a?(Game_Actor) && @active_battler.skill_learn?(TURBO_MP_ID)
        @skill.sp_cost*=2
        end    
    # SP ??
    if @active_battler.is_a?(Game_Actor) && @active_battler.skill_learn?(BLOOD_PRICE_ID)
    @active_battler.hp -= (@skill.sp_cost *5 )
  else
    @active_battler.sp -= @skill.sp_cost
    end
    # ?????????????????
    @status_window.refresh
    # ????????????????
    @help_window.set_text(@skill.name, 1)
    # ??????? ID ???
    @animation1_id = @skill.animation1_id
    @animation2_id = @skill.animation2_id
    # ??????? ID ???
    @common_event_id = @skill.common_event_id
    # ??????????
    set_target_battlers(@skill.scope)
    # ?????????
    for target in @target_battlers
      target.skill_effect(@active_battler, @skill)
    end
  end
  end

#==============================================================================
# ? Window_Passive
#------------------------------------------------------------------------------
# ??????????????????????????????????????
#==============================================================================

class Window_Passive < Window_Selectable
  #--------------------------------------------------------------------------
  # ? ?????????
  #     actor : ????
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 128, 640, 352)
    @actor = actor
    @column_max = 2
    refresh
    self.index = 0
    # ????????????????????????????
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills[i]]
      if skill != nil && PASSIVE_SKILLS_IDS.include?(skill.id)
        @data.push(skill)
      end
    end
    # ???? 0 ??????????????????????
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????
  #     index : ????
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
      self.contents.font.color = normal_color
    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)
      end
  #--------------------------------------------------------------------------
  # ? ?????????
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  end
end

#==============================================================================
# ? Scene_Skill
#------------------------------------------------------------------------------
# ??????????????????
#==============================================================================

class Scene_Passive
  #--------------------------------------------------------------------------
  # ? ?????????
  #     actor_index : ??????????
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # ? ?????
  #--------------------------------------------------------------------------
  def main
    # ???????
    @actor = $game_party.actors[@actor_index]
    # ???????????????????????????????
    @help_window = Window_Help.new
    @status_window = Window_SkillStatus.new(@actor)
    @skill_window = Window_Passive.new(@actor)
    # ?????????????
    @skill_window.help_window = @help_window
    # ????????????? (?????????????)
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
    # ?????????
    Graphics.transition
    # ??????
    loop do
      # ????????
      Graphics.update
      # ???????
      Input.update
      # ??????
      update
      # ????????????????
      if $scene != self
        break
      end
    end
    # ?????????
    Graphics.freeze
    # ????????
    @help_window.dispose
    @status_window.dispose
    @skill_window.dispose
    @target_window.dispose
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def update
    # ????????
    @help_window.update
    @status_window.update
    @skill_window.update
    @target_window.update
    # ?????????????????: update_skill ???
    if @skill_window.active
      update_skill
      return
    end
    # ???????????????????: update_target ???
    if @target_window.active
      update_target
      return
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????? (?????????????????)
  #--------------------------------------------------------------------------
  def update_skill
    # B ??????????
    if Input.trigger?(Input::B)
      # ????? SE ???
      $game_system.se_play($data_system.cancel_se)
      # ???????????
      $scene = Scene_Menu.new(2)
      return
    end
    # C ??????????
    if Input.trigger?(Input::C)
      # ????????????????????????
      @skill = @skill_window.skill
      # ????????
      if @skill == nil or not @actor.skill_can_use?(@skill.id)
        # ??? SE ???
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # ?? SE ???
      $game_system.se_play($data_system.decision_se)
      # ??????????
      if @skill.scope >= 3
        # ?????????????????
        @skill_window.active = false
        @target_window.x = (@skill_window.index + 1) % 2 * 304
        @target_window.visible = true
        @target_window.active = true
        # ???? (??/??) ?????????????
        if @skill.scope == 4 || @skill.scope == 6
          @target_window.index = -1
        elsif @skill.scope == 7
          @target_window.index = @actor_index - 10
        else
          @target_window.index = 0
        end
      # ????????????
      else
        # ??????? ID ??????
        if @skill.common_event_id > 0
          # ?????????????
          $game_temp.common_event_id = @skill.common_event_id
          # ??????? SE ???
          $game_system.se_play(@skill.menu_se)
          # SP ??
          @actor.sp -= @skill.sp_cost
          # ?????????????
          @status_window.refresh
          @skill_window.refresh
          @target_window.refresh
          # ??????????
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
    # R ??????????
    if Input.trigger?(Input::R)
      # ???? SE ???
      $game_system.se_play($data_system.cursor_se)
      # ???????
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # ????????????
      $scene = Scene_Skill.new(@actor_index)
      return
    end
    # L ??????????
    if Input.trigger?(Input::L)
      # ???? SE ???
      $game_system.se_play($data_system.cursor_se)
      # ???????
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # ????????????
      $scene = Scene_Skill.new(@actor_index)
      return
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????? (???????????????????)
  #--------------------------------------------------------------------------
  def update_target
    # B ??????????
    if Input.trigger?(Input::B)
      # ????? SE ???
      $game_system.se_play($data_system.cancel_se)
      # ?????????????
      @skill_window.active = true
      @target_window.visible = false
      @target_window.active = false
      return
    end
    # C ??????????
    if Input.trigger?(Input::C)
      # SP ????????????????
      unless @actor.skill_can_use?(@skill.id)
        # ??? SE ???
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # ???????????
      if @target_window.index == -1
        # ??????????????????
        used = false
        for i in $game_party.actors
          used |= i.skill_effect(@actor, @skill)
        end
      end
      # ????????????
      if @target_window.index <= -2
        # ??????????????????????
        target = $game_party.actors[@target_window.index + 10]
        used = target.skill_effect(@actor, @skill)
      end
      # ???????????
      if @target_window.index >= 0
        # ??????????????????????
        target = $game_party.actors[@target_window.index]
        used = target.skill_effect(@actor, @skill)
      end
      # ?????????
      if used
        # ??????? SE ???
        $game_system.se_play(@skill.menu_se)
        # SP ??
        @actor.sp -= @skill.sp_cost
        # ?????????????
        @status_window.refresh
        @skill_window.refresh
        @target_window.refresh
        # ?????
        if $game_party.all_dead?
          # ??????????????
          $scene = Scene_Gameover.new
          return
        end
        # ??????? ID ??????
        if @skill.common_event_id > 0
          # ?????????????
          $game_temp.common_event_id = @skill.common_event_id
          # ??????????
          $scene = Scene_Map.new
          return
        end
      end
      # ????????????
      unless used
        # ??? SE ???
        $game_system.se_play($data_system.buzzer_se)
      end
      return
    end
  end
end

#==============================================================================
# ? Scene_Menu
#------------------------------------------------------------------------------
# ???????????????????
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # ? ?????????
  #     menu_index : ?????????????
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # ? ?????
  #--------------------------------------------------------------------------
  def main
    # ????????????
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = PASSIVE_WORD
    s4 = $data_system.words.equip
    s5 = "État"
    s6 = "Sauvegarder"
    s7 = "Quitter"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.index = @menu_index
    # ??????? 0 ????
    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)
    end
    # ????????
    if $game_system.save_disabled
      # ?????????
      @command_window.disable_item(4)
    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_window.update
    @playtime_window.update
    @steps_window.update
    @gold_window.update
    @status_window.update
    # ??????????????????: update_command ???
    if @command_window.active
      update_command
      return
    end
    # ???????????????????: update_status ???
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????? (??????????????????)
  #--------------------------------------------------------------------------
  def update_command
    # B ??????????
    if Input.trigger?(Input::B)
      # ????? SE ???
      $game_system.se_play($data_system.cancel_se)
      # ??????????
      $scene = Scene_Map.new
      return
    end
    # C ??????????
    if Input.trigger?(Input::C)
      # ??????? 0 ??????????????????????
      if $game_party.actors.size == 0 and @command_window.index < 4
        # ??? SE ???
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # ???????????????????
      case @command_window.index
      when 0  # ????
        # ??  SE ???
        $game_system.se_play($data_system.decision_se)
        # ???????????
        $scene = Scene_Item.new
      when 1  # ???
        # ?? SE ???
        $game_system.se_play($data_system.decision_se)
        # ???????????????????
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # ???
        # ?? SE ???
        $game_system.se_play($data_system.decision_se)
        # ???????????????????
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3  # ??
        # ?? SE ???
        $game_system.se_play($data_system.decision_se)
        # ???????????????????
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4  # ?????
        # ?? SE ???
        $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
          # ??? SE ???
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # ?? SE ???
        $game_system.se_play($data_system.decision_se)
        # ??????????
        $scene = Scene_Save.new
      when 6  # ?????
        # ?? SE ???
        $game_system.se_play($data_system.decision_se)
        # ????????????
        $scene = Scene_End.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????? (???????????????????)
  #--------------------------------------------------------------------------
  def update_status
    # B ??????????
    if Input.trigger?(Input::B)
      # ????? SE ???
      $game_system.se_play($data_system.cancel_se)
      # ??????????????????
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    # C ??????????
    if Input.trigger?(Input::C)
      # ???????????????????
      case @command_window.index
      when 1  # ???
        # ???????????? 2 ?????
        if $game_party.actors[@status_window.index].restriction >= 2
          # ??? SE ???
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # ?? SE ???
        $game_system.se_play($data_system.decision_se)
        # ??????????
        $scene = Scene_Skill.new(@status_window.index)
              when 2  # ???
        # ???????????? 2 ?????
        if $game_party.actors[@status_window.index].restriction >= 2
          # ??? SE ???
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # ?? SE ???
        $game_system.se_play($data_system.decision_se)
        # ??????????
        $scene = Scene_Passive.new(@status_window.index)
      when 3  # ??
        # ?? SE ???
        $game_system.se_play($data_system.decision_se)
        # ?????????
        $scene = Scene_Equip.new(@status_window.index)
      when 4  # ?????
        # ?? SE ???
        $game_system.se_play($data_system.decision_se)
        # ????????????
        $scene = Scene_Status.new(@status_window.index)
      end
      return
    end
  end
end

#==============================================================================
# ? Window_Skill
#------------------------------------------------------------------------------
# ??????????????????????????????????????
#==============================================================================

class Window_Skill < Window_Selectable
  #--------------------------------------------------------------------------
  # ? ?????????
  #     actor : ????
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 128, 640, 352)
    @actor = actor
    @column_max = 2
    refresh
    self.index = 0
    # ????????????????????????????
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills[i]]
      if skill != nil && PASSIVE_SKILLS_IDS.include?(skill.id)
      elsif skill != nil
        @data.push(skill)
      end
      end
    # ???? 0 ??????????????????????
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $fontface
#      self.contents.font.size = $fontsize
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????
  #     index : ????
  #--------------------------------------------------------------------------
  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)
  if skill.sp_cost > 0
    self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  end
end
  #--------------------------------------------------------------------------
  # ? ?????????
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  end
end


class Game_Actor < Game_Battler
  def animation1_id
    weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.animation1_id : BARE_ANIMATION_SELF_ID
  end

  def animation2_id
    weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.animation2_id : BARE_ANIMATION_ID
  end
end

class Scene_Equip

  alias update_item_ers_later update_item
  def update_item
      itemskill = Xelias.ers_config(@item_window.item)
      if Input.trigger?(Input::C)
       unless (@actor.skill_learn?(itemskill[0]))
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      end
    update_item_ers_later
  end
end

class Game_Battler
  
  alias skill_met? skill_can_use?
  def skill_can_use?(skill_id)
    data = Xelias.req_skill(skill_id)
     unless skill_learn?(data) ? false : skill_met?(skill_id)
        return data != nil
    end
  end
end



Bug on a script - PK8 - 12-11-2009

Moving this to Support. :p


Bug on a script - fgsfds - 12-11-2009

I thought support is for non-rgss1/2? Or did I misread?


Bug on a script - PK8 - 12-11-2009

It's for both, as noted in the forum description. :)
Quote:Ask for help on non-RGSS(2) or RGSS(2) related issues here.



Bug on a script - fgsfds - 12-11-2009

Oh! RGSS2, I misread. Sorry for posting on the wrong section


Bug on a script - Charlie Fleed - 12-11-2009

You know sometimes reading the instructions helps...

Quote:# Passive skills can also be used to equip weapons and armors, and to be able to use skills.
# Configure it like that :
#
# When [weapon/armor id] then return [passive skill id]
# When [skill id] then return [passive skill id]
#
# Note that passive skills overwrite class restrictions : if a warrior gets a "Equip Staffs"
# passive ability, he will be able to equip staffs.
#
# On a sad note, all weapons/armors need to be set to a skill in order to be equipped.
# If you put "nil" or "0", the game will crash.
# So set a skill for each different weapon or armor. Default is 100
# The same applies for skills. Skills won't crash, but won't be able to be used. Which is bad.
# However if you put "when skill X then return skill X", the skill will be usable if you have it, which
# means you won't have to learn another passive skill.

Do you see this piece of code in the script?

Code:
def self.req_skill(id)
    case id
      # START Skill Configuration
      when 8 then return 101
    end
    return
  end

You should put all the "dependencies" here, like this:

Code:
def self.req_skill(id)
    case id
      # START Skill Configuration
      when 8 then return 101
      when 1 then return 1 # Heal requires Heal
      when 2 then return 2 # Greater Heal requires Greater Heal
      when 3 then return 2 # Mass Heal requires Greater Heal
    end
    return
  end

However, I suggest to change it a little bit:

Code:
def self.req_skill(id)
    case id
      # START Skill Configuration
      when 8 then return 101
      when 1 then return 1 # Heal requires Heal
      when 2 then return 2 # Greater Heal requires Greater Heal
      when 3 then return 2 # Mass Heal requires Greater Heal
    end
    return id
  end

See the "return id" line? Now the default behavior is that a skill only needs itself to be learned in order to be used.

And if you don't need this feature at all, change it like this:

Code:
def self.req_skill(id)
    return id
  end



Bug on a script - fgsfds - 12-11-2009

Shocked
I still have bad english, I always use translator to translate things which is why my sentence makes no sense.

So, if the skill, weapon and equip works the same.. then I have to write every ID for armor.. I want to use some for the equip and weapon, like the usual thing where you put the ID when you want it, not putting the ID that your forced to do.. can that be done?


Bug on a script - Charlie Fleed - 12-11-2009

err... I'm not sure I understand what you're asking...


Bug on a script - fgsfds - 12-11-2009

Like, by default with no specifying on the script, the equipment/weapon doesn't have the effect and its equipable. Then by putting hash or array in the script, then it will have that passive effect embedded in the equip/weapon.


Bug on a script - Charlie Fleed - 12-11-2009

Ok, we need to keep the two things separated: one thing is whether a weapon/armor is equippable or not, and another is the passive skills embedded in it.
The first one is dealt with in the script. The second one is something you need a different script in order to have it (or a rather complex system of events). Usually the scripts that do this are called "Equipment Skills" or something like that. My Skills Learning System has that feature too.