Save-Point
All Stats Modified - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: All Stats Modified (/thread-5144.html)



All Stats Modified - kyonides - 05-17-2014

All Stats Modified
XP Version

by Kyonides-Arkanthos


Features

Did you want to reduce slip damage caused by poisonous swamps? Did you need to alter your hero's stats by equipping weapons or armors in ways not possible with the default system? Did you want to save MP (SP in RMXP) so your mage could cast more spells during any difficult battle?

Well, now you should be able to do it if you learn how to edit the hash contents but it's not so difficult if you pay attention to the examples already included in my script. There you may find a weapon and several armor pieces or accessories that may alter those stats for you. Some of them may even steal some MP from your hero in exchange for some extra HP or vice versa.


Instructions

Just paste this script below the second last default script and before Main script. If you included a custom battle system, then paste it below it. Just in case it is not compatible, let me know about it and I'll check if I can make it compatible or not. Don't forget to setup the CUSTOM_BATTLE_SYSTEM Constant with the true boolean value in case you added one to your project.

Code:
#  All Stats Modified  XP Version
#  v 1.0 - 2014-05-16 (Y-M-D)
#  Scripter : Kyonides-Arkanthos

#  This script allows you modify your heroes' stats in ways not included in the
#  RMXP Hero / Weapon / Armor Databases.
#  You may reduce Slip Damage caused by poisonous swamps or floors full of
#  little spikes by equipping a piece of any kind of armor.
#  Your hero may reduce any skill mp alias sp cost, weapons or armors may help
#  you with this. Don't forget to properly setup the reduction percentage.
#  Nonetheless you may want to increase your hero's HP by reducing his SP if he
#  or she is a fighter or lancer or vice versa if he or she is a cleric or mage.
#  If you increase a hero's Strength STR, your hero may see how his Intelligence
#  INT gets reduced by the same amount. Dexterity DEX affects Agility AGI while
#  AGI affects DEX directly.
#  All Modified Stats are calculated based on their base value for the current
#  hero's level and will get updated if the hero levels up or down.

#  Please Don't Forget to Properly Setup the Weapons or Armors in the Database!!
#  Believe me when I tell you that's the easiest part of the setup.

#  MODIFIED SCRIPT CLASSES
#    Game_Actor  Window_Skill  Scene_Equip  Default Scene_Battle

module All_Stats
  # DID YOU INCLUDE A CUSTOM BATTLE SYSTEM? Yes : true, No : false or nil
  CUSTOM_BATTLE_SYSTEM = false
  # Armor : { ID => Percentage, ID => Percentage, etc. }
  SLIP_DAMAGE_REDUCTION_ITEMS = { 50 => 10, 51 => 25, 52 => 50}
  # [ Weapon or Armor ] = { ID => Percentage, ID => Percentage, etc. }
  MP_SAVING_ITEMS = { 33 => 10, 34 => 20, 35 => 33, 36 => 50, 37 => 75 }
  # DO NOT MODIFY THE FOLLOWING TWO LINES
  ITEMS  = { :HP => {},  :SP => {},  :STR => {},
             :DEX => {}, :AGI => {}, :INT => {} }
  # YOU MAY MODIFY THE FOLLOWING LINES
  # [ STAT ][ Weapon or Armor ] = { ID => Percentage, ID => Percentage, etc. }
  ITEMS[:HP][:weapon] = { 1 => 10 }
  ITEMS[:HP][:armor]  = { 38 => 10, 44 => 25 }
  ITEMS[:SP][:weapon] = {}
  ITEMS[:SP][:armor]  = { 39 => 10, 45 => 25 }
  ITEMS[:STR][:weapon] = {}
  ITEMS[:STR][:armor]  = { 40 => 10, 46 => 25 }
  ITEMS[:DEX][:weapon] = {}
  ITEMS[:DEX][:armor]  = { 41 => 10, 47 => 25 }
  ITEMS[:AGI][:weapon] = {}
  ITEMS[:AGI][:armor]  = { 42 => 10, 48 => 25 }
  ITEMS[:INT][:weapon] = {}
  ITEMS[:INT][:armor]  = { 43 => 10, 49 => 25 }
  # DO NOT MODIFY THE FOLLOWING LINES
  INDEX = { :weapon => {}, :armor => {} }
  ITEMS.keys.each {|stat|
    ITEMS[stat][:weapon].each {|w| INDEX[:weapon][w[0]] = stat }
    ITEMS[stat][:armor].each {|a| INDEX[:armor][a[0]] = stat } }
