mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-06-13 07:19:28 +00:00
Yet more Rubocopping
This commit is contained in:
@@ -7,7 +7,7 @@ module PBDebug
|
|||||||
rescue
|
rescue
|
||||||
PBDebug.log("")
|
PBDebug.log("")
|
||||||
PBDebug.log("**Exception: #{$!.message}")
|
PBDebug.log("**Exception: #{$!.message}")
|
||||||
PBDebug.log("#{$!.backtrace.inspect}")
|
PBDebug.log($!.backtrace.inspect.to_s)
|
||||||
PBDebug.log("")
|
PBDebug.log("")
|
||||||
pbPrintException($!) # if $INTERNAL
|
pbPrintException($!) # if $INTERNAL
|
||||||
PBDebug.flush
|
PBDebug.flush
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ def pbPrintException(e)
|
|||||||
message += "Exception: #{e.class}\r\n"
|
message += "Exception: #{e.class}\r\n"
|
||||||
message += "Message: "
|
message += "Message: "
|
||||||
end
|
end
|
||||||
message += "#{emessage}"
|
message += emessage
|
||||||
# show last 10/25 lines of backtrace
|
# show last 10/25 lines of backtrace
|
||||||
if !e.is_a?(EventScriptError)
|
if !e.is_a?(EventScriptError)
|
||||||
message += "\r\n\r\nBacktrace:\r\n"
|
message += "\r\n\r\nBacktrace:\r\n"
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ class StringInput
|
|||||||
f = super
|
f = super
|
||||||
yield f
|
yield f
|
||||||
ensure
|
ensure
|
||||||
f.close if f
|
f&.close
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class StringInput
|
|||||||
end
|
end
|
||||||
|
|
||||||
def each_byte
|
def each_byte
|
||||||
while !eof?
|
until eof?
|
||||||
yield getc
|
yield getc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ def pbSetTextMessages
|
|||||||
neednewline = false
|
neednewline = false
|
||||||
end
|
end
|
||||||
if list.code == 101
|
if list.code == 101
|
||||||
lastitem += "#{list.parameters[0]}"
|
lastitem += list.parameters[0].to_s
|
||||||
neednewline = true
|
neednewline = true
|
||||||
elsif list.code == 102
|
elsif list.code == 102
|
||||||
list.parameters[0].length.times do |k|
|
list.parameters[0].length.times do |k|
|
||||||
@@ -78,7 +78,7 @@ def pbSetTextMessages
|
|||||||
neednewline = false
|
neednewline = false
|
||||||
elsif list.code == 401
|
elsif list.code == 401
|
||||||
lastitem += " " if lastitem != ""
|
lastitem += " " if lastitem != ""
|
||||||
lastitem += "#{list.parameters[0]}"
|
lastitem += list.parameters[0].to_s
|
||||||
neednewline = true
|
neednewline = true
|
||||||
elsif list.code == 355 || list.code == 655
|
elsif list.code == 355 || list.code == 655
|
||||||
pbAddScriptTexts(items, list.parameters[0])
|
pbAddScriptTexts(items, list.parameters[0])
|
||||||
@@ -93,11 +93,9 @@ def pbSetTextMessages
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if neednewline
|
if neednewline && lastitem != ""
|
||||||
if lastitem != ""
|
items.push(lastitem)
|
||||||
items.push(lastitem)
|
lastitem = ""
|
||||||
lastitem = ""
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -140,7 +138,7 @@ def pbSetTextMessages
|
|||||||
neednewline = false
|
neednewline = false
|
||||||
end
|
end
|
||||||
if list.code == 101
|
if list.code == 101
|
||||||
lastitem += "#{list.parameters[0]}"
|
lastitem += list.parameters[0].to_s
|
||||||
neednewline = true
|
neednewline = true
|
||||||
elsif list.code == 102
|
elsif list.code == 102
|
||||||
list.parameters[0].length.times do |k|
|
list.parameters[0].length.times do |k|
|
||||||
@@ -149,7 +147,7 @@ def pbSetTextMessages
|
|||||||
neednewline = false
|
neednewline = false
|
||||||
elsif list.code == 401
|
elsif list.code == 401
|
||||||
lastitem += " " if lastitem != ""
|
lastitem += " " if lastitem != ""
|
||||||
lastitem += "#{list.parameters[0]}"
|
lastitem += list.parameters[0].to_s
|
||||||
neednewline = true
|
neednewline = true
|
||||||
elsif list.code == 355 || list.code == 655
|
elsif list.code == 355 || list.code == 655
|
||||||
pbAddScriptTexts(items, list.parameters[0])
|
pbAddScriptTexts(items, list.parameters[0])
|
||||||
@@ -164,11 +162,9 @@ def pbSetTextMessages
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if neednewline
|
if neednewline && lastitem != ""
|
||||||
if lastitem != ""
|
items.push(lastitem)
|
||||||
items.push(lastitem)
|
lastitem = ""
|
||||||
lastitem = ""
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -210,7 +206,7 @@ def pbEachIntlSection(file)
|
|||||||
sectionname = $~[1]
|
sectionname = $~[1]
|
||||||
havesection = true
|
havesection = true
|
||||||
else
|
else
|
||||||
if sectionname == nil
|
if sectionname.nil?
|
||||||
raise _INTL("Expected a section at the beginning of the file (line {1})", lineno)
|
raise _INTL("Expected a section at the beginning of the file (line {1})", lineno)
|
||||||
end
|
end
|
||||||
lastsection.push(line.gsub(/\s+$/, ""))
|
lastsection.push(line.gsub(/\s+$/, ""))
|
||||||
@@ -739,7 +735,7 @@ def _INTL(*arg)
|
|||||||
end
|
end
|
||||||
string = string.clone
|
string = string.clone
|
||||||
(1...arg.length).each do |i|
|
(1...arg.length).each do |i|
|
||||||
string.gsub!(/\{#{i}\}/, "#{arg[i]}")
|
string.gsub!(/\{#{i}\}/, arg[i].to_s)
|
||||||
end
|
end
|
||||||
return string
|
return string
|
||||||
end
|
end
|
||||||
@@ -770,7 +766,7 @@ def _MAPINTL(mapid, *arg)
|
|||||||
string = MessageTypes.getFromMapHash(mapid, arg[0])
|
string = MessageTypes.getFromMapHash(mapid, arg[0])
|
||||||
string = string.clone
|
string = string.clone
|
||||||
(1...arg.length).each do |i|
|
(1...arg.length).each do |i|
|
||||||
string.gsub!(/\{#{i}\}/, "#{arg[i]}")
|
string.gsub!(/\{#{i}\}/, arg[i].to_s)
|
||||||
end
|
end
|
||||||
return string
|
return string
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -319,10 +319,10 @@ module PluginManager
|
|||||||
value = [value] if value.is_a?(String)
|
value = [value] if value.is_a?(String)
|
||||||
if value.is_a?(Array)
|
if value.is_a?(Array)
|
||||||
value.each do |entry|
|
value.each do |entry|
|
||||||
if !entry.is_a?(String)
|
if entry.is_a?(String)
|
||||||
self.error("Plugin '#{name}'s credits array contains a non-string value.")
|
|
||||||
else
|
|
||||||
credits << entry
|
credits << entry
|
||||||
|
else
|
||||||
|
self.error("Plugin '#{name}'s credits array contains a non-string value.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -333,7 +333,7 @@ module PluginManager
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@Plugins.values.each do |plugin|
|
@@Plugins.values.each do |plugin|
|
||||||
if plugin[:incompatibilities] && plugin[:incompatibilities].include?(name)
|
if plugin[:incompatibilities]&.include?(name)
|
||||||
self.error("Plugin '#{plugin[:name]}' is incompatible with '#{name}'. " +
|
self.error("Plugin '#{plugin[:name]}' is incompatible with '#{name}'. " +
|
||||||
"They cannot both be used at the same time.")
|
"They cannot both be used at the same time.")
|
||||||
end
|
end
|
||||||
@@ -475,7 +475,7 @@ module PluginManager
|
|||||||
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl when closing this message to copy it to the clipboard.")
|
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl when closing this message to copy it to the clipboard.")
|
||||||
# Give a ~500ms coyote time to start holding Control
|
# Give a ~500ms coyote time to start holding Control
|
||||||
t = System.delta
|
t = System.delta
|
||||||
until (System.delta - t) >= 500000
|
until (System.delta - t) >= 500_000
|
||||||
Input.update
|
Input.update
|
||||||
if Input.press?(Input::CTRL)
|
if Input.press?(Input::CTRL)
|
||||||
Input.clipboard = message
|
Input.clipboard = message
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ class SpriteAnimation
|
|||||||
@sprite = sprite
|
@sprite = sprite
|
||||||
end
|
end
|
||||||
|
|
||||||
%w[
|
["x", "y", "ox", "oy", "viewport", "flash", "src_rect", "opacity", "tone"].each do |def_name|
|
||||||
x y ox oy viewport flash src_rect opacity tone
|
|
||||||
].each_with_index do |s, _i|
|
|
||||||
eval <<-__END__
|
eval <<-__END__
|
||||||
|
|
||||||
def #{s}(*arg)
|
def #{def_name}(*arg)
|
||||||
@sprite.#{s}(*arg)
|
@sprite.#{def_name}(*arg)
|
||||||
end
|
end
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
@@ -30,7 +28,7 @@ class SpriteAnimation
|
|||||||
def animation(animation, hit, height = 3)
|
def animation(animation, hit, height = 3)
|
||||||
dispose_animation
|
dispose_animation
|
||||||
@_animation = animation
|
@_animation = animation
|
||||||
return if @_animation == nil
|
return if @_animation.nil?
|
||||||
@_animation_hit = hit
|
@_animation_hit = hit
|
||||||
@_animation_height = height
|
@_animation_height = height
|
||||||
@_animation_duration = @_animation.frame_max
|
@_animation_duration = @_animation.frame_max
|
||||||
@@ -66,7 +64,7 @@ class SpriteAnimation
|
|||||||
return if animation == @_loop_animation
|
return if animation == @_loop_animation
|
||||||
dispose_loop_animation
|
dispose_loop_animation
|
||||||
@_loop_animation = animation
|
@_loop_animation = animation
|
||||||
return if @_loop_animation == nil
|
return if @_loop_animation.nil?
|
||||||
@_loop_animation_index = 0
|
@_loop_animation_index = 0
|
||||||
fr = 20
|
fr = 20
|
||||||
if @_animation.name[/\[\s*(\d+?)\s*\]\s*$/]
|
if @_animation.name[/\[\s*(\d+?)\s*\]\s*$/]
|
||||||
@@ -92,7 +90,7 @@ class SpriteAnimation
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose_animation
|
def dispose_animation
|
||||||
return if @_animation_sprites == nil
|
return if @_animation_sprites.nil?
|
||||||
sprite = @_animation_sprites[0]
|
sprite = @_animation_sprites[0]
|
||||||
if sprite != nil
|
if sprite != nil
|
||||||
@@_reference_count[sprite.bitmap] -= 1
|
@@_reference_count[sprite.bitmap] -= 1
|
||||||
@@ -108,7 +106,7 @@ class SpriteAnimation
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose_loop_animation
|
def dispose_loop_animation
|
||||||
return if @_loop_animation_sprites == nil
|
return if @_loop_animation_sprites.nil?
|
||||||
sprite = @_loop_animation_sprites[0]
|
sprite = @_loop_animation_sprites[0]
|
||||||
if sprite != nil
|
if sprite != nil
|
||||||
@@_reference_count[sprite.bitmap] -= 1
|
@@_reference_count[sprite.bitmap] -= 1
|
||||||
@@ -195,7 +193,7 @@ class SpriteAnimation
|
|||||||
16.times do |i|
|
16.times do |i|
|
||||||
sprite = sprites[i]
|
sprite = sprites[i]
|
||||||
pattern = cell_data[i, 0]
|
pattern = cell_data[i, 0]
|
||||||
if sprite == nil || pattern == nil || pattern == -1
|
if sprite.nil? || pattern.nil? || pattern == -1
|
||||||
sprite.visible = false if sprite != nil
|
sprite.visible = false if sprite != nil
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
@@ -377,7 +375,7 @@ module RPG
|
|||||||
|
|
||||||
def pushAnimation(array, anim)
|
def pushAnimation(array, anim)
|
||||||
array.length.times do |i|
|
array.length.times do |i|
|
||||||
next if array[i] && array[i].active?
|
next if array[i]&.active?
|
||||||
array[i] = anim
|
array[i] = anim
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -397,7 +395,7 @@ module RPG
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose_damage
|
def dispose_damage
|
||||||
return if @_damage_sprite == nil
|
return if @_damage_sprite.nil?
|
||||||
@_damage_sprite.bitmap.dispose
|
@_damage_sprite.bitmap.dispose
|
||||||
@_damage_sprite.dispose
|
@_damage_sprite.dispose
|
||||||
@_damage_sprite = nil
|
@_damage_sprite = nil
|
||||||
@@ -406,14 +404,14 @@ module RPG
|
|||||||
|
|
||||||
def dispose_animation
|
def dispose_animation
|
||||||
@animations.each do |a|
|
@animations.each do |a|
|
||||||
a.dispose_animation if a
|
a&.dispose_animation
|
||||||
end
|
end
|
||||||
@animations.clear
|
@animations.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
def dispose_loop_animation
|
def dispose_loop_animation
|
||||||
@loopAnimations.each do |a|
|
@loopAnimations.each do |a|
|
||||||
a.dispose_loop_animation if a
|
a&.dispose_loop_animation
|
||||||
end
|
end
|
||||||
@loopAnimations.clear
|
@loopAnimations.clear
|
||||||
end
|
end
|
||||||
@@ -501,13 +499,13 @@ module RPG
|
|||||||
|
|
||||||
def update_animation
|
def update_animation
|
||||||
@animations.each do |a|
|
@animations.each do |a|
|
||||||
a.update_animation if a && a.active?
|
a.update_animation if a&.active?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_loop_animation
|
def update_loop_animation
|
||||||
@loopAnimations.each do |a|
|
@loopAnimations.each do |a|
|
||||||
a.update_loop_animation if a && a.active?
|
a.update_loop_animation if a&.active?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ module Game
|
|||||||
# Called when starting a new game. Initializes global variables
|
# Called when starting a new game. Initializes global variables
|
||||||
# and transfers the player into the map scene.
|
# and transfers the player into the map scene.
|
||||||
def self.start_new
|
def self.start_new
|
||||||
if $game_map && $game_map.events
|
if $game_map&.events
|
||||||
$game_map.events.each_value { |event| event.clear_starting }
|
$game_map.events.each_value { |event| event.clear_starting }
|
||||||
end
|
end
|
||||||
$game_temp.common_event_id = 0 if $game_temp
|
$game_temp.common_event_id = 0 if $game_temp
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ class Scene_Map
|
|||||||
pbBGMFade(0.8)
|
pbBGMFade(0.8)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if playingBGS && map.autoplay_bgs
|
if playingBGS && map.autoplay_bgs && playingBGS.name != map.bgs.name
|
||||||
pbBGMFade(0.8) if playingBGS.name != map.bgs.name
|
pbBGMFade(0.8)
|
||||||
end
|
end
|
||||||
Graphics.frame_reset
|
Graphics.frame_reset
|
||||||
end
|
end
|
||||||
@@ -145,12 +145,12 @@ class Scene_Map
|
|||||||
end
|
end
|
||||||
keys = @spritesets.keys.clone
|
keys = @spritesets.keys.clone
|
||||||
keys.each do |i|
|
keys.each do |i|
|
||||||
if !$map_factory.hasMap?(i)
|
if $map_factory.hasMap?(i)
|
||||||
@spritesets[i].dispose if @spritesets[i]
|
@spritesets[i].update
|
||||||
|
else
|
||||||
|
@spritesets[i]&.dispose
|
||||||
@spritesets[i] = nil
|
@spritesets[i] = nil
|
||||||
@spritesets.delete(i)
|
@spritesets.delete(i)
|
||||||
else
|
|
||||||
@spritesets[i].update
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@spritesetGlobal.update
|
@spritesetGlobal.update
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ class Interpreter
|
|||||||
def pbEraseThisEvent
|
def pbEraseThisEvent
|
||||||
if $game_map.events[@event_id]
|
if $game_map.events[@event_id]
|
||||||
$game_map.events[@event_id].erase
|
$game_map.events[@event_id].erase
|
||||||
$PokemonMap.addErasedEvent(@event_id) if $PokemonMap
|
$PokemonMap&.addErasedEvent(@event_id)
|
||||||
end
|
end
|
||||||
@index += 1
|
@index += 1
|
||||||
return true
|
return true
|
||||||
@@ -407,7 +407,7 @@ class Interpreter
|
|||||||
when 6 then event.move_right
|
when 6 then event.move_right
|
||||||
when 8 then event.move_up
|
when 8 then event.move_up
|
||||||
end
|
end
|
||||||
$PokemonMap.addMovedEvent(@event_id) if $PokemonMap
|
$PokemonMap&.addMovedEvent(@event_id)
|
||||||
if old_x != event.x || old_y != event.y
|
if old_x != event.x || old_y != event.y
|
||||||
$game_player.lock
|
$game_player.lock
|
||||||
loop do
|
loop do
|
||||||
@@ -443,7 +443,7 @@ class Interpreter
|
|||||||
def pbTrainerEnd
|
def pbTrainerEnd
|
||||||
pbGlobalUnlock
|
pbGlobalUnlock
|
||||||
event = get_self
|
event = get_self
|
||||||
event.erase_route if event
|
event&.erase_route
|
||||||
end
|
end
|
||||||
|
|
||||||
def setPrice(item, buy_price = -1, sell_price = -1)
|
def setPrice(item, buy_price = -1, sell_price = -1)
|
||||||
|
|||||||
@@ -414,8 +414,8 @@ class Interpreter
|
|||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
def command_116
|
def command_116
|
||||||
if @event_id > 0
|
if @event_id > 0
|
||||||
$game_map.events[@event_id].erase if $game_map.events[@event_id]
|
$game_map.events[@event_id]&.erase
|
||||||
$PokemonMap.addErasedEvent(@event_id) if $PokemonMap
|
$PokemonMap&.addErasedEvent(@event_id)
|
||||||
end
|
end
|
||||||
@index += 1
|
@index += 1
|
||||||
return false
|
return false
|
||||||
@@ -512,10 +512,10 @@ class Interpreter
|
|||||||
next if $game_variables[i] == value
|
next if $game_variables[i] == value
|
||||||
$game_variables[i] = value
|
$game_variables[i] = value
|
||||||
when 1 # add
|
when 1 # add
|
||||||
next if $game_variables[i] >= 99999999
|
next if $game_variables[i] >= 99_999_999
|
||||||
$game_variables[i] += value
|
$game_variables[i] += value
|
||||||
when 2 # subtract
|
when 2 # subtract
|
||||||
next if $game_variables[i] <= -99999999
|
next if $game_variables[i] <= -99_999_999
|
||||||
$game_variables[i] -= value
|
$game_variables[i] -= value
|
||||||
when 3 # multiply
|
when 3 # multiply
|
||||||
next if value == 1
|
next if value == 1
|
||||||
@@ -527,8 +527,8 @@ class Interpreter
|
|||||||
next if [0, 1].include?(value)
|
next if [0, 1].include?(value)
|
||||||
$game_variables[i] %= value
|
$game_variables[i] %= value
|
||||||
end
|
end
|
||||||
$game_variables[i] = 99999999 if $game_variables[i] > 99999999
|
$game_variables[i] = 99_999_999 if $game_variables[i] > 99_999_999
|
||||||
$game_variables[i] = -99999999 if $game_variables[i] < -99999999
|
$game_variables[i] = -99_999_999 if $game_variables[i] < -99_999_999
|
||||||
$game_map.need_refresh = true
|
$game_map.need_refresh = true
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ end
|
|||||||
def pbToneChangeAll(tone, duration)
|
def pbToneChangeAll(tone, duration)
|
||||||
$game_screen.start_tone_change(tone, duration * Graphics.frame_rate / 20)
|
$game_screen.start_tone_change(tone, duration * Graphics.frame_rate / 20)
|
||||||
$game_screen.pictures.each do |picture|
|
$game_screen.pictures.each do |picture|
|
||||||
picture.start_tone_change(tone, duration * Graphics.frame_rate / 20) if picture
|
picture&.start_tone_change(tone, duration * Graphics.frame_rate / 20)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -61,11 +61,10 @@ class Game_System
|
|||||||
|
|
||||||
def bgm_play_internal(bgm, position) # :nodoc:
|
def bgm_play_internal(bgm, position) # :nodoc:
|
||||||
@bgm_position = position if !@bgm_paused
|
@bgm_position = position if !@bgm_paused
|
||||||
@playing_bgm = (bgm == nil) ? nil : bgm.clone
|
@playing_bgm = bgm&.clone
|
||||||
if bgm != nil && bgm.name != ""
|
if bgm != nil && bgm.name != ""
|
||||||
if FileTest.audio_exist?("Audio/BGM/" + bgm.name)
|
if !@defaultBGM && FileTest.audio_exist?("Audio/BGM/" + bgm.name)
|
||||||
bgm_play_internal2("Audio/BGM/" + bgm.name,
|
bgm_play_internal2("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch, @bgm_position)
|
||||||
bgm.volume, bgm.pitch, @bgm_position) if !@defaultBGM
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@bgm_position = position if !@bgm_paused
|
@bgm_position = position if !@bgm_paused
|
||||||
@@ -161,7 +160,7 @@ class Game_System
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
def bgs_play(bgs)
|
def bgs_play(bgs)
|
||||||
@playing_bgs = (bgs == nil) ? nil : bgs.clone
|
@playing_bgs = (bgs.nil?) ? nil : bgs.clone
|
||||||
if bgs != nil && bgs.name != ""
|
if bgs != nil && bgs.name != ""
|
||||||
if FileTest.audio_exist?("Audio/BGS/" + bgs.name)
|
if FileTest.audio_exist?("Audio/BGS/" + bgs.name)
|
||||||
vol = bgs.volume
|
vol = bgs.volume
|
||||||
@@ -258,7 +257,7 @@ class Game_System
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
def windowskin_name
|
def windowskin_name
|
||||||
if @windowskin_name == nil
|
if @windowskin_name.nil?
|
||||||
return $data_system.windowskin_name
|
return $data_system.windowskin_name
|
||||||
else
|
else
|
||||||
return @windowskin_name
|
return @windowskin_name
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class Game_Picture
|
|||||||
@zoom_x = zoom_x.to_f
|
@zoom_x = zoom_x.to_f
|
||||||
@zoom_y = zoom_y.to_f
|
@zoom_y = zoom_y.to_f
|
||||||
@opacity = opacity.to_f
|
@opacity = opacity.to_f
|
||||||
@blend_type = blend_type ? blend_type : 0
|
@blend_type = blend_type || 0
|
||||||
@duration = 0
|
@duration = 0
|
||||||
@target_x = @x
|
@target_x = @x
|
||||||
@target_y = @y
|
@target_y = @y
|
||||||
@@ -98,7 +98,7 @@ class Game_Picture
|
|||||||
@target_zoom_x = zoom_x.to_f
|
@target_zoom_x = zoom_x.to_f
|
||||||
@target_zoom_y = zoom_y.to_f
|
@target_zoom_y = zoom_y.to_f
|
||||||
@target_opacity = opacity.to_f
|
@target_opacity = opacity.to_f
|
||||||
@blend_type = blend_type ? blend_type : 0
|
@blend_type = blend_type || 0
|
||||||
end
|
end
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# * Change Rotation Speed
|
# * Change Rotation Speed
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class Game_Map
|
|||||||
if self_event != nil && terrain.can_surf_freely
|
if self_event != nil && terrain.can_surf_freely
|
||||||
[2, 1, 0].each do |j|
|
[2, 1, 0].each do |j|
|
||||||
facing_tile_id = data[newx, newy, j]
|
facing_tile_id = data[newx, newy, j]
|
||||||
return false if facing_tile_id == nil
|
return false if facing_tile_id.nil?
|
||||||
facing_terrain = GameData::TerrainTag.try_get(@terrain_tags[facing_tile_id])
|
facing_terrain = GameData::TerrainTag.try_get(@terrain_tags[facing_tile_id])
|
||||||
if facing_terrain.id != :None && !facing_terrain.ignore_passability
|
if facing_terrain.id != :None && !facing_terrain.ignore_passability
|
||||||
return facing_terrain.can_surf_freely
|
return facing_terrain.can_surf_freely
|
||||||
@@ -207,7 +207,7 @@ class Game_Map
|
|||||||
# Can't walk onto ledges
|
# Can't walk onto ledges
|
||||||
[2, 1, 0].each do |j|
|
[2, 1, 0].each do |j|
|
||||||
facing_tile_id = data[newx, newy, j]
|
facing_tile_id = data[newx, newy, j]
|
||||||
return false if facing_tile_id == nil
|
return false if facing_tile_id.nil?
|
||||||
facing_terrain = GameData::TerrainTag.try_get(@terrain_tags[facing_tile_id])
|
facing_terrain = GameData::TerrainTag.try_get(@terrain_tags[facing_tile_id])
|
||||||
return false if facing_terrain.ledge
|
return false if facing_terrain.ledge
|
||||||
break if facing_terrain.id != :None && !facing_terrain.ignore_passability
|
break if facing_terrain.id != :None && !facing_terrain.ignore_passability
|
||||||
@@ -326,7 +326,7 @@ class Game_Map
|
|||||||
max_x = (self.width - (Graphics.width.to_f / 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
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_y=(value)
|
def display_y=(value)
|
||||||
@@ -336,7 +336,7 @@ class Game_Map
|
|||||||
max_y = (self.height - (Graphics.height.to_f / 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
|
||||||
end
|
end
|
||||||
|
|
||||||
def scroll_up(distance)
|
def scroll_up(distance)
|
||||||
|
|||||||
@@ -93,7 +93,22 @@ class Interpreter
|
|||||||
max_y = ($game_map.height - (Graphics.height.to_f / 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 = false
|
||||||
|
dir = nil
|
||||||
|
if count_x != 0 && count_y != 0
|
||||||
|
return false
|
||||||
|
elsif count_x > 0
|
||||||
|
dir = 4
|
||||||
|
elsif count_x < 0
|
||||||
|
dir = 6
|
||||||
|
elsif count_y > 0
|
||||||
|
dir = 8
|
||||||
|
elsif count_y < 0
|
||||||
|
dir = 2
|
||||||
|
end
|
||||||
|
count = count_x == 0 ? count_y.abs : count_x.abs
|
||||||
|
else
|
||||||
@diag = true
|
@diag = true
|
||||||
dir = nil
|
dir = nil
|
||||||
if count_x > 0
|
if count_x > 0
|
||||||
@@ -110,21 +125,6 @@ class Interpreter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
count = [count_x.abs, count_y.abs].min
|
count = [count_x.abs, count_y.abs].min
|
||||||
else
|
|
||||||
@diag = false
|
|
||||||
dir = nil
|
|
||||||
if count_x != 0 && count_y != 0
|
|
||||||
return false
|
|
||||||
elsif count_x > 0
|
|
||||||
dir = 4
|
|
||||||
elsif count_x < 0
|
|
||||||
dir = 6
|
|
||||||
elsif count_y > 0
|
|
||||||
dir = 8
|
|
||||||
elsif count_y < 0
|
|
||||||
dir = 2
|
|
||||||
end
|
|
||||||
count = count_x != 0 ? count_x.abs : count_y.abs
|
|
||||||
end
|
end
|
||||||
$game_map.start_scroll(dir, count, speed) if dir != nil
|
$game_map.start_scroll(dir, count, speed) if dir != nil
|
||||||
if @diag
|
if @diag
|
||||||
|
|||||||
@@ -185,10 +185,10 @@ class PokemonMapFactory
|
|||||||
return false if !event.through && event.character_name != ""
|
return false if !event.through && event.character_name != ""
|
||||||
end
|
end
|
||||||
# Check passability of player
|
# Check passability of player
|
||||||
if !thisEvent.is_a?(Game_Player)
|
if !thisEvent.is_a?(Game_Player) &&
|
||||||
if $game_map.map_id == mapID && $game_player.x == x && $game_player.y == y
|
$game_map.map_id == mapID && $game_player.x == x && $game_player.y == y &&
|
||||||
return false if !$game_player.through && $game_player.character_name != ""
|
!$game_player.through && $game_player.character_name != ""
|
||||||
end
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -201,8 +201,8 @@ class PokemonMapFactory
|
|||||||
return false if !map.valid?(x, y)
|
return false if !map.valid?(x, y)
|
||||||
return true if thisEvent.through
|
return true if thisEvent.through
|
||||||
if thisEvent == $game_player
|
if thisEvent == $game_player
|
||||||
if !($DEBUG && Input.press?(Input::CTRL))
|
if !($DEBUG && Input.press?(Input::CTRL)) && !map.passableStrict?(x, y, 0, thisEvent)
|
||||||
return false if !map.passableStrict?(x, y, 0, thisEvent)
|
return false
|
||||||
end
|
end
|
||||||
elsif !map.passableStrict?(x, y, 0, thisEvent)
|
elsif !map.passableStrict?(x, y, 0, thisEvent)
|
||||||
return false
|
return false
|
||||||
@@ -289,12 +289,12 @@ class PokemonMapFactory
|
|||||||
|
|
||||||
# NOTE: Assumes the event is 1x1 tile in size. Only returns one tile.
|
# NOTE: Assumes the event is 1x1 tile in size. Only returns one tile.
|
||||||
def getFacingTile(direction = nil, event = nil, steps = 1)
|
def getFacingTile(direction = nil, event = nil, steps = 1)
|
||||||
event = $game_player if event == nil
|
event = $game_player if event.nil?
|
||||||
return [0, 0, 0] if !event
|
return [0, 0, 0] if !event
|
||||||
x = event.x
|
x = event.x
|
||||||
y = event.y
|
y = event.y
|
||||||
id = event.map.map_id
|
id = event.map.map_id
|
||||||
direction = event.direction if direction == nil
|
direction = event.direction if direction.nil?
|
||||||
return getFacingTileFromPos(id, x, y, direction, steps)
|
return getFacingTileFromPos(id, x, y, direction, steps)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -511,6 +511,6 @@ end
|
|||||||
def updateTilesets
|
def updateTilesets
|
||||||
maps = $map_factory.maps
|
maps = $map_factory.maps
|
||||||
maps.each do |map|
|
maps.each do |map|
|
||||||
map.updateTileset if map
|
map&.updateTileset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -244,8 +244,9 @@ class Game_Character
|
|||||||
next if self == event || !event.at_coordinate?(new_x, new_y) || event.through
|
next if self == event || !event.at_coordinate?(new_x, new_y) || event.through
|
||||||
return false if self != $game_player || event.character_name != ""
|
return false if self != $game_player || event.character_name != ""
|
||||||
end
|
end
|
||||||
if $game_player.x == new_x && $game_player.y == new_y
|
if $game_player.x == new_x && $game_player.y == new_y &&
|
||||||
return false if !$game_player.through && @character_name != ""
|
!$game_player.through && @character_name != ""
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -356,7 +357,7 @@ class Game_Character
|
|||||||
end
|
end
|
||||||
|
|
||||||
def force_move_route(move_route)
|
def force_move_route(move_route)
|
||||||
if @original_move_route == nil
|
if @original_move_route.nil?
|
||||||
@original_move_route = @move_route
|
@original_move_route = @move_route
|
||||||
@original_move_route_index = @move_route_index
|
@original_move_route_index = @move_route_index
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class Game_Event < Game_Character
|
|||||||
return $PokemonGlobal.eventvars[[@map_id, @event.id]].to_i
|
return $PokemonGlobal.eventvars[[@map_id, @event.id]].to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def expired?(secs = 86400)
|
def expired?(secs = 86_400)
|
||||||
ontime = self.variable
|
ontime = self.variable
|
||||||
time = pbGetTimeNow
|
time = pbGetTimeNow
|
||||||
return ontime && (time.to_i > ontime + secs)
|
return ontime && (time.to_i > ontime + secs)
|
||||||
@@ -109,8 +109,8 @@ class Game_Event < Game_Character
|
|||||||
ontime = self.variable.to_i
|
ontime = self.variable.to_i
|
||||||
return false if !ontime
|
return false if !ontime
|
||||||
now = pbGetTimeNow
|
now = pbGetTimeNow
|
||||||
elapsed = (now.to_i - ontime) / 86400
|
elapsed = (now.to_i - ontime) / 86_400
|
||||||
elapsed += 1 if (now.to_i - ontime) % 86400 > ((now.hour * 3600) + (now.min * 60) + now.sec)
|
elapsed += 1 if (now.to_i - ontime) % 86_400 > ((now.hour * 3600) + (now.min * 60) + now.sec)
|
||||||
return elapsed >= days
|
return elapsed >= days
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -141,12 +141,12 @@ class Game_Event < Game_Character
|
|||||||
|
|
||||||
def pbCheckEventTriggerAfterTurning
|
def pbCheckEventTriggerAfterTurning
|
||||||
return if $game_system.map_interpreter.running? || @starting
|
return if $game_system.map_interpreter.running? || @starting
|
||||||
if @event.name[/trainer\((\d+)\)/i]
|
return if @trigger != 2 # Event touch
|
||||||
distance = $~[1].to_i
|
return if !@event.name[/trainer\((\d+)\)/i]
|
||||||
if @trigger == 2 && pbEventCanReachPlayer?(self, $game_player, distance)
|
distance = $~[1].to_i
|
||||||
start if !jumping? && !over_trigger?
|
return if !pbEventCanReachPlayer?(self, $game_player, distance)
|
||||||
end
|
return if jumping? || over_trigger?
|
||||||
end
|
start
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_event_trigger_touch(dir)
|
def check_event_trigger_touch(dir)
|
||||||
@@ -170,8 +170,8 @@ class Game_Event < Game_Character
|
|||||||
def check_event_trigger_auto
|
def check_event_trigger_auto
|
||||||
case @trigger
|
case @trigger
|
||||||
when 2 # Event touch
|
when 2 # Event touch
|
||||||
if at_coordinate?($game_player.x, $game_player.y)
|
if at_coordinate?($game_player.x, $game_player.y) && !jumping? && over_trigger?
|
||||||
start if !jumping? && over_trigger?
|
start
|
||||||
end
|
end
|
||||||
when 3 # Autorun
|
when 3 # Autorun
|
||||||
start
|
start
|
||||||
@@ -197,7 +197,7 @@ class Game_Event < Game_Character
|
|||||||
return if new_page == @page
|
return if new_page == @page
|
||||||
@page = new_page
|
@page = new_page
|
||||||
clear_starting
|
clear_starting
|
||||||
if @page == nil
|
if @page.nil?
|
||||||
@tile_id = 0
|
@tile_id = 0
|
||||||
@character_name = ""
|
@character_name = ""
|
||||||
@character_hue = 0
|
@character_hue = 0
|
||||||
|
|||||||
@@ -185,13 +185,12 @@ class Game_Player < Game_Character
|
|||||||
return result if checkIfRunning && $game_system.map_interpreter.running?
|
return result if checkIfRunning && $game_system.map_interpreter.running?
|
||||||
# All event loops
|
# All event loops
|
||||||
$game_map.events.values.each do |event|
|
$game_map.events.values.each do |event|
|
||||||
|
next if !triggers.include?(event.trigger)
|
||||||
next if !event.name[/trainer\((\d+)\)/i]
|
next if !event.name[/trainer\((\d+)\)/i]
|
||||||
distance = $~[1].to_i
|
distance = $~[1].to_i
|
||||||
# If event coordinates and triggers are consistent
|
next if !pbEventCanReachPlayer?(event, self, distance)
|
||||||
if pbEventCanReachPlayer?(event, self, distance) && triggers.include?(event.trigger)
|
next if event.jumping? || event.over_trigger?
|
||||||
# If starting determinant is front event (other than jumping)
|
result.push(event)
|
||||||
result.push(event) if !event.jumping? && !event.over_trigger?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
@@ -202,13 +201,12 @@ class Game_Player < Game_Character
|
|||||||
return result if checkIfRunning && $game_system.map_interpreter.running?
|
return result if checkIfRunning && $game_system.map_interpreter.running?
|
||||||
# All event loops
|
# All event loops
|
||||||
$game_map.events.values.each do |event|
|
$game_map.events.values.each do |event|
|
||||||
|
next if !triggers.include?(event.trigger)
|
||||||
next if !event.name[/counter\((\d+)\)/i]
|
next if !event.name[/counter\((\d+)\)/i]
|
||||||
distance = $~[1].to_i
|
distance = $~[1].to_i
|
||||||
# If event coordinates and triggers are consistent
|
next if !pbEventFacesPlayer?(event, self, distance)
|
||||||
if pbEventFacesPlayer?(event, self, distance) && triggers.include?(event.trigger)
|
next if event.jumping? || event.over_trigger?
|
||||||
# If starting determinant is front event (other than jumping)
|
result.push(event)
|
||||||
result.push(event) if !event.jumping? && !event.over_trigger?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
@@ -355,32 +353,29 @@ class Game_Player < Game_Character
|
|||||||
return false if !$game_map.valid?(new_x, new_y)
|
return false if !$game_map.valid?(new_x, new_y)
|
||||||
# All event loops
|
# All event loops
|
||||||
$game_map.events.values.each do |event|
|
$game_map.events.values.each do |event|
|
||||||
|
next if !triggers.include?(event.trigger)
|
||||||
# If event coordinates and triggers are consistent
|
# If event coordinates and triggers are consistent
|
||||||
next if !event.at_coordinate?(new_x, new_y)
|
next if !event.at_coordinate?(new_x, new_y)
|
||||||
next if !triggers.include?(event.trigger)
|
|
||||||
# If starting determinant is front event (other than jumping)
|
# If starting determinant is front event (other than jumping)
|
||||||
next if event.jumping? || event.over_trigger?
|
next if event.jumping? || event.over_trigger?
|
||||||
event.start
|
event.start
|
||||||
result = true
|
result = true
|
||||||
end
|
end
|
||||||
# If fitting event is not found
|
# If fitting event is not found
|
||||||
if result == false
|
if result == false && $game_map.counter?(new_x, new_y)
|
||||||
# If front tile is a counter
|
# Calculate coordinates of 1 tile further away
|
||||||
if $game_map.counter?(new_x, new_y)
|
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
|
||||||
# Calculate coordinates of 1 tile further away
|
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
|
||||||
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
|
return false if !$game_map.valid?(new_x, new_y)
|
||||||
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
|
# All event loops
|
||||||
return false if !$game_map.valid?(new_x, new_y)
|
$game_map.events.values.each do |event|
|
||||||
# All event loops
|
next if !triggers.include?(event.trigger)
|
||||||
$game_map.events.values.each do |event|
|
# If event coordinates and triggers are consistent
|
||||||
# If event coordinates and triggers are consistent
|
next if !event.at_coordinate?(new_x, new_y)
|
||||||
next if !event.at_coordinate?(new_x, new_y)
|
# If starting determinant is front event (other than jumping)
|
||||||
next if !triggers.include?(event.trigger)
|
next if event.jumping? || event.over_trigger?
|
||||||
# If starting determinant is front event (other than jumping)
|
event.start
|
||||||
next if event.jumping? || event.over_trigger?
|
result = true
|
||||||
event.start
|
|
||||||
result = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
@@ -559,11 +554,10 @@ end
|
|||||||
def pbGetPlayerCharset(charset, trainer = nil, force = false)
|
def pbGetPlayerCharset(charset, trainer = nil, force = false)
|
||||||
trainer = $player if !trainer
|
trainer = $player if !trainer
|
||||||
outfit = (trainer) ? trainer.outfit : 0
|
outfit = (trainer) ? trainer.outfit : 0
|
||||||
if $game_player && $game_player.charsetData && !force
|
return nil if !force && $game_player&.charsetData &&
|
||||||
return nil if $game_player.charsetData[0] == trainer.character_ID &&
|
$game_player.charsetData[0] == trainer.character_ID &&
|
||||||
$game_player.charsetData[1] == charset &&
|
$game_player.charsetData[1] == charset &&
|
||||||
$game_player.charsetData[2] == outfit
|
$game_player.charsetData[2] == outfit
|
||||||
end
|
|
||||||
$game_player.charsetData = [trainer.character_ID, charset, outfit] if $game_player
|
$game_player.charsetData = [trainer.character_ID, charset, outfit] if $game_player
|
||||||
ret = charset
|
ret = charset
|
||||||
if pbResolveBitmap("Graphics/Characters/" + ret + "_" + outfit.to_s)
|
if pbResolveBitmap("Graphics/Characters/" + ret + "_" + outfit.to_s)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class Game_CommonEvent
|
|||||||
def refresh
|
def refresh
|
||||||
# Create an interpreter for parallel process if necessary
|
# Create an interpreter for parallel process if necessary
|
||||||
if self.trigger == 2 && switchIsOn?(self.switch_id)
|
if self.trigger == 2 && switchIsOn?(self.switch_id)
|
||||||
if @interpreter == nil
|
if @interpreter.nil?
|
||||||
@interpreter = Interpreter.new
|
@interpreter = Interpreter.new
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ class Sprite_Picture
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@sprite.dispose if @sprite
|
@sprite&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@sprite.update if @sprite
|
@sprite&.update
|
||||||
# If picture file name is different from current one
|
# If picture file name is different from current one
|
||||||
if @picture_name != @picture.name
|
if @picture_name != @picture.name
|
||||||
# Remember file name to instance variables
|
# Remember file name to instance variables
|
||||||
@@ -27,7 +27,7 @@ class Sprite_Picture
|
|||||||
if @picture_name == ""
|
if @picture_name == ""
|
||||||
# Set sprite to invisible
|
# Set sprite to invisible
|
||||||
if @sprite
|
if @sprite
|
||||||
@sprite.dispose if @sprite
|
@sprite&.dispose
|
||||||
@sprite = nil
|
@sprite = nil
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class Sprite_Timer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@timer.dispose if @timer
|
@timer&.dispose
|
||||||
@timer = nil
|
@timer = nil
|
||||||
@disposed = true
|
@disposed = true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class BushBitmap
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@bitmaps.each { |b| b.dispose if b }
|
@bitmaps.each { |b| b&.dispose }
|
||||||
end
|
end
|
||||||
|
|
||||||
def bitmap
|
def bitmap
|
||||||
@@ -80,13 +80,13 @@ class Sprite_Character < RPG::Sprite
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@bushbitmap.dispose if @bushbitmap
|
@bushbitmap&.dispose
|
||||||
@bushbitmap = nil
|
@bushbitmap = nil
|
||||||
@charbitmap.dispose if @charbitmap
|
@charbitmap&.dispose
|
||||||
@charbitmap = nil
|
@charbitmap = nil
|
||||||
@reflection.dispose if @reflection
|
@reflection&.dispose
|
||||||
@reflection = nil
|
@reflection = nil
|
||||||
@surfbase.dispose if @surfbase
|
@surfbase&.dispose
|
||||||
@surfbase = nil
|
@surfbase = nil
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@@ -102,12 +102,12 @@ class Sprite_Character < RPG::Sprite
|
|||||||
@character_name = @character.character_name
|
@character_name = @character.character_name
|
||||||
@character_hue = @character.character_hue
|
@character_hue = @character.character_hue
|
||||||
@oldbushdepth = @character.bush_depth
|
@oldbushdepth = @character.bush_depth
|
||||||
@charbitmap.dispose if @charbitmap
|
@charbitmap&.dispose
|
||||||
if @tile_id >= 384
|
if @tile_id >= 384
|
||||||
@charbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id,
|
@charbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id,
|
||||||
@character_hue, @character.width, @character.height)
|
@character_hue, @character.width, @character.height)
|
||||||
@charbitmapAnimated = false
|
@charbitmapAnimated = false
|
||||||
@bushbitmap.dispose if @bushbitmap
|
@bushbitmap&.dispose
|
||||||
@bushbitmap = nil
|
@bushbitmap = nil
|
||||||
@spriteoffset = false
|
@spriteoffset = false
|
||||||
@cw = Game_Map::TILE_WIDTH * @character.width
|
@cw = Game_Map::TILE_WIDTH * @character.width
|
||||||
@@ -121,7 +121,7 @@ class Sprite_Character < RPG::Sprite
|
|||||||
)
|
)
|
||||||
RPG::Cache.retain('Graphics/Characters/', @character_name, @character_hue) if @character == $game_player
|
RPG::Cache.retain('Graphics/Characters/', @character_name, @character_hue) if @character == $game_player
|
||||||
@charbitmapAnimated = true
|
@charbitmapAnimated = true
|
||||||
@bushbitmap.dispose if @bushbitmap
|
@bushbitmap&.dispose
|
||||||
@bushbitmap = nil
|
@bushbitmap = nil
|
||||||
@spriteoffset = @character_name[/offset/i]
|
@spriteoffset = @character_name[/offset/i]
|
||||||
@cw = @charbitmap.width / 4
|
@cw = @charbitmap.width / 4
|
||||||
@@ -163,7 +163,7 @@ class Sprite_Character < RPG::Sprite
|
|||||||
animation(animation, true)
|
animation(animation, true)
|
||||||
@character.animation_id = 0
|
@character.animation_id = 0
|
||||||
end
|
end
|
||||||
@reflection.update if @reflection
|
@reflection&.update
|
||||||
@surfbase.update if @surfbase
|
@surfbase&.update
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ class Sprite_Reflection
|
|||||||
@event = event
|
@event = event
|
||||||
@height = 0
|
@height = 0
|
||||||
@fixedheight = false
|
@fixedheight = false
|
||||||
if @event && @event != $game_player
|
if @event != $game_player && @event&.name[/reflection\((\d+)\)/i]
|
||||||
if @event.name[/reflection\((\d+)\)/i]
|
@height = $~[1].to_i || 0
|
||||||
@height = $~[1].to_i || 0
|
@fixedheight = true
|
||||||
@fixedheight = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@viewport = viewport
|
@viewport = viewport
|
||||||
@disposed = false
|
@disposed = false
|
||||||
@@ -21,7 +19,7 @@ class Sprite_Reflection
|
|||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
if !@disposed
|
if !@disposed
|
||||||
@sprite.dispose if @sprite
|
@sprite&.dispose
|
||||||
@sprite = nil
|
@sprite = nil
|
||||||
@disposed = true
|
@disposed = true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Sprite_SurfBase
|
|||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
return if @disposed
|
return if @disposed
|
||||||
@sprite.dispose if @sprite
|
@sprite&.dispose
|
||||||
@sprite = nil
|
@sprite = nil
|
||||||
@surfbitmap.dispose
|
@surfbitmap.dispose
|
||||||
@divebitmap.dispose
|
@divebitmap.dispose
|
||||||
|
|||||||
@@ -122,10 +122,10 @@ class Spriteset_Map
|
|||||||
@character_sprites.each do |sprite|
|
@character_sprites.each do |sprite|
|
||||||
sprite.update
|
sprite.update
|
||||||
end
|
end
|
||||||
if self.map != $game_map
|
if self.map == $game_map
|
||||||
@weather.fade_in(:None, 0, 20)
|
|
||||||
else
|
|
||||||
@weather.fade_in($game_screen.weather_type, $game_screen.weather_max, $game_screen.weather_duration)
|
@weather.fade_in($game_screen.weather_type, $game_screen.weather_max, $game_screen.weather_duration)
|
||||||
|
else
|
||||||
|
@weather.fade_in(:None, 0, 20)
|
||||||
end
|
end
|
||||||
@weather.ox = tmox
|
@weather.ox = tmox
|
||||||
@weather.oy = tmoy
|
@weather.oy = tmoy
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class Sprite_Shadow < RPG::Sprite
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@chbitmap.dispose if @chbitmap
|
@chbitmap&.dispose
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ class Sprite_Shadow < RPG::Sprite
|
|||||||
@tile_id = @character.tile_id
|
@tile_id = @character.tile_id
|
||||||
@character_name = @character.character_name
|
@character_name = @character.character_name
|
||||||
@character_hue = @character.character_hue
|
@character_hue = @character.character_hue
|
||||||
@chbitmap.dispose if @chbitmap
|
@chbitmap&.dispose
|
||||||
if @tile_id >= 384
|
if @tile_id >= 384
|
||||||
@chbitmap = pbGetTileBitmap(@character.map.tileset_name,
|
@chbitmap = pbGetTileBitmap(@character.map.tileset_name,
|
||||||
@tile_id, @character.character_hue)
|
@tile_id, @character.character_hue)
|
||||||
@@ -89,7 +89,7 @@ class Sprite_Shadow < RPG::Sprite
|
|||||||
@deltay = ScreenPosHelper.pbScreenY(@source) - self.y
|
@deltay = ScreenPosHelper.pbScreenY(@source) - self.y
|
||||||
self.color = Color.new(0, 0, 0)
|
self.color = Color.new(0, 0, 0)
|
||||||
@distance = ((@deltax**2) + (@deltay**2))
|
@distance = ((@deltax**2) + (@deltay**2))
|
||||||
self.opacity = @self_opacity * 13000 / ((@distance * 370 / @distancemax) + 6000)
|
self.opacity = @self_opacity * 13_000 / ((@distance * 370 / @distancemax) + 6000)
|
||||||
self.angle = 57.3 * Math.atan2(@deltax, @deltay)
|
self.angle = 57.3 * Math.atan2(@deltax, @deltay)
|
||||||
@angle_trigo = self.angle + 90
|
@angle_trigo = self.angle + 90
|
||||||
@angle_trigo += 360 if @angle_trigo < 0
|
@angle_trigo += 360 if @angle_trigo < 0
|
||||||
@@ -149,7 +149,7 @@ class Sprite_Character < RPG::Sprite
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clearShadows
|
def clearShadows
|
||||||
@ombrelist.each { |s| s.dispose if s }
|
@ombrelist.each { |s| s&.dispose }
|
||||||
@ombrelist.clear
|
@ombrelist.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -185,9 +185,8 @@ class Spriteset_Map
|
|||||||
map = $game_map if !map
|
map = $game_map if !map
|
||||||
map.events.keys.sort.each do |k|
|
map.events.keys.sort.each do |k|
|
||||||
ev = map.events[k]
|
ev = map.events[k]
|
||||||
warn = true if (ev.list != nil && ev.list.length > 0 &&
|
warn = true if ev.list != nil && ev.list.length > 0 && ev.list[0].code == 108 &&
|
||||||
ev.list[0].code == 108 &&
|
(ev.list[0].parameters == ["s"] || ev.list[0].parameters == ["o"])
|
||||||
(ev.list[0].parameters == ["s"] || ev.list[0].parameters == ["o"]))
|
|
||||||
params = XPML_read(map, "Shadow Source", ev, 4)
|
params = XPML_read(map, "Shadow Source", ev, 4)
|
||||||
@shadows.push([ev] + params) if params != nil
|
@shadows.push([ev] + params) if params != nil
|
||||||
end
|
end
|
||||||
@@ -225,11 +224,11 @@ end
|
|||||||
#===================================================
|
#===================================================
|
||||||
def XPML_read(map, markup, event, max_param_number = 0)
|
def XPML_read(map, markup, event, max_param_number = 0)
|
||||||
parameter_list = nil
|
parameter_list = nil
|
||||||
return nil if !event || event.list == nil
|
return nil if !event || event.list.nil?
|
||||||
event.list.size.times do |i|
|
event.list.size.times do |i|
|
||||||
if event.list[i].code == 108 &&
|
if event.list[i].code == 108 &&
|
||||||
event.list[i].parameters[0].downcase == "begin " + markup.downcase
|
event.list[i].parameters[0].downcase == "begin " + markup.downcase
|
||||||
parameter_list = [] if parameter_list == nil
|
parameter_list = [] if parameter_list.nil?
|
||||||
((i + 1)...event.list.size).each do |j|
|
((i + 1)...event.list.size).each do |j|
|
||||||
if event.list[j].code == 108
|
if event.list[j].code == 108
|
||||||
parts = event.list[j].parameters[0].split
|
parts = event.list[j].parameters[0].split
|
||||||
|
|||||||
@@ -57,17 +57,17 @@ class Particle_Engine
|
|||||||
def realloc_effect(event, particle)
|
def realloc_effect(event, particle)
|
||||||
type = pbEventCommentInput(event, 1, "Particle Engine Type")
|
type = pbEventCommentInput(event, 1, "Particle Engine Type")
|
||||||
if type.nil?
|
if type.nil?
|
||||||
particle.dispose if particle
|
particle&.dispose
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
type = type[0].downcase
|
type = type[0].downcase
|
||||||
cls = @effects[type]
|
cls = @effects[type]
|
||||||
if cls.nil?
|
if cls.nil?
|
||||||
particle.dispose if particle
|
particle&.dispose
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
if !particle || !particle.is_a?(cls)
|
if !particle || !particle.is_a?(cls)
|
||||||
particle.dispose if particle
|
particle&.dispose
|
||||||
particle = cls.new(event, @viewport)
|
particle = cls.new(event, @viewport)
|
||||||
end
|
end
|
||||||
return particle
|
return particle
|
||||||
@@ -93,7 +93,7 @@ class Particle_Engine
|
|||||||
particle = realloc_effect(event, particle)
|
particle = realloc_effect(event, particle)
|
||||||
@effect[i] = particle
|
@effect[i] = particle
|
||||||
end
|
end
|
||||||
particle.update if particle
|
particle&.update
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -135,7 +135,7 @@ class ParticleSprite
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@sprite.dispose if @sprite
|
@sprite&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def bitmap=(value)
|
def bitmap=(value)
|
||||||
@@ -517,9 +517,9 @@ class Particle_Engine::Smokescreen < ParticleEffect_Event
|
|||||||
end
|
end
|
||||||
multiple = 1.7
|
multiple = 1.7
|
||||||
xgrav = @xgravity * multiple / @slowdown
|
xgrav = @xgravity * multiple / @slowdown
|
||||||
xgrav = -xgrav if (rand(2) == 1)
|
xgrav = -xgrav if rand(2) == 1
|
||||||
ygrav = @ygravity * multiple / @slowdown
|
ygrav = @ygravity * multiple / @slowdown
|
||||||
ygrav = -ygrav if (rand(2) == 1)
|
ygrav = -ygrav if rand(2) == 1
|
||||||
@particlex[i] += xgrav
|
@particlex[i] += xgrav
|
||||||
@particley[i] += ygrav
|
@particley[i] += ygrav
|
||||||
@particlex[i] -= @__offsetx
|
@particlex[i] -= @__offsetx
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ module ScreenPosHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.pbScreenZ(ch, height = nil)
|
def self.pbScreenZ(ch, height = nil)
|
||||||
if height == nil
|
if height.nil?
|
||||||
height = 0
|
height = 0
|
||||||
if ch.tile_id > 0
|
if ch.tile_id > 0
|
||||||
height = 32
|
height = 32
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ class TilemapRenderer
|
|||||||
bitmap = @bitmaps[filename]
|
bitmap = @bitmaps[filename]
|
||||||
@frame_counts[filename] = [bitmap.width / SOURCE_TILE_WIDTH, 1].max
|
@frame_counts[filename] = [bitmap.width / SOURCE_TILE_WIDTH, 1].max
|
||||||
if bitmap.height > SOURCE_TILE_HEIGHT && @bitmap_wraps[filename]
|
if bitmap.height > SOURCE_TILE_HEIGHT && @bitmap_wraps[filename]
|
||||||
@frame_counts[filename] /= 2 if @bitmap_wraps[filename]
|
@frame_counts[filename] /= 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return @frame_counts[filename]
|
return @frame_counts[filename]
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class TileDrawingHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@tileset.dispose if @tileset
|
@tileset&.dispose
|
||||||
@tileset = nil
|
@tileset = nil
|
||||||
@autotiles.each_with_index do |autotile, i|
|
@autotiles.each_with_index do |autotile, i|
|
||||||
autotile.dispose
|
autotile.dispose
|
||||||
@@ -187,7 +187,7 @@ def bltMinimapAutotile(dstBitmap, x, y, srcBitmap, id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def passable?(passages, tile_id)
|
def passable?(passages, tile_id)
|
||||||
return false if tile_id == nil
|
return false if tile_id.nil?
|
||||||
passage = passages[tile_id]
|
passage = passages[tile_id]
|
||||||
return (passage && passage < 15)
|
return (passage && passage < 15)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ module RPG
|
|||||||
def self.fromCache(i)
|
def self.fromCache(i)
|
||||||
return nil if !@cache.include?(i)
|
return nil if !@cache.include?(i)
|
||||||
obj = @cache[i]
|
obj = @cache[i]
|
||||||
return nil if obj && obj.disposed?
|
return nil if obj&.disposed?
|
||||||
return obj
|
return obj
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -177,7 +177,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 || 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
|
||||||
@@ -393,10 +393,10 @@ end
|
|||||||
def pbDoEnsureBitmap(bitmap, dwidth, dheight)
|
def pbDoEnsureBitmap(bitmap, dwidth, dheight)
|
||||||
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
|
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
|
||||||
oldfont = (bitmap && !bitmap.disposed?) ? bitmap.font : nil
|
oldfont = (bitmap && !bitmap.disposed?) ? bitmap.font : nil
|
||||||
bitmap.dispose if bitmap
|
bitmap&.dispose
|
||||||
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
|
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
|
||||||
(oldfont) ? bitmap.font = oldfont : pbSetSystemFont(bitmap)
|
(oldfont) ? bitmap.font = oldfont : pbSetSystemFont(bitmap)
|
||||||
bitmap.font.shadow = false if bitmap.font && bitmap.font.respond_to?("shadow")
|
bitmap.font.shadow = false if bitmap.font&.respond_to?("shadow")
|
||||||
end
|
end
|
||||||
return bitmap
|
return bitmap
|
||||||
end
|
end
|
||||||
@@ -666,7 +666,7 @@ end
|
|||||||
def pbRestoreActivations(sprites, activeStatuses)
|
def pbRestoreActivations(sprites, activeStatuses)
|
||||||
return if !sprites || !activeStatuses
|
return if !sprites || !activeStatuses
|
||||||
activeStatuses.keys.each do |k|
|
activeStatuses.keys.each do |k|
|
||||||
if sprites[k] && sprites[k].is_a?(Window) && !pbDisposed?(sprites[k])
|
if sprites[k].is_a?(Window) && !pbDisposed?(sprites[k])
|
||||||
sprites[k].active = activeStatuses[k] ? true : false
|
sprites[k].active = activeStatuses[k] ? true : false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -689,7 +689,7 @@ def pbActivateWindow(sprites, key)
|
|||||||
return if !sprites
|
return if !sprites
|
||||||
activeStatuses = {}
|
activeStatuses = {}
|
||||||
sprites.each do |i|
|
sprites.each do |i|
|
||||||
if i[1] && i[1].is_a?(Window) && !pbDisposed?(i[1])
|
if i[1].is_a?(Window) && !pbDisposed?(i[1])
|
||||||
activeStatuses[i[0]] = i[1].active
|
activeStatuses[i[0]] = i[1].active
|
||||||
i[1].active = (i[0] == key)
|
i[1].active = (i[0] == key)
|
||||||
end
|
end
|
||||||
@@ -717,7 +717,7 @@ end
|
|||||||
def addBackgroundPlane(sprites, planename, background, viewport = nil)
|
def addBackgroundPlane(sprites, planename, background, viewport = nil)
|
||||||
sprites[planename] = AnimatedPlane.new(viewport)
|
sprites[planename] = AnimatedPlane.new(viewport)
|
||||||
bitmapName = pbResolveBitmap("Graphics/Pictures/#{background}")
|
bitmapName = pbResolveBitmap("Graphics/Pictures/#{background}")
|
||||||
if bitmapName == nil
|
if bitmapName.nil?
|
||||||
# Plane should exist in any case
|
# Plane should exist in any case
|
||||||
sprites[planename].bitmap = nil
|
sprites[planename].bitmap = nil
|
||||||
sprites[planename].visible = false
|
sprites[planename].visible = false
|
||||||
@@ -739,7 +739,7 @@ end
|
|||||||
# _viewport_ is a viewport to place the background in.
|
# _viewport_ is a viewport to place the background in.
|
||||||
def addBackgroundOrColoredPlane(sprites, planename, background, color, viewport = nil)
|
def addBackgroundOrColoredPlane(sprites, planename, background, color, viewport = nil)
|
||||||
bitmapName = pbResolveBitmap("Graphics/Pictures/#{background}")
|
bitmapName = pbResolveBitmap("Graphics/Pictures/#{background}")
|
||||||
if bitmapName == nil
|
if bitmapName.nil?
|
||||||
# Plane should exist in any case
|
# Plane should exist in any case
|
||||||
sprites[planename] = ColoredPlane.new(color, viewport)
|
sprites[planename] = ColoredPlane.new(color, viewport)
|
||||||
else
|
else
|
||||||
@@ -773,7 +773,7 @@ if !defined?(_INTL)
|
|||||||
def _INTL(*args)
|
def _INTL(*args)
|
||||||
string = args[0].clone
|
string = args[0].clone
|
||||||
(1...args.length).each do |i|
|
(1...args.length).each do |i|
|
||||||
string.gsub!(/\{#{i}\}/, "#{args[i]}")
|
string.gsub!(/\{#{i}\}/, args[i].to_s)
|
||||||
end
|
end
|
||||||
return string
|
return string
|
||||||
end
|
end
|
||||||
@@ -795,7 +795,7 @@ if !defined?(_MAPINTL)
|
|||||||
def _MAPINTL(*args)
|
def _MAPINTL(*args)
|
||||||
string = args[1].clone
|
string = args[1].clone
|
||||||
(2...args.length).each do |i|
|
(2...args.length).each do |i|
|
||||||
string.gsub!(/\{#{i}\}/, "#{args[i + 1]}")
|
string.gsub!(/\{#{i}\}/, args[i + 1].to_s)
|
||||||
end
|
end
|
||||||
return string
|
return string
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -127,16 +127,16 @@ class Window
|
|||||||
def dispose
|
def dispose
|
||||||
if !self.disposed?
|
if !self.disposed?
|
||||||
@sprites.each do |i|
|
@sprites.each do |i|
|
||||||
i[1].dispose if i[1]
|
i[1]&.dispose
|
||||||
@sprites[i[0]] = nil
|
@sprites[i[0]] = nil
|
||||||
end
|
end
|
||||||
@sidebitmaps.each_with_index do |bitmap, i|
|
@sidebitmaps.each_with_index do |bitmap, i|
|
||||||
bitmap.dispose if bitmap
|
bitmap&.dispose
|
||||||
@sidebitmaps[i] = nil
|
@sidebitmaps[i] = nil
|
||||||
end
|
end
|
||||||
@blankcontents.dispose
|
@blankcontents.dispose
|
||||||
@cursorbitmap.dispose if @cursorbitmap
|
@cursorbitmap&.dispose
|
||||||
@backbitmap.dispose if @backbitmap
|
@backbitmap&.dispose
|
||||||
@sprites.clear
|
@sprites.clear
|
||||||
@sidebitmaps.clear
|
@sidebitmaps.clear
|
||||||
@_windowskin = nil
|
@_windowskin = nil
|
||||||
@@ -191,7 +191,7 @@ class Window
|
|||||||
|
|
||||||
def windowskin=(value)
|
def windowskin=(value)
|
||||||
@_windowskin = value
|
@_windowskin = value
|
||||||
if value && value.is_a?(Bitmap) && !value.disposed? && value.width == 128
|
if value.is_a?(Bitmap) && !value.disposed? && value.width == 128
|
||||||
@rpgvx = true
|
@rpgvx = true
|
||||||
else
|
else
|
||||||
@rpgvx = false
|
@rpgvx = false
|
||||||
@@ -210,10 +210,10 @@ class Window
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cursor_rect=(value)
|
def cursor_rect=(value)
|
||||||
if !value
|
if value
|
||||||
@cursor_rect.empty
|
|
||||||
else
|
|
||||||
@cursor_rect.set(value.x, value.y, value.width, value.height)
|
@cursor_rect.set(value.x, value.y, value.width, value.height)
|
||||||
|
else
|
||||||
|
@cursor_rect.empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -322,7 +322,7 @@ class Window
|
|||||||
|
|
||||||
def ensureBitmap(bitmap, dwidth, dheight)
|
def ensureBitmap(bitmap, dwidth, dheight)
|
||||||
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
|
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
|
||||||
bitmap.dispose if bitmap
|
bitmap&.dispose
|
||||||
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
|
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
|
||||||
end
|
end
|
||||||
return bitmap
|
return bitmap
|
||||||
@@ -571,7 +571,12 @@ class Window
|
|||||||
@sprites["back"].src_rect.set(0, 0, 0, 0)
|
@sprites["back"].src_rect.set(0, 0, 0, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if @openness != 255
|
if @openness == 255
|
||||||
|
@spritekeys.each do |k|
|
||||||
|
sprite = @sprites[k]
|
||||||
|
sprite.zoom_y = 1.0
|
||||||
|
end
|
||||||
|
else
|
||||||
opn = @openness / 255.0
|
opn = @openness / 255.0
|
||||||
@spritekeys.each do |k|
|
@spritekeys.each do |k|
|
||||||
sprite = @sprites[k]
|
sprite = @sprites[k]
|
||||||
@@ -580,11 +585,6 @@ class Window
|
|||||||
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
|
||||||
end
|
end
|
||||||
else
|
|
||||||
@spritekeys.each do |k|
|
|
||||||
sprite = @sprites[k]
|
|
||||||
sprite.zoom_y = 1.0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
i = 0
|
i = 0
|
||||||
# Ensure Z order
|
# Ensure Z order
|
||||||
|
|||||||
@@ -113,16 +113,16 @@ class SpriteWindow < Window
|
|||||||
def dispose
|
def dispose
|
||||||
if !self.disposed?
|
if !self.disposed?
|
||||||
@sprites.each do |i|
|
@sprites.each do |i|
|
||||||
i[1].dispose if i[1]
|
i[1]&.dispose
|
||||||
@sprites[i[0]] = nil
|
@sprites[i[0]] = nil
|
||||||
end
|
end
|
||||||
@sidebitmaps.each_with_index do |bitmap, i|
|
@sidebitmaps.each_with_index do |bitmap, i|
|
||||||
bitmap.dispose if bitmap
|
bitmap&.dispose
|
||||||
@sidebitmaps[i] = nil
|
@sidebitmaps[i] = nil
|
||||||
end
|
end
|
||||||
@blankcontents.dispose
|
@blankcontents.dispose
|
||||||
@cursorbitmap.dispose if @cursorbitmap
|
@cursorbitmap&.dispose
|
||||||
@backbitmap.dispose if @backbitmap
|
@backbitmap&.dispose
|
||||||
@sprites.clear
|
@sprites.clear
|
||||||
@sidebitmaps.clear
|
@sidebitmaps.clear
|
||||||
@_windowskin = nil
|
@_windowskin = nil
|
||||||
@@ -143,7 +143,7 @@ class SpriteWindow < Window
|
|||||||
def viewport=(value)
|
def viewport=(value)
|
||||||
@viewport = value
|
@viewport = value
|
||||||
@spritekeys.each do |i|
|
@spritekeys.each do |i|
|
||||||
@sprites[i].dispose if @sprites[i]
|
@sprites[i]&.dispose
|
||||||
if @sprites[i].is_a?(Sprite)
|
if @sprites[i].is_a?(Sprite)
|
||||||
@sprites[i] = Sprite.new(@viewport)
|
@sprites[i] = Sprite.new(@viewport)
|
||||||
else
|
else
|
||||||
@@ -189,10 +189,10 @@ class SpriteWindow < Window
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cursor_rect=(value)
|
def cursor_rect=(value)
|
||||||
if !value
|
if value
|
||||||
@cursor_rect.empty
|
|
||||||
else
|
|
||||||
@cursor_rect.set(value.x, value.y, value.width, value.height)
|
@cursor_rect.set(value.x, value.y, value.width, value.height)
|
||||||
|
else
|
||||||
|
@cursor_rect.empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ class SpriteWindow < Window
|
|||||||
@trim = [16, 16, 16, 16]
|
@trim = [16, 16, 16, 16]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if value && value.is_a?(Bitmap) && !value.disposed? && value.width == 128
|
if value.is_a?(Bitmap) && !value.disposed? && value.width == 128
|
||||||
@rpgvx = true
|
@rpgvx = true
|
||||||
else
|
else
|
||||||
@rpgvx = false
|
@rpgvx = false
|
||||||
@@ -442,7 +442,7 @@ class SpriteWindow < Window
|
|||||||
|
|
||||||
def ensureBitmap(bitmap, dwidth, dheight)
|
def ensureBitmap(bitmap, dwidth, dheight)
|
||||||
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
|
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
|
||||||
bitmap.dispose if bitmap
|
bitmap&.dispose
|
||||||
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
|
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
|
||||||
end
|
end
|
||||||
return bitmap
|
return bitmap
|
||||||
@@ -631,15 +631,13 @@ class SpriteWindow < Window
|
|||||||
end
|
end
|
||||||
@sprites["contents"].x = @x + trimStartX
|
@sprites["contents"].x = @x + trimStartX
|
||||||
@sprites["contents"].y = @y + trimStartY
|
@sprites["contents"].y = @y + trimStartY
|
||||||
if (@compat & CompatBits::ShowScrollArrows) > 0 && @skinformat == 0
|
if (@compat & CompatBits::ShowScrollArrows) > 0 && @skinformat == 0 &&
|
||||||
# Compatibility mode: Make scroll arrows visible
|
@_windowskin && !@_windowskin.disposed? &&
|
||||||
if @skinformat == 0 && @_windowskin && !@_windowskin.disposed? &&
|
@contents && !@contents.disposed?
|
||||||
@contents && !@contents.disposed?
|
@sprites["scroll0"].visible = @visible && hascontents && @oy > 0
|
||||||
@sprites["scroll0"].visible = @visible && hascontents && @oy > 0
|
@sprites["scroll1"].visible = @visible && hascontents && @ox > 0
|
||||||
@sprites["scroll1"].visible = @visible && hascontents && @ox > 0
|
@sprites["scroll2"].visible = @visible && (@contents.width - @ox) > @width - trimWidth
|
||||||
@sprites["scroll2"].visible = @visible && (@contents.width - @ox) > @width - trimWidth
|
@sprites["scroll3"].visible = @visible && (@contents.height - @oy) > @height - trimHeight
|
||||||
@sprites["scroll3"].visible = @visible && (@contents.height - @oy) > @height - trimHeight
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if @_windowskin && !@_windowskin.disposed?
|
if @_windowskin && !@_windowskin.disposed?
|
||||||
borderX = startX + endX
|
borderX = startX + endX
|
||||||
@@ -781,7 +779,13 @@ class SpriteWindow < Window
|
|||||||
@sprites["back"].src_rect.set(0, 0, 0, 0)
|
@sprites["back"].src_rect.set(0, 0, 0, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if @openness != 255
|
if @openness == 255
|
||||||
|
@spritekeys.each do |k|
|
||||||
|
sprite = @sprites[k]
|
||||||
|
sprite.zoom_x = 1.0
|
||||||
|
sprite.zoom_y = 1.0
|
||||||
|
end
|
||||||
|
else
|
||||||
opn = @openness / 255.0
|
opn = @openness / 255.0
|
||||||
@spritekeys.each do |k|
|
@spritekeys.each do |k|
|
||||||
sprite = @sprites[k]
|
sprite = @sprites[k]
|
||||||
@@ -791,12 +795,6 @@ class SpriteWindow < Window
|
|||||||
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
|
||||||
end
|
end
|
||||||
else
|
|
||||||
@spritekeys.each do |k|
|
|
||||||
sprite = @sprites[k]
|
|
||||||
sprite.zoom_x = 1.0
|
|
||||||
sprite.zoom_y = 1.0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
i = 0
|
i = 0
|
||||||
# Ensure Z order
|
# Ensure Z order
|
||||||
@@ -861,7 +859,7 @@ class SpriteWindow_Base < SpriteWindow
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setSkin(skin) # Filename of windowskin to apply. Supports XP, VX, and animated skins.
|
def setSkin(skin) # Filename of windowskin to apply. Supports XP, VX, and animated skins.
|
||||||
@customskin.dispose if @customskin
|
@customskin&.dispose
|
||||||
@customskin = nil
|
@customskin = nil
|
||||||
resolvedName = pbResolveBitmap(skin)
|
resolvedName = pbResolveBitmap(skin)
|
||||||
return if nil_or_empty?(resolvedName)
|
return if nil_or_empty?(resolvedName)
|
||||||
@@ -875,7 +873,7 @@ class SpriteWindow_Base < SpriteWindow
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setSystemFrame
|
def setSystemFrame
|
||||||
@customskin.dispose if @customskin
|
@customskin&.dispose
|
||||||
@customskin = nil
|
@customskin = nil
|
||||||
__setWindowskin(@sysframe.bitmap)
|
__setWindowskin(@sysframe.bitmap)
|
||||||
__resolveSystemFrame
|
__resolveSystemFrame
|
||||||
@@ -899,7 +897,7 @@ class SpriteWindow_Base < SpriteWindow
|
|||||||
if @curframe != MessageConfig.pbGetSystemFrame
|
if @curframe != MessageConfig.pbGetSystemFrame
|
||||||
@curframe = MessageConfig.pbGetSystemFrame
|
@curframe = MessageConfig.pbGetSystemFrame
|
||||||
if @sysframe && !@customskin
|
if @sysframe && !@customskin
|
||||||
@sysframe.dispose if @sysframe
|
@sysframe&.dispose
|
||||||
@sysframe = AnimatedBitmap.new(@curframe)
|
@sysframe = AnimatedBitmap.new(@curframe)
|
||||||
RPG::Cache.retain(@curframe) if @curframe && !@curframe.empty?
|
RPG::Cache.retain(@curframe) if @curframe && !@curframe.empty?
|
||||||
@resolvedFrame = nil
|
@resolvedFrame = nil
|
||||||
@@ -924,9 +922,9 @@ class SpriteWindow_Base < SpriteWindow
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
self.contents.dispose if self.contents
|
self.contents&.dispose
|
||||||
@sysframe.dispose
|
@sysframe.dispose
|
||||||
@customskin.dispose if @customskin
|
@customskin&.dispose
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
|||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
return if disposed?
|
return if disposed?
|
||||||
@pausesprite.dispose if @pausesprite
|
@pausesprite&.dispose
|
||||||
@pausesprite = nil
|
@pausesprite = nil
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@@ -490,10 +490,8 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
|||||||
drawSingleFormattedChar(self.contents, @fmtchars[i])
|
drawSingleFormattedChar(self.contents, @fmtchars[i])
|
||||||
@lastDrawnChar = i
|
@lastDrawnChar = i
|
||||||
end
|
end
|
||||||
if !self.letterbyletter
|
# all characters were drawn, reset old font
|
||||||
# all characters were drawn, reset old font
|
self.contents.font = @oldfont if !self.letterbyletter && @oldfont
|
||||||
self.contents.font = @oldfont if @oldfont
|
|
||||||
end
|
|
||||||
if numchars > 0 && numchars != @numtextchars
|
if numchars > 0 && numchars != @numtextchars
|
||||||
fch = @fmtchars[numchars - 1]
|
fch = @fmtchars[numchars - 1]
|
||||||
if fch
|
if fch
|
||||||
@@ -579,7 +577,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
super
|
super
|
||||||
@pausesprite.update if @pausesprite && @pausesprite.visible
|
@pausesprite.update if @pausesprite&.visible
|
||||||
if @waitcount > 0
|
if @waitcount > 0
|
||||||
@waitcount -= 1
|
@waitcount -= 1
|
||||||
return
|
return
|
||||||
@@ -601,7 +599,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
|||||||
break if @textchars[@curchar] == "\n" || # newline
|
break if @textchars[@curchar] == "\n" || # newline
|
||||||
@textchars[@curchar] == "\1" || # pause
|
@textchars[@curchar] == "\1" || # pause
|
||||||
@textchars[@curchar] == "\2" || # letter-by-letter break
|
@textchars[@curchar] == "\2" || # letter-by-letter break
|
||||||
@textchars[@curchar] == nil
|
@textchars[@curchar].nil?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class IconWindow < SpriteWindow_Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clearBitmaps
|
def clearBitmaps
|
||||||
@_iconbitmap.dispose if @_iconbitmap
|
@_iconbitmap&.dispose
|
||||||
@_iconbitmap = nil
|
@_iconbitmap = nil
|
||||||
self.contents = nil if !self.disposed?
|
self.contents = nil if !self.disposed?
|
||||||
end
|
end
|
||||||
@@ -40,13 +40,13 @@ class IconWindow < SpriteWindow_Base
|
|||||||
def setBitmap(file, hue = 0)
|
def setBitmap(file, hue = 0)
|
||||||
clearBitmaps
|
clearBitmaps
|
||||||
@name = file
|
@name = file
|
||||||
return if file == nil
|
return if file.nil?
|
||||||
if file != ""
|
if file == ""
|
||||||
|
@_iconbitmap = nil
|
||||||
|
else
|
||||||
@_iconbitmap = AnimatedBitmap.new(file, hue)
|
@_iconbitmap = AnimatedBitmap.new(file, hue)
|
||||||
# for compatibility
|
# for compatibility
|
||||||
self.contents = @_iconbitmap ? @_iconbitmap.bitmap : nil
|
self.contents = @_iconbitmap ? @_iconbitmap.bitmap : nil
|
||||||
else
|
|
||||||
@_iconbitmap = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -84,7 +84,7 @@ class PictureWindow < SpriteWindow_Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clearBitmaps
|
def clearBitmaps
|
||||||
@_iconbitmap.dispose if @_iconbitmap
|
@_iconbitmap&.dispose
|
||||||
@_iconbitmap = nil
|
@_iconbitmap = nil
|
||||||
self.contents = nil if !self.disposed?
|
self.contents = nil if !self.disposed?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -280,19 +280,19 @@ class IconSprite < SpriteWrapper
|
|||||||
oldrc = self.src_rect
|
oldrc = self.src_rect
|
||||||
clearBitmaps
|
clearBitmaps
|
||||||
@name = file
|
@name = file
|
||||||
return if file == nil
|
return if file.nil?
|
||||||
if file != ""
|
if file == ""
|
||||||
|
@_iconbitmap = nil
|
||||||
|
else
|
||||||
@_iconbitmap = AnimatedBitmap.new(file, hue)
|
@_iconbitmap = AnimatedBitmap.new(file, hue)
|
||||||
# for compatibility
|
# for compatibility
|
||||||
self.bitmap = @_iconbitmap ? @_iconbitmap.bitmap : nil
|
self.bitmap = @_iconbitmap ? @_iconbitmap.bitmap : nil
|
||||||
self.src_rect = oldrc
|
self.src_rect = oldrc
|
||||||
else
|
|
||||||
@_iconbitmap = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def clearBitmaps
|
def clearBitmaps
|
||||||
@_iconbitmap.dispose if @_iconbitmap
|
@_iconbitmap&.dispose
|
||||||
@_iconbitmap = nil
|
@_iconbitmap = nil
|
||||||
self.bitmap = nil if !self.disposed?
|
self.bitmap = nil if !self.disposed?
|
||||||
end
|
end
|
||||||
@@ -336,7 +336,7 @@ class ChangelingSprite < SpriteWrapper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def addBitmap(key, path)
|
def addBitmap(key, path)
|
||||||
@bitmaps[key].dispose if @bitmaps[key]
|
@bitmaps[key]&.dispose
|
||||||
@bitmaps[key] = AnimatedBitmap.new(path)
|
@bitmaps[key] = AnimatedBitmap.new(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ColoredPlane < Plane
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
self.bitmap.dispose if self.bitmap
|
self.bitmap&.dispose
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ class AnimatedPlane < Plane
|
|||||||
private
|
private
|
||||||
|
|
||||||
def clear_bitmap
|
def clear_bitmap
|
||||||
@bitmap.dispose if @bitmap
|
@bitmap&.dispose
|
||||||
@bitmap = nil
|
@bitmap = nil
|
||||||
self.bitmap = nil if !self.disposed?
|
self.bitmap = nil if !self.disposed?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheig
|
|||||||
characters = []
|
characters = []
|
||||||
textchunks = []
|
textchunks = []
|
||||||
textchunks.push(text)
|
textchunks.push(text)
|
||||||
text = textchunks.join("")
|
text = textchunks.join
|
||||||
textchars = text.scan(/./m)
|
textchars = text.scan(/./m)
|
||||||
lastword = [0, 0] # position of last word
|
lastword = [0, 0] # position of last word
|
||||||
hadspace = false
|
hadspace = false
|
||||||
@@ -406,7 +406,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
|
|||||||
if controls.length == 0
|
if controls.length == 0
|
||||||
ret = getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight,
|
ret = getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight,
|
||||||
newlineBreaks, explicitBreaksOnly)
|
newlineBreaks, explicitBreaksOnly)
|
||||||
dummybitmap.dispose if dummybitmap
|
dummybitmap&.dispose
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
x = y = 0
|
x = y = 0
|
||||||
@@ -414,7 +414,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
|
|||||||
charactersInternal = []
|
charactersInternal = []
|
||||||
# realtext = nil
|
# realtext = nil
|
||||||
# realtextStart = ""
|
# realtextStart = ""
|
||||||
# if !explicitBreaksOnly && textchunks.join("").length == 0
|
# if !explicitBreaksOnly && textchunks.join.length == 0
|
||||||
# # All commands occurred at the beginning of the text string
|
# # All commands occurred at the beginning of the text string
|
||||||
# realtext = (newlineBreaks) ? text : text.gsub(/\n/, " ")
|
# realtext = (newlineBreaks) ? text : text.gsub(/\n/, " ")
|
||||||
# realtextStart = oldtext[0, oldtext.length - realtext.length]
|
# realtextStart = oldtext[0, oldtext.length - realtext.length]
|
||||||
@@ -432,7 +432,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
|
|||||||
textlen += textchunks[i].scan(/./m).length
|
textlen += textchunks[i].scan(/./m).length
|
||||||
control[2] = textlen
|
control[2] = textlen
|
||||||
end
|
end
|
||||||
text = textchunks.join("")
|
text = textchunks.join
|
||||||
textchars = text.scan(/./m)
|
textchars = text.scan(/./m)
|
||||||
colorstack = []
|
colorstack = []
|
||||||
boldcount = 0
|
boldcount = 0
|
||||||
@@ -830,7 +830,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
|
|||||||
# Remove all characters with Y greater or equal to _yDst_+_heightDst_
|
# Remove all characters with Y greater or equal to _yDst_+_heightDst_
|
||||||
characters.delete_if { |ch| ch[2] >= yDst + heightDst } if heightDst >= 0
|
characters.delete_if { |ch| ch[2] >= yDst + heightDst } if heightDst >= 0
|
||||||
bitmap.font = oldfont
|
bitmap.font = oldfont
|
||||||
dummybitmap.dispose if dummybitmap
|
dummybitmap&.dispose
|
||||||
return characters
|
return characters
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -854,7 +854,7 @@ def getLineBrokenText(bitmap, value, width, dims)
|
|||||||
return ret if !bitmap || bitmap.disposed? || width <= 0
|
return ret if !bitmap || bitmap.disposed? || width <= 0
|
||||||
textmsg = value.clone
|
textmsg = value.clone
|
||||||
ret.push(["", 0, 0, 0, bitmap.text_size("X").height, 0, 0, 0, 0])
|
ret.push(["", 0, 0, 0, bitmap.text_size("X").height, 0, 0, 0, 0])
|
||||||
while ((c = textmsg.slice!(/\n|(\S*([ \r\t\f]?))/)) != nil)
|
while (c = textmsg.slice!(/\n|(\S*([ \r\t\f]?))/)) != nil
|
||||||
break if c == ""
|
break if c == ""
|
||||||
length = c.scan(/./m).length
|
length = c.scan(/./m).length
|
||||||
ccheck = c
|
ccheck = c
|
||||||
@@ -1083,8 +1083,8 @@ def drawTextEx(bitmap, x, y, width, numlines, text, baseColor, shadowColor)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def drawFormattedTextEx(bitmap, x, y, width, text, baseColor = nil, shadowColor = nil, lineheight = 32)
|
def drawFormattedTextEx(bitmap, x, y, width, text, baseColor = nil, shadowColor = nil, lineheight = 32)
|
||||||
base = !baseColor ? Color.new(12 * 8, 12 * 8, 12 * 8) : baseColor.clone
|
base = baseColor ? baseColor.clone : Color.new(12 * 8, 12 * 8, 12 * 8)
|
||||||
shadow = !shadowColor ? Color.new(26 * 8, 26 * 8, 25 * 8) : shadowColor.clone
|
shadow = shadowColor ? shadowColor.clone : Color.new(26 * 8, 26 * 8, 25 * 8)
|
||||||
text = "<c2=" + colorToRgb16(base) + colorToRgb16(shadow) + ">" + text
|
text = "<c2=" + colorToRgb16(base) + colorToRgb16(shadow) + ">" + text
|
||||||
chars = getFormattedText(bitmap, x, y, width, -1, text, lineheight)
|
chars = getFormattedText(bitmap, x, y, width, -1, text, lineheight)
|
||||||
drawFormattedChars(bitmap, chars)
|
drawFormattedChars(bitmap, chars)
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ end
|
|||||||
|
|
||||||
def pbMapInterpreterRunning?
|
def pbMapInterpreterRunning?
|
||||||
interp = pbMapInterpreter
|
interp = pbMapInterpreter
|
||||||
return interp && interp.running?
|
return interp&.running?
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbRefreshSceneMap
|
def pbRefreshSceneMap
|
||||||
$scene.miniupdate if $scene && $scene.is_a?(Scene_Map)
|
$scene.miniupdate if $scene.is_a?(Scene_Map)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbUpdateSceneMap
|
def pbUpdateSceneMap
|
||||||
$scene.miniupdate if $scene && $scene.is_a?(Scene_Map) && !pbIsFaded?
|
$scene.miniupdate if $scene.is_a?(Scene_Map) && !pbIsFaded?
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
@@ -26,7 +26,7 @@ def pbEventCommentInput(*args)
|
|||||||
list = args[0].list # List of commands for event or event page
|
list = args[0].list # List of commands for event or event page
|
||||||
elements = args[1] # Number of elements
|
elements = args[1] # Number of elements
|
||||||
trigger = args[2] # Trigger
|
trigger = args[2] # Trigger
|
||||||
return nil if list == nil
|
return nil if list.nil?
|
||||||
return nil unless list.is_a?(Array)
|
return nil unless list.is_a?(Array)
|
||||||
list.each do |item|
|
list.each do |item|
|
||||||
next unless item.code == 108 || item.code == 408
|
next unless item.code == 108 || item.code == 408
|
||||||
@@ -186,7 +186,7 @@ def pbChooseNumber(msgwindow, params)
|
|||||||
Input.update
|
Input.update
|
||||||
pbUpdateSceneMap
|
pbUpdateSceneMap
|
||||||
cmdwindow.update
|
cmdwindow.update
|
||||||
msgwindow.update if msgwindow
|
msgwindow&.update
|
||||||
yield if block_given?
|
yield if block_given?
|
||||||
if Input.trigger?(Input::USE)
|
if Input.trigger?(Input::USE)
|
||||||
ret = cmdwindow.number
|
ret = cmdwindow.number
|
||||||
@@ -220,7 +220,7 @@ class FaceWindowVX < SpriteWindow_Base
|
|||||||
faceinfo = face.split(",")
|
faceinfo = face.split(",")
|
||||||
facefile = pbResolveBitmap("Graphics/Faces/" + faceinfo[0])
|
facefile = pbResolveBitmap("Graphics/Faces/" + faceinfo[0])
|
||||||
facefile = pbResolveBitmap("Graphics/Pictures/" + faceinfo[0]) if !facefile
|
facefile = pbResolveBitmap("Graphics/Pictures/" + faceinfo[0]) if !facefile
|
||||||
self.contents.dispose if self.contents
|
self.contents&.dispose
|
||||||
@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)
|
||||||
@@ -240,7 +240,7 @@ class FaceWindowVX < SpriteWindow_Base
|
|||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@facebitmaptmp.dispose
|
@facebitmaptmp.dispose
|
||||||
@facebitmap.dispose if @facebitmap
|
@facebitmap&.dispose
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -374,10 +374,10 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbCreateStatusWindow(viewport = nil)
|
def pbCreateStatusWindow(viewport = nil)
|
||||||
msgwindow = Window_AdvancedTextPokemon.new("")
|
msgwindow = Window_AdvancedTextPokemon.new("")
|
||||||
if !viewport
|
if viewport
|
||||||
msgwindow.z = 99999
|
|
||||||
else
|
|
||||||
msgwindow.viewport = viewport
|
msgwindow.viewport = viewport
|
||||||
|
else
|
||||||
|
msgwindow.z = 99999
|
||||||
end
|
end
|
||||||
msgwindow.visible = false
|
msgwindow.visible = false
|
||||||
msgwindow.letterbyletter = false
|
msgwindow.letterbyletter = false
|
||||||
@@ -389,10 +389,10 @@ end
|
|||||||
|
|
||||||
def pbCreateMessageWindow(viewport = nil, skin = nil)
|
def pbCreateMessageWindow(viewport = nil, skin = nil)
|
||||||
msgwindow = Window_AdvancedTextPokemon.new("")
|
msgwindow = Window_AdvancedTextPokemon.new("")
|
||||||
if !viewport
|
if viewport
|
||||||
msgwindow.z = 99999
|
|
||||||
else
|
|
||||||
msgwindow.viewport = viewport
|
msgwindow.viewport = viewport
|
||||||
|
else
|
||||||
|
msgwindow.z = 99999
|
||||||
end
|
end
|
||||||
msgwindow.visible = true
|
msgwindow.visible = true
|
||||||
msgwindow.letterbyletter = true
|
msgwindow.letterbyletter = true
|
||||||
@@ -447,10 +447,10 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
text.gsub!(/\\pm/i, _INTL("${1}", $player.money.to_s_formatted)) if $player
|
text.gsub!(/\\pm/i, _INTL("${1}", $player.money.to_s_formatted)) if $player
|
||||||
text.gsub!(/\\n/i, "\n")
|
text.gsub!(/\\n/i, "\n")
|
||||||
text.gsub!(/\\\[([0-9a-f]{8,8})\]/i) { "<c2=" + $1 + ">" }
|
text.gsub!(/\\\[([0-9a-f]{8,8})\]/i) { "<c2=" + $1 + ">" }
|
||||||
text.gsub!(/\\pg/i, "\\b") if $player && $player.male?
|
text.gsub!(/\\pg/i, "\\b") if $player&.male?
|
||||||
text.gsub!(/\\pg/i, "\\r") if $player && $player.female?
|
text.gsub!(/\\pg/i, "\\r") if $player&.female?
|
||||||
text.gsub!(/\\pog/i, "\\r") if $player && $player.male?
|
text.gsub!(/\\pog/i, "\\r") if $player&.male?
|
||||||
text.gsub!(/\\pog/i, "\\b") if $player && $player.female?
|
text.gsub!(/\\pog/i, "\\b") if $player&.female?
|
||||||
text.gsub!(/\\pg/i, "")
|
text.gsub!(/\\pg/i, "")
|
||||||
text.gsub!(/\\pog/i, "")
|
text.gsub!(/\\pog/i, "")
|
||||||
text.gsub!(/\\b/i, "<c3=3050C8,D0D0C8>")
|
text.gsub!(/\\b/i, "<c3=3050C8,D0D0C8>")
|
||||||
@@ -517,7 +517,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
textlen += toUnformattedText(textchunks[i]).scan(/./m).length
|
textlen += toUnformattedText(textchunks[i]).scan(/./m).length
|
||||||
controls[i][2] = textlen
|
controls[i][2] = textlen
|
||||||
end
|
end
|
||||||
text = textchunks.join("")
|
text = textchunks.join
|
||||||
signWaitCount = 0
|
signWaitCount = 0
|
||||||
signWaitTime = Graphics.frame_rate / 2
|
signWaitTime = Graphics.frame_rate / 2
|
||||||
haveSpecialClose = false
|
haveSpecialClose = false
|
||||||
@@ -534,10 +534,10 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
haveSpecialClose = true
|
haveSpecialClose = true
|
||||||
specialCloseSE = param
|
specialCloseSE = param
|
||||||
when "f"
|
when "f"
|
||||||
facewindow.dispose if facewindow
|
facewindow&.dispose
|
||||||
facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
|
facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
|
||||||
when "ff"
|
when "ff"
|
||||||
facewindow.dispose if facewindow
|
facewindow&.dispose
|
||||||
facewindow = FaceWindowVX.new(param)
|
facewindow = FaceWindowVX.new(param)
|
||||||
when "ch"
|
when "ch"
|
||||||
cmds = param.clone
|
cmds = param.clone
|
||||||
@@ -588,25 +588,25 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
param = controls[i][1]
|
param = controls[i][1]
|
||||||
case control
|
case control
|
||||||
when "f"
|
when "f"
|
||||||
facewindow.dispose if facewindow
|
facewindow&.dispose
|
||||||
facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
|
facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
|
||||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||||
facewindow.viewport = msgwindow.viewport
|
facewindow.viewport = msgwindow.viewport
|
||||||
facewindow.z = msgwindow.z
|
facewindow.z = msgwindow.z
|
||||||
when "ff"
|
when "ff"
|
||||||
facewindow.dispose if facewindow
|
facewindow&.dispose
|
||||||
facewindow = FaceWindowVX.new(param)
|
facewindow = FaceWindowVX.new(param)
|
||||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||||
facewindow.viewport = msgwindow.viewport
|
facewindow.viewport = msgwindow.viewport
|
||||||
facewindow.z = msgwindow.z
|
facewindow.z = msgwindow.z
|
||||||
when "g" # Display gold window
|
when "g" # Display gold window
|
||||||
goldwindow.dispose if goldwindow
|
goldwindow&.dispose
|
||||||
goldwindow = pbDisplayGoldWindow(msgwindow)
|
goldwindow = pbDisplayGoldWindow(msgwindow)
|
||||||
when "cn" # Display coins window
|
when "cn" # Display coins window
|
||||||
coinwindow.dispose if coinwindow
|
coinwindow&.dispose
|
||||||
coinwindow = pbDisplayCoinsWindow(msgwindow, goldwindow)
|
coinwindow = pbDisplayCoinsWindow(msgwindow, goldwindow)
|
||||||
when "pt" # Display battle points window
|
when "pt" # Display battle points window
|
||||||
battlepointswindow.dispose if battlepointswindow
|
battlepointswindow&.dispose
|
||||||
battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
|
battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
|
||||||
when "wu"
|
when "wu"
|
||||||
msgwindow.y = 0
|
msgwindow.y = 0
|
||||||
@@ -650,7 +650,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
break if !letterbyletter
|
break if !letterbyletter
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
facewindow.update if facewindow
|
facewindow&.update
|
||||||
if autoresume && msgwindow.waitcount == 0
|
if autoresume && msgwindow.waitcount == 0
|
||||||
msgwindow.resume if msgwindow.busy?
|
msgwindow.resume if msgwindow.busy?
|
||||||
break if !msgwindow.busy?
|
break if !msgwindow.busy?
|
||||||
@@ -677,11 +677,11 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
if commandProc
|
if commandProc
|
||||||
ret = commandProc.call(msgwindow)
|
ret = commandProc.call(msgwindow)
|
||||||
end
|
end
|
||||||
msgback.dispose if msgback
|
msgback&.dispose
|
||||||
goldwindow.dispose if goldwindow
|
goldwindow&.dispose
|
||||||
coinwindow.dispose if coinwindow
|
coinwindow&.dispose
|
||||||
battlepointswindow.dispose if battlepointswindow
|
battlepointswindow&.dispose
|
||||||
facewindow.dispose if facewindow
|
facewindow&.dispose
|
||||||
if haveSpecialClose
|
if haveSpecialClose
|
||||||
pbSEPlay(pbStringToAudioFile(specialCloseSE))
|
pbSEPlay(pbStringToAudioFile(specialCloseSE))
|
||||||
atTop = (msgwindow.y == 0)
|
atTop = (msgwindow.y == 0)
|
||||||
@@ -752,7 +752,7 @@ def pbShowCommands(msgwindow, commands = nil, cmdIfCancel = 0, defaultCmd = 0)
|
|||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
cmdwindow.update
|
cmdwindow.update
|
||||||
msgwindow.update if msgwindow
|
msgwindow&.update
|
||||||
yield if block_given?
|
yield if block_given?
|
||||||
if Input.trigger?(Input::BACK)
|
if Input.trigger?(Input::BACK)
|
||||||
if cmdIfCancel > 0
|
if cmdIfCancel > 0
|
||||||
@@ -832,7 +832,7 @@ def pbMessageWaitForInput(msgwindow, frames, showPause = false)
|
|||||||
frames.times do
|
frames.times do
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
msgwindow.update if msgwindow
|
msgwindow&.update
|
||||||
pbUpdateSceneMap
|
pbUpdateSceneMap
|
||||||
if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
|
if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
|
||||||
break
|
break
|
||||||
@@ -863,7 +863,7 @@ def pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width = 240)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
window.update
|
window.update
|
||||||
msgwindow.update if msgwindow
|
msgwindow&.update
|
||||||
yield if block_given?
|
yield if block_given?
|
||||||
end
|
end
|
||||||
Input.text_input = false
|
Input.text_input = false
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class CharacterEntryHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def passwordChar=(value)
|
def passwordChar=(value)
|
||||||
@passwordChar = value ? value : ""
|
@passwordChar = value || ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def length
|
def length
|
||||||
@@ -192,7 +192,7 @@ class Window_TextEntry < SpriteWindow_Base
|
|||||||
@helper.cursor = 0 if @helper.cursor < 0
|
@helper.cursor = 0 if @helper.cursor < 0
|
||||||
startpos = @helper.cursor
|
startpos = @helper.cursor
|
||||||
fromcursor = 0
|
fromcursor = 0
|
||||||
while (startpos > 0)
|
while startpos > 0
|
||||||
c = (@helper.passwordChar != "") ? @helper.passwordChar : textscan[startpos - 1]
|
c = (@helper.passwordChar != "") ? @helper.passwordChar : textscan[startpos - 1]
|
||||||
fromcursor += bitmap.text_size(c).width
|
fromcursor += bitmap.text_size(c).width
|
||||||
break if fromcursor > width - 4
|
break if fromcursor > width - 4
|
||||||
@@ -226,7 +226,7 @@ class Window_TextEntry_Keyboard < Window_TextEntry
|
|||||||
def update
|
def update
|
||||||
@frame += 1
|
@frame += 1
|
||||||
@frame %= 20
|
@frame %= 20
|
||||||
self.refresh if ((@frame % 10) == 0)
|
self.refresh if (@frame % 10) == 0
|
||||||
return if !self.active
|
return if !self.active
|
||||||
# Moving cursor
|
# Moving cursor
|
||||||
if Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT)
|
if Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT)
|
||||||
@@ -460,7 +460,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
|||||||
def update
|
def update
|
||||||
@frame += 1
|
@frame += 1
|
||||||
@frame %= 20
|
@frame %= 20
|
||||||
self.refresh if ((@frame % 10) == 0)
|
self.refresh if (@frame % 10) == 0
|
||||||
return if !self.active
|
return if !self.active
|
||||||
# Moving cursor
|
# Moving cursor
|
||||||
if Input.triggerex?(:UP) || Input.repeatex?(:UP)
|
if Input.triggerex?(:UP) || Input.repeatex?(:UP)
|
||||||
@@ -543,7 +543,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
|||||||
textheight = text[4]
|
textheight = text[4]
|
||||||
posToCursor = @cursorColumn - thiscolumn
|
posToCursor = @cursorColumn - thiscolumn
|
||||||
if posToCursor >= 0
|
if posToCursor >= 0
|
||||||
partialString = text[0].scan(/./m)[0, posToCursor].join("")
|
partialString = text[0].scan(/./m)[0, posToCursor].join
|
||||||
cursorX += bitmap.text_size(partialString).width
|
cursorX += bitmap.text_size(partialString).width
|
||||||
end
|
end
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ def getPlayTime2(filename)
|
|||||||
loop do
|
loop do
|
||||||
rstr = ""
|
rstr = ""
|
||||||
ateof = false
|
ateof = false
|
||||||
while !file.eof?
|
until file.eof?
|
||||||
if (file.read(1)[0] rescue 0) == 0xFF
|
if (file.read(1)[0] rescue 0) == 0xFF
|
||||||
begin
|
begin
|
||||||
rstr = file.read(3)
|
rstr = file.read(3)
|
||||||
@@ -152,14 +152,14 @@ def getPlayTime2(filename)
|
|||||||
if rstr[0] == 0xFB
|
if rstr[0] == 0xFB
|
||||||
t = rstr[1] >> 4
|
t = rstr[1] >> 4
|
||||||
next if [0, 15].include?(t)
|
next if [0, 15].include?(t)
|
||||||
freqs = [44100, 22050, 11025, 48000]
|
freqs = [44_100, 22_050, 11_025, 48_000]
|
||||||
bitrates = [32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320]
|
bitrates = [32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320]
|
||||||
bitrate = bitrates[t]
|
bitrate = bitrates[t]
|
||||||
t = (rstr[1] >> 2) & 3
|
t = (rstr[1] >> 2) & 3
|
||||||
freq = freqs[t]
|
freq = freqs[t]
|
||||||
t = (rstr[1] >> 1) & 1
|
t = (rstr[1] >> 1) & 1
|
||||||
filesize = FileTest.size(filename)
|
filesize = FileTest.size(filename)
|
||||||
frameLength = ((144000 * bitrate) / freq) + t
|
frameLength = ((144_000 * bitrate) / freq) + t
|
||||||
numFrames = filesize / (frameLength + 4)
|
numFrames = filesize / (frameLength + 4)
|
||||||
time = (numFrames * 1152.0 / freq)
|
time = (numFrames * 1152.0 / freq)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ def pbBGMPlay(param, volume = nil, pitch = nil)
|
|||||||
return
|
return
|
||||||
elsif (RPG.const_defined?(:BGM) rescue false)
|
elsif (RPG.const_defined?(:BGM) rescue false)
|
||||||
b = RPG::BGM.new(param.name, param.volume, param.pitch)
|
b = RPG::BGM.new(param.name, param.volume, param.pitch)
|
||||||
if b && b.respond_to?("play")
|
if b&.respond_to?("play")
|
||||||
b.play
|
b.play
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -108,7 +108,7 @@ def pbMEPlay(param, volume = nil, pitch = nil)
|
|||||||
return
|
return
|
||||||
elsif (RPG.const_defined?(:ME) rescue false)
|
elsif (RPG.const_defined?(:ME) rescue false)
|
||||||
b = RPG::ME.new(param.name, param.volume, param.pitch)
|
b = RPG::ME.new(param.name, param.volume, param.pitch)
|
||||||
if b && b.respond_to?("play")
|
if b&.respond_to?("play")
|
||||||
b.play
|
b.play
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -125,7 +125,7 @@ def pbMEStop(timeInSeconds = 0.0)
|
|||||||
if $game_system && timeInSeconds > 0.0 && $game_system.respond_to?("me_fade")
|
if $game_system && timeInSeconds > 0.0 && $game_system.respond_to?("me_fade")
|
||||||
$game_system.me_fade(timeInSeconds)
|
$game_system.me_fade(timeInSeconds)
|
||||||
return
|
return
|
||||||
elsif $game_system && $game_system.respond_to?("me_stop")
|
elsif $game_system&.respond_to?("me_stop")
|
||||||
$game_system.me_stop(nil)
|
$game_system.me_stop(nil)
|
||||||
return
|
return
|
||||||
elsif (RPG.const_defined?(:ME) rescue false)
|
elsif (RPG.const_defined?(:ME) rescue false)
|
||||||
@@ -158,7 +158,7 @@ def pbBGSPlay(param, volume = nil, pitch = nil)
|
|||||||
return
|
return
|
||||||
elsif (RPG.const_defined?(:BGS) rescue false)
|
elsif (RPG.const_defined?(:BGS) rescue false)
|
||||||
b = RPG::BGS.new(param.name, param.volume, param.pitch)
|
b = RPG::BGS.new(param.name, param.volume, param.pitch)
|
||||||
if b && b.respond_to?("play")
|
if b&.respond_to?("play")
|
||||||
b.play
|
b.play
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -209,7 +209,7 @@ def pbSEPlay(param, volume = nil, pitch = nil)
|
|||||||
end
|
end
|
||||||
if (RPG.const_defined?(:SE) rescue false)
|
if (RPG.const_defined?(:SE) rescue false)
|
||||||
b = RPG::SE.new(param.name, param.volume, param.pitch)
|
b = RPG::SE.new(param.name, param.volume, param.pitch)
|
||||||
if b && b.respond_to?("play")
|
if b&.respond_to?("play")
|
||||||
b.play
|
b.play
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ module Graphics
|
|||||||
def self.update
|
def self.update
|
||||||
update_KGC_SpecialTransition
|
update_KGC_SpecialTransition
|
||||||
@@transition.update if @@transition && !@@transition.disposed?
|
@@transition.update if @@transition && !@@transition.disposed?
|
||||||
@@transition = nil if @@transition && @@transition.disposed?
|
@@transition = nil if @@transition&.disposed?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.judge_special_transition(duration, filename)
|
def self.judge_special_transition(duration, filename)
|
||||||
@@ -137,11 +137,11 @@ module Transitions
|
|||||||
def dispose
|
def dispose
|
||||||
return if disposed?
|
return if disposed?
|
||||||
dispose_all
|
dispose_all
|
||||||
@sprites.each { |s| s.dispose if s }
|
@sprites.each { |s| s&.dispose }
|
||||||
@sprites.clear
|
@sprites.clear
|
||||||
@overworld_sprite.dispose
|
@overworld_sprite.dispose
|
||||||
@overworld_bitmap.dispose if @overworld_bitmap
|
@overworld_bitmap&.dispose
|
||||||
@viewport.dispose if @viewport
|
@viewport&.dispose
|
||||||
@disposed = true
|
@disposed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -404,8 +404,8 @@ module Transitions
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose_all
|
def dispose_all
|
||||||
@buffer_original.dispose if @buffer_original
|
@buffer_original&.dispose
|
||||||
@buffer_temp.dispose if @buffer_temp
|
@buffer_temp&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_anim
|
def update_anim
|
||||||
@@ -628,13 +628,13 @@ module Transitions
|
|||||||
|
|
||||||
def dispose_all
|
def dispose_all
|
||||||
# Dispose sprites
|
# Dispose sprites
|
||||||
@bubbles_sprite.dispose if @bubbles_sprite
|
@bubbles_sprite&.dispose
|
||||||
@splash_sprite.dispose if @splash_sprite
|
@splash_sprite&.dispose
|
||||||
@black_sprite.dispose if @black_sprite
|
@black_sprite&.dispose
|
||||||
# Dispose bitmaps
|
# Dispose bitmaps
|
||||||
@bubble_bitmap.dispose if @bubble_bitmap
|
@bubble_bitmap&.dispose
|
||||||
@splash_bitmap.dispose if @splash_bitmap
|
@splash_bitmap&.dispose
|
||||||
@black_bitmap.dispose if @black_bitmap
|
@black_bitmap&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_anim
|
def update_anim
|
||||||
@@ -704,12 +704,12 @@ module Transitions
|
|||||||
def dispose_all
|
def dispose_all
|
||||||
# Dispose sprites
|
# Dispose sprites
|
||||||
if @ball_sprites
|
if @ball_sprites
|
||||||
@ball_sprites.each { |s| s.dispose if s }
|
@ball_sprites.each { |s| s&.dispose }
|
||||||
@ball_sprites.clear
|
@ball_sprites.clear
|
||||||
end
|
end
|
||||||
# Dispose bitmaps
|
# Dispose bitmaps
|
||||||
@black_bitmap.dispose if @black_bitmap
|
@black_bitmap&.dispose
|
||||||
@ball_bitmap.dispose if @ball_bitmap
|
@ball_bitmap&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_anim
|
def update_anim
|
||||||
@@ -782,20 +782,20 @@ module Transitions
|
|||||||
def dispose_all
|
def dispose_all
|
||||||
# Dispose sprites
|
# Dispose sprites
|
||||||
if @overworld_sprites
|
if @overworld_sprites
|
||||||
@overworld_sprites.each { |s| s.dispose if s }
|
@overworld_sprites.each { |s| s&.dispose }
|
||||||
@overworld_sprites.clear
|
@overworld_sprites.clear
|
||||||
end
|
end
|
||||||
if @black_sprites
|
if @black_sprites
|
||||||
@black_sprites.each { |s| s.dispose if s }
|
@black_sprites.each { |s| s&.dispose }
|
||||||
@black_sprites.clear
|
@black_sprites.clear
|
||||||
end
|
end
|
||||||
if @ball_sprites
|
if @ball_sprites
|
||||||
@ball_sprites.each { |s| s.dispose if s }
|
@ball_sprites.each { |s| s&.dispose }
|
||||||
@ball_sprites.clear
|
@ball_sprites.clear
|
||||||
end
|
end
|
||||||
# Dispose bitmaps
|
# Dispose bitmaps
|
||||||
@black_bitmap.dispose if @black_bitmap
|
@black_bitmap&.dispose
|
||||||
@ball_bitmap.dispose if @ball_bitmap
|
@ball_bitmap&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_anim
|
def update_anim
|
||||||
@@ -892,12 +892,12 @@ module Transitions
|
|||||||
def dispose_all
|
def dispose_all
|
||||||
# Dispose sprites
|
# Dispose sprites
|
||||||
if @ball_sprites
|
if @ball_sprites
|
||||||
@ball_sprites.each { |s| s.dispose if s }
|
@ball_sprites.each { |s| s&.dispose }
|
||||||
@ball_sprites.clear
|
@ball_sprites.clear
|
||||||
end
|
end
|
||||||
# Dispose bitmaps
|
# Dispose bitmaps
|
||||||
@black_bitmap.dispose if @black_bitmap
|
@black_bitmap&.dispose
|
||||||
@ball_bitmap.dispose if @ball_bitmap
|
@ball_bitmap&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_anim
|
def update_anim
|
||||||
@@ -966,11 +966,11 @@ module Transitions
|
|||||||
|
|
||||||
def dispose_all
|
def dispose_all
|
||||||
# Dispose sprites
|
# Dispose sprites
|
||||||
@ball_sprite.dispose if @ball_sprite
|
@ball_sprite&.dispose
|
||||||
# Dispose bitmaps
|
# Dispose bitmaps
|
||||||
@black_bitmap.dispose if @black_bitmap
|
@black_bitmap&.dispose
|
||||||
@curve_bitmap.dispose if @curve_bitmap
|
@curve_bitmap&.dispose
|
||||||
@ball_bitmap.dispose if @ball_bitmap
|
@ball_bitmap&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_anim
|
def update_anim
|
||||||
@@ -1046,16 +1046,16 @@ module Transitions
|
|||||||
def dispose_all
|
def dispose_all
|
||||||
# Dispose sprites
|
# Dispose sprites
|
||||||
if @ball_sprites
|
if @ball_sprites
|
||||||
@ball_sprites.each { |s| s.dispose if s }
|
@ball_sprites.each { |s| s&.dispose }
|
||||||
@ball_sprites.clear
|
@ball_sprites.clear
|
||||||
end
|
end
|
||||||
if @black_trail_sprites
|
if @black_trail_sprites
|
||||||
@black_trail_sprites.each { |s| s.dispose if s }
|
@black_trail_sprites.each { |s| s&.dispose }
|
||||||
@black_trail_sprites.clear
|
@black_trail_sprites.clear
|
||||||
end
|
end
|
||||||
# Dispose bitmaps
|
# Dispose bitmaps
|
||||||
@black_bitmap.dispose if @black_bitmap
|
@black_bitmap&.dispose
|
||||||
@ball_bitmap.dispose if @ball_bitmap
|
@ball_bitmap&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_anim
|
def update_anim
|
||||||
@@ -1122,11 +1122,11 @@ module Transitions
|
|||||||
|
|
||||||
def dispose_all
|
def dispose_all
|
||||||
# Dispose sprites
|
# Dispose sprites
|
||||||
@ball_sprite.dispose if @ball_sprite
|
@ball_sprite&.dispose
|
||||||
@black_sprite.dispose if @black_sprite
|
@black_sprite&.dispose
|
||||||
# Dispose bitmaps
|
# Dispose bitmaps
|
||||||
@black_bitmap.dispose if @black_bitmap
|
@black_bitmap&.dispose
|
||||||
@ball_bitmap.dispose if @ball_bitmap
|
@ball_bitmap&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_anim
|
def update_anim
|
||||||
@@ -1194,14 +1194,14 @@ module Transitions
|
|||||||
|
|
||||||
def dispose_all
|
def dispose_all
|
||||||
# Dispose sprites
|
# Dispose sprites
|
||||||
@ball_sprites.each { |s| s.dispose if s }
|
@ball_sprites.each { |s| s&.dispose }
|
||||||
@ball_sprites.clear
|
@ball_sprites.clear
|
||||||
# Dispose bitmaps
|
# Dispose bitmaps
|
||||||
@black_1_bitmap.dispose if @black_1_bitmap
|
@black_1_bitmap&.dispose
|
||||||
@black_2_bitmap.dispose if @black_2_bitmap
|
@black_2_bitmap&.dispose
|
||||||
@black_3_bitmap.dispose if @black_3_bitmap
|
@black_3_bitmap&.dispose
|
||||||
@black_4_bitmap.dispose if @black_4_bitmap
|
@black_4_bitmap&.dispose
|
||||||
@ball_bitmap.dispose if @ball_bitmap
|
@ball_bitmap&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_anim
|
def update_anim
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class PictureSprite < SpriteWrapper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@pictureBitmap.dispose if @pictureBitmap
|
@pictureBitmap&.dispose
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ class PictureSprite < SpriteWrapper
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
super
|
super
|
||||||
@pictureBitmap.update if @pictureBitmap
|
@pictureBitmap&.update
|
||||||
# If picture file name is different from current one
|
# If picture file name is different from current one
|
||||||
if @customBitmap && @picture.name == ""
|
if @customBitmap && @picture.name == ""
|
||||||
self.bitmap = (@customBitmapIsBitmap) ? @customBitmap : @customBitmap.bitmap
|
self.bitmap = (@customBitmapIsBitmap) ? @customBitmap : @customBitmap.bitmap
|
||||||
@@ -32,13 +32,13 @@ class PictureSprite < SpriteWrapper
|
|||||||
@hue = @picture.hue.to_i
|
@hue = @picture.hue.to_i
|
||||||
# If file name is not empty
|
# If file name is not empty
|
||||||
if @picture_name == ""
|
if @picture_name == ""
|
||||||
@pictureBitmap.dispose if @pictureBitmap
|
@pictureBitmap&.dispose
|
||||||
@pictureBitmap = nil
|
@pictureBitmap = nil
|
||||||
self.visible = false
|
self.visible = false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
# Get picture graphic
|
# Get picture graphic
|
||||||
@pictureBitmap.dispose if @pictureBitmap
|
@pictureBitmap&.dispose
|
||||||
@pictureBitmap = AnimatedBitmap.new(@picture_name, @hue)
|
@pictureBitmap = AnimatedBitmap.new(@picture_name, @hue)
|
||||||
self.bitmap = (@pictureBitmap) ? @pictureBitmap.bitmap : nil
|
self.bitmap = (@pictureBitmap) ? @pictureBitmap.bitmap : nil
|
||||||
elsif @picture_name == ""
|
elsif @picture_name == ""
|
||||||
@@ -175,7 +175,7 @@ class EventScene
|
|||||||
end
|
end
|
||||||
|
|
||||||
def main
|
def main
|
||||||
while !disposed?
|
until disposed?
|
||||||
update
|
update
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ module GameData
|
|||||||
end
|
end
|
||||||
|
|
||||||
def call_after_evolution(*args)
|
def call_after_evolution(*args)
|
||||||
@after_evolution_proc.call(*args) if @after_evolution_proc
|
@after_evolution_proc&.call(*args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -500,8 +500,7 @@ GameData::Evolution.register({
|
|||||||
:minimum_level => 1, # Needs any level up
|
:minimum_level => 1, # Needs any level up
|
||||||
:level_up_proc => proc { |pkmn, parameter|
|
:level_up_proc => proc { |pkmn, parameter|
|
||||||
map_metadata = $game_map.metadata
|
map_metadata = $game_map.metadata
|
||||||
next map_metadata && map_metadata.town_map_position &&
|
next map_metadata&.town_map_position && map_metadata.town_map_position[0] == parameter
|
||||||
map_metadata.town_map_position[0] == parameter
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -42,10 +42,8 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbLoadPhoneData
|
def pbLoadPhoneData
|
||||||
$game_temp = Game_Temp.new if !$game_temp
|
$game_temp = Game_Temp.new if !$game_temp
|
||||||
if !$game_temp.phone_messages_data
|
if !$game_temp.phone_messages_data && pbRgssExists?("Data/phone.dat")
|
||||||
if pbRgssExists?("Data/phone.dat")
|
$game_temp.phone_messages_data = load_data("Data/phone.dat")
|
||||||
$game_temp.phone_messages_data = load_data("Data/phone.dat")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return $game_temp.phone_messages_data
|
return $game_temp.phone_messages_data
|
||||||
end
|
end
|
||||||
@@ -66,10 +64,8 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbLoadBattleAnimations
|
def pbLoadBattleAnimations
|
||||||
$game_temp = Game_Temp.new if !$game_temp
|
$game_temp = Game_Temp.new if !$game_temp
|
||||||
if !$game_temp.battle_animations_data
|
if !$game_temp.battle_animations_data && pbRgssExists?("Data/PkmnAnimations.rxdata")
|
||||||
if pbRgssExists?("Data/PkmnAnimations.rxdata")
|
$game_temp.battle_animations_data = load_data("Data/PkmnAnimations.rxdata")
|
||||||
$game_temp.battle_animations_data = load_data("Data/PkmnAnimations.rxdata")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return $game_temp.battle_animations_data
|
return $game_temp.battle_animations_data
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ module GameData
|
|||||||
:KYOGRE => [:BLUEORB],
|
:KYOGRE => [:BLUEORB],
|
||||||
:GROUDON => [:REDORB]
|
:GROUDON => [:REDORB]
|
||||||
}
|
}
|
||||||
return combos[species] && combos[species].include?(@id)
|
return combos[species]&.include?(@id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ module GameData
|
|||||||
def self.each_of_version(version = 0)
|
def self.each_of_version(version = 0)
|
||||||
self.each do |data|
|
self.each do |data|
|
||||||
yield data if data.version == version
|
yield data if data.version == version
|
||||||
if version > 0
|
if version > 0 && data.version == 0 && !self::DATA.has_key?([data.map, version])
|
||||||
yield data if data.version == 0 && !self::DATA.has_key?([data.map, version])
|
yield data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ module GameData
|
|||||||
|
|
||||||
def self.charset_filename_brief(tr_type)
|
def self.charset_filename_brief(tr_type)
|
||||||
ret = self.charset_filename(tr_type)
|
ret = self.charset_filename(tr_type)
|
||||||
ret.slice!("Graphics/Characters/") if ret
|
ret&.slice!("Graphics/Characters/")
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ class Battle
|
|||||||
def pbAbleCount(idxBattler = 0)
|
def pbAbleCount(idxBattler = 0)
|
||||||
party = pbParty(idxBattler)
|
party = pbParty(idxBattler)
|
||||||
count = 0
|
count = 0
|
||||||
party.each { |pkmn| count += 1 if pkmn && pkmn.able? }
|
party.each { |pkmn| count += 1 if pkmn&.able? }
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -465,11 +465,11 @@ class Battle
|
|||||||
end
|
end
|
||||||
infected.each do |idxParty|
|
infected.each do |idxParty|
|
||||||
strain = $player.party[idxParty].pokerusStrain
|
strain = $player.party[idxParty].pokerusStrain
|
||||||
if idxParty > 0 && $player.party[idxParty - 1].pokerusStage == 0
|
if idxParty > 0 && $player.party[idxParty - 1].pokerusStage == 0 && rand(3) == 0 # 33%
|
||||||
$player.party[idxParty - 1].givePokerus(strain) if rand(3) == 0 # 33%
|
$player.party[idxParty - 1].givePokerus(strain)
|
||||||
end
|
end
|
||||||
if idxParty < $player.party.length - 1 && $player.party[idxParty + 1].pokerusStage == 0
|
if idxParty < $player.party.length - 1 && $player.party[idxParty + 1].pokerusStage == 0 && rand(3) == 0 # 33%
|
||||||
$player.party[idxParty + 1].givePokerus(strain) if rand(3) == 0 # 33%
|
$player.party[idxParty + 1].givePokerus(strain)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ class Battle
|
|||||||
expAll = $player.has_exp_all || $bag.has?(:EXPALL)
|
expAll = $player.has_exp_all || $bag.has?(:EXPALL)
|
||||||
p1 = pbParty(0)
|
p1 = pbParty(0)
|
||||||
@battlers.each do |b|
|
@battlers.each do |b|
|
||||||
next unless b && b.opposes? # Can only gain Exp from fainted foes
|
next unless b&.opposes? # Can only gain Exp from fainted foes
|
||||||
next if b.participants.length == 0
|
next if b.participants.length == 0
|
||||||
next unless b.fainted? || b.captured
|
next unless b.fainted? || b.captured
|
||||||
# Count the number of participants
|
# Count the number of participants
|
||||||
numPartic = 0
|
numPartic = 0
|
||||||
b.participants.each do |partic|
|
b.participants.each do |partic|
|
||||||
next unless p1[partic] && p1[partic].able? && pbIsOwner?(0, partic)
|
next unless p1[partic]&.able? && pbIsOwner?(0, partic)
|
||||||
numPartic += 1
|
numPartic += 1
|
||||||
end
|
end
|
||||||
# Find which Pokémon have an Exp Share
|
# Find which Pokémon have an Exp Share
|
||||||
@@ -199,7 +199,7 @@ class Battle
|
|||||||
if curLevel > newLevel
|
if curLevel > newLevel
|
||||||
# Gained all the Exp now, end the animation
|
# Gained all the Exp now, end the animation
|
||||||
pkmn.calc_stats
|
pkmn.calc_stats
|
||||||
battler.pbUpdate(false) if battler
|
battler&.pbUpdate(false)
|
||||||
@scene.pbRefreshOne(battler.index) if battler
|
@scene.pbRefreshOne(battler.index) if battler
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@@ -211,11 +211,11 @@ class Battle
|
|||||||
oldSpAtk = pkmn.spatk
|
oldSpAtk = pkmn.spatk
|
||||||
oldSpDef = pkmn.spdef
|
oldSpDef = pkmn.spdef
|
||||||
oldSpeed = pkmn.speed
|
oldSpeed = pkmn.speed
|
||||||
if battler && battler.pokemon
|
if battler&.pokemon
|
||||||
battler.pokemon.changeHappiness("levelup")
|
battler.pokemon.changeHappiness("levelup")
|
||||||
end
|
end
|
||||||
pkmn.calc_stats
|
pkmn.calc_stats
|
||||||
battler.pbUpdate(false) if battler
|
battler&.pbUpdate(false)
|
||||||
@scene.pbRefreshOne(battler.index) if battler
|
@scene.pbRefreshOne(battler.index) if battler
|
||||||
pbDisplayPaused(_INTL("{1} grew to Lv. {2}!", pkmn.name, curLevel))
|
pbDisplayPaused(_INTL("{1} grew to Lv. {2}!", pkmn.name, curLevel))
|
||||||
@scene.pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense,
|
@scene.pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense,
|
||||||
@@ -260,7 +260,7 @@ class Battle
|
|||||||
pbDisplayPaused(_INTL("1, 2, and... ... ... Ta-da!")) { pbSEPlay("Battle ball drop") }
|
pbDisplayPaused(_INTL("1, 2, and... ... ... Ta-da!")) { pbSEPlay("Battle ball drop") }
|
||||||
pbDisplayPaused(_INTL("{1} forgot how to use {2}. And...", pkmnName, oldMoveName))
|
pbDisplayPaused(_INTL("{1} forgot how to use {2}. And...", pkmnName, oldMoveName))
|
||||||
pbDisplay(_INTL("{1} learned {2}!", pkmnName, moveName)) { pbSEPlay("Pkmn move learnt") }
|
pbDisplay(_INTL("{1} learned {2}!", pkmnName, moveName)) { pbSEPlay("Pkmn move learnt") }
|
||||||
battler.pbCheckFormOnMovesetChange if battler
|
battler&.pbCheckFormOnMovesetChange
|
||||||
break
|
break
|
||||||
elsif pbDisplayConfirm(_INTL("Give up on learning {1}?", moveName))
|
elsif pbDisplayConfirm(_INTL("Give up on learning {1}?", moveName))
|
||||||
pbDisplay(_INTL("{1} did not learn {2}.", pkmnName, moveName))
|
pbDisplay(_INTL("{1} did not learn {2}.", pkmnName, moveName))
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Battle
|
|||||||
return false if idxParty >= party.length
|
return false if idxParty >= party.length
|
||||||
return false if !party[idxParty]
|
return false if !party[idxParty]
|
||||||
if party[idxParty].egg?
|
if party[idxParty].egg?
|
||||||
partyScene.pbDisplay(_INTL("An Egg can't battle!")) if partyScene
|
partyScene&.pbDisplay(_INTL("An Egg can't battle!"))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if !pbIsOwner?(idxBattler, idxParty)
|
if !pbIsOwner?(idxBattler, idxParty)
|
||||||
@@ -24,11 +24,11 @@ class Battle
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if party[idxParty].fainted?
|
if party[idxParty].fainted?
|
||||||
partyScene.pbDisplay(_INTL("{1} has no energy left to battle!", party[idxParty].name)) if partyScene
|
partyScene&.pbDisplay(_INTL("{1} has no energy left to battle!", party[idxParty].name))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if pbFindBattler(idxParty, idxBattler)
|
if pbFindBattler(idxParty, idxBattler)
|
||||||
partyScene.pbDisplay(_INTL("{1} is already in battle!", party[idxParty].name)) if partyScene
|
partyScene&.pbDisplay(_INTL("{1} is already in battle!", party[idxParty].name))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@@ -45,45 +45,43 @@ class Battle
|
|||||||
# Pokémon
|
# Pokémon
|
||||||
allSameSideBattlers(idxBattler).each do |b|
|
allSameSideBattlers(idxBattler).each do |b|
|
||||||
next if choices[b.index][0] != :SwitchOut || choices[b.index][1] != idxParty
|
next if choices[b.index][0] != :SwitchOut || choices[b.index][1] != idxParty
|
||||||
partyScene.pbDisplay(_INTL("{1} has already been selected.",
|
partyScene&.pbDisplay(_INTL("{1} has already been selected.",
|
||||||
pbParty(idxBattler)[idxParty].name)) if partyScene
|
pbParty(idxBattler)[idxParty].name))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
# Check whether battler can switch out
|
# Check whether battler can switch out
|
||||||
battler = @battlers[idxBattler]
|
battler = @battlers[idxBattler]
|
||||||
return true if battler.fainted?
|
return true if battler.fainted?
|
||||||
# Ability/item effects that allow switching no matter what
|
# Ability/item effects that allow switching no matter what
|
||||||
if battler.abilityActive?
|
if battler.abilityActive? &&
|
||||||
if Battle::AbilityEffects.triggerCertainSwitching(battler.ability, battler, self)
|
Battle::AbilityEffects.triggerCertainSwitching(battler.ability, battler, self)
|
||||||
return true
|
return true
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if battler.itemActive?
|
if battler.itemActive? &&
|
||||||
if Battle::ItemEffects.triggerCertainSwitching(battler.item, battler, self)
|
Battle::ItemEffects.triggerCertainSwitching(battler.item, battler, self)
|
||||||
return true
|
return true
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Other certain switching effects
|
# Other certain switching effects
|
||||||
return true if Settings::MORE_TYPE_EFFECTS && battler.pbHasType?(:GHOST)
|
return true if Settings::MORE_TYPE_EFFECTS && battler.pbHasType?(:GHOST)
|
||||||
# Other certain trapping effects
|
# Other certain trapping effects
|
||||||
if battler.trappedInBattle?
|
if battler.trappedInBattle?
|
||||||
partyScene.pbDisplay(_INTL("{1} can't be switched out!", battler.pbThis)) if partyScene
|
partyScene&.pbDisplay(_INTL("{1} can't be switched out!", battler.pbThis))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
# Trapping abilities/items
|
# Trapping abilities/items
|
||||||
allOtherSideBattlers(idxBattler).each do |b|
|
allOtherSideBattlers(idxBattler).each do |b|
|
||||||
next if !b.abilityActive?
|
next if !b.abilityActive?
|
||||||
if Battle::AbilityEffects.triggerTrappingByTarget(b.ability, battler, b, self)
|
if Battle::AbilityEffects.triggerTrappingByTarget(b.ability, battler, b, self)
|
||||||
partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!",
|
partyScene&.pbDisplay(_INTL("{1}'s {2} prevents switching!",
|
||||||
b.pbThis, b.abilityName)) if partyScene
|
b.pbThis, b.abilityName))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
allOtherSideBattlers(idxBattler).each do |b|
|
allOtherSideBattlers(idxBattler).each do |b|
|
||||||
next if !b.itemActive?
|
next if !b.itemActive?
|
||||||
if Battle::ItemEffects.triggerTrappingByTarget(b.item, battler, b, self)
|
if Battle::ItemEffects.triggerTrappingByTarget(b.item, battler, b, self)
|
||||||
partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!",
|
partyScene&.pbDisplay(_INTL("{1}'s {2} prevents switching!",
|
||||||
b.pbThis, b.itemName)) if partyScene
|
b.pbThis, b.itemName))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -119,8 +117,8 @@ class Battle
|
|||||||
elsif !pbCanSwitch?(idxBattler, idxParty, partyScene)
|
elsif !pbCanSwitch?(idxBattler, idxParty, partyScene)
|
||||||
next false
|
next false
|
||||||
end
|
end
|
||||||
if shouldRegister
|
if shouldRegister && (idxParty < 0 || !pbRegisterSwitch(idxBattler, idxParty))
|
||||||
next false if idxParty < 0 || !pbRegisterSwitch(idxBattler, idxParty)
|
next false
|
||||||
end
|
end
|
||||||
ret = idxParty
|
ret = idxParty
|
||||||
next true
|
next true
|
||||||
@@ -187,10 +185,10 @@ class Battle
|
|||||||
switched.push(idxBattler)
|
switched.push(idxBattler)
|
||||||
else # Player's Pokémon has fainted in a wild battle
|
else # Player's Pokémon has fainted in a wild battle
|
||||||
switch = false
|
switch = false
|
||||||
if !pbDisplayConfirm(_INTL("Use next Pokémon?"))
|
if pbDisplayConfirm(_INTL("Use next Pokémon?"))
|
||||||
switch = (pbRun(idxBattler, true) <= 0)
|
|
||||||
else
|
|
||||||
switch = true
|
switch = true
|
||||||
|
else
|
||||||
|
switch = (pbRun(idxBattler, true) <= 0)
|
||||||
end
|
end
|
||||||
if switch
|
if switch
|
||||||
idxPlayerPartyNew = pbGetReplacementPokemonIndex(idxBattler) # Owner chooses
|
idxPlayerPartyNew = pbGetReplacementPokemonIndex(idxBattler) # Owner chooses
|
||||||
|
|||||||
@@ -56,14 +56,14 @@ class Battle
|
|||||||
return if !item
|
return if !item
|
||||||
return if !GameData::Item.get(item).consumed_after_use?
|
return if !GameData::Item.get(item).consumed_after_use?
|
||||||
if pbOwnedByPlayer?(idxBattler)
|
if pbOwnedByPlayer?(idxBattler)
|
||||||
if $bag && $bag.can_add?(item)
|
if $bag&.can_add?(item)
|
||||||
$bag.add(item)
|
$bag.add(item)
|
||||||
else
|
else
|
||||||
raise _INTL("Couldn't return unused item to Bag somehow.")
|
raise _INTL("Couldn't return unused item to Bag somehow.")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
items = pbGetOwnerItems(idxBattler)
|
items = pbGetOwnerItems(idxBattler)
|
||||||
items.push(item) if items
|
items&.push(item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -75,24 +75,22 @@ class Battle
|
|||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
# Abilities that guarantee escape
|
# Abilities that guarantee escape
|
||||||
if battler.abilityActive?
|
if battler.abilityActive? &&
|
||||||
if Battle::AbilityEffects.triggerCertainEscapeFromBattle(battler.ability, battler)
|
Battle::AbilityEffects.triggerCertainEscapeFromBattle(battler.ability, battler)
|
||||||
pbShowAbilitySplash(battler, true)
|
pbShowAbilitySplash(battler, true)
|
||||||
pbHideAbilitySplash(battler)
|
pbHideAbilitySplash(battler)
|
||||||
pbSEPlay("Battle flee")
|
pbSEPlay("Battle flee")
|
||||||
pbDisplayPaused(_INTL("You got away safely!"))
|
pbDisplayPaused(_INTL("You got away safely!"))
|
||||||
@decision = 3
|
@decision = 3
|
||||||
return 1
|
return 1
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Held items that guarantee escape
|
# Held items that guarantee escape
|
||||||
if battler.itemActive?
|
if battler.itemActive? &&
|
||||||
if Battle::ItemEffects.triggerCertainEscapeFromBattle(battler.item, battler)
|
Battle::ItemEffects.triggerCertainEscapeFromBattle(battler.item, battler)
|
||||||
pbSEPlay("Battle flee")
|
pbSEPlay("Battle flee")
|
||||||
pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis, battler.itemName))
|
pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis, battler.itemName))
|
||||||
@decision = 3
|
@decision = 3
|
||||||
return 1
|
return 1
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Other certain trapping effects
|
# Other certain trapping effects
|
||||||
if battler.trappedInBattle?
|
if battler.trappedInBattle?
|
||||||
|
|||||||
@@ -161,10 +161,10 @@ class Battle
|
|||||||
next if advance
|
next if advance
|
||||||
# Check for all done
|
# Check for all done
|
||||||
priority.each do |b|
|
priority.each do |b|
|
||||||
if !b.fainted? && !b.movedThisRound?
|
next if b.fainted?
|
||||||
advance = true if @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
|
next if b.movedThisRound? || ![:UseMove, :Shift].include?(@choices[b.index][0])
|
||||||
end
|
advance = true
|
||||||
break if advance
|
break
|
||||||
end
|
end
|
||||||
next if advance
|
next if advance
|
||||||
# All Pokémon have moved; end the loop
|
# All Pokémon have moved; end the loop
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ class Battle
|
|||||||
if !moveUser # User isn't in battle, get it from the party
|
if !moveUser # User isn't in battle, get it from the party
|
||||||
party = pbParty(pos.effects[PBEffects::FutureSightUserIndex])
|
party = pbParty(pos.effects[PBEffects::FutureSightUserIndex])
|
||||||
pkmn = party[pos.effects[PBEffects::FutureSightUserPartyIndex]]
|
pkmn = party[pos.effects[PBEffects::FutureSightUserPartyIndex]]
|
||||||
if pkmn && pkmn.able?
|
if pkmn&.able?
|
||||||
moveUser = Battler.new(self, pos.effects[PBEffects::FutureSightUserIndex])
|
moveUser = Battler.new(self, pos.effects[PBEffects::FutureSightUserIndex])
|
||||||
moveUser.pbInitDummyPokemon(pkmn, pos.effects[PBEffects::FutureSightUserPartyIndex])
|
moveUser.pbInitDummyPokemon(pkmn, pos.effects[PBEffects::FutureSightUserPartyIndex])
|
||||||
end
|
end
|
||||||
@@ -504,12 +504,11 @@ class Battle
|
|||||||
b.pbItemHPHealCheck
|
b.pbItemHPHealCheck
|
||||||
b.pbFaint if b.fainted?
|
b.pbFaint if b.fainted?
|
||||||
end
|
end
|
||||||
if perishSongUsers.length > 0
|
# Judge if all remaining Pokemon fainted by a Perish Song triggered by a single side
|
||||||
# If all remaining Pokemon fainted by a Perish Song triggered by a single side
|
if perishSongUsers.length > 0 &&
|
||||||
if (perishSongUsers.find_all { |idxBattler| opposes?(idxBattler) }.length == perishSongUsers.length) ||
|
((perishSongUsers.find_all { |idxBattler| opposes?(idxBattler) }.length == perishSongUsers.length) ||
|
||||||
(perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length == perishSongUsers.length)
|
(perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length == perishSongUsers.length))
|
||||||
pbJudgeCheckpoint(@battlers[perishSongUsers[0]])
|
pbJudgeCheckpoint(@battlers[perishSongUsers[0]])
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Check for end of battle
|
# Check for end of battle
|
||||||
if @decision > 0
|
if @decision > 0
|
||||||
|
|||||||
@@ -136,17 +136,17 @@ class Battle::Battler
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
def hasMega?
|
def hasMega?
|
||||||
return false if @effects[PBEffects::Transform]
|
return false if @effects[PBEffects::Transform]
|
||||||
return @pokemon && @pokemon.hasMegaForm?
|
return @pokemon&.hasMegaForm?
|
||||||
end
|
end
|
||||||
|
|
||||||
def mega?; return @pokemon && @pokemon.mega?; end
|
def mega?; return @pokemon&.mega?; end
|
||||||
|
|
||||||
def hasPrimal?
|
def hasPrimal?
|
||||||
return false if @effects[PBEffects::Transform]
|
return false if @effects[PBEffects::Transform]
|
||||||
return @pokemon && @pokemon.hasPrimalForm?
|
return @pokemon&.hasPrimalForm?
|
||||||
end
|
end
|
||||||
|
|
||||||
def primal?; return @pokemon && @pokemon.primal?; end
|
def primal?; return @pokemon&.primal?; end
|
||||||
|
|
||||||
def shadowPokemon?; return false; end
|
def shadowPokemon?; return false; end
|
||||||
|
|
||||||
@@ -184,11 +184,11 @@ class Battle::Battler
|
|||||||
|
|
||||||
def shiny?
|
def shiny?
|
||||||
return @effects[PBEffects::Illusion].shiny? if @effects[PBEffects::Illusion]
|
return @effects[PBEffects::Illusion].shiny? if @effects[PBEffects::Illusion]
|
||||||
return @pokemon && @pokemon.shiny?
|
return @pokemon&.shiny?
|
||||||
end
|
end
|
||||||
|
|
||||||
def super_shiny?
|
def super_shiny?
|
||||||
return @pokemon && @pokemon.super_shiny?
|
return @pokemon&.super_shiny?
|
||||||
end
|
end
|
||||||
|
|
||||||
def owned?
|
def owned?
|
||||||
@@ -295,7 +295,7 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def isSpecies?(species)
|
def isSpecies?(species)
|
||||||
return @pokemon && @pokemon.isSpecies?(species)
|
return @pokemon&.isSpecies?(species)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the active types of this Pokémon. The array should not include the
|
# Returns the active types of this Pokémon. The array should not include the
|
||||||
@@ -311,8 +311,8 @@ class Battle::Battler
|
|||||||
ret.push(:NORMAL) if ret.length == 0
|
ret.push(:NORMAL) if ret.length == 0
|
||||||
end
|
end
|
||||||
# Add the third type specially.
|
# Add the third type specially.
|
||||||
if withType3 && @effects[PBEffects::Type3]
|
if withType3 && @effects[PBEffects::Type3] && !ret.include?(@effects[PBEffects::Type3])
|
||||||
ret.push(@effects[PBEffects::Type3]) if !ret.include?(@effects[PBEffects::Type3])
|
ret.push(@effects[PBEffects::Type3])
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -277,14 +277,13 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Zygarde - Power Construct
|
# Zygarde - Power Construct
|
||||||
if isSpecies?(:ZYGARDE) && self.ability == :POWERCONSTRUCT && endOfRound
|
if isSpecies?(:ZYGARDE) && self.ability == :POWERCONSTRUCT && endOfRound &&
|
||||||
if @hp <= @totalhp / 2 && @form < 2 # Turn into Complete Forme
|
@hp <= @totalhp / 2 && @form < 2 # Turn into Complete Forme
|
||||||
newForm = @form + 2
|
newForm = @form + 2
|
||||||
@battle.pbDisplay(_INTL("You sense the presence of many!"))
|
@battle.pbDisplay(_INTL("You sense the presence of many!"))
|
||||||
@battle.pbShowAbilitySplash(self, true)
|
@battle.pbShowAbilitySplash(self, true)
|
||||||
@battle.pbHideAbilitySplash(self)
|
@battle.pbHideAbilitySplash(self)
|
||||||
pbChangeForm(newForm, _INTL("{1} transformed into its Complete Forme!", pbThis))
|
pbChangeForm(newForm, _INTL("{1} transformed into its Complete Forme!", pbThis))
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Morpeko - Hunger Switch
|
# Morpeko - Hunger Switch
|
||||||
if isSpecies?(:MORPEKO) && hasActiveAbility?(:HUNGERSWITCH) && endOfRound
|
if isSpecies?(:MORPEKO) && hasActiveAbility?(:HUNGERSWITCH) && endOfRound
|
||||||
|
|||||||
@@ -281,11 +281,11 @@ class Battle::Battler
|
|||||||
|
|
||||||
def pbCanSleepYawn?
|
def pbCanSleepYawn?
|
||||||
return false if self.status != :NONE
|
return false if self.status != :NONE
|
||||||
if affectedByTerrain?
|
if affectedByTerrain? && [:Electric, :Misty].include?(@battle.field.terrain)
|
||||||
return false if [:Electric, :Misty].include?(@battle.field.terrain)
|
return false
|
||||||
end
|
end
|
||||||
if !hasActiveAbility?(:SOUNDPROOF)
|
if !hasActiveAbility?(:SOUNDPROOF) && @battle.allBattlers.any? { |b| b.effects[PBEffects::Uproar] > 0 }
|
||||||
return false if @battle.allBattlers.any? { |b| b.effects[PBEffects::Uproar] > 0 }
|
return false
|
||||||
end
|
end
|
||||||
if Battle::AbilityEffects.triggerStatusImmunityNonIgnorable(self.ability, self, :SLEEP)
|
if Battle::AbilityEffects.triggerStatusImmunityNonIgnorable(self.ability, self, :SLEEP)
|
||||||
return false
|
return false
|
||||||
@@ -454,19 +454,17 @@ class Battle::Battler
|
|||||||
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!", pbThis(true))) if showMessages
|
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!", pbThis(true))) if showMessages
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if selfInflicted || !@battle.moldBreaker
|
if (selfInflicted || !@battle.moldBreaker) && hasActiveAbility?(:OWNTEMPO)
|
||||||
if hasActiveAbility?(:OWNTEMPO)
|
if showMessages
|
||||||
if showMessages
|
@battle.pbShowAbilitySplash(self)
|
||||||
@battle.pbShowAbilitySplash(self)
|
if Battle::Scene::USE_ABILITY_SPLASH
|
||||||
if Battle::Scene::USE_ABILITY_SPLASH
|
@battle.pbDisplay(_INTL("{1} doesn't become confused!", pbThis))
|
||||||
@battle.pbDisplay(_INTL("{1} doesn't become confused!", pbThis))
|
else
|
||||||
else
|
@battle.pbDisplay(_INTL("{1}'s {2} prevents confusion!", pbThis, abilityName))
|
||||||
@battle.pbDisplay(_INTL("{1}'s {2} prevents confusion!", pbThis, abilityName))
|
|
||||||
end
|
|
||||||
@battle.pbHideAbilitySplash(self)
|
|
||||||
end
|
end
|
||||||
return false
|
@battle.pbHideAbilitySplash(self)
|
||||||
end
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !selfInflicted &&
|
if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !selfInflicted &&
|
||||||
!(user && user.hasActiveAbility?(:INFILTRATOR))
|
!(user && user.hasActiveAbility?(:INFILTRATOR))
|
||||||
|
|||||||
@@ -118,7 +118,8 @@ class Battle::Battler
|
|||||||
return @stages[stat] <= -6
|
return @stages[stat] <= -6
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false, ignoreMirrorArmor = false)
|
def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false,
|
||||||
|
ignoreContrary = false, ignoreMirrorArmor = false)
|
||||||
return false if fainted?
|
return false if fainted?
|
||||||
if !@battle.moldBreaker
|
if !@battle.moldBreaker
|
||||||
# Contrary
|
# Contrary
|
||||||
@@ -126,12 +127,14 @@ class Battle::Battler
|
|||||||
return pbCanRaiseStatStage?(stat, user, move, showFailMsg, true)
|
return pbCanRaiseStatStage?(stat, user, move, showFailMsg, true)
|
||||||
end
|
end
|
||||||
# Mirror Armor
|
# Mirror Armor
|
||||||
if hasActiveAbility?(:MIRRORARMOR) && !ignoreMirrorArmor && user && user.index != @index
|
if hasActiveAbility?(:MIRRORARMOR) && !ignoreMirrorArmor &&
|
||||||
return true if !statStageAtMin?(stat)
|
user && user.index != @index && !statStageAtMin?(stat)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if !user || user.index != @index # Not self-inflicted
|
if !user || user.index != @index # Not self-inflicted
|
||||||
if @effects[PBEffects::Substitute] > 0 && (ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user)))
|
if @effects[PBEffects::Substitute] > 0 &&
|
||||||
|
(ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user)))
|
||||||
@battle.pbDisplay(_INTL("{1} is protected by its substitute!", pbThis)) if showFailMsg
|
@battle.pbDisplay(_INTL("{1} is protected by its substitute!", pbThis)) if showFailMsg
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@@ -328,13 +331,12 @@ class Battle::Battler
|
|||||||
pbThis, user.pbThis(true), user.abilityName))
|
pbThis, user.pbThis(true), user.abilityName))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if abilityActive?
|
if abilityActive? &&
|
||||||
if Battle::AbilityEffects.triggerStatLossImmunity(self.ability, self, :ATTACK, @battle, false) ||
|
(Battle::AbilityEffects.triggerStatLossImmunity(self.ability, self, :ATTACK, @battle, false) ||
|
||||||
Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable(self.ability, self, :ATTACK, @battle, false)
|
Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable(self.ability, self, :ATTACK, @battle, false))
|
||||||
@battle.pbDisplay(_INTL("{1}'s {2} prevented {3}'s {4} from working!",
|
@battle.pbDisplay(_INTL("{1}'s {2} prevented {3}'s {4} from working!",
|
||||||
pbThis, abilityName, user.pbThis(true), user.abilityName))
|
pbThis, abilityName, user.pbThis(true), user.abilityName))
|
||||||
return false
|
return false
|
||||||
end
|
|
||||||
end
|
end
|
||||||
allAllies.each do |b|
|
allAllies.each do |b|
|
||||||
next if !b.abilityActive?
|
next if !b.abilityActive?
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ class Battle::Battler
|
|||||||
|
|
||||||
def pbItemsOnUnnerveEnding
|
def pbItemsOnUnnerveEnding
|
||||||
@battle.pbPriority(true).each do |b|
|
@battle.pbPriority(true).each do |b|
|
||||||
b.pbHeldItemTriggerCheck if b.item && b.item.is_berry?
|
b.pbHeldItemTriggerCheck if b.item&.is_berry?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -175,12 +175,11 @@ class Battle::Battler
|
|||||||
elsif @effects[PBEffects::Encore] > 0 && choice[1] >= 0 &&
|
elsif @effects[PBEffects::Encore] > 0 && choice[1] >= 0 &&
|
||||||
@battle.pbCanShowCommands?(@index)
|
@battle.pbCanShowCommands?(@index)
|
||||||
idxEncoredMove = pbEncoredMoveIndex
|
idxEncoredMove = pbEncoredMoveIndex
|
||||||
if idxEncoredMove >= 0 && @battle.pbCanChooseMove?(@index, idxEncoredMove, false)
|
if idxEncoredMove >= 0 && choice[1] != idxEncoredMove &&
|
||||||
if choice[1] != idxEncoredMove # Change move if battler was Encored mid-round
|
@battle.pbCanChooseMove?(@index, idxEncoredMove, false) # Change move if battler was Encored mid-round
|
||||||
choice[1] = idxEncoredMove
|
choice[1] = idxEncoredMove
|
||||||
choice[2] = @moves[idxEncoredMove]
|
choice[2] = @moves[idxEncoredMove]
|
||||||
choice[3] = -1 # No target chosen
|
choice[3] = -1 # No target chosen
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Labels the move being used as "move"
|
# Labels the move being used as "move"
|
||||||
@@ -203,19 +202,17 @@ class Battle::Battler
|
|||||||
move = choice[2] # In case disobedience changed the move to be used
|
move = choice[2] # In case disobedience changed the move to be used
|
||||||
return if !move # if move was not chosen somehow
|
return if !move # if move was not chosen somehow
|
||||||
# Subtract PP
|
# Subtract PP
|
||||||
if !specialUsage
|
if !specialUsage && !pbReducePP(move)
|
||||||
if !pbReducePP(move)
|
@battle.pbDisplay(_INTL("{1} used {2}!", pbThis, move.name))
|
||||||
@battle.pbDisplay(_INTL("{1} used {2}!", pbThis, move.name))
|
@battle.pbDisplay(_INTL("But there was no PP left for the move!"))
|
||||||
@battle.pbDisplay(_INTL("But there was no PP left for the move!"))
|
@lastMoveUsed = nil
|
||||||
@lastMoveUsed = nil
|
@lastMoveUsedType = nil
|
||||||
@lastMoveUsedType = nil
|
@lastRegularMoveUsed = nil
|
||||||
@lastRegularMoveUsed = nil
|
@lastRegularMoveTarget = -1
|
||||||
@lastRegularMoveTarget = -1
|
@lastMoveFailed = true
|
||||||
@lastMoveFailed = true
|
pbCancelMoves
|
||||||
pbCancelMoves
|
pbEndTurn(choice)
|
||||||
pbEndTurn(choice)
|
return
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Stance Change
|
# Stance Change
|
||||||
if isSpecies?(:AEGISLASH) && self.ability == :STANCECHANGE
|
if isSpecies?(:AEGISLASH) && self.ability == :STANCECHANGE
|
||||||
@@ -356,21 +353,21 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Protean
|
# Protean
|
||||||
if user.hasActiveAbility?([:LIBERO, :PROTEAN]) && !move.callsAnotherMove? && !move.snatched
|
if user.hasActiveAbility?([:LIBERO, :PROTEAN]) &&
|
||||||
if user.pbHasOtherType?(move.calcType) && !GameData::Type.get(move.calcType).pseudo_type
|
!move.callsAnotherMove? && !move.snatched &&
|
||||||
@battle.pbShowAbilitySplash(user)
|
user.pbHasOtherType?(move.calcType) && !GameData::Type.get(move.calcType).pseudo_type
|
||||||
user.pbChangeTypes(move.calcType)
|
@battle.pbShowAbilitySplash(user)
|
||||||
typeName = GameData::Type.get(move.calcType).name
|
user.pbChangeTypes(move.calcType)
|
||||||
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName))
|
typeName = GameData::Type.get(move.calcType).name
|
||||||
@battle.pbHideAbilitySplash(user)
|
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName))
|
||||||
# NOTE: The GF games say that if Curse is used by a non-Ghost-type
|
@battle.pbHideAbilitySplash(user)
|
||||||
# Pokémon which becomes Ghost-type because of Protean, it should
|
# NOTE: The GF games say that if Curse is used by a non-Ghost-type
|
||||||
# target and curse itself. I think this is silly, so I'm making it
|
# Pokémon which becomes Ghost-type because of Protean, it should
|
||||||
# choose a random opponent to curse instead.
|
# target and curse itself. I think this is silly, so I'm making it
|
||||||
if move.function == "CurseTargetOrLowerUserSpd1RaiseUserAtkDef1" && targets.length == 0
|
# choose a random opponent to curse instead.
|
||||||
choice[3] = -1
|
if move.function == "CurseTargetOrLowerUserSpd1RaiseUserAtkDef1" && targets.length == 0
|
||||||
targets = pbFindTargets(choice, move, user)
|
choice[3] = -1
|
||||||
end
|
targets = pbFindTargets(choice, move, user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
@@ -486,7 +483,7 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
pbProcessMoveHit(move, b, newTargets, 0, false) if success
|
pbProcessMoveHit(move, b, newTargets, 0, false) if success
|
||||||
b.lastMoveFailed = true if !success
|
b.lastMoveFailed = true if !success
|
||||||
targets.each { |otherB| otherB.pbFaint if otherB && otherB.fainted? }
|
targets.each { |otherB| otherB.pbFaint if otherB&.fainted? }
|
||||||
user.pbFaint if user.fainted?
|
user.pbFaint if user.fainted?
|
||||||
end
|
end
|
||||||
# Magic Coat's bouncing back (move has no targets)
|
# Magic Coat's bouncing back (move has no targets)
|
||||||
@@ -502,14 +499,14 @@ class Battle::Battler
|
|||||||
success = pbProcessMoveHit(move, mc, [], 0, false)
|
success = pbProcessMoveHit(move, mc, [], 0, false)
|
||||||
end
|
end
|
||||||
mc.lastMoveFailed = true if !success
|
mc.lastMoveFailed = true if !success
|
||||||
targets.each { |b| b.pbFaint if b && b.fainted? }
|
targets.each { |b| b.pbFaint if b&.fainted? }
|
||||||
user.pbFaint if user.fainted?
|
user.pbFaint if user.fainted?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Move-specific effects after all hits
|
# Move-specific effects after all hits
|
||||||
targets.each { |b| move.pbEffectAfterAllHits(user, b) }
|
targets.each { |b| move.pbEffectAfterAllHits(user, b) }
|
||||||
# Faint if 0 HP
|
# Faint if 0 HP
|
||||||
targets.each { |b| b.pbFaint if b && b.fainted? }
|
targets.each { |b| b.pbFaint if b&.fainted? }
|
||||||
user.pbFaint if user.fainted?
|
user.pbFaint if user.fainted?
|
||||||
# External/general effects after all hits. Eject Button, Shell Bell, etc.
|
# External/general effects after all hits. Eject Button, Shell Bell, etc.
|
||||||
pbEffectsAfterMove(user, targets, move, realNumHits)
|
pbEffectsAfterMove(user, targets, move, realNumHits)
|
||||||
@@ -707,7 +704,7 @@ class Battle::Battler
|
|||||||
@battle.pbPriority(true).each { |b| b.pbItemHPHealCheck }
|
@battle.pbPriority(true).each { |b| b.pbItemHPHealCheck }
|
||||||
# Animate battlers fainting (checks all battlers rather than just targets
|
# Animate battlers fainting (checks all battlers rather than just targets
|
||||||
# because Flame Burst's splash damage affects non-targets)
|
# because Flame Burst's splash damage affects non-targets)
|
||||||
@battle.pbPriority(true).each { |b| b.pbFaint if b && b.fainted? }
|
@battle.pbPriority(true).each { |b| b.pbFaint if b&.fainted? }
|
||||||
end
|
end
|
||||||
@battle.pbJudgeCheckpoint(user, move)
|
@battle.pbJudgeCheckpoint(user, move)
|
||||||
# Main effect (recoil/drain, etc.)
|
# Main effect (recoil/drain, etc.)
|
||||||
@@ -716,7 +713,7 @@ class Battle::Battler
|
|||||||
move.pbEffectAgainstTarget(user, b)
|
move.pbEffectAgainstTarget(user, b)
|
||||||
end
|
end
|
||||||
move.pbEffectGeneral(user)
|
move.pbEffectGeneral(user)
|
||||||
targets.each { |b| b.pbFaint if b && b.fainted? }
|
targets.each { |b| b.pbFaint if b&.fainted? }
|
||||||
user.pbFaint if user.fainted?
|
user.pbFaint if user.fainted?
|
||||||
# Additional effect
|
# Additional effect
|
||||||
if !user.hasActiveAbility?(:SHEERFORCE)
|
if !user.hasActiveAbility?(:SHEERFORCE)
|
||||||
@@ -761,13 +758,12 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Fainting
|
# Fainting
|
||||||
targets.each { |b| b.pbFaint if b && b.fainted? }
|
targets.each { |b| b.pbFaint if b&.fainted? }
|
||||||
user.pbFaint if user.fainted?
|
user.pbFaint if user.fainted?
|
||||||
# Dragon Darts' second half of attack
|
# Dragon Darts' second half of attack
|
||||||
if move.pbRepeatHit? && hitNum == 0
|
if move.pbRepeatHit? && hitNum == 0 &&
|
||||||
if targets.any? { |b| !b.fainted? && !b.damageState.unaffected }
|
targets.any? { |b| !b.fainted? && !b.damageState.unaffected }
|
||||||
pbProcessMoveHit(move, user, all_targets, 1, skipAccuracyCheck)
|
pbProcessMoveHit(move, user, all_targets, 1, skipAccuracyCheck)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -265,12 +265,10 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Paralysis
|
# Paralysis
|
||||||
if @status == :PARALYSIS
|
if @status == :PARALYSIS && @battle.pbRandom(100) < 25
|
||||||
if @battle.pbRandom(100) < 25
|
pbContinueStatus
|
||||||
pbContinueStatus
|
@lastMoveFailed = true
|
||||||
@lastMoveFailed = true
|
return false
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Infatuation
|
# Infatuation
|
||||||
if @effects[PBEffects::Attract] >= 0
|
if @effects[PBEffects::Attract] >= 0
|
||||||
@@ -358,10 +356,9 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
target.damageState.protected = true
|
target.damageState.protected = true
|
||||||
@battle.successStates[user.index].protected = true
|
@battle.successStates[user.index].protected = true
|
||||||
if move.pbContactMove?(user) && user.affectedByContactEffect?
|
if move.pbContactMove?(user) && user.affectedByContactEffect? &&
|
||||||
if user.pbCanLowerStatStage?(:ATTACK, target)
|
user.pbCanLowerStatStage?(:ATTACK, target)
|
||||||
user.pbLowerStatStage(:ATTACK, (Settings::MECHANICS_GENERATION >= 8) ? 1 : 2, target)
|
user.pbLowerStatStage(:ATTACK, (Settings::MECHANICS_GENERATION >= 8) ? 1 : 2, target)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@@ -389,8 +386,9 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
target.damageState.protected = true
|
target.damageState.protected = true
|
||||||
@battle.successStates[user.index].protected = true
|
@battle.successStates[user.index].protected = true
|
||||||
if move.pbContactMove?(user) && user.affectedByContactEffect?
|
if move.pbContactMove?(user) && user.affectedByContactEffect? &&
|
||||||
user.pbPoison(target) if user.pbCanPoison?(target, false)
|
user.pbCanPoison?(target, false)
|
||||||
|
user.pbPoison(target)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@@ -402,10 +400,9 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
target.damageState.protected = true
|
target.damageState.protected = true
|
||||||
@battle.successStates[user.index].protected = true
|
@battle.successStates[user.index].protected = true
|
||||||
if move.pbContactMove?(user) && user.affectedByContactEffect?
|
if move.pbContactMove?(user) && user.affectedByContactEffect? &&
|
||||||
if user.pbCanLowerStatStage?(:DEFENSE, target)
|
user.pbCanLowerStatStage?(:DEFENSE, target)
|
||||||
user.pbLowerStatStage(:DEFENSE, 2, target)
|
user.pbLowerStatStage(:DEFENSE, 2, target)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@@ -550,8 +547,8 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if target.effects[PBEffects::SkyDrop] >= 0 &&
|
if target.effects[PBEffects::SkyDrop] >= 0 &&
|
||||||
target.effects[PBEffects::SkyDrop] != user.index
|
target.effects[PBEffects::SkyDrop] != user.index && !move.hitsFlyingTargets?
|
||||||
miss = true if !move.hitsFlyingTargets?
|
miss = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
target.damageState.invulnerable = true if miss
|
target.damageState.invulnerable = true if miss
|
||||||
@@ -572,9 +569,7 @@ class Battle::Battler
|
|||||||
def pbMissMessage(move, user, target)
|
def pbMissMessage(move, user, target)
|
||||||
if target.damageState.affection_missed
|
if target.damageState.affection_missed
|
||||||
@battle.pbDisplay(_INTL("{1} avoided the move in time with your shout!", target.pbThis))
|
@battle.pbDisplay(_INTL("{1} avoided the move in time with your shout!", target.pbThis))
|
||||||
elsif move.pbTarget(user).num_targets > 1
|
elsif move.pbTarget(user).num_targets > 1 || target.effects[PBEffects::TwoTurnAttack]
|
||||||
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
|
|
||||||
elsif target.effects[PBEffects::TwoTurnAttack]
|
|
||||||
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
|
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
|
||||||
elsif !move.pbMissMessage(user, target)
|
elsif !move.pbMissMessage(user, target)
|
||||||
@battle.pbDisplay(_INTL("{1}'s attack missed!", user.pbThis))
|
@battle.pbDisplay(_INTL("{1}'s attack missed!", user.pbThis))
|
||||||
|
|||||||
@@ -45,27 +45,26 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
if target.opposes?(user)
|
if target.opposes?(user)
|
||||||
# Rage
|
# Rage
|
||||||
if target.effects[PBEffects::Rage] && !target.fainted?
|
if target.effects[PBEffects::Rage] && !target.fainted? &&
|
||||||
if target.pbCanRaiseStatStage?(:ATTACK, target)
|
target.pbCanRaiseStatStage?(:ATTACK, target)
|
||||||
@battle.pbDisplay(_INTL("{1}'s rage is building!", target.pbThis))
|
@battle.pbDisplay(_INTL("{1}'s rage is building!", target.pbThis))
|
||||||
target.pbRaiseStatStage(:ATTACK, 1, target)
|
target.pbRaiseStatStage(:ATTACK, 1, target)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Beak Blast
|
# Beak Blast
|
||||||
if target.effects[PBEffects::BeakBlast]
|
if target.effects[PBEffects::BeakBlast]
|
||||||
PBDebug.log("[Lingering effect] #{target.pbThis}'s Beak Blast")
|
PBDebug.log("[Lingering effect] #{target.pbThis}'s Beak Blast")
|
||||||
if move.pbContactMove?(user) && user.affectedByContactEffect?
|
if move.pbContactMove?(user) && user.affectedByContactEffect? &&
|
||||||
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
|
target.pbCanBurn?(user, false, self)
|
||||||
|
target.pbBurn(user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Shell Trap (make the trapper move next if the trap was triggered)
|
# Shell Trap (make the trapper move next if the trap was triggered)
|
||||||
if target.effects[PBEffects::ShellTrap] &&
|
if target.effects[PBEffects::ShellTrap] && move.physicalMove? &&
|
||||||
@battle.choices[target.index][0] == :UseMove && !target.movedThisRound?
|
@battle.choices[target.index][0] == :UseMove && !target.movedThisRound? &&
|
||||||
if target.damageState.hpLost > 0 && !target.damageState.substitute && move.physicalMove?
|
target.damageState.hpLost > 0 && !target.damageState.substitute
|
||||||
target.tookPhysicalHit = true
|
target.tookPhysicalHit = true
|
||||||
target.effects[PBEffects::MoveNext] = true
|
target.effects[PBEffects::MoveNext] = true
|
||||||
target.effects[PBEffects::Quash] = 0
|
target.effects[PBEffects::Quash] = 0
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Grudge
|
# Grudge
|
||||||
if target.effects[PBEffects::Grudge] && target.fainted?
|
if target.effects[PBEffects::Grudge] && target.fainted?
|
||||||
@@ -74,10 +73,9 @@ class Battle::Battler
|
|||||||
user.pbThis, move.name))
|
user.pbThis, move.name))
|
||||||
end
|
end
|
||||||
# Destiny Bond (recording that it should apply)
|
# Destiny Bond (recording that it should apply)
|
||||||
if target.effects[PBEffects::DestinyBond] && target.fainted?
|
if target.effects[PBEffects::DestinyBond] && target.fainted? &&
|
||||||
if user.effects[PBEffects::DestinyBondTarget] < 0
|
user.effects[PBEffects::DestinyBondTarget] < 0
|
||||||
user.effects[PBEffects::DestinyBondTarget] = target.index
|
user.effects[PBEffects::DestinyBondTarget] = target.index
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -114,10 +112,10 @@ class Battle::Battler
|
|||||||
if user.abilityActive?
|
if user.abilityActive?
|
||||||
Battle::AbilityEffects.triggerOnEndOfUsingMove(user.ability, user, targets, move, @battle)
|
Battle::AbilityEffects.triggerOnEndOfUsingMove(user.ability, user, targets, move, @battle)
|
||||||
end
|
end
|
||||||
# Greninja - Battle Bond
|
|
||||||
if !user.fainted? && !user.effects[PBEffects::Transform] &&
|
if !user.fainted? && !user.effects[PBEffects::Transform] &&
|
||||||
user.isSpecies?(:GRENINJA) && user.ability == :BATTLEBOND
|
!@battle.pbAllFainted?(user.idxOpposingSide)
|
||||||
if !@battle.pbAllFainted?(user.idxOpposingSide) &&
|
# Greninja - Battle Bond
|
||||||
|
if user.isSpecies?(:GRENINJA) && user.ability == :BATTLEBOND &&
|
||||||
!@battle.battleBond[user.index & 1][user.pokemonIndex]
|
!@battle.battleBond[user.index & 1][user.pokemonIndex]
|
||||||
numFainted = 0
|
numFainted = 0
|
||||||
targets.each { |b| numFainted += 1 if b.damageState.fainted }
|
targets.each { |b| numFainted += 1 if b.damageState.fainted }
|
||||||
@@ -129,11 +127,8 @@ class Battle::Battler
|
|||||||
user.pbChangeForm(2, _INTL("{1} became Ash-Greninja!", user.pbThis))
|
user.pbChangeForm(2, _INTL("{1} became Ash-Greninja!", user.pbThis))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
# Cramorant = Gulp Missile
|
||||||
# Cramorant = Gulp Missile
|
if user.isSpecies?(:CRAMORANT) && user.ability == :GULPMISSILE && user.form == 0 &&
|
||||||
if !user.fainted? && !user.effects[PBEffects::Transform] &&
|
|
||||||
user.isSpecies?(:CRAMORANT) && user.ability == :GULPMISSILE && user.form == 0
|
|
||||||
if !@battle.pbAllFainted?(user.idxOpposingSide) &&
|
|
||||||
((move.id == :SURF && numHits > 0) || (move.id == :DIVE && move.chargingTurn))
|
((move.id == :SURF && numHits > 0) || (move.id == :DIVE && move.chargingTurn))
|
||||||
# NOTE: Intentionally no ability splash or message here.
|
# NOTE: Intentionally no ability splash or message here.
|
||||||
user.pbChangeForm((user.hp > user.totalhp / 2) ? 1 : 2, nil)
|
user.pbChangeForm((user.hp > user.totalhp / 2) ? 1 : 2, nil)
|
||||||
@@ -181,16 +176,13 @@ class Battle::Battler
|
|||||||
def pbEffectsAfterMove2(user, targets, move, numHits, switched_battlers)
|
def pbEffectsAfterMove2(user, targets, move, numHits, switched_battlers)
|
||||||
# Target's held item (Eject Button, Red Card, Eject Pack)
|
# Target's held item (Eject Button, Red Card, Eject Pack)
|
||||||
@battle.pbPriority(true).each do |b|
|
@battle.pbPriority(true).each do |b|
|
||||||
if targets.any? { |targetB| targetB.index == b.index }
|
if targets.any? { |targetB| targetB.index == b.index } &&
|
||||||
if !b.damageState.unaffected && b.damageState.calcDamage > 0 && b.itemActive?
|
!b.damageState.unaffected && b.damageState.calcDamage > 0 && b.itemActive?
|
||||||
Battle::ItemEffects.triggerAfterMoveUseFromTarget(b.item, b, user, move, switched_battlers, @battle)
|
Battle::ItemEffects.triggerAfterMoveUseFromTarget(b.item, b, user, move, switched_battlers, @battle)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Target's Eject Pack
|
# Target's Eject Pack
|
||||||
if switched_battlers.empty? && b.index != user.index
|
if switched_battlers.empty? && b.index != user.index && b.pbItemOnStatDropped(user)
|
||||||
if b.pbItemOnStatDropped(user)
|
switched_battlers.push(b.index)
|
||||||
switched_battlers.push(b.index)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# User's held item (Life Orb, Shell Bell, Throat Spray, Eject Pack)
|
# User's held item (Life Orb, Shell Bell, Throat Spray, Eject Pack)
|
||||||
@@ -199,16 +191,14 @@ class Battle::Battler
|
|||||||
end
|
end
|
||||||
# Target's ability (Berserk, Color Change, Emergency Exit, Pickpocket, Wimp Out)
|
# Target's ability (Berserk, Color Change, Emergency Exit, Pickpocket, Wimp Out)
|
||||||
@battle.pbPriority(true).each do |b|
|
@battle.pbPriority(true).each do |b|
|
||||||
if targets.any? { |targetB| targetB.index == b.index }
|
if targets.any? { |targetB| targetB.index == b.index } &&
|
||||||
if !b.damageState.unaffected && !switched_battlers.include?(b.index) && b.abilityActive?
|
!b.damageState.unaffected && !switched_battlers.include?(b.index) && b.abilityActive?
|
||||||
Battle::AbilityEffects.triggerAfterMoveUseFromTarget(b.ability, b, user, move, switched_battlers, @battle)
|
Battle::AbilityEffects.triggerAfterMoveUseFromTarget(b.ability, b, user, move, switched_battlers, @battle)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Target's Emergency Exit, Wimp Out (including for Pokémon hurt by Flame Burst)
|
# Target's Emergency Exit, Wimp Out (including for Pokémon hurt by Flame Burst)
|
||||||
if switched_battlers.empty? && move.damagingMove? && b.index != user.index
|
if switched_battlers.empty? && move.damagingMove? &&
|
||||||
if b.pbAbilitiesOnDamageTaken(user)
|
b.index != user.index && b.pbAbilitiesOnDamageTaken(user)
|
||||||
switched_battlers.push(b.index)
|
switched_battlers.push(b.index)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -216,16 +206,12 @@ class Battle::Battler
|
|||||||
# Everything in this method is negated by Sheer Force.
|
# Everything in this method is negated by Sheer Force.
|
||||||
def pbEffectsAfterMove3(user, targets, move, numHits, switched_battlers)
|
def pbEffectsAfterMove3(user, targets, move, numHits, switched_battlers)
|
||||||
# User's held item that switches it out (Eject Pack)
|
# User's held item that switches it out (Eject Pack)
|
||||||
if switched_battlers.empty?
|
if switched_battlers.empty? && user.pbItemOnStatDropped(user)
|
||||||
if user.pbItemOnStatDropped(user)
|
switched_battlers.push(user.index)
|
||||||
switched_battlers.push(user.index)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# User's ability (Emergency Exit, Wimp Out)
|
# User's ability (Emergency Exit, Wimp Out)
|
||||||
if switched_battlers.empty? && move.damagingMove?
|
if switched_battlers.empty? && move.damagingMove? && user.pbAbilitiesOnDamageTaken(user)
|
||||||
if user.pbAbilitiesOnDamageTaken(user)
|
switched_battlers.push(user.index)
|
||||||
switched_battlers.push(user.index)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ class Battle::Move
|
|||||||
def ignoresSubstitute?(user) # user is the Pokémon using this move
|
def ignoresSubstitute?(user) # user is the Pokémon using this move
|
||||||
if Settings::MECHANICS_GENERATION >= 6
|
if Settings::MECHANICS_GENERATION >= 6
|
||||||
return true if soundMove?
|
return true if soundMove?
|
||||||
return true if user && user.hasActiveAbility?(:INFILTRATOR)
|
return true if user&.hasActiveAbility?(:INFILTRATOR)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,28 +31,29 @@ class Battle::Move
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
def pbCalcTypeModSingle(moveType, defType, user, target)
|
def pbCalcTypeModSingle(moveType, defType, user, target)
|
||||||
ret = Effectiveness.calculate_one(moveType, defType)
|
ret = Effectiveness.calculate_one(moveType, defType)
|
||||||
# Ring Target
|
if Effectiveness.ineffective_type?(moveType, defType)
|
||||||
if target.hasActiveItem?(:RINGTARGET)
|
# Ring Target
|
||||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if Effectiveness.ineffective_type?(moveType, defType)
|
if target.hasActiveItem?(:RINGTARGET)
|
||||||
end
|
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||||
# Foresight
|
end
|
||||||
if user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]
|
# Foresight
|
||||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :GHOST &&
|
if (user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]) &&
|
||||||
Effectiveness.ineffective_type?(moveType, defType)
|
defType == :GHOST
|
||||||
end
|
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||||
# Miracle Eye
|
end
|
||||||
if target.effects[PBEffects::MiracleEye]
|
# Miracle Eye
|
||||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :DARK &&
|
if target.effects[PBEffects::MiracleEye] && defType == :DARK
|
||||||
Effectiveness.ineffective_type?(moveType, defType)
|
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||||
end
|
end
|
||||||
# Delta Stream's weather
|
elsif Effectiveness.super_effective_type?(moveType, defType)
|
||||||
if target.effectiveWeather == :StrongWinds
|
# Delta Stream's weather
|
||||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING &&
|
if target.effectiveWeather == :StrongWinds && defType == :FLYING
|
||||||
Effectiveness.super_effective_type?(moveType, defType)
|
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||||
|
end
|
||||||
end
|
end
|
||||||
# Grounded Flying-type Pokémon become susceptible to Ground moves
|
# Grounded Flying-type Pokémon become susceptible to Ground moves
|
||||||
if !target.airborne?
|
if !target.airborne? && defType == :FLYING && moveType == :GROUND
|
||||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && moveType == :GROUND
|
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
@@ -493,9 +494,9 @@ class Battle::Move
|
|||||||
def pbAdditionalEffectChance(user, target, effectChance = 0)
|
def pbAdditionalEffectChance(user, target, effectChance = 0)
|
||||||
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
|
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
|
||||||
ret = (effectChance > 0) ? effectChance : @addlEffect
|
ret = (effectChance > 0) ? effectChance : @addlEffect
|
||||||
if Settings::MECHANICS_GENERATION >= 6 || @function != "EffectDependsOnEnvironment"
|
if (Settings::MECHANICS_GENERATION >= 6 || @function != "EffectDependsOnEnvironment") &&
|
||||||
ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) ||
|
(user.hasActiveAbility?(:SERENEGRACE) || user.pbOwnSide.effects[PBEffects::Rainbow] > 0)
|
||||||
user.pbOwnSide.effects[PBEffects::Rainbow] > 0
|
ret *= 2
|
||||||
end
|
end
|
||||||
ret = 100 if $DEBUG && Input.press?(Input::CTRL)
|
ret = 100 if $DEBUG && Input.press?(Input::CTRL)
|
||||||
return ret
|
return ret
|
||||||
@@ -507,9 +508,8 @@ class Battle::Move
|
|||||||
return 0 if flinchingMove?
|
return 0 if flinchingMove?
|
||||||
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
|
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
|
||||||
ret = 0
|
ret = 0
|
||||||
if user.hasActiveAbility?(:STENCH, true)
|
if user.hasActiveAbility?(:STENCH, true) ||
|
||||||
ret = 10
|
user.hasActiveItem?([:KINGSROCK, :RAZORFANG], true)
|
||||||
elsif user.hasActiveItem?([:KINGSROCK, :RAZORFANG], true)
|
|
||||||
ret = 10
|
ret = 10
|
||||||
end
|
end
|
||||||
ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) ||
|
ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) ||
|
||||||
|
|||||||
@@ -1427,9 +1427,7 @@ class Battle::Move::RaiseUserAndAlliesAtkDef1 < Battle::Move
|
|||||||
def pbEffectAgainstTarget(user, target)
|
def pbEffectAgainstTarget(user, target)
|
||||||
showAnim = true
|
showAnim = true
|
||||||
if target.pbCanRaiseStatStage?(:ATTACK, user, self)
|
if target.pbCanRaiseStatStage?(:ATTACK, user, self)
|
||||||
if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
showAnim = false if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||||
showAnim = false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if target.pbCanRaiseStatStage?(:DEFENSE, user, self)
|
if target.pbCanRaiseStatStage?(:DEFENSE, user, self)
|
||||||
target.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
|
target.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
|
||||||
@@ -1477,9 +1475,7 @@ class Battle::Move::RaisePlusMinusUserAndAlliesAtkSpAtk1 < Battle::Move
|
|||||||
def pbEffectAgainstTarget(user, target)
|
def pbEffectAgainstTarget(user, target)
|
||||||
showAnim = true
|
showAnim = true
|
||||||
if target.pbCanRaiseStatStage?(:ATTACK, user, self)
|
if target.pbCanRaiseStatStage?(:ATTACK, user, self)
|
||||||
if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
showAnim = false if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||||
showAnim = false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self)
|
if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self)
|
||||||
target.pbRaiseStatStage(:SPECIAL_ATTACK, 1, user, showAnim)
|
target.pbRaiseStatStage(:SPECIAL_ATTACK, 1, user, showAnim)
|
||||||
@@ -1532,9 +1528,7 @@ class Battle::Move::RaisePlusMinusUserAndAlliesDefSpDef1 < Battle::Move
|
|||||||
def pbEffectAgainstTarget(user, target)
|
def pbEffectAgainstTarget(user, target)
|
||||||
showAnim = true
|
showAnim = true
|
||||||
if target.pbCanRaiseStatStage?(:DEFENSE, user, self)
|
if target.pbCanRaiseStatStage?(:DEFENSE, user, self)
|
||||||
if target.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
|
showAnim = false if target.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
|
||||||
showAnim = false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if target.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, user, self)
|
if target.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, user, self)
|
||||||
target.pbRaiseStatStage(:SPECIAL_DEFENSE, 1, user, showAnim)
|
target.pbRaiseStatStage(:SPECIAL_DEFENSE, 1, user, showAnim)
|
||||||
@@ -1579,9 +1573,7 @@ class Battle::Move::RaiseGroundedGrassBattlersAtkSpAtk1 < Battle::Move
|
|||||||
def pbEffectAgainstTarget(user, target)
|
def pbEffectAgainstTarget(user, target)
|
||||||
showAnim = true
|
showAnim = true
|
||||||
if target.pbCanRaiseStatStage?(:ATTACK, user, self)
|
if target.pbCanRaiseStatStage?(:ATTACK, user, self)
|
||||||
if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
showAnim = false if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||||
showAnim = false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self)
|
if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self)
|
||||||
target.pbRaiseStatStage(:SPECIAL_ATTACK, 1, user, showAnim)
|
target.pbRaiseStatStage(:SPECIAL_ATTACK, 1, user, showAnim)
|
||||||
@@ -1729,9 +1721,7 @@ class Battle::Move::UserStealTargetPositiveStatStages < Battle::Move
|
|||||||
GameData::Stat.each_battle do |s|
|
GameData::Stat.each_battle do |s|
|
||||||
next if target.stages[s.id] <= 0
|
next if target.stages[s.id] <= 0
|
||||||
if user.pbCanRaiseStatStage?(s.id, user, self)
|
if user.pbCanRaiseStatStage?(s.id, user, self)
|
||||||
if user.pbRaiseStatStage(s.id, target.stages[s.id], user, showAnim)
|
showAnim = false if user.pbRaiseStatStage(s.id, target.stages[s.id], user, showAnim)
|
||||||
showAnim = false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
target.statsLoweredThisRound = true
|
target.statsLoweredThisRound = true
|
||||||
target.statsDropped = true
|
target.statsDropped = true
|
||||||
|
|||||||
@@ -209,8 +209,8 @@ class Battle::Move::ParalyzeFlinchTarget < Battle::Move
|
|||||||
return if target.damageState.substitute
|
return if target.damageState.substitute
|
||||||
chance = pbAdditionalEffectChance(user, target, 10)
|
chance = pbAdditionalEffectChance(user, target, 10)
|
||||||
return if chance == 0
|
return if chance == 0
|
||||||
if @battle.pbRandom(100) < chance
|
if target.pbCanParalyze?(user, false, self) && @battle.pbRandom(100) < chance
|
||||||
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
|
target.pbParalyze(user)
|
||||||
end
|
end
|
||||||
target.pbFlinch(user) if @battle.pbRandom(100) < chance
|
target.pbFlinch(user) if @battle.pbRandom(100) < chance
|
||||||
end
|
end
|
||||||
@@ -258,8 +258,8 @@ class Battle::Move::BurnFlinchTarget < Battle::Move
|
|||||||
return if target.damageState.substitute
|
return if target.damageState.substitute
|
||||||
chance = pbAdditionalEffectChance(user, target, 10)
|
chance = pbAdditionalEffectChance(user, target, 10)
|
||||||
return if chance == 0
|
return if chance == 0
|
||||||
if @battle.pbRandom(100) < chance
|
if target.pbCanBurn?(user, false, self) && @battle.pbRandom(100) < chance
|
||||||
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
|
target.pbBurn(user)
|
||||||
end
|
end
|
||||||
target.pbFlinch(user) if @battle.pbRandom(100) < chance
|
target.pbFlinch(user) if @battle.pbRandom(100) < chance
|
||||||
end
|
end
|
||||||
@@ -317,8 +317,8 @@ class Battle::Move::FreezeFlinchTarget < Battle::Move
|
|||||||
return if target.damageState.substitute
|
return if target.damageState.substitute
|
||||||
chance = pbAdditionalEffectChance(user, target, 10)
|
chance = pbAdditionalEffectChance(user, target, 10)
|
||||||
return if chance == 0
|
return if chance == 0
|
||||||
if @battle.pbRandom(100) < chance
|
if target.pbCanFreeze?(user, false, self) && @battle.pbRandom(100) < chance
|
||||||
target.pbFreeze if target.pbCanFreeze?(user, false, self)
|
target.pbFreeze
|
||||||
end
|
end
|
||||||
target.pbFlinch(user) if @battle.pbRandom(100) < chance
|
target.pbFlinch(user) if @battle.pbRandom(100) < chance
|
||||||
end
|
end
|
||||||
@@ -429,7 +429,7 @@ class Battle::Move::CureUserPartyStatus < Battle::Move
|
|||||||
def pbMoveFailed?(user, targets)
|
def pbMoveFailed?(user, targets)
|
||||||
has_effect = @battle.allSameSideBattlers(user).any? { |b| b.status != :NONE }
|
has_effect = @battle.allSameSideBattlers(user).any? { |b| b.status != :NONE }
|
||||||
if !has_effect
|
if !has_effect
|
||||||
has_effect = @battle.pbParty(user.index).any? { |pkmn| pkmn && pkmn.able? && pkmn.status != :NONE }
|
has_effect = @battle.pbParty(user.index).any? { |pkmn| pkmn&.able? && pkmn.status != :NONE }
|
||||||
end
|
end
|
||||||
if !has_effect
|
if !has_effect
|
||||||
@battle.pbDisplay(_INTL("But it failed!"))
|
@battle.pbDisplay(_INTL("But it failed!"))
|
||||||
|
|||||||
@@ -221,13 +221,12 @@ end
|
|||||||
class Battle::Move::TwoTurnAttackOneTurnInSun < Battle::Move::TwoTurnMove
|
class Battle::Move::TwoTurnAttackOneTurnInSun < Battle::Move::TwoTurnMove
|
||||||
def pbIsChargingTurn?(user)
|
def pbIsChargingTurn?(user)
|
||||||
ret = super
|
ret = super
|
||||||
if !user.effects[PBEffects::TwoTurnAttack]
|
if !user.effects[PBEffects::TwoTurnAttack] &&
|
||||||
if [:Sun, :HarshSun].include?(user.effectiveWeather)
|
[:Sun, :HarshSun].include?(user.effectiveWeather)
|
||||||
@powerHerb = false
|
@powerHerb = false
|
||||||
@chargingTurn = true
|
@chargingTurn = true
|
||||||
@damagingTurn = true
|
@damagingTurn = true
|
||||||
return false
|
return false
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -175,9 +175,7 @@ class Battle::Move::CurseTargetOrLowerUserSpd1RaiseUserAtkDef1 < Battle::Move
|
|||||||
end
|
end
|
||||||
showAnim = true
|
showAnim = true
|
||||||
if user.pbCanRaiseStatStage?(:ATTACK, user, self)
|
if user.pbCanRaiseStatStage?(:ATTACK, user, self)
|
||||||
if user.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
showAnim = false if user.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||||
showAnim = false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if user.pbCanRaiseStatStage?(:DEFENSE, user, self)
|
if user.pbCanRaiseStatStage?(:DEFENSE, user, self)
|
||||||
user.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
|
user.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
|
||||||
@@ -562,9 +560,7 @@ class Battle::Move::PowerDependsOnUserStockpile < Battle::Move
|
|||||||
showAnim = true
|
showAnim = true
|
||||||
if user.effects[PBEffects::StockpileDef] > 0 &&
|
if user.effects[PBEffects::StockpileDef] > 0 &&
|
||||||
user.pbCanLowerStatStage?(:DEFENSE, user, self)
|
user.pbCanLowerStatStage?(:DEFENSE, user, self)
|
||||||
if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
|
showAnim = false if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
|
||||||
showAnim = false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if user.effects[PBEffects::StockpileSpDef] > 0 &&
|
if user.effects[PBEffects::StockpileSpDef] > 0 &&
|
||||||
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self)
|
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self)
|
||||||
@@ -611,11 +607,9 @@ class Battle::Move::HealUserDependingOnUserStockpile < Battle::Move
|
|||||||
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!", user.pbThis))
|
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!", user.pbThis))
|
||||||
showAnim = true
|
showAnim = true
|
||||||
if user.effects[PBEffects::StockpileDef] > 0 &&
|
if user.effects[PBEffects::StockpileDef] > 0 &&
|
||||||
user.pbCanLowerStatStage?(:DEFENSE, user, self)
|
user.pbCanLowerStatStage?(:DEFENSE, user, self) && user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
|
||||||
if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
|
|
||||||
showAnim = false
|
showAnim = false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if user.effects[PBEffects::StockpileSpDef] > 0 &&
|
if user.effects[PBEffects::StockpileSpDef] > 0 &&
|
||||||
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self)
|
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self)
|
||||||
user.pbLowerStatStage(:SPECIAL_DEFENSE, user.effects[PBEffects::StockpileSpDef], user, showAnim)
|
user.pbLowerStatStage(:SPECIAL_DEFENSE, user.effects[PBEffects::StockpileSpDef], user, showAnim)
|
||||||
|
|||||||
@@ -112,24 +112,24 @@ class Battle::Scene
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pbFrameUpdate(cw = nil)
|
def pbFrameUpdate(cw = nil)
|
||||||
cw.update if cw
|
cw&.update
|
||||||
@battle.battlers.each_with_index do |b, i|
|
@battle.battlers.each_with_index do |b, i|
|
||||||
next if !b
|
next if !b
|
||||||
@sprites["dataBox_#{i}"].update(@frameCounter) if @sprites["dataBox_#{i}"]
|
@sprites["dataBox_#{i}"]&.update(@frameCounter)
|
||||||
@sprites["pokemon_#{i}"].update(@frameCounter) if @sprites["pokemon_#{i}"]
|
@sprites["pokemon_#{i}"]&.update(@frameCounter)
|
||||||
@sprites["shadow_#{i}"].update(@frameCounter) if @sprites["shadow_#{i}"]
|
@sprites["shadow_#{i}"]&.update(@frameCounter)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbRefresh
|
def pbRefresh
|
||||||
@battle.battlers.each_with_index do |b, i|
|
@battle.battlers.each_with_index do |b, i|
|
||||||
next if !b
|
next if !b
|
||||||
@sprites["dataBox_#{i}"].refresh if @sprites["dataBox_#{i}"]
|
@sprites["dataBox_#{i}"]&.refresh
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbRefreshOne(idxBattler)
|
def pbRefreshOne(idxBattler)
|
||||||
@sprites["dataBox_#{idxBattler}"].refresh if @sprites["dataBox_#{idxBattler}"]
|
@sprites["dataBox_#{idxBattler}"]&.refresh
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbRefreshEverything
|
def pbRefreshEverything
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class Battle::Scene
|
|||||||
cw = @sprites["fightWindow"]
|
cw = @sprites["fightWindow"]
|
||||||
cw.battler = battler
|
cw.battler = battler
|
||||||
moveIndex = 0
|
moveIndex = 0
|
||||||
if battler.moves[@lastMove[idxBattler]] && battler.moves[@lastMove[idxBattler]].id
|
if battler.moves[@lastMove[idxBattler]]&.id
|
||||||
moveIndex = @lastMove[idxBattler]
|
moveIndex = @lastMove[idxBattler]
|
||||||
end
|
end
|
||||||
cw.shiftMode = (@battle.pbCanShift?(idxBattler)) ? 1 : 0
|
cw.shiftMode = (@battle.pbCanShift?(idxBattler)) ? 1 : 0
|
||||||
@@ -98,14 +98,14 @@ class Battle::Scene
|
|||||||
if Input.trigger?(Input::LEFT)
|
if Input.trigger?(Input::LEFT)
|
||||||
cw.index -= 1 if (cw.index & 1) == 1
|
cw.index -= 1 if (cw.index & 1) == 1
|
||||||
elsif Input.trigger?(Input::RIGHT)
|
elsif Input.trigger?(Input::RIGHT)
|
||||||
if battler.moves[cw.index + 1] && battler.moves[cw.index + 1].id
|
if battler.moves[cw.index + 1]&.id && (cw.index & 1) == 0
|
||||||
cw.index += 1 if (cw.index & 1) == 0
|
cw.index += 1
|
||||||
end
|
end
|
||||||
elsif Input.trigger?(Input::UP)
|
elsif Input.trigger?(Input::UP)
|
||||||
cw.index -= 2 if (cw.index & 2) == 2
|
cw.index -= 2 if (cw.index & 2) == 2
|
||||||
elsif Input.trigger?(Input::DOWN)
|
elsif Input.trigger?(Input::DOWN)
|
||||||
if battler.moves[cw.index + 2] && battler.moves[cw.index + 2].id
|
if battler.moves[cw.index + 2]&.id && (cw.index & 2) == 0
|
||||||
cw.index += 2 if (cw.index & 2) == 0
|
cw.index += 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
pbPlayCursorSE if cw.index != oldIndex
|
pbPlayCursorSE if cw.index != oldIndex
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ class Battle::Scene
|
|||||||
a[2] = true if a[1].animDone?
|
a[2] = true if a[1].animDone?
|
||||||
end
|
end
|
||||||
pbUpdate
|
pbUpdate
|
||||||
if !inPartyAnimation?
|
if !inPartyAnimation? && !sendOutAnims.any? { |a| !a[2] }
|
||||||
break if !sendOutAnims.any? { |a| !a[2] }
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
fadeAnim.dispose
|
fadeAnim.dispose
|
||||||
@@ -165,7 +165,7 @@ class Battle::Scene
|
|||||||
# Recall animation
|
# Recall animation
|
||||||
recallAnim = Animation::BattlerRecall.new(@sprites, @viewport, idxBattler)
|
recallAnim = Animation::BattlerRecall.new(@sprites, @viewport, idxBattler)
|
||||||
loop do
|
loop do
|
||||||
recallAnim.update if recallAnim
|
recallAnim&.update
|
||||||
pbUpdate
|
pbUpdate
|
||||||
break if recallAnim.animDone?
|
break if recallAnim.animDone?
|
||||||
end
|
end
|
||||||
@@ -495,7 +495,7 @@ class Battle::Scene
|
|||||||
animID = pbFindMoveAnimation(moveID, user.index, hitNum)
|
animID = pbFindMoveAnimation(moveID, user.index, hitNum)
|
||||||
return if !animID
|
return if !animID
|
||||||
anim = animID[0]
|
anim = animID[0]
|
||||||
target = (targets && targets.is_a?(Array)) ? targets[0] : targets
|
target = (targets.is_a?(Array)) ? targets[0] : targets
|
||||||
animations = pbLoadBattleAnimations
|
animations = pbLoadBattleAnimations
|
||||||
return if !animations
|
return if !animations
|
||||||
pbSaveShadows {
|
pbSaveShadows {
|
||||||
@@ -510,7 +510,7 @@ class Battle::Scene
|
|||||||
# Plays a common animation.
|
# Plays a common animation.
|
||||||
def pbCommonAnimation(animName, user = nil, target = nil)
|
def pbCommonAnimation(animName, user = nil, target = nil)
|
||||||
return if nil_or_empty?(animName)
|
return if nil_or_empty?(animName)
|
||||||
target = target[0] if target && target.is_a?(Array)
|
target = target[0] if target.is_a?(Array)
|
||||||
animations = pbLoadBattleAnimations
|
animations = pbLoadBattleAnimations
|
||||||
return if !animations
|
return if !animations
|
||||||
animations.each do |a|
|
animations.each do |a|
|
||||||
@@ -534,7 +534,7 @@ class Battle::Scene
|
|||||||
animPlayer = PBAnimationPlayerX.new(animation, user, target, self, oppMove)
|
animPlayer = PBAnimationPlayerX.new(animation, user, target, self, oppMove)
|
||||||
# Apply a transformation to the animation based on where the user and target
|
# Apply a transformation to the animation based on where the user and target
|
||||||
# actually are. Get the centres of each sprite.
|
# actually are. Get the centres of each sprite.
|
||||||
userHeight = (userSprite && userSprite.bitmap && !userSprite.bitmap.disposed?) ? userSprite.bitmap.height : 128
|
userHeight = (userSprite&.bitmap && !userSprite.bitmap.disposed?) ? userSprite.bitmap.height : 128
|
||||||
if targetSprite
|
if targetSprite
|
||||||
targetHeight = (targetSprite.bitmap && !targetSprite.bitmap.disposed?) ? targetSprite.bitmap.height : 128
|
targetHeight = (targetSprite.bitmap && !targetSprite.bitmap.disposed?) ? targetSprite.bitmap.height : 128
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
|
|||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
super
|
super
|
||||||
@buttonBitmap.dispose if @buttonBitmap
|
@buttonBitmap&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def z=(value)
|
def z=(value)
|
||||||
@@ -191,7 +191,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
|
|||||||
|
|
||||||
def refresh
|
def refresh
|
||||||
@msgBox.refresh
|
@msgBox.refresh
|
||||||
@cmdWindow.refresh if @cmdWindow
|
@cmdWindow&.refresh
|
||||||
refreshButtons
|
refreshButtons
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -310,10 +310,10 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
|
|||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
super
|
super
|
||||||
@buttonBitmap.dispose if @buttonBitmap
|
@buttonBitmap&.dispose
|
||||||
@typeBitmap.dispose if @typeBitmap
|
@typeBitmap&.dispose
|
||||||
@megaEvoBitmap.dispose if @megaEvoBitmap
|
@megaEvoBitmap&.dispose
|
||||||
@shiftBitmap.dispose if @shiftBitmap
|
@shiftBitmap&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def z=(value)
|
def z=(value)
|
||||||
@@ -510,7 +510,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
|
|||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
super
|
super
|
||||||
@buttonBitmap.dispose if @buttonBitmap
|
@buttonBitmap&.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def z=(value)
|
def z=(value)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
|
|||||||
bgFilename = ["Graphics/Pictures/Battle/databox_thin",
|
bgFilename = ["Graphics/Pictures/Battle/databox_thin",
|
||||||
"Graphics/Pictures/Battle/databox_thin_foe"][@battler.index % 2]
|
"Graphics/Pictures/Battle/databox_thin_foe"][@battler.index % 2]
|
||||||
end
|
end
|
||||||
@databoxBitmap.dispose if @databoxBitmap
|
@databoxBitmap&.dispose
|
||||||
@databoxBitmap = AnimatedBitmap.new(bgFilename)
|
@databoxBitmap = AnimatedBitmap.new(bgFilename)
|
||||||
# Determine the co-ordinates of the data box and the left edge padding width
|
# Determine the co-ordinates of the data box and the left edge padding width
|
||||||
if onPlayerSide
|
if onPlayerSide
|
||||||
@@ -500,7 +500,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@_iconBitmap.dispose if @_iconBitmap
|
@_iconBitmap&.dispose
|
||||||
@_iconBitmap = nil
|
@_iconBitmap = nil
|
||||||
self.bitmap = nil if !self.disposed?
|
self.bitmap = nil if !self.disposed?
|
||||||
super
|
super
|
||||||
@@ -552,7 +552,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
|
|||||||
|
|
||||||
def setPokemonBitmap(pkmn, back = false)
|
def setPokemonBitmap(pkmn, back = false)
|
||||||
@pkmn = pkmn
|
@pkmn = pkmn
|
||||||
@_iconBitmap.dispose if @_iconBitmap
|
@_iconBitmap&.dispose
|
||||||
@_iconBitmap = GameData::Species.sprite_bitmap_from_pokemon(@pkmn, back)
|
@_iconBitmap = GameData::Species.sprite_bitmap_from_pokemon(@pkmn, back)
|
||||||
self.bitmap = (@_iconBitmap) ? @_iconBitmap.bitmap : nil
|
self.bitmap = (@_iconBitmap) ? @_iconBitmap.bitmap : nil
|
||||||
pbSetPosition
|
pbSetPosition
|
||||||
@@ -563,7 +563,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
|
|||||||
# recommendation is to create a PictureEx animation and push it into
|
# recommendation is to create a PictureEx animation and push it into
|
||||||
# the @battleAnimations array.
|
# the @battleAnimations array.
|
||||||
def pbPlayIntroAnimation(pictureEx = nil)
|
def pbPlayIntroAnimation(pictureEx = nil)
|
||||||
@pkmn.play_cry if @pkmn
|
@pkmn&.play_cry
|
||||||
end
|
end
|
||||||
|
|
||||||
QUARTER_ANIM_PERIOD = Graphics.frame_rate * 3 / 20
|
QUARTER_ANIM_PERIOD = Graphics.frame_rate * 3 / 20
|
||||||
@@ -617,7 +617,7 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@_iconBitmap.dispose if @_iconBitmap
|
@_iconBitmap&.dispose
|
||||||
@_iconBitmap = nil
|
@_iconBitmap = nil
|
||||||
self.bitmap = nil if !self.disposed?
|
self.bitmap = nil if !self.disposed?
|
||||||
super
|
super
|
||||||
@@ -647,7 +647,7 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite
|
|||||||
|
|
||||||
def setPokemonBitmap(pkmn)
|
def setPokemonBitmap(pkmn)
|
||||||
@pkmn = pkmn
|
@pkmn = pkmn
|
||||||
@_iconBitmap.dispose if @_iconBitmap
|
@_iconBitmap&.dispose
|
||||||
@_iconBitmap = GameData::Species.shadow_bitmap_from_pokemon(@pkmn)
|
@_iconBitmap = GameData::Species.shadow_bitmap_from_pokemon(@pkmn)
|
||||||
self.bitmap = (@_iconBitmap) ? @_iconBitmap.bitmap : nil
|
self.bitmap = (@_iconBitmap) ? @_iconBitmap.bitmap : nil
|
||||||
pbSetPosition
|
pbSetPosition
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class Battle::Scene::Animation
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@tempSprites.each { |s| s.dispose if s }
|
@tempSprites.each { |s| s&.dispose }
|
||||||
end
|
end
|
||||||
|
|
||||||
def createProcesses; end
|
def createProcesses; end
|
||||||
@@ -47,7 +47,7 @@ class Battle::Scene::Animation
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
return if @animDone
|
return if @animDone
|
||||||
@tempSprites.each { |s| s.update if s }
|
@tempSprites.each { |s| s&.update }
|
||||||
finished = true
|
finished = true
|
||||||
@pictureEx.each_with_index do |p, i|
|
@pictureEx.each_with_index do |p, i|
|
||||||
next if !p.running?
|
next if !p.running?
|
||||||
|
|||||||
@@ -140,9 +140,9 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
|
|||||||
startsIndex = idxBall / ballsPerTrainer
|
startsIndex = idxBall / ballsPerTrainer
|
||||||
teamIndex = idxBall % ballsPerTrainer
|
teamIndex = idxBall % ballsPerTrainer
|
||||||
ret = @partyStarts[startsIndex] + teamIndex
|
ret = @partyStarts[startsIndex] + teamIndex
|
||||||
if startsIndex < @partyStarts.length - 1
|
if startsIndex < @partyStarts.length - 1 && ret >= @partyStarts[startsIndex + 1]
|
||||||
# There is a later trainer, don't spill over into its team
|
# There is a later trainer, don't spill over into its team
|
||||||
return -1 if ret >= @partyStarts[startsIndex + 1]
|
return -1
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
@@ -332,7 +332,7 @@ class Battle::Scene::Animation::PlayerFade < Battle::Scene::Animation
|
|||||||
end
|
end
|
||||||
# Move and fade party bar/balls
|
# Move and fade party bar/balls
|
||||||
delay = 3
|
delay = 3
|
||||||
if @sprites["partyBar_0"] && @sprites["partyBar_0"].visible
|
if @sprites["partyBar_0"]&.visible
|
||||||
partyBar = addSprite(@sprites["partyBar_0"])
|
partyBar = addSprite(@sprites["partyBar_0"])
|
||||||
partyBar.moveDelta(delay, 16, -Graphics.width / 4, 0) if @fullAnim
|
partyBar.moveDelta(delay, 16, -Graphics.width / 4, 0) if @fullAnim
|
||||||
partyBar.moveOpacity(delay, 12, 0)
|
partyBar.moveOpacity(delay, 12, 0)
|
||||||
@@ -377,7 +377,7 @@ class Battle::Scene::Animation::TrainerFade < Battle::Scene::Animation
|
|||||||
end
|
end
|
||||||
# Move and fade party bar/balls
|
# Move and fade party bar/balls
|
||||||
delay = 3
|
delay = 3
|
||||||
if @sprites["partyBar_1"] && @sprites["partyBar_1"].visible
|
if @sprites["partyBar_1"]&.visible
|
||||||
partyBar = addSprite(@sprites["partyBar_1"])
|
partyBar = addSprite(@sprites["partyBar_1"])
|
||||||
partyBar.moveDelta(delay, 16, Graphics.width / 4, 0) if @fullAnim
|
partyBar.moveDelta(delay, 16, Graphics.width / 4, 0) if @fullAnim
|
||||||
partyBar.moveOpacity(delay, 12, 0)
|
partyBar.moveOpacity(delay, 12, 0)
|
||||||
@@ -722,12 +722,10 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
|
|||||||
ball.setZ(0, batSprite.z + 1)
|
ball.setZ(0, batSprite.z + 1)
|
||||||
@ballSpriteIndex = (@success) ? @tempSprites.length - 1 : -1
|
@ballSpriteIndex = (@success) ? @tempSprites.length - 1 : -1
|
||||||
# Set up trainer sprite (only visible in Safari Zone battles)
|
# Set up trainer sprite (only visible in Safari Zone battles)
|
||||||
if @showingTrainer && traSprite
|
if @showingTrainer && traSprite && traSprite.bitmap.width >= traSprite.bitmap.height * 2
|
||||||
if traSprite.bitmap.width >= traSprite.bitmap.height * 2
|
trainer = addSprite(traSprite, PictureOrigin::Bottom)
|
||||||
trainer = addSprite(traSprite, PictureOrigin::Bottom)
|
# Trainer animation
|
||||||
# Trainer animation
|
ballStartX, ballStartY = trainerThrowingFrames(ball, trainer, traSprite)
|
||||||
ballStartX, ballStartY = trainerThrowingFrames(ball, trainer, traSprite)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
delay = ball.totalDuration # 0 or 7
|
delay = ball.totalDuration # 0 or 7
|
||||||
# Poké Ball arc animation
|
# Poké Ball arc animation
|
||||||
|
|||||||
@@ -115,12 +115,10 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Log Full Restores (HP healer and status curer)
|
# Log Full Restores (HP healer and status curer)
|
||||||
if losthp > 0 || battler.status != :NONE
|
if fullRestoreItems.include?(i) && (losthp > 0 || battler.status != :NONE)
|
||||||
if fullRestoreItems.include?(i)
|
usableHPItems.push([i, (preferFullRestore) ? 3 : 7, 999])
|
||||||
usableHPItems.push([i, (preferFullRestore) ? 3 : 7, 999])
|
usableStatusItems.push([i, (preferFullRestore) ? 3 : 9])
|
||||||
usableStatusItems.push([i, (preferFullRestore) ? 3 : 9])
|
next
|
||||||
next
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Log single status-curing items
|
# Log single status-curing items
|
||||||
if oneStatusItems.include?(i)
|
if oneStatusItems.include?(i)
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ class Battle::AI
|
|||||||
skill >= PBTrainerAI.highSkill
|
skill >= PBTrainerAI.highSkill
|
||||||
toxicHP = battler.totalhp / 16
|
toxicHP = battler.totalhp / 16
|
||||||
nextToxicHP = toxicHP * (battler.effects[PBEffects::Toxic] + 1)
|
nextToxicHP = toxicHP * (battler.effects[PBEffects::Toxic] + 1)
|
||||||
if battler.hp <= nextToxicHP && battler.hp > toxicHP * 2
|
if battler.hp <= nextToxicHP && battler.hp > toxicHP * 2 && pbAIRandom(100) < 80
|
||||||
shouldSwitch = true if pbAIRandom(100) < 80
|
shouldSwitch = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Pokémon is Encored into an unfavourable move
|
# Pokémon is Encored into an unfavourable move
|
||||||
@@ -62,8 +62,8 @@ class Battle::AI
|
|||||||
scoreSum += pbGetMoveScore(battler.moves[idxEncoredMove], battler, b, skill)
|
scoreSum += pbGetMoveScore(battler.moves[idxEncoredMove], battler, b, skill)
|
||||||
scoreCount += 1
|
scoreCount += 1
|
||||||
end
|
end
|
||||||
if scoreCount > 0 && scoreSum / scoreCount <= 20
|
if scoreCount > 0 && scoreSum / scoreCount <= 20 && pbAIRandom(100) < 80
|
||||||
shouldSwitch = true if pbAIRandom(100) < 80
|
shouldSwitch = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -72,9 +72,9 @@ class Battle::AI
|
|||||||
if @battle.pbSideSize(battler.index + 1) == 1 &&
|
if @battle.pbSideSize(battler.index + 1) == 1 &&
|
||||||
!battler.pbDirectOpposing.fainted? && skill >= PBTrainerAI.highSkill
|
!battler.pbDirectOpposing.fainted? && skill >= PBTrainerAI.highSkill
|
||||||
opp = battler.pbDirectOpposing
|
opp = battler.pbDirectOpposing
|
||||||
if opp.effects[PBEffects::HyperBeam] > 0 ||
|
if (opp.effects[PBEffects::HyperBeam] > 0 ||
|
||||||
(opp.hasActiveAbility?(:TRUANT) && opp.effects[PBEffects::Truant])
|
(opp.hasActiveAbility?(:TRUANT) && opp.effects[PBEffects::Truant])) && pbAIRandom(100) < 80
|
||||||
shouldSwitch = false if pbAIRandom(100) < 80
|
shouldSwitch = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Sudden Death rule - I'm not sure what this means
|
# Sudden Death rule - I'm not sure what this means
|
||||||
@@ -103,9 +103,8 @@ class Battle::AI
|
|||||||
# Don't switch to this if too little HP
|
# Don't switch to this if too little HP
|
||||||
if spikes > 0
|
if spikes > 0
|
||||||
spikesDmg = [8, 6, 4][spikes - 1]
|
spikesDmg = [8, 6, 4][spikes - 1]
|
||||||
if pkmn.hp <= pkmn.totalhp / spikesDmg
|
next if pkmn.hp <= pkmn.totalhp / spikesDmg &&
|
||||||
next if !pkmn.hasType?(:FLYING) && !pkmn.hasActiveAbility?(:LEVITATE)
|
!pkmn.hasType?(:FLYING) && !pkmn.hasActiveAbility?(:LEVITATE)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# moveType is the type of the target's last used move
|
# moveType is the type of the target's last used move
|
||||||
@@ -136,7 +135,7 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
if @battle.pbRegisterSwitch(idxBattler, list[0])
|
if @battle.pbRegisterSwitch(idxBattler, list[0])
|
||||||
PBDebug.log("[AI] #{battler.pbThis} (#{idxBattler}) will switch with " +
|
PBDebug.log("[AI] #{battler.pbThis} (#{idxBattler}) will switch with " +
|
||||||
"#{@battle.pbParty(idxBattler)[list[0]].name}")
|
@battle.pbParty(idxBattler)[list[0]].name)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ class Battle::AI
|
|||||||
# Decide whether all choices are bad, and if so, try switching instead
|
# Decide whether all choices are bad, and if so, try switching instead
|
||||||
if !wildBattler && skill >= PBTrainerAI.highSkill
|
if !wildBattler && skill >= PBTrainerAI.highSkill
|
||||||
badMoves = false
|
badMoves = false
|
||||||
if (maxScore <= 20 && user.turnCount > 2) ||
|
if ((maxScore <= 20 && user.turnCount > 2) ||
|
||||||
(maxScore <= 40 && user.turnCount > 5)
|
(maxScore <= 40 && user.turnCount > 5)) && pbAIRandom(100) < 80
|
||||||
badMoves = true if pbAIRandom(100) < 80
|
badMoves = true
|
||||||
end
|
end
|
||||||
if !badMoves && totalScore < 100 && user.turnCount > 1
|
if !badMoves && totalScore < 100 && user.turnCount > 1
|
||||||
badMoves = true
|
badMoves = true
|
||||||
@@ -160,13 +160,12 @@ class Battle::AI
|
|||||||
return 0 if score <= 0
|
return 0 if score <= 0
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
# Prefer damaging moves if AI has no more Pokémon or AI is less clever
|
# Prefer damaging moves if AI has no more Pokémon or AI is less clever
|
||||||
if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0
|
if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 &&
|
||||||
if !(skill >= PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide) > 0)
|
!(skill >= PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide) > 0)
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
score /= 1.5
|
score /= 1.5
|
||||||
elsif target.hp <= target.totalhp / 2
|
elsif target.hp <= target.totalhp / 2
|
||||||
score *= 1.5
|
score *= 1.5
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Don't prefer attacking the target if they'd be semi-invulnerable
|
# Don't prefer attacking the target if they'd be semi-invulnerable
|
||||||
@@ -266,18 +265,16 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
# Prefer flinching external effects (note that move effects which cause
|
# Prefer flinching external effects (note that move effects which cause
|
||||||
# flinching are dealt with in the function code part of score calculation)
|
# flinching are dealt with in the function code part of score calculation)
|
||||||
if skill >= PBTrainerAI.mediumSkill && !move.flinchingMove?
|
if skill >= PBTrainerAI.mediumSkill && !move.flinchingMove? &&
|
||||||
if !target.hasActiveAbility?(:INNERFOCUS) &&
|
!target.hasActiveAbility?(:INNERFOCUS) &&
|
||||||
!target.hasActiveAbility?(:SHIELDDUST) &&
|
!target.hasActiveAbility?(:SHIELDDUST) &&
|
||||||
target.effects[PBEffects::Substitute] == 0
|
target.effects[PBEffects::Substitute] == 0
|
||||||
canFlinch = false
|
canFlinch = false
|
||||||
if user.hasActiveItem?([:KINGSROCK, :RAZORFANG])
|
if user.hasActiveItem?([:KINGSROCK, :RAZORFANG]) ||
|
||||||
canFlinch = true
|
user.hasActiveAbility?(:STENCH)
|
||||||
elsif user.hasActiveAbility?(:STENCH)
|
canFlinch = true
|
||||||
canFlinch = true
|
|
||||||
end
|
|
||||||
realDamage *= 1.3 if canFlinch
|
|
||||||
end
|
end
|
||||||
|
realDamage *= 1.3 if canFlinch
|
||||||
end
|
end
|
||||||
# Convert damage to percentage of target's remaining HP
|
# Convert damage to percentage of target's remaining HP
|
||||||
damagePercentage = realDamage * 100.0 / target.hp
|
damagePercentage = realDamage * 100.0 / target.hp
|
||||||
|
|||||||
@@ -859,9 +859,7 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetAttack1"
|
when "LowerTargetAttack1"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:ATTACK, user)
|
if target.pbCanLowerStatStage?(:ATTACK, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += target.stages[:ATTACK] * 20
|
score += target.stages[:ATTACK] * 20
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
hasPhysicalAttack = false
|
hasPhysicalAttack = false
|
||||||
@@ -876,6 +874,8 @@ class Battle::AI
|
|||||||
score -= 90
|
score -= 90
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
score += 20 if target.stages[:ATTACK] > 0
|
score += 20 if target.stages[:ATTACK] > 0
|
||||||
@@ -892,10 +892,10 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetDefense1"
|
when "LowerTargetDefense1"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:DEFENSE, user)
|
if target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += target.stages[:DEFENSE] * 20
|
score += target.stages[:DEFENSE] * 20
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
elsif target.stages[:DEFENSE] > 0
|
elsif target.stages[:DEFENSE] > 0
|
||||||
score += 20
|
score += 20
|
||||||
@@ -903,15 +903,15 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetSpeed1", "LowerTargetSpeed1WeakerInGrassyTerrain"
|
when "LowerTargetSpeed1", "LowerTargetSpeed1WeakerInGrassyTerrain"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:SPEED, user)
|
if target.pbCanLowerStatStage?(:SPEED, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += target.stages[:SPEED] * 10
|
score += target.stages[:SPEED] * 10
|
||||||
if skill >= PBTrainerAI.highSkill
|
if skill >= PBTrainerAI.highSkill
|
||||||
aspeed = pbRoughStat(user, :SPEED, skill)
|
aspeed = pbRoughStat(user, :SPEED, skill)
|
||||||
ospeed = pbRoughStat(target, :SPEED, skill)
|
ospeed = pbRoughStat(target, :SPEED, skill)
|
||||||
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
|
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
elsif user.stages[:SPEED] > 0
|
elsif user.stages[:SPEED] > 0
|
||||||
score += 20
|
score += 20
|
||||||
@@ -919,9 +919,7 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetSpAtk1"
|
when "LowerTargetSpAtk1"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += user.stages[:SPECIAL_ATTACK] * 20
|
score += user.stages[:SPECIAL_ATTACK] * 20
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
hasSpecicalAttack = false
|
hasSpecicalAttack = false
|
||||||
@@ -936,6 +934,8 @@ class Battle::AI
|
|||||||
score -= 90
|
score -= 90
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
score += 20 if user.stages[:SPECIAL_ATTACK] > 0
|
score += 20 if user.stages[:SPECIAL_ATTACK] > 0
|
||||||
@@ -952,10 +952,10 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetSpDef1"
|
when "LowerTargetSpDef1"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
if target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += target.stages[:SPECIAL_DEFENSE] * 20
|
score += target.stages[:SPECIAL_DEFENSE] * 20
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
elsif target.stages[:SPECIAL_DEFENSE] > 0
|
elsif target.stages[:SPECIAL_DEFENSE] > 0
|
||||||
score += 20
|
score += 20
|
||||||
@@ -963,10 +963,10 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetAccuracy1", "LowerTargetAccuracy2", "LowerTargetAccuracy3"
|
when "LowerTargetAccuracy1", "LowerTargetAccuracy2", "LowerTargetAccuracy3"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:ACCURACY, user)
|
if target.pbCanLowerStatStage?(:ACCURACY, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += target.stages[:ACCURACY] * 10
|
score += target.stages[:ACCURACY] * 10
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
elsif target.stages[:ACCURACY] > 0
|
elsif target.stages[:ACCURACY] > 0
|
||||||
score += 20
|
score += 20
|
||||||
@@ -974,10 +974,10 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetEvasion1", "LowerTargetEvasion2", "LowerTargetEvasion3"
|
when "LowerTargetEvasion1", "LowerTargetEvasion2", "LowerTargetEvasion3"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:EVASION, user)
|
if target.pbCanLowerStatStage?(:EVASION, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += target.stages[:EVASION] * 10
|
score += target.stages[:EVASION] * 10
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
elsif target.stages[:EVASION] > 0
|
elsif target.stages[:EVASION] > 0
|
||||||
score += 20
|
score += 20
|
||||||
@@ -985,10 +985,10 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetEvasion1RemoveSideEffects"
|
when "LowerTargetEvasion1RemoveSideEffects"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:EVASION, user)
|
if target.pbCanLowerStatStage?(:EVASION, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += target.stages[:EVASION] * 10
|
score += target.stages[:EVASION] * 10
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
elsif target.stages[:EVASION] > 0
|
elsif target.stages[:EVASION] > 0
|
||||||
score += 20
|
score += 20
|
||||||
@@ -1009,9 +1009,7 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetAttack2", "LowerTargetAttack3"
|
when "LowerTargetAttack2", "LowerTargetAttack3"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:ATTACK, user)
|
if target.pbCanLowerStatStage?(:ATTACK, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += 40 if user.turnCount == 0
|
score += 40 if user.turnCount == 0
|
||||||
score += target.stages[:ATTACK] * 20
|
score += target.stages[:ATTACK] * 20
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
@@ -1027,6 +1025,8 @@ class Battle::AI
|
|||||||
score -= 90
|
score -= 90
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
score += 10 if user.turnCount == 0
|
score += 10 if user.turnCount == 0
|
||||||
@@ -1044,11 +1044,11 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetDefense2", "LowerTargetDefense3"
|
when "LowerTargetDefense2", "LowerTargetDefense3"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:DEFENSE, user)
|
if target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += 40 if user.turnCount == 0
|
score += 40 if user.turnCount == 0
|
||||||
score += target.stages[:DEFENSE] * 20
|
score += target.stages[:DEFENSE] * 20
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
score += 10 if user.turnCount == 0
|
score += 10 if user.turnCount == 0
|
||||||
@@ -1057,9 +1057,7 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetSpeed2", "LowerTargetSpeed3"
|
when "LowerTargetSpeed2", "LowerTargetSpeed3"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:SPEED, user)
|
if target.pbCanLowerStatStage?(:SPEED, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += 20 if user.turnCount == 0
|
score += 20 if user.turnCount == 0
|
||||||
score += target.stages[:SPEED] * 20
|
score += target.stages[:SPEED] * 20
|
||||||
if skill >= PBTrainerAI.highSkill
|
if skill >= PBTrainerAI.highSkill
|
||||||
@@ -1067,6 +1065,8 @@ class Battle::AI
|
|||||||
ospeed = pbRoughStat(target, :SPEED, skill)
|
ospeed = pbRoughStat(target, :SPEED, skill)
|
||||||
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
|
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
score += 10 if user.turnCount == 0
|
score += 10 if user.turnCount == 0
|
||||||
@@ -1078,9 +1078,7 @@ class Battle::AI
|
|||||||
target.hasActiveAbility?(:OBLIVIOUS)
|
target.hasActiveAbility?(:OBLIVIOUS)
|
||||||
score -= 90
|
score -= 90
|
||||||
elsif move.statusMove?
|
elsif move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += 40 if user.turnCount == 0
|
score += 40 if user.turnCount == 0
|
||||||
score += target.stages[:SPECIAL_ATTACK] * 20
|
score += target.stages[:SPECIAL_ATTACK] * 20
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
@@ -1096,6 +1094,8 @@ class Battle::AI
|
|||||||
score -= 90
|
score -= 90
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
score += 10 if user.turnCount == 0
|
score += 10 if user.turnCount == 0
|
||||||
@@ -1113,11 +1113,11 @@ class Battle::AI
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetSpDef2", "LowerTargetSpDef3"
|
when "LowerTargetSpDef2", "LowerTargetSpDef3"
|
||||||
if move.statusMove?
|
if move.statusMove?
|
||||||
if !target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
if target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += 40 if user.turnCount == 0
|
score += 40 if user.turnCount == 0
|
||||||
score += target.stages[:SPECIAL_DEFENSE] * 20
|
score += target.stages[:SPECIAL_DEFENSE] * 20
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
score += 10 if user.turnCount == 0
|
score += 10 if user.turnCount == 0
|
||||||
@@ -1323,9 +1323,7 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "SetUserTypesToUserMoveType"
|
when "SetUserTypesToUserMoveType"
|
||||||
if !user.canChangeType?
|
if user.canChangeType?
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
has_possible_type = false
|
has_possible_type = false
|
||||||
user.eachMoveWithIndex do |m, i|
|
user.eachMoveWithIndex do |m, i|
|
||||||
break if Settings::MECHANICS_GENERATION >= 6 && i > 0
|
break if Settings::MECHANICS_GENERATION >= 6 && i > 0
|
||||||
@@ -1335,6 +1333,8 @@ class Battle::AI
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
score -= 90 if !has_possible_type
|
score -= 90 if !has_possible_type
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "SetUserTypesToResistLastAttack"
|
when "SetUserTypesToResistLastAttack"
|
||||||
@@ -1350,9 +1350,7 @@ class Battle::AI
|
|||||||
aType = m.pbCalcType(user)
|
aType = m.pbCalcType(user)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
if !aType
|
if aType
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
has_possible_type = false
|
has_possible_type = false
|
||||||
GameData::Type.each do |t|
|
GameData::Type.each do |t|
|
||||||
next if t.pseudo_type || user.pbHasType?(t.id) ||
|
next if t.pseudo_type || user.pbHasType?(t.id) ||
|
||||||
@@ -1361,6 +1359,8 @@ class Battle::AI
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
score -= 90 if !has_possible_type
|
score -= 90 if !has_possible_type
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
@@ -1793,9 +1793,7 @@ class Battle::AI
|
|||||||
if target.effects[PBEffects::Encore] > 0
|
if target.effects[PBEffects::Encore] > 0
|
||||||
score -= 90
|
score -= 90
|
||||||
elsif aspeed > ospeed
|
elsif aspeed > ospeed
|
||||||
if !target.lastRegularMoveUsed
|
if target.lastRegularMoveUsed
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
moveData = GameData::Move.get(target.lastRegularMoveUsed)
|
moveData = GameData::Move.get(target.lastRegularMoveUsed)
|
||||||
if moveData.category == 2 && # Status move
|
if moveData.category == 2 && # Status move
|
||||||
[:User, :BothSides].include?(moveData.target)
|
[:User, :BothSides].include?(moveData.target)
|
||||||
@@ -1805,6 +1803,8 @@ class Battle::AI
|
|||||||
Effectiveness.ineffective?(pbCalcTypeMod(moveData.type, target, user))
|
Effectiveness.ineffective?(pbCalcTypeMod(moveData.type, target, user))
|
||||||
score += 60
|
score += 60
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
@@ -2056,9 +2056,7 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "SwitchOutUserPassOnEffects"
|
when "SwitchOutUserPassOnEffects"
|
||||||
if !@battle.pbCanChooseNonActive?(user.index)
|
if @battle.pbCanChooseNonActive?(user.index)
|
||||||
score -= 100
|
|
||||||
else
|
|
||||||
score -= 40 if user.effects[PBEffects::Confusion] > 0
|
score -= 40 if user.effects[PBEffects::Confusion] > 0
|
||||||
total = 0
|
total = 0
|
||||||
GameData::Stat.each_battle { |s| total += user.stages[s.id] }
|
GameData::Stat.each_battle { |s| total += user.stages[s.id] }
|
||||||
@@ -2075,6 +2073,8 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
score += 75 if !hasDamagingMove
|
score += 75 if !hasDamagingMove
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
score -= 100
|
||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "TrapTargetInBattle"
|
when "TrapTargetInBattle"
|
||||||
@@ -2505,9 +2505,7 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetAttack1BypassSubstitute"
|
when "LowerTargetAttack1BypassSubstitute"
|
||||||
if !target.pbCanLowerStatStage?(:ATTACK, user)
|
if target.pbCanLowerStatStage?(:ATTACK, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += target.stages[:ATTACK] * 20
|
score += target.stages[:ATTACK] * 20
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
hasPhysicalAttack = false
|
hasPhysicalAttack = false
|
||||||
@@ -2522,6 +2520,8 @@ class Battle::AI
|
|||||||
score -= 90
|
score -= 90
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetAtkSpAtk1"
|
when "LowerTargetAtkSpAtk1"
|
||||||
@@ -2537,11 +2537,11 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetSpAtk2", "LowerTargetSpAtk3"
|
when "LowerTargetSpAtk2", "LowerTargetSpAtk3"
|
||||||
if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += 40 if user.turnCount == 0
|
score += 40 if user.turnCount == 0
|
||||||
score += target.stages[:SPECIAL_ATTACK] * 20
|
score += target.stages[:SPECIAL_ATTACK] * 20
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "RaiseGroundedGrassBattlersAtkSpAtk1"
|
when "RaiseGroundedGrassBattlersAtkSpAtk1"
|
||||||
@@ -3005,7 +3005,7 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
GameData::Stat.each_main_battle { |s| score += 10 if user.stages[s.id] <= 0 }
|
GameData::Stat.each_main_battle { |s| score += 10 if user.stages[s.id] <= 0 }
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
hasDamagingAttack = user.moves.any? { |m| next m && m.damagingMove? }
|
hasDamagingAttack = user.moves.any? { |m| next m&.damagingMove? }
|
||||||
score += 20 if hasDamagingAttack
|
score += 20 if hasDamagingAttack
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3031,7 +3031,7 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
GameData::Stat.each_main_battle { |s| score += 10 if user.stages[s.id] <= 0 }
|
GameData::Stat.each_main_battle { |s| score += 10 if user.stages[s.id] <= 0 }
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
hasDamagingAttack = user.moves.any? { |m| next m && m.damagingMove? }
|
hasDamagingAttack = user.moves.any? { |m| next m&.damagingMove? }
|
||||||
score += 20 if hasDamagingAttack
|
score += 20 if hasDamagingAttack
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3064,11 +3064,11 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
when "LowerTargetDefense1DoublePowerInGravity"
|
when "LowerTargetDefense1DoublePowerInGravity"
|
||||||
if !target.pbCanLowerStatStage?(:DEFENSE, user)
|
if target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||||
score -= 90
|
|
||||||
else
|
|
||||||
score += 20
|
score += 20
|
||||||
score += target.stages[:DEFENSE] * 20
|
score += target.stages[:DEFENSE] * 20
|
||||||
|
else
|
||||||
|
score -= 90
|
||||||
end
|
end
|
||||||
score += 30 if @battle.field.effects[PBEffects::Gravity] > 0
|
score += 30 if @battle.field.effects[PBEffects::Gravity] > 0
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -28,28 +28,29 @@ class Battle::AI
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
def pbCalcTypeModSingle(moveType, defType, user, target)
|
def pbCalcTypeModSingle(moveType, defType, user, target)
|
||||||
ret = Effectiveness.calculate_one(moveType, defType)
|
ret = Effectiveness.calculate_one(moveType, defType)
|
||||||
# Ring Target
|
if Effectiveness.ineffective_type?(moveType, defType)
|
||||||
if target.hasActiveItem?(:RINGTARGET)
|
# Ring Target
|
||||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if Effectiveness.ineffective_type?(moveType, defType)
|
if target.hasActiveItem?(:RINGTARGET)
|
||||||
end
|
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||||
# Foresight
|
end
|
||||||
if user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]
|
# Foresight
|
||||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :GHOST &&
|
if (user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]) &&
|
||||||
Effectiveness.ineffective_type?(moveType, defType)
|
defType == :GHOST
|
||||||
end
|
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||||
# Miracle Eye
|
end
|
||||||
if target.effects[PBEffects::MiracleEye]
|
# Miracle Eye
|
||||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :DARK &&
|
if target.effects[PBEffects::MiracleEye] && defType == :DARK
|
||||||
Effectiveness.ineffective_type?(moveType, defType)
|
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||||
end
|
end
|
||||||
# Delta Stream's weather
|
elsif Effectiveness.super_effective_type?(moveType, defType)
|
||||||
if target.effectiveWeather == :StrongWinds
|
# Delta Stream's weather
|
||||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING &&
|
if target.effectiveWeather == :StrongWinds && defType == :FLYING
|
||||||
Effectiveness.super_effective_type?(moveType, defType)
|
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||||
|
end
|
||||||
end
|
end
|
||||||
# Grounded Flying-type Pokémon become susceptible to Ground moves
|
# Grounded Flying-type Pokémon become susceptible to Ground moves
|
||||||
if !target.airborne?
|
if !target.airborne? && defType == :FLYING && moveType == :GROUND
|
||||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && moveType == :GROUND
|
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
@@ -256,7 +257,7 @@ class Battle::AI
|
|||||||
when "HitOncePerUserTeamMember" # Beat Up
|
when "HitOncePerUserTeamMember" # Beat Up
|
||||||
mult = 0
|
mult = 0
|
||||||
@battle.eachInTeamFromBattlerIndex(user.index) do |pkmn, _i|
|
@battle.eachInTeamFromBattlerIndex(user.index) do |pkmn, _i|
|
||||||
mult += 1 if pkmn && pkmn.able? && pkmn.status == :NONE
|
mult += 1 if pkmn&.able? && pkmn.status == :NONE
|
||||||
end
|
end
|
||||||
baseDmg *= mult
|
baseDmg *= mult
|
||||||
when "TwoTurnAttackOneTurnInSun" # Solar Beam
|
when "TwoTurnAttackOneTurnInSun" # Solar Beam
|
||||||
@@ -390,26 +391,20 @@ class Battle::AI
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if skill >= PBTrainerAI.bestSkill && target.itemActive?
|
if skill >= PBTrainerAI.bestSkill && target.itemActive? && (target.item && !target.item.is_berry?)
|
||||||
# NOTE: Type-weakening berries aren't suitable for checking at the start
|
|
||||||
# of the round.
|
|
||||||
if target.item && !target.item.is_berry?
|
|
||||||
Battle::ItemEffects.triggerDamageCalcFromTarget(
|
Battle::ItemEffects.triggerDamageCalcFromTarget(
|
||||||
target.item, user, target, move, multipliers, baseDmg, type
|
target.item, user, target, move, multipliers, baseDmg, type
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Global abilities
|
# Global abilities
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill && ((@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
|
||||||
if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
|
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY))
|
||||||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY)
|
|
||||||
if @battle.pbCheckGlobalAbility(:AURABREAK)
|
if @battle.pbCheckGlobalAbility(:AURABREAK)
|
||||||
multipliers[:base_damage_multiplier] *= 2 / 3.0
|
multipliers[:base_damage_multiplier] *= 2 / 3.0
|
||||||
else
|
else
|
||||||
multipliers[:base_damage_multiplier] *= 4 / 3.0
|
multipliers[:base_damage_multiplier] *= 4 / 3.0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Parental Bond
|
# Parental Bond
|
||||||
if skill >= PBTrainerAI.mediumSkill && user.hasActiveAbility?(:PARENTALBOND)
|
if skill >= PBTrainerAI.mediumSkill && user.hasActiveAbility?(:PARENTALBOND)
|
||||||
multipliers[:base_damage_multiplier] *= 1.25
|
multipliers[:base_damage_multiplier] *= 1.25
|
||||||
@@ -418,11 +413,9 @@ class Battle::AI
|
|||||||
# TODO
|
# TODO
|
||||||
# Helping Hand - n/a
|
# Helping Hand - n/a
|
||||||
# Charge
|
# Charge
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill && (user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC)
|
||||||
if user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC
|
|
||||||
multipliers[:base_damage_multiplier] *= 2
|
multipliers[:base_damage_multiplier] *= 2
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Mud Sport and Water Sport
|
# Mud Sport and Water Sport
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
if type == :ELECTRIC
|
if type == :ELECTRIC
|
||||||
@@ -456,25 +449,17 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Badge multipliers
|
# Badge multipliers
|
||||||
if skill >= PBTrainerAI.highSkill
|
if skill >= PBTrainerAI.highSkill && @battle.internalBattle && target.pbOwnedByPlayer?
|
||||||
if @battle.internalBattle
|
|
||||||
# Don't need to check the Atk/Sp Atk-boosting badges because the AI
|
|
||||||
# won't control the player's Pokémon.
|
|
||||||
if target.pbOwnedByPlayer?
|
|
||||||
if move.physicalMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_DEFENSE
|
if move.physicalMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_DEFENSE
|
||||||
multipliers[:defense_multiplier] *= 1.1
|
multipliers[:defense_multiplier] *= 1.1
|
||||||
elsif move.specialMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_SPDEF
|
elsif move.specialMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_SPDEF
|
||||||
multipliers[:defense_multiplier] *= 1.1
|
multipliers[:defense_multiplier] *= 1.1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
# Multi-targeting attacks
|
# Multi-targeting attacks
|
||||||
if skill >= PBTrainerAI.highSkill
|
if skill >= PBTrainerAI.highSkill && pbTargetsMultiple?(move, user)
|
||||||
if pbTargetsMultiple?(move, user)
|
|
||||||
multipliers[:final_damage_multiplier] *= 0.75
|
multipliers[:final_damage_multiplier] *= 0.75
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Weather
|
# Weather
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
case user.effectiveWeather
|
case user.effectiveWeather
|
||||||
@@ -502,31 +487,26 @@ class Battle::AI
|
|||||||
# Critical hits - n/a
|
# Critical hits - n/a
|
||||||
# Random variance - n/a
|
# Random variance - n/a
|
||||||
# STAB
|
# STAB
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill && (type && user.pbHasType?(type))
|
||||||
if type && user.pbHasType?(type)
|
|
||||||
if user.hasActiveAbility?(:ADAPTABILITY)
|
if user.hasActiveAbility?(:ADAPTABILITY)
|
||||||
multipliers[:final_damage_multiplier] *= 2
|
multipliers[:final_damage_multiplier] *= 2
|
||||||
else
|
else
|
||||||
multipliers[:final_damage_multiplier] *= 1.5
|
multipliers[:final_damage_multiplier] *= 1.5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Type effectiveness
|
# Type effectiveness
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
typemod = pbCalcTypeMod(type, user, target)
|
typemod = pbCalcTypeMod(type, user, target)
|
||||||
multipliers[:final_damage_multiplier] *= typemod.to_f / Effectiveness::NORMAL_EFFECTIVE
|
multipliers[:final_damage_multiplier] *= typemod.to_f / Effectiveness::NORMAL_EFFECTIVE
|
||||||
end
|
end
|
||||||
# Burn
|
# Burn
|
||||||
if skill >= PBTrainerAI.highSkill
|
if skill >= PBTrainerAI.highSkill && (user.status == :BURN && move.physicalMove?(type) &&
|
||||||
if user.status == :BURN && move.physicalMove?(type) &&
|
|
||||||
!user.hasActiveAbility?(:GUTS) &&
|
!user.hasActiveAbility?(:GUTS) &&
|
||||||
!(Settings::MECHANICS_GENERATION >= 6 && move.function == "DoublePowerIfUserPoisonedBurnedParalyzed") # Facade
|
!(Settings::MECHANICS_GENERATION >= 6 && move.function == "DoublePowerIfUserPoisonedBurnedParalyzed")) # Facade
|
||||||
multipliers[:final_damage_multiplier] /= 2
|
multipliers[:final_damage_multiplier] /= 2
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Aurora Veil, Reflect, Light Screen
|
# Aurora Veil, Reflect, Light Screen
|
||||||
if skill >= PBTrainerAI.highSkill
|
if skill >= PBTrainerAI.highSkill && (!move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR))
|
||||||
if !move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR)
|
|
||||||
if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0
|
if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0
|
||||||
if @battle.pbSideBattlerCount(target) > 1
|
if @battle.pbSideBattlerCount(target) > 1
|
||||||
multipliers[:final_damage_multiplier] *= 2 / 3.0
|
multipliers[:final_damage_multiplier] *= 2 / 3.0
|
||||||
@@ -547,13 +527,10 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Minimize
|
# Minimize
|
||||||
if skill >= PBTrainerAI.highSkill
|
if skill >= PBTrainerAI.highSkill && (target.effects[PBEffects::Minimize] && move.tramplesMinimize?(2))
|
||||||
if target.effects[PBEffects::Minimize] && move.tramplesMinimize?(2)
|
|
||||||
multipliers[:final_damage_multiplier] *= 2
|
multipliers[:final_damage_multiplier] *= 2
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Move-specific base damage modifiers
|
# Move-specific base damage modifiers
|
||||||
# TODO
|
# TODO
|
||||||
# Move-specific final damage modifiers
|
# Move-specific final damage modifiers
|
||||||
@@ -572,20 +549,16 @@ class Battle::AI
|
|||||||
if c >= 0 && user.abilityActive?
|
if c >= 0 && user.abilityActive?
|
||||||
c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c)
|
c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c)
|
||||||
end
|
end
|
||||||
if skill >= PBTrainerAI.bestSkill
|
if skill >= PBTrainerAI.bestSkill && (c >= 0 && !moldBreaker && target.abilityActive?)
|
||||||
if c >= 0 && !moldBreaker && target.abilityActive?
|
|
||||||
c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c)
|
c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Item effects that alter critical hit rate
|
# Item effects that alter critical hit rate
|
||||||
if c >= 0 && user.itemActive?
|
if c >= 0 && user.itemActive?
|
||||||
c = Battle::ItemEffects.triggerCriticalCalcFromUser(user.item, user, target, c)
|
c = Battle::ItemEffects.triggerCriticalCalcFromUser(user.item, user, target, c)
|
||||||
end
|
end
|
||||||
if skill >= PBTrainerAI.bestSkill
|
if skill >= PBTrainerAI.bestSkill && (c >= 0 && target.itemActive?)
|
||||||
if c >= 0 && target.itemActive?
|
|
||||||
c = Battle::ItemEffects.triggerCriticalCalcFromTarget(target.item, user, target, c)
|
c = Battle::ItemEffects.triggerCriticalCalcFromTarget(target.item, user, target, c)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Other efffects
|
# Other efffects
|
||||||
c = -1 if target.pbOwnSide.effects[PBEffects::LuckyChant] > 0
|
c = -1 if target.pbOwnSide.effects[PBEffects::LuckyChant] > 0
|
||||||
if c >= 0
|
if c >= 0
|
||||||
@@ -659,28 +632,22 @@ class Battle::AI
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if skill >= PBTrainerAI.bestSkill
|
if skill >= PBTrainerAI.bestSkill && (target.abilityActive? && !moldBreaker)
|
||||||
if target.abilityActive? && !moldBreaker
|
|
||||||
Battle::AbilityEffects.triggerAccuracyCalcFromTarget(
|
Battle::AbilityEffects.triggerAccuracyCalcFromTarget(
|
||||||
target.ability, modifiers, user, target, move, type
|
target.ability, modifiers, user, target, move, type
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Item effects that alter accuracy calculation
|
# Item effects that alter accuracy calculation
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill && user.itemActive?
|
||||||
if user.itemActive?
|
|
||||||
Battle::ItemEffects.triggerAccuracyCalcFromUser(
|
Battle::ItemEffects.triggerAccuracyCalcFromUser(
|
||||||
user.item, modifiers, user, target, move, type
|
user.item, modifiers, user, target, move, type
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
if skill >= PBTrainerAI.bestSkill && target.itemActive?
|
||||||
if skill >= PBTrainerAI.bestSkill
|
|
||||||
if target.itemActive?
|
|
||||||
Battle::ItemEffects.triggerAccuracyCalcFromTarget(
|
Battle::ItemEffects.triggerAccuracyCalcFromTarget(
|
||||||
target.item, modifiers, user, target, move, type
|
target.item, modifiers, user, target, move, type
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Other effects, inc. ones that set accuracy_multiplier or evasion_stage to specific values
|
# Other effects, inc. ones that set accuracy_multiplier or evasion_stage to specific values
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
if @battle.field.effects[PBEffects::Gravity] > 0
|
if @battle.field.effects[PBEffects::Gravity] > 0
|
||||||
@@ -699,15 +666,15 @@ class Battle::AI
|
|||||||
user.effects[PBEffects::LockOnPos] == target.index
|
user.effects[PBEffects::LockOnPos] == target.index
|
||||||
end
|
end
|
||||||
if skill >= PBTrainerAI.highSkill
|
if skill >= PBTrainerAI.highSkill
|
||||||
if move.function == "BadPoisonTarget" # Toxic
|
if move.function == "BadPoisonTarget" && (Settings::MORE_TYPE_EFFECTS && move.statusMove? &&
|
||||||
modifiers[:base_accuracy] = 0 if Settings::MORE_TYPE_EFFECTS && move.statusMove? &&
|
user.pbHasType?(:POISON)) # Toxic
|
||||||
user.pbHasType?(:POISON)
|
modifiers[:base_accuracy] = 0
|
||||||
end
|
end
|
||||||
if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(move.function)
|
if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(move.function)
|
||||||
modifiers[:base_accuracy] = move.accuracy + user.level - target.level
|
modifiers[:base_accuracy] = move.accuracy + user.level - target.level
|
||||||
modifiers[:accuracy_multiplier] = 0 if target.level > user.level
|
modifiers[:accuracy_multiplier] = 0 if target.level > user.level
|
||||||
if skill >= PBTrainerAI.bestSkill
|
if skill >= PBTrainerAI.bestSkill && target.hasActiveAbility?(:STURDY)
|
||||||
modifiers[:accuracy_multiplier] = 0 if target.hasActiveAbility?(:STURDY)
|
modifiers[:accuracy_multiplier] = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ module Battle::CatchAndStoreMixin
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
def pbStorePokemon(pkmn)
|
def pbStorePokemon(pkmn)
|
||||||
# Nickname the Pokémon (unless it's a Shadow Pokémon)
|
# Nickname the Pokémon (unless it's a Shadow Pokémon)
|
||||||
if !pkmn.shadowPokemon? && $PokemonSystem.givenicknames == 0
|
if !pkmn.shadowPokemon?
|
||||||
if pbDisplayConfirm(_INTL("Would you like to give a nickname to {1}?", pkmn.name))
|
if $PokemonSystem.givenicknames == 0 &&
|
||||||
|
pbDisplayConfirm(_INTL("Would you like to give a nickname to {1}?", pkmn.name))
|
||||||
nickname = @scene.pbNameEntry(_INTL("{1}'s nickname?", pkmn.speciesName), pkmn)
|
nickname = @scene.pbNameEntry(_INTL("{1}'s nickname?", pkmn.speciesName), pkmn)
|
||||||
pkmn.name = nickname
|
pkmn.name = nickname
|
||||||
end
|
end
|
||||||
@@ -166,7 +167,7 @@ module Battle::CatchAndStoreMixin
|
|||||||
# Definite capture, no need to perform randomness checks
|
# Definite capture, no need to perform randomness checks
|
||||||
return 4 if x >= 255 || Battle::PokeBallEffects.isUnconditional?(ball, self, battler)
|
return 4 if x >= 255 || Battle::PokeBallEffects.isUnconditional?(ball, self, battler)
|
||||||
# Second half of the shakes calculation
|
# Second half of the shakes calculation
|
||||||
y = (65536 / ((255.0 / x)**0.1875)).floor
|
y = (65_536 / ((255.0 / x)**0.1875)).floor
|
||||||
# Critical capture check
|
# Critical capture check
|
||||||
if Settings::ENABLE_CRITICAL_CAPTURES
|
if Settings::ENABLE_CRITICAL_CAPTURES
|
||||||
dex_modifier = 0
|
dex_modifier = 0
|
||||||
@@ -187,7 +188,7 @@ module Battle::CatchAndStoreMixin
|
|||||||
# Calculate the number of shakes
|
# Calculate the number of shakes
|
||||||
if c > 0 && pbRandom(256) < c
|
if c > 0 && pbRandom(256) < c
|
||||||
@criticalCapture = true
|
@criticalCapture = true
|
||||||
return 4 if pbRandom(65536) < y
|
return 4 if pbRandom(65_536) < y
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -195,7 +196,7 @@ module Battle::CatchAndStoreMixin
|
|||||||
numShakes = 0
|
numShakes = 0
|
||||||
4.times do |i|
|
4.times do |i|
|
||||||
break if numShakes < i
|
break if numShakes < i
|
||||||
numShakes += 1 if pbRandom(65536) < y
|
numShakes += 1 if pbRandom(65_536) < y
|
||||||
end
|
end
|
||||||
return numShakes
|
return numShakes
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ class PBAnimation < Array
|
|||||||
when 0 # Play SE
|
when 0 # Play SE
|
||||||
if i.name && i.name != ""
|
if i.name && i.name != ""
|
||||||
pbSEPlay("Anim/" + i.name, i.volume, i.pitch)
|
pbSEPlay("Anim/" + i.name, i.volume, i.pitch)
|
||||||
elsif user && user.pokemon
|
elsif user&.pokemon
|
||||||
name = GameData::Species.cry_filename_from_pokemon(user.pokemon)
|
name = GameData::Species.cry_filename_from_pokemon(user.pokemon)
|
||||||
pbSEPlay(name, i.volume, i.pitch) if name
|
pbSEPlay(name, i.volume, i.pitch) if name
|
||||||
end
|
end
|
||||||
@@ -517,16 +517,16 @@ class PBAnimation < Array
|
|||||||
bgColor.opacity = i.opacity || 0
|
bgColor.opacity = i.opacity || 0
|
||||||
end
|
end
|
||||||
when 2 # Move/recolour background graphic
|
when 2 # Move/recolour background graphic
|
||||||
if bgGraphic.bitmap != nil
|
if bgGraphic.bitmap.nil?
|
||||||
oldbg[0] = bgGraphic.ox || 0
|
|
||||||
oldbg[1] = bgGraphic.oy || 0
|
|
||||||
oldbg[2] = bgGraphic.opacity || 0
|
|
||||||
oldbg[3] = bgGraphic.color.clone || Color.new(0, 0, 0, 0)
|
|
||||||
else
|
|
||||||
oldbg[0] = 0
|
oldbg[0] = 0
|
||||||
oldbg[1] = 0
|
oldbg[1] = 0
|
||||||
oldbg[2] = bgColor.opacity || 0
|
oldbg[2] = bgColor.opacity || 0
|
||||||
oldbg[3] = bgColor.color.clone || Color.new(0, 0, 0, 0)
|
oldbg[3] = bgColor.color.clone || Color.new(0, 0, 0, 0)
|
||||||
|
else
|
||||||
|
oldbg[0] = bgGraphic.ox || 0
|
||||||
|
oldbg[1] = bgGraphic.oy || 0
|
||||||
|
oldbg[2] = bgGraphic.opacity || 0
|
||||||
|
oldbg[3] = bgGraphic.color.clone || Color.new(0, 0, 0, 0)
|
||||||
end
|
end
|
||||||
when 3 # Set foreground graphic (immediate)
|
when 3 # Set foreground graphic (immediate)
|
||||||
if i.name && i.name != ""
|
if i.name && i.name != ""
|
||||||
@@ -543,16 +543,16 @@ class PBAnimation < Array
|
|||||||
foColor.opacity = i.opacity || 0
|
foColor.opacity = i.opacity || 0
|
||||||
end
|
end
|
||||||
when 4 # Move/recolour foreground graphic
|
when 4 # Move/recolour foreground graphic
|
||||||
if foGraphic.bitmap != nil
|
if foGraphic.bitmap.nil?
|
||||||
oldfo[0] = foGraphic.ox || 0
|
|
||||||
oldfo[1] = foGraphic.oy || 0
|
|
||||||
oldfo[2] = foGraphic.opacity || 0
|
|
||||||
oldfo[3] = foGraphic.color.clone || Color.new(0, 0, 0, 0)
|
|
||||||
else
|
|
||||||
oldfo[0] = 0
|
oldfo[0] = 0
|
||||||
oldfo[1] = 0
|
oldfo[1] = 0
|
||||||
oldfo[2] = foColor.opacity || 0
|
oldfo[2] = foColor.opacity || 0
|
||||||
oldfo[3] = foColor.color.clone || Color.new(0, 0, 0, 0)
|
oldfo[3] = foColor.color.clone || Color.new(0, 0, 0, 0)
|
||||||
|
else
|
||||||
|
oldfo[0] = foGraphic.ox || 0
|
||||||
|
oldfo[1] = foGraphic.oy || 0
|
||||||
|
oldfo[2] = foGraphic.opacity || 0
|
||||||
|
oldfo[3] = foGraphic.color.clone || Color.new(0, 0, 0, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -562,7 +562,14 @@ class PBAnimation < Array
|
|||||||
next if !i.duration || i.duration <= 0
|
next if !i.duration || i.duration <= 0
|
||||||
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?
|
||||||
|
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
|
||||||
|
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
|
||||||
|
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
|
||||||
|
bgColor.color = Color.new(cr, cg, cb, ca)
|
||||||
|
else
|
||||||
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
|
||||||
@@ -571,19 +578,19 @@ class PBAnimation < Array
|
|||||||
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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
|
|
||||||
bgColor.color = Color.new(cr, cg, cb, ca)
|
|
||||||
end
|
end
|
||||||
when 4
|
when 4
|
||||||
next if !i.duration || i.duration <= 0
|
next if !i.duration || i.duration <= 0
|
||||||
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?
|
||||||
|
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
|
||||||
|
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
|
||||||
|
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
|
||||||
|
foColor.color = Color.new(cr, cg, cb, ca)
|
||||||
|
else
|
||||||
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
|
||||||
@@ -592,13 +599,6 @@ class PBAnimation < Array
|
|||||||
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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
|
|
||||||
foColor.color = Color.new(cr, cg, cb, ca)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -700,10 +700,10 @@ class PBAnimationPlayerX
|
|||||||
@user = (oppMove) ? target : user # Just used for playing user's cry
|
@user = (oppMove) ? target : user # Just used for playing user's cry
|
||||||
@usersprite = (user) ? scene.sprites["pokemon_#{user.index}"] : nil
|
@usersprite = (user) ? scene.sprites["pokemon_#{user.index}"] : nil
|
||||||
@targetsprite = (target) ? scene.sprites["pokemon_#{target.index}"] : nil
|
@targetsprite = (target) ? scene.sprites["pokemon_#{target.index}"] : nil
|
||||||
@userbitmap = (@usersprite && @usersprite.bitmap) ? @usersprite.bitmap : nil # not to be disposed
|
@userbitmap = @usersprite&.bitmap # not to be disposed
|
||||||
@targetbitmap = (@targetsprite && @targetsprite.bitmap) ? @targetsprite.bitmap : nil # not to be disposed
|
@targetbitmap = @targetsprite&.bitmap # not to be disposed
|
||||||
@scene = scene
|
@scene = scene
|
||||||
@viewport = (scene) ? scene.viewport : nil
|
@viewport = scene&.viewport
|
||||||
@inEditor = inEditor
|
@inEditor = inEditor
|
||||||
@looping = false
|
@looping = false
|
||||||
@animbitmap = nil # Animation sheet graphic
|
@animbitmap = nil # Animation sheet graphic
|
||||||
@@ -761,9 +761,9 @@ class PBAnimationPlayerX
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@animbitmap.dispose if @animbitmap
|
@animbitmap&.dispose
|
||||||
(2...MAX_SPRITES).each do |i|
|
(2...MAX_SPRITES).each do |i|
|
||||||
@animsprites[i].dispose if @animsprites[i]
|
@animsprites[i]&.dispose
|
||||||
end
|
end
|
||||||
@bgGraphic.dispose
|
@bgGraphic.dispose
|
||||||
@bgColor.dispose
|
@bgColor.dispose
|
||||||
@@ -792,7 +792,7 @@ class PBAnimationPlayerX
|
|||||||
if animFrame >= @animation.length
|
if animFrame >= @animation.length
|
||||||
@frame = (@looping) ? 0 : -1
|
@frame = (@looping) ? 0 : -1
|
||||||
if @frame < 0
|
if @frame < 0
|
||||||
@animbitmap.dispose if @animbitmap
|
@animbitmap&.dispose
|
||||||
@animbitmap = nil
|
@animbitmap = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1179,8 +1179,8 @@ Battle::AbilityEffects::AccuracyCalcFromTarget.add(:UNAWARE,
|
|||||||
|
|
||||||
Battle::AbilityEffects::AccuracyCalcFromTarget.add(:WONDERSKIN,
|
Battle::AbilityEffects::AccuracyCalcFromTarget.add(:WONDERSKIN,
|
||||||
proc { |ability, mods, user, target, move, type|
|
proc { |ability, mods, user, target, move, type|
|
||||||
if move.statusMove? && user.opposes?(target)
|
if move.statusMove? && user.opposes?(target) && mods[:base_accuracy] > 50
|
||||||
mods[:base_accuracy] = 50 if mods[:base_accuracy] > 50
|
mods[:base_accuracy] = 50
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1421,11 +1421,10 @@ Battle::ItemEffects::OnBeingHit.add(:STICKYBARB,
|
|||||||
user.item = target.item
|
user.item = target.item
|
||||||
target.item = nil
|
target.item = nil
|
||||||
target.effects[PBEffects::Unburden] = true if target.hasActiveAbility?(:UNBURDEN)
|
target.effects[PBEffects::Unburden] = true if target.hasActiveAbility?(:UNBURDEN)
|
||||||
if battle.wildBattle? && !user.opposes?
|
if battle.wildBattle? && !user.opposes? &&
|
||||||
if !user.initialItem && user.item == target.initialItem
|
!user.initialItem && user.item == target.initialItem
|
||||||
user.setInitialItem(user.item)
|
user.setInitialItem(user.item)
|
||||||
target.setInitialItem(nil)
|
target.setInitialItem(nil)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
battle.pbDisplay(_INTL("{1}'s {2} was transferred to {3}!",
|
battle.pbDisplay(_INTL("{1}'s {2} was transferred to {3}!",
|
||||||
target.pbThis, user.itemName, user.pbThis(true)))
|
target.pbThis, user.itemName, user.pbThis(true)))
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class Battle::FakeBattler
|
|||||||
def super_shiny?; return @pokemon.super_shiny?; end
|
def super_shiny?; return @pokemon.super_shiny?; end
|
||||||
|
|
||||||
def isSpecies?(check_species)
|
def isSpecies?(check_species)
|
||||||
return @pokemon && @pokemon.isSpecies?(check_species)
|
return @pokemon&.isSpecies?(check_species)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fainted?; return false; end
|
def fainted?; return false; end
|
||||||
|
|||||||
@@ -87,8 +87,9 @@ class BattlePalaceBattle < Battle
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
# though incorrect, just for convenience (actually checks Torment later)
|
# though incorrect, just for convenience (actually checks Torment later)
|
||||||
if thispkmn.effects[PBEffects::Torment] && thispkmn.lastMoveUsed
|
if thispkmn.effects[PBEffects::Torment] &&
|
||||||
return false if thismove.id == thispkmn.lastMoveUsed
|
thispkmn.lastMoveUsed && thismove.id == thispkmn.lastMoveUsed
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ class BattleArenaBattle < Battle
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pbCanSwitchLax?(idxBattler, _idxParty, partyScene = nil)
|
def pbCanSwitchLax?(idxBattler, _idxParty, partyScene = nil)
|
||||||
if partyScene
|
partyScene&.pbDisplay(_INTL("{1} can't be switched out!", @battlers[idxBattler].pbThis))
|
||||||
partyScene.pbDisplay(_INTL("{1} can't be switched out!", @battlers[idxBattler].pbThis))
|
|
||||||
end
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -366,8 +364,8 @@ class Battle::Scene
|
|||||||
ensure
|
ensure
|
||||||
pbDisposeMessageWindow(msgwindow)
|
pbDisposeMessageWindow(msgwindow)
|
||||||
dimmingvp.dispose
|
dimmingvp.dispose
|
||||||
infowindow.contents.dispose if infowindow && infowindow.contents
|
infowindow&.contents&.dispose
|
||||||
infowindow.dispose if infowindow
|
infowindow&.dispose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ module RPG
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose
|
def dispose
|
||||||
@sprites.each { |sprite| sprite.dispose if sprite }
|
@sprites.each { |sprite| sprite&.dispose }
|
||||||
@new_sprites.each { |sprite| sprite.dispose if sprite }
|
@new_sprites.each { |sprite| sprite&.dispose }
|
||||||
@tiles.each { |sprite| sprite.dispose if sprite }
|
@tiles.each { |sprite| sprite&.dispose }
|
||||||
@viewport.dispose
|
@viewport.dispose
|
||||||
@weatherTypes.each_value do |weather|
|
@weatherTypes.each_value do |weather|
|
||||||
next if !weather
|
next if !weather
|
||||||
weather[1].each { |bitmap| bitmap.dispose if bitmap }
|
weather[1].each { |bitmap| bitmap&.dispose }
|
||||||
weather[2].each { |bitmap| bitmap.dispose if bitmap }
|
weather[2].each { |bitmap| bitmap&.dispose }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ module RPG
|
|||||||
@time_shift += 1 # No previous tiles to fade out first
|
@time_shift += 1 # No previous tiles to fade out first
|
||||||
end
|
end
|
||||||
@fading = true
|
@fading = true
|
||||||
@new_sprites.each { |sprite| sprite.dispose if sprite }
|
@new_sprites.each { |sprite| sprite&.dispose }
|
||||||
@new_sprites.clear
|
@new_sprites.clear
|
||||||
ensureSprites
|
ensureSprites
|
||||||
@new_sprites.each_with_index { |sprite, i| set_sprite_bitmap(sprite, i, @target_type) }
|
@new_sprites.each_with_index { |sprite, i| set_sprite_bitmap(sprite, i, @target_type) }
|
||||||
@@ -456,25 +456,24 @@ module RPG
|
|||||||
@new_sprites.each_with_index { |sprite, i| sprite.visible = (i < @new_max) if sprite }
|
@new_sprites.each_with_index { |sprite, i| sprite.visible = (i < @new_max) if sprite }
|
||||||
end
|
end
|
||||||
# End fading
|
# End fading
|
||||||
if @fade_time >= ((@target_type == :None) ? FADE_OLD_PARTICLES_END : FADE_NEW_TILES_END) - @time_shift
|
if @fade_time >= ((@target_type == :None) ? FADE_OLD_PARTICLES_END : FADE_NEW_TILES_END) - @time_shift &&
|
||||||
if !@sprites.any? { |sprite| sprite.visible }
|
!@sprites.any? { |sprite| sprite.visible }
|
||||||
@type = @target_type
|
@type = @target_type
|
||||||
@max = @target_max
|
@max = @target_max
|
||||||
@target_type = nil
|
@target_type = nil
|
||||||
@target_max = nil
|
@target_max = nil
|
||||||
@old_max = nil
|
@old_max = nil
|
||||||
@new_max = nil
|
@new_max = nil
|
||||||
@old_tone = nil
|
@old_tone = nil
|
||||||
@target_tone = nil
|
@target_tone = nil
|
||||||
@fade_time = 0.0
|
@fade_time = 0.0
|
||||||
@time_shift = 0
|
@time_shift = 0
|
||||||
@sprites.each { |sprite| sprite.dispose if sprite }
|
@sprites.each { |sprite| sprite&.dispose }
|
||||||
@sprites = @new_sprites
|
@sprites = @new_sprites
|
||||||
@new_sprites = []
|
@new_sprites = []
|
||||||
@sprite_lifetimes = @new_sprite_lifetimes
|
@sprite_lifetimes = @new_sprite_lifetimes
|
||||||
@new_sprite_lifetimes = []
|
@new_sprite_lifetimes = []
|
||||||
@fading = false
|
@fading = false
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -501,7 +500,7 @@ module RPG
|
|||||||
update_sprite_position(@sprites[i], i, false)
|
update_sprite_position(@sprites[i], i, false)
|
||||||
end
|
end
|
||||||
elsif @sprites.length > 0
|
elsif @sprites.length > 0
|
||||||
@sprites.each { |sprite| sprite.dispose if sprite }
|
@sprites.each { |sprite| sprite&.dispose }
|
||||||
@sprites.clear
|
@sprites.clear
|
||||||
end
|
end
|
||||||
# Update new weather particles (while fading in only)
|
# Update new weather particles (while fading in only)
|
||||||
@@ -511,7 +510,7 @@ module RPG
|
|||||||
update_sprite_position(@new_sprites[i], i, true)
|
update_sprite_position(@new_sprites[i], i, true)
|
||||||
end
|
end
|
||||||
elsif @new_sprites.length > 0
|
elsif @new_sprites.length > 0
|
||||||
@new_sprites.each { |sprite| sprite.dispose if sprite }
|
@new_sprites.each { |sprite| sprite&.dispose }
|
||||||
@new_sprites.clear
|
@new_sprites.clear
|
||||||
end
|
end
|
||||||
# Update weather tiles (sandstorm/blizzard tiled overlay)
|
# Update weather tiles (sandstorm/blizzard tiled overlay)
|
||||||
@@ -520,7 +519,7 @@ module RPG
|
|||||||
recalculate_tile_positions
|
recalculate_tile_positions
|
||||||
@tiles.each_with_index { |sprite, i| update_tile_position(sprite, i) }
|
@tiles.each_with_index { |sprite, i| update_tile_position(sprite, i) }
|
||||||
elsif @tiles.length > 0
|
elsif @tiles.length > 0
|
||||||
@tiles.each { |sprite| sprite.dispose if sprite }
|
@tiles.each { |sprite| sprite&.dispose }
|
||||||
@tiles.clear
|
@tiles.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -47,23 +47,18 @@ def pbBatteryLow?
|
|||||||
end
|
end
|
||||||
|
|
||||||
Events.onMapUpdate += proc { |_sender, _e|
|
Events.onMapUpdate += proc { |_sender, _e|
|
||||||
if !$game_temp.warned_low_battery && pbBatteryLow?
|
if !$game_temp.warned_low_battery && pbBatteryLow? &&
|
||||||
if !$game_temp.in_menu && !$game_temp.in_battle &&
|
!$game_temp.in_menu && !$game_temp.in_battle && !$game_player.move_route_forcing &&
|
||||||
!$game_player.move_route_forcing && !$game_temp.message_window_showing &&
|
!$game_temp.message_window_showing && !pbMapInterpreterRunning? &&
|
||||||
!pbMapInterpreterRunning?
|
pbGetTimeNow.sec == 0
|
||||||
if pbGetTimeNow.sec == 0
|
pbMessage(_INTL("The game has detected that the battery is low. You should save soon to avoid losing your progress."))
|
||||||
pbMessage(_INTL("The game has detected that the battery is low. You should save soon to avoid losing your progress."))
|
$game_temp.warned_low_battery = true
|
||||||
$game_temp.warned_low_battery = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if $game_temp.cue_bgm_frame_delay
|
if $game_temp.cue_bgm_frame_delay
|
||||||
$game_temp.cue_bgm_frame_delay -= 1
|
$game_temp.cue_bgm_frame_delay -= 1
|
||||||
if $game_temp.cue_bgm_frame_delay <= 0
|
if $game_temp.cue_bgm_frame_delay <= 0
|
||||||
$game_temp.cue_bgm_frame_delay = nil
|
$game_temp.cue_bgm_frame_delay = nil
|
||||||
if $game_system.getPlayingBGM == nil
|
pbBGMPlay($game_temp.cue_bgm) if $game_system.getPlayingBGM.nil?
|
||||||
pbBGMPlay($game_temp.cue_bgm)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -133,7 +128,7 @@ Events.onStepTakenFieldMovement += proc { |_sender, e|
|
|||||||
map = $map_factory.getMap(thistile[0])
|
map = $map_factory.getMap(thistile[0])
|
||||||
[2, 1, 0].each do |i|
|
[2, 1, 0].each do |i|
|
||||||
tile_id = map.data[thistile[1], thistile[2], i]
|
tile_id = map.data[thistile[1], thistile[2], i]
|
||||||
next if tile_id == nil
|
next if tile_id.nil?
|
||||||
next if GameData::TerrainTag.try_get(map.terrain_tags[tile_id]).id != :SootGrass
|
next if GameData::TerrainTag.try_get(map.terrain_tags[tile_id]).id != :SootGrass
|
||||||
if event == $game_player && $bag.has?(:SOOTSACK)
|
if event == $game_player && $bag.has?(:SOOTSACK)
|
||||||
old_soot = $player.soot
|
old_soot = $player.soot
|
||||||
@@ -229,7 +224,7 @@ Events.onMapChanging += proc { |_sender, e|
|
|||||||
map_infos = pbLoadMapInfos
|
map_infos = pbLoadMapInfos
|
||||||
if $game_map.name == map_infos[new_map_ID].name
|
if $game_map.name == map_infos[new_map_ID].name
|
||||||
new_map_metadata = GameData::MapMetadata.try_get(new_map_ID)
|
new_map_metadata = GameData::MapMetadata.try_get(new_map_ID)
|
||||||
next if new_map_metadata && new_map_metadata.weather
|
next if new_map_metadata&.weather
|
||||||
end
|
end
|
||||||
$game_screen.weather(:None, 0, 0)
|
$game_screen.weather(:None, 0, 0)
|
||||||
}
|
}
|
||||||
@@ -238,18 +233,18 @@ Events.onMapChanging += proc { |_sender, e|
|
|||||||
Events.onMapChange += proc { |_sender, e|
|
Events.onMapChange += proc { |_sender, e|
|
||||||
old_map_ID = e[0] # previous map ID, is 0 if no map ID
|
old_map_ID = e[0] # previous map ID, is 0 if no map ID
|
||||||
new_map_metadata = $game_map.metadata
|
new_map_metadata = $game_map.metadata
|
||||||
if new_map_metadata && new_map_metadata.teleport_destination
|
if new_map_metadata&.teleport_destination
|
||||||
$PokemonGlobal.healingSpot = new_map_metadata.teleport_destination
|
$PokemonGlobal.healingSpot = new_map_metadata.teleport_destination
|
||||||
end
|
end
|
||||||
$PokemonMap.clear if $PokemonMap
|
$PokemonMap&.clear
|
||||||
$PokemonEncounters.setup($game_map.map_id) if $PokemonEncounters
|
$PokemonEncounters&.setup($game_map.map_id)
|
||||||
$PokemonGlobal.visitedMaps[$game_map.map_id] = true
|
$PokemonGlobal.visitedMaps[$game_map.map_id] = true
|
||||||
next if old_map_ID == 0 || old_map_ID == $game_map.map_id
|
next if old_map_ID == 0 || old_map_ID == $game_map.map_id
|
||||||
next if !new_map_metadata || !new_map_metadata.weather
|
next if !new_map_metadata || !new_map_metadata.weather
|
||||||
map_infos = pbLoadMapInfos
|
map_infos = pbLoadMapInfos
|
||||||
if $game_map.name == map_infos[old_map_ID].name
|
if $game_map.name == map_infos[old_map_ID].name
|
||||||
old_map_metadata = GameData::MapMetadata.try_get(old_map_ID)
|
old_map_metadata = GameData::MapMetadata.try_get(old_map_ID)
|
||||||
next if old_map_metadata && old_map_metadata.weather
|
next if old_map_metadata&.weather
|
||||||
end
|
end
|
||||||
new_weather = new_map_metadata.weather
|
new_weather = new_map_metadata.weather
|
||||||
$game_screen.weather(new_weather[0], 9, 0) if rand(100) < new_weather[1]
|
$game_screen.weather(new_weather[0], 9, 0) if rand(100) < new_weather[1]
|
||||||
@@ -262,14 +257,14 @@ Events.onMapSceneChange += proc { |_sender, e|
|
|||||||
# Update map trail
|
# Update map trail
|
||||||
if $game_map
|
if $game_map
|
||||||
$PokemonGlobal.mapTrail = [] if !$PokemonGlobal.mapTrail
|
$PokemonGlobal.mapTrail = [] if !$PokemonGlobal.mapTrail
|
||||||
if $PokemonGlobal.mapTrail[0] != $game_map.map_id
|
if $PokemonGlobal.mapTrail[0] != $game_map.map_id && $PokemonGlobal.mapTrail.length >= 4
|
||||||
$PokemonGlobal.mapTrail.pop if $PokemonGlobal.mapTrail.length >= 4
|
$PokemonGlobal.mapTrail.pop
|
||||||
end
|
end
|
||||||
$PokemonGlobal.mapTrail = [$game_map.map_id] + $PokemonGlobal.mapTrail
|
$PokemonGlobal.mapTrail = [$game_map.map_id] + $PokemonGlobal.mapTrail
|
||||||
end
|
end
|
||||||
# Display darkness circle on dark maps
|
# Display darkness circle on dark maps
|
||||||
map_metadata = $game_map.metadata
|
map_metadata = $game_map.metadata
|
||||||
if map_metadata && map_metadata.dark_map
|
if map_metadata&.dark_map
|
||||||
$game_temp.darkness_sprite = DarknessSprite.new
|
$game_temp.darkness_sprite = DarknessSprite.new
|
||||||
scene.spriteset.addUserSprite($game_temp.darkness_sprite)
|
scene.spriteset.addUserSprite($game_temp.darkness_sprite)
|
||||||
if $PokemonGlobal.flashUsed
|
if $PokemonGlobal.flashUsed
|
||||||
@@ -277,7 +272,7 @@ Events.onMapSceneChange += proc { |_sender, e|
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
$PokemonGlobal.flashUsed = false
|
$PokemonGlobal.flashUsed = false
|
||||||
$game_temp.darkness_sprite.dispose if $game_temp.darkness_sprite
|
$game_temp.darkness_sprite&.dispose
|
||||||
$game_temp.darkness_sprite = nil
|
$game_temp.darkness_sprite = nil
|
||||||
end
|
end
|
||||||
# Show location signpost
|
# Show location signpost
|
||||||
@@ -298,7 +293,7 @@ Events.onMapSceneChange += proc { |_sender, e|
|
|||||||
scene.spriteset.addUserSprite(LocationWindow.new($game_map.name)) if !nosignpost
|
scene.spriteset.addUserSprite(LocationWindow.new($game_map.name)) if !nosignpost
|
||||||
end
|
end
|
||||||
# Force cycling/walking
|
# Force cycling/walking
|
||||||
if map_metadata && map_metadata.always_bicycle
|
if map_metadata&.always_bicycle
|
||||||
pbMountBike
|
pbMountBike
|
||||||
elsif !pbCanUseBike?($game_map.map_id)
|
elsif !pbCanUseBike?($game_map.map_id)
|
||||||
pbDismountBike
|
pbDismountBike
|
||||||
@@ -517,9 +512,7 @@ def pbMoveRoute(event, commands, waitComplete = false)
|
|||||||
end
|
end
|
||||||
route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOff))
|
route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOff))
|
||||||
route.list.push(RPG::MoveCommand.new(0))
|
route.list.push(RPG::MoveCommand.new(0))
|
||||||
if event
|
event&.force_move_route(route)
|
||||||
event.force_move_route(route)
|
|
||||||
end
|
|
||||||
return route
|
return route
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -610,7 +603,7 @@ def pbMoveTowardPlayer(event)
|
|||||||
pbUpdateSceneMap
|
pbUpdateSceneMap
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
$PokemonMap.addMovedEvent(event.id) if $PokemonMap
|
$PokemonMap&.addMovedEvent(event.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbJumpToward(dist = 1, playSound = false, cancelSurf = false)
|
def pbJumpToward(dist = 1, playSound = false, cancelSurf = false)
|
||||||
|
|||||||
@@ -573,11 +573,9 @@ def pbAfterBattle(decision, canLose)
|
|||||||
pkmn.makeUnprimal
|
pkmn.makeUnprimal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if [2, 5].include?(decision) # if loss or draw
|
if [2, 5].include?(decision) && canLose # if loss or draw
|
||||||
if canLose
|
$player.party.each { |pkmn| pkmn.heal }
|
||||||
$player.party.each { |pkmn| pkmn.heal }
|
(Graphics.frame_rate / 4).times { Graphics.update }
|
||||||
(Graphics.frame_rate / 4).times { Graphics.update }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
Events.onEndBattle.trigger(nil, decision, canLose)
|
Events.onEndBattle.trigger(nil, decision, canLose)
|
||||||
$game_player.straighten
|
$game_player.straighten
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ end
|
|||||||
# Battle intro animation
|
# Battle intro animation
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbSceneStandby
|
def pbSceneStandby
|
||||||
$scene.disposeSpritesets if $scene && $scene.is_a?(Scene_Map)
|
$scene.disposeSpritesets if $scene.is_a?(Scene_Map)
|
||||||
RPG::Cache.clear
|
RPG::Cache.clear
|
||||||
Graphics.frame_reset
|
Graphics.frame_reset
|
||||||
yield
|
yield
|
||||||
$scene.createSpritesets if $scene && $scene.is_a?(Scene_Map)
|
$scene.createSpritesets if $scene.is_a?(Scene_Map)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
|
def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
|
||||||
@@ -46,7 +46,7 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
|
|||||||
# Set up audio
|
# Set up audio
|
||||||
playingBGS = nil
|
playingBGS = nil
|
||||||
playingBGM = nil
|
playingBGM = nil
|
||||||
if $game_system && $game_system.is_a?(Game_System)
|
if $game_system.is_a?(Game_System)
|
||||||
playingBGS = $game_system.getPlayingBGS
|
playingBGS = $game_system.getPlayingBGS
|
||||||
playingBGM = $game_system.getPlayingBGM
|
playingBGM = $game_system.getPlayingBGM
|
||||||
$game_system.bgm_pause
|
$game_system.bgm_pause
|
||||||
@@ -120,7 +120,7 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Take screenshot of game, for use in some animations
|
# Take screenshot of game, for use in some animations
|
||||||
$game_temp.background_bitmap.dispose if $game_temp.background_bitmap
|
$game_temp.background_bitmap&.dispose
|
||||||
$game_temp.background_bitmap = Graphics.snap_to_bitmap
|
$game_temp.background_bitmap = Graphics.snap_to_bitmap
|
||||||
# Play main animation
|
# Play main animation
|
||||||
Graphics.freeze
|
Graphics.freeze
|
||||||
@@ -138,7 +138,7 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
|
|||||||
yield if block_given?
|
yield if block_given?
|
||||||
# After the battle
|
# After the battle
|
||||||
pbPopFade
|
pbPopFade
|
||||||
if $game_system && $game_system.is_a?(Game_System)
|
if $game_system.is_a?(Game_System)
|
||||||
$game_system.bgm_resume(playingBGM)
|
$game_system.bgm_resume(playingBGM)
|
||||||
$game_system.bgs_resume(playingBGS)
|
$game_system.bgs_resume(playingBGS)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -281,25 +281,21 @@ class PokemonEncounters
|
|||||||
favored_type = nil
|
favored_type = nil
|
||||||
case first_pkmn.ability_id
|
case first_pkmn.ability_id
|
||||||
when :FLASHFIRE
|
when :FLASHFIRE
|
||||||
if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS
|
favored_type = :FIRE if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS &&
|
||||||
favored_type = :FIRE if GameData::Type.exists?(:FIRE) && rand(100) < 50
|
GameData::Type.exists?(:FIRE) && rand(100) < 50
|
||||||
end
|
|
||||||
when :HARVEST
|
when :HARVEST
|
||||||
if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS
|
favored_type = :GRASS if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS &&
|
||||||
favored_type = :GRASS if GameData::Type.exists?(:GRASS) && rand(100) < 50
|
GameData::Type.exists?(:GRASS) && rand(100) < 50
|
||||||
end
|
|
||||||
when :LIGHTNINGROD
|
when :LIGHTNINGROD
|
||||||
if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS
|
favored_type = :ELECTRIC if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS &&
|
||||||
favored_type = :ELECTRIC if GameData::Type.exists?(:ELECTRIC) && rand(100) < 50
|
GameData::Type.exists?(:ELECTRIC) && rand(100) < 50
|
||||||
end
|
|
||||||
when :MAGNETPULL
|
when :MAGNETPULL
|
||||||
favored_type = :STEEL if GameData::Type.exists?(:STEEL) && rand(100) < 50
|
favored_type = :STEEL if GameData::Type.exists?(:STEEL) && rand(100) < 50
|
||||||
when :STATIC
|
when :STATIC
|
||||||
favored_type = :ELECTRIC if GameData::Type.exists?(:ELECTRIC) && rand(100) < 50
|
favored_type = :ELECTRIC if GameData::Type.exists?(:ELECTRIC) && rand(100) < 50
|
||||||
when :STORMDRAIN
|
when :STORMDRAIN
|
||||||
if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS
|
favored_type = :WATER if Settings::MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS &&
|
||||||
favored_type = :WATER if GameData::Type.exists?(:WATER) && rand(100) < 50
|
GameData::Type.exists?(:WATER) && rand(100) < 50
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if favored_type
|
if favored_type
|
||||||
new_enc_list = []
|
new_enc_list = []
|
||||||
@@ -433,7 +429,7 @@ def pbGenerateWildPokemon(species, level, isRoamer = false)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Give Pokérus
|
# Give Pokérus
|
||||||
genwildpoke.givePokerus if rand(65536) < Settings::POKERUS_CHANCE
|
genwildpoke.givePokerus if rand(65_536) < Settings::POKERUS_CHANCE
|
||||||
# Change wild Pokémon's gender/nature depending on the lead party Pokémon's
|
# Change wild Pokémon's gender/nature depending on the lead party Pokémon's
|
||||||
# ability
|
# ability
|
||||||
if first_pkmn
|
if first_pkmn
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class PokemonMapMetadata
|
|||||||
@erasedEvents.each do |i|
|
@erasedEvents.each do |i|
|
||||||
if i[0][0] == $game_map.map_id && i[1]
|
if i[0][0] == $game_map.map_id && i[1]
|
||||||
event = $game_map.events[i[0][1]]
|
event = $game_map.events[i[0][1]]
|
||||||
event.erase if event
|
event&.erase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@movedEvents.each do |i|
|
@movedEvents.each do |i|
|
||||||
|
|||||||
@@ -149,9 +149,9 @@ def moonphase(time = nil) # in UTC
|
|||||||
]
|
]
|
||||||
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 > 2_299_160
|
||||||
j += (((time.hour * 60) + (time.min * 60)) + time.sec) / 86400.0
|
j += (((time.hour * 60) + (time.min * 60)) + time.sec) / 86_400.0
|
||||||
v = (j - 2451550.1) / 29.530588853
|
v = (j - 2_451_550.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
|
||||||
transitions.length.times do |i|
|
transitions.length.times do |i|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user