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.

KyoTeleTrans XP - VX

KyoTeleTrans XP and VX
Version: 1.3
By: Kyonides
alias kyonides-arkanthos, shadowball

Introduction

Teleport Menu, shows a destination menu, a world map, city (names) sprites, a pointer among other things.

Features

  • Add and remove teleport destinations at will
  • Destinations may be disabled and reenabled at will
  • Make the destinations menu (dis-)appear (change a constant assigned value first)

Screenshots

XP Version
kyoteletransxp.png

kyoteletransxp1.png


VX Version
kyoteletransvx.png

kyoteletransvx1.png

Demo

Coming Soon...

Script

Code:
 

##==========================================================

##

##   KyoTeleTrans XP v 1.3.0  (20090328 - 0402)

##   by Kyonides  alias kyonides-arkanthos, shadowball

##

##==========================================================

=begin

  Instructions:

 

   Copy and paste the script above Main.

   To open the menu window press A or SHIFT button once.

   

   To make the destination menu visible:

   

   MenuVisible = true

   

   To make the destination menu disappear:

   

   MenuVisible = false

   

   To create a destination entry for your party a new array is needed

   

   Campment = ['Campment', DE01, 1, 7, 13, 0, 0, 40, 160]

   

   Array Values Description:

   

   Place = [

     Name, Description, MapID, MapX, MapY, Character direction on map, 

     City Sprite, CityX, CityY

   ]

   

   I personally encourage the use of Constants whenever it's possible,

   except for number values.

 

   You don't know where to get the MapX and MapY coordinates?

   Take a look at the bottom of the RPG Maker screen.

 

   #ID    Name    Dimensions  Coord. X,Y

   001: Campment   (21x18)     010,014

 

  Script Calls

  

   You can also call the script by entering the following line:

   

   $scene = KyoTeleTrans.new

 

   Adding New Places to the $places variable

 

     KyoVocab.new_place =

     KyoVocab::NameOfDestination

 

   Forgetting previously saved Destinations

 

     KyoVocab.forget_place =

     KyoVocab::NameOfDestination

 

   The path is blocked, you can go there...

 

     KyoVocab.forbidden = 'Name of Location'

     

   The path is now open, you may travel to X destination...

   

     KyoVocab.available = 'Name of Location'

 

   You may use Constants for the names of all destinations, i.e.

   

   Loc01 = 'My Workplace'

 

=end

module KyoVocab

  # Destination Menu Visible or Invisible

  MenuVisible = true

  # Mapa Sprite (Small One): Width 372, Height 304 px

  MAP = 'mini_mapaxp' if MenuVisible

  # Map Sprite (Large One): Width 640, Height 304 px

  MAP = 'gran_mapaxp' if MenuVisible == false

  # Constant for A Simple Question

  QUESTION = 'Where do you want to go now?'

  # Lands or Countries

  Land01 = 'Kaythege'

  # Places Constants

  Loc01 = 'Campamento'

  Loc02 = 'Cementerio'

  Loc03 = 'Montaña'

  # Sprites

  Pic01 = 'city01'

  Pic02 = 'city02'

  Pic03 = 'city03'

  Pic04 = 'city04'

  Pic05 = 'city05'

  Pic06 = 'city06'

  Pic07 = 'city01'

  Pic08 = 'mountain'

  # Descriptions (Strings)

  DE01 = 'Great community of 4 tents only...'

  DE02 = 'Last home for many losers like...'

  DE03 = 'One of the most dangerous cliffs...'

  # Available Places

  Campment = [Loc01, DE01, 1, 7, 13, 0, Pic01,  60, 168]

  Graveyard = [Loc02, DE02, 2, 9, 17, 0, Pic02,  88,  88]

  Mountain  = [Loc03, DE03, 3, 8,  5, 0, Pic08, 160, 140]

  NoPlace   = ['No Destinations']

  $places = [Graveyard, Montain]

  $forbidden = [Loc01]

  # Other Constants

  X, Y, Pointer, Error = 28, 16, 'sword', 'wrong'

  # Save new destination if not included already

  def self.new_place=(place)

    $places.push place if !$places.include?(place)

  end

  # Forget destination if already included

  def self.forget_place=(place)

    $places.delete place if $places.include?(place)

  end

  # Cannot travel to x destination if forbidden

  def self.forbidden=(place)

    $forbidden.push place if !$forbidden.include?(place)

  end

  # Cannot now travel to x destination, restriction lifted / waived

  def self.available=(place)

    $forbidden.delete place if $forbidden.include?(place)

  end

end

# Pointer Sprite Class

