Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Darkness

Teleportation Script

Recommended Posts

I want the script that can be the skill to use. Like,when I use the teleport skill, the list of the places I've visited will showed up and when I choose that place I'll go there. (if there's effect, it' good).

 

Is there any script like that?

Edited by Darkness

Share this post


Link to post
Share on other sites

hows this?

 

 

#==============================================================================#
# * Teleportation Selection												    #
#======================#=======================================================#
#   * Script Calls *   #
#======================#
#	 * $game_system.tele_array.push(LOCATION_ID)
#	    adds locations to be displayed as setup below in the config
#
#	 * $game_system.tele_array.delete(LOCATION_ID)
#	   removes said location
#
#	 * $scene = Scene_Tele.new
#	   calls the Scene, note if you call the scene without having any locations
#	   to teleport to it will throw an error
#
#==============================================================================#
#					 B E G I N   C O N F I G U R A T I O N				    #
#==============================================================================#
module Tele_Config
 HEADER_TEXT = 'please select a location'
 def self.tele_locations(location)
   case location
  #when TELE_LOCATION_ID then ['NAME', MAP_ID, X_POSITION, Y_POSSITION, DIRECTION]
  #--------------#
  #  directions  #
  #--------------#
  # 0 = unchanged
  # 2 = down
  # 4 = left
  # 6 = right
  # 8 = up
  #--------------#
   when 1 then ['TOWN 1', 2, 10, 10, 2]
   when 2 then ['TOWN 2', 1, 10, 10, 2]
   #ect
   end
 end
end
#===============================================================================
#					   E N D   C O N F I G U R A T I O N
#===============================================================================
class Game_System
 attr_accessor :tele_array
 alias tele_init initialize
 def initialize
   tele_init
   @tele_array = []
 end
