收起左侧

[交流] 解决判断单位数量前置科技BUG方法

[复制链接]
こはね发表于 2021-2-12 18:55:42
一个悲惨的消息,因为当时编写圣典,没有测试清楚,现在已经坑害他人两年。注:被坑人数=0

坑人的教程为12-6神话时代科技条件中判断单位数量的前置条件写错,gte解释成了等于,实测为大于等于,现已修复网页版,至于软件,懒得管了

其实我今天是来解决判断单位数量BUG的,然后无意中发现gte写错了,顺带测试了lte、eq与neq,最终测试结果如下:
<typecount unit="A" count="X.00" state="noneState aliveState buildingState" operator="lt"/>当单位A数量<X时开启本科技
<typecount unit="A" count="X.00" state="noneState aliveState buildingState" operator="lte"/>当单位A数量<=X时开启本科技
<typecount unit="A" count="X.00" state="noneState aliveState buildingState" operator="gte"/>当单位A数量>=X时开启本科技
<typecount unit="A" count="X.00" state="noneState aliveState buildingState" operator="gt"/>当单位A数量>X时开启本科技
<typecount unit="A" count="X.00" state="noneState aliveState buildingState" operator="eq"/>当单位A数量=X时开启本科技
<typecount unit="A" count="X.00" state="noneState aliveState buildingState" operator="neq"/>当单位A数量=X时开启本科技,备注:经过实际测试,neq在帝国3里面的确为等于,而不是不等于。

错误版本与正确版本对比:
原教程

解决判断单位数量前置科技BUG方法

解决判断单位数量前置科技BUG方法

解决判断单位数量前置科技BUG方法

解决判断单位数量前置科技BUG方法

已修复的网页版

解决判断单位数量前置科技BUG方法

解决判断单位数量前置科技BUG方法

解决判断单位数量前置科技BUG方法

解决判断单位数量前置科技BUG方法

回到正题,判断单位数量的BUG在圣典已经解释过,自己训练的单位要改良任意一个科技或建造支持人口的建筑才能刷新显示科技,而旗军、剧情编辑器放置的单位不受影响(tactics生产的单位未测,估计spawn不受影响,而Maintain会受影响,tactics只是估计,没有经过实测,请勿当真)。下面来构思解决方法,大概有以下两种种

1.无限研究科技
2.无限利用tactics生成人口数量单位

第1种方法已经实现了
初步构思为 科技A禁用科技A并启用科技B,科技B启用科技A并禁用科技B,两个科技均为0秒科技会自动研发;
<Tech name="LoopTech1" type="Normal">
<DBID>5290</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>OBTAINABLE</Status>
<Icon>ui\units\ironclad_icon</Icon>
<Flag>YPInfiniteTech</Flag>
<Effects>
<Effect type ='TechStatus' status ='unobtainable'>LoopTech1</Effect>
<Effect type ='TechStatus' status ='obtainable'>LoopTech2</Effect>
<Effect type ='TextOutput'>00028</Effect>
<Effect type ="TextOutputAll">00028</Effect>
</Effects>
</Tech>
<Tech name="LoopTech2" type="Normal">
<DBID>5290</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>OBTAINABLE</Status>
<Icon>ui\units\ironclad_icon</Icon>
<Flag>YPInfiniteTech</Flag>
<Effects>
<Effect type ='TechStatus' status ='unobtainable'>LoopTech2</Effect>
<Effect type ='TechStatus' status ='obtainable'>LoopTech1</Effect>
<Effect type ='TextOutput'>00029</Effect>
<Effect type ="TextOutputAll">00029</Effect>
</Effects>
</Tech>



TextOutput是用来输出stringtabley文字的,方便查看结果
<String _locID="00028">Loop Tech1.</String>
<String _locID="00029">Loop Tech2.</String>

实测结果,只运行了6次,停止运行,失败告终。得出结论为0秒科技也是有限制的,同一科技自动研发不会超过3次(至于这个结论是否正确,请自行研究)。

后面我想到了有一个<Flag>Volatile</Flag>会自动改良科技,然后给两个科技都添加上就成功了

<Tech name="LoopTech1" type="Normal">
<DBID>5290</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>OBTAINABLE</Status>
<Icon>ui\units\ironclad_icon</Icon>
<Flag>Volatile</Flag>
<Flag>YPInfiniteTech</Flag>
<Effects>
<Effect type ='TechStatus' status ='unobtainable'>LoopTech1</Effect>
<Effect type ='TechStatus' status ='obtainable'>LoopTech2</Effect>
<Effect type ='TextOutput'>00028</Effect>
<Effect type ="TextOutputAll">00028</Effect>
</Effects>
</Tech>
<Tech name="LoopTech2" type="Normal">
<DBID>5290</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>OBTAINABLE</Status>
<Icon>ui\units\ironclad_icon</Icon>
<Flag>YPInfiniteTech</Flag>
<Flag>Volatile</Flag>
<Effects>
<Effect type ='TechStatus' status ='unobtainable'>LoopTech2</Effect>
<Effect type ='TechStatus' status ='obtainable'>LoopTech1</Effect>
<Effect type ='TextOutput'>00029</Effect>
<Effect type ="TextOutputAll">00029</Effect>
</Effects>
</Tech>



实测结果:

解决判断单位数量前置科技BUG方法

解决判断单位数量前置科技BUG方法

上面的两个可能有点消耗内存,我又把科技改成了一个科技,自己禁用自己,再启用自己
<Tech name="LoopTech" type="Normal">
<DBID>5290</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>OBTAINABLE</Status>
<Icon>ui\units\ironclad_icon</Icon>
<Flag>Volatile</Flag>
<Flag>YPInfiniteTech</Flag>
<Effects>
<Effect type ='TechStatus' status ='unobtainable'>LoopTech</Effect>
<Effect type ='TechStatus' status ='obtainable'>LoopTech</Effect>
<Effect type ='TextOutput'>00028</Effect>
<Effect type ="TextOutputAll">00028</Effect>
</Effects>
</Tech>
实测结果:16分钟研究48万次?有点怕低配置电脑不能运行起来

解决判断单位数量前置科技BUG方法

解决判断单位数量前置科技BUG方法


然后又过了5个小时,又发现<Flag>Volatile</Flag>的一个特性,如果使用<Effect type ='TechStatus' status ='unobtainable'>xxxx</Effect>对带<Flag>Volatile</Flag>的科技使用后,那么并不会关闭科技,而是重新激活一次,如果使用<Effect type ='TechStatus' status ='obtainable'>xxxx</Effect>则只能在未启用状态下(<Status>OBTAINABLE</Status>)激活一次,自动改良后无法再次激活。也就是说,上面的思路虽然没错,但也只是误打误撞成功让<Flag>Volatile</Flag>自动改良而已。
至于为什么用两个科技比一个科技卡顿也解释的通了,因为两个科技在无限运行。。。
那么重新整理一下最终语句
<Tech name="LoopTech" type="Normal">
<DBID>5290</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>OBTAINABLE</Status>
<Flag>Volatile</Flag>
<Flag>YPInfiniteTech</Flag>
<Effects>
<Effect type ='TechStatus' status ='unobtainable'>LoopTech</Effect>
</Effects>
</Tech>

将上面语句粘贴进入techtreey后,开局就会无限研发LoopTech,能达到刷新科技显示目的,这样就能使用下面5个前置科技条件判断了。



<typecount unit="A" count="X.00" state="noneState aliveState buildingState" operator="lt"/>当单位A数量<X时开启本科技
<typecount unit="A" count="X.00" state="noneState aliveState buildingState" operator="lte"/>当单位A数量<=X时开启本科技
<typecount unit="A" count="X.00" state="noneState aliveState buildingState" operator="gte"/>当单位A数量>=X时开启本科技
<typecount unit="A" count="X.00" state="noneState aliveState buildingState" operator="gt"/>当单位A数量>X时开启本科技
<typecount unit="A" count="X.00" state="noneState aliveState buildingState" operator="eq"/>当单位A数量=X时开启本科技

