Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================#
- # PartyPlus 4.0.1 for Pokemon Essentials 19.1 #
- #==============================================================================#
- # Important usage Instructions: START A NEW SAVE FILE BEFORE USING THIS SCRIPT!#
- # To use as a plugin, drag and drop the folder containing this file into the #
- # /Plugins folder. to use as a script, create a new script section within RMXP #
- # and paste all text here into the new section (To add new sections, press #
- # 'Insert' on your keyboard. If you overwrite something, that's on you #
- #==============================================================================#
- # This script allows a developer to modify how many pokemon the player may play#
- # with. the current allowed sizes are between 1-20, with 3,5,7,11,13,17, and 19#
- # being invalid. This script also features "Benching", A mechanic that allowes #
- # Pokemon to travel with the player but are unable to participate in battle. #
- # to easily set the Party Limit and Bench limits, use the command `ppSetLimit` #
- # followed by two valid limits between 0-20. Ex: ppSetLimit(14,7) will let you #
- # travel with 14 pokemon, but only allow you to battle with 7 of them. setting #
- # the first argument to 0 will disable the limit modifyer, as well as the bench#
- # limit entierly. know that the continue screen, healing animation, and hall of#
- # fame are unedited, and updates for them are up to the user of the script to #
- # properly implement. #
- #==============================================================================#
- # Party Plus Settings #
- #==============================================================================#
- module Settings
- HARD_TEAM_LIMIT = 20 #The highest number of pokemon a trainer may have
- end
- #==============================================================================#
- # Custom commands for modifying the party. Modify me if you want to use party
- # limits over 20
- #==============================================================================#
- def ppSetLimit(total,limit=total)
- ########[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20]
- size = [ 1, 1, 1 ,0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1]
- legal = true if size[total]==1
- legal = false if size[total]==0
- limit = total if limit == 0
- if legal && total <= 20
- #total is greater than 1
- $Trainer.pluscount = total if total>=1
- $Trainer.partybenched = limit if total>=1
- $Trainer.partyplus = true if total>=1
- pbMessage(_INTL("Total Party Size and Battler limit Set.")) if total>=1
- # total equals 0
- $Trainer.partyplus = false if total==0
- $Trainer.pluscount = 0 if total==0
- $Trainer.partybenched = 0 if total==0
- pbMessage(_INTL("Party Size returned to Default value.")) if total==0
- elsif total >= 21
- pbMessage(_INTL("Current limit for trainer party cannot exceed 20."))
- else
- pbMessage(_INTL("The party value is invalid. Please enter a valid total."))
- end
- end
- def ppSetBenched
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- limit = $Trainer.partybenched
- limit = plus if plus==1
- if $Trainer.partyplus==true
- for j in 0...limit
- $Trainer.party[j].benched=false if $Trainer.party[j]!=nil
- end
- for i in limit...plus
- $Trainer.party[i].benched=true if limit<plus && $Trainer.party[i]!=nil
- end
- else
- for i in 0...$Trainer.party.length
- $Trainer.party[i].benched=false if $Trainer.party[i]!=nil
- end
- end
- end
- def ppUpdate
- partydep = $Trainer.partyplus
- plusded = false if $Trainer.partyif $Trainer.partyplus==false
- plusded = true if $Trainer.partyif $Trainer.partyplus==true
- $Trainer.partyplus = plusdep
- $Trainer.pluscount = partydep
- end
- #===============================================================================
- # Open the party screen
- #===============================================================================
- class PokemonPartyBlankPanel < SpriteWrapper
- def initialize(_pokemon,index,viewport=nil)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- super(viewport)
- ##########[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13, 14, 15,16,17, 18,19,20]
- csn = [ 2, 2, 2, 0, 2, 0, 2, 0, 2, 3, 2, 0, 3, 0, 7, 5, 4, 0, 6, 0, 5]
- rsn = [ 2, 2, 2, 0, 2, 0, 2, 0, 2, 3, 2, 0, 3, 0, 7, 5, 4, 0, 6, 0, 5]
- psy = [96, 0,96, 0,160, 0,106, 0,80,106,64, 0,80, 0,160,106,80, 0,108, 0,80]
- if $Trainer.partyplus==true && $Trainer.pluscount>=1
- self.x = (index % csn[plus]) * Graphics.width / csn[plus]
- self.y = 0 * (index % rsn[plus]) + psy[plus] * (index / rsn[plus])
- else
- self.x = (index % 2) * Graphics.width / 2
- self.y = 16 * (index % 2) + 96 * (index / 2)
- end
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_blank") if $Trainer.partyplus==true
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/panel_blank") if $Trainer.partyplus==false
- self.bitmap = @panelbgsprite.bitmap
- @text = nil
- end
- end
- #===============================================================================
- # Pokémon party panel
- #===============================================================================
- class PokemonPartyPanel < SpriteWrapper
- attr_reader :pokemon
- attr_reader :active
- attr_reader :selected
- attr_reader :preselected
- attr_reader :switching
- attr_reader :text
- def initialize(pokemon,index,viewport=nil)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- super(viewport)
- @pokemon = pokemon
- @active = (index==0) # true = rounded panel, false = rectangular panel
- @refreshing = true
- ##########[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13, 14, 15,16,17, 18,19,20]
- csn = [ 2, 2, 2, 0, 2, 0, 2, 0, 2, 3, 2, 0, 3, 0, 7, 5, 4, 0, 6, 0, 5]
- rsn = [ 2, 2, 2, 0, 2, 0, 2, 0, 2, 3, 2, 0, 3, 0, 7, 5, 4, 0, 6, 0, 5]
- psy = [96, 0,96, 0,160, 0,106, 0,80,106,64, 0,80, 0,160,106,80, 0,108, 0,80]
- if $Trainer.partyplus==true && $Trainer.pluscount>=1
- self.x = (index % csn[plus]) * Graphics.width / csn[plus]
- self.y = 0 * (index % rsn[plus]) + psy[plus] * (index / rsn[plus])
- else
- self.x = (index % 2) * Graphics.width / 2
- self.y = 16 * (index % 2) + 96 * (index / 2)
- end
- @panelbgsprite = ChangelingSprite.new(0,0,viewport)
- @panelbgsprite.z = self.z
- if @active # Rounded panel
- #Normal Panel
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/panel_round") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/panel_round_sel") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/panel_round_faint") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/panel_round_faint_sel") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/panel_round_swap") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/panel_round_swap_sel") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/panel_round_swap_sel2") if $Trainer.partyplus==false
- #Plus Pannels
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_sel") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_faint") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_faint_sel") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_swap") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_swap_sel") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_swap_sel2") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("benched","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_bench") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("benchsel","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_bench_sel") if $Trainer.partyplus==true
- else # Rectangular panel
- #Normal Panel
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/panel_rect") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/panel_rect_sel") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/panel_rect_faint") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/panel_rect_faint_sel") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/panel_rect_swap") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/panel_rect_swap_sel") if $Trainer.partyplus==false
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/panel_rect_swap_sel2") if $Trainer.partyplus==false
- #Plus Pannels
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_sel") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_faint") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_faint_sel") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_swap") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_swap_sel") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_swap_sel2") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("benched","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_bench") if $Trainer.partyplus==true
- @panelbgsprite.addBitmap("benchsel","Graphics/Pictures/Party/PartyPlus/"+"#{plus}"+" - Party/panel_rect_bench_sel") if $Trainer.partyplus==true
- end
- count = [1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0]
- show = true if count[$Trainer.pluscount]==1
- show = false if count[$Trainer.pluscount]==0
- if show
- @hpbgsprite = ChangelingSprite.new(0,0,viewport)
- @hpbgsprite.z = self.z+1
- @hpbgsprite.addBitmap("able","Graphics/Pictures/Party/overlay_hp_back")
- @hpbgsprite.addBitmap("fainted","Graphics/Pictures/Party/overlay_hp_back_faint")
- @hpbgsprite.addBitmap("swap","Graphics/Pictures/Party/overlay_hp_back_swap")
- end
- @ballsprite = ChangelingSprite.new(0,0,viewport)
- @ballsprite.z = self.z+1
- @ballsprite.addBitmap("desel","Graphics/Pictures/Party/icon_ball")
- @ballsprite.addBitmap("sel","Graphics/Pictures/Party/icon_ball_sel")
- @pkmnsprite = PokemonIconSprite.new(pokemon,viewport)
- @pkmnsprite.setOffset(PictureOrigin::Center) if $Trainer.partyplus==false
- @pkmnsprite.setOffset(PictureOrigin::TopLeft) if $Trainer.partyplus==true
- @pkmnsprite.active = @active
- @pkmnsprite.z = self.z+2
- #---------------------------------------------------------------------------
- # ZUD - Dynamax Icons
- #---------------------------------------------------------------------------
- _ZUD_DynamaxSize if defined?(Settings::ZUD_COMPAT)
- #---------------------------------------------------------------------------
- @helditemsprite = HeldItemIconSprite.new(0,0,@pokemon,viewport)
- @helditemsprite.z = self.z+3
- @overlaysprite = BitmapSprite.new(Graphics.width,Graphics.height,viewport)
- @overlaysprite.z = self.z+4
- @hpbar = AnimatedBitmap.new("Graphics/Pictures/Party/overlay_hp")
- @statuses = AnimatedBitmap.new(_INTL("Graphics/Pictures/statuses"))
- @selected = false
- @preselected = false
- @switching = false
- @text = nil
- @refreshBitmap = true
- @refreshing = false
- refresh
- end
- def dispose
- count = [1,1,1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0]
- show = true if count[$Trainer.pluscount]==1
- show = false if count[$Trainer.pluscount]==0
- @panelbgsprite.dispose
- @hpbgsprite.dispose if show
- @ballsprite.dispose
- @pkmnsprite.dispose
- @helditemsprite.dispose
- @overlaysprite.bitmap.dispose
- @overlaysprite.dispose
- @hpbar.dispose if show
- @statuses.dispose
- super
- end
- def refresh
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- ##############[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- name = [1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
- hp_bar = [1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
- hp_txt = [1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
- show_name = true if name[$Trainer.pluscount]==1
- show_name = false if name[$Trainer.pluscount]==0
- show_bar = true if hp_bar[$Trainer.pluscount]==1
- show_bar = false if hp_bar[$Trainer.pluscount]==0
- show_hp = true if hp_txt[$Trainer.pluscount]==1
- show_hp = false if hp_txt[$Trainer.pluscount]==0
- return if disposed?
- return if @refreshing
- @refreshing = true
- if @panelbgsprite && !@panelbgsprite.disposed?
- if self.selected
- if self.preselected; @panelbgsprite.changeBitmap("swapsel2")
- elsif @switching; @panelbgsprite.changeBitmap("swapsel")
- elsif @pokemon.fainted?; @panelbgsprite.changeBitmap("faintedsel")
- elsif @pokemon.benched?; @panelbgsprite.changeBitmap("benchsel")
- else; @panelbgsprite.changeBitmap("ablesel")
- end
- else
- if self.preselected; @panelbgsprite.changeBitmap("swap")
- elsif @pokemon.fainted?; @panelbgsprite.changeBitmap("fainted")
- elsif @pokemon.benched?; @panelbgsprite.changeBitmap("benched")
- else; @panelbgsprite.changeBitmap("able")
- end
- end
- @panelbgsprite.x = self.x
- @panelbgsprite.y = self.y
- @panelbgsprite.color = self.color
- end
- if @hpbgsprite && !@hpbgsprite.disposed?
- @hpbgsprite.visible = (!@pokemon.egg? && !(@text && @text.length>0))
- if @hpbgsprite.visible
- if self.preselected || (self.selected && @switching); @hpbgsprite.changeBitmap("swap")
- elsif @pokemon.fainted?; @hpbgsprite.changeBitmap("fainted")
- else; @hpbgsprite.changeBitmap("able")
- end
- ##############[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- hsx = [108,364,108, 0,108, 0,108, 0,108, 22,108, 0, 96, 0, 96, 96, 96, 0, 96, 0, 96]
- hsy = [ 47,153,153, 0, 73, 0, 47, 0, 33, 46, 25, 0, 32, 0, 32, 32, 32, 0, 32, 0, 32]
- @hpbgsprite.x = self.x+hsx[$Trainer.pluscount]
- @hpbgsprite.y = self.y+hsy[$Trainer.pluscount]
- @hpbgsprite.color = self.color
- end
- end
- if @ballsprite && !@ballsprite.disposed?
- @ballsprite.changeBitmap((self.selected) ? "sel" : "desel")
- @ballsprite.x = self.x+2
- @ballsprite.y = self.y-4
- @ballsprite.color = self.color
- end
- if @pkmnsprite && !@pkmnsprite.disposed?
- @pkmnsprite.x = self.x+60 if $Trainer.partyplus==false
- @pkmnsprite.x = self.x if $Trainer.partyplus==true
- @pkmnsprite.y = self.y+40 if $Trainer.partyplus==false
- @pkmnsprite.y = self.y if $Trainer.partyplus==true
- @pkmnsprite.color = self.color
- #-------------------------------------------------------------------------
- # ZUD - Dynamax Icons
- #-------------------------------------------------------------------------
- _ZUD_DynamaxColor if defined?(Settings::ZUD_COMPAT)
- #-------------------------------------------------------------------------
- @pkmnsprite.selected = self.selected
- end
- if @helditemsprite && !@helditemsprite.disposed?
- if @helditemsprite.visible
- @helditemsprite.x = self.x+62
- @helditemsprite.y = self.y+48
- @helditemsprite.color = self.color
- end
- end
- if @overlaysprite && !@overlaysprite.disposed?
- @overlaysprite.x = self.x
- @overlaysprite.y = self.y
- @overlaysprite.color = self.color
- end
- if @refreshBitmap
- @refreshBitmap = false
- @overlaysprite.bitmap.clear if @overlaysprite.bitmap
- basecolor = Color.new(248,248,248)
- shadowcolor = Color.new(40,40,40)
- pbSetSystemFont(@overlaysprite.bitmap)
- textpos = []
- # Draw Pokémon name
- ############[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- pnx = [244,502,244, 0,244, 0,244, 0,244,158,244, 0, 96, 0, 96, 96, 96, 0, 96, 0, 96]
- pny = [ 22, 10, 10, 0, 10, 0, 10, 0, 10, 10, 10, 0, 10, 0, 10, 10, 10, 0, 10, 0, 10]
- if @pokemon.male? || @pokemon.female?
- textpos.push([@pokemon.name,pnx[$Trainer.pluscount]-16,pny[$Trainer.pluscount]-12,1,basecolor,shadowcolor]) if show_name
- else
- textpos.push([@pokemon.name,pnx[$Trainer.pluscount],pny[$Trainer.pluscount]-12,1,basecolor,shadowcolor]) if show_name
- end
- if !@pokemon.egg?
- if !@text || @text.length==0
- # Draw HP numbers
- ################[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- hpx = [244,502,244, 0,244, 0,244, 0,244,158,244, 0, 96, 0, 96, 96, 96, 0, 96, 0, 96]
- hpy = [ 68,290,290, 0,130, 0, 78, 0, 50, 76, 34, 0, 32, 0, 32, 32, 32, 0, 32, 0, 32]
- textpos.push([sprintf("% 3d /% 3d",@pokemon.hp,@pokemon.totalhp),hpx[$Trainer.pluscount],hpy[$Trainer.pluscount]-12,1,basecolor,shadowcolor]) if show_hp
- # Draw HP bar
- if @pokemon.hp>0
- w = @pokemon.hp*96*1.0/@pokemon.totalhp
- w = 1 if w<1
- w = ((w/2).round)*2
- hpzone = 0
- hpzone = 1 if @pokemon.hp<=(@pokemon.totalhp/2).floor
- hpzone = 2 if @pokemon.hp<=(@pokemon.totalhp/4).floor
- hprect = Rect.new(0,hpzone*8,w,8)
- ##################[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- hbx = [108,364,108, 0,108, 0,108, 0,108, 22,108, 0, 96, 0, 96, 96, 96, 0, 96, 0, 96]
- hby = [ 47,153,153, 0, 73, 0, 47, 0, 33, 46, 25, 0, 32, 0, 32, 32, 32, 0, 32, 0, 32]
- @overlaysprite.bitmap.blt(hbx[$Trainer.pluscount]+32,hby[$Trainer.pluscount]+2,@hpbar.bitmap,hprect) if show_bar
- end
- # Draw status
- status = 0
- if @pokemon.fainted?
- status = GameData::Status::DATA.keys.length / 2
- elsif @pokemon.status != :NONE
- status = GameData::Status.get(@pokemon.status).id_number
- elsif @pokemon.pokerusStage == 1
- status = GameData::Status::DATA.keys.length / 2 + 1
- end
- status -= 1
- if status >= 0
- statusrect = Rect.new(0,16*status,44,16)
- @overlaysprite.bitmap.blt(78,68,@statuses.bitmap,statusrect)
- end
- end
- # draw gender symbol
- ##############[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- gxp = [244,502,244, 0,244, 0,244, 0,244,158,244, 0, 96, 0, 96, 96, 96, 0, 96, 0, 96]
- gyp = [ 22, 10, 10, 0, 10, 0, 10, 0, 10, 10, 10, 0, 10, 0, 10, 10, 10, 0, 10, 0, 10]
- if @pokemon.male? && show_name
- textpos.push([_INTL("♂"),gxp[$Trainer.pluscount],gyp[$Trainer.pluscount]-12,1,Color.new(0,112,248),Color.new(120,184,232)])
- elsif @pokemon.female? && show_name
- textpos.push([_INTL("♀"),gxp[$Trainer.pluscount],gyp[$Trainer.pluscount]-12,1,Color.new(232,32,16),Color.new(248,168,184)])
- end
- # Draw shiny icon
- if @pokemon.shiny?
- pbDrawImagePositions(@overlaysprite.bitmap,[[
- "Graphics/Pictures/shiny",80,48,0,0,16,16]])
- end
- end
- pbDrawTextPositions(@overlaysprite.bitmap,textpos)
- # Draw level text
- if !@pokemon.egg?
- pbDrawImagePositions(@overlaysprite.bitmap,[["Graphics/Pictures/Party/overlay_lv",20,70,0,0,22,14]]) if $Trainer.partyplus==false
- pbDrawImagePositions(@overlaysprite.bitmap,[["Graphics/Pictures/Party/overlay_lv",20,60,0,0,22,14]]) if $Trainer.partyplus==true
- pbSetSmallFont(@overlaysprite.bitmap)
- pbDrawTextPositions(@overlaysprite.bitmap,[[@pokemon.level.to_s,42,57,0,basecolor,shadowcolor]]) if $Trainer.partyplus==false
- pbDrawTextPositions(@overlaysprite.bitmap,[[@pokemon.level.to_s,42,47,0,basecolor,shadowcolor]]) if $Trainer.partyplus==true
- end
- # Draw annotation text
- if @text && @text.length>0
- pbSetSystemFont(@overlaysprite.bitmap)
- pbDrawTextPositions(@overlaysprite.bitmap,[
- [@text,96,52,0,basecolor,shadowcolor]
- ])
- end
- end
- @refreshing = false
- end
- def update
- count = [1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,0,0]
- show = true if count[$Trainer.pluscount]==1
- show = false if count[$Trainer.pluscount]==0
- super
- @panelbgsprite.update if @panelbgsprite && !@panelbgsprite.disposed?
- @hpbgsprite.update if @hpbgsprite && !@hpbgsprite.disposed? && show
- @ballsprite.update if @ballsprite && !@ballsprite.disposed?
- @pkmnsprite.update if @pkmnsprite && !@pkmnsprite.disposed?
- @helditemsprite.update if @helditemsprite && !@helditemsprite.disposed?
- end
- end
- #===============================================================================
- # Basic trainer class (use a child class rather than this one)
- #===============================================================================
- class Player < Trainer
- attr_accessor :partyplus
- attr_accessor :partybenched
- attr_accessor :pluscount
- alias _partyplus_initialize initialize
- def initialize(name, trainer_type)
- _partyplus_initialize(name, trainer_type)
- @partyplus = false
- @partybenched = 0
- @pluscount = 0
- end
- def able_party
- return @party.find_all { |p| p && !p.egg? && !p.fainted? && !p.benched? }
- end
- end
- #===============================================================================
- # Standard methods that start a trainer battle of various sizes
- #===============================================================================
- # Used by most trainer events, which can be positioned in such a way that
- # multiple trainer events spot the player at once. The extra code in this method
- # deals with that case and can cause a double trainer battle instead.
- def pbTrainerBattle(trainerID, trainerName, endSpeech=nil,
- doubleBattle=false, trainerPartyID=0, canLose=false, outcomeVar=1)
- # If there is another NPC trainer who spotted the player at the same time, and
- # it is possible to have a double battle (the player has 2+ able Pokémon or
- # has a partner trainer), then record this first NPC trainer into
- # $PokemonTemp.waitingTrainer and end this method. That second NPC event will
- # then trigger and cause the battle to happen against this first trainer and
- # themselves.
- if !$PokemonTemp.waitingTrainer && pbMapInterpreterRunning? && ($Trainer.able_pokemon_count > 1 || ($Trainer.able_pokemon_count > 0 && $PokemonGlobal.partner))
- thisEvent = pbMapInterpreter.get_character(0)
- # Find all other triggered trainer events
- triggeredEvents = $game_player.pbTriggeredTrainerEvents([2],false)
- otherEvent = []
- for i in triggeredEvents
- next if i.id==thisEvent.id
- next if $game_self_switches[[$game_map.map_id,i.id,"A"]]
- otherEvent.push(i)
- end
- # Load the trainer's data, and call an event which might modify it
- trainer = pbLoadTrainer(trainerID,trainerName,trainerPartyID)
- pbMissingTrainer(trainerID,trainerName,trainerPartyID) if !trainer
- return false if !trainer
- Events.onTrainerPartyLoad.trigger(nil,trainer)
- # If there is exactly 1 other triggered trainer event, and this trainer has
- # 6 or fewer Pokémon, record this trainer for a double battle caused by the
- # other triggered trainer event
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- if otherEvent.length == 1 && trainer.party.length <= plus
- trainer.lose_text = endSpeech if endSpeech && !endSpeech.empty?
- $PokemonTemp.waitingTrainer = [trainer, thisEvent.id]
- return false
- end
- end
- # Set some battle rules
- setBattleRule("outcomeVar",outcomeVar) if outcomeVar!=1
- setBattleRule("canLose") if canLose
- setBattleRule("double") if doubleBattle || $PokemonTemp.waitingTrainer
- # Perform the battle
- if $PokemonTemp.waitingTrainer
- decision = pbTrainerBattleCore($PokemonTemp.waitingTrainer[0],
- [trainerID,trainerName,trainerPartyID,endSpeech]
- )
- else
- decision = pbTrainerBattleCore([trainerID,trainerName,trainerPartyID,endSpeech])
- end
- # Finish off the recorded waiting trainer, because they have now been battled
- if decision==1 && $PokemonTemp.waitingTrainer # Win
- pbMapInterpreter.pbSetSelfSwitch($PokemonTemp.waitingTrainer[1], "A", true)
- end
- $PokemonTemp.waitingTrainer = nil
- # Return true if the player won the battle, and false if any other result
- return (decision==1)
- end
- #===============================================================================
- # Basic trainer class (use a child class rather than this one)
- #===============================================================================
- class Trainer
- def party_full?
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- return party_count >= plus
- end
- end
- #===============================================================================
- #
- #===============================================================================
- def pbNewTrainer(tr_type, tr_name, tr_version, save_changes = true)
- party = []
- for i in 0...Settings::HARD_TEAM_LIMIT
- if i == 0
- pbMessage(_INTL("Please enter the first Pokémon.",i))
- else
- break if !pbConfirmMessage(_INTL("Add another Pokémon?"))
- end
- loop do
- species = pbChooseSpeciesList
- if species
- params = ChooseNumberParams.new
- params.setRange(1, GameData::GrowthRate.max_level)
- params.setDefaultValue(10)
- level = pbMessageChooseNumber(_INTL("Set the level for {1} (max. #{params.maxNumber}).",
- GameData::Species.get(species).name), params)
- party.push([species, level])
- break
- else
- break if i > 0
- pbMessage(_INTL("This trainer must have at least 1 Pokémon!"))
- end
- end
- end
- trainer = [tr_type, tr_name, [], party, tr_version]
- if save_changes
- trainer_hash = {
- :id_number => GameData::Trainer::DATA.keys.length / 2,
- :trainer_type => tr_type,
- :name => tr_name,
- :version => tr_version,
- :pokemon => []
- }
- party.each do |pkmn|
- trainer_hash[:pokemon].push({
- :species => pkmn[0],
- :level => pkmn[1]
- })
- end
- # Add trainer's data to records
- trainer_hash[:id] = [trainer_hash[:trainer_type], trainer_hash[:name], trainer_hash[:version]]
- GameData::Trainer.register(trainer_hash)
- GameData::Trainer.save
- pbConvertTrainerData
- pbMessage(_INTL("The Trainer's data was added to the list of battles and in PBS/trainers.txt."))
- end
- return trainer
- end
- #===============================================================================
- # Pokémon party visuals
- #===============================================================================
- class PokemonParty_Scene
- def pbStartScene(party,starthelptext,annotations=nil,multiselect=false)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- ppSetBenched
- @sprites = {}
- @party = party
- @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z = 99999
- @multiselect = multiselect
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/bg",@viewport) if $Trainer.partyplus==true
- addBackgroundPlane(@sprites,"partybg","Party/bg",@viewport) if $Trainer.partyplus==false
- @sprites["messagebox"] = Window_AdvancedTextPokemon.new("")
- @sprites["messagebox"].viewport = @viewport
- @sprites["messagebox"].visible = false
- @sprites["messagebox"].letterbyletter = true
- pbBottomLeftLines(@sprites["messagebox"],2)
- @sprites["helpwindow"] = Window_UnformattedTextPokemon.new(starthelptext)
- @sprites["helpwindow"].viewport = @viewport
- @sprites["helpwindow"].visible = true
- pbBottomLeftLines(@sprites["helpwindow"],1)
- pbSetHelpText(starthelptext)
- # Add party Pokémon sprites
- for i in 0...plus
- if @party[i]
- @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i],i,@viewport)
- else
- @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i],i,@viewport)
- end
- @sprites["pokemon#{i}"].text = annotations[i] if annotations
- end
- if @multiselect
- @sprites["pokemon#{plus}"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon#{plus + 1}"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon#{plus}"] = PokemonPartyCancelSprite.new(@viewport)
- end
- # Select first Pokémon
- @activecmd = 0
- @sprites["pokemon0"].selected = true
- pbFadeInAndShow(@sprites) { update }
- end
- def pbAnnotate(annot)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- for i in 0...plus
- @sprites["pokemon#{i}"].text = (annot) ? annot[i] : nil
- end
- end
- def pbSelect(item)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- @activecmd = item
- numsprites = plus + ((@multiselect) ? 2 : 1)
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- def pbSwitchEnd(oldid,newid)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- pbSEPlay("GUI party switch")
- oldsprite = @sprites["pokemon#{oldid}"]
- newsprite = @sprites["pokemon#{newid}"]
- oldsprite.pokemon = @party[oldid]
- newsprite.pokemon = @party[newid]
- timeTaken = Graphics.frame_rate*4/10
- distancePerFrame = (Graphics.width/(2.0*timeTaken)).ceil
- timeTaken.times do
- oldsprite.x -= (oldid&1)==0 ? -distancePerFrame : distancePerFrame
- newsprite.x -= (newid&1)==0 ? -distancePerFrame : distancePerFrame
- Graphics.update
- Input.update
- self.update
- end
- #Inject Benching Code Here
- for i in 0...plus
- @sprites["pokemon#{i}"].preselected = false
- @sprites["pokemon#{i}"].switching = false
- end
- ppSetBenched
- pbRefresh
- end
- def pbClearSwitching
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- for i in 0...plus
- @sprites["pokemon#{i}"].preselected = false
- @sprites["pokemon#{i}"].switching = false
- end
- end
- def pbChoosePokemon(switching=false,initialsel=-1,canswitch=0)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- for i in 0...plus
- @sprites["pokemon#{i}"].preselected = (switching && i==@activecmd)
- @sprites["pokemon#{i}"].switching = switching
- end
- @activecmd = initialsel if initialsel>=0
- pbRefresh
- loop do
- Graphics.update
- Input.update
- self.update
- oldsel = @activecmd
- key = -1
- key = Input::DOWN if Input.repeat?(Input::DOWN)
- key = Input::RIGHT if Input.repeat?(Input::RIGHT)
- key = Input::LEFT if Input.repeat?(Input::LEFT)
- key = Input::UP if Input.repeat?(Input::UP)
- if key>=0
- @activecmd = pbChangeSelection(key,@activecmd)
- end
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = plus + ((@multiselect) ? 2 : 1)
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = plus + ((@multiselect) ? 1 : 0)
- if Input.trigger?(Input::ACTION) && canswitch==1 && @activecmd!=cancelsprite
- pbPlayDecisionSE
- return [1,@activecmd]
- elsif Input.trigger?(Input::ACTION) && canswitch==2
- return -1
- elsif Input.trigger?(Input::BACK)
- pbPlayCloseMenuSE if !switching
- return -1
- elsif Input.trigger?(Input::USE)
- if @activecmd==cancelsprite
- (switching) ? pbPlayDecisionSE : pbPlayCloseMenuSE
- return -1
- else
- pbPlayDecisionSE
- return @activecmd
- end
- end
- end
- end
- def pbChangeSelection(key,currentsel) #Further Mods Needed
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- div = [ 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 3, 2, 7, 5, 4, 2, 6, 2, 5]
- numsprites = plus + ((@multiselect) ? 2 : 1)
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel > 0 && currentsel < @party.length && !@party[currentsel]
- if currentsel >= @party.length && currentsel < plus
- currentsel = @party.length - 1
- end
- currentsel = numsprites - 1 if currentsel < 0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel < @party.length && !@party[currentsel]
- if currentsel == @party.length
- currentsel = plus
- elsif currentsel == numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel >= plus
- currentsel -= 1
- while currentsel > 0 && currentsel < plus && !@party[currentsel]
- currentsel -= 1
- end
- else
- begin
- currentsel -= div[plus]
- end while currentsel > 0 && !@party[currentsel]
- end
- if currentsel >= @party.length && currentsel < plus
- currentsel = @party.length-1
- end
- currentsel = numsprites - 1 if currentsel < 0
- when Input::DOWN
- if currentsel >= plus - 1
- currentsel += 1
- else
- currentsel += div[plus]
- currentsel = plus if currentsel < plus && !@party[currentsel]
- end
- if currentsel >= @party.length && currentsel < plus
- currentsel = plus
- elsif currentsel >= numsprites
- currentsel = 0
- end
- end
- return currentsel
- end
- def pbHardRefresh
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- oldtext = []
- lastselected = -1
- for i in 0...plus
- oldtext.push(@sprites["pokemon#{i}"].text)
- lastselected = i if @sprites["pokemon#{i}"].selected
- @sprites["pokemon#{i}"].dispose
- end
- lastselected = @party.length-1 if lastselected>=@party.length
- lastselected = 0 if lastselected<0
- for i in 0...plus
- if @party[i]
- @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i],i,@viewport)
- else
- @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i],i,@viewport)
- end
- @sprites["pokemon#{i}"].text = oldtext[i]
- end
- pbSelect(lastselected)
- end
- def pbRefresh
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- for i in 0...plus
- sprite = @sprites["pokemon#{i}"]
- if sprite
- if sprite.is_a?(PokemonPartyPanel)
- sprite.pokemon = sprite.pokemon
- else
- sprite.refresh
- end
- end
- end
- end
- end
- #===============================================================================
- # Pokémon party mechanics
- #===============================================================================
- class PokemonPartyScreen
- def pbPokemonMultipleEntryScreenEx(ruleset)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- annot = []
- statuses = []
- ordinals = [_INTL("INELIGIBLE"), _INTL("NOT ENTERED"), _INTL("BANNED")]
- positions = [_INTL("1st"), _INTL("2nd"), _INTL("3rd"), _INTL("4th"),
- _INTL("5th"), _INTL("6th"), _INTL("7th"), _INTL("8th"),
- _INTL("9th"),_INTL("10th"), _INTL("11th"), _INTL("12"),
- _INTL("13th"), _INTL("14th"), _INTL("15th"), _INTL("16th"),
- _INTL("17th"), _INTL("18th"), _INTL("19th"), _INTL("20th"),
- _INTL("21st"), _INTL("22nd"), _INTL("23rd"), _INTL("24th"),
- _INTL("25th"), _INTL("26th"), _INTL("27th"), _INTL("28th"),
- _INTL("29th"), _INTL("30th"), _INTL("31st"), _INTL("32nd"),
- _INTL("33rd"), _INTL("34th"), _INTL("35th"), _INTL("36th"),
- _INTL("37th"), _INTL("38th"), _INTL("39th"), _INTL("40th"),]
- for i in 0...plus
- if i < positions.length
- ordinals.push(positions[i])
- else
- ordinals.push("#{i + 1}th")
- end
- end
- return nil if !ruleset.hasValidTeam?(@party)
- ret = nil
- addedEntry = false
- for i in 0...@party.length
- statuses[i] = (ruleset.isPokemonValid?(@party[i])) ? 1 : 2
- end
- for i in 0...@party.length
- annot[i] = ordinals[statuses[i]]
- end
- @scene.pbStartScene(@party,_INTL("Choose Pokémon and confirm."),annot,true)
- loop do
- realorder = []
- for i in 0...@party.length
- for j in 0...@party.length
- if statuses[j]==i+3
- realorder.push(j)
- break
- end
- end
- end
- for i in 0...realorder.length
- statuses[realorder[i]] = i+3
- end
- for i in 0...@party.length
- annot[i] = ordinals[statuses[i]]
- end
- @scene.pbAnnotate(annot)
- if realorder.length==ruleset.number && addedEntry
- @scene.pbSelect(plus)
- end
- @scene.pbSetHelpText(_INTL("Choose Pokémon and confirm."))
- pkmnid = @scene.pbChoosePokemon
- addedEntry = false
- if pkmnid == plus # Confirm was chosen
- ret = []
- for i in realorder; ret.push(@party[i]); end
- error = []
- break if ruleset.isValid?(ret,error)
- pbDisplay(error[0])
- ret = nil
- end
- break if pkmnid<0 # Cancelled
- cmdEntry = -1
- cmdNoEntry = -1
- cmdSummary = -1
- commands = []
- if (statuses[pkmnid] || 0) == 1
- commands[cmdEntry = commands.length] = _INTL("Entry")
- elsif (statuses[pkmnid] || 0) > 2
- commands[cmdNoEntry = commands.length] = _INTL("No Entry")
- end
- pkmn = @party[pkmnid]
- commands[cmdSummary = commands.length] = _INTL("Summary")
- commands[commands.length] = _INTL("Cancel")
- command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands) if pkmn
- if cmdEntry>=0 && command==cmdEntry
- if realorder.length>=ruleset.number && ruleset.number>0
- pbDisplay(_INTL("No more than {1} Pokémon may enter.",ruleset.number))
- else
- statuses[pkmnid] = realorder.length+3
- addedEntry = true
- pbRefreshSingle(pkmnid)
- end
- elsif cmdNoEntry>=0 && command==cmdNoEntry
- statuses[pkmnid] = 1
- pbRefreshSingle(pkmnid)
- elsif cmdSummary>=0 && command==cmdSummary
- @scene.pbSummary(pkmnid) {
- @scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
- }
- end
- end
- @scene.pbEndScene
- return ret
- end
- end
- #===============================================================================
- # Instances of this class are individual Pokémon.
- # The player's party Pokémon are stored in the array $Trainer.party.
- #===============================================================================
- class Pokemon
- attr_writer :benched
- def benched?
- return @benched
- end
- # @return [Boolean] whether the Pokémon is not fainted and not an egg
- def able?
- return !egg? && !benched? && @hp > 0
- end
- alias _PPB_initialize initialize
- def initialize(species, level, owner = $Trainer, withMoves = true, recheck_form = true)
- _PPB_initialize(species, level, owner = $Trainer, withMoves = true, recheck_form = true)
- @benched = nil
- end
- end
- #===============================================================================
- #
- #===============================================================================
- class StorageSystemPC
- def access
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- pbMessage(_INTL("\\se[PC access]The Pokémon Storage System was opened."))
- command = 0
- loop do
- if plus==1
- command = pbShowCommandsWithHelp(nil,
- [_INTL("Organize Boxes"),
- _INTL("See ya!")],
- [_INTL("Organize the Pokémon in Boxes and in your party."),
- _INTL("Return to the previous menu.")],-1,command
- )
- if command>=0 && command<1
- pbFadeOutIn {
- scene = PokemonStorageScene.new
- screen = PokemonStorageScreen.new(scene,$PokemonStorage)
- screen.pbStartScreen(command)
- }
- else
- break
- end
- else
- command = pbShowCommandsWithHelp(nil,
- [_INTL("Organize Boxes"),
- _INTL("Withdraw Pokémon"),
- _INTL("Deposit Pokémon"),
- _INTL("See ya!")],
- [_INTL("Organize the Pokémon in Boxes and in your party."),
- _INTL("Move Pokémon stored in Boxes to your party."),
- _INTL("Store Pokémon in your party in Boxes."),
- _INTL("Return to the previous menu.")],-1,command
- )
- if command>=0 && command<3
- if command==1 # Withdraw
- if $PokemonStorage.party_full?
- pbMessage(_INTL("Your party is full!"))
- next
- end
- elsif command==2 # Deposit
- count=0
- for p in $PokemonStorage.party
- count += 1 if p && !p.egg? && p.hp>0
- end
- if count<=1
- pbMessage(_INTL("Can't deposit the last Pokémon!"))
- next
- end
- end
- pbFadeOutIn {
- scene = PokemonStorageScene.new
- screen = PokemonStorageScreen.new(scene,$PokemonStorage)
- screen.pbStartScreen(command)
- }
- else
- break
- end
- end
- end
- end
- end
- #===============================================================================
- # Party pop-up panel
- #===============================================================================
- class PokemonBoxPartySprite < SpriteWrapper
- def initialize(party,viewport=nil)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- super(viewport)
- @party = party
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/PartyPlus/"+"#{plus}"+" - overlay_party") if $Trainer.partyplus==true
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_party") if $Trainer.partyplus==false
- @pokemonsprites = []
- for i in 0...plus
- @pokemonsprites[i] = nil
- pokemon = @party[i]
- if pokemon
- @pokemonsprites[i] = PokemonBoxIcon.new(pokemon,viewport)
- end
- end
- ##########[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- gxd = [182,164,164,182,164,182,164,182,164,224,164,182,224,182,488,356,296,182,432,182,356]
- gyd = [352,130,130,352,180,352,230,352,280,230,330,352,280,352,180,230,280,352,230,352,280]
- @contents = BitmapWrapper.new(gxd[plus],gyd[plus]) if $Trainer.partyplus==true
- @contents = BitmapWrapper.new(172,352) if $Trainer.partyplus==false
- self.bitmap = @contents
- self.x = Graphics.width-gxd[plus]-8 if $Trainer.partyplus==true
- self.y = Graphics.height-gyd[plus] if $Trainer.partyplus==true
- self.x = 182 if $Trainer.partyplus==false
- self.y = Graphics.height-352 if $Trainer.partyplus==false
- pbSetSystemFont(self.bitmap)
- refresh
- end
- def dispose
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- for i in 0...plus
- @pokemonsprites[i].dispose if @pokemonsprites[i]
- end
- @boxbitmap.dispose
- @contents.dispose
- super
- end
- def color=(value)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- super
- for i in 0...plus
- if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
- @pokemonsprites[i].color = pbSrcOver(@pokemonsprites[i].color,value)
- end
- end
- end
- def visible=(value)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- super
- for i in 0...plus
- if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
- @pokemonsprites[i].visible = value
- end
- end
- end
- def refresh
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- ##########[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- gxd = [182,164,164,182,164,182,164,182,162,224,164,182,224,182,488,356,296,182,432,182,356]
- gyd = [352,130,130,352,180,352,230,352,280,230,330,352,280,352,180,230,280,352,230,352,280]
- if $Trainer.partyplus==true
- @contents.blt(0, 0, @boxbitmap.bitmap, Rect.new(0, 0, gxd[plus], gyd[plus]))
- else
- @contents.blt(0, 0, @boxbitmap.bitmap, Rect.new(0, 0, 172, 352))
- end
- pbDrawTextPositions(self.bitmap,[[_INTL("Back"), 86, 240, 2, Color.new(248, 248, 248), Color.new(80, 80, 80), 1]]) if $Trainer.partyplus==false
- pbDrawTextPositions(self.bitmap,[[_INTL(" "), 86, 240, 2, Color.new(248, 248, 248), Color.new(80, 80, 80), 1]]) if $Trainer.partyplus==true
- ##########[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- pxp = [ 18, 50, 16, 2, 16, 2, 16, 2, 16, 14, 16, 2, 14, 2, 14, 14, 14, 2, 14, 2, 14]
- pcp = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 3, 2, 7, 5, 4, 2, 6, 2, 5]
- pig = [ 0, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 2, 2, 2, 2, 4, 2, 4, 2, 2]
- xvalues = [] # [18, 90, 18, 90, 18, 90]
- yvalues = [] # [2, 18, 66, 82, 130, 146]
- for i in 0...plus
- #Party Plus Formula
- xvalues.push(pxp[plus] + (64+pig[plus]) * (i % pcp[plus])) if $Trainer.partyplus==true
- yvalues.push(2 + 0 * (i % pcp[plus]) + 50 * (i / pcp[plus])) if $Trainer.partyplus==true
- #Vanilla Formula
- xvalues.push(18 + 72 * (i % 2)) if $Trainer.partyplus==false
- yvalues.push(2 + 16 * (i % 2) + 64 * (i / 2)) if $Trainer.partyplus==false
- end
- for j in 0...plus
- @pokemonsprites[j] = nil if @pokemonsprites[j] && @pokemonsprites[j].disposed?
- end
- @pokemonsprites.compact!
- for j in 0...plus
- sprite = @pokemonsprites[j]
- if sprite && !sprite.disposed?
- sprite.viewport = self.viewport
- sprite.x = self.x + xvalues[j]
- sprite.y = self.y + yvalues[j]
- sprite.z = 0
- end
- end
- end
- def update
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- super
- for i in 0...plus
- @pokemonsprites[i].update if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
- end
- end
- end
- #===============================================================================
- # Pokémon storage visuals
- #===============================================================================
- class PokemonStorageScene
- def pbStartBox(screen,command)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- @screen = screen
- @storage = screen.storage
- @bgviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @bgviewport.z = 99999
- @boxviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @boxviewport.z = 99999
- @boxsidesviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @boxsidesviewport.z = 99999
- @arrowviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @arrowviewport.z = 99999
- @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z = 99999
- @selection = 0
- @quickswap = false
- @sprites = {}
- @choseFromParty = false
- @command = command
- addBackgroundPlane(@sprites,"background","Storage/bg",@bgviewport)
- @sprites["box"] = PokemonBoxSprite.new(@storage,@storage.currentBox,@boxviewport)
- @sprites["boxsides"] = IconSprite.new(0,0,@boxsidesviewport)
- @sprites["boxsides"].setBitmap("Graphics/Pictures/Storage/overlay_main")
- @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@boxsidesviewport)
- pbSetSystemFont(@sprites["overlay"].bitmap)
- @sprites["pokemon"] = AutoMosaicPokemonSprite.new(@boxsidesviewport)
- @sprites["pokemon"].setOffset(PictureOrigin::Center)
- @sprites["pokemon"].x = 90
- @sprites["pokemon"].y = 134
- @sprites["boxparty"] = PokemonBoxPartySprite.new(@storage.party,@boxsidesviewport)
- if command!=2 # Drop down tab only on Deposit
- ############[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- gxd = [182,164,164,182,164,182,164,182,164,224,164,182,224,182,488,356,296,182,432,182,356]
- @sprites["boxparty"].x = Graphics.width-gxd[plus]-8 if $Trainer.partyplus==true
- @sprites["boxparty"].x = 182 if $Trainer.partyplus==false
- @sprites["boxparty"].y = Graphics.height
- end
- @markingbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/markings")
- @sprites["markingbg"] = IconSprite.new(292,68,@boxsidesviewport)
- @sprites["markingbg"].setBitmap("Graphics/Pictures/Storage/overlay_marking")
- @sprites["markingbg"].visible = false
- @sprites["markingoverlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@boxsidesviewport)
- @sprites["markingoverlay"].visible = false
- pbSetSystemFont(@sprites["markingoverlay"].bitmap)
- @sprites["arrow"] = PokemonBoxArrow.new(@arrowviewport)
- @sprites["arrow"].z += 1
- if command!=2
- pbSetArrow(@sprites["arrow"],@selection)
- pbUpdateOverlay(@selection)
- pbSetMosaic(@selection)
- else
- pbPartySetArrow(@sprites["arrow"],@selection)
- pbUpdateOverlay(@selection,@storage.party)
- pbSetMosaic(@selection)
- end
- pbSEPlay("PC access")
- pbFadeInAndShow(@sprites)
- end
- def pbPartySetArrow(arrow,selection)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- return if selection < 0
- ##########[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- pbs = [ 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 3, 2, 7, 5, 4, 2, 6, 2, 5]
- prs = [ 3, 1, 1, 2, 2, 2, 3, 2, 4, 3, 5, 2, 4, 2, 2, 3, 4, 2, 6, 2, 5]
- axp = [200,390,356, 0,356, 0,356, 0,356,294,356, 0,294, 0, 30,162,222, 0, 86, 0,162]
- ayp = [ 16,224,224, 0,174, 0,124, 0, 74,124, 24, 0, 74, 0,174,124, 74, 0,124, 0, 72]
- igx = [ 0, 2, 4, 0, 4, 0, 4, 0, 4, 2, 4, 0, 2, 0, 2, 2, 4, 0, 4, 0, 2]
- xvalues = [] # [200, 272, 200, 272, 200, 272, 236]
- yvalues = [] # [2, 18, 66, 82, 130, 146, 220]
- for i in 0...plus
- #Plus Cords
- xvalues.push(axp[plus] + (igx[plus]+64) * (i % pbs[plus])) if $Trainer.partyplus==true
- yvalues.push(ayp[plus] + 0 * (i % pbs[plus]) + 50 * (i / pbs[plus])) if $Trainer.partyplus==true
- #Vanilla Cords
- xvalues.push(200 + 72 * (i % 2)) if $Trainer.partyplus==false
- yvalues.push(2 + 16 * (i % 2) + 64 * (i / 2)) if $Trainer.partyplus==false
- end
- #Plus Back
- ##########[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- bxp = [236,390,390, 0,390, 0,390, 0,390,360,390, 0,360, 0,228,294,324, 0,256, 0,294]
- xvalues.push(bxp[plus]) if $Trainer.partyplus==true
- yvalues.push(280) if $Trainer.partyplus==true
- #Vanilla Back
- xvalues.push(236) if $Trainer.partyplus==false
- yvalues.push(220) if $Trainer.partyplus==false
- arrow.angle = 0
- arrow.mirror = false
- arrow.ox = 0
- arrow.oy = 0
- arrow.x = xvalues[selection]
- arrow.y = yvalues[selection]
- end
- def pbPartyChangeSelection(key,selection)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- div = [ 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 3, 2, 7, 5, 4, 2, 6, 2, 5]
- case key
- when Input::LEFT
- selection -= 1
- selection = plus if selection < 0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection > plus
- when Input::UP
- if selection == plus
- selection = plus - 1
- else
- selection -= div[plus]
- selection = plus if selection < 0
- end
- when Input::DOWN
- if selection == plus
- selection = 0
- else
- selection += div[plus]
- selection = plus if selection > plus
- end
- end
- return selection
- end
- def pbSelectPartyInternal(party,depositing)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- selection = @selection
- pbPartySetArrow(@sprites["arrow"],selection)
- pbUpdateOverlay(selection,party)
- pbSetMosaic(selection)
- lastsel = 1
- loop do
- Graphics.update
- Input.update
- key = -1
- key = Input::DOWN if Input.repeat?(Input::DOWN)
- key = Input::RIGHT if Input.repeat?(Input::RIGHT)
- key = Input::LEFT if Input.repeat?(Input::LEFT)
- key = Input::UP if Input.repeat?(Input::UP)
- if key>=0
- pbPlayCursorSE
- newselection = pbPartyChangeSelection(key,selection)
- if newselection==-1
- return -1 if !depositing
- elsif newselection==-2
- selection = lastsel
- else
- selection = newselection
- end
- pbPartySetArrow(@sprites["arrow"],selection)
- lastsel = selection if selection>0
- pbUpdateOverlay(selection,party)
- pbSetMosaic(selection)
- end
- self.update
- if Input.trigger?(Input::ACTION) && @command == 0 # Organize only
- pbPlayDecisionSE
- pbSetQuickSwap(!@quickswap)
- elsif Input.trigger?(Input::BACK)
- @selection = selection
- return -1
- elsif Input.trigger?(Input::USE)
- if selection >= 0 && selection < plus
- @selection = selection
- return selection
- elsif selection == plus # Close Box
- @selection = selection
- return (depositing) ? -3 : -1
- end
- end
- end
- end
- def pbShowPartyTab
- plus = $Trainer.pluscount
- ##########[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- gyd = [352,130,130, 0,180, 0,230, 0,280,230,330, 0,280, 0,180,230,280, 0,230, 0,280]
- pbSEPlay("GUI storage show party panel")
- distancePerFrame = 48*20/Graphics.frame_rate
- loop do
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= distancePerFrame
- self.update
- break if @sprites["boxparty"].y<=Graphics.height-gyd[plus]
- end
- @sprites["boxparty"].y = Graphics.height-gyd[plus]
- end
- def pbHidePartyTab
- plus = $Trainer.pluscount
- ##########[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- gyd = [352,130,130, 0,180, 0,230, 0,280,230,330, 0,280, 0,180,230,280, 0,230, 0,280]
- pbSEPlay("GUI storage hide party panel")
- distancePerFrame = 48*20/Graphics.frame_rate
- loop do
- Graphics.update
- Input.update
- @sprites["boxparty"].y += distancePerFrame
- self.update
- break if @sprites["boxparty"].y>=Graphics.height
- end
- @sprites["boxparty"].y = Graphics.height
- end
- def maxPokemon(box)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- return 0 if box >= self.maxBoxes
- return (box < 0) ? plus : self[box].length
- end
- def pbFirstFreePos(box)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- if box==-1
- ret = self.party.length
- return (ret >= plus) ? -1 : ret
- end
- for i in 0...maxPokemon(box)
- return i if !self[box,i]
- end
- return -1
- end
- end
- #==============================================================================#
- # Pokemon Storage Calls
- #==============================================================================#
- class PokemonStorage
- def maxPokemon(box)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- return 0 if box >= self.maxBoxes
- return (box < 0) ? plus : self[box].length
- end
- def pbFirstFreePos(box)
- plus = $Trainer.pluscount if $Trainer.partyplus==true
- plus = Settings::MAX_PARTY_SIZE if $Trainer.partyplus==false
- if box==-1
- ret = self.party.length
- return (ret >= plus) ? -1 : ret
- end
- for i in 0...maxPokemon(box)
- return i if !self[box,i]
- end
- return -1
- end
- end
- #===============================================================================
- # Individual trainer editor
- #===============================================================================
- module TrainerBattleProperty
- def self.set(settingname, oldsetting)
- return nil if !oldsetting
- properties = [
- [_INTL("Trainer Type"), TrainerTypeProperty, _INTL("Name of the trainer type for this Trainer.")],
- [_INTL("Trainer Name"), StringProperty, _INTL("Name of the Trainer.")],
- [_INTL("Version"), LimitProperty.new(9999), _INTL("Number used to distinguish Trainers with the same name and trainer type.")],
- [_INTL("Lose Text"), StringProperty, _INTL("Message shown in battle when the Trainer is defeated.")]
- ]
- Settings::HARD_TEAM_LIMIT.times do |i|
- properties.push([_INTL("Pokémon {1}", i + 1), TrainerPokemonProperty, _INTL("A Pokémon owned by the Trainer.")])
- end
- NUM_ITEMS.times do |i|
- properties.push([_INTL("Item {1}", i + 1), ItemProperty, _INTL("An item used by the Trainer during battle.")])
- end
- return nil if !pbPropertyList(settingname, oldsetting, properties, true)
- oldsetting = nil if !oldsetting[0]
- return oldsetting
- end
- end
- def pbTrainerBattleEditor
- modified = false
- pbListScreenBlock(_INTL("Trainer Battles"), TrainerBattleLister.new(0, true)) { |button, trainer_id|
- if trainer_id
- if button == Input::ACTION
- if trainer_id.is_a?(Array)
- if pbConfirmMessageSerious("Delete this trainer battle?")
- tr_data = GameData::Trainer::DATA[trainer_id]
- GameData::Trainer::DATA.delete(trainer_id)
- GameData::Trainer::DATA.delete(tr_data.id_number)
- modified = true
- pbMessage(_INTL("The Trainer battle was deleted."))
- end
- end
- elsif button == Input::USE
- if trainer_id.is_a?(Array) # Edit existing trainer
- tr_data = GameData::Trainer::DATA[trainer_id]
- old_type = tr_data.trainer_type
- old_name = tr_data.real_name
- old_version = tr_data.version
- data = [
- tr_data.trainer_type,
- tr_data.real_name,
- tr_data.version,
- tr_data.real_lose_text
- ]
- for i in 0...Settings::HARD_TEAM_LIMIT
- data.push(tr_data.pokemon[i])
- end
- for i in 0...TrainerBattleProperty::NUM_ITEMS
- data.push(tr_data.items[i])
- end
- loop do
- data = TrainerBattleProperty.set(tr_data.real_name, data)
- break if !data
- party = []
- items = []
- for i in 0...Settings::HARD_TEAM_LIMIT
- party.push(data[4 + i]) if data[4 + i] && data[4 + i][:species]
- end
- for i in 0...TrainerBattleProperty::NUM_ITEMS
- items.push(data[4 + Settings::HARD_TEAM_LIMIT + i]) if data[4 + Settings::HARD_TEAM_LIMIT + i]
- end
- if !data[0]
- pbMessage(_INTL("Can't save. No trainer type was chosen."))
- elsif !data[1] || data[1].empty?
- pbMessage(_INTL("Can't save. No name was entered."))
- elsif party.length == 0
- pbMessage(_INTL("Can't save. The Pokémon list is empty."))
- else
- trainer_hash = {
- :id_number => tr_data.id_number,
- :trainer_type => data[0],
- :name => data[1],
- :version => data[2],
- :lose_text => data[3],
- :pokemon => party,
- :items => items
- }
- # Add trainer type's data to records
- trainer_hash[:id] = [trainer_hash[:trainer_type], trainer_hash[:name], trainer_hash[:version]]
- GameData::Trainer.register(trainer_hash)
- if data[0] != old_type || data[1] != old_name || data[2] != old_version
- GameData::Trainer::DATA.delete([old_type, old_name, old_version])
- end
- modified = true
- break
- end
- end
- else # New trainer
- tr_type = nil
- ret = pbMessage(_INTL("First, define the new trainer's type."), [
- _INTL("Use existing type"),
- _INTL("Create new type"),
- _INTL("Cancel")], 3)
- case ret
- when 0
- tr_type = pbListScreen(_INTL("TRAINER TYPE"), TrainerTypeLister.new(0, false))
- when 1
- tr_type = pbTrainerTypeEditorNew(nil)
- else
- next
- end
- next if !tr_type
- tr_name = pbMessageFreeText(_INTL("Now enter the trainer's name."), "", false, 30)
- next if nil_or_empty?(tr_name)
- tr_version = pbGetFreeTrainerParty(tr_type, tr_name)
- if tr_version < 0
- pbMessage(_INTL("There is no room to create a trainer of that type and name."))
- next
- end
- t = pbNewTrainer(tr_type, tr_name, tr_version, false)
- if t
- trainer_hash = {
- :id_number => GameData::Trainer::DATA.keys.length / 2,
- :trainer_type => tr_type,
- :name => tr_name,
- :version => tr_version,
- :pokemon => []
- }
- t[3].each do |pkmn|
- trainer_hash[:pokemon].push({
- :species => pkmn[0],
- :level => pkmn[1]
- })
- end
- # Add trainer's data to records
- trainer_hash[:id] = [trainer_hash[:trainer_type], trainer_hash[:name], trainer_hash[:version]]
- GameData::Trainer.register(trainer_hash)
- pbMessage(_INTL("The Trainer battle was added."))
- modified = true
- end
- end
- end
- end
- }
- if modified && pbConfirmMessage(_INTL("Save changes?"))
- GameData::Trainer.save
- pbConvertTrainerData
- else
- GameData::Trainer.load
- end
- end
Add Comment
Please, Sign In to add comment