end

module Calculate
  def self.skill_sp_cost(user, sp_cost, consume_sp=true)
    if user.is_a?(Game_Actor)
      ids = [user.weapon_id, user.armor1_id, user.armor2_id,
             user.armor3_id, user.armor4_id]
      for id in ids
        if All_Stats::MP_SAVING_ITEMS.keys.include?(id)
          sp_cost -= sp_cost * All_Stats::MP_SAVING_ITEMS[id] / 100
        end
      end
      ids.clear
    end
    return consume_sp ? user.sp -= sp_cost : sp_cost
  end
end

class Game_Actor
  alias kyon_stats_modif_gm_actor_setup setup
  def setup(actor_id)
    kyon_stats_modif_gm_actor_setup(actor_id)
    @hp_mod  = { :weapon => {}, :armor => {} }
    @sp_mod  = { :weapon => {}, :armor => {} }
    @str_mod = { :weapon => {}, :armor => {} }
    @dex_mod = { :weapon => {}, :armor => {} }
    @agi_mod = { :weapon => {}, :armor => {} }
    @int_mod = { :weapon => {}, :armor => {} }
    update_all_modified_stats
  end

  alias kyon_stats_modif_gm_actor_level= level=
  def level=(level)
    kyon_stats_modif_gm_actor_level=(level)
    update_all_modified_stats
  end

  def equip(equip_type, id)
    case equip_type
    when 0  # Weapon
      if id == 0 or $game_party.weapon_number(id) > 0
        $game_party.gain_weapon(@weapon_id, 1)
        previous_id = @weapon_id
        @weapon_id = id
        $game_party.lose_weapon(id, 1)
        update_modified_stats(:weapon, previous_id, id)
      end
    when 1  # Shield
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor1_id], $data_armors[id])
        $game_party.gain_armor(@armor1_id, 1)
        previous_id = @armor1_id
        @armor1_id = id
        $game_party.lose_armor(id, 1)
        update_modified_stats(:armor, previous_id, id)
      end
    when 2  # Head
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor2_id], $data_armors[id])
        $game_party.gain_armor(@armor2_id, 1)
        previous_id = @armor2_id
        @armor2_id = id
        $game_party.lose_armor(id, 1)
        update_modified_stats(:armor, previous_id, id)
      end
    when 3  # Body
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor3_id], $data_armors[id])
        $game_party.gain_armor(@armor3_id, 1)
        previous_id = @armor3_id
        @armor3_id = id
        $game_party.lose_armor(id, 1)
        update_modified_stats(:armor, previous_id, id)
      end
    when 4  # Accessory
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor4_id], $data_armors[id])
        $game_party.gain_armor(@armor4_id, 1)
        previous_id = @armor4_id
        @armor4_id = id
        $game_party.lose_armor(id, 1)
        update_modified_stats(:armor, previous_id, id)
      end
    end
  end

  def update_modified_stats(kind, previous_id, new_id)
    stat = All_Stats::INDEX[kind]
    if stat.keys.include?(new_id)
      item = All_Stats::ITEMS[stat[new_id]][kind][new_id]
      case stat[new_id]
      when :HP
        @hp_mod[kind][new_id] = self.base_maxsp * item / 100
        self.maxhp += @hp_mod[kind][new_id]
        self.maxsp -= @hp_mod[kind][new_id]
      when :SP
        @sp_mod[kind][new_id] = self.base_maxhp * item / 100
        self.maxsp += @sp_mod[kind][new_id]
        self.maxhp -= @sp_mod[kind][new_id]
      when :STR
        @str_mod[kind][new_id] = self.base_int * item / 100
        self.str += @str_mod[kind][new_id]
        self.int -= @str_mod[kind][new_id]
      when :DEX
        @dex_mod[kind][new_id] = self.base_agi * item / 100
        self.dex += @dex_mod[kind][new_id]
        self.agi -= @dex_mod[kind][new_id]
      when :AGI
        @agi_mod[kind][new_id] = self.base_dex * item / 100
        self.agi += @agi_mod[kind][new_id]
        self.dex -= @agi_mod[kind][new_id]
      when :INT
        @int_mod[kind][new_id] = self.base_str * item / 100
        self.int += @int_mod[kind][new_id]
        self.str -= @int_mod[kind][new_id]
      end
    elsif stat.keys.include?(previous_id)
      case stat[previous_id]
      when :HP
        self.maxhp -= @hp_mod[kind][previous_id]
        self.maxsp += @hp_mod[kind][previous_id]
        @hp_mod[kind].delete(previous_id)
      when :SP
        self.maxsp -= @sp_mod[kind][previous_id]
        self.maxhp += @sp_mod[kind][previous_id]
        @sp_mod[kind].delete(previous_id)
      when :STR
        self.str -= @str_mod[kind][previous_id]
        self.int += @str_mod[kind][previous_id]
        @str_mod[kind].delete(previous_id)
      when :DEX
        self.dex -= @dex_mod[kind][previous_id]
        self.agi += @dex_mod[kind][previous_id]
        @dex_mod[kind].delete(previous_id)
      when :AGI
        self.agi -= @agi_mod[kind][previous_id]
        self.dex += @agi_mod[kind][previous_id]
        @agi_mod[kind].delete(previous_id)
      when :INT
        self.int -= @int_mod[kind][previous_id]
        self.str += @int_mod[kind][previous_id]
        @int_mod[kind].delete(previous_id)
      end
    end
  end

  def update_all_modified_stats
    update_modified_stats(:weapon, 0, @weapon_id)
    update_modified_stats(:armor, 0, @armor1_id)
    update_modified_stats(:armor, 0, @armor2_id)
    update_modified_stats(:armor, 0, @armor3_id)
    update_modified_stats(:armor, 0, @armor4_id)
  end

  def skill_can_use?(skill_id)
    sp_cost = $data_skills[skill_id].sp_cost
    sp_cost = Calculate.skill_sp_cost(self, sp_cost, false)
    # If there's not enough SP, the skill cannot be used.
    return false if sp_cost > self.sp
    # Unusable if incapacitated
    return false if dead?
    # If silent, only physical skills can be used
    return false if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
    # Get usable time
    occasion = $data_skills[skill_id].occasion
    # If in battle
    if $game_temp.in_battle
      # Usable with [Normal] and [Only Battle]
      return (occasion == 0 or occasion == 1)
    # If not in battle
    else
      # Usable with [Normal] and [Only Menu]
      return (occasion == 0 or occasion == 2)
    end
  end

  def slip_damage_effect
    # Set damage
    self.damage = self.maxhp / 10
    ### Modification ###
    slip_dmg_items = All_Stats::SLIP_DAMAGE_REDUCTION_ITEMS
    for equip_id in [@weapon_id, @armor1_id, @armor2_id, @armor3_id, @armor4_id]
      next unless slip_dmg_items.include?(equip_id)
      self.damage -= self.damage * slip_dmg_items[equip_id] / 100
    end
    ### End of Modification ###
    # Dispersion
    if self.damage.abs > 0
      amp = [self.damage.abs * 15 / 100, 1].max
      self.damage += rand(amp+1) + rand(amp+1) - amp
    end
    # Subtract damage from HP
    self.hp -= self.damage
    # End Method
    return true
  end
