public static string ShotCalculationTipString(Thing target) { StringBuilder stringBuilder = new StringBuilder(); if (Find.Selector.SingleSelectedThing != null) { Verb verb = null; Pawn pawn = Find.Selector.SingleSelectedThing as Pawn; if (pawn != null && pawn != target && pawn.equipment != null && pawn.equipment.Primary != null && pawn.equipment.PrimaryEq.PrimaryVerb is Verb_LaunchProjectile) { verb = pawn.equipment.PrimaryEq.PrimaryVerb; } Building_TurretGun building_TurretGun = Find.Selector.SingleSelectedThing as Building_TurretGun; if (building_TurretGun != null && building_TurretGun != target) { verb = building_TurretGun.AttackVerb; } if (verb != null) { stringBuilder.Append("ShotBy".Translate(new object[] { Find.Selector.SingleSelectedThing.LabelShort }) + ": "); if (verb.CanHitTarget(target)) { stringBuilder.Append(ShotReport.HitReportFor(verb.caster, verb, target).GetTextReadout()); } else { stringBuilder.Append("CannotHit".Translate()); } } } return(stringBuilder.ToString()); }
public static ShotReport HitReportFor(Thing caster, Verb verb, LocalTargetInfo target) { Pawn pawn = caster as Pawn; IntVec3 cell = target.Cell; ShotReport result = default(ShotReport); result.distance = (cell - caster.Position).LengthHorizontal; result.target = target.ToTargetInfo(caster.Map); float f = (float)((pawn == null) ? 0.95999997854232788 : pawn.GetStatValue(StatDefOf.ShootingAccuracy, true)); result.factorFromShooterAndDist = Mathf.Pow(f, result.distance); if (result.factorFromShooterAndDist < 0.020099999383091927) { result.factorFromShooterAndDist = 0.0201f; } result.factorFromEquipment = verb.verbProps.GetHitChanceFactor(verb.ownerEquipment, result.distance); result.covers = CoverUtility.CalculateCoverGiverSet(cell, caster.Position, caster.Map); result.coversOverallBlockChance = CoverUtility.CalculateOverallBlockChance(cell, caster.Position, caster.Map); result.coveringGas = null; ShootLine shootLine = default(ShootLine); if (verb.TryFindShootLineFromTo(verb.caster.Position, target, out shootLine)) { foreach (IntVec3 item in shootLine.Points()) { Thing gas = item.GetGas(caster.Map); if (gas != null && (result.coveringGas == null || result.coveringGas.gas.accuracyPenalty < gas.def.gas.accuracyPenalty)) { result.coveringGas = gas.def; } } } if (!caster.Position.Roofed(caster.Map) && !target.Cell.Roofed(caster.Map)) { result.factorFromWeather = caster.Map.weatherManager.CurWeatherAccuracyMultiplier; } else { result.factorFromWeather = 1f; } result.factorFromTargetSize = 1f; if (target.HasThing) { Pawn pawn2 = target.Thing as Pawn; if (pawn2 != null) { result.factorFromTargetSize = pawn2.BodySize; } else { result.factorFromTargetSize = (float)(target.Thing.def.fillPercent * 1.7000000476837158); } result.factorFromTargetSize = Mathf.Clamp(result.factorFromTargetSize, 0.5f, 2f); } result.forcedMissRadius = verb.verbProps.forcedMissRadius; return(result); }
public static ShotReport HitReportFor(Thing caster, Verb verb, LocalTargetInfo target) { IntVec3 cell = target.Cell; ShotReport result = default(ShotReport); result.distance = (cell - caster.Position).LengthHorizontal; result.target = target.ToTargetInfo(caster.Map); result.factorFromShooterAndDist = HitFactorFromShooter(caster, result.distance); result.factorFromEquipment = verb.verbProps.GetHitChanceFactor(verb.EquipmentSource, result.distance); result.covers = CoverUtility.CalculateCoverGiverSet(target, caster.Position, caster.Map); result.coversOverallBlockChance = CoverUtility.CalculateOverallBlockChance(target, caster.Position, caster.Map); result.coveringGas = null; if (verb.TryFindShootLineFromTo(verb.caster.Position, target, out result.shootLine)) { foreach (IntVec3 item in result.shootLine.Points()) { Thing gas = item.GetGas(caster.Map); if (gas != null && (result.coveringGas == null || result.coveringGas.gas.accuracyPenalty < gas.def.gas.accuracyPenalty)) { result.coveringGas = gas.def; } } } else { result.shootLine = new ShootLine(IntVec3.Invalid, IntVec3.Invalid); } if (!caster.Position.Roofed(caster.Map) || !target.Cell.Roofed(caster.Map)) { result.factorFromWeather = caster.Map.weatherManager.CurWeatherAccuracyMultiplier; } else { result.factorFromWeather = 1f; } if (target.HasThing) { Pawn pawn = target.Thing as Pawn; if (pawn != null) { result.factorFromTargetSize = pawn.BodySize; } else { result.factorFromTargetSize = target.Thing.def.fillPercent * (float)target.Thing.def.size.x * (float)target.Thing.def.size.z * 2.5f; } result.factorFromTargetSize = Mathf.Clamp(result.factorFromTargetSize, 0.5f, 2f); } else { result.factorFromTargetSize = 1f; } result.forcedMissRadius = verb.verbProps.forcedMissRadius; return(result); }
public static string ShotCalculationTipString(Thing target) { StringBuilder stringBuilder = new StringBuilder(); if (Find.Selector.SingleSelectedThing != null) { Thing singleSelectedThing = Find.Selector.SingleSelectedThing; Verb verb = null; Pawn pawn = singleSelectedThing as Pawn; if (pawn != null && pawn != target && pawn.equipment != null && pawn.equipment.Primary != null && pawn.equipment.PrimaryEq.PrimaryVerb is Verb_LaunchProjectile) { verb = pawn.equipment.PrimaryEq.PrimaryVerb; } Building_TurretGun building_TurretGun = singleSelectedThing as Building_TurretGun; if (building_TurretGun != null && building_TurretGun != target) { verb = building_TurretGun.AttackVerb; } if (verb != null) { stringBuilder.Append("ShotBy".Translate(new object[] { Find.Selector.SingleSelectedThing.LabelShort }) + ": "); if (verb.CanHitTarget(target)) { stringBuilder.Append(ShotReport.HitReportFor(verb.caster, verb, target).GetTextReadout()); } else { stringBuilder.AppendLine("CannotHit".Translate()); } Pawn pawn2 = target as Pawn; if (pawn2 != null && pawn2.Faction == null && !pawn2.InAggroMentalState) { float manhunterOnDamageChance; if (verb.IsMeleeAttack) { manhunterOnDamageChance = PawnUtility.GetManhunterOnDamageChance(pawn2, 0f, singleSelectedThing); } else { manhunterOnDamageChance = PawnUtility.GetManhunterOnDamageChance(pawn2, singleSelectedThing); } if (manhunterOnDamageChance > 0f) { stringBuilder.AppendLine(); stringBuilder.AppendLine(string.Format("{0}: {1}", "ManhunterPerHit".Translate(), manhunterOnDamageChance.ToStringPercent())); } } } } return(stringBuilder.ToString()); }
protected override bool TryCastShot() { if (this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map) { return(false); } ThingDef projectile = this.Projectile; if (projectile == null) { return(false); } ShootLine shootLine; bool flag = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out shootLine); if (this.verbProps.stopBurstWithoutLos && !flag) { return(false); } if (this.ownerEquipment != null) { CompChangeableProjectile comp = this.ownerEquipment.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } } Thing launcher = this.caster; Thing equipment = this.ownerEquipment; CompMannable compMannable = this.caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = this.caster; } Vector3 drawPos = this.caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map); projectile2.FreeIntercept = (this.canFreeInterceptNow && !projectile2.def.projectile.flyOverhead); if (this.verbProps.forcedMissRadius > 0.5f) { float num = (float)(this.currentTarget.Cell - this.caster.Position).LengthHorizontalSquared; float num2; if (num < 9f) { num2 = 0f; } else if (num < 25f) { num2 = this.verbProps.forcedMissRadius * 0.5f; } else if (num < 49f) { num2 = this.verbProps.forcedMissRadius * 0.8f; } else { num2 = this.verbProps.forcedMissRadius * 1f; } if (num2 > 0.5f) { int max = GenRadial.NumCellsInRadius(this.verbProps.forcedMissRadius); int num3 = Rand.Range(0, max); if (num3 > 0) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToForRad", -1f); } IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num3]; if (this.currentTarget.HasThing) { projectile2.ThingToNeverIntercept = this.currentTarget.Thing; } if (!projectile2.def.projectile.flyOverhead) { projectile2.InterceptWalls = true; } projectile2.Launch(launcher, drawPos, c, equipment, this.currentTarget.Thing); return(true); } } } ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); if (Rand.Value > shotReport.ChanceToNotGoWild_IgnoringPosture) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToWild", -1f); } shootLine.ChangeDestToMissWild(); if (this.currentTarget.HasThing) { projectile2.ThingToNeverIntercept = this.currentTarget.Thing; } if (!projectile2.def.projectile.flyOverhead) { projectile2.InterceptWalls = true; } projectile2.Launch(launcher, drawPos, shootLine.Dest, equipment, this.currentTarget.Thing); return(true); } if (Rand.Value > shotReport.ChanceToNotHitCover) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToCover", -1f); } if (this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn) { Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); if (!projectile2.def.projectile.flyOverhead) { projectile2.InterceptWalls = true; } projectile2.Launch(launcher, drawPos, randomCoverToMissInto, equipment, this.currentTarget.Thing); return(true); } } if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToHit", -1f); } if (!projectile2.def.projectile.flyOverhead) { projectile2.InterceptWalls = (!this.currentTarget.HasThing || this.currentTarget.Thing.def.Fillage == FillCategory.Full); } if (this.currentTarget.Thing != null) { projectile2.Launch(launcher, drawPos, this.currentTarget, equipment, this.currentTarget.Thing); } else { projectile2.Launch(launcher, drawPos, shootLine.Dest, equipment, this.currentTarget.Thing); } return(true); }
protected override bool TryCastShot() { if (currentTarget.HasThing && currentTarget.Thing.Map != caster.Map) { return(false); } ThingDef projectile = Projectile; if (projectile == null) { return(false); } ShootLine resultingLine; bool flag = TryFindShootLineFromTo(caster.Position, currentTarget, out resultingLine); if (verbProps.stopBurstWithoutLos && !flag) { return(false); } if (base.EquipmentSource != null) { base.EquipmentSource.GetComp <CompChangeableProjectile>()?.Notify_ProjectileLaunched(); base.EquipmentSource.GetComp <CompReloadable>()?.UsedOnce(); } Thing launcher = caster; Thing equipment = base.EquipmentSource; CompMannable compMannable = caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = caster; } Vector3 drawPos = caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, resultingLine.Source, caster.Map); if (verbProps.forcedMissRadius > 0.5f) { float num = VerbUtility.CalculateAdjustedForcedMiss(verbProps.forcedMissRadius, currentTarget.Cell - caster.Position); if (num > 0.5f) { int max = GenRadial.NumCellsInRadius(num); int num2 = Rand.Range(0, max); if (num2 > 0) { IntVec3 c = currentTarget.Cell + GenRadial.RadialPattern[num2]; ThrowDebugText("ToRadius"); ThrowDebugText("Rad\nDest", c); ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f)) { projectileHitFlags = ProjectileHitFlags.All; } if (!canHitNonTargetPawnsNow) { projectileHitFlags &= ~ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, c, currentTarget, projectileHitFlags, equipment); return(true); } } } ShotReport shotReport = ShotReport.HitReportFor(caster, this, currentTarget); Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); ThingDef targetCoverDef = randomCoverToMissInto?.def; if (!Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture)) { resultingLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget); ThrowDebugText("ToWild" + (canHitNonTargetPawnsNow ? "\nchntp" : "")); ThrowDebugText("Wild\nDest", resultingLine.Dest); ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f) && canHitNonTargetPawnsNow) { projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, resultingLine.Dest, currentTarget, projectileHitFlags2, equipment, targetCoverDef); return(true); } if (currentTarget.Thing != null && currentTarget.Thing.def.category == ThingCategory.Pawn && !Rand.Chance(shotReport.PassCoverChance)) { ThrowDebugText("ToCover" + (canHitNonTargetPawnsNow ? "\nchntp" : "")); ThrowDebugText("Cover\nDest", randomCoverToMissInto.Position); ProjectileHitFlags projectileHitFlags3 = ProjectileHitFlags.NonTargetWorld; if (canHitNonTargetPawnsNow) { projectileHitFlags3 |= ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, randomCoverToMissInto, currentTarget, projectileHitFlags3, equipment, targetCoverDef); return(true); } ProjectileHitFlags projectileHitFlags4 = ProjectileHitFlags.IntendedTarget; if (canHitNonTargetPawnsNow) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetPawns; } if (!currentTarget.HasThing || currentTarget.Thing.def.Fillage == FillCategory.Full) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetWorld; } ThrowDebugText("ToHit" + (canHitNonTargetPawnsNow ? "\nchntp" : "")); if (currentTarget.Thing != null) { projectile2.Launch(launcher, drawPos, currentTarget, currentTarget, projectileHitFlags4, equipment, targetCoverDef); ThrowDebugText("Hit\nDest", currentTarget.Cell); } else { projectile2.Launch(launcher, drawPos, resultingLine.Dest, currentTarget, projectileHitFlags4, equipment, targetCoverDef); ThrowDebugText("Hit\nDest", resultingLine.Dest); } return(true); }
// Token: 0x060064F4 RID: 25844 RVA: 0x001B8C14 File Offset: 0x001B7014 protected override bool TryCastShot() { // Log.Message(string.Format("{0}, {1}, {2}, {3}", CasterPawn.equipment.Primary != null , CasterPawn.equipment.Primary.def.IsRangedWeapon , CasterPawn.equipment.PrimaryEq.PrimaryVerb.HarmsHealth() , !CasterPawn.equipment.PrimaryEq.PrimaryVerb.UsesExplosiveProjectiles())); if (this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map) { return(false); } ThingDef projectile = this.Projectile; if (projectile == null) { return(false); } bool flag = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out ShootLine shootLine); if (this.verbProps.stopBurstWithoutLos && !flag) { return(false); } if (base.EquipmentSource != null) { CompChangeableProjectile comp = base.EquipmentSource.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } } Thing launcher = this.caster; Thing equipment = base.EquipmentSource; CompMannable compMannable = this.caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = this.caster; } Vector3 drawPos = this.caster.DrawPos; Stuffable_Projectile projectile2 = (Stuffable_Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map, WipeMode.Vanish); if (this.verbProps.forcedMissRadius > 0.5f) { float num = VerbUtility.CalculateAdjustedForcedMiss(this.verbProps.forcedMissRadius, this.currentTarget.Cell - this.caster.Position); if (num > 0.5f) { int max = GenRadial.NumCellsInRadius(num); int num2 = Rand.Range(0, max); if (num2 > 0) { IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num2]; this.ThrowDebugText("ToRadius"); this.ThrowDebugText("Rad\nDest", c); ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f)) { projectileHitFlags = ProjectileHitFlags.All; } if (!this.canHitNonTargetPawnsNow) { projectileHitFlags &= ~ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, c, this.currentTarget, projectileHitFlags, equipment, null); return(true); } } } ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); ThingDef targetCoverDef = randomCoverToMissInto?.def; if (!Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture)) { shootLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget); this.ThrowDebugText("ToWild" + ((!this.canHitNonTargetPawnsNow) ? string.Empty : "\nchntp")); this.ThrowDebugText("Wild\nDest", shootLine.Dest); ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f) && this.canHitNonTargetPawnsNow) { projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags2, equipment, targetCoverDef); return(true); } if (this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn && !Rand.Chance(shotReport.PassCoverChance)) { this.ThrowDebugText("ToCover" + ((!this.canHitNonTargetPawnsNow) ? string.Empty : "\nchntp")); this.ThrowDebugText("Cover\nDest", randomCoverToMissInto.Position); ProjectileHitFlags projectileHitFlags3 = ProjectileHitFlags.NonTargetWorld; if (this.canHitNonTargetPawnsNow) { projectileHitFlags3 |= ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, randomCoverToMissInto, this.currentTarget, projectileHitFlags3, equipment, targetCoverDef); return(true); } ProjectileHitFlags projectileHitFlags4 = ProjectileHitFlags.IntendedTarget; if (this.canHitNonTargetPawnsNow) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetPawns; } if (!this.currentTarget.HasThing || this.currentTarget.Thing.def.Fillage == FillCategory.Full) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetWorld; } this.ThrowDebugText("ToHit" + ((!this.canHitNonTargetPawnsNow) ? string.Empty : "\nchntp")); if (this.currentTarget.Thing != null) { projectile2.Launch(launcher, drawPos, this.currentTarget, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", this.currentTarget.Cell); } else { projectile2.Launch(launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", shootLine.Dest); } return(true); }
public static float HitFactorFromShooter(Thing caster, float distance) { float accRating = (!(caster is Pawn)) ? caster.GetStatValue(StatDefOf.ShootingAccuracyTurret, true) : caster.GetStatValue(StatDefOf.ShootingAccuracyPawn, true); return(ShotReport.HitFactorFromShooter(accRating, distance)); }
// Token: 0x06000006 RID: 6 RVA: 0x0000225C File Offset: 0x0000045C protected override bool TryCastShot() { bool flag = this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map; bool result; if (flag) { result = false; } else { ThingDef projectile = this.Projectile; bool flag2 = projectile == null; if (flag2) { result = false; } else { ShootLine shootLine; bool flag3 = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out shootLine); bool flag4 = this.verbProps.stopBurstWithoutLos && !flag3; if (flag4) { result = false; } else { bool flag5 = this.EquipmentSource != null; if (flag5) { CompChangeableProjectile comp = this.EquipmentSource.GetComp <CompChangeableProjectile>(); bool flag6 = comp != null; if (flag6) { comp.Notify_ProjectileLaunched(); } } Thing thing = this.caster; Thing thing2 = this.EquipmentSource; CompMannable compMannable = this.caster.TryGetComp <CompMannable>(); bool flag7 = compMannable != null && compMannable.ManningPawn != null; if (flag7) { thing = compMannable.ManningPawn; thing2 = this.caster; } Vector3 drawPos = this.caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map); int num = this.PelletsPerShot(projectile); bool flag8 = num < 1; if (flag8) { num = 1; } Projectile[] array = new Projectile[num]; ShootLine[] array2 = new ShootLine[num]; for (int i = 0; i < num; i++) { base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out array2[i]); array[i] = (Projectile)GenSpawn.Spawn(projectile, array2[i].Source, this.caster.Map); //array[i].FreeIntercept = (this.canFreeInterceptNow && !array[i].def.projectile.flyOverhead); } float num2 = (this.currentTarget.Cell - this.caster.Position).LengthHorizontal; float num3 = this.ScatterRadiusAt10tilesAway(projectile) * num2 / 10f; float num4 = this.verbProps.forcedMissRadius + this.ForsedScatterRadius(projectile) + num3; int j = 0; while (j < num) { bool flag9 = num4 > 0.5f; if (!flag9) { goto IL_41E; } float num5 = (float)(this.currentTarget.Cell - this.caster.Position).LengthHorizontalSquared; bool flag10 = num5 < 9f; float num6; if (flag10) { num6 = 0f; } else { bool flag11 = num5 < 25f; if (flag11) { num6 = num4 * 0.5f; } else { bool flag12 = num5 < 49f; if (flag12) { num6 = num4 * 0.8f; } else { num6 = num4 * 1f; } } } bool flag13 = num6 > 0.5f; if (!flag13) { goto IL_41E; } int max = GenRadial.NumCellsInRadius(num4); int num7 = Rand.Range(0, max); bool flag14 = num7 > 0; if (flag14) { bool drawShooting = DebugViewSettings.drawShooting; if (drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToForRad", -1f); } bool hasThing = this.currentTarget.HasThing; if (hasThing) { array[j].HitFlags = ProjectileHitFlags.All; //array[j].ThingToNeverIntercept = this.currentTarget.Thing; } bool flag15 = !array[j].def.projectile.flyOverhead; if (flag15) { array[j].HitFlags = ProjectileHitFlags.IntendedTarget; } IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num7]; array[j].Launch(thing, origin: drawPos, usedTarget: new LocalTargetInfo(c), intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); } else { array[j].Launch(thing, origin: drawPos, usedTarget: new LocalTargetInfo(this.currentTarget.Cell), intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); //array[j].Launch(thing, drawPos, this.currentTarget.Cell, thing2, this.currentTarget.Thing); } IL_6D8: j++; continue; IL_41E: ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); bool flag16 = Rand.Value > shotReport.AimOnTargetChance_IgnoringPosture; if (flag16) { bool drawShooting2 = DebugViewSettings.drawShooting; if (drawShooting2) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToWild", -1f); } array2[j].ChangeDestToMissWild(shotReport.AimOnTargetChance); bool hasThing2 = this.currentTarget.HasThing; if (hasThing2) { array[j].HitFlags = ProjectileHitFlags.All; //array[j].ThingToNeverIntercept = this.currentTarget.Thing; } bool flag17 = !array[j].def.projectile.flyOverhead; if (flag17) { array[j].HitFlags = ProjectileHitFlags.IntendedTarget; //array[j].InterceptWalls = true; } array[j].Launch(thing, origin: drawPos, usedTarget: new LocalTargetInfo(array2[j].Dest), intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); //array[j].Launch(thing, drawPos, array2[j].Dest, thing2, this.currentTarget.Thing); goto IL_6D8; } bool flag18 = Rand.Value > shotReport.PassCoverChance; if (flag18) { bool drawShooting3 = DebugViewSettings.drawShooting; if (drawShooting3) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToCover", -1f); } bool flag19 = this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn; if (flag19) { Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); bool flag20 = !array[j].def.projectile.flyOverhead; if (flag20) { array[j].HitFlags = ProjectileHitFlags.IntendedTarget; } array[j].Launch(thing, origin: drawPos, usedTarget: new LocalTargetInfo(randomCoverToMissInto), intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); //array[j].Launch(thing, drawPos, randomCoverToMissInto, thing2, this.currentTarget.Thing); goto IL_6D8; } } bool drawShooting4 = DebugViewSettings.drawShooting; if (drawShooting4) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToHit", -1f); } bool flag21 = !array[j].def.projectile.flyOverhead && (!this.currentTarget.HasThing || this.currentTarget.Thing.def.Fillage == FillCategory.Full); if (flag21) { array[j].HitFlags = ProjectileHitFlags.IntendedTarget; } bool flag22 = this.currentTarget.Thing != null; if (flag22) { array[j].Launch(thing, origin: drawPos, usedTarget: currentTarget, intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); //array[j].Launch(thing, drawPos, this.currentTarget, thing2, this.currentTarget.Thing); } else { array[j].Launch(thing, origin: drawPos, usedTarget: new LocalTargetInfo(array2[j].Dest), intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); //array[j].Launch(thing, drawPos, array2[j].Dest, thing2, this.currentTarget.Thing); } goto IL_6D8; } result = true; } } } return(result); }
protected override bool TryCastShot() { if (this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map) { return(false); } // ThingDef projectile = this.Projectile; ThingDef projectile = this.Projectile; // projectile.projectileWhenLoaded. if (projectile == null) { return(false); } ShootLine shootLine; bool flag = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out shootLine); if (this.verbProps.stopBurstWithoutLos && !flag) { return(false); } if (this.EquipmentSource != null) { CompChangeableProjectile comp = this.EquipmentSource.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } } Thing launcher = this.caster; Thing equipment = this.EquipmentSource; CompMannable compMannable = this.caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = this.caster; } Vector3 drawPos = this.caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map); //--------------- int pellets = this.PelletsPerShot(projectile); if (pellets < 1) { pellets = 1; } Projectile[] projectiles = new Projectile[pellets]; ShootLine[] shootLines = new ShootLine[pellets]; for (int i = 0; i < pellets; i++) { base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out shootLines[i]); projectiles[i] = (Projectile)GenSpawn.Spawn(projectile, shootLines[i].Source, this.caster.Map); //projectiles[i].FreeIntercept = (this.canFreeInterceptNow && !projectiles[i].def.projectile.flyOverhead); } //projectile2.FreeIntercept = (this.canFreeInterceptNow && !projectile2.def.projectile.flyOverhead); //projectile3.FreeIntercept = (this.canFreeInterceptNow && !projectile2.def.projectile.flyOverhead); //projectile4.FreeIntercept = (this.canFreeInterceptNow && !projectile2.def.projectile.flyOverhead); float distance = (float)(this.currentTarget.Cell - this.caster.Position).LengthHorizontal; float scatter = ScatterRadiusAt10tilesAway(projectile) * distance / 10.0f; float missRadius = this.verbProps.forcedMissRadius + ForsedScatterRadius(projectile) + scatter; for (int i = 0; i < pellets; i++) { if (missRadius > 0.5f) { float num = (float)(this.currentTarget.Cell - this.caster.Position).LengthHorizontalSquared; float num2; if (num < 9f) { num2 = 0f; } else if (num < 25f) { num2 = missRadius * 0.5f; } else if (num < 49f) { num2 = missRadius * 0.8f; } else { num2 = missRadius * 1f; } if (num2 > 0.5f) { int max = GenRadial.NumCellsInRadius(missRadius); //int num3 = Rand.Range(0, max); int num3 = Rand.Range(0, max); if (num3 > 0) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToForRad", -1f); } //if (this.currentTarget.HasThing) //{ // // projectile2.ThingToNeverIntercept = this.currentTarget.Thing; // projectiles[i].ThingToNeverIntercept = this.currentTarget.Thing; //} //if (!projectiles[i].def.projectile.flyOverhead) //{ // projectiles[i].InterceptWalls = true; //} IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num3]; projectiles[i].Launch(launcher, origin: drawPos, usedTarget: new LocalTargetInfo(c), intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectile2.Launch(launcher, drawPos, c, equipment, this.currentTarget.Thing); //projectile3.Launch(launcher, drawPos, c, equipment, this.currentTarget.Thing); //projectile4.Launch(launcher, drawPos, c, equipment, this.currentTarget.Thing); continue;// return true; } else { projectiles[i].Launch(launcher, origin: drawPos, usedTarget: new LocalTargetInfo(this.currentTarget.Cell), intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectiles[i].Launch(launcher, drawPos, this.currentTarget.Cell, equipment, this.currentTarget.Thing); continue; } } } ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); if (Rand.Value > shotReport.AimOnTargetChance_IgnoringPosture) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToWild", -1f); } shootLines[i].ChangeDestToMissWild(shotReport.AimOnTargetChance); // shootLine2.ChangeDestToMissWild(); if (this.currentTarget.HasThing) { projectiles[i].HitFlags = ProjectileHitFlags.All; // projectile2.ThingToNeverIntercept = this.currentTarget.Thing; } if (!projectiles[i].def.projectile.flyOverhead) { projectiles[i].HitFlags = ProjectileHitFlags.IntendedTarget; } projectiles[i].Launch(launcher, origin: drawPos, usedTarget: new LocalTargetInfo(shootLines[i].Dest), intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectiles[i].Launch(launcher, drawPos, shootLines[i].Dest, equipment, this.currentTarget.Thing); //projectile2.Launch(launcher, drawPos, shootLine2.Dest, equipment, this.currentTarget.Thing); continue;//return true; } if (Rand.Value > shotReport.PassCoverChance) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToCover", -1f); } if (this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn) { Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); if (!projectiles[i].def.projectile.flyOverhead) { projectiles[i].HitFlags = ProjectileHitFlags.IntendedTarget; } projectiles[i].Launch(launcher, origin: drawPos, usedTarget: new LocalTargetInfo(randomCoverToMissInto), intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectiles[i].Launch(launcher, drawPos, randomCoverToMissInto, equipment, this.currentTarget.Thing); //projectile2.Launch(launcher, drawPos, randomCoverToMissInto, equipment, this.currentTarget.Thing); continue;//return true; } } if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToHit", -1f); } if (!projectiles[i].def.projectile.flyOverhead && (!this.currentTarget.HasThing || this.currentTarget.Thing.def.Fillage == FillCategory.Full)) { projectiles[i].HitFlags = ProjectileHitFlags.IntendedTarget; } if (this.currentTarget.Thing != null) { projectiles[i].Launch(launcher, origin: drawPos, usedTarget: currentTarget, intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectiles[i].Launch(launcher, drawPos, this.currentTarget, equipment, this.currentTarget.Thing); } else { projectiles[i].Launch(launcher, origin: drawPos, usedTarget: new LocalTargetInfo(shootLines[i].Dest), intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectiles[i].Launch(launcher, drawPos, shootLines[i].Dest, equipment, this.currentTarget.Thing); } } return(true); }