RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

[RMVX]Help making a quick edit

Started by zerothedarklord, March 01, 2015, 04:57:20 AM

0 Members and 1 Guest are viewing this topic.

zerothedarklord

Had someone make a script for me a while back that essentially creates a state to Parry. it's setup in a way that it's essentially 2 stats, Parry Chance, and Parry Amount. the problem I am having is that it lets you parry heals, resulting in being healed for a lesser amount. Was just curious if anyone could make a quick fix for this issue?

This is the script itself:


#==============================================================================
# Dodginess
# by ???nOBodY???
# Requested By: Zerothedarklord
#==============================================================================

USE_DODGINESS = true

module Vocab
  # Dodged
  ActorDodged = "%s avoided a direct hit!!"
  EnemyDodged = "%s shrugged it off!!"
end

DEBUG_DODGINESS = false

#=================================================================================
$imported = {} if $imported == nil
$imported["Dodginess"] = true
class Game_Battler
  #===============================================================================
  # Below you can create a dodginess skill growth for each actor. The array should
  # be set up as:
  # DODGINGCHANCE_GROWTH = [[Actor ID, level 1 skill, level 100 skill]]
  # DODGINGAMOUNT_GROWTH = [[Actor ID, level 1 skill, level 100 skill]]
  # Be sure to put commas between each individual array, marked by brackets [].
  # Armors, States, and Weapons can all alter this stat by putting in the note
  # <dodgeChc X> or <dodgeVal X> or <bothDodge> where X will be the value you want
  # to increase/decrease the dodginess skill. Use <bothDodge> to boost both
  # chance and amount of dodginess at once.
  # Two script calls can be used to modify each dodginess skill and rating.
  # After calculating the bonuses from equipment and stats, dodginess can
  # have further boosts based off of script calls for that actor.
  # change_dodgeChc(actor, amount, type)  amount is any integer that will be
  #                            added/subtracted from the type. Type is if you're
  #                            changing the skill or dodginess rating itself.
  #                            For skill, type should be set to 0, and for rate
  #                            it should be 1.
  #
  # set_dodgeChc(actor, amount, type)   This functions the same as change_dodgeChc
  #                            except instead of adding/subtracting it will set
  #                            the bonus to an actor's dodginess to the amount.
  # change_dodgeVal(actor, amount, type)  amount is any integer that will be
  #                            added/subtracted from the type. Type is if you're
  #                            changing the skill or dodginess rating itself.
  #                            For skill, type should be set to 0, and for rate
  #                            it should be 1.
  #
  # set_dodgeVal(actor, amount, type)   This functions the same as change_dodgeVal
  #                            except instead of adding/subtracting it will set
  #                            the bonus to an actor's dodginess to the amount.
  #===============================================================================
  DODGINGCHANCE_GROWTH = [[1, 10, 10], [2, 10, 10], [3, 10, 10],
                             [4, 10, 10], [5, 10, 10], [6, 10, 10],
                             [7, 10, 10], [8, 10, 10]]
  DODGINGAMOUNT_GROWTH = [[1, 60, 60], [2, 60, 60], [3, 60, 60],
                             [4, 60, 60], [5, 60, 60], [6, 60, 60],
                             [7, 60, 60], [8, 60, 60]]
  #===============================================================================
  # Below you can set up the pen modifiers. The pen modifiers are level
  # dependent and change the amount of pen skill that is needed for 1% of
  # pen. It should be set up as:
  # class_id => [[level, modifier], [level, modifier]],
  #===============================================================================
  CUSTOM_DODGINGCHANCE = {
    0 => [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2],
  [9, 2], [10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2], [16, 2],
  [17, 2], [18, 2], [19, 2], [20, 2], [21, 2], [22, 2], [23, 2], [24, 2],
  [25, 2], [26, 2], [27, 2], [28, 2], [29, 2], [30, 2], [31, 2], [32, 2],
  [33, 2], [34, 2], [35, 2], [36, 2], [37, 2], [38, 2], [39, 2], [40, 2],
  [41, 2], [42, 2], [43, 2], [44, 2], [45, 2], [46, 2], [47, 2], [48, 2],
  [49, 2], [50, 2], [51, 2], [52, 2], [53, 2], [54, 2], [55, 2], [56, 2],
  [57, 2], [58, 2], [59, 2], [60, 2], [61, 2], [62, 2], [63, 2], [64, 2],
  [65, 2], [66, 2], [67, 2], [68, 2], [69, 2], [70, 2], [71, 2], [72, 2],
  [73, 2], [74, 2], [75, 2], [76, 2], [77, 2], [78, 2], [79, 2], [80, 2],
  [81, 2], [82, 2], [83, 2], [84, 2], [85, 2], [86, 2], [87, 2], [88, 2],
  [89, 2], [90, 2], [91, 2], [92, 2], [93, 2], [94, 2], [95, 2], [96, 2],
  [97, 2], [98, 2], [99, 2], [100, 2]],
  }
  CUSTOM_DODGINGAMOUNT = {
    0 => [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2],
  [9, 2], [10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2], [16, 2],
  [17, 2], [18, 2], [19, 2], [20, 2], [21, 2], [22, 2], [23, 2], [24, 2],
  [25, 2], [26, 2], [27, 2], [28, 2], [29, 2], [30, 2], [31, 2], [32, 2],
  [33, 2], [34, 2], [35, 2], [36, 2], [37, 2], [38, 2], [39, 2], [40, 2],
  [41, 2], [42, 2], [43, 2], [44, 2], [45, 2], [46, 2], [47, 2], [48, 2],
  [49, 2], [50, 2], [51, 2], [52, 2], [53, 2], [54, 2], [55, 2], [56, 2],
  [57, 2], [58, 2], [59, 2], [60, 2], [61, 2], [62, 2], [63, 2], [64, 2],
  [65, 2], [66, 2], [67, 2], [68, 2], [69, 2], [70, 2], [71, 2], [72, 2],
  [73, 2], [74, 2], [75, 2], [76, 2], [77, 2], [78, 2], [79, 2], [80, 2],
  [81, 2], [82, 2], [83, 2], [84, 2], [85, 2], [86, 2], [87, 2], [88, 2],
  [89, 2], [90, 2], [91, 2], [92, 2], [93, 2], [94, 2], [95, 2], [96, 2],
  [97, 2], [98, 2], [99, 2], [100, 2]],
  }
  #===============================================================================
  # The four values below set a default armor/spell pen skill amount
  # and default modifier for if an actor/level has none defined.
  #===============================================================================
  DEFAULT_DODGINGCHANCE_SKILL = 10
  DEFAULT_DODGINGCHANCE_MODIFIER = 2
  DEFAULT_DODGINGAMOUNT_SKILL = 60
  DEFAULT_DODGINGAMOUNT_MODIFIER = 2
 
  attr_accessor :dodgingChance_points_bonus
  attr_accessor :dodgingChance_rate_bonus
  attr_accessor :dodgingAmount_points_bonus
  attr_accessor :dodgingAmount_rate_bonus
  attr_reader   :dodged
  alias dodginessChanceAndAmount_initializer initialize
  def initialize#(actor_id)
    dodginessChanceAndAmount_initializer#(actor_id)
    @dodgingChance_points_bonus = 0
    @dodgingChance_rate_bonus = 0
    @dodgingAmount_points_bonus = 0
    @dodgingAmount_rate_bonus = 0
    @dodged = false
  end
  def dodgingChance_growth
    for item in DODGINGCHANCE_GROWTH
      if self.id == item[0]
        dc_skill = 0
        dc_actor = item[0]
        dc_level = self.level
        base_dc = item[1] * 100
        final_dc = item[2] * 100
        dc_grow = (final_dc - base_dc) / 100
        dc_skill = (dc_grow*dc_level) + base_dc
        dc_skill /= 100
        temp = 0
        for item in self.weapons
          if item != nil
            item.note[/<dodgeChc ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp+0 : temp+$1.to_i
            item.note[/<bothDodge ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp+0 : temp+$1.to_i
          end
        end
        dc_skill += temp
        temp = 0
        for item in self.states
          if item != nil
            item.note[/<dodgeChc ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp+0 : temp+$1.to_i
            item.note[/<bothDodge ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp+0 : temp+$1.to_i
          end
        end
        dc_skill += temp
        temp = 0
        for item in self.armors
          if item != nil
            item.note[/<dodgeChc ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp : temp+$1.to_i
            item.note[/<bothDodge ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp+0 : temp+$1.to_i
          end
        end
        dc_skill += temp
        dc_skill += @dodgingChance_points_bonus
        return dc_skill
      else
        dc_skill = DEFAULT_DODGINGCHANCE_SKILL
        dc_skill += @dodgingChance_points_bonus
        return dc_skill
      end
    end
  end
  def dodgingChance
    return 0 if USE_DODGINESS == false
    if self.is_a?(Game_Actor)
      if CUSTOM_DODGINGCHANCE.include?(@class_id)
        for item in CUSTOM_DODGINGCHANCE[@class_id]
          if item[0] == @level
            n = dodgingChance_growth / item[1]
            n += @dodgingChance_rate_bonus
            return n
          end
        end
        n = dodgingChance_growth / DEFAULT_DODGINGCHANCE_MODIFIER
        n += @dodgingChance_rate_bonus
        return n
      else
        for item in CUSTOM_DODGINGCHANCE[0]
          if item[0] == @level
            n = dodgingChance_growth / item[1]
            n += @dodgingChance_rate_bonus
            return n
          end
        end
        n = dodgingChance_growth / DEFAULT_DODGINGCHANCE_MODIFIER
        n += @dodgingChance_rate_bonus
        return n
      end
    else #self.is_a?(Game_Enemy)
      return 0
    end
  end
  def dodgingAmount_growth
    for item in DODGINGAMOUNT_GROWTH
      if self.id == item[0]
        da_skill = 0
        da_actor = item[0]
        da_level = self.level
        base_da = item[1] * 100
        final_da = item[2] * 100
        da_grow = (final_da - base_da) / 100
        da_skill = (da_grow*da_level) + base_da
        da_skill /= 100
        temp = 0
        for item in self.weapons
          if item != nil
            item.note[/<dodgeVal ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp+0 : temp+$1.to_i
            item.note[/<bothDodge ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp+0 : temp+$1.to_i
          end
        end
        da_skill += temp
        temp = 0
        for item in self.states
          if item != nil
            item.note[/<dodgeVal ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp+0 : temp+$1.to_i
            item.note[/<bothDodge ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp+0 : temp+$1.to_i
          end
        end
        da_skill += temp
        temp = 0
        for item in self.armors
          if item != nil
            item.note[/<dodgeVal ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp : temp+$1.to_i
            item.note[/<bothDodge ([0-9]+)>/] != nil ? $1.to_i : 0
            temp = $1 == nil ? temp+0 : temp+$1.to_i
          end
        end
        da_skill += temp
        da_skill += @dodgingAmount_points_bonus
        return da_skill
      else
        da_skill = DEFAULT_DODGINGAMOUNT_SKILL
        da_skill += @dodgingAmount_points_bonus
        return da_skill
      end
    end
  end
  def dodgingAmount
    return 0 if USE_DODGINESS == false
    if self.is_a?(Game_Actor)
      if CUSTOM_DODGINGAMOUNT.include?(@class_id)
        for item in CUSTOM_DODGINGAMOUNT[@class_id]
          if item[0] == @level
            n = dodgingAmount_growth / item[1]
            n += @dodgingAmount_rate_bonus
            return n
          end
        end
        n = dodgingAmount_growth / DEFAULT_DODGINGAMOUNT_MODIFIER
        n += @dodgingAmount_rate_bonus
        return n
      else
        for item in CUSTOM_DODGINGAMOUNT[0]
          if item[0] == @level
            n = dodgingAmount_growth / item[1]
            n += @dodgingAmount_rate_bonus
            return n
          end
        end
        n = dodgingAmount_growth / DEFAULT_DODGINGAMOUNT_MODIFIER
        n += @dodgingAmount_rate_bonus
        return n
      end
    else #self.is_a?(Game_Enemy)
      return 0
    end
  end
  #--------------------------------------------------------------------------
  # * Calculation of Damage From Normal Attack
  #     attacker : Attacker
  #    The results are substituted for @hp_damage
  #--------------------------------------------------------------------------
  alias dodginess_make_attack_damage_value make_attack_damage_value
  def make_attack_damage_value(attacker)
    if USE_DODGINESS
      @dodged = (rand(100) < self.dodgingChance)
      #return if @dodged
    end
    dodginess_make_attack_damage_value(attacker)
    if USE_DODGINESS
      if @dodged
        p self.dodgingAmount
        temp = self.dodgingAmount > 100 ? 100 : self.dodgingAmount
        @hp_damage = @hp_damage * temp / 100
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Calculation of Damage Caused by Skills or Items
  #     user : User of skill or item
  #     obj  : Skill or item (for normal attacks, this is nil)
  #    The results are substituted for @hp_damage or @mp_damage.
  #--------------------------------------------------------------------------
  alias dodginess_make_obj_damage_value make_obj_damage_value
  def make_obj_damage_value(user, obj)
    if USE_DODGINESS
      @dodged = (rand(100) < self.dodgingChance)
      #return if @dodged
    end
    dodginess_make_obj_damage_value(user, obj)
    if USE_DODGINESS
      if @dodged
        temp = self.dodgingAmount > 100 ? 100 : self.dodgingAmount
        if obj.damage_to_mp 
          @mp_damage = @hp_damage * temp / 100
        else
          @hp_damage = @hp_damage * temp / 100
        end
      end
    end
  end
 
  def dodgingChance_points_bonus_shift(amount)
    @dodgingChance_points_bonus += amount
  end
  def dodgingChance_rate_bonus_shift(amount)
    @dodgingChance_rate_bonus += amount
  end
  def dodgingChance_points_bonus_set(amount)
    @dodgingChance_points_bonus = amount
  end
  def dodgingChance_rate_bonus_set(amount)
    @dodgingChance_rate_bonus = amount
  end
  def dodgingAmount_points_bonus_shift(amount)
    @dodgingAmount_points_bonus += amount
  end
  def dodgingAmount_rate_bonus_shift(amount)
    @dodgingAmount_rate_bonus += amount
  end
  def dodgingAmount_points_bonus_set(amount)
    @dodgingAmount_points_bonus = amount
  end
  def dodgingAmount_rate_bonus_set(amount)
    @dodgingAmount_rate_bonus = amount
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Show Action Results
  #     target : Target
  #     obj    : Skill or item
  #--------------------------------------------------------------------------
  def display_action_effects(target, obj = nil)
    unless target.skipped
      line_number = @message_window.line_number
      wait(5)
      display_dodged(target, obj)
      display_critical(target, obj)
      display_damage(target, obj)
      display_state_changes(target, obj)
      if line_number == @message_window.line_number
        display_failure(target, obj) unless target.states_active?
      end
      if line_number != @message_window.line_number
        wait(30)
      end
      @message_window.back_to(line_number)
    end
  end
  #--------------------------------------------------------------------------
  # * Show Dodginess
  #     target : Target
  #     obj    : Skill or item
  #--------------------------------------------------------------------------
  def display_dodged(target, obj = nil)
    if target.dodged
      if target.actor?
        text = sprintf(Vocab::ActorDodged, target.name)
      else
        text = sprintf(Vocab::EnemyDodged, target.name)
      end
      @message_window.add_instant_text(text)
      wait(20)
    end
  end
end

class Game_Interpreter
  def change_dodgeChc(id, amount, type)
    case type
    when 0
      $game_actors[id].dodgingChance_points_bonus_shift(amount)
    when 1
      $game_actors[id].dodgingChance_rate_bonus_shift(amount)
    end
  end
  def set_dodgeChc(id, amount, type)
    case type
    when 0
      $game_actors[id].dodgingChance_points_bonus_set(amount)
    when 1
      $game_actors[id].dodgingChance_rate_bonus_set(amount)
    end
  end
  def change_dodgeVal(id, amount, type)
    case type
    when 0
      $game_actors[id].dodgingAmount_points_bonus_shift(amount)
    when 1
      $game_actors[id].dodgingAmount_rate_bonus_shift(amount)
    end
  end
  def set_dodgeVal(id, amount, type)
    case type
    when 0
      $game_actors[id].dodgingAmount_points_bonus_set(amount)
    when 1
      $game_actors[id].dodgingAmount_rate_bonus_set(amount)
    end
  end
end