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
@@ -17,9 +17,10 @@ def pbGetExceptionMessage(e, _script = "")
return e.event_message.dup if e.is_a?(EventScriptError) # Message with map/event ID generated elsewhere return e.event_message.dup if e.is_a?(EventScriptError) # Message with map/event ID generated elsewhere
emessage = e.message.dup emessage = e.message.dup
emessage.force_encoding(Encoding::UTF_8) emessage.force_encoding(Encoding::UTF_8)
if e.is_a?(Hangup) case e
when Hangup
emessage = "The script is taking too long. The game will restart." emessage = "The script is taking too long. The game will restart."
elsif e.is_a?(Errno::ENOENT) when Errno::ENOENT
filename = emessage.sub("No such file or directory - ", "") filename = emessage.sub("No such file or directory - ", "")
emessage = "File #{filename} not found." emessage = "File #{filename} not found."
end end
@@ -67,7 +67,7 @@ module FileInputMixin
self.pos = 0 self.pos = 0
offset = fgetdw >> 3 offset = fgetdw >> 3
return 0 if index >= offset return 0 if index >= offset
self.pos = index * 8 + 4 self.pos = (index * 8) + 4
return fgetdw return fgetdw
end end
@@ -412,7 +412,8 @@ class Messages
def self.writeObject(f, msgs, secname, origMessages = nil) def self.writeObject(f, msgs, secname, origMessages = nil)
return if !msgs return if !msgs
if msgs.is_a?(Array) case msgs
when Array
f.write("[#{secname}]\r\n") f.write("[#{secname}]\r\n")
for j in 0...msgs.length for j in 0...msgs.length
next if nil_or_empty?(msgs[j]) next if nil_or_empty?(msgs[j])
@@ -427,7 +428,7 @@ class Messages
f.write(origValue + "\r\n") f.write(origValue + "\r\n")
f.write(value + "\r\n") f.write(value + "\r\n")
end end
elsif msgs.is_a?(OrderedHash) when OrderedHash
f.write("[#{secname}]\r\n") f.write("[#{secname}]\r\n")
keys = msgs.keys keys = msgs.keys
for key in keys for key in keys
@@ -212,11 +212,12 @@ module PluginManager
dependencies = value dependencies = value
dependencies = [dependencies] if !dependencies.is_a?(Array) || !dependencies[0].is_a?(Array) dependencies = [dependencies] if !dependencies.is_a?(Array) || !dependencies[0].is_a?(Array)
for dep in value for dep in value
if dep.is_a?(String) # "plugin name" case dep
when String # "plugin name"
if !self.installed?(dep) if !self.installed?(dep)
self.error("Plugin '#{name}' requires plugin '#{dep}' to be installed above it.") self.error("Plugin '#{name}' requires plugin '#{dep}' to be installed above it.")
end end
elsif dep.is_a?(Array) when Array
case dep.size case dep.size
when 1 # ["plugin name"] when 1 # ["plugin name"]
if dep[0].is_a?(String) if dep[0].is_a?(String)
@@ -428,8 +429,8 @@ module PluginManager
return 1 if !c2 return 1 if !c2
return 1 if c1.to_i(16) > c2.to_i(16) return 1 if c1.to_i(16) > c2.to_i(16)
return -1 if c1.to_i(16) < c2.to_i(16) return -1 if c1.to_i(16) < c2.to_i(16)
else elsif c2
return -1 if c2 return -1
end end
end end
return 0 return 0
+6 -6
View File
@@ -187,7 +187,7 @@ class SpriteAnimation
sprite_y = self.viewport.rect.height - 160 sprite_y = self.viewport.rect.height - 160
end end
else else
sprite_x = self.x - self.ox + self.src_rect.width / 2 sprite_x = self.x - self.ox + (self.src_rect.width / 2)
sprite_y = self.y - self.oy sprite_y = self.y - self.oy
sprite_y += self.src_rect.height / 2 if position == 1 sprite_y += self.src_rect.height / 2 if position == 1
sprite_y += self.src_rect.height if position == 2 sprite_y += self.src_rect.height if position == 2
@@ -370,7 +370,7 @@ module RPG
@_damage_sprite.ox = 80 @_damage_sprite.ox = 80
@_damage_sprite.oy = 20 @_damage_sprite.oy = 20
@_damage_sprite.x = self.x @_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy / 2 @_damage_sprite.y = self.y - (self.oy / 2)
@_damage_sprite.z = 3000 @_damage_sprite.z = 3000
@_damage_duration = 40 @_damage_duration = 40
end end
@@ -450,7 +450,7 @@ module RPG
super super
if @_whiten_duration > 0 if @_whiten_duration > 0
@_whiten_duration -= 1 @_whiten_duration -= 1
self.color.alpha = 128 - (16 - @_whiten_duration) * 10 self.color.alpha = 128 - ((16 - @_whiten_duration) * 10)
end end
if @_appear_duration > 0 if @_appear_duration > 0
@_appear_duration -= 1 @_appear_duration -= 1
@@ -458,11 +458,11 @@ module RPG
end end
if @_escape_duration > 0 if @_escape_duration > 0
@_escape_duration -= 1 @_escape_duration -= 1
self.opacity = 256 - (32 - @_escape_duration) * 10 self.opacity = 256 - ((32 - @_escape_duration) * 10)
end end
if @_collapse_duration > 0 if @_collapse_duration > 0
@_collapse_duration -= 1 @_collapse_duration -= 1
self.opacity = 256 - (48 - @_collapse_duration) * 6 self.opacity = 256 - ((48 - @_collapse_duration) * 6)
end end
if @_damage_duration > 0 if @_damage_duration > 0
@_damage_duration -= 1 @_damage_duration -= 1
@@ -476,7 +476,7 @@ module RPG
when 28..33 when 28..33
@_damage_sprite.y += 4 @_damage_sprite.y += 4
end end
@_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32 @_damage_sprite.opacity = 256 - ((12 - @_damage_duration) * 32)
if @_damage_duration == 0 if @_damage_duration == 0
dispose_damage dispose_damage
end end
@@ -57,8 +57,8 @@ class Scene_Map
if playingBGM && map.autoplay_bgm if playingBGM && map.autoplay_bgm
if (PBDayNight.isNight? rescue false) if (PBDayNight.isNight? rescue false)
pbBGMFade(0.8) if playingBGM.name != map.bgm.name && playingBGM.name != map.bgm.name + "_n" pbBGMFade(0.8) if playingBGM.name != map.bgm.name && playingBGM.name != map.bgm.name + "_n"
else elsif playingBGM.name != map.bgm.name
pbBGMFade(0.8) if playingBGM.name != map.bgm.name pbBGMFade(0.8)
end end
end end
if playingBGS && map.autoplay_bgs if playingBGS && map.autoplay_bgs
@@ -452,8 +452,8 @@ class Interpreter
$game_temp.mart_prices[item][0] = buy_price if buy_price > 0 $game_temp.mart_prices[item][0] = buy_price if buy_price > 0
if sell_price >= 0 # 0=can't sell if sell_price >= 0 # 0=can't sell
$game_temp.mart_prices[item][1] = sell_price * 2 $game_temp.mart_prices[item][1] = sell_price * 2
else elsif buy_price > 0
$game_temp.mart_prices[item][1] = buy_price if buy_price > 0 $game_temp.mart_prices[item][1] = buy_price
end end
end end
@@ -97,15 +97,15 @@ class Game_Screen
end end
if @fadein_duration && @fadein_duration >= 1 if @fadein_duration && @fadein_duration >= 1
d = @fadein_duration d = @fadein_duration
@brightness = (@brightness * (d - 1) + 255) / d @brightness = ((@brightness * (d - 1)) + 255) / d
@fadein_duration -= 1 @fadein_duration -= 1
end end
if @tone_duration >= 1 if @tone_duration >= 1
d = @tone_duration d = @tone_duration
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d @tone.red = ((@tone.red * (d - 1)) + @tone_target.red) / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d @tone.green = ((@tone.green * (d - 1)) + @tone_target.green) / d
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d @tone.blue = ((@tone.blue * (d - 1)) + @tone_target.blue) / d
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d @tone.gray = ((@tone.gray * (d - 1)) + @tone_target.gray) / d
@tone_duration -= 1 @tone_duration -= 1
end end
if @flash_duration >= 1 if @flash_duration >= 1
@@ -131,19 +131,19 @@ class Game_Picture
def update def update
if @duration >= 1 if @duration >= 1
d = @duration d = @duration
@x = (@x * (d - 1) + @target_x) / d @x = ((@x * (d - 1)) + @target_x) / d
@y = (@y * (d - 1) + @target_y) / d @y = ((@y * (d - 1)) + @target_y) / d
@zoom_x = (@zoom_x * (d - 1) + @target_zoom_x) / d @zoom_x = ((@zoom_x * (d - 1)) + @target_zoom_x) / d
@zoom_y = (@zoom_y * (d - 1) + @target_zoom_y) / d @zoom_y = ((@zoom_y * (d - 1)) + @target_zoom_y) / d
@opacity = (@opacity * (d - 1) + @target_opacity) / d @opacity = ((@opacity * (d - 1)) + @target_opacity) / d
@duration -= 1 @duration -= 1
end end
if @tone_duration >= 1 if @tone_duration >= 1
d = @tone_duration d = @tone_duration
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d @tone.red = ((@tone.red * (d - 1)) + @tone_target.red) / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d @tone.green = ((@tone.green * (d - 1)) + @tone_target.green) / d
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d @tone.blue = ((@tone.blue * (d - 1)) + @tone_target.blue) / d
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d @tone.gray = ((@tone.gray * (d - 1)) + @tone_target.gray) / d
@tone_duration -= 1 @tone_duration -= 1
end end
if @rotate_speed != 0 if @rotate_speed != 0
+10 -10
View File
@@ -147,7 +147,7 @@ class Game_Map
def passable?(x, y, d, self_event = nil) def passable?(x, y, d, self_event = nil)
return false if !valid?(x, y) return false if !valid?(x, y)
bit = (1 << (d / 2 - 1)) & 0x0f bit = (1 << ((d / 2) - 1)) & 0x0f
for event in events.values for event in events.values
next if event.tile_id <= 0 next if event.tile_id <= 0
next if event == self_event next if event == self_event
@@ -224,7 +224,7 @@ class Game_Map
end end
def playerPassable?(x, y, d, self_event = nil) 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] for i in [2, 1, 0]
tile_id = data[x, y, i] tile_id = data[x, y, i]
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id]) terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
@@ -323,7 +323,7 @@ class Game_Map
return if @display_x == value return if @display_x == value
@display_x = value @display_x = value
if metadata&.snap_edges 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 @display_x = [0, [@display_x, max_x].min].max
end end
$map_factory.setMapsInRange if $map_factory $map_factory.setMapsInRange if $map_factory
@@ -333,7 +333,7 @@ class Game_Map
return if @display_y == value return if @display_y == value
@display_y = value @display_y = value
if metadata&.snap_edges 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 @display_y = [0, [@display_y, max_y].min].max
end end
$map_factory.setMapsInRange if $map_factory $map_factory.setMapsInRange if $map_factory
@@ -378,7 +378,7 @@ class Game_Map
end end
def start_fog_opacity_change(opacity, duration) def start_fog_opacity_change(opacity, duration)
@fog_opacity_target = opacity * 1.0 @fog_opacity_target = opacity.to_f
@fog_opacity_duration = duration @fog_opacity_duration = duration
if @fog_opacity_duration == 0 if @fog_opacity_duration == 0
@fog_opacity = @fog_opacity_target @fog_opacity = @fog_opacity_target
@@ -437,15 +437,15 @@ class Game_Map
if @fog_tone_duration >= 1 if @fog_tone_duration >= 1
d = @fog_tone_duration d = @fog_tone_duration
target = @fog_tone_target target = @fog_tone_target
@fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / 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.green = ((@fog_tone.green * (d - 1)) + target.green) / d
@fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / 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.gray = ((@fog_tone.gray * (d - 1)) + target.gray) / d
@fog_tone_duration -= 1 @fog_tone_duration -= 1
end end
if @fog_opacity_duration >= 1 if @fog_opacity_duration >= 1
d = @fog_opacity_duration 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 @fog_opacity_duration -= 1
end end
end end
@@ -87,12 +87,12 @@ class Interpreter
print 'Map Autoscroll: invalid speed (1-6 only)' print 'Map Autoscroll: invalid speed (1-6 only)'
return command_skip return command_skip
end end
center_x = (Graphics.width / 2 - Game_Map::TILE_WIDTH / 2) * 4 # X coordinate in the center of the screen 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 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_x = ($game_map.width - (Graphics.width.to_f / 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 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_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 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 if !@diag
@diag = true @diag = true
dir = nil dir = nil
@@ -148,20 +148,20 @@ end
class Game_Map class Game_Map
def scroll_downright(distance) def scroll_downright(distance)
@display_x = [@display_x + 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, @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 end
def scroll_downleft(distance) def scroll_downleft(distance)
@display_x = [@display_x - distance, 0].max @display_x = [@display_x - distance, 0].max
@display_y = [@display_y + distance, @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 end
def scroll_upright(distance) def scroll_upright(distance)
@display_x = [@display_x + 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 @display_y = [@display_y - distance, 0].max
end end
@@ -122,8 +122,8 @@ class PokemonMapFactory
for conn in conns[id] for conn in conns[id]
if conn[0] == id if conn[0] == id
mapA = getMap(conn[0]) mapA = getMap(conn[0])
newdispx = (conn[4] - conn[1]) * Game_Map::REAL_RES_X + mapA.display_x 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 newdispy = ((conn[5] - conn[2]) * Game_Map::REAL_RES_Y) + mapA.display_y
if hasMap?(conn[3]) || MapFactoryHelper.mapInRangeById?(conn[3], newdispx, newdispy) if hasMap?(conn[3]) || MapFactoryHelper.mapInRangeById?(conn[3], newdispx, newdispy)
mapB = getMap(conn[3]) mapB = getMap(conn[3])
mapB.display_x = newdispx if mapB.display_x != newdispx mapB.display_x = newdispx if mapB.display_x != newdispx
@@ -131,8 +131,8 @@ class PokemonMapFactory
end end
else else
mapA = getMap(conn[3]) mapA = getMap(conn[3])
newdispx = (conn[1] - conn[4]) * Game_Map::REAL_RES_X + mapA.display_x 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 newdispy = ((conn[2] - conn[5]) * Game_Map::REAL_RES_Y) + mapA.display_y
if hasMap?(conn[0]) || MapFactoryHelper.mapInRangeById?(conn[0], newdispx, newdispy) if hasMap?(conn[0]) || MapFactoryHelper.mapInRangeById?(conn[0], newdispx, newdispy)
mapB = getMap(conn[0]) mapB = getMap(conn[0])
mapB.display_x = newdispx if mapB.display_x != newdispx mapB.display_x = newdispx if mapB.display_x != newdispx
@@ -204,8 +204,8 @@ class PokemonMapFactory
if !($DEBUG && Input.press?(Input::CTRL)) if !($DEBUG && Input.press?(Input::CTRL))
return false if !map.passableStrict?(x, y, 0, thisEvent) return false if !map.passableStrict?(x, y, 0, thisEvent)
end end
else elsif !map.passableStrict?(x, y, 0, thisEvent)
return false if !map.passableStrict?(x, y, 0, thisEvent) return false
end end
for event in map.events.values for event in map.events.values
next if event == thisEvent || !event.at_coordinate?(x, y) next if event == thisEvent || !event.at_coordinate?(x, y)
@@ -488,8 +488,8 @@ module MapFactoryHelper
dispy = map.display_y dispy = map.display_y
return false if dispx >= (map.width + range) * Game_Map::REAL_RES_X 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 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 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 dispy <= -(Graphics.height + (range * Game_Map::TILE_HEIGHT)) * Game_Map::Y_SUBPIXELS
return true return true
end end
@@ -498,8 +498,8 @@ module MapFactoryHelper
dims = MapFactoryHelper.getMapDims(id) dims = MapFactoryHelper.getMapDims(id)
return false if dispx >= (dims[0] + range) * Game_Map::REAL_RES_X 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 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 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 dispy <= -(Graphics.height + (range * Game_Map::TILE_HEIGHT)) * Game_Map::Y_SUBPIXELS
return true return true
end end
end end
@@ -142,7 +142,7 @@ class Game_Character
# 4 => 64 # 1.6 seconds # 4 => 64 # 1.6 seconds
# 5 => 30 # 0.75 seconds # 5 => 30 # 0.75 seconds
# 6 => 0 # 0 seconds, i.e. continuous movement # 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 end
def move_frequency_real def move_frequency_real
@@ -318,7 +318,7 @@ class Game_Character
else else
jump_fraction = ((@jump_distance_left / @jump_distance) - 0.5).abs # 0.5 to 0 to 0.5 jump_fraction = ((@jump_distance_left / @jump_distance) - 0.5).abs # 0.5 to 0 to 0.5
end end
ret += @jump_peak * (4 * jump_fraction**2 - 1) ret += @jump_peak * ((4 * (jump_fraction**2)) - 1)
end end
return ret return ret
end end
@@ -328,7 +328,7 @@ class Game_Character
z = screen_y_ground z = screen_y_ground
if @tile_id > 0 if @tile_id > 0
begin begin
return z + self.map.priorities[@tile_id] * 32 return z + (self.map.priorities[@tile_id] * 32)
rescue rescue
raise "Event's graphic is an out-of-range tile (event #{@id}, map #{self.map.map_id})" raise "Event's graphic is an out-of-range tile (event #{@id}, map #{self.map.map_id})"
end end
@@ -405,8 +405,8 @@ class Game_Character
end end
def move_type_toward_player def move_type_toward_player
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 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) sy = @y - (@height / 2.0) - ($game_player.y - ($game_player.height / 2.0))
if sx.abs + sy.abs >= 20 if sx.abs + sy.abs >= 20
move_random move_random
return return
@@ -662,8 +662,8 @@ class Game_Character
end end
def move_toward_player def move_toward_player
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 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) sy = @y - (@height / 2.0) - ($game_player.y - ($game_player.height / 2.0))
return if sx == 0 && sy == 0 return if sx == 0 && sy == 0
abs_sx = sx.abs abs_sx = sx.abs
abs_sy = sy.abs abs_sy = sy.abs
@@ -684,8 +684,8 @@ class Game_Character
end end
def move_away_from_player def move_away_from_player
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 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) sy = @y - (@height / 2.0) - ($game_player.y - ($game_player.height / 2.0))
return if sx == 0 && sy == 0 return if sx == 0 && sy == 0
abs_sx = sx.abs abs_sx = sx.abs
abs_sy = sy.abs abs_sy = sy.abs
@@ -737,7 +737,7 @@ class Game_Character
end end
@x = @x + x_plus @x = @x + x_plus
@y = @y + y_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 distance = [1, real_distance].max
@jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping @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 @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 end
def turn_toward_player def turn_toward_player
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 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) sy = @y - (@height / 2.0) - ($game_player.y - ($game_player.height / 2.0))
return if sx == 0 && sy == 0 return if sx == 0 && sy == 0
if sx.abs > sy.abs if sx.abs > sy.abs
(sx > 0) ? turn_left : turn_right (sx > 0) ? turn_left : turn_right
@@ -835,8 +835,8 @@ class Game_Character
end end
def turn_away_from_player def turn_away_from_player
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 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) sy = @y - (@height / 2.0) - ($game_player.y - ($game_player.height / 2.0))
return if sx == 0 && sy == 0 return if sx == 0 && sy == 0
if sx.abs > sy.abs if sx.abs > sy.abs
(sx > 0) ? turn_right : turn_left (sx > 0) ? turn_right : turn_left
@@ -110,7 +110,7 @@ class Game_Event < Game_Character
return false if !ontime return false if !ontime
now = pbGetTimeNow now = pbGetTimeNow
elapsed = (now.to_i - ontime) / 86400 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 return elapsed >= days
end end
@@ -249,9 +249,9 @@ class Game_Event < Game_Character
return true if @move_route_forcing return true if @move_route_forcing
return true if @event.name[/update/i] return true if @event.name[/update/i]
range = 2 # Number of tiles 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) > 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_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 - @sprite_size[1] > Graphics.height + (range * Game_Map::TILE_HEIGHT)
return false if self.screen_y_ground < -range * Game_Map::TILE_HEIGHT return false if self.screen_y_ground < -range * Game_Map::TILE_HEIGHT
return true return true
end end
@@ -10,8 +10,8 @@ class Game_Player < Game_Character
attr_accessor :charsetData attr_accessor :charsetData
attr_accessor :encounter_count attr_accessor :encounter_count
SCREEN_CENTER_X = (Settings::SCREEN_WIDTH / 2 - Game_Map::TILE_WIDTH / 2) * Game_Map::X_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 SCREEN_CENTER_Y = ((Settings::SCREEN_HEIGHT / 2) - (Game_Map::TILE_HEIGHT / 2)) * Game_Map::Y_SUBPIXELS
@@bobFrameSpeed = 1.0 / 15 @@bobFrameSpeed = 1.0 / 15
@@ -157,7 +157,7 @@ class Game_Player < Game_Character
end end
@x = @x + x_plus @x = @x + x_plus
@y = @y + y_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 distance = [1, real_distance].max
@jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping @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 @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 # * Set Map Display Position to Center of Screen
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def center(x, y) def center(x, y)
self.map.display_x = x * Game_Map::REAL_RES_X - SCREEN_CENTER_X 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_y = (y * Game_Map::REAL_RES_Y) - SCREEN_CENTER_Y
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -164,7 +164,7 @@ class Game_Follower < Game_Event
return false if !this_map || !this_map.valid?(x, y) return false if !this_map || !this_map.valid?(x, y)
return true if @through return true if @through
passed_tile_checks = false 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 # Check all events for ones using tiles as graphics, and see if they're passable
for event in this_map.events.values for event in this_map.events.values
next if event.tile_id < 0 || event.through || !event.at_coordinate?(x, y) next if event.tile_id < 0 || event.through || !event.at_coordinate?(x, y)
+2 -2
View File
@@ -38,8 +38,8 @@ class Sprite_Timer
@timer.text = _ISPRINTF("<ac>{1:02d}:{2:02d}", min, sec) @timer.text = _ISPRINTF("<ac>{1:02d}:{2:02d}", min, sec)
end end
@timer.update @timer.update
else elsif @timer
@timer.visible = false if @timer @timer.visible = false
end end
end end
end end
@@ -57,10 +57,10 @@ class Sprite_Reflection
y += @height * 16 y += @height * 16
width = @rsprite.src_rect.width width = @rsprite.src_rect.width
height = @rsprite.src_rect.height height = @rsprite.src_rect.height
@sprite.x = x + width / 2 @sprite.x = x + (width / 2)
@sprite.y = y + height + height / 2 @sprite.y = y + height + (height / 2)
@sprite.ox = width / 2 @sprite.ox = width / 2
@sprite.oy = height / 2 - 2 # Hard-coded 2 pixel shift up @sprite.oy = (height / 2) - 2 # Hard-coded 2 pixel shift up
@sprite.oy -= @rsprite.character.bob_height * 2 @sprite.oy -= @rsprite.character.bob_height * 2
@sprite.z = -50 # Still water is -100, map is 0 and above @sprite.z = -50 # Still water is -100, map is 0 and above
@sprite.z += 1 if @event == $game_player @sprite.z += 1 if @event == $game_player
@@ -63,8 +63,8 @@ class Sprite_SurfBase
sy = ((@event.direction - 2) / 2) * ch sy = ((@event.direction - 2) / 2) * ch
@sprite.src_rect.set(sx, sy, cw, ch) @sprite.src_rect.set(sx, sy, cw, ch)
if $game_temp.surf_base_coords if $game_temp.surf_base_coords
@sprite.x = ($game_temp.surf_base_coords[0] * Game_Map::REAL_RES_X - @event.map.display_x + 3) / 4 + (Game_Map::TILE_WIDTH / 2) @sprite.x = ((($game_temp.surf_base_coords[0] * Game_Map::REAL_RES_X) - @event.map.display_x + 3) / 4) + (Game_Map::TILE_WIDTH / 2)
@sprite.y = ($game_temp.surf_base_coords[1] * Game_Map::REAL_RES_Y - @event.map.display_y + 3) / 4 + (Game_Map::TILE_HEIGHT / 2) + 16 @sprite.y = ((($game_temp.surf_base_coords[1] * Game_Map::REAL_RES_Y) - @event.map.display_y + 3) / 4) + (Game_Map::TILE_HEIGHT / 2) + 16
else else
@sprite.x = @rsprite.x @sprite.x = @rsprite.x
@sprite.y = @rsprite.y @sprite.y = @rsprite.y
@@ -9,7 +9,7 @@ class ClippableSprite < Sprite_Character
def update def update
super super
@_src_rect = self.src_rect @_src_rect = self.src_rect
tmright = @tilemap.map_data.xsize * Game_Map::TILE_WIDTH - @tilemap.ox tmright = (@tilemap.map_data.xsize * Game_Map::TILE_WIDTH) - @tilemap.ox
echoln "x=#{self.x},ox=#{self.ox},tmright=#{tmright},tmox=#{@tilemap.ox}" echoln "x=#{self.x},ox=#{self.ox},tmright=#{tmright},tmox=#{@tilemap.ox}"
if @tilemap.ox - self.ox < -self.x if @tilemap.ox - self.ox < -self.x
# clipped on left # clipped on left
@@ -18,9 +18,9 @@ class AnimationSprite < RPG::Sprite
end end
def setCoords def setCoords
self.x = ((@tileX * Game_Map::REAL_RES_X - @map.display_x) / Game_Map::X_SUBPIXELS).ceil self.x = (((@tileX * Game_Map::REAL_RES_X) - @map.display_x) / Game_Map::X_SUBPIXELS).ceil
self.x += Game_Map::TILE_WIDTH / 2 self.x += Game_Map::TILE_WIDTH / 2
self.y = ((@tileY * Game_Map::REAL_RES_Y - @map.display_y) / Game_Map::Y_SUBPIXELS).ceil self.y = (((@tileY * Game_Map::REAL_RES_Y) - @map.display_y) / Game_Map::Y_SUBPIXELS).ceil
self.y += Game_Map::TILE_HEIGHT self.y += Game_Map::TILE_HEIGHT
end end
@@ -261,9 +261,9 @@ class ParticleEffect_Event < ParticleEffect
@real_y = newRealY @real_y = newRealY
if @opacityvar > 0 && @viewport if @opacityvar > 0 && @viewport
opac = 255.0 / @opacityvar opac = 255.0 / @opacityvar
minX = opac * (-@xgravity * 1.0 / @slowdown).floor + @startingx minX = (opac * (-@xgravity.to_f / @slowdown).floor) + @startingx
maxX = opac * (@xgravity * 1.0 / @slowdown).floor + @startingx maxX = (opac * (@xgravity.to_f / @slowdown).floor) + @startingx
minY = opac * (-@ygravity * 1.0 / @slowdown).floor + @startingy minY = (opac * (-@ygravity.to_f / @slowdown).floor) + @startingy
maxY = @startingy maxY = @startingy
minX -= @bmwidth minX -= @bmwidth
minY -= @bmheight minY -= @bmheight
@@ -309,15 +309,13 @@ class ParticleEffect_Event < ParticleEffect
@particlex[i] = 0.0 @particlex[i] = 0.0
@particley[i] = 0.0 @particley[i] = 0.0
end end
else elsif @opacity[i] <= 0
if @opacity[i] <= 0
@opacity[i] = 250 @opacity[i] = 250
@particles[i].y = @startingy + @yoffset @particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset @particles[i].x = @startingx + @xoffset
@particlex[i] = 0.0 @particlex[i] = 0.0
@particley[i] = 0.0 @particley[i] = 0.0
end end
end
calcParticlePos(i) calcParticlePos(i)
if @randomhue == 1 if @randomhue == 1
@hue += 0.5 @hue += 0.5
@@ -333,11 +331,11 @@ class ParticleEffect_Event < ParticleEffect
def calcParticlePos(i) def calcParticlePos(i)
@leftright = rand(2) @leftright = rand(2)
if @leftright == 1 if @leftright == 1
xo = -@xgravity * 1.0 / @slowdown xo = -@xgravity.to_f / @slowdown
else else
xo = @xgravity * 1.0 / @slowdown xo = @xgravity.to_f / @slowdown
end end
yo = -@ygravity * 1.0 / @slowdown yo = -@ygravity.to_f / @slowdown
@particlex[i] += xo @particlex[i] += xo
@particley[i] += yo @particley[i] += yo
@particlex[i] -= @__offsetx @particlex[i] -= @__offsetx
+31 -30
View File
@@ -47,23 +47,23 @@ def getCubicPoint2(src, t)
x1 = src[6] x1 = src[6]
y1 = src[7] y1 = src[7]
x1 = cx1 + (x1 - cx1) * t x1 = cx1 + ((x1 - cx1) * t)
x0 = x0 + (cx0 - x0) * t x0 = x0 + ((cx0 - x0) * t)
cx0 = cx0 + (cx1 - cx0) * t cx0 = cx0 + ((cx1 - cx0) * t)
cx1 = cx0 + (x1 - cx0) * t cx1 = cx0 + ((x1 - cx0) * t)
cx0 = x0 + (cx0 - x0) * t cx0 = x0 + ((cx0 - x0) * t)
cx = cx0 + (cx1 - cx0) * t cx = cx0 + ((cx1 - cx0) * t)
# a = x1 - 3 * cx1 + 3 * cx0 - x0 # a = x1 - 3 * cx1 + 3 * cx0 - x0
# b = 3 * (cx1 - 2 * cx0 + x0) # b = 3 * (cx1 - 2 * cx0 + x0)
# c = 3 * (cx0 - x0) # c = 3 * (cx0 - x0)
# d = x0 # d = x0
# cx = a*t*t*t + b*t*t + c*t + d # cx = a*t*t*t + b*t*t + c*t + d
y1 = cy1 + (y1 - cy1) * t y1 = cy1 + ((y1 - cy1) * t)
y0 = y0 + (cy0 - y0) * t y0 = y0 + ((cy0 - y0) * t)
cy0 = cy0 + (cy1 - cy0) * t cy0 = cy0 + ((cy1 - cy0) * t)
cy1 = cy0 + (y1 - cy0) * t cy1 = cy0 + ((y1 - cy0) * t)
cy0 = y0 + (cy0 - y0) * t cy0 = y0 + ((cy0 - y0) * t)
cy = cy0 + (cy1 - cy0) * t cy = cy0 + ((cy1 - cy0) * t)
# a = y1 - 3 * cy1 + 3 * cy0 - y0 # a = y1 - 3 * cy1 + 3 * cy0 - y0
# b = 3 * (cy1 - 2 * cy0 + y0) # b = 3 * (cy1 - 2 * cy0 + y0)
# c = 3 * (cy0 - y0) # c = 3 * (cy0 - y0)
@@ -121,11 +121,12 @@ class PictureEx
end end
def callback(cb) def callback(cb)
if cb.is_a?(Proc) case cb
when Proc
cb.call(self) cb.call(self)
elsif cb.is_a?(Array) when Array
cb[0].method(cb[1]).call(self) cb[0].method(cb[1]).call(self)
elsif cb.is_a?(Method) when Method
cb.call(self) cb.call(self)
end end
end end
@@ -390,31 +391,31 @@ class PictureEx
dur = (process[2] == 0) ? 1 : process[2] # Total duration of process dur = (process[2] == 0) ? 1 : process[2] # Total duration of process
case process[0] case process[0]
when Processes::XY, Processes::DeltaXY when Processes::XY, Processes::DeltaXY
@x = process[5] + fra * (process[7] - process[5]) / dur @x = process[5] + (fra * (process[7] - process[5]) / dur)
@y = process[6] + fra * (process[8] - process[6]) / dur @y = process[6] + (fra * (process[8] - process[6]) / dur)
when Processes::Curve when Processes::Curve
@x, @y = getCubicPoint2(process[5], fra.to_f / dur) @x, @y = getCubicPoint2(process[5], fra.to_f / dur)
when Processes::Z when Processes::Z
@z = process[5] + fra * (process[6] - process[5]) / dur @z = process[5] + (fra * (process[6] - process[5]) / dur)
when Processes::Zoom when Processes::Zoom
@zoom_x = process[5] + fra * (process[7] - process[5]) / dur @zoom_x = process[5] + (fra * (process[7] - process[5]) / dur)
@zoom_y = process[6] + fra * (process[8] - process[6]) / dur @zoom_y = process[6] + (fra * (process[8] - process[6]) / dur)
when Processes::Angle when Processes::Angle
@angle = process[5] + fra * (process[6] - process[5]) / dur @angle = process[5] + (fra * (process[6] - process[5]) / dur)
when Processes::Tone when Processes::Tone
@tone.red = process[5].red + fra * (process[6].red - process[5].red) / dur @tone.red = process[5].red + (fra * (process[6].red - process[5].red) / dur)
@tone.green = process[5].green + fra * (process[6].green - process[5].green) / dur @tone.green = process[5].green + (fra * (process[6].green - process[5].green) / dur)
@tone.blue = process[5].blue + fra * (process[6].blue - process[5].blue) / dur @tone.blue = process[5].blue + (fra * (process[6].blue - process[5].blue) / dur)
@tone.gray = process[5].gray + fra * (process[6].gray - process[5].gray) / dur @tone.gray = process[5].gray + (fra * (process[6].gray - process[5].gray) / dur)
when Processes::Color when Processes::Color
@color.red = process[5].red + fra * (process[6].red - process[5].red) / dur @color.red = process[5].red + (fra * (process[6].red - process[5].red) / dur)
@color.green = process[5].green + fra * (process[6].green - process[5].green) / dur @color.green = process[5].green + (fra * (process[6].green - process[5].green) / dur)
@color.blue = process[5].blue + fra * (process[6].blue - process[5].blue) / dur @color.blue = process[5].blue + (fra * (process[6].blue - process[5].blue) / dur)
@color.alpha = process[5].alpha + fra * (process[6].alpha - process[5].alpha) / dur @color.alpha = process[5].alpha + (fra * (process[6].alpha - process[5].alpha) / dur)
when Processes::Hue when Processes::Hue
@hue = (process[6] - process[5]).to_f / dur @hue = (process[6] - process[5]).to_f / dur
when Processes::Opacity when Processes::Opacity
@opacity = process[5] + fra * (process[6] - process[5]) / dur @opacity = process[5] + (fra * (process[6] - process[5]) / dur)
when Processes::Visible when Processes::Visible
@visible = process[5] @visible = process[5]
when Processes::BlendType when Processes::BlendType
+18 -18
View File
@@ -51,26 +51,26 @@ class Interpolator
def update def update
if @tweening if @tweening
t = (@step * 1.0) / @frames t = @step.to_f / @frames
for i in 0...@tweensteps.length for i in 0...@tweensteps.length
item = @tweensteps[i] item = @tweensteps[i]
next if !item next if !item
case i case i
when ZOOM_X when ZOOM_X
@sprite.zoom_x = item[0] + item[1] * t @sprite.zoom_x = item[0] + (item[1] * t)
when ZOOM_Y when ZOOM_Y
@sprite.zoom_y = item[0] + item[1] * t @sprite.zoom_y = item[0] + (item[1] * t)
when X when X
@sprite.x = item[0] + item[1] * t @sprite.x = item[0] + (item[1] * t)
when Y when Y
@sprite.y = item[0] + item[1] * t @sprite.y = item[0] + (item[1] * t)
when OPACITY when OPACITY
@sprite.opacity = item[0] + item[1] * t @sprite.opacity = item[0] + (item[1] * t)
when COLOR when COLOR
@sprite.color = Color.new(item[0].red + item[1].red * t, @sprite.color = Color.new(item[0].red + (item[1].red * t),
item[0].green + item[1].green * t, item[0].green + (item[1].green * t),
item[0].blue + item[1].blue * t, item[0].blue + (item[1].blue * t),
item[0].alpha + item[1].alpha * t) item[0].alpha + (item[1].alpha * t))
end end
end end
@step += 1 @step += 1
@@ -108,19 +108,19 @@ class RectInterpolator
def update def update
return if done? return if done?
t = (@curframe * 1.0 / @frames) t = @curframe.to_f / @frames
x1 = @oldrect.x x1 = @oldrect.x
x2 = @newrect.x x2 = @newrect.x
x = x1 + t * (x2 - x1) x = x1 + (t * (x2 - x1))
y1 = @oldrect.y y1 = @oldrect.y
y2 = @newrect.y y2 = @newrect.y
y = y1 + t * (y2 - y1) y = y1 + (t * (y2 - y1))
rx1 = @oldrect.x + @oldrect.width rx1 = @oldrect.x + @oldrect.width
rx2 = @newrect.x + @newrect.width rx2 = @newrect.x + @newrect.width
rx = rx1 + t * (rx2 - rx1) rx = rx1 + (t * (rx2 - rx1))
ry1 = @oldrect.y + @oldrect.height ry1 = @oldrect.y + @oldrect.height
ry2 = @newrect.y + @newrect.height ry2 = @newrect.y + @newrect.height
ry = ry1 + t * (ry2 - ry1) ry = ry1 + (t * (ry2 - ry1))
minx = x < rx ? x : rx minx = x < rx ? x : rx
maxx = x > rx ? x : rx maxx = x > rx ? x : rx
miny = y < ry ? y : ry miny = y < ry ? y : ry
@@ -157,13 +157,13 @@ class PointInterpolator
def update def update
return if done? return if done?
t = (@curframe * 1.0 / @frames) t = @curframe.to_f / @frames
rx1 = @oldx rx1 = @oldx
rx2 = @newx rx2 = @newx
@x = rx1 + t * (rx2 - rx1) @x = rx1 + (t * (rx2 - rx1))
ry1 = @oldy ry1 = @oldy
ry2 = @newy ry2 = @newy
@y = ry1 + t * (ry2 - ry1) @y = ry1 + (t * (ry2 - ry1))
@curframe += 1 @curframe += 1
end end
end end
@@ -372,7 +372,7 @@ class TilemapRenderer
if tile_id < true_tileset_start_id if tile_id < true_tileset_start_id
filename = "" filename = ""
if tile_id < TILESET_START_ID # Real autotiles if tile_id < TILESET_START_ID # Real autotiles
filename = map.autotile_names[tile_id / TILES_PER_AUTOTILE - 1] filename = map.autotile_names[(tile_id / TILES_PER_AUTOTILE) - 1]
elsif tile_id < single_autotile_start_id # Large extra autotiles elsif tile_id < single_autotile_start_id # Large extra autotiles
filename = extra_autotile_arrays[0][(tile_id - TILESET_START_ID) / TILES_PER_AUTOTILE] filename = extra_autotile_arrays[0][(tile_id - TILESET_START_ID) / TILES_PER_AUTOTILE]
else # Single extra autotiles else # Single extra autotiles
@@ -406,8 +406,8 @@ class TilemapRenderer
# x and y are the positions of tile within @tiles, not a map x/y # x and y are the positions of tile within @tiles, not a map x/y
def refresh_tile_coordinates(tile, x, y) def refresh_tile_coordinates(tile, x, y)
tile.x = x * DISPLAY_TILE_WIDTH - @pixel_offset_x tile.x = (x * DISPLAY_TILE_WIDTH) - @pixel_offset_x
tile.y = y * DISPLAY_TILE_HEIGHT - @pixel_offset_y tile.y = (y * DISPLAY_TILE_HEIGHT) - @pixel_offset_y
end end
def refresh_tile_z(tile, map, y, layer, tile_id) def refresh_tile_z(tile, map, y, layer, tile_id)
@@ -417,7 +417,7 @@ class TilemapRenderer
tile.z = 0 tile.z = 0
else else
priority = tile.priority priority = tile.priority
tile.z = (priority == 0) ? 0 : y * DISPLAY_TILE_HEIGHT + priority * 32 + 32 tile.z = (priority == 0) ? 0 : (y * DISPLAY_TILE_HEIGHT) + (priority * 32) + 32
end end
end end
@@ -23,7 +23,7 @@ class TilemapRenderer
TILESET_WIDTH = SOURCE_TILE_WIDTH * TILESET_TILES_PER_ROW TILESET_WIDTH = SOURCE_TILE_WIDTH * TILESET_TILES_PER_ROW
# Looks useless, but covers weird numbers given to mkxp.json or a funky driver # Looks useless, but covers weird numbers given to mkxp.json or a funky driver
MAX_TEX_SIZE = (Bitmap.max_size / 1024) * 1024 MAX_TEX_SIZE = (Bitmap.max_size / 1024) * 1024
MAX_TEX_SIZE_BOOSTED = MAX_TEX_SIZE**2 / TILESET_WIDTH MAX_TEX_SIZE_BOOSTED = (MAX_TEX_SIZE**2) / TILESET_WIDTH
module_function module_function
@@ -49,7 +49,7 @@ class TilemapRenderer
def getWrappedRect(src_rect) def getWrappedRect(src_rect)
ret = Rect.new(0, 0, 0, 0) ret = Rect.new(0, 0, 0, 0)
col = (src_rect.y / MAX_TEX_SIZE.to_f).floor col = (src_rect.y / MAX_TEX_SIZE.to_f).floor
ret.x = col * TILESET_WIDTH + src_rect.x.clamp(0, TILESET_WIDTH) ret.x = (col * TILESET_WIDTH) + src_rect.x.clamp(0, TILESET_WIDTH)
ret.y = src_rect.y % MAX_TEX_SIZE ret.y = src_rect.y % MAX_TEX_SIZE
ret.width = src_rect.width.clamp(0, TILESET_WIDTH - src_rect.x) ret.width = src_rect.width.clamp(0, TILESET_WIDTH - src_rect.x)
ret.height = src_rect.height.clamp(0, MAX_TEX_SIZE) ret.height = src_rect.height.clamp(0, MAX_TEX_SIZE)
@@ -36,11 +36,11 @@ class TilemapRenderer
SOURCE_TILE_WIDTH, SOURCE_TILE_HEIGHT)) SOURCE_TILE_WIDTH, SOURCE_TILE_HEIGHT))
when 2 # Top right corner when 2 # Top right corner
new_bitmap.blt(dest_x, dest_y, bitmap, new_bitmap.blt(dest_x, dest_y, bitmap,
Rect.new(SOURCE_TILE_WIDTH + frame * SOURCE_TILE_WIDTH * 3, SOURCE_TILE_HEIGHT * 4, Rect.new(SOURCE_TILE_WIDTH + (frame * SOURCE_TILE_WIDTH * 3), SOURCE_TILE_HEIGHT * 4,
SOURCE_TILE_WIDTH, SOURCE_TILE_HEIGHT)) SOURCE_TILE_WIDTH, SOURCE_TILE_HEIGHT))
when 4 # Bottom right corner when 4 # Bottom right corner
new_bitmap.blt(dest_x, dest_y, bitmap, new_bitmap.blt(dest_x, dest_y, bitmap,
Rect.new(SOURCE_TILE_WIDTH + frame * SOURCE_TILE_WIDTH * 3, SOURCE_TILE_HEIGHT * 5, Rect.new(SOURCE_TILE_WIDTH + (frame * SOURCE_TILE_WIDTH * 3), SOURCE_TILE_HEIGHT * 5,
SOURCE_TILE_WIDTH, SOURCE_TILE_HEIGHT)) SOURCE_TILE_WIDTH, SOURCE_TILE_HEIGHT))
when 8 # Bottom left corner when 8 # Bottom left corner
new_bitmap.blt(dest_x, dest_y, bitmap, new_bitmap.blt(dest_x, dest_y, bitmap,
@@ -89,7 +89,7 @@ class TileDrawingHelper
def bltSmallAutotile(bitmap, x, y, cxTile, cyTile, id, frame) def bltSmallAutotile(bitmap, x, y, cxTile, cyTile, id, frame)
return if id >= 384 || frame < 0 || !@autotiles return if id >= 384 || frame < 0 || !@autotiles
autotile = @autotiles[id / 48 - 1] autotile = @autotiles[(id / 48) - 1]
return if !autotile || autotile.disposed? return if !autotile || autotile.disposed?
cxTile = [cxTile / 2, 1].max cxTile = [cxTile / 2, 1].max
cyTile = [cyTile / 2, 1].max cyTile = [cyTile / 2, 1].max
@@ -104,8 +104,8 @@ class TileDrawingHelper
src = Rect.new(0, 0, 0, 0) src = Rect.new(0, 0, 0, 0)
for i in 0...4 for i in 0...4
tile_position = tiles[i] - 1 tile_position = tiles[i] - 1
src.set(tile_position % 6 * 16 + anim, tile_position / 6 * 16, 16, 16) src.set((tile_position % 6 * 16) + anim, tile_position / 6 * 16, 16, 16)
bitmap.stretch_blt(Rect.new(i % 2 * cxTile + x, i / 2 * cyTile + y, cxTile, cyTile), bitmap.stretch_blt(Rect.new((i % 2 * cxTile) + x, (i / 2 * cyTile) + y, cxTile, cyTile),
autotile, src) autotile, src)
end end
end end
@@ -180,9 +180,9 @@ def bltMinimapAutotile(dstBitmap, x, y, srcBitmap, id)
src = Rect.new(0, 0, 0, 0) src = Rect.new(0, 0, 0, 0)
for i in 0...4 for i in 0...4
tile_position = tiles[i] - 1 tile_position = tiles[i] - 1
src.set(tile_position % 6 * cxTile + anim, src.set((tile_position % 6 * cxTile) + anim,
tile_position / 6 * cyTile, cxTile, cyTile) tile_position / 6 * cyTile, cxTile, cyTile)
dstBitmap.blt(i % 2 * cxTile + x, i / 2 * cyTile + y, srcBitmap, src) dstBitmap.blt((i % 2 * cxTile) + x, (i / 2 * cyTile) + y, srcBitmap, src)
end end
end end
@@ -146,9 +146,10 @@ module MessageConfig
def self.pbTryFonts(*args) def self.pbTryFonts(*args)
for a in args for a in args
next if !a next if !a
if a.is_a?(String) case a
when String
return a if Font.exist?(a) return a if Font.exist?(a)
elsif a.is_a?(Array) when Array
for aa in a for aa in a
ret = MessageConfig.pbTryFonts(aa) ret = MessageConfig.pbTryFonts(aa)
return ret if ret != "" return ret if ret != ""
@@ -177,7 +178,7 @@ end
def pbBottomLeftLines(window, lines, width = nil) def pbBottomLeftLines(window, lines, width = nil)
window.x = 0 window.x = 0
window.width = width ? width : Graphics.width window.width = width ? width : Graphics.width
window.height = (window.borderY rescue 32) + lines * 32 window.height = (window.borderY rescue 32) + (lines * 32)
window.y = Graphics.height - window.height window.y = Graphics.height - window.height
end end
@@ -230,7 +231,7 @@ end
# internal function # internal function
def pbRepositionMessageWindow(msgwindow, linecount = 2) def pbRepositionMessageWindow(msgwindow, linecount = 2)
msgwindow.height = 32 * linecount + msgwindow.borderY msgwindow.height = (32 * linecount) + msgwindow.borderY
msgwindow.y = (Graphics.height) - (msgwindow.height) msgwindow.y = (Graphics.height) - (msgwindow.height)
if $game_system if $game_system
case $game_system.message_position case $game_system.message_position
@@ -278,10 +279,10 @@ def isDarkBackground(background, rect = nil)
return true if rect.width <= 0 || rect.height <= 0 return true if rect.width <= 0 || rect.height <= 0
xSeg = (rect.width / 16) xSeg = (rect.width / 16)
xLoop = (xSeg == 0) ? 1 : 16 xLoop = (xSeg == 0) ? 1 : 16
xStart = (xSeg == 0) ? rect.x + (rect.width / 2) : rect.x + xSeg / 2 xStart = (xSeg == 0) ? rect.x + (rect.width / 2) : rect.x + (xSeg / 2)
ySeg = (rect.height / 16) ySeg = (rect.height / 16)
yLoop = (ySeg == 0) ? 1 : 16 yLoop = (ySeg == 0) ? 1 : 16
yStart = (ySeg == 0) ? rect.y + (rect.height / 2) : rect.y + ySeg / 2 yStart = (ySeg == 0) ? rect.y + (rect.height / 2) : rect.y + (ySeg / 2)
count = 0 count = 0
y = yStart y = yStart
r = g = b = 0 r = g = b = 0
@@ -303,7 +304,7 @@ def isDarkBackground(background, rect = nil)
r /= count r /= count
g /= count g /= count
b /= count b /= count
return (r * 0.299 + g * 0.587 + b * 0.114) < 160 return ((r * 0.299) + (g * 0.587) + (b * 0.114)) < 160
end end
def isDarkWindowskin(windowskin) def isDarkWindowskin(windowskin)
@@ -316,7 +317,7 @@ def isDarkWindowskin(windowskin)
return isDarkBackground(windowskin, Rect.new(32, 16, 16, 16)) return isDarkBackground(windowskin, Rect.new(32, 16, 16, 16))
else else
clr = windowskin.get_pixel(windowskin.width / 2, windowskin.height / 2) clr = windowskin.get_pixel(windowskin.width / 2, windowskin.height / 2)
return (clr.red * 0.299 + clr.green * 0.587 + clr.blue * 0.114) < 160 return ((clr.red * 0.299) + (clr.green * 0.587) + (clr.blue * 0.114)) < 160
end end
end end
@@ -352,14 +353,14 @@ def getSkinColor(windowskin, color, isDarkSkin)
end end
# Special colour as listed above # Special colour as listed above
if isDarkSkin && color != 12 # Dark background, light text if isDarkSkin && color != 12 # Dark background, light text
return sprintf("<c3=%s,%s>", textcolors[2 * (color - 1) + 1], textcolors[2 * (color - 1)]) return sprintf("<c3=%s,%s>", textcolors[(2 * (color - 1)) + 1], textcolors[2 * (color - 1)])
end end
# Light background, dark text # Light background, dark text
return sprintf("<c3=%s,%s>", textcolors[2 * (color - 1)], textcolors[2 * (color - 1) + 1]) return sprintf("<c3=%s,%s>", textcolors[2 * (color - 1)], textcolors[(2 * (color - 1)) + 1])
else # VX windowskin else # VX windowskin
color = 0 if color >= 32 color = 0 if color >= 32
x = 64 + (color % 8) * 8 x = 64 + ((color % 8) * 8)
y = 96 + (color / 8) * 8 y = 96 + ((color / 8) * 8)
pixel = windowskin.get_pixel(x, y) pixel = windowskin.get_pixel(x, y)
return shadowctagFromColor(pixel) return shadowctagFromColor(pixel)
end end
@@ -441,10 +442,10 @@ def pbSrcOver(dstColor, srcColor)
cg = dstColor.green * dstColor.alpha / 255 cg = dstColor.green * dstColor.alpha / 255
cb = dstColor.blue * dstColor.alpha / 255 cb = dstColor.blue * dstColor.alpha / 255
ica = 255 - dstColor.alpha ica = 255 - dstColor.alpha
a = 255 - (iea * ica) / 255 a = 255 - ((iea * ica) / 255)
r = (iea * cr) / 255 + er r = ((iea * cr) / 255) + er
g = (iea * cg) / 255 + eg g = ((iea * cg) / 255) + eg
b = (iea * cb) / 255 + eb b = ((iea * cb) / 255) + eb
r = (a == 0) ? 0 : r * 255 / a r = (a == 0) ? 0 : r * 255 / a
g = (a == 0) ? 0 : g * 255 / a g = (a == 0) ? 0 : g * 255 / a
b = (a == 0) ? 0 : b * 255 / a b = (a == 0) ? 0 : b * 255 / a
@@ -463,7 +463,7 @@ class Window
pauseWidth = 16 pauseWidth = 16
pauseHeight = 16 pauseHeight = 16
@sprites["pause"].src_rect.set(pauseRects[@pauseframe * 2], @sprites["pause"].src_rect.set(pauseRects[@pauseframe * 2],
pauseRects[@pauseframe * 2 + 1], pauseRects[(@pauseframe * 2) + 1],
pauseWidth, pauseWidth,
pauseHeight) pauseHeight)
@sprites["pause"].x = @x + (@width / 2) - (pauseWidth / 2) @sprites["pause"].x = @x + (@width / 2) - (pauseWidth / 2)
@@ -486,13 +486,13 @@ class Window
@sprites["side2"].y = @y + 16 @sprites["side2"].y = @y + 16
@sprites["side3"].x = @x + 16 @sprites["side3"].x = @x + 16
@sprites["side3"].y = @y + @height - 16 @sprites["side3"].y = @y + @height - 16
@sprites["scroll0"].x = @x + @width / 2 - 8 @sprites["scroll0"].x = @x + (@width / 2) - 8
@sprites["scroll0"].y = @y + 8 @sprites["scroll0"].y = @y + 8
@sprites["scroll1"].x = @x + 8 @sprites["scroll1"].x = @x + 8
@sprites["scroll1"].y = @y + @height / 2 - 8 @sprites["scroll1"].y = @y + (@height / 2) - 8
@sprites["scroll2"].x = @x + @width - 16 @sprites["scroll2"].x = @x + @width - 16
@sprites["scroll2"].y = @y + @height / 2 - 8 @sprites["scroll2"].y = @y + (@height / 2) - 8
@sprites["scroll3"].x = @x + @width / 2 - 8 @sprites["scroll3"].x = @x + (@width / 2) - 8
@sprites["scroll3"].y = @y + @height - 16 @sprites["scroll3"].y = @y + @height - 16
@sprites["back"].x = @x + 2 @sprites["back"].x = @x + 2
@sprites["back"].y = @y + 2 @sprites["back"].y = @y + 2
@@ -575,7 +575,7 @@ class Window
opn = @openness / 255.0 opn = @openness / 255.0
for k in @spritekeys for k in @spritekeys
sprite = @sprites[k] sprite = @sprites[k]
ratio = (@height <= 0) ? 0 : (sprite.y - @y) * 1.0 / @height ratio = (@height <= 0) ? 0 : (sprite.y - @y) / @height.to_f
sprite.zoom_y = opn sprite.zoom_y = opn
sprite.oy = 0 sprite.oy = 0
sprite.y = (@y + (@height / 2.0) + (@height * ratio * opn) - (@height / 2 * opn)).floor sprite.y = (@y + (@height / 2.0) + (@height * ratio * opn) - (@height / 2 * opn)).floor
@@ -578,23 +578,19 @@ class SpriteWindow < Window
@sprites["scroll2"].src_rect.set(trimX + 40, trimY + 24, 8, 16) # right @sprites["scroll2"].src_rect.set(trimX + 40, trimY + 24, 8, 16) # right
cursorX = trimX cursorX = trimX
cursorY = trimY + 64 cursorY = trimY + 64
sideRects = [ sideRects = [Rect.new(trimX + 16, trimY + 0, 32, 16),
Rect.new(trimX + 16, trimY + 0, 32, 16),
Rect.new(trimX, trimY + 16, 16, 32), Rect.new(trimX, trimY + 16, 16, 32),
Rect.new(trimX + 48, trimY + 16, 16, 32), Rect.new(trimX + 48, trimY + 16, 16, 32),
Rect.new(trimX + 16, trimY + 48, 32, 16) Rect.new(trimX + 16, trimY + 48, 32, 16)]
] pauseRects = [trimX + 32, trimY + 64,
pauseRects = [
trimX + 32, trimY + 64,
trimX + 48, trimY + 64, trimX + 48, trimY + 64,
trimX + 32, trimY + 80, trimX + 32, trimY + 80,
trimX + 48, trimY + 80 trimX + 48, trimY + 80]
]
pauseWidth = 16 pauseWidth = 16
pauseHeight = 16 pauseHeight = 16
@sprites["pause"].src_rect.set( @sprites["pause"].src_rect.set(
pauseRects[@pauseframe * 2], pauseRects[@pauseframe * 2],
pauseRects[@pauseframe * 2 + 1], pauseRects[(@pauseframe * 2) + 1],
pauseWidth, pauseHeight pauseWidth, pauseHeight
) )
end end
@@ -664,13 +660,13 @@ class SpriteWindow < Window
@sprites["side2"].y = @y + startY @sprites["side2"].y = @y + startY
@sprites["side3"].x = @x + startX @sprites["side3"].x = @x + startX
@sprites["side3"].y = @y + @height - endY @sprites["side3"].y = @y + @height - endY
@sprites["scroll0"].x = @x + @width / 2 - 8 @sprites["scroll0"].x = @x + (@width / 2) - 8
@sprites["scroll0"].y = @y + 8 @sprites["scroll0"].y = @y + 8
@sprites["scroll1"].x = @x + 8 @sprites["scroll1"].x = @x + 8
@sprites["scroll1"].y = @y + @height / 2 - 8 @sprites["scroll1"].y = @y + (@height / 2) - 8
@sprites["scroll2"].x = @x + @width - 16 @sprites["scroll2"].x = @x + @width - 16
@sprites["scroll2"].y = @y + @height / 2 - 8 @sprites["scroll2"].y = @y + (@height / 2) - 8
@sprites["scroll3"].x = @x + @width / 2 - 8 @sprites["scroll3"].x = @x + (@width / 2) - 8
@sprites["scroll3"].y = @y + @height - 16 @sprites["scroll3"].y = @y + @height - 16
@sprites["cursor"].x = @x + startX + @cursor_rect.x @sprites["cursor"].x = @x + startX + @cursor_rect.x
@sprites["cursor"].y = @y + startY + @cursor_rect.y @sprites["cursor"].y = @y + startY + @cursor_rect.y
@@ -789,7 +785,7 @@ class SpriteWindow < Window
opn = @openness / 255.0 opn = @openness / 255.0
for k in @spritekeys for k in @spritekeys
sprite = @sprites[k] sprite = @sprites[k]
ratio = (@height <= 0) ? 0 : (sprite.y - @y) * 1.0 / @height ratio = (@height <= 0) ? 0 : (sprite.y - @y) / @height.to_f
sprite.zoom_y = opn sprite.zoom_y = opn
sprite.zoom_x = 1.0 sprite.zoom_x = 1.0
sprite.oy = 0 sprite.oy = 0
@@ -845,8 +841,8 @@ class SpriteWindow_Base < SpriteWindow
end end
def __setWindowskin(skin) def __setWindowskin(skin)
if skin && (skin.width == 192 && skin.height == 128) || # RPGXP Windowskin if skin && ((skin.width == 192 && skin.height == 128) || # RPGXP Windowskin
(skin.width == 128 && skin.height == 128) # RPGVX Windowskin (skin.width == 128 && skin.height == 128)) # RPGVX Windowskin
self.skinformat = 0 self.skinformat = 0
else else
self.skinformat = 1 self.skinformat = 1
@@ -621,7 +621,7 @@ class Window_InputNumberPokemon < SpriteWindow_Base
@sign = false @sign = false
@negative = false @negative = false
super(0, 0, 32, 32) super(0, 0, 32, 32)
self.width = digits_max * 24 + 8 + self.borderX self.width = (digits_max * 24) + 8 + self.borderX
self.height = 32 + self.borderY self.height = 32 + self.borderY
colors = getDefaultTextColors(self.windowskin) colors = getDefaultTextColors(self.windowskin)
@baseColor = colors[0] @baseColor = colors[0]
@@ -644,16 +644,16 @@ class Window_InputNumberPokemon < SpriteWindow_Base
value = 0 if !value.is_a?(Numeric) value = 0 if !value.is_a?(Numeric)
if @sign if @sign
@negative = (value < 0) @negative = (value < 0)
@number = [value.abs, 10**@digits_max - 1].min @number = [value.abs, (10**@digits_max) - 1].min
else else
@number = [[value, 0].max, 10**@digits_max - 1].min @number = [[value, 0].max, (10**@digits_max) - 1].min
end end
refresh refresh
end end
def sign=(value) def sign=(value)
@sign = value @sign = value
self.width = @digits_max * 24 + 8 + self.borderX + (@sign ? 24 : 0) self.width = (@digits_max * 24) + 8 + self.borderX + (@sign ? 24 : 0)
@index = (@digits_max - 1) + (@sign ? 1 : 0) @index = (@digits_max - 1) + (@sign ? 1 : 0)
refresh refresh
end end
@@ -717,9 +717,9 @@ class Window_InputNumberPokemon < SpriteWindow_Base
def textHelper(x, y, text, i) def textHelper(x, y, text, i)
textwidth = self.contents.text_size(text).width textwidth = self.contents.text_size(text).width
pbDrawShadowText(self.contents, x + (12 - textwidth / 2), y, textwidth + 4, 32, text, @baseColor, @shadowColor) pbDrawShadowText(self.contents, x + (12 - (textwidth / 2)), y, textwidth + 4, 32, text, @baseColor, @shadowColor)
if @index == i && @active && @frame / 15 == 0 if @index == i && @active && @frame / 15 == 0
self.contents.fill_rect(x + (12 - textwidth / 2), y + 30, textwidth, 2, @baseColor) self.contents.fill_rect(x + (12 - (textwidth / 2)), y + 30, textwidth, 2, @baseColor)
end end
end end
end end
@@ -825,9 +825,9 @@ class SpriteWindow_Selectable < SpriteWindow_Base
item > self.top_item + self.page_item_max item > self.top_item + self.page_item_max
return Rect.new(0, 0, 0, 0) return Rect.new(0, 0, 0, 0)
else else
cursor_width = (self.width - self.borderX - (@column_max - 1) * @column_spacing) / @column_max cursor_width = (self.width - self.borderX - ((@column_max - 1) * @column_spacing)) / @column_max
x = item % @column_max * (cursor_width + @column_spacing) x = item % @column_max * (cursor_width + @column_spacing)
y = item / @column_max * @row_height - @virtualOy y = (item / @column_max * @row_height) - @virtualOy
return Rect.new(x, y, cursor_width, @row_height) return Rect.new(x, y, cursor_width, @row_height)
end end
end end
@@ -946,7 +946,7 @@ class SpriteWindow_Selectable < SpriteWindow_Base
# End of code # End of code
cursor_width = (self.width - self.borderX) / @column_max cursor_width = (self.width - self.borderX) / @column_max
x = self.index % @column_max * (cursor_width + @column_spacing) x = self.index % @column_max * (cursor_width + @column_spacing)
y = self.index / @column_max * @row_height - @virtualOy y = (self.index / @column_max * @row_height) - @virtualOy
self.cursor_rect.set(x, y, cursor_width, @row_height) self.cursor_rect.set(x, y, cursor_width, @row_height)
self.refresh if dorefresh || force self.refresh if dorefresh || force
end end
@@ -992,8 +992,8 @@ module UpDownArrowMixin
def adjustForZoom(sprite) def adjustForZoom(sprite)
sprite.zoom_x = self.zoom_x sprite.zoom_x = self.zoom_x
sprite.zoom_y = self.zoom_y sprite.zoom_y = self.zoom_y
sprite.x = sprite.x * self.zoom_x + self.offset_x / self.zoom_x sprite.x = (sprite.x * self.zoom_x) + (self.offset_x / self.zoom_x)
sprite.y = sprite.y * self.zoom_y + self.offset_y / self.zoom_y sprite.y = (sprite.y * self.zoom_y) + (self.offset_y / self.zoom_y)
end end
def update def update
@@ -1093,7 +1093,7 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
end end
# Store suggested width and height of window # Store suggested width and height of window
dims[0] = [self.borderX + 1, dims[0] = [self.borderX + 1,
(width * self.columns) + self.borderX + (self.columns - 1) * self.columnSpacing].max (width * self.columns) + self.borderX + ((self.columns - 1) * self.columnSpacing)].max
dims[1] = [self.borderY + 1, windowheight].max dims[1] = [self.borderY + 1, windowheight].max
dims[1] = [dims[1], Graphics.height].min dims[1] = [dims[1], Graphics.height].min
end end
@@ -94,12 +94,13 @@ class PictureWindow < SpriteWindow_Base
def setBitmap(pathOrBitmap, hue = 0) def setBitmap(pathOrBitmap, hue = 0)
clearBitmaps clearBitmaps
if pathOrBitmap != nil && pathOrBitmap != "" if pathOrBitmap != nil && pathOrBitmap != ""
if pathOrBitmap.is_a?(Bitmap) case pathOrBitmap
when Bitmap
@_iconbitmap = pathOrBitmap @_iconbitmap = pathOrBitmap
self.contents = @_iconbitmap self.contents = @_iconbitmap
self.width = @_iconbitmap.width + self.borderX self.width = @_iconbitmap.width + self.borderX
self.height = @_iconbitmap.height + self.borderY self.height = @_iconbitmap.height + self.borderY
elsif pathOrBitmap.is_a?(AnimatedBitmap) when AnimatedBitmap
@_iconbitmap = pathOrBitmap @_iconbitmap = pathOrBitmap
self.contents = @_iconbitmap.bitmap self.contents = @_iconbitmap.bitmap
self.width = @_iconbitmap.bitmap.width + self.borderX self.width = @_iconbitmap.bitmap.width + self.borderX
@@ -98,9 +98,9 @@ def getContrastColor(color)
g = color.green g = color.green
b = color.blue b = color.blue
yuv = [ yuv = [
r * 0.299 + g * 0.587 + b * 0.114, (r * 0.299) + (g * 0.587) + (b * 0.114),
r * -0.1687 + g * -0.3313 + b * 0.500 + 0.5, (r * -0.1687) + (g * -0.3313) + (b * 0.500) + 0.5,
r * 0.500 + g * -0.4187 + b * -0.0813 + 0.5 (r * 0.500) + (g * -0.4187) + (b * -0.0813) + 0.5
] ]
if yuv[0] < 127.5 if yuv[0] < 127.5
yuv[0] += (255 - yuv[0]) / 2 yuv[0] += (255 - yuv[0]) / 2
@@ -108,9 +108,9 @@ def getContrastColor(color)
yuv[0] = yuv[0] / 2 yuv[0] = yuv[0] / 2
end end
return Color.new( return Color.new(
yuv[0] + 1.4075 * (yuv[2] - 0.5), yuv[0] + (1.4075 * (yuv[2] - 0.5)),
yuv[0] - 0.3455 * (yuv[1] - 0.5) - 0.7169 * (yuv[2] - 0.5), yuv[0] - (0.3455 * (yuv[1] - 0.5)) - (0.7169 * (yuv[2] - 0.5)),
yuv[0] + 1.7790 * (yuv[1] - 0.5), yuv[0] + (1.7790 * (yuv[1] - 0.5)),
color.alpha color.alpha
) )
end end
@@ -198,7 +198,7 @@ def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheig
if textchars[position] == "\n" if textchars[position] == "\n"
if newlineBreaks # treat newline as break if newlineBreaks # treat newline as break
havenl = true havenl = true
characters.push(["\n", x, y * lineheight + yDst, 0, lineheight, false, false, characters.push(["\n", x, (y * lineheight) + yDst, 0, lineheight, false, false,
false, colorclone, nil, false, false, "", 8, position, nil, 0]) false, colorclone, nil, false, false, "", 8, position, nil, 0])
y += 1 y += 1
x = 0 x = 0
@@ -224,18 +224,16 @@ def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheig
# Push character # Push character
if heightDst < 0 || yStart < yDst + heightDst if heightDst < 0 || yStart < yDst + heightDst
havenl = true if isWaitChar(textchars[position]) havenl = true if isWaitChar(textchars[position])
characters.push([ characters.push([textchars[position],
textchars[position],
x + xStart, texty, width + 2, lineheight, x + xStart, texty, width + 2, lineheight,
false, bold, italic, colorclone, nil, false, false, false, bold, italic, colorclone, nil, false, false,
defaultfontname, bitmap.font.size, position, nil, 0 defaultfontname, bitmap.font.size, position, nil, 0])
])
end end
x += width x += width
if !explicitBreaksOnly && x + 2 > widthDst && lastword[1] != 0 && if !explicitBreaksOnly && x + 2 > widthDst && lastword[1] != 0 &&
(!hadnonspace || !hadspace) (!hadnonspace || !hadspace)
havenl = true havenl = true
characters.insert(lastword[0], ["\n", x, y * lineheight + yDst, 0, lineheight, characters.insert(lastword[0], ["\n", x, (y * lineheight) + yDst, 0, lineheight,
false, false, false, colorclone, nil, false, false, "", 8, position]) false, false, false, colorclone, nil, false, false, "", 8, position])
lastword[0] += 1 lastword[0] += 1
y += 1 y += 1
@@ -626,7 +624,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end end
nextline.times do nextline.times do
havenl = true havenl = true
characters.push(["\n", x, y * lineheight + yDst, 0, lineheight, false, false, false, characters.push(["\n", x, (y * lineheight) + yDst, 0, lineheight, false, false, false,
defaultcolors[0], defaultcolors[1], false, false, "", 8, position, nil, 0]) defaultcolors[0], defaultcolors[1], false, false, "", 8, position, nil, 0])
charactersInternal.push([alignment, y, 0]) charactersInternal.push([alignment, y, 0])
y += 1 y += 1
@@ -640,7 +638,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
if newlineBreaks if newlineBreaks
if nextline == 0 if nextline == 0
havenl = true havenl = true
characters.push(["\n", x, y * lineheight + yDst, 0, lineheight, false, false, false, characters.push(["\n", x, (y * lineheight) + yDst, 0, lineheight, false, false, false,
defaultcolors[0], defaultcolors[1], false, false, "", 8, position, nil, 0]) defaultcolors[0], defaultcolors[1], false, false, "", 8, position, nil, 0])
charactersInternal.push([alignment, y, 0]) charactersInternal.push([alignment, y, 0])
y += 1 y += 1
@@ -675,22 +673,20 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
if heightDst < 0 || texty < yDst + heightDst if heightDst < 0 || texty < yDst + heightDst
havenl = true if !graphic && isWaitChar(textchars[position]) havenl = true if !graphic && isWaitChar(textchars[position])
extraspace = (!graphic && italiccount > 0) ? 2 + (width / 2) : 2 extraspace = (!graphic && italiccount > 0) ? 2 + (width / 2) : 2
characters.push([ characters.push([graphic || textchars[position],
graphic || textchars[position],
x + xStart, texty, width + extraspace, lineheight, x + xStart, texty, width + extraspace, lineheight,
graphic ? true : false, graphic ? true : false,
(boldcount > 0), (italiccount > 0), colors[0], colors[1], (boldcount > 0), (italiccount > 0), colors[0], colors[1],
(underlinecount > 0), (strikecount > 0), fontname, fontsize, (underlinecount > 0), (strikecount > 0), fontname, fontsize,
position, graphicRect, position, graphicRect,
((outlinecount > 0) ? 1 : 0) + ((outline2count > 0) ? 2 : 0) ((outlinecount > 0) ? 1 : 0) + ((outline2count > 0) ? 2 : 0)])
])
charactersInternal.push([alignment, y, xStart, textchars[position], extraspace]) charactersInternal.push([alignment, y, xStart, textchars[position], extraspace])
end end
x += width x += width
if !explicitBreaksOnly && x + 2 > widthDst && lastword[1] != 0 && if !explicitBreaksOnly && x + 2 > widthDst && lastword[1] != 0 &&
(!hadnonspace || !hadspace) (!hadnonspace || !hadspace)
havenl = true havenl = true
characters.insert(lastword[0], ["\n", x, y * lineheight + yDst, 0, lineheight, characters.insert(lastword[0], ["\n", x, (y * lineheight) + yDst, 0, lineheight,
false, false, false, false, false, false,
defaultcolors[0], defaultcolors[1], defaultcolors[0], defaultcolors[1],
false, false, "", 8, position, nil]) false, false, "", 8, position, nil])
@@ -1045,8 +1041,8 @@ def drawSingleFormattedChar(bitmap, ch)
end end
bitmap.font.color = ch[8] if bitmap.font.color != ch[8] bitmap.font.color = ch[8] if bitmap.font.color != ch[8]
bitmap.draw_text(ch[1] + offset, ch[2] + offset, ch[3], ch[4], ch[0]) bitmap.draw_text(ch[1] + offset, ch[2] + offset, ch[3], ch[4], ch[0])
else elsif bitmap.font.color != ch[8]
bitmap.font.color = ch[8] if bitmap.font.color != ch[8] bitmap.font.color = ch[8]
end end
if ch[10] # underline if ch[10] # underline
bitmap.fill_rect(ch[1], ch[2] + ch[4] - 4 - [(ch[4] - bitmap.font.size) / 2, 0].max - 2, bitmap.fill_rect(ch[1], ch[2] + ch[4] - 4 - [(ch[4] - bitmap.font.size) / 2, 0].max - 2,
@@ -224,10 +224,9 @@ class FaceWindowVX < SpriteWindow_Base
@faceIndex = faceinfo[1].to_i @faceIndex = faceinfo[1].to_i
@facebitmaptmp = AnimatedBitmap.new(facefile) @facebitmaptmp = AnimatedBitmap.new(facefile)
@facebitmap = BitmapWrapper.new(96, 96) @facebitmap = BitmapWrapper.new(96, 96)
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap, Rect.new( @facebitmap.blt(0, 0, @facebitmaptmp.bitmap,
(@faceIndex % 4) * 96, Rect.new((@faceIndex % 4) * 96, (@faceIndex / 4) * 96, 96, 96)
(@faceIndex / 4) * 96, 96, 96 )
))
self.contents = @facebitmap self.contents = @facebitmap
end end
@@ -235,10 +234,9 @@ class FaceWindowVX < SpriteWindow_Base
super super
if @facebitmaptmp.totalFrames > 1 if @facebitmaptmp.totalFrames > 1
@facebitmaptmp.update @facebitmaptmp.update
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap, Rect.new( @facebitmap.blt(0, 0, @facebitmaptmp.bitmap,
(@faceIndex % 4) * 96, Rect.new((@faceIndex % 4) * 96, (@faceIndex / 4) * 96, 96, 96)
(@faceIndex / 4) * 96, 96, 96 )
))
end end
end end
@@ -581,7 +579,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
if atTop if atTop
msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime
else else
msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime)
end end
end end
for i in 0...controls.length for i in 0...controls.length
@@ -627,7 +625,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
msgwindow.y = Graphics.height - msgwindow.height msgwindow.y = Graphics.height - msgwindow.height
msgback.y = msgwindow.y if msgback msgback.y = msgwindow.y if msgback
pbPositionNearMsgWindow(facewindow, msgwindow, :left) pbPositionNearMsgWindow(facewindow, msgwindow, :left)
msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime)
when "ts" # Change text speed when "ts" # Change text speed
msgwindow.textspeed = (param == "") ? -999 : param.to_i msgwindow.textspeed = (param == "") ? -999 : param.to_i
when "." # Wait 0.25 seconds when "." # Wait 0.25 seconds
@@ -662,8 +660,8 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
if msgwindow.busy? if msgwindow.busy?
pbPlayDecisionSE if msgwindow.pausing? pbPlayDecisionSE if msgwindow.pausing?
msgwindow.resume msgwindow.resume
else elsif signWaitCount == 0
break if signWaitCount == 0 break
end end
end end
pbUpdateSceneMap pbUpdateSceneMap
@@ -692,7 +690,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
if atTop if atTop
msgwindow.y = -msgwindow.height * i / signWaitTime msgwindow.y = -msgwindow.height * i / signWaitTime
else else
msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - i) / signWaitTime msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - i) / signWaitTime)
end end
Graphics.update Graphics.update
Input.update Input.update
@@ -453,10 +453,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
totalColumns = getColumnsInLine(@cursorLine) totalColumns = getColumnsInLine(@cursorLine)
@cursorColumn = totalColumns if @cursorColumn > totalColumns @cursorColumn = totalColumns if @cursorColumn > totalColumns
@cursorColumn = 0 if @cursorColumn < 0 # totalColumns can be 0 @cursorColumn = 0 if @cursorColumn < 0 # totalColumns can be 0
updateCursorPos( updateCursorPos(oldCursorLine != @cursorLine || oldCursorColumn != @cursorColumn)
oldCursorLine != @cursorLine ||
oldCursorColumn != @cursorColumn
)
# echoln ["aftermoving",@cursorLine,@cursorColumn] # echoln ["aftermoving",@cursorLine,@cursorColumn]
end end
+1 -1
View File
@@ -128,7 +128,7 @@ def getPlayTime2(filename)
data = fgetdw.call(file) data = fgetdw.call(file)
return -1 if data != 0x61746164 # "data" return -1 if data != 0x61746164 # "data"
datasize = fgetdw.call(file) datasize = fgetdw.call(file)
time = (datasize * 1.0) / bytessec time = datasize.to_f / bytessec
return time return time
when 0x5367674F # "OggS" when 0x5367674F # "OggS"
file.pos = 0 file.pos = 0
+57 -57
View File
@@ -178,7 +178,7 @@ module Transitions
sprite_height = @overworld_bitmap.height / NUM_SPRITES_Y sprite_height = @overworld_bitmap.height / NUM_SPRITES_Y
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_sprite = j * NUM_SPRITES_X + i idx_sprite = (j * NUM_SPRITES_X) + i
@sprites[idx_sprite] = new_sprite(i * sprite_width, j * sprite_height, @overworld_bitmap) @sprites[idx_sprite] = new_sprite(i * sprite_width, j * sprite_height, @overworld_bitmap)
@sprites[idx_sprite].src_rect.set(i * sprite_width, j * sprite_height, sprite_width, sprite_height) @sprites[idx_sprite].src_rect.set(i * sprite_width, j * sprite_height, sprite_width, sprite_height)
end end
@@ -189,7 +189,7 @@ module Transitions
@start_y = [] @start_y = []
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_sprite = j * NUM_SPRITES_X + i idx_sprite = (j * NUM_SPRITES_X) + i
@start_y[idx_sprite] = @sprites[idx_sprite].y @start_y[idx_sprite] = @sprites[idx_sprite].y
@timings[idx_sprite] = 0.5 + rand @timings[idx_sprite] = 0.5 + rand
end end
@@ -199,7 +199,7 @@ module Transitions
def update_anim def update_anim
proportion = @timer / @duration proportion = @timer / @duration
@sprites.each_with_index do |sprite, i| @sprites.each_with_index do |sprite, i|
sprite.y = @start_y[i] + Graphics.height * @timings[i] * proportion * proportion sprite.y = @start_y[i] + (Graphics.height * @timings[i] * proportion * proportion)
sprite.opacity = 255 * (1 - proportion) sprite.opacity = 255 * (1 - proportion)
end end
end end
@@ -219,7 +219,7 @@ module Transitions
sprite_height = @overworld_bitmap.height / NUM_SPRITES_Y sprite_height = @overworld_bitmap.height / NUM_SPRITES_Y
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_sprite = j * NUM_SPRITES_X + i idx_sprite = (j * NUM_SPRITES_X) + i
@sprites[idx_sprite] = new_sprite((i + 0.5) * sprite_width, (j + 0.5) * sprite_height, @sprites[idx_sprite] = new_sprite((i + 0.5) * sprite_width, (j + 0.5) * sprite_height,
@overworld_bitmap, sprite_width / 2, sprite_height / 2) @overworld_bitmap, sprite_width / 2, sprite_height / 2)
@sprites[idx_sprite].src_rect.set(i * sprite_width, j * sprite_height, sprite_width, sprite_height) @sprites[idx_sprite].src_rect.set(i * sprite_width, j * sprite_height, sprite_width, sprite_height)
@@ -230,10 +230,10 @@ module Transitions
def update_anim def update_anim
proportion = @timer / @duration proportion = @timer / @duration
@sprites.each_with_index do |sprite, i| @sprites.each_with_index do |sprite, i|
sprite.zoom_x = 1.0 * (1 - proportion) sprite.zoom_x = (1 - proportion).to_f
sprite.zoom_y = sprite.zoom_x sprite.zoom_y = sprite.zoom_x
if @parameters[0] # Rotation if @parameters[0] # Rotation
direction = (1 - 2 * ((i / NUM_SPRITES_X + i % NUM_SPRITES_X) % 2)) direction = (1 - (2 * (((i / NUM_SPRITES_X) + (i % NUM_SPRITES_X)) % 2)))
sprite.angle = direction * 360 * 2 * proportion sprite.angle = direction * 360 * 2 * proportion
end end
end end
@@ -258,7 +258,7 @@ module Transitions
sprite_height = @overworld_bitmap.height / NUM_SPRITES_Y sprite_height = @overworld_bitmap.height / NUM_SPRITES_Y
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_sprite = j * NUM_SPRITES_X + i idx_sprite = (j * NUM_SPRITES_X) + i
@sprites[idx_sprite] = new_sprite((i + 0.5) * sprite_width, (j + 0.5) * sprite_height, @sprites[idx_sprite] = new_sprite((i + 0.5) * sprite_width, (j + 0.5) * sprite_height,
@overworld_bitmap, sprite_width / 2, sprite_height / 2) @overworld_bitmap, sprite_width / 2, sprite_height / 2)
@sprites[idx_sprite].src_rect.set(i * sprite_width, j * sprite_height, sprite_width, sprite_height) @sprites[idx_sprite].src_rect.set(i * sprite_width, j * sprite_height, sprite_width, sprite_height)
@@ -272,17 +272,17 @@ module Transitions
vague = (@parameters[0] || 9.6) * SPEED vague = (@parameters[0] || 9.6) * SPEED
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_sprite = j * NUM_SPRITES_X + i idx_sprite = (j * NUM_SPRITES_X) + i
spr = @sprites[idx_sprite] spr = @sprites[idx_sprite]
@start_positions[idx_sprite] = [spr.x, spr.y] @start_positions[idx_sprite] = [spr.x, spr.y]
dx = spr.x - Graphics.width / 2 dx = spr.x - (Graphics.width / 2)
dy = spr.y - Graphics.height / 2 dy = spr.y - (Graphics.height / 2)
move_x = move_y = 0 move_x = move_y = 0
if dx == 0 && dy == 0 if dx == 0 && dy == 0
move_x = (dx == 0) ? rand_sign * vague : dx * SPEED * 1.5 move_x = (dx == 0) ? rand_sign * vague : dx * SPEED * 1.5
move_y = (dy == 0) ? rand_sign * vague : dy * SPEED * 1.5 move_y = (dy == 0) ? rand_sign * vague : dy * SPEED * 1.5
else else
radius = Math.sqrt(dx**2 + dy**2) radius = Math.sqrt((dx**2) + (dy**2))
move_x = dx * vague / radius move_x = dx * vague / radius
move_y = dy * vague / radius move_y = dy * vague / radius
end end
@@ -296,8 +296,8 @@ module Transitions
def update_anim def update_anim
proportion = @timer / @duration proportion = @timer / @duration
@sprites.each_with_index do |sprite, i| @sprites.each_with_index do |sprite, i|
sprite.x = @start_positions[i][0] + @move_vectors[i][0] * proportion sprite.x = @start_positions[i][0] + (@move_vectors[i][0] * proportion)
sprite.y = @start_positions[i][1] + @move_vectors[i][1] * proportion sprite.y = @start_positions[i][1] + (@move_vectors[i][1] * proportion)
sprite.opacity = 384 * (1 - proportion) sprite.opacity = 384 * (1 - proportion)
end end
end end
@@ -331,7 +331,7 @@ module Transitions
end end
for j in 0...num_stripes_y for j in 0...num_stripes_y
for i in 0...num_stripes_x for i in 0...num_stripes_x
idx_sprite = j * num_stripes_x + i idx_sprite = (j * num_stripes_x) + i
@sprites[idx_sprite] = new_sprite(i * sprite_width, j * sprite_height, @overworld_bitmap) @sprites[idx_sprite] = new_sprite(i * sprite_width, j * sprite_height, @overworld_bitmap)
@sprites[idx_sprite].src_rect.set(i * sprite_width, j * sprite_height, sprite_width, sprite_height) @sprites[idx_sprite].src_rect.set(i * sprite_width, j * sprite_height, sprite_width, sprite_height)
end end
@@ -367,7 +367,7 @@ module Transitions
def update_anim def update_anim
proportion = @timer / @duration proportion = @timer / @duration
@overworld_sprite.zoom_x = 1.0 + 7.0 * proportion @overworld_sprite.zoom_x = 1 + (7 * proportion)
@overworld_sprite.zoom_y = @overworld_sprite.zoom_x @overworld_sprite.zoom_y = @overworld_sprite.zoom_x
@overworld_sprite.opacity = 255 * (1 - proportion) @overworld_sprite.opacity = 255 * (1 - proportion)
end end
@@ -410,7 +410,7 @@ module Transitions
def update_anim def update_anim
proportion = @timer / @duration proportion = @timer / @duration
inv_proportion = 1 / (1 + proportion * (MAX_PIXELLATION_FACTOR - 1)) inv_proportion = 1 / (1 + (proportion * (MAX_PIXELLATION_FACTOR - 1)))
new_size_rect = Rect.new(0, 0, @overworld_bitmap.width * inv_proportion, new_size_rect = Rect.new(0, 0, @overworld_bitmap.width * inv_proportion,
@overworld_bitmap.height * inv_proportion) @overworld_bitmap.height * inv_proportion)
# Take all of buffer_original, shrink it and put it into buffer_temp # Take all of buffer_original, shrink it and put it into buffer_temp
@@ -420,7 +420,7 @@ module Transitions
@overworld_bitmap.stretch_blt(Rect.new(0, 0, @overworld_bitmap.width, @overworld_bitmap.height), @overworld_bitmap.stretch_blt(Rect.new(0, 0, @overworld_bitmap.width, @overworld_bitmap.height),
@buffer_temp, new_size_rect) @buffer_temp, new_size_rect)
if @timer >= @start_black_fade if @timer >= @start_black_fade
@overworld_sprite.opacity = 255 * (1 - (@timer - @start_black_fade) / (@duration - @start_black_fade)) @overworld_sprite.opacity = 255 * (1 - ((@timer - @start_black_fade) / (@duration - @start_black_fade)))
end end
end end
end end
@@ -466,7 +466,7 @@ module Transitions
def initialize_sprites def initialize_sprites
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_sprite = j * NUM_SPRITES_X + i idx_sprite = (j * NUM_SPRITES_X) + i
if idx_sprite >= TOTAL_SPRITES / 2 if idx_sprite >= TOTAL_SPRITES / 2
sprite_x = ((j.odd?) ? i : (NUM_SPRITES_X - i - 1)) * @black_bitmap.width sprite_x = ((j.odd?) ? i : (NUM_SPRITES_X - i - 1)) * @black_bitmap.width
else else
@@ -485,7 +485,7 @@ module Transitions
time_between_zooms = (@duration - TIME_TO_ZOOM) * 2 / (TOTAL_SPRITES - 1) time_between_zooms = (@duration - TIME_TO_ZOOM) * 2 / (TOTAL_SPRITES - 1)
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_sprite = j * NUM_SPRITES_X + i idx_sprite = (j * NUM_SPRITES_X) + i
idx_from_start = (idx_sprite >= TOTAL_SPRITES / 2) ? TOTAL_SPRITES - 1 - idx_sprite : idx_sprite idx_from_start = (idx_sprite >= TOTAL_SPRITES / 2) ? TOTAL_SPRITES - 1 - idx_sprite : idx_sprite
@timings[idx_sprite] = time_between_zooms * idx_from_start @timings[idx_sprite] = time_between_zooms * idx_from_start
end end
@@ -534,9 +534,9 @@ module Transitions
def initialize_sprites def initialize_sprites
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_sprite = j * NUM_SPRITES_X + i idx_sprite = (j * NUM_SPRITES_X) + i
@sprites[idx_sprite] = new_sprite((i * @bitmap.width + @bitmap.width / 2) * @zoom_x_target, @sprites[idx_sprite] = new_sprite(((i * @bitmap.width) + (@bitmap.width / 2)) * @zoom_x_target,
(j * @bitmap.height + @bitmap.height / 2) * @zoom_y_target, ((j * @bitmap.height) + (@bitmap.height / 2)) * @zoom_y_target,
@bitmap, @bitmap.width / 2, @bitmap.height / 2) @bitmap, @bitmap.width / 2, @bitmap.height / 2)
@sprites[idx_sprite].visible = false @sprites[idx_sprite].visible = false
end end
@@ -546,16 +546,16 @@ module Transitions
def set_up_timings def set_up_timings
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_from_start = j * NUM_SPRITES_X + i # Top left -> bottom right idx_from_start = (j * NUM_SPRITES_X) + i # Top left -> bottom right
case @parameters[0] # Origin case @parameters[0] # Origin
when 1 # Top right -> bottom left when 1 # Top right -> bottom left
idx_from_start = j * NUM_SPRITES_X + NUM_SPRITES_X - i - 1 idx_from_start = (j * NUM_SPRITES_X) + NUM_SPRITES_X - i - 1
when 2 # Bottom left -> top right when 2 # Bottom left -> top right
idx_from_start = TOTAL_SPRITES - 1 - (j * NUM_SPRITES_X + NUM_SPRITES_X - i - 1) idx_from_start = TOTAL_SPRITES - 1 - ((j * NUM_SPRITES_X) + NUM_SPRITES_X - i - 1)
when 3 # Bottom right -> top left when 3 # Bottom right -> top left
idx_from_start = TOTAL_SPRITES - 1 - idx_from_start idx_from_start = TOTAL_SPRITES - 1 - idx_from_start
end end
dist = i + j.to_f * (NUM_SPRITES_X - 1) / (NUM_SPRITES_Y - 1) dist = i + (j.to_f * (NUM_SPRITES_X - 1) / (NUM_SPRITES_Y - 1))
@timings[idx_from_start] = (dist / ((NUM_SPRITES_X - 1) * 2)) * (@duration - TIME_TO_ZOOM) @timings[idx_from_start] = (dist / ((NUM_SPRITES_X - 1) * 2)) * (@duration - TIME_TO_ZOOM)
end end
end end
@@ -641,16 +641,16 @@ module Transitions
# Make overworld wave strips oscillate # Make overworld wave strips oscillate
amplitude = MAX_WAVE_AMPLITUDE * [@timer / 0.1, 1].min # Build up to max in 0.1 seconds amplitude = MAX_WAVE_AMPLITUDE * [@timer / 0.1, 1].min # Build up to max in 0.1 seconds
@sprites.each_with_index do |sprite, i| @sprites.each_with_index do |sprite, i|
sprite.x = amplitude * Math.sin(@timer * WAVE_SPEED + i * WAVE_SPACING) sprite.x = amplitude * Math.sin((@timer * WAVE_SPEED) + (i * WAVE_SPACING))
end end
# Move bubbles sprite up and oscillate side to side # Move bubbles sprite up and oscillate side to side
@bubbles_sprite.x = (Graphics.width - @bubble_bitmap.width) / 2 @bubbles_sprite.x = (Graphics.width - @bubble_bitmap.width) / 2
@bubbles_sprite.x += MAX_BUBBLE_AMPLITUDE * Math.sin(@timer * BUBBLES_WAVE_SPEED) @bubbles_sprite.x += MAX_BUBBLE_AMPLITUDE * Math.sin(@timer * BUBBLES_WAVE_SPEED)
@bubbles_sprite.y = Graphics.height * (1 - @timer * 1.2) @bubbles_sprite.y = Graphics.height * (1 - (@timer * 1.2))
# Move splash sprite up # Move splash sprite up
if @timer >= @splash_rising_start if @timer >= @splash_rising_start
proportion = (@timer - @splash_rising_start) / (@duration - @splash_rising_start) proportion = (@timer - @splash_rising_start) / (@duration - @splash_rising_start)
@splash_sprite.y = Graphics.height * (1 - proportion * 2) @splash_sprite.y = Graphics.height * (1 - (proportion * 2))
end end
# Move black sprite up # Move black sprite up
if @timer >= @black_rising_start if @timer >= @black_rising_start
@@ -680,15 +680,15 @@ module Transitions
# Balls that roll across the screen # Balls that roll across the screen
@ball_sprites = [] @ball_sprites = []
for i in 0...2 for i in 0...2
x = (1 - i) * Graphics.width + (1 - i * 2) * @ball_bitmap.width / 2 x = ((1 - i) * Graphics.width) + ((1 - (i * 2)) * @ball_bitmap.width / 2)
y = (Graphics.height + (i * 2 - 1) * @ball_bitmap.width) / 2 y = (Graphics.height + (((i * 2) - 1) * @ball_bitmap.width)) / 2
@ball_sprites[i] = new_sprite(x, y, @ball_bitmap, @ball_sprites[i] = new_sprite(x, y, @ball_bitmap,
@ball_bitmap.width / 2, @ball_bitmap.height / 2) @ball_bitmap.width / 2, @ball_bitmap.height / 2)
@ball_sprites[i].z = 2 @ball_sprites[i].z = 2
end end
# Black foreground sprites # Black foreground sprites
for i in 0...2 for i in 0...2
@sprites[i] = new_sprite((1 - i * 2) * Graphics.width, i * Graphics.height / 2, @black_bitmap) @sprites[i] = new_sprite((1 - (i * 2)) * Graphics.width, i * Graphics.height / 2, @black_bitmap)
@sprites[i].z = 1 @sprites[i].z = 1
end end
@sprites[2] = new_sprite(0, Graphics.height / 2, @black_bitmap, 0, @black_bitmap.height / 2) @sprites[2] = new_sprite(0, Graphics.height / 2, @black_bitmap, 0, @black_bitmap.height / 2)
@@ -718,8 +718,8 @@ module Transitions
proportion = @timer / @ball_roll_end proportion = @timer / @ball_roll_end
total_distance = Graphics.width + @ball_bitmap.width total_distance = Graphics.width + @ball_bitmap.width
@ball_sprites.each_with_index do |sprite, i| @ball_sprites.each_with_index do |sprite, i|
sprite.x = @ball_start_x[i] + (2 * i - 1) * (total_distance * proportion) sprite.x = @ball_start_x[i] + (((2 * i) - 1) * (total_distance * proportion))
sprite.angle = (2 * i - 1) * 360 * proportion * 2 sprite.angle = ((2 * i) - 1) * 360 * proportion * 2
end end
else else
proportion = (@timer - @ball_roll_end) / (@duration - @ball_roll_end) proportion = (@timer - @ball_roll_end) / (@duration - @ball_roll_end)
@@ -728,11 +728,11 @@ module Transitions
@ball_sprites.each { |s| s.visible = false } @ball_sprites.each { |s| s.visible = false }
end end
# Zoom in overworld sprite # Zoom in overworld sprite
@overworld_sprite.zoom_x = 1.0 + proportion * proportion # Ends at 2x zoom @overworld_sprite.zoom_x = 1.0 + (proportion * proportion) # Ends at 2x zoom
@overworld_sprite.zoom_y = @overworld_sprite.zoom_x @overworld_sprite.zoom_y = @overworld_sprite.zoom_x
# Slide first two black bars across # Slide first two black bars across
@sprites[0].x = Graphics.width * (1 - proportion * proportion) @sprites[0].x = Graphics.width * (1 - (proportion * proportion))
@sprites[1].x = Graphics.width * (proportion * proportion - 1) @sprites[1].x = Graphics.width * ((proportion * proportion) - 1)
# Expand third black bar # Expand third black bar
@sprites[2].zoom_y = 2.0 * proportion * proportion # Ends at 2x zoom @sprites[2].zoom_y = 2.0 * proportion * proportion # Ends at 2x zoom
end end
@@ -820,10 +820,10 @@ module Transitions
# Split overworld/ball apart, move blackness in following them # Split overworld/ball apart, move blackness in following them
proportion = (@timer - @slide_start) / (@duration - @slide_start) proportion = (@timer - @slide_start) / (@duration - @slide_start)
@overworld_sprites.each_with_index do |sprite, i| @overworld_sprites.each_with_index do |sprite, i|
sprite.x = (0.5 + (i * 2 - 1) * proportion * proportion) * Graphics.width sprite.x = (0.5 + (((i * 2) - 1) * proportion * proportion)) * Graphics.width
sprite.zoom_x = 1.0 + proportion * proportion # Ends at 2x zoom sprite.zoom_x = 1.0 + (proportion * proportion) # Ends at 2x zoom
sprite.zoom_y = sprite.zoom_x sprite.zoom_y = sprite.zoom_x
@black_sprites[i].x = sprite.x + (1 - i * 2) * Graphics.width / 2 @black_sprites[i].x = sprite.x + ((1 - (i * 2)) * Graphics.width / 2)
@ball_sprites[i].x = sprite.x @ball_sprites[i].x = sprite.x
end end
end end
@@ -859,7 +859,7 @@ module Transitions
# Black squares # Black squares
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_sprite = j * NUM_SPRITES_X + i idx_sprite = (j * NUM_SPRITES_X) + i
@sprites[idx_sprite] = new_sprite(i * @black_bitmap.width * @zoom_x_target, @sprites[idx_sprite] = new_sprite(i * @black_bitmap.width * @zoom_x_target,
j * @black_bitmap.height * @zoom_y_target, @black_bitmap) j * @black_bitmap.height * @zoom_y_target, @black_bitmap)
@sprites[idx_sprite].visible = false @sprites[idx_sprite].visible = false
@@ -868,7 +868,7 @@ module Transitions
# Falling balls # Falling balls
@ball_sprites = [] @ball_sprites = []
for i in 0...3 for i in 0...3
@ball_sprites[i] = new_sprite(Graphics.width / 2 + (i - 1) * 160, @ball_sprites[i] = new_sprite((Graphics.width / 2) + ((i - 1) * 160),
-@ball_bitmap.height - BALL_START_Y_OFFSETS[i], -@ball_bitmap.height - BALL_START_Y_OFFSETS[i],
@ball_bitmap, @ball_bitmap.width / 2, @ball_bitmap.height / 2) @ball_bitmap, @ball_bitmap.width / 2, @ball_bitmap.height / 2)
@ball_sprites[i].z = 2 @ball_sprites[i].z = 2
@@ -882,8 +882,8 @@ module Transitions
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
row_offset = NUM_SPRITES_Y - j - 1 row_offset = NUM_SPRITES_Y - j - 1
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_sprite = j * NUM_SPRITES_X + i idx_sprite = (j * NUM_SPRITES_X) + i
@timings[idx_sprite] = period * (row_offset * NUM_SPRITES_X + appear_order[i]) / TOTAL_SPRITES @timings[idx_sprite] = period * ((row_offset * NUM_SPRITES_X) + appear_order[i]) / TOTAL_SPRITES
@timings[idx_sprite] += @black_appear_start @timings[idx_sprite] += @black_appear_start
end end
end end
@@ -906,7 +906,7 @@ module Transitions
proportion = @timer / @black_appear_start proportion = @timer / @black_appear_start
@ball_sprites.each_with_index do |sprite, i| @ball_sprites.each_with_index do |sprite, i|
sprite.y = -@ball_bitmap.height - BALL_START_Y_OFFSETS[i] sprite.y = -@ball_bitmap.height - BALL_START_Y_OFFSETS[i]
sprite.y += (Graphics.height + BALL_START_Y_OFFSETS.max + @ball_bitmap.height * 2) * proportion sprite.y += (Graphics.height + BALL_START_Y_OFFSETS.max + (@ball_bitmap.height * 2)) * proportion
sprite.angle = 1.5 * 360 * proportion * ([1, -1][(i == 2) ? 0 : 1]) sprite.angle = 1.5 * 360 * proportion * ([1, -1][(i == 2) ? 0 : 1])
end end
else else
@@ -921,7 +921,7 @@ module Transitions
end end
# Zoom in overworld sprite # Zoom in overworld sprite
proportion = (@timer - @black_appear_start) / (@duration - @black_appear_start) proportion = (@timer - @black_appear_start) / (@duration - @black_appear_start)
@overworld_sprite.zoom_x = 1.0 + proportion * proportion # Ends at 2x zoom @overworld_sprite.zoom_x = 1.0 + (proportion * proportion) # Ends at 2x zoom
@overworld_sprite.zoom_y = @overworld_sprite.zoom_x @overworld_sprite.zoom_y = @overworld_sprite.zoom_x
end end
end end
@@ -977,7 +977,7 @@ module Transitions
if @timer <= @ball_appear_end if @timer <= @ball_appear_end
# Make ball drop down and zoom in # Make ball drop down and zoom in
proportion = @timer / @ball_appear_end proportion = @timer / @ball_appear_end
@ball_sprite.y = -@ball_bitmap.height / 2 + (Graphics.height + @ball_bitmap.height * 3) * proportion * proportion @ball_sprite.y = (-@ball_bitmap.height / 2) + ((Graphics.height + (@ball_bitmap.height * 3)) * proportion * proportion)
@ball_sprite.angle = -1.5 * 360 * proportion @ball_sprite.angle = -1.5 * 360 * proportion
@ball_sprite.zoom_x = 3 * proportion * proportion @ball_sprite.zoom_x = 3 * proportion * proportion
@ball_sprite.zoom_y = @ball_sprite.zoom_x @ball_sprite.zoom_y = @ball_sprite.zoom_x
@@ -986,10 +986,10 @@ module Transitions
# Black curve and blackness descends # Black curve and blackness descends
proportion = (@timer - @ball_appear_end) / (@duration - @ball_appear_end) proportion = (@timer - @ball_appear_end) / (@duration - @ball_appear_end)
@sprites.each do |sprite| @sprites.each do |sprite|
sprite.y = -@curve_bitmap.height + (Graphics.height + @curve_bitmap.height) * proportion sprite.y = -@curve_bitmap.height + ((Graphics.height + @curve_bitmap.height) * proportion)
end end
# Zoom in overworld sprite # Zoom in overworld sprite
@overworld_sprite.zoom_x = 1.0 + proportion * proportion # Ends at 2x zoom @overworld_sprite.zoom_x = 1.0 + (proportion * proportion) # Ends at 2x zoom
@overworld_sprite.zoom_y = @overworld_sprite.zoom_x @overworld_sprite.zoom_y = @overworld_sprite.zoom_x
end end
end end
@@ -1024,7 +1024,7 @@ module Transitions
# Ball sprites # Ball sprites
@ball_sprites = [] @ball_sprites = []
for i in 0...3 for i in 0...3
@ball_sprites[i] = new_sprite((2 * i + 1) * Graphics.width / 6, @ball_sprites[i] = new_sprite(((2 * i) + 1) * Graphics.width / 6,
BALL_OFFSETS[i] * Graphics.height, BALL_OFFSETS[i] * Graphics.height,
@ball_bitmap, @ball_bitmap.width / 2, @ball_bitmap.height / 2) @ball_bitmap, @ball_bitmap.width / 2, @ball_bitmap.height / 2)
@ball_sprites[i].z = 4 @ball_sprites[i].z = 4
@@ -1062,13 +1062,13 @@ module Transitions
# Make overworld wave strips oscillate # Make overworld wave strips oscillate
amplitude = MAX_WAVE_AMPLITUDE * [@timer / 0.1, 1].min # Build up to max in 0.1 seconds amplitude = MAX_WAVE_AMPLITUDE * [@timer / 0.1, 1].min # Build up to max in 0.1 seconds
@sprites.each_with_index do |sprite, i| @sprites.each_with_index do |sprite, i|
sprite.x = (1 - (i % 2) * 2) * amplitude * Math.sin(@timer * WAVE_SPEED + i * WAVE_SPACING) sprite.x = (1 - ((i % 2) * 2)) * amplitude * Math.sin((@timer * WAVE_SPEED) + (i * WAVE_SPACING))
end end
# Move balls and trailing blackness up # Move balls and trailing blackness up
if @timer >= @ball_rising_start if @timer >= @ball_rising_start
proportion = (@timer - @ball_rising_start) / (@duration - @ball_rising_start) proportion = (@timer - @ball_rising_start) / (@duration - @ball_rising_start)
@ball_sprites.each_with_index do |sprite, i| @ball_sprites.each_with_index do |sprite, i|
sprite.y = BALL_OFFSETS[i] * Graphics.height - Graphics.height * 3.5 * proportion sprite.y = (BALL_OFFSETS[i] * Graphics.height) - (Graphics.height * 3.5 * proportion)
sprite.angle = [-1, -1, 1][i] * 360 * 2 * proportion sprite.angle = [-1, -1, 1][i] * 360 * 2 * proportion
@black_trail_sprites[i].y = sprite.y @black_trail_sprites[i].y = sprite.y
@black_trail_sprites[i].y = 0 if @black_trail_sprites[i].y < 0 @black_trail_sprites[i].y = 0 if @black_trail_sprites[i].y < 0
@@ -1133,7 +1133,7 @@ module Transitions
# Make overworld wave strips oscillate # Make overworld wave strips oscillate
amplitude = MAX_WAVE_AMPLITUDE * [@timer / 0.1, 1].min # Build up to max in 0.1 seconds amplitude = MAX_WAVE_AMPLITUDE * [@timer / 0.1, 1].min # Build up to max in 0.1 seconds
@sprites.each_with_index do |sprite, i| @sprites.each_with_index do |sprite, i|
sprite.x = (1 - (i % 2) * 2) * amplitude * Math.sin(@timer * WAVE_SPEED + i * WAVE_SPACING) sprite.x = (1 - ((i % 2) * 2)) * amplitude * Math.sin((@timer * WAVE_SPEED) + (i * WAVE_SPACING))
end end
if @timer <= @ball_appear_end if @timer <= @ball_appear_end
# Fade in ball while spinning # Fade in ball while spinning
@@ -1208,11 +1208,11 @@ module Transitions
if @timer <= @ball_appear_end if @timer <= @ball_appear_end
# Balls fly out from centre of screen # Balls fly out from centre of screen
proportion = @timer / @ball_appear_end proportion = @timer / @ball_appear_end
ball_travel_x = (Graphics.width + @ball_bitmap.width * 2) / 2 ball_travel_x = (Graphics.width + (@ball_bitmap.width * 2)) / 2
ball_travel_y = (Graphics.height + @ball_bitmap.height * 2) / 2 ball_travel_y = (Graphics.height + (@ball_bitmap.height * 2)) / 2
@ball_sprites.each_with_index do |sprite, i| @ball_sprites.each_with_index do |sprite, i|
sprite.x = Graphics.width / 2 + [0, 1, 0, -1][i] * ball_travel_x * proportion if i.odd? sprite.x = (Graphics.width / 2) + ([0, 1, 0, -1][i] * ball_travel_x * proportion) if i.odd?
sprite.y = Graphics.height / 2 + [1, 0, -1, 0][i] * ball_travel_y * proportion if i.even? sprite.y = (Graphics.height / 2) + ([1, 0, -1, 0][i] * ball_travel_y * proportion) if i.even?
end end
else else
# Black wedges expand to fill screen # Black wedges expand to fill screen
+5 -4
View File
@@ -207,13 +207,14 @@ module GameData
# @return [Boolean] whether other represents the same thing as this thing # @return [Boolean] whether other represents the same thing as this thing
def ==(other) def ==(other)
return false if other.nil? return false if other.nil?
if other.is_a?(Symbol) case other
when Symbol
return @id == other return @id == other
elsif other.is_a?(self.class) when self.class
return @id == other.id return @id == other.id
elsif other.is_a?(String) when String
return @id == other.to_sym return @id == other.to_sym
elsif other.is_a?(Integer) when Integer
return @id_number == other return @id_number == other
end end
return false return false
@@ -133,7 +133,7 @@ GameData::GrowthRate.register({
765275, 804997, 834809, 877201, 908905, 954084, 987754, 1035837, 1071552, 1122660, 765275, 804997, 834809, 877201, 908905, 954084, 987754, 1035837, 1071552, 1122660,
1160499, 1214753, 1254796, 1312322, 1354652, 1415577, 1460276, 1524731, 1571884, 1640000], 1160499, 1214753, 1254796, 1312322, 1354652, 1415577, 1460276, 1524731, 1571884, 1640000],
:exp_formula => proc { |level| :exp_formula => proc { |level|
rate = [82 - (level - 100) / 2.0, 40].max rate = [82 - ((level - 100) / 2.0), 40].max
next (level**4) * rate / 5000 next (level**4) * rate / 5000
} }
}) })
@@ -152,7 +152,7 @@ GameData::GrowthRate.register({
360838, 377197, 394045, 411388, 429235, 447591, 466464, 485862, 505791, 526260, 360838, 377197, 394045, 411388, 429235, 447591, 466464, 485862, 505791, 526260,
547274, 568841, 590969, 613664, 636935, 660787, 685228, 710266, 735907, 762160, 547274, 568841, 590969, 613664, 636935, 660787, 685228, 710266, 735907, 762160,
789030, 816525, 844653, 873420, 902835, 932903, 963632, 995030, 1027103, 1059860], 789030, 816525, 844653, 873420, 902835, 932903, 963632, 995030, 1027103, 1059860],
:exp_formula => proc { |level| next ((level**3) * 6 / 5) - 15 * (level**2) + 100 * level - 140 } :exp_formula => proc { |level| next ((level**3) * 6 / 5) - (15 * (level**2)) + (100 * level) - 140 }
}) })
GameData::GrowthRate.register({ GameData::GrowthRate.register({
@@ -311,8 +311,8 @@ module GameData
evos.each do |evo| evos.each do |evo|
if check_method.is_a?(Array) if check_method.is_a?(Array)
next if !check_method.include?(evo[2]) next if !check_method.include?(evo[2])
else elsif evo[2] != check_method
next if evo[2] != check_method next
end end
return true if check_param.nil? || evo[3] == check_param return true if check_param.nil? || evo[3] == check_param
end end
@@ -69,8 +69,7 @@ module GameData
if (index & 1) == 1 # Foe Pokémon if (index & 1) == 1 # Foe Pokémon
sprite.x += @shadow_x * 2 sprite.x += @shadow_x * 2
end end
else elsif (index & 1) == 0 # Player's Pokémon
if (index & 1) == 0 # Player's Pokémon
sprite.x += @back_sprite[0] * 2 sprite.x += @back_sprite[0] * 2
sprite.y += @back_sprite[1] * 2 sprite.y += @back_sprite[1] * 2
else # Foe Pokémon else # Foe Pokémon
@@ -79,7 +78,6 @@ module GameData
sprite.y -= @front_sprite_altitude * 2 sprite.y -= @front_sprite_altitude * 2
end end
end end
end
def shows_shadow? def shows_shadow?
return true return true
@@ -202,7 +202,7 @@ class Battle
end end
def maxBattlerIndex def maxBattlerIndex
return (pbSideSize(0) > pbSideSize(1)) ? (pbSideSize(0) - 1) * 2 : pbSideSize(1) * 2 - 1 return (pbSideSize(0) > pbSideSize(1)) ? (pbSideSize(0) - 1) * 2 : (pbSideSize(1) * 2) - 1
end end
#============================================================================= #=============================================================================
@@ -282,7 +282,7 @@ class Battle
def pbNumPositions(side, idxTrainer) def pbNumPositions(side, idxTrainer)
ret = 0 ret = 0
for i in 0...pbSideSize(side) for i in 0...pbSideSize(side)
t = pbGetOwnerIndexFromBattlerIndex(i * 2 + side) t = pbGetOwnerIndexFromBattlerIndex((i * 2) + side)
next if t != idxTrainer next if t != idxTrainer
ret += 1 ret += 1
end end
@@ -49,7 +49,7 @@ class Battle
requireds = [] requireds = []
# Find out how many Pokémon each trainer on side needs to have # Find out how many Pokémon each trainer on side needs to have
for i in 0...@sideSizes[side] for i in 0...@sideSizes[side]
idxTrainer = pbGetOwnerIndexFromBattlerIndex(i * 2 + side) idxTrainer = pbGetOwnerIndexFromBattlerIndex((i * 2) + side)
requireds[idxTrainer] = 0 if requireds[idxTrainer].nil? requireds[idxTrainer] = 0 if requireds[idxTrainer].nil?
requireds[idxTrainer] += 1 requireds[idxTrainer] += 1
end end
@@ -119,10 +119,10 @@ class Battle
# Set up wild Pokémon # Set up wild Pokémon
if side == 1 && wildBattle? if side == 1 && wildBattle?
pbParty(1).each_with_index do |pkmn, idxPkmn| pbParty(1).each_with_index do |pkmn, idxPkmn|
pbCreateBattler(2 * idxPkmn + side, pkmn, idxPkmn) pbCreateBattler((2 * idxPkmn) + side, pkmn, idxPkmn)
# Changes the Pokémon's form upon entering battle (if it should) # Changes the Pokémon's form upon entering battle (if it should)
@peer.pbOnEnteringBattle(self, @battlers[2 * idxPkmn + side], pkmn, true) @peer.pbOnEnteringBattle(self, @battlers[(2 * idxPkmn) + side], pkmn, true)
pbSetSeen(@battlers[2 * idxPkmn + side]) pbSetSeen(@battlers[(2 * idxPkmn) + side])
@usedInBattle[side][idxPkmn] = true @usedInBattle[side][idxPkmn] = true
end end
next next
@@ -132,7 +132,7 @@ class Battle
requireds = [] requireds = []
# Find out how many Pokémon each trainer on side needs to have # Find out how many Pokémon each trainer on side needs to have
for i in 0...@sideSizes[side] for i in 0...@sideSizes[side]
idxTrainer = pbGetOwnerIndexFromBattlerIndex(i * 2 + side) idxTrainer = pbGetOwnerIndexFromBattlerIndex((i * 2) + side)
requireds[idxTrainer] = 0 if requireds[idxTrainer].nil? requireds[idxTrainer] = 0 if requireds[idxTrainer].nil?
requireds[idxTrainer] += 1 requireds[idxTrainer] += 1
end end
@@ -143,7 +143,7 @@ class Battle
ret[side][idxTrainer] = [] ret[side][idxTrainer] = []
eachInTeam(side, idxTrainer) do |pkmn, idxPkmn| eachInTeam(side, idxTrainer) do |pkmn, idxPkmn|
next if !pkmn.able? next if !pkmn.able?
idxBattler = 2 * battlerNumber + side idxBattler = (2 * battlerNumber) + side
pbCreateBattler(idxBattler, pkmn, idxPkmn) pbCreateBattler(idxBattler, pkmn, idxPkmn)
ret[side][idxTrainer].push(idxBattler) ret[side][idxTrainer].push(idxBattler)
battlerNumber += 1 battlerNumber += 1
@@ -125,7 +125,7 @@ class Battle
# Scale the gained Exp based on the gainer's level (or not) # Scale the gained Exp based on the gainer's level (or not)
if Settings::SCALED_EXP_FORMULA if Settings::SCALED_EXP_FORMULA
exp /= 5 exp /= 5
levelAdjust = (2 * level + 10.0) / (pkmn.level + level + 10.0) levelAdjust = ((2 * level) + 10.0) / (pkmn.level + level + 10.0)
levelAdjust = levelAdjust**5 levelAdjust = levelAdjust**5
levelAdjust = Math.sqrt(levelAdjust) levelAdjust = Math.sqrt(levelAdjust)
exp *= levelAdjust exp *= levelAdjust
@@ -116,8 +116,8 @@ class Battle
@scene.pbPartyScreen(idxBattler, canCancel) { |idxParty, partyScene| @scene.pbPartyScreen(idxBattler, canCancel) { |idxParty, partyScene|
if checkLaxOnly if checkLaxOnly
next false if !pbCanSwitchLax?(idxBattler, idxParty, partyScene) next false if !pbCanSwitchLax?(idxBattler, idxParty, partyScene)
else elsif !pbCanSwitch?(idxBattler, idxParty, partyScene)
next false if !pbCanSwitch?(idxBattler, idxParty, partyScene) next false
end end
if shouldRegister if shouldRegister
next false if idxParty < 0 || !pbRegisterSwitch(idxBattler, idxParty) next false if idxParty < 0 || !pbRegisterSwitch(idxBattler, idxParty)
@@ -119,13 +119,10 @@ class Battle::Battler
else else
pbRaiseStatStageByCause(stat, increment, self, abilityName) pbRaiseStatStageByCause(stat, increment, self, abilityName)
end end
else elsif Battle::Scene::USE_ABILITY_SPLASH
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) @battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true)))
else else
@battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!", @battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!", pbThis, abilityName, move.name))
pbThis, abilityName, move.name))
end
end end
@battle.pbHideAbilitySplash(self) @battle.pbHideAbilitySplash(self)
end end
@@ -149,13 +146,10 @@ class Battle::Battler
else else
@battle.pbDisplay(_INTL("{1}'s {2} restored its HP.", pbThis, abilityName)) @battle.pbDisplay(_INTL("{1}'s {2} restored its HP.", pbThis, abilityName))
end end
else elsif Battle::Scene::USE_ABILITY_SPLASH
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) @battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true)))
else else
@battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!", @battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!", pbThis, abilityName, move.name))
pbThis, abilityName, move.name))
end
end end
@battle.pbHideAbilitySplash(self) @battle.pbHideAbilitySplash(self)
end end
@@ -298,14 +298,12 @@ class Battle::Move
else else
@battle.pbDisplay(_INTL("{1} landed a critical hit, wishing to be praised!", user.pbThis)) @battle.pbDisplay(_INTL("{1} landed a critical hit, wishing to be praised!", user.pbThis))
end end
else elsif numTargets > 1
if numTargets > 1
@battle.pbDisplay(_INTL("A critical hit on {1}!", target.pbThis(true))) @battle.pbDisplay(_INTL("A critical hit on {1}!", target.pbThis(true)))
else else
@battle.pbDisplay(_INTL("A critical hit!")) @battle.pbDisplay(_INTL("A critical hit!"))
end end
end end
end
# Effectiveness message, for moves with 1 hit # Effectiveness message, for moves with 1 hit
if !multiHitMove? && user.effects[PBEffects::ParentalBond] == 0 if !multiHitMove? && user.effects[PBEffects::ParentalBond] == 0
pbEffectivenessMessage(user, target, numTargets) pbEffectivenessMessage(user, target, numTargets)
@@ -283,7 +283,7 @@ class Battle::Move
baseDmg = [(baseDmg * multipliers[:base_damage_multiplier]).round, 1].max baseDmg = [(baseDmg * multipliers[:base_damage_multiplier]).round, 1].max
atk = [(atk * multipliers[:attack_multiplier]).round, 1].max atk = [(atk * multipliers[:attack_multiplier]).round, 1].max
defense = [(defense * multipliers[:defense_multiplier]).round, 1].max defense = [(defense * multipliers[:defense_multiplier]).round, 1].max
damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2 damage = ((((2.0 * user.level / 5) + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2
damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max
target.damageState.calcDamage = damage target.damageState.calcDamage = damage
end end
@@ -130,7 +130,7 @@ class Battle::Move::MultiStatUpMove < Battle::Move
showAnim = true showAnim = true
for i in 0...@statUp.length / 2 for i in 0...@statUp.length / 2
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self) next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
if user.pbRaiseStatStage(@statUp[i * 2], @statUp[i * 2 + 1], user, showAnim) if user.pbRaiseStatStage(@statUp[i * 2], @statUp[(i * 2) + 1], user, showAnim)
showAnim = false showAnim = false
end end
end end
@@ -140,7 +140,7 @@ class Battle::Move::MultiStatUpMove < Battle::Move
showAnim = true showAnim = true
for i in 0...@statUp.length / 2 for i in 0...@statUp.length / 2
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self) next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
if user.pbRaiseStatStage(@statUp[i * 2], @statUp[i * 2 + 1], user, showAnim) if user.pbRaiseStatStage(@statUp[i * 2], @statUp[(i * 2) + 1], user, showAnim)
showAnim = false showAnim = false
end end
end end
@@ -156,7 +156,7 @@ class Battle::Move::StatDownMove < Battle::Move
showAnim = true showAnim = true
for i in 0...@statDown.length / 2 for i in 0...@statDown.length / 2
next if !user.pbCanLowerStatStage?(@statDown[i * 2], user, self) next if !user.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if user.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user, showAnim) if user.pbLowerStatStage(@statDown[i * 2], @statDown[(i * 2) + 1], user, showAnim)
showAnim = false showAnim = false
end end
end end
@@ -255,7 +255,7 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move
showMirrorArmorSplash = true showMirrorArmorSplash = true
for i in 0...@statDown.length / 2 for i in 0...@statDown.length / 2
next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self) next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if target.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user, if target.pbLowerStatStage(@statDown[i * 2], @statDown[(i * 2) + 1], user,
showAnim, false, (showMirrorArmorSplash) ? 1 : 3) showAnim, false, (showMirrorArmorSplash) ? 1 : 3)
showAnim = false showAnim = false
end end
@@ -440,14 +440,14 @@ class Battle::Move::LowerUserDefSpDef1RaiseUserAtkSpAtkSpd2 < Battle::Move
showAnim = true showAnim = true
for i in 0...@statDown.length / 2 for i in 0...@statDown.length / 2
next if !user.pbCanLowerStatStage?(@statDown[i * 2], user, self) next if !user.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if user.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user, showAnim) if user.pbLowerStatStage(@statDown[i * 2], @statDown[(i * 2) + 1], user, showAnim)
showAnim = false showAnim = false
end end
end end
showAnim = true showAnim = true
for i in 0...@statUp.length / 2 for i in 0...@statUp.length / 2
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self) next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
if user.pbRaiseStatStage(@statUp[i * 2], @statUp[i * 2 + 1], user, showAnim) if user.pbRaiseStatStage(@statUp[i * 2], @statUp[(i * 2) + 1], user, showAnim)
showAnim = false showAnim = false
end end
end end
@@ -1385,7 +1385,7 @@ class Battle::Move::LowerPoisonedTargetAtkSpAtkSpd1 < Battle::Move
showMirrorArmorSplash = true showMirrorArmorSplash = true
for i in 0...@statDown.length / 2 for i in 0...@statDown.length / 2
next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self) next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if target.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user, if target.pbLowerStatStage(@statDown[i * 2], @statDown[(i * 2) + 1], user,
showAnim, false, (showMirrorArmorSplash) ? 1 : 3) showAnim, false, (showMirrorArmorSplash) ? 1 : 3)
showAnim = false showAnim = false
end end
@@ -710,12 +710,10 @@ class Battle::Move::StartWeakenElectricMoves < Battle::Move
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
else elsif @battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] }
if @battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] }
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
end
return false return false
end end
@@ -739,12 +737,10 @@ class Battle::Move::StartWeakenFireMoves < Battle::Move
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
else elsif @battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] }
if @battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] }
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
end
return false return false
end end
@@ -1359,7 +1355,7 @@ def pbHiddenPower(pkmn)
power |= (iv[:SPEED] & 2) << 2 power |= (iv[:SPEED] & 2) << 2
power |= (iv[:SPECIAL_ATTACK] & 2) << 3 power |= (iv[:SPECIAL_ATTACK] & 2) << 3
power |= (iv[:SPECIAL_DEFENSE] & 2) << 4 power |= (iv[:SPECIAL_DEFENSE] & 2) << 4
power = powerMin + (powerMax - powerMin) * power / 63 power = powerMin + ((powerMax - powerMin) * power / 63)
end end
return [type, power] return [type, power]
end end
@@ -64,11 +64,11 @@ class Battle::Scene
# Shift depending on index (no shifting needed for sideSize of 1) # Shift depending on index (no shifting needed for sideSize of 1)
case sideSize case sideSize
when 2 when 2
ret[0] += [-48, 48, 32, -32][2 * index + side] ret[0] += [-48, 48, 32, -32][(2 * index) + side]
ret[1] += [ 0, 0, 0, -16][2 * index + side] ret[1] += [ 0, 0, 0, -16][(2 * index) + side]
when 3 when 3
ret[0] += [-80, 80, 0, 0, 80, -80][2 * index + side] ret[0] += [-80, 80, 0, 0, 80, -80][(2 * index) + side]
ret[1] += [ 0, 0, 0, -8, 0, -16][2 * index + side] ret[1] += [ 0, 0, 0, -8, 0, -16][(2 * index) + side]
end end
return ret return ret
end end
@@ -83,7 +83,7 @@ class Battle::Scene
# Wild battle, so set up the Pokémon sprite(s) accordingly # Wild battle, so set up the Pokémon sprite(s) accordingly
if @battle.wildBattle? if @battle.wildBattle?
@battle.pbParty(1).each_with_index do |pkmn, i| @battle.pbParty(1).each_with_index do |pkmn, i|
index = i * 2 + 1 index = (i * 2) + 1
pbChangePokemon(index, pkmn) pbChangePokemon(index, pkmn)
pkmnSprite = @sprites["pokemon_#{index}"] pkmnSprite = @sprites["pokemon_#{index}"]
pkmnSprite.tone = Tone.new(-80, -80, -80) pkmnSprite.tone = Tone.new(-80, -80, -80)
@@ -28,7 +28,7 @@ class Battle::Scene
# shiny animation(s) # shiny animation(s)
# Set up data box animation # Set up data box animation
for i in 0...@battle.sideSizes[1] for i in 0...@battle.sideSizes[1]
idxBattler = 2 * i + 1 idxBattler = (2 * i) + 1
next if !@battle.battlers[idxBattler] next if !@battle.battlers[idxBattler]
dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, idxBattler) dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, idxBattler)
@animations.push(dataBoxAnim) @animations.push(dataBoxAnim)
@@ -43,7 +43,7 @@ class Battle::Scene
# Show shiny animation for wild Pokémon # Show shiny animation for wild Pokémon
if @battle.showAnims if @battle.showAnims
for i in 0...@battle.sideSizes[1] for i in 0...@battle.sideSizes[1]
idxBattler = 2 * i + 1 idxBattler = (2 * i) + 1
next if !@battle.battlers[idxBattler] || !@battle.battlers[idxBattler].shiny? next if !@battle.battlers[idxBattler] || !@battle.battlers[idxBattler].shiny?
if Settings::SUPER_SHINY && @battle.battlers[idxBattler].super_shiny? if Settings::SUPER_SHINY && @battle.battlers[idxBattler].super_shiny?
pbCommonAnimation("SuperShiny", @battle.battlers[idxBattler]) pbCommonAnimation("SuperShiny", @battle.battlers[idxBattler])
@@ -58,15 +58,16 @@ class Battle::Scene
# Animates a party lineup appearing for the given side # Animates a party lineup appearing for the given side
#============================================================================= #=============================================================================
def pbShowPartyLineup(side, fullAnim = false) def pbShowPartyLineup(side, fullAnim = false)
@animations.push(Animation::LineupAppear.new( @animations.push(
@sprites, @viewport, side, @battle.pbParty(side), @battle.pbPartyStarts(side), fullAnim Animation::LineupAppear.new(@sprites, @viewport, side,
)) @battle.pbParty(side), @battle.pbPartyStarts(side),
if !fullAnim fullAnim)
)
return if fullAnim
while inPartyAnimation? while inPartyAnimation?
pbUpdate pbUpdate
end end
end end
end
#============================================================================= #=============================================================================
# Animates an opposing trainer sliding in from off-screen. Will animate a # Animates an opposing trainer sliding in from off-screen. Will animate a
@@ -541,7 +542,7 @@ class Battle::Scene
end end
animPlayer.setLineTransform( animPlayer.setLineTransform(
FOCUSUSER_X, FOCUSUSER_Y, FOCUSTARGET_X, FOCUSTARGET_Y, FOCUSUSER_X, FOCUSUSER_Y, FOCUSTARGET_X, FOCUSTARGET_Y,
oldUserX, oldUserY - userHeight / 2, oldTargetX, oldTargetY - targetHeight / 2 oldUserX, oldUserY - (userHeight / 2), oldTargetX, oldTargetY - (targetHeight / 2)
) )
# Play the animation # Play the animation
animPlayer.start animPlayer.start
@@ -137,7 +137,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
button = SpriteWrapper.new(viewport) button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap button.bitmap = @buttonBitmap.bitmap
button.x = self.x + Graphics.width - 260 button.x = self.x + Graphics.width - 260
button.x += (i.even? ? 0 : @buttonBitmap.width / 2 - 4) button.x += (i.even? ? 0 : (@buttonBitmap.width / 2) - 4)
button.y = self.y + 6 button.y = self.y + 6
button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4) button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4)
button.src_rect.width = @buttonBitmap.width / 2 button.src_rect.width = @buttonBitmap.width / 2
@@ -247,7 +247,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
button = SpriteWrapper.new(viewport) button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap button.bitmap = @buttonBitmap.bitmap
button.x = self.x + 4 button.x = self.x + 4
button.x += (i.even? ? 0 : @buttonBitmap.width / 2 - 4) button.x += (i.even? ? 0 : (@buttonBitmap.width / 2) - 4)
button.y = self.y + 6 button.y = self.y + 6
button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4) button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4)
button.src_rect.width = @buttonBitmap.width / 2 button.src_rect.width = @buttonBitmap.width / 2
@@ -278,7 +278,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
@megaButton = SpriteWrapper.new(viewport) @megaButton = SpriteWrapper.new(viewport)
@megaButton.bitmap = @megaEvoBitmap.bitmap @megaButton.bitmap = @megaEvoBitmap.bitmap
@megaButton.x = self.x + 120 @megaButton.x = self.x + 120
@megaButton.y = self.y - @megaEvoBitmap.height / 2 @megaButton.y = self.y - (@megaEvoBitmap.height / 2)
@megaButton.src_rect.height = @megaEvoBitmap.height / 2 @megaButton.src_rect.height = @megaEvoBitmap.height / 2
addSprite("megaButton", @megaButton) addSprite("megaButton", @megaButton)
# Create Shift button # Create Shift button
@@ -354,7 +354,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
textPos = [] textPos = []
@buttons.each_with_index do |button, i| @buttons.each_with_index do |button, i|
next if !@visibility["button_#{i}"] next if !@visibility["button_#{i}"]
x = button.x - self.x + button.src_rect.width / 2 x = button.x - self.x + (button.src_rect.width / 2)
y = button.y - self.y + 2 y = button.y - self.y + 2
moveNameBase = TEXT_BASE_COLOR moveNameBase = TEXT_BASE_COLOR
if GET_MOVE_TEXT_COLOR_FROM_MOVE_BUTTON && moves[i].display_type(@battler) if GET_MOVE_TEXT_COLOR_FROM_MOVE_BUTTON && moves[i].display_type(@battler)
@@ -414,7 +414,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
ppFraction = [(4.0 * move.pp / move.total_pp).ceil, 3].min ppFraction = [(4.0 * move.pp / move.total_pp).ceil, 3].min
textPos = [] textPos = []
textPos.push([_INTL("PP: {1}/{2}", move.pp, move.total_pp), textPos.push([_INTL("PP: {1}/{2}", move.pp, move.total_pp),
448, 44, 2, PP_COLORS[ppFraction * 2], PP_COLORS[ppFraction * 2 + 1]]) 448, 44, 2, PP_COLORS[ppFraction * 2], PP_COLORS[(ppFraction * 2) + 1]])
pbDrawTextPositions(@infoOverlay.bitmap, textPos) pbDrawTextPositions(@infoOverlay.bitmap, textPos)
end end
end end
@@ -467,7 +467,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
def initialize(viewport, z, sideSizes) def initialize(viewport, z, sideSizes)
super(viewport) super(viewport)
@sideSizes = sideSizes @sideSizes = sideSizes
maxIndex = (@sideSizes[0] > @sideSizes[1]) ? (@sideSizes[0] - 1) * 2 : @sideSizes[1] * 2 - 1 maxIndex = (@sideSizes[0] > @sideSizes[1]) ? (@sideSizes[0] - 1) * 2 : (@sideSizes[1] * 2) - 1
@smallButtons = (@sideSizes.max > 2) @smallButtons = (@sideSizes.max > 2)
self.x = 0 self.x = 0
self.y = Graphics.height - 96 self.y = Graphics.height - 96
@@ -483,7 +483,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
# NOTE: Battler indexes go from left to right from the perspective of # NOTE: Battler indexes go from left to right from the perspective of
# that side's trainer, so inc is different for each side for the # that side's trainer, so inc is different for each side for the
# same value of i/2. # same value of i/2.
inc = (i.even?) ? i / 2 : numButtons - 1 - i / 2 inc = (i.even?) ? i / 2 : numButtons - 1 - (i / 2)
button = SpriteWrapper.new(viewport) button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap button.bitmap = @buttonBitmap.bitmap
button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width / 2 button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width / 2
@@ -536,7 +536,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
sel ||= (@mode == 1) sel ||= (@mode == 1)
buttonType = (i.even?) ? 1 : 2 buttonType = (i.even?) ? 1 : 2
end end
buttonType = 2 * buttonType + ((@smallButtons) ? 1 : 0) buttonType = (2 * buttonType) + ((@smallButtons) ? 1 : 0)
button.src_rect.x = (sel) ? @buttonBitmap.width / 2 : 0 button.src_rect.x = (sel) ? @buttonBitmap.width / 2 : 0
button.src_rect.y = buttonType * BUTTON_HEIGHT button.src_rect.y = buttonType * BUTTON_HEIGHT
button.z = self.z + ((sel) ? 3 : 2) button.z = self.z + ((sel) ? 3 : 2)
@@ -546,7 +546,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
textpos = [] textpos = []
@buttons.each_with_index do |button, i| @buttons.each_with_index do |button, i|
next if !button || nil_or_empty?(@texts[i]) next if !button || nil_or_empty?(@texts[i])
x = button.x - self.x + button.src_rect.width / 2 x = button.x - self.x + (button.src_rect.width / 2)
y = button.y - self.y + 2 y = button.y - self.y + 2
textpos.push([@texts[i], x, y, 2, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR]) textpos.push([@texts[i], x, y, 2, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR])
end end
@@ -96,7 +96,7 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
@contents = BitmapWrapper.new(@databoxBitmap.width, @databoxBitmap.height) @contents = BitmapWrapper.new(@databoxBitmap.width, @databoxBitmap.height)
self.bitmap = @contents self.bitmap = @contents
self.visible = false self.visible = false
self.z = 150 + ((@battler.index) / 2) * 5 self.z = 150 + ((@battler.index / 2) * 5)
pbSetSystemFont(self.bitmap) pbSetSystemFont(self.bitmap)
end end
@@ -538,9 +538,9 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
return if !@_iconBitmap return if !@_iconBitmap
pbSetOrigin pbSetOrigin
if @index.even? if @index.even?
self.z = 50 + 5 * @index / 2 self.z = 50 + (5 * @index / 2)
else else
self.z = 50 - 5 * (@index + 1) / 2 self.z = 50 - (5 * (@index + 1) / 2)
end end
# Set original position # Set original position
p = Battle::Scene.pbBattlerPosition(@index, @sideSize) p = Battle::Scene.pbBattlerPosition(@index, @sideSize)
@@ -102,7 +102,7 @@ module Battle::Scene::Animation::BallAnimationMixin
ball.setVisible(7, true) ball.setVisible(7, true)
ballStartX = traSprite.x ballStartX = traSprite.x
ballStartX -= ball.totalDuration * (Graphics.width / (2 * 16)) if !safariThrow ballStartX -= ball.totalDuration * (Graphics.width / (2 * 16)) if !safariThrow
ballStartY = traSprite.y - traSprite.bitmap.height / 2 ballStartY = traSprite.y - (traSprite.bitmap.height / 2)
return ballStartX, ballStartY return ballStartX, ballStartY
end end
# Back sprite is animated, make the Poké Ball track the trainer's hand # Back sprite is animated, make the Poké Ball track the trainer's hand
@@ -166,13 +166,13 @@ module Battle::Scene::Animation::BallAnimationMixin
# throw). Instead, that throw animation and initialDelay are designed # throw). Instead, that throw animation and initialDelay are designed
# to make sure the Ball's trajectory starts at the same position. # to make sure the Ball's trajectory starts at the same position.
ball.setVisible(delay, true) ball.setVisible(delay, true)
a = 2 * startY - 4 * midY + 2 * endY a = (2 * startY) - (4 * midY) + (2 * endY)
b = 4 * midY - 3 * startY - endY b = (4 * midY) - (3 * startY) - endY
c = startY c = startY
for i in 1..duration for i in 1..duration
t = i.to_f / duration # t ranges from 0 to 1 t = i.to_f / duration # t ranges from 0 to 1
x = startX + (endX - startX) * t # Linear in t x = startX + ((endX - startX) * t) # Linear in t
y = a * t**2 + b * t + c # Quadratic in t y = (a * (t**2)) + (b * t) + c # Quadratic in t
ball.moveXY(delay + i - 1, 1, x, y) ball.moveXY(delay + i - 1, 1, x, y)
end end
createBallTumbling(ball, delay, duration) createBallTumbling(ball, delay, duration)
@@ -28,7 +28,7 @@ class Battle::Scene::Animation::Intro < Battle::Scene::Animation
end end
else # Wild battle else # Wild battle
@battle.pbParty(1).each_with_index do |_pkmn, i| @battle.pbParty(1).each_with_index do |_pkmn, i|
idxBattler = 2 * i + 1 idxBattler = (2 * i) + 1
makeSlideSprite("pokemon_#{idxBattler}", -1, appearTime, PictureOrigin::Bottom) makeSlideSprite("pokemon_#{idxBattler}", -1, appearTime, PictureOrigin::Bottom)
end end
end end
@@ -71,7 +71,7 @@ class Battle::Scene::Animation::Intro2 < Battle::Scene::Animation
def createProcesses def createProcesses
for i in 0...@sideSize for i in 0...@sideSize
idxBattler = 2 * i + 1 idxBattler = (2 * i) + 1
next if !@sprites["pokemon_#{idxBattler}"] next if !@sprites["pokemon_#{idxBattler}"]
battler = addSprite(@sprites["pokemon_#{idxBattler}"], PictureOrigin::Bottom) battler = addSprite(@sprites["pokemon_#{idxBattler}"], PictureOrigin::Bottom)
battler.moveTone(0, 4, Tone.new(0, 0, 0, 0)) battler.moveTone(0, 4, Tone.new(0, 0, 0, 0))
@@ -112,7 +112,7 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
ballY = barY - 30 ballY = barY - 30
barX -= bar.bitmap.width barX -= bar.bitmap.width
end end
ballXdiff = 32 * (1 - 2 * @side) ballXdiff = 32 * (1 - (2 * @side))
bar.x = barX bar.x = barX
bar.y = barY bar.y = barY
bar.opacity = 255 bar.opacity = 255
@@ -155,7 +155,7 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
bar.moveDelta(0, 8, -dir * Graphics.width / 2, 0) bar.moveDelta(0, 8, -dir * Graphics.width / 2, 0)
delay = bar.totalDuration delay = bar.totalDuration
for i in 0...Battle::Scene::NUM_BALLS for i in 0...Battle::Scene::NUM_BALLS
createBall(i, (@fullAnim) ? delay + i * 2 : 0, dir) createBall(i, (@fullAnim) ? delay + (i * 2) : 0, dir)
end end
end end
@@ -287,7 +287,7 @@ class Battle::Scene::Animation::TrainerAppear < Battle::Scene::Animation
# Make new trainer sprite move on-screen # Make new trainer sprite move on-screen
if @sprites["trainer_#{@idxTrainer + 1}"] if @sprites["trainer_#{@idxTrainer + 1}"]
trainerX, trainerY = Battle::Scene.pbTrainerPosition(1) trainerX, trainerY = Battle::Scene.pbTrainerPosition(1)
trainerX += 64 + Graphics.width / 4 trainerX += 64 + (Graphics.width / 4)
newTrainer = addSprite(@sprites["trainer_#{@idxTrainer + 1}"], PictureOrigin::Bottom) newTrainer = addSprite(@sprites["trainer_#{@idxTrainer + 1}"], PictureOrigin::Bottom)
newTrainer.setVisible(delay, true) newTrainer.setVisible(delay, true)
newTrainer.setXY(delay, trainerX, trainerY) newTrainer.setXY(delay, trainerX, trainerY)
@@ -342,7 +342,7 @@ class Battle::Scene::Animation::PlayerFade < Battle::Scene::Animation
for i in 0...Battle::Scene::NUM_BALLS for i in 0...Battle::Scene::NUM_BALLS
next if !@sprites["partyBall_0_#{i}"] || !@sprites["partyBall_0_#{i}"].visible next if !@sprites["partyBall_0_#{i}"] || !@sprites["partyBall_0_#{i}"].visible
partyBall = addSprite(@sprites["partyBall_0_#{i}"]) partyBall = addSprite(@sprites["partyBall_0_#{i}"])
partyBall.moveDelta(delay + 2 * i, 16, -Graphics.width, 0) if @fullAnim partyBall.moveDelta(delay + (2 * i), 16, -Graphics.width, 0) if @fullAnim
partyBall.moveOpacity(delay, 12, 0) partyBall.moveOpacity(delay, 12, 0)
partyBall.setVisible(delay + 12, false) partyBall.setVisible(delay + 12, false)
partyBall.setOpacity(delay + 12, 255) partyBall.setOpacity(delay + 12, 255)
@@ -387,7 +387,7 @@ class Battle::Scene::Animation::TrainerFade < Battle::Scene::Animation
for i in 0...Battle::Scene::NUM_BALLS for i in 0...Battle::Scene::NUM_BALLS
next if !@sprites["partyBall_1_#{i}"] || !@sprites["partyBall_1_#{i}"].visible next if !@sprites["partyBall_1_#{i}"] || !@sprites["partyBall_1_#{i}"].visible
partyBall = addSprite(@sprites["partyBall_1_#{i}"]) partyBall = addSprite(@sprites["partyBall_1_#{i}"])
partyBall.moveDelta(delay + 2 * i, 16, Graphics.width, 0) if @fullAnim partyBall.moveDelta(delay + (2 * i), 16, Graphics.width, 0) if @fullAnim
partyBall.moveOpacity(delay, 12, 0) partyBall.moveOpacity(delay, 12, 0)
partyBall.setVisible(delay + 12, false) partyBall.setVisible(delay + 12, false)
partyBall.setOpacity(delay + 12, 255) partyBall.setOpacity(delay + 12, 255)
@@ -782,12 +782,12 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
d = [1, 2, 4, 8][i] # Fraction of the starting height each bounce rises to d = [1, 2, 4, 8][i] # Fraction of the starting height each bounce rises to
delay -= t if i == 0 delay -= t if i == 0
if i > 0 if i > 0
ball.setZoomXY(delay, 100 + 5 * (5 - i), 100 - 5 * (5 - i)) # Squish ball.setZoomXY(delay, 100 + (5 * (5 - i)), 100 - (5 * (5 - i))) # Squish
ball.moveZoom(delay, 2, 100) # Unsquish ball.moveZoom(delay, 2, 100) # Unsquish
ball.moveXY(delay, t, ballEndX, ballGroundY - (ballGroundY - ballEndY) / d) ball.moveXY(delay, t, ballEndX, ballGroundY - ((ballGroundY - ballEndY) / d))
end end
ball.moveXY(delay + t, t, ballEndX, ballGroundY) ball.moveXY(delay + t, t, ballEndX, ballGroundY)
ball.setSE(delay + 2 * t, "Battle ball drop", 100 - i * 7) ball.setSE(delay + (2 * t), "Battle ball drop", 100 - (i * 7))
delay = ball.totalDuration delay = ball.totalDuration
end end
battler.setXY(ball.totalDuration, ballEndX, ballGroundY) battler.setXY(ball.totalDuration, ballEndX, ballGroundY)
@@ -795,9 +795,9 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
delay = ball.totalDuration + 12 delay = ball.totalDuration + 12
for i in 0...[@numShakes, 3].min for i in 0...[@numShakes, 3].min
ball.setSE(delay, "Battle ball shake") ball.setSE(delay, "Battle ball shake")
ball.moveXY(delay, 2, ballEndX - 2 * (4 - i), ballGroundY) ball.moveXY(delay, 2, ballEndX - (2 * (4 - i)), ballGroundY)
ball.moveAngle(delay, 2, 5 * (4 - i)) # positive means counterclockwise ball.moveAngle(delay, 2, 5 * (4 - i)) # positive means counterclockwise
ball.moveXY(delay + 2, 4, ballEndX + 2 * (4 - i), ballGroundY) ball.moveXY(delay + 2, 4, ballEndX + (2 * (4 - i)), ballGroundY)
ball.moveAngle(delay + 2, 4, -5 * (4 - i)) # negative means clockwise ball.moveAngle(delay + 2, 4, -5 * (4 - i)) # negative means clockwise
ball.moveXY(delay + 6, 2, ballEndX, ballGroundY) ball.moveXY(delay + 6, 2, ballEndX, ballGroundY)
ball.moveAngle(delay + 6, 2, 0) ball.moveAngle(delay + 6, 2, 0)
@@ -176,10 +176,8 @@ class Battle::AI
miss = false if user.hasActiveAbility?(:NOGUARD) || target.hasActiveAbility?(:NOGUARD) miss = false if user.hasActiveAbility?(:NOGUARD) || target.hasActiveAbility?(:NOGUARD)
if miss && pbRoughStat(user, :SPEED, skill) > pbRoughStat(target, :SPEED, skill) if miss && pbRoughStat(user, :SPEED, skill) > pbRoughStat(target, :SPEED, skill)
# Knows what can get past semi-invulnerability # Knows what can get past semi-invulnerability
if target.effects[PBEffects::SkyDrop] >= 0 if target.effects[PBEffects::SkyDrop] >= 0 ||
miss = false if move.hitsFlyingTargets? target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky",
else
if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky",
"TwoTurnAttackInvulnerableInSkyParalyzeTarget", "TwoTurnAttackInvulnerableInSkyParalyzeTarget",
"TwoTurnAttackInvulnerableInSkyTargetCannotAct") "TwoTurnAttackInvulnerableInSkyTargetCannotAct")
miss = false if move.hitsFlyingTargets? miss = false if move.hitsFlyingTargets?
@@ -189,7 +187,6 @@ class Battle::AI
miss = false if move.hitsDivingTargets? miss = false if move.hitsDivingTargets?
end end
end end
end
score -= 80 if miss score -= 80 if miss
end end
# Pick a good move for the Choice items # Pick a good move for the Choice items
@@ -28,11 +28,9 @@ class Battle::AI
score -= 50 score -= 50
end end
end end
else elsif skill >= PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
score -= 90 if move.statusMove? score -= 90 if move.statusMove?
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "SleepTargetNextTurn" when "SleepTargetNextTurn"
if target.effects[PBEffects::Yawn] > 0 || !target.pbCanSleep?(user, false) if target.effects[PBEffects::Yawn] > 0 || !target.pbCanSleep?(user, false)
@@ -63,11 +61,9 @@ class Battle::AI
score += 10 if pbRoughStat(target, :SPECIAL_DEFENSE, skill) > 100 score += 10 if pbRoughStat(target, :SPECIAL_DEFENSE, skill) > 100
score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :TOXICBOOST]) score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :TOXICBOOST])
end end
else elsif skill >= PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
score -= 90 if move.statusMove? score -= 90 if move.statusMove?
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "ParalyzeTarget", "ParalyzeTargetIfNotTypeImmune", when "ParalyzeTarget", "ParalyzeTargetIfNotTypeImmune",
"ParalyzeTargetTrampleMinimize", "ParalyzeTargetAlwaysHitsInRainHitsTargetInSky", "ParalyzeTargetTrampleMinimize", "ParalyzeTargetAlwaysHitsInRainHitsTargetInSky",
@@ -89,11 +85,9 @@ class Battle::AI
if skill >= PBTrainerAI.highSkill if skill >= PBTrainerAI.highSkill
score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :QUICKFEET]) score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :QUICKFEET])
end end
else elsif skill >= PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
score -= 90 if move.statusMove? score -= 90 if move.statusMove?
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "BurnTarget", "BurnFlinchTarget", "TwoTurnAttackBurnTarget" when "BurnTarget", "BurnFlinchTarget", "TwoTurnAttackBurnTarget"
if target.pbCanBurn?(user, false) if target.pbCanBurn?(user, false)
@@ -101,11 +95,9 @@ class Battle::AI
if skill >= PBTrainerAI.highSkill if skill >= PBTrainerAI.highSkill
score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :QUICKFEET, :FLAREBOOST]) score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :QUICKFEET, :FLAREBOOST])
end end
else elsif skill >= PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
score -= 90 if move.statusMove? score -= 90 if move.statusMove?
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "FreezeTarget", "FreezeTargetAlwaysHitsInHail", "FreezeFlinchTarget" when "FreezeTarget", "FreezeTargetAlwaysHitsInHail", "FreezeFlinchTarget"
if target.pbCanFreeze?(user, false) if target.pbCanFreeze?(user, false)
@@ -113,11 +105,9 @@ class Battle::AI
if skill >= PBTrainerAI.highSkill if skill >= PBTrainerAI.highSkill
score -= 20 if target.hasActiveAbility?(:MARVELSCALE) score -= 20 if target.hasActiveAbility?(:MARVELSCALE)
end end
else elsif skill >= PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
score -= 90 if move.statusMove? score -= 90 if move.statusMove?
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "FlinchTarget" when "FlinchTarget"
score += 30 score += 30
@@ -159,11 +149,9 @@ class Battle::AI
when "ConfuseTarget", "ConfuseTargetAlwaysHitsInRainHitsTargetInSky" when "ConfuseTarget", "ConfuseTargetAlwaysHitsInRainHitsTargetInSky"
if target.pbCanConfuse?(user, false) if target.pbCanConfuse?(user, false)
score += 30 score += 30
else elsif skill >= PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
score -= 90 if move.statusMove? score -= 90 if move.statusMove?
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "AttractTarget" when "AttractTarget"
canattract = true canattract = true
@@ -274,8 +262,8 @@ class Battle::AI
else else
score -= user.stages[:DEFENSE] * 20 score -= user.stages[:DEFENSE] * 20
end end
else elsif user.stages[:DEFENSE] < 0
score += 20 if user.stages[:DEFENSE] < 0 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "RaiseUserSpeed1" when "RaiseUserSpeed1"
@@ -290,8 +278,8 @@ class Battle::AI
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
end end
end end
else elsif user.stages[:SPEED] < 0
score += 20 if user.stages[:SPEED] < 0 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "RaiseUserSpAtk1" when "RaiseUserSpAtk1"
@@ -341,8 +329,8 @@ class Battle::AI
else else
score -= user.stages[:SPECIAL_DEFENSE] * 20 score -= user.stages[:SPECIAL_DEFENSE] * 20
end end
else elsif user.stages[:SPECIAL_DEFENSE] < 0
score += 20 if user.stages[:SPECIAL_DEFENSE] < 0 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "RaiseUserEvasion1" when "RaiseUserEvasion1"
@@ -352,8 +340,8 @@ class Battle::AI
else else
score -= user.stages[:EVASION] * 10 score -= user.stages[:EVASION] * 10
end end
else elsif user.stages[:EVASION] < 0
score += 20 if user.stages[:EVASION] < 0 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "RaiseUserCriticalHitRate2" when "RaiseUserCriticalHitRate2"
@@ -363,8 +351,8 @@ class Battle::AI
else else
score += 30 score += 30
end end
else elsif user.effects[PBEffects::FocusEnergy] < 2
score += 30 if user.effects[PBEffects::FocusEnergy] < 2 score += 30
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "RaiseUserAtkDef1" when "RaiseUserAtkDef1"
@@ -858,15 +846,15 @@ class Battle::AI
when "RaiseTargetSpAtk1ConfuseTarget" when "RaiseTargetSpAtk1ConfuseTarget"
if !target.pbCanConfuse?(user, false) if !target.pbCanConfuse?(user, false)
score -= 90 score -= 90
else elsif target.stages[:SPECIAL_ATTACK] < 0
score += 30 if target.stages[:SPECIAL_ATTACK] < 0 score += 30
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "RaiseTargetAttack2ConfuseTarget" when "RaiseTargetAttack2ConfuseTarget"
if !target.pbCanConfuse?(user, false) if !target.pbCanConfuse?(user, false)
score -= 90 score -= 90
else elsif target.stages[:ATTACK] < 0
score += 30 if target.stages[:ATTACK] < 0 score += 30
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "LowerTargetAttack1" when "LowerTargetAttack1"
@@ -909,8 +897,8 @@ class Battle::AI
else else
score += target.stages[:DEFENSE] * 20 score += target.stages[:DEFENSE] * 20
end end
else elsif target.stages[:DEFENSE] > 0
score += 20 if target.stages[:DEFENSE] > 0 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "LowerTargetSpeed1", "LowerTargetSpeed1WeakerInGrassyTerrain" when "LowerTargetSpeed1", "LowerTargetSpeed1WeakerInGrassyTerrain"
@@ -925,8 +913,8 @@ class Battle::AI
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
end end
end end
else elsif user.stages[:SPEED] > 0
score += 20 if user.stages[:SPEED] > 0 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "LowerTargetSpAtk1" when "LowerTargetSpAtk1"
@@ -969,8 +957,8 @@ class Battle::AI
else else
score += target.stages[:SPECIAL_DEFENSE] * 20 score += target.stages[:SPECIAL_DEFENSE] * 20
end end
else elsif target.stages[:SPECIAL_DEFENSE] > 0
score += 20 if target.stages[:SPECIAL_DEFENSE] > 0 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "LowerTargetAccuracy1", "LowerTargetAccuracy2", "LowerTargetAccuracy3" when "LowerTargetAccuracy1", "LowerTargetAccuracy2", "LowerTargetAccuracy3"
@@ -980,8 +968,8 @@ class Battle::AI
else else
score += target.stages[:ACCURACY] * 10 score += target.stages[:ACCURACY] * 10
end end
else elsif target.stages[:ACCURACY] > 0
score += 20 if target.stages[:ACCURACY] > 0 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "LowerTargetEvasion1", "LowerTargetEvasion2", "LowerTargetEvasion3" when "LowerTargetEvasion1", "LowerTargetEvasion2", "LowerTargetEvasion3"
@@ -991,8 +979,8 @@ class Battle::AI
else else
score += target.stages[:EVASION] * 10 score += target.stages[:EVASION] * 10
end end
else elsif target.stages[:EVASION] > 0
score += 20 if target.stages[:EVASION] > 0 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "LowerTargetEvasion1RemoveSideEffects" when "LowerTargetEvasion1RemoveSideEffects"
@@ -1002,8 +990,8 @@ class Battle::AI
else else
score += target.stages[:EVASION] * 10 score += target.stages[:EVASION] * 10
end end
else elsif target.stages[:EVASION] > 0
score += 20 if target.stages[:EVASION] > 0 score += 20
end end
score += 30 if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 || score += 30 if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 ||
target.pbOwnSide.effects[PBEffects::Reflect] > 0 || target.pbOwnSide.effects[PBEffects::Reflect] > 0 ||
@@ -1918,15 +1906,15 @@ class Battle::AI
score -= 90 score -= 90
elsif skill >= PBTrainerAI.mediumSkill && target.pbHasType?(:GRASS) elsif skill >= PBTrainerAI.mediumSkill && target.pbHasType?(:GRASS)
score -= 90 score -= 90
else elsif user.turnCount == 0
score += 60 if user.turnCount == 0 score += 60
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "HealUserByHalfOfDamageDone" when "HealUserByHalfOfDamageDone"
if skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE) if skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE)
score -= 70 score -= 70
else elsif user.hp <= user.totalhp / 2
score += 20 if user.hp <= user.totalhp / 2 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "HealUserByHalfOfDamageDoneIfTargetAsleep" when "HealUserByHalfOfDamageDoneIfTargetAsleep"
@@ -1934,16 +1922,15 @@ class Battle::AI
score -= 100 score -= 100
elsif skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE) elsif skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE)
score -= 70 score -= 70
else elsif user.hp <= user.totalhp / 2
score += 20 if user.hp <= user.totalhp / 2 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "HealTargetHalfOfTotalHP" when "HealTargetHalfOfTotalHP"
if user.opposes?(target) if user.opposes?(target)
score -= 100 score -= 100
else elsif target.hp < target.totalhp / 2 && target.effects[PBEffects::Substitute] == 0
score += 20 if target.hp < target.totalhp / 2 && score += 20
target.effects[PBEffects::Substitute] == 0
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "UserFaintsExplosive" when "UserFaintsExplosive"
@@ -1979,8 +1966,8 @@ class Battle::AI
when "StartPerishCountsForAllBattlers" when "StartPerishCountsForAllBattlers"
if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0
score -= 90 score -= 90
else elsif target.effects[PBEffects::PerishSong] > 0
score -= 90 if target.effects[PBEffects::PerishSong] > 0 score -= 90
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "ReduceAttackerMovePPTo0IfUserFaints" when "ReduceAttackerMovePPTo0IfUserFaints"
@@ -2125,14 +2112,12 @@ class Battle::AI
when "TargetTakesUserItem" when "TargetTakesUserItem"
if !user.item || target.item if !user.item || target.item
score -= 90 score -= 90
else elsif user.hasActiveItem?([:FLAMEORB, :TOXICORB, :STICKYBARB, :IRONBALL,
if user.hasActiveItem?([:FLAMEORB, :TOXICORB, :STICKYBARB, :IRONBALL,
:CHOICEBAND, :CHOICESCARF, :CHOICESPECS]) :CHOICEBAND, :CHOICESCARF, :CHOICESPECS])
score += 50 score += 50
else else
score -= 80 score -= 80
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "UserConsumeTargetBerry", "DestroyTargetBerryOrGem" when "UserConsumeTargetBerry", "DestroyTargetBerryOrGem"
if target.effects[PBEffects::Substitute] == 0 if target.effects[PBEffects::Substitute] == 0
@@ -2160,8 +2145,8 @@ class Battle::AI
when "StartNegateHeldItems" when "StartNegateHeldItems"
if @battle.field.effects[PBEffects::MagicRoom] > 0 if @battle.field.effects[PBEffects::MagicRoom] > 0
score -= 90 score -= 90
else elsif !user.item && target.item
score += 30 if !user.item && target.item score += 30
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "RecoilQuarterOfDamageDealt" when "RecoilQuarterOfDamageDealt"
@@ -2245,40 +2230,31 @@ class Battle::AI
when "AddSpikesToFoeSide" when "AddSpikesToFoeSide"
if user.pbOpposingSide.effects[PBEffects::Spikes] >= 3 if user.pbOpposingSide.effects[PBEffects::Spikes] >= 3
score -= 90 score -= 90
else elsif user.allOpposing.none? { |b| @battle.pbCanChooseNonActive?(b.index) }
if user.allOpposing.none? { |b| @battle.pbCanChooseNonActive?(b.index) } score -= 90 # Opponent can't switch in any Pokemon
# Opponent can't switch in any Pokemon
score -= 90
else else
score += 10 * @battle.pbAbleNonActiveCount(user.idxOpposingSide) score += 10 * @battle.pbAbleNonActiveCount(user.idxOpposingSide)
score += [40, 26, 13][user.pbOpposingSide.effects[PBEffects::Spikes]] score += [40, 26, 13][user.pbOpposingSide.effects[PBEffects::Spikes]]
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "AddToxicSpikesToFoeSide" when "AddToxicSpikesToFoeSide"
if user.pbOpposingSide.effects[PBEffects::ToxicSpikes] >= 2 if user.pbOpposingSide.effects[PBEffects::ToxicSpikes] >= 2
score -= 90 score -= 90
else elsif user.allOpposing.none? { |b| @battle.pbCanChooseNonActive?(b.index) }
if user.allOpposing.none? { |b| @battle.pbCanChooseNonActive?(b.index) } score -= 90 # Opponent can't switch in any Pokemon
# Opponent can't switch in any Pokemon
score -= 90
else else
score += 8 * @battle.pbAbleNonActiveCount(user.idxOpposingSide) score += 8 * @battle.pbAbleNonActiveCount(user.idxOpposingSide)
score += [26, 13][user.pbOpposingSide.effects[PBEffects::ToxicSpikes]] score += [26, 13][user.pbOpposingSide.effects[PBEffects::ToxicSpikes]]
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "AddStealthRocksToFoeSide" when "AddStealthRocksToFoeSide"
if user.pbOpposingSide.effects[PBEffects::StealthRock] if user.pbOpposingSide.effects[PBEffects::StealthRock]
score -= 90 score -= 90
else elsif user.allOpposing.none? { |b| @battle.pbCanChooseNonActive?(b.index) }
if user.allOpposing.none? { |b| @battle.pbCanChooseNonActive?(b.index) } score -= 90 # Opponent can't switch in any Pokemon
# Opponent can't switch in any Pokemon
score -= 90
else else
score += 10 * @battle.pbAbleNonActiveCount(user.idxOpposingSide) score += 10 * @battle.pbAbleNonActiveCount(user.idxOpposingSide)
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "GrassPledge" when "GrassPledge"
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -2360,10 +2336,9 @@ class Battle::AI
score += avg / 2 score += avg / 2
if user.effects[PBEffects::Stockpile] >= 3 if user.effects[PBEffects::Stockpile] >= 3
score -= 80 score -= 80
else elsif user.pbHasMoveFunction?("PowerDependsOnUserStockpile",
# More preferable if user also has Spit Up/Swallow
score += 20 if user.pbHasMoveFunction?("PowerDependsOnUserStockpile",
"HealUserDependingOnUserStockpile") # Spit Up, Swallow "HealUserDependingOnUserStockpile") # Spit Up, Swallow
score += 20 # More preferable if user also has Spit Up/Swallow
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "PowerDependsOnUserStockpile" when "PowerDependsOnUserStockpile"
@@ -2557,8 +2532,8 @@ class Battle::AI
when "HoopaRemoveProtectionsBypassSubstituteLowerUserDef1" when "HoopaRemoveProtectionsBypassSubstituteLowerUserDef1"
if !user.isSpecies?(:HOOPA) || user.form != 1 if !user.isSpecies?(:HOOPA) || user.form != 1
score -= 100 score -= 100
else elsif target.stages[:DEFENSE] > 0
score += 20 if target.stages[:DEFENSE] > 0 score += 20
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "LowerTargetSpAtk2", "LowerTargetSpAtk3" when "LowerTargetSpAtk2", "LowerTargetSpAtk3"
@@ -2657,8 +2632,8 @@ class Battle::AI
ospeed = pbRoughStat(target, :SPEED, skill) ospeed = pbRoughStat(target, :SPEED, skill)
if aspeed > ospeed if aspeed > ospeed
score -= 90 score -= 90
else elsif target.pbHasMoveType?(:FIRE)
score += 30 if target.pbHasMoveType?(:FIRE) score += 30
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "ProtectUserSideFromDamagingMovesIfUserFirstTurn" when "ProtectUserSideFromDamagingMovesIfUserFirstTurn"
@@ -2715,8 +2690,8 @@ class Battle::AI
when "HealUserByThreeQuartersOfDamageDone" when "HealUserByThreeQuartersOfDamageDone"
if skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE) if skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE)
score -= 80 score -= 80
else elsif user.hp <= user.totalhp / 2
score += 40 if user.hp <= user.totalhp / 2 score += 40
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "RaiseTargetAttack1" when "RaiseTargetAttack1"
@@ -2776,8 +2751,8 @@ class Battle::AI
when "CureTargetBurn" when "CureTargetBurn"
if target.opposes?(user) if target.opposes?(user)
score -= 40 if target.status == :BURN score -= 40 if target.status == :BURN
else elsif target.status == :BURN
score += 40 if target.status == :BURN score += 40
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "CureTargetStatusHealUserHalfOfTotalHP" when "CureTargetStatusHealUserHalfOfTotalHP"
@@ -562,7 +562,7 @@ class Battle::AI
baseDmg = [(baseDmg * multipliers[:base_damage_multiplier]).round, 1].max baseDmg = [(baseDmg * multipliers[:base_damage_multiplier]).round, 1].max
atk = [(atk * multipliers[:attack_multiplier]).round, 1].max atk = [(atk * multipliers[:attack_multiplier]).round, 1].max
defense = [(defense * multipliers[:defense_multiplier]).round, 1].max defense = [(defense * multipliers[:defense_multiplier]).round, 1].max
damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2 damage = ((((2.0 * user.level / 5) + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2
damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max
# "AI-specific calculations below" # "AI-specific calculations below"
# Increased critical hit rates # Increased critical hit rates
@@ -154,7 +154,7 @@ module Battle::CatchAndStoreMixin
# First half of the shakes calculation # First half of the shakes calculation
a = battler.totalhp a = battler.totalhp
b = battler.hp b = battler.hp
x = ((3 * a - 2 * b) * catch_rate.to_f) / (3 * a) x = (((3 * a) - (2 * b)) * catch_rate.to_f) / (3 * a)
# Calculation modifiers # Calculation modifiers
if battler.status == :SLEEP || battler.status == :FROZEN if battler.status == :SLEEP || battler.status == :FROZEN
x *= 2.5 x *= 2.5
@@ -45,8 +45,8 @@ end
def repositionY(x1, y1, x2, y2, tx, ty) def repositionY(x1, y1, x2, y2, tx, ty)
dx = x2 - x1 dx = x2 - x1
dy = y2 - y1 dy = y2 - y1
x = x1 + tx * dx.to_f x = x1 + (tx * dx.to_f)
y = y1 + ty * dy.to_f y = y1 + (ty * dy.to_f)
return [x, y] return [x, y]
end end
@@ -219,11 +219,9 @@ class RPG::Animation
timing = RPG::Animation::Timing.new timing = RPG::Animation::Timing.new
othertiming = otherAnim.timings[i] othertiming = otherAnim.timings[i]
timing.frame = frame + othertiming.frame timing.frame = frame + othertiming.frame
timing.se = RPG::AudioFile.new( timing.se = RPG::AudioFile.new(othertiming.se.name.clone,
othertiming.se.name.clone,
othertiming.se.volume, othertiming.se.volume,
othertiming.se.pitch othertiming.se.pitch)
)
timing.flash_scope = othertiming.flash_scope timing.flash_scope = othertiming.flash_scope
timing.flash_color = othertiming.flash_color.clone timing.flash_color = othertiming.flash_color.clone
timing.flash_duration = othertiming.flash_duration timing.flash_duration = othertiming.flash_duration
@@ -571,20 +569,20 @@ class PBAnimation < Array
next if frame < i.frame || frame > i.frame + i.duration next if frame < i.frame || frame > i.frame + i.duration
fraction = (frame - i.frame).to_f / i.duration fraction = (frame - i.frame).to_f / i.duration
if bgGraphic.bitmap != nil if bgGraphic.bitmap != nil
bgGraphic.ox = oldbg[0] - (i.bgX - oldbg[0]) * fraction if i.bgX != nil bgGraphic.ox = oldbg[0] - ((i.bgX - oldbg[0]) * fraction) if i.bgX != nil
bgGraphic.oy = oldbg[1] - (i.bgY - oldbg[1]) * fraction if i.bgY != nil bgGraphic.oy = oldbg[1] - ((i.bgY - oldbg[1]) * fraction) if i.bgY != nil
bgGraphic.opacity = oldbg[2] + (i.opacity - oldbg[2]) * fraction if i.opacity != nil bgGraphic.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity != nil
cr = (i.colorRed != nil) ? oldbg[3].red + (i.colorRed - oldbg[3].red) * fraction : oldbg[3].red cr = (i.colorRed != nil) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
cg = (i.colorGreen != nil) ? oldbg[3].green + (i.colorGreen - oldbg[3].green) * fraction : oldbg[3].green cg = (i.colorGreen != nil) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
cb = (i.colorBlue != nil) ? oldbg[3].blue + (i.colorBlue - oldbg[3].blue) * fraction : oldbg[3].blue cb = (i.colorBlue != nil) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + (i.colorAlpha - oldbg[3].alpha) * fraction : oldbg[3].alpha ca = (i.colorAlpha != nil) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
bgGraphic.color = Color.new(cr, cg, cb, ca) bgGraphic.color = Color.new(cr, cg, cb, ca)
else else
bgColor.opacity = oldbg[2] + (i.opacity - oldbg[2]) * fraction if i.opacity != nil bgColor.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity != nil
cr = (i.colorRed != nil) ? oldbg[3].red + (i.colorRed - oldbg[3].red) * fraction : oldbg[3].red cr = (i.colorRed != nil) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
cg = (i.colorGreen != nil) ? oldbg[3].green + (i.colorGreen - oldbg[3].green) * fraction : oldbg[3].green cg = (i.colorGreen != nil) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
cb = (i.colorBlue != nil) ? oldbg[3].blue + (i.colorBlue - oldbg[3].blue) * fraction : oldbg[3].blue cb = (i.colorBlue != nil) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + (i.colorAlpha - oldbg[3].alpha) * fraction : oldbg[3].alpha ca = (i.colorAlpha != nil) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
bgColor.color = Color.new(cr, cg, cb, ca) bgColor.color = Color.new(cr, cg, cb, ca)
end end
when 4 when 4
@@ -592,20 +590,20 @@ class PBAnimation < Array
next if frame < i.frame || frame > i.frame + i.duration next if frame < i.frame || frame > i.frame + i.duration
fraction = (frame - i.frame).to_f / i.duration fraction = (frame - i.frame).to_f / i.duration
if foGraphic.bitmap != nil if foGraphic.bitmap != nil
foGraphic.ox = oldfo[0] - (i.bgX - oldfo[0]) * fraction if i.bgX != nil foGraphic.ox = oldfo[0] - ((i.bgX - oldfo[0]) * fraction) if i.bgX != nil
foGraphic.oy = oldfo[1] - (i.bgY - oldfo[1]) * fraction if i.bgY != nil foGraphic.oy = oldfo[1] - ((i.bgY - oldfo[1]) * fraction) if i.bgY != nil
foGraphic.opacity = oldfo[2] + (i.opacity - oldfo[2]) * fraction if i.opacity != nil foGraphic.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity != nil
cr = (i.colorRed != nil) ? oldfo[3].red + (i.colorRed - oldfo[3].red) * fraction : oldfo[3].red cr = (i.colorRed != nil) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
cg = (i.colorGreen != nil) ? oldfo[3].green + (i.colorGreen - oldfo[3].green) * fraction : oldfo[3].green cg = (i.colorGreen != nil) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
cb = (i.colorBlue != nil) ? oldfo[3].blue + (i.colorBlue - oldfo[3].blue) * fraction : oldfo[3].blue cb = (i.colorBlue != nil) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + (i.colorAlpha - oldfo[3].alpha) * fraction : oldfo[3].alpha ca = (i.colorAlpha != nil) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
foGraphic.color = Color.new(cr, cg, cb, ca) foGraphic.color = Color.new(cr, cg, cb, ca)
else else
foColor.opacity = oldfo[2] + (i.opacity - oldfo[2]) * fraction if i.opacity != nil foColor.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity != nil
cr = (i.colorRed != nil) ? oldfo[3].red + (i.colorRed - oldfo[3].red) * fraction : oldfo[3].red cr = (i.colorRed != nil) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
cg = (i.colorGreen != nil) ? oldfo[3].green + (i.colorGreen - oldfo[3].green) * fraction : oldfo[3].green cg = (i.colorGreen != nil) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
cb = (i.colorBlue != nil) ? oldfo[3].blue + (i.colorBlue - oldfo[3].blue) * fraction : oldfo[3].blue cb = (i.colorBlue != nil) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + (i.colorAlpha - oldfo[3].alpha) * fraction : oldfo[3].alpha ca = (i.colorAlpha != nil) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
foColor.color = Color.new(cr, cg, cb, ca) foColor.color = Color.new(cr, cg, cb, ca)
end end
end end
@@ -925,14 +925,12 @@ Battle::AbilityEffects::MoveImmunity.add(:FLASHFIRE,
battle.pbDisplay(_INTL("The power of {1}'s Fire-type moves rose because of its {2}!", battle.pbDisplay(_INTL("The power of {1}'s Fire-type moves rose because of its {2}!",
target.pbThis(true), target.abilityName)) target.pbThis(true), target.abilityName))
end end
else elsif Battle::Scene::USE_ABILITY_SPLASH
if Battle::Scene::USE_ABILITY_SPLASH
battle.pbDisplay(_INTL("It doesn't affect {1}...", target.pbThis(true))) battle.pbDisplay(_INTL("It doesn't affect {1}...", target.pbThis(true)))
else else
battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!", battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
target.pbThis, target.abilityName, move.name)) target.pbThis, target.abilityName, move.name))
end end
end
battle.pbHideAbilitySplash(target) battle.pbHideAbilitySplash(target)
end end
next true next true
@@ -2604,8 +2602,8 @@ Battle::AbilityEffects::OnSwitchIn.add(:ANTICIPATION,
next if Effectiveness.ineffective?(eff) next if Effectiveness.ineffective?(eff)
next if !Effectiveness.super_effective?(eff) && next if !Effectiveness.super_effective?(eff) &&
!["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function) !["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function)
else elsif !["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function)
next if !["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function) next
end end
found = true found = true
break break
@@ -2857,8 +2855,8 @@ Battle::AbilityEffects::OnSwitchIn.add(:INTIMIDATE,
check_item = true check_item = true
if b.hasActiveAbility?(:CONTRARY) if b.hasActiveAbility?(:CONTRARY)
check_item = false if b.statStageAtMax?(:ATTACK) check_item = false if b.statStageAtMax?(:ATTACK)
else elsif b.statStageAtMin?(:ATTACK)
check_item = false if b.statStageAtMin?(:ATTACK) check_item = false
end end
check_ability = b.pbLowerAttackStatStageIntimidate(battler) check_ability = b.pbLowerAttackStatStageIntimidate(battler)
b.pbAbilitiesOnIntimidated if check_ability b.pbAbilitiesOnIntimidated if check_ability
@@ -922,7 +922,7 @@ Battle::ItemEffects::DamageCalcFromUser.copy(:METALCOAT, :IRONPLATE)
Battle::ItemEffects::DamageCalcFromUser.add(:METRONOME, Battle::ItemEffects::DamageCalcFromUser.add(:METRONOME,
proc { |item, user, target, move, mults, baseDmg, type| proc { |item, user, target, move, mults, baseDmg, type|
met = 1 + 0.2 * [user.effects[PBEffects::Metronome], 5].min met = 1 + (0.2 * [user.effects[PBEffects::Metronome], 5].min)
mults[:final_damage_multiplier] *= met mults[:final_damage_multiplier] *= met
} }
) )
@@ -1030,11 +1030,9 @@ Battle::ItemEffects::DamageCalcFromUser.add(:SOULDEW,
next if !user.isSpecies?(:LATIAS) && !user.isSpecies?(:LATIOS) next if !user.isSpecies?(:LATIAS) && !user.isSpecies?(:LATIOS)
if Settings::SOUL_DEW_POWERS_UP_TYPES if Settings::SOUL_DEW_POWERS_UP_TYPES
mults[:final_damage_multiplier] *= 1.2 if [:DRAGON, :PSYCHIC].include?(type) mults[:final_damage_multiplier] *= 1.2 if [:DRAGON, :PSYCHIC].include?(type)
else elsif move.specialMove? && !user.battle.rules["souldewclause"]
if move.specialMove? && !user.battle.rules["souldewclause"]
mults[:attack_multiplier] *= 1.5 mults[:attack_multiplier] *= 1.5
end end
end
} }
) )
@@ -113,7 +113,7 @@ class Battle::Scene::Animation::ThrowBait < Battle::Scene::Animation
traSprite = @sprites["player_1"] traSprite = @sprites["player_1"]
ballPos = Battle::Scene.pbBattlerPosition(@battler.index, batSprite.sideSize) ballPos = Battle::Scene.pbBattlerPosition(@battler.index, batSprite.sideSize)
ballStartX = traSprite.x ballStartX = traSprite.x
ballStartY = traSprite.y - traSprite.bitmap.height / 2 ballStartY = traSprite.y - (traSprite.bitmap.height / 2)
ballMidX = 0 # Unused in arc calculation ballMidX = 0 # Unused in arc calculation
ballMidY = 122 ballMidY = 122
ballEndX = ballPos[0] - 40 ballEndX = ballPos[0] - 40
@@ -178,11 +178,11 @@ class Battle::Scene::Animation::ThrowRock < Battle::Scene::Animation
batSprite = @sprites["pokemon_#{@battler.index}"] batSprite = @sprites["pokemon_#{@battler.index}"]
traSprite = @sprites["player_1"] traSprite = @sprites["player_1"]
ballStartX = traSprite.x ballStartX = traSprite.x
ballStartY = traSprite.y - traSprite.bitmap.height / 2 ballStartY = traSprite.y - (traSprite.bitmap.height / 2)
ballMidX = 0 # Unused in arc calculation ballMidX = 0 # Unused in arc calculation
ballMidY = 122 ballMidY = 122
ballEndX = batSprite.x ballEndX = batSprite.x
ballEndY = batSprite.y - batSprite.bitmap.height / 2 ballEndY = batSprite.y - (batSprite.bitmap.height / 2)
# Set up trainer sprite # Set up trainer sprite
trainer = addSprite(traSprite, PictureOrigin::Bottom) trainer = addSprite(traSprite, PictureOrigin::Bottom)
# Set up bait sprite # Set up bait sprite
@@ -242,13 +242,12 @@ class Battle::Scene
end end
def pbSafariCommandMenu(index) def pbSafariCommandMenu(index)
pbCommandMenuEx(index, [ pbCommandMenuEx(index,
_INTL("What will\n{1} throw?", @battle.pbPlayer.name), [_INTL("What will\n{1} throw?", @battle.pbPlayer.name),
_INTL("Ball"), _INTL("Ball"),
_INTL("Bait"), _INTL("Bait"),
_INTL("Rock"), _INTL("Rock"),
_INTL("Run") _INTL("Run")], 3)
], 3)
end end
def pbThrowBait def pbThrowBait
@@ -324,10 +323,8 @@ class SafariBattle
@player = [player] @player = [player]
@party2 = party2 @party2 = party2
@sideSizes = [1, 1] @sideSizes = [1, 1]
@battlers = [ @battlers = [Battle::FakeBattler.new(self, 0),
Battle::FakeBattler.new(self, 0), Battle::FakeBattler.new(self, 1)]
Battle::FakeBattler.new(self, 1)
]
@rules = {} @rules = {}
@ballCount = 0 @ballCount = 0
end end
@@ -45,13 +45,12 @@ class BugContestBattle < Battle
end end
def pbCommandMenu(idxBattler, _firstAction) def pbCommandMenu(idxBattler, _firstAction)
return @scene.pbCommandMenuEx(idxBattler, [ return @scene.pbCommandMenuEx(idxBattler,
_INTL("Sport Balls: {1}", @ballCount), [_INTL("Sport Balls: {1}", @ballCount),
_INTL("Fight"), _INTL("Fight"),
_INTL("Ball"), _INTL("Ball"),
_INTL("Pokémon"), _INTL("Pokémon"),
_INTL("Run") _INTL("Run")], 4)
], 4)
end end
def pbConsumeItemInBag(_item, _idxBattler) def pbConsumeItemInBag(_item, _idxBattler)
@@ -245,8 +245,8 @@ module RPG
return return
end end
if @weatherTypes[weather_type][0].category == :Rain && index.odd? # Splash if @weatherTypes[weather_type][0].category == :Rain && index.odd? # Splash
sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + sprite.bitmap.width * 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) 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 lifetimes[index] = (rand(30...50)) * 0.01 # 0.3-0.5 seconds
else else
x_speed = @weatherTypes[weather_type][0].particle_delta_x x_speed = @weatherTypes[weather_type][0].particle_delta_x
@@ -255,14 +255,14 @@ module RPG
if gradient.abs >= 1 if gradient.abs >= 1
# Position sprite to the right of the screen # Position sprite to the right of the screen
sprite.x = @ox + Graphics.width + rand(Graphics.width) sprite.x = @ox + Graphics.width + rand(Graphics.width)
sprite.y = @oy + Graphics.height - rand(Graphics.height + sprite.bitmap.height - Graphics.width / gradient) 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) 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 lifetimes[index] = (distance_to_cover.to_f / x_speed).abs
else else
# Position sprite to the top of the screen # 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) 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 lifetimes[index] = (distance_to_cover.to_f / y_speed).abs
end end
end end
@@ -333,8 +333,8 @@ module RPG
def update_tile_position(sprite, index) def update_tile_position(sprite, index)
return if !sprite || !sprite.bitmap || !sprite.visible return if !sprite || !sprite.bitmap || !sprite.visible
sprite.x = @tile_x.round + (index % @tiles_wide) * sprite.bitmap.width sprite.x = @tile_x.round + ((index % @tiles_wide) * sprite.bitmap.width)
sprite.y = @tile_y.round + (index / @tiles_wide) * sprite.bitmap.height 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.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.y -= @tiles_tall * sprite.bitmap.height if sprite.y - @oy > Graphics.height
sprite.visible = true sprite.visible = true
@@ -372,10 +372,10 @@ module RPG
@fade_time < [FADE_NEW_TONE_END - @time_shift, 0].max @fade_time < [FADE_NEW_TONE_END - @time_shift, 0].max
weather_max = @target_max weather_max = @target_max
fract = (@fade_time - [FADE_NEW_TONE_START - @time_shift, 0].max) / (FADE_NEW_TONE_END - FADE_NEW_TONE_START) 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_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_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_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_gray = @target_tone.gray + ((1 - fract) * (@old_tone.gray - @target_tone.gray))
else else
tone_red = @viewport.tone.red tone_red = @viewport.tone.red
tone_green = @viewport.tone.green tone_green = @viewport.tone.green
@@ -153,12 +153,12 @@ class LightEffect_Basic < LightEffect
super super
if (Object.const_defined?(:ScreenPosHelper) rescue false) if (Object.const_defined?(:ScreenPosHelper) rescue false)
@light.x = ScreenPosHelper.pbScreenX(@event) @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_x = ScreenPosHelper.pbScreenZoomX(@event)
@light.zoom_y = @light.zoom_x @light.zoom_y = @light.zoom_x
else else
@light.x = @event.screen_x @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 end
@light.tone = $game_screen.tone @light.tone = $game_screen.tone
end end
@@ -188,12 +188,12 @@ class LightEffect_DayNight < LightEffect
if @light.opacity > 0 if @light.opacity > 0
if (Object.const_defined?(:ScreenPosHelper) rescue false) if (Object.const_defined?(:ScreenPosHelper) rescue false)
@light.x = ScreenPosHelper.pbScreenX(@event) @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_x = ScreenPosHelper.pbScreenZoomX(@event)
@light.zoom_y = ScreenPosHelper.pbScreenZoomY(@event) @light.zoom_y = ScreenPosHelper.pbScreenZoomY(@event)
else else
@light.x = @event.screen_x @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 end
@light.tone.set($game_screen.tone.red, @light.tone.set($game_screen.tone.red,
$game_screen.tone.green, $game_screen.tone.green,
+3 -3
View File
@@ -286,8 +286,8 @@ Events.onMapSceneChange += proc { |_sender, e|
if $PokemonGlobal.mapTrail[1] if $PokemonGlobal.mapTrail[1]
for i in 0...Settings::NO_SIGNPOSTS.length / 2 for i in 0...Settings::NO_SIGNPOSTS.length / 2
nosignpost = true if Settings::NO_SIGNPOSTS[2 * i] == $PokemonGlobal.mapTrail[1] && nosignpost = true if Settings::NO_SIGNPOSTS[2 * i] == $PokemonGlobal.mapTrail[1] &&
Settings::NO_SIGNPOSTS[2 * i + 1] == $game_map.map_id Settings::NO_SIGNPOSTS[(2 * i) + 1] == $game_map.map_id
nosignpost = true if Settings::NO_SIGNPOSTS[2 * i + 1] == $PokemonGlobal.mapTrail[1] && nosignpost = true if Settings::NO_SIGNPOSTS[(2 * i) + 1] == $PokemonGlobal.mapTrail[1] &&
Settings::NO_SIGNPOSTS[2 * i] == $game_map.map_id Settings::NO_SIGNPOSTS[2 * i] == $game_map.map_id
break if nosignpost break if nosignpost
end end
@@ -378,7 +378,7 @@ def pbEventCanReachPlayer?(event, player, distance)
end end
if real_distance > 0 if real_distance > 0
real_distance.times do |i| 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
end end
return true return true
@@ -182,8 +182,8 @@ def pbGetEnvironment
tile_environment = terrainTag.battle_environment tile_environment = terrainTag.battle_environment
if ret == :Forest && [:Grass, :TallGrass].include?(tile_environment) if ret == :Forest && [:Grass, :TallGrass].include?(tile_environment)
ret = :ForestGrass ret = :ForestGrass
else elsif tile_environment
ret = tile_environment if tile_environment ret = tile_environment
end end
return ret return ret
end end
@@ -383,13 +383,14 @@ def pbTrainerBattleCore(*args)
foeParty = [] foeParty = []
foePartyStarts = [] foePartyStarts = []
for arg in args for arg in args
if arg.is_a?(NPCTrainer) case arg
when NPCTrainer
foeTrainers.push(arg) foeTrainers.push(arg)
foePartyStarts.push(foeParty.length) foePartyStarts.push(foeParty.length)
arg.party.each { |pkmn| foeParty.push(pkmn) } arg.party.each { |pkmn| foeParty.push(pkmn) }
foeEndSpeeches.push(arg.lose_text) foeEndSpeeches.push(arg.lose_text)
foeItems.push(arg.items) 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]) trainer = pbLoadTrainer(arg[0], arg[1], arg[2])
pbMissingTrainer(arg[0], arg[1], arg[2]) if !trainer pbMissingTrainer(arg[0], arg[1], arg[2]) if !trainer
return 0 if !trainer return 0 if !trainer
@@ -709,7 +710,7 @@ end
def pbHoneyGather(pkmn) def pbHoneyGather(pkmn)
return if !GameData::Item.exists?(:HONEY) return if !GameData::Item.exists?(:HONEY)
return if pkmn.egg? || !pkmn.hasAbility?(:HONEYGATHER) || pkmn.hasItem? 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 return unless rand(100) < chance
pkmn.item = :HONEY pkmn.item = :HONEY
end end
@@ -155,7 +155,7 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
Input.update Input.update
pbUpdateSceneMap pbUpdateSceneMap
timer += Graphics.delta_s 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 break if viewport.color.alpha <= 0
end end
viewport.dispose viewport.dispose
@@ -267,9 +267,9 @@ SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
flash.opacity -= 52 * 20 / Graphics.frame_rate if flash.opacity > 0 flash.opacity -= 52 * 20 / Graphics.frame_rate if flash.opacity > 0
bar1.ox -= 32 * 20 / Graphics.frame_rate bar1.ox -= 32 * 20 / Graphics.frame_rate
bar2.ox += 32 * 20 / Graphics.frame_rate bar2.ox += 32 * 20 / Graphics.frame_rate
if i >= animTime / 2 && i < slideInTime + animTime / 2 if i >= animTime / 2 && i < slideInTime + (animTime / 2)
player.x = xoffset * (i + 1 - slideInTime - animTime / 2) / slideInTime player.x = xoffset * (i + 1 - slideInTime - (animTime / 2)) / slideInTime
trainer.x = xoffset * (slideInTime - i - 1 + animTime / 2) / slideInTime trainer.x = xoffset * (slideInTime - i - 1 + (animTime / 2)) / slideInTime
end end
pbWait(1) pbWait(1)
end end
@@ -114,7 +114,7 @@ class PokemonEncounters
return true if pbPokeRadarOnShakingGrass return true if pbPokeRadarOnShakingGrass
# Get base encounter chance and minimum steps grace period # Get base encounter chance and minimum steps grace period
encounter_chance = @step_chances[enc_type].to_f 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 # Apply modifiers to the encounter chance and the minimum steps amount
if triggered_by_step if triggered_by_step
encounter_chance += @chance_accumulator / 200 encounter_chance += @chance_accumulator / 200
@@ -168,7 +168,7 @@ class PokemonEncounters
# after a previous wild encounter # after a previous wild encounter
if triggered_by_step && @step_count < min_steps_needed if triggered_by_step && @step_count < min_steps_needed
@step_count += 1 @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 end
# Decide whether the wild encounter should actually happen # Decide whether the wild encounter should actually happen
return true if rand(100) < encounter_chance return true if rand(100) < encounter_chance
@@ -429,7 +429,7 @@ def pbGenerateWildPokemon(species, level, isRoamer = false)
shiny_retries.times do shiny_retries.times do
break if genwildpoke.shiny? break if genwildpoke.shiny?
genwildpoke.shiny = nil # Make it recalculate shininess 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
end end
# Give Pokérus # Give Pokérus
@@ -148,9 +148,9 @@ def moonphase(time = nil) # in UTC
27.6849270496875 27.6849270496875
] ]
yy = time.year - ((12 - time.mon) / 10.0).floor 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 -= (((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 = (j - 2451550.1) / 29.530588853
v = ((v - v.floor) + (v < 0 ? 1 : 0)) v = ((v - v.floor) + (v < 0 ? 1 : 0))
ag = v * 29.53 ag = v * 29.53
@@ -178,8 +178,8 @@ def zodiac(month, day)
2, 19, 3, 20 # Pisces 2, 19, 3, 20 # Pisces
] ]
for i in 0...12 for i in 0...12
return i if month == time[i * 4] && day >= time[i * 4 + 1] 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) + 2] && day <= time[(i * 4) + 3]
end end
return 0 return 0
end end
@@ -258,8 +258,7 @@ def pbGetMonthName(month)
end end
def pbGetAbbrevMonthName(month) def pbGetAbbrevMonthName(month)
return ["", return [_INTL("Jan."),
_INTL("Jan."),
_INTL("Feb."), _INTL("Feb."),
_INTL("Mar."), _INTL("Mar."),
_INTL("Apr."), _INTL("Apr."),
@@ -270,7 +269,7 @@ def pbGetAbbrevMonthName(month)
_INTL("Sep."), _INTL("Sep."),
_INTL("Oct."), _INTL("Oct."),
_INTL("Nov."), _INTL("Nov."),
_INTL("Dec.")][month] _INTL("Dec.")][month - 1]
end end
#=============================================================================== #===============================================================================
@@ -287,12 +286,10 @@ def pbIsSeason(seasonVariable, *arg)
ret = true if wd == thisseason ret = true if wd == thisseason
end end
if seasonVariable > 0 if seasonVariable > 0
$game_variables[seasonVariable] = [ $game_variables[seasonVariable] = [_INTL("Spring"),
_INTL("Spring"),
_INTL("Summer"), _INTL("Summer"),
_INTL("Autumn"), _INTL("Autumn"),
_INTL("Winter") _INTL("Winter")][thisseason]
][thisseason]
$game_map.need_refresh = true if $game_map $game_map.need_refresh = true if $game_map
end end
return ret return ret
@@ -159,15 +159,15 @@ def pbHiddenMoveAnimation(pokemon)
strobe.ox = strobe.viewport.rect.x strobe.ox = strobe.viewport.rect.x
strobe.oy = strobe.viewport.rect.y strobe.oy = strobe.viewport.rect.y
if !strobe.visible # Initial placement of strobes if !strobe.visible # Initial placement of strobes
randomY = 16 * (1 + rand(bg.bitmap.height / 16 - 2)) randomY = 16 * (1 + rand((bg.bitmap.height / 16) - 2))
strobe.y = randomY + (Graphics.height - bg.bitmap.height) / 2 strobe.y = randomY + ((Graphics.height - bg.bitmap.height) / 2)
strobe.x = rand(Graphics.width) strobe.x = rand(Graphics.width)
strobe.visible = true strobe.visible = true
elsif strobe.x < Graphics.width # Move strobe right elsif strobe.x < Graphics.width # Move strobe right
strobe.x += strobeSpeed strobe.x += strobeSpeed
else # Strobe is off the screen, reposition it to the left of the screen else # Strobe is off the screen, reposition it to the left of the screen
randomY = 16 * (1 + rand(bg.bitmap.height / 16 - 2)) randomY = 16 * (1 + rand((bg.bitmap.height / 16) - 2))
strobe.y = randomY + (Graphics.height - bg.bitmap.height) / 2 strobe.y = randomY + ((Graphics.height - bg.bitmap.height) / 2)
strobe.x = -strobe.bitmap.width - rand(Graphics.width / 4) strobe.x = -strobe.bitmap.width - rand(Graphics.width / 4)
end end
end end
@@ -236,15 +236,13 @@ def pbSmashEvent(event)
elsif event.name[/smashrock/i] elsif event.name[/smashrock/i]
pbSEPlay("Rock Smash", 80) pbSEPlay("Rock Smash", 80)
end end
pbMoveRoute(event, [ pbMoveRoute(event, [PBMoveRoute::Wait, 2,
PBMoveRoute::Wait, 2,
PBMoveRoute::TurnLeft, PBMoveRoute::TurnLeft,
PBMoveRoute::Wait, 2, PBMoveRoute::Wait, 2,
PBMoveRoute::TurnRight, PBMoveRoute::TurnRight,
PBMoveRoute::Wait, 2, PBMoveRoute::Wait, 2,
PBMoveRoute::TurnUp, PBMoveRoute::TurnUp,
PBMoveRoute::Wait, 2 PBMoveRoute::Wait, 2])
])
pbWait(Graphics.frame_rate * 4 / 10) pbWait(Graphics.frame_rate * 4 / 10)
event.erase event.erase
$PokemonMap.addErasedEvent(event.id) if $PokemonMap $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 $map_factory.getTerrainTag(surface_map_id, $game_player.x, $game_player.y).can_dive
pbSurfacing pbSurfacing
end end
else elsif $game_player.terrain_tag.can_dive
pbDive if $game_player.terrain_tag.can_dive pbDive
end end
} }
@@ -84,16 +84,13 @@ class BerryPlantData
data = GameData::BerryPlant.get(@berry_id) data = GameData::BerryPlant.get(@berry_id)
if @new_mechanics if @new_mechanics
return [data.maximum_yield * (5 - @yield_penalty) / 5, data.minimum_yield].max return [data.maximum_yield * (5 - @yield_penalty) / 5, data.minimum_yield].max
else elsif @watering_count > 0
if @watering_count > 0
ret = (data.maximum_yield - data.minimum_yield) * (@watering_count - 1) ret = (data.maximum_yield - data.minimum_yield) * (@watering_count - 1)
ret += rand(1 + data.maximum_yield - data.minimum_yield) ret += rand(1 + data.maximum_yield - data.minimum_yield)
return (ret / 4) + data.minimum_yield return (ret / 4) + data.minimum_yield
else end
return data.minimum_yield return data.minimum_yield
end end
end
end
# Old mechanics only update a plant when its map is loaded. New mechanics # Old mechanics only update a plant when its map is loaded. New mechanics
# update it every frame while its map is loaded. # update it every frame while its map is loaded.
@@ -138,7 +135,7 @@ class BerryPlantData
# Update how long plant has been alive for # Update how long plant has been alive for
old_growth_stage = @growth_stage old_growth_stage = @growth_stage
@time_alive = new_time_alive @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 @growth_stage += 1 if replanted? # Replants start at stage 2
@time_last_updated = time_now.to_i @time_last_updated = time_now.to_i
# Record watering (old mechanics), and apply drying out per hour (new mechanics) # Record watering (old mechanics), and apply drying out per hour (new mechanics)
@@ -244,7 +244,7 @@ class DayCare
shiny_retries.times do shiny_retries.times do
break if egg.shiny? break if egg.shiny?
egg.shiny = nil # Make it recalculate shininess 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
end end
@@ -118,7 +118,7 @@ module RandomDungeonGenerator
def paint_corridor(tile, x, y, width, height) def paint_corridor(tile, x, y, width, height)
for j in 0...height for j in 0...height
for i in 0...width 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 end
end end
@@ -129,25 +129,25 @@ module RandomDungeonGenerator
when TURN_NONE when TURN_NONE
for y in 0...CELL_HEIGHT for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH 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
end end
when TURN_LEFT when TURN_LEFT
for y in 0...CELL_HEIGHT for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH 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
end end
when TURN_RIGHT when TURN_RIGHT
for y in 0...CELL_HEIGHT for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH 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
end end
when TURN_BACK when TURN_BACK
for y in 0...CELL_HEIGHT for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH 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 end
end end
@@ -164,8 +164,8 @@ module RandomDungeonGenerator
width = rand(ROOM_MIN_WIDTH..ROOM_MAX_WIDTH) width = rand(ROOM_MIN_WIDTH..ROOM_MAX_WIDTH)
height = rand(ROOM_MIN_HEIGHT..ROOM_MAX_HEIGHT) height = rand(ROOM_MIN_HEIGHT..ROOM_MAX_HEIGHT)
return false if width <= 0 || height <= 0 return false if width <= 0 || height <= 0
centerX = CELL_WIDTH / 2 + rand(5) - 2 centerX = (CELL_WIDTH / 2) + rand(5) - 2
centerY = CELL_HEIGHT / 2 + rand(5) - 2 centerY = (CELL_HEIGHT / 2) + rand(5) - 2
x = centerX - (width / 2) x = centerX - (width / 2)
y = centerY - (height / 2) y = centerY - (height / 2)
rect = [x, y, width, height] rect = [x, y, width, height]
@@ -244,17 +244,17 @@ module RandomDungeonGenerator
def getVisited(x, y) def getVisited(x, y)
return false if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight 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 end
def setVisited(x, y) def setVisited(x, y)
return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight
@cells[y * cellWidth + x] |= EdgeMasks::VISITED @cells[(y * cellWidth) + x] |= EdgeMasks::VISITED
end end
def clearVisited(x, y) def clearVisited(x, y)
return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight
@cells[y * cellWidth + x] &= ~EdgeMasks::VISITED @cells[(y * cellWidth) + x] &= ~EdgeMasks::VISITED
end end
def clearAllCells def clearAllCells
@@ -265,12 +265,12 @@ module RandomDungeonGenerator
def getEdgeNode(x, y, edge) def getEdgeNode(x, y, edge)
return false if x < 0 || y < 0 || x >= nodeWidth || y >= nodeHeight 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 end
def setEdgeNode(x, y, edge) def setEdgeNode(x, y, edge)
return if x < 0 || x >= nodeWidth || y < 0 || y >= nodeHeight return if x < 0 || x >= nodeWidth || y < 0 || y >= nodeHeight
@nodes[y * nodeWidth + x].setEdge(edge) @nodes[(y * nodeWidth) + x].setEdge(edge)
e = 0 e = 0
nx = x nx = x
ny = y ny = y
@@ -291,7 +291,7 @@ module RandomDungeonGenerator
return return
end end
return if nx < 0 || ny < 0 || nx >= nodeWidth || ny >= nodeHeight return if nx < 0 || ny < 0 || nx >= nodeWidth || ny >= nodeHeight
@nodes[ny * nodeWidth + nx].setEdge(e) @nodes[(ny * nodeWidth) + nx].setEdge(e)
end end
def setAllEdges def setAllEdges
@@ -302,7 +302,7 @@ module RandomDungeonGenerator
def clearEdgeNode(x, y, edge) def clearEdgeNode(x, y, edge)
return if x < 0 || x >= nodeWidth || y < 0 || y >= nodeHeight return if x < 0 || x >= nodeWidth || y < 0 || y >= nodeHeight
@nodes[y * nodeWidth + x].clearEdge(edge) @nodes[(y * nodeWidth) + x].clearEdge(edge)
e = 0 e = 0
nx = x nx = x
ny = y ny = y
@@ -323,7 +323,7 @@ module RandomDungeonGenerator
raise ArgumentError.new raise ArgumentError.new
end end
return if nx < 0 || ny < 0 || nx >= nodeWidth || ny >= nodeHeight return if nx < 0 || ny < 0 || nx >= nodeWidth || ny >= nodeHeight
@nodes[ny * nodeWidth + nx].clearEdge(e) @nodes[(ny * nodeWidth) + nx].clearEdge(e)
end end
def clearAllEdges def clearAllEdges
@@ -334,7 +334,7 @@ module RandomDungeonGenerator
def isBlockedNode?(x, y) def isBlockedNode?(x, y)
return false if x < 0 || y < 0 || x >= nodeWidth || y >= nodeHeight return false if x < 0 || y < 0 || x >= nodeWidth || y >= nodeHeight
return @nodes[y * nodeWidth + x].isBlocked? return @nodes[(y * nodeWidth) + x].isBlocked?
end end
def getEdgePattern(x, y) def getEdgePattern(x, y)
@@ -483,22 +483,22 @@ module RandomDungeonGenerator
end end
def [](x, y) def [](x, y)
return @array[y * @width + x] return @array[(y * @width) + x]
end end
def []=(x, y, value) def []=(x, y, value)
@array[y * @width + x] = value @array[(y * @width) + x] = value
end end
def value(x, y) def value(x, y)
return DungeonTile::VOID if x < 0 || y < 0 || x >= @width || y >= @height return DungeonTile::VOID if x < 0 || y < 0 || x >= @width || y >= @height
return @array[y * @width + x] return @array[(y * @width) + x]
end end
# Unused # Unused
def get(x, y) def get(x, y)
return false if x < 0 || y < 0 || x >= @width || y >= @height 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 end
# Unused # Unused
@@ -553,8 +553,8 @@ module RandomDungeonGenerator
def generate def generate
self.clear self.clear
maxWidth = @width - BUFFER_X * 2 maxWidth = @width - (BUFFER_X * 2)
maxHeight = @height - BUFFER_Y * 2 maxHeight = @height - (BUFFER_Y * 2)
cellWidth = DungeonMaze::CELL_WIDTH cellWidth = DungeonMaze::CELL_WIDTH
cellHeight = DungeonMaze::CELL_HEIGHT cellHeight = DungeonMaze::CELL_HEIGHT
return if maxWidth < 0 || maxHeight < 0 return if maxWidth < 0 || maxHeight < 0
@@ -576,7 +576,7 @@ module RandomDungeonGenerator
for x in 0...maxWidth / cellWidth for x in 0...maxWidth / cellWidth
pattern = maze.getEdgePattern(x, y) pattern = maze.getEdgePattern(x, y)
next if !DungeonMaze.paint_cell_contents( 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 corridor_patterns[pattern], DungeonMaze::TURN_NONE
) )
roomcount += 1 roomcount += 1
@@ -605,7 +605,7 @@ module RandomDungeonGenerator
for j in 0...map.height for j in 0...map.height
nb = TileDrawingHelper.tableNeighbors(tbl, i, j) nb = TileDrawingHelper.tableNeighbors(tbl, i, j)
tile = TileDrawingHelper::NEIGHBORS_TO_AUTOTILE_INDEX[nb] 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, 1] = 0
map.data[i, j, 2] = 0 map.data[i, j, 2] = 0
end end
@@ -638,8 +638,8 @@ module RandomDungeonGenerator
# @param x_cells [Integer] the number of cells wide the dungeon will be # @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 # @param y_cells [Intenger] the number of cells tall the dungeon will be
def self.generate_test_dungeon(x_cells = 4, y_cells = 4) def self.generate_test_dungeon(x_cells = 4, y_cells = 4)
dungeon = Dungeon.new(Dungeon::BUFFER_X * 2 + DungeonMaze::CELL_WIDTH * x_cells, dungeon = Dungeon.new((Dungeon::BUFFER_X * 2) + (DungeonMaze::CELL_WIDTH * x_cells),
Dungeon::BUFFER_Y * 2 + DungeonMaze::CELL_HEIGHT * y_cells) (Dungeon::BUFFER_Y * 2) + (DungeonMaze::CELL_HEIGHT * y_cells))
dungeon.generate dungeon.generate
echoln dungeon.write echoln dungeon.write
end end
+6 -16
View File
@@ -319,7 +319,7 @@ def pbGainExpFromExpCandy(pkmn, base_amt, qty, scene)
if qty > 1 if qty > 1
(qty - 1).times { pkmn.changeHappiness("vitamin") } (qty - 1).times { pkmn.changeHappiness("vitamin") }
end end
pbChangeExp(pkmn, pkmn.exp + base_amt * qty, scene) pbChangeExp(pkmn, pkmn.exp + (base_amt * qty), scene)
scene.pbHardRefresh scene.pbHardRefresh
return true return true
end end
@@ -351,11 +351,9 @@ def pbBattleHPItem(pkmn, battler, restoreHP, scene)
if battler.pbRecoverHP(restoreHP) > 0 if battler.pbRecoverHP(restoreHP) > 0
scene.pbDisplay(_INTL("{1}'s HP was restored.", battler.pbThis)) scene.pbDisplay(_INTL("{1}'s HP was restored.", battler.pbThis))
end end
else elsif pbItemRestoreHP(pkmn, restoreHP) > 0
if pbItemRestoreHP(pkmn, restoreHP) > 0
scene.pbDisplay(_INTL("{1}'s HP was restored.", pkmn.name)) scene.pbDisplay(_INTL("{1}'s HP was restored.", pkmn.name))
end end
end
return true return true
end end
@@ -814,36 +812,28 @@ def pbGiveItemToPokemon(item, pkmn, scene, pkmnid = 0)
if scene.pbConfirm(_INTL("Would you like to switch the two items?")) if scene.pbConfirm(_INTL("Would you like to switch the two items?"))
$bag.remove(item) $bag.remove(item)
if !$bag.add(pkmn.item) if !$bag.add(pkmn.item)
if !$bag.add(item) raise _INTL("Couldn't re-store deleted item in Bag somehow") if !$bag.add(item)
raise _INTL("Could't re-store deleted item in Bag somehow")
end
scene.pbDisplay(_INTL("The Bag is full. The Pokémon's item could not be removed.")) scene.pbDisplay(_INTL("The Bag is full. The Pokémon's item could not be removed."))
else elsif GameData::Item.get(item).is_mail?
if GameData::Item.get(item).is_mail?
if pbWriteMail(item, pkmn, pkmnid, scene) if pbWriteMail(item, pkmn, pkmnid, scene)
pkmn.item = item pkmn.item = item
scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.", olditemname, pkmn.name, newitemname)) scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.", olditemname, pkmn.name, newitemname))
return true return true
else elsif !$bag.add(item)
if !$bag.add(item)
raise _INTL("Couldn't re-store deleted item in Bag somehow") raise _INTL("Couldn't re-store deleted item in Bag somehow")
end end
end
else else
pkmn.item = item pkmn.item = item
scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.", olditemname, pkmn.name, newitemname)) scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.", olditemname, pkmn.name, newitemname))
return true return true
end end
end end
end elsif !GameData::Item.get(item).is_mail? || pbWriteMail(item, pkmn, pkmnid, scene)
else
if !GameData::Item.get(item).is_mail? || pbWriteMail(item, pkmn, pkmnid, scene)
$bag.remove(item) $bag.remove(item)
pkmn.item = item pkmn.item = item
scene.pbDisplay(_INTL("{1} is now holding the {2}.", pkmn.name, newitemname)) scene.pbDisplay(_INTL("{1} is now holding the {2}.", pkmn.name, newitemname))
return true return true
end end
end
return false return false
end end
+24 -12
View File
@@ -943,11 +943,13 @@ ItemHandlers::UseOnPokemonMaximum.add(:POMEGBERRY, proc { |item, pkmn|
}) })
ItemHandlers::UseOnPokemon.add(:POMEGBERRY, proc { |item, qty, pkmn, scene| ItemHandlers::UseOnPokemon.add(:POMEGBERRY, proc { |item, qty, pkmn, scene|
next pbRaiseHappinessAndLowerEV(pkmn, scene, :HP, qty, [ next pbRaiseHappinessAndLowerEV(
pkmn, scene, :HP, qty, [
_INTL("{1} adores you! Its base HP fell!", pkmn.name), _INTL("{1} adores you! Its base HP fell!", pkmn.name),
_INTL("{1} became more friendly. Its base HP can't go lower.", pkmn.name), _INTL("{1} became more friendly. Its base HP can't go lower.", pkmn.name),
_INTL("{1} became more friendly. However, its base HP fell!", pkmn.name) _INTL("{1} became more friendly. However, its base HP fell!", pkmn.name)
]) ]
)
}) })
ItemHandlers::UseOnPokemonMaximum.add(:KELPSYBERRY, proc { |item, pkmn| ItemHandlers::UseOnPokemonMaximum.add(:KELPSYBERRY, proc { |item, pkmn|
@@ -955,11 +957,13 @@ ItemHandlers::UseOnPokemonMaximum.add(:KELPSYBERRY, proc { |item, pkmn|
}) })
ItemHandlers::UseOnPokemon.add(:KELPSYBERRY, proc { |item, qty, pkmn, scene| ItemHandlers::UseOnPokemon.add(:KELPSYBERRY, proc { |item, qty, pkmn, scene|
next pbRaiseHappinessAndLowerEV(pkmn, scene, :ATTACK, qty, [ next pbRaiseHappinessAndLowerEV(
pkmn, scene, :ATTACK, qty, [
_INTL("{1} adores you! Its base Attack fell!", pkmn.name), _INTL("{1} adores you! Its base Attack fell!", pkmn.name),
_INTL("{1} became more friendly. Its base Attack can't go lower.", pkmn.name), _INTL("{1} became more friendly. Its base Attack can't go lower.", pkmn.name),
_INTL("{1} became more friendly. However, its base Attack fell!", pkmn.name) _INTL("{1} became more friendly. However, its base Attack fell!", pkmn.name)
]) ]
)
}) })
ItemHandlers::UseOnPokemonMaximum.add(:QUALOTBERRY, proc { |item, pkmn| ItemHandlers::UseOnPokemonMaximum.add(:QUALOTBERRY, proc { |item, pkmn|
@@ -967,11 +971,13 @@ ItemHandlers::UseOnPokemonMaximum.add(:QUALOTBERRY, proc { |item, pkmn|
}) })
ItemHandlers::UseOnPokemon.add(:QUALOTBERRY, proc { |item, qty, pkmn, scene| ItemHandlers::UseOnPokemon.add(:QUALOTBERRY, proc { |item, qty, pkmn, scene|
next pbRaiseHappinessAndLowerEV(pkmn, scene, :DEFENSE, qty, [ next pbRaiseHappinessAndLowerEV(
pkmn, scene, :DEFENSE, qty, [
_INTL("{1} adores you! Its base Defense fell!", pkmn.name), _INTL("{1} adores you! Its base Defense fell!", pkmn.name),
_INTL("{1} became more friendly. Its base Defense can't go lower.", pkmn.name), _INTL("{1} became more friendly. Its base Defense can't go lower.", pkmn.name),
_INTL("{1} became more friendly. However, its base Defense fell!", pkmn.name) _INTL("{1} became more friendly. However, its base Defense fell!", pkmn.name)
]) ]
)
}) })
ItemHandlers::UseOnPokemonMaximum.add(:HONDEWBERRY, proc { |item, pkmn| ItemHandlers::UseOnPokemonMaximum.add(:HONDEWBERRY, proc { |item, pkmn|
@@ -979,11 +985,13 @@ ItemHandlers::UseOnPokemonMaximum.add(:HONDEWBERRY, proc { |item, pkmn|
}) })
ItemHandlers::UseOnPokemon.add(:HONDEWBERRY, proc { |item, qty, pkmn, scene| ItemHandlers::UseOnPokemon.add(:HONDEWBERRY, proc { |item, qty, pkmn, scene|
next pbRaiseHappinessAndLowerEV(pkmn, scene, :SPECIAL_ATTACK, qty, [ next pbRaiseHappinessAndLowerEV(
pkmn, scene, :SPECIAL_ATTACK, qty, [
_INTL("{1} adores you! Its base Special Attack fell!", pkmn.name), _INTL("{1} adores you! Its base Special Attack fell!", pkmn.name),
_INTL("{1} became more friendly. Its base Special Attack can't go lower.", pkmn.name), _INTL("{1} became more friendly. Its base Special Attack can't go lower.", pkmn.name),
_INTL("{1} became more friendly. However, its base Special Attack fell!", pkmn.name) _INTL("{1} became more friendly. However, its base Special Attack fell!", pkmn.name)
]) ]
)
}) })
ItemHandlers::UseOnPokemonMaximum.add(:GREPABERRY, proc { |item, pkmn| ItemHandlers::UseOnPokemonMaximum.add(:GREPABERRY, proc { |item, pkmn|
@@ -991,11 +999,13 @@ ItemHandlers::UseOnPokemonMaximum.add(:GREPABERRY, proc { |item, pkmn|
}) })
ItemHandlers::UseOnPokemon.add(:GREPABERRY, proc { |item, qty, pkmn, scene| ItemHandlers::UseOnPokemon.add(:GREPABERRY, proc { |item, qty, pkmn, scene|
next pbRaiseHappinessAndLowerEV(pkmn, scene, :SPECIAL_DEFENSE, qty, [ next pbRaiseHappinessAndLowerEV(
pkmn, scene, :SPECIAL_DEFENSE, qty, [
_INTL("{1} adores you! Its base Special Defense fell!", pkmn.name), _INTL("{1} adores you! Its base Special Defense fell!", pkmn.name),
_INTL("{1} became more friendly. Its base Special Defense can't go lower.", pkmn.name), _INTL("{1} became more friendly. Its base Special Defense can't go lower.", pkmn.name),
_INTL("{1} became more friendly. However, its base Special Defense fell!", pkmn.name) _INTL("{1} became more friendly. However, its base Special Defense fell!", pkmn.name)
]) ]
)
}) })
ItemHandlers::UseOnPokemonMaximum.add(:TAMATOBERRY, proc { |item, pkmn| ItemHandlers::UseOnPokemonMaximum.add(:TAMATOBERRY, proc { |item, pkmn|
@@ -1003,11 +1013,13 @@ ItemHandlers::UseOnPokemonMaximum.add(:TAMATOBERRY, proc { |item, pkmn|
}) })
ItemHandlers::UseOnPokemon.add(:TAMATOBERRY, proc { |item, qty, pkmn, scene| ItemHandlers::UseOnPokemon.add(:TAMATOBERRY, proc { |item, qty, pkmn, scene|
next pbRaiseHappinessAndLowerEV(pkmn, scene, :SPEED, qty, [ next pbRaiseHappinessAndLowerEV(
pkmn, scene, :SPEED, qty, [
_INTL("{1} adores you! Its base Speed fell!", pkmn.name), _INTL("{1} adores you! Its base Speed fell!", pkmn.name),
_INTL("{1} became more friendly. Its base Speed can't go lower.", pkmn.name), _INTL("{1} became more friendly. Its base Speed can't go lower.", pkmn.name),
_INTL("{1} became more friendly. However, its base Speed fell!", pkmn.name) _INTL("{1} became more friendly. However, its base Speed fell!", pkmn.name)
]) ]
)
}) })
ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE, proc { |item, qty, pkmn, scene| ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE, proc { |item, qty, pkmn, scene|
@@ -49,8 +49,8 @@ ItemHandlers::CanUseInBattle.addIf(proc { |item| GameData::Item.get(item).is_pok
if battle.pbOpposingBattlerCount > 1 && !(GameData::Item.get(item).is_snag_ball? && battle.trainerBattle?) if battle.pbOpposingBattlerCount > 1 && !(GameData::Item.get(item).is_snag_ball? && battle.trainerBattle?)
if battle.pbOpposingBattlerCount == 2 if battle.pbOpposingBattlerCount == 2
scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there are two Pokémon!")) if showMessages scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there are two Pokémon!")) if showMessages
else elsif showMessages
scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there are more than one Pokémon!")) if showMessages scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there are more than one Pokémon!"))
end end
next false next false
end end
+1 -1
View File
@@ -150,7 +150,7 @@ Events.onMapUpdate += proc { |_sender, _e|
next if !num[0] || num.length != 8 # if not visible or not a trainer next if !num[0] || num.length != 8 # if not visible or not a trainer
# Reset time to next can-battle if necessary # Reset time to next can-battle if necessary
if num[4] == 0 if num[4] == 0
num[3] = 20 * 60 + rand(20 * 60) # 20-40 minutes num[3] = rand(20...40) * 60 # 20-40 minutes
num[4] = 1 num[4] = 1
end end
# Count down time to next can-battle # Count down time to next can-battle
+7 -7
View File
@@ -66,11 +66,11 @@ def pbPokeRadarHighlightGrass(showmessage = true)
if r <= (i + 1) * 2 if r <= (i + 1) * 2
x = $game_player.x - i - 1 + r x = $game_player.x - i - 1 + r
y = $game_player.y - i - 1 y = $game_player.y - i - 1
elsif r <= (i + 1) * 6 - 2 elsif r <= ((i + 1) * 6) - 2
x = [$game_player.x + i + 1, $game_player.x - i - 1][r % 2] x = [$game_player.x + i + 1, $game_player.x - i - 1][r % 2]
y = $game_player.y - i + ((r - 1 - (i + 1) * 2) / 2).floor y = $game_player.y - i + ((r - 1 - ((i + 1) * 2)) / 2).floor
else else
x = $game_player.x - i + r - (i + 1) * 6 x = $game_player.x - i + r - ((i + 1) * 6)
y = $game_player.y + i + 1 y = $game_player.y + i + 1
end end
# Add tile to grasses array if it's a valid grass tile # Add tile to grasses array if it's a valid grass tile
@@ -81,7 +81,7 @@ def pbPokeRadarHighlightGrass(showmessage = true)
# Choose a rarity for the grass (0=normal, 1=rare, 2=shiny) # Choose a rarity for the grass (0=normal, 1=rare, 2=shiny)
s = (rand(100) < 25) ? 1 : 0 s = (rand(100) < 25) ? 1 : 0
if $game_temp.poke_radar_data && $game_temp.poke_radar_data[2] > 0 if $game_temp.poke_radar_data && $game_temp.poke_radar_data[2] > 0
v = [(65536 / Settings::SHINY_POKEMON_CHANCE) - [$game_temp.poke_radar_data[2], 40].min * 200, 200].max v = [(65536 / Settings::SHINY_POKEMON_CHANCE) - ([$game_temp.poke_radar_data[2], 40].min * 200), 200].max
v = (65536 / v.to_f).ceil v = (65536 / v.to_f).ceil
s = 2 if rand(65536) < v s = 2 if rand(65536) < v
end end
@@ -164,7 +164,7 @@ EncounterModifier.register(proc { |encounter|
$game_temp.poke_radar_data[3].each { |g| rarity = g[3] if g[2] == ring } $game_temp.poke_radar_data[3].each { |g| rarity = g[3] if g[2] == ring }
if $game_temp.poke_radar_data[2] > 0 # Chain count, i.e. is chaining if $game_temp.poke_radar_data[2] > 0 # Chain count, i.e. is chaining
if rarity == 2 || if rarity == 2 ||
rand(100) < 58 + ring * 10 + ([$game_temp.poke_radar_data[2], 40].min / 4) + ($game_temp.poke_radar_data[4] ? 10 : 0) rand(100) < 58 + (ring * 10) + ([$game_temp.poke_radar_data[2], 40].min / 4) + ($game_temp.poke_radar_data[4] ? 10 : 0)
# Continue the chain # Continue the chain
encounter = [$game_temp.poke_radar_data[0], $game_temp.poke_radar_data[1]] encounter = [$game_temp.poke_radar_data[0], $game_temp.poke_radar_data[1]]
$game_temp.force_single_battle = true $game_temp.force_single_battle = true
@@ -186,8 +186,8 @@ EncounterModifier.register(proc { |encounter|
encounter = pbPokeRadarGetEncounter(rarity) encounter = pbPokeRadarGetEncounter(rarity)
$game_temp.force_single_battle = true $game_temp.force_single_battle = true
end end
else # Encounter triggered by stepping in non-rustling grass elsif encounter # Encounter triggered by stepping in non-rustling grass
pbPokeRadarCancel if encounter pbPokeRadarCancel
end end
next encounter next encounter
}) })
@@ -394,7 +394,7 @@ MultipleForms.copy(:SCATTERBUG, :SPEWPA, :VIVILLON)
MultipleForms.register(:FURFROU, { MultipleForms.register(:FURFROU, {
"getForm" => proc { |pkmn| "getForm" => proc { |pkmn|
if !pkmn.time_form_set || if !pkmn.time_form_set ||
pbGetTimeNow.to_i > pkmn.time_form_set.to_i + 60 * 60 * 24 * 5 # 5 days pbGetTimeNow.to_i > pkmn.time_form_set.to_i + (60 * 60 * 24 * 5) # 5 days
next 0 next 0
end end
}, },
@@ -447,7 +447,7 @@ MultipleForms.register(:ZYGARDE, {
MultipleForms.register(:HOOPA, { MultipleForms.register(:HOOPA, {
"getForm" => proc { |pkmn| "getForm" => proc { |pkmn|
if !pkmn.time_form_set || if !pkmn.time_form_set ||
pbGetTimeNow.to_i > pkmn.time_form_set.to_i + 60 * 60 * 24 * 3 # 3 days pbGetTimeNow.to_i > pkmn.time_form_set.to_i + (60 * 60 * 24 * 3) # 3 days
next 0 next 0
end end
}, },
@@ -596,7 +596,7 @@ MultipleForms.register(:MILCERY, {
sweets = [:STRAWBERRYSWEET, :BERRYSWEET, :LOVESWEET, :STARSWEET, sweets = [:STRAWBERRYSWEET, :BERRYSWEET, :LOVESWEET, :STARSWEET,
:CLOVERSWEET, :FLOWERSWEET, :RIBBONSWEET] :CLOVERSWEET, :FLOWERSWEET, :RIBBONSWEET]
if sweets.include?(pkmn.item_id) if sweets.include?(pkmn.item_id)
next sweets.index(pkmn.item_id) + (pkmn.personalID % num_flavors) * sweets.length next sweets.index(pkmn.item_id) + ((pkmn.personalID % num_flavors) * sweets.length)
end end
next 0 next 0
} }
+6 -5
View File
@@ -1071,12 +1071,12 @@ class Pokemon
# @return [Integer] the maximum HP of this Pokémon # @return [Integer] the maximum HP of this Pokémon
def calcHP(base, level, iv, ev) def calcHP(base, level, iv, ev)
return 1 if base == 1 # For Shedinja return 1 if base == 1 # For Shedinja
return ((base * 2 + iv + (ev / 4)) * level / 100).floor + level + 10 return (((base * 2) + iv + (ev / 4)) * level / 100).floor + level + 10
end end
# @return [Integer] the specified stat of this Pokémon (not used for total HP) # @return [Integer] the specified stat of this Pokémon (not used for total HP)
def calcStat(base, level, iv, ev, nat) def calcStat(base, level, iv, ev, nat)
return ((((base * 2 + iv + (ev / 4)) * level / 100).floor + 5) * nat / 100).floor return (((((base * 2) + iv + (ev / 4)) * level / 100).floor + 5) * nat / 100).floor
end end
# Recalculates this Pokémon's stats. # Recalculates this Pokémon's stats.
@@ -1179,9 +1179,10 @@ class Pokemon
@iv[s.id] = rand(IV_STAT_LIMIT + 1) @iv[s.id] = rand(IV_STAT_LIMIT + 1)
@ev[s.id] = 0 @ev[s.id] = 0
end end
if owner.is_a?(Owner) case owner
when Owner
@owner = owner @owner = owner
elsif owner.is_a?(Player) || owner.is_a?(NPCTrainer) when Player, NPCTrainer
@owner = Owner.new_from_trainer(owner) @owner = Owner.new_from_trainer(owner)
else else
@owner = Owner.new(0, '', 2, 2) @owner = Owner.new(0, '', 2, 2)
@@ -1195,7 +1196,7 @@ class Pokemon
@timeReceived = pbGetTimeNow.to_i @timeReceived = pbGetTimeNow.to_i
@timeEggHatched = nil @timeEggHatched = nil
@fused = nil @fused = nil
@personalID = rand(2**16) | rand(2**16) << 16 @personalID = rand(2**16) | (rand(2**16) << 16)
@hp = 1 @hp = 1
@totalhp = 1 @totalhp = 1
calc_stats calc_stats
+1 -1
View File
@@ -43,7 +43,7 @@ class Pokemon
# @return [Integer] total PP # @return [Integer] total PP
def total_pp def total_pp
max_pp = GameData::Move.get(@id).total_pp max_pp = GameData::Move.get(@id).total_pp
return max_pp + max_pp * @ppup / 5 return max_pp + (max_pp * @ppup / 5)
end end
alias totalpp total_pp alias totalpp total_pp
@@ -34,7 +34,7 @@ class Trainer
# Random ID other than this Trainer's ID # Random ID other than this Trainer's ID
def make_foreign_ID def make_foreign_ID
loop do loop do
ret = rand(2**16) | rand(2**16) << 16 ret = rand(2**16) | (rand(2**16) << 16)
return ret if ret != @id return ret if ret != @id
end end
return 0 return 0
@@ -168,7 +168,7 @@ class Trainer
def initialize(name, trainer_type) def initialize(name, trainer_type)
@trainer_type = GameData::TrainerType.get(trainer_type).id @trainer_type = GameData::TrainerType.get(trainer_type).id
@name = name @name = name
@id = rand(2**16) | rand(2**16) << 16 @id = rand(2**16) | (rand(2**16) << 16)
@language = pbGetLanguage @language = pbGetLanguage
@party = [] @party = []
end end
@@ -14,8 +14,8 @@ def pbNewTrainer(tr_type, tr_name, tr_version, save_changes = true)
for i in 0...Settings::MAX_PARTY_SIZE for i in 0...Settings::MAX_PARTY_SIZE
if i == 0 if i == 0
pbMessage(_INTL("Please enter the first Pokémon.", i)) pbMessage(_INTL("Please enter the first Pokémon.", i))
else elsif !pbConfirmMessage(_INTL("Add another Pokémon?"))
break if !pbConfirmMessage(_INTL("Add another Pokémon?")) break
end end
loop do loop do
species = pbChooseSpeciesList species = pbChooseSpeciesList
@@ -42,10 +42,12 @@ def pbNewTrainer(tr_type, tr_name, tr_version, save_changes = true)
:pokemon => [] :pokemon => []
} }
party.each do |pkmn| party.each do |pkmn|
trainer_hash[:pokemon].push({ trainer_hash[:pokemon].push(
{
:species => pkmn[0], :species => pkmn[0],
:level => pkmn[1] :level => pkmn[1]
}) }
)
end end
# Add trainer's data to records # Add trainer's data to records
trainer_hash[:id] = [trainer_hash[:trainer_type], trainer_hash[:name], trainer_hash[:version]] trainer_hash[:id] = [trainer_hash[:trainer_type], trainer_hash[:name], trainer_hash[:version]]
@@ -89,8 +89,8 @@ class PokemonEggHatch_Scene
@pokemon.species_data.apply_metrics_to_sprite(@sprites["pokemon"], 1) @pokemon.species_data.apply_metrics_to_sprite(@sprites["pokemon"], 1)
@sprites["hatch"].visible = false @sprites["hatch"].visible = false
for i in 1..fadeTime for i in 1..fadeTime
@sprites["pokemon"].tone = Tone.new(255 - i * toneDiff, 255 - i * toneDiff, 255 - i * toneDiff) @sprites["pokemon"].tone = Tone.new(255 - (i * toneDiff), 255 - (i * toneDiff), 255 - (i * toneDiff))
@sprites["overlay"].opacity = 255 - i * toneDiff @sprites["overlay"].opacity = 255 - (i * toneDiff)
updateScene updateScene
end end
@sprites["pokemon"].tone = Tone.new(0, 0, 0) @sprites["pokemon"].tone = Tone.new(0, 0, 0)
@@ -124,12 +124,12 @@ class PokemonTrade_Scene
d = [1, 2, 4, 8][i] # Fraction of the starting height each bounce rises to d = [1, 2, 4, 8][i] # Fraction of the starting height each bounce rises to
delay -= t if i == 0 delay -= t if i == 0
if i > 0 if i > 0
pictureBall.setZoomXY(delay, 100 + 5 * (5 - i), 100 - 5 * (5 - i)) # Squish pictureBall.setZoomXY(delay, 100 + (5 * (5 - i)), 100 - (5 * (5 - i))) # Squish
pictureBall.moveZoom(delay, 2, 100) # Unsquish pictureBall.moveZoom(delay, 2, 100) # Unsquish
pictureBall.moveXY(delay, t, Graphics.width / 2, y - 100 / d) pictureBall.moveXY(delay, t, Graphics.width / 2, y - (100 / d))
end end
pictureBall.moveXY(delay + t, t, Graphics.width / 2, y) pictureBall.moveXY(delay + t, t, Graphics.width / 2, y)
pictureBall.setSE(delay + 2 * t, "Battle ball drop") pictureBall.setSE(delay + (2 * t), "Battle ball drop")
delay = pictureBall.totalDuration delay = pictureBall.totalDuration
end end
picturePoke.setXY(delay, Graphics.width / 2, y) picturePoke.setXY(delay, Graphics.width / 2, y)
@@ -139,10 +139,10 @@ class HallOfFame_Scene
def xpointformula(battlernumber) def xpointformula(battlernumber)
ret = 0 ret = 0
if !SINGLEROW if !SINGLEROW
ret = 32 + 160 * xpositionformula(battlernumber) ret = 32 + (160 * xpositionformula(battlernumber))
else else
ret = (60 * (battlernumber / 2) + 48) * (xpositionformula(battlernumber) - 1) ret = ((60 * (battlernumber / 2)) + 48) * (xpositionformula(battlernumber) - 1)
ret += Graphics.width / 2 - 56 ret += (Graphics.width / 2) - 56
end end
return ret return ret
end end
@@ -150,9 +150,9 @@ class HallOfFame_Scene
def ypointformula(battlernumber) def ypointformula(battlernumber)
ret = 0 ret = 0
if !SINGLEROW if !SINGLEROW
ret = 32 + 128 * ypositionformula(battlernumber) / 2 ret = 32 + (128 * ypositionformula(battlernumber) / 2)
else else
ret = 96 - 8 * (battlernumber / 2) ret = 96 - (8 * (battlernumber / 2))
end end
return ret return ret
end end
@@ -319,8 +319,8 @@ class HallOfFame_Scene
Graphics.width - 192, Graphics.height - 54, 2, BASECOLOR, SHADOWCOLOR] Graphics.width - 192, Graphics.height - 54, 2, BASECOLOR, SHADOWCOLOR]
] ]
if (hallNumber > -1) if (hallNumber > -1)
textPositions.push([_INTL("Hall of Fame No."), Graphics.width / 2 - 104, -6, 0, BASECOLOR, SHADOWCOLOR]) textPositions.push([_INTL("Hall of Fame No."), (Graphics.width / 2) - 104, -6, 0, BASECOLOR, SHADOWCOLOR])
textPositions.push([hallNumber.to_s, Graphics.width / 2 + 104, -6, 1, BASECOLOR, SHADOWCOLOR]) textPositions.push([hallNumber.to_s, (Graphics.width / 2) + 104, -6, 1, BASECOLOR, SHADOWCOLOR])
end end
pbDrawTextPositions(overlay, textPositions) pbDrawTextPositions(overlay, textPositions)
end end
@@ -118,14 +118,14 @@ _END_
pcred = PluginManager.credits(plugin) pcred = PluginManager.credits(plugin)
plugin_credits << "\"#{plugin}\" v.#{PluginManager.version(plugin)} by:\n" plugin_credits << "\"#{plugin}\" v.#{PluginManager.version(plugin)} by:\n"
if pcred.size >= 5 if pcred.size >= 5
plugin_credits << pcred[0] + "\n" plugin_credits << (pcred[0] + "\n")
i = 1 i = 1
until i >= pcred.size until i >= pcred.size
plugin_credits << pcred[i] + "<s>" + (pcred[i + 1] || "") + "\n" plugin_credits << (pcred[i] + "<s>" + (pcred[i + 1] || "") + "\n")
i += 2 i += 2
end end
else else
pcred.each { |name| plugin_credits << name + "\n" } pcred.each { |name| plugin_credits << (name + "\n") }
end end
plugin_credits << "\n" plugin_credits << "\n"
end end
@@ -148,7 +148,7 @@ _END_
credit_bitmap = Bitmap.new(Graphics.width, @bitmap_height + 16) credit_bitmap = Bitmap.new(Graphics.width, @bitmap_height + 16)
pbSetSystemFont(credit_bitmap) pbSetSystemFont(credit_bitmap)
for j in 0...lines_per_bitmap for j in 0...lines_per_bitmap
line = credit_lines[i * lines_per_bitmap + j] line = credit_lines[(i * lines_per_bitmap) + j]
next if !line next if !line
line = line.split("<s>") line = line.split("<s>")
xpos = 0 xpos = 0
@@ -156,29 +156,29 @@ _END_
linewidth = Graphics.width linewidth = Graphics.width
for k in 0...line.length for k in 0...line.length
if line.length > 1 if line.length > 1
xpos = (k == 0) ? 0 : 20 + Graphics.width / 2 xpos = (k == 0) ? 0 : 20 + (Graphics.width / 2)
align = (k == 0) ? 2 : 0 # Right align : left align align = (k == 0) ? 2 : 0 # Right align : left align
linewidth = Graphics.width / 2 - 20 linewidth = (Graphics.width / 2) - 20
end end
credit_bitmap.font.color = TEXT_SHADOW_COLOR credit_bitmap.font.color = TEXT_SHADOW_COLOR
credit_bitmap.draw_text(xpos, j * 32 + 12, linewidth, 32, line[k], align) credit_bitmap.draw_text(xpos, (j * 32) + 12, linewidth, 32, line[k], align)
credit_bitmap.font.color = TEXT_OUTLINE_COLOR credit_bitmap.font.color = TEXT_OUTLINE_COLOR
credit_bitmap.draw_text(xpos + 2, j * 32 + 2, linewidth, 32, line[k], align) credit_bitmap.draw_text(xpos + 2, (j * 32) + 2, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos, j * 32 + 2, linewidth, 32, line[k], align) credit_bitmap.draw_text(xpos, (j * 32) + 2, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos - 2, j * 32 + 2, linewidth, 32, line[k], align) credit_bitmap.draw_text(xpos - 2, (j * 32) + 2, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos + 2, j * 32 + 4, linewidth, 32, line[k], align) credit_bitmap.draw_text(xpos + 2, (j * 32) + 4, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos - 2, j * 32 + 4, linewidth, 32, line[k], align) credit_bitmap.draw_text(xpos - 2, (j * 32) + 4, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos + 2, j * 32 + 6, linewidth, 32, line[k], align) credit_bitmap.draw_text(xpos + 2, (j * 32) + 6, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos, j * 32 + 6, linewidth, 32, line[k], align) credit_bitmap.draw_text(xpos, (j * 32) + 6, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos - 2, j * 32 + 6, linewidth, 32, line[k], align) credit_bitmap.draw_text(xpos - 2, (j * 32) + 6, linewidth, 32, line[k], align)
credit_bitmap.font.color = TEXT_BASE_COLOR credit_bitmap.font.color = TEXT_BASE_COLOR
credit_bitmap.draw_text(xpos, j * 32 + 4, linewidth, 32, line[k], align) credit_bitmap.draw_text(xpos, (j * 32) + 4, linewidth, 32, line[k], align)
end end
end end
credit_sprite = Sprite.new(text_viewport) credit_sprite = Sprite.new(text_viewport)
credit_sprite.bitmap = credit_bitmap credit_sprite.bitmap = credit_bitmap
credit_sprite.z = 9998 credit_sprite.z = 9998
credit_sprite.oy = @realOY - @bitmap_height * i credit_sprite.oy = @realOY - (@bitmap_height * i)
@credit_sprites[i] = credit_sprite @credit_sprites[i] = credit_sprite
end end
#------------------------------- #-------------------------------
@@ -245,6 +245,6 @@ _END_
return if cancel? return if cancel?
return if last? return if last?
@realOY += SCROLL_SPEED * delta @realOY += SCROLL_SPEED * delta
@credit_sprites.each_with_index { |s, i| s.oy = @realOY - @bitmap_height * i } @credit_sprites.each_with_index { |s, i| s.oy = @realOY - (@bitmap_height * i) }
end end
end end
+4 -8
View File
@@ -143,8 +143,8 @@ class PokemonPauseMenu
@scene.pbShowInfo(_INTL("Caught: None\nBalls: {1}", pbBugContestState.ballcount)) @scene.pbShowInfo(_INTL("Caught: None\nBalls: {1}", pbBugContestState.ballcount))
end end
commands[cmdQuit = commands.length] = _INTL("Quit Contest") commands[cmdQuit = commands.length] = _INTL("Quit Contest")
else elsif $game_system && !$game_system.save_disabled
commands[cmdSave = commands.length] = _INTL("Save") if $game_system && !$game_system.save_disabled commands[cmdSave = commands.length] = _INTL("Save")
end end
commands[cmdOption = commands.length] = _INTL("Options") commands[cmdOption = commands.length] = _INTL("Options")
commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
@@ -160,8 +160,7 @@ class PokemonPauseMenu
screen.pbStartScreen screen.pbStartScreen
@scene.pbRefresh @scene.pbRefresh
} }
else elsif $player.pokedex.accessible_dexes.length == 1
if $player.pokedex.accessible_dexes.length == 1
$PokemonGlobal.pokedexDex = $player.pokedex.accessible_dexes[0] $PokemonGlobal.pokedexDex = $player.pokedex.accessible_dexes[0]
pbFadeOutIn { pbFadeOutIn {
scene = PokemonPokedex_Scene.new scene = PokemonPokedex_Scene.new
@@ -177,7 +176,6 @@ class PokemonPauseMenu
@scene.pbRefresh @scene.pbRefresh
} }
end end
end
elsif cmdPokemon >= 0 && command == cmdPokemon elsif cmdPokemon >= 0 && command == cmdPokemon
pbPlayDecisionSE pbPlayDecisionSE
hiddenmove = nil hiddenmove = nil
@@ -243,15 +241,13 @@ class PokemonPauseMenu
else else
pbShowMenu pbShowMenu
end end
else elsif pbConfirmMessage(_INTL("Would you like to end the Contest now?"))
if pbConfirmMessage(_INTL("Would you like to end the Contest now?"))
@scene.pbEndScene @scene.pbEndScene
pbBugContestState.pbStartJudging pbBugContestState.pbStartJudging
return return
else else
pbShowMenu pbShowMenu
end end
end
elsif cmdSave >= 0 && command == cmdSave elsif cmdSave >= 0 && command == cmdSave
@scene.pbHideMenu @scene.pbHideMenu
scene = PokemonSave_Scene.new scene = PokemonSave_Scene.new
+5 -4
View File
@@ -23,10 +23,11 @@ class Window_DexesList < Window_CommandPokemon
sprintf("%d", @commands2[index][1]), self.baseColor, self.shadowColor, 1) sprintf("%d", @commands2[index][1]), self.baseColor, self.shadowColor, 1)
allseen = (@commands2[index][0] >= @commands2[index][2]) allseen = (@commands2[index][0] >= @commands2[index][2])
allown = (@commands2[index][1] >= @commands2[index][2]) allown = (@commands2[index][1] >= @commands2[index][2])
pbDrawImagePositions(self.contents, [ pbDrawImagePositions(
["Graphics/Pictures/Pokedex/icon_menuseenown", rect.x + 236, rect.y + 2, (allseen) ? 24 : 0, 0, 24, 24], self.contents,
["Graphics/Pictures/Pokedex/icon_menuseenown", rect.x + 332, rect.y + 2, (allown) ? 24 : 0, 24, 24, 24] [["Graphics/Pictures/Pokedex/icon_menuseenown", rect.x + 236, rect.y + 2, (allseen) ? 24 : 0, 0, 24, 24],
]) ["Graphics/Pictures/Pokedex/icon_menuseenown", rect.x + 332, rect.y + 2, (allown) ? 24 : 0, 24, 24, 24]]
)
end end
end end
end end
+32 -32
View File
@@ -169,7 +169,7 @@ class PokedexSearchSelectionSprite < SpriteWrapper
self.y = 52 self.y = 52
when 1, 2, 3, 4 # Name, type, height, weight when 1, 2, 3, 4 # Name, type, height, weight
self.x = 114 self.x = 114
self.y = 110 + (@index - 1) * 52 self.y = 110 + ((@index - 1) * 52)
when 5 # Color when 5 # Color
self.x = 382 self.x = 382
self.y = 110 self.y = 110
@@ -177,7 +177,7 @@ class PokedexSearchSelectionSprite < SpriteWrapper
self.x = 420 self.x = 420
self.y = 214 self.y = 214
when 7, 8, 9 # Reset, start, cancel when 7, 8, 9 # Reset, start, cancel
self.x = 4 + (@index - 7) * 176 self.x = 4 + ((@index - 7) * 176)
self.y = 334 self.y = 334
end end
else # Parameter screen else # Parameter screen
@@ -207,11 +207,11 @@ class PokedexSearchSelectionSprite < SpriteWrapper
case @index case @index
when -1 # Blank option when -1 # Blank option
if @mode == 3 || @mode == 4 # Height/weight range if @mode == 3 || @mode == 4 # Height/weight range
self.x = @xstart + (@cmds + 1) * @xgap * (@minmax % 2) self.x = @xstart + ((@cmds + 1) * @xgap * (@minmax % 2))
self.y = @ystart + @ygap * ((@minmax + 1) % 2) self.y = @ystart + (@ygap * ((@minmax + 1) % 2))
else else
self.x = @xstart + (@cols - 1) * @xgap self.x = @xstart + ((@cols - 1) * @xgap)
self.y = @ystart + (@cmds / @cols).floor * @ygap self.y = @ystart + ((@cmds / @cols).floor * @ygap)
end end
when -2 # OK when -2 # OK
self.x = 4 self.x = 4
@@ -223,19 +223,19 @@ class PokedexSearchSelectionSprite < SpriteWrapper
case @mode case @mode
when 0, 1, 2, 5, 6 # Order, name, type, color, shape when 0, 1, 2, 5, 6 # Order, name, type, color, shape
if @index >= @cmds if @index >= @cmds
self.x = @xstart + (@cols - 1) * @xgap self.x = @xstart + ((@cols - 1) * @xgap)
self.y = @ystart + (@cmds / @cols).floor * @ygap self.y = @ystart + ((@cmds / @cols).floor * @ygap)
else else
self.x = @xstart + (@index % @cols) * @xgap self.x = @xstart + ((@index % @cols) * @xgap)
self.y = @ystart + (@index / @cols).floor * @ygap self.y = @ystart + ((@index / @cols).floor * @ygap)
end end
when 3, 4 # Height, weight when 3, 4 # Height, weight
if @index >= @cmds if @index >= @cmds
self.x = @xstart + (@cmds + 1) * @xgap * ((@minmax + 1) % 2) self.x = @xstart + ((@cmds + 1) * @xgap * ((@minmax + 1) % 2))
else else
self.x = @xstart + (@index + 1) * @xgap self.x = @xstart + ((@index + 1) * @xgap)
end end
self.y = @ystart + @ygap * ((@minmax + 1) % 2) self.y = @ystart + (@ygap * ((@minmax + 1) % 2))
end end
end end
end end
@@ -462,8 +462,8 @@ class PokemonPokedex_Scene
overlay.blt(468, y, @sliderbitmap.bitmap, Rect.new(40, 0, 40, 8)) overlay.blt(468, y, @sliderbitmap.bitmap, Rect.new(40, 0, 40, 8))
i = 0 i = 0
while i * 16 < boxheight - 8 - 16 while i * 16 < boxheight - 8 - 16
height = [boxheight - 8 - 16 - i * 16, 16].min height = [boxheight - 8 - 16 - (i * 16), 16].min
overlay.blt(468, y + 8 + i * 16, @sliderbitmap.bitmap, Rect.new(40, 8, 40, height)) overlay.blt(468, y + 8 + (i * 16), @sliderbitmap.bitmap, Rect.new(40, 8, 40, height))
i += 1 i += 1
end end
overlay.blt(468, y + boxheight - 16, @sliderbitmap.bitmap, Rect.new(40, 24, 40, 16)) overlay.blt(468, y + boxheight - 16, @sliderbitmap.bitmap, Rect.new(40, 24, 40, 16))
@@ -615,11 +615,11 @@ class PokemonPokedex_Scene
when 2 # Type icons when 2 # Type icons
for i in 0...2 for i in 0...2
if !sel[i] || sel[i] < 0 if !sel[i] || sel[i] < 0
textpos.push(["----", 298 + 128 * i, 58, 2, base, shadow, 1]) textpos.push(["----", 298 + (128 * i), 58, 2, base, shadow, 1])
else else
type_number = @typeCommands[sel[i]].icon_position type_number = @typeCommands[sel[i]].icon_position
typerect = Rect.new(0, type_number * 32, 96, 32) typerect = Rect.new(0, type_number * 32, 96, 32)
overlay.blt(250 + 128 * i, 58, @typebitmap.bitmap, typerect) overlay.blt(250 + (128 * i), 58, @typebitmap.bitmap, typerect)
end end
end end
when 3 # Height range when 3 # Height range
@@ -677,10 +677,10 @@ class PokemonPokedex_Scene
end end
# Draw selected option(s) button graphic # Draw selected option(s) button graphic
if [3, 4].include?(mode) # Height, weight if [3, 4].include?(mode) # Height, weight
xpos1 = xstart + (sel[0] + 1) * xgap xpos1 = xstart + ((sel[0] + 1) * xgap)
xpos1 = xstart if sel[0] < -1 xpos1 = xstart if sel[0] < -1
xpos2 = xstart + (sel[1] + 1) * xgap xpos2 = xstart + ((sel[1] + 1) * xgap)
xpos2 = xstart + cols * xgap if sel[1] < 0 xpos2 = xstart + (cols * xgap) if sel[1] < 0
xpos2 = xstart if sel[1] >= cols - 1 xpos2 = xstart if sel[1] >= cols - 1
ypos1 = ystart + 172 ypos1 = ystart + 172
ypos2 = ystart + 28 ypos2 = ystart + 28
@@ -698,9 +698,9 @@ class PokemonPokedex_Scene
for i in 0...sel.length for i in 0...sel.length
selrect = Rect.new(0, selbuttony, @selbitmap.bitmap.width, selbuttonheight) selrect = Rect.new(0, selbuttony, @selbitmap.bitmap.width, selbuttonheight)
if sel[i] >= 0 if sel[i] >= 0
overlay.blt(xstart + (sel[i] % cols) * xgap, ystart + (sel[i] / cols).floor * ygap, @selbitmap.bitmap, selrect) overlay.blt(xstart + ((sel[i] % cols) * xgap), ystart + ((sel[i] / cols).floor * ygap), @selbitmap.bitmap, selrect)
else else
overlay.blt(xstart + (cols - 1) * xgap, ystart + (cmds.length / cols).floor * ygap, @selbitmap.bitmap, selrect) overlay.blt(xstart + ((cols - 1) * xgap), ystart + ((cmds.length / cols).floor * ygap), @selbitmap.bitmap, selrect)
end end
end end
end end
@@ -708,35 +708,35 @@ class PokemonPokedex_Scene
case mode case mode
when 0, 1 # Order, name when 0, 1 # Order, name
for i in 0...cmds.length for i in 0...cmds.length
x = xstart + halfwidth + (i % cols) * xgap x = xstart + halfwidth + ((i % cols) * xgap)
y = ystart + 6 + (i / cols).floor * ygap y = ystart + 6 + ((i / cols).floor * ygap)
textpos.push([cmds[i], x, y, 2, base, shadow, 1]) textpos.push([cmds[i], x, y, 2, base, shadow, 1])
end end
if mode != 0 if mode != 0
textpos.push([(mode == 1) ? "-" : "----", textpos.push([(mode == 1) ? "-" : "----",
xstart + halfwidth + (cols - 1) * xgap, ystart + 6 + (cmds.length / cols).floor * ygap, 2, base, shadow, 1]) xstart + halfwidth + ((cols - 1) * xgap), ystart + 6 + ((cmds.length / cols).floor * ygap), 2, base, shadow, 1])
end end
when 2 # Type when 2 # Type
typerect = Rect.new(0, 0, 96, 32) typerect = Rect.new(0, 0, 96, 32)
for i in 0...cmds.length for i in 0...cmds.length
typerect.y = @typeCommands[i].icon_position * 32 typerect.y = @typeCommands[i].icon_position * 32
overlay.blt(xstart + 14 + (i % cols) * xgap, ystart + 6 + (i / cols).floor * ygap, @typebitmap.bitmap, typerect) overlay.blt(xstart + 14 + ((i % cols) * xgap), ystart + 6 + ((i / cols).floor * ygap), @typebitmap.bitmap, typerect)
end end
textpos.push(["----", textpos.push(["----",
xstart + halfwidth + (cols - 1) * xgap, ystart + 6 + (cmds.length / cols).floor * ygap, 2, base, shadow, 1]) xstart + halfwidth + ((cols - 1) * xgap), ystart + 6 + ((cmds.length / cols).floor * ygap), 2, base, shadow, 1])
when 5 # Color when 5 # Color
for i in 0...cmds.length for i in 0...cmds.length
x = xstart + halfwidth + (i % cols) * xgap x = xstart + halfwidth + ((i % cols) * xgap)
y = ystart + 6 + (i / cols).floor * ygap y = ystart + 6 + ((i / cols).floor * ygap)
textpos.push([cmds[i].name, x, y, 2, base, shadow, 1]) textpos.push([cmds[i].name, x, y, 2, base, shadow, 1])
end end
textpos.push(["----", textpos.push(["----",
xstart + halfwidth + (cols - 1) * xgap, ystart + 6 + (cmds.length / cols).floor * ygap, 2, base, shadow, 1]) xstart + halfwidth + ((cols - 1) * xgap), ystart + 6 + ((cmds.length / cols).floor * ygap), 2, base, shadow, 1])
when 6 # Shape when 6 # Shape
shaperect = Rect.new(0, 0, 60, 60) shaperect = Rect.new(0, 0, 60, 60)
for i in 0...cmds.length for i in 0...cmds.length
shaperect.y = @shapeCommands[i].icon_position * 60 shaperect.y = @shapeCommands[i].icon_position * 60
overlay.blt(xstart + 4 + (i % cols) * xgap, ystart + 4 + (i / cols).floor * ygap, @shapebitmap.bitmap, shaperect) overlay.blt(xstart + 4 + ((i % cols) * xgap), ystart + 4 + ((i / cols).floor * ygap), @shapebitmap.bitmap, shaperect)
end end
end end
# Draw all text # Draw all text
@@ -986,7 +986,7 @@ class PokemonPokedex_Scene
else else
if Input.trigger?(Input::UP) if Input.trigger?(Input::UP)
if index == -1 # From blank if index == -1 # From blank
index = cmds.length - 1 - (cmds.length - 1) % cols - 1 index = cmds.length - 1 - ((cmds.length - 1) % cols) - 1
elsif index == -2 # From OK elsif index == -2 # From OK
index = ((cmds.length - 1) / cols).floor * cols index = ((cmds.length - 1) / cols).floor * cols
elsif index == -3 && mode == 0 # From Cancel elsif index == -3 && mode == 0 # From Cancel
+15 -13
View File
@@ -28,11 +28,12 @@ class PokemonPokedexInfo_Scene
@sprites["areamap"].y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2 @sprites["areamap"].y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2
for hidden in Settings::REGION_MAP_EXTRAS for hidden in Settings::REGION_MAP_EXTRAS
if hidden[0] == @region && hidden[1] > 0 && $game_switches[hidden[1]] if hidden[0] == @region && hidden[1] > 0 && $game_switches[hidden[1]]
pbDrawImagePositions(@sprites["areamap"].bitmap, [ pbDrawImagePositions(
["Graphics/Pictures/#{hidden[4]}", @sprites["areamap"].bitmap,
[["Graphics/Pictures/#{hidden[4]}",
hidden[2] * PokemonRegionMap_Scene::SQUARE_WIDTH, hidden[2] * PokemonRegionMap_Scene::SQUARE_WIDTH,
hidden[3] * PokemonRegionMap_Scene::SQUARE_HEIGHT] hidden[3] * PokemonRegionMap_Scene::SQUARE_HEIGHT]]
]) )
end end
end end
@sprites["areahighlight"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) @sprites["areahighlight"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
@@ -261,7 +262,7 @@ class PokemonPokedexInfo_Scene
species_data.types.each_with_index do |type, i| species_data.types.each_with_index do |type, i|
type_number = GameData::Type.get(type).icon_position type_number = GameData::Type.get(type).icon_position
type_rect = Rect.new(0, type_number * 32, 96, 32) type_rect = Rect.new(0, type_number * 32, 96, 32)
overlay.blt(296 + 100 * i, 120, @typebitmap.bitmap, type_rect) overlay.blt(296 + (100 * i), 120, @typebitmap.bitmap, type_rect)
end end
else else
# Write the category # Write the category
@@ -316,16 +317,16 @@ class PokemonPokedexInfo_Scene
mapsize = map_metadata.town_map_size mapsize = map_metadata.town_map_size
if mapsize && mapsize[0] && mapsize[0] > 0 if mapsize && mapsize[0] && mapsize[0] > 0
sqwidth = mapsize[0] sqwidth = mapsize[0]
sqheight = (mapsize[1].length * 1.0 / mapsize[0]).ceil sqheight = (mapsize[1].length.to_f / mapsize[0]).ceil
for i in 0...sqwidth for i in 0...sqwidth
for j in 0...sqheight for j in 0...sqheight
if mapsize[1][i + j * sqwidth, 1].to_i > 0 if mapsize[1][i + (j * sqwidth), 1].to_i > 0
points[mappos[1] + i + (mappos[2] + j) * mapwidth] = true points[mappos[1] + i + ((mappos[2] + j) * mapwidth)] = true
end end
end end
end end
else else
points[mappos[1] + mappos[2] * mapwidth] = true points[mappos[1] + (mappos[2] * mapwidth)] = true
end end
end end
# Draw coloured squares on each square of the region map with a nest # Draw coloured squares on each square of the region map with a nest
@@ -357,10 +358,11 @@ class PokemonPokedexInfo_Scene
# Set the text # Set the text
textpos = [] textpos = []
if points.length == 0 if points.length == 0
pbDrawImagePositions(overlay, [ pbDrawImagePositions(
[sprintf("Graphics/Pictures/Pokedex/overlay_areanone"), 108, 188] overlay,
]) [[sprintf("Graphics/Pictures/Pokedex/overlay_areanone"), 108, 188]]
textpos.push([_INTL("Area unknown"), Graphics.width / 2, Graphics.height / 2 - 6, 2, base, shadow]) )
textpos.push([_INTL("Area unknown"), Graphics.width / 2, (Graphics.height / 2) - 6, 2, base, shadow])
end end
textpos.push([pbGetMessage(MessageTypes::RegionNames, @region), 414, 38, 2, base, shadow]) textpos.push([pbGetMessage(MessageTypes::RegionNames, @region), 414, 38, 2, base, shadow])
textpos.push([_INTL("{1}'s area", GameData::Species.get(@species).name), textpos.push([_INTL("{1}'s area", GameData::Species.get(@species).name),
+8 -12
View File
@@ -140,7 +140,7 @@ class PokemonPartyBlankPanel < SpriteWrapper
def initialize(_pokemon, index, viewport = nil) def initialize(_pokemon, index, viewport = nil)
super(viewport) super(viewport)
self.x = (index % 2) * Graphics.width / 2 self.x = (index % 2) * Graphics.width / 2
self.y = 16 * (index % 2) + 96 * (index / 2) self.y = (16 * (index % 2)) + (96 * (index / 2))
@panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/panel_blank") @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/panel_blank")
self.bitmap = @panelbgsprite.bitmap self.bitmap = @panelbgsprite.bitmap
@text = nil @text = nil
@@ -177,7 +177,7 @@ class PokemonPartyPanel < SpriteWrapper
@active = (index == 0) # true = rounded panel, false = rectangular panel @active = (index == 0) # true = rounded panel, false = rectangular panel
@refreshing = true @refreshing = true
self.x = (index % 2) * Graphics.width / 2 self.x = (index % 2) * Graphics.width / 2
self.y = 16 * (index % 2) + 96 * (index / 2) self.y = (16 * (index % 2)) + (96 * (index / 2))
@panelbgsprite = ChangelingSprite.new(0, 0, viewport) @panelbgsprite = ChangelingSprite.new(0, 0, viewport)
@panelbgsprite.z = self.z @panelbgsprite.z = self.z
if @active # Rounded panel if @active # Rounded panel
@@ -374,7 +374,7 @@ class PokemonPartyPanel < SpriteWrapper
textpos.push([sprintf("% 3d /% 3d", @pokemon.hp, @pokemon.totalhp), 224, 54, 1, basecolor, shadowcolor]) textpos.push([sprintf("% 3d /% 3d", @pokemon.hp, @pokemon.totalhp), 224, 54, 1, basecolor, shadowcolor])
# Draw HP bar # Draw HP bar
if @pokemon.hp > 0 if @pokemon.hp > 0
w = @pokemon.hp * 96 * 1.0 / @pokemon.totalhp w = @pokemon.hp * 96 / @pokemon.totalhp.to_f
w = 1 if w < 1 w = 1 if w < 1
w = ((w / 2).round) * 2 w = ((w / 2).round) * 2
hpzone = 0 hpzone = 0
@@ -415,16 +415,14 @@ class PokemonPartyPanel < SpriteWrapper
pbDrawImagePositions(@overlaysprite.bitmap, pbDrawImagePositions(@overlaysprite.bitmap,
[["Graphics/Pictures/Party/overlay_lv", 20, 70, 0, 0, 22, 14]]) [["Graphics/Pictures/Party/overlay_lv", 20, 70, 0, 0, 22, 14]])
pbSetSmallFont(@overlaysprite.bitmap) pbSetSmallFont(@overlaysprite.bitmap)
pbDrawTextPositions(@overlaysprite.bitmap, [ pbDrawTextPositions(@overlaysprite.bitmap,
[@pokemon.level.to_s, 42, 57, 0, basecolor, shadowcolor] [[@pokemon.level.to_s, 42, 57, 0, basecolor, shadowcolor]])
])
end end
# Draw annotation text # Draw annotation text
if @text && @text.length > 0 if @text && @text.length > 0
pbSetSystemFont(@overlaysprite.bitmap) pbSetSystemFont(@overlaysprite.bitmap)
pbDrawTextPositions(@overlaysprite.bitmap, [ pbDrawTextPositions(@overlaysprite.bitmap,
[@text, 96, 52, 0, basecolor, shadowcolor] [[@text, 96, 52, 0, basecolor, shadowcolor]])
])
end end
end end
@refreshing = false @refreshing = false
@@ -514,12 +512,10 @@ class PokemonParty_Scene
pbPlayDecisionSE if @sprites["messagebox"].pausing? pbPlayDecisionSE if @sprites["messagebox"].pausing?
@sprites["messagebox"].resume @sprites["messagebox"].resume
end end
else elsif Input.trigger?(Input::BACK) || Input.trigger?(Input::USE)
if Input.trigger?(Input::BACK) || Input.trigger?(Input::USE)
break break
end end
end end
end
@sprites["messagebox"].visible = false @sprites["messagebox"].visible = false
@sprites["helpwindow"].visible = true @sprites["helpwindow"].visible = true
end end
+16 -19
View File
@@ -78,7 +78,7 @@ class RibbonSelectionSprite < MoveSelectionSprite
def refresh def refresh
w = @movesel.width w = @movesel.width
h = @movesel.height / 2 h = @movesel.height / 2
self.x = 228 + (self.index % 4) * 68 self.x = 228 + ((self.index % 4) * 68)
self.y = 76 + ((self.index / 4).floor * 68) self.y = 76 + ((self.index / 4).floor * 68)
self.bitmap = @movesel.bitmap self.bitmap = @movesel.bitmap
if self.preselected if self.preselected
@@ -291,7 +291,7 @@ class PokemonSummary_Scene
(@markingbitmap.bitmap.width / MARK_WIDTH).times do |i| (@markingbitmap.bitmap.width / MARK_WIDTH).times do |i|
markrect.x = i * MARK_WIDTH markrect.x = i * MARK_WIDTH
markrect.y = [(markings[i] || 0), mark_variants - 1].min * MARK_HEIGHT markrect.y = [(markings[i] || 0), mark_variants - 1].min * MARK_HEIGHT
bitmap.blt(x + i * MARK_WIDTH, y, @markingbitmap.bitmap, markrect) bitmap.blt(x + (i * MARK_WIDTH), y, @markingbitmap.bitmap, markrect)
end end
end end
@@ -459,16 +459,15 @@ class PokemonSummary_Scene
@pokemon.types.each_with_index do |type, i| @pokemon.types.each_with_index do |type, i|
type_number = GameData::Type.get(type).icon_position type_number = GameData::Type.get(type).icon_position
type_rect = Rect.new(0, type_number * 28, 64, 28) type_rect = Rect.new(0, type_number * 28, 64, 28)
type_x = (@pokemon.types.length == 1) ? 402 : 370 + 66 * i type_x = (@pokemon.types.length == 1) ? 402 : 370 + (66 * i)
overlay.blt(type_x, 146, @typebitmap.bitmap, type_rect) overlay.blt(type_x, 146, @typebitmap.bitmap, type_rect)
end end
# Draw Exp bar # Draw Exp bar
if @pokemon.level < GameData::GrowthRate.max_level if @pokemon.level < GameData::GrowthRate.max_level
w = @pokemon.exp_fraction * 128 w = @pokemon.exp_fraction * 128
w = ((w / 2).round) * 2 w = ((w / 2).round) * 2
pbDrawImagePositions(overlay, [ pbDrawImagePositions(overlay,
["Graphics/Pictures/Summary/overlay_exp", 362, 372, 0, 0, w, 6] [["Graphics/Pictures/Summary/overlay_exp", 362, 372, 0, 0, w, 6]])
])
end end
end end
@@ -663,7 +662,7 @@ class PokemonSummary_Scene
pbDrawTextPositions(overlay, textpos) pbDrawTextPositions(overlay, textpos)
# Draw HP bar # Draw HP bar
if @pokemon.hp > 0 if @pokemon.hp > 0
w = @pokemon.hp * 96 * 1.0 / @pokemon.totalhp w = @pokemon.hp * 96 / @pokemon.totalhp.to_f
w = 1 if w < 1 w = 1 if w < 1
w = ((w / 2).round) * 2 w = ((w / 2).round) * 2
hpzone = 0 hpzone = 0
@@ -792,7 +791,7 @@ class PokemonSummary_Scene
@pokemon.types.each_with_index do |type, i| @pokemon.types.each_with_index do |type, i|
type_number = GameData::Type.get(type).icon_position type_number = GameData::Type.get(type).icon_position
type_rect = Rect.new(0, type_number * 28, 64, 28) type_rect = Rect.new(0, type_number * 28, 64, 28)
type_x = (@pokemon.types.length == 1) ? 130 : 96 + 70 * i type_x = (@pokemon.types.length == 1) ? 130 : 96 + (70 * i)
overlay.blt(type_x, 78, @typebitmap.bitmap, type_rect) overlay.blt(type_x, 78, @typebitmap.bitmap, type_rect)
end end
end end
@@ -843,12 +842,12 @@ class PokemonSummary_Scene
# Show all ribbons # Show all ribbons
imagepos = [] imagepos = []
coord = 0 coord = 0
for i in @ribbonOffset * 4...@ribbonOffset * 4 + 12 for i in @ribbonOffset * 4...(@ribbonOffset * 4) + 12
break if !@pokemon.ribbons[i] break if !@pokemon.ribbons[i]
ribbon_data = GameData::Ribbon.get(@pokemon.ribbons[i]) ribbon_data = GameData::Ribbon.get(@pokemon.ribbons[i])
ribn = ribbon_data.icon_position ribn = ribbon_data.icon_position
imagepos.push(["Graphics/Pictures/ribbons", imagepos.push(["Graphics/Pictures/ribbons",
230 + 68 * (coord % 4), 78 + 68 * (coord / 4).floor, 230 + (68 * (coord % 4)), 78 + (68 * (coord / 4).floor),
64 * (ribn % 8), 64 * (ribn / 8).floor, 64, 64]) 64 * (ribn % 8), 64 * (ribn / 8).floor, 64, 64])
coord += 1 coord += 1
end end
@@ -939,8 +938,7 @@ class PokemonSummary_Scene
break if !switching break if !switching
@sprites["movepresel"].visible = false @sprites["movepresel"].visible = false
switching = false switching = false
else elsif !@pokemon.shadowPokemon?
if !@pokemon.shadowPokemon?
if !switching if !switching
@sprites["movepresel"].index = selmove @sprites["movepresel"].index = selmove
@sprites["movepresel"].visible = true @sprites["movepresel"].visible = true
@@ -955,7 +953,6 @@ class PokemonSummary_Scene
drawSelectedMove(nil, @pokemon.moves[selmove]) drawSelectedMove(nil, @pokemon.moves[selmove])
end end
end end
end
elsif Input.trigger?(Input::UP) elsif Input.trigger?(Input::UP)
selmove -= 1 selmove -= 1
if selmove < Pokemon::MAX_MOVES && selmove >= @pokemon.numMoves if selmove < Pokemon::MAX_MOVES && selmove >= @pokemon.numMoves
@@ -1009,7 +1006,7 @@ class PokemonSummary_Scene
if !switching if !switching
if @pokemon.ribbons[selribbon] if @pokemon.ribbons[selribbon]
pbPlayDecisionSE pbPlayDecisionSE
@sprites["ribbonpresel"].index = selribbon - @ribbonOffset * 4 @sprites["ribbonpresel"].index = selribbon - (@ribbonOffset * 4)
oldselribbon = selribbon oldselribbon = selribbon
@sprites["ribbonpresel"].visible = true @sprites["ribbonpresel"].visible = true
switching = true switching = true
@@ -1056,8 +1053,8 @@ class PokemonSummary_Scene
@ribbonOffset = (selribbon / 4).floor - 2 if selribbon >= (@ribbonOffset + 3) * 4 @ribbonOffset = (selribbon / 4).floor - 2 if selribbon >= (@ribbonOffset + 3) * 4
@ribbonOffset = 0 if @ribbonOffset < 0 @ribbonOffset = 0 if @ribbonOffset < 0
@ribbonOffset = numRows - 3 if @ribbonOffset > numRows - 3 @ribbonOffset = numRows - 3 if @ribbonOffset > numRows - 3
@sprites["ribbonsel"].index = selribbon - @ribbonOffset * 4 @sprites["ribbonsel"].index = selribbon - (@ribbonOffset * 4)
@sprites["ribbonpresel"].index = oldselribbon - @ribbonOffset * 4 @sprites["ribbonpresel"].index = oldselribbon - (@ribbonOffset * 4)
drawSelectedRibbon(@pokemon.ribbons[selribbon]) drawSelectedRibbon(@pokemon.ribbons[selribbon])
end end
end end
@@ -1083,7 +1080,7 @@ class PokemonSummary_Scene
(@markingbitmap.bitmap.width / MARK_WIDTH).times do |i| (@markingbitmap.bitmap.width / MARK_WIDTH).times do |i|
markrect.x = i * MARK_WIDTH markrect.x = i * MARK_WIDTH
markrect.y = [(markings[i] || 0), mark_variants - 1].min * MARK_HEIGHT markrect.y = [(markings[i] || 0), mark_variants - 1].min * MARK_HEIGHT
@sprites["markingoverlay"].bitmap.blt(300 + 58 * (i % 3), 154 + 50 * (i / 3), @sprites["markingoverlay"].bitmap.blt(300 + (58 * (i % 3)), 154 + (50 * (i / 3)),
@markingbitmap.bitmap, markrect) @markingbitmap.bitmap, markrect)
end end
textpos = [ textpos = [
@@ -1095,8 +1092,8 @@ class PokemonSummary_Scene
redraw = false redraw = false
end end
# Reposition the cursor # Reposition the cursor
@sprites["markingsel"].x = 284 + 58 * (index % 3) @sprites["markingsel"].x = 284 + (58 * (index % 3))
@sprites["markingsel"].y = 144 + 50 * (index / 3) @sprites["markingsel"].y = 144 + (50 * (index / 3))
case index case index
when 6 # OK when 6 # OK
@sprites["markingsel"].x = 284 @sprites["markingsel"].x = 284
+24 -26
View File
@@ -47,9 +47,9 @@ class Window_PokemonBag < Window_DrawableCommand
item > self.top_item + self.page_item_max item > self.top_item + self.page_item_max
return Rect.new(0, 0, 0, 0) return Rect.new(0, 0, 0, 0)
else else
cursor_width = (self.width - self.borderX - (@column_max - 1) * @column_spacing) / @column_max cursor_width = (self.width - self.borderX - ((@column_max - 1) * @column_spacing)) / @column_max
x = item % @column_max * (cursor_width + @column_spacing) x = item % @column_max * (cursor_width + @column_spacing)
y = item / @column_max * @row_height - @virtualOy y = (item / @column_max * @row_height) - @virtualOy
return Rect.new(x, y, cursor_width, @row_height) return Rect.new(x, y, cursor_width, @row_height)
end end
end end
@@ -80,13 +80,13 @@ class Window_PokemonBag < Window_DrawableCommand
) )
if GameData::Item.get(item).is_important? if GameData::Item.get(item).is_important?
if @bag.registered?(item) if @bag.registered?(item)
pbDrawImagePositions(self.contents, [ pbDrawImagePositions(
["Graphics/Pictures/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 0, -1, 24] self.contents,
]) [["Graphics/Pictures/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 0, -1, 24]])
elsif pbCanRegisterItem?(item) elsif pbCanRegisterItem?(item)
pbDrawImagePositions(self.contents, [ pbDrawImagePositions(
["Graphics/Pictures/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 24, -1, 24] self.contents,
]) [["Graphics/Pictures/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 24, -1, 24]])
end end
else else
qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1] qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1]
@@ -190,7 +190,7 @@ class PokemonBag_Scene
@sprites["rightarrow"].y = 76 @sprites["rightarrow"].y = 76
@sprites["rightarrow"].visible = (!@choosing || numfilledpockets > 1) @sprites["rightarrow"].visible = (!@choosing || numfilledpockets > 1)
@sprites["rightarrow"].play @sprites["rightarrow"].play
@sprites["itemlist"] = Window_PokemonBag.new(@bag, @filterlist, lastpocket, 168, -8, 314, 40 + 32 + ITEMSVISIBLE * 32) @sprites["itemlist"] = Window_PokemonBag.new(@bag, @filterlist, lastpocket, 168, -8, 314, 40 + 32 + (ITEMSVISIBLE * 32))
@sprites["itemlist"].viewport = @viewport @sprites["itemlist"].viewport = @viewport
@sprites["itemlist"].pocket = lastpocket @sprites["itemlist"].pocket = lastpocket
@sprites["itemlist"].index = @bag.last_viewed_index(lastpocket) @sprites["itemlist"].index = @bag.last_viewed_index(lastpocket)
@@ -270,13 +270,13 @@ class PokemonBag_Scene
for i in 1...@bag.pockets.length for i in 1...@bag.pockets.length
if @filterlist[i].length == 0 if @filterlist[i].length == 0
@sprites["pocketicon"].bitmap.blt( @sprites["pocketicon"].bitmap.blt(
6 + (i - 1) * 22, 6, @pocketbitmap.bitmap, Rect.new((i - 1) * 20, 28, 20, 20) 6 + ((i - 1) * 22), 6, @pocketbitmap.bitmap, Rect.new((i - 1) * 20, 28, 20, 20)
) )
end end
end end
end end
@sprites["pocketicon"].bitmap.blt( @sprites["pocketicon"].bitmap.blt(
2 + (@sprites["itemlist"].pocket - 1) * 22, 2, @pocketbitmap.bitmap, 2 + ((@sprites["itemlist"].pocket - 1) * 22), 2, @pocketbitmap.bitmap,
Rect.new((@sprites["itemlist"].pocket - 1) * 28, 0, 28, 28) Rect.new((@sprites["itemlist"].pocket - 1) * 28, 0, 28, 28)
) )
# Refresh the item window # Refresh the item window
@@ -290,9 +290,9 @@ class PokemonBag_Scene
overlay = @sprites["overlay"].bitmap overlay = @sprites["overlay"].bitmap
overlay.clear overlay.clear
# Draw the pocket name # Draw the pocket name
pbDrawTextPositions(overlay, [ pbDrawTextPositions(
[PokemonBag.pocket_names[@bag.last_viewed_pocket - 1], 94, 176, 2, POCKETNAMEBASECOLOR, POCKETNAMESHADOWCOLOR] overlay,
]) [[PokemonBag.pocket_names[@bag.last_viewed_pocket - 1], 94, 176, 2, POCKETNAMEBASECOLOR, POCKETNAMESHADOWCOLOR]])
# Draw slider arrows # Draw slider arrows
showslider = false showslider = false
if itemlist.top_row > 0 if itemlist.top_row > 0
@@ -314,8 +314,8 @@ class PokemonBag_Scene
overlay.blt(470, y, @sliderbitmap.bitmap, Rect.new(36, 0, 36, 4)) overlay.blt(470, y, @sliderbitmap.bitmap, Rect.new(36, 0, 36, 4))
i = 0 i = 0
while i * 16 < boxheight - 4 - 18 while i * 16 < boxheight - 4 - 18
height = [boxheight - 4 - 18 - i * 16, 16].min height = [boxheight - 4 - 18 - (i * 16), 16].min
overlay.blt(470, y + 4 + i * 16, @sliderbitmap.bitmap, Rect.new(36, 4, 36, height)) overlay.blt(470, y + 4 + (i * 16), @sliderbitmap.bitmap, Rect.new(36, 4, 36, height))
i += 1 i += 1
end end
overlay.blt(470, y + boxheight - 18, @sliderbitmap.bitmap, Rect.new(36, 20, 36, 18)) overlay.blt(470, y + boxheight - 18, @sliderbitmap.bitmap, Rect.new(36, 20, 36, 18))
@@ -377,8 +377,7 @@ class PokemonBag_Scene
pbPlayCancelSE pbPlayCancelSE
pbRefresh pbRefresh
end end
else else # Change pockets
# Change pockets
if Input.trigger?(Input::LEFT) if Input.trigger?(Input::LEFT)
newpocket = itemwindow.pocket newpocket = itemwindow.pocket
loop do loop do
@@ -386,8 +385,8 @@ class PokemonBag_Scene
break if !@choosing || newpocket == itemwindow.pocket break if !@choosing || newpocket == itemwindow.pocket
if @filterlist if @filterlist
break if @filterlist[newpocket].length > 0 break if @filterlist[newpocket].length > 0
else elsif @bag.pockets[newpocket].length > 0
break if @bag.pockets[newpocket].length > 0 break
end end
end end
if itemwindow.pocket != newpocket if itemwindow.pocket != newpocket
@@ -404,8 +403,8 @@ class PokemonBag_Scene
break if !@choosing || newpocket == itemwindow.pocket break if !@choosing || newpocket == itemwindow.pocket
if @filterlist if @filterlist
break if @filterlist[newpocket].length > 0 break if @filterlist[newpocket].length > 0
else elsif @bag.pockets[newpocket].length > 0
break if @bag.pockets[newpocket].length > 0 break
end end
end end
if itemwindow.pocket != newpocket if itemwindow.pocket != newpocket
@@ -539,11 +538,10 @@ class PokemonBagScreen
elsif cmdDebug >= 0 && command == cmdDebug # Debug elsif cmdDebug >= 0 && command == cmdDebug # Debug
command = 0 command = 0
loop do loop do
command = @scene.pbShowCommands(_INTL("Do what with {1}?", itemname), [ command = @scene.pbShowCommands(_INTL("Do what with {1}?", itemname),
_INTL("Change quantity"), [_INTL("Change quantity"),
_INTL("Make Mystery Gift"), _INTL("Make Mystery Gift"),
_INTL("Cancel") _INTL("Cancel")], command)
], command)
case command case command
### Cancel ### ### Cancel ###
when -1, 2 when -1, 2

Some files were not shown because too many files have changed in this diff Show More