[XP] Proto Damage Cap

Started by G_G, August 12, 2010, 02:03:06 pm

Previous topic - Next topic

G_G

August 12, 2010, 02:03:06 pm Last Edit: August 12, 2010, 02:07:18 pm by game_guy
Proto Damage Cap
Authors: game_guy
Version: 1.0
Type: Battle Add-On
Key Term: Battle Add-on



Introduction

Applies a simple damage cap like in most rpg's. You can only do 9999 damage at the max for example. But in most rpg's you can also break that damage cap with certain skills, weapons, or armors.


Features


  • Set damage cap to whatever
  • Change damage cap in game
  • Toggle damage cap in game
  • Excluded weapons, items, armors, and skills and enemies



Screenshots

N/A


Demo

N/A


Script

Spoiler: ShowHide

#===============================================================================
# Proto Damage Cap
# Author game_guy
# Version 1.0
#-------------------------------------------------------------------------------
# Intro:
# Applies a simple damage cap like in most rpg's. You can only do 9999 damage
# at the max for example. But in most rpg's you can also break that damage
# cap with certain skills, weapons, or armors.
#
# Features:
# Set damage cap to whatever
# Change damage cap in game
# Toggle damage cap in game
# Excluded weapons, items, armors, and skills and enemies
#
# Instructions:
# Go down to the config below and configure everything there.
#
# Script Calls:
# This can turn the damage cap on or off
# $game_system.cap_on = true/false : true = on, false = off
# This can change the damage cap in game
# $game_system.damage_cap = x : x = a number
#
# Compatibility:
# Not tested with SDK.
# Should work with about every battle system.
#
# Credits:
# game_guy ~ For making it
# GAX72 ~ For requesting it
# anagura.raziel ~ For requesting more features
#===============================================================================
module GG_Cap
  #===========================================
  # This is the max damage cap set for
  # anything. Items, skills, attacks, etc.
  #===========================================
  Damage_Cap          = 9999
  #===========================================
  # Any weapon placed in the array below is
  # equipped, the damage cap won't apply to
  # that actor.
  #===========================================
  Exclude_Weapons     = [2, 3, 4]
  #===========================================
  # Any armor placed in the array below is
  # equipped, the damage cap won't apply to
  # that actor.
  #===========================================
  Exclude_Armors      = [1, 2, 3]
  #===========================================
  # Any skill placed in the array below is
  # used, the damage cap won't apply to
  # that skill.
  #===========================================
  Exclude_Skills      = [7, 8, 9, 57]
  #===========================================
  # Any skill placed in the array below is
  # used, the damage cap won't apply to
  # that skill.
  #===========================================
  Exclude_Items       = [1, 2, 3]
  #===========================================
  # Any enemy placed in the array below,
  # the damage cap won't apply to
  # that enemy. This also means
  # the cap will not apply to any skill
  # that enemy uses.
  #===========================================
  Exclude_Enemies     = [29, 30]
end
class Game_System
  attr_accessor :damage_cap
  attr_accessor :cap_on
  alias gg_init_damage_cap_lat initialize
  def initialize
    @damage_cap = GG_Cap::Damage_Cap
    @cap_on = true
    gg_init_damage_cap_lat
  end