以下为测试结果
techtreey.xml
<Tech name="LoopTech" type="Normal">
<DBID>5290</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>OBTAINABLE</Status>
<Flag>Volatile</Flag>
<Flag>YPInfiniteTech</Flag>
<Effects>
<Effect type ='TechStatus' status ='unobtainable'>LoopTech</Effect>
</Effects>
</Tech>

<Tech name ='TypecountTech0' type ='Normal'>
<DBID>5271</DBID>
<DisplayNameID>00033</DisplayNameID>
<Status>OBTAINABLE</Status>
<RolloverTextID>06002</RolloverTextID>
<Icon>icon\flagtest\lt_icon</Icon>
<Flag>CountsTowardEconomicScore</Flag>
<Prereqs>
<typecount unit="Musketeer" count="5.00" state="noneState aliveState buildingState" operator="lt"/>
</Prereqs>
<Effects>
</Effects>
</Tech>
<Tech name ='TypecountTech1' type ='Normal'>
<DBID>5271</DBID>
<DisplayNameID>00034</DisplayNameID>
<Status>OBTAINABLE</Status>
<RolloverTextID>06002</RolloverTextID>
<Icon>icon\flagtest\lte_icon</Icon>
<Flag>CountsTowardEconomicScore</Flag>
<Prereqs>
<typecount unit="Musketeer" count="5.00" state="noneState aliveState buildingState" operator="lte"/>
</Prereqs>
<Effects>
</Effects>
</Tech>
<Tech name ='TypecountTech2' type ='Normal'>
<DBID>5271</DBID>
<DisplayNameID>00035</DisplayNameID>
<Status>OBTAINABLE</Status>
<RolloverTextID>06004</RolloverTextID>
<Icon>icon\flagtest\gte_icon</Icon>
<Flag>CountsTowardEconomicScore</Flag>
<Prereqs>
<typecount unit="Musketeer" count="5.00" state="noneState aliveState buildingState" operator="gte"/>
</Prereqs>
<Effects>
</Effects>
</Tech>
<Tech name ='TypecountTech3' type ='Normal'>
<DBID>5271</DBID>
<DisplayNameID>00036</DisplayNameID>
<Status>OBTAINABLE</Status>
<RolloverTextID>06004</RolloverTextID>
<Icon>icon\flagtest\gt_icon</Icon>
<Flag>CountsTowardEconomicScore</Flag>
<Prereqs>
<typecount unit="Musketeer" count="5.00" state="noneState aliveState buildingState" operator="gt"/>
</Prereqs>
<Effects>
</Effects>
</Tech>
<Tech name ='TypecountTech4' type ='Normal'>
<DBID>5271</DBID>
<DisplayNameID>00037</DisplayNameID>
<Status>OBTAINABLE</Status>
<RolloverTextID>06004</RolloverTextID>
<Icon>icon\flagtest\eq_icon</Icon>
<Flag>CountsTowardEconomicScore</Flag>
<Prereqs>
<typecount unit="Musketeer" count="5.00" state="noneState aliveState buildingState" operator="eq"/>
</Prereqs>
<Effects>
</Effects>
</Tech>
<Tech name ='TypecountTech5' type ='Normal'>
<DBID>5271</DBID>
<DisplayNameID>00038</DisplayNameID>
<Status>OBTAINABLE</Status>
<RolloverTextID>06004</RolloverTextID>
<Icon>icon\flagtest\neq_icon</Icon>
<Flag>CountsTowardEconomicScore</Flag>
<Prereqs>
<typecount unit="Musketeer" count="5.00" state="noneState aliveState buildingState" operator="neq"/>
</Prereqs>
<Effects>
</Effects>
</Tech>




PS:我每一个科技都是用<Status>OBTAINABLE</Status>,所以每一个国家都会激活该科技,无需用其他语句激活。


protoy.xml
<Tech row ='0' page ='2' column ='0'>TypecountTech0</Tech>
<Tech row ='0' page ='2' column ='1'>TypecountTech1</Tech>
<Tech row ='0' page ='2' column ='2'>TypecountTech2</Tech>
<Tech row ='0' page ='2' column ='3'>TypecountTech3</Tech>
<Tech row ='0' page ='2' column ='4'>TypecountTech4</Tech>
<Tech row ='0' page ='2' column ='5'>TypecountTech5</Tech>

视频:



こはね发表于 2021-2-12 20:51:45
你以为我的目的就是为了修复这个BUG吗?那就错了



这个方法有点小问题,计算不精准
无限运送单位的科技,类似上面的无限研究科技,但是加入了检测单位数量,执行条件为Tool1的数量等于1,(需要配合上面所说的无限研发科技)
techtreey.xml
<Tech name="LoopSentUnit" type="Normal">
<DBID>5290</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>OBTAINABLE</Status>
<Icon>ui\units\ironclad_icon</Icon>
<Flag>Volatile</Flag>
<Flag>YPInfiniteTech</Flag>
<Prereqs>
<typecount unit="Tool1" count="1.00" state="noneState aliveState buildingState" operator="eq"/>
</Prereqs>
<Effects>
<Effect type ='TechStatus' status ='unobtainable'>LoopSentUnit</Effect>
<Effect type ='TechStatus' status ='obtainable'>LoopSentUnit</Effect>
<Effect type="Data" amount="10.00" subtype="FreeHomeCityMerc" unittype="Musketeer" relativity="Absolute">
<Target type="Player"/></Effect>
</Effects>
</Tech>

有个BUG,第一次训练单位会改良2次,<Lifespan>0.019</Lifespan>是测试出来的值,那个无限研发科技1秒大概研究500次,也就是每0.02秒刷新一次,但是所以必须在0.02秒内杀掉单位,否者会变成无限研发,瞬间运送多次单位,那样就没意义了。不是说1秒研发500次吗?为什么这里是0.02秒,我也不知道,总之我0.002秒删掉单位太快,科技无法执行,测试用0.01秒删单位也不行,也许一次检测要用上0.02秒左右
protoy.xml
<Unit id ='909' name ='Tool1'>
<DBID>1333</DBID>
<ObstructionRadiusX>0.00</ObstructionRadiusX>
<ObstructionRadiusZ>0.00</ObstructionRadiusZ>
<FormationCategory>Ranged</FormationCategory>
<MaxVelocity>4.5000</MaxVelocity>
<MaxRunVelocity>6.0000</MaxRunVelocity>
<MovementType>air</MovementType>
<Lifespan>0.019</Lifespan>
<TurnRate>18.0000</TurnRate>
<AnimFile>units\asians\chinese\chu_ko_nu\chu_ko_nu.xml</AnimFile>
<ImpactType>Flesh</ImpactType>
<PhysicsInfo>dude</PhysicsInfo>
<Icon>units\asians\chinese\chu_ko_nu\chu_ko_nu_icon_64</Icon>
<PortraitIcon>units\asians\chinese\chu_ko_nu\chu_ko_nu_icon_portrait</PortraitIcon>
<RolloverTextID>60151</RolloverTextID>
<ShortRolloverTextID>60150</ShortRolloverTextID>
<InitialHitpoints>90.0000</InitialHitpoints>
<MaxHitpoints>90.0000</MaxHitpoints>
<LOS>0.0000</LOS>
<ProjectileProtoUnit>Arrow</ProjectileProtoUnit>
<AutoAttackRange>16.0000</AutoAttackRange>
<UnitAIType>RangedCombative</UnitAIType>
<TrainPoints>10.0000</TrainPoints>
<Bounty>9.0000</Bounty>
<BuildBounty>9.0000</BuildBounty>
<AllowedAge>1</AllowedAge>
<Armor type ='Ranged' value ='0.2000'></Armor>
<UnitType>Unit</UnitType>
<Flag>CollidesWithProjectiles</Flag>
<Flag>ApplyHandicapTraining</Flag>
<Flag>CorpseDecays</Flag>
<Flag>ShowGarrisonButton</Flag>
<Flag>DontRotateObstruction</Flag>
<Flag>ObscuredByUnits</Flag>
<Flag>Tracked</Flag>
<Command page ='10' column ='1'>Stop</Command>
<Command page ='10' column ='0'>Garrison</Command>
<Command page ='10' column ='2'>Delete</Command>
<Tactics>tool1.tactics</Tactics>
</Unit>




too2的作用就是用tactics生成tool1
<Unit id ='909' name ='Tool2'>
<DBID>1333</DBID>
<ObstructionRadiusX>0.00</ObstructionRadiusX>
<ObstructionRadiusZ>0.00</ObstructionRadiusZ>
<FormationCategory>Ranged</FormationCategory>
<MaxVelocity>4.5000</MaxVelocity>
<MaxRunVelocity>6.0000</MaxRunVelocity>
<MovementType>air</MovementType>
<TurnRate>18.0000</TurnRate>
<AnimFile>units\asians\chinese\chu_ko_nu\chu_ko_nu.xml</AnimFile>
<ImpactType>Flesh</ImpactType>
<PhysicsInfo>dude</PhysicsInfo>
<Icon>units\asians\chinese\chu_ko_nu\chu_ko_nu_icon_64</Icon>
<PortraitIcon>units\asians\chinese\chu_ko_nu\chu_ko_nu_icon_portrait</PortraitIcon>
<RolloverTextID>60151</RolloverTextID>
<ShortRolloverTextID>60150</ShortRolloverTextID>
<InitialHitpoints>90.0000</InitialHitpoints>
<MaxHitpoints>90.0000</MaxHitpoints>
<LOS>0.0000</LOS>
<ProjectileProtoUnit>Arrow</ProjectileProtoUnit>
<AutoAttackRange>16.0000</AutoAttackRange>
<UnitAIType>RangedCombative</UnitAIType>
<TrainPoints>10.0000</TrainPoints>
<Bounty>9.0000</Bounty>
<BuildBounty>9.0000</BuildBounty>
<AllowedAge>1</AllowedAge>
<Armor type ='Ranged' value ='0.2000'></Armor>
<UnitType>Unit</UnitType>
<Flag>CollidesWithProjectiles</Flag>
<Flag>ApplyHandicapTraining</Flag>
<Flag>CorpseDecays</Flag>
<Flag>ShowGarrisonButton</Flag>
<Flag>DontRotateObstruction</Flag>
<Flag>ObscuredByUnits</Flag>
<Flag>Tracked</Flag>
<Command page ='10' column ='1'>Stop</Command>
<Command page ='10' column ='0'>Garrison</Command>
<Command page ='10' column ='2'>Delete</Command>
<Tactics>tool2.tactics</Tactics>
</Unit>

tool2.tactics
<?xml version="1.0" encoding="utf-8"?>


<tactics>
<action>
<name>SpawnTool</name>
<type>Maintain</type>
<rate type="Tool1">1.0</rate>
<active>1</active>
<persistent>1</persistent>
</action>
<tactic>
Idle
<action>SpawnTool</action>
<attacktype>LogicalTypeRangedUnitsAttack</attacktype>
<autoattacktype>LogicalTypeRangedUnitsAutoAttack</autoattacktype>
<attackresponsetype>LogicalTypeRangedUnitsAttack</attackresponsetype>
<runaway>1</runaway>
<autoretarget>1</autoretarget>
<idleanim>Volley_standing_idle</idleanim>
<boredanim>Volley_standing_bored</boredanim>
<deathanim>Death_by_melee</deathanim>
<walkanim>Volley_walk</walkanim>
<joganim>Volley_jog</joganim>
<runanim>Volley_run</runanim>
</tactic>
</tactics>

こはね发表于 2021-2-13 00:28:56
最新发现(一楼已修正)如果使用<Effect type ='TechStatus' status ='unobtainable'>xxxx</Effect>对带<Flag>Volatile</Flag>的科技使用后,那么并不会关闭科技,而是重新激活一次,如果使用<Effect type ='TechStatus' status ='obtainable'>xxxx</Effect>则只能在未启用状态下(<Status>UNOBTAINABLE</Status>)激活一次,激活后无法关闭。

然后已经研究出比二楼更精准的运算方法(二楼的方法首次判断会因为卡顿或者运行速度多改良1-2次科技)
这次是利用两个单位交互式运行判断科技:LoopSentUnit1检测Tool3数量然后激活LoopSentUnit2 ;然后LoopSentUnit2检测Tool4数量然后激活LoopSentUnit1;要注意,激活语句用的不是 status ='obtainable',而是 status ='unobtainable',上面有说的,别忘记了。
techtreey.xml
<Tech name="LoopSentUnit1" type="Normal">
<DBID>5290</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>UNOBTAINABLE</Status>
<Icon>ui\units\ironclad_icon</Icon>
<Flag>Volatile</Flag>
<Flag>YPInfiniteTech</Flag>
<Prereqs>
<typecount unit="Tool3" count="1.00" state="noneState aliveState buildingState" operator="eq"/>
</Prereqs>
<Effects>
<Effect type="Data" amount="10.00" subtype="FreeHomeCityMerc" unittype="Musketeer" relativity="Absolute">
<Target type="Player"/></Effect>
<Effect type ='TechStatus' status ='unobtainable'>LoopSentUnit2</Effect>
</Effects>
</Tech>
<Tech name="LoopSentUnit2" type="Normal">
<DBID>5290</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>UNOBTAINABLE</Status>
<Icon>ui\units\ironclad_icon</Icon>
<Flag>Volatile</Flag>
<Flag>YPInfiniteTech</Flag>
<Prereqs>
<typecount unit="Tool4" count="1.00" state="noneState aliveState buildingState" operator="eq"/>
</Prereqs>
<Effects>
<Effect type="Data" amount="10.00" subtype="FreeHomeCityMerc" unittype="Musketeer" relativity="Absolute">
<Target type="Player"/></Effect>
<Effect type ='TechStatus' status ='unobtainable'>LoopSentUnit1</Effect>
</Effects>
</Tech>

