Balrogic

Easy Teleport 1.0c by Balrogic

Jan 4th, 2015
414
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Easy Teleport 1.0c by Balrogic
  2.  
  3. =begin
  4. This script enables a very simple teleportation system that
  5. requires minimal configuration by you, the game developer.
  6. There are two teleport lists. Both can be used at the same
  7. time if you feel like it. One is unsorted and adds locations
  8. to the list in the same order they are added. The other needs
  9. to be told which location belongs where in the list. Both lists
  10. automatically set the new location equal to the current map's
  11. display name and the player's location. You can override this
  12. behavior if you so choose by adding arguments when you call
  13. the method.
  14.  
  15. To add a location to the unsorted list put this in a script call.
  16. I like making the player step on an event set to event touch.
  17.  
  18. Balrogic::Teleport::nosetup
  19.  
  20. To add a location to the sorted list put this in a script call.
  21. Replace 0 with whatever sorting number you want for that location.
  22.  
  23. Balrogic::Teleport::somesetup(0)
  24.  
  25. For finer control, include as many of the following arguments as
  26. you want.
  27. For direction, 0 is retain. 2 is down. 4 is left. 6 is right. 8 is up.
  28.  
  29. Balrogic::Teleport::nosetup("name", map_id, x, y, direction)
  30. Balrogic::Teleport::somesetup(sorting, "name", map_id, x, y, direction)
  31.  
  32. To access the teleport list put the following in a script call.
  33. For the unsorted list:
  34.  
  35. Balrogic::Teleport::unsorted
  36.  
  37. For the sorted list:
  38.  
  39. Balrogic::Teleport::sorted
  40.  
  41.  
  42. To disable access to teleportation, use script call below.
  43.  
  44. Balrogic::Teleport::disable
  45.  
  46. To re-enable:
  47.  
  48. Balrogic::Teleport::enable
  49. =end
  50.  
  51. module Balrogic   # Module 1
  52.   module Teleport # Module 2
  53.  
  54. # Configuration - Comment out anything you don't want to use.
  55. # Display message when selecting teleport destination.
  56.   @destination = "Please select your destination."
  57.  
  58. # Message to show when you don't know any destinations.
  59.   @nodestination = "You don't know where to go!"
  60.  
  61. # Message to show when teleportation is disabled.
  62.   @disabled = "Teleportation sealed."
  63.  
  64. # Sound effect to play on teleportation.
  65.   @sound = Proc.new {
  66.   RPG::SE.new("Teleport", 100, 100).play # Sound name, volume and pitch.
  67.   } # Leave this alone.
  68.  
  69. # Transition effect. 0 is default black, 1 is white, 2 for none.
  70.   @transition = Proc.new {
  71.   $game_temp.fade_type = 1
  72.   } # Leave this alone too.
  73. # End configuration.
  74.  
  75.   def self.unsorted
  76.     $game_self_switches[[:balrogic, :teleport, :override]] = true
  77.     if $game_self_switches[[:balrogic, :teleport, :disabled]]
  78.       $game_message.add(@disabled) if @disabled
  79.       $game_self_switches[[:balrogic, :teleport, :override]] = nil
  80.     else
  81.       if $game_self_switches[[:balrogic, :teleport]]
  82.         $game_message.choice_cancel_type = 999999999999
  83.         $game_self_switches[[:balrogic, :teleport]].each{ |x|
  84.           $game_message.choices << x[0]
  85.           }
  86.         $game_message.choice_proc = Proc.new { |x|
  87.           $game_player.reserve_transfer($game_self_switches[[:balrogic, :teleport]][x][1], $game_self_switches[[:balrogic, :teleport]][x][2], $game_self_switches[[:balrogic, :teleport]][x][3], $game_self_switches[[:balrogic, :teleport]][x][4])
  88.           Balrogic::Teleport::configuration
  89.           }
  90.         $game_message.add(@destination) if @destination
  91.       else
  92.         $game_message.add(@nodestination) if @nodestination
  93.         $game_self_switches[[:balrogic, :teleport, :override]] = nil
  94.       end
  95.     end
  96.   end
  97.  
  98.   def self.sorted
  99.     $game_self_switches[[:balrogic, :teleport, :override]] = true
  100.     if $game_self_switches[[:balrogic, :teleport, :disabled]]
  101.       $game_message.add(@disabled) if @disabled
  102.       $game_self_switches[[:balrogic, :teleport, :override]] = nil
  103.     else
  104.       if $game_self_switches[[:balrogic, :teleport_manual]]
  105.         $game_message.choice_cancel_type = 999999999999
  106.         @sorted_list = []
  107.         $game_self_switches[[:balrogic, :teleport_manual]].each{ |x|
  108.           @sorted_list << x if x
  109.           }
  110.         @sorted_list.each{ |x|
  111.           $game_message.choices << x[0]
  112.           }
  113.         $game_message.choice_proc = Proc.new { |x|
  114.           $game_player.reserve_transfer(@sorted_list[x][1], @sorted_list[x][2], @sorted_list[x][3], @sorted_list[x][4])
  115.           Balrogic::Teleport::configuration
  116.           }
  117.         $game_message.add(@destination) if @destination
  118.       else
  119.         $game_message.add(@nodestination) if @nodestination
  120.         $game_self_switches[[:balrogic, :teleport, :override]] = nil
  121.       end
  122.     end
  123.   end
  124.  
  125.   def self.nosetup(name=$game_map.display_name, map=$game_map.map_id, x=$game_player.x, y=$game_player.y, dir=2)
  126.     $game_self_switches[[:balrogic, :teleport]] ||= []
  127.     $game_self_switches[[:balrogic, :teleport]] << [name, map, x, y, dir]
  128.   end
  129.  
  130.   def self.somesetup(sort, name=$game_map.display_name, map=$game_map.map_id, x=$game_player.x, y=$game_player.y, dir=2)
  131.     $game_self_switches[[:balrogic, :teleport_manual]] ||= []
  132.     $game_self_switches[[:balrogic, :teleport_manual]][sort] = [name, map, x, y, dir]
  133.   end
  134.  
  135.   def self.disable
  136.     $game_self_switches[[:balrogic, :teleport, :disabled]] = true
  137.   end
  138.  
  139.   def self.enable
  140.     $game_self_switches[[:balrogic, :teleport, :disabled]] = nil
  141.   end
  142.  
  143.   def self.configuration
  144.     @transition.call if @transition
  145.     @sound.call if @sound
  146.     $game_self_switches[[:balrogic, :teleport, :override]] = nil
  147.   end
  148.  
  149.   def self.update
  150.     $game_self_switches[[:balrogic, :teleport]] = $game_self_switches["Balrogic Teleport"] if $game_self_switches["Balrogic Teleport"]
  151.     $game_self_switches[[:balrogic, :teleport_manual]] = $game_self_switches["Balrogic Teleport Manual"] if $game_self_switches["Balrogic Teleport Manual"]
  152.     $game_self_switches[[:balrogic, :teleport, :disabled]] = $game_self_switches["Balrogic Teleport Disabled"] if $game_self_switches["Balrogic Teleport Disabled"]
  153.     $game_self_switches["Balrogic Teleport"] = nil
  154.     $game_self_switches["Balrogic Teleport Manual"] = nil
  155.     $game_self_switches["Balrogic Teleport Disabled"] = nil
  156.   end
  157.  
  158.   end # Module 2
  159. end   # Module 1
  160.  
  161. class Window_ChoiceList < Window_Command
  162.  
  163.   alias balrogic_old_update_placement update_placement
  164.   def update_placement
  165.     if $game_self_switches[[:balrogic, :teleport, :override]]
  166.       self.width = [max_choice_width + 12, 96].max + padding * 2
  167.       self.width = [width, Graphics.width].min
  168.       self.height = fitting_height($game_message.choices.size) if $game_message.choices.size <= 8
  169.       self.height = fitting_height(8) if $game_message.choices.size >= 9
  170.       self.x = Graphics.width - width
  171.       if @message_window.y >= Graphics.height / 2
  172.         self.y = @message_window.y - height
  173.       else
  174.         self.y = @message_window.y + @message_window.height
  175.       end
  176.     else
  177.       balrogic_old_update_placement
  178.     end
  179.   end
  180. end
  181.  
  182. class Game_SelfSwitches
  183.   def [](key)
  184.     @data[key] || false
  185.   end
  186. end
RAW Paste Data