end

class Window_Skill
  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)
    sp_cost = Calculate.skill_sp_cost(@actor, skill.sp_cost, false)
    self.contents.draw_text(x + 232, y, 48, 32, sp_cost.to_s, 2)
  end
end

class Scene_Skill
  def update_skill
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(1)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the skill window
      @skill = @skill_window.skill
      # If unable to use
      if @skill == nil or not @actor.skill_can_use?(@skill.id)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # If effect scope is ally
      if @skill.scope >= 3
        # Activate target window
        @skill_window.active = false
        @target_window.x = (@skill_window.index + 1) % 2 * 304
        @target_window.visible = true
        @target_window.active = true
        # Set cursor position to effect scope (single / all)
        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
      # If effect scope is other than ally
      else
        # If common event ID is valid
        if @skill.common_event_id > 0
          # Common event call reservation
          $game_temp.common_event_id = @skill.common_event_id
          # Play use skill SE
          $game_system.se_play(@skill.menu_se)
          ### Modification ###
          # Use up SP
          Calculate.skill_sp_cost(@actor, @skill.sp_cost)
          ### End of Modification ###
          # Remake each window content
          @status_window.refresh
          @skill_window.refresh
          @target_window.refresh
          # Switch to map screen
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
    # If R or L button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different skill screen
      $scene = Scene_Skill.new(@actor_index)
      return
    elsif Input.trigger?(Input::L)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous actor
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Switch to different skill screen
      $scene = Scene_Skill.new(@actor_index)
      return
    end
  end

  def update_target
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Erase target window
      @skill_window.active = true
      @target_window.visible = false
      @target_window.active = false
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If unable to use because SP ran out
      unless @actor.skill_can_use?(@skill.id)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If target is all
      if @target_window.index == -1
        # Apply skill use effects to entire party
        used = false
        for i in $game_party.actors
          used |= i.skill_effect(@actor, @skill)
        end
      end
      # If target is user
      if @target_window.index <= -2
        # Apply skill use effects to target actor
        target = $game_party.actors[@target_window.index + 10]
        used = target.skill_effect(@actor, @skill)
      end
      # If single target
      if @target_window.index >= 0
        # Apply skill use effects to target actor
        target = $game_party.actors[@target_window.index]
        used = target.skill_effect(@actor, @skill)
      end
      # If skill was used
      if used
        # Play skill use SE
        $game_system.se_play(@skill.menu_se)
        # Use up SP
        Calculate.skill_sp_cost(@actor, @skill.sp_cost)
        # Remake each window content
        @status_window.refresh
        @skill_window.refresh
        @target_window.refresh
        # If entire party is dead
        if $game_party.all_dead?
          # Switch to game over screen
          $scene = Scene_Gameover.new
          return
        end
        # If command event ID is valid
        if @skill.common_event_id > 0
          # Command event call reservation
          $game_temp.common_event_id = @skill.common_event_id
          # Switch to map screen
          $scene = Scene_Map.new
          return
        end
      end
      # If skill wasn't used, play buzzer SE
      $game_system.se_play($data_system.buzzer_se) unless used
      return
    end
  end
