Generalised a species' types to allow any number of types

This commit is contained in:
Maruno17
2022-12-31 17:24:33 +00:00
parent 3a4b01e2dc
commit 3fe324d0da
24 changed files with 200 additions and 203 deletions

View File

@@ -25,7 +25,7 @@ class Window_Pokedex < Window_DrawableCommand
end
def species
return (@commands.length == 0) ? 0 : @commands[self.index][0]
return (@commands.length == 0) ? 0 : @commands[self.index][:species]
end
def itemCount
@@ -35,9 +35,9 @@ class Window_Pokedex < Window_DrawableCommand
def drawItem(index, _count, rect)
return if index >= self.top_row + self.page_item_max
rect = Rect.new(rect.x + 16, rect.y, rect.width - 16, rect.height)
species = @commands[index][0]
indexNumber = @commands[index][4]
indexNumber -= 1 if @commands[index][5]
species = @commands[index][:species]
indexNumber = @commands[index][:number]
indexNumber -= 1 if @commands[index][:shift]
if $player.seen?(species)
if $player.owned?(species)
pbCopyBitmap(self.contents, @pokeballOwn.bitmap, rect.x - 6, rect.y + 10)
@@ -45,7 +45,7 @@ class Window_Pokedex < Window_DrawableCommand
pbCopyBitmap(self.contents, @pokeballSeen.bitmap, rect.x - 6, rect.y + 10)
end
num_text = sprintf("%03d", indexNumber)
name_text = @commands[index][1]
name_text = @commands[index][:name]
else
num_text = sprintf("%03d", indexNumber)
name_text = "----------"
@@ -362,13 +362,17 @@ class PokemonPokedex_Scene
next if !pbCanAddForModeList?($PokemonGlobal.pokedexMode, species)
_gender, form, _shiny = $player.pokedex.last_form_seen(species)
species_data = GameData::Species.get_species_form(species, form)
color = species_data.color
type1 = species_data.types[0]
type2 = species_data.types[1] || type1
shape = species_data.shape
height = species_data.height
weight = species_data.weight
ret.push([species, species_data.name, height, weight, i + 1, shift, type1, type2, color, shape])
ret.push({
:species => species,
:name => species_data.name,
:height => species_data.height,
:weight => species_data.weight,
:number => i + 1,
:shift => shift,
:types => species_data.types,
:color => species_data.color,
:shape => species_data.shape
})
end
return ret
end
@@ -378,27 +382,27 @@ class PokemonPokedex_Scene
case $PokemonGlobal.pokedexMode
when MODENUMERICAL
# Hide the Dex number 0 species if unseen
dexlist[0] = nil if dexlist[0][5] && !$player.seen?(dexlist[0][0])
dexlist[0] = nil if dexlist[0][:shift] && !$player.seen?(dexlist[0][:species])
# Remove unseen species from the end of the list
i = dexlist.length - 1
loop do
break if i < 0 || !dexlist[i] || $player.seen?(dexlist[i][0])
break if i < 0 || !dexlist[i] || $player.seen?(dexlist[i][:species])
dexlist[i] = nil
i -= 1
end
dexlist.compact!
# Sort species in ascending order by Regional Dex number
dexlist.sort! { |a, b| a[4] <=> b[4] }
dexlist.sort! { |a, b| a[:number] <=> b[:number] }
when MODEATOZ
dexlist.sort! { |a, b| (a[1] == b[1]) ? a[4] <=> b[4] : a[1] <=> b[1] }
dexlist.sort! { |a, b| (a[:name] == b[:name]) ? a[:number] <=> b[:number] : a[:name] <=> b[:name] }
when MODEHEAVIEST
dexlist.sort! { |a, b| (a[3] == b[3]) ? a[4] <=> b[4] : b[3] <=> a[3] }
dexlist.sort! { |a, b| (a[:weight] == b[:weight]) ? a[:number] <=> b[:number] : b[:weight] <=> a[:weight] }
when MODELIGHTEST
dexlist.sort! { |a, b| (a[3] == b[3]) ? a[4] <=> b[4] : a[3] <=> b[3] }
dexlist.sort! { |a, b| (a[:weight] == b[:weight]) ? a[:number] <=> b[:number] : a[:weight] <=> b[:weight] }
when MODETALLEST
dexlist.sort! { |a, b| (a[2] == b[2]) ? a[4] <=> b[4] : b[2] <=> a[2] }
dexlist.sort! { |a, b| (a[:height] == b[:height]) ? a[:number] <=> b[:number] : b[:height] <=> a[:height] }
when MODESMALLEST
dexlist.sort! { |a, b| (a[2] == b[2]) ? a[4] <=> b[4] : a[2] <=> b[2] }
dexlist.sort! { |a, b| (a[:height] == b[:height]) ? a[:number] <=> b[:number] : a[:height] <=> b[:height] }
end
@dexlist = dexlist
@sprites["pokedex"].commands = @dexlist
@@ -774,8 +778,8 @@ class PokemonPokedex_Scene
if params[1] >= 0
scanNameCommand = @nameCommands[params[1]].scan(/./)
dexlist = dexlist.find_all { |item|
next false if !$player.seen?(item[0])
firstChar = item[1][0, 1]
next false if !$player.seen?(item[:species])
firstChar = item[:name][0, 1]
next scanNameCommand.any? { |v| v == firstChar }
}
end
@@ -784,18 +788,17 @@ class PokemonPokedex_Scene
stype1 = (params[2] >= 0) ? @typeCommands[params[2]].id : nil
stype2 = (params[3] >= 0) ? @typeCommands[params[3]].id : nil
dexlist = dexlist.find_all { |item|
next false if !$player.owned?(item[0])
type1 = item[6]
type2 = item[7]
next false if !$player.owned?(item[:species])
types = item[:types]
if stype1 && stype2
# Find species that match both types
next (type1 == stype1 && type2 == stype2) || (type1 == stype2 && type2 == stype1)
next types.include?(stype1) && types.include?(stype2)
elsif stype1
# Find species that match first type entered
next type1 == stype1 || type2 == stype1
next types.include?(stype1)
elsif stype2
# Find species that match second type entered
next type1 == stype2 || type2 == stype2
next types.include?(stype2)
else
next false
end
@@ -806,8 +809,8 @@ class PokemonPokedex_Scene
minh = (params[4] < 0) ? 0 : (params[4] >= @heightCommands.length) ? 999 : @heightCommands[params[4]]
maxh = (params[5] < 0) ? 999 : (params[5] >= @heightCommands.length) ? 0 : @heightCommands[params[5]]
dexlist = dexlist.find_all { |item|
next false if !$player.owned?(item[0])
height = item[2]
next false if !$player.owned?(item[:species])
height = item[:height]
next height >= minh && height <= maxh
}
end
@@ -816,8 +819,8 @@ class PokemonPokedex_Scene
minw = (params[6] < 0) ? 0 : (params[6] >= @weightCommands.length) ? 9999 : @weightCommands[params[6]]
maxw = (params[7] < 0) ? 9999 : (params[7] >= @weightCommands.length) ? 0 : @weightCommands[params[7]]
dexlist = dexlist.find_all { |item|
next false if !$player.owned?(item[0])
weight = item[3]
next false if !$player.owned?(item[:species])
weight = item[:weight]
next weight >= minw && weight <= maxw
}
end
@@ -825,27 +828,27 @@ class PokemonPokedex_Scene
if params[8] >= 0
scolor = @colorCommands[params[8]].id
dexlist = dexlist.find_all { |item|
next false if !$player.seen?(item[0])
next item[8] == scolor
next false if !$player.seen?(item[:species])
next item[:color] == scolor
}
end
# Filter by shape
if params[9] >= 0
sshape = @shapeCommands[params[9]].id
dexlist = dexlist.find_all { |item|
next false if !$player.seen?(item[0])
next item[9] == sshape
next false if !$player.seen?(item[:species])
next item[:shape] == sshape
}
end
# Remove all unseen species from the results
dexlist = dexlist.find_all { |item| next $player.seen?(item[0]) }
dexlist = dexlist.find_all { |item| next $player.seen?(item[:species]) }
case $PokemonGlobal.pokedexMode
when MODENUMERICAL then dexlist.sort! { |a, b| a[4] <=> b[4] }
when MODEATOZ then dexlist.sort! { |a, b| a[1] <=> b[1] }
when MODEHEAVIEST then dexlist.sort! { |a, b| b[3] <=> a[3] }
when MODELIGHTEST then dexlist.sort! { |a, b| a[3] <=> b[3] }
when MODETALLEST then dexlist.sort! { |a, b| b[2] <=> a[2] }
when MODESMALLEST then dexlist.sort! { |a, b| a[2] <=> b[2] }
when MODENUMERICAL then dexlist.sort! { |a, b| a[:number] <=> b[:number] }
when MODEATOZ then dexlist.sort! { |a, b| a[:name] <=> b[:name] }
when MODEHEAVIEST then dexlist.sort! { |a, b| b[:weight] <=> a[:weight] }
when MODELIGHTEST then dexlist.sort! { |a, b| a[:weight] <=> b[:weight] }
when MODETALLEST then dexlist.sort! { |a, b| b[:height] <=> a[:height] }
when MODESMALLEST then dexlist.sort! { |a, b| a[:height] <=> b[:height] }
end
return dexlist
end
@@ -858,7 +861,7 @@ class PokemonPokedex_Scene
@searchParams = [$PokemonGlobal.pokedexMode, -1, -1, -1, -1, -1, -1, -1, -1, -1]
pbRefreshDexList($PokemonGlobal.pokedexIndex[pbGetSavePositionIndex])
@dexlist.length.times do |i|
next if @dexlist[i][0] != oldspecies
next if @dexlist[i][:species] != oldspecies
@sprites["pokedex"].index = i
pbRefresh
break

View File

@@ -90,8 +90,15 @@ class PokemonPokedexInfo_Scene
break
end
end
@dexlist = [[species, "", 0, 0, dexnum, dexnumshift]]
@index = 0
@dexlist = [{
:species => species,
:name => "",
:height => 0,
:weight => 0,
:number => dexnum,
:shift => dexnumshift
}]
@index = 0
@page = 1
@brief = true
@typebitmap = AnimatedBitmap.new(_INTL("Graphics/UI/Pokedex/icon_types"))
@@ -125,7 +132,7 @@ class PokemonPokedexInfo_Scene
end
def pbUpdateDummyPokemon
@species = @dexlist[@index][0]
@species = @dexlist[@index][:species]
@gender, @form, _shiny = $player.pokedex.last_form_seen(@species)
@shiny = false
metrics_data = GameData::SpeciesMetrics.get_species_form(@species, @form)
@@ -209,9 +216,9 @@ class PokemonPokedexInfo_Scene
species_data = GameData::Species.get_species_form(@species, @form)
# Write various bits of text
indexText = "???"
if @dexlist[@index][4] > 0
indexNumber = @dexlist[@index][4]
indexNumber -= 1 if @dexlist[@index][5]
if @dexlist[@index][:number] > 0
indexNumber = @dexlist[@index][:number]
indexNumber -= 1 if @dexlist[@index][:shift]
indexText = sprintf("%03d", indexNumber)
end
textpos = [
@@ -406,7 +413,7 @@ class PokemonPokedexInfo_Scene
newindex = @index
while newindex > 0
newindex -= 1
if $player.seen?(@dexlist[newindex][0])
if $player.seen?(@dexlist[newindex][:species])
@index = newindex
break
end
@@ -417,7 +424,7 @@ class PokemonPokedexInfo_Scene
newindex = @index
while newindex < @dexlist.length - 1
newindex += 1
if $player.seen?(@dexlist[newindex][0])
if $player.seen?(@dexlist[newindex][:species])
@index = newindex
break
end
@@ -581,7 +588,14 @@ class PokemonPokedexInfoScreen
end
dexnum = pbGetRegionalNumber(region, species)
dexnumshift = Settings::DEXES_WITH_OFFSETS.include?(region)
dexlist = [[species, GameData::Species.get(species).name, 0, 0, dexnum, dexnumshift]]
dexlist = [{
:species => species,
:name => GameData::Species.get(species).name,
:height => 0,
:weight => 0,
:number => dexnum,
:shift => dexnumshift
}]
@scene.pbStartScene(dexlist, 0, region)
@scene.pbScene
@scene.pbEndScene

View File

@@ -141,17 +141,17 @@ class PurifyChamberSet
end
# Purify Chamber treats Normal/Normal matchup as super effective
def self.typeAdvantage(p1, p2)
return true if p1 == :NORMAL && p2 == :NORMAL
return Effectiveness.super_effective_type?(p1, p2)
def self.typeAdvantage(type1, type2)
return true if type1 == :NORMAL && type2 == :NORMAL
return Effectiveness.super_effective_type?(type1, type2)
end
def self.isSuperEffective(p1, p2)
return true if typeAdvantage(p1.types[0], p2.types[0])
return true if p2.types[1] && typeAdvantage(p1.types[0], p2.types[1])
return false if p1.types[1].nil?
return true if typeAdvantage(p1.types[1], p2.types[0])
return true if p2.types[1] && typeAdvantage(p1.types[1], p2.types[1])
def self.isSuperEffective(pkmn1, pkmn2)
pkmn1.types.each do |type1|
pkmn2.types.each do |type2|
return true if typeAdvantage(type1, type2)
end
end
return false
end
end
@@ -952,16 +952,13 @@ class PurifyChamberSetView < Sprite
pbSetSmallFont(@info.bitmap)
textpos = []
if pkmn
if pkmn.types.length == 1
textpos.push([_INTL("{1} Lv.{2} {3}", pkmn.name, pkmn.level,
GameData::Type.get(pkmn.types[0]).name),
2, 6, 0, Color.new(248, 248, 248), Color.new(128, 128, 128)])
else
textpos.push([_INTL("{1} Lv.{2} {3}/{4}", pkmn.name, pkmn.level,
GameData::Type.get(pkmn.types[0]).name,
GameData::Type.get(pkmn.types[1]).name),
2, 6, 0, Color.new(248, 248, 248), Color.new(128, 128, 128)])
type_string = ""
pkmn.types.each_with_index do |type, i|
type_string += "/" if i > 0
type_string += GameData::Type.get(type).name
end
textpos.push([_INTL("{1} Lv.{2} {3}", pkmn.name, pkmn.level, type_string),
2, 6, 0, Color.new(248, 248, 248), Color.new(128, 128, 128)])
textpos.push([_INTL("FLOW"), 2 + (@info.bitmap.width / 2), 30, 0,
Color.new(248, 248, 248), Color.new(128, 128, 128)])
# draw heart gauge