Beispiel #1
0
        private void DoRangedAttack(LocalTargetInfo target)
        {
            bool flag = target.Cell != default(IntVec3);

            if (flag)
            {
                Thing launchedThing = new Thing()
                {
                    def = ThingDef.Named("FlyingObject_DemonBolt")
                };
                FlyingObject_Advanced flyingObject = (FlyingObject_Advanced)GenSpawn.Spawn(ThingDef.Named("FlyingObject_DemonBolt"), this.Pawn.Position, this.Pawn.Map);
                flyingObject.AdvancedLaunch(this.Pawn, ThingDef.Named("Mote_Demon_Flame"), 2, Rand.Range(5, 60), false, this.Pawn.DrawPos, target.Cell, launchedThing, Rand.Range(32, 38), true, Rand.Range(18, 26), Rand.Range(1.4f, 2.4f), DamageDefOf.Burn, null);
            }
        }
Beispiel #2
0
        public override void Tick()
        {
            //base.Tick();

            if (Manned)
            {
                if (!initialized)
                {
                    comp                   = mannableComp.ManningPawn.GetComp <CompAbilityUserMight>();
                    this.verVal            = mannableComp.ManningPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_60mmMortar.FirstOrDefault((MightPowerSkill x) => x.label == "TM_60mmMortar_ver").level;
                    this.pwrVal            = mannableComp.ManningPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_60mmMortar.FirstOrDefault((MightPowerSkill x) => x.label == "TM_60mmMortar_pwr").level;
                    this.effVal            = mannableComp.ManningPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_60mmMortar.FirstOrDefault((MightPowerSkill x) => x.label == "TM_60mmMortar_eff").level;
                    this.mortarTicksToFire = Find.TickManager.TicksGame + (300);
                    this.mortarMaxRange   += (verVal * 10);
                    if (verVal >= 3)
                    {
                        this.mortarCount++;
                    }
                    this.mortarAccuracy = mortarAccuracy - (.7f * effVal);
                    this.setTarget      = null;
                    this.targetingParameters.canTargetBuildings = true;
                    this.targetingParameters.canTargetPawns     = true;
                    this.targetingParameters.canTargetLocations = true;
                    this.initialized = true;
                }

                if (!mannableComp.ManningPawn.DestroyedOrNull() && !mannableComp.ManningPawn.Dead && !mannableComp.ManningPawn.Downed)
                {
                    if (this.mortarTicksToFire < Find.TickManager.TicksGame && this.mortarCount > 0)
                    {
                        this.mortarTicksToFire = Find.TickManager.TicksGame + (60 - (6 * verVal));
                        LocalTargetInfo target = null;
                        if (this.setTarget != null)
                        {
                            target = setTarget;
                        }
                        else
                        {
                            target = TM_Calc.FindNearbyEnemy(this.Position, this.Map, this.Faction, this.mortarMaxRange, this.mortarMinRange);
                        }
                        if (target != null && target.Cell.IsValid && target.Cell.DistanceToEdge(this.Map) > 5)
                        {
                            bool flag = target.Cell != default(IntVec3);
                            if (flag)
                            {
                                IntVec3 rndTarget = target.Cell;
                                rndTarget.x += Mathf.RoundToInt(Rand.Range(-mortarAccuracy, mortarAccuracy));
                                rndTarget.z += Mathf.RoundToInt(Rand.Range(-mortarAccuracy, mortarAccuracy));
                                Thing launchedThing = new Thing()
                                {
                                    def = projectileDef
                                };
                                int arc = 1;
                                if (target.Cell.x >= this.Position.x)
                                {
                                    arc = -1;
                                }
                                FlyingObject_Advanced flyingObject = (FlyingObject_Advanced)GenSpawn.Spawn(this.projectileDef, this.Position, this.Map);
                                flyingObject.AdvancedLaunch(this, null, 0, Mathf.Clamp(Rand.Range(50, 60), 0, this.Position.DistanceToEdge(this.Map)), false, this.DrawPos, rndTarget, launchedThing, Rand.Range(35, 40), true, Rand.Range(14 + pwrVal, 20 + (2 * pwrVal)), (3f + (.35f * pwrVal)), DamageDefOf.Bomb, null, arc, true);
                                this.mortarCount--;
                            }
                            SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Position, this.Map, false), MaintenanceType.None);
                            info.pitchFactor  = 1.6f;
                            info.volumeFactor = .7f;
                            SoundDef.Named("Mortar_LaunchA").PlayOneShot(info);
                        }
                    }
                }

                if (this.mortarCount <= 0)
                {
                    this.mannableComp.ManningPawn.jobs.EndCurrentJob(JobCondition.Succeeded);
                    this.Destroy(DestroyMode.Vanish);
                }
            }
            else
            {
                this.Destroy(DestroyMode.Vanish);
            }
        }
