设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 116|回复: 0

[转载发布] Teleport to Visited sites

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-2 08:57:23 | 显示全部楼层 |阅读模式
    https://www.youtube.com/embed/jrAQVEw21lQ

    Script Name:  TeleportToVisited

    Author:       Newold

    Description:  With this script you can make a window appear that
                         allows you to teleport to any map you have visited before.
                         You can also store different teleport points on each map.

    Version:      1.4 - 10-01-2019

    Credits and License: You can use this script as you want. It is free for comercial and not comercial projects. You can give me thanks in the credits of your game or not, as you wish



    **************************************************************************
    Installation and use
         **************************************************************************

    INSTALLATION

         - Put this script over main

         - You need to download these images and unzip them in the folder
           "Graphics/Pictures"
           Link: Bajar]https://www.mediafire.com/file/n7bv66tbdr7cj3m/TeleportImages.rar/file] (Downloads images from mediafire)

         - you can configure this script below this instructions


    HOW TO USE

         - When you visited a map, this map is added automatically to the
           teleport's list.
           If you do not want the map to be added automatically, you need
           to create an empty event on that map and name it
           ⇒⇒⇒⇒              noAddToTeleportList            ⇐⇐⇐⇐

         ··········································································

         - To add a teleport point manually, use the command call script of
           the events and inside you put this code:

           add_map(ref, name, map_id, x, y, direction)

             ● ref         
    Can be a number (Ex: 1), a string (Ex: "name") or
                             symbol
    symbol)
                             ref is used to identify this teleport.
             ● name        
    Only can be a string (Ex: "name")
                             name is used to name this teleport.
             ● map_id      
    it can be nil (current map) or a number.
                             map_id refers to the id of the map.
             ● x           
    it can be nil (current position X of player)
                             or a number.
             ● y           
    it can be nil (current position Y of player)
                             or a number.
             ● direction   
    it can be nil (current direction of player)
                             or a number. (2 = Down, 4 = Left, 6 = Right, 8 = Up)

         ··········································································

         - To modify a parameter of a teleport point already added, use the
           command call script of the events and inside you put this code:

           update_map_info(map_id, attr, value, ref)

             ● map_id      
    it is a number. map_id refers to the id of the map.
             ● attr        
    name of the parameter to modify
                             (including the two points)
                             attr only can be :x, :y, :direction or :map_name
                                 ● :x         
    Use :x to modify the
                                                 X coordinate of teleport
                                 ● :y         
    Use :y to modify the
                                                 Y coordinate of teleport
                                 ● :direction  
    Use :direction to modify where
                                                 the character will look when
                                                 teleporting
                                 ● :map_name   
    Use :map_name to change the name
                                                 of teleport
             ● value      
    It must be a text between quotation marks to modify
                             the value of :map_name (example "my text") or a number
                             to modify the other values
             ● ref         
    Can be a number (Ex: 1), a string (Ex: "name") or
                             symbol
    symbol)

         ··········································································

         - To show the teleport selection window, use the command call script
           of the events and inside you put this code:

           open_teleport

         ··········································································
         **************************************************************************



    SCRIPT

                    Code:       
    1. #===============================================================================
    2. class TeleportToVisited
    3. =begin
    4.       **************************************************************************
    5.       Script Name:  TeleportToVisited
    6.      
    7.       Author:       Newold
    8.      
    9.       Description:  With this script you can make a window appear that
    10.                     allows you to teleport to any map you have visited before.
    11.                     You can also store different teleport points on each map.
    12.                   
    13.       Version:      1.4 - 10-01-2019
    14.      
    15.       License and   You can use this script as you want.
    16.       Credits       It is free for comercial and not comercial projects.
    17.                     You can give me thanks in the credits of your game or not,
    18.                     as you wish.
    19.    
    20.       History / Updates:
    21.         ▼ 10-01-2019 - Fixed "stack to deep" bug
    22.         ▼ 09-01-2019 - You can now to postpone teleport and do it manually.
    23.         ▼ 09-01-2019 - You can now disable/enable last teleport used
    24.                       (default = false)
    25.         ▼ 08-01-2019 - Now you can add teleports to any map from any map
    26.         ▼ 07-01-2019 - Release Day.
    27.       **************************************************************************
    28.    
    29.    
    30.       **************************************************************************
    31.                             Installation and use
    32.       **************************************************************************
    33.       ⚫ INSTALLATION
    34.      
    35.       - Put this script over main
    36.      
    37.       - You need to download these images and unzip them in the folder
    38.         "Graphics/Pictures"
    39.         Link: Download images from mediafire (you need unzip):
    40.           https://www.mediafire.com/file/n7bv66tbdr7cj3m/TeleportImages.rar/file
    41.       
    42.       - you can configure this script below this instructions
    43.      
    44.       ⚫ HOW TO USE
    45.      
    46.       - When you visited a map, this map is added automatically to the
    47.         teleport's list.
    48.         If you do not want the map to be added automatically, you need
    49.         to create an empty event on that map and name it
    50.         ⇒⇒⇒⇒              noAddToTeleportList            ⇐⇐⇐⇐
    51.      
    52.       ··········································································
    53.      
    54.       - To add a teleport point manually, use the command call script of
    55.         the events and inside you put this code:
    56.       
    57.         add_map(ref, name, map_id, x, y, direction)
    58.       
    59.           ● ref         ▶ Can be a number (Ex: 1), a string (Ex: "name") or
    60.                           symbol (:symbol)
    61.                           ref is used to identify this teleport.
    62.           ● name        ▶ Only can be a string (Ex: "name")
    63.                           name is used to name this teleport.
    64.           ● map_id      ▶ it can be nil (current map) or a number.
    65.                           map_id refers to the id of the map.
    66.           ● x           ▶ it can be nil (current position X of player)
    67.                           or a number.
    68.           ● y           ▶ it can be nil (current position Y of player)
    69.                           or a number.
    70.           ● direction   ▶ it can be nil (current direction of player)
    71.                           or a number. (2 = Down, 4 = Left, 6 = Right, 8 = Up)
    72.                         
    73.       ··········································································
    74.      
    75.       - To modify a parameter of a teleport point already added, use the
    76.         command call script of the events and inside you put this code:
    77.       
    78.         update_map_info(map_id, attr, value, ref)
    79.       
    80.           ● map_id      ▶ it is a number. map_id refers to the id of the map.
    81.           ● attr        ▶ name of the parameter to modify
    82.                           (including the two points)
    83.                           attr only can be :x, :y, :direction or :map_name
    84.                               ● :x          ▶ Use :x to modify the
    85.                                               X coordinate of teleport
    86.                               ● :y          ▶ Use :y to modify the
    87.                                               Y coordinate of teleport
    88.                               ● :direction  ▶ Use :direction to modify where
    89.                                               the character will look when
    90.                                               teleporting
    91.                               ● :map_name   ▶ Use :map_name to change the name
    92.                                               of teleport
    93.           ● value       ▶ It must be a text between quotation marks to modify
    94.                           the value of :map_name (example "my text") or a number
    95.                           to modify the other values
    96.           ● ref         ▶ Can be a number (Ex: 1), a string (Ex: "name") or
    97.                           symbol (:symbol)
    98.                         
    99.       ··········································································
    100.      
    101.       - To show the teleport selection window, use the command call script
    102.         of the events and inside you put this code:
    103.       
    104.         open_teleport
    105.       
    106.       - If you want to postpone the teleport and activate a switch instead to
    107.         create some engine, you need put config @@config[:pospone_teleport] in
    108.         true and define switch in @@config[:activate_switch]. Then you can
    109.         create any engine in your game and finally teleport using the command
    110.         call script of the events and inside you put this code:
    111.       
    112.         perform_teleport
    113.       
    114.       ··········································································
    115.       **************************************************************************
    116. =end
    117.    
    118.   #=============================================================================
    119.   #             ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ CONFIGURATION ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
    120.   #=============================================================================
    121.   @@config = {}
    122.   # ············································································
    123.   #                   images (in folder Graphics/Pictures)
    124.   # ············································································
    125.   # Image of cursor (hand)
    126.   @@config[:cursor1] = "cursor001"
    127.   # Image of cursor (selector)
    128.   @@config[:cursor2] = "cursor002"
    129.   # Image of cursor (current map)
    130.   @@config[:cursor3] = "cursor003"
    131.   # Pattern for window
    132.   @@config[:window_pattern] = "window001"
    133.   # ············································································
    134.   # ············································································
    135.   #                     Sounds (in folder Audio/SE)
    136.   # ············································································
    137.   # Cursor movement
    138.   @@config[:cursor_se] = {
    139.     :name     => "Cursor1",
    140.     :volume   => 75,
    141.     :pitch    => 100
    142.   }
    143.   # Decision (OK)
    144.   @@config[:decision_se] = {
    145.     :name     => "Decision2",
    146.     :volume   => 75,
    147.     :pitch    => 100
    148.   }
    149.   # Error (Buzzer)
    150.   @@config[:buzzer_se] = {
    151.     :name     => "Buzzer1",
    152.     :volume   => 75,
    153.     :pitch    => 100
    154.   }
    155.   # Cancel
    156.   @@config[:cancel_se] = {
    157.     :name     => "Cancel1",
    158.     :volume   => 75,
    159.     :pitch    => 100
    160.   }
    161.   # Teleport
    162.   @@config[:teleport_se] = {
    163.     :name     => "Teleport",
    164.     :volume   => 75,
    165.     :pitch    => 100
    166.   }
    167.   # ············································································
    168.   # ············································································
    169.   #                         Window Config
    170.   # ············································································
    171.   # Width window
    172.   @@config[:window_width] = 240
    173.   # Height window
    174.   @@config[:window_height] = 160
    175.   # Show displacement bar
    176.   @@config[:show_displacement_bar] = true
    177.   # Draw background stretched
    178.   @@config[:stretch_background] = false
    179.   # Config Font
    180.   @@config[:font] = {
    181.     :name                 => "Verdana",
    182.     :size                 => 20,
    183.     :color                => Color.new(255,255,255),
    184.     :outline              => true,
    185.     :out_color            => Color.new(0,0,0),
    186.     :current_map_color    => Color.new(9,104,20)
    187.   }
    188.   # ············································································
    189.     # ·········································································
    190.     # Position Window
    191.     # ·········································································
    192.     # :top_left       > -------------------------------------------------------
    193.     # :top            >
    194.     # :top_right      >
    195.     # :left           >
    196.     # :screen_center  >                       screen
    197.     # :right          >
    198.     # :bottom_left    >
    199.     # :bottom         >
    200.     # :bottom_right   > -------------------------------------------------------
    201.    
    202.     # :center_top     > -------------------------------------------------------
    203.     # :center_left    >
    204.     # :center_right   >                      character
    205.     # :center_bottom  >
    206.     # :center         > -------------------------------------------------------
    207.    
    208.     # Point           > Fixed point (Point.new(x, y))
    209.     # ·········································································
    210.     @@config[:window_position] = :center_left
    211.     # ·········································································
    212.   # ············································································
    213.    
    214.   # ············································································
    215.   # Other Config
    216.   # ············································································
    217.   # Suavize animation (show / hide window)
    218.   @@config[:animation_suavize] = 8
    219.   # Screen margin for window
    220.   @@config[:screen_margin] = 10
    221.   # Disable same teleport than current map
    222.   # (last teleport is disabled. It enable when change teleport)
    223.   @@config[:disable_last_teleport] = false
    224.   # Postpone teleportation and activate switch
    225.   @@config[:pospone_teleport] = false
    226.   # switch to activate when success teleport. If you use
    227.   # @@config[:pospone_teleport], this switch is activated instead of teleport
    228.   # player. You must manually teleport the player using this command:
    229.   # $TeleportToVisited.perform_teleport
    230.   @@config[:activate_switch] = 100
    231.   # ············································································
    232.   #=============================================================================
    233.   #           ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ END CONFIGURATION ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
    234.   #=============================================================================
    235.   #=============================================================================
    236.   class Point
    237.     attr_accessor :x, :y
    238.     def initialize(x=0, y=0)
    239.       @x, @y = x, y
    240.     end
    241.   end
    242.   #=============================================================================
    243.   class Data
    244.     attr_accessor :x, :y, :direction, :map_name, :map_id, :ref
    245.   end
    246.   #=============================================================================
    247.   #-----------------------------------------------------------------------------
    248.   attr_reader :data
    249.   #-----------------------------------------------------------------------------
    250.   def initialize
    251.     @data = []
    252.     @drawed = []
    253.     @current_map = nil
    254.     @index = 0
    255.     @cursor_animation_index = 0
    256.     @cursor_animation = [-1, 0, 0, -1, -1, 0, 1, 0, 0, 1, 0, 0, 1]
    257.     @arrows_animation_index = 0
    258.     @arrows_animation = [-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0]
    259.     @bar_displacement = 0
    260.     @show_displacement_bar = true
    261.     create_cursor
    262.     create_window
    263.   end
    264.   #-----------------------------------------------------------------------------
    265.   def create_cursor
    266.     @cursor = Sprite.new
    267.     @cursor.bitmap = Cache.picture(@@config[:cursor1])
    268.     @cursor.z = 10000020
    269.     @cursor.opacity = 0
    270.     @cursor.visible = false
    271.   end
    272.   #-----------------------------------------------------------------------------
    273.   def create_window
    274.     src_rects = get_rects
    275.    
    276.     bitmap = Cache.picture(@@config[:window_pattern])
    277.     transparent = Color.new(0,0,0,0)
    278.    
    279.     viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
    280.     viewport.z = 500
    281.     @window = Sprite.new(viewport)
    282.     @window.x = 200
    283.     @window.y = 100
    284.     @window.bitmap = Bitmap.new(@@config[:window_width],
    285.       @@config[:window_height])
    286.     @window.ox = @window.width / 2
    287.     @window.oy = @window.height / 2
    288.     # Draw borders
    289.     # ··············································
    290.     # Left
    291.     rect = src_rects[:left]
    292.     h1 = src_rects[:top_left].height
    293.     h2 = src_rects[:bottom_left].height
    294.     rect2 = Rect.new(0, h1, rect.width, @window.height - h1 - h2)
    295.     draw_window_part(bitmap, rect, rect2)
    296.     # ··············································
    297.     # Right
    298.     rect = src_rects[:right]
    299.     h1 = src_rects[:top_right].height
    300.     h2 = src_rects[:bottom_right].height
    301.     rect2 = Rect.new(@window.width - rect.width,
    302.       h1, rect.width, @window.height - h1 - h2)
    303.     draw_window_part(bitmap, rect, rect2)
    304.     # ··············································
    305.     # Top
    306.     rect = src_rects[:top]
    307.     w1 = src_rects[:top_left].width
    308.     w2 = src_rects[:top_right].width
    309.     rect2 = Rect.new(w1, 0, @window.width - w1 - w2, rect.height)
    310.     draw_window_part(bitmap, rect, rect2)
    311.     # ··············································
    312.     # Bottom
    313.     rect = src_rects[:bottom]
    314.     w1 = src_rects[:bottom_left].width
    315.     h2 = src_rects[:bottom_right].width
    316.     rect2 = Rect.new(w1, @window.height - rect.height,
    317.     @window.width - w1 - w2, rect.height)
    318.     draw_window_part(bitmap, rect, rect2)
    319.     # ··············································
    320.     # Center and contents
    321.     rect = src_rects[:center]
    322.     x = src_rects[:top_left].width
    323.     y = src_rects[:top_left].height
    324.     w = @window.width - x - src_rects[:top_right].width
    325.     h = @window.height - y - src_rects[:bottom_right].height
    326.     rect2 = Rect.new(x, y, w, h)
    327.     draw_window_part(bitmap, rect, rect2)
    328.     # ··············································
    329.     # Corner Top Left
    330.     rect = src_rects[:top_left]
    331.     x = 0
    332.     y = 0
    333.     draw_window_part_corner(bitmap, x, y, rect, transparent)
    334.     # ··············································
    335.     # Corner Top Right
    336.     rect = src_rects[:top_right]
    337.     x = @window.width - rect.width
    338.     y = 0
    339.     draw_window_part_corner(bitmap, x, y, rect, transparent)
    340.     # ··············································
    341.     # Corner Bottom Left
    342.     rect = src_rects[:bottom_left]
    343.     x = 0
    344.     y = @window.height - rect.height
    345.     draw_window_part_corner(bitmap, x, y, rect, transparent)
    346.     # ··············································
    347.     # Corner Bottom Right
    348.     rect = src_rects[:bottom_right]
    349.     x = @window.width - rect.width
    350.     y = @window.height - rect.height
    351.     draw_window_part_corner(bitmap, x, y, rect, transparent)
    352.     # ··············································
    353.     @window.z = 10000000
    354.     # ··············································
    355.    
    356.     x = @window.x - @window.ox + src_rects[:top_left].width
    357.     y = @window.y - @window.oy + src_rects[:top_left].height
    358.     @viewport = Viewport.new(x, y, w, h)
    359.     @viewport.z = 1000
    360.    
    361.     @contents = Sprite.new(@viewport)
    362.     @bar_background = Sprite.new(@viewport)
    363.     @bar_top = Sprite.new(@viewport)
    364.     @selector = Sprite.new(@viewport)
    365.    
    366.     @contents.z = 100
    367.     @selector.z = 150
    368.     @bar_background.z = 200
    369.     @bar_top.z = 250
    370.    
    371.     @arrow_top = Sprite.new
    372.     rect = src_rects[:arrow_top]
    373.     @arrow_top.bitmap = Bitmap.new(rect.width, rect.height)
    374.     @arrow_top.bitmap.blt(0, 0, bitmap, rect)
    375.     @arrow_bottom = Sprite.new
    376.     rect = src_rects[:arrow_bottom]
    377.     @arrow_bottom.bitmap = Bitmap.new(rect.width, rect.height)
    378.     @arrow_bottom.bitmap.blt(0, 0, bitmap, rect)
    379.     @arrow_top.z = 10000050
    380.     @arrow_bottom.z = 10000050
    381.    
    382.     @window.visible           =         @contents.visible   =
    383.     @bar_background.visible   =         @bar_top.visible    = false
    384.    
    385.     @window.opacity           =         @contents.opacity   =
    386.     @bar_background.opacity   =         @bar_top.opacity    =
    387.     @window.zoom_x            =         @contents.zoom_x    =
    388.     @bar_background.zoom_x    =         @bar_top.zoom_x     =
    389.     @window.zoom_y            =         @contents.zoom_y    =
    390.     @bar_background.zoom_y    =         @bar_top.zoom_y     = 0
    391.     @selector.visible = @arrow_top.visible = @arrow_bottom.visible = false
    392.   end
    393.   #-----------------------------------------------------------------------------
    394.   def draw_window_part(bitmap, rect1, rect2)
    395.     if @@config[:stretch_background] == true
    396.       @window.bitmap.stretch_blt(rect2, bitmap, rect1)
    397.     else
    398.       w1 = rect1.width
    399.       h1 = rect1.height
    400.       w2 = rect2.width
    401.       h2 = rect2.height
    402.       mx = [(w2 / w1.to_f).ceil, 1].max
    403.       my = [(h2 / h1.to_f).ceil, 1].max
    404.       for i in 0...mx
    405.         for j in 0...my
    406.           x = rect2.x + i*w1
    407.           y = rect2.y + j*h1
    408.           @window.bitmap.blt(x, y, bitmap, rect1)
    409.         end
    410.       end
    411.     end
    412.   end
    413.   #-----------------------------------------------------------------------------
    414.   def draw_window_part_corner(bitmap, x, y, rect, fill_color)
    415.     @window.bitmap.fill_rect(x, y, rect.width, rect.height, fill_color)
    416.     @window.bitmap.blt(x, y, bitmap, rect)
    417.   end
    418.   #-----------------------------------------------------------------------------
    419.   def get_rects
    420.     rects = {
    421.       :top_left         => Rect.new(0,0,8,8),
    422.       :top              => Rect.new(8,0,8,8),
    423.       :top_right        => Rect.new(16,0,8,8),
    424.       :bottom_left      => Rect.new(0,16,8,8),
    425.       :bottom           => Rect.new(8,16,8,8),
    426.       :bottom_right     => Rect.new(16,16,8,8),
    427.       :left             => Rect.new(0,8,8,8),
    428.       :right            => Rect.new(16,8,8,8),
    429.       :center           => Rect.new(8,8,8,8),
    430.       :arrow_top        => Rect.new(24,0,8,4),
    431.       :arrow_bottom     => Rect.new(24,4,8,4),
    432.       :bar_background   => Rect.new(24,16,8,8),
    433.       :bar_topA         => Rect.new(24,8,8,3),
    434.       :bar_topB         => Rect.new(24,11,8,2),
    435.       :bar_topC         => Rect.new(24,13,8,3)
    436.     }
    437.     rects
    438.   end
    439.   #-----------------------------------------------------------------------------
    440.   def draw_displacement_bar(id)
    441.     if @@config[:show_displacement_bar]
    442.       bitmap = Cache.picture(@@config[:window_pattern])
    443.       src_rects = get_rects
    444.       case id
    445.       when :background
    446.         # Draw background
    447.         unless @bar_background.bitmap.nil?
    448.           @bar_background.bitmap.dispose
    449.         end
    450.         viewport = @viewport
    451.         rect = src_rects[:bar_background]
    452.         rect2 = Rect.new(0, 0, rect.width, viewport.rect.height)
    453.         @bar_background.bitmap = Bitmap.new(rect2.width, rect2.height)
    454.         ox = @bar_background.width / 2
    455.         oy = @bar_background.height / 2
    456.         @bar_background.ox = ox
    457.         @bar_background.oy = oy
    458.         @bar_background.bitmap.stretch_blt(rect2, bitmap, rect)
    459.         @bar_background.x = viewport.rect.width - @bar_background.width + ox
    460.         @bar_background.y = oy
    461.       when :top
    462.         # draw top
    463.         unless @bar_top.bitmap.nil?
    464.           @bar_top.bitmap.dispose
    465.         end
    466.         min_height = 25
    467.         max_height = @contents.viewport.rect.height
    468.         rows = max_height / @h
    469.         extra_rows = @real_data.size - rows
    470.         bar_height = (extra_rows <= 0) ? max_height :
    471.           [[max_height / extra_rows, min_height].max, max_height].min
    472.          
    473.         if rows == @real_data.size-1 && bar_height == max_height
    474.           bar_height = max_height * 0.9
    475.         end
    476.       
    477.         @bar_top.bitmap = Bitmap.new(@bar_background.width, bar_height)
    478.       
    479.         rect1 = src_rects[:bar_topA]
    480.         rect2 = Rect.new(0, 0, @bar_top.width, 3)
    481.         @bar_top.bitmap.stretch_blt(rect2, bitmap, rect1)
    482.       
    483.         rect1 = src_rects[:bar_topB]
    484.         rect2 = Rect.new(0, 3, @bar_top.width, bar_height - 6)
    485.         @bar_top.bitmap.stretch_blt(rect2, bitmap, rect1)
    486.       
    487.         rect1 = src_rects[:bar_topC]
    488.         rect2 = Rect.new(0, @bar_top.height - 3, @bar_top.width, 3)
    489.         @bar_top.bitmap.fill_rect(rect2, Color.new(0,0,0,0))
    490.         @bar_top.bitmap.stretch_blt(rect2, bitmap, rect1)
    491.       
    492.         @bar_top.ox, @bar_top.oy = @bar_top.width/2, @bar_top.height/2
    493.         @bar_top.x = @bar_background.x
    494.         @bar_top.y = @bar_background.y - @bar_background.oy + @bar_top.oy
    495.       
    496.         if @contents.height > @contents.viewport.rect.height
    497.           h = extra_rows * @h.to_f
    498.           h2 = (max_height - @bar_top.height)
    499.           @bar_displacement = h2 / h
    500.           @show_displacement_bar = true
    501.         else
    502.           @bar_displacement = 0
    503.           @show_displacement_bar = false
    504.         end
    505.       end
    506.     end
    507.   end
    508.   #-----------------------------------------------------------------------------
    509.   def draw_contents(initial=false)
    510.    
    511.     data = []
    512.     if initial
    513.       @data.each{|d1|
    514.         unless d1.nil?
    515.           d1.each{|d2|
    516.             unless d2.nil?
    517.               data << d2
    518.             end
    519.           }
    520.         end
    521.       }
    522.     else
    523.       data = @real_data
    524.     end
    525.     b = Bitmap.new(1,1)
    526.     font = Font.new
    527.     font.name = @@config[:font][:name]
    528.     font.size = @@config[:font][:size]
    529.     font.outline = @@config[:font][:outline]
    530.     font.color = @@config[:font][:color]
    531.     font.out_color = @@config[:font][:out_color]
    532.     b.font = font
    533.     size = b.text_size("O")
    534.     h = size.height * data.size
    535.     w = @contents.viewport.rect.width
    536.     if @show_displacement_bar == true || h > @contents.viewport.rect.height
    537.       w -= @bar_background.width
    538.     end
    539.     if initial
    540.       unless @contents.bitmap.nil?
    541.         @contents.bitmap.dispose
    542.       end
    543.       @contents.bitmap = Bitmap.new(w, h)
    544.       @contents.bitmap.font = font
    545.       @h = size.height
    546.     end
    547.     iniData = @contents.viewport.oy / @h
    548.     endData = [iniData + @contents.viewport.rect.height / @h, data.size].min
    549.     for i in iniData..endData
    550.       next unless @drawed[i].nil?
    551.       d = data[i]
    552.       break if d.nil?
    553.       tw = @contents.bitmap.font.size
    554.       y = i * @h
    555.       mod = 0
    556.       if d == @current_map && @@config[:disable_last_teleport] == true
    557.         b2 = Cache.picture(@@config[:cursor3])
    558.         ratio = b2.height / @h.to_f
    559.         nw = [(b2.width * ratio).to_i,   1].max
    560.         nh = [(b2.height * ratio).to_i,  1].max
    561.         rect = Rect.new(w-nw, y, nw, nh)
    562.         @contents.bitmap.stretch_blt(rect, b2, b2.rect)
    563.         mod = rect.width
    564.       end
    565.       while @contents.bitmap.text_size(d.map_name).width - mod > w &&
    566.         @contents.bitmap.font.size > 4
    567.         @contents.bitmap.font.size -= 1
    568.       end
    569.       @contents.bitmap.font.color = (d == @current_map &&
    570.         @@config[:disable_last_teleport] == true) ?
    571.         @@config[:font][:current_map_color] : @@config[:font][:color]
    572.       @contents.bitmap.draw_text(0, y, w, size.height, d.map_name)
    573.       @contents.bitmap.font.size = tw
    574.      
    575.       @drawed[i] = true
    576.     end
    577.     ox = @contents.width / 2
    578.     oy = @contents.height / 2
    579.     @contents.ox = ox
    580.     @contents.oy = oy
    581.     @contents.x = ox
    582.     @contents.y = oy
    583.    
    584.     if initial
    585.       unless @selector.bitmap.nil?
    586.         @selector.bitmap.dispose
    587.       end
    588.       @selector.bitmap = Bitmap.new(w, @h)
    589.       bitmap = Cache.picture(@@config[:cursor2])
    590.       @selector.bitmap.stretch_blt(@selector.bitmap.rect, bitmap, bitmap.rect)
    591.       @selector.y = 0
    592.       @selector.visible = true
    593.       @selector.opacity = 0
    594.       @real_data = data
    595.     end
    596.   end
    597.   #-----------------------------------------------------------------------------
    598.   def add_map(map_id, ref=nil, name=nil, x=nil, y=nil, direction=nil)
    599.     if !FileTest.exist?(sprintf("Data/Map%03d.rvdata2", map_id))
    600.       return
    601.     end
    602.     x = x.nil? ? $game_player.x : x.to_i rescue 0
    603.     y = y.nil? ? $game_player.y : y.to_i rescue 0
    604.     direction = direction.nil? ? $game_player.direction : direction.to_i rescue 0
    605.     name = name.nil? ? $data_mapinfos[map_id].name : name.to_s
    606.     if @data[map_id].nil?
    607.       @data[map_id] ||= []
    608.       data            = Data.new
    609.       data.x          = x
    610.       data.y          = y
    611.       data.direction  = direction
    612.       data.map_name   = name
    613.       data.map_id     = map_id
    614.       data.ref = ref
    615.       @data[map_id] << data
    616.       @current_map = data
    617.     else
    618.       add = true
    619.       @data[map_id].each{|data|
    620.         if data.ref == ref
    621.           add = false
    622.           break
    623.         end
    624.       }
    625.       if add
    626.         data            = Data.new
    627.         data.x          = x
    628.         data.y          = y
    629.         data.direction  = direction
    630.         data.map_name   = name
    631.         data.map_id     = map_id
    632.         data.ref = ref
    633.         @data[map_id] << data
    634.         @current_map = data
    635.       end
    636.     end
    637.   end
    638.   #-----------------------------------------------------------------------------
    639.   def update_map_info(map_id, attr, value, ref=nil)
    640.     unless @data[map_id].nil?
    641.       data = nil
    642.       @data[map_id].each{|data2|
    643.         next if data2.nil? || data2.ref != ref
    644.         data = data2
    645.         break
    646.       }
    647.       unless data.nil?
    648.         begin
    649.           eval("data.#{attr} = value")
    650.         rescue
    651.         end
    652.       end
    653.     end
    654.   end
    655.   #-----------------------------------------------------------------------------
    656.   def show_window(x=0, y=0)
    657.     if @window.disposed?
    658.       dispose
    659.       create_cursor
    660.       create_window
    661.     end
    662.     @drawed.clear
    663.     draw_displacement_bar(:background)
    664.     draw_contents(true)
    665.     draw_displacement_bar(:top)
    666.     fix_position(x, y)
    667.     mod = @@config[:animation_suavize]
    668.     opacity = 255.0 / mod
    669.     zoom = 1.0 / mod
    670.     @viewport.ox = @viewport.oy = @index = 0
    671.     update_index(0)
    672.     data1 = [@cursor, @selector, @arrow_top, @arrow_bottom]
    673.     data2 = [@window, @contents, @bar_background, @bar_top]
    674.     data2.each{|s| s.visible = true}
    675.     if !@show_displacement_bar
    676.       @bar_background.visible = @bar_top.visible = false
    677.     end
    678.     while mod > 0
    679.       data2.each{|s|
    680.         s.opacity += opacity
    681.         s.zoom_x += zoom
    682.         s.zoom_y += zoom
    683.       }
    684.       Graphics.update
    685.       mod -= 1
    686.     end
    687.     data1.each{|s|
    688.       s.visible = true
    689.       s.opacity = 255
    690.     }
    691.     update_pos_cursor
    692.     @index = 0
    693.     @cursor_animation_index = 0
    694.     main
    695.   end
    696.   #-----------------------------------------------------------------------------
    697.   def fix_position(x, y)
    698.     ox, oy, w, h = @window.ox, @window.oy, @window.width, @window.height
    699.     smx, smy = Graphics.width / 2, Graphics.height / 2
    700.     margin = @@config[:screen_margin]
    701.     case @@config[:window_position]
    702.     when :top_left
    703.       @window.x = margin + ox
    704.       @window.y = margin + oy
    705.     when :top
    706.       @window.x = smx - w/2 + ox
    707.       @window.y = margin + oy
    708.     when :top_right
    709.       @window.x = Graphics.width - margin - w + ox
    710.       @window.y = margin + @window.oy
    711.     when :left
    712.       @window.x = margin + ox
    713.       @window.y = smy - h/2 + oy
    714.     when :screen_center
    715.       @window.x = smx - w/2 + ox
    716.       @window.y = smy - h/2 + oy
    717.     when :right
    718.       @window.x = Graphics.width - margin - w + ox
    719.       @window.y = smy - h/2 + oy
    720.     when :bottom_left
    721.       @window.x = margin + ox
    722.       @window.y = Graphics.height - margin - h + oy
    723.     when :bottom
    724.       @window.x = smx - w/2 + ox
    725.       @window.y = Graphics.height - margin - h + oy
    726.     when :bottom_right
    727.       @window.x = Graphics.width - margin - w + ox
    728.       @window.y = Graphics.height - margin - h + oy
    729.     when :center_top
    730.       @window.x = x
    731.       @window.y = y - h + oy - 32
    732.     when :center_bottom
    733.       @window.x = x
    734.       @window.y = y + oy
    735.     when :center_left
    736.       @window.x = x - w + ox - 16
    737.       @window.y = y - 13
    738.     when :center_right
    739.       @window.x = x + ox + 16
    740.       @window.y = y - 13
    741.     when Point
    742.       @window.x = @@config[:window_position].x + ox
    743.       @window.y = @@config[:window_position].y + oy
    744.     else
    745.       @window.x = x + 16
    746.       @window.y = y - 13
    747.     end
    748.     if @window.x - ox < @@config[:screen_margin]
    749.       @window.x = @@config[:screen_margin] + ox
    750.     end
    751.     if @window.y - oy < @@config[:screen_margin]
    752.       @window.y = @@config[:screen_margin] + oy
    753.     end
    754.     if @window.x + ox > Graphics.width - @@config[:screen_margin]
    755.       @window.x = Graphics.width - @@config[:screen_margin] - w + ox
    756.     end
    757.     if @window.y + oy > Graphics.height - @@config[:screen_margin]
    758.       @window.y = Graphics.height - @@config[:screen_margin] - h + oy
    759.     end
    760.     src_rects = get_rects
    761.     x = @window.x - @window.ox + src_rects[:top_left].width
    762.     y = @window.y - @window.oy + src_rects[:top_left].height
    763.     @viewport.rect.x = x
    764.     @viewport.rect.y = y
    765.     x = @window.x - @window.ox
    766.     y = @window.y - @window.oy
    767.     @arrow_top.x = (x + @window.width / 2) - (@arrow_top.width / 2)
    768.     @arrow_top.y = y + (@arrow_top.height / 2)
    769.     @arrow_bottom.x = (x + @window.width / 2) - (@arrow_bottom.width / 2)
    770.     @arrow_bottom.y = y + @window.height - (@arrow_top.height / 2)
    771.   end
    772.   #-----------------------------------------------------------------------------
    773.   def hide(skip_animation=false)
    774.     mod = @@config[:animation_suavize]
    775.     opacity = 255.0 / mod
    776.     zoom = 1.0 / mod
    777.     data1 = [@cursor, @selector, @arrow_top, @arrow_bottom]
    778.     data2 = [@window, @contents, @bar_background, @bar_top]
    779.     while mod > 0 && !skip_animation
    780.       data1.each{|s| s.opacity -= opacity}
    781.       data2.each{|s|
    782.         s.opacity -= opacity
    783.         s.zoom_x -= zoom
    784.         s.zoom_y -= zoom
    785.       }
    786.       Graphics.update
    787.       mod -= 1
    788.     end
    789.     data1.each{|s|
    790.       s.visible = false
    791.       s.opacity = 0
    792.     }
    793.     data2.each{|s|
    794.       s.visible = false
    795.       s.opacity = s.zoom_x = s.zoom_y = 0
    796.     }
    797.     @exit = true
    798.   end
    799.   #-----------------------------------------------------------------------------
    800.   def main
    801.     @exit = false
    802.     @action = false
    803.     while !@exit
    804.       Graphics.update
    805.       Input.update
    806.       update
    807.       update_cursor_animation
    808.       update_arrows_animation
    809.       break if @exit
    810.     end
    811.     if @action
    812.       if @@config[:pospone_teleport] == true
    813.         id = [[@@config[:activate_switch].to_i, 1].max, 9999].min
    814.         $game_switches[id] = true
    815.       else
    816.         perform_teleport
    817.       end
    818.     end
    819.   end
    820.   #-----------------------------------------------------------------------------
    821.   def perform_teleport
    822.     $game_map.interpreter.clear
    823.     play_fx(:decision_se)
    824.     play_fx(:teleport_se)
    825.     SceneManager.scene.pre_transfer
    826.     data = @real_data[@index]
    827.     $game_player.reserve_transfer(data.map_id, data.x, data.y, data.direction)
    828.     $game_player.perform_transfer
    829.     $game_map.update
    830.     SceneManager.scene.post_transfer
    831.     if @@config[:pospone_teleport] == true
    832.       id = [[@@config[:activate_switch].to_i, 1].max, 9999].min
    833.       $game_switches[id] = false
    834.     end
    835.   end
    836.   #-----------------------------------------------------------------------------
    837.   def update
    838.     if Input.repeat?(Input::DOWN)
    839.       update_index(1)
    840.     elsif Input.repeat?(Input::UP)
    841.       update_index(-1)
    842.     end
    843.     if Input.repeat?(Input::LEFT) || Input.repeat?(Input::L)
    844.       update_index(-(@contents.viewport.rect.height / @h))
    845.     elsif Input.repeat?(Input::RIGHT) || Input.repeat?(Input::R)
    846.       update_index(@contents.viewport.rect.height / @h)
    847.     end
    848.     if Input.trigger?(Input::B)
    849.       play_fx(:cancel_se)
    850.       hide
    851.     end
    852.     if Input.trigger?(Input::C)
    853.       if @real_data[@index] == @current_map &&
    854.         @@config[:disable_last_teleport] == true
    855.         cancel_action
    856.         return
    857.       end
    858.       hide(true)
    859.       @action = true
    860.       @current_map = @real_data[@index]
    861.     end
    862.   end
    863.   #-----------------------------------------------------------------------------
    864.   def cancel_action
    865.     play_fx(:buzzer_se)
    866.   end
    867.   #-----------------------------------------------------------------------------
    868.   def play_fx(id)
    869.     begin
    870.       data = @@config[id]
    871.       Audio.se_play("Audio/SE/#{data[:name]}",
    872.         data [:volume].to_i, data[:pitch].to_i)
    873.     rescue
    874.     end
    875.   end
    876.   #-----------------------------------------------------------------------------
    877.   def update_index(n)
    878.     last_index = @index
    879.     @index += n
    880.     if @index < 0
    881.       @index = @real_data.size - 1
    882.     elsif @index > @real_data.size - 1
    883.       @index = 0
    884.     end
    885.     @selector.y = @h * @index
    886.     if @selector.y - @viewport.oy < 0
    887.       n = -(@selector.y - @viewport.oy)
    888.       @viewport.oy -= n
    889.       @bar_background.y -= n
    890.     elsif @selector.y + @selector.height - @viewport.oy > @viewport.rect.height
    891.       n = (@selector.y + @selector.height - @viewport.oy) - @viewport.rect.height
    892.       @viewport.oy += n
    893.       @bar_background.y += n
    894.     end
    895.     if last_index != @index
    896.       play_fx(:cursor_se)
    897.       draw_contents
    898.       if @bar_displacement != 0
    899.         @bar_top.y = @bar_background.y - @bar_background.oy + @bar_top.oy +
    900.           @bar_displacement * @contents.viewport.oy
    901.       end
    902.       if @index == @real_data.size - 1
    903.         @bar_top.y = @bar_background.y - @bar_background.oy +
    904.           @bar_background.height + @bar_top.oy - @bar_top.height
    905.       end
    906.     end
    907.     update_pos_cursor
    908.   end
    909.   #-----------------------------------------------------------------------------
    910.   def update_pos_cursor
    911.     @cursor.x = @viewport.rect.x - @cursor.width
    912.     @cursor.y = @selector.y + @selector.height / 2 - @cursor.height / 2 -
    913.       @viewport.oy + @viewport.rect.y
    914.     @cursor_animation_index = 0
    915.   end
    916.   #-----------------------------------------------------------------------------
    917.   def update_cursor_animation
    918.     @cursor.x += @cursor_animation[@cursor_animation_index]
    919.     @cursor_animation_index += 1
    920.     if @cursor_animation_index > @cursor_animation.size - 1
    921.       @cursor_animation_index = 0
    922.     end
    923.   end
    924.   #-----------------------------------------------------------------------------
    925.   def update_arrows_animation
    926.     v = @contents.viewport
    927.     @arrow_top.visible = (v.oy != 0)
    928.     @arrow_bottom.visible = (@contents.height - v.oy > v.rect.height)
    929.     @arrow_top.y    += @arrows_animation[@arrows_animation_index]
    930.     @arrow_bottom.y -= @arrows_animation[@arrows_animation_index]
    931.     @arrows_animation_index += 1
    932.     if @arrows_animation_index > @arrows_animation.size - 1
    933.       @arrows_animation_index = 0
    934.     end
    935.   end
    936.   #-----------------------------------------------------------------------------
    937.   def clear(data=nil)
    938.     @data.clear
    939.     unless data.nil?
    940.       @data = data
    941.       unless @data[$game_map.map_id].nil?
    942.         @current_map = @data[$game_map.map_id][0]
    943.       else
    944.         @current_map = nil
    945.       end
    946.     end
    947.   end
    948.   #-----------------------------------------------------------------------------
    949.   def dispose
    950.     instance_variables.each{|var|
    951.       if var.respond_to?(:dispose)
    952.         var.dispose rescue next
    953.       end
    954.     }
    955.   end
    956.   #-----------------------------------------------------------------------------
    957. end
    958. #===============================================================================
    959. #===============================================================================
    960. class Game_Map
    961.   #-----------------------------------------------------------------------------
    962.   unless method_defined?(:setup_teleport_newold)
    963.     alias setup_teleport_newold setup
    964.   end
    965.   #-----------------------------------------------------------------------------
    966.   def setup(map_id)
    967.     setup_teleport_newold(map_id)
    968.     add_to_teleport_list = true
    969.     no_add_text = "noAddToTeleportList".downcase
    970.     @map.events.each do |i, event|
    971.       if event.name.downcase == no_add_text
    972.         add_to_teleport_list = false
    973.         break
    974.       end
    975.     end
    976.     if add_to_teleport_list
    977.       $TeleportToVisited.add_map(map_id)
    978.     end
    979.   end
    980.   #-----------------------------------------------------------------------------
    981. end
    982. #===============================================================================
    983. #===============================================================================
    984. class Game_Player < Game_Character
    985.   #-----------------------------------------------------------------------------
    986.   unless method_defined?(:moveto_teleport_newold)
    987.     alias moveto_teleport_newold moveto
    988.   end
    989.   #-----------------------------------------------------------------------------
    990.   def moveto(x, y)
    991.     if (x < 0 || x > $game_map.width - 1)
    992.       @new_x = 0
    993.       x = 0
    994.     end
    995.     if (y < 0 || y > $game_map.height - 1)
    996.       @new_y = 0
    997.       y = 0
    998.     end
    999.     moveto_teleport_newold(x, y)
    1000.     map_id = $game_map.map_id
    1001.     $TeleportToVisited.update_map_info(map_id, :x, x)
    1002.     $TeleportToVisited.update_map_info(map_id, :y, y)
    1003.     $TeleportToVisited.update_map_info(map_id, :direction, self.direction)
    1004.   end
    1005.   #-----------------------------------------------------------------------------
    1006. end
    1007. #===============================================================================
    1008. #===============================================================================
    1009. module DataManager
    1010.   #=============================================================================
    1011.   class << self
    1012.     #---------------------------------------------------------------------------
    1013.     unless method_defined?(:setup_new_game_teleport_newold)
    1014.       alias setup_new_game_teleport_newold setup_new_game
    1015.     end
    1016.     def setup_new_game
    1017.       $TeleportToVisited.clear
    1018.       setup_new_game_teleport_newold
    1019.     end
    1020.     #---------------------------------------------------------------------------
    1021.     unless method_defined?(:load_game_without_rescue_teleport_newold)
    1022.       alias load_game_without_rescue_teleport_newold load_game_without_rescue
    1023.     end
    1024.     def load_game_without_rescue(index)
    1025.       $TeleportToVisited.clear
    1026.       load_game_without_rescue_teleport_newold(index)
    1027.     end
    1028.     #---------------------------------------------------------------------------
    1029.     unless method_defined?(:make_save_contents_teleport_newold)
    1030.       alias make_save_contents_teleport_newold make_save_contents
    1031.     end
    1032.     def make_save_contents
    1033.       contents = make_save_contents_teleport_newold
    1034.       contents[:teleportToVisited] = $TeleportToVisited.data.dup
    1035.       return contents
    1036.     end
    1037.     #---------------------------------------------------------------------------
    1038.     unless method_defined?(:extract_save_contents_teleport_newold)
    1039.       alias extract_save_contents_teleport_newold extract_save_contents
    1040.     end
    1041.     def extract_save_contents(contents)
    1042.       extract_save_contents_teleport_newold(contents)
    1043.       $TeleportToVisited.clear(contents[:teleportToVisited])
    1044.     end
    1045.     #---------------------------------------------------------------------------
    1046.   end
    1047.   #============================================================================
    1048. end
    1049. #===============================================================================
    1050. #===============================================================================
    1051. class Game_Interpreter
    1052.   #-----------------------------------------------------------------------------
    1053.   def open_teleport
    1054.     x = $game_map.events[@event_id].screen_x
    1055.     y = $game_map.events[@event_id].screen_y
    1056.     $TeleportToVisited.show_window(x, y)
    1057.   end
    1058.   #-----------------------------------------------------------------------------
    1059.   def perform_teleport
    1060.     $TeleportToVisited.perform_teleport
    1061.   end
    1062.   #-----------------------------------------------------------------------------
    1063.   def update_map_info(map_id, attr, value, ref=nil)
    1064.     $TeleportToVisited.update_map_info(map_id, attr, value, ref)
    1065.   end
    1066.   #-----------------------------------------------------------------------------
    1067.   def add_map(ref=nil, name="", map_id=nil, x=nil, y=nil, direction=nil)
    1068.     map_id = map_id.nil? ? $game_map.map_id : map_id.to_i
    1069.     direction = ([nil, 2, 4, 6, 8].include?(direction)) ? direction : 2
    1070.     $TeleportToVisited.add_map(map_id, ref, name, x, y, direction)
    1071.   end
    1072.   #-----------------------------------------------------------------------------
    1073.   def run
    1074.     begin
    1075.       wait_for_message
    1076.       while @list[@index] do
    1077.         execute_command
    1078.         @index += 1
    1079.       end
    1080.     rescue
    1081.       return
    1082.     end
    1083.     Fiber.yield
    1084.     @fiber = nil
    1085.   end
    1086.   #-----------------------------------------------------------------------------
    1087. end
    1088. #===============================================================================
    1089. $TeleportToVisited = TeleportToVisited.new
    复制代码




    本贴来自国际rpgmaker官方论坛作者:newold处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/teleport-to-visited-sites.104205/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 12:38 , Processed in 0.108370 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表