More tweaks from the Rubocop overlord

This commit is contained in:
Maruno17
2021-12-19 17:28:59 +00:00
parent 33781493f4
commit 65b1a8d6c3
161 changed files with 2839 additions and 2967 deletions

View File

@@ -97,15 +97,15 @@ class Game_Screen
end
if @fadein_duration && @fadein_duration >= 1
d = @fadein_duration
@brightness = (@brightness * (d - 1) + 255) / d
@brightness = ((@brightness * (d - 1)) + 255) / d
@fadein_duration -= 1
end
if @tone_duration >= 1
d = @tone_duration
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
@tone.red = ((@tone.red * (d - 1)) + @tone_target.red) / d
@tone.green = ((@tone.green * (d - 1)) + @tone_target.green) / d
@tone.blue = ((@tone.blue * (d - 1)) + @tone_target.blue) / d
@tone.gray = ((@tone.gray * (d - 1)) + @tone_target.gray) / d
@tone_duration -= 1
end
if @flash_duration >= 1

View File

@@ -131,19 +131,19 @@ class Game_Picture
def update
if @duration >= 1
d = @duration
@x = (@x * (d - 1) + @target_x) / d
@y = (@y * (d - 1) + @target_y) / d
@zoom_x = (@zoom_x * (d - 1) + @target_zoom_x) / d
@zoom_y = (@zoom_y * (d - 1) + @target_zoom_y) / d
@opacity = (@opacity * (d - 1) + @target_opacity) / d
@x = ((@x * (d - 1)) + @target_x) / d
@y = ((@y * (d - 1)) + @target_y) / d
@zoom_x = ((@zoom_x * (d - 1)) + @target_zoom_x) / d
@zoom_y = ((@zoom_y * (d - 1)) + @target_zoom_y) / d
@opacity = ((@opacity * (d - 1)) + @target_opacity) / d
@duration -= 1
end
if @tone_duration >= 1
d = @tone_duration
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
@tone.red = ((@tone.red * (d - 1)) + @tone_target.red) / d
@tone.green = ((@tone.green * (d - 1)) + @tone_target.green) / d
@tone.blue = ((@tone.blue * (d - 1)) + @tone_target.blue) / d
@tone.gray = ((@tone.gray * (d - 1)) + @tone_target.gray) / d
@tone_duration -= 1
end
if @rotate_speed != 0

View File

@@ -147,7 +147,7 @@ class Game_Map
def passable?(x, y, d, self_event = nil)
return false if !valid?(x, y)
bit = (1 << (d / 2 - 1)) & 0x0f
bit = (1 << ((d / 2) - 1)) & 0x0f
for event in events.values
next if event.tile_id <= 0
next if event == self_event
@@ -224,7 +224,7 @@ class Game_Map
end
def playerPassable?(x, y, d, self_event = nil)
bit = (1 << (d / 2 - 1)) & 0x0f
bit = (1 << ((d / 2) - 1)) & 0x0f
for i in [2, 1, 0]
tile_id = data[x, y, i]
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
@@ -323,7 +323,7 @@ class Game_Map
return if @display_x == value
@display_x = value
if metadata&.snap_edges
max_x = (self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X
max_x = (self.width - (Graphics.width.to_f / TILE_WIDTH)) * REAL_RES_X
@display_x = [0, [@display_x, max_x].min].max
end
$map_factory.setMapsInRange if $map_factory
@@ -333,7 +333,7 @@ class Game_Map
return if @display_y == value
@display_y = value
if metadata&.snap_edges
max_y = (self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y
max_y = (self.height - (Graphics.height.to_f / TILE_HEIGHT)) * REAL_RES_Y
@display_y = [0, [@display_y, max_y].min].max
end
$map_factory.setMapsInRange if $map_factory
@@ -378,7 +378,7 @@ class Game_Map
end
def start_fog_opacity_change(opacity, duration)
@fog_opacity_target = opacity * 1.0
@fog_opacity_target = opacity.to_f
@fog_opacity_duration = duration
if @fog_opacity_duration == 0
@fog_opacity = @fog_opacity_target
@@ -437,15 +437,15 @@ class Game_Map
if @fog_tone_duration >= 1
d = @fog_tone_duration
target = @fog_tone_target
@fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
@fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
@fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
@fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
@fog_tone.red = ((@fog_tone.red * (d - 1)) + target.red) / d
@fog_tone.green = ((@fog_tone.green * (d - 1)) + target.green) / d
@fog_tone.blue = ((@fog_tone.blue * (d - 1)) + target.blue) / d
@fog_tone.gray = ((@fog_tone.gray * (d - 1)) + target.gray) / d
@fog_tone_duration -= 1
end
if @fog_opacity_duration >= 1
d = @fog_opacity_duration
@fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
@fog_opacity = ((@fog_opacity * (d - 1)) + @fog_opacity_target) / d
@fog_opacity_duration -= 1
end
end

View File

@@ -87,12 +87,12 @@ class Interpreter
print 'Map Autoscroll: invalid speed (1-6 only)'
return command_skip
end
center_x = (Graphics.width / 2 - Game_Map::TILE_WIDTH / 2) * 4 # X coordinate in the center of the screen
center_y = (Graphics.height / 2 - Game_Map::TILE_HEIGHT / 2) * 4 # Y coordinate in the center of the screen
max_x = ($game_map.width - Graphics.width * 1.0 / Game_Map::TILE_WIDTH) * 4 * Game_Map::TILE_WIDTH
max_y = ($game_map.height - Graphics.height * 1.0 / Game_Map::TILE_HEIGHT) * 4 * Game_Map::TILE_HEIGHT
count_x = ($game_map.display_x - [0, [x * Game_Map::REAL_RES_X - center_x, max_x].min].max) / Game_Map::REAL_RES_X
count_y = ($game_map.display_y - [0, [y * Game_Map::REAL_RES_Y - center_y, max_y].min].max) / Game_Map::REAL_RES_Y
center_x = ((Graphics.width / 2) - (Game_Map::TILE_WIDTH / 2)) * 4 # X coordinate in the center of the screen
center_y = ((Graphics.height / 2) - (Game_Map::TILE_HEIGHT / 2)) * 4 # Y coordinate in the center of the screen
max_x = ($game_map.width - (Graphics.width.to_f / Game_Map::TILE_WIDTH)) * 4 * Game_Map::TILE_WIDTH
max_y = ($game_map.height - (Graphics.height.to_f / Game_Map::TILE_HEIGHT)) * 4 * Game_Map::TILE_HEIGHT
count_x = ($game_map.display_x - [0, [(x * Game_Map::REAL_RES_X) - center_x, max_x].min].max) / Game_Map::REAL_RES_X
count_y = ($game_map.display_y - [0, [(y * Game_Map::REAL_RES_Y) - center_y, max_y].min].max) / Game_Map::REAL_RES_Y
if !@diag
@diag = true
dir = nil
@@ -148,20 +148,20 @@ end
class Game_Map
def scroll_downright(distance)
@display_x = [@display_x + distance,
(self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X].min
(self.width - (Graphics.width.to_f / TILE_WIDTH)) * REAL_RES_X].min
@display_y = [@display_y + distance,
(self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y].min
(self.height - (Graphics.height.to_f / TILE_HEIGHT)) * REAL_RES_Y].min
end
def scroll_downleft(distance)
@display_x = [@display_x - distance, 0].max
@display_y = [@display_y + distance,
(self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y].min
(self.height - (Graphics.height.to_f / TILE_HEIGHT)) * REAL_RES_Y].min
end
def scroll_upright(distance)
@display_x = [@display_x + distance,
(self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X].min
(self.width - (Graphics.width.to_f / TILE_WIDTH)) * REAL_RES_X].min
@display_y = [@display_y - distance, 0].max
end

View File

@@ -122,8 +122,8 @@ class PokemonMapFactory
for conn in conns[id]
if conn[0] == id
mapA = getMap(conn[0])
newdispx = (conn[4] - conn[1]) * Game_Map::REAL_RES_X + mapA.display_x
newdispy = (conn[5] - conn[2]) * Game_Map::REAL_RES_Y + mapA.display_y
newdispx = ((conn[4] - conn[1]) * Game_Map::REAL_RES_X) + mapA.display_x
newdispy = ((conn[5] - conn[2]) * Game_Map::REAL_RES_Y) + mapA.display_y
if hasMap?(conn[3]) || MapFactoryHelper.mapInRangeById?(conn[3], newdispx, newdispy)
mapB = getMap(conn[3])
mapB.display_x = newdispx if mapB.display_x != newdispx
@@ -131,8 +131,8 @@ class PokemonMapFactory
end
else
mapA = getMap(conn[3])
newdispx = (conn[1] - conn[4]) * Game_Map::REAL_RES_X + mapA.display_x
newdispy = (conn[2] - conn[5]) * Game_Map::REAL_RES_Y + mapA.display_y
newdispx = ((conn[1] - conn[4]) * Game_Map::REAL_RES_X) + mapA.display_x
newdispy = ((conn[2] - conn[5]) * Game_Map::REAL_RES_Y) + mapA.display_y
if hasMap?(conn[0]) || MapFactoryHelper.mapInRangeById?(conn[0], newdispx, newdispy)
mapB = getMap(conn[0])
mapB.display_x = newdispx if mapB.display_x != newdispx
@@ -204,8 +204,8 @@ class PokemonMapFactory
if !($DEBUG && Input.press?(Input::CTRL))
return false if !map.passableStrict?(x, y, 0, thisEvent)
end
else
return false if !map.passableStrict?(x, y, 0, thisEvent)
elsif !map.passableStrict?(x, y, 0, thisEvent)
return false
end
for event in map.events.values
next if event == thisEvent || !event.at_coordinate?(x, y)
@@ -488,8 +488,8 @@ module MapFactoryHelper
dispy = map.display_y
return false if dispx >= (map.width + range) * Game_Map::REAL_RES_X
return false if dispy >= (map.height + range) * Game_Map::REAL_RES_Y
return false if dispx <= -(Graphics.width + range * Game_Map::TILE_WIDTH) * Game_Map::X_SUBPIXELS
return false if dispy <= -(Graphics.height + range * Game_Map::TILE_HEIGHT) * Game_Map::Y_SUBPIXELS
return false if dispx <= -(Graphics.width + (range * Game_Map::TILE_WIDTH)) * Game_Map::X_SUBPIXELS
return false if dispy <= -(Graphics.height + (range * Game_Map::TILE_HEIGHT)) * Game_Map::Y_SUBPIXELS
return true
end
@@ -498,8 +498,8 @@ module MapFactoryHelper
dims = MapFactoryHelper.getMapDims(id)
return false if dispx >= (dims[0] + range) * Game_Map::REAL_RES_X
return false if dispy >= (dims[1] + range) * Game_Map::REAL_RES_Y
return false if dispx <= -(Graphics.width + range * Game_Map::TILE_WIDTH) * Game_Map::X_SUBPIXELS
return false if dispy <= -(Graphics.height + range * Game_Map::TILE_HEIGHT) * Game_Map::Y_SUBPIXELS
return false if dispx <= -(Graphics.width + (range * Game_Map::TILE_WIDTH)) * Game_Map::X_SUBPIXELS
return false if dispy <= -(Graphics.height + (range * Game_Map::TILE_HEIGHT)) * Game_Map::Y_SUBPIXELS
return true
end
end

View File

@@ -142,7 +142,7 @@ class Game_Character
# 4 => 64 # 1.6 seconds
# 5 => 30 # 0.75 seconds
# 6 => 0 # 0 seconds, i.e. continuous movement
self.move_frequency_real = (40 - val * 2) * (6 - val)
self.move_frequency_real = (40 - (val * 2)) * (6 - val)
end
def move_frequency_real
@@ -318,7 +318,7 @@ class Game_Character
else
jump_fraction = ((@jump_distance_left / @jump_distance) - 0.5).abs # 0.5 to 0 to 0.5
end
ret += @jump_peak * (4 * jump_fraction**2 - 1)
ret += @jump_peak * ((4 * (jump_fraction**2)) - 1)
end
return ret
end
@@ -328,7 +328,7 @@ class Game_Character
z = screen_y_ground
if @tile_id > 0
begin
return z + self.map.priorities[@tile_id] * 32
return z + (self.map.priorities[@tile_id] * 32)
rescue
raise "Event's graphic is an out-of-range tile (event #{@id}, map #{self.map.map_id})"
end
@@ -405,8 +405,8 @@ class Game_Character
end
def move_type_toward_player
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 2.0)
sy = @y - @height / 2.0 - ($game_player.y - $game_player.height / 2.0)
sx = @x + (@width / 2.0) - ($game_player.x + ($game_player.width / 2.0))
sy = @y - (@height / 2.0) - ($game_player.y - ($game_player.height / 2.0))
if sx.abs + sy.abs >= 20
move_random
return
@@ -662,8 +662,8 @@ class Game_Character
end
def move_toward_player
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 2.0)
sy = @y - @height / 2.0 - ($game_player.y - $game_player.height / 2.0)
sx = @x + (@width / 2.0) - ($game_player.x + ($game_player.width / 2.0))
sy = @y - (@height / 2.0) - ($game_player.y - ($game_player.height / 2.0))
return if sx == 0 && sy == 0
abs_sx = sx.abs
abs_sy = sy.abs
@@ -684,8 +684,8 @@ class Game_Character
end
def move_away_from_player
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 2.0)
sy = @y - @height / 2.0 - ($game_player.y - $game_player.height / 2.0)
sx = @x + (@width / 2.0) - ($game_player.x + ($game_player.width / 2.0))
sy = @y - (@height / 2.0) - ($game_player.y - ($game_player.height / 2.0))
return if sx == 0 && sy == 0
abs_sx = sx.abs
abs_sy = sy.abs
@@ -737,7 +737,7 @@ class Game_Character
end
@x = @x + x_plus
@y = @y + y_plus
real_distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus)
real_distance = Math.sqrt((x_plus * x_plus) + (y_plus * y_plus))
distance = [1, real_distance].max
@jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping
@jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max
@@ -824,8 +824,8 @@ class Game_Character
end
def turn_toward_player
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 2.0)
sy = @y - @height / 2.0 - ($game_player.y - $game_player.height / 2.0)
sx = @x + (@width / 2.0) - ($game_player.x + ($game_player.width / 2.0))
sy = @y - (@height / 2.0) - ($game_player.y - ($game_player.height / 2.0))
return if sx == 0 && sy == 0
if sx.abs > sy.abs
(sx > 0) ? turn_left : turn_right
@@ -835,8 +835,8 @@ class Game_Character
end
def turn_away_from_player
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 2.0)
sy = @y - @height / 2.0 - ($game_player.y - $game_player.height / 2.0)
sx = @x + (@width / 2.0) - ($game_player.x + ($game_player.width / 2.0))
sy = @y - (@height / 2.0) - ($game_player.y - ($game_player.height / 2.0))
return if sx == 0 && sy == 0
if sx.abs > sy.abs
(sx > 0) ? turn_right : turn_left

