Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Damage limit and formula change
#1
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


RPG Maker XP has no damage limit. Because of this, and the way the battle calculations are, it can make it possible kill your end boss with a mere few hits, if not just one, even with normal attacks if your stats are pretty darn high enough. We wouldn't want that to happen unless it was an Ultimate Overdrive Skill or something. I also found it weird how your players can only have 9999 HP but you can do tens of thousands of damage (if not hundreds of thounsands) and enemies can have up to 999,999 HP.

So I decided to play around and made up a damage limit script. What this will do is that the damage will not exceed a certain amount, like in most RPGs. For this particular script the damage cap I used was 9999. What you will do first is go to Game_Battler3. Then, under def attack_effect, you'll see this:

Code:
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
      # 属性修正
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # ダメージã?®ç¬¦å?·ã?Œæ­£ã?®å� ´å?ˆ
      if self.damage > 0
        # クリãƒ� ィカル修正
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # 防御修正
        if self.guarding?
          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 ã?‹ã‚‰ãƒ€ãƒ¡ãƒ¼ã‚¸ã‚’減算
      self.hp -= self.damage
      # スãƒ� ート変化
      @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

That is the battle calculations for standard attacks. To keep damages from going over 9999, put this code right under the line "self.damage /= 100" after the elements correction stuff but before the critical/guarding if conditions:

Code:
if self.damage >= 9999
        self.damage = 9999
      end

It should now look like this:

Code:
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
      # 属性修正
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      ### HERE ###
      if self.damage >= 9999 ###<--- DAMAGE LIMIT
        self.damage = 9999 ###<--- DAMAGE LIMIT
      end

The reason we put this BEFORE the critical/guarding stuff is so that when the defender defends and the enemy would have done 9999 (or over, but the limit will keep it at 9999), the defender will take 4000+/5000+ instead. If we did not do this, the character would have always suffered 9999 regardless if he/she defends or not.

Now we are going to insert this code again. You'll see why. First, scroll down until you get to this stuff, right under the critical/guarding things:

Code:
if self.damage > 0
        # クリãƒ� ィカル修正
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # 防御修正
        if self.guarding?
          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

The abs things is what we are concerned about. You must put the damage code somewhere under the variance code, either directly under it, or after the evasion calculations, or right before "self.hp -= self.damage" under the hit result true condition. In this case I will put it right below the variance:

Code:
if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      ### HERE ###
      if self.damage >= 9999 ### <-- DAMAGE LIMIT (VARIANCE)
        self.damage = 9999 ### <-- DAMAGE LIMIT (VARIANCE)
      end

Now to answer why we did this when we already put down the limit earlier. This is because the varying damage might go over 9999, and it probably will if the target's stats are high enough. This second insertion of the damage limit code will keep the variance from upping the damage from 9999.

Now we are done with attack_effect, now to skill_effect. It is pretty similar to attack_effect, just gotta put the cap under slightly different codes. Scroll down until you get to the skill's element correction (it's somewhere below the stat influence stuff):

Code:
self.damage *= elements_correct(skill.element_set)
      self.damage /= 100

Notice it said "skill.element_set" instead of the attack_effect's "attacker.element_set". That's the difference between the two. Anyway, put the damage limit right under the element correction, it should look like this:

Code:
self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      if self.damage >= 9999
        self.damage = 9999
      end

This is right before the critical/guarding thing, and it should have the same results as in attack_effect (half damage instead of always 9999).

Now go to variance:

Code:
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

Put the limit code somewhere under it, in this case I put it directly below the variance:

Code:
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
      ### HERE ###
      if self.damage >= 9999 ### <-- DAMAGE LIMIT (SKILL VARIANCE)
        self.damage = 9999 ### <-- DAMAGE LIMIT (SKILL VARIANCE)
      end

Again, it keeps the damage from varying over 9999.

I think that's it. I didn't bother with item_effect. It seems possible to damage oneself or an enemy with an item, but it also seems possible to heal an enemy with an item (though it's unlikely you'd use an item like that). I really wasn't sure what to do there, so I didn't bother with any "damage/recovery limits" there.

Well, this post became too long so I won't show battle calculation changes. But I will say that if you decide to set the damage limit to 999 or 9999, you may have to change the formulas accordingly or else you would do 999(9) very, very quickly. If your limit is something like 99,999 however, then I think the default formulas are fine as they are.


Edit: I was told that I could put "self.damage = [9999, self.damage].min" in the >= 9999 damage if condition. I tried both that and the one I used before and they both worked the same to me...

Edit 2: Whoops, I forgot the slip_damage_effect (poison). We wouldn't want any monster suffering tens of thousands of damage from poison or that would be too easy. Unless you want it that way.

Well, if you don't, go to slip_damage_effect:

Code:
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

Put the limit code right after the variance:

Code:
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
    if self.damage >= 9999
      self.damage = 9999
    end
    # HP ã?‹ã‚‰ãƒ€ãƒ¡ãƒ¼ã‚¸ã‚’減算
    self.hp -= self.damage
    # メソッド終äº�
    return true
  end

There.
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Change character script jaigai 0 2,737 11-19-2006, 01:00 PM
Last Post: jaigai
  Change menu character sprites to Pictures like in rpg maker 2003 Abyssos 0 3,628 09-28-2006, 01:00 PM
Last Post: Abyssos
  New visual damage kojima 0 2,441 09-01-2006, 01:00 PM
Last Post: kojima
  Change Color of The diferent Status Script MASTERLOKI 0 2,267 07-18-2006, 01:00 PM
Last Post: MASTERLOKI
  Change Cursor with differend commands in Battle Divinity 0 2,209 06-22-2006, 01:00 PM
Last Post: Divinity
  Change Level/Exp/Status name ryujijitei 0 1,997 04-29-2006, 01:00 PM
Last Post: ryujijitei
  Change the hue of pictures Sheol 0 2,054 11-29-2005, 01:00 PM
Last Post: Sheol
  Equipment Menu Change Seraphim Dark 0 2,243 07-21-2005, 01:00 PM
Last Post: Seraphim Dark
  Unarmed Damage! Tazzo da Clown 0 2,430 07-17-2005, 01:00 PM
Last Post: Tazzo da Clown
  Change hero's equipment-based stats permanently PhotonWeapon 0 1,865 07-15-2005, 01:00 PM
Last Post: PhotonWeapon



Users browsing this thread: