rigbycwts
Hmm, hmm.
- 98
- Posts
- 12
- Years
- Seen Feb 22, 2019
This tutorial implements the Affection, Fullness, and Enjoyment stats. Also includes a toned-down version of Pokemon-Amie.
You know this drill: to avoid breaking codes, set the thread to Printable.
1. Modify PokeBattle_Pokemon:
1.1. In the row where the attr_accessors are located, add these lines:
1.2. Below the changeHappiness(method) function, add the following lines:
1.3. Inside def initialize, below calcStats, add these lines:
2. Modify PokeBattle_Battler:
2.1. Above this line:
add these lines:
2.2. Above the initialize method, add all of these methods:
3. Modify PokeBattle_Battle:
3.1. Find this line inside pbSwitch:
Then replace it with these two lines:
3.2. Find this line inside pbAttackPhase:
Replace it with these two lines:
4. Add the following script below the EBS scripts if you have them, but put it above Main.
5. Modify PScreen_Pokegear to enable Pokemon-Amie.
5.1. Replace the contents of PScreen_Pokegear with this:
Screenshot:
You know this drill: to avoid breaking codes, set the thread to Printable.
1. Modify PokeBattle_Pokemon:
Spoiler:
1.1. In the row where the attr_accessors are located, add these lines:
Code:
attr_accessor(:amie_affection)
attr_accessor(:amie_fullness)
attr_accessor(:amie_enjoyment) # Pokemon-Amie stats
MAXAMIEPOINTS = 255 # Max points that a single Amie/Refresh stat can have
Code:
################################################################################
# Pokemon-Amie/Pokemon Refresh stats.
################################################################################
# Getters - return each stat values in points
def amie_affection
@amie_affection=0 if !@amie_affection
return @amie_affection
end
def amie_fullness
@amie_fullness=0 if !@amie_fullness
return @amie_fullness
end
def amie_enjoyment
@amie_enjoyment=0 if !@amie_enjoyment
return @amie_enjoyment
end
# Setters - sets each stat values in points
def amie_affection=(value)
# Failsafes.
if value > MAXAMIEPOINTS
@amie_affection = MAXAMIEPOINTS
elsif value < 0
@amie_affection = 0
else
@amie_affection = value
end
end
def amie_fullness=(value)
# Failsafes.
if value > MAXAMIEPOINTS
@amie_fullness = MAXAMIEPOINTS
elsif value < 0
@amie_fullness = 0
else
@amie_fullness = value
end
end
def amie_enjoyment=(value)
# Failsafes.
if value > MAXAMIEPOINTS
@amie_enjoyment = MAXAMIEPOINTS
elsif value < 0
@amie_enjoyment = 0
else
@amie_enjoyment = value
end
end
# Converts the points for every Amie stat into an abstracted level.
def getAmieStatLevel(points)
case points
when 0
return 0
when 1...50
return 1
when 50...100
return 2
when 100...150
return 3
when 150...255
return 4
when 255
return 5
end
end
# Returns the Affection level. Needed for other scripts, e.g. evolution methods
def getAffectionLevel
return getAmieStatLevel(@amie_affection)
end
# Changes the happiness of this Pokémon depending on what happened to change it.
# Feel free to add your own methods.
def changeAmieStats(method)
affGain=0
fullGain=0
enjoyGain=0
case method
when "walking" # Walk approx. 50 steps
fullGain=-1
enjoyGain=-1
when "sendInBattle" # Send Pokemon in to a battle
fullGain=-25
enjoyGain=-25
when "feedPlainBean" # Feed Pokémon a whole Plain Bean
affGain=3
fullGain=rand(2)+100
when "feedPatternBean" # Feed Pokémon a whole Pattern Bean
affGain=5
fullGain=rand(2)+100
when "feedRainbowBean" # Feed Pokémon a whole Rainbow Bean
affGain=125
fullGain=rand(2)+100
when "feedMalasada" # Feed Pokemon a malasada (SunMoon) or a Shirogi bread (ColMerc)
fullGain=255
affGain=5
when "feedMalasadaDisliked"
fullGain=255
affGain=3
when "feedMalasadaLiked"
fullGain=255
affGain=10
when "pet" # Pet Pokemon. No spots implemented due to engine limitations.
affGain=rand(2)+2
enjoyGain=rand(20)+20
else
Kernel.pbMessage(_INTL("Unknown stat-changing method."))
end
@amie_affection+=affGain
@amie_affection=[[MAXAMIEPOINTS,@amie_affection].min,0].max
@amie_fullness+=fullGain
@amie_fullness=[[MAXAMIEPOINTS,@amie_fullness].min,0].max
@amie_enjoyment+=enjoyGain
@amie_enjoyment=[[MAXAMIEPOINTS,@amie_enjoyment].min,0].max
end
# Sets the Pokemon's Affection to 0.
# Usually used when traded.
def resetAffection
@amie_affection = 0
end
1.3. Inside def initialize, below calcStats, add these lines:
Code:
@amie_affection=0
@amie_fullness=0
@amie_enjoyment=0
2. Modify PokeBattle_Battler:
Spoiler:
2.1. Above this line:
Code:
def inHyperMode?; return false; end
Code:
attr_accessor :amie_affection
attr_accessor :amie_fullness
attr_accessor :amie_enjoyment
Code:
# Getters - return each stat values in points
def amie_affection
return (@pokemon) ? @pokemon.amie_affection : 0
end
def amie_fullness
return (@pokemon) ? @pokemon.amie_fullness : 0
end
def amie_enjoyment
return (@pokemon) ? @pokemon.amie_enjoyment : 0
end
def getAffectionLevel
return (@pokemon) ? @pokemon.getAmieStatLevel(@pokemon.amie_affection) : 0
end
3. Modify PokeBattle_Battle:
Spoiler:
3.1. Find this line inside pbSwitch:
Code:
pbDisplayBrief(_INTL("{1}, that's enough! Come back!",@battlers[0].name))
Code:
pbDisplayBrief(_INTL("{1}, that's enough! Come back!",@battlers[0].name)) if @battlers[0].getAffectionLevel < 3
pbDisplayBrief(_INTL("Come on back, {1}! You did great out there!",@battlers[0].name)) if @battlers[0].getAffectionLevel >= 3
Code:
pbDisplayBrief(_INTL("{1}, that's enough!\r\nCome back!",i.name))
Code:
pbDisplayBrief(_INTL("{1}, that's enough!\r\nCome back!",i.name)) if i.getAffectionLevel < 3
pbDisplayBrief(_INTL("Come on back, {1}!\r\nYou did great out there!",i.name)) if i.getAffectionLevel >= 3
4. Add the following script below the EBS scripts if you have them, but put it above Main.
Spoiler:
Code:
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
#===============================================================================
# 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(-90,-90)
@sprites["bgmap"].setBitmap(self.pbBackdrop)
@sprites["bgmap"].z=200
@sprites["background"] = IconSprite.new(0,0)
@sprites["background"].setBitmap("Graphics/Pictures/PokeAmie/Choices")
@sprites["background"].z=255
@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("Pokemon-Amie for Essentials"),
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
@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
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 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
Kernel.pbMessage(_INTL("This feature is coming soon."))
when 2 # Exit
pbPlayDecisionSE()
$scene = Scene_Pokegear.new
end
return
end
end
end
5. Modify PScreen_Pokegear to enable Pokemon-Amie.
Spoiler:
5.1. Replace the contents of PScreen_Pokegear with this:
Code:
class PokegearButton < 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
#===============================================================================
# - Scene_Pokegear
#-------------------------------------------------------------------------------
# Modified By Harshboy
# Modified by Peter O.
# Also Modified By OblivionMew
# Overhauled by Maruno
#===============================================================================
class Scene_Pokegear
#-----------------------------------------------------------------------------
# initialize
#-----------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#-----------------------------------------------------------------------------
# main
#-----------------------------------------------------------------------------
def main
commands=[]
# OPTIONS - If you change these, you should also change update_command below.
@cmdMap=-1
@cmdPhone=-1
@cmdAmie=-1
@cmdJukebox=-1
commands[@cmdMap=commands.length]=_INTL("Map")
commands[@cmdPhone=commands.length]=_INTL("Phone") if $PokemonGlobal.phoneNumbers &&
$PokemonGlobal.phoneNumbers.length>0
commands[@cmdJukebox=commands.length]=_INTL("Jukebox")
commands[@cmdAmie=commands.length]=_INTL("Pokemon-Amie") if $Trainer.party.length>0
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@button=AnimatedBitmap.new("Graphics/Pictures/pokegearButton")
@sprites={}
@sprites["background"] = IconSprite.new(0,0)
femback=pbResolveBitmap(sprintf("Graphics/Pictures/pokegearbgf"))
if $Trainer.isFemale? && femback
@sprites["background"].setBitmap("Graphics/Pictures/pokegearbgf")
else
@sprites["background"].setBitmap("Graphics/Pictures/pokegearbg")
end
@sprites["command_window"] = Window_CommandPokemon.new(commands,160)
@sprites["command_window"].visible = false
@sprites["command_window"].index = @menu_index
for i in 0...commands.length
x=118
y=196 - (commands.length*24) + (i*48)
@sprites["button#{i}"]=PokegearButton.new(x,y,commands[i],i,@viewport)
@sprites["button#{i}"].selected=(i==@sprites["command_window"].index)
@sprites["button#{i}"].update
end
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
pbDisposeSpriteHash(@sprites)
end
#-----------------------------------------------------------------------------
# update the scene
#-----------------------------------------------------------------------------
def update
for i in 0...@sprites["command_window"].commands.length
sprite=@sprites["button#{i}"]
sprite.selected=(i==@sprites["command_window"].index) ? true : false
end
pbUpdateSpriteHash(@sprites)
#update command window and the info if it's active
if @sprites["command_window"].active
update_command
return
end
end
#-----------------------------------------------------------------------------
# update the command window
#-----------------------------------------------------------------------------
def update_command
if Input.trigger?(Input::B)
pbPlayCancelSE()
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if @cmdMap>=0 && @sprites["command_window"].index==@cmdMap
pbPlayDecisionSE()
pbShowMap(-1,false)
end
if @cmdPhone>=0 && @sprites["command_window"].index==@cmdPhone
pbPlayDecisionSE()
pbFadeOutIn(99999) {
PokemonPhoneScene.new.start
}
end
if @cmdAmie>=0 && @sprites["command_window"].index==@cmdAmie
pbPlayDecisionSE()
pbFadeOutIn(99999) {
pbChooseNonEggPokemon(1,3)
$scene = PokeAmie_Essentials.new($Trainer.party[pbGet(1)],pbGet(1))
}
end
if @cmdJukebox>=0 && @sprites["command_window"].index==@cmdJukebox
pbPlayDecisionSE()
$scene = Scene_Jukebox.new
end
return
end
end
end
Screenshot:
![[PokeCommunity.com] Pokemon-Amie in Essentials, plus the Affection, Fullness, and Enjoyment stats [PokeCommunity.com] Pokemon-Amie in Essentials, plus the Affection, Fullness, and Enjoyment stats](https://ibin.co/3DHHfm7MSYEf.png)
Last edited: