Created and implemented GameData::Type

This commit is contained in:
Maruno17
2020-12-12 21:26:46 +00:00
parent c8790bafc9
commit bc13517cb7
50 changed files with 698 additions and 784 deletions

View File

@@ -273,7 +273,7 @@ module PokemonDebugMixin
totaliv += pkmn.iv[i]
end
msg = _INTL("Change which IV?\nHidden Power:\n{1}, power {2}\nTotal: {3}/{4} ({5}%)",
PBTypes.getName(hiddenpower[0]),hiddenpower[1],totaliv,numstats*31,
GameData::Type.get(hiddenpower[0]).name,hiddenpower[1],totaliv,numstats*31,
100*totaliv/(numstats*31))
ivcommands.push(_INTL("Randomise all"))
cmd2 = pbShowCommands(msg,ivcommands,cmd2)

View File

@@ -895,7 +895,7 @@ def pbPokemonEditor
habitat = speciesData[SpeciesData::HABITAT]
type1 = speciesData[SpeciesData::TYPE1]
type2 = speciesData[SpeciesData::TYPE2]
type2 = nil if type2==type1
type2 = nil if type2 == type1
baseStats = speciesData[SpeciesData::BASE_STATS].clone if speciesData[SpeciesData::BASE_STATS]
rareness = speciesData[SpeciesData::RARENESS]
shape = speciesData[SpeciesData::SHAPE]
@@ -993,7 +993,7 @@ def pbPokemonEditor
save = pbPropertyList(data[0],data,species,true)
if save
# Make sure both Type1 and Type2 are recorded correctly
data[2] = (data[3] || 0) if !data[2]
data[2] = data[3] if !data[2]
data[3] = data[2] if !data[3]
# Make sure both Compatibilities are recorded correctly
data[19] = (data[20] && data[20]!=0) ? data[20] : PBEggGroups::Undiscovered if !data[19] || data[19]==0

View File

