Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #There's two changes in other scripts that need to be made to make this work right:
- # In Battle_StartAndEnd, find def pbEndOfBattle and paste this right below it: (minus the #)
- # $game_variables[BARS_VARIABLE]=0
- # This makes sure that the variable for bonus bars is reset after each battle.
- # In PItem_BattleItemEffects, find this section:
- # if battler.semiInvulnerable?
- # scene.pbDisplay(_INTL("It's no good! It's impossible to aim at a Pokémon that's not in sight!")) if showMessages
- # next false
- # end
- # Below "end", paste this: (minus the #s)
- # if battler.pokemon.hpbars && battler.pokemon.hpbars>0
- # scene.pbDisplay(_INTL("It's no good! There's no way the Pokémon can be caught with this much HP!")) if showMessages
- # next false
- # end
- # This makes sure that the player can't catch a Pokemon with bonus bars
- #The variable that stores how many bonus bars a Pokemon will get
- BARS_VARIABLE=2
- #The variable that stores which position in a trainer's party should be given bonus bars
- TRAINER_POSITION_VARIABLE=4
- module Multiple_HP
- attr_reader :hpbars
- @hpbars=0
- def hpbars=(value)
- value = 0 if value<0
- @hpbars = value
- @pokemon.hpbars = value if @pokemon
- end
- def hp=(value)
- value = 0 if value<0
- @hp = value
- if @hp==0
- if @hpbars>0
- @hpbars-=1
- @hp=@totalhp
- else
- @status = PBStatuses::NONE
- @statusCount = 0
- end
- end
- end
- end
- class PokeBattle_Pokemon
- include Multiple_HP
- end
- class PokeBattle_Battler
- include Multiple_HP
- def pbFaint(showMessage=true)
- if @pokemon.hpbars
- if @pokemon.hpbars>0
- @pokemon.hpbars-=1
- self.hp+=self.totalhp
- @battle.scene.pbRefreshOne(@index)
- @battle.pbDisplayBrief(_INTL("{1}'s health bar was depleted!",pbThis)) if showMessage
- return
- end
- end
- if !fainted?
- PBDebug.log("!!!***Can't faint with HP greater than 0")
- return
- end
- return if @fainted # Has already fainted properly
- @battle.pbDisplayBrief(_INTL("{1} fainted!",pbThis)) if showMessage
- PBDebug.log("[Pokémon fainted] #{pbThis} (#{@index})") if !showMessage
- @battle.scene.pbFaintBattler(self)
- pbInitEffects(false)
- # Reset status
- self.status = PBStatuses::NONE
- self.statusCount = 0
- # Lose happiness
- if @pokemon && @battle.internalBattle
- badLoss = false
- @battle.eachOtherSideBattler(@index) do |b|
- badLoss = true if b.level>=self.level+30
- end
- @pokemon.changeHappiness((badLoss) ? "faintbad" : "faint")
- end
- # Reset form
- @battle.peer.pbOnLeavingBattle(@battle,@pokemon,@battle.usedInBattle[idxOwnSide][@index/2])
- @pokemon.makeUnmega if mega?
- @pokemon.makeUnprimal if primal?
- # Do other things
- @battle.pbClearChoice(@index) # Reset choice
- pbOwnSide.effects[PBEffects::LastRoundFainted] = @battle.turnCount
- # Check other battlers' abilities that trigger upon a battler fainting
- pbAbilitiesOnFainting
- # Check for end of primordial weather
- @battle.pbEndPrimordialWeather
- end
- end
- class PokemonDataBox
- def initializeDataBoxGraphic(sideSize)
- @sideSize=sideSize
- onPlayerSide = ((@battler.index%2)==0)
- if !@battler.pokemon.hpbars
- @battler.pokemon.hpbars=0
- end
- # Get the data box graphic and set whether the HP numbers/Exp bar are shown
- if sideSize==1 # One Pokémon on side, use the regular data box BG
- bgFilename = ["Graphics/Pictures/Battle/databox_normal",
- "Graphics/Pictures/Battle/databox_normal_foe"][@battler.index%2]
- if onPlayerSide
- @showHP = true
- @showExp = true
- end
- else # Multiple Pokémon on side, use the thin data box BG
- bgFilename = ["Graphics/Pictures/Battle/databox_thin",
- "Graphics/Pictures/Battle/databox_thin_foe"][@battler.index%2]
- end
- #Set up multibar box BGs
- if @battler.pokemon.hpbars>0
- @showHP = false
- @showExp = false
- bgFilename = ["Graphics/Pictures/Battle/databox_multibars",
- "Graphics/Pictures/Battle/databox_multibars_foe"][@battler.index%2]
- if @battler.pokemon.hpbars>3
- bgFilename = ["Graphics/Pictures/Battle/databox_multibars_mid",
- "Graphics/Pictures/Battle/databox_multibars_mid_foe"][@battler.index%2]
- end
- if @battler.pokemon.hpbars>6
- bgFilename = ["Graphics/Pictures/Battle/databox_multibars_big",
- "Graphics/Pictures/Battle/databox_multibars_big_foe"][@battler.index%2]
- end
- end
- bgFilename = ["Graphics/Pictures/Battle/databox_multibars_big",
- "Graphics/Pictures/Battle/databox_multibars_big_foe"][@battler.index%2]
- @databoxBitmap = AnimatedBitmap.new(bgFilename)
- # Determine the co-ordinates of the data box and the left edge padding width
- if onPlayerSide
- if @battler.pokemon.hpbars>0
- @spriteX = Graphics.width - 260
- else
- @spriteX = Graphics.width - 244
- end
- @spriteY = Graphics.height - 192
- if @battler.pokemon.hpbars>6
- @spriteY = Graphics.height - 212
- end
- @spriteBaseX = 34
- else
- if @battler.pokemon.hpbars>0
- @spriteX = 0
- else
- @spriteX = -16
- end
- @spriteY = 36
- if @battler.pokemon.hpbars>6
- @spriteY = 16
- end
- @spriteBaseX = 16
- end
- case sideSize
- when 2
- @spriteX += [-12, 12, 0, 0][@battler.index]
- @spriteY += [-20, -34, 34, 20][@battler.index]
- when 3
- @spriteX += [-12, 12, -6, 6, 0, 0][@battler.index]
- @spriteY += [-42, -46, 4, 0, 50, 46][@battler.index]
- end
- end
- def initializeOtherGraphics(viewport)
- # Create other bitmaps
- @numbersBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/icon_numbers"))
- @hpBarBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/overlay_hp"))
- @expBarBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/overlay_exp"))
- # Create sprite to draw HP numbers on
- @hpNumbers = BitmapSprite.new(124,16,viewport)
- pbSetSmallFont(@hpNumbers.bitmap)
- @sprites["hpNumbers"] = @hpNumbers
- # Create sprite wrapper that displays HP bar
- @hpBar = SpriteWrapper.new(viewport)
- @hpBar.bitmap = @hpBarBitmap.bitmap
- @hpBar.src_rect.height = @hpBarBitmap.height/3
- @sprites["hpBar"] = @hpBar
- # Create sprite wrapper that displays Exp bar
- @expBar = SpriteWrapper.new(viewport)
- @expBar.bitmap = @expBarBitmap.bitmap
- @sprites["expBar"] = @expBar
- # Create sprite wrapper that displays everything except the above
- @contents = BitmapWrapper.new(@databoxBitmap.width,@databoxBitmap.height)
- self.bitmap = @contents
- self.visible = false
- self.z = 150+((@battler.index)/2)*5
- pbSetSystemFont(self.bitmap)
- end
- def dispose
- pbDisposeSpriteHash(@sprites)
- @databoxBitmap.dispose
- @numbersBitmap.dispose
- @hpBarBitmap.dispose
- @expBarBitmap.dispose
- @contents.dispose
- super
- end
- def refresh
- self.bitmap.clear
- return if !@battler.pokemon
- if !@battler.pokemon.hpbars
- @battler.pokemon.hpbars=0
- end
- textPos = []
- imagePos = []
- # Draw background panel
- #update the panel if number of bars has changed
- onPlayerSide = ((@battler.index%2)==0)
- # Get the data box graphic and set whether the HP numbers/Exp bar are shown
- if @sideSize==1 # One Pokémon on side, use the regular data box BG
- bgFilename = ["Graphics/Pictures/Battle/databox_normal",
- "Graphics/Pictures/Battle/databox_normal_foe"][@battler.index%2]
- if onPlayerSide
- @showHP = true
- @showExp = true
- end
- else # Multiple Pokémon on side, use the thin data box BG
- bgFilename = ["Graphics/Pictures/Battle/databox_thin",
- "Graphics/Pictures/Battle/databox_thin_foe"][@battler.index%2]
- end
- if @battler.pokemon.hpbars>0
- @showHP = false
- @showExp = false
- bgFilename = ["Graphics/Pictures/Battle/databox_multibars_big",
- "Graphics/Pictures/Battle/databox_multibars_big_foe"][@battler.index%2]
- if @battler.pokemon.hpbars<=6
- bgFilename = ["Graphics/Pictures/Battle/databox_multibars_mid",
- "Graphics/Pictures/Battle/databox_multibars_mid_foe"][@battler.index%2]
- end
- if @battler.pokemon.hpbars<=3
- bgFilename = ["Graphics/Pictures/Battle/databox_multibars",
- "Graphics/Pictures/Battle/databox_multibars_foe"][@battler.index%2]
- end
- end
- @databoxBitmap = AnimatedBitmap.new(bgFilename)
- if onPlayerSide
- @spriteX = Graphics.width - 260
- @spriteY = Graphics.height - 192
- if @battler.pokemon.hpbars>6
- @spriteY = Graphics.height - 212
- end
- else
- @spriteX = 0
- @spriteY = 36
- if @battler.pokemon.hpbars>6
- @spriteY = 16
- end
- end
- self.bitmap.blt(0,0,@databoxBitmap.bitmap,Rect.new(0,0,@databoxBitmap.width,@databoxBitmap.height))
- # Draw Pokémon's name
- nameWidth = self.bitmap.text_size(@battler.name).width
- nameOffset = 0
- nameOffset = nameWidth-116 if nameWidth>116
- textPos.push([@battler.name,@spriteBaseX+8-nameOffset,6,false,NAME_BASE_COLOR,NAME_SHADOW_COLOR])
- # Draw Pokémon's gender symbol
- case @battler.displayGender
- when 0 # Male
- textPos.push([_INTL("♂"),@spriteBaseX+126,6,false,MALE_BASE_COLOR,MALE_SHADOW_COLOR])
- when 1 # Female
- textPos.push([_INTL("♀"),@spriteBaseX+126,6,false,FEMALE_BASE_COLOR,FEMALE_SHADOW_COLOR])
- end
- pbDrawTextPositions(self.bitmap,textPos)
- # Draw Pokémon's level
- imagePos.push(["Graphics/Pictures/Battle/overlay_lv",@spriteBaseX+140,16])
- pbDrawNumber(@battler.level,self.bitmap,@spriteBaseX+162,16)
- # Draw shiny icon
- if @battler.shiny?
- shinyX = (@battler.opposes?(0)) ? 206 : -6 # Foe's/player's
- imagePos.push(["Graphics/Pictures/shiny",@spriteBaseX+shinyX,36])
- end
- # Draw Mega Evolution/Primal Reversion icon
- if @battler.mega?
- imagePos.push(["Graphics/Pictures/Battle/icon_mega",@spriteBaseX+8,34])
- elsif @battler.primal?
- primalX = (@battler.opposes?) ? 208 : -28 # Foe's/player's
- if @battler.isSpecies?(:KYOGRE)
- imagePos.push(["Graphics/Pictures/Battle/icon_primal_Kyogre",@spriteBaseX+primalX,4])
- elsif @battler.isSpecies?(:GROUDON)
- imagePos.push(["Graphics/Pictures/Battle/icon_primal_Groudon",@spriteBaseX+primalX,4])
- end
- end
- # Draw owned icon (foe Pokémon only)
- if @battler.owned? && @battler.opposes?(0)
- imagePos.push(["Graphics/Pictures/Battle/icon_own",@spriteBaseX+8,36])
- end
- # Draw status icon
- if @battler.status>0
- s = @battler.status
- s = 6 if s==PBStatuses::POISON && @battler.statusCount>0 # Badly poisoned
- imagePos.push(["Graphics/Pictures/Battle/icon_statuses",@spriteBaseX+24,36,
- 0,(s-1)*STATUS_ICON_HEIGHT,-1,STATUS_ICON_HEIGHT])
- end
- #Draw bonus HP bars
- if @battler.pokemon.hpbars>0
- if onPlayerSide
- @Column=[36,110,186]
- @Row=[68,84,100]
- else
- @Column=[8,84,160]
- @Row=[60,76,92]
- end
- @ColumnNo=0
- @RowNo=0
- for i in 0...@battler.pokemon.hpbars
- if @ColumnNo>2
- @ColumnNo=0
- @RowNo+=1
- end
- imagePos.push(["Graphics/Pictures/Battle/overlay_multibar",@Column[@ColumnNo],@Row[@RowNo],0,0,66,6])
- @ColumnNo+=1
- end
- end
- pbDrawImagePositions(self.bitmap,imagePos)
- refreshHP
- refreshExp
- end
- end
- def multibarFoe(bars,position=0)
- $game_variables[BARS_VARIABLE]=bars
- $game_variables[TRAINER_POSITION_VARIABLE]=position
- end
- #Sets wild Pokemon to have bonus bars
- Events.onWildPokemonCreate += proc { |_sender, e|
- pokemon = e[0]
- if $game_variables[BARS_VARIABLE]>0
- pokemon.hpbars=$game_variables[BARS_VARIABLE]
- end
- }
- #Sets a trainer's Pokemon to have bonus bars
- Events.onTrainerPartyLoad += proc { |_sender, e|
- 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
- position=$game_variables[TRAINER_POSITION_VARIABLE]
- bars=$game_variables[BARS_VARIABLE]
- if bars>0
- pokemon=party[position]
- pokemon.hpbars=bars
- end
- end
- }
- #Blocking transform
- def pbFailsAgainstTarget?(user,target)
- if target.effects[PBEffects::Transform] ||
- target.effects[PBEffects::Illusion] ||
- target.pokemon.hpbars && target.pokemon.hpbars>0
- @battle.pbDisplay(_INTL("But it failed!"))
- return true
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement