Minimap for XP

Started by Exiled_by_choise, April 11, 2009, 04:15:06 am

Previous topic - Next topic

Exiled_by_choise

April 11, 2009, 04:15:06 am Last Edit: April 15, 2009, 03:39:20 am by Exiled_by_choise
I would like the minimap from Blizz ABS but without using Blizz ABS I asked Blizzard how he did it and he said it's just like the minimap on Tons of addons but better looking. So I was wondering if you could make me something every similar to the Blizz ABS minimap.
I'm using RPG Maker XP
Here are some images of the Blizz ABS minimap from The chronicals of Sir Lag-a-lot
Spoiler: ShowHide

Now I want there to be some distinction between different types of events like save, player, teleport, random people you can talk to and if I want there will be the occasional enemy that you can see. I also want the ability to change these colours at will.

Here is the script section from Tons if you need to look at it (take in mind that it needs all of Tons to work).
]#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Dynamic Passability Minimap by Blizzard
# Version: 1.01b
# Type: Game Playability Improvement
# Date: 7.2.2007
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
#   95% compatible with SDK v1.x. 60% compatible with SDK v2.x. This add-on
#   NEEDS "Quick Passability Test" by Blizzard. WILL corrupt your old
#   savegames. Might not work with special map add-ons. Does NOT work with
#   pixel-movement without changing the code.
#
#
# Why this minimap script better is than any other (aka features):
#
#   - simple display to avoid lag
#   - custom size, position and opacity, changeable even during the game
#   - no bitmaps, no pictures to import, only plain script
#
#
# Explanation:
#
#   This add-on will draw a real-time minimap on the specified X and Y
#   coordinate on your screen. It will show the player, events that do NOT have
#   a comment in their code that says "no_minimap", that are not parallel
#   process and that are not auto-start and that are not erased yet. Events
#   with a teleport/transfer player command will be shown in a different color.
#   Any event with and comment with "special" in their code will be also
#   displayed differently. Blizz-ABS disables this add-on automatically and
#   uses the more enhanced built-in Blizz-ABS Minimap.
#
#
# Instructions:
#
#   You can trigger the minimap visible/invisible with F5 during the game.
#   Set up the starting configuration below. The colors follow a template of:
#
#     WHAT_COLOR = Color.new(R, G, B)
#
#   R - red
#   G - green
#   B - blue
#
#   Change the colors of the dots on the map as you prefer it.
#
#   PLAYER_COLOR    - the player on the minimap
#   EVENT_COLOR     - any event on the minimap that is not erased, is not
#                     auto-start, is not parallel process and does not have a
#                     comment in its code with the word "no_minimap"
#   TELEPORT_COLOR  - any event like the one above, but that has a teleport/
#                     transfer_player command
#   SPECIAL_COLOR   - any event with a comment with the word "special"
#   MINIMAP_X       - default X of the minimap on the screen
#   MINIMAP_Y       - default Y of the minimap on the screen
#   MINIMAP_WIDTH   - default maximal allowed width of the minimap
#   MINIMAP_HEIGHT  - default maximal allowed height of the minimap
#   MINIMAP_OPACITY - default opacity of the minimap on the screen
#
#   You have the possibility to change the minimap's size, coordinates and
#   opacity during the game process. The command you need to type in into a
#   "Call Script" command window are:
#
#     $game_system.mini_coos(X, Y)
#     $game_system.mini_size(W, H)
#     $game_system.mini_opaq(A)
#
#   X - new X
#   Y - new Y
#   W - new width
#   H - new height
#   A - new opacity
#
#   Any changes will be applied instantly. Note that you don't need to use ALL
#   commands.
#
#
# Note:
#
#   Changing X, Y and opacity during the game will result in just moving the
#   sprite. The minimap will not work if the maximal allowed size is smaller
#   than the map size. (i.e. if your minimap is 160x120, maps like 170x130,
#   180x15 or 20x140 will not work.)
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Start Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

