Advertisement
Black_Mage

Galv Map Positions Script Addon/Edit

Jan 8th, 2020
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.27 KB | None | 0 0
  1. # Require Galv Map Position Script
  2. # https://galvs-scripts.com/2012/11/07/map-positions/
  3.  
  4. # This script is an edit on certain method of Galv Map Position script. It
  5. # enable the use of custom graphic for each event instead a common one for all
  6. # event like the original does.
  7.  
  8. # To use the aforementioned feature, set EVENT_LOCATION_MARKERS value as 0 in
  9. # Galv Map Position script. Put this
  10. # <map_icon pic_name>
  11. # on comment command on the event that going to use a custom picture, where
  12. # pic_name is the name of the picture located on the Pictures folder. Make sure
  13. # that the comment is not the first command on the event or it will appear as
  14. # the name of the event on the galv's map.
  15.  
  16. class Scene_ViewMap < Scene_MenuBase
  17.   def create_event_blips
  18.     return if $game_map.markers[$game_map.map_id].nil?
  19.     m = $game_map.markers[$game_map.map_id]
  20.     event_count = m.count; @event_blip = {}; @event_text = {}
  21.     if Galv_Map::EVENT_LOCATION_MARKERS == 1
  22.  
  23.       event_count.times { |i|
  24.         if !$game_map.events[m[i]].nil?
  25.           @tile_id = $game_map.events[m[i]].tile_id
  26.           @event_text_color = Galv_Map::EVENT_TEXT_COLOR
  27.           @event_blip[i+1] = Sprite.new
  28.  
  29.           if @tile_id > 0
  30.             sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
  31.             sy = @tile_id % 256 / 8 % 16 * 32;
  32.             @event_blip[i+1].bitmap = tileset_bitmap(@tile_id)
  33.             @event_blip[i+1].src_rect.set(sx, sy, 32, 32)
  34.             cw = @event_blip[i+1].src_rect.width
  35.             ch = @event_blip[i+1].src_rect.height
  36.           else
  37.             @event_blip[i+1].bitmap = Cache.character($game_map.events[m[i]].character_name)
  38.             sign = $game_map.events[m[i]].character_name[/^[\!\$]./]
  39.             if sign && sign.include?('$')
  40.               cw = @event_blip[i+1].bitmap.width / 3
  41.               ch = @event_blip[i+1].bitmap.height / 4
  42.             else
  43.               cw = @event_blip[i+1].bitmap.width / 12
  44.               ch = @event_blip[i+1].bitmap.height / 8
  45.             end
  46.             n = $game_map.events[m[i]].character_index
  47.             case $game_map.events[m[i]].direction
  48.             when 2; dir = 0; when 4; dir = ch; when 6; dir = ch * 2; when 8; dir = ch * 3; end
  49.             pat = $game_map.events[m[i]].pattern; pat = 1 if pat > 2
  50.             @event_blip[i+1].src_rect = Rect.new((n%4*3 + pat)*cw, (n/4*4)*ch + dir, cw, ch)
  51.           end
  52.           @event_blip[i+1].x = (($game_map.events[m[i]].x / @scale_x.to_f).to_f * 32) + @map.x.to_f - (cw.to_f / 2).to_f + 4
  53.           @event_blip[i+1].y = (($game_map.events[m[i]].y / @scale_y.to_f).to_f * 32) + @map.y.to_f - (ch.to_f / 2).to_f + 4
  54.           @event_blip[i+1].bitmap.blt(0 - cw / 2, 0 - ch, @event_blip[i+1].bitmap, @event_blip[i+1].src_rect)
  55.  
  56.           if $game_map.events[m[i]].list[0].code == 108
  57.             @show_text = $game_map.events[m[i]].list[0].parameters[0]
  58.             @show_text = convert_escape_characters(@show_text)
  59.             @event_text[i+1] = Sprite.new
  60.             @event_text[i+1].bitmap = Bitmap.new(150, Galv_Map::EVENT_TEXT_SIZE)
  61.             @event_text[i+1].bitmap.font.size = Galv_Map::EVENT_TEXT_SIZE
  62.             @event_text[i+1].bitmap.font.color.set(text_color(@event_text_color))
  63.             @event_text[i+1].bitmap.draw_text(@event_text[i+1].bitmap.rect, @show_text, 1)
  64.             @event_text[i+1].x = (($game_map.events[m[i]].x / @scale_x.to_f).to_f * 32) + @map.x.to_f - (@event_text[i+1].bitmap.width.to_f / 2).to_f + 5
  65.             @event_text[i+1].y = (($game_map.events[m[i]].y / @scale_y.to_f).to_f * 32) + @map.y.to_f - (@event_text[i+1].bitmap.height.to_f / 2).to_f + (ch / 1.5).to_f
  66.  
  67.           end
  68.         end        
  69.       }
  70.  
  71.     else
  72.       event_count.times { |i|
  73.         @event_text_color = Galv_Map::EVENT_TEXT_COLOR
  74.         if !$game_map.events[m[i]].nil?
  75.           @event_blip[i+1] = Sprite.new
  76.           a = Galv_Map::EVENT_IMAGE
  77.           $game_map.events[m[i]].list.each do |command|
  78.             a = $1 if command.code == 108 && command.parameters[0] =~ /<map_icon (.+)>/
  79.           end
  80.           @event_blip[i+1].bitmap = Cache.picture(a)
  81.           @event_blip[i+1].x = (($game_map.events[m[i]].x / @scale_x.to_f).to_f * 32) + @map.x.to_f - (@event_blip[i+1].bitmap.width / 2).to_f + 4
  82.           @event_blip[i+1].y = (($game_map.events[m[i]].y / @scale_y.to_f).to_f * 32) + @map.y.to_f - (@event_blip[i+1].bitmap.height / 2).to_f + 4
  83.  
  84.           if $game_map.events[m[i]].list[0].code == 108
  85.             @show_text = $game_map.events[m[i]].list[0].parameters[0]
  86.             @show_text = convert_escape_characters(@show_text)
  87.             @event_text[i+1] = Sprite.new
  88.             @event_text[i+1].bitmap = Bitmap.new(150, Galv_Map::EVENT_TEXT_SIZE)
  89.             @event_text[i+1].bitmap.font.size = Galv_Map::EVENT_TEXT_SIZE
  90.             @event_text[i+1].bitmap.font.color.set(text_color(@event_text_color))
  91.             @event_text[i+1].bitmap.draw_text(@event_text[i+1].bitmap.rect, @show_text, 1)
  92.             @event_text[i+1].x = (($game_map.events[m[i]].x / @scale_x.to_f).to_f * 32) + @map.x.to_f - (@event_text[i+1].bitmap.width.to_f / 2).to_f + 5
  93.             @event_text[i+1].y = (($game_map.events[m[i]].y / @scale_y.to_f).to_f * 32) + @map.y.to_f + (@event_blip[i+1].bitmap.height / 2)
  94.           end
  95.         end
  96.       }
  97.     end
  98.   end
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement