tactics Spawn高级应用

spawn是什么?spawn是tactics里面的一个action类型,效果是(立刻)强制生成单位,比如英国的庄园自动生产村民;如果善于利用spawn,可以解决很多问题,例如以下例子:
  1. 可以代替旗军,直接利用科技干预tactics修改生成的单位
  2. 训练同一单位,但是不同国家使用科技激活不同的战术,使其spawn出来的单位不一样
  3. 你甚至可以训练多个旗军或捆绑单位,而不是每次只能训练一个旗军
  4. 贸易路线运送单位是不能运送旗军的,可以利用spawn直接生成多个单位,此处请参考贸易路线运送单位
  5. 无法利用Maintain自动生产旗军单位,利用spawn直接生成多个单位
  6. 发射物什么的可以直接spawn一个单位,然后自己可以意淫用来做什么
  7. 动作技能召唤单位,让一个单位攻击某处,然后在发射物spawn召唤单位
  8. 己方单位的践踏伤害不能伤害自己,可以spawn一个强制为大自然的单位,然后就能对自己造成伤害了。
  9. 链式炸电脑,你可以让一个单位spawn与其相同的单位,然后一秒后满地图都是那个单位,大概有成千上万个吧,成功达成炸电脑目的

天明MOD旧步军(旧汉军)改革后黄鹤楼(颐和园)训练神机箭、长斧兵等单位

天明MOD中,运送旧步军改革后,如何解决黄鹤楼训练的单位仍然是诸葛弩、长枪兵,而不是神机箭、长斧兵?我相信这个问题大部分人都想不出解决办法。实际上,解决办法很简单。你的想法是?想办法停用掉旧单位,然后启用新单位?96nn在多年前都没办法实现,此办法不可行。还有什么办法?利用战术取代按钮?然后启用禁用战术?理论上可行,不过过于复杂。换个角度思考,事实上没必要纠结于停用与启用单位,我们可以直接利用tactics中的spawn战术来生成单位,然后利用科技启用停用战术就可以了。以下为此方法的示例:

首先,创建一个看不见的透明单位(anim file可以直接使用protoy第一个单位子弹),设定预期生命为1秒,tactics设定2个spawn战术;一个作用中,另一个需要用科技激活。

单位图标、训练时间全部按照旧步军,UnitType那些也按照原有的旧步军,最好是直接复制旧步军这个单位,然后把animfile改成子弹。
protoy.xml - 记事本
	<Unit id="0" name="SpawnOldHanArmy">
		<DBID>20</DBID>
		<DisplayNameID>68416</DisplayNameID>
		<ObstructionRadiusX>0.1000</ObstructionRadiusX>
		<ObstructionRadiusZ>0.1000</ObstructionRadiusZ>
		<MaxVelocity>60.0000</MaxVelocity>
		<MovementType>air</MovementType>
		<AnimFile>effects\projectiles\musket_ball.xml</AnimFile>
		<Icon>icon\army_old_han_icon_64</Icon>
		<PortraitIcon>units\asians\chinese\standard_army\standard_army_icon_portrait</PortraitIcon>
		<Lifespan>1.0000</Lifespan>
		<TrainPoints>153.0000</TrainPoints>
		<Bounty>44.0000</Bounty>
		<BuildBounty>44.0000</BuildBounty>
		<Cost resourcetype ='Food'>255.0000</Cost>
		<Cost resourcetype ='Wood'>180.0000</Cost>
		<LOS>0.0000</LOS>
		<UnitType>EmbellishmentClass</UnitType>
		<UnitType>AbstractBannerArmy</UnitType>
		<UnitType>Military</UnitType>
		<UnitType>Unit</UnitType>
		<UnitType>Ranged</UnitType>
		<UnitType>HasBountyValue</UnitType>
		<Flag>NotPlayerPlaceable</Flag>
		<Flag>Tracked</Flag>
		<Tactics>SpawnOldHanArmy.tactics</Tactics>
	</Unit>
SpawnOldHanArmy.tactics - 记事本
<?xml version="1.0" encoding="utf-8"?>

