Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Limiting Damage
Ty
post Oct 1 2007, 04:21 PM
Post #1


Level 38
Group Icon

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed




Script Name: Limiting Damage
Written by: Synthesize
Current Version: V1.00
Release Date: October 1st, 2007

What is it??
With this script the designer has the ability to define the minimum and maximum amounts of damage that can be dealt on a single attack.

The Script
Place in a new script window above Main.
CODE
#============================================================================
#                            Limiting Damage  
#----------------------------------------------------------------------------
# Written by Synthesize
# Version 100
# October 1st, 2007
#============================================================================
# Compatibility:
# Rewrites:
#    Game_Battler::attack_effect
#    Game_Battler::skill_effect
#--------------------------------------------------------------------------
# Begin Customization Section
#--------------------------------------------------------------------------
module LimitDamage  
  Maximum_Damage = 9999
  Minimum_Damage = 1
  Maximum_SkillDamage = 9999
  Minimum_SkillDamage = 1
  # Change these values to your expected setting.
  # Note: By default minimum damage is 0.
end
#--------------------------------------------------------------------------
# End Customization Section
#--------------------------------------------------------------------------
# Begin Game_Battler Rewrite
#--------------------------------------------------------------------------
class Game_Battler
  def attack_effect(attacker)
   # Clear critical flag
    self.critical = false
    # First hit detection
    hit_result = (rand(100) < attacker.hit)
    # If hit occurs
    if hit_result == true
      # Calculate basic damage
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
      # Element correction
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Critical correction
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Dispersion
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      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 occurs
    if hit_result == true
      # State Removed by Shock
      remove_states_shock
      # Substract damage from HP
      if self.damage < LimitDamage::Minimum_Damage
        self.damage = LimitDamage::Minimum_Damage
      elsif self.damage > LimitDamage::Maximum_Damage
        self.damage = LimitDamage::Maximum_Damage
      end
      self.hp -= self.damage
      # State change
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # When missing
    else
      # Set damage to "Miss"
      self.damage = "Miss"
      # Clear critical flag
      self.critical = false
    end
    # End Method
    return true
  end
  #---------------------------------------------------------------------
  # Begin Skill Adjustment
  #---------------------------------------------------------------------
   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
      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
      # 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
      if self.damage < LimitDamage::Minimum_SkillDamage
        self.damage = LimitDamage::Minimum_SkillDamage
      elsif self.damage > LimitDamage::Maximum_SkillDamage
        self.damage = LimitDamage::Maximum_SkillDamage
      end
      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

#============================================================================
# Written by Synthesize
# Special Thanks: Peter for the request
#----------------------------------------------------------------------------
#                            Limiting Damage
#============================================================================

Questions Concerns? Post them.

This post has been edited by Synthesize: Oct 2 2007, 03:37 PM


__________________________
My Script Demo link broken? Looking for old scripts? Go here:
http://synthesize.4shared.com
Go to the top of the page
 
+Quote Post
   
Peter
post Oct 2 2007, 12:32 AM
Post #2


Level 1
Group Icon

Group: Member
Posts: 8
Type: Event Designer
RM Skill: Skilled




Thanks for the script this is exactly what I needed.

Though I have a question, would this script work with a multi-hit script?

This post has been edited by Peter: Oct 2 2007, 12:38 AM
Go to the top of the page
 
+Quote Post
   
Ty
post Oct 2 2007, 02:21 PM
Post #3


Level 38
Group Icon

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed




It would work with a multi-hit script, as long as the methods I rewrote are not rewritten again.

This post has been edited by Synthesize: Oct 2 2007, 02:26 PM


__________________________
My Script Demo link broken? Looking for old scripts? Go here:
http://synthesize.4shared.com
Go to the top of the page
 
+Quote Post
   
Peter
post Oct 15 2007, 12:42 AM
Post #4


Level 1
Group Icon

Group: Member
Posts: 8
Type: Event Designer
RM Skill: Skilled




I tried your script on my game yet it inclueds ATB, and overdrive as well as multi-hit scripts. Everything works fine except when I give the attack command. An error flashes and before I can read it the game shuts down. I think It has somehing to do with the Game_Battler section in my overdrive script , should I replace my current Game battler scrip for yours in both the ATB script and the Overdrive Scripts
Go to the top of the page
 
+Quote Post
   
Ty
post Oct 15 2007, 03:31 PM
Post #5


Level 38
Group Icon

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed




Can you send me a link to these scripts? Thanks ^^

And don't replace anything in your Overdrive/ATB Script.


__________________________
My Script Demo link broken? Looking for old scripts? Go here:
http://synthesize.4shared.com
Go to the top of the page
 
+Quote Post
   
Guest_RPG Wizard_*
post Nov 5 2007, 08:40 PM
Post #6





Guests





Added to the database.

http://www.rpgrevolution.com/script/13
Go to the top of the page
 
+Quote Post
   
FatalDemon
post Jan 1 2008, 11:19 PM
Post #7


Level 1
Group Icon

Group: Member
Posts: 10
Type: None
RM Skill: Skilled




I know this is old but could you add some kind of limit break system? Like certain people or attacks that can break the limit? Or is that already in and I am just an idiot? >.>
Go to the top of the page
 
+Quote Post
   
jens009
post Jan 2 2008, 12:14 AM
Post #8


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




QUOTE
I know this is old but could you add some kind of limit break system? Like certain people or attacks that can break the limit? Or is that already in and I am just an idiot? >.>

I had done this before but not with Synthesize script.

@Synthesize: If you ever saw his request, you can do this by making an element that has a name of "Limit Break" per say and allow that skill to break the limit. (Meaning being able to go beyond the set limit of your script)

In any case, I'll try to look into it.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 05:09 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker