New account registration is temporarily disabled.

WRITING A VX ACE SCRIPT WHERE SPECIALLY-TAGGED MAPS SHOW MINI CHARACTERS; HAVING TROUBLE

Posts

Pages: 1
so the idea is that I want my overworld map to show teeny-tiny characters, instead of their regular sprites. to make this a feature EVERYONE could use, I set out to make my own script, complete with tags an everything. it's my first time making something so extensive from scratch (I've mostly done simple method replacements), and I'm running into trouble...

if anyone else is interested in such a script, or just wants to help out :D, I could really use the help! I feel like I'm very close, but missing something basic or critical.

I've written this script with this thought-process:
* each character keeps track of whether it's in mini mode or not
* a character in mini mode uses a mini character set, instead of their normal graphic set
* when a player switches maps, if the new map has the <minimap> tag, then all party members are put into mini mode; otherwise, they are put into non-mini mode

I've pasted my script below, and inserted a ton of comments to explain what I'm doing... if it doesn't make sense, definitely feel free to ask me!

class Game_Actor
  #--------------------------------------------------------------------------
  # * Initialize Graphics
  #--------------------------------------------------------------------------
  def init_graphics
    @character_name = actor.character_name
    @character_index = actor.character_index
    @face_name = actor.face_name
    @face_index = actor.face_index

    # above is the normal init_graphics
    
    # this is my addition:
    @true_character_name = @character_name
    @true_character_index = @character_index
    @mini = false
  end
  
  #--------------------------------------------------------------------------
  # * Change Graphics
  #--------------------------------------------------------------------------
  def set_graphic(character_name, character_index, face_name, face_index)
    
    # okay: if the character ISN'T mini, we change their graphic
    if !@mini
      @character_name = character_name
      @character_index = character_index
    end
    
    # regardless, we always change their "true" graphic
    @true_character_name = character_name
    @true_character_index = character_index

    # normal code
    @face_name = face_name
    @face_index = face_index
  end
  
  # custom method: if we call mini!(true), then we change the
  # character graphics to be our custom mini graphic. if we call
  # mini!(false), then we set the character graphics to their
  # "true" graphics.
  def mini!(mini)
    if mini
      @character_name = "$player minimap.png"
      @character_index = 0
    else
      @character_name = @true_character_name
      @character_index = @true_character_index
    end
    
    @mini = mini
  end
  
end

class Scene_Map
  #--------------------------------------------------------------------------
  # * Player Transfer Processing
  #--------------------------------------------------------------------------
  def perform_transfer
    pre_transfer
    $game_player.perform_transfer
    
    # inserted this line, to handle minimaps
    do_minimap_transformation
    
    post_transfer
  end
  
  # minimap handler
  # we call mini! on each party member, passing true when the map
  # is a mini map, and false when it's not
  def do_minimap_transformation
    $game_party.members.each { |x|
      x.mini!($game_map.minimap?)
    }
  end

end

class Game_Map

  # minimap? check for maps. if minimap is nil (hasn't been determined yet),
  # then we call check_for_minimap_tag
  def minimap?
    check_for_minimap_tag if @minimap.nil?
    return @minimap
  end
  
  # and here's the tag check, where we mark the map as mini if its
  # note contains "<minimap>"
  def check_for_minimap_tag
    if @map.note.match(/<minimap>/i)
      @minimap = true
    else
      @minimap = false
    end
  end

end

# custom method: if we call mini!(true), then we change the
# character graphics to be our custom mini graphic. if we call
# mini!(false), then we set the character graphics to their
# "true" graphics.
def mini!(mini)
if mini
@character_name = "$player minimap.png"
@character_index = 0
else
@character_name = @true_character_name
@character_index = @true_character_index
end
$game_player.refresh
@mini = mini
end

end

You forgot the refresh :P, could paste that after the do_minimap_transformation too
Also imo, I think it would be easier to just add a suffix.
so it would be

if mini
@character_name = @true_character_name+"_Mini"
@character_index = 0
else
...
Used true_character_name instead of character_name, to avoid _Mini stacking, not sure if it would stack but just to be safe lol
you are a hero! I had no idea about the refresh method!

having a mini version for each character is smart, too, and something most people will probably like. for my purposes, it is not needed, but when I post the script on rmn, I will include it (with thanks to you!), since, again, this functionality will probably appeal to a lot of people.

I also noticed that my method for checking for the minimap tag was not quite correct, but I fixed that up.

I also discovered a funny side-effect: when you save, if you're on a minimap, then the save shows the mini versions of all your characters! 'makes sense in retrospect, but it is a little silly :P

anyway, thanks again!
No problem, I tend to forget a lot of the little things as well and I spend hours to figure out I forgot to call a method somewhere :P

And I'd agree, this script would be pretty nice for over world maps, very simple to use too.
submitted! assuming the script is approved, it will appear at http://rpgmaker.net/scripts/400/ :)

in the meanwhile...

# tag maps with <minimap> to make your party take on a different look while
# on that map! you'll need to provide "_Mini" versions of your character
# sprites, for example if you have a character in spritesheet "Actor1",
# then this script will look to "Actor1_Mini" for the mini version.
#
# see line 58 for some extra options.
#
# by Ben(telk) [url]http://benmakesgames.com[/url]
# and huge thanks to Quasi for helping out

class Game_Actor
  #--------------------------------------------------------------------------
  # * Initialize Graphics
  #--------------------------------------------------------------------------
  def init_graphics
    @character_name = actor.character_name
    @character_index = actor.character_index
    @face_name = actor.face_name
    @face_index = actor.face_index
    # above is the normal init_graphics
    
    # this is the addition for the script:
    @true_character_name = @character_name
    @true_character_index = @character_index
    @mini = false
  end
  
  #--------------------------------------------------------------------------
  # * Change Graphics
  #--------------------------------------------------------------------------
  def set_graphic(character_name, character_index, face_name, face_index)
    
    # okay: if the character ISN'T mini, we change their graphic...
    if !@mini
      @character_name = character_name
      @character_index = character_index
    end
    
    # ... regardless, we always change their "true" graphic.
    @true_character_name = character_name
    @true_character_index = character_index

    # normal code
    @face_name = face_name
    @face_index = face_index
  end
  
  # custom method: if we call mini!(true), then we change the
  # character graphics to be our custom mini graphic. if we call
  # mini!(false), then we set the character graphics to their
  # "true" graphics.
  def mini!(mini)
    if mini

      # each character has their own mini version:
      @character_name = @true_character_name + "_Mini"

      # comment out the above line, and uncomment the next two, to make party
      # members all use the SAME mini sprite (rename "$minimap player"
      # to match the name of the sprite sheet you will actually use!)

      #@character_name = "$minimap player"
      #@character_index = 0

    else
      @character_name = @true_character_name
      @character_index = @true_character_index
    end
    
    $game_player.refresh
    
    @mini = mini
  end
  
end

class Scene_Map
  #--------------------------------------------------------------------------
  # * Player Transfer Processing
  #--------------------------------------------------------------------------
  def perform_transfer
    pre_transfer
    $game_player.perform_transfer
    
    # inserted this line, to handle entering/leaving minimaps
    do_minimap_transformation
    
    post_transfer
  end
  
  # minimap handler
  # we call mini! on each party member, passing true when the map
  # is a mini map, and false when it's not
  def do_minimap_transformation
    $game_party.members.each { |x|
      x.mini!($game_map.minimap?)
    }
  end

end

class Game_Map
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def setup(map_id)
    @map_id = map_id
    @map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
    @tileset_id = @map.tileset_id
    @display_x = 0
    @display_y = 0
    referesh_vehicles
    setup_events
    setup_scroll
    setup_parallax
    setup_battleback
    @need_refresh = false
    # normal code above

    # addition for this script:
    if @map.note.match(/<minimap>/i).nil?
      @minimap = false
    else
      @minimap = true
    end
  end

  # added method to check minimap status; used by Scene_Map
  def minimap?
    @minimap
  end

end
Pages: 1