class Sprite_KyoArrow < Sprite

  def initialize(viewport)

    @viewport = viewport

    super(@viewport)

    self.x, self.y, self.z = x+8, y-16, 1000

  end

  

  def show_arrow(x,y) # Show Pointer if player can travel

    self.bitmap = RPG::Cache.picture(KyoVocab::Sword)

    self.x, self.y = x+8, y-16

    return

  end

  

  def show_cross(x,y) # Show error mark if forbidden

    self.bitmap = RPG::Cache.picture(KyoVocab::Error)

    self.x, self.y = x-4, y-8

    return

  end

end

# City Sprite Class

class Sprite_KyoCity < Sprite

  def initialize(viewport,picture,index,x,y,ox=0,oy=0)

    @viewport = viewport

    @viewport.z = 2500

    super(@viewport)

    # Use instance variables instead of global ones, create arrey

    @index, @places, @forbidden, @disabled = index, $places, $forbidden, []

    self.bitmap = RPG::Cache.picture(picture)

    self.x, self.y = x, y

    self.ox, self.oy = ox, oy

    self.zoom_x, self.zoom_y = 0.45, 0.45

    refresh

  end

  

  def dispose

    self.bitmap.dispose

    super

  end

  

  def disabled?(index)

    if @disabled.include?(index)

      return true

    else

      return false

    end

  end

  

  def refresh

    # If a location is forbidden, push its value into

    # disabled locations array

    if @forbidden.include?(@places[@index][0])

      @disabled.push @index if !@disabled.include?(@index)

      self.opacity = 128

    else

      self.opacity = 255

    end

  end

end

# City Name Sprite Class (shown on destination map)

class Sprite_KyoCityName < Sprite

  def initialize(viewport, city, x, y, index)

    super(viewport)

    @city, @index, @disabled = city, index, []

    # Use instance variables instead of global ones

    @places, @forbidden = $places, $forbidden

    self.bitmap = Bitmap.new(92, 44)

    self.bitmap.font.name = 'Arial'

    self.bitmap.font.size = 16

    self.x, self.y, self.z = x, y, 200

    update

  end

  

  def dispose

    self.bitmap.dispose

    super

  end

  

  def disabled?(index)

    if @disabled.include?(index)

      return true

    else

      return false

    end

  end

  

  def update

    super

    self.visible = true

    self.bitmap.font.bold = true

    # If a location is forbidden, push its value into

    # disabled locations array

    if @forbidden.include?(@places[@index][0])

      @disabled.push @index if !@disabled.include?(@index)

      self.bitmap.font.color.set(255,255,255,128)

    else

      self.bitmap.font.color.set(255,255,255,255)

    end

    self.bitmap.draw_text(self.bitmap.rect, @city, 1)

  end

end

# Window_Help Class Replacement

class Window_KyoHelp < Window_Base

  def initialize(x=180, y=416, w=460) # Default Values

    super(x, y, w, 64) # (X, Y, Width values required)

    self.contents = Bitmap.new(width - 32, height - 32)

  end

  

  def set_text(text, align=0, color=0)

    if text != @text or align != @align

      self.contents.clear

      self.contents.font.color = normal_color if color == 0

      self.contents.font.color = system_color if color == 1

      self.contents.draw_text(0, 0, self.width - 40, 32, text, align)

      @text = text

      @align = align

      @actor = nil

    end

    self.visible = true

  end

end

 

