Exemplo n.º 1
0
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);

            ThingDef def = this.def;

            if (!this.initialized)
            {
                this.pawn = this.launcher as Pawn;
                this.map  = this.pawn.Map;
                CompAbilityUserMagic   comp        = pawn.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill        pwr         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Scorn.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Scorn_pwr");
                MagicPowerSkill        ver         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Scorn.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Scorn_ver");
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                pwrVal         = pwr.level;
                verVal         = ver.level;
                this.arcaneDmg = comp.arcaneDmg;
                if (settingsRef.AIHardMode && !pawn.IsColonist)
                {
                    pwrVal = 1;
                    verVal = 1;
                }
                this.radius = this.def.projectile.explosionRadius + verVal;
                //this.duration = Mathf.RoundToInt(this.radius * this.strikeDelay);
                this.initialized = true;
            }

            if (!launchedFlag)
            {
                ModOptions.Constants.SetPawnInFlight(true);
                if (ModCheck.Validate.GiddyUp.Core_IsInitialized())
                {
                    ModCheck.GiddyUp.ForceDismount(pawn);
                }
                skyfaller = SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("TM_ScornLeaving"), pawn.Position, this.map);
                if (base.Position.x < pawn.Position.x)
                {
                    this.angle = Rand.Range(20, 40);
                }
                else
                {
                    this.angle = Rand.Range(-40, -20);
                }
                skyfaller.angle = this.angle;
                launchedFlag    = true;
                pawn.DeSpawn();
            }
            if (skyfaller.DestroyedOrNull() && !pivotFlag)
            {
                safePos = base.Position;
                if (safePos.x > this.map.Size.x - 5)
                {
                    safePos.x = this.map.Size.x - 5;
                }
                else if (safePos.x < 5)
                {
                    safePos.x = 5;
                }

                if (safePos.z > this.map.Size.z - 5)
                {
                    safePos.z = this.map.Size.z - 5;
                }
                else if (safePos.z < 5)
                {
                    safePos.z = 5;
                }
                skyfaller2       = SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("TM_ScornIncoming"), safePos, this.map);
                skyfaller2.angle = this.angle;
                pivotFlag        = true;
            }

            if (skyfaller2.DestroyedOrNull() && pivotFlag && launchedFlag && !landedFlag)
            {
                landedFlag = true;
                GenSpawn.Spawn(pawn, safePos, this.map);
                if (pawn.drafter != null)
                {
                    pawn.drafter.Drafted = true;
                }
                ModOptions.Constants.SetPawnInFlight(false);
                if (verVal == 0)
                {
                    HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_DemonScornHD, 60f + (pwrVal * 15));
                }
                else if (verVal == 1)
                {
                    HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_DemonScornHD_I, 60f + (pwrVal * 15));
                }
                else if (verVal == 2)
                {
                    HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_DemonScornHD_II, 60f + (pwrVal * 15));
                }
                else
                {
                    HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_DemonScornHD_III, 60f + (pwrVal * 15));
                }
            }
            if (landedFlag)
            {
                if (Find.TickManager.TicksGame % strikeDelay == 0)
                {
                    if (safePos.DistanceToEdge(this.map) > strikeNum)
                    {
                        IEnumerable <IntVec3> targets;
                        if (strikeNum == 1)
                        {
                            targets = GenRadial.RadialCellsAround(safePos, this.strikeNum, false);
                        }
                        else
                        {
                            IEnumerable <IntVec3> oldTargets = GenRadial.RadialCellsAround(base.Position, this.strikeNum - 1, false);
                            targets = GenRadial.RadialCellsAround(safePos, this.strikeNum, false).Except(oldTargets);
                        }
                        foreach (var cell in targets)
                        {
                            IntVec3 curCell = cell;
                            if (this.map != null && curCell.IsValid && curCell.InBounds(this.map))
                            {
                                GenExplosion.DoExplosion(curCell, this.Map, .4f, TMDamageDefOf.DamageDefOf.TM_Shadow, this.pawn, (int)(this.def.projectile.GetDamageAmount(1, null) * (1 + (.15 * pwrVal)) * this.arcaneDmg * Rand.Range(.75f, 1.25f)), 0, TorannMagicDefOf.TM_SoftExplosion, def, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                            }
                        }
                        this.strikeNum++;
                    }
                    else
                    {
                        strikeNum = (int)this.radius + 1;
                    }
                }
            }
            if (this.strikeNum > this.radius)
            {
                this.age = this.duration;
                this.Destroy(DestroyMode.Vanish);
            }
        }
Exemplo n.º 2
0
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);

            ThingDef def    = this.def;
            Pawn     victim = null;

            if (!this.initialized)
            {
                this.pawn = this.launcher as Pawn;
                this.map  = this.pawn.Map;
                CompAbilityUserMagic   comp        = pawn.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill        pwr         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Repulsion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Repulsion_pwr");
                MagicPowerSkill        ver         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Repulsion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Repulsion_ver");
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                pwrVal         = pwr.level;
                verVal         = ver.level;
                this.arcaneDmg = comp.arcaneDmg;
                if (settingsRef.AIHardMode && !pawn.IsColonist)
                {
                    pwrVal = 3;
                    verVal = 3;
                }
                this.radius = this.def.projectile.explosionRadius + verVal;
                //this.duration = Mathf.RoundToInt(this.radius * this.strikeDelay);
                this.initialized = true;
            }

            if (!launchedFlag)
            {
                skyfaller = SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("TM_ScornLeaving"), pawn.Position, this.map);
                if (base.Position.x < pawn.Position.x)
                {
                    this.angle = Rand.Range(20, 40);
                }
                else
                {
                    this.angle = Rand.Range(-40, -20);
                }
                skyfaller.angle = this.angle;
                launchedFlag    = true;
                pawn.DeSpawn();
            }
            if (skyfaller.DestroyedOrNull() && !pivotFlag)
            {
                skyfaller2       = SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("TM_ScornIncoming"), base.Position, this.map);
                skyfaller2.angle = this.angle;
                pivotFlag        = true;
            }
            if (skyfaller2.DestroyedOrNull() && pivotFlag && launchedFlag && !landedFlag)
            {
                landedFlag = true;
                GenSpawn.Spawn(pawn, base.Position, this.map);
                pawn.drafter.Drafted = true;
            }
            if (landedFlag)
            {
                if (Find.TickManager.TicksGame % strikeDelay == 0)
                {
                    IEnumerable <IntVec3> targets;
                    if (strikeNum == 1)
                    {
                        targets = GenRadial.RadialCellsAround(base.Position, this.strikeNum, false);
                    }
                    else
                    {
                        IEnumerable <IntVec3> oldTargets = GenRadial.RadialCellsAround(base.Position, this.strikeNum - 1, false);
                        targets = GenRadial.RadialCellsAround(base.Position, this.strikeNum, false).Except(oldTargets);
                    }
                    for (int j = 0; j < targets.Count(); j++)
                    {
                        IntVec3 curCell = targets.ToArray <IntVec3>()[j];
                        if (curCell.IsValid && curCell.InBounds(this.map))
                        {
                            GenExplosion.DoExplosion(curCell, this.Map, .4f, TMDamageDefOf.DamageDefOf.TM_Shadow, this.pawn, (int)((this.def.projectile.GetDamageAmount(1, null) * (1 + .15 * pwrVal)) * this.arcaneDmg * Rand.Range(.75f, 1.25f)), 0, TorannMagicDefOf.TM_SoftExplosion, def, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                        }
                    }
                    this.strikeNum++;
                    if (this.strikeNum > this.radius)
                    {
                        this.age = this.duration;
                        this.Destroy(DestroyMode.Vanish);
                    }
                }
            }
        }