mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 06:04:59 +00:00
Yet more Rubocopping
This commit is contained in:
@@ -50,14 +50,14 @@ module RPG
|
||||
end
|
||||
|
||||
def dispose
|
||||
@sprites.each { |sprite| sprite.dispose if sprite }
|
||||
@new_sprites.each { |sprite| sprite.dispose if sprite }
|
||||
@tiles.each { |sprite| sprite.dispose if sprite }
|
||||
@sprites.each { |sprite| sprite&.dispose }
|
||||
@new_sprites.each { |sprite| sprite&.dispose }
|
||||
@tiles.each { |sprite| sprite&.dispose }
|
||||
@viewport.dispose
|
||||
@weatherTypes.each_value do |weather|
|
||||
next if !weather
|
||||
weather[1].each { |bitmap| bitmap.dispose if bitmap }
|
||||
weather[2].each { |bitmap| bitmap.dispose if bitmap }
|
||||
weather[1].each { |bitmap| bitmap&.dispose }
|
||||
weather[2].each { |bitmap| bitmap&.dispose }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -83,7 +83,7 @@ module RPG
|
||||
@time_shift += 1 # No previous tiles to fade out first
|
||||
end
|
||||
@fading = true
|
||||
@new_sprites.each { |sprite| sprite.dispose if sprite }
|
||||
@new_sprites.each { |sprite| sprite&.dispose }
|
||||
@new_sprites.clear
|
||||
ensureSprites
|
||||
@new_sprites.each_with_index { |sprite, i| set_sprite_bitmap(sprite, i, @target_type) }
|
||||
@@ -456,25 +456,24 @@ module RPG
|
||||
@new_sprites.each_with_index { |sprite, i| sprite.visible = (i < @new_max) if sprite }
|
||||
end
|
||||
# End fading
|
||||
if @fade_time >= ((@target_type == :None) ? FADE_OLD_PARTICLES_END : FADE_NEW_TILES_END) - @time_shift
|
||||
if !@sprites.any? { |sprite| sprite.visible }
|
||||
@type = @target_type
|
||||
@max = @target_max
|
||||
@target_type = nil
|
||||
@target_max = nil
|
||||
@old_max = nil
|
||||
@new_max = nil
|
||||
@old_tone = nil
|
||||
@target_tone = nil
|
||||
@fade_time = 0.0
|
||||
@time_shift = 0
|
||||
@sprites.each { |sprite| sprite.dispose if sprite }
|
||||
@sprites = @new_sprites
|
||||
@new_sprites = []
|
||||
@sprite_lifetimes = @new_sprite_lifetimes
|
||||
@new_sprite_lifetimes = []
|
||||
@fading = false
|
||||
end
|
||||
if @fade_time >= ((@target_type == :None) ? FADE_OLD_PARTICLES_END : FADE_NEW_TILES_END) - @time_shift &&
|
||||
!@sprites.any? { |sprite| sprite.visible }
|
||||
@type = @target_type
|
||||
@max = @target_max
|
||||
@target_type = nil
|
||||
@target_max = nil
|
||||
@old_max = nil
|
||||
@new_max = nil
|
||||
@old_tone = nil
|
||||
@target_tone = nil
|
||||
@fade_time = 0.0
|
||||
@time_shift = 0
|
||||
@sprites.each { |sprite| sprite&.dispose }
|
||||
@sprites = @new_sprites
|
||||
@new_sprites = []
|
||||
@sprite_lifetimes = @new_sprite_lifetimes
|
||||
@new_sprite_lifetimes = []
|
||||
@fading = false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -501,7 +500,7 @@ module RPG
|
||||
update_sprite_position(@sprites[i], i, false)
|
||||
end
|
||||
elsif @sprites.length > 0
|
||||
@sprites.each { |sprite| sprite.dispose if sprite }
|
||||
@sprites.each { |sprite| sprite&.dispose }
|
||||
@sprites.clear
|
||||
end
|
||||
# Update new weather particles (while fading in only)
|
||||
@@ -511,7 +510,7 @@ module RPG
|
||||
update_sprite_position(@new_sprites[i], i, true)
|
||||
end
|
||||
elsif @new_sprites.length > 0
|
||||
@new_sprites.each { |sprite| sprite.dispose if sprite }
|
||||
@new_sprites.each { |sprite| sprite&.dispose }
|
||||
@new_sprites.clear
|
||||
end
|
||||
# Update weather tiles (sandstorm/blizzard tiled overlay)
|
||||
@@ -520,7 +519,7 @@ module RPG
|
||||
recalculate_tile_positions
|
||||
@tiles.each_with_index { |sprite, i| update_tile_position(sprite, i) }
|
||||
elsif @tiles.length > 0
|
||||
@tiles.each { |sprite| sprite.dispose if sprite }
|
||||
@tiles.each { |sprite| sprite&.dispose }
|
||||
@tiles.clear
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,23 +47,18 @@ def pbBatteryLow?
|
||||
end
|
||||
|
||||
Events.onMapUpdate += proc { |_sender, _e|
|
||||
if !$game_temp.warned_low_battery && pbBatteryLow?
|
||||
if !$game_temp.in_menu && !$game_temp.in_battle &&
|
||||
!$game_player.move_route_forcing && !$game_temp.message_window_showing &&
|
||||
!pbMapInterpreterRunning?
|
||||
if pbGetTimeNow.sec == 0
|
||||
pbMessage(_INTL("The game has detected that the battery is low. You should save soon to avoid losing your progress."))
|
||||
$game_temp.warned_low_battery = true
|
||||
end
|
||||
end
|
||||
if !$game_temp.warned_low_battery && pbBatteryLow? &&
|
||||
!$game_temp.in_menu && !$game_temp.in_battle && !$game_player.move_route_forcing &&
|
||||
!$game_temp.message_window_showing && !pbMapInterpreterRunning? &&
|
||||
pbGetTimeNow.sec == 0
|
||||
pbMessage(_INTL("The game has detected that the battery is low. You should save soon to avoid losing your progress."))
|
||||
$game_temp.warned_low_battery = true
|
||||
end
|
||||
if $game_temp.cue_bgm_frame_delay
|
||||
$game_temp.cue_bgm_frame_delay -= 1
|
||||
if $game_temp.cue_bgm_frame_delay <= 0
|
||||
$game_temp.cue_bgm_frame_delay = nil
|
||||
if $game_system.getPlayingBGM == nil
|
||||
pbBGMPlay($game_temp.cue_bgm)
|
||||
end
|
||||
pbBGMPlay($game_temp.cue_bgm) if $game_system.getPlayingBGM.nil?
|
||||
end
|
||||
end
|
||||
}
|
||||
@@ -133,7 +128,7 @@ Events.onStepTakenFieldMovement += proc { |_sender, e|
|
||||
map = $map_factory.getMap(thistile[0])
|
||||
[2, 1, 0].each do |i|
|
||||
tile_id = map.data[thistile[1], thistile[2], i]
|
||||
next if tile_id == nil
|
||||
next if tile_id.nil?
|
||||
next if GameData::TerrainTag.try_get(map.terrain_tags[tile_id]).id != :SootGrass
|
||||
if event == $game_player && $bag.has?(:SOOTSACK)
|
||||
old_soot = $player.soot
|
||||
@@ -229,7 +224,7 @@ Events.onMapChanging += proc { |_sender, e|
|
||||
map_infos = pbLoadMapInfos
|
||||
if $game_map.name == map_infos[new_map_ID].name
|
||||
new_map_metadata = GameData::MapMetadata.try_get(new_map_ID)
|
||||
next if new_map_metadata && new_map_metadata.weather
|
||||
next if new_map_metadata&.weather
|
||||
end
|
||||
$game_screen.weather(:None, 0, 0)
|
||||
}
|
||||
@@ -238,18 +233,18 @@ Events.onMapChanging += proc { |_sender, e|
|
||||
Events.onMapChange += proc { |_sender, e|
|
||||
old_map_ID = e[0] # previous map ID, is 0 if no map ID
|
||||
new_map_metadata = $game_map.metadata
|
||||
if new_map_metadata && new_map_metadata.teleport_destination
|
||||
if new_map_metadata&.teleport_destination
|
||||
$PokemonGlobal.healingSpot = new_map_metadata.teleport_destination
|
||||
end
|
||||
$PokemonMap.clear if $PokemonMap
|
||||
$PokemonEncounters.setup($game_map.map_id) if $PokemonEncounters
|
||||
$PokemonMap&.clear
|
||||
$PokemonEncounters&.setup($game_map.map_id)
|
||||
$PokemonGlobal.visitedMaps[$game_map.map_id] = true
|
||||
next if old_map_ID == 0 || old_map_ID == $game_map.map_id
|
||||
next if !new_map_metadata || !new_map_metadata.weather
|
||||
map_infos = pbLoadMapInfos
|
||||
if $game_map.name == map_infos[old_map_ID].name
|
||||
old_map_metadata = GameData::MapMetadata.try_get(old_map_ID)
|
||||
next if old_map_metadata && old_map_metadata.weather
|
||||
next if old_map_metadata&.weather
|
||||
end
|
||||
new_weather = new_map_metadata.weather
|
||||
$game_screen.weather(new_weather[0], 9, 0) if rand(100) < new_weather[1]
|
||||
@@ -262,14 +257,14 @@ Events.onMapSceneChange += proc { |_sender, e|
|
||||
# Update map trail
|
||||
if $game_map
|
||||
$PokemonGlobal.mapTrail = [] if !$PokemonGlobal.mapTrail
|
||||
if $PokemonGlobal.mapTrail[0] != $game_map.map_id
|
||||
$PokemonGlobal.mapTrail.pop if $PokemonGlobal.mapTrail.length >= 4
|
||||
if $PokemonGlobal.mapTrail[0] != $game_map.map_id && $PokemonGlobal.mapTrail.length >= 4
|
||||
$PokemonGlobal.mapTrail.pop
|
||||
end
|
||||
$PokemonGlobal.mapTrail = [$game_map.map_id] + $PokemonGlobal.mapTrail
|
||||
end
|
||||
# Display darkness circle on dark maps
|
||||
map_metadata = $game_map.metadata
|
||||
if map_metadata && map_metadata.dark_map
|
||||
if map_metadata&.dark_map
|
||||
$game_temp.darkness_sprite = DarknessSprite.new
|
||||
scene.spriteset.addUserSprite($game_temp.darkness_sprite)
|
||||
if $PokemonGlobal.flashUsed
|
||||
@@ -277,7 +272,7 @@ Events.onMapSceneChange += proc { |_sender, e|
|
||||
end
|
||||
else
|
||||
$PokemonGlobal.flashUsed = false
|
||||
$game_temp.darkness_sprite.dispose if $game_temp.darkness_sprite
|
||||
$game_temp.darkness_sprite&.dispose
|
||||
$game_temp.darkness_sprite = nil
|
||||
end
|
||||
# Show location signpost
|
||||
@@ -298,7 +293,7 @@ Events.onMapSceneChange += proc { |_sender, e|
|
||||
scene.spriteset.addUserSprite(LocationWindow.new($game_map.name)) if !nosignpost
|
||||
end
|
||||
# Force cycling/walking
|
||||
if map_metadata && map_metadata.always_bicycle
|
||||
if map_metadata&.always_bicycle
|
||||
pbMountBike
|
||||
elsif !pbCanUseBike?($game_map.map_id)
|
||||
pbDismountBike
|
||||
@@ -517,9 +512,7 @@ def pbMoveRoute(event, commands, waitComplete = false)
|
||||
end
|
||||
route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOff))
|
||||
route.list.push(RPG::MoveCommand.new(0))
|
||||
if event
|
||||
event.force_move_route(route)
|
||||
end
|
||||
event&.force_move_route(route)
|
||||
return route
|
||||
end
|
||||
|
||||
@@ -610,7 +603,7 @@ def pbMoveTowardPlayer(event)
|
||||
pbUpdateSceneMap
|
||||
end
|
||||
end
|
||||
$PokemonMap.addMovedEvent(event.id) if $PokemonMap
|
||||
$PokemonMap&.addMovedEvent(event.id)
|
||||
end
|
||||
|
||||
def pbJumpToward(dist = 1, playSound = false, cancelSurf = false)
|
||||
|
||||
@@ -573,11 +573,9 @@ def pbAfterBattle(decision, canLose)
|
||||
pkmn.makeUnprimal
|
||||
end
|
||||
end
|
||||
if [2, 5].include?(decision) # if loss or draw
|
||||
if canLose
|
||||
$player.party.each { |pkmn| pkmn.heal }
|
||||
(Graphics.frame_rate / 4).times { Graphics.update }
|
||||
end
|
||||
if [2, 5].include?(decision) && canLose # if loss or draw
|
||||
$player.party.each { |pkmn| pkmn.heal }
|
||||
(Graphics.frame_rate / 4).times { Graphics.update }
|
||||
end
|
||||
Events.onEndBattle.trigger(nil, decision, canLose)
|
||||
$game_player.straighten
|
||||
|
||||
@@ -32,11 +32,11 @@ end
|
||||
# Battle intro animation
|
||||
#===============================================================================
|
||||
def pbSceneStandby
|
||||
$scene.disposeSpritesets if $scene && $scene.is_a?(Scene_Map)
|
||||
$scene.disposeSpritesets if $scene.is_a?(Scene_Map)
|
||||
RPG::Cache.clear
|
||||
Graphics.frame_reset
|
||||
yield
|
||||
$scene.createSpritesets if $scene && $scene.is_a?(Scene_Map)
|
||||
$scene.createSpritesets if $scene.is_a?(Scene_Map)
|
||||
end
|
||||
|
||||
def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
|
||||
@@ -46,7 +46,7 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
|
||||
# Set up audio
|
||||
playingBGS = nil
|
||||
playingBGM = nil
|
||||
if $game_system && $game_system.is_a?(Game_System)
|
||||
if $game_system.is_a?(Game_System)
|
||||
playingBGS = $game_system.getPlayingBGS
|
||||
playingBGM = $game_system.getPlayingBGM
|
||||
$game_system.bgm_pause
|
||||
@@ -120,7 +120,7 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
|
||||
end
|
||||
end
|
||||
# Take screenshot of game, for use in some animations
|
||||
$game_temp.background_bitmap.dispose if $game_temp.background_bitmap
|
||||
$game_temp.background_bitmap&.dispose
|
||||
$game_temp.background_bitmap = Graphics.snap_to_bitmap
|
||||
# Play main animation
|
||||
Graphics.freeze
|
||||
@@ -138,7 +138,7 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
|
||||
yield if block_given?
|
||||
# After the battle
|
||||
pbPopFade
|
||||
if $game_system && $game_system.is_a?(Game_System)
|
||||
if $game_system.is_a?(Game_System)
|
||||
$game_system.bgm_resume(playingBGM)
|
||||
$game_system.bgs_resume(playingBGS)
|
||||
end
|
||||
|
||||
@@ -281,25 +281,21 @@ class PokemonEncounters
|
||||
favored_type = nil
|
||||
case first_pkmn.ability_id
|
||||
when :FLASHFIRE
|
||||
if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS
|
||||
favored_type = :FIRE if GameData::Type.exists?(:FIRE) && rand(100) < 50
|
||||
end
|
||||
favored_type = :FIRE if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS &&
|
||||
GameData::Type.exists?(:FIRE) && rand(100) < 50
|
||||
when :HARVEST
|
||||
if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS
|
||||
favored_type = :GRASS if GameData::Type.exists?(:GRASS) && rand(100) < 50
|
||||
end
|
||||
favored_type = :GRASS if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS &&
|
||||
GameData::Type.exists?(:GRASS) && rand(100) < 50
|
||||
when :LIGHTNINGROD
|
||||
if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS
|
||||
favored_type = :ELECTRIC if GameData::Type.exists?(:ELECTRIC) && rand(100) < 50
|
||||
end
|
||||
favored_type = :ELECTRIC if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS &&
|
||||
GameData::Type.exists?(:ELECTRIC) && rand(100) < 50
|
||||
when :MAGNETPULL
|
||||
favored_type = :STEEL if GameData::Type.exists?(:STEEL) && rand(100) < 50
|
||||
when :STATIC
|
||||
favored_type = :ELECTRIC if GameData::Type.exists?(:ELECTRIC) && rand(100) < 50
|
||||
when :STORMDRAIN
|
||||
if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS
|
||||
favored_type = :WATER if GameData::Type.exists?(:WATER) && rand(100) < 50
|
||||
end
|
||||
favored_type = :WATER if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS &&
|
||||
GameData::Type.exists?(:WATER) && rand(100) < 50
|
||||
end
|
||||
if favored_type
|
||||
new_enc_list = []
|
||||
@@ -433,7 +429,7 @@ def pbGenerateWildPokemon(species, level, isRoamer = false)
|
||||
end
|
||||
end
|
||||
# Give Pokérus
|
||||
genwildpoke.givePokerus if rand(65536) < Settings::POKERUS_CHANCE
|
||||
genwildpoke.givePokerus if rand(65_536) < Settings::POKERUS_CHANCE
|
||||
# Change wild Pokémon's gender/nature depending on the lead party Pokémon's
|
||||
# ability
|
||||
if first_pkmn
|
||||
|
||||
@@ -156,7 +156,7 @@ class PokemonMapMetadata
|
||||
@erasedEvents.each do |i|
|
||||
if i[0][0] == $game_map.map_id && i[1]
|
||||
event = $game_map.events[i[0][1]]
|
||||
event.erase if event
|
||||
event&.erase
|
||||
end
|
||||
end
|
||||
@movedEvents.each do |i|
|
||||
|
||||
@@ -149,9 +149,9 @@ def moonphase(time = nil) # in UTC
|
||||
]
|
||||
yy = time.year - ((12 - time.mon) / 10.0).floor
|
||||
j = (365.25 * (4712 + yy)).floor + ((((time.mon + 9) % 12) * 30.6) + 0.5).floor + time.day + 59
|
||||
j -= (((yy / 100.0) + 49).floor * 0.75).floor - 38 if j > 2299160
|
||||
j += (((time.hour * 60) + (time.min * 60)) + time.sec) / 86400.0
|
||||
v = (j - 2451550.1) / 29.530588853
|
||||
j -= (((yy / 100.0) + 49).floor * 0.75).floor - 38 if j > 2_299_160
|
||||
j += (((time.hour * 60) + (time.min * 60)) + time.sec) / 86_400.0
|
||||
v = (j - 2_451_550.1) / 29.530588853
|
||||
v = ((v - v.floor) + (v < 0 ? 1 : 0))
|
||||
ag = v * 29.53
|
||||
transitions.length.times do |i|
|
||||
|
||||
@@ -245,7 +245,7 @@ def pbSmashEvent(event)
|
||||
PBMoveRoute::Wait, 2])
|
||||
pbWait(Graphics.frame_rate * 4 / 10)
|
||||
event.erase
|
||||
$PokemonMap.addErasedEvent(event.id) if $PokemonMap
|
||||
$PokemonMap&.addErasedEvent(event.id)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ class BerryPlantData
|
||||
end
|
||||
end
|
||||
else
|
||||
old_growth_stage = (done_replant) ? 0 : old_growth_stage
|
||||
old_growth_stage = 0 if done_replant
|
||||
new_growth_stage = [@growth_stage, stages_growing + 1].min
|
||||
@watered_this_stage = false if new_growth_stage > old_growth_stage
|
||||
water if $game_screen && GameData::Weather.get($game_screen.weather_type).category == :Rain
|
||||
@@ -268,8 +268,8 @@ class BerryPlantSprite
|
||||
if berry_plant.new_mechanics && @old_stage != berry_plant.growth_stage &&
|
||||
@old_stage > 0 && berry_plant.growth_stage <= GameData::BerryPlant::NUMBER_OF_GROWTH_STAGES + 1
|
||||
spriteset = $scene.spriteset(@map.map_id)
|
||||
spriteset.addUserAnimation(Settings::PLANT_SPARKLE_ANIMATION_ID,
|
||||
@event.x, @event.y, false, 1) if spriteset
|
||||
spriteset&.addUserAnimation(Settings::PLANT_SPARKLE_ANIMATION_ID,
|
||||
@event.x, @event.y, false, 1)
|
||||
end
|
||||
end
|
||||
@old_stage = berry_plant.growth_stage
|
||||
|
||||
@@ -119,11 +119,10 @@ class DayCare
|
||||
end
|
||||
end
|
||||
# Learn Volt Tackle if a parent has a Light Ball and is in the Pichu family
|
||||
if egg.species == :PICHU && GameData::Move.exists?(:VOLTTACKLE)
|
||||
if (father[2] && father[0].hasItem?(:LIGHTBALL)) ||
|
||||
(mother[2] && mother[0].hasItem?(:LIGHTBALL))
|
||||
moves.push(:VOLTTACKLE)
|
||||
end
|
||||
if egg.species == :PICHU && GameData::Move.exists?(:VOLTTACKLE) &&
|
||||
((father[2] && father[0].hasItem?(:LIGHTBALL)) ||
|
||||
(mother[2] && mother[0].hasItem?(:LIGHTBALL)))
|
||||
moves.push(:VOLTTACKLE)
|
||||
end
|
||||
return moves
|
||||
end
|
||||
@@ -249,7 +248,7 @@ class DayCare
|
||||
end
|
||||
|
||||
def set_pokerus(egg)
|
||||
egg.givePokerus if rand(65536) < Settings::POKERUS_CHANCE
|
||||
egg.givePokerus if rand(65_536) < Settings::POKERUS_CHANCE
|
||||
end
|
||||
end
|
||||
|
||||
@@ -370,11 +369,11 @@ class DayCare
|
||||
pkmn2.moves.each { |m| known_moves2.push(m.id) if egg_moves1.include?(m.id) && !pkmn1.hasMove?(m.id) }
|
||||
end
|
||||
if !known_moves1.empty?
|
||||
if !known_moves2.empty?
|
||||
if known_moves2.empty?
|
||||
pkmn2.learn_move(known_moves1[0])
|
||||
else
|
||||
learner = [[pkmn1, known_moves2[0]], [pkmn2, known_moves1[0]]].sample
|
||||
learner[0].learn_move(learner[1])
|
||||
else
|
||||
pkmn2.learn_move(known_moves1[0])
|
||||
end
|
||||
elsif !known_moves2.empty?
|
||||
pkmn1.learn_move(known_moves2[0])
|
||||
|
||||
@@ -412,11 +412,9 @@ module RandomDungeonGenerator
|
||||
when EdgeMasks::WEST
|
||||
cx -= 1
|
||||
end
|
||||
if cx >= 0 && cy >= 0 && cx < cellWidth && cy < cellHeight
|
||||
if !getVisited(cx, cy)
|
||||
clearEdgeNode(x, y, d)
|
||||
recurseDepthFirst(cx, cy, depth + 1)
|
||||
end
|
||||
if cx >= 0 && cy >= 0 && cx < cellWidth && cy < cellHeight && !getVisited(cx, cy)
|
||||
clearEdgeNode(x, y, d)
|
||||
recurseDepthFirst(cx, cy, depth + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user