Beispiel #3
0
        public override void Tick()
        {
            base.Tick();

            //if (!manPawn.DestroyedOrNull() && !manPawn.Dead && !manPawn.Downed && manPawn.Position == this.InteractionCell)
            if (Manned)
            {
                if (!initialized)
                {
                    comp        = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>();
                    this.verVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_ver").level;
                    this.pwrVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_pwr").level;
                    this.effVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_eff").level;

                    if (this.verVal >= 5)
                    {
                        this.rocketTicksToFire = 600 - ((verVal - 5) * 20);
                        this.rocketCount       = verVal / 5;
                        this.rocketManaCost    = .04f - (.001f * this.effVal);
                    }
                    if (this.verVal >= 10)
                    {
                        this.mortarTicksToFire = 900 - ((verVal - 10) * 40);
                        this.mortarMaxRange   += (verVal - 10) * 5;
                        this.mortarManaCost    = .08f - (.002f * effVal);
                    }
                    this.initialized = true;
                }

                if (!mannableComp.ManningPawn.DestroyedOrNull() && !mannableComp.ManningPawn.Dead && !mannableComp.ManningPawn.Downed)
                {
                    if (this.verVal >= 5 && this.nextRocketFireTick < Find.TickManager.TicksGame && this.TargetCurrentlyAimingAt != null && comp.Mana.CurLevel >= this.rocketManaCost)
                    {
                        if (this.TargetCurrentlyAimingAt.Cell.IsValid && this.TargetCurrentlyAimingAt.Cell.DistanceToEdge(this.Map) > 5 && (this.TargetCurrentlyAimingAt.Cell - this.Position).LengthHorizontal >= this.rocketMinRange)
                        {
                            bool flag = this.TargetCurrentlyAimingAt.Cell != default(IntVec3);
                            if (flag)
                            {
                                Thing launchedThing = new Thing()
                                {
                                    def = ThingDef.Named("FlyingObject_RocketSmall")
                                };
                                FlyingObject_Advanced flyingObject = (FlyingObject_Advanced)GenSpawn.Spawn(ThingDef.Named("FlyingObject_RocketSmall"), this.Position, this.Map);
                                flyingObject.AdvancedLaunch(this, ThingDef.Named("Mote_Smoke"), 1, Rand.Range(5, 25), false, this.DrawPos, this.TargetCurrentlyAimingAt.Cell, launchedThing, Rand.Range(32, 38), true, Mathf.RoundToInt(Rand.Range(22f, 30f) * comp.arcaneDmg), 2, TMDamageDefOf.DamageDefOf.TM_PersonnelBombDD, null);
                                this.rocketCount--;
                                SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Position, this.Map, false), MaintenanceType.None);
                                info.pitchFactor  = 1.3f;
                                info.volumeFactor = 1.5f;
                                TorannMagicDefOf.TM_AirWoosh.PlayOneShot(info);
                            }
                            if (rocketCount <= 0)
                            {
                                this.rocketCount        = verVal / 5;
                                this.nextRocketFireTick = Find.TickManager.TicksGame + (600 - ((verVal - 5) * 20));
                                comp.Mana.CurLevel     -= this.rocketManaCost;
                                comp.MagicUserXP       += Rand.Range(9, 12);
                            }
                            else
                            {
                                this.nextRocketFireTick = Find.TickManager.TicksGame + 20;
                            }
                        }
                    }

                    if (this.verVal >= 10 && this.mortarTicksToFire < Find.TickManager.TicksGame && comp.Mana.CurLevel >= this.mortarManaCost)
                    {
                        this.mortarTicksToFire = Find.TickManager.TicksGame + (900 - ((verVal - 10) * 40));
                        Pawn target = TM_Calc.FindNearbyEnemy(this.Position, this.Map, this.Faction, this.mortarMaxRange, this.mortarMinRange);
                        if (target != null && target.Position.DistanceToEdge(this.Map) > 8)
                        {
                            bool flag = target.Position != default(IntVec3);
                            if (flag)
                            {
                                for (int i = 0; i < 5; i++)
                                {
                                    IntVec3 rndTarget = target.Position;
                                    rndTarget.x += Rand.RangeInclusive(-6, 6);
                                    rndTarget.z += Rand.RangeInclusive(-6, 6);
                                    Projectile newProjectile = (Projectile)GenSpawn.Spawn(ThingDef.Named("Bullet_Shell_TechnoTurretExplosive"), this.Position, this.Map, WipeMode.Vanish);
                                    newProjectile.Launch(this, rndTarget, target, ProjectileHitFlags.All, null);
                                }
                            }
                            SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Position, this.Map, false), MaintenanceType.None);
                            info.pitchFactor  = 1.3f;
                            info.volumeFactor = .8f;
                            SoundDef.Named("Mortar_LaunchA").PlayOneShot(info);
                            comp.Mana.CurLevel -= this.mortarManaCost;
                            comp.MagicUserXP   += Rand.Range(12, 15);
                        }
                    }

                    if (CanExtractShell && MannedByColonist)
                    {
                        CompChangeableProjectile compChangeableProjectile = gun.TryGetComp <CompChangeableProjectile>();
                        if (!compChangeableProjectile.allowedShellsSettings.AllowedToAccept(compChangeableProjectile.LoadedShell))
                        {
                            ExtractShell();
                        }
                    }
                    if (forcedTarget.IsValid && !CanSetForcedTarget)
                    {
                        ResetForcedTarget();
                    }
                    if (forcedTarget.ThingDestroyed)
                    {
                        ResetForcedTarget();
                    }
                    if ((powerComp == null || powerComp.PowerOn) && (mannableComp == null || mannableComp.MannedNow) && base.Spawned)
                    {
                        GunCompEq.verbTracker.VerbsTick();
                        if (!stunner.Stunned && AttackVerb.state != VerbState.Bursting)
                        {
                            if (WarmingUp)
                            {
                                burstWarmupTicksLeft--;
                                if (burstWarmupTicksLeft == 0)
                                {
                                    BeginBurst();
                                }
                            }
                            else
                            {
                                if (burstCooldownTicksLeft > 0)
                                {
                                    burstCooldownTicksLeft--;
                                }
                                if (burstCooldownTicksLeft <= 0 && this.IsHashIntervalTick(10))
                                {
                                    TryStartShootSomething(canBeginBurstImmediately: true);
                                }
                            }
                            top.TurretTopTick();
                        }
                    }
                    else
                    {
                        ResetCurrentTarget();
                    }
                }
            }
            else
            {
                for (int i = 0; i < 4; i++)
                {
                    Vector3 rndPos = this.DrawPos;
                    rndPos.x += Rand.Range(-.5f, .5f);
                    rndPos.z += Rand.Range(-.5f, .5f);
                    TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SparkFlash"), rndPos, this.Map, Rand.Range(.6f, .8f), .1f, .05f, .05f, 0, 0, 0, Rand.Range(0, 360));
                    MoteMaker.ThrowSmoke(rndPos, this.Map, Rand.Range(.8f, 1.2f));
                    rndPos    = this.DrawPos;
                    rndPos.x += Rand.Range(-.5f, .5f);
                    rndPos.z += Rand.Range(-.5f, .5f);
                    TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_ElectricalSpark"), rndPos, this.Map, Rand.Range(.4f, .7f), .2f, .05f, .1f, 0, 0, 0, Rand.Range(0, 360));
                }
                GenExplosion.DoExplosion(this.Position, this.Map, 1f, DamageDefOf.EMP, this, 0, 0, SoundDefOf.Crunch, null, null, this, null, 0, 0, false, null, 0, 0, 0, false);
                this.Destroy(DestroyMode.Vanish);
            }
        }