// Token: 0x06002252 RID: 8786 RVA: 0x000D128C File Offset: 0x000CF48C 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 (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; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map, WipeMode.Vanish); ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); ThingDef targetCoverDef = (randomCoverToMissInto != null) ? randomCoverToMissInto.def : null; ProjectileHitFlags projectileHitFlags4 = ProjectileHitFlags.IntendedTarget; this.ThrowDebugText("ToHit" + (this.canHitNonTargetPawnsNow ? "\nchntp" : "")); if (this.currentTarget.Thing != null) { projectile2.Launch(launcher, drawPos, this.currentTarget, this.currentTarget, projectileHitFlags4, false, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", this.currentTarget.Cell); } else { projectile2.Launch(launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags4, false, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", shootLine.Dest); } return(true); }
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); }
// 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); }
// Token: 0x0600651E RID: 25886 RVA: 0x001B8BC0 File Offset: 0x001B6FC0 public static bool TryCastExtraShot(ref AbilitesExtended.Verb_EquipmentLaunchProjectile __instance, LocalTargetInfo currentTarget, bool canHitNonTargetPawnsNow) { if (currentTarget.HasThing && currentTarget.Thing.Map != __instance.caster.Map) { return(false); } ThingDef projectile = __instance.Projectile; if (projectile == null) { return(false); } ShootLine shootLine; bool flag = __instance.TryFindShootLineFromTo(__instance.caster.Position, currentTarget, out shootLine); if (__instance.verbProps.stopBurstWithoutLos && !flag) { return(false); } if (__instance.EquipmentSource != null) { CompChangeableProjectile comp = __instance.EquipmentSource.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } } Thing launcher = __instance.caster; Thing equipment = __instance.EquipmentSource; CompMannable compMannable = __instance.caster.TryGetCompFast <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = __instance.caster; } Vector3 drawPos = __instance.caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, __instance.caster.Map, WipeMode.Vanish); if (__instance.verbProps.forcedMissRadius > 0.5f) { float num = VerbUtility.CalculateAdjustedForcedMiss(__instance.verbProps.forcedMissRadius, currentTarget.Cell - __instance.caster.Position); if (num > 0.5f) { int max = GenRadial.NumCellsInRadius(num); Rand.PushState(); int num2 = Rand.Range(0, max); Rand.PopState(); if (num2 > 0) { IntVec3 c = currentTarget.Cell + GenRadial.RadialPattern[num2]; ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.NonTargetWorld; Rand.PushState(); if (Rand.Chance(0.5f)) { projectileHitFlags = ProjectileHitFlags.All; } Rand.PopState(); if (!canHitNonTargetPawnsNow) { projectileHitFlags &= ~ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, c, currentTarget, projectileHitFlags, equipment, null); return(true); } } } ShotReport shotReport = ShotReport.HitReportFor(__instance.caster, __instance, currentTarget); Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); ThingDef targetCoverDef = randomCoverToMissInto?.def; Rand.PushState(); bool f1 = !Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture); Rand.PopState(); if (f1) { shootLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget); ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld; Rand.PushState(); if (Rand.Chance(0.5f) && canHitNonTargetPawnsNow) { projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns; } Rand.PopState(); projectile2.Launch(launcher, drawPos, shootLine.Dest, currentTarget, projectileHitFlags2, equipment, targetCoverDef); return(true); } Rand.PushState(); bool f2 = !Rand.Chance(shotReport.PassCoverChance); Rand.PopState(); if (currentTarget.Thing != null && currentTarget.Thing.def.category == ThingCategory.Pawn && f2) { 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; } if (currentTarget.Thing != null) { projectile2.Launch(launcher, drawPos, currentTarget, currentTarget, projectileHitFlags4, equipment, targetCoverDef); } else { projectile2.Launch(launcher, drawPos, shootLine.Dest, currentTarget, projectileHitFlags4, equipment, targetCoverDef); } return(true); }
// Token: 0x060057CC RID: 22476 RVA: 0x0017B880 File Offset: 0x00179C80 protected override bool TryCastShot() { //If we are aiming at something real on the map if (this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map) { return(false); } ThingDef projectile = this.Projectile; if (projectile == null) { return(false); } //Check to see if we have line of sight 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) { //!!!!!!!!!!!!!!!! This could be used to subtract from a battery pack comp.Notify_ProjectileLaunched(); } } //Launcher is the user; equipment is what is being used to shoot 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; } //This drawPos may need to be modified so that the beam emerges from the weapon and not the user Vector3 drawPos = this.caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map); //Can the projectile strike something on its flightpath? projectile2.FreeIntercept = (this.canFreeInterceptNow && !projectile2.def.projectile.flyOverhead); //ShotReport gives us our chance that the shot actual hit ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); //If the shot was a miss... if (Rand.Value > shotReport.ChanceToNotGoWild_IgnoringPosture) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToWild", -1f); } //Modify the shoot line to hit something else shootLine.ChangeDestToMissWild(); if (this.currentTarget.HasThing) { //Ensure that the projectile actually hits something else projectile2.ThingToNeverIntercept = this.currentTarget.Thing; } if (!projectile2.def.projectile.flyOverhead) { projectile2.InterceptWalls = true; } //Launch doomed projectile for shootLine's bad destination //Consider giving the beam projectile a function to switch destinations when something gets between launcher and shootLine.Dest 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); }
public bool FireProjectile() { if (base.currentTarget.HasThing && base.currentTarget.Thing.Map != base.caster.Map) { return(false); } ThingDef projectile = this.Projectile; if (projectile == null) { return(false); } ShootLine shootLine = default(ShootLine); bool flag = base.TryFindShootLineFromTo(base.caster.Position, base.currentTarget, out shootLine); if (base.verbProps.stopBurstWithoutLos && !flag) { return(false); } if (base.EquipmentSource != null) { CompChangeableProjectile comp = base.EquipmentSource.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } } Thing launcher = base.caster; Thing equipment = base.EquipmentSource; CompMannable compMannable = base.caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = base.caster; // Earn skills if (compMannable.ManningPawn.skills != null) { int skillsAffectingAccuracy = 0; if (Settings.intellectualAffectsMortarAccuracy) { skillsAffectingAccuracy++; } if (Settings.shootingAffectsMortarAccuracy) { skillsAffectingAccuracy++; } float skillXP = verbProps.AdjustedFullCycleTime(this, CasterPawn) * 100; skillXP /= skillsAffectingAccuracy; if (Settings.intellectualAffectsMortarAccuracy) { compMannable.ManningPawn.skills.Learn(SkillDefOf.Intellectual, skillXP, false); } if (Settings.shootingAffectsMortarAccuracy) { compMannable.ManningPawn.skills.Learn(SkillDefOf.Shooting, skillXP, false); } } } Vector3 drawPos = base.caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, base.caster.Map, WipeMode.Vanish); // If targetting a pawn if (Settings.targetLeading) { if (currentTarget != null && currentTarget.Thing != null && currentTarget.Thing is Pawn targetPawn && targetPawn.pather.curPath != null) { List <IntVec3> nodes = new List <IntVec3>(targetPawn.pather.curPath.NodesReversed); nodes.Reverse(); // Purge outdated nodes from list for (int i = 0; i < nodes.Count; i++) { if (nodes[i] == targetPawn.Position) { // Remove all previous nodes nodes.RemoveRange(0, i); //Log.Message("Removed " + i + " entries. First node is now " + nodes[0].ToString()); break; } } // Path of target pawn from current to destination // Need travel speed of pawn, estimate Vec3 they will be in based on travel speed of our projectile float targetMoveSpeed = targetPawn.GetStatValue(StatDefOf.MoveSpeed); float projectileMoveSpeed = projectile.projectile.speed; // Estimate position target will be in after this amount of time IntVec3 bestTarget = targetPawn.Position; float bestTimeOffset = float.MaxValue; //Log.Message("Default time offset = " + Mathf.Abs(((targetPawn.Position - caster.Position).LengthHorizontal) / projectileMoveSpeed)); float accumulatedTargetTime = 0f; IntVec3 previousPosition = targetPawn.Position; foreach (IntVec3 pathPosition in nodes) { float projectileDistanceFromTarget = (pathPosition - caster.Position).LengthHorizontal; float timeForProjectileToReachPosition = projectileDistanceFromTarget / projectileMoveSpeed; //float pawnDistanceFromTarget = (pathPosition - targetPawn.Position).LengthHorizontal; //float timeForPawnToReachPosition = pawnDistanceFromTarget / targetMoveSpeed; float pawnDistanceFromLastPositionToHere = (pathPosition - previousPosition).LengthHorizontal; float timeForPawnToReachPositionFromLastPosition = pawnDistanceFromLastPositionToHere / targetMoveSpeed; accumulatedTargetTime += timeForPawnToReachPositionFromLastPosition; float timeOffset = Mathf.Abs(timeForProjectileToReachPosition - accumulatedTargetTime); if (timeOffset < bestTimeOffset) { bestTarget = pathPosition; bestTimeOffset = timeOffset; //Log.Message("Position " + pathPosition.ToString() + " is better. Time offset is " + timeOffset); } else { //Log.Message("Position " + pathPosition.ToString() + " is not better. Time offset is " + timeOffset); } previousPosition = pathPosition; } //Log.Message("Initial target cell = " + currentTarget.Cell.ToString() + " and new target is " + bestTarget.ToString()); currentTarget = new LocalTargetInfo(bestTarget); } } if (base.verbProps.forcedMissRadius > 0.5f) { float adjustedForcedMissRadius = GetAdjustedForcedMissRadius(); ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.All; IntVec3 c = currentTarget.Cell; if (adjustedForcedMissRadius > 0.5f) { int max = GenRadial.NumCellsInRadius(adjustedForcedMissRadius); int num2 = Rand.Range(0, max); c = base.currentTarget.Cell + GenRadial.RadialPattern[num2]; /*if (num2 > 0) * { * this.ThrowDebugText("ToRadius"); * this.ThrowDebugText("Rad\nDest", c); * ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.NonTargetWorld; * if (Rand.Chance(0.5f)) * { * projectileHitFlags = ProjectileHitFlags.All; * } * if (!base.canHitNonTargetPawnsNow) * { * projectileHitFlags &= ~ProjectileHitFlags.NonTargetPawns; * } * projectile2.Launch(launcher, drawPos, c, base.currentTarget, projectileHitFlags, equipment, null); * return true; * }*/ } //Log.Message("Final target is " + c.ToString()); projectile2.Launch(launcher, drawPos, c, base.currentTarget, projectileHitFlags, equipment, null); return(true); } ShotReport shotReport = ShotReport.HitReportFor(base.caster, this, base.currentTarget); Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); ThingDef targetCoverDef = (randomCoverToMissInto == null) ? null : randomCoverToMissInto.def; /*if (!Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture)) * { * shootLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget); * this.ThrowDebugText("ToWild" + ((!base.canHitNonTargetPawnsNow) ? string.Empty : "\nchntp")); * this.ThrowDebugText("Wild\nDest", shootLine.Dest); * ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld; * if (Rand.Chance(0.5f) && base.canHitNonTargetPawnsNow) * { * projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns; * } * projectile2.Launch(launcher, drawPos, shootLine.Dest, base.currentTarget, projectileHitFlags2, equipment, targetCoverDef); * return true; * }*/ /*if (base.currentTarget.Thing != null && base.currentTarget.Thing.def.category == ThingCategory.Pawn && !Rand.Chance(shotReport.PassCoverChance)) * { * this.ThrowDebugText("ToCover" + ((!base.canHitNonTargetPawnsNow) ? string.Empty : "\nchntp")); * this.ThrowDebugText("Cover\nDest", randomCoverToMissInto.Position); * ProjectileHitFlags projectileHitFlags3 = ProjectileHitFlags.NonTargetWorld; * if (base.canHitNonTargetPawnsNow) * { * projectileHitFlags3 |= ProjectileHitFlags.NonTargetPawns; * } * projectile2.Launch(launcher, drawPos, randomCoverToMissInto, base.currentTarget, projectileHitFlags3, equipment, targetCoverDef); * return true; * }*/ ProjectileHitFlags projectileHitFlags4 = ProjectileHitFlags.IntendedTarget; if (base.canHitNonTargetPawnsNow) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetPawns; } if (!base.currentTarget.HasThing || base.currentTarget.Thing.def.Fillage == FillCategory.Full) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetWorld; } this.ThrowDebugText("ToHit" + ((!base.canHitNonTargetPawnsNow) ? string.Empty : "\nchntp")); if (base.currentTarget.Thing != null) { projectile2.Launch(launcher, drawPos, base.currentTarget, base.currentTarget, projectileHitFlags4, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", base.currentTarget.Cell); } else { projectile2.Launch(launcher, drawPos, shootLine.Dest, base.currentTarget, projectileHitFlags4, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", shootLine.Dest); } return(true); }
// Token: 0x06002252 RID: 8786 RVA: 0x000D128C File Offset: 0x000CF48C protected bool base_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 (base.EquipmentSource != null) { CompChangeableProjectile comp = base.EquipmentSource.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } //修改精度 if (CompShootMode != null) { CompShootMode.PostPreEachShoot(this); } } 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; Projectile projectile2 = (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; } LanuchWithDamageMultiplier(projectile2, 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 != null) ? randomCoverToMissInto.def : null; if (!Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture)) { shootLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget); this.ThrowDebugText("ToWild" + (this.canHitNonTargetPawnsNow ? "\nchntp" : "")); this.ThrowDebugText("Wild\nDest", shootLine.Dest); ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f) && this.canHitNonTargetPawnsNow) { projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns; } LanuchWithDamageMultiplier(projectile2, 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 ? "\nchntp" : "")); this.ThrowDebugText("Cover\nDest", randomCoverToMissInto.Position); ProjectileHitFlags projectileHitFlags3 = ProjectileHitFlags.NonTargetWorld; if (this.canHitNonTargetPawnsNow) { projectileHitFlags3 |= ProjectileHitFlags.NonTargetPawns; } LanuchWithDamageMultiplier(projectile2, 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 ? "\nchntp" : "")); if (this.currentTarget.Thing != null) { LanuchWithDamageMultiplier(projectile2, launcher, drawPos, this.currentTarget, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", this.currentTarget.Cell); } else { LanuchWithDamageMultiplier(projectile2, launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", shootLine.Dest); } return(true); }
protected override (bool success, Vector3 launchPos, float angle) TryCastShotInternal() { IntVec3 exitTarget = caster.Position.CellFromDistAngle(Building_Artillery.MaxMapDistance, heading); if (!target.HasWorldObject && !target.HasThing) { return(false, Vector3.zero, 0); } ThingDef projectile = Projectile; if (projectile is null) { return(false, Vector3.zero, 0); } bool flag = TryFindShootLineFromTo(caster.Position, exitTarget, out ShootLine shootLine); if (verbProps.stopBurstWithoutLos && !flag) { return(false, Vector3.zero, 0); } if (EquipmentSource != null) { CompChangeableProjectile comp = EquipmentSource.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } CompReloadable comp2 = EquipmentSource.GetComp <CompReloadable>(); if (comp2 != null) { comp2.UsedOnce(); } } Thing launcher = caster; Thing equipment = EquipmentSource; CompMannable compMannable = caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = caster; } Vector3 launchPos = caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, caster.Position, caster.Map, WipeMode.Vanish); if (projectile2.AllComps.NullOrEmpty()) { AccessTools.Field(typeof(ThingWithComps), "comps").SetValue(projectile2, new List <ThingComp>()); } projectile2.AllComps.Add(new CompProjectileExitMap(CasterTWC) { airDefenseDef = AntiAircraftDefOf.FlakProjectile, target = target.WorldObject as AerialVehicleInFlight, spawnPos = Building_Artillery.RandomWorldPosition(caster.Map.Tile, 1).FirstOrDefault() }); if (caster.def.GetModExtension <ProjectilePropertiesDefModExtension>() is ProjectilePropertiesDefModExtension projectileProps) { projectile2.AllComps.Add(new CompTurretProjectileProperties(CasterTWC) { speed = projectileProps.speed > 0 ? projectileProps.speed : projectile2.def.projectile.speed, hitflag = ProjectileHitFlags.IntendedTarget, hitflags = null }); } ThrowDebugText("ToHit" + (canHitNonTargetPawnsNow ? "\nchntp" : "")); launchPos += new Vector3(VerbProps.shootOffset.x, 0, VerbProps.shootOffset.y).RotatedBy(heading); projectile2.Launch(launcher, launchPos, exitTarget, exitTarget, ProjectileHitFlags.IntendedTarget, equipment); ThrowDebugText("Hit\nDest", shootLine.Dest); return(true, launchPos, heading); }
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 (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; } /* * if (equipment == null) * { * Log.Message("equipment==null"); * } * else * { * Log.Message(equipment.LabelShortCap); * } */ Vector3 drawPos = this.caster.DrawPos; Projectile projectile2 = (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); Rand.PushState(); int num2 = Rand.Range(0, max); Rand.PopState(); if (num2 > 0) { IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num2]; this.ThrowDebugText("ToRadius"); this.ThrowDebugText("Rad\nDest", c); ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.NonTargetWorld; Rand.PushState(); if (Rand.Chance(0.5f)) { projectileHitFlags = ProjectileHitFlags.All; } Rand.PopState(); if (!this.canHitNonTargetPawnsNow) { projectileHitFlags &= ~ProjectileHitFlags.NonTargetPawns; } // Log.Message("EquipmentAbility projectile2.Launch forcedMissRadius"); 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 != null) ? randomCoverToMissInto.def : null; Rand.PushState(); bool AimOnTarget = Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture); Rand.PopState(); if (!AimOnTarget) { shootLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget); this.ThrowDebugText("ToWild" + (this.canHitNonTargetPawnsNow ? "\nchntp" : "")); this.ThrowDebugText("Wild\nDest", shootLine.Dest); ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld; Rand.PushState(); if (Rand.Chance(0.5f) && this.canHitNonTargetPawnsNow) { projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns; } Rand.PopState(); projectile2.Launch(launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags2, equipment, targetCoverDef); // Log.Message("EquipmentAbility projectile2.Launch OffTarget"); return(true); } Rand.PushState(); bool PassCover = Rand.Chance(shotReport.PassCoverChance); Rand.PopState(); if (this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn && !PassCover) { this.ThrowDebugText("ToCover" + (this.canHitNonTargetPawnsNow ? "\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); // Log.Message("EquipmentAbility projectile2.Launch IntoCover"); 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 ? "\nchntp" : "")); if (this.currentTarget.Thing != null) { projectile2.Launch(launcher, drawPos, this.currentTarget, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef); // Log.Message("EquipmentAbility projectile2.Launch NoThing"); this.ThrowDebugText("Hit\nDest", this.currentTarget.Cell); } else { projectile2.Launch(launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef); // Log.Message("EquipmentAbility projectile2.Launch AtThing"); this.ThrowDebugText("Hit\nDest", shootLine.Dest); } return(true); // return this.ability.Activate(this.currentTarget, this.currentDestination); }
// 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); }
// Token: 0x0600640C RID: 25612 RVA: 0x001B4770 File Offset: 0x001B2B70 protected override bool TryCastShot() { if (this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map) { return(false); } ShootLine shootLine; bool flag = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out 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; SpawnBeam(); hitThing(); ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); ThingDef targetCoverDef = (randomCoverToMissInto == null) ? null : randomCoverToMissInto.def; if (!Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture)) { shootLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget); ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f) && this.canHitNonTargetPawnsNow) { projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns; } return(true); } if (this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn && !Rand.Chance(shotReport.PassCoverChance)) { ProjectileHitFlags projectileHitFlags3 = ProjectileHitFlags.NonTargetWorld; if (this.canHitNonTargetPawnsNow) { projectileHitFlags3 |= ProjectileHitFlags.NonTargetPawns; } 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; } return(true); }
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); }
//[HarmonyPrefix] static bool Prefix(ref bool __result, Verb_LaunchProjectile __instance, LocalTargetInfo ___currentTarget) { if (__instance.verbProps.forcedMissRadius < 0.5f || __instance.verbProps.requireLineOfSight) { // Assuming this is not a mortar-like thing // Perform vanilla logic return(true); } else { // Perform the same vanilla checks if (___currentTarget.HasThing && ___currentTarget.Thing.Map != __instance.caster.Map) { __result = false; return(false); } ThingDef projectile = __instance.Projectile; if (projectile == null) { __result = false; return(false); } ShootLine shootLine = default(ShootLine); bool flag = __instance.TryFindShootLineFromTo(__instance.caster.Position, ___currentTarget, out shootLine); if (__instance.verbProps.stopBurstWithoutLos && !flag) { __result = false; return(false); } // Vanilla checks pass, we can shoot if (__instance.EquipmentSource != null) { CompChangeableProjectile comp = __instance.EquipmentSource.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } CompReloadable comp2 = __instance.EquipmentSource.GetComp <CompReloadable>(); if (comp2 != null) { comp2.UsedOnce(); } } Thing launcher = __instance.caster; Thing equipment = __instance.EquipmentSource; CompMannable compMannable = __instance.caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = __instance.caster; // Earn skills if (compMannable.ManningPawn.skills != null) { int skillsAffectingAccuracy = 0; if (Settings.intellectualAffectsMortarAccuracy) { skillsAffectingAccuracy++; } if (Settings.shootingAffectsMortarAccuracy) { skillsAffectingAccuracy++; } float skillXP = __instance.verbProps.AdjustedFullCycleTime(__instance, __instance.CasterPawn) * 100; skillXP = Mathf.Clamp(skillXP, 0, 200); skillXP /= skillsAffectingAccuracy; if (Settings.intellectualAffectsMortarAccuracy) { compMannable.ManningPawn.skills.Learn(SkillDefOf.Intellectual, skillXP, false); } if (Settings.shootingAffectsMortarAccuracy) { compMannable.ManningPawn.skills.Learn(SkillDefOf.Shooting, skillXP, false); } } } Vector3 drawPos = __instance.caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, __instance.caster.Map, WipeMode.Vanish); // If targetting a pawn if (Settings.targetLeading) { if (___currentTarget != null && ___currentTarget.Thing != null && ___currentTarget.Thing is Pawn targetPawn && targetPawn.pather.curPath != null) { List <IntVec3> nodes = new List <IntVec3>(targetPawn.pather.curPath.NodesReversed); nodes.Reverse(); // Purge outdated nodes from list for (int i = 0; i < nodes.Count; i++) { if (nodes[i] == targetPawn.Position) { // Remove all previous nodes nodes.RemoveRange(0, i); //Log.Message("Removed " + i + " entries. First node is now " + nodes[0].ToString()); break; } } // Path of target pawn from current to destination // Need travel speed of pawn, estimate Vec3 they will be in based on travel speed of our projectile float targetMoveSpeed = targetPawn.GetStatValue(StatDefOf.MoveSpeed); float projectileMoveSpeed = projectile.projectile.speed; // Estimate position target will be in after this amount of time IntVec3 bestTarget = targetPawn.Position; float bestTimeOffset = float.MaxValue; //Log.Message("Default time offset = " + Mathf.Abs(((targetPawn.Position - caster.Position).LengthHorizontal) / projectileMoveSpeed)); float accumulatedTargetTime = 0f; IntVec3 previousPosition = targetPawn.Position; foreach (IntVec3 pathPosition in nodes) { float projectileDistanceFromTarget = (pathPosition - __instance.caster.Position).LengthHorizontal; float timeForProjectileToReachPosition = projectileDistanceFromTarget / projectileMoveSpeed; //float pawnDistanceFromTarget = (pathPosition - targetPawn.Position).LengthHorizontal; //float timeForPawnToReachPosition = pawnDistanceFromTarget / targetMoveSpeed; float pawnDistanceFromLastPositionToHere = (pathPosition - previousPosition).LengthHorizontal; float timeForPawnToReachPositionFromLastPosition = pawnDistanceFromLastPositionToHere / targetMoveSpeed; accumulatedTargetTime += timeForPawnToReachPositionFromLastPosition; float timeOffset = Mathf.Abs(timeForProjectileToReachPosition - accumulatedTargetTime); if (timeOffset < bestTimeOffset) { bestTarget = pathPosition; bestTimeOffset = timeOffset; //Log.Message("Position " + pathPosition.ToString() + " is better. Time offset is " + timeOffset); } else { //Log.Message("Position " + pathPosition.ToString() + " is not better. Time offset is " + timeOffset); } previousPosition = pathPosition; } //Log.Message("Initial target cell = " + currentTarget.Cell.ToString() + " and new target is " + bestTarget.ToString()); ___currentTarget = new LocalTargetInfo(bestTarget); } } float adjustedForcedMissRadius = GetAdjustedForcedMissRadius(__instance, ___currentTarget); ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.All; IntVec3 targetPosition = ___currentTarget.Cell; //if (adjustedForcedMissRadius > 0.5f) { if (MP.enabled) { Rand.PushState(); } // Calculate random target position using a uniform distribution float randomCircleArea = Rand.Range(0, Mathf.PI * adjustedForcedMissRadius * adjustedForcedMissRadius); float radiusOfRandomCircle = Mathf.Sqrt(randomCircleArea / Mathf.PI); float randomAngle = Rand.Range(0, 2 * Mathf.PI); targetPosition = new IntVec3( (int)(targetPosition.x + radiusOfRandomCircle * Mathf.Cos(randomAngle)), targetPosition.y, (int)(targetPosition.z + radiusOfRandomCircle * Mathf.Sin(randomAngle)) ); if (MP.enabled) { Rand.PopState(); } } //Log.Message("Final target is " + c.ToString()); projectile2.Launch(launcher, drawPos, targetPosition, ___currentTarget, projectileHitFlags, equipment, null); } __result = true; return(false); }
protected virtual (bool success, Vector3 launchPos, float angle) TryCastShotInternal() { if (currentTarget.HasThing && currentTarget.Thing.Map != caster.Map) { return(false, Vector3.zero, 0); } ThingDef projectile = Projectile; if (projectile == null) { return(false, Vector3.zero, 0); } ShootLine shootLine; bool flag = TryFindShootLineFromTo(caster.Position, currentTarget, out shootLine); if (verbProps.stopBurstWithoutLos && !flag) { return(false, Vector3.zero, 0); } if (EquipmentSource != null) { CompChangeableProjectile comp = EquipmentSource.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } CompReloadable comp2 = EquipmentSource.GetComp <CompReloadable>(); if (comp2 != null) { comp2.UsedOnce(); } } Thing launcher = caster; Thing equipment = EquipmentSource; CompMannable compMannable = caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = caster; } Vector3 launchPos = caster.DrawPos; float angle = launchPos.AngleToPoint(currentTarget.CenterVector3); Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, caster.Map, WipeMode.Vanish); if (caster.def.GetModExtension <ProjectilePropertiesDefModExtension>() is ProjectilePropertiesDefModExtension projectileProps) { projectile2.AllComps.Insert(0, new CompTurretProjectileProperties(CasterTWC) { speed = projectileProps.speed > 0 ? projectileProps.speed : projectile2.def.projectile.speed, hitflag = projectileProps.projectileHitFlag, hitflags = projectileProps.hitFlagDef }); } 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]; launchPos += new Vector3(VerbProps.shootOffset.x, 0, VerbProps.shootOffset.y).RotatedBy(angle); 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, launchPos, c, currentTarget, projectileHitFlags, equipment, null); return(true, launchPos, angle); } } } ShotReport shotReport = ShotReport.HitReportFor(caster, this, currentTarget); Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); ThingDef targetCoverDef = (randomCoverToMissInto != null) ? randomCoverToMissInto.def : null; if (!Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture)) { shootLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget); ThrowDebugText("ToWild" + (canHitNonTargetPawnsNow ? "\nchntp" : "")); ThrowDebugText("Wild\nDest", shootLine.Dest); ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f) && canHitNonTargetPawnsNow) { projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns; } launchPos += new Vector3(VerbProps.shootOffset.x, 0, VerbProps.shootOffset.y).RotatedBy(angle); projectile2.Launch(launcher, launchPos, shootLine.Dest, currentTarget, projectileHitFlags2, equipment, targetCoverDef); return(true, launchPos, angle); } 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; } launchPos += new Vector3(VerbProps.shootOffset.x, 0, VerbProps.shootOffset.y).RotatedBy(angle); projectile2.Launch(launcher, launchPos, randomCoverToMissInto, currentTarget, projectileHitFlags3, equipment, targetCoverDef); return(true, launchPos, angle); } 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) { angle = launchPos.AngleToPoint(currentTarget.CenterVector3); launchPos += new Vector3(VerbProps.shootOffset.x, 0, VerbProps.shootOffset.y).RotatedBy(angle); projectile2.Launch(launcher, launchPos, currentTarget, currentTarget, projectileHitFlags4, equipment, targetCoverDef); ThrowDebugText("Hit\nDest", currentTarget.Cell); } else { angle = launchPos.AngleToPoint(shootLine.Dest.ToVector3Shifted()); launchPos += new Vector3(VerbProps.shootOffset.x, 0, VerbProps.shootOffset.y).RotatedBy(angle); projectile2.Launch(launcher, launchPos, shootLine.Dest, currentTarget, projectileHitFlags4, equipment, targetCoverDef); ThrowDebugText("Hit\nDest", shootLine.Dest); } return(true, launchPos, angle); }
protected override bool TryCastShot() { if (this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map) { return(false); } if (Projectile == null) { return(false); } ShootLine shootLine; bool flag = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out shootLine); if (ownerEquipment != null) { //Debug this to find if this is a turret or gun or both CompChangeableProjectile comp = this.ownerEquipment.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } } //This part reconfigures the participants if a turret is being used 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; } //Determine the chance the weapon user screws up 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); } //Modify the shoot line to aim for a cell adjacent to the target shootLine.ChangeDestToMissWild(); } 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(); return(true); } } if (activeBeam == null) //Only spawn one EnergyBeam effect (no real need to spawn multiple beams) { activeBeam = (EnergyBeam)ThingMaker.MakeThing(beamProps.defaultBeam); GenSpawn.Spawn(activeBeam, shootLine.Source, caster.Map); activeBeam.Emit(); } activeBeam.verb = this; activeBeam.targetSquare = shootLine.Dest; return(true); }