class Window_KyoTeleTrans < Window_Selectable

  include KyoVocab

  def initialize(x=0, y=64)

    super(x, y, 180, 352) #(0, 128, 180, 352)

    @column_max = 1

    # Use instance variables instead of global ones, create array

    @places, @forbidden, @disabled = $places, $forbidden, []

    # Make window disappear if MenuVisible value is false

    self.opacity, self.back_opacity = 0, 0 if MenuVisible == false

    refresh

    self.index = 0

  end

 

  def all_places # get contents of places array

    return @places

  end

 

  def place # get all contents of a single destination array

    return @places[self.index]

  end

  

  def place_name(index) # get destination name

    return @places[index][0]

  end

  

  def description # get destination description

    return @places[self.index][1]

  end

  

  def map_id(index) # get new MapID

    return @places[index][2]

  end

  

  def map_x(index) # get new map X coordinate

    return @places[index][3]

  end

  

  def map_y(index) # get new map Y coordinate

    return @places[index][4]

  end

  

  def char_dir(index) # get character sprite direction

    return @places[index][5]

  end

  

  def sprite(index) # get city sprite name

    return @places[index][6]

  end

  

  def city_x(index) # get city X coordinate on dest. map

    return @places[index][7]

  end

  

  def city_y(index) # get city Y coordinate on dest. map

    return @places[index][8]

  end

  

  def disabled?(index) # check forbidden destinations array

    if @disabled.include?(index)

      return true

    else

      return false

    end

  end

 

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    # If no place found, create temporary array

    @item_max = NoPlace.size if @places.empty?

    # Get places array values size if it's not empty

    @item_max = @places.size if !@places.empty?

    if @item_max > 0

      self.contents = Bitmap.new(width - 32, row_max * 32)

      for i in 0...@item_max

        draw_place(i)

      end

    else

      self.contents.draw_text(4, 0, 212, 32, NoHay[0], 0)

    end

  end

 

  def draw_place(index)

    x = 4 + index % 1 * (288 + 32)

    y = index * 32

    # Destination Travel Permit Check

    if @forbidden.include?(place_name(index))

      @disabled.push index if !@disabled.include?(index)

      self.contents.font.color = disabled_color

    elsif @places.empty? and MenuVisible

      self.contents.font.color = normal_color

    end

    if !@places.empty? and MenuVisible

      self.contents.draw_text(4, y, 212, 32, place_name(index), 0)

    elsif @places.empty? and MenuVisible

      self.contents.font.color = disabled_color

      self.contents.draw_text(4, y, 212, 32, NoHay[0], 0)

    elsif MenuVisible == false

      self.contents.font.color.alpha = 0

    end

  end

  # Modified Parent Class Method - Pointer position and visibility

  def update_cursor_rect

    if @index < 0 or MenuVisible == false # If MenuVisible is false

      self.cursor_rect.empty # Menu cursor is invisible

      return

    end

    row = @index / @column_max

    if row < self.top_row

      self.top_row = row

    end

    if row > self.top_row + (self.page_row_max - 1)

      self.top_row = row - (self.page_row_max - 1)

    end

    cursor_width = self.width / @column_max - 32

    x = @index % @column_max * (cursor_width + 32)

    y = @index / @column_max * 32 - self.oy

    self.cursor_rect.set(x, y, cursor_width, 32)

  end

 

  def update_help # Update Current Destination Description

    @help_window.set_text(self.place == nil ? "" : description)

  end

end

 

# if =begin and =end are commented out you have the script calls

# for adding a new destination to the list may look like in the

# examples on the Instructions section above.

#   KyoVocab.new_place = Campment

# If not commented out, you may call a script function like this:

#   new_place = Campment

 

#=begin

class Interpreter;  include KyoVocab;  end

#=end

