Tripitaka

Krieger

  • »Tripitaka« ist der Autor dieses Themas

Motto: Menschen sind doof, Tiere sind doof, Pflanzen sind doof... Steine sind okay.

  • Nachricht senden

1

Samstag, 11. Februar 2017, 18:56

Verwirrung um TDS Quick Travel

Hallo zusammen.
Ich habe mir für mein Spiel ein Quick Travel System raussuchen wollen und bin dabei auf den Script von TDS gestoßen.

Ich habe keinerlei Probleme mit dem Script (noch nicht) und er funktioniert so weit genauso, wie ich es gern hätte - nur wirft er dennoch an einigen Stellen Fragen auf, die mich zutiefst verwirren.
Hier einmal der Script zum Ansehen:
Spoiler

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
#==============================================================================
# ** TDS Quick Travel
#    Ver: 1.4
#------------------------------------------------------------------------------
#  * Description:
#  This script allows you to quickly travel to pre determined locations on a 
#  map.
#------------------------------------------------------------------------------
#  * Features: 
#  Quickly change locations on a map.
#------------------------------------------------------------------------------
#  * Instructions:
#
#  To add a quick travel location to a map use this in a script call:
#
#  add_map_quick_travel(id, name, map, map_id, x, y, dir)
#
#   id     = ID of the quick travel point. (It's order in the list)
#   name   = name of the quick travel location.
#   map    = map id to add quick travel location to.
#   map_id = map ID to quick travel to.
#   x      = X coordinate of the quick travel location on the map
#   y      = Y coordinate of the quick travel location on the map
#   dir    = facing direction after quick traveling (2: Down , 4: Left, 6: Right, 8: Up)  
#
#  To disable quick travel use this on a script call:
#
#    disable_map_quick_travel
#  
#  To enable quick travel use this on a script call:
#
#    disable_map_quick_travel
#
#  To call the quick travel selection menu press the "X" (A) key.
#
#  To call the quick travel menu from an event, use this on a script call:
#
#    call_map_quick_travel_menu
#
#------------------------------------------------------------------------------
#  * Notes:
#  None.
#------------------------------------------------------------------------------
# WARNING:
#
# Do not release, distribute or change my work without my expressed written 
# consent, doing so violates the terms of use of this work.
#
# If you really want to share my work please just post a link to the original
# site.
#
# * Not Knowing English or understanding these terms will not excuse you in any
#   way from the consequenses.
#==============================================================================
# * Import to Global Hash *
#==============================================================================
($imported ||= {})[:TDS_Quick_Travel] = true
 
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#==============================================================================
 
class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :map_quick_travel
  attr_accessor :disable_quick_travel
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_quick_travel_game_system_initialize                    initialize  
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Run Original Method
    tds_quick_travel_game_system_initialize     
    # Initialize Quick Travel Values
    init_quick_travel        
  end
  #--------------------------------------------------------------------------
  # * Initialize Map Quick Travel
  #--------------------------------------------------------------------------
  def init_quick_travel  
    # Disable Quick Travel Flag
    @disable_quick_travel = false
    # Make Map Quick Travel Hash
    @map_quick_travel = {}
  end  
  #--------------------------------------------------------------------------
  # * Determine if Map Quick Travel is possible
  #--------------------------------------------------------------------------
  def can_quick_travel?
    # Return false if map quick travel is disabled
    return false if @disable_quick_travel
    # Return false if Map has no quick travel points
    return false if !has_quick_travel?
    # Return true by default
    return true
  end
  #--------------------------------------------------------------------------
  # * Determine if Map has Quick Travel points
  #--------------------------------------------------------------------------
  def has_quick_travel?
    # Return false if Map Quick Travel List is nil or empty
    return false if @map_quick_travel[$game_map.map_id].nil?
    # Return true by default
    return true
  end  
  #--------------------------------------------------------------------------
  # * Get Quick Travel Map List
  #--------------------------------------------------------------------------
  def quick_travel_map_list
    # Get Map Quick Travel Points
    return @map_quick_travel[$game_map.map_id].keys.sort.collect {|id| @map_quick_travel[$game_map.map_id][id]}
  end
end
 
 
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
 
