- UID
- 38867
- 阅读权限
- 80
- 注册时间
- 2010-1-23
- 最后登录
- 2021-9-10
- 在线时间
- 311 小时
- 性别
- 男
- 生日
- 1988 年 11 月 2 日
国王
- 耕战
- 933
- 鹰币
- 4
- 天龙币
- 0
- 回帖
- 249
|
楼主 |
发表于 2013-9-4 00:45:47
|
显示全部楼层
正在编辑
本帖最后由 tankant 于 2013-9-8 21:19 编辑
根据野猪填的单位id对照表,我整理出自己能够看懂的表。
经过抽样测试,锁定几个变量不能定义到新id上:
my-unique-unit
my-elite-unique-unit
my-unique-unit-line
解决方案就是定义6个新变量:
my-unique-unit1
my-elite-unique-unit1
my-unique-unit-line1
my-unique-unit2
my-elite-unique-unit2
my-unique-unit-line2
#!/usr/bin/env python
import os,re
file_list=[]
def get_all_file(floder_path):
file_list=[]
if floder_path is None:
raise Exception("floder_path is None")
for dirpath, dirnames, filenames in os.walk(floder_path):
for name in filenames:
file_list.append(dirpath + '/' + name)
return file_list
file_list_result=get_all_file("/media/926bfa98-9eb6-414d-ab62-88b3fd1ba801/geli/HawKAoC/AI")
for i in file_list_result:
i=re.sub(r'\s+','\\ ',i)
stmt="sed -i 's/my-unique-unit-line/aort-my-unique-unit-line1/g' "+i
stmt2="sed -i 's/my-unique-unit/aort-my-unique-unit1/g' "+i
os.system(stmt)
os.system(stmt2)
对应每个民族的新特色兵种。
这样就应该把所有AOFE原来的变量名利用#load-if-define来定义my-unique-unit1等变量的值
然后替换原来的my-unique-unit-line等变量。
以my-unique-unit-line为例,运行自己写的查找脚本:
import os
def is_file_contain_word(file_list, query_word):
for _file in file_list:
if query_word in open(_file).read():
print _file
#os.system('notepad '+_file)
print("Finish searching.")
#www.orayes.com
def get_all_file(floder_path):
file_list = []
if floder_path is None:
#www.orayes.com
raise Exception("floder_path is None")
for dirpath, dirnames, filenames in os.walk(floder_path):
for name in filenames:
file_list.append(dirpath + '/' + name)
return file_list
#www.orayes.com
while 1:
query_word = raw_input("Please input the key word that you want to search:")
basedir = raw_input("Please input the directory:")
is_file_contain_word(get_all_file(basedir), query_word)
raw_input("Press Enter to quit.")
定位结果如下:
Please input the key word that you want to search:my-unique-unit-line
Please input the directory:.
./Principality.ai
./Principality.per
./Barbarian.per
./The Horde.per
./STD AI DM FIX/elite petersen deathmatch.per
./STD AI DM FIX/elite petersen full tech.per
./STD AI DM FIX/elite petersen supplement.per
./Barbarian_2.0/Castles.per
./Barbarian_2.0/RaidTheCamps.per
./Barbarian_2.0/MonksAndTrebs.per
./Barbarian_2.0/WallAndBoom.per
./Barbarian_2.0/HeavySkirms.per
./Barbarian_2.0/OnlyMeso.per
./Barbarian_2.0/WonderAssault.per
./Barbarian_2.0/DeathMatch.per
./Barbarian_2.0/TheGrowlOfTheJaguar.per
./Barbarian_2.0/Strategies/MONGOLBOOM.per
./Barbarian_2.0/Strategies/CASTLESLING.per
./Crusade 4.42/Army Selection.per
./tools/AORT的AI代码生成工具雏形/t/orayes.db3
./tools/附件/帝国时代2征服者AI脚本官方文档/1.0c官方文档数据整理/parameter/unit.csv
./tools/代码/t/orayes.db3
Finish searching.
Press Enter to quit.
绿色的都是带有my-unique-unit-line字样的文件,必须全部替换成my-unique-unit-line1和my-unique-unit-line2。由于一个关键词替换成2个,无法用批量替换脚本orayes.sh。这时候必须手动翻看这些文件然后一一处理。
原来不需要的单位也应该替换成新单位:
包含诸葛弩的文件:
Please input the key word that you want to search:chu-ko-nu
Please input the directory:.
./Barbarian.per
./The Horde.per
./STD AI DM FIX/elite petersen upgrades.per
./STD AI DM FIX/elite petersen deathmatch.per
./STD AI DM FIX/elite petersen supplement.per
./STD AI DM FIX/elite wonder kill.per
./Barbarian_2.0/SuicidalKnightRush.per
./Barbarian_2.0/MonksAndTrebs.per
./Barbarian_2.0/Strategies1v1.per
./Barbarian_2.0/StrategiesTG.per
./Barbarian_2.0/DeathMatch.per
./Barbarian_2.0/TheGrowlOfTheJaguar.per
./Barbarian_2.0/Strategies/WarGalleys.per
./Crusade 4.42/Unit Training.per
./Crusade 4.42/Main Upgrades.per
./Crusade 4.42/Threat rules.per
./tools/AORT的AI代码生成工具雏形/t/orayes.db3
./tools/附件/帝国时代2征服者AI脚本官方文档/1.0c官方文档数据整理/parameter/unit.csv
./tools/附件/帝国时代2征服者AI脚本官方文档/1.0c官方文档数据整理/parameter/research_item.csv
./tools/代码/t/orayes.db3
Finish searching.
Press Enter to quit.
批量替换诸葛弩为陌刀兵的脚本:
#!/usr/bin/env python
import os,re
file_list=[]
def get_all_file(floder_path):
file_list=[]
if floder_path is None:
raise Exception("floder_path is None")
for dirpath, dirnames, filenames in os.walk(floder_path):
for name in filenames:
file_list.append(dirpath + '/' + name)
return file_list
file_list_result=get_all_file("/media/926bfa98-9eb6-414d-ab62-88b3fd1ba801/HawKAoC/AI")
for i in file_list_result:
i=re.sub(r'\s+','\\ ',i)
stmt="sed -i 's/chu-ko-nu/modaobing/g' "+i
os.system(stmt)
运行成功,再次运行搜索脚本,结果如下
Please input the key word that you want to search:chu-ko-nu
Please input the directory:.
./empires2.EXE
./Data/gamedata_x1.drs
./Data/gamedata.drs
./age2_x1a/age2_x1.exe
./age2_x1/age2_x1.exe_bak
./age2_x1/aom.exe
./age2_x1/age2_x1.exe.setupaoc.backup
./age2_x1/age2_x1.exe
Finish searching.
Press Enter to quit.
发现确实诸葛弩chu-ko-nu确实都替换掉了。顺便发现,嵌入AI的drs文件应该在./Data/gamedata_x1.drs或者./Data/gamedata.drs里面。
以下是已经包含陌刀兵modaobing的文件:
Please input the key word that you want to search:modaobing
Please input the directory:.
./AI/Barbarian.per
./AI/The Horde.per
./AI/STD AI DM FIX/elite petersen upgrades.per
./AI/STD AI DM FIX/elite petersen deathmatch.per
./AI/STD AI DM FIX/elite petersen supplement.per
./AI/STD AI DM FIX/elite wonder kill.per
./AI/Barbarian_2.0/SuicidalKnightRush.per
./AI/Barbarian_2.0/MonksAndTrebs.per
./AI/Barbarian_2.0/Strategies1v1.per
./AI/Barbarian_2.0/StrategiesTG.per
./AI/Barbarian_2.0/DeathMatch.per
./AI/Barbarian_2.0/TheGrowlOfTheJaguar.per
./AI/Barbarian_2.0/Strategies/WarGalleys.per
./AI/Crusade 4.42/Unit Training.per
./AI/Crusade 4.42/Main Upgrades.per
./AI/Crusade 4.42/Threat rules.per
Finish searching.
Press Enter to quit.
我们可以重点研究这些文件
突然发现自己总结的文档也被替换掉了,必须手动修改这些文档然后转移。
以./AI/Barbarian.per为例,
vim ./AI/Barbarian.per:
/modaobing
yypn:s/modaobing/gongjveweidui/g
pn:s/modaobing/sakesunchangqiangbing/g
pn:s/modaobing/beiouchangfubing/g
pn:s/modaobing/buluozhanshi/g
pn:s/modaobing/silafuyongshi/g
pn:s/modaobing/kehanweidui/g
pn:s/modaobing/toumaoqibing/g
pn:s/modaobing/liudima/g
pn:s/modaobing/lunbadenushou/g
pn
:s/modaobing/yinduxiangshe/g
pn
:s/modaobing/gaomianjianuzhanxiang/g
pn
:s/modaobing/hualangsheshou/g
pn
:s/modaobing/falankeqibing/g
pn
:s/modaobing/sashanqibing/g
pn
:s/modaobing/gaoyuanqibing/g
pn
:s/modaobing/subiqibing/g
pn
:s/modaobing/jinlangtuqi/g
pn
:s/modaobing/xuanjiaqibing/g
下一处modaobing的地方就很难批量修改,必须手动改:
#load-if-defined CHINESE-CIV
(defrule
(up-compare-goal gl-current-age >= gv-feudal-up)
(unit-type-count-total modaobing-line > 12)
(strategic-number sn-allow-resource-spending > 2)
(building-type-count-total archery-range < 1)
(can-build archery-range)
=>
(build archery-range)
)
#end-if
很显然,这个rule应该把所有archery-range换成barrack:
n/archery-range
:s/archery-range/barrack/g
n:s/archery-range/barrack/g
n:s/archery-range/barrack/g
脚本发展成:
vim ./AI/Barbarian.per<<EOF
:%s/teutonic-knight/gongjveweidui/g
:%s/jaguar-warrior/war-elephant/g
:%s/chu-ko-nu/modaobing/g
gg/modaobing
yypn:s/modaobing/sakesunchangqiangbing/g
pn:s/modaobing/beiouchangfubing/g
pn:s/modaobing/buluozhanshi/g
pn:s/modaobing/silafuyongshi/g
pn:s/modaobing/toumaoqibing/g
pn:s/modaobing/liudima/g
pn:s/modaobing/lunbadenushou/g
pn:s/modaobing/yinduxiangshe/g
pn:s/modaobing/gaomianjianuzhanxiang/g
pn:s/modaobing/hualangsheshou/g
pn:s/modaobing/falankeqibing/g
pn:s/modaobing/sashanqibing/g
pn:s/modaobing/subiqibing/g
pn:s/modaobing/jinlangtuqi/g
pn:s/modaobing/xuanjiaqibing/g
/#load-if-defined CHINESE-CIV
/modaobing
/archery-range
:s/archery-range/barrack/g
n:s/archery-range/barrack/g
n:s/archery-range/barrack/g
/modaobing
/ri-fletching
:s/ri-fletching/forging/g
/ri-bodkin-arrow
:s/ri-bodkin-arrow/ri-iron-casting/g
/ri-bracer
:s/ri-bracer/ri-blast-furnace/g
/modaobing
/ri-fletching
:s/ri-fletching/forging/g
/ri-bodkin-arrow
:s/ri-bodkin-arrow/ri-iron-casting/g
/ri-bracer
:s/ri-bracer/ri-blast-furnace/g
/ri-fletching
:s/ri-fletching/forging/g
/ri-bodkin-arrow
:s/ri-bodkin-arrow/ri-iron-casting/g
/ri-bracer
:s/ri-bracer/ri-blast-furnace/g
/modaobing
/ri-chemistry
:s/ri-chemistry/1070/g
/ri-padded-archer-armor
:s/ri-padded-archer-armor/ri-scale-mail/g
/ri-leather-archer-armor
:s/ri-leather-archer-armor/ri-chain-mail/g
/ri-ring-archer-armor
:s/ri-ring-archer-armor/ri-plate-mail/g
/ri-chemistry
:s/ri-chemistry/1070/g
/ri-padded-archer-armor
:s/ri-padded-archer-armor/ri-scale-mail/g
/ri-leather-archer-armor
:s/ri-leather-archer-armor/ri-chain-mail/g
/ri-ring-archer-armor
:s/ri-ring-archer-armor/ri-plate-mail/g
/modaobing
/ri-ballistics
:s/ri-ballistics/ri-squires/g
/ri-thumb-ring
:s/ri-thumb-ring/ri-tracking/g
/ri-ballistics
:s/ri-ballistics/ri-squires/g
/ri-thumb-ring
:s/ri-thumb-ring/ri-tracking/g
:x
EOF
以下是除了诸葛弩之外的6个不用了的特种兵,马上除去还是最后统一除去待定。
conquistador
jaguar-warrior
janisarry
mangudai
teutonic-knight
woad-raider
打算这样搞:
:%s/teutonic-knight/gongjveweidui/g
:%s/jaguar-warrior/war-elephant/g
:s/conquistador/war-elephant/g
需要修改建筑:
:s/archery-range/stable
:s/mangudai/gaoyuanqibing/g
需要修改建筑
:s/archery-range/stable
:s/janisarry/kehanweidui/g
需要修改建筑
:s/barrack/stable
:s/woad-raider/war-elephant/g
需要修改建筑
:s/barrack/stable
以下四个新单位考虑到其特殊性,以后再安排位置。
gongchengta
yuntiche
yunbingmache
jiangjun
继续找modaobing
/modaobing
|
|