System chodzenia w 8 stron.
Wystąpiły następujące problemy:
Warning [2] Cannot modify header information - headers already sent by (output started at /home/ayene/public_html/forum/inc/languages/polish/global.lang.php:1) - Line: 411 - File: inc/plugins/google_seo/redirect.php PHP 5.6.40 (Linux)
File Line Function
[PHP]   errorHandler->error
/inc/plugins/google_seo/redirect.php 411 header
/inc/plugins/google_seo/redirect.php 399 google_seo_redirect_header
/inc/class_plugins.php 101 google_seo_redirect_hook
/global.php 101 pluginSystem->run_hooks
/showthread.php 22 require_once
Warning [2] Cannot modify header information - headers already sent by (output started at /home/ayene/public_html/forum/inc/languages/polish/global.lang.php:1) - Line: 1710 - File: inc/functions.php PHP 5.6.40 (Linux)
File Line Function
[PHP]   errorHandler->error
/inc/functions.php 1710 header
/inc/functions.php 1772 my_setcookie
/inc/functions_indicators.php 42 my_set_array_cookie
/showthread.php 578 mark_thread_read
Warning [2] Cannot modify header information - headers already sent by (output started at /home/ayene/public_html/forum/inc/languages/polish/global.lang.php:1) - Line: 1710 - File: inc/functions.php PHP 5.6.40 (Linux)
File Line Function
[PHP]   errorHandler->error
/inc/functions.php 1710 header
/inc/functions.php 1772 my_setcookie
/inc/functions_indicators.php 218 my_set_array_cookie
/inc/functions_indicators.php 48 mark_forum_read
/showthread.php 578 mark_thread_read



Aktualny czas: 20-04-24, 12:40 Witaj! Przejdź do zakładki Logowanie lub Rejestracja


Wątek zamknięty 
[XP] System chodzenia w 8 stron.
Mcjas Offline
*


Liczba postów: 13
Dołączył: 21-08-17

Pomógł: 0



Post: #1
System chodzenia w 8 stron.

Witam potrzebuje jakiegoś skryptu na system chdozenai w 8 stron poniewaz jak użyłem tego wyskakuję mi błąd : Script line 65 Type error occured undefinited superclass " Game_unit "
21-08-17 16:52
Znajdź wszystkie posty użytkownika
"Pomógł" przyznał(a):
Yoroiookami Offline
*


Liczba postów: 985
Dołączył: 01-05-13

Pomógł: 137



Post: #2
RE: System chodzenia w 8 stron.

Możliwe, że gryzą ci się skrypty.
A jaki to jest "ten"? Nie podałeś go w temacie. :-?

#==============================================================================
# ** Eight Directional / Multiple Frame Movement Script v2         (10-05-2006)
#    by DerVVulfman
#------------------------------------------------------------------------------
#
#  This system allows the user to have either 4 OR 8 directional movement by
#  the events and player sprites he uses.  It also allows the user to set up
#  the number of animation frames and whether a generic idle pose is used.
#  
#==============================================================================

# * Configuration Section *

  DIR_8_CHAR    = false    # This enables/disables 8 directional charsets
  DIR_8_CONTROL = true    # This enables/disables 8 directional movement
  DIR_8_POSES   = false    # This enables/disables 8 directional facing
  DIR_8_FRAMES  = 4       # This holds the number of motion frames when walking
  DIR_8_STAND   = false    # This determines if separate frame used for standing
  $dir_8_fram   = {1 => 8, 2 => 4}
  
=begin
  FULL DEFINITIONS ON EDITABLES ABOVE:
  
  DIR_8_CHAR:    This value (true/false) determines whether the sprite's charset
                 uses 4 directional movement (up,down,left,right), or whether it
                 uses 8 directional movement (the diagonals too).  Turning it on
                 allows you to use sprites that have 8 directional movement.
                 --If you turn this to 'true' when using a 4 directional sprite,
                   you will have an on-screen image of a sprite cut in half. Or,
                   if you set this to 'false' when using an 8 directional sprite
                   in your system,  then your sprite will show two images on top
                   of each other.--
                  
                   Ex:  [1] Down   [1] Down/left
                        [2] Right  [2] Down
                        [3] Left   [3] Down/Right
                        [4] Up     [4] Right
                                   [5] Up/Left
                                   [6] Left
                                   [7] Up/Right
                                   [8] Up
                  
  DIR_8_CONTROL:  This value (true/false) determines whether the player-control-
                  led character can be moved diagonally, regardless of character
                  pose.  It won't affect [event] movement controls.
                  --If you turn this to 'true'  when using a 4 directional char-
                    racter sprite, you will still  only have them  facing 4 ways
                    (up, down, left, right), even if your character is moving in
                    diagonal directions. Likewise, if you have this value set to
                    'false', even 8 directional player-controlled will be forced
                    to move in just the 4 prime directions... even if events can
                    move in all 8.

  DIR_8_POSES:    This value (true/false) determines whether the event or sprite
                  (if using an 8-directional charset) uses all 8 poses available
                  or whether just the prime 4 poses are used.   It's pretty much
                  a given that IF you turn DIR_8_CHAR to true,  you'll turn this
                  value to true as well.
                  
  DIR_8_FRAMES:   This value (numeric) sets how many frames of animation is per-
                  formed by the sprite or event in motion.   By default, the RTP
                  sprite uses a basic 4 frames (the default).   Please note that
                  this only determines  how many frames  are in the animation of
                  the sprite and has nothing to do with the IDLE pose.
                  
  DIR_8_STAND:    This value (true/false) determines whether an additional frame
                  is in the charset.   This frame is of the character in an IDLE
                  pose... standing.  The idle pose is always the first frame per
                  direction.  
                  --This in no way is an animated idle pose (feet tapping on the
                    ground as the game waits for the player  to make an action).
                    It only shows a single frame. The inclusion of a 'dash/idle'
                    script that replaces  the charset with an applicable charset
                    would do the trick.   But the charset would still have to be
                    goverened by the same layout as all the other charactersets.
                    Implementing the other person's idle/dash script  will be up
                    to you,  including timing mechanics such as how long to wait
                    before the on-screen character  begins to perform their ani-
                    mated idle pose.
                  
  NOTE:  If you have a sprite with 6 frames of animation and an idle pose (for a
         total of 7 frames per direction) you would label them as:
        
               DIR_8_FRAMES = 6
               DIR_8_STAND  = true
                ________ ________ ________ ________ ________ ________ ________
         EX:   |        |        |        |        |        |        |        |
               |  Idle  | Move 1 | Move 2 | Move 3 | Move 4 | Move 5 | Move 6 |
               |  Pose  | Frame  | Frame  | Frame  | Frame  | Frame  | Frame  |
               |________|________|________|________|________|________|________|


FINAL NOTES FOR EVENTS:

1)    This script affects ALL charactersets  used in your game.  You cannot have
      8 directional and/or 8 framed characters running around the screen and not
      use similarly designed  charactersets in your events.   Using RTP graphics
      with more advanced character graphics will give you... weirdly clipped re-
      sults.  You've been warned!  Mwuahahahahahaha..... *cough*
      
2)    To allow [event] sprites to remain in place while triggering the the "Turn
      to Player" command  in the event editor  (to simulate sentries),  you will
      want to toggle the event's 'Move Animation' checkbox OFF (So uncheck it!).
      For charsets that contain an 'IDLE' pose,this'll prevent these event-drawn
      characters from using the first frame of the movement animation from being
      shown... a little fix I picked up on. :)
        
=end