PLAYER_COLOR = Color.new(0, 255, 0)
EVENT_COLOR = Color.new(0, 128, 255)
TELEPORT_COLOR = Color.new(255, 255, 0)
SPECIAL_COLOR = Color.new(255, 0, 0)
MINIMAP_X = 0
MINIMAP_Y = 0
MINIMAP_WIDTH = 160
MINIMAP_HEIGHT = 160
MINIMAP_OPACITY = 96

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# End Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

if $quick_pass != true
  p 'Attention! Minimap is missing a vital add-on! Application will now close!'
  exit
end

#==============================================================================
# Game_System
#==============================================================================

class Game_System
 
  attr_reader   :minimap_x
  attr_reader   :minimap_y
  attr_reader   :minimap_w
  attr_reader   :minimap_h
  attr_reader   :minimap_a
  attr_accessor :minimap_visible
 
  alias init_minimap_later initialize
  def initialize
    init_minimap_later
    @minimap_visible = true
    @minimap_x = [[MINIMAP_X, 0].max, 640].min
    @minimap_y = [[MINIMAP_Y, 0].max, 480].min
    @minimap_w = [[MINIMAP_WIDTH, 0].max, 640].min
    @minimap_h = [[MINIMAP_HEIGHT, 0].max, 480].min
    @minimap_a = [[MINIMAP_OPACITY, 0].max, 255].min
  end
 
  def mini_coos(x, y)
    @minimap_x, @minimap_y = [[x, 0].max, 640].min, [[y, 0].max, 480].min
  end
 
  def mini_size(w, h)
    @minimap_w, @minimap_h = [[w, 0].max, 640].min, [[h, 0].max, 480].min
    $game_map.setup_passability_net
  end
 
  def mini_opaq(a)
    @minimap_a = [[a, 0].max, 255].min
  end
 
end

#==============================================================================
# Game_Event
#==============================================================================

class Game_Event
 
  attr_reader :erased
 
  def conditions
    @event.pages.reverse.each {|page|
        c = page.condition
        next if c.switch1_valid && !$game_switches[c.switch1_id]
        next if c.switch2_valid && !$game_switches[c.switch2_id]
        if c.variable_valid
          next if $game_variables[c.variable_id] < c.variable_value
        end
        if c.self_switch_valid
          key = [@map_id, @event.id, c.self_switch_ch]
          next if $game_self_switches[key] != true
        end
        return true}
    return false
  end
 
end
 
#==============================================================================
# Minimap
#==============================================================================

class Minimap < RPG::Sprite
 
  def initialize(viewport = nil)
    super
    self.z = 10100
    create_minimap
  end
 
  def create_minimap
    coos = $game_map.passables
    @w, @h = $game_system.minimap_w, $game_system.minimap_h
    s = [@w / $game_map.width, @h / $game_map.height]
    @size = (s[0] > s[1] ? s[1] : s[0])
    if @size > 0
      self.bitmap = Bitmap.new(@size*$game_map.width, @size*$game_map.height)
      self.bitmap.fill_rect(0, 0, @w, @h, Color.new(0, 0, 0))
      color = Color.new(128, 128, 128)
      coos.each {|coo|
          self.bitmap.fill_rect(coo[0]*@size, coo[1]*@size, @size, @size, color)}
      @events = get_events
      create_sevents
      update
    else
      self.dispose
    end
  end
 
  def update
    super
    ev = get_events
    if ev != @events
      @events = ev
      destroy_sevents
      create_sevents
    end
    self.x, self.y = $game_system.minimap_x, $game_system.minimap_y
    self.opacity = $game_system.minimap_a
    @sevents.each_index {|i|
        @sevents[i].x = @events[i].x * @size + self.x
        @sevents[i].y = @events[i].y * @size + self.y
        @sevents[i].opacity = $game_system.minimap_a}
    if @w != $game_system.minimap_w || @h != $game_system.minimap_h
      self.bitmap.dispose
      destroy_sevents
      create_minimap
    end
  end
 
  def create_sevents
    @sevents = []
    @events.each_index {|i|
        sprite = RPG::Sprite.new
        sprite.bitmap = Bitmap.new(@size, @size)
        if @events[i].is_a?(Game_Player)
          color = PLAYER_COLOR
        elsif event_comment(@events[i], 'special')
          color = SPECIAL_COLOR
        elsif @events[i].list != nil && @events[i].list.any? {|j| j.code == 201}
          color = TELEPORT_COLOR
        else
          color = EVENT_COLOR
        end
        sprite.bitmap.fill_rect(0, 0, @size, @size, color)
        sprite.z = 10200
        @sevents.push(sprite)}
  end
   
  def destroy_sevents
    @sevents.each {|i| i.dispose}
    @sevents = nil
  end
 
  def get_events
    events = [$game_player]
    $game_map.events.each_value {|event|
        if !event.erased && ![3, 4].include?(event.trigger) &&
            !event_comment(event, 'no_minimap') && event.conditions
          events.push(event)
        end}
    return events
  end
 
  def event_comment(event, comment)
    return false unless event.list.is_a?(Array)
    return (event.list.any? {|c| c.code == 108 && c.parameters[0] == comment})
  end
 
  def dispose
    destroy_sevents if @sevents != nil
    super
  end
 
end

#==============================================================================
# Scene_Map
#==============================================================================

class Scene_Map
 
  alias main_minimap_later main
  def main
    @minimap = Minimap.new if $game_system.minimap_visible
    main_minimap_later
    @minimap.dispose if @minimap != nil
  end
 
  alias upd_minimap_later update
  def update
    upd_minimap_later
    return if $BlizzABS && BlizzABS::VERSION >= 1.20
    if $game_system.MINIMAP
      if @minimap != nil
        if Input.trigger?(Input::F5)
          @minimap.dispose
          @minimap = nil
          $game_system.minimap_visible = false
        else
          @minimap.update
        end
      elsif Input.trigger?(Input::F5)
        @minimap = Minimap.new
        if @minimap.disposed?
          $game_system.minimap_visible = false
          @minimap = nil
        else
          $game_system.minimap_visible = true
        end
      end
    end
  end
 
  alias transfer_player_minimap_later transfer_player
  def transfer_player
    if $game_system.minimap_visible
      @minimap.dispose
      @minimap = nil
    end
    transfer_player_minimap_later
    @minimap = Minimap.new if $game_system.minimap_visible
    if @minimap != nil && @minimap.disposed?
      @minimap = nil
      $game_system.minimap_visible = false
    end
  end
 
end

fugibo

Use a [code][/code] tag please

Reno-s--Joker

I know of another Minimap script which does all this.
If you're interested then I'll try and find out where I got it from.

Exiled_by_choise

Quote from: Reno-s--Batman on April 11, 2009, 07:18:32 am
I know of another Minimap script which does all this.
If you're interested then I'll try and find out where I got it from.

If you could that would be great.

Fantasist

@Reno: If you're talking about Selwyn's minimap script, it has no way of taking care of lag on large maps which the Blizz-ABS minimap does.
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Exiled_by_choise

Quote from: Mirage on April 15, 2009, 04:45:51 am
@Reno: If you're talking about Selwyn's minimap script, it has no way of taking care of lag on large maps which the Blizz-ABS minimap does.

Damn coz I found Selwyn's script and I tested it on a small test map and it looks great.
But if you say that it lags on bigger maps then I might be in some trouble coz my biggest map is nearly 300 x 300.

If any1 wants the minimap by Selwyn then heres the link for it http://www.rmxp.org/forums/viewtopic.php?t=2930 but the images don't work.
But i found this translated site it has the script and the images but I just used the images.

Reno-s--Joker

Thanks Fant!! I wasn't aware of that. :D
And thanks for posting the link, Exiled_by_choise! Again, I didn't know that but I hope that if no one can help you with the BlizzABS map then the lag won't be too much trouble... >.<