• Anmelden

Shabraxxx

Projekt: Ressourcenbereich & Seitenredaktion

  • »Shabraxxx« ist der Autor dieses Themas

Motto: Mein Luftkissenfahrzeug ist voller Aale.

  • Nachricht senden

1

Montag, 27. Juli 2015, 20:04

Dem trainenden Actor im Train Actor eine Moveroute geben

Hallo Gast,

in einem meiner Projekt nutze ich ein Train-Actor-Script von fukuyama. Dieses tut, trotz seines beachtlichen Alters, seinen Dienst in ganz vorzüglichem Maße, allerdings benötige ich – wie immer eigentlich – eine recht spezielle Extrawurst, um vollends glücklich damit zu sein.
Im Wesentlichen würde ich gerne dem "Event", das den folgenden Charakter darstellt (es gibt nur zwei Charaktere im Spiel) ein Moveroute verpassen können, zumindest Drehbefehle (Turn XY) und ein Change Graphic sollten drin sein. Eventuell ist das schon irgendwie mit der Version des Scripts machbar, aber bevor ich wild herumprobiere, wollte ich doch lieber hier nachfragen.
Optional würde ich zusätzlich gerne die Position des zweiten Charakters auf der Map auslesen können (um Sprechblasen und solche Scherze auch an der richtigen Stelle erscheinen zu lassen), aber das ist, wie gesagt, optional, die Moveroute ist mir deutlich wichtiger.

Spoiler: Das Script

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
#==============================================================================
# *** Caterpillar walking script ***
# **********************************
#    * Copyright © 2005 fukuyama *
#
#------------------------------------------------------------------------------
 
#==============================================================================
# ? Train_Actor::Config
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================
 
module Train_Actor
 
# ?Switch setup for transparent status
# When true, switch control is used
TRANSPARENT_SWITCH = true
 
# ?Switch number for transparent status
# When TRANSPARENT_SWITCH is true, transparency will be activated when the switch of this number is on
TRANSPARENT_SWITCHES_INDEX = 20
 
# ?Maximum number of actors
# There will be support for a large number of people in a party in the future...
TRAIN_ACTOR_SIZE_MAX = 4
 
# Constants
DOWN_LEFT  = 1
DOWN_RIGHT = 3
UP_LEFT    = 7
UP_RIGHT   = 9
JUMP       = 5
 
# Put any actor IDs who should have a "stopped animation" if in the caterpillar
# i.e. if a party member "is floating" it will look stupid if he suddenly stops
# moving in the air.
# - added by Blizzard
ACTOR_IDS = []
 
end
 
#==============================================================================
# ? Spriteset_Map_Module
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================
 
module Train_Actor
 
module Spriteset_Map_Module
  def setup_actor_character_sprites?
    return @setup_actor_character_sprites_flag != nil
  end
  def setup_actor_character_sprites(characters)
    if !setup_actor_character_sprites?
      for character in characters.reverse
        @character_sprites.unshift(
          Sprite_Character.new(@viewport1, character)
        )
      end
      @setup_actor_character_sprites_flag = true
    end
  end
end
 
end
 
class Spriteset_Map
  include Train_Actor::Spriteset_Map_Module
end
 
#==============================================================================
# ? Scene_Map_Module
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================
 
module Train_Actor
 
module Scene_Map_Module
  def setup_actor_character_sprites(characters)
    @spriteset.setup_actor_character_sprites(characters)
  end
end
 
end
 
class Scene_Map
  include Train_Actor::Scene_Map_Module
end
 
#==============================================================================
# ? Game_Party_Module
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================
 
module Train_Actor
 