class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Constants (Structs)
  #--------------------------------------------------------------------------
  # Battle Action Base
  Quick_Travel_Settings = Struct.new(:name, :map_id, :x, :y, :direction)        
  #--------------------------------------------------------------------------
  # * Enable or Disable Map Quick Travel
  #--------------------------------------------------------------------------
  def enable_map_quick_travel  ; $game_system.disable_quick_travel = false end  
  def disable_map_quick_travel ; $game_system.disable_quick_travel = true end
  #--------------------------------------------------------------------------
  # * Call Map Quick Travel Menu
  #--------------------------------------------------------------------------
  def call_map_quick_travel_menu
    # If on Scene Map and there are quick travel points
    if SceneManager.scene_is?(Scene_Map) and $game_system.has_quick_travel?
      # Call Quick Travel Menu Process
      SceneManager.scene.start_quick_travel_selection
    end
  end      
  #--------------------------------------------------------------------------
  # * Add Map Quick Travel
  #--------------------------------------------------------------------------
  def add_map_quick_travel(id, name, map, map_id, x, y, dir = 2)
    # Make Empty hash if necessary
    $game_system.map_quick_travel[map] ||= {}
    # Set Map Quick Travel Point
    $game_system.map_quick_travel[map][id] = Quick_Travel_Settings.new(name, map_id, x, y, dir)
  end   
  #--------------------------------------------------------------------------
  # * Remove Map Quick Travel
  #--------------------------------------------------------------------------
  def remove_map_quick_travel(map_id, id)
    # Return if there are quick travel points in the map
    return if $game_system.map_quick_travel[map_id].nil?
    # Delete Map Quick Travel Point
    $game_system.map_quick_travel[map_id].delete(id)
  end 
end
 
 
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================
 
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_quick_travel_scene_map_update                              update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update Quick Travel Input
    update_quick_travel_input   
    # Run Original Method
    tds_quick_travel_scene_map_update
  end
  #--------------------------------------------------------------------------
  # * Start Quick Travel SElection
  #--------------------------------------------------------------------------
  def start_quick_travel_selection
    # Make Scene Cover Sprite
    @scene_cover = Sprite.new
    @scene_cover.bitmap = Graphics.snap_to_bitmap
    @scene_cover.bitmap.blur      
    @scene_cover.opacity = 0      
    @scene_cover.tone.set(-30, -30, -30)
    @scene_cover.z = 5000
    # Make Quick Travel Window
    @quick_travel_list_window = Window_Quick_Travel_List.new
    @quick_travel_list_window.x = (Graphics.width - @quick_travel_list_window.width) / 2
    @quick_travel_list_window.y = (Graphics.height - @quick_travel_list_window.height) / 2      
    @quick_travel_list_window.z = 5100
    @quick_travel_list_window.openness = 0
    @quick_travel_list_window.open.activate.select(0)
    # Set Quick Travel Window Handlers
    @quick_travel_list_window.set_handler(:ok,     method(:on_quick_travel_selection_ok))
    @quick_travel_list_window.set_handler(:cancel, method(:on_quick_travel_selection_cancel))
    # Fade In Scene Cover
    15.times { Graphics.update ; @scene_cover.opacity += 17}
    # Quick Travel Selection Update Loop
    loop { 
      # Update Graphics, Input and Quick Travel Window
      Graphics.update ; Input.update ; @quick_travel_list_window.update
      # Break if Quick Travelis nil
      break if @quick_travel_list_window.nil?
    }
  end
  #--------------------------------------------------------------------------
  # * [OK] Quick Travel Selection
  #--------------------------------------------------------------------------
  def on_quick_travel_selection_ok
    # Get Transfer Information
    transfer = @quick_travel_list_window.selected_transfer 
    # Deactivate and Close Quick Travel List window
    @quick_travel_list_window.deactivate ; @quick_travel_list_window.close
    # Update Graphics and Fadeout Scene Cover
    10.times { Graphics.update ; @scene_cover.opacity -= 17 ; @quick_travel_list_window.update }
    # Dispose of Scene Cover
    @scene_cover.bitmap.dispose ; @scene_cover.dispose ; @scene_cover = nil
    # Dispose of Quick Travel List Window
    @quick_travel_list_window.dispose ; @quick_travel_list_window = nil
    # Start Transfer
    $game_player.reserve_transfer(transfer.map_id, transfer.x, transfer.y, transfer.direction)
    $game_temp.fade_type = 0
    # Update Input
    Input.update
  end
  #--------------------------------------------------------------------------
  # * [Cancel] Quick Travel Selection
  #--------------------------------------------------------------------------
  def on_quick_travel_selection_cancel
    # Deactivate and Close Quick Travel List window
    @quick_travel_list_window.deactivate ; @quick_travel_list_window.close
    # Update Graphics and Fadeout Scene Cover
    10.times { Graphics.update ; @scene_cover.opacity -= 17 ; @quick_travel_list_window.update }
    # Dispose of Scene Cover
    @scene_cover.bitmap.dispose ; @scene_cover.dispose ; @scene_cover = nil
    # Dispose of Quick Travel List Window
    @quick_travel_list_window.dispose ; @quick_travel_list_window = nil
    # Update Input
    Input.update
  end
  #--------------------------------------------------------------------------
  # * Update Quick Travel Input
  #--------------------------------------------------------------------------
  def update_quick_travel_input
    # Return if Interpreter is running or messages
    return if !$game_system.can_quick_travel? or $game_map.interpreter.running? or ($game_message.busy? or $game_message.visible)    
    # If Input Trigger A
    if Input.trigger?(:X)
      # Play Ok Sound
      Sound.play_ok
      # Start Quick Travel Selection
      start_quick_travel_selection
    end
  end