View File

@@ -110,7 +110,7 @@ class Game_Event < Game_Character
return false if !ontime
now = pbGetTimeNow
elapsed = (now.to_i - ontime) / 86400
elapsed += 1 if (now.to_i - ontime) % 86400 > (now.hour * 3600 + now.min * 60 + now.sec)
elapsed += 1 if (now.to_i - ontime) % 86400 > ((now.hour * 3600) + (now.min * 60) + now.sec)
return elapsed >= days
end
@@ -249,9 +249,9 @@ class Game_Event < Game_Character
return true if @move_route_forcing
return true if @event.name[/update/i]
range = 2 # Number of tiles
return false if self.screen_x - @sprite_size[0] / 2 > Graphics.width + range * Game_Map::TILE_WIDTH
return false if self.screen_x + @sprite_size[0] / 2 < -range * Game_Map::TILE_WIDTH
return false if self.screen_y_ground - @sprite_size[1] > Graphics.height + range * Game_Map::TILE_HEIGHT
return false if self.screen_x - (@sprite_size[0] / 2) > Graphics.width + (range * Game_Map::TILE_WIDTH)
return false if self.screen_x + (@sprite_size[0] / 2) < -range * Game_Map::TILE_WIDTH
return false if self.screen_y_ground - @sprite_size[1] > Graphics.height + (range * Game_Map::TILE_HEIGHT)
return false if self.screen_y_ground < -range * Game_Map::TILE_HEIGHT
return true
end