end
class Game_Battler
  include GG_Cap
  alias gg_dmg_cap_atk_effect_lat attack_effect
  def attack_effect(attacker)
    return if !$game_system.cap_on
    dmg = $game_system.damage_cap
    last_hp = self.hp
    result = gg_dmg_cap_atk_effect_lat(attacker)
    if result && self.damage.is_a?(Integer)
      if attacker.is_a?(Game_Actor)
        flag = false
        actor = attacker
        Exclude_Armors.each{|a|
        flag = (actor.armor1_id == a or
        actor.armor2_id == a or
        actor.armor3_id == a or
        actor.armor4_id == a)
        break if flag == true}
        if Exclude_Weapons.include?(attacker.weapon_id)
          flag = true
        end
        unless flag
          self.hp = last_hp
          self.hp = self.hp
          self.damage = [self.damage, dmg].min
          self.hp -= Integer(self.damage)
        end
      elsif attacker.is_a?(Game_Enemy)
        unless Exclude_Enemies.include?(self.id)
          self.hp = last_hp
          self.hp = self.hp
          self.damage = [self.damage, dmg].min
          self.hp -= Integer(self.damage)
        end
      end
    end
    return result
  end
  alias gg_dmg_cap_skil_effect_lat skill_effect
  def skill_effect(user, skill)
    return if !$game_system.cap_on
    dmg = $game_system.damage_cap
    last_hp = self.hp
    result = gg_dmg_cap_skil_effect_lat(user, skill)
    if result && self.damage.is_a?(Integer)
      if user.is_a?(Game_Actor)
        if !Exclude_Skills.include?(skill.id)
          if self.damage < 0
            self.hp = last_hp
            self.hp = self.hp
            self.damage = [self.damage, -dmg].max
            self.hp -= Integer(self.damage)
          else
            self.hp = last_hp
            self.hp = self.hp
            self.damage = [self.damage, dmg].min
            self.hp -= Integer(self.damage)
          end
        end
      elsif user.is_a?(Game_Enemy)
        if !Exclude_Enemies.include?(self.id) ||
           !Exclude_Skills.include?(skill.id)
          if self.damage < 0
            self.hp = last_hp
            self.hp = self.hp
            self.damage = [self.damage, -dmg].max
            self.hp -= Integer(self.damage)
          else
            self.hp = last_hp
            self.hp = self.hp
            self.damage = [self.damage, dmg].min
            self.hp -= Integer(self.damage)
          end
        end
      end
    end
    return result
  end
  alias gg_dmg_cap_item_effect_lat item_effect
  def item_effect(item)
    return if !$game_system.cap_on
    dmg = $game_system.damage_cap
    result = gg_dmg_cap_item_effect(item)
    if result && self.damamge.is_a?(Integer)
      if !Exclude_Items.include?(item.id)
        if self.damage < 0
          self.hp = last_hp
          self.hp = self.hp
          self.damage = [self.damage, -dmg].max
          self.hp -= Integer(self.damage)
        else
          self.hp = last_hp
          self.hp = self.hp
          self.damage = [self.damage, dmg].min
          self.hp -= Integer(self.damage)
        end
      end
    end
  end
end



Instructions

In script.
Place below your custom battle system, unless its blizz-abs because I know it works.


Compatibility

Not tested with SDK.
Should work with any battle system.


Credits and Thanks


  • game_guy ~ For making it
  • GAX72 ~ For requesting it
  • anagura.raziel ~ For requesting more features



Author's Notes

Enjoy! :D

Blizzard

Lol, I was thinking "Wasn't GAX looking for something like this?" and then I saw that he requested it. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

anagura.raziel


anagura.raziel

Hey, I get an error when trying to use recovery items from the menu.

Spoiler: ShowHide


Script 'Proto Damage Cap [Game_Guy]' Line 166:
NoMethodError occured.

undefined method 'gg_dmg_cap_item_effect' for
#<Game_Actor: 0x3da40d8>



I tried adding the items to the script (in the exclude items section) which didn't help.

Also, This script is the very last one before main.


PS: on an arguably related note, how's your modify max amount script coming along?

Calintz

Great job.
I didn't know this marvel was here.

anagura.raziel

Ok, just tried it on a new project (with no other scripts) and still get the error

anagura.raziel

Bump. Does anybody know how to resolve this? I think the script is perfect aside from the error.

Sorry to trouble anyone.  :huh:

ForeverZer0

Have tested the script, but from just looking at the code above, looks like the method name is missing the "_lat" from the end of the alias name.

On line 166, change the "gg_dmg_cap_item_effect" to "gg_dmg_cap_item_effect_lat". See if thats the problem.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

anagura.raziel

fixed the error in question, however a new one appeared.

can't quite recall the exact error but on the next line down was a simple spelling error.
something like "damamge" which I changed to "damage".

Now the items don't get consumed, nor does it update your new HP\SP on the menu until you exit the menu and return. (actually, that's probably what happens to the items too, they may get consumed but you can't see it until you leave the menu, then come back.)

Anyway, it occured to me that maybe I could just remove the whole section regarding items which is what I did. I just wish I'd thought of that weeks ago, lol.

Gonna play test for a while.

Thanks ForeverZer0