end

class Scene_Equip
  def refresh
    # Set item window to visible
    @item_window1.visible = (@right_window.index == 0)
    @item_window2.visible = (@right_window.index == 1)
    @item_window3.visible = (@right_window.index == 2)
    @item_window4.visible = (@right_window.index == 3)
    @item_window5.visible = (@right_window.index == 4)
    # Get currently equipped item
    item1 = @right_window.item
    # Set current item window to @item_window
    case @right_window.index
    when 0
      @item_window = @item_window1
    when 1
      @item_window = @item_window2
    when 2
      @item_window = @item_window3
    when 3
      @item_window = @item_window4
    when 4
      @item_window = @item_window5
    end
    # If right window is active
    if @right_window.active
      # Erase parameters for after equipment change
      @left_window.set_new_parameters(nil, nil, nil)
    end
    ### Modification ###
    # If item window is active
    if @item_window.active and @last_item != @item_window.item
      # Replaced Actual Hero with a Duplicate to avoid unintended statistics
      # modifications that could reach the maximum value allowed by the game
      @temp_actor = @actor.dup
      # Get currently selected item
      @last_item = item2 = @item_window.item
      # Change equipment
      last_hp = @temp_actor.hp
      last_sp = @temp_actor.sp
      @temp_actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
      # Get parameters for after equipment change
      new_atk = @temp_actor.atk
      new_pdef = @temp_actor.pdef
      new_mdef = @temp_actor.mdef
      # Return equipment
      @temp_actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
      @temp_actor.hp = last_hp
      @temp_actor.sp = last_sp
    ### End of Modification ###
      # Draw in left window
      @left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
    end
  end
end

unless All_Stats::CUSTOM_BATTLE_SYSTEM

class Scene_Battle
  def make_skill_action_result
    # Get skill
    @skill = $data_skills[@active_battler.current_action.skill_id]
    # If not a forcing action
    unless @active_battler.current_action.forcing
      # If unable to use due to SP running out
      unless @active_battler.skill_can_use?(@skill.id)
        # Clear battler being forced into action
        $game_temp.forcing_battler = nil
        # Shift to step 1
        @phase4_step = 1
        return
      end
    end
    ### Modification ###
    # Use up SP
    Calculate.skill_sp_cost(@active_battler, @skill.sp_cost)
    ### End of Modification ###
    # Refresh status window
    @status_window.refresh
    # Show skill name on help window
    @help_window.set_text(@skill.name, 1)
    # Set animation ID
    @animation1_id = @skill.animation1_id
    @animation2_id = @skill.animation2_id
    # Set command event ID
    @common_event_id = @skill.common_event_id
    # Set target battlers
    set_target_battlers(@skill.scope)
    # Apply skill effect
    for target in @target_battlers
      target.skill_effect(@active_battler, @skill)
    end
  end
end

end


Credits

Yeah, you should include me in your credits. Not available for commercial games.