class KyoTeleTrans

  include KyoVocab

  def initialize

    @kyon_active_teletransport = false

  end

 

  def main

    #@spriteset = Spriteset_Map.new

    @map = Sprite.new 

    @map.bitmap = RPG::Cache.picture(MAP)

    @map.x, @map.y = 180, 64 if MenuVisible

    @map.x, @map.y =   0, 64 if MenuVisible == false

    # Show Country Name - To be improved in future releases

    @country_window = Window_KyoHelp.new(0,416,180)

    @country_window.set_text(Land01,1,1)

    @question_window = Window_Help.new

    @question_window.set_text(QUESTION,1)

    @help_window = Window_KyoHelp.new

    # Available Destinations Menu Window

    @teletrans_window = Window_KyoTeleTrans.new

    # Link TeleTrans Window to Window_Help Window

    @teletrans_window.help_window = @help_window

    create_places_sprites

    Graphics.transition(60, "Graphics/Transitions/015-Diamond01")

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self;  break;  end

    end

    Graphics.freeze

    dispose_places_sprites

    @country_window.dispose

    @question_window.dispose

    @help_window.dispose

    @teletrans_window.dispose

    @map.dispose

    unless @kyon_active_teletransport

      Graphics.transition(60, "Graphics/Transitions/015-Diamond01")

    else

      Graphics.transition(60, "Graphics/Transitions/006-Stripe02")

    end

    #@spriteset.dispose

  end

  

  def create_places_sprites # Create City and City Name Sprites

    @places_sprites, @places_names = [], []

    # Map, Cursor and Places Viewport if menu is visible

    @view = Viewport.new(180, 64, 372, 320) if MenuVisible

    # Map, Cursor and Places Viewport if menu is invisible

    @view = Viewport.new(0, 64, 640, 320)   if MenuVisible == false

    # Default Pointer location on Destination Map

    x = @teletrans_window.city_x(0)

    y = @teletrans_window.city_y(0)

    @arrow = Sprite_KyoArrow.new(@view)

    @arrow.show_arrow(x,y)

    for i in 0...@teletrans_window.all_places.size

      x = @teletrans_window.city_x(i)

      y = @teletrans_window.city_y(i)

      city_name = @teletrans_window.place_name(i) # Get city name

      @sprite = @teletrans_window.sprite(i)   # Get its sprite filename

      # If Sprite name is nil, randomly select a custom sprite filename

      random_city_picture(@teletrans_window.sprite(i)) if @sprite == nil

      # Sprites de Ciudades y Otros Lugares

      @places_sprites.push(Sprite_KyoCity.new(@view, @sprite, i, x, y))

      # Leyendas de Nombres de Ciudades y Otros Lugares

      name_sprite = Sprite_KyoCityName.new(@view, city_name, x-X, y+Y, i)

      @places_names.push(name_sprite)

    end

  end

  # Dispose City, City name and Pointer Sprites

  def dispose_places_sprites

    (@places_sprites+@places_names).each {|sprite| sprite.dispose}

    @arrow.dispose

  end

  # If Sprite name is nil, randomly select a custom sprite filename

  def random_city_picture(sprite=nil)

    case rand(7) # Random Value Assignment

    when 0,1; @sprite = 'city01'

    when 2;   @sprite = 'city02'

    when 3;   @sprite = 'city03'

    when 4;   @sprite = 'city04'

    when 5;   @sprite = 'city05'

    when 6;   @sprite = 'city06'

    when 7;   @sprite = 'city07'

    end

  end

  

  def update

    @arrow.update

    @country_window.update

    @question_window.update

    @help_window.update

    @teletrans_window.update

    @index = @teletrans_window.index

    if @teletrans_window.active;  update_places;  return;  end

  end

  

  def update_places

    update_arrow

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      @kyon_active_teletransport = false

      $scene = Scene_Map.new

      return

    end

    if Input.trigger?(Input::C)

      if $places.size == 0 or @teletrans_window.disabled?(@index)

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      $game_system.se_play($data_system.decision_se)

      # Interruptor para cambiar Efecto de Transición

      @kyon_active_teletransport = true

      # Procesar teletransportación

      $game_temp.player_transferring = true

      $game_temp.player_new_map_id = @teletrans_window.map_id(@index)

      $game_temp.player_new_x = @teletrans_window.map_x(@index)

      $game_temp.player_new_y = @teletrans_window.map_y(@index)

      $game_temp.player_new_direction = @teletrans_window.char_dir(@index)

      Graphics.freeze

      $game_temp.transition_processing = true

      $scene = Scene_Map.new

      #$game_temp.transition_name = "015-Diamond01"

      return

    end

  end

  # Change pointer if next location is available or grayed out

  def update_arrow

    if @index != @i

      if @teletrans_window.disabled?(@index)

        @arrow.show_cross(@teletrans_window.city_x(@index),

            @teletrans_window.city_y(@index))

      else

        @arrow.show_arrow(@teletrans_window.city_x(@index), 

            @teletrans_window.city_y(@index))

      end

      @i = @index

    end

  end

end

 

class Scene_Map

  alias kyon_sm_up update

  def update

    # If player press A or SHIFT button, call script

    if Input.trigger?(Input::A) or Input.trigger?(Input::Z)

      $game_system.se_play($data_system.decision_se)

      $scene = KyoTeleTrans.new # Go to Dest. Map and Menu Scene

      return

    end

    kyon_sm_up

  end

end

 

class Scene_Save  

  alias kyon_write_save_data write_save_data

  def write_save_data(file)

    kyon_write_save_data(file)

    # Saved non-standard global variables

    Marshal.dump($places, file)

    Marshal.dump($forbidden, file)

  end

end

 

class Scene_Load

  alias kyon_read_save_data read_save_data

  def read_save_data(file)

    kyon_read_save_data(file)

    # Load non-standard global variables

    $places    = Marshal.load(file)

    $forbidden = Marshal.load(file)

  end

end

Instructions

Copy and paste the script above Main. Change the settings in module KyoVocab if needed. Create arrays like in the examples included in the Instructions section.

FAQ

You tell me...

Compatibility

You tell me...

Author's Notes

Version 1.3

Included a common menu that could be invisible, two available options for the world map (a small and a large one) depending on current MenuVisible constant assigned value, a pointer (for available and disabled destinations), some city and city name sprites. Same 4 functions calls included. Changed the scene class script and created 3 new custom Sprite classes. Modified 2 default classes script methods. Bug fixes.

If no city sprite filename provided (the respective value is equal to nil), the script may select random one.

In the future the world map graphic may change depending on the region you're currently looking at, i.e. "The Lowlands" or "The Highlands".

Version 1.2

Included a common menu and a world map, some city and city name sprites but no pointer. 4 functions calls included. Bug fixes.

Version 1.1

Included a common menu and a world map, no pointer, city and city name sprites. 3 functions calls included. Bug fixes.

Version 1.0

It just included a common menu and no world map, no pointer, city and city name sprites. I only included one or two functions calls.

Terms and Conditions

Not intended for Commercial Use.
Include my name in your projects if you'll going to include it there.
Only I, shadowball alias Kyonides, kyonides-arkanthos can post this script on any forum.
 