@@ -2,41 +2,22 @@
# Save type data to PBS file
#===============================================================================
def pbSaveTypes
return if (PBTypes.maxValue rescue 0)==0
File.open("PBS/types.txt","wb") { |f|
File.open("PBS/types.txt", "wb") { |f|
f.write(0xEF.chr)
f.write(0xBB.chr)
f.write(0xBF.chr)
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
for i in 0..(PBTypes.maxValue rescue 25)
name = PBTypes.getName(i) rescue nil
next if !name || name==""
# Write each type in turn
GameData::Type.each do |type|
f.write("\#-------------------------------\r\n")
constname = getConstantName(PBTypes,i) rescue pbGetTypeConst(i)
f.write(sprintf("[%d]\r\n",i))
f.write(sprintf("Name = %s\r\n",name))
f.write(sprintf("InternalName = %s\r\n",constname))
if (PBTypes.isPseudoType?(i) rescue isConst?(i,PBTypes,QMARKS))
f.write("IsPseudoType = true\r\n")
end
if (PBTypes.isSpecialType?(i) rescue pbIsOldSpecialType?(i))
f.write("IsSpecialType = true\r\n")
end
weak = []
resist = []
immune = []
for j in 0..(PBTypes.maxValue rescue 25)
cname = getConstantName(PBTypes,j) rescue pbGetTypeConst(j)
next if !cname || cname==""
case PBTypes.getEffectiveness(j,i)
when PBTypeEffectiveness::SUPER_EFFECTIVE_ONE then weak.push(cname)
when PBTypeEffectiveness::NOT_EFFECTIVE_ONE then resist.push(cname)
when PBTypeEffectiveness::INEFFECTIVE then immune.push(cname)
end
end
f.write("Weaknesses = "+weak.join(",")+"\r\n") if weak.length>0
f.write("Resistances = "+resist.join(",")+"\r\n") if resist.length>0
f.write("Immunities = "+immune.join(",")+"\r\n") if immune.length>0
f.write("[#{type.id_number}]\r\n")
f.write("Name = #{type.real_name}\r\n")
f.write("InternalName = #{type.id.to_s}\r\n")
f.write("IsPseudoType = true\r\n") if type.pseudo_type
f.write("IsSpecialType = true\r\n") if type.special?
f.write("Weaknesses = #{type.weaknesses.join(",")}\r\n") if type.weaknesses.length > 0
f.write("Resistances = #{type.resistances.join(",")}\r\n") if type.resistances.length > 0
f.write("Immunities = #{type.immunities.join(",")}\r\n") if type.immunities.length > 0
end
}
end
@@ -87,12 +68,12 @@ def pbSaveMoveData
csvQuote(m.real_name),
csvQuote(m.function_code),
m.base_damage,
(getConstantName(PBTypes, m.type) rescue pbGetTypeConst(m.type) rescue ""),
m.type.to_s,
["Physical", "Special", "Status"][m.category],
m.accuracy,
m.total_pp,
m.effect_chance,
(getConstantName(PBTargets, m.target) rescue sprintf("%02X", m.target)),
(getConstantName(PBTargets, m.target) rescue sprintf("%d", m.target)),
m.priority,
csvQuote(m.flags),
csvQuoteAlways(m.real_description)
@@ -616,7 +597,7 @@ def pbSavePokemonData
end
color = speciesData[i][SpeciesData::COLOR] || 0
habitat = speciesData[i][SpeciesData::HABITAT] || 0
type1 = speciesData[i][SpeciesData::TYPE1] || 0
type1 = speciesData[i][SpeciesData::TYPE1]
type2 = speciesData[i][SpeciesData::TYPE2] || type1
if speciesData[i][SpeciesData::BASE_STATS]
basestats = speciesData[i][SpeciesData::BASE_STATS].clone
@@ -664,11 +645,11 @@ def pbSavePokemonData
pokedata.write("\#-------------------------------\r\n")
pokedata.write("[#{i}]\r\nName = #{speciesname}\r\n")
pokedata.write("InternalName = #{cname}\r\n")
ctype1 = getConstantName(PBTypes,type1) rescue pbGetTypeConst(type1) || pbGetTypeConst(0) || "NORMAL"
pokedata.write("Type1 = #{ctype1}\r\n")
if type1!=type2
ctype2 = getConstantName(PBTypes,type2) rescue pbGetTypeConst(type2) || pbGetTypeConst(0) || "NORMAL"
pokedata.write("Type2 = #{ctype2}\r\n")
if type1
pokedata.write("Type1 = #{type1.to_s}\r\n")
end
if type2 && type2 != type1
pokedata.write("Type2 = #{type2.to_s}\r\n")
end
pokedata.write("BaseStats = #{basestats[0]},#{basestats[1]},#{basestats[2]},#{basestats[3]},#{basestats[4]},#{basestats[5]}\r\n")
gendername = getConstantName(PBGenderRates,gender) rescue pbGetGenderConst(gender)
@@ -680,36 +661,30 @@ def pbSavePokemonData
pokedata.write("Happiness = #{happiness}\r\n")
pokedata.write("Abilities = ")
if ability1
cability1 = GameData::Ability.get(ability1).id.to_s
pokedata.write("#{cability1}")
pokedata.write("#{ability1.to_s}")
pokedata.write(",") if ability2
end
if ability2
cability2 = GameData::Ability.get(ability2).id.to_s
pokedata.write("#{cability2}")
pokedata.write("#{ability2.to_s}")
end
pokedata.write("\r\n")
if hiddenability1 || hiddenability2 || hiddenability3 || hiddenability4
pokedata.write("HiddenAbility = ")
needcomma = false
if hiddenability1
cabilityh = GameData::Ability.get(hiddenability1).id.to_s
pokedata.write("#{cabilityh}"); needcomma = true
pokedata.write("#{hiddenability1.to_s}"); needcomma = true
end
if hiddenability2
pokedata.write(",") if needcomma
cabilityh = GameData::Ability.get(hiddenability2).id.to_s
pokedata.write("#{cabilityh}"); needcomma = true
pokedata.write("#{hiddenability2.to_s}"); needcomma = true
end
if hiddenability3
pokedata.write(",") if needcomma
cabilityh = GameData::Ability.get(hiddenability3).id.to_s
pokedata.write("#{cabilityh}"); needcomma = true
pokedata.write("#{hiddenability3.to_s}"); needcomma = true
end
if hiddenability4
pokedata.write(",") if needcomma
cabilityh = GameData::Ability.get(hiddenability4).id.to_s
pokedata.write("#{cabilityh}")
pokedata.write("#{hiddenability4.to_s}")
end
pokedata.write("\r\n")
end
@@ -724,8 +699,7 @@ def pbSavePokemonData
level = m[0]
move = m[1]
pokedata.write(",") if !first
cmove = GameData::Move.get(move).id.to_s
pokedata.write(sprintf("%d,%s",level,cmove))
pokedata.write(sprintf("%d,%s",level,move.to_s))
first = false
end
pokedata.write("\r\n")
@@ -734,10 +708,9 @@ def pbSavePokemonData
pokedata.write("EggMoves = ")
first = true
eggMoves[i].each do |m|
next if !m || m==0
next if !m
pokedata.write(",") if !first
cmove = GameData::Move.get(m).id.to_s
pokedata.write("#{cmove}")
pokedata.write("#{m.to_s}")
first = false
end
pokedata.write("\r\n")
@@ -782,16 +755,13 @@ def pbSavePokemonData
pokedata.write("FormName = #{formname}\r\n")
end
if item1
citem1 = GameData::Item.get(item1).id.to_s
pokedata.write("WildItemCommon = #{citem1}\r\n")
pokedata.write("WildItemCommon = #{item1.to_s}\r\n")
end
if item2
citem2 = GameData::Item.get(item2).id.to_s
pokedata.write("WildItemUncommon = #{citem2}\r\n")
pokedata.write("WildItemUncommon = #{item2.to_s}\r\n")
end
if item3
citem3 = GameData::Item.get(item3).id.to_s
pokedata.write("WildItemRare = #{citem3}\r\n")
pokedata.write("WildItemRare = #{item3.to_s}\r\n")
end
if metrics && metrics.length>0
pokedata.write("BattlerPlayerX = #{metrics[SpeciesData::METRIC_PLAYER_X][i] || 0}\r\n")
@@ -818,7 +788,7 @@ def pbSavePokemonData
has_param = !PBEvolution.hasFunction?(method, "parameterType") || param_type != nil
if has_param
if param_type
if [:Ability, :Item].include?(param_type)
if [:Ability, :Item, :Move, :TrainerType, :Type].include?(param_type)
pokedata.write("#{parameter.to_s}")
else
cparameter = (getConstantName(param_type, parameter) rescue parameter)
@@ -832,8 +802,7 @@ def pbSavePokemonData
end
pokedata.write("\r\n")
if incense
initem = GameData::Item.get(incense).id.to_s
pokedata.write("Incense = #{initem}\r\n")
pokedata.write("Incense = #{incense.to_s}\r\n")
end
if i%20==0
Graphics.update
@@ -885,7 +854,7 @@ def pbSavePokemonFormsData
end
origdata["color"] = speciesData[species][SpeciesData::COLOR] || 0
origdata["habitat"] = speciesData[species][SpeciesData::HABITAT] || 0
origdata["type1"] = speciesData[species][SpeciesData::TYPE1] || 0
origdata["type1"] = speciesData[species][SpeciesData::TYPE1]
origdata["type2"] = speciesData[species][SpeciesData::TYPE2] || type1
if speciesData[species][SpeciesData::BASE_STATS]
origdata["basestats"] = speciesData[species][SpeciesData::BASE_STATS].clone
@@ -945,7 +914,7 @@ def pbSavePokemonFormsData
color = nil if color==origdata["color"]
habitat = speciesData[i][SpeciesData::HABITAT] || 0
habitat = nil if habitat==origdata["habitat"]
type1 = speciesData[i][SpeciesData::TYPE1] || 0
type1 = speciesData[i][SpeciesData::TYPE1]
type2 = speciesData[i][SpeciesData::TYPE2] || type1
if type1==origdata["type1"] && type2==origdata["type2"]
type1 = type2 = nil
@@ -1037,22 +1006,18 @@ def pbSavePokemonFormsData
pokedata.write("FormName = #{formname}\r\n") if formname && formname!=""
pokedata.write("PokedexForm = #{pokedexform}\r\n") if pokedexform>0
if megastone
citem = GameData::Item.get(megastone).id.to_s
pokedata.write("MegaStone = #{citem}\r\n")
pokedata.write("MegaStone = #{megastone.to_s}\r\n")
end
if megamove
cmove = GameData::Move.get(megamove).id.to_s
pokedata.write("MegaMove = #{cmove}\r\n")
pokedata.write("MegaMove = #{megamove.to_s}\r\n")
end
pokedata.write("UnmegaForm = #{unmega}\r\n") if unmega>0
pokedata.write("MegaMessage = #{megamessage}\r\n") if megamessage>0
if type1!=nil && type2!=nil
ctype1 = getConstantName(PBTypes,type1) rescue pbGetTypeConst(type1) || pbGetTypeConst(0) || "NORMAL"
pokedata.write("Type1 = #{ctype1}\r\n")
if type1!=type2
ctype2 = getConstantName(PBTypes,type2) rescue pbGetTypeConst(type2) || pbGetTypeConst(0) || "NORMAL"
pokedata.write("Type2 = #{ctype2}\r\n")
end
if type1
pokedata.write("Type1 = #{type1.to_s}\r\n")
end
if type2 && type2 != type1
pokedata.write("Type2 = #{type2.to_s}\r\n")
end
if basestats!=nil
pokedata.write("BaseStats = #{basestats[0]},#{basestats[1]},#{basestats[2]},#{basestats[3]},#{basestats[4]},#{basestats[5]}\r\n")
@@ -1079,13 +1044,11 @@ def pbSavePokemonFormsData
if ability1 || ability2
pokedata.write("Abilities = ")
if ability1
cability1 = GameData::Ability.get(ability1).id.to_s
pokedata.write("#{cability1}")
pokedata.write("#{ability1.to_s}")
pokedata.write(",") if ability2
end
if ability2
cability2 = GameData::Ability.get(ability2).id.to_s
pokedata.write("#{cability2}")
pokedata.write("#{ability2.to_s}")
end
pokedata.write("\r\n")
end
@@ -1094,23 +1057,19 @@ def pbSavePokemonFormsData
pokedata.write("HiddenAbility = ")
needcomma = false
if hiddenability1
cabilityh = GameData::Ability.get(hiddenability1).id.to_s
pokedata.write("#{cabilityh}"); needcomma=true
pokedata.write("#{hiddenability1.to_s}"); needcomma=true
end
if hiddenability2
pokedata.write(",") if needcomma
cabilityh = GameData::Ability.get(hiddenability2).id.to_s
pokedata.write("#{cabilityh}"); needcomma=true
pokedata.write("#{hiddenability2.to_s}"); needcomma=true
end
if hiddenability3
pokedata.write(",") if needcomma
cabilityh = GameData::Ability.get(hiddenability3).id.to_s
pokedata.write("#{cabilityh}"); needcomma=true
pokedata.write("#{hiddenability3.to_s}"); needcomma=true
end
if hiddenability4
pokedata.write(",") if needcomma
cabilityh = GameData::Ability.get(hiddenability4).id.to_s
pokedata.write("#{cabilityh}")
pokedata.write("#{hiddenability4.to_s}")
end
pokedata.write("\r\n")
end
@@ -1139,8 +1098,7 @@ def pbSavePokemonFormsData
level = m[0]
move = m[1]
pokedata.write(",") if !first
cmove = GameData::Move.get(move).id.to_s
pokedata.write(sprintf("%d,%s",level,cmove))
pokedata.write(sprintf("%d,%s",level,move.to_s))
first = false
end
pokedata.write("\r\n")
@@ -1165,8 +1123,7 @@ def pbSavePokemonFormsData
eggList.each do |m|
next if !m || m==0
pokedata.write(",") if !first
cmove = GameData::Move.get(m).id.to_s
pokedata.write("#{cmove}")
pokedata.write("#{m.to_s}")
first = false
end
pokedata.write("\r\n")
@@ -1211,16 +1168,13 @@ def pbSavePokemonFormsData
pokedata.write("Pokedex = #{entry}\r\n")
end
if item1
citem1 = GameData::Item.get(item1).id.to_s
pokedata.write("WildItemCommon = #{citem1}\r\n")
pokedata.write("WildItemCommon = #{item1.to_s}\r\n")
end
if item2
citem1 = GameData::Item.get(item2).id.to_s
pokedata.write("WildItemUncommon = #{citem2}\r\n")
pokedata.write("WildItemUncommon = #{item2.to_s}\r\n")
end
if item3
citem1 = GameData::Item.get(item3).id.to_s
pokedata.write("WildItemRare = #{citem3}\r\n")
pokedata.write("WildItemRare = #{item3.to_s}\r\n")
end
if metrics && metrics.length>0
for j in 0...6
@@ -1282,8 +1236,12 @@ def pbSavePokemonFormsData
has_param = !PBEvolution.hasFunction?(method, "parameterType") || param_type != nil
if has_param
if param_type
cparameter = (getConstantName(param_type, parameter) rescue parameter)
pokedata.write("#{cparameter}")
if [:Ability, :Item, :Move, :TrainerType, :Type].include?(param_type)
pokedata.write("#{parameter.to_s}")
else
cparameter = (getConstantName(param_type, parameter) rescue parameter)
pokedata.write("#{cparameter}")
end
else
pokedata.write("#{parameter}")
end
@@ -1293,8 +1251,7 @@ def pbSavePokemonFormsData
pokedata.write("\r\n")
end
if incense
initem = GameData::Item.get(incense).id.to_s
pokedata.write("Incense = #{initem}\r\n")
pokedata.write("Incense = #{incense.to_s}\r\n")
end
if i%20==0
Graphics.update

View File

@@ -279,17 +279,17 @@ end
module TypeProperty
def self.set(_settingname,oldsetting)
ret = pbChooseTypeList((oldsetting) ? oldsetting : 0)
return (ret<0) ? (oldsetting) ? oldsetting : 0 : ret
def self.set(_settingname, oldsetting)
ret = pbChooseTypeList(oldsetting || nil)
return ret || oldsetting
end
def self.defaultValue
return 0
return nil
end
def self.format(value)
return (value) ? PBTypes.getName(value) : "-"
return (value && GameData::Type.exists?(value)) ? GameData::Type.get(value).real_name : "-"
end
end
@@ -1256,8 +1256,7 @@ class EvolutionsProperty
newparam = pbChooseMoveList
when :PBSpecies
newparam = pbChooseSpeciesList
when :PBTypes
allow_zero = true
when :Type
newparam = pbChooseTypeList
when :Ability
newparam = pbChooseAbilityList
@@ -1345,8 +1344,7 @@ class EvolutionsProperty
newparam = pbChooseMoveList(entry[1])
when :PBSpecies
newparam = pbChooseSpeciesList(entry[1])
when :PBTypes
allow_zero = true
when :Type
newparam = pbChooseTypeList(entry[1])
when :Ability
newparam = pbChooseAbilityList(entry[1])

View File

@@ -1,14 +1,3 @@
def pbIsOldSpecialType?(type)
return isConst?(type,PBTypes,:FIRE) ||
isConst?(type,PBTypes,:WATER) ||
isConst?(type,PBTypes,:ICE) ||
isConst?(type,PBTypes,:GRASS) ||
isConst?(type,PBTypes,:ELECTRIC) ||
isConst?(type,PBTypes,:PSYCHIC) ||
isConst?(type,PBTypes,:DRAGON) ||
isConst?(type,PBTypes,:DARK)
end
def pbGetLegalMoves(species)
moves = []
return moves if !species || species<=0
@@ -164,17 +153,6 @@ end
def pbGetTypeConst(i)
ret = MakeshiftConsts.get(MessageTypes::Types,i,PBTypes)
if !ret
ret = ["NORMAL","FIGHTING","FLYING","POISON","GROUND",
"ROCK","BUG","GHOST","STEEL","QMARKS",
"FIRE","WATER","GRASS","ELECTRIC","PSYCHIC",
"ICE","DRAGON","DARK"][i]
end
return ret
end
def pbGetEvolutionConst(i)
ret = MakeshiftConsts.get(50,i,PBEvolution)
if !ret
@@ -259,10 +237,11 @@ def pbChooseSpeciesList(default=0)
return pbChooseList(commands,default,0,-1)
end
# Displays an alphabetically sorted list of all moves, and returns the ID of the
# move selected (or -1 if the selection was canceled). "default", if specified,
# is the ID of the move to initially select.
def pbChooseMoveList(default=0)
# Displays a list of all moves, and returns the ID of the move selected (or nil
# if the selection was canceled). "default", if specified, is the ID of the move
# to initially select. Pressing Input::A will toggle the list sorting between
# numerical and alphabetical.
def pbChooseMoveList(default = nil)
commands = []
GameData::Move.each { |i| commands.push([i.id_number, i.name, i.id]) }
return pbChooseList(commands, default, nil, -1)
@@ -304,19 +283,17 @@ def pbChooseMoveListForSpecies(species, defaultMoveID = nil)
return (ret >= 0) ? commands[ret][2] : nil
end
# Displays an alphabetically sorted list of all types, and returns the ID of the
# type selected (or -1 if the selection was canceled). "default", if specified,
# is the ID of the type to initially select.
def pbChooseTypeList(default=-1)
# Displays a list of all types, and returns the ID of the type selected (or nil
# if the selection was canceled). "default", if specified, is the ID of the type
# to initially select. Pressing Input::A will toggle the list sorting between
# numerical and alphabetical.
def pbChooseTypeList(default = nil)
commands = []
for i in 0..PBTypes.maxValue
cname = getConstantName(PBTypes,i) rescue nil
commands.push([i,PBTypes.getName(i)]) if cname && !PBTypes.isPseudoType?(i)
end
return pbChooseList(commands,default)
GameData::Type.each { |t| commands.push([t.id_number, t.name, t.id]) if !t.pseudo_type }
return pbChooseList(commands, default, nil, -1)
end
# Displays a list of all items, and returns the ID of the item selected (or -1
# Displays a list of all items, and returns the ID of the item selected (or nil
# if the selection was canceled). "default", if specified, is the ID of the item
# to initially select. Pressing Input::A will toggle the list sorting between
# numerical and alphabetical.
@@ -327,7 +304,7 @@ def pbChooseItemList(default = nil)
end
# Displays a list of all abilities, and returns the ID of the ability selected
# (or -1 if the selection was canceled). "default", if specified, is the ID of
# (or nil if the selection was canceled). "default", if specified, is the ID of
# the ability to initially select. Pressing Input::A will toggle the list
# sorting between numerical and alphabetical.
def pbChooseAbilityList(default = nil)