Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # LM² - Global Minimap 1.4.1
- # Data 07/05/15 | Revisão 28/08/17
- # Criado por LeonMM, alguns metodos pertencem a Squall e RD12
- # Versão Netplay Diamond - Obrigado Kies~ pelos testes
- class Global_Minimap < Sprite
- # Posicionamento do minimapa
- X = 675
- Y = 10
- attr_accessor :show_players
- # Inicializar minimapa
- def initialize(showplayers = true)
- @view = Viewport.new(X,Y,110,110)
- @view.z = 1000
- @bg = Sprite.new
- @bg.bitmap = RPG::Cache.minimap("BG")
- @bg.x = X - 5
- @bg.y = Y - 5
- @bg.z = 999
- @pass = Sprite.new(@view)
- @pass.bitmap = Bitmap.new($game_map.width * 5 , $game_map.height * 5)
- @nicon = Sprite.new
- @nicon.bitmap = showplayers ? RPG::Cache.minimap("Players") : RPG::Cache.minimap("PlayersOFF")
- @nicon.x = X - 34
- @nicon.y = Y - 5
- @nicon.z = 1000
- @show_players = showplayers
- @events = {}
- @enemys = {}
- @netplayers = {}
- @oldmpp = nil
- @gplayer_x = $game_player.x
- @gplayer_y = $game_player.y
- draw
- draw_player
- draw_events
- end
- # Desenhar o minimapa, jogadores e eventos
- def draw
- @pass.bitmap.clear
- for x in 0...$game_map.width
- for y in 0...$game_map.height
- next if not $game_map.passable?(x,y,0)
- passbm = RPG::Cache.minimap("Passable")
- @pass.bitmap.blt( x * 5, y * 5, passbm, Rect.new( 0, 0, 5, 5))
- end
- end
- end
- def draw_player
- @player = Sprite.new(@view)
- @player.bitmap = RPG::Cache.minimap("Player")
- @player.x = $game_player.x * 5
- @player.y = $game_player.y * 5
- @player.z = 1003
- minox = @player.x - 50
- maxox = (@pass.bitmap.width - 110)
- newox = (@pass.bitmap.width - 60) >= @player.x ? minox : maxox
- minoy = @player.y - 50
- maxoy = (@pass.bitmap.height - 110)
- newoy = (@pass.bitmap.height - 60) >= @player.y ? minoy : maxoy
- @view.ox = newox <= 0 ? 0 : newox
- @view.oy = newoy <= 0 ? 0 : newoy
- end
- def draw_events
- for key in $game_map.events.keys
- event = $game_map.events[key]
- next if event.list == nil
- for i in 0...event.list.size
- next if event.list[i].code != 108
- @events[key] = Sprite.new(@view)
- @events[key].z = 1002
- @events[key].x = event.x * 5
- @events[key].y = event.y * 5
- if event.list[i].parameters[0].include?("Inim")
- @events[key].bitmap = RPG::Cache.minimap("Enemies")
- @enemys[key] = true
- elsif event.list[i].parameters[0].include?("Event")
- @events[key].bitmap = RPG::Cache.minimap("Events")
- elsif event.list[i].parameters[0].include?("Objective")
- @events[key].bitmap = RPG::Cache.minimap("Objective")
- end
- end
- end
- end
- # Atualizar o minimapa, jogadores e eventos
- def update
- update_player
- update_events
- update_netplayers if @show_players
- update_view if moving?
- update_icon if $mouse.in_area?(@nicon.x, @nicon.y, 26, 26)
- end
- def update_player
- @player.x = $game_player.x * 5
- @player.y = $game_player.y * 5
- end
- def update_events
- for key in @events.keys
- event = @events[key]
- mapevent = $game_map.events[key]
- if @enemys[key]
- event.visible = !mapevent.erased
- next if !event.visible
- end
- event.x = mapevent.x * 5
- event.y = mapevent.y * 5
- end
- end
- def update_netplayers
- if @oldmpp != Network.players.values.compact
- @oldmpp = Network.players.values.compact
- @netplayers.clear
- for key in Network.players.values.compact
- @netplayers[key] = Sprite.new(@view)
- @netplayers[key].z = 1003
- @netplayers[key].bitmap = RPG::Cache.minimap("OPlayers")
- end
- end
- for key in Network.players.values.compact
- next unless @netplayers[key]
- @netplayers[key].x = key.x * 5
- @netplayers[key].y = key.y * 5
- end
- end
- def update_view
- if $game_player.x >= 11 and (@pass.bitmap.width - 60) >= @player.x
- if $game_player.direction == 6
- @view.ox += 5
- elsif $game_player.direction == 4
- @view.ox -= 5
- end
- elsif $game_player.x <= 10
- @view.ox = 0
- end
- if $game_player.y >= 11 and (@pass.bitmap.height- 60) >= @player.y
- if $game_player.direction == 2
- @view.oy += 5
- elsif $game_player.direction == 8
- @view.oy -= 5
- end
- elsif $game_player.y <= 10
- @view.oy = 0
- end
- end
- # Verificação do Icone
- def update_icon
- return unless Input.trigger?(Input::Key['Mouse Left'])
- @show_players = !@show_players
- @nicon.bitmap = @show_players ? RPG::Cache.minimap("Players") : RPG::Cache.minimap("PlayersOFF")
- if @show_players
- @netplayers.clear
- for key in Network.players.values.compact
- @netplayers[key] = Sprite.new(@view)
- @netplayers[key].z = 1003
- @netplayers[key].bitmap = RPG::Cache.minimap("OPlayers")
- end
- else
- for mp in @netplayers.values
- mp.dispose if !@show_players
- end
- end
- end
- # Metodo dispose
- def dispose
- @bg.dispose
- @pass.dispose
- @player.dispose
- @nicon.dispose
- for event in @events.values
- event.dispose
- end
- for mp in @netplayers.values
- mp.dispose
- end
- end
- # Ajuste de posicionamento
- def moving?
- if $game_player.x != @gplayer_x or $game_player.y != @gplayer_y
- @gplayer_x = $game_player.x
- @gplayer_y = $game_player.y
- return true
- end
- return false
- end
- # Redesenhar Eventos
- def redraw_events
- for event in @events.values
- event.dispose
- end
- @events.clear
- draw_events
- end
- end
- # Insere o minimapa na cena
- class Scene_Map
- alias main_gminimap main
- alias update_gminimap update
- alias transfer_gminimap transfer_player
- attr_accessor :mini_map
- attr_accessor :mini_map_active
- def main
- @mini_map_active = true
- @mini_map = Global_Minimap.new(true)
- main_gminimap
- @mini_map.dispose
- end
- def update
- update_gminimap
- if Input.trigger?(Input::Key['M'])
- return if $typing
- @mini_map_active = !@mini_map_active
- if @mini_map_active
- @mini_map = Global_Minimap.new(@mini_map.show_players)
- else
- @mini_map.dispose
- end
- end
- @mini_map.update if @mini_map_active
- end
- def transfer_player
- transfer_gminimap
- if @mini_map_active
- @mini_map.dispose
- @mini_map = Global_Minimap.new(@mini_map.show_players)
- end
- end
- end
- # Game_Event
- class Game_Event
- alias refresh_gminimap refresh
- def refresh
- refresh_gminimap
- $scene.mini_map.redraw_events if $scene.is_a?(Scene_Map) and $scene.mini_map_active
- end
- end
- # Modulo de RPG::Cache.minimap
- module RPG
- module Cache
- def self.minimap(filename)
- self.load_bitmap("Graphics/Pictures/Minimapa/", filename)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement