• Anmelden

1

Montag, 22. Dezember 2014, 20:41

Icon Display 1.0 skript sorgt dafür, dass ein event mit "through" Eigenschaft nicht mehr durch den Held geht.

Hallo erstmal. Wie soll ich ich mein Problem erläutern? Fangen wir doch mal ganz generell an:
Normalerweise kann ein Event durch den Held hindurch gehen, wenn das Event mit der Eigenschaft "through" belegt wurde.
Also z.B. wenn ein Event immer nach rechts geht und mit der Eigenschaft through versehen ist, geht er irgendwann durch den Held durch vorausgesetzt, dass der Held auf der gleichen Linie wie das Event ist.
Soweit so gut.

Es gibt da ein Icon display skript von Mr.Mo "Muhammet Sivri, welches es erlaubt icons über NPCS laufen zu lasssen. Das Skript besteht aus zwei Skripte. Einmal das Icon Overhead Display und einmal das Module UCoders. Wenn man die beiden codes nun über main hinzufügt, funktionieren diese einwandfrei. Aber nachdem die beiden codes hinzugefügt wurden, können events nicht mehr über den Helden oder über andere Events gehen, obwohl beim Event die Option through an ist. Normalerweise geht der Event über den Spieler, wenn bei ihm die Option through an ist. Irgendwo im Code muss ein Bug sein, ich kann mir nicht vorstellen, dass das zum Skript dazugehört bzw. das das gewollt ist.



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
#===============================================================================
# ** Icon Display 1.0 - www.unknowncoders.com
#-------------------------------------------------------------------------------
# Author Mr.Mo "Muhammet Sivri"
# Version 1.0
# Date 12/04/07 (m/d/y)
#===============================================================================
# Introduction
#===============================================================================
# Displays an icon over events or the player. You can choose for how long.
# You can also display without triggering the event by using comments on events.
#
# To display over an event, call this script:
#
# $game_map.events[EVENT_ID].display_icon("icon_name")
#
# EVENT_ID = the ID of the event, can be found on the left top corner of the
# event editor. Make sure to remove any 0 that are up front.
# For exmple: 001 = 1 or 010 = 10
#
# To display over an event without triggers using comments:
#
# IconD icon_name frames
#
# You do not need frames if you want to display non-stop. Examples:
#
# IconD 049-Skill06
# IconD 049-Skill06 30
#
# The first one displays forever, the second displays for 3 seconds.
#
# To display over a player, call this script:
#
# $game_player.display_icon("icon_name")
#
# NOTE: You can also add how long it should be shown, default is until map change.
# To add the lenght of display do this:
#
# .display_icon("icon_name",FRAMES)
#
# FRAMES = number of frames(10=1) that the icon will be displayed.
#
# Exmaples:
#
# $game_map.events[EVENT_ID].display_icon("icon_name",100) > 10 seconds
# $game_player.display_icon("icon_name",40) > 4 seconds
#===============================================================================
UCoders.include('Icon Display', ['Mr.Mo','1.0'])
class Game_Character
 attr_accessor :icon, :icon_frames, :displaying_icon, :current_icon
 #--------------------------------------------------------------------------
 alias mrmo_icond_game_character_initialize initialize
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
 @icon = @displaying_icon = @current_icon = ""
 @icon_frames = 0
 mrmo_icond_game_character_initialize
 end
 #--------------------------------------------------------------------------
 # * Display Icon
 #--------------------------------------------------------------------------
 def display_icon(icon,frames=0)
 @icon = icon
 @icon_frames = frames
 end 
 #--------------------------------------------------------------------------
 # * Setup Icon
 #--------------------------------------------------------------------------
 def setup_icond(event,list)
 parameters = UCoders.event_comment_input(event,1,"IconD"); return false if parameters.nil?
 # Get Icon
 @icon = parameters[0].split[1].to_s
 @icon_frames = (parameters[0].split[2].to_i)
 end
end
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# This sprite is used to display the character.It observes the Game_Character
# class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Character < RPG::Sprite
 alias mrmo_icond_sprite_character_int initialize
 alias mrmo_icond_sprite_character_update update
 #--------------------------------------------------------------------------
 # * Initialize
 #--------------------------------------------------------------------------
 def initialize(viewport, character = nil)
 mrmo_icond_sprite_character_int(viewport, character)
 show_icon unless (@character.icon=@character.current_icon).empty?
 #@character.displaying_icon = ""
 end
 #--------------------------------------------------------------------------
 # * Dispose
 #--------------------------------------------------------------------------
 def dispose
 super
 @icon_sprite.dispose if !@icon_sprite.nil? && !@icon_sprite.disposed?
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
 mrmo_icond_sprite_character_update
 # Check if an icon needs to be displayed
 if @character.icon == "r"
 @icon_sprite.dispose unless @icon_sprite.nil?
 @icon_sprite = nil
 @character.icon = @character.current_icon = @character.displaying_icon = ""
 end
 if !@character.icon.empty?
 show_icon
 @character.icon = ""
 end
 if !@icon_sprite.nil?
 @icon_sprite.x = self.x-(@icon_sprite.bitmap.width/2)
 @icon_sprite.y = (self.y-@icon_sprite.bitmap.height)-self.bitmap.height/4 + 4
 @character.icon_frames -= 1 if @character.icon_frames > 1
 if @character.icon_frames == 1
 @icon_sprite.dispose
 @icon_sprite = nil
 @character.current_icon = @character.displaying_icon = ""
 end
 end
 end
 #--------------------------------------------------------------------------
 # * Show Icon
 #--------------------------------------------------------------------------
 def show_icon
 @character.current_icon = @character.displaying_icon = @icon = @character.icon
 # Create Sprite
 @icon_sprite = Sprite.new if @icon_sprite.nil?
 @icon_sprite.bitmap = RPG::Cache.icon("#{@icon}")
 end
end
 
#============================================================================
# * Game Event 
#============================================================================
class Game_Event < Game_Character
 #--------------------------------------------------------------------------
 alias mrmo_icon_game_event_refresh refresh
 #--------------------------------------------------------------------------
 # * Refreshes Page
 #--------------------------------------------------------------------------
 def refresh
 mrmo_icon_game_event_refresh
 setup_icond(self,@list)
 endend

zum Lesen den Text mit der Maus markieren








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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
#===============================================================================
# ** Module UCoders - Contains Methods used by Unknown Coders' scripts
#
# Visit Us:
# www.unknowncoders.com
#
#-------------------------------------------------------------------------------
# Authors Mr.Mo "Muhammet Sivri" | Trebor777
# Version 1.2
# Date 11/24/07 (m/d/y)
#===============================================================================
module UCoders
 #--------------------------------------------------------------------------
 # * Constants
 #--------------------------------------------------------------------------
 Object = {}
 Scripts = {}
 #--------------------------------------------------------------------------
 # * Include Script
 #--------------------------------------------------------------------------
 def UCoders.include(name,args) 
 Scripts[name] = args
 end
 #--------------------------------------------------------------------------
 # * Include Script
 #--------------------------------------------------------------------------
 def UCoders.has?(name)
 return !Scripts[name].nil?
 end
 #--------------------------------------------------------------------------
 # * Returns a list of parameters from an event's comments
 #--------------------------------------------------------------------------
 def UCoders.event_comment_input(*args)
 parameters = []; list = *args[0].list; lines = *args[1]; trigger = *args[2]
 return nil if list.nil? || !list.is_a?(Array)
 list.each { |o|
 next if o.code != 108 || !(o.parameters[0].to_s).include?(trigger)
 start = list.index(o)
 finish = start + lines
 for id in start...finish
 next if !list[id]; parameters.push(list[id].parameters[0])
 end
 return parameters 
 }
 return nil
 end
 #--------------------------------------------------------------------------
 # * Returns the event comment with the needed key
 #--------------------------------------------------------------------------
 def UCoders.event_comment(*args)
 parameters = []; list = *args[0].list; trigger = *args[1]
 return nil if list.nil? || !list.is_a?(Array)
 list.each { |o| next if o.code != 108 || !(o.parameters[0].to_s).include?(trigger)
 parameters.push(o.parameters)
 }
 return parameters unless parameters.empty?
 return nil
 end
 #--------------------------------------------------------------------------
 # * Log Error - Records and Saves all errors.
 #--------------------------------------------------------------------------
 def UCoders.log_error
 # Record Error 
 k = 0
 time = Time.now.strftime("%a %d %b %Y, %X")
 log = File.open("ErrorLog.rxdata","a+")
 log.write("[ #{time} ]\n")
 # Write Message and Type
 log.write("'#{$!.message}' Type #{$!.class}\n")
 for i in 0..$!.backtrace.size
 e = $!.backtrace
 /Section(.*):(.*):in (.*)/.match(e)
 space = " "*(i*2)
 log.write(space+" <>Script '#{$RGSS_SCRIPTS[$1.to_i][1]}' | Line #{$2} | Method #{$3}\n")
 # Don't list more then 4 backtraces to make it simpler, can be changed! 
 break if i >= 4
 next if k == 1
 # Get the first trace
 script = "#{$RGSS_SCRIPTS[$1.to_i][1]}"
 line = $2
 method = $3
 k = 1
 end
 log.write("\n")
 log.close
 # Make some sense
 if $DEBUG
 print "#{$!.message} \nScript '#{script}' \nLine '#{line}' \nMethod '#{method}' \nType '#{$!.class}'"
 else
 print "Unexpected Error! The ErrorLog is in folder:\n #{File.expand_path('.')}"
 end
 end
 #--------------------------------------------------------------------------
 # * Checks the object range
 #--------------------------------------------------------------------------
 def UCoders.in_screen?(object)
 scene_x = $game_map.display_x - 256
 scene_y = $game_map.display_y - 256
 scene_width = $game_map.display_x + 2816
 scene_height = $game_map.display_y + 2176
 return (object.real_x.between?(scene_x, scene_width) and object.real_y.between?(scene_y,scene_height))
 end
 #--------------------------------------------------------------------------
 # * Get Events In (range of element)
 #--------------------------------------------------------------------------
 def UCoders.get_events_in(range,element)
 objects = []
 $game_map.events.each_value { |e| objects.push(e) if UCoders.in_range?(element, e, range) }
 return objects
 end
 #--------------------------------------------------------------------------
 # * Get Range(Element, Object)
 #--------------------------------------------------------------------------
 def UCoders.get_range(element, object)
 x = (element.x - object.x)**2
 y = (element.y - object.y)**2
 r = x + y
 return Math.sqrt(r).to_i
 end
 #--------------------------------------------------------------------------
 # * In Range?(Element, Object, Range)
 #--------------------------------------------------------------------------
 def UCoders.in_range?(element, object, range)
 x = (element.x - object.x)**2
 y = (element.y - object.y)**2
 return x + y <= (range * range)
 end
 #--------------------------------------------------------------------------
 # * In Direction?(Element, Object)
 #--------------------------------------------------------------------------
 def UCoders.in_direction?(event,object)
 return true if event.direction == 2 && object.y >= event.y && object.x == event.x
 return true if event.direction == 4 && object.x <= event.x && object.y == event.y
 return true if event.direction == 6 && object.x >= event.x && object.y == event.y
 return true if event.direction == 8 && object.y <= event.y && object.x == event.x
 return false
 end
end
#==============================================================================
# ** Multi-Dimensional Array
# Creates a MultiD array. When value not specified, returns nil. 
#==============================================================================
class MultiArray
 #--------------------------------------------------------------------------
 # * Initialize
 # d : number of dimensions(x,y,z) 
 #--------------------------------------------------------------------------
 def initialize(*dimensions)
 @dimensions=Array.new(dimensions.size)
 @factors=Array.new(dimensions.size)
 product=1
 i=dimensions.size-1
 while i >= 0
 @dimensions=dimensions
 @factors=product
 product*=@dimensions
 i-=1
 end
 @data=Array.new(product)
 end
 #--------------------------------------------------------------------------
 # * X Size
 #--------------------------------------------------------------------------
 def xsize
 return @dimensions[0]
 end
 #--------------------------------------------------------------------------
 # * Y Size
 #--------------------------------------------------------------------------
 def ysize
 return 1 if @dimensions.size<2
 return @dimensions[1]
 end
 #--------------------------------------------------------------------------
 # * Z Size
 #--------------------------------------------------------------------------
 def zsize
 return 1 if @dimensions.size<3
 return @dimensions[2]
 end
 #--------------------------------------------------------------------------
 # * NSize
 #--------------------------------------------------------------------------
 def nsize(n)
 raise IndexError if @dimensions.size<n
 return @dimensions[n-1]
 end
 #--------------------------------------------------------------------------
 # * Get ID
 #--------------------------------------------------------------------------
 def get_id(indices)
 raise IndexError if indices.size != @dimensions.size
 offset=0
 for i in 0 ... @dimensions.size
 raise IndexError if indices < 0 or indices>=@dimensions
 offset += @factors*indices
 end
 return offset
 end
 #--------------------------------------------------------------------------
 # * Get []
 #--------------------------------------------------------------------------
 def [](*indices)
 @data[self.get_id(indices)]
 end
 #--------------------------------------------------------------------------
 # * Set []=
 #--------------------------------------------------------------------------
 def []=(*indicesAndValue)
 value = indicesAndValue.pop
 @data[self.get_id(indicesAndValue)]=value
 end
end
#==============================================================================
# ** 2-Dimensional Array
# Creates a 2D array. When value not specified, returns 0. 
#==============================================================================
class Array2D
 #--------------------------------------------------------------------------
 # * Initialize
 #--------------------------------------------------------------------------
 def initialize
 # Create Data Array
 @data = {}
 end
 #--------------------------------------------------------------------------
 # * Get
 #--------------------------------------------------------------------------
 def [](i,j)
 @data = {} if @data.nil?
 @data[j] = 0 if @data[j].nil?
 return @data[j]
 end
 #--------------------------------------------------------------------------
 # * Set
 #--------------------------------------------------------------------------
 def []=(i,j,v)
 @data = {} if @data.nil?
 @data[j] = v
 return v
 end
