コード例 #1
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def = this.def;

            GenExplosion.DoExplosion(base.Position, map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, this.launcher, this.def.projectile.GetDamageAmount(1, null), 0, SoundDefOf.Artillery_ShellLoaded, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
            Pawn p = this.launcher as Pawn;

            if (p != null)
            {
                CompAbilityUserMagic comp = p.TryGetComp <CompAbilityUserMagic>();
                if (comp != null)
                {
                    if (comp.MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_pwr").level >= 4)
                    {
                        List <Pawn> allPawns = TM_Calc.FindAllPawnsAround(map, base.Position, this.def.projectile.explosionRadius);
                        if (allPawns != null && allPawns.Count > 0)
                        {
                            for (int i = 0; i < allPawns.Count; i++)
                            {
                                Pawn ele = allPawns[i];
                                if (TM_Calc.IsElemental(ele))
                                {
                                    TM_Action.DamageEntities(ele, null, Rand.Range(10, 20), DamageDefOf.Burn, p);
                                }
                                else if (ele.def == TorannMagicDefOf.TM_DemonR)
                                {
                                    TM_Action.DamageEntities(ele, null, Rand.Range(30, 50), DamageDefOf.Burn, p);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        public override void CompTick()
        {
            if (this.age > 0)
            {
                if (!this.initialized)
                {
                    HealthUtility.AdjustSeverity(this.Pawn, TorannMagicDefOf.TM_LichHD, .5f);
                    this.initialized = true;
                }

                if (this.Pawn.Spawned)
                {
                    if (!this.Pawn.Downed)
                    {
                        if (!this.Pawn.stances.curStance.StanceBusy)
                        {
                            if (this.tauntTarget != null && this.Pawn.Faction != null && !this.Pawn.Faction.IsPlayer && this.NextTaunt < Find.TickManager.TicksGame && this.Pawn.CurJob.def != JobDefOf.Goto)
                            {
                                if ((this.tauntTarget.Cell - this.Pawn.Position).LengthHorizontal > 5)
                                {
                                    GotoRaiseLocation(this.Pawn.Map, this.tauntTarget);
                                }
                                else
                                {
                                    StartTaunt(this.Pawn.Map, this.tauntTarget);
                                }
                            }

                            if (this.shouldDoTaunt)
                            {
                                DoTaunt(this.Pawn.Map, this.tauntTarget.Cell);
                            }

                            if (this.flightTarget != null)
                            {
                                DoChargeAttack(this.flightTarget.Cell);
                                goto exitTick;
                            }

                            if (this.rangedBurstShots > 0 && this.rangedNextBurst < Find.TickManager.TicksGame)
                            {
                                DoRangedAttack(this.rangedTarget);
                                this.rangedBurstShots--;
                                this.rangedNextBurst = Find.TickManager.TicksGame + this.Props.rangedTicksBetweenBursts;
                            }

                            if (shouldDoAOEAttack)
                            {
                                if (this.attackTarget != null)
                                {
                                    DoAoEAttack(this.attackTarget.Cell, this.attackTarget);
                                }
                            }

                            if (shouldDoKnockBackAttack)
                            {
                                if (this.attackTarget != null)
                                {
                                    DoKnockbackAttack(this.attackTarget.Cell, 5);
                                }
                            }

                            if (Find.TickManager.TicksGame % 30 == 0)
                            {
                                if (this.buildingThreats.Count() > 0)
                                {
                                    Building randomBuildingThreat = this.buildingThreats.RandomElement();
                                    if ((randomBuildingThreat.Position - this.Pawn.Position).LengthHorizontal < 80 && this.NextRangedAttack < Find.TickManager.TicksGame && TargetIsValid(randomBuildingThreat))
                                    {
                                        this.rangedTarget = randomBuildingThreat;
                                        StartRangedAttack();
                                    }
                                }

                                if (this.Pawn.CurJob != null && this.Pawn.CurJob.targetA != null && this.Pawn.CurJob.targetA.Thing != null && this.Pawn.TargetCurrentlyAimingAt == null)
                                {
                                    Thing currentTargetThing = this.Pawn.CurJob.targetA.Thing;
                                    if ((currentTargetThing.Position - this.Pawn.Position).LengthHorizontal > (this.Props.maxRangeForCloseThreat * 2))
                                    {
                                        if (Rand.Chance(.6f) && this.NextRangedAttack < Find.TickManager.TicksGame && TargetIsValid(currentTargetThing))
                                        {
                                            this.rangedTarget = currentTargetThing;
                                            StartRangedAttack();
                                        }
                                    }
                                }
                                else if (this.Pawn.TargetCurrentlyAimingAt != null && this.closeThreats.Count() > 3)
                                {
                                    if (Rand.Chance(.4f) && this.NextAoEAttack < Find.TickManager.TicksGame && TM_Calc.HasLoSFromTo(this.Pawn.Position, this.attackTarget, this.Pawn, 0, 60))
                                    {
                                        this.attackTarget = this.Pawn.TargetCurrentlyAimingAt;
                                        StartAoEAttack(this.attackTarget.Cell, this.attackTarget);
                                    }

                                    if (Rand.Chance(.8f) && this.NextAoEAttack < Find.TickManager.TicksGame && this.farThreats.Count() > (4 * this.closeThreats.Count()) && TM_Calc.HasLoSFromTo(this.Pawn.Position, this.attackTarget, this.Pawn, 0, 60))
                                    {
                                        Pawn p = this.farThreats.RandomElement();
                                        if (TM_Calc.FindAllPawnsAround(this.Pawn.Map, p.Position, 5, p.Faction, false).Count > 3)
                                        {
                                            this.attackTarget = p;
                                            StartAoEAttack(p.Position, p);
                                        }
                                    }
                                }

                                if (this.closeThreats != null && this.closeThreats.Count > 5)
                                {
                                    if (Rand.Chance(.2f) && this.NextKnockbackAttack < Find.TickManager.TicksGame)
                                    {
                                        Pawn p = this.closeThreats.RandomElement();
                                        if (p.health != null && p.health.hediffSet != null && !p.health.hediffSet.HasHediff(TorannMagicDefOf.TM_DeathMarkHD))
                                        {
                                            this.attackTarget = p;
                                            StartKnockbackAttack(p.Position, 5);
                                        }
                                    }
                                    else if (Rand.Chance(.4f) && this.NextChargeAttack < Find.TickManager.TicksGame)
                                    {
                                        this.flightTarget = TM_Calc.TryFindSafeCell(this.Pawn, this.Pawn.Position, 40, 3, 2);
                                        StartChargeAttack(this.flightTarget.Cell);
                                    }
                                }

                                if (this.farThreats.Count() < 2 * this.closeThreats.Count() && Rand.Chance(.3f))
                                {
                                    if (this.NextChargeAttack < Find.TickManager.TicksGame && this.farThreats.Count >= 1)
                                    {
                                        Pawn tempTarget = this.farThreats.RandomElement();
                                        if (TargetIsValid(tempTarget) && (tempTarget.Position - this.Pawn.Position).LengthHorizontal > (this.Props.maxRangeForCloseThreat * 3) && (tempTarget.Position - this.Pawn.Position).LengthHorizontal < (this.Props.maxRangeForCloseThreat * 6))
                                        {
                                            this.flightTarget = tempTarget;
                                            StartChargeAttack(this.flightTarget.Cell);
                                        }
                                    }
                                }

                                if (this.farThreats.Count() > 2)
                                {
                                    if (Rand.Chance(.4f) && this.NextRangedAttack < Find.TickManager.TicksGame)
                                    {
                                        Pawn randomRangedPawn = this.farThreats.RandomElement();
                                        if ((randomRangedPawn.Position - this.Pawn.Position).LengthHorizontal < this.Props.maxRangeForFarThreat * 2f)
                                        {
                                            this.rangedTarget = randomRangedPawn;
                                            StartRangedAttack();
                                        }
                                    }

                                    if (Rand.Chance(.2f) && this.NextAoEAttack < Find.TickManager.TicksGame)
                                    {
                                        Pawn p = this.farThreats.RandomElement();
                                        if ((p.Position - this.Pawn.Position).LengthHorizontal < this.Props.maxRangeForFarThreat * 2f && TM_Calc.HasLoSFromTo(this.Pawn.Position, this.attackTarget, this.Pawn, 0, 60))
                                        {
                                            List <Pawn> threatPawns = TM_Calc.FindAllPawnsAround(this.Pawn.Map, p.Position, 5, p.Faction, true);
                                            if (threatPawns != null && threatPawns.Count > 3)
                                            {
                                                this.attackTarget = p;
                                                StartAoEAttack(this.attackTarget.Cell, this.attackTarget);
                                            }
                                        }
                                    }
                                }

                                if (this.Pawn.CurJob != null)
                                {
                                    if (this.Pawn.CurJob.targetA == null || this.Pawn.CurJob.targetA == this.Pawn)
                                    {
                                        if (this.closeThreats.Count() > 0)
                                        {
                                            Thing tempTarget = this.closeThreats.RandomElement();
                                            if (TargetIsValid(tempTarget))
                                            {
                                                this.Pawn.CurJob.targetA = tempTarget;
                                                this.Pawn.TryStartAttack(this.Pawn.CurJob.targetA);
                                            }
                                        }
                                        else if (this.farThreats.Count() > 0)
                                        {
                                            Thing tempTarget = this.farThreats.RandomElement();
                                            if (TargetIsValid(tempTarget))
                                            {
                                                this.Pawn.CurJob.targetA = tempTarget;
                                                this.Pawn.TryStartAttack(this.Pawn.CurJob.targetA);
                                            }
                                        }
                                        else if (this.buildingThreats.Count() > 0)
                                        {
                                            Thing tempTarget = this.buildingThreats.RandomElement();
                                            if (TargetIsValid(tempTarget))
                                            {
                                                this.Pawn.CurJob.targetA = tempTarget;
                                                this.Pawn.TryStartAttack(this.Pawn.CurJob.targetA);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else if (IsCasting)
                        {
                            if (Find.TickManager.TicksGame % 12 == 0)
                            {
                                TM_MoteMaker.ThrowCastingMote_Anti(this.Pawn.DrawPos, this.Pawn.Map, 2f);
                            }
                        }

                        if (Find.TickManager.TicksGame % 279 == 0)
                        {
                            DetermineThreats();
                        }
                    }

                    if (Find.TickManager.TicksGame % 4 == 0)
                    {
                        ThingDef rndMote = ThingDefOf.Gas_Smoke;
                        TM_MoteMaker.ThrowGenericMote(rndMote, MoteDrawPos, this.Pawn.Map, Rand.Range(.4f, .5f), .1f, 0f, Rand.Range(.5f, .6f), Rand.Range(-40, 40), Rand.Range(.2f, .3f), Rand.Range(-95, -110), Rand.Range(0, 360));
                        TM_MoteMaker.ThrowGenericMote(rndMote, MoteDrawPos, this.Pawn.Map, Rand.Range(.4f, .5f), .1f, 0f, Rand.Range(.5f, .6f), Rand.Range(-40, 40), Rand.Range(.2f, .3f), Rand.Range(90, 110), Rand.Range(0, 360));
                    }

                    if (this.Pawn.Downed)
                    {
                        this.Pawn.Kill(null);
                    }
                }
            }
            exitTick :;
            age++;
        }
コード例 #3
0
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);
            if (!this.initialized)
            {
                this.pawn        = this.launcher as Pawn;
                launcherPosition = this.Launcher.Position;
                CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
                pwrVal         = TM_Calc.GetMagicSkillLevel(this.pawn, comp.MagicData.MagicPowerSkill_LightSkip, "TM_LightSkip", "_pwr", false);
                this.arcaneDmg = comp.arcaneDmg;
                this.draftFlag = this.pawn.drafter != null ? this.pawn.Drafted : false;
                this.gi        = 0;
                podTList.Clear();
                pawnList.Clear();
                pods.Clear();
                this.initialized = true;
            }

            if (!launchedFlag)
            {
                ModOptions.Constants.SetPawnInFlight(true);
                List <Pawn> tmpList = TM_Calc.FindAllPawnsAround(this.Map, launcherPosition, 5f, this.pawn.Faction, true);
                if (tmpList != null)
                {
                    for (int i = 0; i < tmpList.Count; i++)
                    {
                        if (!tmpList[i].Position.Roofed(this.Map))
                        {
                            if (ModCheck.Validate.GiddyUp.Core_IsInitialized())
                            {
                                if (ModCheck.GiddyUp.IsMount(tmpList[i]))
                                {
                                    continue;
                                }
                            }
                            pawnList.Add(tmpList[i]);
                        }
                    }
                    unroofedCells = GetUnroofedCellsAround(base.Position, this.radius);
                    CreatePodGroup();
                    this.allPawnsLaunched = false;
                    launchedFlag          = true;
                }
                else
                {
                    this.allPawnsLaunched = true;
                    launchedFlag          = true;
                }
            }

            if (launchedFlag)
            {
                if (allPawnsLaunched)
                {
                    this.age++;
                    this.Destroy(DestroyMode.Vanish);
                }
                else if (Find.TickManager.TicksGame % 2 == 0)
                {
                    if (podTList != null && podTList.Count > 0)
                    {
                        if (gi < podTList.Count)
                        {
                            IntVec3          newPosition = GetRelativePositionOffset(base.Position, launcherPosition, pods[gi].Position);
                            GlobalTargetInfo gti         = new GlobalTargetInfo(newPosition, base.Map, false);
                            LaunchLightPod(pods[gi], podTList[gi], gti.Tile, gti.Cell);
                            gi++;
                        }
                        else
                        {
                            allPawnsLaunched = true;
                        }
                    }
                    else
                    {
                        allPawnsLaunched = true;
                    }
                }
            }
        }
コード例 #4
0
 public override void Tick()
 {
     if (!initialized)
     {
         initialized     = true;
         this.nextSearch = Find.TickManager.TicksGame + Rand.Range(400, 500);
     }
     if (Find.TickManager.TicksGame % 8 == 0)
     {
         this.matRng++;
         if (this.matRng >= 3)
         {
             matRng = 0;
         }
     }
     if (Find.TickManager.TicksGame >= this.nextSearch)
     {
         this.nextSearch = Find.TickManager.TicksGame + Rand.Range(400, 500);
         if (defensive)
         {
             List <Pawn> ePawns = TM_Calc.FindAllPawnsAround(this.Map, this.Position, 10, this.factionInt, false);
             if (ePawns != null && ePawns.Count > 0)
             {
                 for (int i = 0; i < ePawns.Count; i++)
                 {
                     if (ePawns[i].Faction.HostileTo(this.Faction))
                     {
                         HealthUtility.AdjustSeverity(ePawns[i], TorannMagicDefOf.TM_FrostSlowHD, .4f);
                         TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Ice, ePawns[i].DrawPos, this.Map, 1f, .3f, .1f, .8f, Rand.Range(-100, 100), .4f, Rand.Range(0, 35), Rand.Range(0, 360));
                     }
                 }
             }
         }
         if (buffCool)
         {
             List <Pawn> pList = TM_Calc.FindAllPawnsAround(this.Map, this.Position, 7, this.Faction, true);
             if (pList != null && pList.Count > 0)
             {
                 for (int i = 0; i < pList.Count; i++)
                 {
                     Pawn p = pList[i];
                     if (p.health != null && p.health.hediffSet != null)
                     {
                         HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_CoolHD, 0.25f);
                     }
                 }
             }
         }
         if (buffFresh)
         {
             List <Pawn> pList = TM_Calc.FindAllPawnsAround(this.Map, this.Position, 7, this.Faction, true);
             if (pList != null && pList.Count > 0)
             {
                 for (int i = 0; i < pList.Count; i++)
                 {
                     Pawn p = pList[i];
                     if (p.health != null && p.health.hediffSet != null)
                     {
                         HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_RefreshedHD, 0.2f);
                     }
                 }
             }
         }
     }
     base.Tick();
 }
コード例 #5
0
        protected override void Impact(Thing hitThing)
        {
            if (!this.initialized)
            {
                this.pawn = this.launcher as Pawn;
                CompAbilityUserMagic   comp        = pawn.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill        pwr         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AccelerateTime.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AccelerateTime_pwr");
                MagicPowerSkill        ver         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AccelerateTime.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AccelerateTime_ver");
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                pwrVal = pwr.level;
                verVal = ver.level;
                if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                {
                    MightPowerSkill mpwr = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                    MightPowerSkill mver = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                    pwrVal = mpwr.level;
                    verVal = mver.level;
                }
                this.arcaneDmg = comp.arcaneDmg;
                if (settingsRef.AIHardMode && !pawn.IsColonist)
                {
                    pwrVal = 3;
                    verVal = 3;
                }
                this.strikeDelay = this.strikeDelay - verVal;
                this.radius      = this.def.projectile.explosionRadius;
                this.duration    = Mathf.RoundToInt(this.radius * this.strikeDelay);
                this.initialized = true;
                this.targets     = GenRadial.RadialCellsAround(base.Position, this.radius, true);
                //cellList = targets.ToList<IntVec3>();
            }


            Pawn targetPawn = this.intendedTarget.Thing as Pawn;

            if (targetPawn == null)
            {
                base.Position.GetFirstPawn(this.Map);
            }

            if (targetPawn != null)
            {
                if (targetPawn.Faction != null && targetPawn.Faction == this.launcher.Faction)
                {
                    AgePawn(targetPawn, Mathf.RoundToInt((24 * 2500) * (1 + (.1f * verVal))), false);
                }
                else
                {
                    List <Pawn> pawnList = TM_Calc.FindAllPawnsAround(this.launcher.Map, base.Position, this.radius, this.launcher.Faction, false);
                    if (pawnList != null && pawnList.Count > 0)
                    {
                        for (int i = 0; i < Mathf.Clamp(pawnList.Count, 0, 2 + verVal); i++)
                        {
                            if (pawnList[i].Faction != null && !pawnList[i].Faction.HostileTo(this.pawn.Faction))
                            {
                                pawnList[i].Faction.TryAffectGoodwillWith(this.pawn.Faction, -25);
                            }

                            if (pawnList[i].Faction != null && pawnList[i].Faction != this.pawn.Faction)
                            {
                                AgePawn(pawnList[i], Mathf.RoundToInt((2500) * (1 + (.1f * verVal))), true);
                                if (pawnList[i].IsColonist && !this.pawn.IsColonist)
                                {
                                    TM_Action.SpellAffectedPlayerWarning(pawnList[i]);
                                }
                            }
                            else if (pawnList[i].Faction == null)
                            {
                                AgePawn(pawnList[i], Mathf.RoundToInt((2500) * (1 + (.1f * verVal))), true);
                            }
                        }
                    }
                }
            }
            else
            {
                List <Pawn> pawnList = TM_Calc.FindAllPawnsAround(this.launcher.Map, base.Position, this.radius, this.launcher.Faction, false);
                if (pawnList != null && pawnList.Count > 0)
                {
                    for (int i = 0; i < Mathf.Clamp(pawnList.Count, 0, 2 + verVal); i++)
                    {
                        if (pawnList[i].Faction != null && !pawnList[i].Faction.HostileTo(this.pawn.Faction))
                        {
                            pawnList[i].Faction.TryAffectGoodwillWith(this.pawn.Faction, -25);
                        }

                        targetPawn = pawnList[i];
                        if (targetPawn.Faction != null && targetPawn.Faction != this.pawn.Faction)
                        {
                            AgePawn(pawnList[i], Mathf.RoundToInt((2500) * (1 + (.1f * verVal))), true);
                        }
                        else if (targetPawn.Faction == null)
                        {
                            AgePawn(pawnList[i], Mathf.RoundToInt((2500) * (1 + (.1f * verVal))), true);
                        }
                    }
                }
            }

            List <Thing> thingList = base.Position.GetThingList(this.Map);
            Thing        thing     = null;

            if (targetPawn == null && thingList != null && thingList.Count > 0)
            {
                for (int i = 0; i < thingList.Count; i++)
                {
                    if (thingList[i] != null && !(thingList[i] is Pawn) && !(thingList[i] is Building))
                    {
                        //if (thingList[i].def.thingCategories != null && thingList[i].def.thingCategories.Count > 0 && (thingList[i].def.thingCategories.Contains(ThingCategoryDefOf.ResourcesRaw) || thingList[i].def.thingCategories.Contains(ThingCategoryDefOf.StoneBlocks) || thingList[i].def.defName == "RawMagicyte"))
                        if (thingList[i].def.MadeFromStuff)
                        {
                            thing = thingList[i];
                            break;
                        }
                        if (!thingList[i].def.MadeFromStuff && thingList[i].TryGetComp <CompQuality>() != null)
                        {
                            thing = thingList[i];
                            break;
                        }
                    }
                }
            }

            if (thing != null)
            {
                AgeThing(thing);
            }

            List <IntVec3> cellList = targets.ToList();

            if (cellList != null && cellList.Count > 0)
            {
                for (int i = 0; i < cellList.Count; i++)
                {
                    thingList = cellList[i].GetThingList(this.Map);
                    if (thingList != null && thingList.Count > 0)
                    {
                        for (int j = 0; j < thingList.Count; j++)
                        {
                            if (thingList[j] is Plant)
                            {
                                Plant plant = thingList[j] as Plant;
                                try
                                {
                                    plant.Growth = plant.Growth + ((Rand.Range((2 + pwrVal), (4 + pwrVal)) / plant.def.plant.growDays) * this.arcaneDmg);
                                }
                                catch (NullReferenceException ex)
                                {
                                    plant.Growth *= (1.1f + (.1f * pwrVal));
                                }
                            }
                            CompHatcher compHatcher = thingList[j].TryGetComp <CompHatcher>();
                            if (compHatcher != null)
                            {
                                float gestateProgress = Traverse.Create(root: compHatcher).Field(name: "gestateProgress").GetValue <float>();
                                Traverse.Create(root: compHatcher).Field(name: "gestateProgress").SetValue((gestateProgress + Rand.Range(.3f + (.1f * pwrVal), .7f + (.1f * pwrVal))) * this.arcaneDmg);
                            }
                        }
                    }
                }
            }

            Effecter AreaAccelEffect = TorannMagicDefOf.TM_TimeAccelerationAreaEffecter.Spawn();

            AreaAccelEffect.Trigger(new TargetInfo(base.Position, this.Map, false), new TargetInfo(base.Position, this.Map, false));
            AreaAccelEffect.Cleanup();

            this.age = this.duration;
            this.Destroy(DestroyMode.Vanish);
        }
コード例 #6
0
 public override void Tick()
 {
     if (!initialized)
     {
         initialized     = true;
         this.nextSearch = Find.TickManager.TicksGame + Rand.Range(180, 220);
     }
     if (Find.TickManager.TicksGame % 8 == 0)
     {
         this.matRng++;
         if (this.matRng >= 4)
         {
             matRng = 0;
         }
     }
     if (Find.TickManager.TicksGame >= this.nextSearch)
     {
         this.nextSearch = Find.TickManager.TicksGame + Rand.Range(180, 220);
         if (defensive)
         {
             Pawn e = TM_Calc.FindNearbyEnemy(this.Position, this.Map, this.factionInt, 20, 0);
             if (e != null && TM_Calc.HasLoSFromTo(this.Position, e, this, 0, 20))
             {
                 GenExplosion.DoExplosion(e.Position, this.Map, .4f, DamageDefOf.Stun, this, 4, 1f);
                 if (e.RaceProps.IsMechanoid || TM_Calc.IsRobotPawn(e))
                 {
                     GenExplosion.DoExplosion(e.Position, this.Map, .4f, TMDamageDefOf.DamageDefOf.TM_ElectricalBurn, this, 8, 1f);
                 }
             }
         }
         if (buffShock)
         {
             List <Pawn> pList = TM_Calc.FindAllPawnsAround(this.Map, this.Position, 6, this.Faction, true);
             if (pList != null && pList.Count > 0)
             {
                 for (int i = 0; i < pList.Count; i++)
                 {
                     Pawn p = pList[i];
                     if (p.health != null && p.health.hediffSet != null)
                     {
                         HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_ShockTherapyHD, 0.12f);
                     }
                 }
             }
         }
         if (buffJolt)
         {
             List <Pawn> pList = TM_Calc.FindAllPawnsAround(this.Map, this.Position, 6, this.Faction, true);
             if (pList != null && pList.Count > 0)
             {
                 for (int i = 0; i < pList.Count; i++)
                 {
                     Pawn p = pList[i];
                     if (p.health != null && p.health.hediffSet != null)
                     {
                         HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_JoltHD, 0.1f);
                     }
                 }
             }
         }
     }
     base.Tick();
 }
コード例 #7
0
        public void SearchForTargets(IntVec3 center, float radius)
        {
            Pawn     curPawnTarg = null;
            Building curBldgTarg = null;
            //IntVec3 curCell;
            //IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(center, radius, true);
            //for (int i = 0; i < targets.Count(); i++)
            //{
            //    curCell = targets.ToArray<IntVec3>()[i];
            //    if ( curCell.InBounds(base.Map) && curCell.IsValid)
            //    {
            //        curPawnTarg = curCell.GetFirstPawn(base.Map);
            //        curBldgTarg = curCell.GetFirstBuilding(base.Map);
            //    }
            List <Pawn> targets = new List <Pawn>();

            targets.Clear();
            if (this.age > this.lastStrike)
            {
                targets = TM_Calc.FindAllPawnsAround(base.Map, center, radius);
                if (targets != null && targets.Count > 0)
                {
                    curPawnTarg = targets.RandomElement();
                    if (curPawnTarg != launcher)
                    {
                        CellRect cellRect = CellRect.CenteredOn(curPawnTarg.Position, 2);
                        cellRect.ClipInsideMap(base.Map);
                        DrawStrike(center, curPawnTarg.Position.ToVector3());
                        for (int k = 0; k < Rand.Range(1, 8); k++)
                        {
                            IntVec3 randomCell = cellRect.RandomCell;
                            GenExplosion.DoExplosion(randomCell, base.Map, Rand.Range(.4f, .8f), TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(5 + pwrVal, 9 + 3 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OnMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true);
                        }
                        GenExplosion.DoExplosion(curPawnTarg.Position, base.Map, 1f, TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(5 + pwrVal, 9 + 3 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true);
                        this.lastStrike = this.age + (this.maxStrikeDelay - (int)Rand.Range(0 + (pwrVal * 20), 50 + (pwrVal * 10)));
                    }
                    else
                    {
                        this.lastStrike += 10;
                    }
                }
                else
                {
                    this.lastStrike += 10;
                }
            }

            if (this.age > this.lastStrikeBldg)
            {
                List <Building> list = new List <Building>();
                list.Clear();
                list = (from x in base.Map.listerThings.AllThings
                        where x.Position.InHorDistOf(center, radius) && !x.DestroyedOrNull() && x is Building
                        select x as Building).ToList <Building>();
                if (list.Count > 0)
                {
                    curBldgTarg = list.RandomElement();
                    CellRect cellRect = CellRect.CenteredOn(curBldgTarg.Position, 1);
                    cellRect.ClipInsideMap(base.Map);
                    DrawStrike(center, curBldgTarg.Position.ToVector3());
                    for (int k = 0; k < Rand.Range(1, 8); k++)
                    {
                        IntVec3 randomCell = cellRect.RandomCell;
                        GenExplosion.DoExplosion(randomCell, base.Map, Rand.Range(.2f, .6f), TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(3 + 3 * pwrVal, 7 + 5 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true);
                    }
                    GenExplosion.DoExplosion(curBldgTarg.Position, base.Map, 1f, TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(10 + 3 * pwrVal, 25 + 5 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true);
                    this.lastStrikeBldg = this.age + (this.maxStrikeDelayBldg - (int)Rand.Range(0 + (pwrVal * 10), (pwrVal * 15)));
                }
                else
                {
                    this.lastStrikeBldg += 10;
                }
            }

            //}
            DrawStrikeFading();
            age++;
        }