• Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Resource icon

Battle-Worn Opponents 1.0

Battle-Worn Opponents
Current Version: 1.0

bJ7VrIF.gif

*This script will work with both PE v16.2 and v17+!

-------
It always bothered me how enemy trainers always had their Pokemon in peak condition. This script simulates a bit of "wear and tear" that implies these trainers have been in previous battles before challenging you.

Includes three modules: missing health, status ailments, and fainting. All of these can be enabled or disabled individually, and the chances of each one of these occurring can be altered.

I made the script highly customizable, and even included a Global Switch so you can disable it quickly if you need to (i.e. like before a Gym Leader fight).


*This script is completely plug-and-play and requires very little setup.
**See the notes at the top of the script for installation and usage instructions!

Script:
Code:
#==============================================================================#
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
#==============================================================================#
#                            Battle-Worn Opponents                             #
#                                    v1.0                                      #
#                             By Ulithium_Dragon                               #
#                                                                              #
#==============================================================================#
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
#==============================================================================#
#                                                                              #
#  Randomly reduces the health an opponent's Pokemon as if they had recently   #
#   been in battle. Also includes options for Status Ailments and Fainting.    #
#                                                                              #
#------------------------------------------------------------------------------#
#   **Place this script somewhere above Main and below PokeBattle_Scene.       #
#==============================================================================#
#------------------------------------------------------------------------------#
#        :::::This script is compatible with both PE v16 and v17+:::::         #
#------------------------------------------------------------------------------#
#                                                                              #
#==============================================================================#
#                                 OPTIONS                                      #
#==============================================================================#
#------#
# The Global Switch used to easily disable this system (i.e. like in Events).
#  *NOTE: Make sure this switch is not used by anything else!
SWITCH_DISABLE_BATTLEWORN = 325

#------#
# Whether an opponent's Pokemon has a chance to have missing HP.
ENABLE_OPPONENT_HPLOSS  =  true   #Default: true
# The chance for an opponent Pokemon to have missing HP.
CHANCE_OPPONENT_HPLOSS  =  30     #Default: 30
# Maximum percentage of HP that can be missing.
MAX_OPPONENT_HPLOSS     =  25     #Default: 25
# Minimum percentage of HP that can be missing.
MIN_OPPONENT_HPLOSS     =  10     #Default: 10

#------#
# Whether an opponent's Pokemon has a chance to have a Status Ailment.
ENABLE_OPPONENT_STATUS  =  true   #Default: true
# The chance for an opponent Pokemon to have a Status Ailment.
CHANCE_OPPONENT_STATUS  =  15     #Default: 15
# If enabled, Electric-type Pokemon can't by Paralyzed.
USE_LATERGEN_RULES      =  true   #Default: true

#------#
# Whether an opponent's Pokemon can already have Fainted before the battle.
ENABLE_OPPONENT_FAINT   =  true   #Default: true
# The chance for an opponent Pokemon to have already Fainted.
CHANCE_OPPONENT_FAINT   =  10     #Default: 10
#==============================================================================#
#//////////////////////////////////////////////////////////////////////////////#
#==============================================================================#


Events.onTrainerPartyLoad+=proc {|sender,e|
   if !$game_switches[SWITCH_DISABLE_BATTLEWORN]
     if e[0] # Trainer data should exist to be loaded, but may not exist somehow.
       trainer=e[0][0] # A PokeBattle_Trainer object of the loaded trainer.
       items=e[0][1]   # An array of the trainer's items they can use.
       party=e[0][2]   # An array of the trainer's Pokémon.
       $counterBW = 0
       $numFaintedBW = 0
       for i in 0...party.length
         pbBattlewornOpponents(party,party[i])
         party[i].calcStats
       end
     end
   end
}

def pbBattlewornOpponents(party,opponent)
  #Run through each module, starting with fainting.
  pbOpponentsPriorFainted(party,opponent)
  pbOpponentsPriorHPLoss(party,opponent)
  pbOpponentsPriorStatus(party,opponent)
end


def pbOpponentsPriorHPLoss(party,opponent)
  if ENABLE_OPPONENT_HPLOSS && !$game_switches[SWITCH_DISABLE_BATTLEWORN] &&
            opponent.hp>0 && !opponent.isEgg?
    case rand(100)
    when 0..CHANCE_OPPONENT_HPLOSS
      #Convert the percentage into a float that can be multiplied by the HP value.
      hpRandomPercent = rand(MAX_OPPONENT_HPLOSS.to_f - MIN_OPPONENT_HPLOSS.to_f)
      hpDamagePercent = MAX_OPPONENT_HPLOSS.to_f - hpRandomPercent.to_f
      #Decrease the opponent Pokemon's HP by a random amount.
      opponent.hp = opponent.totalhp - opponent.hp*(hpDamagePercent/100)
      opponent.hp = opponent.hp.ceil
    end
  end
end


def pbOpponentsPriorStatus(party,opponent)
  if ENABLE_OPPONENT_STATUS && !$game_switches[SWITCH_DISABLE_BATTLEWORN] &&
            opponent.hp>0 && !opponent.isEgg?
    case rand(100)
    when 0..CHANCE_OPPONENT_STATUS
      loop do
        case rand(5)
        when 1  #Sleeping
          if !opponent.hasAbility?(:VITALSPIRIT) &&
                     !opponent.hasAbility?(:INSOMNIA) &&
                     !opponent.hasAbility?(:SWEETVEIL) &&
                    (!opponent.hasAbility?(:FLOWERVEIL) && !opponent.hasType?(:GRASS)) &&
                    (!opponent.hasAbility?(:LEAFGUARD) && ($game_screen.weather_type!=PBFieldWeather::Sun)) &&
                    (!opponent.hasAbility?(:SHIELDSDOWN) && opponent.hp!=opponent.hp>(opponent.totalhp/2).floor)
            opponent.status=PBStatuses::SLEEP
            break
          end
        when 2  #Poisoned
          if !opponent.hasType?(:POISON) &&
                     !opponent.hasType?(:STEEL) &&
                     !opponent.hasAbility?(:IMMUNITY) &&
                    (!opponent.hasAbility?(:FLOWERVEIL) && !opponent.hasType?(:GRASS)) &&
                    (!opponent.hasAbility?(:LEAFGUARD) && ($game_screen.weather_type!=PBFieldWeather::Sun)) &&
                    (!opponent.hasAbility?(:SHIELDSDOWN) && opponent.hp!=opponent.hp>(opponent.totalhp/2).floor)
            opponent.status=PBStatuses::POISON
            break
          end
        when 3  #Burned
          if !opponent.hasType?(:FIRE) &&
                     !opponent.hasAbility?(:WATERVEIL) &&
                    (!opponent.hasAbility?(:FLOWERVEIL) && !opponent.hasType?(:GRASS)) &&
                    (!opponent.hasAbility?(:LEAFGUARD) && ($game_screen.weather_type!=PBFieldWeather::Sun)) &&
                    (!opponent.hasAbility?(:SHIELDSDOWN) && opponent.hp!=opponent.hp>(opponent.totalhp/2).floor)
            opponent.status=PBStatuses::BURN
            break
          end
        when 4  #Paralysed
          if USE_LATERGEN_RULES
            if !opponent.hasType?(:ELECTRIC) &&
                     !opponent.hasAbility?(:LIMBER) &&
                    (!opponent.hasAbility?(:FLOWERVEIL) && !opponent.hasType?(:GRASS)) &&
                    (!opponent.hasAbility?(:LEAFGUARD) && ($game_screen.weather_type!=PBFieldWeather::Sun)) &&
                    (!opponent.hasAbility?(:SHIELDSDOWN) && opponent.hp!=opponent.hp>(opponent.totalhp/2).floor)
              opponent.status=PBStatuses::PARALYSIS
              break
            end
          else
            if !opponent.hasAbility?(:LIMBER) &&
                    (!opponent.hasAbility?(:FLOWERVEIL) && !opponent.hasType?(:GRASS)) &&
                    (!opponent.hasAbility?(:LEAFGUARD) && ($game_screen.weather_type!=PBFieldWeather::Sun)) &&
                    (!opponent.hasAbility?(:SHIELDSDOWN) && opponent.hp!=opponent.hp>(opponent.totalhp/2).floor)
              opponent.status=PBStatuses::PARALYSIS
              break
            end
          end
        when 5  #Frozen
          if !opponent.hasType?(:ICE) &&
                    !opponent.hasAbility?(:MAGMAARMOR) &&
                    (!opponent.hasAbility?(:FLOWERVEIL) && !opponent.hasType?(:GRASS)) &&
                    (!opponent.hasAbility?(:LEAFGUARD) && ($game_screen.weather_type!=PBFieldWeather::Sun)) &&
                    (!opponent.hasAbility?(:SHIELDSDOWN) && opponent.hp!=opponent.hp>(opponent.totalhp/2).floor)
            opponent.status=PBStatuses::FROZEN
            break
          end
        end
      end
    end
  end
end


  def ablePokemonCount
    ret=0
    for i in 0...@party.length
      ret+=1 if @party[i] && !@party[i].isEgg? && @party[i].hp>0
    end
    return ret
  end

def pbOpponentsPriorFainted(party,opponent)
  #Make sure they have at least 2 Pokemon first!
  if ENABLE_OPPONENT_FAINT && party.length > 1 &&
            !$game_switches[SWITCH_DISABLE_BATTLEWORN] && opponent.hp>0 &&
            !opponent.isEgg?
    $counterBW += 1
    if $counterBW < party.length
      #Make sure not all their Pokemon have fainted!
      if $numFaintedBW != party.length
      #if $counterBW != party.length && $numFaintedBW != party.length
        case rand(100)
        when 0..CHANCE_OPPONENT_FAINT
          opponent.hp = 0
          $numFaintedBW += 1
        end
      end
    end
  end
end

Pastebin Mirror:
Credits
- This script was written by me, Ulithium_Dragon.

I don't need credit for it, but it's always appreciated.
Author
Ulithium_Dragon
Downloads
714
Views
1,052
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Ulithium_Dragon

Back
Top