Change theThat looks cool you made better use of this than I did. How did you display the money and how many Pokemon you caught?
ret[0] = _INTL("text one")
ret[1] = _INTL("text two")
pbFadeOutIn isn't called when you change map (at least in examples). If you mean adding the fade into HUD, change line '@hud = HUD.new(@viewport1) if !@hud' into '@hud = HUD.new(@@viewport1) if !@hud'.WolfPP said:When i change the map, the HUD still keep into the screen (pbFadeOutIn doens't works for it). How can i change that? I mean, i would like to do something like:
When player changes the map; pbfadeoutin (HUD included) and then refresh to the new map.
Thanks in advanced!
First you need to add the space button. After line 'module Input' add line 'SPACE = 40'. Before line 'when Input::SHIFT; return [0x10]' add line 'when Input::SPACE; return [0x20]'. Since Space also works as "confirm", you probably need to remove this feature. To do this, change line 'when Input::C; return [0x43,0x0D,0x20]' into 'when Input::C; return [0x43,0x0D]'.Cardcaptor Sakura said:Can you help me with how to make it so when you press a button such as space, the HUD closes and tapping it again makes it reopen.
Below. I put above the pokémon, since there is no much space left.I was wondering if anyone has had success adding functionality to show when each Pokemon is inflicted with a status condition? I've tried mimicking the methods that are used to show the pokemon icons, however I can only seem to get it to show the status icon for the first pokemon in the party. Any tips? Thanks in advance!
class Spriteset_Map
class HUD
# If you wish to use a background picture, put the image path below, like
# BGPATH="Graphics/Pictures/battleMessage". I recommend a 512x64 picture
BGPATH=""
# Make as 'false' to don't show the blue bar
USEBAR=true
# Make as 'true' to draw the HUD at bottom
DRAWATBOTTOM=false
# Make as 'true' to only show HUD in the pause menu
DRAWONLYINMENU=false
# Make as 'false' to don't show the hp bars
SHOWHPBARS=true
# When above 0, only displays HUD when this switch is on.
SWITCHNUMBER = 0
# Lower this number = more lag.
FRAMESPERUPDATE=2
# The size of drawable content.
BARHEIGHT = 64
def initialize(viewport1)
@viewport1 = viewport1
@sprites = {}
@yposition = DRAWATBOTTOM ? Graphics.height-64 : 0
@statuses = AnimatedBitmap.new(_INTL("Graphics/Pictures/statuses")) #statuses
end
def showHUD?
return (
$Trainer &&
(SWITCHNUMBER<=0 || $game_switches[SWITCHNUMBER]) &&
(!DRAWONLYINMENU || $game_temp.in_menu)
)
end
def create
@sprites.clear
@partySpecies = Array.new(6, 0)
@partyForm = Array.new(6, 0)
@partyIsEgg = Array.new(6, false)
@partyHP = Array.new(6, 0)
@partyTotalHP = Array.new(6, 0)
@partyStatuses = Array.new(6, 0)# statuses
if USEBAR
@sprites["bar"]=IconSprite.new(0,@yposition,@viewport1)
barBitmap = Bitmap.new(Graphics.width,BARHEIGHT)
barRect = Rect.new(0,0,barBitmap.width,barBitmap.height)
barBitmap.fill_rect(barRect,Color.new(128,128,192))
@sprites["bar"].bitmap = barBitmap
end
drawBarFromPath = BGPATH != ""
if drawBarFromPath
@sprites["bgbar"]=IconSprite.new(0,@yposition,@viewport1)
@sprites["bgbar"].setBitmap(BGPATH)
end
@currentTexts = textsDefined
drawText
for i in 0...6
x = 16+64*i
y = @yposition-8
y-=8 if SHOWHPBARS
@sprites["pokeicon#{i}"]=IconSprite.new(x,y,@viewport1)
end
refreshPartyIcons
if SHOWHPBARS
borderWidth = 36
borderHeight = 10
fillWidth = 32
fillHeight = 6
for i in 0...6
x=64*i+48
y=@yposition+55
@sprites["hpbarborder#{i}"] = BitmapSprite.new(
borderWidth,borderHeight,@viewport1
)
@sprites["hpbarborder#{i}"].x = x-borderWidth/2
@sprites["hpbarborder#{i}"].y = y-borderHeight/2
@sprites["hpbarborder#{i}"].bitmap.fill_rect(
Rect.new(0,0,borderWidth,borderHeight),
Color.new(32,32,32)
)
@sprites["hpbarborder#{i}"].bitmap.fill_rect(
(borderWidth-fillWidth)/2,
(borderHeight-fillHeight)/2,
fillWidth,
fillHeight,
Color.new(96,96,96)
)
@sprites["hpbarborder#{i}"].visible = false
@sprites["hpbarfill#{i}"] = BitmapSprite.new(
fillWidth,fillHeight,@viewport1
)
@sprites["hpbarfill#{i}"].x = x-fillWidth/2
@sprites["hpbarfill#{i}"].y = y-fillHeight/2
#statuses
@sprites["statuses#{i}"] = BitmapSprite.new(44,16,@viewport1)
@sprites["statuses#{i}"].x = 22+64*i
@sprites["statuses#{i}"].y = @yposition+16
end
refreshHPBars
end
for sprite in @sprites.values
sprite.z+=600
end
end
def drawText
baseColor=Color.new(72,72,72)
shadowColor=Color.new(160,160,160)
if @sprites.include?("overlay")
@sprites["overlay"].bitmap.clear
else
width = Graphics.width
@sprites["overlay"] = BitmapSprite.new(width,BARHEIGHT,@viewport1)
@sprites["overlay"].y = @yposition
end
xposition = Graphics.width-64
textPositions=[
[@currentTexts[0],xposition,0,2,baseColor,shadowColor],
[@currentTexts[1],xposition,32,2,baseColor,shadowColor]
]
pbSetSystemFont(@sprites["overlay"].bitmap)
pbDrawTextPositions(@sprites["overlay"].bitmap,textPositions)
end
# Note that this method is called on each refresh, but the texts
# only will be redrawed if any character change.
def textsDefined
ret=[]
ret[0] = _INTL("text one")
ret[1] = _INTL("text two")
return ret
end
def refreshPartyIcons
for i in 0...6
partyMemberExists = $Trainer.party.size > i
partySpecie = 0
partyForm = 0
partyIsEgg = false
if partyMemberExists
partySpecie = $Trainer.party[i].species
partyForm = $Trainer.party[i].form
partyIsEgg = $Trainer.party[i].egg?
end
refresh = (
@partySpecies[i]!=partySpecie ||
@partyForm[i]!=partyForm ||
@partyIsEgg[i]!=partyIsEgg
)
if refresh
@partySpecies[i] = partySpecie
@partyForm[i] = partyForm
@partyIsEgg[i] = partyIsEgg
if partyMemberExists
pokemonIconFile = pbPokemonIconFile($Trainer.party[i])
@sprites["pokeicon#{i}"].setBitmap(pokemonIconFile)
@sprites["pokeicon#{i}"].src_rect=Rect.new(0,0,64,64)
end
@sprites["pokeicon#{i}"].visible = partyMemberExists
end
end
end
def refreshHPBars
for i in 0...6
hp = 0
totalhp = 0
hasHP = i<$Trainer.party.size && !$Trainer.party[i].egg?
if hasHP
hp = $Trainer.party[i].hp
totalhp = $Trainer.party[i].totalhp
end
lastTimeWasHP = @partyTotalHP[i] != 0
@sprites["hpbarborder#{i}"].visible = hasHP if lastTimeWasHP != hasHP
redrawFill = hp != @partyHP[i] || totalhp != @partyTotalHP[i]
if redrawFill
@partyHP[i] = hp
@partyTotalHP[i] = totalhp
@sprites["hpbarfill#{i}"].bitmap.clear
width = @sprites["hpbarfill#{i}"].bitmap.width
height = @sprites["hpbarfill#{i}"].bitmap.height
fillAmount = (hp==0 || totalhp==0) ? 0 : hp*width/totalhp
# Always show a bit of HP when alive
fillAmount = 1 if fillAmount==0 && hp>0
if fillAmount > 0
hpColors=nil
if hp<=(totalhp/4).floor
hpColors = [Color.new(240,80,32),Color.new(168,48,56)] # Red
elsif hp<=(totalhp/2).floor
hpColors = [Color.new(248,184,0),Color.new(184,112,0)] # Orange
else
hpColors = [Color.new(24,192,32),Color.new(0,144,0)] # Green
end
shadowHeight = 2
rect = Rect.new(0,0,fillAmount,shadowHeight)
@sprites["hpbarfill#{i}"].bitmap.fill_rect(rect, hpColors[1])
rect = Rect.new(0,shadowHeight,fillAmount,height-shadowHeight)
@sprites["hpbarfill#{i}"].bitmap.fill_rect(rect, hpColors[0])
end
end
#statuses
status = i<$Trainer.party.size ? $Trainer.party[i].status : 0
redrawStatuses = status != @partyStatuses[i]
if redrawStatuses
@partyStatuses[i] = status
@sprites["statuses#{i}"].bitmap.clear
if @partyStatuses[i] >= 0
rect = Rect.new(
0,
16*(@partyStatuses[i]-1),
@sprites["statuses#{i}"].bitmap.width,
@sprites["statuses#{i}"].bitmap.height
)
@sprites["statuses#{i}"].bitmap.blt(0,0,@statuses.bitmap,rect)
end
end
end
end
def update
if showHUD?
if @sprites.empty?
create
else
updateHUDContent = (
FRAMESPERUPDATE<=1 || Graphics.frame_count%FRAMESPERUPDATE==0
)
if updateHUDContent
newTexts = textsDefined
if @currentTexts != newTexts
@currentTexts = newTexts
drawText
end
refreshPartyIcons
refreshHPBars if SHOWHPBARS
end
end
pbUpdateSpriteHash(@sprites)
else
dispose if [email protected]?
end
end
def dispose
pbDisposeSpriteHash(@sprites)
@statuses.dispose #statuses
end
end
alias :initializeOldFL :initialize
alias :disposeOldFL :dispose
alias :updateOldFL :update
def initialize(map=nil)
initializeOldFL(map)
end
def dispose
@hud.dispose if @hud
disposeOldFL
end
def update
updateOldFL
@hud = HUD.new(@viewport1) if !@hud
@hud.update
end
end
Below. I put above the pokémon, since there is no much space left.
Spoiler:
Code:class Spriteset_Map class HUD # If you wish to use a background picture, put the image path below, like # BGPATH="Graphics/Pictures/battleMessage". I recommend a 512x64 picture BGPATH="" # Make as 'false' to don't show the blue bar USEBAR=true # Make as 'true' to draw the HUD at bottom DRAWATBOTTOM=false # Make as 'true' to only show HUD in the pause menu DRAWONLYINMENU=false # Make as 'false' to don't show the hp bars SHOWHPBARS=true # When above 0, only displays HUD when this switch is on. SWITCHNUMBER = 0 # Lower this number = more lag. FRAMESPERUPDATE=2 # The size of drawable content. BARHEIGHT = 64 def initialize(viewport1) @viewport1 = viewport1 @sprites = {} @yposition = DRAWATBOTTOM ? Graphics.height-64 : 0 @statuses = AnimatedBitmap.new(_INTL("Graphics/Pictures/statuses")) #statuses end def showHUD? return ( $Trainer && (SWITCHNUMBER<=0 || $game_switches[SWITCHNUMBER]) && (!DRAWONLYINMENU || $game_temp.in_menu) ) end def create @sprites.clear @partySpecies = Array.new(6, 0) @partyForm = Array.new(6, 0) @partyIsEgg = Array.new(6, false) @partyHP = Array.new(6, 0) @partyTotalHP = Array.new(6, 0) @partyStatuses = Array.new(6, 0)# statuses if USEBAR @sprites["bar"]=IconSprite.new(0,@yposition,@viewport1) barBitmap = Bitmap.new(Graphics.width,BARHEIGHT) barRect = Rect.new(0,0,barBitmap.width,barBitmap.height) barBitmap.fill_rect(barRect,Color.new(128,128,192)) @sprites["bar"].bitmap = barBitmap end drawBarFromPath = BGPATH != "" if drawBarFromPath @sprites["bgbar"]=IconSprite.new(0,@yposition,@viewport1) @sprites["bgbar"].setBitmap(BGPATH) end @currentTexts = textsDefined drawText for i in 0...6 x = 16+64*i y = @yposition-8 y-=8 if SHOWHPBARS @sprites["pokeicon#{i}"]=IconSprite.new(x,y,@viewport1) end refreshPartyIcons if SHOWHPBARS borderWidth = 36 borderHeight = 10 fillWidth = 32 fillHeight = 6 for i in 0...6 x=64*i+48 y=@yposition+55 @sprites["hpbarborder#{i}"] = BitmapSprite.new( borderWidth,borderHeight,@viewport1 ) @sprites["hpbarborder#{i}"].x = x-borderWidth/2 @sprites["hpbarborder#{i}"].y = y-borderHeight/2 @sprites["hpbarborder#{i}"].bitmap.fill_rect( Rect.new(0,0,borderWidth,borderHeight), Color.new(32,32,32) ) @sprites["hpbarborder#{i}"].bitmap.fill_rect( (borderWidth-fillWidth)/2, (borderHeight-fillHeight)/2, fillWidth, fillHeight, Color.new(96,96,96) ) @sprites["hpbarborder#{i}"].visible = false @sprites["hpbarfill#{i}"] = BitmapSprite.new( fillWidth,fillHeight,@viewport1 ) @sprites["hpbarfill#{i}"].x = x-fillWidth/2 @sprites["hpbarfill#{i}"].y = y-fillHeight/2 #statuses @sprites["statuses#{i}"] = BitmapSprite.new(44,16,@viewport1) @sprites["statuses#{i}"].x = 22+64*i @sprites["statuses#{i}"].y = @yposition+16 end refreshHPBars end for sprite in @sprites.values sprite.z+=600 end end def drawText baseColor=Color.new(72,72,72) shadowColor=Color.new(160,160,160) if @sprites.include?("overlay") @sprites["overlay"].bitmap.clear else width = Graphics.width @sprites["overlay"] = BitmapSprite.new(width,BARHEIGHT,@viewport1) @sprites["overlay"].y = @yposition end xposition = Graphics.width-64 textPositions=[ [@currentTexts[0],xposition,0,2,baseColor,shadowColor], [@currentTexts[1],xposition,32,2,baseColor,shadowColor] ] pbSetSystemFont(@sprites["overlay"].bitmap) pbDrawTextPositions(@sprites["overlay"].bitmap,textPositions) end # Note that this method is called on each refresh, but the texts # only will be redrawed if any character change. def textsDefined ret=[] ret[0] = _INTL("text one") ret[1] = _INTL("text two") return ret end def refreshPartyIcons for i in 0...6 partyMemberExists = $Trainer.party.size > i partySpecie = 0 partyForm = 0 partyIsEgg = false if partyMemberExists partySpecie = $Trainer.party[i].species partyForm = $Trainer.party[i].form partyIsEgg = $Trainer.party[i].egg? end refresh = ( @partySpecies[i]!=partySpecie || @partyForm[i]!=partyForm || @partyIsEgg[i]!=partyIsEgg ) if refresh @partySpecies[i] = partySpecie @partyForm[i] = partyForm @partyIsEgg[i] = partyIsEgg if partyMemberExists pokemonIconFile = pbPokemonIconFile($Trainer.party[i]) @sprites["pokeicon#{i}"].setBitmap(pokemonIconFile) @sprites["pokeicon#{i}"].src_rect=Rect.new(0,0,64,64) end @sprites["pokeicon#{i}"].visible = partyMemberExists end end end def refreshHPBars for i in 0...6 hp = 0 totalhp = 0 hasHP = i<$Trainer.party.size && !$Trainer.party[i].egg? if hasHP hp = $Trainer.party[i].hp totalhp = $Trainer.party[i].totalhp end lastTimeWasHP = @partyTotalHP[i] != 0 @sprites["hpbarborder#{i}"].visible = hasHP if lastTimeWasHP != hasHP redrawFill = hp != @partyHP[i] || totalhp != @partyTotalHP[i] if redrawFill @partyHP[i] = hp @partyTotalHP[i] = totalhp @sprites["hpbarfill#{i}"].bitmap.clear width = @sprites["hpbarfill#{i}"].bitmap.width height = @sprites["hpbarfill#{i}"].bitmap.height fillAmount = (hp==0 || totalhp==0) ? 0 : hp*width/totalhp # Always show a bit of HP when alive fillAmount = 1 if fillAmount==0 && hp>0 if fillAmount > 0 hpColors=nil if hp<=(totalhp/4).floor hpColors = [Color.new(240,80,32),Color.new(168,48,56)] # Red elsif hp<=(totalhp/2).floor hpColors = [Color.new(248,184,0),Color.new(184,112,0)] # Orange else hpColors = [Color.new(24,192,32),Color.new(0,144,0)] # Green end shadowHeight = 2 rect = Rect.new(0,0,fillAmount,shadowHeight) @sprites["hpbarfill#{i}"].bitmap.fill_rect(rect, hpColors[1]) rect = Rect.new(0,shadowHeight,fillAmount,height-shadowHeight) @sprites["hpbarfill#{i}"].bitmap.fill_rect(rect, hpColors[0]) end end #statuses status = i<$Trainer.party.size ? $Trainer.party[i].status : 0 redrawStatuses = status != @partyStatuses[i] if redrawStatuses @partyStatuses[i] = status @sprites["statuses#{i}"].bitmap.clear if @partyStatuses[i] >= 0 rect = Rect.new( 0, 16*(@partyStatuses[i]-1), @sprites["statuses#{i}"].bitmap.width, @sprites["statuses#{i}"].bitmap.height ) @sprites["statuses#{i}"].bitmap.blt(0,0,@statuses.bitmap,rect) end end end end def update if showHUD? if @sprites.empty? create else updateHUDContent = ( FRAMESPERUPDATE<=1 || Graphics.frame_count%FRAMESPERUPDATE==0 ) if updateHUDContent newTexts = textsDefined if @currentTexts != newTexts @currentTexts = newTexts drawText end refreshPartyIcons refreshHPBars if SHOWHPBARS end end pbUpdateSpriteHash(@sprites) else dispose if [email protected]? end end def dispose pbDisposeSpriteHash(@sprites) @statuses.dispose #statuses end end alias :initializeOldFL :initialize alias :disposeOldFL :dispose alias :updateOldFL :update def initialize(map=nil) initializeOldFL(map) end def dispose @hud.dispose if @hud disposeOldFL end def update updateOldFL @hud = HUD.new(@viewport1) if !@hud @hud.update end end
#===============================================================================
BURNTONE = [204,51,51,50]
POISONTONE = [153,102,204,50]
PARALYSISTONE = [255,255,153,50]
FREEZETONE = [153,204,204,50]
SLEEPTONE = [0,0,0,0]
#===============================================================================
#===============================================================================
# * Script for when a pokemon gets a status condicion
#===============================================================================
class DependentEventSprites
attr_accessor :sprites
def update
if $PokemonTemp.dependentEvents.lastUpdate!=@lastUpdate
refresh
@lastUpdate=$PokemonTemp.dependentEvents.lastUpdate
end
for sprite in @sprites
sprite.update
end
for i in [email protected]
pbDayNightTint(@sprites[i])
if $game_switches[TOGGLE_FOLLOWING] && $Trainer.party[0] &&
$Trainer.party[0].hp>0
events=$PokemonTemp.dependentEvents
case $Trainer.party[0].status
when PBStatuses::BURN;@sprites[i].tone.set(@sprites[i].tone.red+BURNTONE[0],@sprites[i].tone.green+BURNTONE[1],@sprites[i].tone.blue+BURNTONE[2],@sprites[i].tone.gray+BURNTONE[3])
when PBStatuses::POISON;@sprites[i].tone.set(@sprites[i].tone.red+POISONTONE[0],@sprites[i].tone.green+POISONTONE[1],@sprites[i].tone.blue+POISONTONE[2],@sprites[i].tone.gray+POISONTONE[3])
when PBStatuses::PARALYSIS;@sprites[i].tone.set(@sprites[i].tone.red+PARALYSISTONE[0],@sprites[i].tone.green+PARALYSISTONE[1],@sprites[i].tone.blue+PARALYSISTONE[2],@sprites[i].tone.gray+PARALYSISTONE[3])
when PBStatuses::FROZEN;@sprites[i].tone.set(@sprites[i].tone.red+FREEZETONE[0],@sprites[i].tone.green+FREEZETONE[1],@sprites[i].tone.blue+FREEZETONE[2],@sprites[i].tone.gray+FREEZETONE[3])
when PBStatuses::SLEEP;@sprites[i].tone.set(@sprites[i].tone.red+SLEEPTONE[0],@sprites[i].tone.green+SLEEPTONE[1],@sprites[i].tone.blue+SLEEPTONE[2],@sprites[i].tone.gray+SLEEPTONE[3])
end
end
end
end
end
[@currentTexts[2],xpos,ypos,2,baseColor,shadowColor]
ret[2] = $game_map.name
Take note than there is no tone for sleep. Anyway, here the script:FL, like we have into Following Pokémon Script, about status into overworld:
Spoiler:Code:#=============================================================================== BURNTONE = [204,51,51,50] POISONTONE = [153,102,204,50] PARALYSISTONE = [255,255,153,50] FREEZETONE = [153,204,204,50] SLEEPTONE = [0,0,0,0] #=============================================================================== #=============================================================================== # * Script for when a pokemon gets a status condicion #=============================================================================== class DependentEventSprites attr_accessor :sprites def update if $PokemonTemp.dependentEvents.lastUpdate!=@lastUpdate refresh @lastUpdate=$PokemonTemp.dependentEvents.lastUpdate end for sprite in @sprites sprite.update end for i in [email protected] pbDayNightTint(@sprites[i]) if $game_switches[TOGGLE_FOLLOWING] && $Trainer.party[0] && $Trainer.party[0].hp>0 events=$PokemonTemp.dependentEvents case $Trainer.party[0].status when PBStatuses::BURN;@sprites[i].tone.set(@sprites[i].tone.red+BURNTONE[0],@sprites[i].tone.green+BURNTONE[1],@sprites[i].tone.blue+BURNTONE[2],@sprites[i].tone.gray+BURNTONE[3]) when PBStatuses::POISON;@sprites[i].tone.set(@sprites[i].tone.red+POISONTONE[0],@sprites[i].tone.green+POISONTONE[1],@sprites[i].tone.blue+POISONTONE[2],@sprites[i].tone.gray+POISONTONE[3]) when PBStatuses::PARALYSIS;@sprites[i].tone.set(@sprites[i].tone.red+PARALYSISTONE[0],@sprites[i].tone.green+PARALYSISTONE[1],@sprites[i].tone.blue+PARALYSISTONE[2],@sprites[i].tone.gray+PARALYSISTONE[3]) when PBStatuses::FROZEN;@sprites[i].tone.set(@sprites[i].tone.red+FREEZETONE[0],@sprites[i].tone.green+FREEZETONE[1],@sprites[i].tone.blue+FREEZETONE[2],@sprites[i].tone.gray+FREEZETONE[3]) when PBStatuses::SLEEP;@sprites[i].tone.set(@sprites[i].tone.red+SLEEPTONE[0],@sprites[i].tone.green+SLEEPTONE[1],@sprites[i].tone.blue+SLEEPTONE[2],@sprites[i].tone.gray+SLEEPTONE[3]) end end end end end
Is possible to put to color the icon sprite too using 'tone' code instead showing status condicion icon?
Thank you!
class Spriteset_Map
class HUD
# If you wish to use a background picture, put the image path below, like
# BGPATH="Graphics/Pictures/battleMessage". I recommend a 512x64 picture
BGPATH=""
# Make as 'false' to don't show the blue bar
USEBAR=true
# Make as 'true' to draw the HUD at bottom
DRAWATBOTTOM=false
# Make as 'true' to only show HUD in the pause menu
DRAWONLYINMENU=false
# Make as 'false' to don't show the hp bars
SHOWHPBARS=true
# When above 0, only displays HUD when this switch is on.
SWITCHNUMBER = 0
# Lower this number = more lag.
FRAMESPERUPDATE=2
# The size of drawable content.
BARHEIGHT = 64
def initialize(viewport1)
@viewport1 = viewport1
@sprites = {}
@yposition = DRAWATBOTTOM ? Graphics.height-64 : 0
@statuses = AnimatedBitmap.new(_INTL("Graphics/Pictures/statuses")) #statuses
@toneArrayPerStatus = [ #statuses
Tone.new(0,0,0,0), # Normal
Tone.new(0,0,0,0), # Sleep
Tone.new(153,102,204,50), # Poison
Tone.new(204,51,51,50), # Burn
Tone.new(255,255,153,50), # Paralysis
Tone.new(153,204,204,50) # Freeze
]
end
def showHUD?
return (
$Trainer &&
(SWITCHNUMBER<=0 || $game_switches[SWITCHNUMBER]) &&
(!DRAWONLYINMENU || $game_temp.in_menu)
)
end
def create
@sprites.clear
@partySpecies = Array.new(6, 0)
@partyForm = Array.new(6, 0)
@partyIsEgg = Array.new(6, false)
@partyHP = Array.new(6, 0)
@partyTotalHP = Array.new(6, 0)
@partyStatuses = Array.new(6, 0)# statuses
if USEBAR
@sprites["bar"]=IconSprite.new(0,@yposition,@viewport1)
barBitmap = Bitmap.new(Graphics.width,BARHEIGHT)
barRect = Rect.new(0,0,barBitmap.width,barBitmap.height)
barBitmap.fill_rect(barRect,Color.new(128,128,192))
@sprites["bar"].bitmap = barBitmap
end
drawBarFromPath = BGPATH != ""
if drawBarFromPath
@sprites["bgbar"]=IconSprite.new(0,@yposition,@viewport1)
@sprites["bgbar"].setBitmap(BGPATH)
end
@currentTexts = textsDefined
drawText
for i in 0...6
x = 16+64*i
y = @yposition-8
y-=8 if SHOWHPBARS
@sprites["pokeicon#{i}"]=IconSprite.new(x,y,@viewport1)
end
refreshPartyIcons
if SHOWHPBARS
borderWidth = 36
borderHeight = 10
fillWidth = 32
fillHeight = 6
for i in 0...6
x=64*i+48
y=@yposition+55
@sprites["hpbarborder#{i}"] = BitmapSprite.new(
borderWidth,borderHeight,@viewport1
)
@sprites["hpbarborder#{i}"].x = x-borderWidth/2
@sprites["hpbarborder#{i}"].y = y-borderHeight/2
@sprites["hpbarborder#{i}"].bitmap.fill_rect(
Rect.new(0,0,borderWidth,borderHeight),
Color.new(32,32,32)
)
@sprites["hpbarborder#{i}"].bitmap.fill_rect(
(borderWidth-fillWidth)/2,
(borderHeight-fillHeight)/2,
fillWidth,
fillHeight,
Color.new(96,96,96)
)
@sprites["hpbarborder#{i}"].visible = false
@sprites["hpbarfill#{i}"] = BitmapSprite.new(
fillWidth,fillHeight,@viewport1
)
@sprites["hpbarfill#{i}"].x = x-fillWidth/2
@sprites["hpbarfill#{i}"].y = y-fillHeight/2
#statuses
#@sprites["statuses#{i}"] = BitmapSprite.new(44,16,@viewport1)
#@sprites["statuses#{i}"].x = 22+64*i
#@sprites["statuses#{i}"].y = @yposition+16
end
refreshHPBars
end
for sprite in @sprites.values
sprite.z+=600
end
end
def drawText
baseColor=Color.new(72,72,72)
shadowColor=Color.new(160,160,160)
if @sprites.include?("overlay")
@sprites["overlay"].bitmap.clear
else
width = Graphics.width
@sprites["overlay"] = BitmapSprite.new(width,BARHEIGHT,@viewport1)
@sprites["overlay"].y = @yposition
end
xposition = Graphics.width-64
textPositions=[
[@currentTexts[0],xposition,0,2,baseColor,shadowColor],
[@currentTexts[1],xposition,32,2,baseColor,shadowColor]
]
pbSetSystemFont(@sprites["overlay"].bitmap)
pbDrawTextPositions(@sprites["overlay"].bitmap,textPositions)
end
# Note that this method is called on each refresh, but the texts
# only will be redrawed if any character change.
def textsDefined
ret=[]
ret[0] = _INTL("text one")
ret[1] = _INTL("text two")
return ret
end
def refreshPartyIcons
for i in 0...6
partyMemberExists = $Trainer.party.size > i
partySpecie = 0
partyForm = 0
partyIsEgg = false
if partyMemberExists
partySpecie = $Trainer.party[i].species
partyForm = $Trainer.party[i].form
partyIsEgg = $Trainer.party[i].egg?
end
refresh = (
@partySpecies[i]!=partySpecie ||
@partyForm[i]!=partyForm ||
@partyIsEgg[i]!=partyIsEgg
)
if refresh
@partySpecies[i] = partySpecie
@partyForm[i] = partyForm
@partyIsEgg[i] = partyIsEgg
if partyMemberExists
pokemonIconFile = pbPokemonIconFile($Trainer.party[i])
@sprites["pokeicon#{i}"].setBitmap(pokemonIconFile)
@sprites["pokeicon#{i}"].src_rect=Rect.new(0,0,64,64)
end
@sprites["pokeicon#{i}"].visible = partyMemberExists
end
end
end
def refreshHPBars
for i in 0...6
hp = 0
totalhp = 0
hasHP = i<$Trainer.party.size && !$Trainer.party[i].egg?
if hasHP
hp = $Trainer.party[i].hp
totalhp = $Trainer.party[i].totalhp
end
lastTimeWasHP = @partyTotalHP[i] != 0
@sprites["hpbarborder#{i}"].visible = hasHP if lastTimeWasHP != hasHP
redrawFill = hp != @partyHP[i] || totalhp != @partyTotalHP[i]
if redrawFill
@partyHP[i] = hp
@partyTotalHP[i] = totalhp
@sprites["hpbarfill#{i}"].bitmap.clear
width = @sprites["hpbarfill#{i}"].bitmap.width
height = @sprites["hpbarfill#{i}"].bitmap.height
fillAmount = (hp==0 || totalhp==0) ? 0 : hp*width/totalhp
# Always show a bit of HP when alive
fillAmount = 1 if fillAmount==0 && hp>0
if fillAmount > 0
hpColors=nil
if hp<=(totalhp/4).floor
hpColors = [Color.new(240,80,32),Color.new(168,48,56)] # Red
elsif hp<=(totalhp/2).floor
hpColors = [Color.new(248,184,0),Color.new(184,112,0)] # Orange
else
hpColors = [Color.new(24,192,32),Color.new(0,144,0)] # Green
end
shadowHeight = 2
rect = Rect.new(0,0,fillAmount,shadowHeight)
@sprites["hpbarfill#{i}"].bitmap.fill_rect(rect, hpColors[1])
rect = Rect.new(0,shadowHeight,fillAmount,height-shadowHeight)
@sprites["hpbarfill#{i}"].bitmap.fill_rect(rect, hpColors[0])
end
end
#statuses
status = i<$Trainer.party.size ? $Trainer.party[i].status : 0
redrawStatuses = status != @partyStatuses[i]
if redrawStatuses
@partyStatuses[i] = status
#@sprites["statuses#{i}"].bitmap.clear
#if @partyStatuses[i] >= 0
# rect = Rect.new(
# 0,
# 16*(@partyStatuses[i]-1),
# @sprites["statuses#{i}"].bitmap.width,
# @sprites["statuses#{i}"].bitmap.height
# )
# @sprites["statuses#{i}"].bitmap.blt(0,0,@statuses.bitmap,rect)
#end
@sprites["pokeicon#{i}"].tone = @toneArrayPerStatus[@partyStatuses[i]] #statuses
end
end
end
def update
if showHUD?
if @sprites.empty?
create
else
updateHUDContent = (
FRAMESPERUPDATE<=1 || Graphics.frame_count%FRAMESPERUPDATE==0
)
if updateHUDContent
newTexts = textsDefined
if @currentTexts != newTexts
@currentTexts = newTexts
drawText
end
refreshPartyIcons
refreshHPBars if SHOWHPBARS
end
end
pbUpdateSpriteHash(@sprites)
else
dispose if [email protected]?
end
end
def dispose
pbDisposeSpriteHash(@sprites)
@statuses.dispose #statuses
end
end
alias :initializeOldFL :initialize
alias :disposeOldFL :dispose
alias :updateOldFL :update
def initialize(map=nil)
initializeOldFL(map)
end
def dispose
@hud.dispose if @hud
disposeOldFL
end
def update
updateOldFL
@hud = HUD.new(@viewport1) if !@hud
@hud.update
end
end
These screenshots are very cool! Any your change for route name is neat! Thanks for sharing!Thanks a bunch @FL, I managed to sort mine out somewhat after a bit of tinkering.
I added a GPS, if anyone is interested:
first add to currentTexts
Code:[@currentTexts[2],xpos,ypos,2,baseColor,shadowColor]
and then
in def textsDefined add:
Code:ret[2] = $game_map.name
Not sure if I understand. You wish to print the player money and catch count? If so, change.I dont have any idea of scripting :/, how did you put the "$" money symbol and he "caught"?
def textsDefined
ret=[]
ret[0] = _INTL("text one")
ret[1] = _INTL("text two")
return ret
end
def textsDefined
ret=[]
ret[0] = _INTL("$ "+$Trainer.money.to_s)
ret[1] = _INTL("Caught: "+$Trainer.pokedexOwned(0).to_s)
return ret
end
Not sure if I understand. You wish to print the player money and catch count? If so, change.
Code:def textsDefined ret=[] ret[0] = _INTL("text one") ret[1] = _INTL("text two") return ret end
Code:def textsDefined ret=[] ret[0] = _INTL("$ "+$Trainer.money.to_s) ret[1] = _INTL("Caught: "+$Trainer.pokedexOwned(0).to_s) return ret end
The "$" symbol is automatic converted into Pokédollar symbol by the font.
Why can't we use it with Luka's Neo Pause Menu?
This was a affirmation, wasn't?Well. Can you answer my question I asked about an year ago?
#===============================================================================
# * Simple HUD Optimized - by FL (Credits will be apreciated)
#===============================================================================
#
# This script is for Pokémon Essentials. It displays a simple HUD with the
# party icons, HP Bars and some small text.
#
#===============================================================================
#
# To this script works, put it above main.
#
#===============================================================================
class Spriteset_Map
class HUD
# If you wish to use a background picture, put the image path below, like
# BGPATH="Graphics/Pictures/battleMessage". I recommend a 512x64 picture
BGPATH="Graphcs/Pictures/bgbar.png"
# Make as 'false' to don't show the blue bar
USEBAR=false
# Make as 'true' to draw the HUD at bottom
DRAWATBOTTOM=false
# Make as 'true' to only show HUD in the pause menu
DRAWONLYINMENU=false
# Make as 'false' to don't show the hp bars
SHOWHPBARS=true
# When above 0, only displays HUD when this switch is on.
SWITCHNUMBER = 0
# Lower this number = more lag.
FRAMESPERUPDATE=2
# The size of drawable content.
BARHEIGHT = 64
def initialize(viewport1)
@viewport1 = viewport1
@sprites = {}
@yposition = DRAWATBOTTOM ? Graphics.height-64 : 0
end
def showHUD?
return (
$Trainer &&
(SWITCHNUMBER<=0 || $game_switches[SWITCHNUMBER]) &&
(!DRAWONLYINMENU || $game_temp.in_menu)
)
end
def create
@sprites.clear
@partySpecies = Array.new(6, 0)
@partyForm = Array.new(6, 0)
@partyIsEgg = Array.new(6, false)
@partyHP = Array.new(6, 0)
@partyTotalHP = Array.new(6, 0)
if USEBAR
@sprites["bar"]=IconSprite.new(0,@yposition,@viewport1)
barBitmap = Bitmap.new(Graphics.width,BARHEIGHT)
barRect = Rect.new(0,0,barBitmap.width,barBitmap.height)
barBitmap.fill_rect(barRect,Color.new(128,128,192))
@sprites["bar"].bitmap = barBitmap
end
drawBarFromPath = BGPATH != ""
if drawBarFromPath
@sprites["bgbar"]=IconSprite.new(0,@yposition,@viewport1)
@sprites["bgbar"].setBitmap(BGPATH)
end
@currentTexts = textsDefined
drawText
for i in 0...6
x = 16+64*i
y = @yposition-8
y-=8 if SHOWHPBARS
@sprites["pokeicon#{i}"]=IconSprite.new(x,y,@viewport1)
end
refreshPartyIcons
if SHOWHPBARS
borderWidth = 36
borderHeight = 10
fillWidth = 32
fillHeight = 6
for i in 0...6
x=64*i+48
y=@yposition+55
@sprites["hpbarborder#{i}"] = BitmapSprite.new(
borderWidth,borderHeight,@viewport1
)
@sprites["hpbarborder#{i}"].x = x-borderWidth/2
@sprites["hpbarborder#{i}"].y = y-borderHeight/2
@sprites["hpbarborder#{i}"].bitmap.fill_rect(
Rect.new(0,0,borderWidth,borderHeight),
Color.new(32,32,32)
)
@sprites["hpbarborder#{i}"].bitmap.fill_rect(
(borderWidth-fillWidth)/2,
(borderHeight-fillHeight)/2,
fillWidth,
fillHeight,
Color.new(96,96,96)
)
@sprites["hpbarborder#{i}"].visible = false
@sprites["hpbarfill#{i}"] = BitmapSprite.new(
fillWidth,fillHeight,@viewport1
)
@sprites["hpbarfill#{i}"].x = x-fillWidth/2
@sprites["hpbarfill#{i}"].y = y-fillHeight/2
end
refreshHPBars
end
for sprite in @sprites.values
sprite.z+=600
end
end
def drawText
baseColor=Color.new(72,72,72)
shadowColor=Color.new(160,160,160)
if @sprites.include?("overlay")
@sprites["overlay"].bitmap.clear
else
width = Graphics.width
@sprites["overlay"] = BitmapSprite.new(width,BARHEIGHT,@viewport1)
@sprites["overlay"].y = @yposition
end
xposition = Graphics.width-64
textPositions=[
[@currentTexts[0],xposition,0,2,baseColor,shadowColor],
[@currentTexts[1],xposition,32,2,baseColor,shadowColor]
]
pbSetSystemFont(@sprites["overlay"].bitmap)
pbDrawTextPositions(@sprites["overlay"].bitmap,textPositions)
end
# Note that this method is called on each refresh, but the texts
# only will be redrawed if any character change.
def textsDefined
ret=[]
ret[0] = _INTL("${1}",pbCommaNumber($Trainer.money))
ret[1] = _INTL("Badges:")
return ret
end
def refreshPartyIcons
for i in 0...6
partyMemberExists = $Trainer.party.size > i
partySpecie = 0
partyForm = 0
partyIsEgg = false
if partyMemberExists
partySpecie = $Trainer.party[i].species
partyForm = $Trainer.party[i].form
partyIsEgg = $Trainer.party[i].egg?
end
refresh = (
@partySpecies[i]!=partySpecie ||
@partyForm[i]!=partyForm ||
@partyIsEgg[i]!=partyIsEgg
)
if refresh
@partySpecies[i] = partySpecie
@partyForm[i] = partyForm
@partyIsEgg[i] = partyIsEgg
if partyMemberExists
pokemonIconFile = pbPokemonIconFile($Trainer.party[i])
@sprites["pokeicon#{i}"].setBitmap(pokemonIconFile)
@sprites["pokeicon#{i}"].src_rect=Rect.new(0,0,64,64)
end
@sprites["pokeicon#{i}"].visible = partyMemberExists
end
end
end
def refreshHPBars
for i in 0...6
hp = 0
totalhp = 0
hasHP = i<$Trainer.party.size && !$Trainer.party[i].egg?
if hasHP
hp = $Trainer.party[i].hp
totalhp = $Trainer.party[i].totalhp
end
lastTimeWasHP = @partyTotalHP[i] != 0
@sprites["hpbarborder#{i}"].visible = hasHP if lastTimeWasHP != hasHP
redrawFill = hp != @partyHP[i] || totalhp != @partyTotalHP[i]
if redrawFill
@partyHP[i] = hp
@partyTotalHP[i] = totalhp
@sprites["hpbarfill#{i}"].bitmap.clear
width = @sprites["hpbarfill#{i}"].bitmap.width
height = @sprites["hpbarfill#{i}"].bitmap.height
fillAmount = (hp==0 || totalhp==0) ? 0 : hp*width/totalhp
# Always show a bit of HP when alive
fillAmount = 1 if fillAmount==0 && hp>0
if fillAmount > 0
hpColors=nil
if hp<=(totalhp/4).floor
hpColors = [Color.new(240,80,32),Color.new(168,48,56)] # Red
elsif hp<=(totalhp/2).floor
hpColors = [Color.new(248,184,0),Color.new(184,112,0)] # Orange
else
hpColors = [Color.new(24,192,32),Color.new(0,144,0)] # Green
end
shadowHeight = 2
rect = Rect.new(0,0,fillAmount,shadowHeight)
@sprites["hpbarfill#{i}"].bitmap.fill_rect(rect, hpColors[1])
rect = Rect.new(0,shadowHeight,fillAmount,height-shadowHeight)
@sprites["hpbarfill#{i}"].bitmap.fill_rect(rect, hpColors[0])
end
end
end
end
def update
if showHUD?
if @sprites.empty?
create
else
updateHUDContent = (
FRAMESPERUPDATE<=1 || Graphics.frame_count%FRAMESPERUPDATE==0
)
if updateHUDContent
newTexts = textsDefined
if @currentTexts != newTexts
@currentTexts = newTexts
drawText
end
refreshPartyIcons
refreshHPBars if SHOWHPBARS
end
end
pbUpdateSpriteHash(@sprites)
else
dispose if [email protected]?
end
end
def dispose
pbDisposeSpriteHash(@sprites)
end
end
alias :initializeOldFL :initialize
alias :disposeOldFL :dispose
alias :updateOldFL :update
def initialize(map=nil)
initializeOldFL(map)
end
def dispose
@hud.dispose if @hud
disposeOldFL
end
def update
updateOldFL
@hud = HUD.new(@viewport1) if !@hud
@hud.update
end
end