Implemented usage of GameData::Item

This commit is contained in:
Maruno17
2020-11-08 22:45:59 +00:00
parent ff70791104
commit 1955d3698e
82 changed files with 1986 additions and 2195 deletions

View File

@@ -490,16 +490,17 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
# Item options
#=============================================================================
when "additem"
pbListScreenBlock(_INTL("ADD ITEM"),ItemLister.new(0)) { |button,item|
if button==Input::C && item && item>0
pbListScreenBlock(_INTL("ADD ITEM"),ItemLister.new) { |button,item|
if button==Input::C && item
params = ChooseNumberParams.new
params.setRange(1,BAG_MAX_PER_SLOT)
params.setInitialValue(1)
params.setCancelValue(0)
qty = pbMessageChooseNumber(_INTL("Choose the number of items."),params)
qty = pbMessageChooseNumber(_INTL("Add how many {1}?",
GameData::Item.get(item).name_plural), params)
if qty>0
$PokemonBag.pbStoreItem(item,qty)
pbMessage(_INTL("Gave {1}x {2}.",qty,PBItems.getName(item)))
pbMessage(_INTL("Gave {1}x {2}.",qty,GameData::Item.get(item).name))
end
end
}
@@ -510,14 +511,7 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
params.setCancelValue(0)
qty = pbMessageChooseNumber(_INTL("Choose the number of items."),params)
if qty>0
itemconsts = []
for i in PBItems.constants
itemconsts.push(PBItems.const_get(i))
end
itemconsts.sort! { |a,b| a<=>b }
for i in itemconsts
$PokemonBag.pbStoreItem(i,qty)
end
GameData::Item.each { |i| $PokemonBag.pbStoreItem(i.id, qty) }
pbMessage(_INTL("The Bag was filled with {1} of each item.",qty))
end
when "emptybag"
@@ -731,6 +725,7 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
#=============================================================================
when "setmetadata"
pbMetadataScreen(pbDefaultMap)
# TODO: Only need to reload the metadata.
pbClearData
when "mapconnections"
pbFadeOutIn { pbConnectionsEditor }
@@ -745,8 +740,9 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
pbEncounterEditorMap(encdata,map)
end
save_data(encdata,"Data/encounters.dat")
# TODO: Only need to reload the encounters data.
pbClearData
pbSaveEncounterData
pbSaveEncounterData # Rewrite PBS file encounters.txt
when "trainertypes"
pbFadeOutIn { pbTrainerTypeEditor }
when "edittrainers"

View File

@@ -433,7 +433,7 @@ module PokemonDebugMixin
oldabil = (pkmn.ability) ? pkmn.ability.name : "No ability"
commands = []
for i in abils
commands.push(((i[1]<2) ? "" : "(H) ") + PokemonData::Ability.get(i[0]).name)
commands.push(((i[1]<2) ? "" : "(H) ") + GameData::Ability.get(i[0]).name)
end
commands.push(_INTL("Remove override"))
msg = [_INTL("Ability {1} is natural.",oldabil),
@@ -615,8 +615,8 @@ module PokemonDebugMixin
when "setpokeball"
commands = []; balls = []
for key in $BallTypes.keys
item = getID(PBItems,$BallTypes[key])
balls.push([key.to_i,PBItems.getName(item)]) if item && item>0
item = GameData::Item.try_get($BallTypes[key])
balls.push([key.to_i, item.name]) if item
end
balls.sort! { |a,b| a[1]<=>b[1] }
cmd = 0
@@ -629,7 +629,7 @@ module PokemonDebugMixin
commands.push(i[1])
end
loop do
oldball = PBItems.getName(pbBallTypeToItem(pkmn.ballused))
oldball = pbBallTypeToItem(pkmn.ballused).name
cmd = pbShowCommands(_INTL("{1} used.",oldball),commands,cmd)
break if cmd<0
pkmn.ballused = balls[cmd][0]

View File

@@ -298,15 +298,17 @@ end
def pbTrainerTypeEditor
selection = 0
trainerTypes = [
[_INTL("Internal Name"),ReadOnlyProperty,_INTL("Internal name that appears in constructs like PBTrainers::XXX.")],
[_INTL("Trainer Name"),StringProperty,_INTL("Name of the trainer type as displayed by the game.")],
[_INTL("Money Per Level"),LimitProperty.new(9999),_INTL("Player earns this amount times the highest level among the trainer's Pokémon.")],
[_INTL("Battle BGM"),BGMProperty,_INTL("BGM played in battles against trainers of this type.")],
[_INTL("Battle End ME"),MEProperty,_INTL("ME played when player wins battles against trainers of this type.")],
[_INTL("Battle Intro ME"),MEProperty,_INTL("ME played before battles against trainers of this type.")],
[_INTL("Gender"),EnumProperty.new([_INTL("Male"),_INTL("Female"),_INTL("Mixed gender")]),_INTL("Gender of this Trainer type.")],
[_INTL("Skill"),LimitProperty.new(9999),_INTL("Skill level of this Trainer type.")],
[_INTL("Skill Codes"),StringProperty,_INTL("Letters/phrases representing AI modifications of trainers of this type.")],
[_INTL("Internal Name"), ReadOnlyProperty, _INTL("Internal name that appears in constructs like PBTrainers::XXX.")],
[_INTL("Trainer Name"), StringProperty, _INTL("Name of the trainer type as displayed by the game.")],
[_INTL("Money Per Level"), LimitProperty.new(9999), _INTL("Player earns this amount times the highest level among the trainer's Pokémon.")],
[_INTL("Battle BGM"), BGMProperty, _INTL("BGM played in battles against trainers of this type.")],
[_INTL("Battle End ME"), MEProperty, _INTL("ME played when player wins battles against trainers of this type.")],
[_INTL("Battle Intro ME"), MEProperty, _INTL("ME played before battles against trainers of this type.")],
[_INTL("Gender"), EnumProperty.new([
_INTL("Male"),_INTL("Female"),_INTL("Mixed gender")]),
_INTL("Gender of this Trainer type.")],
[_INTL("Skill"), LimitProperty.new(9999), _INTL("Skill level of this Trainer type.")],
[_INTL("Skill Codes"), StringProperty, _INTL("Letters/phrases representing AI modifications of trainers of this type.")],
]
pbListScreenBlock(_INTL("Trainer Types"),TrainerTypeLister.new(selection,true)) { |button,trtype|
if trtype
@@ -354,24 +356,24 @@ module TrainerBattleProperty
def self.set(settingname,oldsetting)
return nil if !oldsetting
properties = [
[_INTL("Trainer Type"),TrainerTypeProperty,_INTL("Name of the trainer type for this Trainer.")],
[_INTL("Trainer Name"),StringProperty,_INTL("Name of the Trainer.")],
[_INTL("Battle ID"),LimitProperty.new(9999),_INTL("ID used to distinguish Trainers with the same name and trainer type.")],
[_INTL("Lose Text"),StringProperty,_INTL("Message shown in battle when the Trainer is defeated.")],
[_INTL("Pokémon 1"),TrainerPokemonProperty,_INTL("First Pokémon.")],
[_INTL("Pokémon 2"),TrainerPokemonProperty,_INTL("Second Pokémon.")],
[_INTL("Pokémon 3"),TrainerPokemonProperty,_INTL("Third Pokémon.")],
[_INTL("Pokémon 4"),TrainerPokemonProperty,_INTL("Fourth Pokémon.")],
[_INTL("Pokémon 5"),TrainerPokemonProperty,_INTL("Fifth Pokémon.")],
[_INTL("Pokémon 6"),TrainerPokemonProperty,_INTL("Sixth Pokémon.")],
[_INTL("Item 1"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
[_INTL("Item 2"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
[_INTL("Item 3"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
[_INTL("Item 4"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
[_INTL("Item 5"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
[_INTL("Item 6"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
[_INTL("Item 7"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
[_INTL("Item 8"),ItemProperty,_INTL("Item used by the Trainer during battle.")]
[_INTL("Trainer Type"), TrainerTypeProperty, _INTL("Name of the trainer type for this Trainer.")],
[_INTL("Trainer Name"), StringProperty, _INTL("Name of the Trainer.")],
[_INTL("Battle ID"), LimitProperty.new(9999), _INTL("ID used to distinguish Trainers with the same name and trainer type.")],
[_INTL("Lose Text"), StringProperty, _INTL("Message shown in battle when the Trainer is defeated.")],
[_INTL("Pokémon 1"), TrainerPokemonProperty, _INTL("First Pokémon.")],
[_INTL("Pokémon 2"), TrainerPokemonProperty, _INTL("Second Pokémon.")],
[_INTL("Pokémon 3"), TrainerPokemonProperty, _INTL("Third Pokémon.")],
[_INTL("Pokémon 4"), TrainerPokemonProperty, _INTL("Fourth Pokémon.")],
[_INTL("Pokémon 5"), TrainerPokemonProperty, _INTL("Fifth Pokémon.")],
[_INTL("Pokémon 6"), TrainerPokemonProperty, _INTL("Sixth Pokémon.")],
[_INTL("Item 1"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
[_INTL("Item 2"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
[_INTL("Item 3"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
[_INTL("Item 4"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
[_INTL("Item 5"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
[_INTL("Item 6"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
[_INTL("Item 7"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
[_INTL("Item 8"), ItemProperty, _INTL("Item used by the Trainer during battle.")]
]
if !pbPropertyList(settingname,oldsetting,properties,true)
return nil
@@ -457,7 +459,7 @@ def pbTrainerBattleEditor
trainerdata = [
data[0],
data[1],
[data[10],data[11],data[12],data[13],data[14],data[15],data[16],data[17]].find_all { |i| i && i!=0 }, # Item list
[data[10],data[11],data[12],data[13],data[14],data[15],data[16],data[17]].compact!, # Item list
[data[4],data[5],data[6],data[7],data[8],data[9]].find_all { |i| i && i[TrainerData::SPECIES]!=0 }, # Pokémon list
data[2],
data[3]
@@ -502,24 +504,24 @@ module TrainerPokemonProperty
end
mLevel = PBExperience.maxLevel
properties = [
[_INTL("Species"),SpeciesProperty,_INTL("Species of the Pokémon.")],
[_INTL("Level"),NonzeroLimitProperty.new(mLevel),_INTL("Level of the Pokémon (1-{1}).",mLevel)],
[_INTL("Held item"),ItemProperty,_INTL("Item held by the Pokémon.")],
[_INTL("Move 1"),MoveProperty2.new(oldsetting),_INTL("First move. Leave all moves blank (use Z key) to give it a wild moveset.")],
[_INTL("Move 2"),MoveProperty2.new(oldsetting),_INTL("Second move. Leave all moves blank (use Z key) to give it a wild moveset.")],
[_INTL("Move 3"),MoveProperty2.new(oldsetting),_INTL("Third move. Leave all moves blank (use Z key) to give it a wild moveset.")],
[_INTL("Move 4"),MoveProperty2.new(oldsetting),_INTL("Fourth move. Leave all moves blank (use Z key) to give it a wild moveset.")],
[_INTL("Ability"),LimitProperty2.new(5),_INTL("Ability flag. 0=first ability, 1=second ability, 2-5=hidden ability.")],
[_INTL("Gender"),GenderProperty.new,_INTL("Gender of the Pokémon.")],
[_INTL("Form"),LimitProperty2.new(999),_INTL("Form of the Pokémon.")],
[_INTL("Shiny"),BooleanProperty2,_INTL("If set to true, the Pokémon is a different-colored Pokémon.")],
[_INTL("Nature"),NatureProperty,_INTL("Nature of the Pokémon.")],
[_INTL("IVs"), IVsProperty.new(Pokemon::IV_STAT_LIMIT), _INTL("Individual values for each of the Pokémon's stats.")],
[_INTL("Happiness"),LimitProperty2.new(255),_INTL("Happiness of the Pokémon (0-255).")],
[_INTL("Nickname"),StringProperty,_INTL("Name of the Pokémon.")],
[_INTL("Shadow"),BooleanProperty2,_INTL("If set to true, the Pokémon is a Shadow Pokémon.")],
[_INTL("Ball"),BallProperty.new(oldsetting),_INTL("The kind of Poké Ball the Pokémon is kept in.")],
[_INTL("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")]
[_INTL("Species"), SpeciesProperty, _INTL("Species of the Pokémon.")],
[_INTL("Level"), NonzeroLimitProperty.new(mLevel), _INTL("Level of the Pokémon (1-{1}).",mLevel)],
[_INTL("Held item"), ItemProperty, _INTL("Item held by the Pokémon.")],
[_INTL("Move 1"), MoveProperty2.new(oldsetting), _INTL("First move. Leave all moves blank (use Z key) to give it a wild moveset.")],
[_INTL("Move 2"), MoveProperty2.new(oldsetting), _INTL("Second move. Leave all moves blank (use Z key) to give it a wild moveset.")],
[_INTL("Move 3"), MoveProperty2.new(oldsetting), _INTL("Third move. Leave all moves blank (use Z key) to give it a wild moveset.")],
[_INTL("Move 4"), MoveProperty2.new(oldsetting), _INTL("Fourth move. Leave all moves blank (use Z key) to give it a wild moveset.")],
[_INTL("Ability"), LimitProperty2.new(5), _INTL("Ability flag. 0=first ability, 1=second ability, 2-5=hidden ability.")],
[_INTL("Gender"), GenderProperty.new, _INTL("Gender of the Pokémon.")],
[_INTL("Form"), LimitProperty2.new(999), _INTL("Form of the Pokémon.")],
[_INTL("Shiny"), BooleanProperty2, _INTL("If set to true, the Pokémon is a different-colored Pokémon.")],
[_INTL("Nature"), NatureProperty, _INTL("Nature of the Pokémon.")],
[_INTL("IVs"), IVsProperty.new(Pokemon::IV_STAT_LIMIT), _INTL("Individual values for each of the Pokémon's stats.")],
[_INTL("Happiness"), LimitProperty2.new(255), _INTL("Happiness of the Pokémon (0-255).")],
[_INTL("Nickname"), StringProperty, _INTL("Name of the Pokémon.")],
[_INTL("Shadow"), BooleanProperty2, _INTL("If set to true, the Pokémon is a Shadow Pokémon.")],
[_INTL("Ball"), BallProperty.new(oldsetting), _INTL("The kind of Poké Ball the Pokémon is kept in.")],
[_INTL("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")]
]
pbPropertyList(settingname,oldsetting,properties,false)
return nil if !oldsetting[TrainerData::SPECIES] || oldsetting[TrainerData::SPECIES]==0
@@ -535,7 +537,7 @@ module TrainerPokemonProperty
end
moves.compact!
ret[TrainerData::MOVES] = moves if moves.length>0
# Remove unnecessarily nils from the end of ret
# Remove unnecessary nils from the end of ret
ret.pop while ret.last.nil? && ret.size>0
return ret
end
@@ -582,153 +584,142 @@ end
def pbItemEditor
selection = 0
items = [
[_INTL("Internal Name"),ReadOnlyProperty,_INTL("Internal name that appears in constructs like PBItems::XXX.")],
[_INTL("Item Name"),ItemNameProperty,_INTL("Name of the item as displayed by the game.")],
[_INTL("Item Name Plural"),ItemNameProperty,_INTL("Plural name of the item as displayed by the game.")],
[_INTL("Pocket"),PocketProperty,_INTL("Pocket in the bag where the item is stored.")],
[_INTL("Purchase price"),LimitProperty.new(999999),_INTL("Purchase price of the item.")],
[_INTL("Description"),StringProperty,_INTL("Description of the item")],
[_INTL("Use Out of Battle"),EnumProperty.new([
_INTL("Can't Use"),_INTL("On a Pokémon"),_INTL("Use directly"),
_INTL("TM"),_INTL("HM"),_INTL("On a Pokémon reusable")]),
_INTL("Specifies how this item can be used outside of battle.")],
[_INTL("Use In Battle"),EnumProperty.new([
_INTL("Can't Use"),_INTL("On a Pokémon"),_INTL("On Pokémon's move"),
_INTL("On battler"),_INTL("On foe battler"),_INTL("Use directly"),
_INTL("On a Pokémon reusable"),_INTL("On Pokémon's move reusable"),
_INTL("On battler reusable"),_INTL("On foe battler reusable"),
[_INTL("Internal Name"), ReadOnlyProperty, _INTL("Internal name that is used as a symbol like :XXX.")],
[_INTL("Item Name"), ItemNameProperty, _INTL("Name of the item as displayed by the game.")],
[_INTL("Item Name Plural"), ItemNameProperty, _INTL("Plural name of the item as displayed by the game.")],
[_INTL("Pocket"), PocketProperty, _INTL("Pocket in the bag where the item is stored.")],
[_INTL("Purchase price"), LimitProperty.new(999999), _INTL("Purchase price of the item.")],
[_INTL("Description"), StringProperty, _INTL("Description of the item")],
[_INTL("Use Out of Battle"), EnumProperty.new([
_INTL("Can't Use"), _INTL("On a Pokémon"), _INTL("Use directly"),
_INTL("TM"), _INTL("HM"), _INTL("On a Pokémon reusable")]),
_INTL("Specifies how this item can be used outside of battle.")],
[_INTL("Use In Battle"), EnumProperty.new([
_INTL("Can't Use"), _INTL("On a Pokémon"), _INTL("On Pokémon's move"),
_INTL("On battler"), _INTL("On foe battler"), _INTL("Use directly"),
_INTL("On a Pokémon reusable"), _INTL("On Pokémon's move reusable"),
_INTL("On battler reusable"), _INTL("On foe battler reusable"),
_INTL("Use directly reusable")]),
_INTL("Specifies how this item can be used within a battle.")],
[_INTL("Special Items"),EnumProperty.new([
_INTL("None of below"),_INTL("Mail"),_INTL("Mail with Pictures"),
_INTL("Snag Ball"),_INTL("Poké Ball"),_INTL("Plantable Berry"),
_INTL("Key Item"),_INTL("Evolution Stone"),_INTL("Fossil"),
_INTL("Apricorn"),_INTL("Type-boosting Gem"),_INTL("Mulch"),
_INTL("Specifies how this item can be used within a battle.")],
[_INTL("Special Items"), EnumProperty.new([
_INTL("None of below"), _INTL("Mail"), _INTL("Mail with Pictures"),
_INTL("Snag Ball"), _INTL("Poké Ball"), _INTL("Plantable Berry"),
_INTL("Key Item"), _INTL("Evolution Stone"), _INTL("Fossil"),
_INTL("Apricorn"), _INTL("Type-boosting Gem"), _INTL("Mulch"),
_INTL("Mega Stone")]),
_INTL("For special kinds of items.")],
[_INTL("Machine"),MoveProperty,_INTL("Move taught by this TM or HM.")]
_INTL("For special kinds of items.")],
[_INTL("Machine"), MoveProperty, _INTL("Move taught by this TM or HM.")]
]
pbListScreenBlock(_INTL("Items"),ItemLister.new(selection,true)) { |button,trtype|
if trtype
pbListScreenBlock(_INTL("Items"), ItemLister.new(selection, true)) { |button, item|
if item
if button==Input::A
if trtype>=0
if item.is_a?(Symbol)
if pbConfirmMessageSerious("Delete this item?")
data = pbLoadItemsData
removeConstantValue(PBItems,trtype)
data.delete_if { |item| item[0]==trtype }
for x in data
p x if data[0]==0
end
save_data(data,"Data/items.dat")
$PokemonTemp.itemsData = nil
id_number = GameData::Item.get(item).id_number
GameData::Item::DATA.delete(item)
GameData::Item::DATA.delete(id_number)
GameData::Item.save
pbSaveItems
pbMessage(_INTL("The item was deleted."))
end
end
elsif button==Input::C
selection = trtype
if selection<0
newid = pbItemEditorNew(nil)
if newid>=0
selection = newid
end
else
data = [getConstantName(PBItems,selection)]
itemdata = pbLoadItemsData
data.push(itemdata[selection][ItemData::NAME])
data.push(itemdata[selection][ItemData::NAME_PLURAL])
data.push(itemdata[selection][ItemData::POCKET])
data.push(itemdata[selection][ItemData::PRICE])
data.push(itemdata[selection][ItemData::DESCRIPTION])
data.push(itemdata[selection][ItemData::FIELD_USE])
data.push(itemdata[selection][ItemData::BATTLE_USE])
data.push(itemdata[selection][ItemData::TYPE])
data.push(itemdata[selection][ItemData::MOVE])
save = pbPropertyList(data[ItemData::NAME],data,items,true)
if item.is_a?(Symbol)
itm = GameData::Item.get(item)
data = [
itm.id.to_s,
itm.real_name,
itm.real_name_plural,
itm.pocket,
itm.price,
itm.real_description,
itm.field_use,
itm.battle_use,
itm.type,
itm.move || 0
]
save = pbPropertyList(itm.id.to_s, data, items, true)
if save
itemdata[selection][ItemData::NAME] = data[ItemData::NAME]
itemdata[selection][ItemData::NAME_PLURAL] = data[ItemData::NAME_PLURAL]
itemdata[selection][ItemData::POCKET] = data[ItemData::POCKET]
itemdata[selection][ItemData::PRICE] = data[ItemData::PRICE]
itemdata[selection][ItemData::DESCRIPTION] = data[ItemData::DESCRIPTION]
itemdata[selection][ItemData::FIELD_USE] = data[ItemData::FIELD_USE]
itemdata[selection][ItemData::BATTLE_USE] = data[ItemData::BATTLE_USE]
itemdata[selection][ItemData::TYPE] = data[ItemData::TYPE]
itemdata[selection][ItemData::MOVE] = data[ItemData::MOVE]
save_data(itemdata,"Data/items.dat")
$PokemonTemp.itemsData = nil
# Construct item hash
item_hash = {
:id_number => itm.id_number,
:id => itm.id,
:name => data[1],
:name_plural => data[2],
:pocket => data[3],
:price => data[4],
:description => data[5],
:field_use => data[6],
:battle_use => data[7],
:type => data[8],
:move => (data[9] > 0) ? data[9] : nil
}
# Add item's data to records
GameData::Item::DATA[itm.id_number] = GameData::Item::DATA[itm.id] = GameData::Item.new(item_hash)
GameData::Item.save
pbSaveItems
end
else # Add a new item
pbItemEditorNew(nil)
end
end
end
}
end
def pbItemEditorNew(defaultname)
itemdata = pbLoadItemsData
# Get the first blank ID for the new item to use.
maxid = PBItems.maxValue+1
index = maxid
itemname = pbMessageFreeText(_INTL("Please enter the item's name."),
(defaultname) ? defaultname.gsub(/_+/," ") : "",false,30)
if itemname=="" && !defaultname
return -1
else
# Create a default name if there is none.
if !defaultname
defaultname = itemname.gsub(/[^A-Za-z0-9_]/,"")
defaultname = defaultname.sub(/^([a-z])/) { $1.upcase }
if defaultname.length==0
defaultname = sprintf("Item%03d",index)
elsif !defaultname[0,1][/[A-Z]/]
defaultname = "Item"+defaultname
end
end
itemname = defaultname if itemname==""
# Create an internal name based on the item name.
cname = itemname.gsub(/é/,"e")
cname = cname.gsub(/[^A-Za-z0-9_]/,"")
cname = cname.upcase
if hasConst?(PBItems,cname)
suffix = 1
100.times do
tname = sprintf("%s_%d",cname,suffix)
if !hasConst?(PBItems,tname)
cname = tname
break
end
suffix += 1
end
end
if hasConst?(PBItems,cname)
pbMessage(_INTL("Failed to create the item. Choose a different name."))
return -1
end
pocket = PocketProperty.set("",0)
return -1 if pocket==0
price = LimitProperty.new(999999).set(_INTL("Purchase price"),-1)
return -1 if price==-1
desc = StringProperty.set(_INTL("Description"),"")
# Item list will create record automatically
itemdata[index][ItemData::ID] = index
itemdata[index][ItemData::NAME] = itemname
itemdata[index][ItemData::POCKET] = pocket
itemdata[index][ItemData::PRICE] = price
itemdata[index][ItemData::DESCRIPTION] = desc
itemdata[index][ItemData::FIELD_USE] = 0
itemdata[index][ItemData::BATTLE_USE] = 0
itemdata[index][ItemData::TYPE] = 0
itemdata[index][ItemData::MOVE] = 0
PBItems.const_set(cname,index)
save_data(itemdata,"Data/items.dat")
$PokemonTemp.itemsData = nil
pbSaveItems
pbMessage(_INTL("The item was created (ID: {1}).",index))
pbMessage(_ISPRINTF("Put the item's graphic (item{1:03d}.png or item{2:s}.png) in Graphics/Icons, or it will be blank.",
index,getConstantName(PBItems,index)))
return index
def pbItemEditorNew(default_name)
# Get an unused ID number for the new item
max_id = 0
GameData::Item.each { |i| max_id = i.id_number if max_id < i.id_number }
id_number = max_id + 1
# Choose a name
name = pbMessageFreeText(_INTL("Please enter the item's name."),
(default_name) ? default_name.gsub(/_+/, " ") : "", false, 30)
if name == ""
return if !default_name
name = default_name
end
# Generate an ID based on the item name
id = name.gsub(/é/, "e")
id = id.gsub(/[^A-Za-z0-9_]/, "")
id = id.upcase
if GameData::Item.exists?(id)
for i in 1..100
trial_id = sprintf("%s_%d", id, i)
next if GameData::Item.exists?(trial_id)
id = trial_id
break
end
end
if GameData::Item.exists?(id)
pbMessage(_INTL("Failed to create the item. Choose a different name."))
return
end
# Choose a pocket
pocket = PocketProperty.set("", 0)
return if pocket == 0
# Choose a price
price = LimitProperty.new(999999).set(_INTL("Purchase price"), -1)
return if price == -1
# Choose a description
description = StringProperty.set(_INTL("Description"), "")
# Construct item hash
item_hash = {
:id_number => id_number,
:id => id.to_sym,
:name => name,
:name_plural => name + "s",
:pocket => pocket,
:price => price,
:description => description
}
# Add item's data to records
GameData::Item::DATA[id_number] = GameData::Item::DATA[id.to_sym] = GameData::Item.new(item_hash)
GameData::Item.save
pbSaveItems
pbMessage(_INTL("The item {1} was created (ID: {2}).", name, id.to_s))
pbMessage(_ISPRINTF("Put the item's graphic (item{1:s}.png or item{2:03d}.png) in Graphics/Icons, or it will be blank.",
id.to_s, id_number))
end
@@ -741,71 +732,71 @@ def pbPokemonEditor
metrics = pbLoadSpeciesMetrics
selection = 0
species = [
[_INTL("Name"), LimitStringProperty.new(Pokemon::MAX_NAME_SIZE), _INTL("Name of the Pokémon.")],
[_INTL("InternalName"),ReadOnlyProperty,_INTL("Internal name of the Pokémon.")],
[_INTL("Type1"),TypeProperty,_INTL("Pokémon's type. If same as Type2, this Pokémon has a single type.")],
[_INTL("Type2"),TypeProperty,_INTL("Pokémon's type. If same as Type1, this Pokémon has a single type.")],
[_INTL("BaseStats"),BaseStatsProperty,_INTL("Base stats of the Pokémon.")],
[_INTL("GenderRate"),EnumProperty.new([
[_INTL("Name"), LimitStringProperty.new(Pokemon::MAX_NAME_SIZE), _INTL("Name of the Pokémon.")],
[_INTL("InternalName"), ReadOnlyProperty, _INTL("Internal name of the Pokémon.")],
[_INTL("Type1"), TypeProperty, _INTL("Pokémon's type. If same as Type2, this Pokémon has a single type.")],
[_INTL("Type2"), TypeProperty, _INTL("Pokémon's type. If same as Type1, this Pokémon has a single type.")],
[_INTL("BaseStats"), BaseStatsProperty, _INTL("Base stats of the Pokémon.")],
[_INTL("GenderRate"), EnumProperty.new([
_INTL("Genderless"),_INTL("AlwaysMale"),_INTL("FemaleOneEighth"),
_INTL("Female25Percent"),_INTL("Female50Percent"),_INTL("Female75Percent"),
_INTL("FemaleSevenEighths"),_INTL("AlwaysFemale")]),
_INTL("Proportion of males to females for this species.")],
[_INTL("GrowthRate"),EnumProperty.new([
_INTL("Proportion of males to females for this species.")],
[_INTL("GrowthRate"), EnumProperty.new([
_INTL("Medium"),_INTL("Erratic"),_INTL("Fluctuating"),_INTL("Parabolic"),
_INTL("Fast"),_INTL("Slow")]),
_INTL("Pokémon's growth rate.")],
[_INTL("BaseEXP"),LimitProperty.new(9999),_INTL("Base experience earned when this species is defeated.")],
[_INTL("EffortPoints"),EffortValuesProperty,_INTL("Effort Value points earned when this species is defeated.")],
[_INTL("Rareness"),LimitProperty.new(255),_INTL("Catch rate of this species (0-255).")],
[_INTL("Happiness"),LimitProperty.new(255),_INTL("Base happiness of this species (0-255).")],
[_INTL("Ability1"),AbilityProperty,_INTL("One ability which the Pokémon can have.")],
[_INTL("Ability2"),AbilityProperty,_INTL("Another ability which the Pokémon can have.")],
[_INTL("HiddenAbility 1"),AbilityProperty,_INTL("A secret ability which the Pokémon can have.")],
[_INTL("HiddenAbility 2"),AbilityProperty,_INTL("A secret ability which the Pokémon can have.")],
[_INTL("HiddenAbility 3"),AbilityProperty,_INTL("A secret ability which the Pokémon can have.")],
[_INTL("HiddenAbility 4"),AbilityProperty,_INTL("A secret ability which the Pokémon can have.")],
[_INTL("Moves"),MovePoolProperty,_INTL("Moves which the Pokémon learns while levelling up.")],
[_INTL("EggMoves"),EggMovesProperty,_INTL("Moves which the Pokémon can learn via breeding.")],
[_INTL("Compat1"),EnumProperty.new([
_INTL("Pokémon's growth rate.")],
[_INTL("BaseEXP"), LimitProperty.new(9999), _INTL("Base experience earned when this species is defeated.")],
[_INTL("EffortPoints"), EffortValuesProperty, _INTL("Effort Value points earned when this species is defeated.")],
[_INTL("Rareness"), LimitProperty.new(255), _INTL("Catch rate of this species (0-255).")],
[_INTL("Happiness"), LimitProperty.new(255), _INTL("Base happiness of this species (0-255).")],
[_INTL("Ability1"), AbilityProperty, _INTL("One ability which the Pokémon can have.")],
[_INTL("Ability2"), AbilityProperty, _INTL("Another ability which the Pokémon can have.")],
[_INTL("HiddenAbility 1"), AbilityProperty, _INTL("A secret ability which the Pokémon can have.")],
[_INTL("HiddenAbility 2"), AbilityProperty, _INTL("A secret ability which the Pokémon can have.")],
[_INTL("HiddenAbility 3"), AbilityProperty, _INTL("A secret ability which the Pokémon can have.")],
[_INTL("HiddenAbility 4"), AbilityProperty, _INTL("A secret ability which the Pokémon can have.")],
[_INTL("Moves"), MovePoolProperty, _INTL("Moves which the Pokémon learns while levelling up.")],
[_INTL("EggMoves"), EggMovesProperty, _INTL("Moves which the Pokémon can learn via breeding.")],
[_INTL("Compat1"), EnumProperty.new([
"Undiscovered","Monster","Water 1","Bug","Flying",
"Field","Fairy","Grass","Human-like","Water 3",
"Mineral","Amorphous","Water 2","Ditto","Dragon"]),
_INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("Compat2"),EnumProperty.new([
_INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("Compat2"), EnumProperty.new([
"Undiscovered","Monster","Water 1","Bug","Flying",
"Field","Fairy","Grass","Human-like","Water 3",
"Mineral","Amorphous","Water 2","Ditto","Dragon"]),
_INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("StepsToHatch"),LimitProperty.new(99999),_INTL("Number of steps until an egg of this species hatches.")],
[_INTL("Height"),NonzeroLimitProperty.new(999),_INTL("Height of the Pokémon in 0.1 metres (e.g. 42 = 4.2m).")],
[_INTL("Weight"),NonzeroLimitProperty.new(9999),_INTL("Weight of the Pokémon in 0.1 kilograms (e.g. 42 = 4.2kg).")],
[_INTL("Color"),EnumProperty.new([
_INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("StepsToHatch"), LimitProperty.new(99999), _INTL("Number of steps until an egg of this species hatches.")],
[_INTL("Height"), NonzeroLimitProperty.new(999), _INTL("Height of the Pokémon in 0.1 metres (e.g. 42 = 4.2m).")],
[_INTL("Weight"), NonzeroLimitProperty.new(9999), _INTL("Weight of the Pokémon in 0.1 kilograms (e.g. 42 = 4.2kg).")],
[_INTL("Color"), EnumProperty.new([
_INTL("Red"),_INTL("Blue"),_INTL("Yellow"),_INTL("Green"),_INTL("Black"),
_INTL("Brown"),_INTL("Purple"),_INTL("Gray"),_INTL("White"),_INTL("Pink")]),
_INTL("Pokémon's body color.")],
[_INTL("Shape"),LimitProperty.new(14),_INTL("Body shape of this species (0-14).")],
[_INTL("Habitat"),EnumProperty.new([
_INTL("Pokémon's body color.")],
[_INTL("Shape"), LimitProperty.new(14), _INTL("Body shape of this species (0-14).")],
[_INTL("Habitat"), EnumProperty.new([
_INTL("None"),_INTL("Grassland"),_INTL("Forest"),_INTL("WatersEdge"),
_INTL("Sea"),_INTL("Cave"),_INTL("Mountain"),_INTL("RoughTerrain"),
_INTL("Urban"),_INTL("Rare")]),
_INTL("The habitat of this species.")],
[_INTL("RegionalNumbers"),ReadOnlyProperty,_INTL("Regional Dex numbers for the Pokémon. These are edited elsewhere.")],
[_INTL("Kind"),StringProperty,_INTL("Kind of Pokémon species.")],
[_INTL("Pokédex"),StringProperty,_INTL("Description of the Pokémon as displayed in the Pokédex.")],
[_INTL("FormName"),StringProperty,_INTL("Name of this form of the Pokémon.")],
[_INTL("WildItemCommon"),ItemProperty,_INTL("Item commonly held by wild Pokémon of this species.")],
[_INTL("WildItemUncommon"),ItemProperty,_INTL("Item uncommonly held by wild Pokémon of this species.")],
[_INTL("WildItemRare"),ItemProperty,_INTL("Item rarely held by wild Pokémon of this species.")],
[_INTL("BattlerPlayerX"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerPlayerY"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerEnemyX"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerEnemyY"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerAltitude"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerShadowX"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerShadowSize"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("Evolutions"),EvolutionsProperty.new,_INTL("Evolution paths of this species.")],
[_INTL("Incense"),ItemProperty,_INTL("Item needed to be held by a parent to produce an egg of this species.")],
_INTL("The habitat of this species.")],
[_INTL("RegionalNumbers"), ReadOnlyProperty, _INTL("Regional Dex numbers for the Pokémon. These are edited elsewhere.")],
[_INTL("Kind"), StringProperty, _INTL("Kind of Pokémon species.")],
[_INTL("Pokédex"), StringProperty, _INTL("Description of the Pokémon as displayed in the Pokédex.")],
[_INTL("FormName"), StringProperty, _INTL("Name of this form of the Pokémon.")],
[_INTL("WildItemCommon"), ItemProperty, _INTL("Item commonly held by wild Pokémon of this species.")],
[_INTL("WildItemUncommon"), ItemProperty, _INTL("Item uncommonly held by wild Pokémon of this species.")],
[_INTL("WildItemRare"), ItemProperty, _INTL("Item rarely held by wild Pokémon of this species.")],
[_INTL("BattlerPlayerX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerPlayerY"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerEnemyX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerEnemyY"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerAltitude"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerShadowX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerShadowSize"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("Evolutions"), EvolutionsProperty.new, _INTL("Evolution paths of this species.")],
[_INTL("Incense"), ItemProperty, _INTL("Item needed to be held by a parent to produce an egg of this species.")],
]
pbListScreenBlock(_INTL("Pokémon species"),SpeciesLister.new(selection,false)) { |button,index|
if index
@@ -838,11 +829,11 @@ def pbPokemonEditor
formname = messages.get(MessageTypes::FormNames,selection)
abilities = speciesData[SpeciesData::ABILITIES]
if abilities.is_a?(Array)
ability1 = (abilities[0]) ? PokemonData::Ability.get(abilities[0]).id_number : 0
ability2 = (abilities[1]) ? PokemonData::Ability.get(abilities[1]).id_number : 0
ability1 = abilities[0]
ability2 = abilities[1]
else
ability1 = (abilities) ? PokemonData::Ability.get(abilities).id_number : 0
ability2 = 0
ability1 = abilities
ability2 = nil
end
color = speciesData[SpeciesData::COLOR]
habitat = speciesData[SpeciesData::HABITAT]
@@ -870,15 +861,15 @@ def pbPokemonEditor
baseexp = speciesData[SpeciesData::BASE_EXP]
hiddenAbils = speciesData[SpeciesData::HIDDEN_ABILITY]
if hiddenAbils.is_a?(Array)
hiddenability1 = (hiddenAbils[0]) ? PokemonData::Ability.get(hiddenAbils[0]).id_number : 0
hiddenability2 = (hiddenAbils[1]) ? PokemonData::Ability.get(hiddenAbils[1]).id_number : 0
hiddenability3 = (hiddenAbils[2]) ? PokemonData::Ability.get(hiddenAbils[2]).id_number : 0
hiddenability4 = (hiddenAbils[3]) ? PokemonData::Ability.get(hiddenAbils[3]).id_number : 0
hiddenability1 = hiddenAbils[0]
hiddenability2 = hiddenAbils[1]
hiddenability3 = hiddenAbils[2]
hiddenability4 = hiddenAbils[3]
else
hiddenability1 = (hiddenAbils) ? PokemonData::Ability.get(hiddenAbils).id_number : 0
hiddenability2 = 0
hiddenability3 = 0
hiddenability4 = 0
hiddenability1 = hiddenAbils
hiddenability2 = nil
hiddenability3 = nil
hiddenability4 = nil
end
item1 = speciesData[SpeciesData::WILD_ITEM_COMMON]
item2 = speciesData[SpeciesData::WILD_ITEM_UNCOMMON]
@@ -953,18 +944,13 @@ def pbPokemonEditor
data[20] = data[19] if !data[20] || data[20]==0
compats = (data[20] && data[20]>0) ? [data[19],data[20]] : data[19]
# Make sure both Abilities are recorded correctly
data[11] = data[12] if !data[11] || data[11]==0
data[11] = 0 if !data[11]
data[12] = 0 if data[11]==data[12]
abils = (data[12] && data[12]>0) ? [data[11],data[12]] : data[11]
data[11] = data[12] if !data[11]
data[12] = nil if data[11] == data[12]
abils = (data[12]) ? [data[11], data[12]] : data[11]
# Make sure all Hidden Abilities are recorded correctly
hiddenAbils = []; shouldArray = false
for i in 13..17
data[i] = nil if data[i] && data[i]==0
hiddenAbils.push(data[i])
shouldArray = true if i>13 && data[i]
end
hiddenAbils = hiddenAbils[0] if !shouldArray
hiddenAbils = [data[13], data[14], data[15], data[16]]
hiddenAbils.compact!
hiddenAbils = hiddenAbils[0] if hiddenAbils.length <= 1
# Save data
speciesData[SpeciesData::ABILITIES] = abils
speciesData[SpeciesData::COLOR] = data[24]
@@ -1057,8 +1043,11 @@ def pbPokemonEditor
save_data(evos,"Data/species_evolutions.dat")
# Don't need to save metrics or regional numbers
# because they can't be edited here
# TODO: Only need to reload whichever sets of Pokémon data were
# edited here (species, movesets, egg moves, evolutions).
# These are likely to be merged into a single data file.
pbClearData
pbSavePokemonData
pbSavePokemonData # Rewrite PBS files pokemon.txt and pokemonforms.txt
pbMessage(_INTL("Data saved."))
end
end

View File

@@ -55,12 +55,12 @@ def pbSaveAbilities
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
f.write("\r\n")
f.write("\#-------------------------------\r\n")
PokemonData::Ability.each do |a|
GameData::Ability.each do |a|
f.write(sprintf("%d,%s,%s,%s\r\n",
a.id_number,
csvQuote(a.id.to_s),
csvQuote(a.name),
csvQuoteAlways(a.description)
csvQuote(a.real_name),
csvQuoteAlways(a.real_description)
))
end
}
@@ -228,41 +228,35 @@ end
# Save item data to PBS file
#===============================================================================
def pbSaveItems
itemData = pbLoadItemsData rescue nil
return if !itemData || itemData.length==0
File.open("PBS/items.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."))
f.write("\r\n")
curpocket = 0
for i in 0...itemData.length
next if !itemData[i]
data = itemData[i]
cname = getConstantName(PBItems,i) rescue sprintf("ITEM%03d",i)
next if !cname || cname=="" || data[0]==0
if curpocket!=data[ItemData::POCKET]
curpocket = data[ItemData::POCKET]
current_pocket = 0
GameData::Item.each do |i|
if current_pocket != i.pocket
current_pocket = i.pocket
f.write("\#-------------------------------\r\n")
end
machine = ""
if data[ItemData::MOVE]>0
machine = getConstantName(PBMoves,data[ItemData::MOVE]) rescue pbGetMoveConst(data[ItemData::MOVE]) rescue ""
move_name = ""
if i.move
move_name = getConstantName(PBMoves, i.move) rescue pbGetMoveConst(i.move) rescue ""
end
f.write(sprintf("%d,%s,%s,%s,%d,%d,%s,%d,%d,%d,%s",
data[ItemData::ID],
csvQuote(cname),
csvQuote(data[ItemData::NAME]),
csvQuote(data[ItemData::NAME_PLURAL]),
data[ItemData::POCKET],
data[ItemData::PRICE],
csvQuoteAlways(data[ItemData::DESCRIPTION]),
data[ItemData::FIELD_USE],
data[ItemData::BATTLE_USE],
data[ItemData::TYPE],
csvQuote(machine)))
f.write("\r\n")
f.write(sprintf("%d,%s,%s,%s,%d,%d,%s,%d,%d,%d,%s\r\n",
i.id_number,
csvQuote(i.id.to_s),
csvQuote(i.real_name),
csvQuote(i.real_name_plural),
i.pocket,
i.price,
csvQuoteAlways(i.real_description),
i.field_use,
i.battle_use,
i.type,
csvQuote(move_name)
))
end
}
end
@@ -282,13 +276,12 @@ def pbSaveBerryPlants
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
f.write("\r\n")
f.write("\#-------------------------------\r\n")
for i in 0...berryPlantData.length
next if !berryPlantData[i]
data = berryPlantData[i]
cname = getConstantName(PBItems,i) rescue sprintf("ITEM%03d",i)
next if !cname || cname=="" || i==0
keys = berryPlantData.keys.sort
keys.each do |key|
data = berryPlantData[key]
next if !data || !GameData::Item.exists?(key)
f.write(sprintf("%s = %d,%d,%d,%d",
csvQuote(cname),data[0],data[1],data[2],data[3]))
csvQuote(GameData::Item.get(key).id.to_s), data[0], data[1], data[2], data[3]))
f.write("\r\n")
end
}
@@ -368,7 +361,7 @@ def pbSaveEncounterData
f.write(0xBF.chr)
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
f.write("\r\n")
sortedkeys = encdata.keys.sort { |a,b| a<=>b }
sortedkeys = encdata.keys.sort
for i in sortedkeys
next if !encdata[i]
e = encdata[i]
@@ -461,10 +454,8 @@ def pbSaveTrainerBattles
if trainer[2] && trainer[2].length>0
itemstring = ""
for i in 0...trainer[2].length
itemname = getConstantName(PBItems,trainer[2][i]) rescue pbGetItemConst(trainer[2][i]) rescue nil
next if !itemname
itemstring.concat(",") if i>0
itemstring.concat(itemname)
itemstring.concat(",") if i > 0
itemstring.concat(trainer[2][i].to_s)
end
f.write(sprintf("Items = %s\r\n",itemstring)) if itemstring!=""
end
@@ -502,11 +493,10 @@ def pbSaveTrainerBattles
f.write(sprintf(" Moves = %s\r\n",movestring)) if movestring!=""
end
if poke[TrainerData::ABILITY]
f.write(sprintf(" Ability = %d\r\n",poke[TrainerData::ABILITY]))
f.write(sprintf(" Ability = %s\r\n",poke[TrainerData::ABILITY].to_s))
end
if poke[TrainerData::ITEM] && poke[TrainerData::ITEM]>0
item = getConstantName(PBItems,poke[TrainerData::ITEM]) rescue pbGetItemConst(poke[TrainerData::ITEM]) rescue nil
f.write(sprintf(" Item = %s\r\n",item)) if item
if poke[TrainerData::ITEM]
f.write(sprintf(" Item = %s\r\n",poke[TrainerData::ITEM].to_s))
end
if poke[TrainerData::NATURE]
nature = getConstantName(PBNatures,poke[TrainerData::NATURE]) rescue nil
@@ -688,10 +678,10 @@ def pbSavePokemonData
hiddenability3 = nil
hiddenability4 = nil
end
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON] || 0
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON] || 0
item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE] || 0
incense = speciesData[i][SpeciesData::INCENSE] || 0
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON]
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON]
item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE]
incense = speciesData[i][SpeciesData::INCENSE]
pokedata.write("\#-------------------------------\r\n")
pokedata.write("[#{i}]\r\nName = #{speciesname}\r\n")
pokedata.write("InternalName = #{cname}\r\n")
@@ -711,12 +701,12 @@ def pbSavePokemonData
pokedata.write("Happiness = #{happiness}\r\n")
pokedata.write("Abilities = ")
if ability1
cability1 = PokemonData::Ability.get(ability1).name
cability1 = GameData::Ability.get(ability1).id.to_s
pokedata.write("#{cability1}")
pokedata.write(",") if ability2
end
if ability2
cability2 = PokemonData::Ability.get(ability2).name
cability2 = GameData::Ability.get(ability2).id.to_s
pokedata.write("#{cability2}")
end
pokedata.write("\r\n")
@@ -724,22 +714,22 @@ def pbSavePokemonData
pokedata.write("HiddenAbility = ")
needcomma = false
if hiddenability1
cabilityh = PokemonData::Ability.get(hiddenability1).name
cabilityh = GameData::Ability.get(hiddenability1).id.to_s
pokedata.write("#{cabilityh}"); needcomma = true
end
if hiddenability2
pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability2).name
cabilityh = GameData::Ability.get(hiddenability2).id.to_s
pokedata.write("#{cabilityh}"); needcomma = true
end
if hiddenability3
pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability3).name
cabilityh = GameData::Ability.get(hiddenability3).id.to_s
pokedata.write("#{cabilityh}"); needcomma = true
end
if hiddenability4
pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability4).name
cabilityh = GameData::Ability.get(hiddenability4).id.to_s
pokedata.write("#{cabilityh}")
end
pokedata.write("\r\n")
@@ -812,16 +802,16 @@ def pbSavePokemonData
if formname && formname!=""
pokedata.write("FormName = #{formname}\r\n")
end
if item1>0
citem1 = getConstantName(PBItems,item1) rescue pbGetItemConst(item1)
if item1
citem1 = GameData::Item.get(item1).id.to_s
pokedata.write("WildItemCommon = #{citem1}\r\n")
end
if item2>0
citem2 = getConstantName(PBItems,item2) rescue pbGetItemConst(item2)
if item2
citem2 = GameData::Item.get(item2).id.to_s
pokedata.write("WildItemUncommon = #{citem2}\r\n")
end
if item3>0
citem3 = getConstantName(PBItems,item3) rescue pbGetItemConst(item3)
if item3
citem3 = GameData::Item.get(item3).id.to_s
pokedata.write("WildItemRare = #{citem3}\r\n")
end
if metrics && metrics.length>0
@@ -849,8 +839,12 @@ def pbSavePokemonData
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].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
@@ -858,8 +852,8 @@ def pbSavePokemonData
count += 1
end
pokedata.write("\r\n")
if incense>0
initem = getConstantName(PBItems,incense) rescue pbGetItemConst(incense)
if incense
initem = GameData::Item.get(incense).id.to_s
pokedata.write("Incense = #{initem}\r\n")
end
if i%20==0
@@ -954,10 +948,10 @@ def pbSavePokemonFormsData
origdata["hiddenability3"] = nil
origdata["hiddenability4"] = nil
end
origdata["item1"] = speciesData[species][SpeciesData::WILD_ITEM_COMMON] || 0
origdata["item2"] = speciesData[species][SpeciesData::WILD_ITEM_UNCOMMON] || 0
origdata["item3"] = speciesData[species][SpeciesData::WILD_ITEM_RARE] || 0
origdata["incense"] = speciesData[species][SpeciesData::INCENSE] || 0
origdata["item1"] = speciesData[species][SpeciesData::WILD_ITEM_COMMON]
origdata["item2"] = speciesData[species][SpeciesData::WILD_ITEM_UNCOMMON]
origdata["item3"] = speciesData[species][SpeciesData::WILD_ITEM_RARE]
origdata["incense"] = speciesData[species][SpeciesData::INCENSE]
abilities = speciesData[i][SpeciesData::ABILITIES]
if abilities.is_a?(Array)
ability1 = abilities[0]
@@ -1047,16 +1041,16 @@ def pbSavePokemonFormsData
hiddenability4==origdata["hiddenability4"]
hiddenability1 = hiddenability2 = hiddenability3 = hiddenability4 = nil
end
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON] || 0
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON] || 0
item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE] || 0
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON]
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON]
item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE]
if item1==origdata["item1"] && item2==origdata["item2"] && item3==origdata["item3"]
item1 = item2 = item3 = nil
end
incense = speciesData[i][SpeciesData::INCENSE] || 0
incense = speciesData[i][SpeciesData::INCENSE]
incense = nil if incense==origdata["incense"]
pokedexform = speciesData[i][SpeciesData::POKEDEX_FORM] || 0 # No nil check
megastone = speciesData[i][SpeciesData::MEGA_STONE] || 0 # No nil check
megastone = speciesData[i][SpeciesData::MEGA_STONE] # No nil check
megamove = speciesData[i][SpeciesData::MEGA_MOVE] || 0 # No nil check
unmega = speciesData[i][SpeciesData::UNMEGA_FORM] || 0 # No nil check
megamessage = speciesData[i][SpeciesData::MEGA_MESSAGE] || 0 # No nil check
@@ -1064,8 +1058,8 @@ def pbSavePokemonFormsData
pokedata.write("[#{cname},#{form}]\r\n")
pokedata.write("FormName = #{formname}\r\n") if formname && formname!=""
pokedata.write("PokedexForm = #{pokedexform}\r\n") if pokedexform>0
if megastone>0
citem = getConstantName(PBItems,megastone) rescue pbGetItemConst(megastone)
if megastone
citem = GameData::Item.get(megastone).id.to_s
pokedata.write("MegaStone = #{citem}\r\n")
end
if megamove>0
@@ -1107,12 +1101,12 @@ def pbSavePokemonFormsData
if ability1 || ability2
pokedata.write("Abilities = ")
if ability1
cability1 = PokemonData::Ability.get(ability1).name
cability1 = GameData::Ability.get(ability1).id.to_s
pokedata.write("#{cability1}")
pokedata.write(",") if ability2
end
if ability2
cability2 = PokemonData::Ability.get(ability2).name
cability2 = GameData::Ability.get(ability2).id.to_s
pokedata.write("#{cability2}")
end
pokedata.write("\r\n")
@@ -1122,22 +1116,22 @@ def pbSavePokemonFormsData
pokedata.write("HiddenAbility = ")
needcomma = false
if hiddenability1
cabilityh = PokemonData::Ability.get(hiddenability1).name
cabilityh = GameData::Ability.get(hiddenability1).id.to_s
pokedata.write("#{cabilityh}"); needcomma=true
end
if hiddenability2
pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability2).name
cabilityh = GameData::Ability.get(hiddenability2).id.to_s
pokedata.write("#{cabilityh}"); needcomma=true
end
if hiddenability3
pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability3).name
cabilityh = GameData::Ability.get(hiddenability3).id.to_s
pokedata.write("#{cabilityh}"); needcomma=true
end
if hiddenability4
pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability4).name
cabilityh = GameData::Ability.get(hiddenability4).id.to_s
pokedata.write("#{cabilityh}")
end
pokedata.write("\r\n")
@@ -1238,19 +1232,17 @@ def pbSavePokemonFormsData
if entry!=nil
pokedata.write("Pokedex = #{entry}\r\n")
end
if item1!=nil && item2!=nil && item3!=nil
if item1>0
citem1 = getConstantName(PBItems,item1) rescue pbGetItemConst(item1)
pokedata.write("WildItemCommon = #{citem1}\r\n")
end
if item2>0
citem2 = getConstantName(PBItems,item2) rescue pbGetItemConst(item2)
pokedata.write("WildItemUncommon = #{citem2}\r\n")
end
if item3>0
citem3 = getConstantName(PBItems,item3) rescue pbGetItemConst(item3)
pokedata.write("WildItemRare = #{citem3}\r\n")
end
if item1
citem1 = GameData::Item.get(item1).id.to_s
pokedata.write("WildItemCommon = #{citem1}\r\n")
end
if item2
citem1 = GameData::Item.get(item2).id.to_s
pokedata.write("WildItemUncommon = #{citem2}\r\n")
end
if item3
citem1 = GameData::Item.get(item3).id.to_s
pokedata.write("WildItemRare = #{citem3}\r\n")
end
if metrics && metrics.length>0
for j in 0...6
@@ -1322,11 +1314,9 @@ def pbSavePokemonFormsData
end
pokedata.write("\r\n")
end
if incense!=nil
if incense>0
initem = getConstantName(PBItems,incense) rescue pbGetItemConst(incense)
pokedata.write("Incense = #{initem}\r\n")
end
if incense
initem = GameData::Item.get(incense).id.to_s
pokedata.write("Incense = #{initem}\r\n")
end
if i%20==0
Graphics.update
@@ -1439,8 +1429,7 @@ end
def pbFastInspect(pkmn,moves,species,items,natures)
c1 = (species[pkmn.species]) ? species[pkmn.species] :
(species[pkmn.species] = (getConstantName(PBSpecies,pkmn.species) rescue pbGetSpeciesConst(pkmn.species)))
c2 = (items[pkmn.item]) ? items[pkmn.item] :
(items[pkmn.item] = (getConstantName(PBItems,pkmn.item) rescue pbGetItemConst(pkmn.item)))
c2 = (items[pkmn.item]) ? items[pkmn.item] : (items[pkmn.item] = GameData::Item.get(pkmn.item).id.to_s)
c3 = (natures[pkmn.nature]) ? natures[pkmn.nature] :
(natures[pkmn.nature] = getConstantName(PBNatures,pkmn.nature))
evlist = ""

View File

@@ -352,9 +352,9 @@ end
module ItemProperty
def self.set(_settingname,oldsetting)
ret = pbChooseItemList((oldsetting) ? oldsetting : 1)
return (ret>0) ? ret : (oldsetting) ? oldsetting : nil
def self.set(_settingname, oldsetting)
ret = pbChooseItemList((oldsetting) ? oldsetting : nil)
return ret || oldsetting
end
def self.defaultValue
@@ -362,7 +362,7 @@ module ItemProperty
end
def self.format(value)
return (value) ? PBItems.getName(value) : "-"
return (value && GameData::Item.exists?(value)) ? GameData::Item.get(value).real_name : "-"
end
end
@@ -522,8 +522,7 @@ class BallProperty
end
def format(value)
return "-" if !value
return PBItems.getName(pbBallTypeToItem(value))
return (value) ? pbBallTypeToItem(value).name : "-"
end
end
@@ -817,17 +816,17 @@ end
module AbilityProperty
def self.set(_settingname,oldsetting)
ret = pbChooseAbilityList((oldsetting) ? oldsetting : 1)
return (ret<=0) ? (oldsetting) ? oldsetting : 0 : ret
def self.set(_settingname, oldsetting)
ret = pbChooseAbilityList((oldsetting) ? oldsetting : nil)
return ret || oldsetting
end
def self.defaultValue
return 0
return nil
end
def self.format(value)
return (value && PokemonData::Ability.exists?(value)) ? PokemonData::Ability.get(value).name : "-"
return (value && GameData::Ability.exists?(value)) ? GameData::Ability.get(value).real_name : "-"
end
end
@@ -1253,7 +1252,7 @@ class EvolutionsProperty
if has_param
allow_zero = false
case param_type
when :PBItems
when :Item
newparam = pbChooseItemList
when :PBMoves
newparam = pbChooseMoveList
@@ -1272,7 +1271,8 @@ class EvolutionsProperty
newparam = pbMessageChooseNumber(_INTL("Choose a parameter."),params)
end
end
if !has_param || newparam > 0 || (allow_zero && newparam == 0)
if !has_param || newparam.is_a?(Symbol) ||
(newparam.is_a?(Integer) && (newparam > 0 || (allow_zero && newparam == 0)))
havemove = -1
for i in 0...realcmds.length
havemove = realcmds[i][3] if realcmds[i][0]==newmethod &&
@@ -1341,7 +1341,7 @@ class EvolutionsProperty
if has_param
allow_zero = false
case param_type
when :PBItems
when :Item
newparam = pbChooseItemList(entry[1])
when :PBMoves
newparam = pbChooseMoveList(entry[1])
@@ -1360,7 +1360,8 @@ class EvolutionsProperty
params.setCancelValue(-1)
newparam = pbMessageChooseNumber(_INTL("Choose a parameter."),params)
end
if newparam>0 || (allow_zero && newparam == 0)
if newparam.is_a?(Symbol) ||
(newparam.is_a?(Integer) && (newparam > 0 || (allow_zero && newparam == 0)))
havemove = -1
for i in 0...realcmds.length
havemove = realcmds[i][3] if realcmds[i][0]==entry[0] &&

View File

@@ -376,9 +376,9 @@ end
class ItemLister
def initialize(selection,includeNew=false)
def initialize(selection=0,includeNew=false)
@sprite = IconSprite.new(0,0)
@sprite = ItemIconSprite.new(Graphics.width*3/4,Graphics.height/2,-1)
@sprite = ItemIconSprite.new(Graphics.width*3/4,Graphics.height/2,nil)
@sprite.z = 2
@selection = selection
@commands = []
@@ -404,23 +404,18 @@ class ItemLister
def commands # Sorted alphabetically
@commands.clear
@ids.clear
@itemdata = pbLoadItemsData
cmds = []
for i in 1..PBItems.maxValue
next if !@itemdata[i]
name = @itemdata[i][ItemData::NAME]
if name && name!="" && @itemdata[i][ItemData::POCKET]!=0
cmds.push([i,name])
end
GameData::Item.each do |item|
cmds.push([item.id_number, item.id, item.real_name])
end
cmds.sort! { |a,b| a[1]<=>b[1] }
cmds.sort! { |a, b| a[2].downcase <=> b[2].downcase }
if @includeNew
@commands.push(_INTL("[NEW ITEM]"))
@ids.push(-1)
@ids.push(true)
end
for i in cmds
@commands.push(sprintf("%03d: %s",i[0],i[1]))
@ids.push(i[0])
@commands.push(sprintf("%03d: %s", i[0], i[2]))
@ids.push(i[1])
end
@index = @selection
@index = @commands.length-1 if @index>=@commands.length
@@ -434,7 +429,7 @@ class ItemLister
end
def refresh(index)
@sprite.item = @ids[index]
@sprite.item = (@ids[index].is_a?(Symbol)) ? @ids[index] : nil
end
end

View File

@@ -14,16 +14,11 @@ def pbGetLegalMoves(species)
return moves if !species || species<=0
moveset = pbGetSpeciesMoveset(species)
moveset.each { |m| moves.push(m[1]) }
itemData = pbLoadItemsData
tmdat = pbLoadSpeciesTMData
for i in 0...itemData.length
next if !itemData[i]
atk = itemData[i][8]
next if !atk || atk==0
next if !tmdat[atk]
if tmdat[atk].any? { |item| item==species }
moves.push(atk)
end
GameData::Item.each do |i|
next if !i.move
atk = getConst(PBMoves, i.move)
moves.push(atk) if tmdat[atk] && tmdat[atk].include?(species)
end
babyspecies = pbGetBabySpecies(species)
eggMoves = pbGetSpeciesEggMoves(babyspecies)
@@ -252,9 +247,10 @@ def pbGetMoveConst(i)
return MakeshiftConsts.get(MessageTypes::Moves,i,PBMoves)
end
def pbGetItemConst(i)
return MakeshiftConsts.get(MessageTypes::Items,i,PBItems)
end
# Unused
#def pbGetItemConst(i)
# return MakeshiftConsts.get(MessageTypes::Items,i,PBItems)
#end
def pbGetSpeciesConst(i)
return MakeshiftConsts.get(MessageTypes::Species,i,PBSpecies)
@@ -346,48 +342,43 @@ end
# 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.
def pbChooseItemList(default=0)
def pbChooseItemList(default = nil)
commands = []
for i in 1..PBItems.maxValue
cname = getConstantName(PBItems,i) rescue nil
commands.push([i,PBItems.getName(i)]) if cname
end
return pbChooseList(commands,default,0,-1)
GameData::Item.each { |i| commands.push([i.id_number, i.name, i.id]) }
return pbChooseList(commands, default, nil, -1)
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
# the ability to initially select. Pressing Input::A will toggle the list
# sorting between numerical and alphabetical.
def pbChooseAbilityList(default=0)
def pbChooseAbilityList(default = 0)
commands = []
PokemonData::Ability.each do |a|
commands.push([a.id_number, a.name])
end
return pbChooseList(commands,default,0,-1)
GameData::Ability.each { |a| commands.push([a.id_number, a.name, a.id]) }
return pbChooseList(commands, default, nil, -1)
end
def pbChooseBallList(defaultMoveID=-1)
cmdwin = pbListWindow([],200)
def pbChooseBallList(defaultMoveID = -1)
cmdwin = pbListWindow([], 200)
commands = []
moveDefault = 0
for key in $BallTypes.keys
item = getID(PBItems,$BallTypes[key])
commands.push([key,item,PBItems.getName(item)]) if item && item>0
item = GameData::Item.try_get($BallTypes[key])
balls.push([key.to_i, item.name]) if item
end
commands.sort! { |a,b| a[2]<=>b[2] }
if defaultMoveID>=0
commands.sort! { |a, b| a[1] <=> b[1] }
if defaultMoveID >= 0
for i in 0...commands.length
moveDefault = i if defaultMoveID==commands[i][0]
moveDefault = i if commands[i][0] == defaultMoveID
end
end
realcommands = []
for i in commands
realcommands.push(i[2])
realcommands.push(i[1])
end
ret = pbCommands2(cmdwin,realcommands,-1,moveDefault,true)
ret = pbCommands2(cmdwin, realcommands, -1, moveDefault, true)
cmdwin.dispose
return (ret>=0) ? commands[ret][0] : defaultMoveID
return (ret >= 0) ? commands[ret][0] : defaultMoveID
end
@@ -486,39 +477,41 @@ def pbCommands3(cmdwindow,commands,cmdIfCancel,defaultindex=-1,noresize=false)
return ret
end
def pbChooseList(commands,default=0,cancelValue=-1,sortType=1)
def pbChooseList(commands, default = 0, cancelValue = -1, sortType = 1)
cmdwin = pbListWindow([])
itemID = default
itemIndex = 0
sortMode = (sortType>=0) ? sortType : 0 # 0=ID, 1=alphabetical
sortMode = (sortType >= 0) ? sortType : 0 # 0=ID, 1=alphabetical
sorting = true
loop do
if sorting
if sortMode==0
commands.sort! { |a,b| a[0]<=>b[0] }
elsif sortMode==1
commands.sort! { |a,b| a[1]<=>b[1] }
if sortMode == 0
commands.sort! { |a, b| a[0] <=> b[0] }
elsif sortMode == 1
commands.sort! { |a, b| a[1] <=> b[1] }
end
if itemID>0
commands.each_with_index { |command,i| itemIndex = i if command[0]==itemID }
if itemID.is_a?(Symbol)
commands.each_with_index { |command, i| itemIndex = i if command[2] == itemID }
elsif itemID && itemID > 0
commands.each_with_index { |command, i| itemIndex = i if command[0] == itemID }
end
realcommands = []
for command in commands
if sortType<=0
realcommands.push(sprintf("%03d: %s",command[0],command[1]))
if sortType <= 0
realcommands.push(sprintf("%03d: %s", command[0], command[1]))
else
realcommands.push(command[1])
end
end
sorting = false
end
cmd = pbCommandsSortable(cmdwin,realcommands,-1,itemIndex,(sortType<0))
if cmd[0]==0 # Chose an option or cancelled
itemID = (cmd[1]<0) ? cancelValue : commands[cmd[1]][0]
cmd = pbCommandsSortable(cmdwin, realcommands, -1, itemIndex, (sortType < 0))
if cmd[0] == 0 # Chose an option or cancelled
itemID = (cmd[1] < 0) ? cancelValue : (commands[cmd[1]][2] || commands[cmd[1]][0])
break
elsif cmd[0]==1 # Toggle sorting
itemID = commands[cmd[1]][0]
sortMode = (sortMode+1)%2
elsif cmd[0] == 1 # Toggle sorting
itemID = commands[cmd[1]][2] || commands[cmd[1]][0]
sortMode = (sortMode + 1) % 2
sorting = true
end
end

View File

@@ -793,6 +793,7 @@ class MapScreenScene
serializeConnectionData
serializeMetadata
save_data(@encdata,"Data/encounters.dat")
# TODO: Only need to reload connections, metadata, encounter data.
pbClearData
pbSaveEncounterData
end