module Game_Party_Module
 
  attr_reader :characters
 
  def update_party_order() return actors end
 
  def setup_actor_character_sprites
    if @characters.nil?
      @characters = []
      for i in 1 ... TRAIN_ACTOR_SIZE_MAX
        @characters.push(Game_Party_Actor.new)
      end
    end
    setup_actors = update_party_order
    for i in 1 ... TRAIN_ACTOR_SIZE_MAX
      @characters[i - 1].setup(setup_actors[i])
    end
    if $scene.class.method_defined?('setup_actor_character_sprites')
      $scene.setup_actor_character_sprites(@characters)
    end
  end
 
  def update_party_actors
     update_party_order
    setup_actor_character_sprites
    transparent = $game_player.transparent
    if transparent == false and TRANSPARENT_SWITCH
      transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
    end
    for character in @characters
      character.transparent = transparent
      character.move_speed = $game_player.move_speed
      if ACTOR_IDS.include?(character.cp_id)
        character.step_anime = true
      else
        character.step_anime = $game_player.step_anime
      end
      character.update
    end
  end
 
  def moveto_party_actors( x, y )
    setup_actor_character_sprites
    for character in @characters
      character.moveto( x, y )
    end
    @move_list = [] if @move_list == nil
    move_list_setup
  end
 
  def move_party_actors
    if @move_list == nil
      @move_list = []
      move_list_setup
    end
    @move_list.each_index do |i|
    if @characters[i] != nil
      case @move_list[i].type
        when Input::DOWN
          @characters[i].move_down(@move_list[i].args[0])
        when Input::LEFT
          @characters[i].move_left(@move_list[i].args[0])
        when Input::RIGHT
          @characters[i].move_right(@move_list[i].args[0])
        when Input::UP
          @characters[i].move_up(@move_list[i].args[0])
        when DOWN_LEFT
          @characters[i].move_lower_left
        when DOWN_RIGHT
          @characters[i].move_lower_right
        when UP_LEFT
          @characters[i].move_upper_left
        when UP_RIGHT
          @characters[i].move_upper_right
        when JUMP
          @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
        end
      end
    end
  end
 
  class Move_List_Element
 
    def initialize(type,args)
      @type = type
      @args = args
    end
 
    def type() return @type end
 
    def args() return @args end
 
    end
 
    def move_list_setup
      for i in 0 .. TRAIN_ACTOR_SIZE_MAX
        @move_list[i] = nil
      end
    end
 
    def add_move_list(type,*args)
      @move_list.unshift(Move_List_Element.new(type,args)).pop
    end
 
    def move_down_party_actors(turn_enabled = true)
      move_party_actors
      add_move_list(Input::DOWN,turn_enabled)
    end
 
    def move_left_party_actors(turn_enabled = true)
      move_party_actors
      add_move_list(Input::LEFT,turn_enabled)
    end
 
    def move_right_party_actors(turn_enabled = true)
      move_party_actors
      add_move_list(Input::RIGHT,turn_enabled)
    end
 
    def move_up_party_actors(turn_enabled = true)
      move_party_actors
      add_move_list(Input::UP,turn_enabled)
    end
 
    def move_lower_left_party_actors
      move_party_actors
      add_move_list(DOWN_LEFT)
    end
 
    def move_lower_right_party_actors
      move_party_actors
      add_move_list(DOWN_RIGHT)
    end
 
    def move_upper_left_party_actors
      move_party_actors
      add_move_list(UP_LEFT)
    end
 
    def move_upper_right_party_actors
      move_party_actors
      add_move_list(UP_RIGHT)
    end
 
    def jump_party_actors(x_plus, y_plus)
      move_party_actors
      add_move_list(JUMP,x_plus, y_plus)
    end
 
  end  
 
end
 
class Game_Party
  include Train_Actor::Game_Party_Module
end
 
#==============================================================================
# ? Game_Player_Module
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================
 
module Train_Actor
 
module Game_Player_Module
 
  attr_reader :move_speed
  attr_reader :step_anime
 
  def update_party_actors
    $game_party.update_party_actors
    $game_party.actors.each do |actor|
      @character_name = actor.character_name
      @character_hue = actor.character_hue
      break
    end
  end
 
  def update
    update_party_actors
    super
  end
 
  def moveto( x, y )
    $game_party.moveto_party_actors( x, y )
    super( x, y )
  end
 
  def move_down(turn_enabled = true)
    if passable?(@x, @y, Input::DOWN)
      $game_party.move_down_party_actors(turn_enabled)
    end
    super(turn_enabled)
  end
 
  def move_left(turn_enabled = true)
    if passable?(@x, @y, Input::LEFT)
      $game_party.move_left_party_actors(turn_enabled)
    end
    super(turn_enabled)
  end
 
  def move_right(turn_enabled = true)
    if passable?(@x, @y, Input::RIGHT)
      $game_party.move_right_party_actors(turn_enabled)
    end
    super(turn_enabled)
  end
 
  def move_up(turn_enabled = true)
    if passable?(@x, @y, Input::UP)
      $game_party.move_up_party_actors(turn_enabled)
    end
    super(turn_enabled)
  end
 
  def move_lower_left
    # When possible to move from down?left or from left?down
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
      $game_party.move_lower_left_party_actors
    end
    super
  end
 
  def move_lower_right
    # When possible to move from down?right or from right?down
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
      $game_party.move_lower_right_party_actors
    end
    super
  end
 
  def move_upper_left
    # When possible to move from up?left or from left?up
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
      $game_party.move_upper_left_party_actors
    end
    super
  end
 
  def move_upper_right
    # When possible to move from up?right or from right?up
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
      $game_party.move_upper_right_party_actors
    end
    super
  end
 
  def jump(x_plus, y_plus)
    # New coordinates are calculated
    new_x = @x + x_plus
    new_y = @y + y_plus
    # When addition values are (0,0), it is possible to jump to the destination
    if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
      $game_party.jump_party_actors(x_plus, y_plus)
    end
    super(x_plus, y_plus)
  end
 