<tactics>
	<action>
		<name>Spawn1</name>
		<type>Spawn</type>
		<rate type="ypChuKoNu">3</rate>
		<rate type="ypQiangPikeman">3</rate>
		<active>1</active>
		<singleuse>1</singleuse>
		<persistent>1</persistent>
	</action>
	<action>
		<name>Spawn2</name>
		<type>Spawn</type>
		<rate type="ypChuKoNu2">3</rate>
		<rate type="ypQiangPikeman2">3</rate>
		<active>0</active>
		<singleuse>1</singleuse>
		<persistent>1</persistent>
	</action>
	<tactic>
		Normal
		<action>Spawn1</action>
		<action>Spawn2</action>
	</tactic>
</tactics>


然后在tactics,将黄鹤楼原有的单位修改成上面的透明单位。(另一种方法是在civs将原有的旗军设定成该单位,不过要修改的地方有点多,这里不举例。)
summerpalace.tactics
<?xml version="1.0" encoding="utf-8"?>

<tactics>
	<action>
		<name stringid="68982">OldHanArmySpawn</name>
		<type>DanceBonus</type>
		<active>1</active>
		<persistent>1</persistent>
		<dancebonustype>UnitSpawn</dancebonustype>
		<modifyprotoid>SpawnOldHanArmy</modifyprotoid>
		<modifymultiplier>0.065</modifymultiplier>
		<modifyexponent>1.03</modifyexponent>
		<modifybase>0.0</modifybase>
	</action>
	<action>
		<name stringid="68976">StandardArmySpawn</name>
		<type>DanceBonus</type>
		<active>1</active>
		<persistent>1</persistent>
		<dancebonustype>UnitSpawn</dancebonustype>
		<modifyprotoid>ypStandardArmySpawn</modifyprotoid>
		<modifymultiplier>0.065</modifymultiplier>
		<modifyexponent>1.03</modifyexponent>
		<modifybase>0.0</modifybase>
	</action>
	<action>
		<name stringid="68979">MingArmySpawn</name>
		<type>DanceBonus</type>
		<active>1</active>
		<persistent>1</persistent>
		<dancebonustype>UnitSpawn</dancebonustype>
		<modifyprotoid>ypMingArmySpawn</modifyprotoid>
		<modifymultiplier>0.065</modifymultiplier>
		<modifyexponent>1.03</modifyexponent>
		<modifybase>0.0</modifybase>
	</action>
	<action>
		<name stringid="68977">TerritorialArmySpawn</name>
		<type>DanceBonus</type>
		<active>1</active>
		<persistent>1</persistent>
		<dancebonustype>UnitSpawn</dancebonustype>
		<modifyprotoid>ypTerritorialArmySpawn</modifyprotoid>
		<modifymultiplier>0.065</modifymultiplier>
		<modifyexponent>1.03</modifyexponent>
		<modifybase>0.0</modifybase>
	</action>
	<action>
		<name stringid="68981">ForbiddenArmySpawn</name>
		<type>DanceBonus</type>
		<active>1</active>
		<persistent>1</persistent>
		<dancebonustype>UnitSpawn</dancebonustype>
		<modifyprotoid>ypForbiddenArmySpawn</modifyprotoid>
		<modifymultiplier>0.065</modifymultiplier>
		<modifyexponent>1.03</modifyexponent>
		<modifybase>0.0</modifybase>
	</action>
	<action>
		<name stringid="68980">ImperialArmySpawn</name>
		<type>DanceBonus</type>
		<active>1</active>
		<persistent>1</persistent>
		<dancebonustype>UnitSpawn</dancebonustype>
		<modifyprotoid>ypImperialArmySpawn</modifyprotoid>
		<modifymultiplier>0.065</modifymultiplier>
		<modifyexponent>1.03</modifyexponent>
		<modifybase>0.0</modifybase>
	</action>
	<action>
		<name stringid="99644">ThreeThousandArmySpawn</name>
		<type>DanceBonus</type>
		<active>1</active>
		<persistent>1</persistent>
		<dancebonustype>UnitSpawn</dancebonustype>
		<modifyprotoid>ThreeThousandArmySpawn</modifyprotoid>
		<modifymultiplier>0.065</modifymultiplier>
		<modifyexponent>1.03</modifyexponent>
		<modifybase>0.0</modifybase>
	</action>
	<action>
		<name stringid="61766">AutoGatherXP</name>
		<type>AutoGather</type>
		<active>1</active>
		<persistent>1</persistent>
	</action>
	<tactic>
		StandardArmy
		<action>StandardArmySpawn</action>
		<protounitcommand>WonderStandardArmy</protounitcommand>
		<agerequirement>1</agerequirement>
		<active>1</active>
		<transition>
			<tactic>Food</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>MingArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ForbiddenArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>OldHanArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ImperialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>TerritorialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ThreeThousandArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ShrineXP</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
	</tactic>
	<tactic>
		MingArmy
		<action>MingArmySpawn</action>
		<protounitcommand>WonderMingArmy</protounitcommand>
		<agerequirement>1</agerequirement>
		<active>1</active>
		<transition>
			<tactic>Food</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>StandardArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ForbiddenArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>OldHanArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ImperialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>TerritorialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ThreeThousandArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ShrineXP</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
	</tactic>
	<tactic>
		TerritorialArmy
		<action>TerritorialArmySpawn</action>
		<protounitcommand>WonderTerritorialArmy</protounitcommand>
		<agerequirement>2</agerequirement>
		<active>1</active>
		<transition>
			<tactic>Food</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>MingArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>StandardArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ForbiddenArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>OldHanArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ImperialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ThreeThousandArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ShrineXP</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
	</tactic>
	<tactic>
		ImperialArmy
		<action>ImperialArmySpawn</action>
		<protounitcommand>WonderImperialArmy</protounitcommand>
		<agerequirement>2</agerequirement>
		<active>1</active>
		<transition>
			<tactic>Food</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>MingArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>StandardArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ForbiddenArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>OldHanArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>TerritorialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ThreeThousandArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ShrineXP</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
	</tactic>
	<tactic>
		ForbiddenArmy
		<action>ForbiddenArmySpawn</action>
		<protounitcommand>WonderForbiddenArmy</protounitcommand>
		<agerequirement>2</agerequirement>
		<active>1</active>
		<transition>
			<tactic>Food</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>MingArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>StandardArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>OldHanArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ImperialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>TerritorialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ThreeThousandArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ShrineXP</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
	</tactic>
	<tactic>
		OldHanArmy
		<action>OldHanArmySpawn</action>
		<protounitcommand>WonderOldHanArmy</protounitcommand>
		<agerequirement>1</agerequirement>
		<active>1</active>
		<transition>
			<tactic>Food</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>MingArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>StandardArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ForbiddenArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ImperialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>TerritorialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ThreeThousandArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ShrineXP</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
	</tactic>
	<tactic>
		ThreeThousandArmy
		<action>ThreeThousandArmySpawn</action>
		<protounitcommand>WonderThreeThousandArmy</protounitcommand>
		<agerequirement>1</agerequirement>
		<active>1</active>
		<transition>
			<tactic>Food</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>MingArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>StandardArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ForbiddenArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ImperialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>TerritorialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>OldHanArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ShrineXP</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
	</tactic>
	<tactic>
		ShrineXP
		<action>AutoGatherXP</action>
		<protounitcommand>TacticXP</protounitcommand>
		<transition>
			<tactic>Food</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>OldHanArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>MingArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>StandardArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ForbiddenArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ImperialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>TerritorialArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
		<transition>
			<tactic>ThreeThousandArmy</tactic>
			<length>2</length>
			<exit>1</exit>
		</transition>
	</tactic>
