Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PokeAmieButton < SpriteWrapper
- attr_reader :index
- attr_reader :name
- attr_accessor :selected
- def initialize(x,y,name="",index=0,viewport=nil)
- super(viewport)
- @index=index
- @name=name
- @selected=false
- fembutton=pbResolveBitmap(sprintf("Graphics/Pictures/pokegearButtonf"))
- if $Trainer.isFemale? && fembutton
- @button=AnimatedBitmap.new("Graphics/Pictures/pokegearButtonf")
- else
- @button=AnimatedBitmap.new("Graphics/Pictures/pokegearButton")
- end
- @contents=BitmapWrapper.new(@button.width,@button.height)
- self.bitmap=@contents
- self.x=x
- self.y=y
- refresh
- update
- end
- def dispose
- @button.dispose
- @contents.dispose
- super
- end
- def refresh
- self.bitmap.clear
- self.bitmap.blt(0,0,@button.bitmap,Rect.new(0,0,@button.width,@button.height))
- pbSetSystemFont(self.bitmap)
- textpos=[ # Name is written on both unselected and selected buttons
- [@name,self.bitmap.width/2,10,2,Color.new(248,248,248),Color.new(40,40,40)],
- [@name,self.bitmap.width/2,62,2,Color.new(248,248,248),Color.new(40,40,40)]
- ]
- pbDrawTextPositions(self.bitmap,textpos)
- icon=sprintf("Graphics/Pictures/pokegear"+@name)
- imagepos=[ # Icon is put on both unselected and selected buttons
- [icon,18,10,0,0,-1,-1],
- [icon,18,62,0,0,-1,-1]
- ]
- pbDrawImagePositions(self.bitmap,imagepos)
- end
- def update
- if self.selected
- self.src_rect.set(0,self.bitmap.height/2,self.bitmap.width,self.bitmap.height/2)
- else
- self.src_rect.set(0,0,self.bitmap.width,self.bitmap.height/2)
- end
- super
- end
- end
- module BeanColors
- Red = 0
- Orange = 1
- Yellow = 2
- Green = 3
- LightBlue = 4
- Blue = 5
- Purple = 6
- Pink = 7
- RedPatterned = 8
- OrangePatterned = 9
- YellowPatterned = 10
- GreenPatterned = 11
- LightBluePatterned = 12
- BluePatterned = 13
- PurplePatterned = 14
- PinkPatterned = 15
- Rainbow = 16
- def BeanColors.getName(id)
- names=[
- _INTL("Red Bean"),
- _INTL("Orange Bean"),
- _INTL("Yellow Bean"),
- _INTL("Green Bean"),
- _INTL("Light Blue Bean"),
- _INTL("Blue Bean"),
- _INTL("Purple Bean"),
- _INTL("Pink Bean"),
- _INTL("Patterned Red Bean"),
- _INTL("Patterned Orange Bean"),
- _INTL("Patterned Yellow Bean"),
- _INTL("Patterned Green Bean"),
- _INTL("Patterned Light Blue Bean"),
- _INTL("Patterned Blue Bean"),
- _INTL("Patterned Purple Bean"),
- _INTL("Patterned Pink Bean"),
- _INTL("Rainbow Bean"),
- ]
- return names[id]
- end
- end
- class PokeBattle_Trainer
- attr_accessor :beans
- alias amie_initialize initialize
- def initialize(name,trainertype)
- amie_initialize(name,trainertype)
- @beans=[]
- for i in 0..16
- @beans.push(0)
- end
- end
- end
- def addBeans(bean,num)
- if bean.is_a?(String) || bean.is_a?(Symbol)
- bean=getID(BeanColors,bean)
- end
- if $Trainer.beans[bean]+num>255
- num=255-$Trainer.beans[bean]
- end
- $Trainer.beans[bean]+=num
- Kernel.pbMessage(_INTL("\\se[itemlevel]Obtained \\c[1]{1}\\c[0]!\\wtnp[30]",BeanColors.getName(bean)))
- end
- #===============================================================================
- # This class performs menu screen processing.
- #-------------------------------------------------------------------------------
- # Adapted by rigbycwts for use with Pokemon-Amie for Essentials.
- #===============================================================================
- class PokeAmie_Essentials
- #-----------------------------------------------------------------------------
- # * Object Initialization
- # menu_index : command cursor's initial position
- #-----------------------------------------------------------------------------
- def initialize(pokemon, partyIndex, menu_index = 0)
- @pokemon = pokemon
- @partyIndex = partyIndex
- @menu_index = menu_index
- end
- #-----------------------------------------------------------------------------
- # * Main Processing
- #-----------------------------------------------------------------------------
- def main
- # Make command window
- fadein = true
- # Makes the text window
- @sprites={}
- @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z=99999
- @sprites["bgmap"] = IconSprite.new(0,0)
- @sprites["bgmap"].setBitmap(self.pbBackdrop)
- @sprites["bgmap"].z=200
- @sprites["border"] = IconSprite.new(0,280)
- @sprites["border"].setBitmap("Graphics/Pictures/AmieBottom")
- @sprites["border"].z=240
- @sprites["background"] = IconSprite.new(0,0)
- @sprites["background"].setBitmap("Graphics/Pictures/PokeAmie/Choices")
- @sprites["background"].z=255
- @sprites["affection"]=IconSprite.new(40,120)
- @sprites["affection"].setBitmap(@affectionbar)
- @sprites["affection"].z=245
- @sprites["pokemon"]=PokemonSprite.new(@viewport)
- @sprites["pokemon"].setPokemonBitmap(@pokemon)
- @sprites["pokemon"].mirror=false
- @sprites["pokemon"].color=Color.new(0,0,0,0)
- pbPositionPokemonSprite(@sprites["pokemon"],40,144)
- @choices=[
- _INTL("Pet"),
- _INTL("Feed"),
- _INTL("Exit")
- ]
- @sprites["header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("Pokémon-Amie"),
- 2,-18,640,64,@viewport)
- @sprites["header"].baseColor=Color.new(248,248,248)
- @sprites["header"].shadowColor=Color.new(0,0,0)
- @sprites["header"].windowskin=nil
- @sprites["command_window"] = Window_CommandPokemon.new(@choices,324)
- @sprites["command_window"].windowskin=nil
- @sprites["command_window"].index = @menu_index
- @sprites["command_window"].height = 224
- @sprites["command_window"].width = 124
- @sprites["command_window"].x = 320
- @sprites["command_window"].y = 92
- @sprites["command_window"].z = 256
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection")
- if @pokemon.getAffectionLevel>=5
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection5")
- elsif @pokemon.getAffectionLevel>=4
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection4")
- elsif @pokemon.getAffectionLevel>=3
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection3")
- elsif @pokemon.getAffectionLevel>=2
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection2")
- elsif @pokemon.getAffectionLevel>=1
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection1")
- end
- @custom = false
- # Execute transition
- Graphics.transition
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame update
- update
- # Abort loop if screen is changed
- if $scene != self
- break
- end
- end
- # Prepares for transition
- Graphics.freeze
- # Disposes the windows
- pbDisposeSpriteHash(@sprites)
- @viewport.dispose
- end
- def pbBackdrop
- environ=pbGetEnvironment
- # Choose backdrop
- backdrop="Field"
- if environ==PBEnvironment::Cave
- backdrop="Cave"
- elsif environ==PBEnvironment::MovingWater || environ==PBEnvironment::StillWater
- backdrop="Water"
- elsif environ==PBEnvironment::Underwater
- backdrop="Underwater"
- elsif environ==PBEnvironment::Rock
- backdrop="Mountain"
- else
- if !$game_map || !pbGetMetadata($game_map.map_id,MetadataOutdoor)
- backdrop="IndoorA"
- end
- end
- if $game_map
- back=pbGetMetadata($game_map.map_id,MetadataBattleBack)
- if back && back!=""
- backdrop=back
- end
- end
- if $PokemonGlobal && $PokemonGlobal.nextBattleBack
- backdrop=$PokemonGlobal.nextBattleBack
- end
- # Apply graphics
- battlebg="Graphics/Battlebacks/battlebg"+backdrop
- return battlebg
- #pbDayNightTint(@sprites["battlebg"])
- end
- #-----------------------------------------------------------------------------
- # * Frame Update
- #-----------------------------------------------------------------------------
- def update
- # Update windows
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection")
- if @pokemon.getAffectionLevel>=5
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection5")
- elsif @pokemon.getAffectionLevel>=4
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection4")
- elsif @pokemon.getAffectionLevel>=3
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection3")
- elsif @pokemon.getAffectionLevel>=2
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection2")
- elsif @pokemon.getAffectionLevel>=1
- @sprites["affection"].setBitmap("Graphics/Pictures/PokeAmie/affection1")
- end
- pbUpdateSpriteHash(@sprites)
- if @custom
- updateCustom
- else
- update_command
- end
- return
- end
- #-----------------------------------------------------------------------------
- # * Frame Update (when command window is active)
- #-----------------------------------------------------------------------------
- def updateCustom
- if Input.trigger?(Input::B)
- @sprites["command_window"].commands=@choices
- @sprites["command_window"].index=2
- @custom = false
- return
- end
- if Input.trigger?(Input::C)
- # if (self.nature%5)==flavor && (self.nature/5).floor!=(self.nature%5)
- Kernel.pbMessage(_INTL("This feature is coming soon."))
- end
- end
- def hasBean?
- if !$Trainer.beans
- $Trainer.beans=[]
- for i in 0..16
- $Trainer.beans.push(0)
- end
- end
- return $Trainer.beans.any? {|item| item > 0 }
- end
- def canEat?(species)
- return !(isConst?(species,PBSpecies,:METAPOD) ||
- isConst?(species,PBSpecies,:KAKUNA) ||
- isConst?(species,PBSpecies,:PINECO) ||
- isConst?(species,PBSpecies,:SILCOON) ||
- isConst?(species,PBSpecies,:CASCOON) ||
- isConst?(species,PBSpecies,:SHEDNINJA) ||
- isConst?(species,PBSpecies,:SPEWPA) ||
- isConst?(species,PBSpecies,:COSMOEN))
- end
- def update_command
- # If B button was pressed
- if Input.trigger?(Input::B)
- pbPlayCancelSE()
- # Switch to map screen
- $scene = Scene_Pokegear.new
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Branch by command window cursor position
- case @sprites["command_window"].index
- when 0 # Pet
- $Trainer.party[@partyIndex].changeAmieStats("pet")
- Kernel.pbMessage(_INTL("Affection and Enjoyment increased."))
- when 1 # Feed
- if canEat?($Trainer.party[@partyIndex].species)
- if hasBean?
- commands=[]
- for i in 0..16
- commands.push(sprintf("x%03d - %s",$Trainer.beans[i],BeanColors.getName(i)))
- end
- bean=Kernel.pbMessage(_INTL("What do you want to feed them?"),commands,-1)
- if bean==-1
- return
- elsif $Trainer.beans[bean]<1
- Kernel.pbMessage(_INTL("You have no beans of that type."))
- return
- elsif bean<=BeanColors::Pink
- $Trainer.party[@partyIndex].changeAmieStats("feedPlainBean")
- $Trainer.beans[bean]-=1
- elsif bean<=BeanColors::PinkPatterned
- $Trainer.party[@partyIndex].changeAmieStats("feedPatternBean")
- $Trainer.beans[bean]-=1
- else
- $Trainer.party[@partyIndex].changeAmieStats("feedRainbowBean")
- $Trainer.beans[bean]-=1
- end
- else
- Kernel.pbMessage(_INTL("You have no beans."))
- end
- else
- Kernel.pbMessage(_INTL("{1} can't eat beans.",$Trainer.party[@partyIndex].name))
- end
- when 2 # Exit
- pbPlayDecisionSE()
- $scene = Scene_Pokegear.new
- end
- return
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement