Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Simple City Navigation Script

Xk8

Member

Been a while since i submitted a script. (I submitted a party switching script in April, but nobody cared T_T)

I released this script on a request in the Screenshot forum.

This is how it is seen in my game:

http://img300.imageshack.us/img300/4275 ... eenmx8.jpg[/img]

This is how it is seen as a bald script, with no editing:

http://img502.imageshack.us/img502/7607 ... iptxp1.jpg[/img]

Note that i took out the option to go the main menu. It's too much of a hassle, and incompatible with the saving option, without editing
other scripts.

This is the script. Instructions are included. Just paste the script above Main. Terms for usage is simply crediting me.

Code:
=begin
City Navigation Menu by Xk8 (Level: Simple) Give Credit to use.

I made this script out of a custom script for my project. It was requested
from the Screenshot topic. I made it as easy to use as possible (At the cost
of practical scripting.)

In this script, your 'capital' will have 10 areas. e.g. Castle, Residential
areas, Shop District etc.

If you want more areas, figure it out for yourself, it's to tedious to type,
and it's easy to understand.

How to use:

FIRST: @variable_id_desc = 1 #use an empty variable here
  use a non-used variable number here. It is used to determine 
  which option to be selected and link it to it's description.
  
  First editable = Area Descriptions, this is what you see at '4' in the 
  screenshot
  
  Second editable = 'Where do you want to go' at line 89, seen at '1'
  
  Third editable = show the actor graphic, as seen at '5', this can be done
  at line 115
  
  Fourth Editable = Names of the maps you can teleport to,  starting
  at line 129
  
  Fifth Editable The name of the background at line 141. This must be in 
  the panorama folder. '6'
  
  Sixth Editable = Icon names, starting at line 149, see '3'
  
  Seventh Editable = The names of the maps as seen at '2'. line 227
  
  All the maps you teleport to, will automatically teleport you to 
  the coordinates (0, 0). You can change this per map. Find these lines
  
  $game_player.moveto(0, 0)
  
  at the bottom of Scene_City. These are the coordinates per map. 'when 0'
  being area 1 and so on.
  
  CALL THE SCRIPT WITH THIS COMMAND: $scene = Scene_City.new
=end
class Window_Citydesc < Window_Base
  
  attr_accessor :variable_id_desc
  
  def initialize
    super(0, 0, 400, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 100
    @variable_id_desc = 1 #use an empty variable here
    refresh
  end
  
  def refresh
    if $game_variables[@variable_id_desc] == 0
      desc = "Description of Area 1." #These are the area descriptions
    elsif $game_variables[@variable_id_desc] == 1 
      desc = "Description of Area 2." #These are editable
    elsif $game_variables[@variable_id_desc] == 2
      desc = "Description of Area 3."
    elsif $game_variables[@variable_id_desc] == 3
      desc = "Description of Area 4."
    elsif $game_variables[@variable_id_desc] == 4
      desc = "Description of Area 5."
    elsif $game_variables[@variable_id_desc] == 5
      desc = "Description of Area 6."
    elsif $game_variables[@variable_id_desc] == 6
      desc = "Description of Area 7."
    elsif $game_variables[@variable_id_desc] == 7
      desc = "Description of Area 8."
    elsif $game_variables[@variable_id_desc] == 8
      desc = "Description of Area 9."
    elsif $game_variables[@variable_id_desc] == 9
      desc = "Description of Area 10."
    end
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 640, 32, desc)
  end
end

class Window_Command_City < Window_Selectable
  
  def initialize(width, commands)
   
    super(0, 0, width, commands.size * 32 + 64)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(width - 32, @item_max * 32 + 32)
    refresh
    self.index = 0
  end
  
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(4, 32 * index + 32, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    
    self.contents.draw_text(rect, @commands[index])
    
    self.contents.draw_text(4, 0, 160, 32, "Where do you want to go?")
  end
  
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  
  def update_cursor_rect
    self.cursor_rect.set(0, @index * 32 + 32, self.width - 32, 32)
  end
end

class Window_CityStatus < Window_Selectable
 
  def initialize
    super(0, 0, 480, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    refresh
    self.active = false
    self.index = -1
  end
  
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
       actor = $game_party.actors[i]
      draw_actor_graphic(actor,i * 64 + 20, 60) #Show the actor graphic
    end
  end
end


class Scene_City
 
  def initialize(menu_index = 0)
    @menu_index = menu_index
    @area_name_1 = "MAP001" #These are the map names of the 
    @area_name_2 = "MAP002" #possible areas
    @area_name_3 = "MAP003" #edit these to the names of your areas
    @area_name_4 = "MAP004"
    @area_name_5 = "MAP005"
    @area_name_6 = "MAP006"
    @area_name_7 = "MAP007"
    @area_name_8 = "MAP008"
    @area_name_9 = "MAP009"
    @area_name_10 = "MAP010"
    
    @backdrop_name = "006-Mountains01" #the name of the PANORAMA used as 
                                  #background for your city navigation.
                                  
    @icon_name1 = "019-accessory04" #these are the icons you see
    @icon_name2 = "001-Weapon01"    #left of the options. editable.
    @icon_name3 = "009-Shield01"
    @icon_name4 = "041-Item10"
    @icon_name5 = "032-Item01"
    @icon_name6 = "042-Item11"
    @icon_name7 = "042-Item11"
    @icon_name8 = "042-Item11"
    @icon_name9 = "042-Item11"
    @icon_name10 = "025-Herb01"
  end
 
  def main
    @backdrop = Sprite.new
    @backdrop.bitmap = RPG::Cache.panorama(@backdrop_name, $game_map.panorama_hue)
    
    @icon1 = Sprite.new
    @icon1.bitmap = RPG::Cache.icon(@icon_name1)
    @icon1.x = 42
    @icon1.y = 96
    @icon1.z = 9999
    
    @icon2 = Sprite.new
    @icon2.bitmap = RPG::Cache.icon(@icon_name2)
    @icon2.x = 42
    @icon2.y = 128
    @icon2.z = 9999
    
    @icon3 = Sprite.new
    @icon3.bitmap = RPG::Cache.icon(@icon_name3)
    @icon3.x = 42
    @icon3.y = 160
    @icon3.z = 9999
    
    @icon4 = Sprite.new
    @icon4.bitmap = RPG::Cache.icon(@icon_name4)
    @icon4.x = 42
    @icon4.y = 192
    @icon4.z = 9999
    
    @icon5 = Sprite.new
    @icon5.bitmap = RPG::Cache.icon(@icon_name5)
    @icon5.x = 42
    @icon5.y = 224
    @icon5.z = 9999
    
    @icon6 = Sprite.new
    @icon6.bitmap = RPG::Cache.icon(@icon_name6)
    @icon6.x = 42
    @icon6.y = 256
    @icon6.z = 9999
    
    @icon7 = Sprite.new
    @icon7.bitmap = RPG::Cache.icon(@icon_name7)
    @icon7.x = 42
    @icon7.y = 288
    @icon7.z = 9999
    
    @icon8 = Sprite.new
    @icon8.bitmap = RPG::Cache.icon(@icon_name8)
    @icon8.x = 42
    @icon8.y = 320
    @icon8.z = 9999
    
    @icon9 = Sprite.new
    @icon9.bitmap = RPG::Cache.icon(@icon_name9)
    @icon9.x = 42
    @icon9.y = 352
    @icon9.z = 9999
    
    @icon10 = Sprite.new
    @icon10.bitmap = RPG::Cache.icon(@icon_name10)
    @icon10.x = 42
    @icon10.y = 384
    @icon10.z = 9999
    
    s1 = "Go to Area 1" #Names of the Areas on the menu. Editable.
    s2 = "Go to Area 2"
    s3 = "Go to Area 3"
    s4 = "Go to Area 4"
    s5 = "Go to Area 5"
    s6 = "Go to Area 6"
    s7 = "Go to Area 7"
    s8 = "Go to Area 8"
    s9 = "Go to Area 9"
    s10 = "Go to Area 10"
    @command_window = Window_Command_City.new(180, [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10])
    @command_window.index = @menu_index
    @command_window.opacity = 100
    @command_window.x = 50
    @command_window.y = 80 - 32
    
    @status = Window_CityStatus.new
    @status.x = 360
    @status.y = 390
    
    @desc = Window_Citydesc.new
    @desc.x = 230
    @desc.y = 80
    @desc.z = 9999
    @variable_id_desc = @desc.variable_id_desc
    
    Graphics.transition
    
    loop do
      Graphics.update
      Input.update
      update
      
      if $scene != self
        break
      end
    end
    
    Graphics.freeze
    
    @command_window.dispose
    @backdrop.dispose
    @icon1.dispose
    @icon2.dispose
    @icon3.dispose
    @icon4.dispose
    @icon5.dispose
    @icon6.dispose
    @icon7.dispose
    @icon8.dispose
    @icon9.dispose
    @icon10.dispose
    @status.dispose
    @desc.dispose
  end
  
  def update
    $game_variables[@variable_id_desc] = @command_window.index
    @desc.refresh
    @icon1.opacity = 100
    @icon2.opacity = 100
    @icon3.opacity = 100
    @icon4.opacity = 100
    @icon5.opacity = 100
    @icon6.opacity = 100
    @icon7.opacity = 100
    @icon8.opacity = 100
    @icon9.opacity = 100
    @icon10.opacity = 100
    case @command_window.index
       when 0
         @icon1.opacity = 255
         @desc.y = 80
       when 1
         @icon2.opacity = 255
         @desc.y = 80+32
       when 2
         @icon3.opacity = 255
         @desc.y = 80 + 64
       when 3
         @icon4.opacity = 255
         @desc.y = 80 + 96
        when 4
         @icon5.opacity = 255
         @desc.y = 80 + 128
        when 5
         @icon6.opacity = 255
         @desc.y = 80 + 160
        when 6
         @icon7.opacity = 255
         @desc.y = 80 + 192
        when 7
         @icon8.opacity = 255
         @desc.y = 80 + 224
        when 8
         @icon9.opacity = 255
         @desc.y =  80 + 256
        when 9
         @icon10.opacity = 255
         @desc.y = 80 + 288
     end
    
    @command_window.update
    if @command_window.active
      update_command
      return
    end
  end
  
  def update_command
    if Input.trigger?(Input::C)
       $map_infos = load_data("Data/MapInfos.rxdata")
    case @command_window.index
      when 0  
        $game_system.se_play($data_system.decision_se)
          for key in $map_infos.keys
            if $map_infos[key].name == @area_name_1
              $game_map.setup(key)
              $game_player.moveto(0, 0)
              $game_player.refresh
              $game_map.autoplay
              $game_map.update
              $scene = Scene_Map.new
            end
          end
      when 1  
        $game_system.se_play($data_system.decision_se)
          for key in $map_infos.keys
              if $map_infos[key].name == @area_name_2
                $game_map.setup(key)
                $game_player.moveto(0, 0)
                $game_player.refresh
                $game_map.autoplay
                $game_map.update
                $scene = Scene_Map.new
              end
            end
      when 2  
        $game_system.se_play($data_system.decision_se)
          for key in $map_infos.keys
              if $map_infos[key].name == @area_name_3
                $game_map.setup(key)
                $game_player.moveto(0, 0)
                $game_player.refresh
                $game_map.autoplay
                $game_map.update
                $scene = Scene_Map.new
              end
            end
      when 3  
        $game_system.se_play($data_system.decision_se)
          for key in $map_infos.keys
              if $map_infos[key].name == @area_name_4
                $game_map.setup(key)
                $game_player.moveto(0, 0)
                $game_player.refresh
                $game_map.autoplay
                $game_map.update
                $scene = Scene_Map.new
              end
            end
      when 4  
        $game_system.se_play($data_system.decision_se)
          for key in $map_infos.keys
              if $map_infos[key].name == @area_name_5
                $game_map.setup(key)
                $game_player.moveto(0, 0)
                $game_player.refresh
                $game_map.autoplay
                $game_map.update
                $scene = Scene_Map.new
              end
            end
      when 5  
        $game_system.se_play($data_system.decision_se)
          for key in $map_infos.keys
              if $map_infos[key].name == @area_name_6
                $game_map.setup(key)
                $game_player.moveto(0, 0)
                $game_player.refresh
                $game_map.autoplay
                $game_map.update
                $scene = Scene_Map.new
              end
            end
        when 6
          $game_system.se_play($data_system.decision_se)
          for key in $map_infos.keys
              if $map_infos[key].name == @area_name_7
                $game_map.setup(key)
                $game_player.moveto(0, 0)
                $game_player.refresh
                $game_map.autoplay
                $game_map.update
                $scene = Scene_Map.new
              end
            end
          when 7
            $game_system.se_play($data_system.decision_se)
          for key in $map_infos.keys
              if $map_infos[key].name == @area_name_8
                $game_map.setup(key)
                $game_player.moveto(0, 0)
                $game_player.refresh
                $game_map.autoplay
                $game_map.update
                $scene = Scene_Map.new
              end
            end
            when 8
              $game_system.se_play($data_system.decision_se)
          for key in $map_infos.keys
              if $map_infos[key].name == @area_name_9
                $game_map.setup(key)
                $game_player.moveto(0, 0)
                $game_player.refresh
                $game_map.autoplay
                $game_map.update
                $scene = Scene_Map.new
              end
            end
              when 9
                $game_system.se_play($data_system.decision_se)
          for key in $map_infos.keys
              if $map_infos[key].name == @area_name_10
                $game_map.setup(key)
                $game_player.moveto(0, 0)
                $game_player.refresh
                $game_map.autoplay
                $game_map.update
                $scene = Scene_Map.new
              end
            end
          end
      return
    end
  end
end

La~.
 

cairn

Member

dude, this was exactly what I was looking for! I was thinking of using trickster's teleport script, but this make things much easier! Good job! :thumb:
 

Xk8

Member

Glad to hear that. If people are -really- having trouble with adding or removing area's (default = 10), post it here, and I'll make a tutorial or such.
 
This is a cool script. You've just given me an idea for a little side project... Anyway, I have a few questions:
If you wanted to use this script for every town you come to, how do you make it so that different options are shown?
How do you show pictures (i.e. character picture(like in your screen)) in the background?
 

Xk8

Member

@fox5: Oh, I haven't made this for that option, you see, I made this specifically for my project, which only has one capital-city. I just released it for public on request, only editing it to be more user-friendly. I don't have plans to change it, since it was never intended to be a full fledged community script like that. Think of it as Lindblum in Final Fantasy IX.

An easy way to do it, however, is to do something like

case $game_variables 
 

Sabao

Sponsor

I don't like how the description box follows the cursor. I was hoping I could edit it myself so the box is in a fixed position somewhere at the bottom of the screen. I have very minor experience with scripting though, so pointing me to the right line and how it works might help.
 
Mmm...the script is good, but won't this just make game developers lazier? Say bye bye to exploring cities :<
Anyway, I suppose if anyone was making a picture-based game, then this is ACE! Good job.
 

Sabao

Sponsor

Necrile":6bpe4lhb said:
Mmm...the script is good, but won't this just make game developers lazier? Say bye bye to exploring cities :<
Anyway, I suppose if anyone was making a picture-based game, then this is ACE! Good job.
That'd really be a loss on the developer's end. It's a matter of knowing what and where to implement.
 
Mmm...the script is good, but won't this just make game developers lazier? Say bye bye to exploring cities :

Couldn't one also use this script to make a World Map though, kind of like FFX-2 or Shadow Hearts?
 

Jking

Member

this could be promising but i think tricksters teleport script could make a much more dynamic version of this but i must say if you want a fast easy way to make it so you can go were you want this is what you need (this would be perfect for contests and such things)
 

Xk8

Member

Thanks for feedback, guys. I love reading replies and critique.

As to not make the description window move along with the cursor:

on line 314, there's this line: @desc.y = 80

change the number (80) to any number you'd like. Do it for the @desc.y = x below too.

Or you could just do this:

@desc.y = x

right above @command_window.update on line 345.

=]
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top