end
#==============================================================================
# ** RPG::Event::Page::Condition
#==============================================================================
 
class RPG::Event::Page::Condition
 #--------------------------------------------------------------------------
 # * Conditions Met?
 #--------------------------------------------------------------------------
 def conditions_met?(map_id, event_id)
 # Switch 1 condition confirmation
 if @switch1_valid && $game_switches[@switch1_id] == false
 return false
 end
 # Switch 2 condition confirmation
 if @switch2_valid && $game_switches[@switch2_id] == false
 return false
 end
 # Variable condition confirmation
 if @variable_valid && $game_variables[@variable_id] < @variable_value
 return false
 end
 # Self switch condition confirmation
 if @self_switch_valid
 key = [map_id, event_id, @self_switch_ch]
 if $game_self_switches[key] == false
 return false
 end
 end
 # Returns True
 return true
 end
end
 
#==============================================================================
# ** Game_Event
#==============================================================================
class Game_Event < Game_Character
 attr_reader :real_x, :real_y, :event
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
 new_page = refresh_new_page # Get New Page
 return if refresh_page_change?(new_page) # Return if No Page Change
 clear_starting # Clear starting flag
 return if refresh_page_reset? # Return if Nil Page Reset
 refresh_set_page # Set page variables
 refresh_check_process # Check parallel processing
 check_event_trigger_auto # Auto event start determinant
 end
 #--------------------------------------------------------------------------
 # * Refresh : New Page
 #--------------------------------------------------------------------------
 def refresh_new_page
 return @erased ? nil : refresh_trigger_conditions
 end
 #--------------------------------------------------------------------------
 # * Refresh Trigger Conditions
 #--------------------------------------------------------------------------
 def refresh_trigger_conditions
 # Check in order of large event pages
 for page in @event.pages.reverse
 # Skips If Page Conditions Not Met
 next unless page.condition.conditions_met?(@map_id, @id)
 # Set local variable: new_page
 new_page = page
 # Remove loop
 break
 end
 # Return new page
 return new_page
 end
 #--------------------------------------------------------------------------
 # * Refresh : Page Change
 #--------------------------------------------------------------------------
 def refresh_page_change?(new_page)
 # If event page is the same as last time
 if new_page == @page
 # End method
 return true
 end
 # Set @page as current event page
 @page = new_page
 return false
 end
 #--------------------------------------------------------------------------
 # * Refresh : Page Reset
 #--------------------------------------------------------------------------
 def refresh_page_reset?
 # If no page fulfills conditions
 if @page == nil
 # Reset values
 refresh_reset
 # End method
 return true
 end
 return false
 end
 #--------------------------------------------------------------------------
 # * Refresh Reset
 #--------------------------------------------------------------------------
 def refresh_reset
 # Set each instance variable
 @tile_id = 0
 @character_name = ""
 @character_hue = 0
 @move_type = 0
 @through = true
 @trigger = nil
 @list = nil
 @interpreter = nil
 end
 #--------------------------------------------------------------------------
 # * Refresh Set Page
 #--------------------------------------------------------------------------
 def refresh_set_page
 # Set each instance variable
 @tile_id = @page.graphic.tile_id
 @character_name = @page.graphic.character_name
 @character_hue = @page.graphic.character_hue
 if @original_direction != @page.graphic.direction
 @direction = @page.graphic.direction
 @original_direction = @direction
 @prelock_direction = 0
 end
 if @original_pattern != @page.graphic.pattern
 @pattern = @page.graphic.pattern
 @original_pattern = @pattern
 end
 @opacity = @page.graphic.opacity
 @blend_type = @page.graphic.blend_type
 @move_type = @page.move_type
 @move_speed = @page.move_speed
 @move_frequency = @page.move_frequency
 @move_route = @page.move_route
 @move_route_index = 0
 @move_route_forcing = false
 @walk_anime = @page.walk_anime
 @step_anime = @page.step_anime
 @direction_fix = @page.direction_fix
 @through = @page.through
 @always_on_top = @page.always_on_top
 @trigger = @page.trigger
 @list = @page.list
 @interpreter = nil
 end
 #--------------------------------------------------------------------------
 # * Refresh Check Process
 #--------------------------------------------------------------------------
 def refresh_check_process
 # If trigger is [parallel process]
 if @trigger == 4
 # Create parallel process interpreter
 @interpreter = Interpreter.new
 end
 end
end
 
class Interpreter
 #--------------------------------------------------------------------------
 # * Script
 #--------------------------------------------------------------------------
 def command_355
 # Set first line to script
 script = @list[@index].parameters[0] + "\n"
 # Loop
 loop do
 # If next event command is second line of script || after
 if @list[@index+1].code == 655
 # Add second line || after to script
 script += @list[@index+1].parameters[0] + "\n"
 # If event command is not second line || after
 else
 # Abort loop
 break
 end
 # Advance index
 @index += 1
 end
 # Evaluation
 result = eval(script)
 # Continue
 return true
 end
 #--------------------------------------------------------------------------
 # * In Range?(Element, Object, Range)
 #--------------------------------------------------------------------------
 def in_range?(element, object, range)
 x = (element.x - object.x)**2
 y = (element.y - object.y)**2
 return x + y <= (range * range)
 end
end
 
#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
# This class performs load screen processing.
#==============================================================================
 
class Scene_Load < Scene_File
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
 # Remake temporary object
 $game_temp = Game_Temp.new
 # Timestamp selects new file
 $game_temp.last_file_index = 0
 latest_time = Time.at(0)
 for i in 0..3
 filename = make_filename(i)
 if FileTest.exist?(filename)
 file = File.open(filename, "r")
 if file.mtime > latest_time
 latest_time = file.mtime
 $game_temp.last_file_index = i
 end
 file.close
 end
 end
 super("Which file would you like to load?")
 end
 #--------------------------------------------------------------------------
 # * Decision Processing
 #--------------------------------------------------------------------------
 def on_decision(filename)
 # If file doesn't exist
 unless FileTest.exist?(filename)
 # Play buzzer SE
 $game_system.se_play($data_system.buzzer_se)
 return
 end
 # Play load SE
 $game_system.se_play($data_system.load_se)
 # Read save data
 file = File.open(filename, "rb")
 read_save_data(file)
 file.close
 # Restore BGM and BGS
 $game_system.bgm_play($game_system.playing_bgm)
 $game_system.bgs_play($game_system.playing_bgs)
 # Update map (run parallel process event)
 $game_map.update
 # Switch to map screen
 $scene = Scene_Map.new
 end
 #--------------------------------------------------------------------------
 # * Cancel Processing
 #--------------------------------------------------------------------------
 def on_cancel
 # Play cancel SE
 $game_system.se_play($data_system.cancel_se)
 # Switch to title screen
 $scene = Scene_Title.new
 end
 #--------------------------------------------------------------------------
 # * Read Save Data
 # file : file object for reading (opened)
 #--------------------------------------------------------------------------
 def read_save_data(file)
 read_characters(file)
 read_frame(file)
 read_data(file)
 read_edit
 read_refresh
 end
 #--------------------------------------------------------------------------
 # * Read Character Data
 #--------------------------------------------------------------------------
 def read_characters(file)
 # Read character data for drawing save file
 characters = Marshal.load(file)
 end
 #--------------------------------------------------------------------------
 # * Read Frame Count
 #--------------------------------------------------------------------------
 def read_frame(file)
 # Read frame count for measuring play time
 Graphics.frame_count = Marshal.load(file)
 end
 #--------------------------------------------------------------------------
 # * Read Data
 #--------------------------------------------------------------------------
 def read_data(file)
 # Read each type of game object
 $game_system = Marshal.load(file)
 $game_switches = Marshal.load(file)
 $game_variables = Marshal.load(file)
 $game_self_switches = Marshal.load(file)
 $game_screen = Marshal.load(file)
 $game_actors = Marshal.load(file)
 $game_party = Marshal.load(file)
 $game_troop = Marshal.load(file)
 $game_map = Marshal.load(file)
 $game_player = Marshal.load(file)
 end
 #--------------------------------------------------------------------------
 # * Read Edit
 #--------------------------------------------------------------------------
 def read_edit
 # If magic number is different from when saving
 # (if editing was added with editor)
 if $game_system.magic_number != $data_system.magic_number
 # Load map
 $game_map.setup($game_map.map_id)
 $game_player.center($game_player.x, $game_player.y)
 end
 end
 #--------------------------------------------------------------------------
 # * Refresh Game Party
 #--------------------------------------------------------------------------
 def read_refresh
 # Refresh party members
 $game_party.refresh
 end
end
 
