mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Created and implemented GameData::TrainerType, fixed free text entry text mispositioning
This commit is contained in:
@@ -311,7 +311,7 @@ module Compiler
|
||||
end
|
||||
return enumer.const_get(ret.to_sym)
|
||||
elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
|
||||
if [:Ability, :Item, :Move].include?(enumer)
|
||||
if [:Ability, :Item, :Move, :TrainerType].include?(enumer)
|
||||
enumer = GameData.const_get(enumer.to_sym)
|
||||
begin
|
||||
if ret == "" || !enumer.exists?(ret.to_sym)
|
||||
@@ -353,7 +353,7 @@ module Compiler
|
||||
return nil if ret=="" || !(enumer.const_defined?(ret) rescue false)
|
||||
return enumer.const_get(ret.to_sym)
|
||||
elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
|
||||
if [:Ability, :Item, :Move].include?(enumer)
|
||||
if [:Ability, :Item, :Move, :TrainerType].include?(enumer)
|
||||
enumer = GameData.const_get(enumer.to_sym)
|
||||
return nil if ret == "" || !enumer.exists?(ret.to_sym)
|
||||
return ret.to_sym
|
||||
@@ -568,7 +568,7 @@ module Compiler
|
||||
clonitem.sub!(/\s*$/,"")
|
||||
itm = GameData::Item.try_get(clonitem)
|
||||
if !itm
|
||||
raise _INTL("Undefined item constant name: %s\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the item is defined in\r\nPBS/items.txt.\r\n{1}", item, FileLineData.linereport)
|
||||
raise _INTL("Undefined item constant name: {1}\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the item is defined in\r\nPBS/items.txt.\r\n{2}", item, FileLineData.linereport)
|
||||
end
|
||||
return itm.id.to_s
|
||||
end
|
||||
@@ -589,7 +589,7 @@ module Compiler
|
||||
mov = GameData::Move.try_get(clonmove)
|
||||
if !mov
|
||||
return nil if skip_unknown
|
||||
raise _INTL("Undefined move constant name: %s\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the move is defined in\r\nPBS/moves.txt.\r\n{1}", move, FileLineData.linereport)
|
||||
raise _INTL("Undefined move constant name: {1}\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the move is defined in\r\nPBS/moves.txt.\r\n{2}", move, FileLineData.linereport)
|
||||
end
|
||||
return mov.id.to_s
|
||||
end
|
||||
@@ -603,11 +603,15 @@ module Compiler
|
||||
end
|
||||
|
||||
# Unused
|
||||
def parseTrainer(item)
|
||||
clonitem = item.clone
|
||||
clonitem.sub!(/^\s*/,"")
|
||||
clonitem.sub!(/\s*$/,"")
|
||||
return pbGetConst(PBTrainers,clonitem,_INTL("Undefined Trainer constant name: %s\r\nName must consist only of letters, numbers, and\r\nunderscores and can't begin with a number.\r\nIn addition, the name must be defined\r\nin trainertypes.txt.\r\n{1}",FileLineData.linereport))
|
||||
def parseTrainer(type)
|
||||
clontype = type.clone
|
||||
clontype.sub!(/^\s*/, "")
|
||||
clontype.sub!(/\s*$/, "")
|
||||
typ = GameData::TrainerType.try_get(clontype)
|
||||
if !typ
|
||||
raise _INTL("Undefined Trainer type constant name: {1}\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the trainer type is defined in\r\ntrainertypes.txt.\r\n{2}", type, FileLineData.linereport)
|
||||
end
|
||||
return typ.id.to_s
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -644,11 +648,11 @@ module Compiler
|
||||
yield(_INTL("Compiling Trainer data"))
|
||||
compile_trainers # Depends on PBSpecies, Item, Move
|
||||
yield(_INTL("Compiling phone data"))
|
||||
compile_phone # Depends on PBTrainers
|
||||
compile_phone
|
||||
yield(_INTL("Compiling metadata"))
|
||||
compile_metadata # Depends on PBTrainers
|
||||
compile_metadata # Depends on TrainerType
|
||||
yield(_INTL("Compiling battle Trainer data"))
|
||||
compile_trainer_lists # Depends on PBTrainers
|
||||
compile_trainer_lists # Depends on TrainerType
|
||||
yield(_INTL("Compiling encounter data"))
|
||||
compile_encounters # Depends on PBSpecies
|
||||
yield(_INTL("Compiling shadow moveset data"))
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
class PBTrainers; end
|
||||
|
||||
module Compiler
|
||||
module_function
|
||||
|
||||
@@ -1220,42 +1218,45 @@ module Compiler
|
||||
# Compile trainer types
|
||||
#=============================================================================
|
||||
def compile_trainer_types
|
||||
records = []
|
||||
trainernames = []
|
||||
maxValue = 0
|
||||
pbCompilerEachPreppedLine("PBS/trainertypes.txt") { |line,lineno|
|
||||
record=pbGetCsvRecord(line,lineno,[0,"unsUSSSeUS", # ID can be 0
|
||||
nil,nil,nil,nil,nil,nil,nil,{
|
||||
"" => 2,
|
||||
"Male" => 0,"M" => 0,"0" => 0,
|
||||
"Female" => 1,"F" => 1,"1" => 1,
|
||||
"Mixed" => 2,"X" => 2,"2" => 2
|
||||
},nil,nil]
|
||||
GameData::TrainerType::DATA.clear
|
||||
tr_type_names = []
|
||||
# Read each line of trainertypes.txt at a time and compile it into a trainer type
|
||||
pbCompilerEachCommentedLine("PBS/trainertypes.txt") { |line, line_no|
|
||||
line = pbGetCsvRecord(line, line_no, [0, "unsUSSSeUS",
|
||||
nil, nil, nil, nil, nil, nil, nil, {
|
||||
"Male" => 0, "M" => 0, "0" => 0,
|
||||
"Female" => 1, "F" => 1, "1" => 1,
|
||||
"Mixed" => 2, "X" => 2, "2" => 2, "" => 2
|
||||
}, nil, nil]
|
||||
)
|
||||
if records[record[0]]
|
||||
raise _INTL("Two trainer types ({1} and {2}) have the same ID ({3}), which is not allowed.\r\n{4}",
|
||||
records[record[0]][1],record[1],record[0],FileLineData.linereport)
|
||||
type_number = line[0]
|
||||
type_symbol = line[1].to_sym
|
||||
if GameData::TrainerType::DATA[type_number]
|
||||
raise _INTL("Trainer type ID number '{1}' is used twice.\r\n{2}", type_number, FileLineData.linereport)
|
||||
elsif GameData::TrainerType::DATA[type_symbol]
|
||||
raise _INTL("Trainer type ID '{1}' is used twice.\r\n{2}", type_symbol, FileLineData.linereport)
|
||||
end
|
||||
trainernames[record[0]] = record[2]
|
||||
records[record[0]] = record
|
||||
maxValue = [maxValue,record[0]].max
|
||||
# Construct trainer type hash
|
||||
type_hash = {
|
||||
:id_number => type_number,
|
||||
:id => type_symbol,
|
||||
:name => line[2],
|
||||
:base_money => line[3],
|
||||
:battle_BGM => line[4],
|
||||
:victory_ME => line[5],
|
||||
:intro_ME => line[6],
|
||||
:gender => line[7],
|
||||
:skill_level => line[8],
|
||||
:skill_code => line[9]
|
||||
}
|
||||
# Add trainer type's data to records
|
||||
GameData::TrainerType::DATA[type_number] = GameData::TrainerType::DATA[type_symbol] = GameData::TrainerType.new(type_hash)
|
||||
tr_type_names[type_number] = type_hash[:name]
|
||||
}
|
||||
count = records.compact.length
|
||||
MessageTypes.setMessages(MessageTypes::TrainerTypes,trainernames)
|
||||
code = "class PBTrainers\r\n"
|
||||
for rec in records
|
||||
next if !rec
|
||||
code += "#{rec[1]}=#{rec[0]}\r\n"
|
||||
end
|
||||
code += "def self.getName(id)\r\n"
|
||||
code += "id=getID(PBTrainers,id)\r\n"
|
||||
code += "return pbGetMessage(MessageTypes::TrainerTypes,id); end\r\n"
|
||||
code += "def self.getCount; return #{count}; end\r\n"
|
||||
code += "def self.maxValue; return #{maxValue}; end\r\n"
|
||||
code += "end\r\n"
|
||||
eval(code, TOPLEVEL_BINDING)
|
||||
pbAddScript(code,"PBTrainers")
|
||||
save_data(records,"Data/trainer_types.dat")
|
||||
# Save all data
|
||||
GameData::TrainerType.save
|
||||
MessageTypes.setMessages(MessageTypes::TrainerTypes, tr_type_names)
|
||||
Graphics.update
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -1280,7 +1281,7 @@ module Compiler
|
||||
if pokemonindex==-1
|
||||
raise _INTL("Started new trainer while previous trainer has no Pokémon.\r\n{1}",FileLineData.linereport)
|
||||
end
|
||||
section = pbGetCsvRecord($~[1],lineno,[0,"esU",PBTrainers])
|
||||
section = pbGetCsvRecord($~[1],lineno,[0,"esU",:TrainerType])
|
||||
trainerindex += 1
|
||||
trainertype = section[0]
|
||||
trainername = section[1]
|
||||
@@ -1378,7 +1379,7 @@ module Compiler
|
||||
oldcompilerline += 1
|
||||
case oldcompilerline
|
||||
when 1 # Trainer type
|
||||
record = pbGetCsvRecord(line,lineno,[0,"e",PBTrainers])
|
||||
record = pbGetCsvRecord(line,lineno,[0,"e",:TrainerType])
|
||||
trainers[trainerindex][0] = record
|
||||
when 2 # Trainer name, version number
|
||||
record = pbGetCsvRecord(line,lineno,[0,"sU"])
|
||||
@@ -1462,7 +1463,7 @@ module Compiler
|
||||
def compile_battle_tower_trainers(filename)
|
||||
sections = []
|
||||
requiredtypes = {
|
||||
"Type" => [0, "e",PBTrainers],
|
||||
"Type" => [0, "e", :TrainerType],
|
||||
"Name" => [1, "s"],
|
||||
"BeginSpeech" => [2, "s"],
|
||||
"EndSpeechWin" => [3, "s"],
|
||||
|
||||
@@ -385,55 +385,37 @@ module Compiler
|
||||
class TrainerChecker
|
||||
def initialize
|
||||
@trainers = nil
|
||||
@trainertypes = nil
|
||||
@dontaskagain = false
|
||||
end
|
||||
|
||||
def pbTrainerTypeCheck(symbol)
|
||||
ret = true
|
||||
if $DEBUG
|
||||
return if @dontaskagain
|
||||
if !hasConst?(PBTrainers,symbol)
|
||||
ret = false
|
||||
else
|
||||
trtype = PBTrainers.const_get(symbol)
|
||||
@trainertypes = load_data("Data/trainer_types.dat") if !@trainertypes
|
||||
ret = false if !@trainertypes || !@trainertypes[trtype]
|
||||
end
|
||||
if !ret
|
||||
if pbConfirmMessage(_INTL("Add new trainer named {1}?",symbol))
|
||||
pbTrainerTypeEditorNew(symbol.to_s)
|
||||
@trainers = nil
|
||||
@trainertypes = nil
|
||||
end
|
||||
# if pbMapInterpreter
|
||||
# pbMapInterpreter.command_end rescue nil
|
||||
# end
|
||||
end
|
||||
def pbTrainerTypeCheck(trainer_type)
|
||||
return if !$DEBUG || @dontaskagain
|
||||
return if GameData::TrainerType.exists?(trainer_type)
|
||||
if pbConfirmMessage(_INTL("Add new trainer type {1}?", trainer_type.to_s))
|
||||
pbTrainerTypeEditorNew(trainer_type.to_s)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbTrainerBattleCheck(trtype,trname,trid)
|
||||
def pbTrainerBattleCheck(tr_type, tr_name, tr_id)
|
||||
return if !$DEBUG || @dontaskagain
|
||||
if trtype.is_a?(String) || trtype.is_a?(Symbol)
|
||||
pbTrainerTypeCheck(trtype)
|
||||
return if !hasConst?(PBTrainers,trtype)
|
||||
trtype = PBTrainers.const_get(trtype)
|
||||
end
|
||||
# Check for existence of trainer type
|
||||
pbTrainerTypeCheck(tr_type)
|
||||
return if !GameData::TrainerType.exists?(tr_type)
|
||||
tr_type = GameData::TrainerType.get(tr_type).id
|
||||
# Check for existence of trainer
|
||||
@trainers = load_data("Data/trainers.dat") if !@trainers
|
||||
if @trainers
|
||||
for trainer in @trainers
|
||||
return if trainer[0]==trtype && trainer[1]==trname && trainer[4]==trid
|
||||
return if trainer[0]==tr_type && trainer[1]==tr_name && trainer[4]==tr_id
|
||||
end
|
||||
end
|
||||
cmd = pbMissingTrainer(trtype,trname,trid)
|
||||
# Add new trainer
|
||||
cmd = pbMissingTrainer(tr_type,tr_name,tr_id)
|
||||
if cmd==2
|
||||
@dontaskagain = true
|
||||
Graphics.update
|
||||
end
|
||||
@trainers = nil
|
||||
@trainertypes = nil
|
||||
@trainers = nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -539,8 +521,8 @@ module Compiler
|
||||
trainerChecker.pbTrainerBattleCheck(trtype,trname,battleid) if !$INEDITOR
|
||||
# Set the event's charset to one depending on the trainer type if the event
|
||||
# doesn't have a charset
|
||||
if firstpage.graphic.character_name=="" && hasConst?(PBTrainers,trtype)
|
||||
trainerid = getConst(PBTrainers,trtype)
|
||||
if firstpage.graphic.character_name=="" && GameData::TrainerType.exists?(trtype)
|
||||
trainerid = GameData::TrainerType.get(trtype).id
|
||||
if trainerid
|
||||
filename = pbTrainerCharNameFile(trainerid)
|
||||
if FileTest.image_exist?("Graphics/Characters/"+filename)
|
||||
|
||||
Reference in New Issue
Block a user