New Version! 1.3.1 release is out!

I edited the script to fix some errors that were reported on another forum, I also change the code a little bit to make it look more simple.

Here's the script

Code:
##==========================================================

##

##   KyoTeleTrans XP v 1.3.1  (20090328 - 0405)

##   by Kyonides  alias kyonides-arkanthos, shadowball

##

##==========================================================

<span style="color:#000080; font-style:italic;">=begin

<span style="color:#000080; font-style:italic;">  Instructions:

 

<span style="color:#000080; font-style:italic;">   Copy and paste the script above Main.

<span style="color:#000080; font-style:italic;">   To open the menu window press A or SHIFT button once.

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">   To make the destination menu visible:

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">   MenuVisible = true

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">   To make the destination menu disappear:

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">   MenuVisible = false

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">   To create a destination entry for your party a new array is needed

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">   Campment = ['Campment', DE01, 1, 7, 13, 0, 0, 40, 160]

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">   Array Values Description:

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">   Place = [

<span style="color:#000080; font-style:italic;">     Name, Description, MapID, MapX, MapY, Character direction on map, 

<span style="color:#000080; font-style:italic;">     City Sprite, CityX, CityY

<span style="color:#000080; font-style:italic;">   ]

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">   I personally encourage the use of Constants whenever it's possible,

<span style="color:#000080; font-style:italic;">   except for number values.

 

<span style="color:#000080; font-style:italic;">   You don't know where to get the MapX and MapY coordinates?

<span style="color:#000080; font-style:italic;">   Take a look at the bottom of the RPG Maker screen.

 

<span style="color:#000080; font-style:italic;">   #ID    Name    Dimensions  Coord. X,Y

<span style="color:#000080; font-style:italic;">   001: Campment   (21x18)     010,014

 

<span style="color:#000080; font-style:italic;">  Script Calls

<span style="color:#000080; font-style:italic;">  

<span style="color:#000080; font-style:italic;">   You can also call the script by entering the following line:

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">   $scene = KyoTeleTrans.new

 

<span style="color:#000080; font-style:italic;">   Adding New Places to the $places variable

 

<span style="color:#000080; font-style:italic;">     KyoVocab.new_place =

<span style="color:#000080; font-style:italic;">     KyoVocab::NameOfDestination

 

<span style="color:#000080; font-style:italic;">   Forgetting previously saved Destinations

 

<span style="color:#000080; font-style:italic;">     KyoVocab.forget_place =

<span style="color:#000080; font-style:italic;">     KyoVocab::NameOfDestination

 

<span style="color:#000080; font-style:italic;">   The path is blocked, you can go there...

 

<span style="color:#000080; font-style:italic;">     KyoVocab.forbidden = 'Name of Location'

<span style="color:#000080; font-style:italic;">     

<span style="color:#000080; font-style:italic;">   The path is now open, you may travel to X destination...

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">     KyoVocab.available = 'Name of Location'

 

<span style="color:#000080; font-style:italic;">   You may use Constants for the names of all destinations, i.e.

<span style="color:#000080; font-style:italic;">   

<span style="color:#000080; font-style:italic;">   Loc01 = 'My Workplace'

 

<span style="color:#000080; font-style:italic;">=end

module KyoVocab

  # Destination Menu Visible or Invisible

  MenuVisible = true

  # Map Sprite (Small One): Width 372, Height 304 px

  MAP = 'mini_mapaxp' if MenuVisible

  # Map Sprite (Large One): Width 640, Height 304 px

  MAP = 'gran_mapaxp' if !MenuVisible

  # Constant for A Simple Question

  QUESTION = 'Where do you want to go now?'

  # Lands or Countries

  Land01 = 'Kaythege'

  # Places Constants

  Loc01 = 'Camp'

  Loc02 = 'Graveyard'

  Loc03 = 'Mountain'

  # Sprites

  Pic01 = 'city01'

  Pic02 = 'city02'

  Pic03 = 'city03'

  Pic04 = 'city04'

  Pic05 = 'city05'

  Pic06 = 'city06'

  Pic07 = 'city01'

  Pic08 = 'mountain'

  # Descriptions (Strings)

  DE01 = 'Great community of 4 tents only...'

  DE02 = 'Last home for many losers like...'

  DE03 = 'One of the most dangerous cliffs...'

  # Available Places

  Campment = [Loc01, DE01, 1, 7, 13, 0, Pic01,  60, 168]

  Graveyard = [Loc02, DE02, 2, 9, 17, 0, Pic02,  88,  88]

  Mountain  = [Loc03, DE03, 3, 8,  5, 0, Pic08, 160, 140]

  NoPlace   = ['No Destinations']

  $places = [Graveyard, Montain]

  $forbidden = [Loc01]

  # Other Constants

  X, Y, Pointer, Error = 28, 16, 'sword', 'wrong'

  # Save new destination if not included already

  def self.new_place=(place)

    $places.push place if !$places.include?(place)

  end

  # Forget destination if already included

  def self.forget_place=(place)

    $places.delete place if $places.include?(place)

  end

  # Cannot travel to x destination if forbidden

  def self.forbidden=(place)

    $forbidden.push place if !$forbidden.include?(place)

  end

  # Cannot now travel to x destination, restriction lifted / waived

  def self.available=(place)

    $forbidden.delete place if $forbidden.include?(place)

  end

