# PG::output_enemies
# PG::run_enemy
=begin
==============使用方法=======================
1. 执行事件脚本 PG::output_enemies
2. 导出文本之后部分说明部分的转行符需要手动删除
3. 将文本内容粘贴到excel之中,执行数据>分列,分割标志为|
4. 编辑数据,其中特征、习得技能、效果、掉落物、敌人行动
等格式为数组的数据无法直接从表格导入
5. 表格编辑完成之后保存成csv格式,再用记事本另存为utf-8编码(否则无法读取中文)
6.执行事件脚本 PG::run_enemy
7.关掉编辑器再打开,数据库里的数据就弄好了
=end
module PG
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def self.output_enemies
ret = ""
$data = load_data("Data/Enemies.rvdata2")
ret += "id"
ret += "|"+ "name"
ret += "|"+ "battler_name"
ret += "|"+ "battler_hue"
ret += "|"+ "params[0]"
ret += "|"+ "params[1]"
ret += "|"+ "params[2]"
ret += "|"+ "params[3]"
ret += "|"+ "params[4]"
ret += "|"+ "params[5]"
ret += "|"+ "params[6]"
ret += "|"+ "params[7]"
ret += "|"+ "exp"
ret += "|"+ "gold"
ret += "|"+ "drop_items"
ret += "|"+ "actions"
ret += "|"+ "features"
for i in 1..$data.size
break if $data[i] == nil
ret += "\n" + $data[i].id.to_s
ret += "|"+ $data[i].name
ret += "|"+ $data[i].battler_name
ret += "|"+ $data[i].battler_hue.to_s
ret += "|"+ $data[i].params[0].to_s
ret += "|"+ $data[i].params[1].to_s
ret += "|"+ $data[i].params[2].to_s
ret += "|"+ $data[i].params[3].to_s
ret += "|"+ $data[i].params[4].to_s
ret += "|"+ $data[i].params[5].to_s
ret += "|"+ $data[i].params[6].to_s
ret += "|"+ $data[i].params[7].to_s
ret += "|"+ $data[i].exp.to_s
ret += "|"+ $data[i].gold.to_s
ret += "|["
if $data[i].drop_items.size>0
for j in 0...$data[i].drop_items.size
ret += "["+ $data[i].drop_items[j].kind.to_s
ret += ","+ $data[i].drop_items[j].data_id.to_s
ret += ","+ $data[i].drop_items[j].denominator.to_s
ret += "],"
end
end
ret += "],"
ret += "|["
if $data[i].actions.size>0
for j in 0...$data[i].actions.size
ret += "["+ $data[i].actions[j].skill_id.to_s
ret += ","+ $data[i].actions[j].condition_type.to_s
ret += ","+ $data[i].actions[j].condition_param1.to_s
ret += ","+ $data[i].actions[j].condition_param2.to_s
ret += ","+ $data[i].actions[j].rating.to_s
ret += "],"
end
end
ret += "],"
ret += "|["
if $data[i].features.size>0
for j in 0...$data[i].features.size
ret += "["+ $data[i].features[j].code.to_s
ret += ","+ $data[i].features[j].data_id.to_s
ret += ","+ $data[i].features[j].value.to_s
ret += "],"
end
end
ret += "],"
end
File.open("Enemies.txt", 'w') { |file| file.write(ret) }
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def self.run_enemy
$data = load_data("Data/Enemies.rvdata2")
File.open("Enemies.csv", 'r') {|f|
@inFile = f
line = read_line
while !@inFile.eof?
line = read_line
i = line[0].to_i
$data << RPG::Enemy.new if $data[i] == nil
$data[i].name = line[1]
$data[i].battler_name = line[2]
$data[i].battler_hue = line[3].to_i
$data[i].params[0] = line[4].to_i
$data[i].params[1] = line[5].to_i
$data[i].params[2] = line[6].to_i
$data[i].params[3] = line[7].to_i
$data[i].params[4] = line[8].to_i
$data[i].params[5] = line[9].to_i
$data[i].params[6] = line[10].to_i
$data[i].params[7] = line[11].to_i
$data[i].exp = line[12].to_i
$data[i].gold = line[13].to_i
end
}
save_data($data, "Data/Enemies.rvdata2")
SceneManager::exit
end
end