end
class Window_Tele < Window_Selectable
 def initialize(width, commands)
   if commands.size <= 12
  super(0, 0, width, commands.size * 32 + 32)
   else
  super(0, 0, width, 416)
   end
   @item_max = commands.size
   @commands = commands
   self.contents = Bitmap.new(width - 32, @item_max * 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, self.contents.width - 8, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   self.contents.draw_text(rect, @commands[index], 1)
 end
end
class Window_Tele_Header < Window_Base
 def initialize
   super(0, 0, 320, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   text = Tele_Config::HEADER_TEXT
   cx = self.contents.text_size(text).width
   centre = ((width - 32) - cx) / 2
   self.contents.draw_text(centre, 0, cx, 32, text)
 end
end
class Scene_Tele
 def main
   choice_array = []
   @tele_array = $game_system.tele_array
   (0...@tele_array.size).each {|i|
  choice_array.push(Tele_Config.tele_locations(@tele_array[i])[0])
   }
   @tele_window = Window_Tele.new(320, choice_array)
   @tele_window.x = (640 - @tele_window.width) / 2
   @tele_window.y = 64
   @head_window = Window_Tele_Header.new
   @head_window.x = @tele_window.x
   @sprite = Spriteset_Map.new
   Graphics.transition
   loop { Graphics.update; Input.update; update; break if $scene != self }
   @tele_window.dispose
   @sprite.dispose
 end
 def update
   @tele_window.update
   if Input.trigger?(Input::B)
  $game_system.se_play($data_system.cancel_se)
  $scene = Scene_Map.new
   end
   if Input.trigger?(Input::C)
  $game_system.se_play($data_system.decision_se)
  key = Tele_Config.tele_locations(@tele_array[@tele_window.index])
  $scene = Scene_Map.new
  $game_temp.player_transferring = true
  $game_temp.player_new_map_id = key[1]
  $game_temp.player_new_x = key[2]
  $game_temp.player_new_y = key[3]
  $game_temp.player_new_direction = key[4]
   end
 end
end

 

 

theres an error as noted, i can change this later if you like to make a buzz noise if there no locations to go to, i can also add teleporting sounds ect if you like, just let me know any aditions you want, as for getting it used by skill, set your skill to call a common event, right now im tired so im of to bed :)

Edited by diagostimo

Share this post


Link to post
Share on other sites

ok i added said features and sorted the error, the script call is now "teleport":

 

 

#==============================================================================#
# * Teleportation Selection
#======================#=======================================================#
#  Author: Diagostimo  #
#----------------------#
#   * Script Calls *   #
#======================#
#	 * $game_system.tele_array.push(LOCATION_ID)
#	    adds locations to be displayed as setup below in the config
#
#	 * $game_system.tele_array.delete(LOCATION_ID)
#	   removes said location
#
#	 * teleport
#	   calls the tele menu, if no tele locations are available the failure
#	   sound will be played instead
#
#==============================================================================#
#					 B E G I N   C O N F I G U R A T I O N				    #
#==============================================================================#
module Tele_Config
 #note for transition images to work properly go into Scene_map, locate line
 #278 which should be Graphics.transition(20), change it to the following:
 =begin
   if $game_temp.transition_name == ""
  Graphics.transition(20)
   else
  Graphics.transition(40, "Graphics/Transitions/" +
  $game_temp.transition_name)
   end
 =end

 #set transitions true/false
 Transitions = true
 #set transition name, leave blank for normal fade
 Transition_name = '001-Blind01'
 #set the Scene failure sound(no tele locations)
 Failure_sound = '008-System08'
 #set the teleporting sound
 Tele_sound = '018-Teleport01'
 #set the headers text
 HEADER_TEXT = 'please select a location'
 def self.tele_locations(location)
   case location
  #when TELE_LOCATION_ID then ['NAME', MAP_ID, X_POSITION, Y_POSSITION, DIRECTION]
  #--------------#
  #  directions  #
  #--------------#
  # 0 = unchanged
  # 2 = down
  # 4 = left
  # 6 = right
  # 8 = up
  #--------------#
   when 1 then ['TOWN 1', 2, 10, 10, 2]
   when 2 then ['TOWN 2', 1, 10, 10, 2]
   #ect
   end
 end
end
#===============================================================================
#					   E N D   C O N F I G U R A T I O N
#===============================================================================
class Game_Temp
 attr_accessor :tele_calling
 attr_accessor :tele_key
 alias init_tele initialize
 def initialize
   init_tele
   @tele_calling = false
   @tele_key = nil
 end
end
class Game_System
 attr_accessor :tele_array
 alias tele_init initialize
 def initialize
   tele_init
   @tele_array = []
 end
end
class Interpreter
 def teleport
   if $game_system.tele_array != []
  $scene = Scene_Tele.new
   else
  Audio.se_play("Audio/SE/" + Tele_Config::Failure_sound, 100, 100)
   end
   @index += 1
   return false
 end
end
class Scene_Map
 alias update_tele update
 def update
   update_tele
   if $game_temp.tele_calling == true
  call_teleport
   end
 end
 def call_teleport
   $game_temp.tele_calling = false
   key = $game_temp.tele_key
   $game_temp.player_transferring = true
   $game_temp.player_new_map_id = key[1]
   $game_temp.player_new_x = key[2]
   $game_temp.player_new_y = key[3]
   $game_temp.player_new_direction = key[4]
   Audio.se_play("Audio/SE/" + Tele_Config::Tele_sound, 100, 100)
   if Tele_Config::Transitions == true
  # Prepare for transition
  Graphics.freeze
  # Set transition processing flag
  $game_temp.transition_processing = true
  $game_temp.transition_name = Tele_Config::Transition_name

   end

 end
end
class Window_Tele < Window_Selectable
 def initialize(width, commands)
   if commands.size <= 12
  super(0, 0, width, commands.size * 32 + 32)
   else
  super(0, 0, width, 416)
   end
   @item_max = commands.size
   @commands = commands
   self.contents = Bitmap.new(width - 32, @item_max * 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, self.contents.width - 8, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   self.contents.draw_text(rect, @commands[index], 1)
 end
end
class Window_Tele_Header < Window_Base
 def initialize
   super(0, 0, 320, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   text = Tele_Config::HEADER_TEXT
   cx = self.contents.text_size(text).width
   centre = ((width - 32) - cx) / 2
   self.contents.draw_text(centre, 0, cx, 32, text)
 end
end
class Scene_Tele
 def main
   choice_array = []
   @tele_array = $game_system.tele_array
   (0...@tele_array.size).each {|i|
  choice_array.push(Tele_Config.tele_locations(@tele_array[i])[0])
   }
   @tele_window = Window_Tele.new(320, choice_array)
   @tele_window.x = (640 - @tele_window.width) / 2
   @tele_window.y = 64
   @head_window = Window_Tele_Header.new
   @head_window.x = @tele_window.x
   @sprite = Spriteset_Map.new
   Graphics.transition
   loop { Graphics.update; Input.update; update; break if $scene != self }
   @tele_window.dispose
   @head_window.dispose
   @sprite.dispose
 end
 def update
   @tele_window.update
   if Input.trigger?(Input::B)
  $game_system.se_play($data_system.cancel_se)
  $scene = Scene_Map.new
   end
   if Input.trigger?(Input::C)
  $game_temp.tele_key = Tele_Config.tele_locations(@tele_array[@tele_window.index])
  $game_system.se_play($data_system.decision_se)
  $game_temp.tele_calling = true
  $scene = Scene_Map.new
   end
 end
end

 

 

enjoy :)

Edited by diagostimo

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...