end

# Pointer Sprite Class

class Sprite_KyoArrow < Sprite

  def initialize(viewport)

    @viewport = viewport

    super(@viewport)

    self.x, self.y, self.z = x+8, y-16, 1000

  end

  

  def show_arrow(x,y) # Show Pointer if player can travel

    self.bitmap = RPG::Cache.picture(KyoVocab::Sword)

    self.x, self.y = x+8, y-16

    return

  end

  

  def show_cross(x,y) # Show error mark if forbidden

    self.bitmap = RPG::Cache.picture(KyoVocab::Error)

    self.x, self.y = x-4, y-8

    return

  end

end

# City Sprite Class

class Sprite_KyoCity < Sprite

  def initialize(viewport,picture,index,x,y,ox=0,oy=0)

    @viewport = viewport

    @viewport.z = 2500

    super(@viewport)

    # Use instance variables instead of global ones, create arrey

    @index, @places, @forbidden, @disabled = index, $places, $forbidden, []

    self.bitmap = RPG::Cache.picture(picture)

    self.x, self.y = x, y

    self.ox, self.oy = ox, oy

    self.zoom_x, self.zoom_y = 0.45, 0.45

    refresh

  end

  

  def dispose

    self.bitmap.dispose

    super

  end

  

  def disabled?(index)

    if @disabled.include?(index)

      return true

    else

      return false

    end

  end

  

  def refresh

    # If a location is forbidden, push its value into

    # disabled locations array

    if @forbidden.include?(@places[@index][0])

      @disabled.push @index if !@disabled.include?(@index)

      self.opacity = 128

    else

      self.opacity = 255

    end

  end

end

# City Name Sprite Class (shown on destination map)

class Sprite_KyoCityName < Sprite

  def initialize(viewport, city, x, y, index)

    super(viewport)

    @city, @index, @disabled = city, index, []

    # Use instance variables instead of global ones

    @places, @forbidden = $places, $forbidden

    self.bitmap = Bitmap.new(92, 44)

    self.bitmap.font.name = 'Arial'

    self.bitmap.font.size = 16

    self.x, self.y, self.z = x, y, 200

    update

  end

  

  def dispose

    self.bitmap.dispose

    super

  end

  

  def disabled?(index)

    if @disabled.include?(index)

      return true

    else

      return false

    end

  end

  

  def update

    super

    self.visible = true

    self.bitmap.font.bold = true

    # If a location is forbidden, push its value into

    # disabled locations array

    if @forbidden.include?(@places[@index][0])

      @disabled.push @index if !@disabled.include?(@index)

      self.bitmap.font.color.set(255,255,255,128)

    else

      self.bitmap.font.color.set(255,255,255,255)

    end

    self.bitmap.draw_text(self.bitmap.rect, @city, 1)

  end

end

# Window_Help Class Replacement

class Window_KyoHelp < Window_Base

  def initialize(x=180, y=416, w=460) # Default Values

    super(x, y, w, 64) # (X, Y, Width values required)

    self.contents = Bitmap.new(width - 32, height - 32)

  end

  

  def set_text(text, align=0, color=0)

    if text != @text or align != @align

      self.contents.clear

      self.contents.font.color = normal_color if color == 0

      self.contents.font.color = system_color if color == 1

      self.contents.draw_text(0, 0, self.width - 40, 32, text, align)

      @text = text

      @align = align

      @actor = nil

    end

    self.visible = true

  end

end

 

