Ludeon Forums

Ludeon Forums

  • September 22, 2019, 06:35:15 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [1.0] Colonists with a shield belt can fire manned turrets/mortars  (Read 196 times)

Alistaire

  • Colonist
  • ***
  • Posts: 478
  • Mod Author
    • View Profile

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

Code: [Select]
// 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.

Code: [Select]
// 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().

Code: [Select]
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:

Code: [Select]
// 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.
Logged

Pangaea

  • Colonist
  • ***
  • Posts: 220
  • Refugee
    • View Profile
Re: [1.0] Colonists with a shield belt can fire manned turrets/mortars
« Reply #1 on: August 27, 2019, 04:32:14 AM »

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.
Logged