#==============================================================================
# ** Game_Character (Modification)
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character  
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :step_anime               # Holds a sprite's step flag
  attr_reader   :walk_anime               # Holds an event's movement flag
  attr_reader   :stop_count               # The number of steps left to count
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Branch with jumping, moving, and stopping
    if jumping?
      update_jump
    elsif moving?
      update_move
    else
      update_stop
    end
    # If animation count exceeds maximum value
    # * Maximum value is move speed * 1 taken from basic value 18
    if @anime_count > 18 - @move_speed * 2
      # If stop animation is OFF when stopping
      if not @step_anime and @stop_count > 0
        # Return to original pattern
        @pattern = @original_pattern
      # If stop animation is ON when moving
      else
        # Update pattern
        @pattern = ((@pattern + 1 ) % DIR_8_FRAMES)
      end
      # Clear animation count
      @anime_count = 0
    end
    # If waiting
    if @wait_count > 0
      # Reduce wait count
      @wait_count -= 1
      return
    end
    # If move route is forced
    if @move_route_forcing
      # Custom move
      move_type_custom
      return
    end
    # When waiting for event execution or locked
    if @starting or lock?
      # Not moving by self
      return
    end
    # If stop count exceeds a certain value (computed from move frequency)
    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
      # Branch by move type
      case @move_type
      when 1  # Random
        move_type_random
      when 2  # Approach
        move_type_toward_player
      when 3  # Custom
        move_type_custom
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Left (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------  
  def move_lower_left
    unless @direction_fix
      if DIR_8_POSES
        # Face down-left
        @direction = 1
      else
        # Face down is facing right or up
        @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)        
      end
    end
    # When a down to left or a left to down course is passable
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
      if DIR_8_POSES
        turn_downleft
      end
      @x -= 1
      @y += 1
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Right (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------  
  def move_lower_right
    unless @direction_fix
      if DIR_8_POSES
        @direction = 3
      else
        # Face right if facing left, and face down if facing up
        @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
      end
    end
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
      (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
      if DIR_8_POSES      
        turn_downright
      end
      @x += 1
      @y += 1
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------  
  def move_upper_left
    unless @direction_fix
      if DIR_8_POSES
        @direction = 7
      else
        # Face left if facing right, and face up if facing down
        @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
      end
    end
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
      (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
      if DIR_8_POSES
        turn_upleft
      end
      @x -= 1
      @y -= 1
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------  
  def move_upper_right
    unless @direction_fix
      if DIR_8_POSES
        @direction = 9
      else
        # Face right if facing left, and face up if facing down
        @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
      end
    end
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
      (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
      if DIR_8_POSES
        turn_upright
      end
      @x += 1
      @y -= 1
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move at Random (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def move_random
    # Determine random value's max based on the number of poses used
    if DIR_8_POSES
      # Random value maxed out at 8 directions
      caserand=8
    else
      # Random value maxed out at 4 directions
      caserand=4
    end
    # Branch according to random value
    case rand(caserand)
    when 0  # Move down
      move_down(false)
    when 1  # Move left
      move_left(false)
    when 2  # Move right
      move_right(false)
    when 3  # Move up
      move_up(false)
    when 4  # Move Upper Left
      move_lower_left
    when 5  # Move Upper Right
      move_lower_right
    when 6  # Move Lower Left
      move_upper_left
    when 7  # Move Lower Right
      move_upper_right
    end
  end
  #--------------------------------------------------------------------------
  # * Move toward Player (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def move_toward_player
    # Get difference in player coordinates
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    # If coordinates are equal
    if sx == 0 and sy == 0
      return
    end
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    if DIR_8_POSES
      # Move towards player, prioritizes diagonal before straight
      if sx > 0
        if sy > 0
          move_upper_left
        elsif sy <0
          move_lower_left
        else
          move_left
        end
      elsif sx <0
        if sy > 0
          move_upper_right
        elsif sy <0
          move_lower_right
        else
          move_right
        end
      else
        if sy > 0
          move_up
        elsif sy <0
          move_down
        else
          # nada (Completely Equal)
        end
      end
    else
      # If horizontal and 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 and right directions
        sx > 0 ? move_left : move_right
        if not moving? and sy != 0
          sy > 0 ? move_up : move_down
        end
      # If vertical distance is longer
      else
        # Move towards player, prioritize up and down directions
        sy > 0 ? move_up : move_down
        if not moving? and sx != 0
          sx > 0 ? move_left : move_right
        end
      end    
    end  
  end
  #--------------------------------------------------------------------------
  # * Move away from Player (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def move_away_from_player
    # Get difference in player coordinates
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    # If coordinates are equal
    if sx == 0 and sy == 0
      return
    end
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    
    if DIR_8_POSES
      # Move away from player, prioritizes diagonal before straight
      if sx > 0
        if sy > 0
          move_lower_right
        elsif sy <0
          move_upper_right
        else
          move_right
        end
      elsif sx <0
        if sy > 0
          move_lower_left
        elsif sy <0
          move_upper_left
        else
          move_left
        end
      else
        if sy > 0
          move_down
        elsif sy <0
          move_up
        else
          # nada (Completely Equal)
        end
      end
    else
      # If horizontal and 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 away from player, prioritize left and right directions
        sx > 0 ? move_right : move_left
        if not moving? and sy != 0
          sy > 0 ? move_down : move_up
        end
      # If vertical distance is longer
      else
        # Move away from player, prioritize up and down directions
        sy > 0 ? move_down : move_up
        if not moving? and sx != 0
          sx > 0 ? move_right : move_left
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * 1 Step Forward (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def move_forward
    if DIR_8_POSES
      case @direction
      when 2
        move_down(false)
      when 4
        move_left(false)
      when 6
        move_right(false)
      when 8
        move_up(false)
      end
    else  
      case @direction
      when 1
        move_lower_left
      when 2
        move_down(false)
      when 3
        move_lower_right
      when 4
        move_left(false)
      when 6
        move_right(false)
      when 7
        move_upper_left
      when 8
        move_up(false)
      when 9
        move_upper_right
      end
    end
  end
  #--------------------------------------------------------------------------
  # * 1 Step Backward (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def move_backward
    # Remember direction fix situation
    last_direction_fix = @direction_fix
    # Force directino fix
    @direction_fix = true
    if DIR_8_POSES
      # Branch by direction
      case @direction
      when 1
        move_upper_right
      when 2
        move_up(false)
      when 3
        move_upper_left
      when 4
        move_right(false)
      when 6
        move_left(false)
      when 7
        move_lower_right
      when 8
        move_down(false)
      when 9
        move_lower_left
      end
    else
      case @direction
      when 2  # Down
        move_up(false)
      when 4  # Left
        move_right(false)
      when 6  # Right
        move_left(false)
      when 8  # Up
        move_down(false)
      end
    end
    # Return direction fix situation back to normal
    @direction_fix = last_direction_fix
  end
  #--------------------------------------------------------------------------
  # * Jump   (Rewritten for diagonal animation)
  #     x_plus : x-coordinate plus value
  #     y_plus : y-coordinate plus value
  #--------------------------------------------------------------------------
  def jump(x_plus, y_plus)
    if DIR_8_POSES
      # Turns player, prioritizes diagonal before straight
      if x_plus > 0
        if y_plus > 0
          turn_downright
        elsif y_plus <0
          turn_upright
        else
          turn_right
        end
      elsif x_plus <0
        if y_plus > 0
          turn_downleft
        elsif y_plus <0
          turn_upleft
        else
          turn_left
        end
      else
        if y_plus > 0
          turn_down
        elsif y_plus <0
          turn_up
        else
          # nada (Completely Equal)
        end
      end
    else
      # If plus value is not (0,0)
      if x_plus != 0 or y_plus != 0
        # If horizontal distnace is longer
        if x_plus.abs > y_plus.abs
          # Change direction to left or right
          x_plus < 0 ? turn_left : turn_right
        # If vertical distance is longer, or equal
        else
          # Change direction to up or down
          y_plus < 0 ? turn_up : turn_down
        end
      end      
    end
    # Calculate new coordinates
    new_x = @x + x_plus
    new_y = @y + y_plus
    # If plus value is (0,0) or jump destination is passable
    if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
      # Straighten position
      straighten
      # Update coordinates
      @x = new_x
      @y = new_y
      # Calculate distance
      distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
      # Set jump count
      @jump_peak = 10 + distance - @move_speed
      @jump_count = @jump_peak * 2
      # Clear stop count
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Turn Up Left (Added for diagonal animation)
  #--------------------------------------------------------------------------  
  def turn_upleft
    unless @direction_fix
      @direction = 7
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Turn Up Right (Added for diagonal animation)
  #--------------------------------------------------------------------------  
  def turn_upright
    unless @direction_fix
      @direction = 9
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Turn Down Left (Added for diagonal animation)
  #--------------------------------------------------------------------------  
  def turn_downleft
    unless @direction_fix
      @direction = 1
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Turn Down Right (Added for diagonal animation)
  #--------------------------------------------------------------------------  
  def turn_downright
    unless @direction_fix
      @direction = 3
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Turn 90° Right (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def turn_right_90
    case @direction
    when 1
      turn_downright
    when 2
      turn_left
    when 3
      turn_upright
    when 4
      turn_up
    when 6
      turn_down
    when 7
      turn_downleft
    when 8
      turn_right
    when 9
      turn_upleft
    end
  end
  #--------------------------------------------------------------------------
  # * Turn 90° Left (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def turn_left_90
    case @direction
    when 1
      turn_upleft
    when 2
      turn_right
    when 3
      turn_downleft
    when 4
      turn_down
    when 6
      turn_up
    when 7
      turn_upright
    when 8
      turn_left
    when 9
      turn_downright
    end
  end
  #--------------------------------------------------------------------------
  # * Turn 180° (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def turn_180
    case @direction
    when 1
      turn_upright
    when 2
      turn_up
    when 3
      turn_upleft
    when 4
      turn_right
    when 6
      turn_left
    when 7
      turn_downright
    when 8
      turn_down
    when 9
      turn_downleft
    end
  end  
  #--------------------------------------------------------------------------
  # * Turn at Random (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def turn_random
    if DIR_8_POSES
      caserand = 8
    else
      caserand = 4
    end
    case rand(caserand)
    when 0  # Move down
      turn_down    
    when 1  # Move left
      turn_left
    when 2  # Move right
      turn_right
    when 3  # Move up
      turn_up
    when 4  # Move Upper Left
      turn_downleft
    when 5  # Move Upper Right
      turn_downright
    when 6  # Move Lower Left
      turn_upleft
    when 7  # Move Lower Right
      turn_upright
    end    
  end  

  #--------------------------------------------------------------------------
  # * Turn Towards Player
  #--------------------------------------------------------------------------
  def turn_toward_player
    # Get difference in player coordinates
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if DIR_8_POSES
      # turn towards player, prioritizes diagonal before straight
      if sx > 0
        if sy > 0
          turn_upleft
        elsif sy <0
          turn_downleft
        else
          turn_left
        end
      elsif sx <0
        if sy > 0
          turn_upright
        elsif sy <0
          turn_downright
        else
          turn_right
        end
      else
        if sy > 0
          turn_up
        elsif sy <0
          turn_down
        else
          # nada (Completely Equal)
        end
      end
    else
      # If coordinates are equal
      if sx == 0 and sy == 0
        return
      end
      # If horizontal distance is longer
      if sx.abs > sy.abs
        # Turn to the right or left towards player
        sx > 0 ? turn_left : turn_right
      # If vertical distance is longer
      else
        # Turn up or down towards player
        sy > 0 ? turn_up : turn_down
      end      
    end
  end
  #--------------------------------------------------------------------------
  # * Turn away from Player (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def turn_away_from_player
    # Get difference in player coordinates
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if DIR_8_POSES
      # Move away from player, prioritizes diagonal before straight
      if sx > 0
        if sy > 0
          turn_downright
        elsif sy <0
          turn_upright
        else
          turn_right
        end
      elsif sx <0
        if sy > 0
          turn_downleft
        elsif sy <0
          turn_upleft
        else
          turn_left
        end
      else
        if sy > 0
          turn_down
        elsif sy <0
          turn_up
        else
          # nada (Completely Equal)
        end
      end
    else
      # If coordinates are equal
      if sx == 0 and sy == 0
        return
      end
      # If horizontal distance is longer
      if sx.abs > sy.abs
        # Turn to the right or left away from player
        sx > 0 ? turn_right : turn_left
      # If vertical distance is longer
      else
        # Turn up or down away from player
        sy > 0 ? turn_down : turn_up
      end      
    end
  end
end  
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. Its functions include event starting
#  determinants and map scrolling. Refer to "$game_player" for the one
#  instance of this class.
#==============================================================================

class Game_Player < Game_Character

  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # 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
      # Rewritten for diagonal animation
      if DIR_8_CONTROL      
        case Input.dir8
        when 2
          move_down
        when 4
          move_left
        when 6
          move_right
        when 8
          move_up
        when 7
          move_upper_left
        when 9
          move_upper_right
        when 3
          move_lower_right
        when 1
          move_lower_left
        end
      else
        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
    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

  
  
  
#==============================================================================
# ** 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  

  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # If tile ID, file name, or hue are different from current ones
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      # Remember tile ID, file name, and hue
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      # If tile ID value is valid
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      # If tile ID value is invalid
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        if DIR_8_STAND
          @cw = bitmap.width / (DIR_8_FRAMES + 1)  # Movement frames w/ stand
        else
          @cw = bitmap.width / (DIR_8_FRAMES)      # Movement frames regular
          end
        if DIR_8_CHAR
          @ch = bitmap.height / 8                 # This sets for 8 directions
        else
          @ch = bitmap.height / 4                 # This sets for 4 directions
        end
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    # Set visible situation
    self.visible = (not @character.transparent)
    # If graphic is character
    if @tile_id == 0
      # Set horizontal transfer (animation frames)
      if not @character.step_anime and @character.stop_count > 0
       sx = (@character.pattern) * @cw
      else
        # If event's Movement flag is checked (or player sprite)
        if @character.walk_anime
          if not DIR_8_CHAR and not DIR_8_STAND
            sx = (@character.pattern) * @cw
          else
            sx = (@character.pattern + 1) * @cw
          end
        # If event's Movement flag unchecked
        else
          sx = (@character.pattern) * @cw
        end
      end
      # Set vertical transfer (direction)
      if DIR_8_CHAR
        dir = @character.direction            # These routines allow for eight
        dec = (dir == 7 or dir== 9) ? 3 : 1   # directional movement.
        sy = (dir - dec) * @ch                
      else
        sy = (@character.direction - 2) / 2 * @ch
      end
      self.src_rect.set(sx, sy, @cw, @ch)
    end
    # Set sprite coordinates
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    # Set opacity level, blend method, and bush depth
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    # Animation
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
  end
end

[Obrazek: mt4dzY7.png]
[Obrazek: k5KQGOe.png]
21-08-17 18:00
Znajdź wszystkie posty użytkownika
"Pomógł" przyznał(a):
Mcjas Offline
*


Liczba postów: 13
Dołączył: 21-08-17

Pomógł: 0



Post: #3
RE: System chodzenia w 8 stron.

(21-08-17 18:00)Yoroiookami napisał(a):  Możliwe, że gryzą ci się skrypty.
A jaki to jest "ten"? Nie podałeś go w temacie. :-?

#==============================================================================
# ** Eight Directional / Multiple Frame Movement Script v2         (10-05-2006)
#    by DerVVulfman
#------------------------------------------------------------------------------
#
#  This system allows the user to have either 4 OR 8 directional movement by
#  the events and player sprites he uses.  It also allows the user to set up
#  the number of animation frames and whether a generic idle pose is used.
#  
#==============================================================================

# * Configuration Section *

  DIR_8_CHAR    = false    # This enables/disables 8 directional charsets
  DIR_8_CONTROL = true    # This enables/disables 8 directional movement
  DIR_8_POSES   = false    # This enables/disables 8 directional facing
  DIR_8_FRAMES  = 4       # This holds the number of motion frames when walking
  DIR_8_STAND   = false    # This determines if separate frame used for standing
  $dir_8_fram   = {1 => 8, 2 => 4}
  
=begin
  FULL DEFINITIONS ON EDITABLES ABOVE:
  
  DIR_8_CHAR:    This value (true/false) determines whether the sprite's charset
                 uses 4 directional movement (up,down,left,right), or whether it
                 uses 8 directional movement (the diagonals too).  Turning it on
                 allows you to use sprites that have 8 directional movement.
                 --If you turn this to 'true' when using a 4 directional sprite,
                   you will have an on-screen image of a sprite cut in half. Or,
                   if you set this to 'false' when using an 8 directional sprite
                   in your system,  then your sprite will show two images on top
                   of each other.--
                  
                   Ex:  [1] Down   [1] Down/left
                        [2] Right  [2] Down
                        [3] Left   [3] Down/Right
                        [4] Up     [4] Right
                                   [5] Up/Left
                                   [6] Left
                                   [7] Up/Right
                                   [8] Up
                  
  DIR_8_CONTROL:  This value (true/false) determines whether the player-control-
                  led character can be moved diagonally, regardless of character
                  pose.  It won't affect [event] movement controls.
                  --If you turn this to 'true'  when using a 4 directional char-
                    racter sprite, you will still  only have them  facing 4 ways
                    (up, down, left, right), even if your character is moving in
                    diagonal directions. Likewise, if you have this value set to
                    'false', even 8 directional player-controlled will be forced
                    to move in just the 4 prime directions... even if events can
                    move in all 8.

  DIR_8_POSES:    This value (true/false) determines whether the event or sprite
                  (if using an 8-directional charset) uses all 8 poses available
                  or whether just the prime 4 poses are used.   It's pretty much
                  a given that IF you turn DIR_8_CHAR to true,  you'll turn this
                  value to true as well.
                  
  DIR_8_FRAMES:   This value (numeric) sets how many frames of animation is per-
                  formed by the sprite or event in motion.   By default, the RTP
                  sprite uses a basic 4 frames (the default).   Please note that
                  this only determines  how many frames  are in the animation of
                  the sprite and has nothing to do with the IDLE pose.
                  
  DIR_8_STAND:    This value (true/false) determines whether an additional frame
                  is in the charset.   This frame is of the character in an IDLE
                  pose... standing.  The idle pose is always the first frame per
                  direction.  
                  --This in no way is an animated idle pose (feet tapping on the
                    ground as the game waits for the player  to make an action).
                    It only shows a single frame. The inclusion of a 'dash/idle'
                    script that replaces  the charset with an applicable charset
                    would do the trick.   But the charset would still have to be
                    goverened by the same layout as all the other charactersets.
                    Implementing the other person's idle/dash script  will be up
                    to you,  including timing mechanics such as how long to wait
                    before the on-screen character  begins to perform their ani-
                    mated idle pose.
                  
  NOTE:  If you have a sprite with 6 frames of animation and an idle pose (for a
         total of 7 frames per direction) you would label them as:
        
               DIR_8_FRAMES = 6
               DIR_8_STAND  = true
                ________ ________ ________ ________ ________ ________ ________
         EX:   |        |        |        |        |        |        |        |
               |  Idle  | Move 1 | Move 2 | Move 3 | Move 4 | Move 5 | Move 6 |
               |  Pose  | Frame  | Frame  | Frame  | Frame  | Frame  | Frame  |
               |________|________|________|________|________|________|________|


FINAL NOTES FOR EVENTS:

1)    This script affects ALL charactersets  used in your game.  You cannot have
      8 directional and/or 8 framed characters running around the screen and not
      use similarly designed  charactersets in your events.   Using RTP graphics
      with more advanced character graphics will give you... weirdly clipped re-
      sults.  You've been warned!  Mwuahahahahahaha..... *cough*
      
2)    To allow [event] sprites to remain in place while triggering the the "Turn
      to Player" command  in the event editor  (to simulate sentries),  you will
      want to toggle the event's 'Move Animation' checkbox OFF (So uncheck it!).
      For charsets that contain an 'IDLE' pose,this'll prevent these event-drawn
      characters from using the first frame of the movement animation from being
      shown... a little fix I picked up on. :)
        
=end


#==============================================================================
# ** Game_Character (Modification)
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character  
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :step_anime               # Holds a sprite's step flag
  attr_reader   :walk_anime               # Holds an event's movement flag
  attr_reader   :stop_count               # The number of steps left to count
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Branch with jumping, moving, and stopping
    if jumping?
      update_jump
    elsif moving?
      update_move
    else
      update_stop
    end
    # If animation count exceeds maximum value
    # * Maximum value is move speed * 1 taken from basic value 18
    if @anime_count > 18 - @move_speed * 2
      # If stop animation is OFF when stopping
      if not @step_anime and @stop_count > 0
        # Return to original pattern
        @pattern = @original_pattern
      # If stop animation is ON when moving
      else
        # Update pattern
        @pattern = ((@pattern + 1 ) % DIR_8_FRAMES)
      end
      # Clear animation count
      @anime_count = 0
    end
    # If waiting
    if @wait_count > 0
      # Reduce wait count
      @wait_count -= 1
      return
    end
    # If move route is forced
    if @move_route_forcing
      # Custom move
      move_type_custom
      return
    end
    # When waiting for event execution or locked
    if @starting or lock?
      # Not moving by self
      return
    end
    # If stop count exceeds a certain value (computed from move frequency)
    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
      # Branch by move type
      case @move_type
      when 1  # Random
        move_type_random
      when 2  # Approach
        move_type_toward_player
      when 3  # Custom
        move_type_custom
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Left (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------  
  def move_lower_left
    unless @direction_fix
      if DIR_8_POSES
        # Face down-left
        @direction = 1
      else
        # Face down is facing right or up
        @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)        
      end
    end
    # When a down to left or a left to down course is passable
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
      if DIR_8_POSES
        turn_downleft
      end
      @x -= 1
      @y += 1
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Right (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------  
  def move_lower_right
    unless @direction_fix
      if DIR_8_POSES
        @direction = 3
      else
        # Face right if facing left, and face down if facing up
        @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
      end
    end
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
      (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
      if DIR_8_POSES      
        turn_downright
      end
      @x += 1
      @y += 1
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------  
  def move_upper_left
    unless @direction_fix
      if DIR_8_POSES
        @direction = 7
      else
        # Face left if facing right, and face up if facing down
        @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
      end
    end
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
      (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
      if DIR_8_POSES
        turn_upleft
      end
      @x -= 1
      @y -= 1
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------  
  def move_upper_right
    unless @direction_fix
      if DIR_8_POSES
        @direction = 9
      else
        # Face right if facing left, and face up if facing down
        @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
      end
    end
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
      (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
      if DIR_8_POSES
        turn_upright
      end
      @x += 1
      @y -= 1
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move at Random (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def move_random
    # Determine random value's max based on the number of poses used
    if DIR_8_POSES
      # Random value maxed out at 8 directions
      caserand=8
    else
      # Random value maxed out at 4 directions
      caserand=4
    end
    # Branch according to random value
    case rand(caserand)
    when 0  # Move down
      move_down(false)
    when 1  # Move left
      move_left(false)
    when 2  # Move right
      move_right(false)
    when 3  # Move up
      move_up(false)
    when 4  # Move Upper Left
      move_lower_left
    when 5  # Move Upper Right
      move_lower_right
    when 6  # Move Lower Left
      move_upper_left
    when 7  # Move Lower Right
      move_upper_right
    end
  end
  #--------------------------------------------------------------------------
  # * Move toward Player (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def move_toward_player
    # Get difference in player coordinates
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    # If coordinates are equal
    if sx == 0 and sy == 0
      return
    end
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    if DIR_8_POSES
      # Move towards player, prioritizes diagonal before straight
      if sx > 0
        if sy > 0
          move_upper_left
        elsif sy <0
          move_lower_left
        else
          move_left
        end
      elsif sx <0
        if sy > 0
          move_upper_right
        elsif sy <0
          move_lower_right
        else
          move_right
        end
      else
        if sy > 0
          move_up
        elsif sy <0
          move_down
        else
          # nada (Completely Equal)
        end
      end
    else
      # If horizontal and 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 and right directions
        sx > 0 ? move_left : move_right
        if not moving? and sy != 0
          sy > 0 ? move_up : move_down
        end
      # If vertical distance is longer
      else
        # Move towards player, prioritize up and down directions
        sy > 0 ? move_up : move_down
        if not moving? and sx != 0
          sx > 0 ? move_left : move_right
        end
      end    
    end  
  end
  #--------------------------------------------------------------------------
  # * Move away from Player (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def move_away_from_player
    # Get difference in player coordinates
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    # If coordinates are equal
    if sx == 0 and sy == 0
      return
    end
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    
    if DIR_8_POSES
      # Move away from player, prioritizes diagonal before straight
      if sx > 0
        if sy > 0
          move_lower_right
        elsif sy <0
          move_upper_right
        else
          move_right
        end
      elsif sx <0
        if sy > 0
          move_lower_left
        elsif sy <0
          move_upper_left
        else
          move_left
        end
      else
        if sy > 0
          move_down
        elsif sy <0
          move_up
        else
          # nada (Completely Equal)
        end
      end
    else
      # If horizontal and 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 away from player, prioritize left and right directions
        sx > 0 ? move_right : move_left
        if not moving? and sy != 0
          sy > 0 ? move_down : move_up
        end
      # If vertical distance is longer
      else
        # Move away from player, prioritize up and down directions
        sy > 0 ? move_down : move_up
        if not moving? and sx != 0
          sx > 0 ? move_right : move_left
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * 1 Step Forward (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def move_forward
    if DIR_8_POSES
      case @direction
      when 2
        move_down(false)
      when 4
        move_left(false)
      when 6
        move_right(false)
      when 8
        move_up(false)
      end
    else  
      case @direction
      when 1
        move_lower_left
      when 2
        move_down(false)
      when 3
        move_lower_right
      when 4
        move_left(false)
      when 6
        move_right(false)
      when 7
        move_upper_left
      when 8
        move_up(false)
      when 9
        move_upper_right
      end
    end
  end
  #--------------------------------------------------------------------------
  # * 1 Step Backward (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def move_backward
    # Remember direction fix situation
    last_direction_fix = @direction_fix
    # Force directino fix
    @direction_fix = true
    if DIR_8_POSES
      # Branch by direction
      case @direction
      when 1
        move_upper_right
      when 2
        move_up(false)
      when 3
        move_upper_left
      when 4
        move_right(false)
      when 6
        move_left(false)
      when 7
        move_lower_right
      when 8
        move_down(false)
      when 9
        move_lower_left
      end
    else
      case @direction
      when 2  # Down
        move_up(false)
      when 4  # Left
        move_right(false)
      when 6  # Right
        move_left(false)
      when 8  # Up
        move_down(false)
      end
    end
    # Return direction fix situation back to normal
    @direction_fix = last_direction_fix
  end
  #--------------------------------------------------------------------------
  # * Jump   (Rewritten for diagonal animation)
  #     x_plus : x-coordinate plus value
  #     y_plus : y-coordinate plus value
  #--------------------------------------------------------------------------
  def jump(x_plus, y_plus)
    if DIR_8_POSES
      # Turns player, prioritizes diagonal before straight
      if x_plus > 0
        if y_plus > 0
          turn_downright
        elsif y_plus <0
          turn_upright
        else
          turn_right
        end
      elsif x_plus <0
        if y_plus > 0
          turn_downleft
        elsif y_plus <0
          turn_upleft
        else
          turn_left
        end
      else
        if y_plus > 0
          turn_down
        elsif y_plus <0
          turn_up
        else
          # nada (Completely Equal)
        end
      end
    else
      # If plus value is not (0,0)
      if x_plus != 0 or y_plus != 0
        # If horizontal distnace is longer
        if x_plus.abs > y_plus.abs
          # Change direction to left or right
          x_plus < 0 ? turn_left : turn_right
        # If vertical distance is longer, or equal
        else
          # Change direction to up or down
          y_plus < 0 ? turn_up : turn_down
        end
      end      
    end
    # Calculate new coordinates
    new_x = @x + x_plus
    new_y = @y + y_plus
    # If plus value is (0,0) or jump destination is passable
    if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
      # Straighten position
      straighten
      # Update coordinates
      @x = new_x
      @y = new_y
      # Calculate distance
      distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
      # Set jump count
      @jump_peak = 10 + distance - @move_speed
      @jump_count = @jump_peak * 2
      # Clear stop count
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Turn Up Left (Added for diagonal animation)
  #--------------------------------------------------------------------------  
  def turn_upleft
    unless @direction_fix
      @direction = 7
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Turn Up Right (Added for diagonal animation)
  #--------------------------------------------------------------------------  
  def turn_upright
    unless @direction_fix
      @direction = 9
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Turn Down Left (Added for diagonal animation)
  #--------------------------------------------------------------------------  
  def turn_downleft
    unless @direction_fix
      @direction = 1
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Turn Down Right (Added for diagonal animation)
  #--------------------------------------------------------------------------  
  def turn_downright
    unless @direction_fix
      @direction = 3
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Turn 90° Right (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def turn_right_90
    case @direction
    when 1
      turn_downright
    when 2
      turn_left
    when 3
      turn_upright
    when 4
      turn_up
    when 6
      turn_down
    when 7
      turn_downleft
    when 8
      turn_right
    when 9
      turn_upleft
    end
  end
  #--------------------------------------------------------------------------
  # * Turn 90° Left (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def turn_left_90
    case @direction
    when 1
      turn_upleft
    when 2
      turn_right
    when 3
      turn_downleft
    when 4
      turn_down
    when 6
      turn_up
    when 7
      turn_upright
    when 8
      turn_left
    when 9
      turn_downright
    end
  end
  #--------------------------------------------------------------------------
  # * Turn 180° (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def turn_180
    case @direction
    when 1
      turn_upright
    when 2
      turn_up
    when 3
      turn_upleft
    when 4
      turn_right
    when 6
      turn_left
    when 7
      turn_downright
    when 8
      turn_down
    when 9
      turn_downleft
    end
  end  
  #--------------------------------------------------------------------------
  # * Turn at Random (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def turn_random
    if DIR_8_POSES
      caserand = 8
    else
      caserand = 4
    end
    case rand(caserand)
    when 0  # Move down
      turn_down    
    when 1  # Move left
      turn_left
    when 2  # Move right
      turn_right
    when 3  # Move up
      turn_up
    when 4  # Move Upper Left
      turn_downleft
    when 5  # Move Upper Right
      turn_downright
    when 6  # Move Lower Left
      turn_upleft
    when 7  # Move Lower Right
      turn_upright
    end    
  end  

  #--------------------------------------------------------------------------
  # * Turn Towards Player
  #--------------------------------------------------------------------------
  def turn_toward_player
    # Get difference in player coordinates
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if DIR_8_POSES
      # turn towards player, prioritizes diagonal before straight
      if sx > 0
        if sy > 0
          turn_upleft
        elsif sy <0
          turn_downleft
        else
          turn_left
        end
      elsif sx <0
        if sy > 0
          turn_upright
        elsif sy <0
          turn_downright
        else
          turn_right
        end
      else
        if sy > 0
          turn_up
        elsif sy <0
          turn_down
        else
          # nada (Completely Equal)
        end
      end
    else
      # If coordinates are equal
      if sx == 0 and sy == 0
        return
      end
      # If horizontal distance is longer
      if sx.abs > sy.abs
        # Turn to the right or left towards player
        sx > 0 ? turn_left : turn_right
      # If vertical distance is longer
      else
        # Turn up or down towards player
        sy > 0 ? turn_up : turn_down
      end      
    end
  end
  #--------------------------------------------------------------------------
  # * Turn away from Player (Rewritten for diagonal animation)
  #--------------------------------------------------------------------------
  def turn_away_from_player
    # Get difference in player coordinates
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if DIR_8_POSES
      # Move away from player, prioritizes diagonal before straight
      if sx > 0
        if sy > 0
          turn_downright
        elsif sy <0
          turn_upright
        else
          turn_right
        end
      elsif sx <0
        if sy > 0
          turn_downleft
        elsif sy <0
          turn_upleft
        else
          turn_left
        end
      else
        if sy > 0
          turn_down
        elsif sy <0
          turn_up
        else
          # nada (Completely Equal)
        end
      end
    else
      # If coordinates are equal
      if sx == 0 and sy == 0
        return
      end
      # If horizontal distance is longer
      if sx.abs > sy.abs
        # Turn to the right or left away from player
        sx > 0 ? turn_right : turn_left
      # If vertical distance is longer
      else
        # Turn up or down away from player
        sy > 0 ? turn_down : turn_up
      end      
    end
  end
end  
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. Its functions include event starting
#  determinants and map scrolling. Refer to "$game_player" for the one
#  instance of this class.
#==============================================================================

class Game_Player < Game_Character

  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # 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
      # Rewritten for diagonal animation
      if DIR_8_CONTROL      
        case Input.dir8
        when 2
          move_down
        when 4
          move_left
        when 6
          move_right
        when 8
          move_up
        when 7
          move_upper_left
        when 9
          move_upper_right
        when 3
          move_lower_right
        when 1
          move_lower_left
        end
      else
        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
    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

  
  
  
#==============================================================================
# ** 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  

  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # If tile ID, file name, or hue are different from current ones
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      # Remember tile ID, file name, and hue
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      # If tile ID value is valid
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      # If tile ID value is invalid
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        if DIR_8_STAND
          @cw = bitmap.width / (DIR_8_FRAMES + 1)  # Movement frames w/ stand
        else
          @cw = bitmap.width / (DIR_8_FRAMES)      # Movement frames regular
          end
        if DIR_8_CHAR
          @ch = bitmap.height / 8                 # This sets for 8 directions
        else
          @ch = bitmap.height / 4                 # This sets for 4 directions
        end
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    # Set visible situation
    self.visible = (not @character.transparent)
    # If graphic is character
    if @tile_id == 0
      # Set horizontal transfer (animation frames)
      if not @character.step_anime and @character.stop_count > 0
       sx = (@character.pattern) * @cw
      else
        # If event's Movement flag is checked (or player sprite)
        if @character.walk_anime
          if not DIR_8_CHAR and not DIR_8_STAND
            sx = (@character.pattern) * @cw
          else
            sx = (@character.pattern + 1) * @cw
          end
        # If event's Movement flag unchecked
        else
          sx = (@character.pattern) * @cw
        end
      end
      # Set vertical transfer (direction)
      if DIR_8_CHAR
        dir = @character.direction            # These routines allow for eight
        dec = (dir == 7 or dir== 9) ? 3 : 1   # directional movement.
        sy = (dir - dec) * @ch                
      else
        sy = (@character.direction - 2) / 2 * @ch
      end
      self.src_rect.set(sx, sy, @cw, @ch)
    end
    # Set sprite coordinates
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    # Set opacity level, blend method, and bush depth
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    # Animation
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
  end
end


A jak animacje? bo to sztywno trochę wygląda :)
21-08-17 18:46
Znajdź wszystkie posty użytkownika
"Pomógł" przyznał(a):
Yoroiookami Offline
*


Liczba postów: 985
Dołączył: 01-05-13

Pomógł: 137



Post: #4
RE: System chodzenia w 8 stron.

Jak sztywno? To tylko daje opcję chodzenia w ośmiu kierunkach. Animacja już zależy od charsetu. Może ci chodzić o pixel movement, ale nie jestem pewien. :co:
# http://members.jcom.home.ne.jp/cogwheel/
#==============================================================================
# Game_Player
#==============================================================================
class Game_Player < Game_Character
UP    = 0
DOWN  = 0
SIDE  = 0
SLANT = false
#--------------------------------------------------------------------------
attr_reader   :event
attr_accessor :move_speed
#--------------------------------------------------------------------------
alias :update_original :update
def update
  @walk  = 4
  @dash  = 5
  @event = 4
  @dot_m = true
  unless moving? or $game_system.map_interpreter.running? or
          @move_route_forcing or $game_temp.message_window_showing
    if @walk != @dash
      if Input.press?(Input::C)
        if @move_speed != @dash
          @move_speed = @dash
        end
      else
        if @move_speed != @walk
          @move_speed = @walk
        end
      end
    end
  end
  if @revise_x == nil and @revise_y == nil
    @revise_x = 0
    @revise_y = 0
  end
  unless @dot_m
    update_original
    return
  end
  if @move_route_forcing
    last_moving = moving?
    last_real_x = @real_x
    last_real_y = @real_y
    if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
      if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
        @revise_x = @real_x - @x * 128
        @revise_y = @real_y - @y * 128
      end
      distance1 = 2 ** @move_speed
      distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
      if distance1 > distance2
        @real_x = @real_x - @revise_x
        @real_y = @real_y - @revise_y
        @revise_x = 0
        @revise_y = 0
        anime_update
      else
        @real_x -= (distance1 * @revise_x / distance2).round
        @real_y -= (distance1 * @revise_y / distance2).round
        @revise_x = @real_x - @x * 128
        @revise_y = @real_y - @y * 128
        anime_update
      end
    else
      super
    end
  else
    @move = false
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      @event_run = false
      case Input.dir8
      when 1
        move_lower_left_p
      when 2
        move_down_p
      when 3
        move_lower_right_p
      when 4
        move_left_p
      when 6
        move_right_p
      when 7
        move_upper_left_p
      when 8
        move_up_p
      when 9
        move_upper_right_p
      end
    end
    last_real_x = @real_x
    last_real_y = @real_y
    @real_x = @x * 128 + @revise_x
    @real_y = @y * 128 + @revise_y
    last_moving = moving?
    move_on
    if (last_real_x != @real_x or last_real_y != @real_y)
      @move_distance = 0 if @move_distance == nil
      @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
                                    (last_real_y - @real_y) ** 2)
      if @move_distance >= 128
        @move_distance %= 128
        increase_steps
      end
      anime_update
    else
      @pattern = 0
    end
  end
  if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
    $game_map.scroll_down(@real_y - last_real_y)
  end
  if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
    $game_map.scroll_left(last_real_x - @real_x)
  end
  if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
    $game_map.scroll_right(@real_x - last_real_x)
  end
  if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
    $game_map.scroll_up(last_real_y - @real_y)
  end
  if last_moving
    result = check_event_trigger_here([1,2])
    if result == false
      unless $DEBUG and Input.press?(Input::CTRL)
        if @encounter_count > 0
          @encounter_count -= 1
        end
      end
    end
  end
  if Input.trigger?(Input::C)
    check_event_trigger_here([0])
    check_event_trigger_there([0,1,2])
  end
end
#--------------------------------------------------------------------------
def initialize
  @revise_x = 0
  @revise_y = 0
  @move == false
  super
end
#--------------------------------------------------------------------------
def moving?
  unless @dot_m
    result = super
    return result
  end
  if @move_route_forcing
    if @move == false
      return false
    end
    super
  else
    return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
  end
end
#--------------------------------------------------------------------------
def moving_a?
  if @move == false
    if (@move_route.list[@move_route_index].code <= 14 or
        @move_route.list[@move_route_index].code == 25)
      @move = true
    end
    return false
  end
  moving?
end
#--------------------------------------------------------------------------
def update_jump
  @jump_count -= 1
  @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
  @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
  if @jump_count == 0
    @revise_x = 0
    @revise_y = 0
  end
end
#--------------------------------------------------------------------------
def move_type_custom
  unless @dot_m
    super
    return
  end
  if jumping? or moving_a?
    return
  end
  while @move_route_index < @move_route.list.size
    command = @move_route.list[@move_route_index]
    if command.code == 0
      if @move_route.repeat
        @move_route_index = 0
      end
      unless @move_route.repeat
        if @move_route_forcing and not @move_route.repeat
          @move_route_forcing = false
          @move_route = @original_move_route
          @move_route_index = @original_move_route_index
          @original_move_route = nil
        end
        @stop_count = 0
      end
      return
    end
    if command.code <= 14
      case command.code
      when 1
        move_down
      when 2
        move_left
      when 3
        move_right
      when 4
        move_up
      when 5
        move_lower_left
      when 6
        move_lower_right
      when 7
        move_upper_left
      when 8
        move_upper_right
      when 9
        move_random
      when 10
        move_toward_player
      when 11
        move_away_from_player
      when 12
        move_forward
      when 13
        move_backward
      when 14
        jump(command.parameters[0], command.parameters[1])
      end
      if not @move_route.skippable and not moving? and not jumping?
        return
      end
      @move_route_index += 1
      return
    end
    if command.code == 15
      @wait_count = command.parameters[0] * 2 - 1
      @move_route_index += 1
      return
    end
    if command.code >= 16 and command.code <= 26
      case command.code
      when 16
        turn_down
      when 17
        turn_left
      when 18
        turn_right
      when 19
        turn_up
      when 20
        turn_right_90
      when 21
        turn_left_90
      when 22
        turn_180
      when 23
        turn_right_or_left_90
      when 24
        turn_random
      when 25
        turn_toward_player
      when 26
        turn_away_from_player
      end
      @move_route_index += 1
      return
    end
    if command.code >= 27
      case command.code
      when 27
        $game_switches[command.parameters[0]] = true
        $game_map.need_refresh = true
      when 28
        $game_switches[command.parameters[0]] = false
        $game_map.need_refresh = true
      when 29
        @move_speed = command.parameters[0]
      when 30
        @move_frequency = command.parameters[0]
      when 31
        @walk_anime = true
      when 32
        @walk_anime = false
      when 33
        @step_anime = true
      when 34
        @step_anime = false
      when 35
        @direction_fix = true
      when 36
        @direction_fix = false
      when 37
        @through = true
      when 38
        @through = false
      when 39
        @always_on_top = true
      when 40
        @always_on_top = false
      when 41
        @tile_id = 0
        @character_name = command.parameters[0]
        @character_hue = command.parameters[1]
        if @original_direction != command.parameters[2]
          @direction = command.parameters[2]
          @original_direction = @direction
          @prelock_direction = 0
        end
        if @original_pattern != command.parameters[3]
          @pattern = command.parameters[3]
          @original_pattern = @pattern
        end
      when 42
        @opacity = command.parameters[0]
      when 43
        @blend_type = command.parameters[0]
      when 44
        $game_system.se_play(command.parameters[0])
      when 45
        result = eval(command.parameters[0])
      end
      @move_route_index += 1
      return
    end
  end
end
#--------------------------------------------------------------------------
def move_down_p
  turn_down
  distance = 2 ** @move_speed
  down1(((@x * 128 + @revise_x) / 128.0).round,
        ((@y * 128 + @revise_y) / 128.0).round, distance, true)
end
#--------------------------------------------------------------------------
def down1(x, y, distance, down = false)
  result = down2(x, y, distance)
  if result == false
    @event_run = check_event_trigger_touch(x, y+1)
    return result
  end
  if @revise_x < -SIDE
    result = down2(x, y + 1, distance, 4)
    result &= down2(x - 1, y, distance)
    if result == false
      if down
        move_lower_right_p
        if @revise_x > SIDE
          @revise_x = SIDE
        end
      end
      return result
    end
  elsif @revise_x > SIDE
    result = down2(x, y + 1, distance, 6)
    result &= down2(x + 1, y, distance)
    if result == false
      if down
        move_lower_left_p
        if @revise_x < -SIDE
          @revise_x = -SIDE
        end
      end
      return result
    end
  end
  @revise_y += distance
  return result
end
#--------------------------------------------------------------------------
def down2(x, y, distance, d = 2)
  if @revise_y + distance > DOWN
    unless passable?(x, y, d)
      if @revise_y < DOWN
        @revise_y = DOWN
      end
      return false
    end
  end
  return true
end
#--------------------------------------------------------------------------
def move_left_p
  turn_left
  distance = 2 ** @move_speed
  left1(((@x * 128 + @revise_x) / 128.0).round,
        ((@y * 128 + @revise_y) / 128.0).round, distance, true)
end
#--------------------------------------------------------------------------
def left1(x, y, distance, left = false)
  result = left2(x, y, distance)
  if result == false
    @event_run = check_event_trigger_touch(x-1, y)
    return result
  end
  if @revise_y < -UP
    result = left2(x - 1, y, distance, 8)
    result &= left2(x, y - 1, distance)
    if result == false
      if left
        move_lower_left_p
        if @revise_y > DOWN
          @revise_y = DOWN
        end
      end
      return result
    end
  elsif @revise_y > DOWN
    result = left2(x - 1, y, distance, 2)
    result &= left2(x, y + 1, distance)
    if result == false
      if left
        move_upper_left_p
        if @revise_y < -UP
          @revise_y = -UP
        end
      end
      return result
    end
  end
  @revise_x -= distance
  return result
end
#--------------------------------------------------------------------------
def left2(x, y, distance, d = 4)
  if @revise_x - distance < -SIDE
    unless passable?(x, y, d)
      if @revise_x > -SIDE
        @revise_x = -SIDE
      end
      return false
    end
  end
  return true
end
#--------------------------------------------------------------------------
def move_right_p
    turn_right
  distance = 2 ** @move_speed
  right1(((@x * 128 + @revise_x) / 128.0).round,
          ((@y * 128 + @revise_y) / 128.0).round, distance, true)
end
#--------------------------------------------------------------------------
def right1(x, y, distance, right = false)
  result = right2(x, y, distance)
  if result == false
    @event_run = check_event_trigger_touch(x+1, y)
    return result
  end
  if @revise_y < -UP
    result = right2(x + 1, y, distance, 8)
    result &= right2(x, y - 1, distance)
    if result == false
      if right
        move_lower_right_p
        if @revise_y > DOWN
          @revise_y = DOWN
        end
      end
      return result
    end
  elsif @revise_y > DOWN
    result = right2(x + 1, y, distance, 2)
    result &= right2(x, y + 1, distance)
    if result == false
      if right
        move_upper_right_p
        if @revise_y < -UP
          @revise_y = -UP
        end
      end
      return result
    end
  end
  @revise_x += distance
  return result
end
#--------------------------------------------------------------------------
def right2(x, y, distance, d = 6)
  if @revise_x + distance > SIDE
    unless passable?(x, y, d)
      if @revise_x < SIDE
        @revise_x = SIDE
      end
      return false
    end
  end
  return true
end
#--------------------------------------------------------------------------
def move_up_p
  turn_up
  distance = 2 ** @move_speed
  up1(((@x * 128 + @revise_x) / 128.0).round,
      ((@y * 128 + @revise_y) / 128.0).round, distance, true)
end
#--------------------------------------------------------------------------
def up1(x, y, distance, up = false)
  result = up2(x, y, distance)
  if result == false
    @event_run = check_event_trigger_touch(x, y-1)
    return result
  end
  if @revise_x < -SIDE
    result = up2(x, y - 1, distance, 4)
    result &= up2(x - 1, y, distance)
    if result == false
      if up
        move_upper_right_p
        if @revise_x > SIDE
          @revise_x = SIDE
        end
      end
      return result
    end
  elsif @revise_x > SIDE
    result = up2(x, y - 1, distance, 6)
    result &= up2(x + 1, y, distance)
    if result == false
      if up
        move_upper_left_p
        if @revise_x < -SIDE
          @revise_x = -SIDE
        end
      end
      return result
    end
  end
  @revise_y -= distance
  return result
end
#--------------------------------------------------------------------------
def up2(x, y, distance, d = 8)
  if @revise_y - distance < -UP
    unless passable?(x, y, d)
      if @revise_y > -UP
        @revise_y = -UP
      end
      return false
    end
  end
  return true
end
#--------------------------------------------------------------------------
def move_lower_left_p
  unless @direction_fix
    @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  end
  distance = (2 ** @move_speed) / Math.sqrt(2)
  turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
                          ((@y * 128 + @revise_y) / 128.0).round, distance)
  turn_down if @event_run
  unless @event_run
    if last_move?(@real_x, @real_y, 2, distance)
      result = check_event_trigger_here([1,2], false)
      if result == true
        return
      end
    end
    move_on
    if @revise_y > DOWN and -UP > @revise_y - distance
      @revise_y = DOWN
    end
    turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
                          ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_left if @event_run
  end
end
#--------------------------------------------------------------------------
def move_lower_right_p
  unless @direction_fix
    @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  end
  distance = (2 ** @move_speed) / Math.sqrt(2)
  turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
                          ((@y * 128 + @revise_y) / 128.0).round, distance)
  turn_down if @event_run
  unless @event_run
    if last_move?(@real_x, @real_y, 2, distance)
      result = check_event_trigger_here([1,2], false)
      if result == true
        return
      end
    end
    move_on
    if @revise_y > DOWN and -UP > @revise_y - distance
      @revise_y = DOWN
    end
    turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
                          ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_right if @event_run
  end
end
#--------------------------------------------------------------------------
def move_upper_left_p
  unless @direction_fix
    @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  end
  distance = (2 ** @move_speed) / Math.sqrt(2)
  turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
                        ((@y * 128 + @revise_y) / 128.0).round, distance)
  turn_up if @event_run
  unless @event_run
    if last_move?(@real_x, @real_y, 8, distance)
      result = check_event_trigger_here([1,2], false)
      if result == true
        return
      end
    end
    move_on
    if @revise_y + distance > DOWN and -UP > @revise_y
      @revise_y = -UP
    end
    turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
                          ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_left if @event_run
  end
end
#--------------------------------------------------------------------------
def move_upper_right_p
  unless @direction_fix
    @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  end
  distance = (2 ** @move_speed) / Math.sqrt(2)
  turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
                        ((@y * 128 + @revise_y) / 128.0).round, distance)
  turn_up if @event_run
  unless @event_run
    if last_move?(@real_x, @real_y, 8, distance)
      result = check_event_trigger_here([1,2], false)
      if result == true
        return
      end
    end
    move_on
    if @revise_y + distance > DOWN and -UP > @revise_y
      @revise_y = -UP
    end
    turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
                          ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_right if @event_run
  end
end
#--------------------------------------------------------------------------
def check_event_trigger_here(triggers, run = true)
  result = false
  if $game_system.map_interpreter.running?
    return result
  end
  for event in $game_map.events.values
    if event.x == ((@x * 128 + @revise_x) / 128.0).round and
        event.y == ((@y * 128 + @revise_y) / 128.0).round and
        triggers.include?(event.trigger)
      if not event.jumping? and event.over_trigger?
        if event.list.size > 1
          if run == true
            event.start
          end
          result = true
        end
      end
    end
  end
  return result
end
#--------------------------------------------------------------------------
def move_on
  if @y < (@y + @revise_y / 128.0).round
    @y += 1
    @revise_y -= 128
  end
  if @x > (@x + @revise_x / 128.0).round
    @x -= 1
    @revise_x += 128
  end
  if @x < (@x + @revise_x / 128.0).round
    @x += 1
    @revise_x -= 128
  end
  if @y > (@y + @revise_y / 128.0).round
    @y -= 1
    @revise_y += 128
  end
end
#--------------------------------------------------------------------------
def anime_update
  if @walk_anime
    @anime_count += 1.5
  elsif @step_anime
    @anime_count += 1
  end
  if @anime_count > 18 - @move_speed * 2
    if not @step_anime and @stop_count > 0
      @pattern = @original_pattern
    else
      @pattern = (@pattern + 1) % 4
    end
    @anime_count = 0
  end
end
#--------------------------------------------------------------------------
alias :moveto_original :moveto
def moveto(x, y)
  @revise_x = 0
  @revise_y = 0
  moveto_original(x, y)
end
#--------------------------------------------------------------------------
def last_move?(x, y, direction, distance)
  if direction == 2 or direction == 6
    distance *= -1
  end
  if (direction == 2 or direction == 8) and
      (y / 128.0).round != ((y - distance) / 128.0).round
    return true
  end
  if (direction == 4 or direction == 6) and
      (x / 128.0).round != ((x - distance) / 128.0).round
    return true
  end
  return false
end
end

#==============================================================================
# Game_Character
#==============================================================================
class Game_Character
def update_move
  distance = 2 ** @move_speed
  if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
    distance /= Math.sqrt(2)
  end
  if @y * 128 > @real_y
    @real_y = [@real_y + distance, @y * 128].min
  end
  if @x * 128 < @real_x
    @real_x = [@real_x - distance, @x * 128].max
  end
  if @x * 128 > @real_x
    @real_x = [@real_x + distance, @x * 128].min
  end
  if @y * 128 < @real_y
    @real_y = [@real_y - distance, @y * 128].max
  end
  if @walk_anime
    @anime_count += 1.5
  elsif @step_anime
    @anime_count += 1
  end
end
end
#==============================================================================
# Game_Event
#==============================================================================
class Game_Event < Game_Character
def start
  if @list.size > 1
    if $game_player.event != 0
      $game_player.move_speed = $game_player.event
    end
    @starting = true
  end
end
end

[Obrazek: mt4dzY7.png]
[Obrazek: k5KQGOe.png]
(Ten post był ostatnio modyfikowany: 21-08-17 19:13 przez Yoroiookami.)
21-08-17 19:13
Znajdź wszystkie posty użytkownika
"Pomógł" przyznał(a):
Wątek zamknięty 


Skocz do:


Użytkownicy przeglądający ten wątek: 1 gości

Kontakt | Ultima Forum | Wróć do góry | Wróć do forów | Wersja bez grafiki | RSS
Powered By MyBB. © 2013 MyBB Group. All Rights Reserved.
Skórka by Ayene.