</tactics>


把旧步兵改革卡片的效果增加停用Spawn1战术,启用Spawn2战术。
techtreey.xml - 记事本
	<Tech name ='YPHCOldHanArmyReforms' type ='Normal'>
		<DBID>3954</DBID>
		<DisplayNameID>61558</DisplayNameID>
		<Cost resourcetype ='Food'>1000.0000</Cost>
		<Cost resourcetype ='Ships'>1.0000</Cost>
		<ResearchPoints>40.0000</ResearchPoints>
		<Status>UNOBTAINABLE</Status>
		<Icon>ui\home_city\hc_old_han_heavy_infantry_bonus</Icon>
		<RolloverTextID>61557</RolloverTextID>
		<Flag>HomeCity</Flag>
		<Effects>
			<Effect type ='Data' action ='Spawn1' amount ='0.0' subtype ='ActionEnable' relativity ='Absolute'>
				<Target type ='ProtoUnit'>SpawnOldHanArmy</Target></Effect>
			<Effect type ='Data' action ='Spawn2' amount ='1.0' subtype ='ActionEnable' relativity ='Absolute'>
				<Target type ='ProtoUnit'>SpawnOldHanArmy</Target></Effect>
			<Effect type ='TransformUnit' toprotoid ='ypChuKoNu2' fromprotoid ='ypChuKoNu'></Effect>
			<Effect type ='TransformUnit' toprotoid ='ypQiangPikeman2' fromprotoid ='ypQiangPikeman'></Effect>
			<Effect type ='TextOutput'>70482</Effect>
			<Effect type ='Data' amount ='-1.00' subtype ='Enable' relativity ='Absolute'>
				<Target type ='ProtoUnit'>ypOldHanArmy</Target></Effect>
			<Effect type ='Data' amount ='-1.00' subtype ='Enable' relativity ='Absolute'>
				<Target type ='ProtoUnit'>ypMingArmy</Target></Effect>
			<Effect type ='Data' amount ='-1.00' subtype ='Enable' relativity ='Absolute'>
				<Target type ='ProtoUnit'>IntegratedArmy</Target></Effect>
			<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
				<Target type ='ProtoUnit'>ypOldHanArmy2</Target></Effect>
			<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
				<Target type ='ProtoUnit'>ypMingArmy2</Target></Effect>
			<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
				<Target type ='ProtoUnit'>IntegratedArmy2</Target></Effect>
			<Effect type ='TechStatus' status ='unobtainable'>RunningCrossbow</Effect>
			<Effect type ='TechStatus' status ='unobtainable'>LongPike</Effect>
			<Effect type ='TechStatus' status ='active'>RunningFireArrow</Effect>
			<Effect type ='TechStatus' status ='active'>LongHalberd</Effect>
		</Effects>
	</Tech>



