Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SCREEN_HEIGHT=486
- class Game_Map
- alias in_range_old in_range?
- def in_range?(object)
- return true if $PokemonSystem.tilemap==2
- screne_x = display_x - 4*32*4
- screne_y = display_y - 4*32*4
- screne_width = display_x + Graphics.width*4 + 4*32*4
- screne_height = display_y + SCREEN_HEIGHT*4 + 4*32*4
- return false if object.real_x <= screne_x
- return false if object.real_x >= screne_width
- return false if object.real_y <= screne_y
- return false if object.real_y >= screne_height
- return true
- end
- alias display_y_old display_y
- def display_y=(value)
- @display_y=value
- if pbGetMetadata(self.map_id,MetadataSnapEdges)
- max_y = (self.height - SCREEN_HEIGHT*1.0/Game_Map::TILEHEIGHT) * Game_Map.realResY
- @display_y = [0, [@display_y, max_y].min].max
- end
- $MapFactory.setMapsInRange if $MapFactory
- end
- alias scroll_downright_old scroll_downright
- def scroll_downright(distance)
- @display_x = [@display_x + distance,
- (self.width - Graphics.width*1.0/Game_Map::TILEWIDTH) * Game_Map.realResX].min
- @display_y = [@display_y + distance,
- (self.height - SCREEN_HEIGHT*1.0/Game_Map::TILEHEIGHT) * Game_Map.realResY].min
- end
- alias scroll_downleft_old scroll_downleft
- def scroll_downleft(distance)
- @display_x = [@display_x - distance, 0].max
- @display_y = [@display_y + distance,
- (self.height - SCREEN_HEIGHT*1.0/Game_Map::TILEHEIGHT) * Game_Map.realResY].min
- end
- end
- class Interpreter
- alias autoscroll_old autoscroll
- def autoscroll(x,y,speed=SCROLL_SPEED_DEFAULT)
- if $game_map.scrolling?
- return false
- elsif not $game_map.valid?(x,y)
- print 'Map Autoscroll: given x,y is invalid'
- return command_skip
- elsif not (1..6).include?(speed)
- print 'Map Autoscroll: invalid speed (1-6 only)'
- return command_skip
- end
- center_x = (Graphics.width/2 - Game_Map::TILEWIDTH/2) * 4 # X coordinate in the center of the screen
- center_y = (SCREEN_HEIGHT/2 - Game_Map::TILEHEIGHT/2) * 4 # Y coordinate in the center of the screen
- max_x = ($game_map.width - Graphics.width*1.0/Game_Map::TILEWIDTH) * 4 * Game_Map::TILEWIDTH
- max_y = ($game_map.height - SCREEN_HEIGHT*1.0/Game_Map::TILEHEIGHT) * 4 * Game_Map::TILEHEIGHT
- count_x = ($game_map.display_x - [0,[x*Game_Map.realResX-center_x,max_x].min].max)/Game_Map.realResX
- count_y = ($game_map.display_y - [0,[y*Game_Map.realResY-center_y,max_y].min].max)/Game_Map.realResY
- if not @diag
- @diag = true
- dir = nil
- if count_x > 0
- if count_y > 0
- dir = 7
- elsif count_y < 0
- dir = 1
- end
- elsif count_x < 0
- if count_y > 0
- dir = 9
- elsif count_y < 0
- dir = 3
- end
- end
- count = [count_x.abs,count_y.abs].min
- else
- @diag = false
- dir = nil
- if count_x != 0 and count_y != 0
- return false
- elsif count_x > 0
- dir = 4
- elsif count_x < 0
- dir = 6
- elsif count_y > 0
- dir = 8
- elsif count_y < 0
- dir = 2
- end
- count = count_x != 0 ? count_x.abs : count_y.abs
- end
- $game_map.start_scroll(dir, count, speed) if dir != nil
- if @diag
- return false
- else
- return true
- end
- end
- end
- class Game_Player < Game_Character
- alias center_old center
- def center(x, y)
- # X coordinate in the center of the screen
- center_x = (Graphics.width/2 - Game_Map::TILEWIDTH/2) * Game_Map::XSUBPIXEL
- # Y coordinate in the center of the screen
- center_y = (SCREEN_HEIGHT/2 - Game_Map::TILEHEIGHT/2) * Game_Map::YSUBPIXEL
- max_x = (self.map.width - Graphics.width*1.0/Game_Map::TILEWIDTH) * Game_Map.realResX
- max_y = (self.map.height - SCREEN_HEIGHT*1.0/Game_Map::TILEHEIGHT) * Game_Map.realResY
- dispx=x * Game_Map.realResX - center_x
- dispy=y * Game_Map.realResY - center_y
- self.map.display_x = dispx
- self.map.display_y = dispy
- end
- alias update_old update
- def update
- # Remember whether or not moving in local variables
- last_moving = moving?
- # If moving, event running, move route forcing, and message window
- # display are all not occurring
- dir=Input.dir4
- unless moving? or $game_system.map_interpreter.running? or
- @move_route_forcing or $game_temp.message_window_showing or
- $PokemonTemp.miniupdate
- # Move player in the direction the directional button is being pressed
- if dir==@lastdir && Graphics.frame_count-@lastdirframe>2
- case dir
- when 2
- move_down
- when 4
- move_left
- when 6
- move_right
- when 8
- move_up
- end
- elsif dir!=@lastdir
- case dir
- when 2
- turn_down
- when 4
- turn_left
- when 6
- turn_right
- when 8
- turn_up
- end
- end
- end
- $PokemonTemp.dependentEvents.updateDependentEvents
- if dir!=@lastdir
- @lastdirframe=Graphics.frame_count
- end
- @lastdir=dir
- # Remember coordinates in local variables
- last_real_x = @real_x
- last_real_y = @real_y
- super
- center_x = (Graphics.width/2 - Game_Map::TILEWIDTH/2) *
- Game_Map::XSUBPIXEL # Center screen x-coordinate * 4
- center_y = (SCREEN_HEIGHT/2 - Game_Map::TILEHEIGHT/2) *
- Game_Map::YSUBPIXEL # Center screen y-coordinate * 4
- # If character moves down and is positioned lower than the center
- # of the screen
- if @real_y > last_real_y and @real_y - $game_map.display_y > center_y
- # Scroll map down
- $game_map.scroll_down(@real_y - last_real_y)
- end
- # If character moves left and is positioned more left on-screen than
- # center
- if @real_x < last_real_x and @real_x - $game_map.display_x < center_x
- # Scroll map left
- $game_map.scroll_left(last_real_x - @real_x)
- end
- # If character moves right and is positioned more right on-screen than
- # center
- if @real_x > last_real_x and @real_x - $game_map.display_x > center_x
- # Scroll map right
- $game_map.scroll_right(@real_x - last_real_x)
- end
- # If character moves up and is positioned higher than the center
- # of the screen
- if @real_y < last_real_y and @real_y - $game_map.display_y < center_y
- # Scroll map up
- $game_map.scroll_up(last_real_y - @real_y)
- end
- # Count down the time between allowed bump sounds
- @bump_se-=1 if @bump_se && @bump_se>0
- # If not moving
- unless moving?
- # If player was moving last time
- if last_moving
- $PokemonTemp.dependentEvents.pbTurnDependentEvents
- result = pbCheckEventTriggerFromDistance([2])
- # Event determinant is via touch of same position event
- result |= check_event_trigger_here([1,2])
- # If event which started does not exist
- Kernel.pbOnStepTaken(result) # *Added function call
- end
- # If C button was pressed
- if Input.trigger?(Input::C) && !$PokemonTemp.miniupdate
- # Same position and front event determinant
- check_event_trigger_here([0])
- check_event_trigger_there([0,2]) # *Modified to prevent unnecessary triggers
- end
- end
- end
- end
- class Spriteset_Map
- alias initialize_old initialize
- def initialize(map=nil)
- @map=map ? map : $game_map
- @viewport1 = Viewport.new(0, 0, Graphics.width,SCREEN_HEIGHT) # Panorama, map, events, player, fog
- @viewport1a = Viewport.new(0, 0, Graphics.width,SCREEN_HEIGHT) # Weather
- @viewport2 = Viewport.new(0, 0, Graphics.width,SCREEN_HEIGHT) # "Show Picture" event command pictures
- @viewport3 = Viewport.new(0, 0, Graphics.width,SCREEN_HEIGHT) # Flashing
- @viewport1a.z = 100
- @viewport2.z = 200
- @viewport3.z = 500
- # @viewport1.resizedZoomX=0.8
- @tilemap = TilemapLoader.new(@viewport1)
- @tilemap.tileset = pbGetTileset(@map.tileset_name)
- for i in 0...7
- autotile_name = @map.autotile_names[i]
- @tilemap.autotiles[i] = pbGetAutotile(autotile_name)
- end
- @tilemap.map_data = @map.data
- @tilemap.priorities = @map.priorities
- @panorama = AnimatedPlane.new(@viewport1)
- @panorama.z = -1000
- @fog = AnimatedPlane.new(@viewport1)
- @fog.z = 3000
- @reflectedSprites=[]
- @character_sprites = []
- for i in @map.events.keys.sort
- sprite = Sprite_Character.new(@viewport1, @map.events[i])
- @character_sprites.push(sprite)
- if [email protected][i].name[/noreflect/]
- @reflectedSprites.push(ReflectedSprite.new(sprite,@map.events[i],@viewport1))
- end
- end
- playersprite=Sprite_Character.new(@viewport1, $game_player)
- @playersprite=playersprite
- @reflectedSprites.push(ReflectedSprite.new(playersprite,$game_player,@viewport1))
- @character_sprites.push(playersprite)
- @weather = RPG::Weather.new(@viewport1a)
- @picture_sprites = []
- for i in 1..50
- @picture_sprites.push(Sprite_Picture.new(@viewport2,$game_screen.pictures[i]))
- end
- @timer_sprite = Sprite_Timer.new
- Kernel.pbOnSpritesetCreate(self,@viewport1)
- update
- end
- alias in_range_old in_range?
- def in_range?(object)
- return true if $PokemonSystem.tilemap==2
- screne_x = @map.display_x - 4*32*4
- screne_y = @map.display_y - 4*32*4
- screne_width = @map.display_x + Graphics.width*4 + 4*32*4
- screne_height = @map.display_y + SCREEN_HEIGHT*4 + 4*32*4
- return false if object.real_x <= screne_x
- return false if object.real_x >= screne_width
- return false if object.real_y <= screne_y
- return false if object.real_y >= screne_height
- return true
- end
- alias update_old update
- def update
- if @panorama_name != @map.panorama_name or
- @panorama_hue != @map.panorama_hue
- @panorama_name = @map.panorama_name
- @panorama_hue = @map.panorama_hue
- if @panorama.bitmap != nil
- @panorama.setPanorama(nil)
- end
- if @panorama_name != ""
- @panorama.setPanorama(@panorama_name, @panorama_hue)
- end
- Graphics.frame_reset
- end
- if @fog_name != @map.fog_name or @fog_hue != @map.fog_hue
- @fog_name = @map.fog_name
- @fog_hue = @map.fog_hue
- if @fog.bitmap != nil
- @fog.setFog(nil)
- end
- if @fog_name != ""
- @fog.setFog(@fog_name, @fog_hue)
- end
- Graphics.frame_reset
- end
- tmox = @map.display_x.to_i / 4
- tmoy = @map.display_y.to_i / 4
- @tilemap.ox=tmox
- @tilemap.oy=tmoy
- if $PokemonSystem.tilemap==0
- # Original Map View only, to prevent wrapping
- @viewport1.rect.x=[-tmox,0].max
- @viewport1.rect.y=[-tmoy,0].max
- @viewport1.rect.width=
- [@tilemap.map_data.xsize*Game_Map::TILEWIDTH-tmox,Graphics.width].min
- @viewport1.rect.height=
- [@tilemap.map_data.ysize*Game_Map::TILEHEIGHT-tmoy,SCREEN_HEIGHT].min
- @viewport1.ox=[-tmox,0].max
- @viewport1.oy=[-tmoy,0].max
- else
- @viewport1.rect.set(0,0,Graphics.width,SCREEN_HEIGHT)
- @viewport1.ox=0
- @viewport1.oy=0
- end
- @viewport1.ox += $game_screen.shake
- @tilemap.update
- @panorama.ox = @map.display_x / 8
- @panorama.oy = @map.display_y / 8
- @fog.zoom_x = @map.fog_zoom / 100.0
- @fog.zoom_y = @map.fog_zoom / 100.0
- @fog.opacity = @map.fog_opacity
- @fog.blend_type = @map.fog_blend_type
- @fog.ox = @map.display_x / 4 + @map.fog_ox
- @fog.oy = @map.display_y / 4 + @map.fog_oy
- @fog.tone = @map.fog_tone
- @panorama.update
- @fog.update
- for sprite in @character_sprites
- if sprite.character.is_a?(Game_Event)
- if sprite.character.trigger == 3 || sprite.character.trigger == 4 ||
- in_range?(sprite.character)
- sprite.update
- end
- else
- sprite.update
- end
- end
- for sprite in @reflectedSprites
- sprite.visible=true
- sprite.visible=(@map==$game_map) if sprite.event==$game_player
- sprite.update
- end
- # Avoids overlap effect of player sprites if player is near edge of
- # a connected map
- @[email protected] && (
- self.map==$game_map || $game_player.x<=0 || $game_player.y<=0 ||
- ($game_map && ($game_player.x>=$game_map.width ||
- $game_player.y>=$game_map.height)))
- if self.map!=$game_map
- @weather.max-=2 if @weather.max>0
- @weather.max=0 if @weather.max<0
- @weather.type = 0 if @weather.max==0
- @weather.ox = 0 if @weather.max==0
- @weather.oy = 0 if @weather.max==0
- else
- @weather.type = $game_screen.weather_type
- @weather.max = $game_screen.weather_max
- @weather.ox = @map.display_x / 4
- @weather.oy = @map.display_y / 4
- end
- @weather.update
- for sprite in @picture_sprites
- sprite.update
- end
- @timer_sprite.update
- @viewport1.tone = $game_screen.tone
- @viewport1a.ox += $game_screen.shake
- @viewport3.color = $game_screen.flash_color
- @viewport1.update
- @viewport1a.update
- @viewport3.update
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment