Ergebnis 1 bis 4 von 4

Thema: (RGSS) Script bei Bedarf aktivieren/deaktivieren (Mobius' Turn & Move)

  1. #1

    (RGSS) Script bei Bedarf aktivieren/deaktivieren (Mobius' Turn & Move)

    Ich teste gerade folgendes Script aus.

    Code:
    # Code by Mobius XVI
    # Based on SirBilly's Player Turn & Move script for VX Ace
    # Requested by Crydsch
    # Causes player to turn before moving
    # (Mord) ++ Waits are decreased from 7 to 4 ++ (Mord)
    class Game_Player < Game_Character  
    #--------------------------------------------------------------------------  
    # * Object Initialization  
    #--------------------------------------------------------------------------
      def initialize
        @wait_time = 0
        super
        end  
    #--------------------------------------------------------------------------  
    # * Frame Update  
    #--------------------------------------------------------------------------  
    # Alias old method
    alias mobius_turn_step_update update  
    # Redefine update
    def update    
    # Decrease wait time
    @wait_time -= 1    
    # Remember whether or not moving in local variables
    last_moving = moving?    
    # If moving, event running, move route forcing, and message window
    # display are all not occurring
    unless moving? or $game_system.map_interpreter.running? or           
      @move_route_forcing or $game_temp.message_window_showing
    # Move player in the direction the directional button is being pressed
    case Input.dir4      
    # When Down
    when 2
      if Input.trigger?(Input::DOWN) and self.direction == 2
        move_down
      elsif Input.trigger?(Input::DOWN)
        @wait_time = 4
        turn_down
      elsif @wait_time <= 0
        move_down
        end      
    # When Left
    when 4
      if Input.trigger?(Input::LEFT) and self.direction == 4
        move_left
      elsif Input.trigger?(Input::LEFT)
        @wait_time = 4
        turn_left
      elsif @wait_time <= 0
        move_left
        end      
    # When right
    when 6
      if Input.trigger?(Input::RIGHT) and self.direction == 6
        move_right
      elsif Input.trigger?(Input::RIGHT)
        @wait_time = 4
        turn_right
      elsif @wait_time <= 0
        move_right
        end      
    # When Up
    when 8
      if Input.trigger?(Input::UP) and self.direction == 8
        move_up
      elsif Input.trigger?(Input::UP)
        @wait_time = 4
        turn_up
      elsif @wait_time <= 0
        move_up
      end
    end
    end    
    # Remember coordinates in local variables
    last_real_x = @real_x
    last_real_y = @real_y
    super    
    # If character moves down and is positioned lower than the center    
    # of the screen
    if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y      
    # Scroll map down
    $game_map.scroll_down(@real_y - last_real_y)
    end    
    # If character moves left and is positioned more let on-screen than    
    # center
    if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X      
    # Scroll map left
    $game_map.scroll_left(last_real_x - @real_x)
    end    
    # If character moves right and is positioned more right on-screen than    
    # center
    if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X      
    # Scroll map right
    $game_map.scroll_right(@real_x - last_real_x)
    end    
    # If character moves up and is positioned higher than the center    
    # of the screen
    if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y      
    # Scroll map up
    $game_map.scroll_up(last_real_y - @real_y)
    end    
    # If not moving
    unless moving?      
    # If player was moving last time
    if last_moving        
    # Event determinant is via touch of same position event
    result = check_event_trigger_here([1,2])        
    # If event which started does not exist
    if result == false          
    # Disregard if debug mode is ON and ctrl key was pressed
    unless $DEBUG and Input.press?(Input::CTRL)            
    # Encounter countdown
    if @encounter_count > 0
      @encounter_count -= 1
    end
    end
    end
    end      
    # If C button was pressed
    if Input.trigger?(Input::C)        
    # Same position and front event determinant
    check_event_trigger_here([0])
    check_event_trigger_there([0,1,2])
    end
    end
    end
    end
    # Class End
    Was das Script tut, ist bei Antippen der entsprechenden Richtungstaste den Character erst in die entsprechende Richtung zu drehen und erst danach die Bewegung um ein Tile auszuführen. Der dafür notwendige wait-Befehl kommt mir nun aber bei einigen Gameplay-Elementen in die Quere. Ich würde gern eine Bedingung einfügen (Script-Befehl oder Switch), die das Script deaktiviert, bis es wieder aktiviert wird, oder eben umgekehrt. Wie vielleicht schon am Code zu erkennen ist, habe ich das Script nur kopiert und die @wait_time-Werte geändert. Zu viel mehr bin ich coding-mäßig leider auch nicht in der Lage.

    Lässt sich das vielleicht recht einfach umsetzen? Ob mir jemand weiterhelfen könnte?

  2. #2
    Ich bin kein Ruby-Experte, aber was du versuchen könntest:

    Code:
    # If moving, event running, move route forcing, and message window
    # display are all not occurring
    unless moving? or $game_system.map_interpreter.running? or           
      @move_route_forcing or $game_temp.message_window_showing
      # Move player in the direction the directional button is being pressed
      if $game_switches[hier die Nummer vom Switch einsetzen]  
        case Input.dir4      
        # When Down
        when 2
          if Input.trigger?(Input::DOWN) and self.direction == 2
            move_down
          elsif Input.trigger?(Input::DOWN)
            @wait_time = 4
            turn_down
          elsif @wait_time <= 0
            move_down
          end      
        # When Left
        when 4
          if Input.trigger?(Input::LEFT) and self.direction == 4
            move_left
          elsif Input.trigger?(Input::LEFT)
            @wait_time = 4
            turn_left
          elsif @wait_time <= 0
            move_left
          end      
        # When right
        when 6
          if Input.trigger?(Input::RIGHT) and self.direction == 6
            move_right
          elsif Input.trigger?(Input::RIGHT)
            @wait_time = 4
            turn_right
          elsif @wait_time <= 0
            move_right
          end      
        # When Up
        when 8
          if Input.trigger?(Input::UP) and self.direction == 8
            move_up
          elsif Input.trigger?(Input::UP)
            @wait_time = 4
            turn_up
          elsif @wait_time <= 0
            move_up
          end
        end
      else
        # Bewegung ohne Drehen
        case Input.dir4
        when 2
          move_down
        when 4
          move_left
        when 6
          move_right
        when 8
          move_up
        end
      end
    end
    # Remember coordinates in local variables
    Mit $game_switches[Nummer] greift man auf die Standard-Switches vom Maker zu. Die Methode fragt ab, ob der Switch an ist und falls ja, wird zuerst die Drehung ausgeführt, falls nein, bewegt sich die Figur ganz normal.

  3. #3
    Vermutlich könnte man auch bei aktiviertem Switch einfach die ursprüngliche update-Methode von Game_Player aufrufen, der Originalautor hat ja ein Alias erstellt.
    Code:
      # Alias old method
      alias mobius_turn_step_update update
      # Redefine update
      def update
        if $game_switches[hier die Nummer vom Switch einsetzen]
          # Run original Game_Player#update instead
          mobius_turn_step_update
          return
        end
        # restlicher Code...

  4. #4
    Ich danke euch beiden sehr, es klappt einwandfrei!

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •