- 163
- Posts
- 8
- Years
- Seen Feb 15, 2025
Very good.
As CharizardThree3 asked , I decided to share this script that is not complete. In fact, it has an important error that I don't know how to solve.
Maybe some of you can do it, you are much more expert than me.
It is far from working well and being complete. As I am mixing two different scripts it is difficult for me to come up with a solution and probably many things in the script that I share do not work very well and honestly ... I do not know!
But I am sure that here there are many more people who master this better and can help!
What is this?
Basically, what I am trying to do is combine the original region map with the BW version, in that way we can show images when selected
one of the points of the map, to be able to give information, show photographs, etc. (Very much like LETS GO)
How is it used?
I replace the original REGION MAP with this...
Then in SETTINGS, we must put this.
PLACEDESC & PLACEINTEREST : In my case I am not using them, because the information already comes in the image that I designed ...
PLACEICON: This represents the image we will show. The method takes advantage of the BW map icon change function to display an image.
If the point on the map has that name, it will show the "part 1" of the image.
Well, finally we should use these graphics and put them on Graphics/Pictures/Townmap
next to all other region map graphics if they are outside the Townmap folder
https://drive.google.com/open?id=1pPvbeslJH9zC4B9UaFSYN2vyF1UZ9diN
Why doesn't it work quite well?
1. I don't master scripting very well, therefore the position in which the image is displayed changes completely
depending on the position in which you are on the map.
It should look like this ...
But sometimes it looks like this ...
And others like this...
...depending on where my character is.
2. This has made it very difficult to establish the size of the sections of the image BACKINFO (With the sections 1,2,3,4, etc)., given
I never know where they are going to show.
If anyone thinks it can help with this, welcome : D
As CharizardThree3 asked , I decided to share this script that is not complete. In fact, it has an important error that I don't know how to solve.
Maybe some of you can do it, you are much more expert than me.
It is far from working well and being complete. As I am mixing two different scripts it is difficult for me to come up with a solution and probably many things in the script that I share do not work very well and honestly ... I do not know!
But I am sure that here there are many more people who master this better and can help!
What is this?
Basically, what I am trying to do is combine the original region map with the BW version, in that way we can show images when selected
one of the points of the map, to be able to give information, show photographs, etc. (Very much like LETS GO)
How is it used?
I replace the original REGION MAP with this...
Spoiler:
Code:
class MapBottomSpriteRegion < SpriteWrapper
attr_reader :mapname,:maplocation,:mapdesc,:mapinterest
def initialize(viewport=nil)
super(viewport)
@mapname=""
@maplocation=""
@mapdetails=""
@mapdesc=""
@mapinterest=[]
@nonests=false
@thisbitmap=BitmapWrapper.new(Graphics.width,Graphics.height)
pbSetSystemFont(@thisbitmap)
self.y=0
self.x=0
self.bitmap=@thisbitmap
refresh
end
def dispose
@thisbitmap.dispose
super
end
def nonests=(value)
@nonests=value
refresh
end
def mapname=(value)
if @mapname!=value
@mapname=value
refresh
end
end
def mapdesc=(value)
if @mapdesc!=value
@mapdesc=value
refresh
end
end
def maplocation=(value)
if @maplocation!=value
@maplocation=value
refresh
end
end
def mapinterest=(value)
if @mapinterest!=value
@mapinterest=value
refresh
end
end
def mapdetails=(value) # From Wichu
if @mapdetails!=value
@mapdetails=value
refresh
end
end
def refresh
self.bitmap.clear
if @maplocation!=""
imagepos=[[sprintf("Graphics/Pictures/TownMap/mapLocationBox"),-15,350,0,0,-1,-1]]
pbDrawImagePositions(self.bitmap,imagepos)
end
textpos=[
#[@mapname,Graphics.width/2,-2,2,Color.new(248,248,248),Color.new(0,0,0)],
# [@maplocation,Graphics.width/148,354,2,Color.new(248,248,248),Color.new(0,0,0)],
[@mapdetails,Graphics.width-16,354,1,Color.new(248,248,248),Color.new(0,0,0)]
]
textpos.push([@maplocation,18,354,0,Color.new(248,248,248),Color.new(0,0,0)]) if @maplocation!=""
initialx=50
initialy=200
for i in [email protected]
textpos.push([@mapinterest[i],initialx,initialy,0,
Color.new(90,82,82),Color.new(165,165,173)])
initialy+=32
if i==2
initialy=256
initialx=272
end
end
pbDrawTextPositions(self.bitmap,textpos)
drawTextEx(self.bitmap,28*2,50,600,2,@mapdesc,
Color.new(90,82,82),Color.new(165,165,173))
end
end
class PokemonRegionMap_Scene
LEFT = 0
TOP = 0
RIGHT = 29
BOTTOM = 19
SQUAREWIDTH = 16
SQUAREHEIGHT = 16
def initialize(region=-1,wallmap=true)
@region = region
@wallmap = wallmap
end
def pbUpdate
pbUpdateSpriteHash(@sprites)
end
def pbStartScene(aseditor=false,mode=0)
@editor=aseditor
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites={}
pbRgssOpen("Data/townmap.dat","rb"){|f|
@mapdata=Marshal.load(f)
}
playerpos=!$game_map ? nil : pbGetMetadata($game_map.map_id,MetadataMapPosition)
if !playerpos
mapindex=0
@map=@mapdata[0]
@mapX=LEFT
@mapY=TOP
elsif @region>=0 && @region!=playerpos[0] && @mapdata[@region]
mapindex=@region
@map=@mapdata[@region]
@mapX=LEFT
@mapY=TOP
else
mapindex=playerpos[0]
@map=@mapdata[playerpos[0]]
@mapX=playerpos[1]
@mapY=playerpos[2]
mapsize=!$game_map ? nil : pbGetMetadata($game_map.map_id,MetadataMapSize)
if mapsize && mapsize[0] && mapsize[0]>0
sqwidth=mapsize[0]
sqheight=(mapsize[1].length*1.0/mapsize[0]).ceil
if sqwidth>1
@mapX+=($game_player.x*sqwidth/$game_map.width).floor
end
if sqheight>1
@mapY+=($game_player.y*sqheight/$game_map.height).floor
end
end
end
if !@map
Kernel.pbMessage(_INTL("The map data cannot be found."))
return false
end
#@sprites["bg"]=Sprite.new(@viewport)
# @sprites["bg"].bitmap=RPG::Cache.picture("TownMap/townmapup")
#@sprites["bg"].z=999999
addBackgroundOrColoredPlane(@sprites,"background","mapbg",Color.new(0,0,0),@viewport)
@sprites["map"]=IconSprite.new(0,0,@viewport)
@sprites["map"].setBitmap("Graphics/Pictures/TownMap/#{@map[1]}")
#@sprites["map"].x+=(Graphics.width-@sprites["map"].bitmap.width)/2
@sprites["map"].x += (Graphics.width-@sprites["map"].bitmap.width)/1
@sprites["map"].y += (Graphics.height-@sprites["map"].bitmap.height)/1
@sprites["mapsel"]=Sprite.new(@viewport)
@sprites["mapsel"].bitmap=RPG::Cache.picture("TownMap/BACKINFO")
@sprites["mapsel"].z=999999
@sprites["mapsel"].src_rect.set(0,@sprites["mapsel"].bitmap.width*0,
@sprites["mapsel"].bitmap.width,@sprites["mapsel"].bitmap.width)
@sprites["mapsel"].visible=false
# @sprites["map"].y+=(DEFAULTSCREENHEIGHT-@sprites["map"].bitmap.height)/2
for hidden in REGIONMAPEXTRAS
if hidden[0]==mapindex && ((@wallmap && hidden[5]) ||
(!@wallmap && hidden[1]>0 && $game_switches[hidden[1]]))
if !@sprites["map2"]
@sprites["map2"]=BitmapSprite.new(480,320,@viewport)
@sprites["map2"].x=@sprites["map"].x; @sprites["map2"].y=@sprites["map"].y
end
pbDrawImagePositions(@sprites["map2"].bitmap,[
["Graphics/Pictures/TownMap/#{hidden[4]}",hidden[2]*SQUAREWIDTH,hidden[3]*SQUAREHEIGHT,0,0,-1,-1]
])
end
end
@sprites["mapbottom"]=MapBottomSpriteRegion.new(@viewport)
@sprites["mapbottom"].mapname=pbGetMessage(MessageTypes::RegionNames,mapindex)
@sprites["mapbottom"].maplocation=pbGetMapLocation(@mapX,@mapY)
@sprites["mapbottom"].mapdetails=pbGetMapDetails(@mapX,@mapY)
@sprites["mapbottom"].z=999999
mapdesc=""
mapinterest=[]
placeicon=-1
for i in 0...PLACEDESC.length
mapdesc=PLACEDESC[i][1] if @sprites["mapbottom"].maplocation==PLACEDESC[i][0]
end
for i in 0...PLACEINTEREST.length
mapinterest=PLACEINTEREST[i][1] if @sprites["mapbottom"].maplocation==PLACEINTEREST[i][0]
end
for i in 0...PLACEICON.length
placeicon=(PLACEICON[i][1]-1) if @sprites["mapbottom"].maplocation==PLACEICON[i][0]
end
@sprites["mapsel"].src_rect.set(0,@sprites["mapsel"].bitmap.width*placeicon,
@sprites["mapsel"].bitmap.width,@sprites["mapsel"].bitmap.width)
@sprites["mapsel"].visible=(@sprites["mapbottom"].maplocation=="") ? false : true
@sprites["mapsel"].x=-SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2-327
@sprites["mapsel"].y=-SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)-71
@sprites["mapbottom"].mapdesc=mapdesc
@sprites["mapbottom"].mapinterest=mapinterest
@sprites["cursorsel"]=AnimatedSprite.create("Graphics/Pictures/TownMap/mapCursorSel",7,4)
@sprites["cursorsel"].viewport=@viewport
@sprites["cursorsel"].play
@sprites["cursorsel"].x = -SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2
@sprites["cursorsel"].y = -SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2
@sprites["cursorsel"].visible=(@sprites["mapbottom"].maplocation=="") ? false : true
if playerpos && mapindex==playerpos[0]
@sprites["player"]=AnimatedSprite.create("Graphics/Pictures/TownMap/mapPlayer",6,10)
@sprites["player"].viewport=@viewport
@sprites["player"].x = -SQUAREWIDTH/1+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/1
@sprites["player"].y = -SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2
@sprites["player"].play
end
if mode>0
@sprites["overlay"]=BitmapSprite.new(Graphics.width,DEFAULTSCREENHEIGHT,@viewport)
@sprites["overlay"].z=999999
@sprites["overlay"].y=400
pbSetSystemFont(@sprites["overlay"].bitmap)
textfly=[
[_INTL("Fly to where?"),32,346,0,Color.new(255,255,255),Color.new(41,41,41)]
]
pbDrawTextPositions(@sprites["overlay"].bitmap, textfly)
end
@sprites["cursor"]=IconSprite.new(0,0,@viewport)
@sprites["cursor"].setBitmap("Graphics/Pictures/TownMap/mapCursor")
@sprites["cursor"].x = -SQUAREWIDTH/0.5+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/0.5
@sprites["cursor"].y = -SQUAREHEIGHT/0.5+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/0.5
@changed=false
pbFadeInAndShow(@sprites){ pbUpdate }
return true
end
def pbSaveMapData
File.open("PBS/townmap.txt","wb"){|f|
for i in [email protected]
map = @mapdata[i]
return if !map
f.write(sprintf("[%d]\r\n",i))
f.write(sprintf("Name=%s\r\nFilename=%s\r\n",csvquote(map[0]),csvquote(map[1])))
for loc in map[2]
f.write("Point=")
pbWriteCsvRecord(loc,f,[nil,"uussUUUU"])
f.write("\r\n")
end
end
}
end
def pbEndScene
pbFadeOutAndHide(@sprites)
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
def pbGetMapLocation(x,y)
return "" if !@map[2]
for loc in @map[2]
if loc[0]==x && loc[1]==y
if !loc[7] || (!@wallmap && $game_switches[loc[7]])
maploc = pbGetMessageFromHash(MessageTypes::PlaceNames,loc[2])
return @editor ? loc[2] : maploc
else
return ""
end
end
end
return ""
end
def pbChangeMapLocation(x,y)
return if !@editor
return "" if !@map[2]
currentname = ""
currentobj = nil
for loc in @map[2]
if loc[0]==x && loc[1]==y
currentobj = loc
currentname = loc[2]
break
end
end
currentname = Kernel.pbMessageFreeText(_INTL("Set the name for this point."),currentname,false,256) { pbUpdate }
if currentname
if currentobj
currentobj[2] = currentname
else
newobj = [x,y,currentname,""]
@map[2].push(newobj)
end
@changed = true
end
end
def pbGetMapDetails(x,y) # From Wichu, with my help
return "" if !@map[2]
for loc in @map[2]
if loc[0]==x && loc[1]==y
if !loc[7] || (!@wallmap && $game_switches[loc[7]])
mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions,loc[3])
return (@editor) ? loc[3] : mapdesc
else
return ""
end
end
end
return ""
end
def pbGetHealingSpot(x,y)
return nil if !@map[2]
for loc in @map[2]
if loc[0]==x && loc[1]==y
if !loc[4] || !loc[5] || !loc[6]
return nil
else
return [loc[4],loc[5],loc[6]]
end
end
end
return nil
end
def mapZoom
@sprites["map"].ox=@mapX*SQUAREWIDTH
@sprites["map"].oy=@mapY*SQUAREHEIGHT
10.times do
Graphics.update
pbUpdate
@sprites["map"].zoom_x+=0.1
@sprites["map"].zoom_y+=0.1
end
end
def pbMapScene(mode=0)
cb=@sprites["returnbuttom"]
xOffset=0
yOffset=0
newX=0
select=false
newY=0
@sprites["cursorsel"].x=-SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2-24
@sprites["cursorsel"].y=-SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+376
@sprites["cursorsel"].visible=(@sprites["mapbottom"].maplocation=="") ? false : true
@sprites["cursor"].x = -SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2
@sprites["cursor"].y = -SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2
loop do
Graphics.update
Input.update
pbUpdate
if xOffset!=0 || yOffset!=0
xOffset+=xOffset>0 ? -4 : (xOffset<0 ? 4 : 0)
yOffset+=yOffset>0 ? -4 : (yOffset<0 ? 4 : 0)
@sprites["cursor"].x=newX-xOffset
@sprites["cursor"].y=newY-yOffset
@sprites["cursorsel"].x=newX-xOffset-38
@sprites["cursorsel"].y=newY-yOffset-8
next
end
updateMapInfo
ox=0
oy=0
if $mouse.inAreaLeft?(0,400,512,336)
#ox=1
oldmapx=@mapX
oldmapy=@mapY
@mapX=$mouse.x/SQUAREWIDTH
@mapY=($mouse.y-400)/SQUAREHEIGHT
if mode==1
select=true if oldmapx==@mapX && oldmapy==@mapY
end
@sprites["cursor"].x=@mapX*SQUAREWIDTH+7
@sprites["cursor"].y=@mapY*SQUAREHEIGHT+376
@sprites["cursorsel"].x=@sprites["cursor"].x-38
@sprites["cursorsel"].y=@sprites["cursor"].y-8
updateMapInfo
end
case Input.dir8
when 1 # lower left
oy=1 if @mapY<BOTTOM
ox=-1 if @mapX>LEFT
when 2 # down
oy=1 if @mapY<BOTTOM
when 3 # lower right
oy=1 if @mapY<BOTTOM
ox=1 if @mapX<RIGHT
when 4 # left
ox=-1 if @mapX>LEFT
when 6 # right
ox=1 if @mapX<RIGHT
when 7 # upper left
oy=-1 if @mapY>TOP
ox=-1 if @mapX>LEFT
when 8 # up
oy=-1 if @mapY>TOP
when 9 # upper right
oy=-1 if @mapY>TOP
ox=1 if @mapX<RIGHT
end
if ox!=0 || oy!=0
@mapX+=ox
@mapY+=oy
xOffset=ox*SQUAREWIDTH
yOffset=oy*SQUAREHEIGHT
newX=@sprites["cursor"].x+xOffset
newY=@sprites["cursor"].y+yOffset
@sprites["cursorsel"].x=newX-xOffset-38
@sprites["cursorsel"].y=newY-yOffset-8
end
if Input.trigger?(Input::B)
if @editor && @changed
if Kernel.pbConfirmMessage(_INTL("Save changes?")) { pbUpdate }
pbSaveMapData
end
if Kernel.pbConfirmMessage(_INTL("Exit from the map?")) { pbUpdate }
break
end
else
break
end
elsif Input.trigger?(Input::C) && mode==1 # Choosing an area to fly to
healspot = pbGetHealingSpot(@mapX,@mapY)
if healspot
if $PokemonGlobal.visitedMaps[healspot[0]] || ($DEBUG && Input.press?(Input::CTRL))
return healspot
end
end
elsif Input.trigger?(Input::C) && @editor # Intentionally placed after other C button check
pbChangeMapLocation(@mapX,@mapY)
end
end
return nil
end
end
def updateMapInfo
@sprites["mapbottom"].maplocation=pbGetMapLocation(@mapX,@mapY)
@sprites["mapbottom"].mapdetails=pbGetMapDetails(@mapX,@mapY)
@sprites["cursorsel"].visible=(@sprites["mapbottom"].maplocation=="") ? false : true
mapdesc=""
mapinterest=[]
placeicon=-1
for i in 0...PLACEDESC.length
mapdesc=PLACEDESC[i][1] if @sprites["mapbottom"].maplocation==PLACEDESC[i][0]
end
for i in 0...PLACEINTEREST.length
mapinterest=PLACEINTEREST[i][1] if @sprites["mapbottom"].maplocation==PLACEINTEREST[i][0]
end
for i in 0...PLACEICON.length
placeicon=(PLACEICON[i][1]-1) if @sprites["mapbottom"].maplocation==PLACEICON[i][0]
end
@sprites["mapsel"].src_rect.set(0,@sprites["mapsel"].bitmap.width*placeicon,
@sprites["mapsel"].bitmap.width,@sprites["mapsel"].bitmap.width)
@sprites["mapsel"].visible=(@sprites["mapbottom"].maplocation=="") ? false : true
#@sprites["mapsel"].x=-SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2+4
#@sprites["mapsel"].y=-SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+404
@sprites["mapbottom"].mapdesc=mapdesc
@sprites["mapbottom"].mapinterest=mapinterest
end
class PokemonRegionMap
def initialize(scene)
@scene=scene
end
def pbStartFlyScreen
@scene.pbStartScene(false,1)
[email protected](1)
@scene.pbEndScene
return ret
end
def pbStartScreen
@scene.pbStartScene($DEBUG)
@scene.pbMapScene
@scene.pbEndScene
end
end
def pbShowMap(region=-1,wallmap=true)
pbFadeOutIn(99999){
scene = PokemonRegionMap_Scene.new(region,wallmap)
screen=PokemonRegionMap.new(scene)
screen.pbStartScreen
}
end
Then in SETTINGS, we must put this.
Code:
#===============================================================================
# € Region map info
#===============================================================================
# Place description (City name, description)
PLACEDESC = [
["PUEBLO PALETA", ""],
["CIUDAD VERDE", ""],
["CIUDAD PLATEADA", ""],
]
# Select the icon picture in mapIconsSel
# that will be showed when the place is selected
PLACEICON = [
["PUEBLO PALETA",1],
["CIUDAD VERDE",2],
["CIUDAD PLATEADA",3],
["CIUDAD CELESTE",4],
["CIUDAD CARMIN",5],
["PUEBLO LAVANDA",6]
]
# Point of interests (max 6)
PLACEINTEREST = [
["PUEBLO PALETA", [""]],
["CIUDAD VERDE", ["", ""]],
]
PLACEDESC & PLACEINTEREST : In my case I am not using them, because the information already comes in the image that I designed ...
PLACEICON: This represents the image we will show. The method takes advantage of the BW map icon change function to display an image.
If the point on the map has that name, it will show the "part 1" of the image.
Well, finally we should use these graphics and put them on Graphics/Pictures/Townmap
next to all other region map graphics if they are outside the Townmap folder
https://drive.google.com/open?id=1pPvbeslJH9zC4B9UaFSYN2vyF1UZ9diN
Why doesn't it work quite well?
1. I don't master scripting very well, therefore the position in which the image is displayed changes completely
depending on the position in which you are on the map.
It should look like this ...
![[PokeCommunity.com] Images on REGION MAP (HELP!!) [PokeCommunity.com] Images on REGION MAP (HELP!!)](https://i.ibb.co/KbfsypL/ERROR-04.png)
But sometimes it looks like this ...
![[PokeCommunity.com] Images on REGION MAP (HELP!!) [PokeCommunity.com] Images on REGION MAP (HELP!!)](https://i.ibb.co/3mDFyXs/ERROR-03.png)
And others like this...
![[PokeCommunity.com] Images on REGION MAP (HELP!!) [PokeCommunity.com] Images on REGION MAP (HELP!!)](https://i.ibb.co/ZWrQXLq/ERROR-02.png)
...depending on where my character is.
2. This has made it very difficult to establish the size of the sections of the image BACKINFO (With the sections 1,2,3,4, etc)., given
I never know where they are going to show.
If anyone thinks it can help with this, welcome : D
Last edited: