
这里双武器指单位的主武器和副武器,自由切换是指“可手动决定使用哪个,并且可选择攻击对象,单位可自由移动。”而逻辑上,用的是Ares.dll(在原版引擎也可以做到部分效果,所以原版爱好者也可以参考,毕竟我的粉丝里面还是有相当人数的红警战网地图组人员),并且用了一系列组合逻辑。

Ctrl攻击地面切换成新的武器。

新的武器能像旧的武器一样自由使用。

也可以切换回来哦,是可逆的。

重点是自由,也就是能动,能点选目标。
如果不知道有什么用的话,可以参考我录制的一个演示视频,只有一分钟网页链接
这个灵感出自于昨日(7.16.2018)同社员方长酱的聊天

(剪去秘密内容)

经过两分钟思考我想到了!

聊天记录比较混乱,具体来说,就是这样个逻辑:
1,首先想到单位攻击时必须要有武器才能在目标上获得攻击指针,于是想到用不同武器区分不同攻击,但是考虑到聊天记录中所说的“点选一个目标,他的攻击方式就被确定了”这一“无解”事实,考虑增设条件在不同情况下使用不同的武器。
2,寻找条件的思考过程是漫长的(两分钟),显然只能是Ares的弹药逻辑,用不同情况的弹药值触发不同的武器。
[TechnoType]►NoAmmoWeapon= (integer)
The weapon index to switch to when there is no ammo left. This will override the normal weapon selection and only allow this weapon to be selected. Valid values 0 for the primary weapon and 1 for the secondary. Use -1 to not switch weapons. Defaults to -1.NoteThis tag cannot override the DeployFireWeapon enabled by DeployFire=yes on VehicleTypes and InfantryTypes.
[TechnoType]►NoAmmoAmount= (integer)
If the current ammo is equal to or below this value, the NoAmmoWeapon will be used. Defaults to 0.
显然很容易想到,用弹药逻辑作为条件,空弹药武器逻辑执行切换武器。
[Weapon]►Ammo= (integer)
The rounds of ammunition needed to fire this weapon. If fewer than the required rounds are present, the unit will not fire and wait for the ammo to reload. Defaults to 1.NoteThis feature does not support AircraftTypes.WarningUnits that do ManualReload=yes will still target enemies and wait for reloading, which never happens.
于是很容易想到用弹药逻辑给默认武器Ammo=0,这样他就不会在默认状态下丢失弹药,切换成新武器,然后新武器的Ammo>0,这样就能实现使用新武器开火不会变回默认武器。
3,那么你需要一个触发媒介,也就是说你需要一个手动改变的方式,去实现切换武器,也就是等价为丢失弹药,丢失弹药的话显然只能考虑使用新武器,然后我第一想法是部署,但是部署的巨大缺陷是部署的武器必须有AreaFire=yes,也就是辐射工兵、尤里复制人那种以自己为圆心画圆的武器,换句话说是不能选定攻击目标的,另一方面部署武器如果用在有炮塔单位身上,部署后炮塔会限制转向右下,这是也是一个巨大缺陷——显然这不符合我的要求,很快我在脑子里面就否定了这个想法。
那么是不是没办法了呢?不是,我们还有一个被遗忘的操作,Ctrl点地面,或者俗称A地板,A地,AG,代码上,就是抛射体AG=yes。
那么初步的逻辑就可以构建出来了:正常攻击目标时,不消耗弹药,使用默认武器;AG时,消耗弹药,弹药低于某个值时,触发新武器,实现切换;停止AG后,经过一段时间,弹药Reload(重新装填)了,又会回到默认武器上,实现反向切换。
这里稍微解释一下为什么会想到AG,因为前面提到“点选一个目标,他的攻击方式就被确定了”,所以你一定不能用点选某个单位这种方式来切换武器,因为这是切不了,所以很容易想到攻击没有护甲类型的地面。
4,根据RA2的引擎判定规律,我们必须把AG的武器放在主武器,因为RA2永远是使用主武器AG的,默认武器放在副武器位置,为了防止AG的武器被用于攻击,所以他的弹头必须全0%,而副武器正常,只要一句Ammo=0。这时我又想到,如果主武器AG但是弹头全0,就算你用空弹药武器逻辑切换了武器,那么一个全0的弹头,也不会对单位造成任何影响啊,所以这里要用到Ares的自定义攻击类型逻辑和分裂武器逻辑。
The Verses flag has three special-case values that can be used to define additional behavior:
0% means no force fire, no retaliate, no passive acquire
1% means no retaliate, no passive acquire
2% means no passive acquire
These behaviors can now be toggled on or off independently of the damage multiplier (so you can now have a warhead that is 100% effective against an armor type but, at the same time, will not directly target a unit with that armor type).
[Warhead]►Versus.magic.ForceFire= (boolean)
Whether or not this warhead is allowed to be force-fired on the magic ArmorType.
[Warhead]►Versus.steel.Retaliate= (boolean)
Whether or not this warhead is allowed to be used in retaliation against the steel ArmorType.
[Warhead]►Versus.clingfilm.PassiveAcquire= (boolean)
Whether or not this warhead is allowed to be used to attack the clingfilm ArmorType automatically.
这是个老逻辑了,也是冷门逻辑,Ares0.1就有了,还好我没忘了它,作用是让一个武器的弹头无视破甲比强制执行攻击/主动攻击/还击命令,这样就算是全0%的弹头,也能攻击所有目标了。
[Projectile]►Splits= (boolean)
Whether the projectile will split into a number of other projectiles defined by Cluster and AirburstWeapon. Can be combined withAirburst. Defaults to no.
[Projectile]►RetargetAccuracy= (float - percentage)
The probability that a split cluster will aim for the same target the original projectile was shot at. The higher the value, the less likely it is for the split projectile to choose another target. Valid range is 0.0 to 1.0. Defaults to 0.0.
空爆武器逻辑的兄弟逻辑,分裂武器逻辑,和空爆武器执行相同的代码,只不过不要AirBurst=yes,要Splits=yes,这个逻辑能像空爆武器一样实现攻击分裂出子武器,不过这个子武器是在命中了目标之后产生(包括建筑!),也是我们常见的创造双弹头武器的方式之一(另一种是动画,但是这里动画不好,或者说动画绝大部分情况下都不好,不计算经验,不计算摧毁数等等都广为诟病),RetargetAccuracy=1(不解释了,看上面的英文说明),Cluster=1(只分裂一个子武器,这个子武器的作用就是造成真实主武器效果),也就是说即便是一个全0%弹头的武器,只要有分裂武器逻辑,可以把主武器用作一个表象,分裂的子武器产生实际效果(注意,子武器不要有一系列动画和音效防止穿帮,特效都做在主武器上就好了)。
5,到这里(两分钟过去了),我就惊奇的发现原来可以实现双武器自由切换!经过一番调试,就实现了上面图片的效果。调试的内容其实就是弹药量以及装填时间,测试发现比较理想的效果是单位弹药量Ammo=2,武器弹药量Ammo=1,单位Reload=90(这个你随便填,这就是你决定的武器切换时间,近似理解为武器切换后反向切换的CD时间),即新武器在找不到可攻击目标或者没有手动选择攻击目标后经过90帧的时间(单机游戏速度5联机游戏速度6的时候60FPS,90帧也就是1.5s),复原为主武器,更形象的说法是“脱离战斗1.5秒复原为默认武器”。EmptyReload=10,这个是你新武器的攻击时间间隔,因为在你攻击一次地面之后,单位弹药量就变成1,就可以作为切换武器判定条件了,这时如果弹药打空,只要10帧时间就重新装填,也就是说单位能继续开火了。
至此大功告成,顺便发一下我演示时用的代码,方便大家理解:
单位
Primary=Inflare
Secondary=105mm;这是单位默认的武器,你写什么都可以。
Ammo=2
NoAmmoWeapon=0
NoAmmoAmount=1
Reload=90
EmptyReload=10
默认武器
[105mm]
Ammo=0
新武器,也就是主武器,切换的武器
[Inflare]
Damage=1
ROF=1
Range=8
Warhead=TarWH
Projectile=InvisibleX
IsLaser=true;这里往下都是红色激光特效,没什么用。
IsHouseColor=false
LaserInnerColor = 255,0,0
LaserOuterColor = 127,0,0;0,0,0
LaserOuterSpread= 40,80,80;20,40,40
LaserDuration = 10;15
新武器的弹头
[TarWH]
Verses=0%,0%,0%,0%,0%,0%,0%,0%,0%,0%,0%;这句代码原版可用,如果你要在原版用的话,就不要用弹药逻辑了,Ammo那一套全部不要,直接给主武器写这个,下面的也不要了,下面这一长串就是让武器能正常攻击。
Versus.none.ForceFire=yes
Versus.flak.ForceFire=yes
Versus.plate.ForceFire=yes
Versus.light.ForceFire=yes
Versus.medium.ForceFire=yes
Versus.heavy.ForceFire=yes
Versus.wood.ForceFire=yes
Versus.steel.ForceFire=yes
Versus.concrete.ForceFire=yes
Versus.special_1.ForceFire=yes
Versus.special_2.ForceFire=yes
Versus.none.PassiveAcquire=yes
Versus.flak.PassiveAcquire=yes
Versus.plate.PassiveAcquire=yes
Versus.light.PassiveAcquire=yes
Versus.medium.PassiveAcquire=yes
Versus.heavy.PassiveAcquire=yes
Versus.wood.PassiveAcquire=yes
Versus.steel.PassiveAcquire=yes
Versus.concrete.PassiveAcquire=yes
Versus.special_1.PassiveAcquire=yes
Versus.special_2.PassiveAcquire=yes
新武器抛射体
[InvisibleX]
Inviso=yes
Image=none
AirburstWeapon=Aim;这个空爆武器执行的是分裂武器逻辑。
Splits=yes;原版可用,直接写,记得上面那句。
RetargetAccuracy=1;原版不要这句。
Cluster=1;只分裂一次,原版也要的。
子武器,这个随便写了,这个效果就是你要的真实主武器效果
[Aim]
Damage=1
ROF=10
Range=1
Warhead=AimWH
Projectile=Invisible
子武器弹头,因为我是要一个激光瞄准所以这样写
[AimWH]
CellSpread=.3
PercentAtMax=.5
Verses=1%,1%,1%,1%,1%,1%,1%,1%,1%,1%,1%
AttachEffect.Cumulative=no
AttachEffect.Animation=none
AttachEffect.Duration=15
AttachEffect.ArmorMultiplier=0.1
最后如果你是Ares,别忘了注册子武器,如果你是原版YR,别忘了找个地方挂上子武器。
这里回来说原版的不足点,如果你原版要用的话,因为用不了弹药逻辑嘛,所以就做不到“自由切换”,但是双武器还是没问题的,用这种方法,原版可以做出普通攻击武器和Ctrl点地面(特殊攻击)武器两种,打个比方,你可以让你的犀牛坦克使用正常的主炮作为副武器(默认武器),使用一个范围清兵破片炮用作主武器(特殊武器),这样犀牛坦克不会影响正常使用,倒是多了个AG范围杀兵的手段(GGI:MMP)。
好啦教程到此为止了,手打六千字不容易,喜欢的话就~

我只是个手残
咫越社外交组146168546