View File

@@ -10,8 +10,8 @@ class Game_Player < Game_Character
attr_accessor :charsetData
attr_accessor :encounter_count
SCREEN_CENTER_X = (Settings::SCREEN_WIDTH / 2 - Game_Map::TILE_WIDTH / 2) * Game_Map::X_SUBPIXELS
SCREEN_CENTER_Y = (Settings::SCREEN_HEIGHT / 2 - Game_Map::TILE_HEIGHT / 2) * Game_Map::Y_SUBPIXELS
SCREEN_CENTER_X = ((Settings::SCREEN_WIDTH / 2) - (Game_Map::TILE_WIDTH / 2)) * Game_Map::X_SUBPIXELS
SCREEN_CENTER_Y = ((Settings::SCREEN_HEIGHT / 2) - (Game_Map::TILE_HEIGHT / 2)) * Game_Map::Y_SUBPIXELS
@@bobFrameSpeed = 1.0 / 15
@@ -157,7 +157,7 @@ class Game_Player < Game_Character
end
@x = @x + x_plus
@y = @y + y_plus
real_distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus)
real_distance = Math.sqrt((x_plus * x_plus) + (y_plus * y_plus))
distance = [1, real_distance].max
@jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping
@jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max
@@ -287,8 +287,8 @@ class Game_Player < Game_Character
# * Set Map Display Position to Center of Screen
#-----------------------------------------------------------------------------
def center(x, y)
self.map.display_x = x * Game_Map::REAL_RES_X - SCREEN_CENTER_X
self.map.display_y = y * Game_Map::REAL_RES_Y - SCREEN_CENTER_Y
self.map.display_x = (x * Game_Map::REAL_RES_X) - SCREEN_CENTER_X
self.map.display_y = (y * Game_Map::REAL_RES_Y) - SCREEN_CENTER_Y
end
#-----------------------------------------------------------------------------

View File

@@ -164,7 +164,7 @@ class Game_Follower < Game_Event
return false if !this_map || !this_map.valid?(x, y)
return true if @through
passed_tile_checks = false
bit = (1 << (direction / 2 - 1)) & 0x0f
bit = (1 << ((direction / 2) - 1)) & 0x0f
# Check all events for ones using tiles as graphics, and see if they're passable
for event in this_map.events.values
next if event.tile_id < 0 || event.through || !event.at_coordinate?(x, y)