class Window_KyoTeleTrans < Window_Selectable

  include KyoVocab

  def initialize(x=0, y=64)

    super(x, y, 180, 352) #(0, 128, 180, 352)

    @column_max = 1

    # Use instance variables instead of global ones, create array

    @places, @forbidden, @disabled = $places, $forbidden, []

    # Make window disappear if MenuVisible value is false

    self.opacity, self.back_opacity = 0, 0 if MenuVisible == false

    refresh

    self.index = 0

  end

 

  def all_places # get contents of places array

    return @places

  end

 

  def place # get all contents of a single destination array

    return @places[self.index]

  end

  

  def place_name(index) # get destination name

    return @places[index][0]

  end

  

  def description # get destination description

    return @places[self.index][1]

  end

  

  def map_id(index) # get new MapID

    return @places[index][2]

  end

  

  def map_x(index) # get new map X coordinate

    return @places[index][3]

  end

  

  def map_y(index) # get new map Y coordinate

    return @places[index][4]

  end

  

  def char_dir(index) # get character sprite direction

    return @places[index][5]

  end

  

  def sprite(index) # get city sprite name

    return @places[index][6]

  end

  

  def city_x(index) # get city X coordinate on dest. map

    return @places[index][7]

  end

  

  def city_y(index) # get city Y coordinate on dest. map

    return @places[index][8]

  end

  

  def disabled?(index) # check forbidden destinations array

    if @disabled.include?(index)

      return true

    else

      return false

    end

  end

 

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    # If no place found, create temporary array

    @item_max = NoPlace.size if @places.empty?

    # Get places array values size if it's not empty

    @item_max = @places.size if !@places.empty?

    if @item_max > 0

      self.contents = Bitmap.new(width - 32, row_max * 32)

      for i in 0...@item_max

        draw_place(i)

      end

    else

      self.contents.draw_text(4, 0, 212, 32, NoHay[0], 0)

    end

  end

 

  def draw_place(index)

    x = 4 + index % 1 * (288 + 32)

    y = index * 32

    # Destination Travel Permit Check

    if !@places.empty? and @forbidden.include?(place_name(index))

      @disabled.push index if !@disabled.include?(index)

      self.contents.font.color = disabled_color

    elsif !@places.empty? and MenuVisible

      self.contents.font.color = normal_color

    end

    if !@places.empty? and MenuVisible

      self.contents.draw_text(4, y, 212, 32, place_name(index), 0)

    elsif @places.empty? and MenuVisible

      self.contents.font.color = disabled_color

      self.contents.draw_text(4, y, 212, 32, NoHay[0], 0)

    elsif !MenuVisible

      self.contents.font.color.alpha = 0

    end

  end

  # Modified Parent Class Method - Pointer position and visibility

  def update_cursor_rect

    if @index < 0 or MenuVisible == false # If MenuVisible is false

      self.cursor_rect.empty # Menu cursor is invisible

      return

    end

    row = @index / @column_max

    if row < self.top_row

      self.top_row = row

    end

    if row > self.top_row + (self.page_row_max - 1)

      self.top_row = row - (self.page_row_max - 1)

    end

    cursor_width = self.width / @column_max - 32

    x = @index % @column_max * (cursor_width + 32)

    y = @index / @column_max * 32 - self.oy

    self.cursor_rect.set(x, y, cursor_width, 32)

  end

 

  def update_help # Update Current Destination Description

    @help_window.set_text(self.place == nil ? "" : description)

  end

end

 

# if =begin and =end are commented out you have the script calls

# for adding a new destination to the list may look like in the

# examples on the Instructions section above.

#   KyoVocab.new_place = Campment

# If not commented out, you may call a script function like this:

#   new_place = Campment

 

#=begin

class Interpreter;  include KyoVocab;  end

#=end