运送卡片“旧步兵改革”后:






以上就是利用spawn代替旗军的方法,但为了不影响原有的设定(例如针灸卡片、旗军学校卡片),应当在techtreey.xml中使用全部替换,将ypOldHanArmySpawn全部替换成SpawnOldHanArmy。




剩下的科技“神臂弓”、“自生火铳”你也知道怎样修改了吧?靖难军、辽东军、戚家军、国姓府军、神机营、十二团营等等全部都要改一遍,可以算是大工程。









如何通过改良科技直接产生单位?

mrf发表于 2021-7-8 21:52:47
我希望实现的效果就是:有一个无限改良的科技(就比如在码头改良吧),每改良一次都在码头旁产生一个拓荒者(岸上)和一个渔船(海上),需要怎么做到呢?FreeHomeCityUnit只能在船运点生成。
tactics的Spawn指令,同一个科技只能开启or关闭同一个战术,改良一次就没效果了(应该),不能做到改良一次生成一次(大概);另外Spawn是强制生产,而我希望在达到人口上限之后就不能生产。
Maintain有训练时间,而我希望改良完成立即运送,且同样存在只能active一次的问题。
如果不设置<singleuse>1</singleuse>那就成不停运送了,同样不行。
捆绑训练,也做不到捆绑两个不同的单位一次训练,所以还是得从techtreey方面入手,可是我想不到了QaQ 跪求大佬!!
こはね发表于 2021-7-8 22:05:35
科技可以无限改良,此处参考外挂漏洞
こはね发表于 2021-7-11 11:20:43
以下语句能在圣典1-2找到(但是这个不是最好的办法,最好的办法是直接照抄中国赛加羚羊的卡片)
    单位开启单位战术、光环,(Actionname为Tactics的定义)
		<Effect type ='Data' action ='Actionname' amount ='1.0' subtype ='ActionEnable' relativity ='Absolute'>
			<Target type ='ProtoUnit'>Protoname</Target>
		</Effect>
    激活一次战术(例如中国难民卡片,用的就是这个语句,Actionname为Tactics的定义)
		<Effect type ='Data' action ='Actionname' amount ='1.00' subtype ='ActionAdd' unittype ='Protoname' relativity ='Absolute'>
			<Target type ='Player'></Target>
		</Effect>
以下语句能在圣典7-0找到
自动生产单位:
(注:类似中国难民卡片不可以设定为旗军,虽然中国难民卡的确是旗军,但是我们新增旗军使用Maintain没有任何效果。)
	<action>
		<name stringid="StringID">XXXX</name>
定义tactics的Action名及其名称
		<type>Maintain</type>
类型。自动生产单位
		<rate type="XXXXXX">X</rate>
XXXXXX单位调用名,X为自动生产单位数量。3.2版本补充:10个单位会变成10倍训练时间,例如某单位训练时间为30秒,用Maintain一次性训练10个需要用300秒。
		<active>1</active>
