Release 6.9.0

This commit is contained in:
chardub
2026-11-02 11:34:46 -05:00
parent 060726298d
commit ae6e2ebc64
5697 changed files with 131795 additions and 17423 deletions
@@ -0,0 +1,60 @@
DEFAULT_AMBIENT_VOLUME = 40
Events.onStepTakenFieldMovement += proc { |_sender, e|
next unless Settings::EXPERIMENTAL_FEATURES
event = e[0]
next unless event == $game_player
nearby_ambient_sounds = scan_for_ambient_sounds
if nearby_ambient_sounds.size > 0
sound, volume = nearby_ambient_sounds.min_by { |sound, volume| volume }
pbBGSPlay(sound, volume)
else
pbBGSFade(2)
restore_weather_ambient_sounds
end
}
AMBIENT_SOUND_SCAN_RADIUS = 5
AMBIENT_SOUND_SCAN_OFFSETS = (-AMBIENT_SOUND_SCAN_RADIUS..AMBIENT_SOUND_SCAN_RADIUS).flat_map { |dx|
(-AMBIENT_SOUND_SCAN_RADIUS..AMBIENT_SOUND_SCAN_RADIUS).map { |dy| [dx, dy, dx.abs + dy.abs] }
}.select { |_dx, _dy, dist| dist <= AMBIENT_SOUND_SCAN_RADIUS }
.sort_by { |_dx, _dy, dist| dist }
.freeze
def scan_for_ambient_sounds
map = $MapFactory.getMapNoAdd($game_map.map_id)
return [] if !map
px = $game_player.x
py = $game_player.y
best_sound = nil
best_priority = nil
best_distance = nil
AMBIENT_SOUND_SCAN_OFFSETS.each do |dx, dy, distance|
terrain_tag = map.terrain_tag(px + dx, py + dy, true)
next unless terrain_tag&.ambient_sound
priority = terrain_tag.ambient_sound_priority
next if best_priority && best_priority >= priority
best_sound = terrain_tag.ambient_sound
best_priority = priority
best_distance = distance
end
return [] if best_sound.nil?
return [[best_sound, calculate_ambient_sound_volume(best_distance)]]
end
def calculate_ambient_sound_volume(distance_from_player)
return DEFAULT_AMBIENT_VOLUME - (5 * distance_from_player)
end
def calculate_distance_from_player(x, y)
dx = (x - $game_player.x).abs
dy = (y - $game_player.y).abs
return dx + dy
end
@@ -0,0 +1,79 @@
#Tiles that change to a different tile when the player or an event steps on it.
# Used for suspended bridges. Maybe some other cool uses.
#
# shifting_tile_vertical -> shifts all tiles aligned vertically with the current one to the tile to the right of it in the tileset.
# shifting_tile_horizontal -> shifts all tiles aligned horizontally with the current one to the tile under it in the tileset.
class Game_Temp
attr_accessor :shifting_tiles
end
def pbGetShiftingTile(map, x, y)
return nil unless map.valid?(x, y)
for layer in [2, 1, 0]
tile_id = map.data[x, y, layer]
next if tile_id.nil?
terrain_tag = GameData::TerrainTag.try_get(map.terrain_tags[tile_id])
next unless terrain_tag
next if terrain_tag.bridge && $PokemonGlobal.bridge == 0
return [layer, tile_id, :vertical] if terrain_tag.shifting_tile_vertical
return [layer, tile_id, :horizontal] if terrain_tag.shifting_tile_horizontal
end
return nil
end
def pbShiftedTileId(tile_id, mode)
return (mode == :horizontal) ? tile_id + 8 : tile_id + 1
end
def pbCollectShiftingTiles(map, mx, my, layer, tile_id, mode)
tiles = [[mx, my, layer, tile_id]]
dirs = (mode == :vertical) ? [[0, -1], [0, 1]] : [[-1, 0], [1, 0]]
dirs.each do |dx, dy|
x, y = mx + dx, my + dy
loop do
result = pbGetShiftingTile(map, x, y)
break unless result && result[2] == mode
tiles << [x, y, result[0], result[1]]
x += dx
y += dy
end
end
return tiles
end
Events.onStepTakenFieldMovement += proc { |_sender, e|
event = e[0]
thistile = $MapFactory.getRealTilePos(event.map.map_id, event.x, event.y)
map = $MapFactory.getMap(thistile[0])
mx, my = thistile[1], thistile[2]
$game_temp.shifting_tiles ||= {}
key = event.object_id
prev = $game_temp.shifting_tiles[key]
current = pbGetShiftingTile(map, mx, my)
if current
layer, tile_id, mode = current
tiles = pbCollectShiftingTiles(map, mx, my, layer, tile_id, mode)
new_coords = tiles.map { |t| t[0, 3] }.sort
prev_coords = prev&.map { |t| [t[:x], t[:y], t[:layer]] }&.sort
unless new_coords == prev_coords
if prev
prev_map = $MapFactory.getMap(prev.first[:map_id])
prev.each { |t| prev_map.set_tile(t[:x], t[:y], t[:layer], t[:original]) }
end
tiles.each { |x, y, layer, tid| map.set_tile(x, y, layer, pbShiftedTileId(tid, mode)) }
$game_temp.shifting_tiles[key] = tiles.map { |x, y, layer, tid|
{ map_id: thistile[0], x: x, y: y, layer: layer, original: tid }
}
end
elsif prev
prev_map = $MapFactory.getMap(prev.first[:map_id])
prev.each { |t| prev_map.set_tile(t[:x], t[:y], t[:layer], t[:original]) }
$game_temp.shifting_tiles.delete(key)
end
}