Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: lonely_cubone on April 10, 2013, 12:54:59 am

Title: [XP] Level-Based Skill Base Power
Post by: lonely_cubone on April 10, 2013, 12:54:59 am
Hi everybody! I know I haven't been here for ages, but I was hoping I could get some help with this :^_^':. I'm looking for a script that makes the base power of a skill scale linearly with the level of the actor who used it. For example, the base power is 10 at level 1, 12 at level 2, 14 at level 3, etc.

I figured a script like this must exist already, but I couldn't find one, so I thought I'd ask here. If nobody knows of a script that does this, could someone please make it if it wouldn't be too difficult?
Title: Re: [XP] Level-Based Skill Base Power
Post by: BetaGod on April 10, 2013, 10:21:20 pm
Try this:
http://save-point.org/thread-912.html (http://save-point.org/thread-912.html)

Or this:
http://houseslashers.b1.jcink.com/index.php?showtopic=87 (http://houseslashers.b1.jcink.com/index.php?showtopic=87)
Title: Re: [XP] Level-Based Skill Base Power
Post by: KK20 on April 10, 2013, 10:55:52 pm

module SkillBasePower
  def self.bonus(skill_id)
    case skill_id
    when 1 then return 3 # Heal
    when 7 then return 2 # Fire
    end
    return 0
  end
end

class Game_Battler
  #--------------------------------------------------------------------------
  # * Apply Skill Effects
  #     user  : the one using skills (battler)
  #     skill : skill
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    # Clear critical flag
    self.critical = false
    # If skill scope is for ally with 1 or more HP, and your own HP = 0,
    # or skill scope is for ally with 0, and your own HP = 1 or more
    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
      # End Method
      return false
    end
    # Clear effective flag
    effective = false
    # Set effective flag if common ID is effective
    effective |= skill.common_event_id > 0
    # First hit detection
    hit = skill.hit
    if skill.atk_f > 0
      hit *= user.hit / 100
    end
    hit_result = (rand(100) < hit)
    # Set effective flag if skill is uncertain
    effective |= hit < 100
    # If hit occurs
    if hit_result == true
      #--------------------------------------------------------------------
      # Calculate power                                           (EDITTED)
      #--------------------------------------------------------------------
      power = skill.power
      power += SkillBasePower.bonus(skill.id)*user.level if user.is_a?(Game_Actor)
      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
      # Calculate rate
      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)
      # Calculate basic damage
      self.damage = power * rate / 20
      # Element correction
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Dispersion
      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
      # Second hit detection
      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)
      # Set effective flag if skill is uncertain
      effective |= hit < 100
    end
    # If hit occurs
    if hit_result == true
      # If physical attack has power other than 0
      if skill.power != 0 and skill.atk_f > 0
        # State Removed by Shock
        remove_states_shock
        # Set to effective flag
        effective = true
      end
      # Substract damage from HP
      last_hp = self.hp
      self.hp -= self.damage
      effective |= self.hp != last_hp
      # State change
      @state_changed = false
      effective |= states_plus(skill.plus_state_set)
      effective |= states_minus(skill.minus_state_set)
      # If power is 0
      if skill.power == 0
        # Set damage to an empty string
        self.damage = ""
        # If state is unchanged
        unless @state_changed
          # Set damage to "Miss"
          self.damage = "Miss"
        end
      end
    # If miss occurs
    else
      # Set damage to "Miss"
      self.damage = "Miss"
    end
    # If not in battle
    unless $game_temp.in_battle
      # Set damage to nil
      self.damage = nil
    end
    # End Method
    return effective
  end
end

Paste below default scripts.
Like this? Note that I had to make an edit to how the skill's damage is calculated--unless you didn't change the default formula in your game.
Title: Re: [XP] Level-Based Skill Base Power
Post by: lonely_cubone on April 11, 2013, 10:39:51 pm
Thank you, both of you! To be honest, the two Vulfman scripts look more complicated than I actually need, so I think I'll use KK20's script, but those scripts could be really useful in the future.

EDIT: Actually, I have a question. KK20, in your example config, the bonus value for Heal is positive. Would that make the skill heal more HP with each level, or would it actually make it heal less (and eventually maybe do damage)?
Title: Re: [XP] Level-Based Skill Base Power
Post by: KK20 on April 11, 2013, 11:24:32 pm
Oh yeah. You should use a negative value for healing skills.