1为启用,0为未启用(需要借助科技激活),没有则默认启用
		<singleuse>1</singleuse>
该战术只能生产一次单位。
		<persistent>1</persistent>
1为无限次生产单位,0为不能自动生产单位,0一般与<singleuse>1</singleuse>配合使用,来生产一次单位,例如中国难民卡片。(如果建筑在建造中,并且带有语句<singleuse>1</singleuse> , 使用该战术生产单位时, 若为0,建造好建筑后不会生产单位,若为1,建造好建筑后会追加生产单位)
	</action>


强制生产单位(无视人口限制,无视训练时间,建议使用<singleuse>1</singleuse>语句,使其只能生产一次。):
	<action>
		<name stringid="StringID">XXXX</name>
定义tactics的Action名及其名称
		<type>Spawn</type>
类型。强制生产单位。3.7版本补充:当被生产的单位到达建造上限后不会生产单位。
		<rate type="XXXXXX">X</rate>
XXXXXX单位调用名,X为强制生产单位数量。
		<active>1</active>
1为启用,0为未启用(需要借助科技激活),没有则默认启用
		<singleuse>1</singleuse>
该战术只能生产一次单位。
		<persistent>1</persistent>
1为无限次强制生产单位,0为不能生产单位,0一般与<singleuse>1</singleuse>配合使用,来生产一次单位,例如中国难民卡片。(如果建筑在建造中,并且带有语句<singleuse>1</singleuse> , 使用该战术生产单位时, 若为0,建造好建筑后不会生产单位,若为1,建造好建筑后会追加生产单位)
	</action>

这是一个测试科技:
techtreey.xml
	<Tech name="test152" type="Normal">
		<DBID>5290</DBID>
		<ResearchPoints>10.0000</ResearchPoints>
		<Status>OBTAINABLE</Status>
		<Icon>ui\units\ironclad_icon</Icon>
		<Flag>YPInfiniteTech</Flag>
		<Effects>
			<Effect type ='Data' action ='spawn' amount ='1.00' subtype ='ActionAdd' unittype ='XXX' relativity ='Absolute'>
				<Target type ='Player'></Target>
			</Effect>
		</Effects>
	</Tech>

这是一个测试单位:
protoy.xml
	<Unit id ='534' name ='XXX'>
		<DBID>704</DBID>
		<ObstructionRadiusX>0.4900</ObstructionRadiusX>
		<ObstructionRadiusZ>0.4900</ObstructionRadiusZ>
		<FormationCategory>Body</FormationCategory>
		<MaxVelocity>5.0000</MaxVelocity>
		<MaxRunVelocity>7.0000</MaxRunVelocity>
		<MovementType>land</MovementType>
		<TurnRate>18.0000</TurnRate>
		<AnimFile>units\spc\delgado\spc_delgado.xml</AnimFile>
		<ImpactType>Flesh</ImpactType>
		<Icon>units\spc\delgado\delgado_icon_64x64</Icon>
		<PortraitIcon>units\spc\delgado\delgado_igc_icon</PortraitIcon>
		<RolloverTextID>32439</RolloverTextID>
		<ShortRolloverTextID>32438</ShortRolloverTextID>
		<InitialHitpoints>1200.0000</InitialHitpoints>
		<MaxHitpoints>1200.0000</MaxHitpoints>
		<LOS>24.0000</LOS>
		<AutoAttackRange>16.0000</AutoAttackRange>
		<UnitAIType>Hero</UnitAIType>
		<Bounty>40.0000</Bounty>
		<AllowedAge>0</AllowedAge>
		<Armor type ='Hand' value ='0.1000'></Armor>
		<UnitType>LogicalTypeHealed</UnitType>
		<UnitType>LogicalTypeNeededForVictory</UnitType>
		<UnitType>LogicalTypeHandUnitsAutoAttack</UnitType>
		<UnitType>LogicalTypeLandMilitary</UnitType>
		<UnitType>LogicalTypeScout</UnitType>
		<UnitType>LogicalTypeValidSPCUnitsDeadCondition</UnitType>
		<UnitType>LogicalTypeGarrisonInShips</UnitType>
		<UnitType>LogicalTypeRangedUnitsAutoAttack</UnitType>
		<UnitType>LogicalTypeVillagersAttack</UnitType>
		<UnitType>LogicalTypeHandUnitsAttack</UnitType>
		<UnitType>LogicalTypeRangedUnitsAttack</UnitType>
		<UnitType>LogicalTypeMinimapFilterMilitary</UnitType>
		<UnitType>AbstractInfantry</UnitType>
		<UnitType>Hero</UnitType>
		<UnitType>Unit</UnitType>
		<UnitType>Military</UnitType>
		<UnitType>UnitClass</UnitType>
		<UnitType>AbstractHandInfantry</UnitType>
		<UnitType>ConvertsHerds</UnitType>
		<UnitType>HasBountyValue</UnitType>
		<Flag>CollidesWithProjectiles</Flag>
		<Flag>ApplyHandicapTraining</Flag>
		<Flag>CorpseDecays</Flag>
		<Flag>ShowGarrisonButton</Flag>
		<Flag>DontRotateObstruction</Flag>
		<Flag>ObscuredByUnits</Flag>
		<Flag>NotDeleteable</Flag>
		<Flag>Tracked</Flag>
		<Tech row ='0' page ='1' column ='0'>test152</Tech>
		<Command page ='10' column ='0'>Garrison</Command>
		<Command page ='11' column ='0'>Abilities</Command>
		<Command page ='10' column ='1'>Stop</Command>
		<Tactics>xxx.tactics</Tactics>
		<ProtoAction>
			<Name>BuildingAttack</Name>
			<Damage>200.000000</Damage>
			<DamageType>Siege</DamageType>
			<ROF>3.000000</ROF>
		</ProtoAction>
		<ProtoAction>
			<Name>HandAttack</Name>
			<Damage>500.000000</Damage>
			<DamageType>Hand</DamageType>
			<ROF>1.500000</ROF>
		</ProtoAction>
	</Unit>


