mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Implemented GameData::Encounter, created new encounters.txt format, tweaked Vs animation filenames
This commit is contained in:
@@ -887,16 +887,7 @@ DebugMenuCommands.register("setencounters", {
|
||||
"description" => _INTL("Edit the wild Pokémon that can be found on maps, and how they are encountered."),
|
||||
"always_show" => true,
|
||||
"effect" => proc {
|
||||
encdata = pbLoadEncountersData
|
||||
map = pbDefaultMap
|
||||
loop do
|
||||
map = pbListScreen(_INTL("SET ENCOUNTERS"), MapLister.new(map))
|
||||
break if map <= 0
|
||||
pbEncounterEditorMap(encdata, map)
|
||||
end
|
||||
save_data(encdata, "Data/encounters.dat")
|
||||
$PokemonTemp.encountersData = nil
|
||||
Compiler.write_encounters # Rewrite PBS file encounters.txt
|
||||
pbFadeOutIn { pbEncountersEditor }
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,217 +1,334 @@
|
||||
#===============================================================================
|
||||
# Wild encounters editor
|
||||
#===============================================================================
|
||||
def pbEncounterEditorTypes(enc,enccmd)
|
||||
# Main editor method for editing wild encounters. Lists all defined encounter
|
||||
# sets, and edits them.
|
||||
def pbEncountersEditor
|
||||
map_infos = load_data("Data/MapInfos.rxdata")
|
||||
commands = []
|
||||
indexes = []
|
||||
haveblank = false
|
||||
if enc
|
||||
commands.push(_INTL("Density: {1},{2},{3}",
|
||||
enc[0][EncounterTypes::Land],
|
||||
enc[0][EncounterTypes::Cave],
|
||||
enc[0][EncounterTypes::Water]))
|
||||
indexes.push(-2)
|
||||
for i in 0...EncounterTypes::EnctypeChances.length
|
||||
if enc[1][i]
|
||||
commands.push(EncounterTypes::Names[i])
|
||||
indexes.push(i)
|
||||
else
|
||||
haveblank = true
|
||||
end
|
||||
end
|
||||
else
|
||||
commands.push(_INTL("Density: Not Defined Yet"))
|
||||
indexes.push(-2)
|
||||
haveblank = true
|
||||
end
|
||||
if haveblank
|
||||
commands.push(_INTL("[New Encounter Type]"))
|
||||
indexes.push(-3)
|
||||
end
|
||||
enccmd.x = 0
|
||||
enccmd.y = 0
|
||||
enccmd.height = Graphics.height if enccmd.height>Graphics.height
|
||||
enccmd.z = 99999
|
||||
enccmd.commands = commands
|
||||
enccmd.active = true
|
||||
enccmd.index = 0
|
||||
enccmd.visible = true
|
||||
command = 0
|
||||
maps = []
|
||||
list = pbListWindow([])
|
||||
help_window = Window_UnformattedTextPokemon.newWithSize(_INTL("Edit wild encounters"),
|
||||
Graphics.width / 2, 0, Graphics.width / 2, 96)
|
||||
help_window.z = 99999
|
||||
ret = 0
|
||||
need_refresh = true
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
enccmd.update
|
||||
if Input.trigger?(Input::A) && indexes[enccmd.index]>=0
|
||||
if pbConfirmMessage(_INTL("Delete the encounter type {1}?",commands[enccmd.index]))
|
||||
enc[1][indexes[enccmd.index]] = nil
|
||||
commands.delete_at(enccmd.index)
|
||||
indexes.delete_at(enccmd.index)
|
||||
enccmd.commands = commands
|
||||
if enccmd.index>=enccmd.commands.length
|
||||
enccmd.index = enccmd.commands.length
|
||||
if need_refresh
|
||||
commands.clear
|
||||
maps.clear
|
||||
commands.push(_INTL("[Add new encounter set]"))
|
||||
GameData::Encounter.each do |enc_data|
|
||||
name = (map_infos[enc_data.map]) ? map_infos[enc_data.map].name : nil
|
||||
if enc_data.version > 0 && name
|
||||
commands.push(sprintf("%03d (v.%d): %s", enc_data.map, enc_data.version, name))
|
||||
elsif enc_data.version > 0
|
||||
commands.push(sprintf("%03d (v.%d)", enc_data.map, enc_data.version))
|
||||
elsif name
|
||||
commands.push(sprintf("%03d: %s", enc_data.map, name))
|
||||
else
|
||||
commands.push(sprintf("%03d", enc_data.map))
|
||||
end
|
||||
maps.push([enc_data.map, enc_data.version])
|
||||
end
|
||||
need_refresh = false
|
||||
end
|
||||
ret = pbCommands2(list, commands, -1, ret)
|
||||
if ret == 0 # Add new encounter set
|
||||
new_map_ID = pbListScreen(_INTL("Choose a map"), MapLister.new(pbDefaultMap))
|
||||
if new_map_ID > 0
|
||||
new_version = LimitProperty2.new(999).set(_INTL("version number"), 0)
|
||||
if new_version && new_version >= 0
|
||||
if GameData::Encounter.exists?(new_map_ID, new_version)
|
||||
pbMessage(_INTL("A set of encounters for map {1} version {2} already exists.", new_map_ID, new_version))
|
||||
else
|
||||
# Construct encounter hash
|
||||
key = sprintf("%s_%d", new_map_ID, new_version).to_sym
|
||||
encounter_hash = {
|
||||
:id => key,
|
||||
:map => new_map_ID,
|
||||
:version => new_version,
|
||||
:step_chances => [],
|
||||
:types => []
|
||||
}
|
||||
GameData::Encounter::DATA[encounter_hash[:id]] = GameData::Encounter.new(encounter_hash)
|
||||
maps.push([new_map_ID, new_version])
|
||||
maps.sort! { |a, b| (a[0] == b[0]) ? a[1] <=> b[1] : a[0] <=> b[0] }
|
||||
ret = maps.index([new_map_ID, new_version]) + 1
|
||||
need_refresh = true
|
||||
end
|
||||
end
|
||||
end
|
||||
elsif Input.trigger?(Input::B)
|
||||
command = -1
|
||||
break
|
||||
elsif Input.trigger?(Input::C) || (enccmd.doubleclick? rescue false)
|
||||
command = enccmd.index
|
||||
break
|
||||
end
|
||||
end
|
||||
ret = command
|
||||
enccmd.active = false
|
||||
return (ret<0) ? -1 : indexes[ret]
|
||||
end
|
||||
|
||||
def pbNewEncounterType(enc)
|
||||
cmdwin = pbListWindow([])
|
||||
commands =[]
|
||||
indexes = []
|
||||
for i in 0...EncounterTypes::EnctypeChances.length
|
||||
dogen = false
|
||||
if !enc[1][i]
|
||||
if i==0
|
||||
dogen = true unless enc[1][EncounterTypes::Cave]
|
||||
elsif i==1
|
||||
dogen = true unless enc[1][EncounterTypes::Land] ||
|
||||
enc[1][EncounterTypes::LandMorning] ||
|
||||
enc[1][EncounterTypes::LandDay] ||
|
||||
enc[1][EncounterTypes::LandNight] ||
|
||||
enc[1][EncounterTypes::BugContest]
|
||||
else
|
||||
dogen = true
|
||||
end
|
||||
end
|
||||
if dogen
|
||||
commands.push(EncounterTypes::Names[i])
|
||||
indexes.push(i)
|
||||
end
|
||||
end
|
||||
ret = pbCommands2(cmdwin,commands,-1)
|
||||
ret = (ret<0) ? -1 : indexes[ret]
|
||||
if ret>=0
|
||||
chances = EncounterTypes::EnctypeChances[ret]
|
||||
enc[1][ret] = []
|
||||
chances.length.times do
|
||||
enc[1][ret].push([1,5,5])
|
||||
end
|
||||
end
|
||||
cmdwin.dispose
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbEditEncounterType(enc,etype)
|
||||
commands = []
|
||||
cmdwin = pbListWindow([])
|
||||
chances = EncounterTypes::EnctypeChances[etype]
|
||||
chancetotal = 0
|
||||
chances.each { |a| chancetotal += a }
|
||||
enctype = enc[1][etype]
|
||||
for i in 0...chances.length
|
||||
enctype[i] = [1,5,5] if !enctype[i]
|
||||
end
|
||||
ret = 0
|
||||
loop do
|
||||
commands.clear
|
||||
for i in 0...enctype.length
|
||||
ch = chances[i]
|
||||
ch = sprintf("%.1f",100.0*chances[i]/chancetotal) if chancetotal!=100
|
||||
if enctype[i][1]==enctype[i][2]
|
||||
commands.push(_INTL("{1}% {2} (Lv.{3})", ch,
|
||||
GameData::Species.get(enctype[i][0]).real_name, enctype[i][1]))
|
||||
else
|
||||
commands.push(_INTL("{1}% {2} (Lv.{3}-Lv.{4})", ch,
|
||||
GameData::Species.get(enctype[i][0]).real_name, enctype[i][1], enctype[i][2]))
|
||||
end
|
||||
end
|
||||
ret = pbCommands2(cmdwin,commands,-1,ret)
|
||||
break if ret<0
|
||||
species = pbChooseSpeciesList(enctype[ret][0])
|
||||
next if !species
|
||||
enctype[ret][0] = species
|
||||
mLevel = PBExperience.maxLevel
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(1,mLevel)
|
||||
params.setDefaultValue(enctype[ret][1])
|
||||
minlevel = pbMessageChooseNumber(_INTL("Set the minimum level."),params)
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(minlevel,mLevel)
|
||||
params.setDefaultValue(minlevel)
|
||||
maxlevel = pbMessageChooseNumber(_INTL("Set the maximum level."),params)
|
||||
enctype[ret][1] = minlevel
|
||||
enctype[ret][2] = maxlevel
|
||||
end
|
||||
cmdwin.dispose
|
||||
end
|
||||
|
||||
def pbEncounterEditorDensity(enc)
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0,100)
|
||||
params.setDefaultValue(enc[0][EncounterTypes::Land])
|
||||
enc[0][EncounterTypes::Land] = pbMessageChooseNumber(
|
||||
_INTL("Set the density of Pokémon on land (default {1}).",
|
||||
EncounterTypes::EnctypeDensities[EncounterTypes::Land]),params)
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0,100)
|
||||
params.setDefaultValue(enc[0][EncounterTypes::Cave])
|
||||
enc[0][EncounterTypes::Cave] = pbMessageChooseNumber(
|
||||
_INTL("Set the density of Pokémon in caves (default {1}).",
|
||||
EncounterTypes::EnctypeDensities[EncounterTypes::Cave]),params)
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0,100)
|
||||
params.setDefaultValue(enc[0][EncounterTypes::Water])
|
||||
enc[0][EncounterTypes::Water] = pbMessageChooseNumber(
|
||||
_INTL("Set the density of Pokémon on water (default {1}).",
|
||||
EncounterTypes::EnctypeDensities[EncounterTypes::Water]),params)
|
||||
for i in 0...EncounterTypes::EnctypeCompileDens.length
|
||||
t = EncounterTypes::EnctypeCompileDens[i]
|
||||
next if !t || t==0
|
||||
enc[0][i] = enc[0][EncounterTypes::Land] if t==1
|
||||
enc[0][i] = enc[0][EncounterTypes::Cave] if t==2
|
||||
enc[0][i] = enc[0][EncounterTypes::Water] if t==3
|
||||
end
|
||||
end
|
||||
|
||||
def pbEncounterEditorMap(encdata,map)
|
||||
enccmd = pbListWindow([])
|
||||
# This window displays the help text
|
||||
enchelp = Window_UnformattedTextPokemon.new("")
|
||||
enchelp.x = Graphics.width/2
|
||||
enchelp.y = 0
|
||||
enchelp.width = Graphics.width/2 - 32
|
||||
enchelp.height = 96
|
||||
enchelp.z = 99999
|
||||
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||
mapname = mapinfos[map].name
|
||||
loop do
|
||||
enc = encdata[map]
|
||||
enchelp.text = _ISPRINTF("{1:03d}: {2:s}\r\nChoose a method",map,mapname)
|
||||
choice = pbEncounterEditorTypes(enc,enccmd)
|
||||
if !enc
|
||||
enc = [EncounterTypes::EnctypeDensities.clone,[]]
|
||||
encdata[map] = enc
|
||||
end
|
||||
if choice==-2
|
||||
pbEncounterEditorDensity(enc)
|
||||
elsif choice==-1
|
||||
break
|
||||
elsif choice==-3
|
||||
ret = pbNewEncounterType(enc)
|
||||
if ret>=0
|
||||
enchelp.text = _ISPRINTF("{1:03d}: {2:s}\r\n{3:s}",map,mapname,EncounterTypes::Names[ret])
|
||||
pbEditEncounterType(enc,ret)
|
||||
elsif ret > 0 # Edit an encounter set
|
||||
this_set = maps[ret - 1]
|
||||
case pbShowCommands(nil, [_INTL("Edit"), _INTL("Copy"), _INTL("Delete"), _INTL("Cancel")], 4)
|
||||
when 0 # Edit
|
||||
pbEncounterMapVersionEditor(GameData::Encounter.get(this_set[0], this_set[1]))
|
||||
need_refresh = true
|
||||
when 1 # Copy
|
||||
new_map_ID = pbListScreen(_INTL("Copy to which map?"), MapLister.new(this_set[0]))
|
||||
if new_map_ID > 0
|
||||
new_version = LimitProperty2.new(999).set(_INTL("version number"), 0)
|
||||
if new_version && new_version >= 0
|
||||
if GameData::Encounter.exists?(new_map_ID, new_version)
|
||||
pbMessage(_INTL("A set of encounters for map {1} version {2} already exists.", new_map_ID, new_version))
|
||||
else
|
||||
types = []
|
||||
GameData::Encounter.get(this_set[0], this_set[1]).types.each_with_index do |enc_type, i|
|
||||
next if !enc_type
|
||||
types[i] = []
|
||||
enc_type.each { |slot| types[i].push(slot.clone) }
|
||||
end
|
||||
# Construct encounter hash
|
||||
key = sprintf("%s_%d", new_map_ID, new_version).to_sym
|
||||
encounter_hash = {
|
||||
:id => key,
|
||||
:map => new_map_ID,
|
||||
:version => new_version,
|
||||
:step_chances => GameData::Encounter.get(this_set[0], this_set[1]).step_chances.clone,
|
||||
:types => types
|
||||
}
|
||||
GameData::Encounter::DATA[encounter_hash[:id]] = GameData::Encounter.new(encounter_hash)
|
||||
maps.push([new_map_ID, new_version])
|
||||
maps.sort! { |a, b| (a[0] == b[0]) ? a[1] <=> b[1] : a[0] <=> b[0] }
|
||||
ret = maps.index([new_map_ID, new_version]) + 1
|
||||
need_refresh = true
|
||||
end
|
||||
end
|
||||
end
|
||||
when 2 # Delete
|
||||
if pbConfirmMessage(_INTL("Delete the encounter set for map {1} version {2}?", this_set[0], this_set[1]))
|
||||
key = sprintf("%s_%d", this_set[0], this_set[1]).to_sym
|
||||
GameData::Encounter::DATA.delete(key)
|
||||
ret -= 1
|
||||
need_refresh = true
|
||||
end
|
||||
end
|
||||
else
|
||||
enchelp.text = _ISPRINTF("{1:03d}: {2:s}\r\n{3:s}",map,mapname,EncounterTypes::Names[choice])
|
||||
pbEditEncounterType(enc,choice)
|
||||
break
|
||||
end
|
||||
end
|
||||
if encdata[map][1].length==0
|
||||
encdata[map] = nil
|
||||
if pbConfirmMessage(_INTL("Save changes?"))
|
||||
GameData::Encounter.save
|
||||
Compiler.write_encounters # Rewrite PBS file encounters.txt
|
||||
else
|
||||
GameData::Encounter.load
|
||||
end
|
||||
enccmd.dispose
|
||||
enchelp.dispose
|
||||
list.dispose
|
||||
help_window.dispose
|
||||
Input.update
|
||||
end
|
||||
|
||||
# Lists the map ID, version number and defined encounter types for the given
|
||||
# encounter data (a GameData::Encounter instance), and edits them.
|
||||
def pbEncounterMapVersionEditor(enc_data)
|
||||
map_infos = load_data("Data/MapInfos.rxdata")
|
||||
commands = []
|
||||
enc_types = []
|
||||
list = pbListWindow([])
|
||||
help_window = Window_UnformattedTextPokemon.newWithSize(_INTL("Edit map's encounters"),
|
||||
Graphics.width / 2, 0, Graphics.width / 2, 96)
|
||||
help_window.z = 99999
|
||||
ret = 0
|
||||
need_refresh = true
|
||||
loop do
|
||||
if need_refresh
|
||||
commands.clear
|
||||
enc_types.clear
|
||||
map_name = (map_infos[enc_data.map]) ? map_infos[enc_data.map].name : nil
|
||||
if map_name
|
||||
commands.push(_INTL("Map ID={1} ({2})", enc_data.map, map_name))
|
||||
else
|
||||
commands.push(_INTL("Map ID={1}", enc_data.map))
|
||||
end
|
||||
commands.push(_INTL("Version={1}", enc_data.version))
|
||||
enc_data.types.each_with_index do |enc_type, i|
|
||||
next if !enc_type
|
||||
commands.push(_INTL("{1} (x{2})", EncounterTypes::Names[i], enc_type.length))
|
||||
enc_types.push(i)
|
||||
end
|
||||
commands.push(_INTL("[Add new encounter type]"))
|
||||
need_refresh = false
|
||||
end
|
||||
ret = pbCommands2(list, commands, -1, ret)
|
||||
if ret == 0 # Edit map ID
|
||||
old_map_ID = enc_data.map
|
||||
new_map_ID = pbListScreen(_INTL("Choose a new map"), MapLister.new(old_map_ID))
|
||||
if new_map_ID > 0 && new_map_ID != old_map_ID
|
||||
if GameData::Encounter.exists?(new_map_ID, enc_data.version)
|
||||
pbMessage(_INTL("A set of encounters for map {1} version {2} already exists.", new_map_ID, enc_data.version))
|
||||
else
|
||||
GameData::Encounter::DATA.delete(enc_data.id)
|
||||
enc_data.map = new_map_ID
|
||||
enc_data.id = sprintf("%s_%d", enc_data.map, enc_data.version).to_sym
|
||||
GameData::Encounter::DATA[enc_data.id] = enc_data
|
||||
need_refresh = true
|
||||
end
|
||||
end
|
||||
elsif ret == 1 # Edit version number
|
||||
old_version = enc_data.version
|
||||
new_version = LimitProperty2.new(999).set(_INTL("version number"), old_version)
|
||||
if new_version && new_version != old_version
|
||||
if GameData::Encounter.exists?(enc_data.map, new_version)
|
||||
pbMessage(_INTL("A set of encounters for map {1} version {2} already exists.", enc_data.map, new_version))
|
||||
else
|
||||
GameData::Encounter::DATA.delete(enc_data.id)
|
||||
enc_data.version = new_version
|
||||
enc_data.id = sprintf("%s_%d", enc_data.map, enc_data.version).to_sym
|
||||
GameData::Encounter::DATA[enc_data.id] = enc_data
|
||||
need_refresh = true
|
||||
end
|
||||
end
|
||||
elsif ret == commands.length - 1 # Add new encounter type
|
||||
new_type_commands = []
|
||||
new_types = []
|
||||
EncounterTypes::Names.each_with_index do |new_type, i|
|
||||
next if enc_data.types[i]
|
||||
new_type_commands.push(new_type)
|
||||
new_types.push(i)
|
||||
end
|
||||
if new_type_commands.length > 0
|
||||
chosen_type_cmd = pbShowCommands(nil, new_type_commands, -1)
|
||||
if chosen_type_cmd >= 0
|
||||
new_type = new_types[chosen_type_cmd]
|
||||
enc_data.step_chances[new_type] = 0
|
||||
enc_data.types[new_type] = []
|
||||
pbEncounterTypeEditor(enc_data, new_type)
|
||||
enc_types.push(new_type)
|
||||
ret = enc_types.sort.index(new_type) + 2
|
||||
need_refresh = true
|
||||
end
|
||||
else
|
||||
pbMessage(_INTL("There are no unused encounter types to add."))
|
||||
end
|
||||
elsif ret > 0 # Edit an encounter type (its step chance and slots)
|
||||
this_type = enc_types[ret - 2]
|
||||
case pbShowCommands(nil, [_INTL("Edit"), _INTL("Copy"), _INTL("Delete"), _INTL("Cancel")], 4)
|
||||
when 0 # Edit
|
||||
pbEncounterTypeEditor(enc_data, this_type)
|
||||
need_refresh = true
|
||||
when 1 # Copy
|
||||
new_type_commands = []
|
||||
new_types = []
|
||||
EncounterTypes::Names.each_with_index do |new_type, i|
|
||||
next if enc_data.types[i]
|
||||
new_type_commands.push(new_type)
|
||||
new_types.push(i)
|
||||
end
|
||||
if new_type_commands.length > 0
|
||||
chosen_type_cmd = pbMessage(_INTL("Choose an encounter type to copy to."),
|
||||
new_type_commands, -1)
|
||||
if chosen_type_cmd >= 0
|
||||
new_type = new_types[chosen_type_cmd]
|
||||
enc_data.step_chances[new_type] = enc_data.step_chances[this_type]
|
||||
enc_data.types[new_type] = []
|
||||
enc_data.types[this_type].each { |enc| enc_data.types[new_type].push(enc.clone) }
|
||||
enc_types.push(new_type)
|
||||
ret = enc_types.sort.index(new_type) + 2
|
||||
need_refresh = true
|
||||
end
|
||||
else
|
||||
pbMessage(_INTL("There are no unused encounter types to copy to."))
|
||||
end
|
||||
when 2 # Delete
|
||||
if pbConfirmMessage(_INTL("Delete the encounter type {1}?", EncounterTypes::Names[this_type]))
|
||||
enc_data.step_chances[this_type] = nil
|
||||
enc_data.types[this_type] = nil
|
||||
need_refresh = true
|
||||
end
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
list.dispose
|
||||
help_window.dispose
|
||||
Input.update
|
||||
end
|
||||
|
||||
# Lists the step chance and encounter slots for the given encounter type in the
|
||||
# given encounter data (a GameData::Encounter instance), and edits them.
|
||||
def pbEncounterTypeEditor(enc_data, enc_type)
|
||||
commands = []
|
||||
list = pbListWindow([])
|
||||
help_window = Window_UnformattedTextPokemon.newWithSize(_INTL("Edit encounter slots"),
|
||||
Graphics.width / 2, 0, Graphics.width / 2, 96)
|
||||
help_window.z = 99999
|
||||
ret = 0
|
||||
need_refresh = true
|
||||
loop do
|
||||
if need_refresh
|
||||
commands.clear
|
||||
commands.push(_INTL("Step chance={1}", enc_data.step_chances[enc_type] || 0))
|
||||
commands.push(_INTL("Encounter type={1}", EncounterTypes::Names[enc_type]))
|
||||
if enc_data.types[enc_type] && enc_data.types[enc_type].length > 0
|
||||
enc_data.types[enc_type].each do |slot|
|
||||
commands.push(EncounterSlotProperty.format(slot))
|
||||
end
|
||||
end
|
||||
commands.push(_INTL("[Add new slot]"))
|
||||
need_refresh = false
|
||||
end
|
||||
ret = pbCommands2(list, commands, -1, ret)
|
||||
if ret == 0 # Edit step chance
|
||||
old_step_chance = enc_data.step_chances[enc_type] || 0
|
||||
new_step_chance = LimitProperty.new(180).set(_INTL("Step chance"), old_step_chance)
|
||||
if new_step_chance != old_step_chance
|
||||
enc_data.step_chances[enc_type] = new_step_chance
|
||||
need_refresh = true
|
||||
end
|
||||
elsif ret == 1 # Edit encounter type
|
||||
new_type_commands = []
|
||||
new_types = []
|
||||
chosen_type_cmd = 0
|
||||
EncounterTypes::Names.each_with_index do |type_name, i|
|
||||
next if enc_data.types[i] && i != enc_type
|
||||
new_type_commands.push(type_name)
|
||||
new_types.push(i)
|
||||
chosen_type_cmd = new_type_commands.length - 1 if i == enc_type
|
||||
end
|
||||
chosen_type_cmd = pbShowCommands(nil, new_type_commands, -1, chosen_type_cmd)
|
||||
if chosen_type_cmd >= 0 && new_types[chosen_type_cmd] != enc_type
|
||||
new_type = new_types[chosen_type_cmd]
|
||||
enc_data.step_chances[new_type] = enc_data.step_chances[enc_type]
|
||||
enc_data.step_chances[enc_type] = nil
|
||||
enc_data.types[new_type] = enc_data.types[enc_type]
|
||||
enc_data.types[enc_type] = nil
|
||||
enc_type = new_type
|
||||
need_refresh = true
|
||||
end
|
||||
elsif ret == commands.length - 1 # Add new encounter slot
|
||||
new_slot_data = EncounterSlotProperty.set(EncounterTypes::Names[enc_type], nil)
|
||||
if new_slot_data
|
||||
enc_data.types[enc_type].push(new_slot_data)
|
||||
need_refresh = true
|
||||
end
|
||||
elsif ret > 0 # Edit a slot
|
||||
case pbShowCommands(nil, [_INTL("Edit"), _INTL("Copy"), _INTL("Delete"), _INTL("Cancel")], 4)
|
||||
when 0 # Edit
|
||||
old_slot_data = enc_data.types[enc_type][ret - 2]
|
||||
new_slot_data = EncounterSlotProperty.set(EncounterTypes::Names[enc_type], old_slot_data.clone)
|
||||
if new_slot_data && new_slot_data != old_slot_data
|
||||
enc_data.types[enc_type][ret - 2] = new_slot_data
|
||||
need_refresh = true
|
||||
end
|
||||
when 1 # Copy
|
||||
enc_data.types[enc_type].insert(ret, enc_data.types[enc_type][ret - 2].clone)
|
||||
ret += 1
|
||||
need_refresh = true
|
||||
when 2 # Delete
|
||||
if pbConfirmMessage(_INTL("Delete this encounter slot?"))
|
||||
enc_data.types[enc_type][ret - 2] = nil
|
||||
enc_data.types[enc_type].compact!
|
||||
need_refresh = true
|
||||
end
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
list.dispose
|
||||
help_window.dispose
|
||||
Input.update
|
||||
end
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class UIntProperty
|
||||
def set(settingname,oldsetting)
|
||||
params = ChooseNumberParams.new
|
||||
params.setMaxDigits(@maxdigits)
|
||||
params.setDefaultValue(oldsetting||0)
|
||||
params.setDefaultValue(oldsetting || 0)
|
||||
return pbMessageChooseNumber(_INTL("Set the value for {1}.",settingname),params)
|
||||
end
|
||||
|
||||
@@ -278,6 +278,31 @@ end
|
||||
|
||||
|
||||
|
||||
module SpeciesFormProperty
|
||||
def self.set(_settingname,oldsetting)
|
||||
ret = pbChooseSpeciesFormList(oldsetting || nil)
|
||||
return ret || oldsetting
|
||||
end
|
||||
|
||||
def self.defaultValue
|
||||
return nil
|
||||
end
|
||||
|
||||
def self.format(value)
|
||||
if value && GameData::Species.exists?(value)
|
||||
species_data = GameData::Species.get(value)
|
||||
if species_data.form > 0
|
||||
return sprintf("%s_%d", species_data.real_name, species_data.form)
|
||||
else
|
||||
return species_data.real_name
|
||||
end
|
||||
end
|
||||
return "-"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
module TypeProperty
|
||||
def self.set(_settingname, oldsetting)
|
||||
ret = pbChooseTypeList(oldsetting || nil)
|
||||
@@ -1112,105 +1137,6 @@ end
|
||||
|
||||
|
||||
|
||||
module FormNamesProperty
|
||||
def self.set(_settingname,oldsetting)
|
||||
ret = oldsetting
|
||||
cmdwin = pbListWindow([],200)
|
||||
commands = []
|
||||
realcmds = []
|
||||
realcmds.push([_INTL("[ADD FORM]"),-1])
|
||||
for i in 0...oldsetting.length
|
||||
realcmds.push([oldsetting[i],i])
|
||||
end
|
||||
refreshlist = true; oldsel = -1
|
||||
cmd = [0,0]
|
||||
loop do
|
||||
if refreshlist
|
||||
realcmds.sort! { |a,b| a[1]<=>b[1] }
|
||||
commands = []
|
||||
for i in 0...realcmds.length
|
||||
text = (realcmds[i][1]>=0) ? sprintf("#{realcmds[i][1]} - #{realcmds[i][0]}") : realcmds[i][0]
|
||||
commands.push(text)
|
||||
cmd[1] = i if oldsel>=0 && realcmds[i][1]==oldsel
|
||||
end
|
||||
end
|
||||
refreshlist = false; oldsel = -1
|
||||
cmd = pbCommands3(cmdwin,commands,-1,cmd[1],true)
|
||||
if cmd[0]==1 # Swap name up
|
||||
if cmd[1]<realcmds.length-1 && realcmds[cmd[1]][1]>=0 && realcmds[cmd[1]+1][1]>=0
|
||||
realcmds[cmd[1]+1][1],realcmds[cmd[1]][1] = realcmds[cmd[1]][1],realcmds[cmd[1]+1][1]
|
||||
refreshlist = true
|
||||
end
|
||||
elsif cmd[0]==2 # Swap name down
|
||||
if cmd[1]>0 && realcmds[cmd[1]][1]>=0 && realcmds[cmd[1]-1][1]>=0
|
||||
realcmds[cmd[1]-1][1],realcmds[cmd[1]][1] = realcmds[cmd[1]][1],realcmds[cmd[1]-1][1]
|
||||
refreshlist = true
|
||||
end
|
||||
elsif cmd[0]==0
|
||||
if cmd[1]>=0
|
||||
entry = realcmds[cmd[1]]
|
||||
if entry[1]<0 # Add new form
|
||||
newname = pbMessageFreeText(_INTL("Choose a form name (no commas)."),"",false,250)
|
||||
if newname!=""
|
||||
realcmds.push([newname,realcmds.length-1])
|
||||
refreshlist = true
|
||||
end
|
||||
else # Edit form name
|
||||
cmd2 = pbMessage(_INTL("\\ts[]Do what with this form name?"),
|
||||
[_INTL("Rename"),_INTL("Delete"),_INTL("Cancel")],3)
|
||||
if cmd2==0
|
||||
newname = pbMessageFreeText(_INTL("Choose a form name (no commas)."),entry[0],false,250)
|
||||
if newname!=""
|
||||
realcmds[cmd[1]][0] = newname
|
||||
refreshlist = true
|
||||
end
|
||||
elsif cmd2==1
|
||||
realcmds[cmd[1]] = nil
|
||||
realcmds.compact!
|
||||
cmd[1] = [cmd[1],realcmds.length-1].min
|
||||
refreshlist = true
|
||||
end
|
||||
end
|
||||
else
|
||||
cmd2 = pbMessage(_INTL("Save changes?"),
|
||||
[_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3)
|
||||
if cmd2==0 || cmd2==1
|
||||
if cmd2==0
|
||||
for i in 0...realcmds.length
|
||||
if realcmds[i][1]<0
|
||||
realcmds[i] = nil
|
||||
else
|
||||
realcmds[i] = realcmds[i][0]
|
||||
end
|
||||
end
|
||||
realcmds.compact!
|
||||
ret = realcmds
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
cmdwin.dispose
|
||||
return ret
|
||||
end
|
||||
|
||||
def self.defaultValue
|
||||
return []
|
||||
end
|
||||
|
||||
def self.format(value)
|
||||
ret = ""
|
||||
for i in 0...value.length
|
||||
ret << "," if i>0
|
||||
ret << sprintf("#{value[i]}")
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class EvolutionsProperty
|
||||
def initialize
|
||||
@methods = []
|
||||
@@ -1464,29 +1390,69 @@ end
|
||||
|
||||
|
||||
|
||||
module EncounterSlotProperty
|
||||
def self.set(setting_name, data)
|
||||
max_level = PBExperience.maxLevel
|
||||
if !data
|
||||
data = [20, nil, 5, 5]
|
||||
GameData::Species.each do |species_data|
|
||||
data[1] = species_data.species
|
||||
break
|
||||
end
|
||||
end
|
||||
data[3] = data[2] if !data[3]
|
||||
properties = [
|
||||
[_INTL("Probability"), NonzeroLimitProperty.new(999), _INTL("Relative probability of choosing this slot.")],
|
||||
[_INTL("Species"), SpeciesFormProperty, _INTL("A Pokémon species/form.")],
|
||||
[_INTL("Minimum level"), NonzeroLimitProperty.new(max_level), _INTL("Minimum level of this species (1-{1}).", max_level)],
|
||||
[_INTL("Maximum level"), NonzeroLimitProperty.new(max_level), _INTL("Maximum level of this species (1-{1}).", max_level)]
|
||||
]
|
||||
pbPropertyList(setting_name, data, properties, false)
|
||||
if data[2] > data[3]
|
||||
data[3], data[2] = data[2], data[3]
|
||||
end
|
||||
return data
|
||||
end
|
||||
|
||||
def self.defaultValue
|
||||
return nil
|
||||
end
|
||||
|
||||
def self.format(value)
|
||||
return "-" if !value
|
||||
species_data = GameData::Species.get(value[1])
|
||||
if species_data.form > 0
|
||||
if value[2] == value[3]
|
||||
return sprintf("%d, %s_%d (Lv.%d)", value[0],
|
||||
species_data.real_name, species_data.form, value[2])
|
||||
end
|
||||
return sprintf("%d, %s_%d (Lv.%d-%d)", value[0],
|
||||
species_data.real_name, species_data.form, value[2], value[3])
|
||||
end
|
||||
if value[2] == value[3]
|
||||
return sprintf("%d, %s (Lv.%d)", value[0], species_data.real_name, value[2])
|
||||
end
|
||||
return sprintf("%d, %s (Lv.%d-%d)", value[0], species_data.real_name, value[2], value[3])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Core property editor script
|
||||
#===============================================================================
|
||||
def pbPropertyList(title,data,properties,saveprompt=false)
|
||||
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
viewport.z = 99999
|
||||
list = pbListWindow([],Graphics.width*5/10)
|
||||
list = pbListWindow([], Graphics.width / 2)
|
||||
list.viewport = viewport
|
||||
list.z = 2
|
||||
title = Window_UnformattedTextPokemon.new(title)
|
||||
title.x = list.width
|
||||
title.y = 0
|
||||
title.width = Graphics.width*5/10
|
||||
title.height = 64
|
||||
title.viewport = viewport
|
||||
title.z = 2
|
||||
desc = Window_UnformattedTextPokemon.new("")
|
||||
desc.x = list.width
|
||||
desc.y = title.height
|
||||
desc.width = Graphics.width*5/10
|
||||
desc.height = Graphics.height-title.height
|
||||
desc.viewport = viewport
|
||||
desc.z = 2
|
||||
title = Window_UnformattedTextPokemon.newWithSize(title,
|
||||
list.width, 0, Graphics.width / 2, 64, viewport)
|
||||
title.z = 2
|
||||
desc = Window_UnformattedTextPokemon.newWithSize("",
|
||||
list.width, title.height, Graphics.width / 2, Graphics.height - title.height, viewport)
|
||||
desc.z = 2
|
||||
selectedmap = -1
|
||||
retval = nil
|
||||
commands = []
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#===============================================================================
|
||||
# Core lister script
|
||||
#===============================================================================
|
||||
def pbListWindow(cmds,width=Graphics.width/2)
|
||||
list = Window_CommandPokemon.newWithSize(cmds,0,0,width,Graphics.height)
|
||||
def pbListWindow(cmds, width = Graphics.width / 2)
|
||||
list = Window_CommandPokemon.newWithSize(cmds, 0, 0, width, Graphics.height)
|
||||
list.index = 0
|
||||
list.rowHeight = 24
|
||||
pbSetSmallFont(list.contents)
|
||||
@@ -16,13 +16,9 @@ def pbListScreen(title,lister)
|
||||
list = pbListWindow([])
|
||||
list.viewport = viewport
|
||||
list.z = 2
|
||||
title = Window_UnformattedTextPokemon.new(title)
|
||||
title.x = Graphics.width/2
|
||||
title.y = 0
|
||||
title.width = Graphics.width-title.x
|
||||
title.height = 64
|
||||
title.viewport = viewport
|
||||
title.z = 2
|
||||
title = Window_UnformattedTextPokemon.newWithSize(title,
|
||||
Graphics.width / 2, 0, Graphics.width / 2, 64, viewport)
|
||||
title.z = 2
|
||||
lister.setViewport(viewport)
|
||||
selectedmap = -1
|
||||
commands = lister.commands
|
||||
@@ -62,18 +58,14 @@ def pbListScreen(title,lister)
|
||||
end
|
||||
|
||||
def pbListScreenBlock(title,lister)
|
||||
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
viewport.z = 99999
|
||||
list = pbListWindow([],Graphics.width/2)
|
||||
list = pbListWindow([], Graphics.width / 2)
|
||||
list.viewport = viewport
|
||||
list.z = 2
|
||||
title = Window_UnformattedTextPokemon.new(title)
|
||||
title.x = Graphics.width/2
|
||||
title.y = 0
|
||||
title.width = Graphics.width-title.x
|
||||
title.height = 64
|
||||
title.viewport = viewport
|
||||
title.z = 2
|
||||
title = Window_UnformattedTextPokemon.newWithSize(title,
|
||||
Graphics.width / 2, 0, Graphics.width - title.x, 64, viewport)
|
||||
title.z = 2
|
||||
lister.setViewport(viewport)
|
||||
selectedmap = -1
|
||||
commands = lister.commands
|
||||
|
||||
@@ -121,6 +121,15 @@ def pbChooseSpeciesList(default = nil)
|
||||
return pbChooseList(commands, default, nil, -1)
|
||||
end
|
||||
|
||||
def pbChooseSpeciesFormList(default = nil)
|
||||
commands = []
|
||||
GameData::Species.each do |s|
|
||||
name = (s.form == 0) ? s.real_name : sprintf("%s_%d", s.real_name, s.form)
|
||||
commands.push([s.id_number, name, s.id])
|
||||
end
|
||||
return pbChooseList(commands, default, nil, -1)
|
||||
end
|
||||
|
||||
# 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
|
||||
|
||||
@@ -335,7 +335,6 @@ class MapScreenScene
|
||||
@sprites["title"].viewport=@viewport
|
||||
@sprites["title"].z=2
|
||||
@mapinfos=load_data("Data/MapInfos.rxdata")
|
||||
@encdata=pbLoadEncountersData
|
||||
conns=MapFactoryHelper.getMapConnections
|
||||
@mapconns=[]
|
||||
for c in conns
|
||||
@@ -361,7 +360,6 @@ class MapScreenScene
|
||||
helptext+=_INTL("S: Go to another map\r\n")
|
||||
helptext+=_INTL("Click to select a map\r\n")
|
||||
helptext+=_INTL("Double-click: Edit map's metadata\r\n")
|
||||
helptext+=_INTL("E: Edit map's encounters\r\n")
|
||||
helptext+=_INTL("Drag map to move it\r\n")
|
||||
helptext+=_INTL("Arrow keys/drag canvas: Move around canvas")
|
||||
title=Window_UnformattedTextPokemon.new(helptext)
|
||||
@@ -556,8 +554,6 @@ class MapScreenScene
|
||||
@sprites["selsprite"].othersprite=nil
|
||||
@selmapid=-1
|
||||
end
|
||||
elsif Input.triggerex?("E"[0])
|
||||
pbEncounterEditorMap(@encdata,@selmapid) if @selmapid>=0
|
||||
elsif Input.trigger?(Input::F5)
|
||||
helpWindow
|
||||
end
|
||||
@@ -573,9 +569,8 @@ class MapScreenScene
|
||||
if pbConfirmMessage(_INTL("Save changes?"))
|
||||
serializeConnectionData
|
||||
MapFactoryHelper.clear
|
||||
save_data(@encdata,"Data/encounters.dat")
|
||||
$PokemonTemp.encountersData = nil
|
||||
Compiler.write_encounters
|
||||
else
|
||||
GameData.Encounter.load
|
||||
end
|
||||
break if pbConfirmMessage(_INTL("Exit from the editor?"))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user