#==============================================================================
# ** Game_Character (part 1)
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass for the
# Game_Player && Game_Event classes.
#==============================================================================
class Game_Character
 #--------------------------------------------------------------------------
 # * Follow_Path
 #--------------------------------------------------------------------------
 def follow_path(x,y,&block)
 node = Node.new(x, y)
 path = A_Star_Pathfinder.new(node, self)
 path.reach_method = block
 end
 #--------------------------------------------------------------------------
 # * Turn Towards B
 #--------------------------------------------------------------------------
 def turn_to(b)
 # Get difference in player coordinates
 sx = @x - b.x
 sy = @y - b.y
 # If coordinates are equal
 if sx == 0 && sy == 0
 return
 end
 # If horizontal distance is longer
 if sx.abs > sy.abs
 # Turn to the right || left towards player
 sx > 0 ? turn_left : turn_right
 # If vertical distance is longer
 else
 # Turn up || down towards player
 sy > 0 ? turn_up : turn_down
 end
 end
 #--------------------------------------------------------------------------
 # * Move toward B
 #--------------------------------------------------------------------------
 def move_towards(b,ran=true)
 return if in_range2?(b,1) || !@a_star_path.nil?
 # Get difference in player coordinates
 sx = @x - b.x
 sy = @y - b.y
 @target = b
 # If coordinates are equal
 return if sx == 0 && sy == 0
 # Get absolute value of difference
 abs_sx = sx.abs
 abs_sy = sy.abs
 # If horizontal && vertical distances are equal
 if abs_sx == abs_sy
 # Increase one of them randomly by 1
 rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
 end
 # If horizontal distance is longer
 if abs_sx > abs_sy
 # Move towards player, prioritize left && right directions
 if sx > 0 
 return move_left if passable?(@x, @y, 4)
 else
 return move_right if passable?(@x, @y, 6)
 end
 if not moving? && sy != 0
 if sy > 0 
 return move_up if passable?(@x, @y, 8)
 else
 return move_down if passable?(@x, @y, 2)
 end
 end
 # If vertical distance is longer
 else
 # Move towards player, prioritize up && down directions
 if sy > 0 
 return move_up if passable?(@x, @y, 8) 
 else 
 return move_down if passable?(@x, @y, 2)
 end
 if not moving? && sx != 0
 if sx > 0 
 return move_left if passable?(@x, @y, 4)
 else
 return move_right if passable?(@x, @y, 6)
 end
 end
 end
=begin
 # Can't find the path, Try pathfidning
 if self.respond_to?(:a_star_path) && @a_star_path.nil?
 # Get X,Y
 x,y=b.x,b.y
 # Follow Path
 nx = x + (passable?(x-1,y,0) ? -1 : passable?(x+1,y,0) ? 1 : 0)
 ny = y + (passable?(x,y-1,0) ? -1 : passable?(x,y+1,0) ? 1 : 0) 
 self.follow_path(nx,ny)
 # Return if Path success
 return if !@a_star_path.nil? && @a_star_path.found
 end
=end
 if ran
 move_random
 turn_to(b)
 end
 end
 #--------------------------------------------------------------------------
 # * Move toward Pos XY
 #--------------------------------------------------------------------------
 def move_towards_pos(x,y,ran=true)
 # Get difference in player coordinates
 sx = @x - x
 sy = @y - y
 # If coordinates are equal
 return if sx == 0 && sy == 0
 # Get absolute value of difference
 abs_sx = sx.abs
 abs_sy = sy.abs
 # If horizontal && vertical distances are equal
 if abs_sx == abs_sy
 # Increase one of them randomly by 1
 rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
 end
 # If horizontal distance is longer
 if abs_sx > abs_sy
 # Move towards player, prioritize left && right directions
 if sx > 0 
 return move_left if passable?(@x, @y, 4)
 else
 return move_right if passable?(@x, @y, 6)
 end
 if not moving? && sy != 0
 if sy > 0 
 return move_up if passable?(@x, @y, 8)
 else
 return move_down if passable?(@x, @y, 2)
 end
 end
 # If vertical distance is longer
 else
 # Move towards player, prioritize up && down directions
 if sy > 0 
 return move_up if passable?(@x, @y, 8) 
 else 
 return move_down if passable?(@x, @y, 2)
 end
 if not moving? && sx != 0
 if sx > 0 
 return move_left if passable?(@x, @y, 4)
 else
 return move_right if passable?(@x, @y, 6)
 end
 end
 end
 if ran
 move_random
 end
 end
 #--------------------------------------------------------------------------
 # * Determine if Passable
 # x : x-coordinate
 # y : y-coordinate
 # d : direction (0,2,4,6,8)
 # * 0 = Determines if all directions are impassable (for jumping)
 #--------------------------------------------------------------------------
 def passable?(x, y, d)
 # Get new coordinates
 new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
 new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
 return false if !check_map_pass(new_x,x,new_y,y,d)
 return false if !check_event_pass(new_x,new_y,d)
 return false if !check_player_pass(new_x,new_y,d)
 # passable
 return true
 end
 #--------------------------------------------------------------------------
 # * Check Map Pass
 #--------------------------------------------------------------------------
 def check_map_pass(new_x,x,new_y,y,d)
 # If coordinates are outside of map
 unless $game_map.valid?(new_x, new_y)
 # impassable
 return false
 end
 # If through is ON
 if @through
 # passable
 return true
 end
 # If unable to leave first move tile in designated direction
 unless $game_map.passable?(x, y, d, self)
 # impassable
 return false
 end
 # If unable to enter move tile in designated direction
 unless $game_map.passable?(new_x, new_y, 10 - d)
 # impassable
 return false
 end
 return true
 end
 #--------------------------------------------------------------------------
 # * Check Event Pass
 #--------------------------------------------------------------------------
 def check_event_pass(new_x,new_y,d)
 # Loop all events
 for event in $game_map.events.values
 # If event coordinates are consistent with move destination
 if event.x == new_x and event.y == new_y
 # If through is OFF
 unless event.through
 # If self is event
 if self_condition_player
 # impassable
 return false
 end
 # With self as the player and partner graphic as character
 if event.character_name != ""
 # impassable
 return false
 end
 end
 end
 end
 return true
 end
 #--------------------------------------------------------------------------
 # * Self Condition Player
 #--------------------------------------------------------------------------
 def self_condition_player
 bool = (self != $game_player)
 return bool
 end
 #--------------------------------------------------------------------------
 # * Check Player Pass
 #--------------------------------------------------------------------------
 def check_player_pass(new_x,new_y,d)
 # If player coordinates are consistent with move destination
 if $game_player.x == new_x and $game_player.y == new_y
 # If through is OFF
 unless $game_player.through
 # If your own graphic is the character
 if @character_name != ""
 # impassable
 return false
 end
 end
 end
 return true
 end