这个是测试单位的tactics
<?xml version="1.0" encoding="utf-8"?>

<tactics>
	<action>
		<name>spawn</name>
		<type>Spawn</type>
		<rate type="settler">1.0</rate>
		<active>1</active>
		<singleuse>1</singleuse>
		<persistent>0</persistent>
	</action>
	<action>
		<name>spawn2</name>
		<type>Spawn</type>
		<rate type="Crossbowman">1.0</rate>
		<rate type="settler">1.0</rate>
		<active>1</active>
		<singleuse>1</singleuse>
		<persistent>0</persistent>
	</action>
	<action>
		<name stringid="69148">Discover</name>
		<type>Discover</type>
		<anim>Pickup</anim>
		<maxrange>0.2</maxrange>
		<rate type="AbstractNugget">1.0</rate>
	</action>
	<action>
		<name stringid="69147">Build</name>
		<type>Build</type>
		<anim>Build</anim>
		<maxrange>0.2</maxrange>
		<rate type="Building">1.0</rate>
	</action>
	<action>
		<name stringid="38134">HandAttack</name>
		<type>Attack</type>
		<attackaction>1</attackaction>
		<handlogic>1</handlogic>
		<anim>HandAttack</anim>
		<idleanim>CombatIdle</idleanim>
		<maxrange>1.75</maxrange>
		<impacteffect>effects\impacts\melee</impacteffect>
		<rate type="Unit">1.0 </rate>
	</action>
	<action>
		<name stringid="38118">BuildingAttack</name>
		<type>Attack</type>
		<rangedlogic>1</rangedlogic>
		<maxrange>6</maxrange>
		<rate type="LogicalTypeShipsAndBuildings">1.0</rate>
		<attackaction>1</attackaction>
		<speedboost>1</speedboost>
		<anim>Raze_Attack</anim>
		<idleanim>Raze_Idle</idleanim>
		<impacteffect>effects\impacts\torch</impacteffect>
		<projectile>TorchProjectile</projectile>
	</action>
	<action>
		<name stringid="38124">Throwbobmod</name>
		<type>Attack</type>
		<attackaction>1</attackaction>
		<rangedlogic>1</rangedlogic>
		<anim>Raze_Attack</anim>
		<idleanim>Raze_Idle</idleanim>
		<maxheight>0</maxheight>
		<accuracy>1.0</accuracy>
		<accuracyreductionfactor>0.001</accuracyreductionfactor>
		<aimbonus>5</aimbonus>
		<trackrating>12</trackrating>
		<rate type="unit">1.0 </rate>
		<impacteffect>effects\impacts\torch</impacteffect>
		<projectile>TorchProjectile</projectile>
		<rof>1.000000</rof>
		<instantballistics>1</instantballistics>
	</action>
	<tactic>
		Melee
		<action priority="100">BuildingAttack</action>
		<action priority="75">HandAttack</action>
		<action>Throwbobmod</action>
		<action>Build</action>
		<action>Discover</action>
		<action>spawn</action>
		<action>spawn2</action>
		<speedmodifier>1.0</speedmodifier>
		<attacktype>LogicalTypeHandUnitsAttack</attacktype>
		<autoattacktype>LogicalTypeHandUnitsAutoAttack</autoattacktype>
		<attackresponsetype>LogicalTypeHandUnitsAttack</attackresponsetype>
		<runaway>1</runaway>
		<autoretarget>1</autoretarget>
		<idleanim>Idle</idleanim>
		<boredanim>Bored</boredanim>
		<deathanim>Death</deathanim>
		<walkanim>Walk</walkanim>
		<joganim>Jog</joganim>
		<runanim>Run</runanim>
	</tactic>
	<tactic>
		Defend
		<action priority="100">BuildingAttack</action>
		<action priority="25">HandAttack</action>
		<action>Throwbobmod</action>
		<action>Build</action>
		<action>Discover</action>
		<action>spawn</action>
		<action>spawn2</action>
		<attacktype>LogicalTypeHandUnitsAttack</attacktype>
		<autoattacktype>LogicalTypeHandUnitsAutoAttack</autoattacktype>
		<attackresponsetype>LogicalTypeHandUnitsAttack</attackresponsetype>
		<runaway>0</runaway>
		<autoretarget>1</autoretarget>
		<idleanim>Idle</idleanim>
		<boredanim>Bored</boredanim>
		<deathanim>Death</deathanim>
		<walkanim>Walk</walkanim>
		<joganim>Jog</joganim>
		<runanim>Run</runanim>
	</tactic>
	<tactic>
		Cover
		<speedmodifier>0.5</speedmodifier>
		<action priority="100">BuildingAttack</action>
		<action priority="25">HandAttack</action>
		<action>Throwbobmod</action>
		<action>Build</action>
		<action>Discover</action>
		<action>spawn</action>
		<action>spawn2</action>
		<attacktype>LogicalTypeHandUnitsAttack</attacktype>
		<autoattacktype>LogicalTypeHandUnitsAutoAttack</autoattacktype>
		<attackresponsetype>LogicalTypeHandUnitsAttack</attackresponsetype>
		<runaway>0</runaway>
		<autoretarget>1</autoretarget>
		<idleanim>Idle</idleanim>
		<boredanim>Bored</boredanim>
		<deathanim>Death</deathanim>
		<walkanim>Walk</walkanim>
		<joganim>Jog</joganim>
		<runanim>Run</runanim>
	</tactic>
