Minorthreat0987
Pokemon Tellurium
- 462
- Posts
- 19
- Years
- Seen Jan 28, 2021
I'm still getting this:
Exception: NoMethodError
Message: undefined method `<' for nil:NilClass
WindowAndTilemap:1134:in `refreshLayer0'
WindowAndTilemap:1132:in `each'
WindowAndTilemap:1132:in `refreshLayer0'
WindowAndTilemap:1116:in `each'
WindowAndTilemap:1116:in `refreshLayer0'
WindowAndTilemap:1115:in `each'
WindowAndTilemap:1115:in `refreshLayer0'
WindowAndTilemap:1275:in `refresh'
WindowAndTilemap:702:in `update'
WindowAndTilemap:1508:in `update'
This error is keeping me and my beta testers from testing the game thoroughly, does anyone know what this is and how to fix it permentally? Please, any help is greatly appreciated.
poccil said:Yes, that one. Replace that script with the one given below. After I made the change and tested it, I didn't notice any further problems.
Spoiler:Code:class WindowCursorRect < Rect def initialize(window) @window=window @x=0 @y=0 @width=0 @height=0 end attr_reader :x,:y,:width,:height def empty needupdate=@x!=0 || @y!=0 || @width!=0 || @height!=0 if needupdate @x=0 @y=0 @width=0 @height=0 @[email protected] end end def set(x,y,width,height) needupdate=@x!=x || @y!=y || @width!=width || @height!=height if needupdate @x=x @y=y @width=width @height=height @[email protected] end end def height=(value) @height=value; @[email protected] end def width=(value) @width=value; @[email protected] end def x=(value) @x=value; @[email protected] end def y=(value) @y=value; @[email protected] end end class Window attr_reader :tone attr_reader :color attr_reader :blend_type attr_reader :viewport attr_reader :contents attr_reader :ox attr_reader :oy attr_reader :x attr_reader :y attr_reader :z attr_reader :width attr_reader :active attr_reader :pause attr_reader :height attr_reader :opacity attr_reader :back_opacity attr_reader :contents_opacity attr_reader :visible attr_reader :cursor_rect attr_reader :openness def windowskin @_windowskin end def initialize(viewport=nil) @sprites={} @spritekeys=[ "back", "corner0","side0","scroll0", "corner1","side1","scroll1", "corner2","side2","scroll2", "corner3","side3","scroll3", "cursor","contents","pause" ] @sidebitmaps=[nil,nil,nil,nil] @cursorbitmap=nil @bgbitmap=nil @viewport=viewport for i in @spritekeys @sprites[i]=Sprite.new(@viewport) end @disposed=false @tone=Tone.new(0,0,0) @color=Color.new(0,0,0,0) @contents=nil @_windowskin=nil @rpgvx=false @x=0 @y=0 @width=0 @openness=255 @height=0 @ox=0 @oy=0 @z=0 @stretch=true @visible=true @active=true @blend_type=0 @opacity=255 @back_opacity=255 @contents_opacity=255 @cursor_rect=WindowCursorRect.new(self) @cursorblink=0 @cursoropacity=255 @pause=false @pauseopacity=255 @pauseframe=0 privRefresh(true) end def dispose if !self.disposed? for i in @sprites i[1].dispose if i[1] @sprites[i[0]]=nil end for i in [email protected] @sidebitmaps[i].dispose if @sidebitmaps[i] @sidebitmaps[i]=nil end @cursorbitmap.dispose if @cursorbitmap @backbitmap.dispose if @backbitmap @sprites.clear @sidebitmaps.clear @_windowskin=nil @_contents=nil @disposed=true end end def openness=(value) @openness=value @openness=0 if @openness<0 @openness=255 if @openness>255 privRefresh end def stretch=(value) @stretch=value privRefresh(true) end def visible=(value) @visible=value privRefresh end def viewport=(value) @viewport=value for i in @spritekeys @sprites[i].dispose if @sprites[i].is_a?(Sprite) @sprites[i]=Sprite.new(@viewport) elsif @sprites[i].is_a?(Plane) @sprites[i]=Plane.new(@viewport) else @sprites[i]=nil end end privRefresh(true) end def z=(value) @z=value privRefresh end def disposed? return @disposed end def contents=(value) @contents=value privRefresh end def windowskin=(value) @_windowskin=value if value && value.is_a?(Bitmap) && !value.disposed? && value.width==128 @rpgvx=true else @rpgvx=false end privRefresh(true) end def ox=(value) @ox=value privRefresh end def active=(value) @active=value privRefresh(true) end def cursor_rect=(value) if !value @cursor_rect.empty else @cursor_rect.set(value.x,value.y,value.width,value.height) end end def oy=(value) @oy=value privRefresh end def width=(value) @width=value privRefresh(true) end def height=(value) @height=value privRefresh(true) end def pause=(value) @pause=value @pauseopacity=0 if !value privRefresh end def x=(value) @x=value privRefresh end def y=(value) @y=value privRefresh end def opacity=(value) @opacity=value @opacity=0 if @opacity<0 @opacity=255 if @opacity>255 privRefresh end def back_opacity=(value) @back_opacity=value @back_opacity=0 if @back_opacity<0 @back_opacity=255 if @back_opacity>255 privRefresh end def contents_opacity=(value) @contents_opacity=value @contents_opacity=0 if @contents_opacity<0 @contents_opacity=255 if @contents_opacity>255 privRefresh end def tone=(value) @tone=value privRefresh end def color=(value) @color=value privRefresh end def blend_type=(value) @blend_type=value privRefresh end def flash(color,duration) return if disposed? for i in @sprites i[1].flash(color,duration) end end def update return if disposed? mustchange=false if @active if @cursorblink==0 @cursoropacity-=8 @cursorblink=1 if @cursoropacity<=128 else @cursoropacity+=8 @cursorblink=0 if @cursoropacity>=255 end mustchange=true else mustchange=true if @cursoropacity!=128 @cursoropacity=128 end if @pause @pauseframe=(Graphics.frame_count / 8) % 4 @pauseopacity=[@pauseopacity+64,255].min mustchange=true end privRefresh if mustchange for i in @sprites i[1].update end end private def ensureBitmap(bitmap,dwidth,dheight) if !bitmap||bitmap.disposed?||bitmap.width<dwidth||bitmap.height<dheight bitmap.dispose if bitmap bitmap=Bitmap.new([1,dwidth].max,[1,dheight].max) end return bitmap end def tileBitmap(dstbitmap,dstrect,srcbitmap,srcrect) return if !srcbitmap || srcbitmap.disposed? left=dstrect.x top=dstrect.y y=0;loop do break unless y<dstrect.height x=0;loop do break unless x<dstrect.width dstbitmap.blt(x+left,y+top,srcbitmap,srcrect) x+=srcrect.width end y+=srcrect.height end end def privRefresh(changeBitmap=false) return if self.disposed? backopac=self.back_opacity*self.opacity/255 contopac=self.contents_opacity cursoropac=@cursoropacity*contopac/255 for i in 0...4 @sprites["corner#{i}"].bitmap=@_windowskin @sprites["scroll#{i}"].bitmap=@_windowskin end @sprites["pause"].bitmap=@_windowskin @sprites["contents"].bitmap=@contents if @_windowskin && !@_windowskin.disposed? for i in 0...4 @sprites["corner#{i}"].opacity=@opacity @sprites["corner#{i}"].tone=@tone @sprites["corner#{i}"].color=@color @sprites["corner#{i}"].blend_type=@blend_type @sprites["corner#{i}"].visible=@visible @sprites["side#{i}"].opacity=@opacity @sprites["side#{i}"].tone=@tone @sprites["side#{i}"].color=@color @sprites["side#{i}"].blend_type=@blend_type @sprites["side#{i}"].visible=@visible @sprites["scroll#{i}"].opacity=@opacity @sprites["scroll#{i}"].tone=@tone @sprites["scroll#{i}"].blend_type=@blend_type @sprites["scroll#{i}"].color=@color @sprites["scroll#{i}"].visible=@visible end for i in ["back","cursor","pause","contents"] @sprites[i].color=@color @sprites[i].tone=@tone @sprites[i].blend_type=@blend_type end @sprites["contents"].blend_type=0 @sprites["back"].opacity=backopac @sprites["contents"].opacity=contopac @sprites["cursor"].opacity=cursoropac @sprites["pause"].opacity=@pauseopacity @sprites["back"].visible=@visible @sprites["contents"].visible=@visible && @openness==255 @sprites["pause"].visible=@visible && @pause @sprites["cursor"].visible=@visible hascontents=(@contents && [email protected]?) @sprites["scroll0"].visible = @visible && hascontents && @oy > 0 @sprites["scroll1"].visible = @visible && hascontents && @ox > 0 @sprites["scroll2"].visible = @visible && hascontents && (@contents.width - @ox) > @width-32 @sprites["scroll3"].visible = @visible && hascontents && (@contents.height - @oy) > @height-32 else for i in 0...4 @sprites["corner#{i}"].visible=false @sprites["side#{i}"].visible=false @sprites["scroll#{i}"].visible=false end @sprites["contents"].visible=@visible && @openness==255 @sprites["contents"].color=@color @sprites["contents"].tone=@tone # @sprites["contents"].blend_type=@blend_type @sprites["contents"].opacity=contopac @sprites["back"].visible=false @sprites["pause"].visible=false @sprites["cursor"].visible=false end for i in @sprites i[1].z=@z end @sprites["cursor"].z=@z+1 # For Compatibility @sprites["contents"].z=@z+2 # For Compatibility @sprites["pause"].z=@z+2 # For Compatibility if @rpgvx trimX=64 trimY=0 backRect=Rect.new(0,0,64,64) blindsRect=Rect.new(0,64,64,64) else trimX=128 trimY=0 backRect=Rect.new(0,0,128,128) blindsRect=nil end @sprites["corner0"].src_rect.set(trimX,trimY+0,16,16); @sprites["corner1"].src_rect.set(trimX+48,trimY+0,16,16); @sprites["corner2"].src_rect.set(trimX,trimY+48,16,16); @sprites["corner3"].src_rect.set(trimX+48,trimY+48,16,16); @sprites["scroll0"].src_rect.set(trimX+24, trimY+16, 16, 8) # up @sprites["scroll3"].src_rect.set(trimX+24, trimY+40, 16, 8) # down @sprites["scroll1"].src_rect.set(trimX+16, trimY+24, 8, 16) # left @sprites["scroll2"].src_rect.set(trimX+40, trimY+24, 8, 16) # right cursorX=trimX cursorY=trimY+64 sideRects=[ Rect.new(trimX+16,trimY+0,32,16), Rect.new(trimX,trimY+16,16,32), Rect.new(trimX+48,trimY+16,16,32), Rect.new(trimX+16,trimY+48,32,16) ] if @width>32 && @height>32 @sprites["contents"].src_rect.set(@ox,@oy,@width-32,@height-32) else @sprites["contents"].src_rect.set(0,0,0,0) end pauseRects=[ trimX+32,trimY+64, trimX+48,trimY+64, trimX+32,trimY+80, trimX+48,trimY+80, ] pauseWidth=16 pauseHeight=16 @sprites["pause"].src_rect.set( pauseRects[@pauseframe*2], pauseRects[@pauseframe*2+1], pauseWidth,pauseHeight ) @sprites["pause"].x=@x+(@width/2)-(pauseWidth/2) @sprites["pause"].y=@y+@height-16 # 16 refers to skin margin @sprites["contents"].x=@x+16 @sprites["contents"].y=@y+16 @sprites["corner0"].x=@x @sprites["corner0"].y=@y @sprites["corner1"].x=@x+@width-16 @sprites["corner1"].y=@y @sprites["corner2"].x=@x @sprites["corner2"].y=@y+@height-16 @sprites["corner3"].x=@x+@width-16 @sprites["corner3"].y=@y+@height-16 @sprites["side0"].x=@x+16 @sprites["side0"].y=@y @sprites["side1"].x=@x @sprites["side1"].y=@y+16 @sprites["side2"].x=@x+@width-16 @sprites["side2"].y=@y+16 @sprites["side3"].x=@x+16 @sprites["side3"].y=@y+@height-16 @sprites["scroll0"].x = @x+@width / 2 - 8 @sprites["scroll0"].y = @y+8 @sprites["scroll1"].x = @x+8 @sprites["scroll1"].y = @y+@height / 2 - 8 @sprites["scroll2"].x = @x+@width - 16 @sprites["scroll2"].y = @y+@height / 2 - 8 @sprites["scroll3"].x = @x+@width / 2 - 8 @sprites["scroll3"].y = @y+@height - 16 @sprites["back"].x=@x+2 @sprites["back"].y=@y+2 @sprites["cursor"].x=@x+16+@cursor_rect.x @sprites["cursor"].y=@y+16+@cursor_rect.y if changeBitmap && @_windowskin && !@_windowskin.disposed? width=@cursor_rect.width height=@cursor_rect.height if width > 0 && height > 0 cursorrects=[ # sides Rect.new(cursorX+2, cursorY+0, 28, 2), Rect.new(cursorX+0, cursorY+2, 2, 28), Rect.new(cursorX+30, cursorY+2, 2, 28), Rect.new(cursorX+2, cursorY+30, 28, 2), # corners Rect.new(cursorX+0, cursorY+0, 2, 2), Rect.new(cursorX+30, cursorY+0, 2, 2), Rect.new(cursorX+0, cursorY+30, 2, 2), Rect.new(cursorX+30, cursorY+30, 2, 2), # back Rect.new(cursorX+2, cursorY+2, 28, 28) ] margin=2 fullmargin=4 @cursorbitmap = ensureBitmap(@cursorbitmap, width, height) @cursorbitmap.clear @sprites["cursor"].bitmap=@cursorbitmap @sprites["cursor"].src_rect.set(0,0,width,height) rect = Rect.new(margin,margin, width - fullmargin, height - fullmargin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[8]) @cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4])# top left @cursorbitmap.blt(width-margin, 0, @_windowskin, cursorrects[5]) # top right @cursorbitmap.blt(0, height-margin, @_windowskin, cursorrects[6]) # bottom right @cursorbitmap.blt(width-margin, height-margin, @_windowskin, cursorrects[7]) # bottom left rect = Rect.new(margin, 0, width - fullmargin, margin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0]) rect = Rect.new(0, margin, margin, height - fullmargin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[1]) rect = Rect.new(width - margin, margin, margin, height - fullmargin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[2]) rect = Rect.new(margin, height-margin, width - fullmargin, margin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[3]) else @sprites["cursor"].visible=false @sprites["cursor"].src_rect.set(0,0,0,0) end for i in 0..3 dwidth=(i==0||i==3) ? @width-32 : 16 dheight=(i==0||i==3) ? 16 : @height-32 @sidebitmaps[i]=ensureBitmap(@sidebitmaps[i],dwidth,dheight) @sprites["side#{i}"].bitmap=@sidebitmaps[i] @sprites["side#{i}"].src_rect.set(0,0,dwidth,dheight) @sidebitmaps[i].clear if sideRects[i].width>0 && sideRects[i].height>0 @sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect, @_windowskin,sideRects[i]) end end backwidth=@width-4 backheight=@height-4 if backwidth>0 && backheight>0 @backbitmap=ensureBitmap(@backbitmap,backwidth,backheight) @sprites["back"].bitmap=@backbitmap @sprites["back"].src_rect.set(0,0,backwidth,backheight) @backbitmap.clear if @stretch @backbitmap.stretch_blt(@sprites["back"].src_rect,@_windowskin,backRect) else tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,backRect) end if blindsRect tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,blindsRect) end else @sprites["back"].visible=false @sprites["back"].src_rect.set(0,0,0,0) end end if @openness!=255 opn=@openness/255.0 for k in @spritekeys sprite=@sprites[k] ratio=(@height<=0) ? 0 : (sprite.y-@y)*1.0/@height sprite.zoom_y=opn sprite.oy=0 sprite.y=(@y+(@height/2.0)+(@height*ratio*opn)-(@height/2*opn)).floor oldbitmap=sprite.bitmap oldsrcrect=sprite.src_rect.clone end else for k in @spritekeys sprite=@sprites[k] sprite.zoom_y=1.0 end end i=0 # Ensure Z order for k in @spritekeys sprite=@sprites[k] y=sprite.y sprite.y=i sprite.oy=(sprite.zoom_y<=0) ? 0 : (i-y)/sprite.zoom_y end end end class CustomTilemapAutotiles attr_accessor :changed def initialize @changed=true @tiles=[nil,nil,nil,nil,nil,nil,nil] end def []=(i,value) @tiles[i]=value @changed=true end def [](i) return @tiles[i] end end class CustomTilemap Animated_Autotiles_Frames = 15 Autotiles = [ [ [27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34], [27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12] ], [ [27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34], [27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12] ], [ [25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12], [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ], [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36], [39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46] ], [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12], [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ], [ [37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44], [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8] ] ] FlashOpacity=[100,90,80,70,80,90] attr_reader :tileset attr_reader :autotiles attr_reader :map_data attr_accessor :flash_data attr_accessor :priorities attr_reader :visible attr_accessor :ox attr_accessor :oy attr_reader :viewport attr_accessor :tone attr_accessor :color def graphicsHeight return 480 end def graphicsWidth return 640 end def initialize(viewport) @tileset = nil # Refers to Map Tileset Name @autotiles = CustomTilemapAutotiles.new @map_data = nil # Refers to 3D Array Of Tile Settings @flash_data = nil # Refers to 3D Array of Tile Flashdata @priorities = nil # Refers to Tileset Priorities @visible = true # Refers to Tileset Visibleness @ox = 0 # Bitmap Offsets @oy = 0 # bitmap Offsets @plane = false @tone=Tone.new(0,0,0,0) @color=Color.new(0,0,0,0) @oldtone=Tone.new(0,0,0,0) @oldcolor=Color.new(0,0,0,0) @selfviewport=Viewport.new(0,0,graphicsWidth,graphicsHeight) @viewport=viewport ? viewport : @selfviewport @tiles=[] @autotileInfo=[] @regularTileInfo=[] @oldOx=0 @oldOy=0 @layer0=Sprite.new(viewport) @layer0.visible=true @nowshown=false @layer0.bitmap=Bitmap.new([graphicsWidth*2,1].max,[graphicsHeight*2,1].max) @flash=nil @layer0.ox=0 @layer0.oy=0 @oxLayer0=0 @oyLayer0=0 @oxFlash=0 @oyFlash=0 @layer0.z=0 @priotiles=[] @prioautotiles=[] @autosprites=[] @framecount=[] @tilesetChanged=true @flashChanged=false @firsttime=true @disposed=false @usedsprites=false @layer0clip=true @firsttimeflash=true @fullyrefreshed=false @fullyrefreshedautos=false end def disposed? return @disposed end def flash_data=(value) @flash_data=value @flashChanged=true end def update if @oldtone!=@tone @layer0.tone=@tone @flash.tone=@tone if @flash for sprite in @autosprites sprite.tone=@tone end for sprite in @tiles sprite.tone=@tone if sprite.is_a?(Sprite) end @[email protected] end if @oldcolor!=@color @layer0.color=@color @flash.color=@color if @flash for sprite in @autosprites sprite.color=@color end for sprite in @tiles sprite.color=@color if sprite.is_a?(Sprite) end @[email protected] end if @autotiles.changed refresh_autotiles repaintAutotiles end if @flashChanged refresh_flash end if @tilesetChanged refresh_tileset end if @flash @flash.opacity=FlashOpacity[(Graphics.frame_count/2) % 6] end if !(@oldOx==@ox && @oldOy==@oy && !@tilesetChanged && [email protected]) refresh end if (Graphics.frame_count % Animated_Autotiles_Frames == 0) || @nowshown repaintAutotiles refresh(true) end @nowshown=false @autotiles.changed=false @tilesetChanged=false end def priorities=(value) @priorities=value @tilesetChanged=true end def tileset=(value) @tileset=value @tilesetChanged=true end def shown? return false if !@visible ysize=@map_data.ysize xsize=@map_data.xsize xStart=(@ox/32)-1 xEnd=((@[email protected])/32)+1 yStart=(@oy/32)-1 yEnd=((@[email protected])/32)+1 xStart=0 if xStart<0 xStart=xsize-1 if xStart>=xsize xEnd=0 if xEnd<0 xEnd=xsize-1 if xEnd>=xsize yStart=0 if yStart<0 yStart=ysize-1 if yStart>=ysize yEnd=0 if yEnd<0 yEnd=ysize-1 if yEnd>=ysize return (xStart<xEnd && yStart<yEnd) end def dispose return if disposed? @help.dispose if @help @help=nil i=0;[email protected];while i<len if @autotileInfo[i] @autotileInfo[i].dispose @autotileInfo[i]=nil end i+=1 end i=0;[email protected];while i<len if @regularTileInfo[i] @regularTileInfo[i].dispose @regularTileInfo[i]=nil end i+=1 end i=0;[email protected];while i<len @tiles[i].dispose @tiles[i]=nil i+=2 end i=0;[email protected];while i<len @autosprites[i].dispose @autosprites[i]=nil i+=2 end if @layer0 @layer0.bitmap.dispose if [email protected]? @layer0.bitmap=nil if [email protected]? @layer0.dispose @layer0=nil end if @flash @flash.bitmap.dispose if [email protected]? @flash.bitmap=nil if [email protected]? @flash.dispose @flash=nil end for i in 0...7 self.autotiles[i]=nil end @tiles.clear @autosprites.clear @autotileInfo.clear @regularTileInfo.clear @tilemap=nil @tileset=nil @priorities=nil @selfviewport.dispose @selfviewport=nil @disposed=true end def bltAutotile(bitmap,x,y,id,frame) return if frame<0 autotile=@autotiles[id/48-1] return if !autotile if autotile.height==32 anim=frame<<5 src_rect=Rect.new(anim,0,32,32) bitmap.blt(x,y,autotile,src_rect) else anim=frame*96 id%=48 tiles = Autotiles[id>>3][id&7] src=Rect.new(0,0,0,0) for i in 0...4 tile_position = tiles[i] - 1 src.set( (tile_position % 6)*16 + anim, (tile_position / 6)*16, 16, 16) bitmap.blt(i%2*16+x,i/2*16+y, autotile, src) end end end def autotileNumFrames(id) autotile=@autotiles[id/48-1] return 0 if !autotile || autotile.disposed? frames=1 if autotile.height==32 frames=autotile.width>>5 else frames=autotile.width/96 end return frames end def autotileFrame(id) autotile=@autotiles[id/48-1] return -1 if !autotile || autotile.disposed? frames=1 if autotile.height==32 frames=autotile.width>>5 else frames=autotile.width/96 end return (Graphics.frame_count/Animated_Autotiles_Frames)%frames end def repaintAutotiles for i in [email protected] next if !@autotileInfo[i] frame=autotileFrame(i) bltAutotile(@autotileInfo[i],0,0,i,frame) end end def getAutotile(sprite,id) anim=autotileFrame(id) return if anim<0 bitmap=@autotileInfo[id] if !bitmap bitmap=Bitmap.new(32,32) bltAutotile(bitmap,0,0,id,anim) @autotileInfo[id]=bitmap end sprite.bitmap=bitmap if !sprite.equal?(bitmap) || sprite.bitmap!=bitmap end def getRegularTile(sprite,id) if false sprite.bitmap=@tileset if !sprite.equal?(@tileset) || sprite.bitmap!=@tileset sprite.src_rect.set(((id - 384)&7)<<5,((id - 384)>>3)<<5,32,32) else bitmap=@regularTileInfo[id] if !bitmap bitmap=Bitmap.new(32,32) rect=Rect.new(((id - 384)&7)<<5,((id - 384)>>3)<<5,32,32) bitmap.blt(0,0,@tileset,rect) @regularTileInfo[id]=bitmap end sprite.bitmap=bitmap if !sprite.equal?(bitmap) || sprite.bitmap!=bitmap end end def addTile(tiles,count,xpos,ypos,id) if id>=384 if count>=tiles.length sprite=Sprite.new(@viewport) tiles.push(sprite,0) else sprite=tiles[count] tiles[count+1]=0 end sprite.visible=@visible sprite.x=xpos sprite.y=ypos sprite.tone=@tone sprite.color=@color getRegularTile(sprite,id) spriteZ=(@priorities[id]==0||!@priorities[id]) ? 0 : ypos+@priorities[id]*32+32 sprite.z=spriteZ count+=2 else if count>=tiles.length sprite=Sprite.new(@viewport) tiles.push(sprite,1) else sprite=tiles[count] tiles[count+1]=1 end sprite.visible=@visible sprite.x=xpos sprite.y=ypos sprite.tone=@tone sprite.color=@color getAutotile(sprite,id) spriteZ=(@priorities[id]==0||!@priorities[id]) ? 0 : ypos+@priorities[id]*32+32 sprite.z=spriteZ count+=2 end return count end def refresh_tileset i=0;[email protected];while i<len if @regularTileInfo[i] @regularTileInfo[i].dispose @regularTileInfo[i]=nil end i+=1 end @regularTileInfo.clear @priotiles.clear ysize=@map_data.ysize xsize=@map_data.xsize zsize=@map_data.zsize if xsize>100 || ysize>100 @fullyrefreshed=false else for z in 0...zsize for y in 0...ysize for x in 0...xsize id = @map_data[x, y, z] next if id==0 || !@priorities[id] next if @priorities[id]==0 @priotiles.push([x,y,z,id]) end end end @fullyrefreshed=true end end def refresh_flash if @flash_data && !@flash @flash=Sprite.new(viewport) @flash.visible=true @flash.z=1 @flash.blend_type=1 @flash.bitmap=Bitmap.new([graphicsWidth*2,1].max,[graphicsHeight*2,1].max) @firsttimeflash=true elsif !@flash_data && @flash @flash.bitmap.dispose if @flash.bitmap @flash.dispose @flash=nil @firsttimeflash=false end end def refresh_autotiles i=0;[email protected];while i<len if @autotileInfo[i] @autotileInfo[i].dispose @autotileInfo[i]=nil end i+=1 end i=0;[email protected];while i<len if @autosprites[i] @autosprites[i].dispose @autosprites[i]=nil end i+=2 end @autosprites.clear @autotileInfo.clear @prioautotiles.clear hasanimated=false for i in 0...7 numframes=autotileNumFrames(48*(i+1)) hasanimated=true if numframes>=2 @framecount[i]=numframes end if hasanimated ysize=@map_data.ysize xsize=@map_data.xsize zsize=@map_data.zsize if xsize>100 || ysize>100 @fullyrefreshedautos=false else for y in 0...ysize for x in 0...xsize haveautotile=false for z in 0...zsize id = @map_data[x, y, z] next if id==0 || id>=384 || @priorities[id]!=0 || !@priorities[id] next if @framecount[id/48-1]<2 haveautotile=true break end @prioautotiles.push([x,y]) if haveautotile end end @fullyrefreshedautos=true end else @fullyrefreshedautos=true end end def map_data=(value) @map_data=value @tilesetChanged=true end def refreshFlashSprite return if !@flash || @flash_data.nil? ptX=@ox-@oxFlash ptY=@oy-@oyFlash if !@firsttimeflash && !@usedsprites && ptX>=0 && [email protected]<[email protected] && ptY>=0 && [email protected]<[email protected] @flash.ox=0 @flash.oy=0 @flash.src_rect.set(ptX.round,ptY.round, @viewport.rect.width,@viewport.rect.height) return end [email protected] [email protected] [email protected] ysize=@map_data.ysize xsize=@map_data.xsize zsize=@map_data.zsize @firsttimeflash=false @oxFlash=@ox-(width>>2) @oyFlash=@oy-(height>>2) @flash.ox=0 @flash.oy=0 @flash.src_rect.set(width>>2,height>>2, @viewport.rect.width,@viewport.rect.height) @flash.bitmap.clear @[email protected] @[email protected] xStart=(@oxFlash>>5) xStart=0 if xStart<0 yStart=(@oyFlash>>5) yStart=0 if yStart<0 xEnd=xStart+(width>>5)+1 yEnd=yStart+(height>>5)+1 xEnd=xsize if xEnd>=xsize yEnd=ysize if yEnd>=ysize if xStart<xEnd && yStart<yEnd yrange=yStart...yEnd xrange=xStart...xEnd tmpcolor=Color.new(0,0,0,0) for y in yrange ypos=(y<<5)-@oyFlash for x in xrange xpos=(x<<5)-@oxFlash id = @flash_data[x, y, 0] r=(id>>8)&15 g=(id>>4)&15 b=(id)&15 tmpcolor.set(r<<4,g<<4,b<<4) bitmap.fill_rect(xpos,ypos,32,32,tmpcolor) end end end end def refreshLayer0(autotiles=false) if autotiles return true if !shown? end ptX=@ox-@oxLayer0 ptY=@oy-@oyLayer0 if !autotiles && !@firsttime && !@usedsprites && ptX>=0 && [email protected]<[email protected] && ptY>=0 && [email protected]<[email protected] if @layer0clip @layer0.ox=0 @layer0.oy=0 @layer0.src_rect.set(ptX.round,ptY.round, @viewport.rect.width,@viewport.rect.height) else @layer0.ox=ptX.round @layer0.oy=ptY.round @layer0.src_rect.set(0,0,@layer0.bitmap.width,@layer0.bitmap.height) end return true end [email protected] [email protected] [email protected] ysize=@map_data.ysize xsize=@map_data.xsize zsize=@map_data.zsize if autotiles return true if @fullyrefreshedautos && @prioautotiles.length==0 xStart=(@oxLayer0>>5) xStart=0 if xStart<0 yStart=(@oyLayer0>>5) yStart=0 if yStart<0 xEnd=xStart+(width>>5)+1 yEnd=yStart+(height>>5)+1 xEnd=xsize if xEnd>xsize yEnd=ysize if yEnd>ysize return true if xStart>=xEnd || yStart>=yEnd trans=Color.new(0,0,0,0) temprect=Rect.new(0,0,0,0) tilerect=Rect.new(0,0,32,32) range=0...zsize overallcount=0 count=0 if !@fullyrefreshedautos for y in yStart..yEnd for x in xStart..xEnd haveautotile=false for z in range id = @map_data[x, y, z] next if !id || id<48 || id>=384 || @priorities[id]!=0 || !@priorities[id] fcount=@framecount[id/48-1] next if !fcount || fcount<2 if !haveautotile haveautotile=true overallcount+=1 xpos=(x<<5)-@oxLayer0 ypos=(y<<5)-@oyLayer0 bitmap.fill_rect(xpos,ypos,0,0,trans) if overallcount<=2000 break end end for z in range id = @map_data[x,y,z] next if !id || id<48 || @priorities[id]!=0 || !@priorities[id] if overallcount>2000 xpos=(x<<5)-@oxLayer0 ypos=(y<<5)-@oyLayer0 count=addTile(@autosprites,count,xpos,ypos,id) next elsif id>=384 temprect.set(((id - 384)&7)<<5,((id - 384)>>3)<<5,32,32) xpos=(x<<5)-@oxLayer0 ypos=(y<<5)-@oyLayer0 bitmap.blt(xpos,ypos,@tileset,temprect) else tilebitmap=@autotileInfo[id] if !tilebitmap anim=autotileFrame(id) next if anim<0 tilebitmap=Bitmap.new(32,32) bltAutotile(tilebitmap,0,0,id,anim) @autotileInfo[id]=tilebitmap end xpos=(x<<5)-@oxLayer0 ypos=(y<<5)-@oyLayer0 bitmap.blt(xpos,ypos,tilebitmap,tilerect) end end end end Graphics.frame_reset else for tile in @prioautotiles x=tile[0] y=tile[1] next if x<xStart||x>xEnd next if y<yStart||y>yEnd overallcount+=1 xpos=(x<<5)-@oxLayer0 ypos=(y<<5)-@oyLayer0 bitmap.fill_rect(xpos,ypos,0,0,trans) if overallcount<=2000 for z in range id = @map_data[x,y,z] next if !id || id<48 || @priorities[id]!=0 || !@priorities[id] if overallcount>2000 count=addTile(@autosprites,count,xpos,ypos,id) next elsif id>=384 temprect.set(((id - 384)&7)<<5,((id - 384)>>3)<<5,32,32) bitmap.blt(xpos,ypos,@tileset,temprect) else tilebitmap=@autotileInfo[id] if !tilebitmap anim=autotileFrame(id) next if anim<0 tilebitmap=Bitmap.new(32,32) bltAutotile(tilebitmap,0,0,id,anim) @autotileInfo[id]=tilebitmap end bitmap.blt(xpos,ypos,tilebitmap,tilerect) end end end Graphics.frame_reset if overallcount>2000 end @usedsprites=false return true end return false if @usedsprites @firsttime=false @oxLayer0=@ox-(width>>2) @oyLayer0=@oy-(height>>2) if @layer0clip @layer0.ox=0 @layer0.oy=0 @layer0.src_rect.set(width>>2,height>>2, @viewport.rect.width,@viewport.rect.height) else @layer0.ox=(width>>2) @layer0.oy=(height>>2) end @layer0.bitmap.clear @[email protected] @[email protected] xStart=(@oxLayer0>>5) xStart=0 if xStart<0 yStart=(@oyLayer0>>5) yStart=0 if yStart<0 xEnd=xStart+(width>>5)+1 yEnd=yStart+(height>>5)+1 xEnd=xsize if xEnd>=xsize yEnd=ysize if yEnd>=ysize if xStart<xEnd && yStart<yEnd tmprect=Rect.new(0,0,0,0) yrange=yStart...yEnd xrange=xStart...xEnd for z in 0...zsize for y in yrange ypos=(y<<5)-@oyLayer0 for x in xrange xpos=(x<<5)-@oxLayer0 id = @map_data[x, y, z] next if id==0 || @priorities[id]!=0 || !@priorities[id] if id>=384 tmprect.set((id - 384) % 8 * 32, (id - 384) / 8 * 32,32,32) bitmap.blt(xpos,ypos,@tileset,tmprect) else frame=autotileFrame(id) bltAutotile(bitmap,xpos,ypos,id,frame) end end end end Graphics.frame_reset end return true end def getResizeFactor return $ResizeFactor ? $ResizeFactor : 1.0 end def ox=(val) val=(val*getResizeFactor).to_i val=(val/getResizeFactor).to_i wasshown=self.shown? @ox=val.floor @nowshown=(!wasshown && self.shown?) end def oy=(val) val=(val*getResizeFactor).to_i val=(val/getResizeFactor).to_i wasshown=self.shown? @oy=val.floor @nowshown=(!wasshown && self.shown?) end def visible=(val) wasshown=@visible @visible=val @nowshown=(!wasshown && val) end def refresh(autotiles=false) @oldOx=@ox @oldOy=@oy usesprites=false if @layer0 @layer0.visible=@visible usesprites=!refreshLayer0(autotiles) if autotiles && !usesprites return end else usesprites=true end refreshFlashSprite [email protected] [email protected] [email protected]+vpx [email protected]+vpy xsize=@map_data.xsize ysize=@map_data.ysize minX=(@ox/32)-1 maxX=((@[email protected])/32)+1 minY=(@oy/32)-1 maxY=((@[email protected])/32)+1 minX=0 if minX<0 minX=xsize-1 if minX>=xsize maxX=0 if maxX<0 maxX=xsize-1 if maxX>=xsize minY=0 if minY<0 minY=ysize-1 if minY>=ysize maxY=0 if maxY<0 maxY=ysize-1 if maxY>=ysize count=0 if minX<maxX && minY<maxY @usedsprites=usesprites || @usedsprites if @layer0 @layer0.visible=false if usesprites end if @fullyrefreshed for prio in @priotiles x=prio[0] y=prio[1] next if x<minX||x>maxX next if y<minY||y>maxY id=prio[3] xpos=(x<<5)-@ox ypos=(y<<5)-@oy count=addTile(@tiles,count,xpos,ypos,id) end else for z in 0...@map_data.zsize for y in minY..maxY for x in minX..maxX id = @map_data[x, y, z] next if id==0 || !@priorities[id] next if @priorities[id]==0 xpos=(x<<5)-@ox ypos=(y<<5)-@oy count=addTile(@tiles,count,xpos,ypos,id) end end end end end if count<@tiles.length bigchange=(count<=(@tiles.length*2/3)) && (@tiles.length*2/3)>25 j=count;[email protected];while j<len sprite=@tiles[j] @tiles[j+1]=-1 if bigchange sprite.dispose @tiles[j]=nil @tiles[j+1]=nil elsif !@tiles[j].disposed? sprite.visible=false if sprite.visible end j+=2 end @tiles.compact! if bigchange end end end class SynchronizedTilemapAutotilesInternal def initialize(oldat) @atdisposables=[[],[],[],[],[],[],[]] @atframes=[[],[],[],[],[],[],[]] @autotiles=[] @oldat=oldat end def dispose for i in 0...7 for bitmap in @atdisposables[i] bitmap.dispose end @atdisposables[i].clear @atframes[i].clear end end def [](i) return @autotiles[i] end def []=(i,value) for frame in @atdisposables[i] frame.dispose end @atframes[i].clear @atdisposables[i].clear if value && !value.disposed? if value.height==32 frames=value.width/32 for j in 0...frames @atdisposables[i][j]=Bitmap.new(32,32) @atdisposables[i][j].blt(0,0,value,Rect.new(j*32,0,32,32)) @atframes[i][j]=@atdisposables[i][j] end elsif value.height==128 frames=value.width/96 for j in 0...frames @atdisposables[i][j]=Bitmap.new(96,128) @atdisposables[i][j].blt(0,0,value,Rect.new(j*96,0,96,128)) @atframes[i][j]=@atdisposables[i][j] end else @atframes[i][0]=value end else @atframes[i][0]=value end @autotiles[i]=value sync end def sync frameused=[] for i in 0...7 frames=[1,@atframes[i].length].max frame=(Graphics.frame_count/15)%frames @oldat[i]=@atframes[i][frame] end end end class SynchronizedTilemapAutotiles def initialize(autotiles) @autotiles=autotiles end def [](i) @autotiles[i] end def []=(i,value) @autotiles[i]=value end end class SynchronizedTilemap < Tilemap # This class derives from Tilemap just to synchronize # the tilemap animation. attr_accessor :numupdates def initialize(viewport=nil) super(viewport) @updating=true @autotiles=SynchronizedTilemapAutotilesInternal.new(self.autotiles) @autos=SynchronizedTilemapAutotiles.new(@autotiles) @updating=false end def dispose @autotiles.dispose super end def autotiles if @updating super else return @autos end end def update return if disposed? @autotiles.sync super end end class TilemapLoader def initialize(viewport) @viewport=viewport @tilemap=nil @color=Color.new(0,0,0,0) @tone=Tone.new(0,0,0,0) updateClass end def updateClass case $PokemonSystem.tilemap when 1 setClass(CustomTilemap) when 2 setClass(Draw_Tilemap) else if Tilemap.method_defined?(:passages) setClass(CustomTilemap) else setClass($ResizeFactor==1.0 ? SynchronizedTilemap : CustomTilemap) end end end def setClass(cls) newtilemap=cls.new(@viewport) if @tilemap [email protected] [email protected]_data [email protected]_data [email protected] [email protected] [email protected] [email protected] for i in 0...7 newtilemap.autotiles[i][email protected][i] end @tilemap.dispose @tilemap=newtilemap newtilemap.update if cls!=SynchronizedTilemap else @tilemap=newtilemap end end def tone @tilemap.tone rescue @tone end def tone=(value) @tilemap.tone=value rescue nil end def disposed? @tilemap.disposed? end def dispose @tilemap.dispose end def update @tilemap.update end def viewport @tilemap.viewport end def autotiles @tilemap.autotiles end def tileset @tilemap.tileset end def tileset=(v) @tilemap.tileset=v end def map_data @tilemap.map_data end def map_data=(v) @tilemap.map_data=v end def flash_data @tilemap.flash_data end def flash_data=(v) @tilemap.flash_data=v end def priorities @tilemap.priorities end def priorities=(v) @tilemap.priorities=v end def visible @tilemap.visible end def visible=(v) @tilemap.visible=v end def ox @tilemap.ox end def ox=(v) @tilemap.ox=v end def oy @tilemap.oy end def oy=(v) @tilemap.oy=v end end
Poccil told me to replace my "WindowAndTilemap" script with the one contained in the spoilers and if fixed that problem, I was having the same problem with my game aswell.
I hope this helps.
Sincerely
MT