06-17-2005, 01:00 PM

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.

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.