Merge branch 'dev' into ai

This commit is contained in:
Maruno17
2023-03-23 23:20:58 +00:00
7 changed files with 494 additions and 453 deletions

View File

@@ -1,6 +1,8 @@
module GameData module GameData
class ShadowPokemon class ShadowPokemon
attr_reader :id attr_reader :id
attr_reader :species
attr_reader :form
attr_reader :moves attr_reader :moves
attr_reader :gauge_size attr_reader :gauge_size
attr_reader :flags attr_reader :flags
@@ -12,7 +14,7 @@ module GameData
OPTIONAL = true OPTIONAL = true
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "e", :Species], "SectionName" => [:id, "eV", :Species],
"GaugeSize" => [:gauge_size, "v"], "GaugeSize" => [:gauge_size, "v"],
"Moves" => [:moves, "*e", :Move], "Moves" => [:moves, "*e", :Move],
"Flags" => [:flags, "*s"] "Flags" => [:flags, "*s"]
@@ -27,8 +29,24 @@ module GameData
__orig__load if safeExists?("Data/#{self::DATA_FILENAME}") __orig__load if safeExists?("Data/#{self::DATA_FILENAME}")
end end
# @param species [Symbol, self, String]
# @param form [Integer]
# @return [self, nil]
def self.get_species_form(species, form)
return nil if !species || !form
validate species => [Symbol, self, String]
validate form => Integer
species = species.species if species.is_a?(self)
species = species.to_sym if species.is_a?(String)
trial = sprintf("%s_%d", species, form).to_sym
species_form = (DATA[trial].nil?) ? species : trial
return (DATA.has_key?(species_form)) ? DATA[species_form] : nil
end
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@species = hash[:species] || @id
@form = hash[:form] || 0
@gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE @gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE
@moves = hash[:moves] || [] @moves = hash[:moves] || []
@flags = hash[:flags] || [] @flags = hash[:flags] || []
@@ -38,5 +56,15 @@ module GameData
def has_flag?(flag) def has_flag?(flag)
return @flags.any? { |f| f.downcase == flag.downcase } return @flags.any? { |f| f.downcase == flag.downcase }
end end
alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS)
def get_property_for_PBS(key)
ret = __orig__get_property_for_PBS(key)
case key
when "SectionName"
ret = [@species, (@form > 0) ? @form : nil]
end
return ret
end
end end
end end

View File

@@ -54,8 +54,8 @@ class Battle::Battler
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.pbCanBurn?(user, false, self) user.pbCanBurn?(target, false, self)
target.pbBurn(user) user.pbBurn(target)
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)

View File

@@ -836,7 +836,7 @@ class Battle::Move::SetTargetTypesToPsychic < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message) def pbFailsAgainstTarget?(user, target, show_message)
if !target.canChangeType? || !GameData::Type.exists?(:PSYCHIC) || if !target.canChangeType? || !GameData::Type.exists?(:PSYCHIC) ||
!target.pbHasOtherType?(:PSYCHIC) || !target.affectedByPowder? !target.pbHasOtherType?(:PSYCHIC)
@battle.pbDisplay(_INTL("But it failed!")) if show_message @battle.pbDisplay(_INTL("But it failed!")) if show_message
return true return true
end end

View File

@@ -30,9 +30,7 @@ class Pokemon
end end
def shadow_data def shadow_data
ret = GameData::ShadowPokemon.try_get(species_data.id) return GameData::ShadowPokemon.get_species_form(@species, form_simple)
ret = GameData::ShadowPokemon.try_get(@species) if !ret
return ret
end end
def max_gauge_size def max_gauge_size

View File

@@ -796,7 +796,7 @@ class PokemonParty_Scene
when Input::LEFT when Input::LEFT
loop do loop do
currentsel -= 1 currentsel -= 1
break unless currentsel > 0 && currentsel < @party.length && !@party[currentsel] break unless currentsel > 0 && currentsel < Settings::MAX_PARTY_SIZE && !@party[currentsel]
end end
if currentsel >= @party.length && currentsel < Settings::MAX_PARTY_SIZE if currentsel >= @party.length && currentsel < Settings::MAX_PARTY_SIZE
currentsel = @party.length - 1 currentsel = @party.length - 1
@@ -805,13 +805,10 @@ class PokemonParty_Scene
when Input::RIGHT when Input::RIGHT
loop do loop do
currentsel += 1 currentsel += 1
break unless currentsel < @party.length && !@party[currentsel] break unless currentsel < Settings::MAX_PARTY_SIZE && !@party[currentsel]
end end
if currentsel == @party.length if currentsel == numsprites
currentsel = Settings::MAX_PARTY_SIZE currentsel = (@party.length == 0) ? Settings::MAX_PARTY_SIZE : 0
elsif currentsel == numsprites
currentsel = 0
currentsel = numsprites - 1 if currentsel >= @party.length
end end
when Input::UP when Input::UP
if currentsel >= Settings::MAX_PARTY_SIZE if currentsel >= Settings::MAX_PARTY_SIZE
@@ -819,7 +816,7 @@ class PokemonParty_Scene
while currentsel > 0 && currentsel < Settings::MAX_PARTY_SIZE && !@party[currentsel] while currentsel > 0 && currentsel < Settings::MAX_PARTY_SIZE && !@party[currentsel]
currentsel -= 1 currentsel -= 1
end end
currentsel = numsprites - 1 if currentsel >= @party.length currentsel = numsprites - 1 if currentsel < Settings::MAX_PARTY_SIZE && currentsel >= @party.length
else else
loop do loop do
currentsel -= 2 currentsel -= 2
@@ -840,8 +837,7 @@ class PokemonParty_Scene
if currentsel >= @party.length && currentsel < Settings::MAX_PARTY_SIZE if currentsel >= @party.length && currentsel < Settings::MAX_PARTY_SIZE
currentsel = Settings::MAX_PARTY_SIZE currentsel = Settings::MAX_PARTY_SIZE
elsif currentsel >= numsprites elsif currentsel >= numsprites
currentsel = 0 currentsel = (@party.length == 0) ? Settings::MAX_PARTY_SIZE : 0
currentsel = numsprites - 1 if currentsel >= @party.length
end end
end end
return currentsel return currentsel

View File

@@ -551,6 +551,16 @@ module Compiler
end end
def validate_compiled_shadow_pokemon(hash) def validate_compiled_shadow_pokemon(hash)
# Split species and form into their own values, generate compound ID from them
if hash[:id].is_a?(Array)
hash[:species] = hash[:id][0]
hash[:form] = hash[:id][1] || 0
if hash[:form] == 0
hash[:id] = hash[:species]
else
hash[:id] = sprintf("%s_%d", hash[:species].to_s, hash[:form]).to_sym
end
end
end end
def validate_all_compiled_shadow_pokemon def validate_all_compiled_shadow_pokemon