end
 
 
#==============================================================================
# ** Window_Quick_Travel_List
#------------------------------------------------------------------------------
#  This window handles Quick Travel List selection.
#==============================================================================
 
class Window_Quick_Travel_List < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :quick_travel_list  
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Get Quick Travel List
    @quick_travel_list =  $game_system.quick_travel_map_list      
    # Get Max Text Width of Commands 
    @max_text_width = max_text_width
    # Create Window Contents
    super(0, 0, window_width, window_height)
    # Draw Window Contents
    refresh
  end
  #--------------------------------------------------------------------------
  # * Get Selected Transfer Information
  #--------------------------------------------------------------------------
  def selected_transfer ; @quick_travel_list[@index] end  
  #--------------------------------------------------------------------------
  # * Window Width and Height
  #--------------------------------------------------------------------------
  def window_width  ; [12 + max_text_width + (standard_padding * 2), Graphics.width].min end
  def window_height ; fitting_height(visible_line_number) end
  #--------------------------------------------------------------------------
  # * Max Columns
  #--------------------------------------------------------------------------
  def col_max ; 1 end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def item_max ; @quick_travel_list.size end 
  #--------------------------------------------------------------------------
  # * Get Number of Lines to Show
  #--------------------------------------------------------------------------
  def visible_line_number ; [[item_max + 1, 16].min, 2].max end
  #--------------------------------------------------------------------------
  # * Get Number of Rows Displayable on 1 Page
  #--------------------------------------------------------------------------
  def page_row_max ; super - 1 end
  #--------------------------------------------------------------------------
  # * Get Row Count
  #--------------------------------------------------------------------------
  def row_max ; super + 1 end
  #--------------------------------------------------------------------------
  # * Item Rect
  #--------------------------------------------------------------------------
  def item_rect(index) ; rect = super ; rect.y += line_height ; rect end  
  #--------------------------------------------------------------------------
  # * Find Max Text Width
  #--------------------------------------------------------------------------
  def max_text_width
    # Create Temporary Contents
    contents = Bitmap.new(1, 1)
    contents.font.size = Font.default_size
    contents.font.bold = Font.default_bold
    contents.font.italic = Font.default_italic    
    # Get Starting Width
    width = 0
    # Go Through Quick Travel List
    @quick_travel_list.each {|t| 
    # Set Max Width
    w = contents.text_size(t.name).width ; width += w if w > width 
    }
    # Dispose of Contents
    contents.dispose ; contents = nil
    # Return Max Text Width
    return [width, 230].max
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    super
    contents.font.color = system_color
    # Draw Quick Travel Header
    draw_text(0, 0, contents_width, line_height, "Quick travel list", 1)
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    # Draw Quick Travel Point Name
    draw_text(item_rect_for_text(index), @quick_travel_list.at(index).name)
  end
end
zum Lesen den Text mit der Maus markieren

Im Endeffekt ist der Script relativ selbsterklärend. Mit einem Script Call wird eine neue Travel Location definiert und das war's. Wenn jedoch die Demo nicht verfügbar wäre, wäre es sicher nicht so leicht gewesen, den Script zu verwenden, denn die Beschreibung verwirrt mich hart...
In Zeile 16 bis 24 wird erklärt, wie eine Location hinzugefügt wird. Was aber bedeutet Zeile 20? In Zeile 21 wird - vermutlich - die Map ID genannt, wohin man teleportiert wird. Aber nach was für eine ID wird in Zeile 20 gefragt? Zumal dieser Wert am Ende nicht einmal vonnöten ist, denn im Beispiel der Demo sieht der Script Call Befehl so aus:

Ruby Quellcode

