Advertisement
TechSkylander1518

Terrain Fix

Dec 25th, 2021 (edited)
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 21.02 KB | None | 0 0
  1. #==============================================================================#
  2. #                             Enhanced Staircases                              #
  3. #                                  by Marin                                    #
  4. #------------------------------------------------------------------------------#
  5. # This script provides pixel movement while walking on staircases, while also  #
  6. # slowing down movement to capture the real feeling and motion of a staircase. #
  7. #------------------------------------------------------------------------------#
  8. #                                  Usage                                       #
  9. #                                                                              #
  10. # To make a stair work smoothly, it must have one event at the bottom, and one #
  11. # at the top (not on the staircase; one tile outwards).                        #
  12. # Staircase events utilize comments to configure the properties of the stairs. #
  13. # These comments are not compiled it any different format unlike, say, trainer #
  14. # generation, and as such do not require you to restart RPG Maker XP.          #
  15. #                                                                              #
  16. # The name of a staircase event must be `Slope` (without the backticks ``),    #
  17. # and the event must contain a comment with the following text:                #
  18. # `Slope: AxB` where A and B are integers, specifying how many tiles           #
  19. # away the second event is. If the staircase is wider than 1 tile, this must   #
  20. # match up with event that has the same stair index, as explained below.       #
  21. #                                                                              #
  22. # If your staircase is more than 1 tile wide, you require an additional        #
  23. # `Width: A/B` comment, where A is the index of the event in the staircase     #
  24. # (i.e. if it's the bottom part of the staircase 0, if it's one higher 1, etc) #
  25. # and B is the total width of the staircase. If you understand the explanation,#
  26. # you'll agree that this means that the top event of a 3-wide staircase will   #
  27. # say `Width: 2/3`.                                                            #
  28. #                                                                              #
  29. # It is also possible to specify at which point during movement from the event #
  30. # to the start of the staircase to increment the vertical offset.              #
  31. # By default, this is a value of 16 pixels. This means that you move without   #
  32. # any vertical increase for the first 16 pixels, and after that start climbing #
  33. # the staircase.                                                               #
  34. # To change this offset, write in a comment, `Offset: Apx`, where A is the     #
  35. # number of pixels after which to start climbing the staircase.                #
  36. #------------------------------------------------------------------------------#
  37. #                    Please give credit when using this.                       #
  38. #==============================================================================#
  39.  
  40. PluginManager.register({
  41.   :name => "Enhanced Staircases",
  42.   :version => "1.7",
  43.   :credits => "Marin",
  44.   :link => "https://reliccastle.com/resources/396/"
  45. })
  46.  
  47. # If true, overwrites default scrolling behaviour to make stair movement smooth
  48. # and to reduce improper scrolling offsets after walking on stairs wider than 1.
  49. SMOOTH_SCROLLING = true
  50.  
  51. $DisableScrollCounter = 0
  52.  
  53. class DependentEvents
  54.   def pbFollowEventAcrossMaps(leader,follower,instant=false,leaderIsTrueLeader=true)
  55.     d=leader.direction
  56.     areConnected=$MapFactory.areConnected?(leader.map.map_id,follower.map.map_id)
  57.     # Get the rear facing tile of leader
  58.     facingDirection=[0,0,8,0,6,0,4,0,2][d]
  59.     if !leaderIsTrueLeader && areConnected
  60.       relativePos=$MapFactory.getThisAndOtherEventRelativePos(leader,follower)
  61.       if (relativePos[1]==0 && relativePos[0]==2) # 2 spaces to the right of leader
  62.         facingDirection=6
  63.       elsif (relativePos[1]==0 && relativePos[0]==-2) # 2 spaces to the left of leader
  64.         facingDirection=4
  65.       elsif relativePos[1]==-2 && relativePos[0]==0 # 2 spaces above leader
  66.         facingDirection=8
  67.       elsif relativePos[1]==2 && relativePos[0]==0 # 2 spaces below leader
  68.         facingDirection=2
  69.       end
  70.     end
  71.     facings=[facingDirection] # Get facing from behind
  72.     facings.push([0,0,4,0,8,0,2,0,6][d]) # Get right facing
  73.     facings.push([0,0,6,0,2,0,8,0,4][d]) # Get left facing
  74.     if !leaderIsTrueLeader
  75.       facings.push([0,0,2,0,4,0,6,0,8][d]) # Get forward facing
  76.     end
  77.     mapTile=nil
  78.     if areConnected
  79.       bestRelativePos=-1
  80.       oldthrough=follower.through
  81.       follower.through=false
  82.       for i in 0...facings.length
  83.         facing=facings[i]
  84.         tile=$MapFactory.getFacingTile(facing,leader)
  85.         passable=tile && $MapFactory.isPassable?(tile[0],tile[1],tile[2],follower)
  86.         if !passable && $PokemonGlobal.bridge>0
  87.           passable = $MapFactory.getTerrainTag(tile[0],tile[1],tile[2]).bridge
  88.         elsif passable && !$PokemonGlobal.surfing && $PokemonGlobal.bridge==0      
  89.           passable=!$MapFactory.getTerrainTag(tile[0],tile[1],tile[2]).can_surf
  90.         end
  91.         if i==0 && !passable && tile &&
  92.            $MapFactory.getTerrainTag(tile[0],tile[1],tile[2],true).ledge &&
  93.            $PokemonGlobal.bridge==0
  94.           # If the tile isn't passable and the tile is a ledge,
  95.           # get tile from further behind
  96.           tile=$MapFactory.getFacingTileFromPos(tile[0],tile[1],tile[2],facing)
  97.           passable=tile && $MapFactory.isPassable?(tile[0],tile[1],tile[2],follower)
  98.           if passable && !$PokemonGlobal.surfing
  99.             passable=!$MapFactory.getTerrainTag(tile[0],tile[1],tile[2]).can_surf
  100.           end
  101.         end
  102.         if passable
  103.           relativePos=$MapFactory.getThisAndOtherPosRelativePos(
  104.              follower,tile[0],tile[1],tile[2])
  105.           distance=Math.sqrt(relativePos[0]*relativePos[0]+relativePos[1]*relativePos[1])
  106.           if bestRelativePos==-1 || bestRelativePos>distance
  107.             bestRelativePos=distance
  108.             mapTile=tile
  109.           end
  110.           if i==0 && distance<=1 # Prefer behind if tile can move up to 1 space
  111.             break
  112.           end
  113.         end
  114.       end
  115.       follower.through=oldthrough
  116.     else
  117.       tile=$MapFactory.getFacingTile(facings[0],leader)
  118.       passable=tile && $MapFactory.isPassable?(
  119.          tile[0],tile[1],tile[2],follower)
  120.       mapTile=passable ? mapTile : nil
  121.     end
  122.     if mapTile && follower.map.map_id==mapTile[0]
  123.       # Follower is on same map
  124.       newX=mapTile[1]
  125.       newY=mapTile[2]
  126.       if leader.on_stair?
  127.         newX = leader.x + (leader.direction == 4 ? 1 : leader.direction == 6 ? -1 : 0)
  128.         if leader.on_middle_of_stair?
  129.           newY = leader.y + (leader.direction == 8 ? 1 : leader.direction == 2 ? -1 : 0)
  130.         else
  131.           if follower.on_middle_of_stair?
  132.             newY = follower.stair_start_y - follower.stair_y_position
  133.           else
  134.             newY = leader.y + (leader.direction == 8 ? 1 : leader.direction == 2 ? -1 : 0)
  135.           end
  136.         end
  137.       end
  138.       deltaX=(d == 6 ? -1 : d == 4 ? 1 : 0)
  139.       deltaY=(d == 2 ? -1 : d == 8 ? 1 : 0)
  140.       posX = newX + deltaX
  141.       posY = newY + deltaY
  142.       follower.move_speed=leader.move_speed # sync movespeed
  143.       if (follower.x-newX==-1 && follower.y==newY) ||
  144.          (follower.x-newX==1 && follower.y==newY) ||
  145.          (follower.y-newY==-1 && follower.x==newX) ||
  146.          (follower.y-newY==1 && follower.x==newX)
  147.         if instant
  148.           follower.moveto(newX,newY)
  149.         else
  150.           pbFancyMoveTo(follower,newX,newY,leader)
  151.         end
  152.       elsif (follower.x-newX==-2 && follower.y==newY) ||
  153.             (follower.x-newX==2 && follower.y==newY) ||
  154.             (follower.y-newY==-2 && follower.x==newX) ||
  155.             (follower.y-newY==2 && follower.x==newX)
  156.         if instant
  157.           follower.moveto(newX,newY)
  158.         else
  159.           pbFancyMoveTo(follower,newX,newY,leader)
  160.         end
  161.       elsif follower.x!=posX || follower.y!=posY
  162.         if instant
  163.           follower.moveto(newX,newY)
  164.         else
  165.           pbFancyMoveTo(follower,posX,posY,leader)
  166.           pbFancyMoveTo(follower,newX,newY,leader)
  167.         end
  168.       end
  169.     else
  170.       if !mapTile
  171.         # Make current position into leader's position
  172.         mapTile=[leader.map.map_id,leader.x,leader.y]
  173.       end
  174.       if follower.map.map_id==mapTile[0]
  175.         # Follower is on same map as leader
  176.         follower.moveto(leader.x,leader.y)
  177.       else
  178.         # Follower will move to different map
  179.         events=$PokemonGlobal.dependentEvents
  180.         eventIndex=pbEnsureEvent(follower,mapTile[0])
  181.         if eventIndex>=0
  182.           newFollower=@realEvents[eventIndex]
  183.           newEventData=events[eventIndex]
  184.           newFollower.moveto(mapTile[1],mapTile[2])
  185.           newEventData[3]=mapTile[1]
  186.           newEventData[4]=mapTile[2]
  187.         end
  188.       end
  189.     end
  190.   end
  191. end
  192.  
  193. def pbTurnTowardEvent(event,otherEvent)
  194.   sx = 0; sy = 0
  195.   if $MapFactory
  196.     relativePos=$MapFactory.getThisAndOtherEventRelativePos(otherEvent,event)
  197.     sx = relativePos[0]
  198.     sy = relativePos[1]
  199.   else
  200.     sx = event.x - otherEvent.x
  201.     sy = event.y - otherEvent.y
  202.   end
  203.   return if sx == 0 and sy == 0
  204.   if event.on_middle_of_stair? && !otherEvent.on_middle_of_stair?
  205.     sx > 0 ? event.turn_left : event.turn_right
  206.     return
  207.   end
  208.   if sx.abs > sy.abs
  209.     (sx > 0) ? event.turn_left : event.turn_right
  210.   else
  211.     (sy > 0) ? event.turn_up : event.turn_down
  212.   end
  213. end
  214.  
  215. class Scene_Map
  216.   alias stair_transfer_player transfer_player
  217.   def transfer_player(cancelVehicles = true)
  218.     stair_transfer_player(cancelVehicles)
  219.     $game_player.clear_stair_data
  220.   end
  221. end
  222.  
  223. class Game_Event
  224.   alias stair_cett check_event_trigger_touch
  225.   def check_event_trigger_touch(dir)
  226.     return if on_stair?
  227.     return stair_cett(dir)
  228.   end
  229.  
  230.   alias stair_ceta check_event_trigger_auto
  231.   def check_event_trigger_auto
  232.     if $game_map && $game_map.events
  233.       for event in $game_map.events.values
  234.         next if self.is_stair_event? || @id == event.id
  235.         if @real_x / Game_Map::REAL_RES_X == event.x &&
  236.            @real_y / Game_Map::REAL_RES_Y == event.y
  237.           if event.is_stair_event?
  238.             self.slope(*event.get_stair_data)
  239.             return
  240.           end
  241.         end
  242.       end
  243.     end
  244.     return if on_stair? || $game_player.on_stair?
  245.     return stair_ceta
  246.   end
  247.  
  248.   alias stair_start start
  249.   def start
  250.     if is_stair_event?
  251.       $game_player.slope(*self.get_stair_data)
  252.     else
  253.       stair_start
  254.     end
  255.   end
  256.  
  257.   def is_stair_event?
  258.     return self.name == "Slope"
  259.   end
  260.  
  261.   def get_stair_data
  262.     return if !is_stair_event?
  263.     return if !@list
  264.     for cmd in @list
  265.       if cmd.code == 108
  266.         if cmd.parameters[0] =~ /Slope: (\d+)x(\d+)/
  267.           xincline, yincline = $1.to_i, $2.to_i
  268.         elsif cmd.parameters[0] =~ /Slope: -(\d+)x(\d+)/
  269.           xincline, yincline = -$1.to_i, $2.to_i
  270.         elsif cmd.parameters[0] =~ /Slope: (\d+)x-(\d+)/
  271.           xincline, yincline = $1.to_i, -$2.to_i
  272.         elsif cmd.parameters[0] =~ /Slope: -(\d+)x-(\d+)/
  273.           xincline, yincline = -$1.to_i, -$2.to_i
  274.         elsif cmd.parameters[0] =~ /Width: (\d+)\/(\d+)/
  275.           ypos, yheight = $1.to_i, $2.to_i
  276.         elsif cmd.parameters[0] =~ /Offset: (\d+)px/
  277.           offset = $1.to_i
  278.         end
  279.       end
  280.       if xincline && yincline && ypos && yheight && offset
  281.         return [xincline, yincline, ypos, yheight, offset]
  282.       end
  283.     end
  284.     return [xincline, yincline, ypos, yheight, 16]
  285.   end
  286. end
  287.  
  288. class Game_Player
  289.   alias stair_cetc check_event_trigger_touch
  290.   def check_event_trigger_touch(dir)
  291.     return if on_stair?
  292.     return stair_cetc(dir)
  293.   end
  294.  
  295.   alias stair_ceth check_event_trigger_here
  296.   def check_event_trigger_here(triggers)
  297.     return if on_stair?
  298.     return stair_ceth(triggers)
  299.   end
  300.  
  301.   alias stair_cett check_event_trigger_there
  302.   def check_event_trigger_there(triggers)
  303.     return if on_stair?
  304.     return stair_cett(triggers)
  305.   end
  306.  
  307.   def move_down(turn_enabled = true)
  308.     turn_down if turn_enabled
  309.     if passable?(@x, @y, 2)
  310.       return if pbLedge(0,1)
  311.       return if pbEndSurf(0,1)
  312.       turn_down
  313.       @y += 1
  314.       $PokemonTemp.dependentEvents.pbMoveDependentEvents
  315.       increase_steps
  316.       moving_vertically(1)
  317.     else
  318.       if !check_event_trigger_touch(@direction)
  319.         if !@bump_se || @bump_se<=0
  320.           pbSEPlay("Player bump"); @bump_se = 10
  321.         end
  322.       end
  323.     end
  324.   end
  325.  
  326.   def move_up(turn_enabled = true)
  327.     turn_up if turn_enabled
  328.     if passable?(@x, @y, 8)
  329.       return if pbLedge(0,-1)
  330.       return if pbEndSurf(0,-1)
  331.       turn_up
  332.       @y -= 1
  333.       $PokemonTemp.dependentEvents.pbMoveDependentEvents
  334.       increase_steps
  335.       moving_vertically(-1)
  336.     else
  337.       if !check_event_trigger_touch(@direction)
  338.         if !@bump_se || @bump_se<=0
  339.           pbSEPlay("Player bump"); @bump_se = 10
  340.         end
  341.       end
  342.     end
  343.   end
  344. end
  345.  
  346. class Game_Map
  347.   alias stair_passable? passable?
  348.   def passable?(x, y, d, self_event = nil)
  349.     return stair_passable?(x, y, d, self_event) if self_event.nil?
  350.     return stair_passable?(x, y, d, self_event) if !self_event.on_middle_of_stair?
  351.     if y > self_event.y
  352.       return self_event.stair_y_position > 0
  353.     elsif y < self_event.y
  354.       return self_event.stair_y_position + 1 < self_event.stair_y_height
  355.     end
  356.     return true
  357.   end
  358.  
  359.   alias stair_scroll_down scroll_down
  360.   def scroll_down(distance)
  361.     return if $DisableScrollCounter == 1
  362.     return stair_scroll_down(distance)
  363.   end
  364.  
  365.   alias stair_scroll_left scroll_left
  366.   def scroll_left(distance)
  367.     return if $DisableScrollCounter == 1
  368.     return stair_scroll_left(distance)
  369.   end
  370.  
  371.   alias stair_scroll_right scroll_right
  372.   def scroll_right(distance)
  373.     return if $DisableScrollCounter == 1
  374.     return stair_scroll_right(distance)
  375.   end
  376.  
  377.   alias stair_scroll_up scroll_up
  378.   def scroll_up(distance)
  379.     return if $DisableScrollCounter == 1
  380.     return stair_scroll_up(distance)
  381.   end
  382. end
  383.  
  384. class Game_Character
  385.   attr_accessor :stair_start_x
  386.   attr_accessor :stair_start_y
  387.   attr_accessor :stair_end_x
  388.   attr_accessor :stair_end_y
  389.   attr_accessor :stair_y_position
  390.   attr_accessor :stair_y_height
  391.   attr_accessor :stair_begin_offset
  392.  
  393.   def on_stair?
  394.     return @stair_begin_offset && @stair_start_x && @stair_start_y &&
  395.            @stair_end_x && @stair_end_y && @stair_y_position && @stair_y_height
  396.   end
  397.  
  398.   def on_middle_of_stair?
  399.     return false if !on_stair?
  400.     if @stair_start_x > @stair_end_x
  401.       return @real_x < (@stair_start_x * Game_Map::TILE_WIDTH - @stair_begin_offset) * Game_Map::X_SUBPIXELS &&
  402.           @real_x > (@stair_end_x * Game_Map::TILE_WIDTH + @stair_begin_offset) * Game_Map::X_SUBPIXELS
  403.     else
  404.       return @real_x > (@stair_start_x * Game_Map::TILE_WIDTH + @stair_begin_offset) * Game_Map::X_SUBPIXELS &&
  405.           @real_x < (@stair_end_x * Game_Map::TILE_WIDTH - @stair_begin_offset) * Game_Map::X_SUBPIXELS      
  406.     end
  407.   end
  408.  
  409.   def slope(x, y, ypos = 0, yheight = 1, begin_offset = 0)
  410.     @stair_start_x = self.is_a?(Game_Player) ? @x : (@real_x / Game_Map::REAL_RES_X).round
  411.     @stair_start_y = self.is_a?(Game_Player) ? @y : (@real_y / Game_Map::REAL_RES_Y).round
  412.     @stair_end_x = @stair_start_x + x
  413.     @stair_end_y = @stair_start_y + y
  414.     @stair_y_position = ypos
  415.     @stair_y_height = yheight
  416.     @stair_begin_offset = begin_offset
  417.     @stair_start_y += ypos
  418.     @stair_end_y += ypos
  419.   end
  420.  
  421.   def clear_stair_data
  422.     @stair_begin_offset = nil
  423.     @stair_start_x = nil
  424.     @stair_start_y = nil
  425.     @stair_end_x = nil
  426.     @stair_end_y = nil
  427.     @stair_y_position = nil
  428.     @stair_y_height = nil
  429.     @stair_last_increment = nil
  430.   end
  431.  
  432.   def move_down(turn_enabled = true)
  433.     turn_down if turn_enabled
  434.     if passable?(@x, @y, 2)
  435.       turn_down
  436.       @y += 1
  437.       increase_steps
  438.       moving_vertically(1)
  439.     else
  440.       check_event_trigger_touch(@direction)
  441.     end
  442.   end
  443.  
  444.   def move_up(turn_enabled = true)
  445.     turn_up if turn_enabled
  446.     if passable?(@x, @y, 8)
  447.       turn_up
  448.       @y -= 1
  449.       increase_steps
  450.       moving_vertically(-1)
  451.     else
  452.       check_event_trigger_touch(@direction)
  453.     end
  454.   end
  455.  
  456.   def moving_vertically(value)
  457.     if on_stair?
  458.       @stair_y_position -= value
  459.       if @stair_y_position >= @stair_y_height || @stair_y_position < 0
  460.         clear_stair_data
  461.       end
  462.     end
  463.   end
  464.  
  465.   alias stair_update update
  466.   def update
  467.     if self == $game_player && SMOOTH_SCROLLING && on_stair?
  468.       # Game_Player#update called; now disable Game_Map#scroll_*
  469.       $DisableScrollCounter = 2
  470.     end
  471.     stair_update
  472.     if on_middle_of_stair?
  473.       @old_move_speed ||= @move_speed
  474.       ptgrs = Math.sqrt((@stair_end_x - @stair_start_x) ** 2 + (@stair_end_y - @stair_start_y) ** 2)
  475.       fraction = (@stair_end_x - @stair_start_x).abs / ptgrs * 0.85
  476.       @move_speed = fraction * @old_move_speed
  477.     else
  478.       @move_speed = @old_move_speed if @old_move_speed
  479.       @old_move_speed = nil
  480.     end
  481.   end
  482.  
  483.   alias stair_update_pattern update_pattern
  484.   def update_pattern
  485.     if self == $game_player && $DisableScrollCounter == 2
  486.       $DisableScrollCounter = 1
  487.     end
  488.     stair_update_pattern
  489.   end
  490.  
  491.   alias stair_moving? moving?
  492.   def moving?
  493.     if self == $game_player && $DisableScrollCounter == 1
  494.       # New Game_Player#update scroll method
  495.       $DisableScrollCounter = 0
  496.       @view_offset_x ||= 0
  497.       @view_offset_y ||= 0
  498.       self.center(
  499.           (@real_x + @view_offset_x) / 4 / Game_Map::TILE_WIDTH,
  500.           (@real_y + @view_offset_y) / 4 / Game_Map::TILE_HEIGHT
  501.       )
  502.     end
  503.     return stair_moving?
  504.   end
  505.  
  506.   alias stair_screen_y screen_y
  507.   def screen_y
  508.     real_y = @real_y
  509.     if on_stair?
  510.       if @real_x / Game_Map::X_SUBPIXELS.to_f <= @stair_start_x * Game_Map::TILE_WIDTH &&
  511.          @stair_end_x < @stair_start_x
  512.         distance = (@stair_start_x - @stair_end_x) * Game_Map::REAL_RES_X -
  513.             2.0 * @stair_begin_offset * Game_Map::X_SUBPIXELS
  514.         rpos = @real_x - @stair_end_x * Game_Map::REAL_RES_X - @stair_begin_offset * Game_Map::X_SUBPIXELS
  515.         fraction = 1 - rpos / distance.to_f
  516.         if fraction >= 0 && fraction <= 1
  517.           diff = fraction * (@stair_end_y - @stair_start_y) * Game_Map::REAL_RES_Y
  518.           real_y += diff
  519.           if self.is_a?(Game_Player)
  520.             if SMOOTH_SCROLLING
  521.               @view_offset_y += diff - (@stair_last_increment || 0)
  522.             else
  523.               $game_map.scroll_down(diff - (@stair_last_increment || 0))
  524.             end
  525.           end
  526.           @stair_last_increment = diff
  527.         end
  528.         if fraction >= 1
  529.           endy = @stair_end_y
  530.           if @stair_end_y < @stair_start_y
  531.             endy -= @stair_y_position
  532.           else
  533.             endy -= @stair_y_position
  534.           end
  535.           @y = endy
  536.           @real_y = endy * Game_Map::REAL_RES_Y
  537.           @view_offset_y = 0 if SMOOTH_SCROLLING && self.is_a?(Game_Player)
  538.           clear_stair_data
  539.           return stair_screen_y
  540.         end
  541.       elsif @real_x / Game_Map::X_SUBPIXELS.to_f >= @stair_start_x * Game_Map::TILE_WIDTH &&
  542.           @stair_end_x > @stair_start_x
  543.         distance = (@stair_end_x - @stair_start_x) * Game_Map::REAL_RES_X -
  544.             2.0 * @stair_begin_offset * Game_Map::X_SUBPIXELS
  545.         rpos = @stair_start_x * Game_Map::REAL_RES_X - @real_x + @stair_begin_offset * Game_Map::X_SUBPIXELS
  546.         fraction = rpos / distance.to_f
  547.         if fraction <= 0 && fraction >= -1
  548.           diff = fraction * (@stair_start_y - @stair_end_y) * Game_Map::REAL_RES_Y
  549.           real_y += diff
  550.           if self.is_a?(Game_Player)
  551.             if SMOOTH_SCROLLING
  552.               @view_offset_y += diff - (@stair_last_increment || 0)
  553.             else
  554.               $game_map.scroll_down(diff - (@stair_last_increment || 0))
  555.             end
  556.           end
  557.           @stair_last_increment = diff
  558.         end
  559.         if fraction <= -1
  560.           endy = @stair_end_y
  561.           if @stair_end_y < @stair_start_y
  562.             endy -= @stair_y_position
  563.           else
  564.             endy -= @stair_y_position
  565.           end
  566.           @y = endy
  567.           @real_y = endy * Game_Map::REAL_RES_Y
  568.           @view_offset_y = 0 if SMOOTH_SCROLLING && self.is_a?(Game_Player)
  569.           clear_stair_data
  570.           return stair_screen_y
  571.         end
  572.       else
  573.         clear_stair_data
  574.       end
  575.     elsif jumping?
  576.       ret = screen_y_ground
  577.       if @jump_count > 0
  578.         jump_fraction = ((@jump_count * jump_speed_real / Game_Map::REAL_RES_X) - 0.5).abs   # 0.5 to 0 to 0.5
  579.       else
  580.         jump_fraction = ((@jump_distance_left / @jump_distance) - 0.5).abs   # 0.5 to 0 to 0.5
  581.       end
  582.       ret += @jump_peak * (4 * jump_fraction**2 - 1)
  583.     end
  584.     if jumping?
  585.         return ret
  586.     end
  587.     return (real_y - self.map.display_y + 3) / 4 + (Game_Map::TILE_HEIGHT)
  588.   end
  589. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement