DasKyu

Untitled

Jan 17th, 2021
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 21.78 KB | None | 0 0
  1. # http://members.jcom.home.ne.jp/cogwheel/
  2. #==============================================================================
  3. # Game_Player
  4. #==============================================================================
  5. class Game_Player < Game_Character
  6. UP  = 0
  7. DOWN  = 0
  8. SIDE  = 0
  9. SLANT = false
  10. #--------------------------------------------------------------------------
  11. attr_reader   :event
  12. attr_accessor :move_speed
  13. #--------------------------------------------------------------------------
  14. alias :update_original :update
  15. attr_accessor :walk
  16. def update
  17.   @walk = 4
  18.   @dash  = 5
  19.   @event = 3
  20.   @dot_m = true
  21.   center_x = (Graphics.width/2 - Game_Map::TILEWIDTH/2) * 4
  22.   center_y = (Graphics.height/2 - Game_Map::TILEHEIGHT/2) * 4
  23.   unless moving? or $game_system.map_interpreter.running? or
  24.            @move_route_forcing or $game_temp.message_window_showing or
  25.            $PokemonTemp.miniupdate or jumping?
  26.     if @walk != @dash
  27.       if  pbCanRun?
  28.         if @move_speed != @dash
  29.           @move_speed = @dash
  30.         end
  31.       else
  32.         if @move_speed != @walk
  33.           @move_speed = @walk
  34.         end
  35.       end
  36.     end
  37.   end
  38.   if @revise_x == nil and @revise_y == nil
  39.     @revise_x = 0
  40.     @revise_y = 0
  41.   end
  42.   unless @dot_m
  43.     update_original
  44.     return
  45.   end
  46.   if @move_route_forcing
  47.     last_moving = moving?
  48.     last_real_x = @real_x
  49.     last_real_y = @real_y
  50.     if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
  51.       if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
  52.         @revise_x = @real_x - @x * 128
  53.         @revise_y = @real_y - @y * 128
  54.       end
  55.       distance1 = 2 ** @move_speed
  56.       distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
  57.       if distance1 > distance2
  58.         @real_x = @real_x - @revise_x
  59.         @real_y = @real_y - @revise_y
  60.         @revise_x = 0
  61.         @revise_y = 0
  62.         anime_update
  63.       else
  64.         @real_x -= (distance1 * @revise_x / distance2).round
  65.         @real_y -= (distance1 * @revise_y / distance2).round
  66.         @revise_x = @real_x - @x * 128
  67.         @revise_y = @real_y - @y * 128
  68.         anime_update
  69.       end
  70.     else
  71.       super
  72.     end
  73.   else
  74.     @move = false
  75.     unless moving? or $game_system.map_interpreter.running? or
  76.            @move_route_forcing or $game_temp.message_window_showing or
  77.            $PokemonTemp.miniupdate or jumping?
  78.       case Input.dir8
  79.       when 1
  80.         move_lower_left_p
  81.       when 2
  82.         move_down_p
  83.       when 3
  84.         move_lower_right_p
  85.       when 4
  86.         move_left_p
  87.       when 6
  88.         move_right_p
  89.       when 7
  90.         move_upper_left_p
  91.       when 8
  92.         move_up_p
  93.       when 9
  94.         move_upper_right_p
  95.   end
  96.  end
  97.   $PokemonTemp.dependentEvents.updateDependentEvents
  98.     last_real_x = @real_x
  99.     last_real_y = @real_y
  100.   unless jumping?
  101.     @real_x = @x * 128 + @revise_x
  102.     @real_y = @y * 128 + @revise_y
  103.  else
  104.   update_jump
  105.  end
  106.     last_moving = moving?
  107.     move_on
  108.     if (last_real_x != @real_x or last_real_y != @real_y)
  109.       @move_distance = 0 if @move_distance == nil
  110.       @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
  111.                                     (last_real_y - @real_y) ** 2)
  112.       if @move_distance >= 128
  113.         @move_distance %= 128
  114.         increase_steps
  115.       end
  116.       anime_update
  117.     else
  118.       @pattern = 0
  119.     end
  120. end
  121.  
  122.     if @real_y > last_real_y and @real_y - $game_map.display_y > center_y
  123.       # Scroll map down
  124.       $game_map.scroll_down(@real_y - last_real_y)
  125.     end
  126.     # If character moves left and is positioned more left on-screen than
  127.     # center
  128.     if @real_x < last_real_x and @real_x - $game_map.display_x < center_x
  129.       # Scroll map left
  130.       $game_map.scroll_left(last_real_x - @real_x)
  131.     end
  132.     # If character moves right and is positioned more right on-screen than
  133.     # center
  134.     if @real_x > last_real_x and @real_x - $game_map.display_x > center_x
  135.       # Scroll map right
  136.       $game_map.scroll_right(@real_x - last_real_x)
  137.     end
  138.     # If character moves up and is positioned higher than the center
  139.     # of the screen
  140.     if @real_y < last_real_y and @real_y - $game_map.display_y < center_y
  141.       # Scroll map up
  142.       $game_map.scroll_up(last_real_y - @real_y)
  143.     end
  144.   @bump_se-=1 if @bump_se && @bump_se>0
  145.   if last_moving
  146.      $PokemonTemp.dependentEvents.pbTurnDependentEvents
  147.     result = pbCheckEventTriggerFromDistance([2])
  148.     # Event determinant is via touch of same position event
  149.     result |= check_event_trigger_here([1,2])
  150.     # If event which started does not exist
  151.     Kernel.pbOnStepTaken(result) # *Added function call
  152.     if result == false
  153.       unless $DEBUG and Input.press?(Input::CTRL)
  154.         if @encounter_count > 0
  155.           @encounter_count -= 1
  156.         end
  157.       end
  158.     end
  159.   end
  160.   if Input.trigger?(Input::C) && !$PokemonTemp.miniupdate
  161.     check_event_trigger_here([0])
  162.     check_event_trigger_there([0,1,2])
  163.   end
  164. end
  165. #--------------------------------------------------------------------------
  166. def initialize
  167.   @revise_x = 0
  168.   @revise_y = 0
  169.   @move == false
  170.   super
  171. end
  172. #--------------------------------------------------------------------------
  173. def moving?
  174.   unless @dot_m
  175.     result = super
  176.     return result
  177.   end
  178.   if @move_route_forcing
  179.     if @move == false
  180.       return false
  181.     end
  182.     super
  183.   else
  184.     return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
  185.   end
  186. end
  187. #--------------------------------------------------------------------------
  188. def moving_a?
  189.   if @move == false
  190.     if (@move_route.list[@move_route_index].code <= 14 or
  191.         @move_route.list[@move_route_index].code == 25)
  192.       @move = true
  193.     end
  194.     return false
  195.   end
  196.   moving?
  197. end
  198. #--------------------------------------------------------------------------
  199. def update_jump
  200.   @jump_count -= 1
  201.   @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
  202.   @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
  203.   if @jump_count == 0
  204.     @revise_x = 0
  205.     @revise_y = 0
  206.   end
  207. end
  208. #--------------------------------------------------------------------------
  209. def jump(x_plus, y_plus)
  210.     if x_plus != 0 or y_plus != 0
  211.       if x_plus.abs > y_plus.abs
  212.         x_plus < 0 ? turn_left : turn_right
  213.       else
  214.         y_plus < 0 ? turn_up : turn_down
  215.       end
  216.     end
  217.     new_x = @x + x_plus
  218.     new_y = @y + y_plus
  219.     oldX=@x
  220.     oldY=@y
  221.     if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  222.       pbSEPlay("jump")
  223.       straighten
  224.       @x = new_x
  225.       @y = new_y
  226.       distance = [4, x_plus * x_plus + y_plus * y_plus].max
  227.       @jump_peak = 6 + distance - @move_speed
  228.       @jump_peak = @jump_peak.floor
  229.       @jump_count = @jump_peak * 2
  230.       @stop_count = 0
  231.       if self.is_a?(Game_Player)
  232.         $PokemonTemp.dependentEvents.pbMoveDependentEvents
  233.       end
  234.       triggerLeaveTile()
  235.     end
  236. end
  237. #--------------------------------------------------------------------------
  238. def move_type_custom
  239.   unless @dot_m
  240.     super
  241.     return
  242.   end
  243.   if jumping? or moving_a?
  244.     return
  245.   end
  246.   while @move_route_index < @move_route.list.size
  247.     command = @move_route.list[@move_route_index]
  248.     if command.code == 0
  249.       if @move_route.repeat
  250.         @move_route_index = 0
  251.       end
  252.       unless @move_route.repeat
  253.         if @move_route_forcing and not @move_route.repeat
  254.           @move_route_forcing = false
  255.           @move_route = @original_move_route
  256.           @move_route_index = @original_move_route_index
  257.           @original_move_route = nil
  258.         end
  259.         @stop_count = 0
  260.       end
  261.       return
  262.     end
  263.     if command.code <= 14
  264.       case command.code
  265.       when 1
  266.         move_down
  267.       when 2
  268.         move_left
  269.       when 3
  270.         move_right
  271.       when 4
  272.         move_up
  273.       when 5
  274.         move_lower_left
  275.       when 6
  276.         move_lower_right
  277.       when 7
  278.         move_upper_left
  279.       when 8
  280.         move_upper_right
  281.       when 9
  282.         move_random
  283.       when 10
  284.         move_toward_player
  285.       when 11
  286.         move_away_from_player
  287.       when 12
  288.         move_forward
  289.       when 13
  290.         move_backward
  291.       when 14
  292.         jump(command.parameters[0], command.parameters[1])
  293.       end
  294.       if not @move_route.skippable and not moving? and not jumping?
  295.         return
  296.       end
  297.       @move_route_index += 1
  298.       return
  299.     end
  300.     if command.code == 15
  301.       @wait_count = command.parameters[0] * 2 - 1
  302.       @move_route_index += 1
  303.       return
  304.     end
  305.     if command.code >= 16 and command.code <= 26
  306.       case command.code
  307.       when 16
  308.         turn_down
  309.       when 17
  310.         turn_left
  311.       when 18
  312.         turn_right
  313.       when 19
  314.         turn_up
  315.       when 20
  316.         turn_right_90
  317.       when 21
  318.         turn_left_90
  319.       when 22
  320.         turn_180
  321.       when 23
  322.         turn_right_or_left_90
  323.       when 24
  324.         turn_random
  325.       when 25
  326.         turn_toward_player
  327.       when 26
  328.         turn_away_from_player
  329.       end
  330.       @move_route_index += 1
  331.       return
  332.     end
  333.     if command.code >= 27
  334.       case command.code
  335.       when 27
  336.         $game_switches[command.parameters[0]] = true
  337.         $game_map.need_refresh = true
  338.       when 28
  339.         $game_switches[command.parameters[0]] = false
  340.         $game_map.need_refresh = true
  341.       when 29
  342.         @move_speed = command.parameters[0]
  343.       when 30
  344.         @move_frequency = command.parameters[0]
  345.       when 31
  346.         @walk_anime = true
  347.       when 32
  348.         @walk_anime = false
  349.       when 33
  350.         @step_anime = true
  351.       when 34
  352.         @step_anime = false
  353.       when 35
  354.         @direction_fix = true
  355.       when 36
  356.         @direction_fix = false
  357.       when 37
  358.         @through = true
  359.       when 38
  360.         @through = false
  361.       when 39
  362.         @always_on_top = true
  363.       when 40
  364.         @always_on_top = false
  365.       when 41
  366.         @tile_id = 0
  367.         @character_name = command.parameters[0]
  368.         @character_hue = command.parameters[1]
  369.         if @original_direction != command.parameters[2]
  370.           @direction = command.parameters[2]
  371.           @original_direction = @direction
  372.           @prelock_direction = 0
  373.         end
  374.         if @original_pattern != command.parameters[3]
  375.           @pattern = command.parameters[3]
  376.           @original_pattern = @pattern
  377.         end
  378.       when 42
  379.         @opacity = command.parameters[0]
  380.       when 43
  381.         @blend_type = command.parameters[0]
  382.       when 44
  383.         $game_system.se_play(command.parameters[0])
  384.       when 45
  385.         result = eval(command.parameters[0])
  386.       end
  387.       @move_route_index += 1
  388.       return
  389.     end
  390.   end
  391. end
  392. #--------------------------------------------------------------------------
  393. def move_down_p
  394.   turn_down
  395.   distance = 2 ** @move_speed
  396.   down1(((@x * 128 + @revise_x) / 128.0).round,
  397.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  398. end
  399. #--------------------------------------------------------------------------
  400. def down1(x, y, distance, down = false)
  401.   result = down2(x, y, distance)
  402.   if result == false
  403.     @event_run = check_event_trigger_touch(x, y+1)
  404.     return result
  405. end
  406.  
  407.   if @revise_x < -SIDE
  408.     result = down2(x, y + 1, distance, 4)
  409.     result &= down2(x - 1, y, distance)
  410.     if result == false
  411.       if down
  412.         move_lower_right_p
  413.         if @revise_x > SIDE
  414.           @revise_x = SIDE
  415.         end
  416.       end
  417.       return result
  418.     end
  419.   elsif @revise_x > SIDE
  420.     result = down2(x, y + 1, distance, 6)
  421.     result &= down2(x + 1, y, distance)
  422.     if result == false
  423.       if down
  424.         move_lower_left_p
  425.         if @revise_x < -SIDE
  426.           @revise_x = -SIDE
  427.         end
  428.       end
  429.       return result
  430.     end
  431. end
  432.   @revise_y += distance
  433.   $PokemonTemp.dependentEvents.pbMoveDependentEvents
  434.   increase_steps
  435.   return result
  436. end
  437. #--------------------------------------------------------------------------
  438. def down2(x, y, distance, d = 2)
  439.   if @revise_y + distance > DOWN
  440.     unless passable?(x, y, d)
  441.   if @revise_y < DOWN
  442.         @revise_y = DOWN
  443.   end
  444.   check_event_trigger_here([0])
  445.       return false
  446.     end
  447. end
  448.   return if pbLedge(0,1)
  449.   return if pbEndSurf(0,1)
  450.   return true
  451. end
  452. #--------------------------------------------------------------------------
  453. def move_left_p
  454.   turn_left
  455.   distance = 2 ** @move_speed
  456.   left1(((@x * 128 + @revise_x) / 128.0).round,
  457.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  458. end
  459. #--------------------------------------------------------------------------
  460. def left1(x, y, distance, left = false)
  461.   result = left2(x, y, distance)
  462.   if result == false
  463.     @event_run = check_event_trigger_touch(x-1, y)
  464.     return result
  465.   end
  466.   if @revise_y < -UP
  467.     result = left2(x - 1, y, distance, 8)
  468.     result &= left2(x, y - 1, distance)
  469.     if result == false
  470.       if left
  471.         move_lower_left_p
  472.         if @revise_y > DOWN
  473.           @revise_y = DOWN
  474.         end
  475.       end
  476.       return result
  477.     end
  478.   elsif @revise_y > DOWN
  479.     result = left2(x - 1, y, distance, 2)
  480.     result &= left2(x, y + 1, distance)
  481.     if result == false
  482.       if left
  483.         move_upper_left_p
  484.         if @revise_y < -UP
  485.           @revise_y = -UP
  486.         end
  487.       end
  488.       return result
  489.     end
  490.   end
  491.   @revise_x -= distance
  492.   $PokemonTemp.dependentEvents.pbMoveDependentEvents
  493.   increase_steps
  494.   return result
  495. end
  496. #--------------------------------------------------------------------------
  497. def left2(x, y, distance, d = 4)
  498.   if @revise_x - distance < -SIDE
  499.     unless passable?(x, y, d)
  500.       if @revise_x > -SIDE
  501.         @revise_x = -SIDE
  502.   end
  503.   check_event_trigger_here([0])
  504.   return false
  505.     end
  506. end
  507.   return if pbLedge(-1,0)
  508.   return if pbEndSurf(-1,0)
  509.   return true
  510. end
  511. #--------------------------------------------------------------------------
  512. def move_right_p
  513.     turn_right
  514.   distance = 2 ** @move_speed
  515.   right1(((@x * 128 + @revise_x) / 128.0).round,
  516.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  517. end
  518. #--------------------------------------------------------------------------
  519. def right1(x, y, distance, right = false)
  520.   result = right2(x, y, distance)
  521.   if result == false
  522.     @event_run = check_event_trigger_touch(x+1, y)
  523.     return result
  524.   end
  525.   if @revise_y < -UP
  526.     result = right2(x + 1, y, distance, 8)
  527.     result &= right2(x, y - 1, distance)
  528.     if result == false
  529.       if right
  530.         move_lower_right_p
  531.         if @revise_y > DOWN
  532.           @revise_y = DOWN
  533.         end
  534.       end
  535.       return result
  536.     end
  537.   elsif @revise_y > DOWN
  538.     result = right2(x + 1, y, distance, 2)
  539.     result &= right2(x, y + 1, distance)
  540.     if result == false
  541.       if right
  542.         move_upper_right_p
  543.         if @revise_y < -UP
  544.           @revise_y = -UP
  545.         end
  546.       end
  547.       return result
  548.     end
  549.   end
  550.   @revise_x += distance
  551.   $PokemonTemp.dependentEvents.pbMoveDependentEvents
  552.   increase_steps
  553.   return result
  554. end
  555. #--------------------------------------------------------------------------
  556. def right2(x, y, distance, d = 6)
  557.   if @revise_x + distance > SIDE
  558.     unless passable?(x, y, d)
  559.       if @revise_x < SIDE
  560.         @revise_x = SIDE
  561.   end
  562.     check_event_trigger_here([0])
  563.       return false
  564.     end
  565.   end
  566.   return if pbLedge(1,0)
  567.   return if pbEndSurf(1,0)
  568.   return true
  569. end
  570. #--------------------------------------------------------------------------
  571. def move_up_p
  572.   turn_up
  573.   distance = 2 ** @move_speed
  574.   up1(((@x * 128 + @revise_x) / 128.0).round,
  575.       ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  576.   end
  577.  
  578. def check
  579.   print "holi"
  580.   @revise_x += 5
  581. end
  582. #--------------------------------------------------------------------------
  583. def up1(x, y, distance, up = false)
  584.   result = up2(x, y, distance)
  585.   if result == false
  586.     @event_run = check_event_trigger_touch(x, y-1)
  587.     return result
  588.   end
  589.   if @revise_x < -SIDE
  590.     result = up2(x, y - 1, distance, 4)
  591.     result &= up2(x - 1, y, distance)
  592.     if result == false
  593.       if up
  594.         move_upper_right_p
  595.         if @revise_x > SIDE
  596.           @revise_x = SIDE
  597.         end
  598.       end
  599.       return result
  600.     end
  601.   elsif @revise_x > SIDE
  602.     result = up2(x, y - 1, distance, 6)
  603.     result &= up2(x + 1, y, distance)
  604.     if result == false
  605.       if up
  606.         move_upper_left_p
  607.         if @revise_x < -SIDE
  608.           @revise_x = -SIDE
  609.         end
  610.       end
  611.       return result
  612.     end
  613.   end
  614.   @revise_y -= distance
  615.   $PokemonTemp.dependentEvents.pbMoveDependentEvents
  616.   increase_steps
  617.   return result
  618. end
  619. #--------------------------------------------------------------------------
  620. def up2(x, y, distance, d = 8)
  621.   if @revise_y - distance < -UP
  622.     unless passable?(x, y, d)
  623.       if @revise_y > -UP
  624.         @revise_y = -UP
  625.   end
  626.     check_event_trigger_here([0])
  627.       return false
  628.     end
  629. end
  630.   return if pbLedge(0,-1)
  631.   return if pbEndSurf(0,-1)
  632.   return true
  633. end
  634. #--------------------------------------------------------------------------
  635. def move_lower_left_p
  636.   unless @direction_fix
  637.     @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  638.   end
  639.   distance = (2 ** @move_speed) / Math.sqrt(2)
  640.   turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  641.                           ((@y * 128 + @revise_y) / 128.0).round, distance)
  642.   turn_down if @event_run
  643.   unless @event_run
  644.     if last_move?(@real_x, @real_y, 2, distance)
  645.       result = check_event_trigger_here([1,2], false)
  646.       if result == true
  647.         return
  648.       end
  649.     end
  650.     move_on
  651.     if @revise_y > DOWN and -UP > @revise_y - distance
  652.       @revise_y = DOWN
  653.     end
  654.     turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  655.                           ((@y * 128 + @revise_y) / 128.0).round, distance)
  656.     turn_left if @event_run
  657.   end
  658. end
  659. #--------------------------------------------------------------------------
  660. def move_lower_right_p
  661.   unless @direction_fix
  662.     @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  663.   end
  664.   distance = (2 ** @move_speed) / Math.sqrt(2)
  665.   turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  666.                           ((@y * 128 + @revise_y) / 128.0).round, distance)
  667.   turn_down if @event_run
  668.   unless @event_run
  669.     if last_move?(@real_x, @real_y, 2, distance)
  670.       result = check_event_trigger_here([1,2], false)
  671.       if result == true
  672.         return
  673.       end
  674.     end
  675.     move_on
  676.     if @revise_y > DOWN and -UP > @revise_y - distance
  677.       @revise_y = DOWN
  678.     end
  679.     turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  680.                           ((@y * 128 + @revise_y) / 128.0).round, distance)
  681.     turn_right if @event_run
  682.   end
  683. end
  684. #--------------------------------------------------------------------------
  685. def move_upper_left_p
  686.   unless @direction_fix
  687.     @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  688.   end
  689.   distance = (2 ** @move_speed) / Math.sqrt(2)
  690.   turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  691.                         ((@y * 128 + @revise_y) / 128.0).round, distance)
  692.   turn_up if @event_run
  693.   unless @event_run
  694.     if last_move?(@real_x, @real_y, 8, distance)
  695.       result = check_event_trigger_here([1,2], false)
  696.       if result == true
  697.         return
  698.       end
  699.     end
  700.     move_on
  701.     if @revise_y + distance > DOWN and -UP > @revise_y
  702.       @revise_y = -UP
  703.     end
  704.     turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  705.                           ((@y * 128 + @revise_y) / 128.0).round, distance)
  706.     turn_left if @event_run
  707.   end
  708. end
  709. #--------------------------------------------------------------------------
  710. def move_upper_right_p
  711.   unless @direction_fix
  712.     @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  713.   end
  714.   distance = (2 ** @move_speed) / Math.sqrt(2)
  715.   turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  716.                         ((@y * 128 + @revise_y) / 128.0).round, distance)
  717.   turn_up if @event_run
  718.   unless @event_run
  719.     if last_move?(@real_x, @real_y, 8, distance)
  720.       result = check_event_trigger_here([1,2], false)
  721.       if result == true
  722.         return
  723.       end
  724.     end
  725.     move_on
  726.     if @revise_y + distance > DOWN and -UP > @revise_y
  727.       @revise_y = -UP
  728.     end
  729.     turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  730.                           ((@y * 128 + @revise_y) / 128.0).round, distance)
  731.     turn_right if @event_run
  732.   end
  733. end
  734. #--------------------------------------------------------------------------
  735. def check_event_trigger_here(triggers, run = true)
  736.   result = false
  737.   if $game_system.map_interpreter.running?
  738.     return result
  739.   end
  740.   for event in $game_map.events.values
  741.     if event.x == ((@x * 128 + @revise_x) / 128.0).round and
  742.         event.y == ((@y * 128 + @revise_y) / 128.0).round and
  743.         triggers.include?(event.trigger)
  744.       if not event.jumping? and event.over_trigger?
  745.         if event.list.size > 1
  746.           if run == true
  747.             event.start
  748.     end
  749.           result = true
  750.         end
  751.       end
  752.     end
  753.   end
  754.   return result
  755. end
  756. #--------------------------------------------------------------------------
  757. def move_on
  758.   if @y < (@y + @revise_y / 128.0).round
  759.     @y += 1
  760.     @revise_y -= 128
  761.   end
  762.   if @x > (@x + @revise_x / 128.0).round
  763.     @x -= 1
  764.     @revise_x += 128
  765.   end
  766.   if @x < (@x + @revise_x / 128.0).round
  767.     @x += 1
  768.     @revise_x -= 128
  769.   end
  770.   if @y > (@y + @revise_y / 128.0).round
  771.     @y -= 1
  772.     @revise_y += 128
  773.   end
  774. end
  775. #--------------------------------------------------------------------------
  776. def anime_update
  777.   if @walk_anime
  778.     @anime_count += 1.5
  779.   elsif @step_anime
  780.     @anime_count += 1
  781.   end
  782.   if @anime_count > 18 - @move_speed * 2
  783.     if not @step_anime and @stop_count > 0
  784.       @pattern = @original_pattern
  785.     else
  786.       @pattern = (@pattern + 1) % 4
  787.     end
  788.     @anime_count = 0
  789.   end
  790. end
  791. #--------------------------------------------------------------------------
  792. alias :moveto_original :moveto
  793. def moveto(x, y)
  794.   @revise_x = 0
  795.   @revise_y = 0
  796.   moveto_original(x, y)
  797. end
  798. #--------------------------------------------------------------------------
  799. def last_move?(x, y, direction, distance)
  800.   if direction == 2 or direction == 6
  801.     distance *= -1
  802.   end
  803.   if (direction == 2 or direction == 8) and
  804.       (y / 128.0).round != ((y - distance) / 128.0).round
  805.     return true
  806.   end
  807.   if (direction == 4 or direction == 6) and
  808.       (x / 128.0).round != ((x - distance) / 128.0).round
  809.     return true
  810.   end
  811.   return false
  812. end
  813. end
  814.  
  815. #==============================================================================
  816. # Game_Character
  817. #==============================================================================
  818. class Game_Character
  819. def update_move
  820.     realResX=Game_Map.realResX
  821.     realResY=Game_Map.realResY
  822.     distance = 2 ** @move_speed
  823.     if @x * 128 < @real_x
  824.       @real_x = [@real_x - distance, @x * realResX].max
  825.     end
  826.     if @x * 128> @real_x
  827.       @real_x = [@real_x + distance, @x * realResX].min
  828.     end
  829.     if @y * 128> @real_y
  830.       @real_y = [@real_y + distance, @y * realResY].min
  831.     end
  832.     if @y * 128 < @real_y
  833.       @real_y = [@real_y - distance, @y * realResY].max
  834.     end
  835.     if !jumping? && !moving?
  836.       Events.onStepTakenFieldMovement.trigger(self,self)
  837.     end
  838.     if @walk_anime
  839.       @anime_count += 1.5
  840.     elsif @step_anime
  841.       @anime_count += 1
  842.     end
  843.   end
  844. end
  845. #==============================================================================
  846. # Game_Event
  847. #==============================================================================
  848. class Game_Event < Game_Character
  849. def start
  850.   if @list.size > 1
  851.     @starting = true
  852.     if $game_player.event != 0
  853.       $game_player.move_speed = $game_player.event
  854.     end
  855.   end
  856. end
  857. end
Advertisement
Add Comment
Please, Sign In to add comment