1
2
3
4
5
6
7
8
n = "Demo Start"
id = 0  # ID of Quick Travel Point
m = 1   # Map ID
x = 11  # X Coordinate on map
y = 9   # Y Coordinate on Map
d = 2   # Direction to face after travel
# Add Map Quick Point
add_map_quick_travel(id, n, m, m, x, y, d)

Laut Script müssen 7 Werte angegeben werden (id, name, map, map_id, x, y, dir) - hier sind aber nur 6 definiert. Warum? Und was genau ist der Unterschied zwischen "map" und "map_id"?
Wie schon gesagt funktioniert der Script so... Scheinbar. Ich habe einfach das Beispiel aus der Demo in mein Projekt kopiert und die entsprechenden Werte abgeändert, nur würde ich dennoch gern wissen, warum der Scrip Call Befehl nicht wie im Script beschrieben aussieht - um eventuelle Spätfolgen oder Fehler zu vermeiden.
Was lebt, das kann man töten. Was tot ist, das kann man essen.
--------------------------------------------------------------------------
:map: Mapping: :star::star::star::star::star:
:compile: Scripting: :star-empty::star-empty::star-empty::star-empty::star-empty:
:system-monitor: Event: :star::star::star::star::star:
:doc: Story: :star::star::star::star::star-empty:
:pencil: Zeichnen: :star::star::star::star::star:
:palette: Pixeln: :star::star::star-half::star-empty::star-empty:
:music-beam-16: Musik & Sounds: :star::star::star::star-empty::star-empty:
--------------------------------------------------------------------------
Bevorzugter Maker: :ace:
Ebenfalls im Besitzt: :rmxp: :rmvx: :rmmv:

2

Samstag, 11. Februar 2017, 19:41

Hast Du einen Link zur Quelle/zum Autor? Eigentlich möchte der nicht, dass seine Scripte repostet werden (Zeile 46).

Der Parameter map ist die MapID, auf der die Schnellreisemöglichkeit zur Verfügung steht. Mach einfach mal zwei Maps. Gebe jeder Map eine Schnellreise auf die andere Map (indem Du bei map die eigene MapID angibst, und bei map_id die ID der zweiten Map). Dann schau dir die Schnellreiseauswahlbildschirme an. Vielleicht hilft es noch eine dritte Map hinzuzufügen und die Schnellreise dorthin nur auf einer der beiden ersten Maps zu erlauben.

Übrigens kannst Du in ein Event Scriptcall die Variable @map_id verwenden, um die aktuelle Map zu referenzieren.

Tripitaka

Krieger

  • »Tripitaka« ist der Autor dieses Themas

Motto: Menschen sind doof, Tiere sind doof, Pflanzen sind doof... Steine sind okay.

  • Nachricht senden

3

Samstag, 11. Februar 2017, 20:18

Jup, hier ist der Link zur Quelle, wo ich den Script her habe:
Quick Travel :: rpgmaker.net


Okay, also heißt es, dass man mit dem Parameter "map" verhindern kann, dass man sich zu dem Point teleportet, an dem man sich gerade befindet - beispielsweise.
In dem Fall wäre es ja praktisch, wenn man sagen könnte, dass man den Point von überall aus wählen kann - AUSSER der Map, zu der man damit reist. Ist das möglich? Nicht zu sagen, auf welcher Map / welchen Maps der Point sichtbar sein soll - sondern wo nicht?
Was lebt, das kann man töten. Was tot ist, das kann man essen.
--------------------------------------------------------------------------
:map: Mapping: :star::star::star::star::star:
:compile: Scripting: :star-empty::star-empty::star-empty::star-empty::star-empty:
:system-monitor: Event: :star::star::star::star::star:
:doc: Story: :star::star::star::star::star-empty:
:pencil: Zeichnen: :star::star::star::star::star:
:palette: Pixeln: :star::star::star-half::star-empty::star-empty:
:music-beam-16: Musik & Sounds: :star::star::star::star-empty::star-empty:
--------------------------------------------------------------------------
Bevorzugter Maker: :ace:
Ebenfalls im Besitzt: :rmxp: :rmvx: :rmmv:

4

Samstag, 18. Februar 2017, 21:07

So wie das System aufgebaut ist, ist das nicht so einfach möglich. Man müsste so ziemlich Alles umschreiben dafür, das vom Originalscript kaum noch etwas übrig wäre.
Was man machen kann, wäre eine Hilfe einzubauen, dass man sehr schnell die Option "Reise nach X" für mehrere Startmaps auf einmal setzen kann.

Ähnliche Themen

Social Bookmarks