</tactics>

使用以上语句就能达成改良科技spawn一次单位


然后问题又出现了,然后一次性出现多个单位?
经过测试,如果科技同时存在两个ActionAdd,那么只会执行最后面那一句,前面的一句不执行,例如下面的例子, action ='spawn' 是不执行的, action ='spawn2' 是执行的。
	<Tech name="test152" type="Normal">
	<DBID>5290</DBID>
	<ResearchPoints>10.0000</ResearchPoints>
	<Status>OBTAINABLE</Status>
	<Icon>ui\units\ironclad_icon</Icon>
	<Flag>YPInfiniteTech</Flag>
	<Effects>
		<Effect type ='Data' action ='spawn' amount ='1.00' subtype ='ActionAdd' unittype ='XXX' relativity ='Absolute'>
			<Target type ='Player'></Target>
		</Effect>
		<Effect type ='Data' action ='spawn2' amount ='1.00' subtype ='ActionAdd' unittype ='XXX' relativity ='Absolute'>
			<Target type ='Player'></Target>
		</Effect>
	</Effects>
</Tech>


我在这里给出两个解决办法:
1.两个科技联用,利用一个科技直接active两个科技
2.tactics的action可以添加多个rate,例如下面
	<action>
		<name>spawn2</name>
		<type>Spawn</type>
		<rate type="Crossbowman">1.0</rate>
		<rate type="settler">1.0</rate>
		<active>1</active>
		<singleuse>1</singleuse>
		<persistent>0</persistent>
	</action>
	
mrf发表于 2021-7-11 11:38:36
感谢こはね大佬!有劳了!