[1.0] Colonists with a shield belt can fire manned turrets/mortars

Started by Alistaire, August 26, 2019, 02:36:18 PM

Previous topic - Next topic

Alistaire

This is because Verse.Verb.CanHitTargetFrom checks Verb.CasterIsPawn and thus Verb.caster.


// Verse.Verb
public virtual bool CanHitTargetFrom(IntVec3 root, LocalTargetInfo targ)

(..)

if (this.CasterIsPawn && this.CasterPawn.apparel != null)
{

(..)


Verb.caster is set to the turretGun, not to the operator of the mannable turret.


// RimWorld.Building_TurretGun
private void UpdateGunVerbs()
{
List<Verb> allVerbs = this.gun.TryGetComp<CompEquippable>().AllVerbs;
for (int i = 0; i < allVerbs.Count; i++)
{
Verb verb = allVerbs[i];
verb.caster = this;
verb.castCompleteCallback = new Action(this.BurstComplete);
}
}


Therefore, the WornApparel of the operator is never checked for Apparel.AllowVerbCast().


if (this.CasterIsPawn && this.CasterPawn.apparel != null)
{
List<Apparel> wornApparel = this.CasterPawn.apparel.WornApparel;
for (int i = 0; i < wornApparel.Count; i++)
{
if (!wornApparel[i].AllowVerbCast(root, this.caster.Map, targ, this))
{
return false;
}
}
}


So the following code for shieldbelts is never checked:


// RimWorld.ShieldBelt
public override bool AllowVerbCast(IntVec3 root, Map map, LocalTargetInfo targ, Verb verb)
{
return !(verb is Verb_LaunchProjectile) || ReachabilityImmediate.CanReachImmediate(root, targ, map, PathEndMode.Touch, null);
}


Thus pawns can fire mortars and other manned turrets, even though they have Verb_LaunchProjectile and their targets aren't within touch range.

Pangaea

Personally I think this makes sense. A mortar is a stationary, big weapon and functions quite differently to your normal assault rifle or whatever. Would probably be pretty annoying if shield belt users couldn't use them tbh. Unless they're drafted, we don't see the "sphere" around them, and could end up in situations where they are manning a mortar, but unable to fire it.

Manned turrets might be different because then the pawns are in the thick of combat and shouldn't really be bulletproof while being able to fire at the enemy. But these come from mods, and aren't in the base game.

Tynan

The shield belt projects a shield just outside arm's reach which stops fast projectiles. It doesn't stop you from pushing a button or pulling a firing lever on a mortar.

And I think it'd be annoying if you had to drop the belt to use a mortar. That's not what it's intended for design-wise. So I'll say it's working as designed. Thanks for taking the time to report.
Tynan Sylvester - @TynanSylvester - Tynan's Blog