protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Misc.ThrowColonistAttackingMote(TargetIndex.A));

            yield return(Toils_Combat.CastVerb(TargetIndex.A, true));

            compPsyker.IsActive = true;

            this.AddFinishAction(() =>
            {
                if (compPsyker.IsActive)
                {
                    PsykerUtility.PsykerShockEvents(compPsyker, compPsyker.curPower.PowerLevel);
                }
                compPsyker.IsActive  = false;
                compPsyker.ShotFired = true;
            });
        }
Exemplo n.º 2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Misc.ThrowColonistAttackingMote(TargetIndex.A));

            Toil getInRangeToil = Toils_Combat.GotoCastPosition(TargetIndex.A, false);

            yield return(getInRangeToil);

            Verb_CastWarpPower verb = pawn.CurJob.verbToUse as Verb_CastWarpPower;

            Find.Targeter.targetingVerb = verb;
            yield return(Toils_Combat.CastVerb(TargetIndex.A, false));

            compPsyker.IsActive = true;
            this.AddFinishAction(() =>
            {
                //   Log.Message("FinishACtion");
                if (compPsyker.IsActive)
                {
                    PsykerUtility.PsykerShockEvents(compPsyker, compPsyker.curPower.PowerLevel);
                }
                compPsyker.ShotFired = true;
            });
        }
Exemplo n.º 3
0
        protected override bool TryCastShot()
        {
            UpdateTargets();
            int burstshots = this.ShotsPerBurst;

            Log.Message(TargetsAoE.Count.ToString());
            for (int i = 0; i < TargetsAoE.Count; i++)
            {
                Log.Message(TargetsAoE[i].Thing.Label);
                for (int j = 0; j < burstshots; j++)
                {
                    ShootLine shootLine;
                    bool      flag = base.TryFindShootLineFromTo(this.caster.Position, TargetsAoE[i], out shootLine);
                    if (this.verbProps.stopBurstWithoutLos && !flag)
                    {
                        return(false);
                    }
                    Vector3    drawPos    = this.caster.DrawPos;
                    Projectile projectile = (Projectile)GenSpawn.Spawn(this.verbProps.projectileDef, shootLine.Source);
                    projectile.FreeIntercept = (this.canFreeInterceptNow && !projectile.def.projectile.flyOverhead);
                    ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, TargetsAoE[i]);
                    if (!this.warpverbprops.AlwaysHits)
                    {
                        if (Rand.Value > shotReport.ChanceToNotGoWild_IgnoringPosture)
                        {
                            if (DebugViewSettings.drawShooting)
                            {
                                MoteMaker.ThrowText(this.caster.DrawPos, "ToWild", -1f);
                            }
                            shootLine.ChangeDestToMissWild();
                            if (TargetsAoE[i].HasThing)
                            {
                                projectile.ThingToNeverIntercept = TargetsAoE[i].Thing;
                            }
                            if (!projectile.def.projectile.flyOverhead)
                            {
                                projectile.InterceptWalls = true;
                            }
                            projectile.Launch(this.caster, drawPos, shootLine.Dest, this.ownerEquipment);
                            return(true);
                        }
                        if (Rand.Value > shotReport.ChanceToNotHitCover)
                        {
                            if (DebugViewSettings.drawShooting)
                            {
                                MoteMaker.ThrowText(this.caster.DrawPos, "ToCover", -1f);
                            }
                            if (TargetsAoE[i].Thing != null && TargetsAoE[i].Thing.def.category == ThingCategory.Pawn)
                            {
                                Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto();
                                if (!projectile.def.projectile.flyOverhead)
                                {
                                    projectile.InterceptWalls = true;
                                }

                                projectile.Launch(this.caster, drawPos, randomCoverToMissInto, this.ownerEquipment);
                                return(true);
                            }
                        }
                    }
                    if (DebugViewSettings.drawShooting)
                    {
                        MoteMaker.ThrowText(this.caster.DrawPos, "ToHit", -1f);
                    }
                    if (!projectile.def.projectile.flyOverhead)
                    {
                        projectile.InterceptWalls = (!TargetsAoE[i].HasThing || TargetsAoE[i].Thing.def.Fillage == FillCategory.Full);
                    }
                    if (TargetsAoE[i].Thing != null)
                    {
                        if (this.warpverbprops.DrawProjectileOnTarget)
                        {
                            Projectile_WarpPower wprojectile = projectile as Projectile_WarpPower;
                            if (wprojectile != null)
                            {
                                wprojectile.selectedTarget = TargetsAoE[i].Thing;
                                wprojectile.Caster         = this.CasterPawn;
                            }
                        }
                        projectile.Launch(this.caster, drawPos, TargetsAoE[i]);
                    }
                    else
                    {
                        if (this.warpverbprops.DrawProjectileOnTarget)
                        {
                            Projectile_WarpPower wprojectile = projectile as Projectile_WarpPower;
                            wprojectile.targetVec = shootLine.Dest.ToVector3();
                        }
                        projectile.Launch(this.caster, drawPos, shootLine.Dest);
                    }
                }

                psycomp.TicksToCast    = this.warpverbprops.TicksToRecharge;
                psycomp.TicksToCastMax = this.warpverbprops.TicksToRecharge;
            }
            this.burstShotsLeft = 0;
            if (soul != null)
            {
                soul.GainNeed(0.01f * (-warpverbprops.CorruptionFactor));
            }
            PsykerUtility.PsykerShockEvents(psycomp, psycomp.curPower.PowerLevel);
            return(true);
        }