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

@@ -245,8 +245,8 @@ module RPG
return
end
if @weatherTypes[weather_type][0].category == :Rain && index.odd? # Splash
sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + sprite.bitmap.width * 2)
sprite.y = @oy - sprite.bitmap.height + rand(Graphics.height + sprite.bitmap.height * 2)
sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + (sprite.bitmap.width * 2))
sprite.y = @oy - sprite.bitmap.height + rand(Graphics.height + (sprite.bitmap.height * 2))
lifetimes[index] = (rand(30...50)) * 0.01 # 0.3-0.5 seconds
else
x_speed = @weatherTypes[weather_type][0].particle_delta_x
@@ -255,14 +255,14 @@ module RPG
if gradient.abs >= 1
# Position sprite to the right of the screen
sprite.x = @ox + Graphics.width + rand(Graphics.width)
sprite.y = @oy + Graphics.height - rand(Graphics.height + sprite.bitmap.height - Graphics.width / gradient)
distance_to_cover = sprite.x - @ox - Graphics.width / 2 + sprite.bitmap.width + rand(Graphics.width * 8 / 5)
sprite.y = @oy + Graphics.height - rand(Graphics.height + sprite.bitmap.height - (Graphics.width / gradient))
distance_to_cover = sprite.x - @ox - (Graphics.width / 2) + sprite.bitmap.width + rand(Graphics.width * 8 / 5)
lifetimes[index] = (distance_to_cover.to_f / x_speed).abs
else
# Position sprite to the top of the screen
sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + sprite.bitmap.width - gradient * Graphics.height)
sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + sprite.bitmap.width - (gradient * Graphics.height))
sprite.y = @oy - sprite.bitmap.height - rand(Graphics.height)
distance_to_cover = @oy - sprite.y + Graphics.height / 2 + rand(Graphics.height * 8 / 5)
distance_to_cover = @oy - sprite.y + (Graphics.height / 2) + rand(Graphics.height * 8 / 5)
lifetimes[index] = (distance_to_cover.to_f / y_speed).abs
end
end
@@ -333,8 +333,8 @@ module RPG
def update_tile_position(sprite, index)
return if !sprite || !sprite.bitmap || !sprite.visible
sprite.x = @tile_x.round + (index % @tiles_wide) * sprite.bitmap.width
sprite.y = @tile_y.round + (index / @tiles_wide) * sprite.bitmap.height
sprite.x = @tile_x.round + ((index % @tiles_wide) * sprite.bitmap.width)
sprite.y = @tile_y.round + ((index / @tiles_wide) * sprite.bitmap.height)
sprite.x += @tiles_wide * sprite.bitmap.width if sprite.x - @ox < -sprite.bitmap.width
sprite.y -= @tiles_tall * sprite.bitmap.height if sprite.y - @oy > Graphics.height
sprite.visible = true
@@ -372,10 +372,10 @@ module RPG
@fade_time < [FADE_NEW_TONE_END - @time_shift, 0].max
weather_max = @target_max
fract = (@fade_time - [FADE_NEW_TONE_START - @time_shift, 0].max) / (FADE_NEW_TONE_END - FADE_NEW_TONE_START)
tone_red = @target_tone.red + (1 - fract) * (@old_tone.red - @target_tone.red)
tone_green = @target_tone.green + (1 - fract) * (@old_tone.green - @target_tone.green)
tone_blue = @target_tone.blue + (1 - fract) * (@old_tone.blue - @target_tone.blue)
tone_gray = @target_tone.gray + (1 - fract) * (@old_tone.gray - @target_tone.gray)
tone_red = @target_tone.red + ((1 - fract) * (@old_tone.red - @target_tone.red))
tone_green = @target_tone.green + ((1 - fract) * (@old_tone.green - @target_tone.green))
tone_blue = @target_tone.blue + ((1 - fract) * (@old_tone.blue - @target_tone.blue))
tone_gray = @target_tone.gray + ((1 - fract) * (@old_tone.gray - @target_tone.gray))
else
tone_red = @viewport.tone.red
tone_green = @viewport.tone.green

View File

@@ -153,12 +153,12 @@ class LightEffect_Basic < LightEffect
super
if (Object.const_defined?(:ScreenPosHelper) rescue false)
@light.x = ScreenPosHelper.pbScreenX(@event)
@light.y = ScreenPosHelper.pbScreenY(@event) - Game_Map::TILE_HEIGHT / 2
@light.y = ScreenPosHelper.pbScreenY(@event) - (Game_Map::TILE_HEIGHT / 2)
@light.zoom_x = ScreenPosHelper.pbScreenZoomX(@event)
@light.zoom_y = @light.zoom_x
else
@light.x = @event.screen_x
@light.y = @event.screen_y - Game_Map::TILE_HEIGHT / 2
@light.y = @event.screen_y - (Game_Map::TILE_HEIGHT / 2)
end
@light.tone = $game_screen.tone
end
@@ -188,12 +188,12 @@ class LightEffect_DayNight < LightEffect
if @light.opacity > 0
if (Object.const_defined?(:ScreenPosHelper) rescue false)
@light.x = ScreenPosHelper.pbScreenX(@event)
@light.y = ScreenPosHelper.pbScreenY(@event) - Game_Map::TILE_HEIGHT / 2
@light.y = ScreenPosHelper.pbScreenY(@event) - (Game_Map::TILE_HEIGHT / 2)
@light.zoom_x = ScreenPosHelper.pbScreenZoomX(@event)
@light.zoom_y = ScreenPosHelper.pbScreenZoomY(@event)
else
@light.x = @event.screen_x
@light.y = @event.screen_y - Game_Map::TILE_HEIGHT / 2
@light.y = @event.screen_y - (Game_Map::TILE_HEIGHT / 2)
end
@light.tone.set($game_screen.tone.red,
$game_screen.tone.green,

View File

@@ -286,8 +286,8 @@ Events.onMapSceneChange += proc { |_sender, e|
if $PokemonGlobal.mapTrail[1]
for i in 0...Settings::NO_SIGNPOSTS.length / 2
nosignpost = true if Settings::NO_SIGNPOSTS[2 * i] == $PokemonGlobal.mapTrail[1] &&
Settings::NO_SIGNPOSTS[2 * i + 1] == $game_map.map_id
nosignpost = true if Settings::NO_SIGNPOSTS[2 * i + 1] == $PokemonGlobal.mapTrail[1] &&
Settings::NO_SIGNPOSTS[(2 * i) + 1] == $game_map.map_id
nosignpost = true if Settings::NO_SIGNPOSTS[(2 * i) + 1] == $PokemonGlobal.mapTrail[1] &&
Settings::NO_SIGNPOSTS[2 * i] == $game_map.map_id
break if nosignpost
end
@@ -378,7 +378,7 @@ def pbEventCanReachPlayer?(event, player, distance)
end
if real_distance > 0
real_distance.times do |i|
return false if !event.can_move_from_coordinate?(event.x + i * delta_x, event.y + i * delta_y, event.direction)
return false if !event.can_move_from_coordinate?(event.x + (i * delta_x), event.y + (i * delta_y), event.direction)
end
end
return true

View File

@@ -182,8 +182,8 @@ def pbGetEnvironment
tile_environment = terrainTag.battle_environment
if ret == :Forest && [:Grass, :TallGrass].include?(tile_environment)
ret = :ForestGrass
else
ret = tile_environment if tile_environment
elsif tile_environment
ret = tile_environment
end
return ret
end
@@ -383,13 +383,14 @@ def pbTrainerBattleCore(*args)
foeParty = []
foePartyStarts = []
for arg in args
if arg.is_a?(NPCTrainer)
case arg
when NPCTrainer
foeTrainers.push(arg)
foePartyStarts.push(foeParty.length)
arg.party.each { |pkmn| foeParty.push(pkmn) }
foeEndSpeeches.push(arg.lose_text)
foeItems.push(arg.items)
elsif arg.is_a?(Array) # [trainer type, trainer name, ID, speech (optional)]
when Array # [trainer type, trainer name, ID, speech (optional)]
trainer = pbLoadTrainer(arg[0], arg[1], arg[2])
pbMissingTrainer(arg[0], arg[1], arg[2]) if !trainer
return 0 if !trainer
@@ -530,8 +531,8 @@ def pbDoubleTrainerBattle(trainerID1, trainerName1, trainerPartyID1, endSpeech1,
setBattleRule("double")
# Perform the battle
decision = pbTrainerBattleCore(
[trainerID1, trainerName1, trainerPartyID1, endSpeech1],
[trainerID2, trainerName2, trainerPartyID2, endSpeech2]
[trainerID1, trainerName1, trainerPartyID1, endSpeech1],
[trainerID2, trainerName2, trainerPartyID2, endSpeech2]
)
# Return true if the player won the battle, and false if any other result
return (decision == 1)
@@ -547,9 +548,9 @@ def pbTripleTrainerBattle(trainerID1, trainerName1, trainerPartyID1, endSpeech1,
setBattleRule("triple")
# Perform the battle
decision = pbTrainerBattleCore(
[trainerID1, trainerName1, trainerPartyID1, endSpeech1],
[trainerID2, trainerName2, trainerPartyID2, endSpeech2],
[trainerID3, trainerName3, trainerPartyID3, endSpeech3]
[trainerID1, trainerName1, trainerPartyID1, endSpeech1],
[trainerID2, trainerName2, trainerPartyID2, endSpeech2],
[trainerID3, trainerName3, trainerPartyID3, endSpeech3]
)
# Return true if the player won the battle, and false if any other result
return (decision == 1)
@@ -644,38 +645,38 @@ def pbPickup(pkmn)
return unless rand(100) < 10 # 10% chance
# Common items to find (9 items from this list are added to the pool)
pickupList = pbDynamicItemList(
:POTION,
:ANTIDOTE,
:SUPERPOTION,
:GREATBALL,
:REPEL,
:ESCAPEROPE,
:FULLHEAL,
:HYPERPOTION,
:ULTRABALL,
:REVIVE,
:RARECANDY,
:SUNSTONE,
:MOONSTONE,
:HEARTSCALE,
:FULLRESTORE,
:MAXREVIVE,
:PPUP,
:MAXELIXIR
:POTION,
:ANTIDOTE,
:SUPERPOTION,
:GREATBALL,
:REPEL,
:ESCAPEROPE,
:FULLHEAL,
:HYPERPOTION,
:ULTRABALL,
:REVIVE,
:RARECANDY,
:SUNSTONE,
:MOONSTONE,
:HEARTSCALE,
:FULLRESTORE,
:MAXREVIVE,
:PPUP,
:MAXELIXIR
)
# Rare items to find (2 items from this list are added to the pool)
pickupListRare = pbDynamicItemList(
:HYPERPOTION,
:NUGGET,
:KINGSROCK,
:FULLRESTORE,
:ETHER,
:IRONBALL,
:DESTINYKNOT,
:ELIXIR,
:DESTINYKNOT,
:LEFTOVERS,
:DESTINYKNOT
:HYPERPOTION,
:NUGGET,
:KINGSROCK,
:FULLRESTORE,
:ETHER,
:IRONBALL,
:DESTINYKNOT,
:ELIXIR,
:DESTINYKNOT,
:LEFTOVERS,
:DESTINYKNOT
)
return if pickupList.length < 18
return if pickupListRare.length < 11
@@ -709,7 +710,7 @@ end
def pbHoneyGather(pkmn)
return if !GameData::Item.exists?(:HONEY)
return if pkmn.egg? || !pkmn.hasAbility?(:HONEYGATHER) || pkmn.hasItem?
chance = 5 + ((pkmn.level - 1) / 10) * 5
chance = 5 + (((pkmn.level - 1) / 10) * 5)
return unless rand(100) < chance
pkmn.item = :HONEY
end

View File

@@ -155,7 +155,7 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
Input.update
pbUpdateSceneMap
timer += Graphics.delta_s
viewport.color.alpha = 255 * (1 - timer / 0.4)
viewport.color.alpha = 255 * (1 - (timer / 0.4))
break if viewport.color.alpha <= 0
end
viewport.dispose
@@ -267,9 +267,9 @@ SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
flash.opacity -= 52 * 20 / Graphics.frame_rate if flash.opacity > 0
bar1.ox -= 32 * 20 / Graphics.frame_rate
bar2.ox += 32 * 20 / Graphics.frame_rate
if i >= animTime / 2 && i < slideInTime + animTime / 2
player.x = xoffset * (i + 1 - slideInTime - animTime / 2) / slideInTime
trainer.x = xoffset * (slideInTime - i - 1 + animTime / 2) / slideInTime
if i >= animTime / 2 && i < slideInTime + (animTime / 2)
player.x = xoffset * (i + 1 - slideInTime - (animTime / 2)) / slideInTime
trainer.x = xoffset * (slideInTime - i - 1 + (animTime / 2)) / slideInTime
end
pbWait(1)
end
@@ -283,10 +283,10 @@ SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
trainer.tone = Tone.new(0, 0, 0)
trainername = foe[0].name
textpos = [
[$player.name, Graphics.width / 4, (Graphics.height / 1.5) + 4, 2,
Color.new(248, 248, 248), Color.new(72, 72, 72)],
[trainername, (Graphics.width / 4) + (Graphics.width / 2), (Graphics.height / 1.5) + 4, 2,
Color.new(248, 248, 248), Color.new(72, 72, 72)]
[$player.name, Graphics.width / 4, (Graphics.height / 1.5) + 4, 2,
Color.new(248, 248, 248), Color.new(72, 72, 72)],
[trainername, (Graphics.width / 4) + (Graphics.width / 2), (Graphics.height / 1.5) + 4, 2,
Color.new(248, 248, 248), Color.new(72, 72, 72)]
]
pbDrawTextPositions(overlay.bitmap, textpos)
# Fade out flash, shudder Vs logo and expand it, and then fade to black

View File

@@ -114,7 +114,7 @@ class PokemonEncounters
return true if pbPokeRadarOnShakingGrass
# Get base encounter chance and minimum steps grace period
encounter_chance = @step_chances[enc_type].to_f
min_steps_needed = (8 - encounter_chance / 10).clamp(0, 8).to_f
min_steps_needed = (8 - (encounter_chance / 10)).clamp(0, 8).to_f
# Apply modifiers to the encounter chance and the minimum steps amount
if triggered_by_step
encounter_chance += @chance_accumulator / 200
@@ -168,7 +168,7 @@ class PokemonEncounters
# after a previous wild encounter
if triggered_by_step && @step_count < min_steps_needed
@step_count += 1
return false if rand(100) >= encounter_chance * 5 / (@step_chances[enc_type] + @chance_accumulator / 200)
return false if rand(100) >= encounter_chance * 5 / (@step_chances[enc_type] + (@chance_accumulator / 200))
end
# Decide whether the wild encounter should actually happen
return true if rand(100) < encounter_chance
@@ -429,7 +429,7 @@ def pbGenerateWildPokemon(species, level, isRoamer = false)
shiny_retries.times do
break if genwildpoke.shiny?
genwildpoke.shiny = nil # Make it recalculate shininess
genwildpoke.personalID = rand(2**16) | rand(2**16) << 16
genwildpoke.personalID = rand(2**16) | (rand(2**16) << 16)
end
end
# Give Pokérus

View File

@@ -138,19 +138,19 @@ end
def moonphase(time = nil) # in UTC
time = pbGetTimeNow if !time
transitions = [
1.8456618033125,
5.5369854099375,
9.2283090165625,
12.9196326231875,
16.6109562298125,
20.3022798364375,
23.9936034430625,
27.6849270496875
1.8456618033125,
5.5369854099375,
9.2283090165625,
12.9196326231875,
16.6109562298125,
20.3022798364375,
23.9936034430625,
27.6849270496875
]
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 = (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
j += (((time.hour * 60) + (time.min * 60)) + time.sec) / 86400.0
v = (j - 2451550.1) / 29.530588853
v = ((v - v.floor) + (v < 0 ? 1 : 0))
ag = v * 29.53
@@ -164,22 +164,22 @@ end
# 0 is Aries, 11 is Pisces. Month is 1 if January, and so on.
def zodiac(month, day)
time = [
3, 21, 4, 19, # Aries
4, 20, 5, 20, # Taurus
5, 21, 6, 20, # Gemini
6, 21, 7, 20, # Cancer
7, 23, 8, 22, # Leo
8, 23, 9, 22, # Virgo
9, 23, 10, 22, # Libra
10, 23, 11, 21, # Scorpio
11, 22, 12, 21, # Sagittarius
12, 22, 1, 19, # Capricorn
1, 20, 2, 18, # Aquarius
2, 19, 3, 20 # Pisces
3, 21, 4, 19, # Aries
4, 20, 5, 20, # Taurus
5, 21, 6, 20, # Gemini
6, 21, 7, 20, # Cancer
7, 23, 8, 22, # Leo
8, 23, 9, 22, # Virgo
9, 23, 10, 22, # Libra
10, 23, 11, 21, # Scorpio
11, 22, 12, 21, # Sagittarius
12, 22, 1, 19, # Capricorn
1, 20, 2, 18, # Aquarius
2, 19, 3, 20 # Pisces
]
for i in 0...12
return i if month == time[i * 4] && day >= time[i * 4 + 1]
return i if month == time[i * 4 + 2] && day <= time[i * 4 + 3]
return i if month == time[i * 4] && day >= time[(i * 4) + 1]
return i if month == time[(i * 4) + 2] && day <= time[(i * 4) + 3]
end
return 0
end
@@ -212,13 +212,13 @@ def pbIsWeekday(wdayVariable, *arg)
end
if wdayVariable > 0
$game_variables[wdayVariable] = [
_INTL("Sunday"),
_INTL("Monday"),
_INTL("Tuesday"),
_INTL("Wednesday"),
_INTL("Thursday"),
_INTL("Friday"),
_INTL("Saturday")
_INTL("Sunday"),
_INTL("Monday"),
_INTL("Tuesday"),
_INTL("Wednesday"),
_INTL("Thursday"),
_INTL("Friday"),
_INTL("Saturday")
][wday]
$game_map.need_refresh = true if $game_map
end
@@ -258,8 +258,7 @@ def pbGetMonthName(month)
end
def pbGetAbbrevMonthName(month)
return ["",
_INTL("Jan."),
return [_INTL("Jan."),
_INTL("Feb."),
_INTL("Mar."),
_INTL("Apr."),
@@ -270,7 +269,7 @@ def pbGetAbbrevMonthName(month)
_INTL("Sep."),
_INTL("Oct."),
_INTL("Nov."),
_INTL("Dec.")][month]
_INTL("Dec.")][month - 1]
end
#===============================================================================
@@ -287,12 +286,10 @@ def pbIsSeason(seasonVariable, *arg)
ret = true if wd == thisseason
end
if seasonVariable > 0
$game_variables[seasonVariable] = [
_INTL("Spring"),
_INTL("Summer"),
_INTL("Autumn"),
_INTL("Winter")
][thisseason]
$game_variables[seasonVariable] = [_INTL("Spring"),
_INTL("Summer"),
_INTL("Autumn"),
_INTL("Winter")][thisseason]
$game_map.need_refresh = true if $game_map
end
return ret

View File

@@ -89,9 +89,9 @@ def pbHiddenMoveAnimation(pokemon)
end
strobebitmap.dispose
interp = RectInterpolator.new(
Rect.new(0, Graphics.height / 2, Graphics.width, 0),
Rect.new(0, (Graphics.height - bg.bitmap.height) / 2, Graphics.width, bg.bitmap.height),
Graphics.frame_rate / 4
Rect.new(0, Graphics.height / 2, Graphics.width, 0),
Rect.new(0, (Graphics.height - bg.bitmap.height) / 2, Graphics.width, bg.bitmap.height),
Graphics.frame_rate / 4
)
ptinterp = nil
phase = 1
@@ -109,9 +109,9 @@ def pbHiddenMoveAnimation(pokemon)
if interp.done?
phase = 2
ptinterp = PointInterpolator.new(
Graphics.width + (sprite.bitmap.width / 2), bg.bitmap.height / 2,
Graphics.width / 2, bg.bitmap.height / 2,
Graphics.frame_rate * 4 / 10
Graphics.width + (sprite.bitmap.width / 2), bg.bitmap.height / 2,
Graphics.width / 2, bg.bitmap.height / 2,
Graphics.frame_rate * 4 / 10
)
end
when 2 # Slide Pokémon sprite in from right to centre
@@ -129,9 +129,9 @@ def pbHiddenMoveAnimation(pokemon)
if frames > Graphics.frame_rate * 3 / 4
phase = 4
ptinterp = PointInterpolator.new(
Graphics.width / 2, bg.bitmap.height / 2,
-(sprite.bitmap.width / 2), bg.bitmap.height / 2,
Graphics.frame_rate * 4 / 10
Graphics.width / 2, bg.bitmap.height / 2,
-(sprite.bitmap.width / 2), bg.bitmap.height / 2,
Graphics.frame_rate * 4 / 10
)
frames = 0
end
@@ -143,9 +143,9 @@ def pbHiddenMoveAnimation(pokemon)
phase = 5
sprite.visible = false
interp = RectInterpolator.new(
Rect.new(0, (Graphics.height - bg.bitmap.height) / 2, Graphics.width, bg.bitmap.height),
Rect.new(0, Graphics.height / 2, Graphics.width, 0),
Graphics.frame_rate / 4
Rect.new(0, (Graphics.height - bg.bitmap.height) / 2, Graphics.width, bg.bitmap.height),
Rect.new(0, Graphics.height / 2, Graphics.width, 0),
Graphics.frame_rate / 4
)
end
when 5 # Shrink viewport height from full to zero
@@ -159,15 +159,15 @@ def pbHiddenMoveAnimation(pokemon)
strobe.ox = strobe.viewport.rect.x
strobe.oy = strobe.viewport.rect.y
if !strobe.visible # Initial placement of strobes
randomY = 16 * (1 + rand(bg.bitmap.height / 16 - 2))
strobe.y = randomY + (Graphics.height - bg.bitmap.height) / 2
randomY = 16 * (1 + rand((bg.bitmap.height / 16) - 2))
strobe.y = randomY + ((Graphics.height - bg.bitmap.height) / 2)
strobe.x = rand(Graphics.width)
strobe.visible = true
elsif strobe.x < Graphics.width # Move strobe right
strobe.x += strobeSpeed
else # Strobe is off the screen, reposition it to the left of the screen
randomY = 16 * (1 + rand(bg.bitmap.height / 16 - 2))
strobe.y = randomY + (Graphics.height - bg.bitmap.height) / 2
randomY = 16 * (1 + rand((bg.bitmap.height / 16) - 2))
strobe.y = randomY + ((Graphics.height - bg.bitmap.height) / 2)
strobe.x = -strobe.bitmap.width - rand(Graphics.width / 4)
end
end
@@ -236,15 +236,13 @@ def pbSmashEvent(event)
elsif event.name[/smashrock/i]
pbSEPlay("Rock Smash", 80)
end
pbMoveRoute(event, [
PBMoveRoute::Wait, 2,
PBMoveRoute::TurnLeft,
PBMoveRoute::Wait, 2,
PBMoveRoute::TurnRight,
PBMoveRoute::Wait, 2,
PBMoveRoute::TurnUp,
PBMoveRoute::Wait, 2
])
pbMoveRoute(event, [PBMoveRoute::Wait, 2,
PBMoveRoute::TurnLeft,
PBMoveRoute::Wait, 2,
PBMoveRoute::TurnRight,
PBMoveRoute::Wait, 2,
PBMoveRoute::TurnUp,
PBMoveRoute::Wait, 2])
pbWait(Graphics.frame_rate * 4 / 10)
event.erase
$PokemonMap.addErasedEvent(event.id) if $PokemonMap
@@ -397,8 +395,8 @@ Events.onAction += proc { |_sender, _e|
$map_factory.getTerrainTag(surface_map_id, $game_player.x, $game_player.y).can_dive
pbSurfacing
end
else
pbDive if $game_player.terrain_tag.can_dive
elsif $game_player.terrain_tag.can_dive
pbDive
end
}

View File

@@ -84,15 +84,12 @@ class BerryPlantData
data = GameData::BerryPlant.get(@berry_id)
if @new_mechanics
return [data.maximum_yield * (5 - @yield_penalty) / 5, data.minimum_yield].max
else
if @watering_count > 0
ret = (data.maximum_yield - data.minimum_yield) * (@watering_count - 1)
ret += rand(1 + data.maximum_yield - data.minimum_yield)
return (ret / 4) + data.minimum_yield
else
return data.minimum_yield
end
elsif @watering_count > 0
ret = (data.maximum_yield - data.minimum_yield) * (@watering_count - 1)
ret += rand(1 + data.maximum_yield - data.minimum_yield)
return (ret / 4) + data.minimum_yield
end
return data.minimum_yield
end
# Old mechanics only update a plant when its map is loaded. New mechanics
@@ -138,7 +135,7 @@ class BerryPlantData
# Update how long plant has been alive for
old_growth_stage = @growth_stage
@time_alive = new_time_alive
@growth_stage = 1 + @time_alive / time_per_stage
@growth_stage = 1 + (@time_alive / time_per_stage)
@growth_stage += 1 if replanted? # Replants start at stage 2
@time_last_updated = time_now.to_i
# Record watering (old mechanics), and apply drying out per hour (new mechanics)

View File

@@ -244,7 +244,7 @@ class DayCare
shiny_retries.times do
break if egg.shiny?
egg.shiny = nil # Make it recalculate shininess
egg.personalID = rand(2**16) | rand(2**16) << 16
egg.personalID = rand(2**16) | (rand(2**16) << 16)
end
end

View File

@@ -118,7 +118,7 @@ module RandomDungeonGenerator
def paint_corridor(tile, x, y, width, height)
for j in 0...height
for i in 0...width
tile[(y + j) * CELL_WIDTH + (x + i)] = DungeonTile::CORRIDOR
tile[((y + j) * CELL_WIDTH) + (x + i)] = DungeonTile::CORRIDOR
end
end
end
@@ -129,25 +129,25 @@ module RandomDungeonGenerator
when TURN_NONE
for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH
dungeon[x + dstX, y + dstY] = tile_layout[y * CELL_WIDTH + x]
dungeon[x + dstX, y + dstY] = tile_layout[(y * CELL_WIDTH) + x]
end
end
when TURN_LEFT
for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH
dungeon[y + dstX, CELL_WIDTH - 1 - x + dstY] = tile_layout[y * CELL_WIDTH + x]
dungeon[y + dstX, CELL_WIDTH - 1 - x + dstY] = tile_layout[(y * CELL_WIDTH) + x]
end
end
when TURN_RIGHT
for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH
dungeon[CELL_HEIGHT - 1 - y + dstX, x + dstY] = tile_layout[y * CELL_WIDTH + x]
dungeon[CELL_HEIGHT - 1 - y + dstX, x + dstY] = tile_layout[(y * CELL_WIDTH) + x]
end
end
when TURN_BACK
for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH
dungeon[CELL_WIDTH - 1 - x + dstX, CELL_HEIGHT - 1 - y + dstY] = tile_layout[y * CELL_WIDTH + x]
dungeon[CELL_WIDTH - 1 - x + dstX, CELL_HEIGHT - 1 - y + dstY] = tile_layout[(y * CELL_WIDTH) + x]
end
end
end
@@ -164,8 +164,8 @@ module RandomDungeonGenerator
width = rand(ROOM_MIN_WIDTH..ROOM_MAX_WIDTH)
height = rand(ROOM_MIN_HEIGHT..ROOM_MAX_HEIGHT)
return false if width <= 0 || height <= 0
centerX = CELL_WIDTH / 2 + rand(5) - 2
centerY = CELL_HEIGHT / 2 + rand(5) - 2
centerX = (CELL_WIDTH / 2) + rand(5) - 2
centerY = (CELL_HEIGHT / 2) + rand(5) - 2
x = centerX - (width / 2)
y = centerY - (height / 2)
rect = [x, y, width, height]
@@ -244,17 +244,17 @@ module RandomDungeonGenerator
def getVisited(x, y)
return false if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight
return (@cells[y * cellWidth + x] & EdgeMasks::VISITED) != 0
return (@cells[(y * cellWidth) + x] & EdgeMasks::VISITED) != 0
end
def setVisited(x, y)
return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight
@cells[y * cellWidth + x] |= EdgeMasks::VISITED
@cells[(y * cellWidth) + x] |= EdgeMasks::VISITED
end
def clearVisited(x, y)
return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight
@cells[y * cellWidth + x] &= ~EdgeMasks::VISITED
@cells[(y * cellWidth) + x] &= ~EdgeMasks::VISITED
end
def clearAllCells
@@ -265,12 +265,12 @@ module RandomDungeonGenerator
def getEdgeNode(x, y, edge)
return false if x < 0 || y < 0 || x >= nodeWidth || y >= nodeHeight
return @nodes[y * nodeWidth + x].getEdge(edge)
return @nodes[(y * nodeWidth) + x].getEdge(edge)
end
def setEdgeNode(x, y, edge)
return if x < 0 || x >= nodeWidth || y < 0 || y >= nodeHeight
@nodes[y * nodeWidth + x].setEdge(edge)
@nodes[(y * nodeWidth) + x].setEdge(edge)
e = 0
nx = x
ny = y
@@ -291,7 +291,7 @@ module RandomDungeonGenerator
return
end
return if nx < 0 || ny < 0 || nx >= nodeWidth || ny >= nodeHeight
@nodes[ny * nodeWidth + nx].setEdge(e)
@nodes[(ny * nodeWidth) + nx].setEdge(e)
end
def setAllEdges
@@ -302,7 +302,7 @@ module RandomDungeonGenerator
def clearEdgeNode(x, y, edge)
return if x < 0 || x >= nodeWidth || y < 0 || y >= nodeHeight
@nodes[y * nodeWidth + x].clearEdge(edge)
@nodes[(y * nodeWidth) + x].clearEdge(edge)
e = 0
nx = x
ny = y
@@ -323,7 +323,7 @@ module RandomDungeonGenerator
raise ArgumentError.new
end
return if nx < 0 || ny < 0 || nx >= nodeWidth || ny >= nodeHeight
@nodes[ny * nodeWidth + nx].clearEdge(e)
@nodes[(ny * nodeWidth) + nx].clearEdge(e)
end
def clearAllEdges
@@ -334,7 +334,7 @@ module RandomDungeonGenerator
def isBlockedNode?(x, y)
return false if x < 0 || y < 0 || x >= nodeWidth || y >= nodeHeight
return @nodes[y * nodeWidth + x].isBlocked?
return @nodes[(y * nodeWidth) + x].isBlocked?
end
def getEdgePattern(x, y)
@@ -483,22 +483,22 @@ module RandomDungeonGenerator
end
def [](x, y)
return @array[y * @width + x]
return @array[(y * @width) + x]
end
def []=(x, y, value)
@array[y * @width + x] = value
@array[(y * @width) + x] = value
end
def value(x, y)
return DungeonTile::VOID if x < 0 || y < 0 || x >= @width || y >= @height
return @array[y * @width + x]
return @array[(y * @width) + x]
end
# Unused
def get(x, y)
return false if x < 0 || y < 0 || x >= @width || y >= @height
return @array[y * @width + x] != DungeonTile::VOID
return @array[(y * @width) + x] != DungeonTile::VOID
end
# Unused
@@ -553,8 +553,8 @@ module RandomDungeonGenerator
def generate
self.clear
maxWidth = @width - BUFFER_X * 2
maxHeight = @height - BUFFER_Y * 2
maxWidth = @width - (BUFFER_X * 2)
maxHeight = @height - (BUFFER_Y * 2)
cellWidth = DungeonMaze::CELL_WIDTH
cellHeight = DungeonMaze::CELL_HEIGHT
return if maxWidth < 0 || maxHeight < 0
@@ -576,7 +576,7 @@ module RandomDungeonGenerator
for x in 0...maxWidth / cellWidth
pattern = maze.getEdgePattern(x, y)
next if !DungeonMaze.paint_cell_contents(
self, BUFFER_X + x * cellWidth, BUFFER_Y + y * cellHeight,
self, BUFFER_X + (x * cellWidth), BUFFER_Y + (y * cellHeight),
corridor_patterns[pattern], DungeonMaze::TURN_NONE
)
roomcount += 1
@@ -605,7 +605,7 @@ module RandomDungeonGenerator
for j in 0...map.height
nb = TileDrawingHelper.tableNeighbors(tbl, i, j)
tile = TileDrawingHelper::NEIGHBORS_TO_AUTOTILE_INDEX[nb]
map.data[i, j, 0] = tile + 48 * (tbl[i, j])
map.data[i, j, 0] = tile + (48 * (tbl[i, j]))
map.data[i, j, 1] = 0
map.data[i, j, 2] = 0
end
@@ -638,8 +638,8 @@ module RandomDungeonGenerator
# @param x_cells [Integer] the number of cells wide the dungeon will be
# @param y_cells [Intenger] the number of cells tall the dungeon will be
def self.generate_test_dungeon(x_cells = 4, y_cells = 4)
dungeon = Dungeon.new(Dungeon::BUFFER_X * 2 + DungeonMaze::CELL_WIDTH * x_cells,
Dungeon::BUFFER_Y * 2 + DungeonMaze::CELL_HEIGHT * y_cells)
dungeon = Dungeon.new((Dungeon::BUFFER_X * 2) + (DungeonMaze::CELL_WIDTH * x_cells),
(Dungeon::BUFFER_Y * 2) + (DungeonMaze::CELL_HEIGHT * y_cells))
dungeon.generate
echoln dungeon.write
end