protoy则使用<Lifespan>10.0</Lifespan>控制单位存活时间,然后用<DeadReplacement>xxxx</DeadReplacement>Tool3死亡后变成Tool4,Tool4死亡后变成Tool3。
protoy.xml
<Unit id ='909' name ='Tool3'>
<DBID>1333</DBID>
<ObstructionRadiusX>0.00</ObstructionRadiusX>
<ObstructionRadiusZ>0.00</ObstructionRadiusZ>
<FormationCategory>Ranged</FormationCategory>
<MaxVelocity>4.5000</MaxVelocity>
<MaxRunVelocity>6.0000</MaxRunVelocity>
<MovementType>air</MovementType>
<Lifespan>10.0</Lifespan>
<TurnRate>18.0000</TurnRate>
<AnimFile>effects\projectiles\musket_ball.xml</AnimFile>
<ImpactType>Flesh</ImpactType>
<PhysicsInfo>dude</PhysicsInfo>
<Icon>units\asians\chinese\chu_ko_nu\chu_ko_nu_icon_64</Icon>
<PortraitIcon>units\asians\chinese\chu_ko_nu\chu_ko_nu_icon_portrait</PortraitIcon>
<RolloverTextID>60151</RolloverTextID>
<ShortRolloverTextID>60150</ShortRolloverTextID>
<InitialHitpoints>90.0000</InitialHitpoints>
<MaxHitpoints>90.0000</MaxHitpoints>
<LOS>0.0000</LOS>
<ProjectileProtoUnit>Arrow</ProjectileProtoUnit>
<AutoAttackRange>16.0000</AutoAttackRange>
<UnitAIType>RangedCombative</UnitAIType>
<DeadReplacement>Tool4</DeadReplacement>
<TrainPoints>10.0000</TrainPoints>
<Bounty>0.0000</Bounty>
<BuildBounty>0.0000</BuildBounty>
<AllowedAge>1</AllowedAge>
<Armor type ='Ranged' value ='0.2000'></Armor>
<UnitType>EmbellishmentClass</UnitType>
<UnitType>TestClass</UnitType>
<UnitType>Unit</UnitType>
<UnitType>Unattackable</UnitType>
<Flag>CollidesWithProjectiles</Flag>
<Flag>ApplyHandicapTraining</Flag>
<Flag>CorpseDecays</Flag>
<Flag>ShowGarrisonButton</Flag>
<Flag>DontRotateObstruction</Flag>
<Flag>ObscuredByUnits</Flag>
<Flag>Tracked</Flag>
<Flag>Wanders</Flag>
<Flag>NotSelectable</Flag>
<Flag>DoNotShowOnMiniMap</Flag>
<Command page ='10' column ='1'>Stop</Command>
<Command page ='10' column ='0'>Garrison</Command>
<Command page ='10' column ='2'>Delete</Command>
<Tactics>tool.tactics</Tactics>
</Unit>
<Unit id ='909' name ='Tool4'>
<DBID>1333</DBID>
<ObstructionRadiusX>0.00</ObstructionRadiusX>
<ObstructionRadiusZ>0.00</ObstructionRadiusZ>
<FormationCategory>Ranged</FormationCategory>
<MaxVelocity>4.5000</MaxVelocity>
<MaxRunVelocity>6.0000</MaxRunVelocity>
<MovementType>air</MovementType>
<Lifespan>10.0</Lifespan>
<TurnRate>18.0000</TurnRate>
<AnimFile>effects\projectiles\musket_ball.xml</AnimFile>
<ImpactType>Flesh</ImpactType>
<PhysicsInfo>dude</PhysicsInfo>
<Icon>units\asians\chinese\chu_ko_nu\chu_ko_nu_icon_64</Icon>
<PortraitIcon>units\asians\chinese\chu_ko_nu\chu_ko_nu_icon_portrait</PortraitIcon>
<RolloverTextID>60151</RolloverTextID>
<ShortRolloverTextID>60150</ShortRolloverTextID>
<InitialHitpoints>90.0000</InitialHitpoints>
<MaxHitpoints>90.0000</MaxHitpoints>
<LOS>0.0000</LOS>
<ProjectileProtoUnit>Arrow</ProjectileProtoUnit>
<AutoAttackRange>16.0000</AutoAttackRange>
<UnitAIType>RangedCombative</UnitAIType>
<TrainPoints>10.0000</TrainPoints>
<Bounty>0.0000</Bounty>
<BuildBounty>0.0000</BuildBounty>
<AllowedAge>1</AllowedAge>
<DeadReplacement>Tool3</DeadReplacement>
<Armor type ='Ranged' value ='0.2000'></Armor>
<UnitType>EmbellishmentClass</UnitType>
<UnitType>Unit</UnitType>
<UnitType>TestClass</UnitType>
<UnitType>Unattackable</UnitType>
<Flag>CollidesWithProjectiles</Flag>
<Flag>ApplyHandicapTraining</Flag>
<Flag>CorpseDecays</Flag>
<Flag>ShowGarrisonButton</Flag>
<Flag>DontRotateObstruction</Flag>
<Flag>ObscuredByUnits</Flag>
<Flag>Tracked</Flag>
<Flag>Wanders</Flag>
<Flag>NotSelectable</Flag>
<Flag>DoNotShowOnMiniMap</Flag>
<Command page ='10' column ='1'>Stop</Command>
<Command page ='10' column ='0'>Garrison</Command>
<Command page ='10' column ='2'>Delete</Command>
</Unit>

上次语句最终运行结果是出现Tool3这个单位,执行一次科技LoopSentUnit1,然后激活科技LoopSentUnit2,接着单位Tool3在10秒后死亡并生成tool4,因为tool4的出现,所以执行一次科技LoopSentUnit2,又因为激活科技LoopSentUnit1以及单位Tool4死亡后会变成Tool3的原因,达到无限循环的目的。





yxtajwj发表于 2021-2-16 00:19:28
 本帖最后由 yxtajwj 于 2021-2-16 00:26 编辑 

小羽大神的新作要顶一个
我觉得我大概好像可能貌似看懂了。。。
正好想做一个“献祭一定数量祭品获得神力”的玩意儿

顺带问一下,这循环开启后怎么停下来? 把LoopSentUnit1和2给 obtainable了可行吗?
こはね发表于 2021-2-16 00:35:08
yxtajwj 发表于 2021-2-16 00:19
小羽大神的新作要顶一个
我觉得我大概好像可能貌似看懂了。。。
正好想做一个“献祭一定数量祭品 ...

循环开启了就不能停下,但是可以在前置条件额外增加一个判断单位数量进行其他干预,或者设定其他前置科技进行干预(<TechStatus status ='Active'>Techname</TechStatus>
例如判断单位数量大于0,单位设定预期生命值结束后数量变回0,循环科技因为前置条件不成立而失效;把已经active前置科技禁用掉,循环科技因为前置条件不成立失效

如果只是执行一次
可以只设定0秒科技即可,不需要添加<Flag>Volatile</Flag>


如果是设定获得多次神力,似乎没办法。。。因为这个判断单位数量是绝对值,没办法进行加减
JWong发表于 2021-2-17 01:03:44
我之前也用數量判斷式弄過n個科技
就是當玩家船運了堡壘1科技以後,又損失了堡壘和堡壘馬車時,開啟科技,玩家可以在城鎮中心用資源和船運重新購買堡壘馬車。籌齊 1堡壘 or 1馬車
然後當玩家船運了堡壘2之後,只剩下一個堡壘或者馬車時,又可以購一個堡壘馬車,反正就是籌齊 2馬車 or 2堡壘 or 1x馬車+1x堡壘 (這裡超複雜)
.......
然鵝,AI 不會研究無限科技,只研究一次
こはね发表于 2021-2-17 09:18:25
JWong 发表于 2021-2-17 01:03
我之前也用數量判斷式弄過n個科技
就是當玩家船運了堡壘1科技以後,又損失了堡壘和堡壘馬車時,開啟科技, ...

这个也不算太复杂,总之头都大就对了

堡垒1,判断马车与堡垒是否等于0
堡垒2卡片关闭堡垒1的判断,然后判断马车与堡垒是否分别小于等于1
こはね发表于 2021-3-24 13:39:04
后续补充,<Flag>Volatile</Flag>会导致AI开局也会自动改良该科技,无论是否激活该科技都会改良;己控制的国家需要激活科技才会自动改良,其他人类玩家未知,暂时没办法联机测试。
建议:
1.对于延时科技或者定时科技直接用0秒科技代替。
2.对于循环科技,让某个国家开局运送特定单位,然后循环科技添加一个前置条件判断是否等于1,这样就不会干涉到其他国家了

こはね发表于 2021-5-2 17:21:27
关于无需循环改良科技,1秒钟运行500次,16分钟运行48万次的问题

<Tech name="LoopTech" type="Normal">
<DBID>5290</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>OBTAINABLE</Status>
<Flag>Volatile</Flag>
<Flag>YPInfiniteTech</Flag>
<Effects>
<Effect type ='TechStatus' status ='unobtainable'>LoopTech</Effect>
</Effects>
</Tech>
其实不用担心影响到游戏运行速度,我已经用虚拟机联机测试过了,非常流畅;正常来说,虚拟机的运行比主机的运行要慢(win7系统最少卡顿10倍),但在虚拟机里面玩起来跟正常一样,所以完全是毫无影响的
暴风截图202152101798140.jpg

暴风截图202152101876781.jpg

跳转到