end  
 
end
 
class Game_Player
 include Train_Actor::Game_Player_Module
end
 
#==============================================================================
# ? Game_Event_Module
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================
 
module Train_Actor
 
module Game_Event_Module
  #--------------------------------------------------------------------------
  # ? Judgement determined
  #     x  : X coordinates
  #     y  : Y coordinates
  #     d  : Direction (0,2,4,6,8)  ? 0 = Checks if all directions are not able to be passed (for a jump)
  # return : Passing is impossible (false), possible (true)
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    result = super(x, y, d)
    if result
      # New coordinates are searched for
      new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
      new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
      # Loops for actor in train
      for actor in $game_party.characters
        # When displayed
        if not actor.character_name.empty?
          # When actor's coordinates correspond to the destination
          if actor.x == new_x and actor.y == new_y
          # When event
            return false if self != $game_player
          end
        end
      end
    end
    return result
  end
 
end
 
end
 
class Game_Event
  include Train_Actor::Game_Event_Module
end
 
#==============================================================================
# ? Game_Party_Actor
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================
 
module Train_Actor
 
class Game_Party_Actor < Game_Character
 
  attr_reader :cp_id
  attr_writer :move_speed
  attr_writer :step_anime
 
  def initialize
    super()
    @through = true
  end
 
  def setup(actor)
    # The file name and hue of the character are set
    @cp_id = $data_actors[actor.id].id
    if actor != nil
      @character_name = actor.character_name
      @character_hue = actor.character_hue
    else
      @character_name = ""
      @character_hue = 0
    end
    # Opacity and blending method are initialized
    @opacity = 255
    @blend_type = 0
  end
 
  def screen_z(height = 0)
    if $game_player.x == @x and $game_player.y == @y
      return $game_player.screen_z(height) - 1
    end
    super(height)
  end
  #--------------------------------------------------------------------------
  # ? Move down
  #     turn_enabled : Flag that permits direction change on the spot
  #--------------------------------------------------------------------------
  def move_down(turn_enabled = true)
    # Face down
    turn_down if turn_enabled
    # When possible to pass
    if passable?(@x, @y, Input::DOWN)
      # Face down
      turn_down
      # Update coordinates
      @y += 1
    end
  end
  #--------------------------------------------------------------------------
  # ? Move left
  #     turn_enabled : Flag that permits direction change on the spot
  #--------------------------------------------------------------------------
  def move_left(turn_enabled = true)
    # Face left
    turn_left if turn_enabled
    # When possible to pass
    if passable?(@x, @y, Input::LEFT)
      # Face left
      turn_left
      # Update coordinates
      @x -= 1
    end
  end
  #--------------------------------------------------------------------------
  # ? Move right
  #     turn_enabled : Flag that permits direction change on the spot
  #--------------------------------------------------------------------------
  def move_right(turn_enabled = true)
    # Face right
    turn_right if turn_enabled
    # When possible to pass
    if passable?(@x, @y, Input::RIGHT)
      # Face right
      turn_right
      # Update coordinates
      @x += 1
    end
  end
  #--------------------------------------------------------------------------
  # ? Move up
  #     turn_enabled : Flag that permits direction change on the spot
  #--------------------------------------------------------------------------
  def move_up(turn_enabled = true)
    # Face up
    turn_up if turn_enabled
    # When possible to pass
    if passable?(@x, @y, Input::UP)
      # Face up
      turn_up
      # Update coordinates
      @y -= 1
    end
  end
  #--------------------------------------------------------------------------
  # ? Move lower left
  #--------------------------------------------------------------------------
  def move_lower_left
    # When no direction fixation
    unless @direction_fix
      # Turn left when facing right, turn down when facing up
      @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
    end
    # When possible to move from down?left or from left?down
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
      # Update coordinates
      @x -= 1
      @y += 1
    end
  end
  #--------------------------------------------------------------------------
  # ? Move lower right
  #--------------------------------------------------------------------------
  def move_lower_right
    # When no direction fixation
    unless @direction_fix
      # Turn right when facing left, turn down when facing up
      @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
    end
    # When possible to move from down?right or from right?down
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
      # Update coordinates
      @x += 1
      @y += 1
    end
  end
  #--------------------------------------------------------------------------
  # ? move upper left
  #--------------------------------------------------------------------------
  def move_upper_left
    # When no direction fixation
    unless @direction_fix
      # Turn left when facing right, turn up when facing down
      @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
    end
    # When possible to move from up?left or from left?up
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
      # Update coordinates
      @x -= 1
      @y -= 1
    end
  end
  #--------------------------------------------------------------------------
  # ? move upper right
  #--------------------------------------------------------------------------
  def move_upper_right
    # When no direction fixation
    unless @direction_fix
      # Turn right when facing left, turn up when facing down
      @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
    end
    # When possible to move from up?right or from right?up
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
      # Update coordinates
      @x += 1
      @y -= 1
    end
  end
 
end
 
end
zum Lesen den Text mit der Maus markieren

Wenn Du etwas im Ermel [sic!] hast, oder dich gar des Scriptens erbarmst, freue ich mich dem Schnitzel ähnlich.
Je nach Aufwand revanchiere ich mich selbstverständlich adäquatest - vom feuchten Händedruck bis zum Creditseintrag ist wirklich alles möglich. ;)
Gruß, Shabz
„Albrecht Dürer, geboren 1471, gestorben 1530.
Der Nürnberger Maler, der ganz Europa faszinierte; mit seinem scharfen Auge, seiner Meisterschaft in Linienführung und Plastizität, sowie seiner Leihwagenfirma.“

2

Montag, 27. Juli 2015, 20:51

Hallo bin gerade auf dem Sprung, deswegen lass ich nur ein paar Anmerkungen da:

Du solltest - wenn Du nur einen weiteren Helden im Team hast - via

Ruby Quellcode

1
follower = $game_party.characters.first

an dessen Game_Character-Instanz herankommen, um seine Position und sein Verhalten auf der Map zu beeinflussen - follower ist dann vom Typ Game_Character und unterstützt alle Methoden dieser Klasse. Für das erzeugen einer eigenen MoveRoute außerhalb des Editors schau dir mal die Hilfedatei RGSS Reference Manual→Game Library→RPGXP Data Structures→RPG::MoveRoute an.

Shabraxxx

Projekt: Ressourcenbereich & Seitenredaktion

  • »Shabraxxx« ist der Autor dieses Themas

Motto: Mein Luftkissenfahrzeug ist voller Aale.

  • Nachricht senden

3

Dienstag, 28. Juli 2015, 21:38

Hallo Playm,

danke schon mal für den Stups in die richtige Richtung. Allerdings steige ich noch nicht so recht durch, was die Beeinflussung des followers angeht. Könntest Du, wenn Du mal nicht auf dem Sprung bist, einen ganz simplen Basicbefehl für den follower formulieren – sowas wie ein Turn Left zum Beispiel? Dann dürfte ich den Rest wohl gebacken kriegen (wenngleich ich mich darauf nicht festlegen möchte).
Gruß, Shabz
„Albrecht Dürer, geboren 1471, gestorben 1530.
Der Nürnberger Maler, der ganz Europa faszinierte; mit seinem scharfen Auge, seiner Meisterschaft in Linienführung und Plastizität, sowie seiner Leihwagenfirma.“

4

Dienstag, 28. Juli 2015, 22:21

Hast Du schon sowas probiert?

Ruby Quellcode

1
2
follower = $game_party.characters.first
follower.turn_left


Oder mal zum Testen dem Event Nr.3 eine MoveRoute geben:

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
#Get Character
char = get_character(3)
#Create new MoveRoute Instance
route = RPG::MoveRoute.new
route.list = [ # Jump to the Right
 RPG::MoveCommand.new( 14, [2,0] ),
#Empty MoveCmd has to be last element
 RPG::MoveCommand.new() ]
route.repeat = false
#Force Character to take this Route
char.force_move_route( route )

Der MoveCommand für ChangeGraphic dürfte so aussehen:

Ruby Quellcode

1
    RPG::MoveCommand.new( 41, [CharacterName, CharacterHUE, Direction, Pattern] )

Shabraxxx

Projekt: Ressourcenbereich & Seitenredaktion

  • »Shabraxxx« ist der Autor dieses Themas

Motto: Mein Luftkissenfahrzeug ist voller Aale.

  • Nachricht senden

5

Mittwoch, 29. Juli 2015, 00:24

Hallo Playm,

herzlichen Dank für die Beispiele. Etwas so Simples wie follower.turn_left ist mir gar nicht in den Sinn gekommen.
Wie es ausschaut, funktioniert es auch astrein. Sollten sich wider Erwarten noch Fragen ergeben, melde ich mich nochmal hier im Thread.
Gruß und Danke, Shabz
„Albrecht Dürer, geboren 1471, gestorben 1530.
Der Nürnberger Maler, der ganz Europa faszinierte; mit seinem scharfen Auge, seiner Meisterschaft in Linienführung und Plastizität, sowie seiner Leihwagenfirma.“

Ähnliche Themen

Social Bookmarks