end
 
#==============================================================================
# ** Game_Map
#==============================================================================
class Game_Map
 def map; return @map; end
 #--------------------------------------------------------------------------
 # * Determine if Passable
 # x : x-coordinate
 # y : y-coordinate
 # d : direction (0,2,4,6,8,10)
 # * 0,10 = determine if all directions are impassable
 # self_event : Self (If event is determined passable)
 #--------------------------------------------------------------------------
 def passable?(x, y, d, self_event = nil)
 # If coordinates given are outside of the map
 unless valid?(x, y)
 # impassable
 return false
 end
 # Change direction (0,2,4,6,8,10) to obstacle bit (0,1,2,4,8,0)
 bit = (1 << (d / 2 - 1)) & 0x0f
 # Pass Events
 pe = pass_events(bit,x,y,self_event)
 return pe unless pe.nil? 
 # Loop searches in order from top of layer
 for i in [2, 1, 0]
 # Get tile ID
 tile_id = data[x, y, i]
 # Tile ID acquistion failure
 if tile_id == nil
 # impassable
 return false
 # If obstacle bit is set
 elsif @passages[tile_id] & bit != 0
 # impassable
 return false
 # If obstacle bit is set in all directions
 elsif @passages[tile_id] & 0x0f == 0x0f
 # impassable
 return false
 # If priorities other than that are 0
 elsif @priorities[tile_id] == 0
 # passable
 return true
 end
 end
 # passable
 return true
 end
 #--------------------------------------------------------------------------
 # * Events
 #--------------------------------------------------------------------------
 def pass_events(bit,x,y,self_event)
 # Loop in all events
 for event in events.values
 # If tiles other than self are consistent with coordinates
 if event.tile_id >= 0 and event != self_event and
 event.x == x and event.y == y and not event.through
 # If obstacle bit is set
 if @passages[event.tile_id] & bit != 0
 # impassable
 return false
 # If obstacle bit is set in all directions
 elsif @passages[event.tile_id] & 0x0f == 0x0f
 # impassable
 return false
 # If priorities other than that are 0
 elsif @priorities[event.tile_id] == 0
 # passable
 return true
 end
 end
 end
 return nil
 end
end
zum Lesen den Text mit der Maus markieren

Anmerkung der Administration: Bitte verwende Spoiler, wenn Du so viel Quellcode postest

3

Dienstag, 6. Januar 2015, 00:17

Das UCoders Modul ist da fehlerhaft implementiert. Sie überschreiben die Methode Game_Character#passable?

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  #--------------------------------------------------------------------------
  # * Determine if Passable
  # x : x-coordinate
  # y : y-coordinate
  # d : direction (0,2,4,6,8)
  # * 0 = Determines if all directions are impassable (for jumping)
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    # Get new coordinates
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    return false if !check_map_pass(new_x,x,new_y,y,d)
    return false if !check_event_pass(new_x,new_y,d)
    return false if !check_player_pass(new_x,new_y,d)
    # passable
    return true
  end

Das Problem ist, dass das @through Attribut nur in ihrer Methode check_map_pass berücksichtigt wird, aber nicht in check_event_pass und check_player_pass, wodurch @through nurnoch für Maptiles gilt und nichtmehr für Events.

Lösung:
Füge im UCoders Modul Skript in Zeile Siebenhundertirgendwas unter

Ruby Quellcode

1
2
3
4
 #--------------------------------------------------------------------------
 # * Check Event Pass
 #--------------------------------------------------------------------------
 def check_event_pass(new_x,new_y,d)

folgende Zeile ein:

Ruby Quellcode

1
    return true  if @through # If through is ON