class KyoTeleTrans

  include KyoVocab

  def initialize

    @kyon_active_teletransport = false

  end

 

  def main

    #@spriteset = Spriteset_Map.new

    @map = Sprite.new 

    @map.bitmap = RPG::Cache.picture(MAP)

    @map.x, @map.y = 180, 64 if MenuVisible

    @map.x, @map.y =   0, 64 if !MenuVisible

    # Show Country Name - To be improved in future releases

    @country_window = Window_KyoHelp.new(0,416,180)

    @country_window.set_text(Land01,1,1)

    @question_window = Window_Help.new

    @question_window.set_text(QUESTION,1)

    @help_window = Window_KyoHelp.new

    # Available Destinations Menu Window

    @teletrans_window = Window_KyoTeleTrans.new

    # Link TeleTrans Window to Window_Help Window

    @teletrans_window.help_window = @help_window

    create_places_sprites

    Graphics.transition(60, "Graphics/Transitions/015-Diamond01")

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self;  break;  end

    end

    Graphics.freeze

    dispose_places_sprites

    @country_window.dispose

    @question_window.dispose

    @help_window.dispose

    @teletrans_window.dispose

    @map.dispose

    unless @kyon_active_teletransport

      Graphics.transition(60, "Graphics/Transitions/015-Diamond01")

    else

      Graphics.transition(60, "Graphics/Transitions/006-Stripe02")

    end

    #@spriteset.dispose

  end

  

  def create_places_sprites # Create City and City Name Sprites

    @places_sprites, @places_names = [], []

    # Map, Cursor and Places Viewport if menu is visible

    @view = Viewport.new(180, 64, 372, 320) if MenuVisible

    # Map, Cursor and Places Viewport if menu is invisible

    @view = Viewport.new(0, 64, 640, 320)   if !MenuVisible

    if !@teletrans_window.all_places.empty?

      # Default Pointer location on Destination Map

      x = @teletrans_window.city_x(0)

      y = @teletrans_window.city_y(0)

      @arrow = Sprite_KyoArrow.new(@view)

      @arrow.show_arrow(x,y)

      for i in 0...@teletrans_window.all_places.size

        x = @teletrans_window.city_x(i)

        y = @teletrans_window.city_y(i)

        city_name = @teletrans_window.place_name(i) # Get city name

        @sprite = @teletrans_window.sprite(i)   # Get its sprite filename

        # If Sprite name is nil, randomly select a custom sprite filename

        random_city_picture(@teletrans_window.sprite(i)) if @sprite == nil

        # Sprites de Ciudades y Otros Lugares

        @places_sprites.push(Sprite_KyoCity.new(@view, @sprite, i, x, y))

        # Leyendas de Nombres de Ciudades y Otros Lugares

        name_sprite = Sprite_KyoCityName.new(@view, city_name, x-X, y+Y, i)

       @places_names.push(name_sprite)

      end

    end

  end

  # Dispose City, City name and Pointer Sprites

  def dispose_places_sprites

    (@places_sprites+@places_names).each {|sprite| sprite.dispose}

    @arrow.dispose if !@teletrans_window.all_places.empty?

  end

  # If Sprite name is nil, randomly select a custom sprite filename

  def random_city_picture(sprite=nil)

    case rand(7) # Random Value Assignment

    when 0,1; @sprite = 'city01'

    when 2;   @sprite = 'city02'

    when 3;   @sprite = 'city03'

    when 4;   @sprite = 'city04'

    when 5;   @sprite = 'city05'

    when 6;   @sprite = 'city06'

    when 7;   @sprite = 'city07'

    end

  end

  

  def update

    @arrow.update if !@teletrans_window.all_places.empty?

    @country_window.update

    @question_window.update

    @help_window.update

    @teletrans_window.update

    @index = @teletrans_window.index

    if @teletrans_window.active;  update_places;  return;  end

  end

  

  def update_places

    update_arrow if !@teletrans_window.all_places.empty?

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      @kyon_active_teletransport = false

      $scene = Scene_Map.new

      return

    end

    if Input.trigger?(Input::C)

      if $places.size == 0 or @teletrans_window.disabled?(@index)

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      $game_system.se_play($data_system.decision_se)

      # Interruptor para cambiar Efecto de Transición

      @kyon_active_teletransport = true

      # Procesar teletransportación

      $game_temp.player_transferring = true

      $game_temp.player_new_map_id = @teletrans_window.map_id(@index)

      $game_temp.player_new_x = @teletrans_window.map_x(@index)

      $game_temp.player_new_y = @teletrans_window.map_y(@index)

      $game_temp.player_new_direction = @teletrans_window.char_dir(@index)

      Graphics.freeze

      $game_temp.transition_processing = true

      $scene = Scene_Map.new

      #$game_temp.transition_name = "015-Diamond01"

      return

    end

  end

  # Change pointer if next location is available or grayed out

  def update_arrow

    if @index != @i

      if @teletrans_window.disabled?(@index)

        @arrow.show_cross(@teletrans_window.city_x(@index),

            @teletrans_window.city_y(@index))

      else

        @arrow.show_arrow(@teletrans_window.city_x(@index), 

            @teletrans_window.city_y(@index))

      end

      @i = @index

    end

  end

end

 

class Scene_Map

  alias kyon_sm_up update

  def update

    # If player press A or SHIFT button, call script

    if Input.trigger?(Input::A) or Input.trigger?(Input::Z)

      $game_system.se_play($data_system.decision_se)

      $scene = KyoTeleTrans.new # Go to Dest. Map and Menu Scene

      return

    end

    kyon_sm_up

  end

end

 

class Scene_Save  

  alias kyon_write_save_data write_save_data

  def write_save_data(file)

    kyon_write_save_data(file)

    # Saved non-standard global variables

    Marshal.dump($places, file)

    Marshal.dump($forbidden, file)

  end

end

 

class Scene_Load

  alias kyon_read_save_data read_save_data

  def read_save_data(file)

    kyon_read_save_data(file)

    # Load non-standard global variables

    $places    = Marshal.load(file)

    $forbidden = Marshal.load(file)

  end

end
 
No I didn't. I just edited the post and suddenly all of its contents were wiped out. I hope it doesn't mean a mod should take a look at the post once again... Man, I understand that they may need to check if a script meets the minimum requirements to be posted on the forum but not for a second time just after it has been approved once...
 

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