Anmerkung:
Das ist nur eine schnelle Lösung. Besser wäre es, das ganze UCoders Modul mal durchzukorrigieren.

Übrigens: Wenn Du das Feature über Event Comments Icons permanent über Events anzuzeigen nicht brauchst, kannst Du auch die Zeile 48 und 150 auskommentieren, dann brauchst Du das UCoders Modul garnicht.

4

Dienstag, 6. Januar 2015, 14:51

Vielen Dank. Du scheinst ja zurückgekehrt zu sein :))

Mit deinem Beitrag kann wieder ein Event über den Held gehen, wenn beide also event und Held die through Option anhaben. Aber eigentlich, müsste es schon reichen, wenn ein Event die Through option anhat.

Denn normalerweise kann ein Event schon über den Held gehen, wenn nur das Event die through Option hat. Ob der Held auch die through Option hat, sollte eigentlich irrelevant sein. Denn ein Event würde normalerweise sowieso über den Held gehen, wenn er mit through belegt ist.

Aber auch mit deinem Skriptschnipssel muss sowohl der Held als auch das Event mit der through option belegt sein, auf dass ein Event den Held überschreitet, was normalerweise nicht so ist.

Irgendwo muss noch ein Fehler sein.



Danke im voraus.

5

Dienstag, 6. Januar 2015, 19:38

Achja, hatte nur dafür gesorgt, das Events über Events laufen können.
Das UCoders Modul hat leider an vielen Stellen kleinere Fehler - zum Beispiel bringt die aufsplittung wie von ihnen vorgenommen wenig.
Vermutlich ist das simpelste, es direkt in ihre passable? Methode ab Zeile 718 etwa einzufügen

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #--------------------------------------------------------------------------
  # * Determine if Passable
  # x : x-coordinate
  # y : y-coordinate
  # d : direction (0,2,4,6,8)
  # * 0 = Determines if all directions are impassable (for jumping)
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    # Get new coordinates
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    return false if !check_map_pass(new_x,x,new_y,y,d)
    return true  if @through # Ich bin eine neue Zeile, ich repariere diese Methode
    return false if !check_event_pass(new_x,new_y,d)
    return false if !check_player_pass(new_x,new_y,d)
    # passable
    return true
  end


off Topic:
Mir sind beim drübergucken noch mehr Fehler im Code aufgefallen, die jetzt aber nichts mit deinem Problem zu tun haben. Zum Beispiel funktioniert deren MultiArray Klasse nicht (bei Initialize fehlt vermutlich in Zeile 157 bei @dimensions das i in eckigen Klammern dahinter, dann ist die ganze Methode etwas umständlich und bei der Array2D Klasse wird die erste Dimension nicht berücksichtigt, es ist also vom Funktionsumfang auch nur ein eindimensionaler Array, und der Index für die erste Dimension hat keinen Effekt. Weiter löschen sie die Funktion heraus, bei Skriptaufrufen die Eventausführung zu unterbrechen (um Beispielsweise die Scene zu wechseln und anschließend das Event weiterlaufen zu lassen) was sehr sinnlos ist und fügen nicht unbedingt sinnvolle Edits in Scene_Load#initialize ein.
Man könnte entweder das Modul mal durchkorrigieren, oder es einfach rauswerfen wenn kein anderes Skript es braucht und dein Icon Display Skript anpassen. Aber das ist optional - theoretisch sollte der Bugfix oben nämlich dafür sorgen, dass erstmal alles läuft.

6

Dienstag, 6. Januar 2015, 20:10

Ich habe die Zeile:
ab 718:

Spoiler
#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8)
# * 0 = Determines if all directions are impassable (for jumping)
#--------------------------------------------------------------------------
def passable?(x, y, d)
# Get new coordinates
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
return false if !check_map_pass(new_x,x,new_y,y,d)
return false if !check_event_pass(new_x,new_y,d)
return false if !check_player_pass(new_x,new_y,d)
# passable
return true
end
zum Lesen den Text mit der Maus markieren


Spoiler


#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8)
# * 0 = Determines if all directions are impassable (for jumping)
#--------------------------------------------------------------------------
def passable?(x, y, d)
# Get new coordinates
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
return false if !check_map_pass(new_x,x,new_y,y,d)
return true if @through # Ich bin eine neue Zeile, ich repariere diese Methode
return false if !check_event_pass(new_x,new_y,d)
return false if !check_player_pass(new_x,new_y,d)
# passable
return true
end
zum Lesen den Text mit der Maus markieren




ersetzt. Ich hoffe, so meintest du das richtig. Scheint geklappt zu haben :)


Vielen Dank!

7

Dienstag, 6. Januar 2015, 20:14

°_°
das manuelle Syntaxhighlight hat sicher lange gedauert.

Ja, so meinte ich das. :)

Social Bookmarks