protected override bool TryCastShot()
        {
            bool result = false;
            bool arg_40_0;

            CompAbilityUserMight comp = this.CasterPawn.GetComp <CompAbilityUserMight>();

            pwr    = comp.MightData.MightPowerSkill_PhaseStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PhaseStrike_pwr");
            ver    = comp.MightData.MightPowerSkill_PhaseStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PhaseStrike_ver");
            verVal = ver.level;
            pwrVal = pwr.level;
            if (base.CasterPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            {
                MightPowerSkill mver = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                MightPowerSkill mpwr = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                verVal = mver.level;
                pwrVal = mpwr.level;
            }
            if (this.CasterPawn.equipment.Primary != null && !this.CasterPawn.equipment.Primary.def.IsRangedWeapon)
            {
                this.dmgNum = GetWeaponDmg(this.CasterPawn);
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode)
                {
                    this.dmgNum += 10;
                }

                if (this.currentTarget != null && base.CasterPawn != null)
                {
                    arg_29_0 = this.currentTarget.Cell;
                    Vector3 vector = this.currentTarget.CenterVector3;
                    arg_40_0 = this.currentTarget.Cell.IsValid;
                    arg_41_0 = vector.InBounds(base.CasterPawn.Map);
                    arg_42_0 = true; // vector.ToIntVec3().Standable(base.CasterPawn.Map);
                }
                else
                {
                    arg_40_0 = false;
                }
                bool flag  = arg_40_0;
                bool flag2 = arg_41_0;
                bool flag3 = arg_42_0;
                if (flag)
                {
                    if (flag2 & flag3)
                    {
                        Pawn    p    = this.CasterPawn;
                        Map     map  = this.CasterPawn.Map;
                        IntVec3 pLoc = this.CasterPawn.Position;
                        if (p.IsColonist)
                        {
                            try
                            {
                                ThingSelectionUtility.SelectNextColonist();
                                this.CasterPawn.DeSpawn();
                                //p.SetPositionDirect(this.currentTarget.Cell);
                                SearchForTargets(arg_29_0, (2f + (float)(.5f * verVal)), map, p);
                                GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                                DrawBlade(p.Position.ToVector3Shifted(), 4f + (float)(verVal));
                                p.drafter.Drafted = true;
                                ThingSelectionUtility.SelectPreviousColonist();
                                TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_BladeSweep"), this.CasterPawn.DrawPos, this.CasterPawn.Map, 1.4f + .4f * ver.level, .04f, 0f, .18f, 1000, 0, 0, Rand.Range(0, 360));
                            }
                            catch
                            {
                                if (!CasterPawn.Spawned)
                                {
                                    GenSpawn.Spawn(p, pLoc, map);
                                    p.drafter.Drafted = true;
                                    Log.Message("Phase strike threw exception - despawned pawn has been recovered at casting location");
                                }
                            }
                        }
                        else
                        {
                            this.CasterPawn.DeSpawn();
                            SearchForTargets(arg_29_0, (2f + (float)(.5f * verVal)), map, p);
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            DrawBlade(p.Position.ToVector3Shifted(), 4f + (float)(verVal));
                        }

                        //this.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                        //base.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                        //this.CasterPawn.pather.ResetToCurrentPosition();
                        result = true;
                    }
                    else
                    {
                        Messages.Message("InvalidTargetLocation".Translate(), MessageTypeDefOf.RejectInput);
                    }
                }
            }
            else
            {
                Messages.Message("MustHaveMeleeWeapon".Translate(
                                     this.CasterPawn.LabelCap
                                     ), MessageTypeDefOf.RejectInput);
                return(false);
            }

            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }
        protected override bool TryCastShot()
        {
            Pawn caster = base.CasterPawn;
            Pawn pawn   = this.currentTarget.Thing as Pawn;

            MagicPowerSkill pwr = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CureDisease.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CureDisease_pwr");
            MagicPowerSkill ver = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CureDisease.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CureDisease_ver");

            verVal = ver.level;
            pwrVal = pwr.level;
            if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            {
                MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                pwrVal = mpwr.level;
                verVal = mver.level;
            }
            bool flag = pawn != null;

            if (flag)
            {
                int num           = 1;
                int sevAdjustment = 0;
                if (pwrVal == 2)
                {
                    //apply immunity buff, 60k ticks in a day
                    HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_DiseaseImmunityHD, 3);
                }
                else if (pwrVal == 3)
                {
                    HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_DiseaseImmunityHD, 5);
                }

                if (pwrVal >= 1)
                {
                    sevAdjustment = 5;
                }
                else
                {
                    sevAdjustment = Mathf.RoundToInt(Rand.Range(0, 1));
                }
                if (sevAdjustment != 0)
                {
                    bool success = false;
                    using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff rec   = enumerator.Current;
                            bool   flag2 = num > 0;


                            if (rec.def.defName == "WoundInfection" || rec.def.defName == "Flu" || rec.def.defName == "Animal_Flu")
                            {
                                rec.Severity -= sevAdjustment;
                                success       = true;
                            }
                            if (verVal >= 1 && (rec.def.defName == "GutWorms" || rec.def == HediffDefOf.Malaria || rec.def == HediffDefOf.FoodPoisoning))
                            {
                                rec.Severity -= sevAdjustment;
                                success       = true;
                            }
                            if (verVal >= 2 && (rec.def.defName == "SleepingSickness" || rec.def.defName == "MuscleParasites"))
                            {
                                rec.Severity -= sevAdjustment;
                                success       = true;
                            }
                            if (verVal == 3 && rec.def.makesSickThought)
                            {
                                rec.Severity -= sevAdjustment;
                                success       = true;
                            }
                        }
                    }
                    if (success == true)
                    {
                        TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3(), pawn.Map, 1.5f);
                        MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Cure Disease" + ": " + StringsToTranslate.AU_CastSuccess, -1f);
                    }
                    else
                    {
                        Messages.Message("TM_CureDiseaseTypeFail".Translate(), MessageTypeDefOf.NegativeEvent);
                        MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Cure Disease" + ": " + StringsToTranslate.AU_CastFailure, -1f);
                    }
                }
                else
                {
                    MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Cure Disease" + ": " + StringsToTranslate.AU_CastFailure, -1f);
                }
            }
            return(false);
        }
Beispiel #3
0
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);

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

            if (!this.initialized)
            {
                pawn = this.launcher as Pawn;
                CompAbilityUserMagic   comp        = pawn.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill        pwr         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Attraction.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Attraction_pwr");
                MagicPowerSkill        ver         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Attraction.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Attraction_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.duration    = this.duration + (180 * verVal);
                this.strikeDelay = this.strikeDelay - verVal;
                this.radius      = this.def.projectile.explosionRadius + (1.5f * pwrVal);
                this.initialized = true;
                IEnumerable <IntVec3> hediffCells = GenRadial.RadialCellsAround(base.Position, 2, true);
                hediffCellList = hediffCells.ToList <IntVec3>();
                IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.radius, false).Except(hediffCells);
                cellList = targets.ToList <IntVec3>();
                for (int i = 0; i < cellList.Count(); i++)
                {
                    if (cellList[i].IsValid && cellList[i].InBounds(pawn.Map))
                    {
                        victim = cellList[i].GetFirstPawn(pawn.Map);
                        if (victim != null && !victim.Dead && !victim.Downed)
                        {
                            HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_GravitySlowHD"), .5f);
                        }
                    }
                }
            }
            IntVec3 curCell = cellList.RandomElement();
            Vector3 angle   = GetVector(base.Position, curCell);

            TM_MoteMaker.ThrowArcaneWaveMote(curCell.ToVector3(), base.Map, .4f * (curCell - base.Position).LengthHorizontal, .1f, .05f, .5f, 0, Rand.Range(1, 2), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), (Quaternion.AngleAxis(-90, Vector3.up) * angle).ToAngleFlat());

            if (Find.TickManager.TicksGame % this.strikeDelay == 0)
            {
                for (int i = 0; i < 3; i++)
                {
                    curCell = cellList.RandomElement();
                    if (curCell.IsValid && curCell.InBounds(base.Map))
                    {
                        victim = curCell.GetFirstPawn(base.Map);
                        if (victim != null && !victim.Dead && victim.RaceProps.IsFlesh && victim != this.pawn)
                        {
                            Vector3 launchVector = GetVector(base.Position, victim.Position);
                            HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_GravitySlowHD"), (.4f + (.1f * verVal)));
                            LaunchFlyingObect(victim.Position + (2f * (1 + (.4f * pwrVal)) * launchVector).ToIntVec3(), victim);
                        }
                        else if (victim != null && !victim.Dead && !victim.RaceProps.IsFlesh)
                        {
                            HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_GravitySlowHD"), .4f + (.1f * verVal));
                        }
                    }
                }
                for (int i = 0; i < hediffCellList.Count(); i++)
                {
                    curCell = hediffCellList[i];
                    if (curCell.IsValid && curCell.InBounds(base.Map))
                    {
                        victim = curCell.GetFirstPawn(base.Map);
                        if (victim != null && !victim.Dead)
                        {
                            HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_GravitySlowHD"), .3f + (.1f * verVal));
                        }
                    }
                }
            }
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def    = this.def;
            Pawn     victim = hitThing as Pawn;
            Thing    item   = hitThing as Thing;
            IntVec3  arg_pos_1;

            Pawn pawn = this.launcher as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      pwr  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SummonPylon.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SummonPylon_pwr");
            MagicPowerSkill      ver  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SummonPylon.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SummonPylon_ver");

            verVal = ver.level;
            pwrVal = pwr.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;
            }
            CellRect cellRect = CellRect.CenteredOn(base.Position, 1);

            cellRect.ClipInsideMap(map);
            IntVec3 centerCell = cellRect.CenterCell;

            if (!this.primed)
            {
                duration += (verVal * 7200);
                duration  = (int)(duration * comp.arcaneDmg);
                arg_pos_1 = centerCell;

                if ((arg_pos_1.IsValid && arg_pos_1.Standable(map)))
                {
                    AbilityUser.SpawnThings tempPod = new SpawnThings();
                    IntVec3 shiftPos = centerCell;
                    centerCell.x++;

                    if (pwrVal == 1)
                    {
                        tempPod.def = ThingDef.Named("DefensePylon_I");
                    }
                    else if (pwrVal == 2)
                    {
                        tempPod.def = ThingDef.Named("DefensePylon_II");
                    }
                    else if (pwrVal == 3)
                    {
                        tempPod.def = ThingDef.Named("DefensePylon_III");
                    }
                    else
                    {
                        tempPod.def = ThingDef.Named("DefensePylon");
                    }
                    tempPod.spawnCount = 1;
                    try
                    {
                        this.SingleSpawnLoop(tempPod, shiftPos, map);
                    }
                    catch
                    {
                        comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_SummonPylon);
                        this.age            = this.duration;
                        Log.Message("TM_Exception".Translate(
                                        pawn.LabelShort,
                                        this.def.defName
                                        ));
                    }

                    this.primed = true;
                }
                else
                {
                    Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                    comp.Mana.GainNeed(comp.ActualManaCost(TorannMagicDefOf.TM_SummonExplosive));
                    this.duration = 0;
                }
            }
            this.age = this.duration;
        }
        protected override bool TryCastShot()
        {
            bool flag = false;
            CompAbilityUserMight comp = base.CasterPawn.GetComp <CompAbilityUserMight>();
            MightPowerSkill      pwr  = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_AnimalFriend.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AnimalFriend_pwr");
            MightPowerSkill      ver  = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_AnimalFriend.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AnimalFriend_ver");
            Pawn pawn   = this.CasterPawn;
            Pawn animal = this.currentTarget.Thing as Pawn;

            if (animal != null && animal.RaceProps.Animal && animal.RaceProps.IsFlesh)
            {
                Pawn oldbond = comp.bondedPet;
                if (animal == comp.bondedPet)
                {
                    comp.bondedPet = null;
                    Messages.Message("TM_BondedAnimalRelease".Translate(
                                         oldbond.LabelShort,
                                         pawn.LabelShort
                                         ), MessageTypeDefOf.NeutralEvent);
                    MoteMaker.ThrowSmoke(oldbond.DrawPos, oldbond.Map, 3f);
                    oldbond.Destroy();
                }
                else if (animal.Faction != null)
                {
                    Messages.Message("TM_AnimalHasAllegience".Translate(
                                         ), MessageTypeDefOf.RejectInput);
                }
                else
                {
                    if (animal.RaceProps.intelligence == Intelligence.Animal) // == TrainableIntelligenceDefOf.Intermediate || animal.RaceProps.TrainableIntelligence == TrainableIntelligenceDefOf.Advanced)
                    {
                        if ((animal.RaceProps.wildness <= .7f) || (animal.RaceProps.wildness <= .8f && pwr.level == 1) || (animal.RaceProps.wildness <= .9f && pwr.level == 2) || pwr.level == 3)
                        {
                            if (Rand.Chance((1 - animal.RaceProps.wildness) * 10))
                            {
                                if (comp.bondedPet != null && comp.bondedPet != animal)
                                {
                                    if (!oldbond.Destroyed)
                                    {
                                        if (!comp.bondedPet.Dead)
                                        {
                                            //bonding with another pet without first pet being dead or destroyed
                                            comp.bondedPet = null;
                                            Messages.Message("TM_BondedAnimalRelease".Translate(
                                                                 oldbond.LabelShort,
                                                                 pawn.LabelShort
                                                                 ), MessageTypeDefOf.NeutralEvent);
                                            if (oldbond.Map != null)
                                            {
                                                MoteMaker.ThrowSmoke(oldbond.DrawPos, oldbond.Map, 3f);
                                            }
                                            else
                                            {
                                                oldbond.ParentHolder.GetDirectlyHeldThings().Remove(oldbond);
                                            }
                                            oldbond.Destroy();
                                        }
                                    }
                                }
                                animal.SetFaction(pawn.Faction);
                                HealthUtility.AdjustSeverity(animal, TorannMagicDefOf.TM_RangerBondHD, -4f);
                                HealthUtility.AdjustSeverity(animal, TorannMagicDefOf.TM_RangerBondHD, .5f + ver.level);
                                comp.bondedPet = animal;

                                if (animal.training.CanBeTrained(TrainableDefOf.Tameness))
                                {
                                    while (!animal.training.HasLearned(TrainableDefOf.Tameness))
                                    {
                                        animal.training.Train(TrainableDefOf.Tameness, pawn);
                                    }
                                }

                                if (animal.training.CanBeTrained(TrainableDefOf.Obedience))
                                {
                                    while (!animal.training.HasLearned(TrainableDefOf.Obedience))
                                    {
                                        animal.training.Train(TrainableDefOf.Obedience, pawn);
                                    }
                                }

                                if (animal.training.CanBeTrained(TrainableDefOf.Release))
                                {
                                    while (!animal.training.HasLearned(TrainableDefOf.Release))
                                    {
                                        animal.training.Train(TrainableDefOf.Release, pawn);
                                    }
                                }

                                if (animal.training.CanBeTrained(TorannMagicDefOf.Haul))
                                {
                                    while (!animal.training.HasLearned(TorannMagicDefOf.Haul))
                                    {
                                        animal.training.Train(TorannMagicDefOf.Haul, pawn);
                                    }
                                }

                                if (animal.training.CanBeTrained(TorannMagicDefOf.Rescue))
                                {
                                    while (!animal.training.HasLearned(TorannMagicDefOf.Rescue))
                                    {
                                        animal.training.Train(TorannMagicDefOf.Rescue, pawn);
                                    }
                                }
                            }
                            else
                            {
                                Messages.Message("TM_FailedRangerBond".Translate(
                                                     animal.LabelShort,
                                                     pawn.LabelShort,
                                                     ((1 - animal.RaceProps.wildness) * 100f)
                                                     ), MessageTypeDefOf.NeutralEvent);
                            }
                        }
                        else
                        {
                            Messages.Message("TM_RangerNotExperienced".Translate(
                                                 animal.LabelShort,
                                                 pawn.LabelShort,
                                                 (animal.RaceProps.wildness * 100).ToString("F"),
                                                 (.7f + .1f * pwr.level) * 100
                                                 ), MessageTypeDefOf.NeutralEvent);
                        }
                    }
                    else
                    {
                        Messages.Message("TM_AnimalIncapableOfBond".Translate(
                                             animal.LabelShort,
                                             pawn.LabelShort
                                             ), MessageTypeDefOf.NeutralEvent);
                    }
                }
            }
            this.PostCastShot(flag, out flag);
            return(flag);
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
            Pawn pawn = this.launcher as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      pwr  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Fireclaw.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Fireclaw_pwr");
            MagicPowerSkill      ver  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Fireclaw.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Fireclaw_ver");

            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;
            }
            if (settingsRef.AIHardMode && !pawn.IsColonist)
            {
                pwrVal = 3;
                verVal = 3;
            }
            IntVec3 target = base.Position;
            IntVec3 origin = this.origin.ToIntVec3();

            if (cflag)
            {
                hyp      = Mathf.Sqrt((Mathf.Pow(origin.x - target.x, 2)) + (Mathf.Pow(origin.z - target.z, 2)));
                duration = (Mathf.RoundToInt(hyp) + 7) * 2;
                angleRad = Mathf.Asin(Mathf.Abs(origin.x - target.x) / hyp);
                angleDeg = Mathf.Rad2Deg * angleRad;
                xProb    = angleDeg / 90;
                cflag    = false; //dont redo calculations
            }

            if (oflag)
            {
                //this.currentPos[j] = origin;
                //this.posAge[j] = 0;
                //this.posFlag[j] = true;
                //this.j++;
                currentPos = origin;
                posFlag    = true;
                pos11Age   = 0;
                oflag      = false;
            }


            if (this.primed == true)
            {
                if (((this.delay + this.lastStrike) < this.age))
                {
                    float rand  = (float)Rand.Range(0, 100);
                    bool  flag  = rand <= (xProb * 100);
                    int   rand2 = Rand.Range(0, 10);                    //used for variance

                    if (rand >= 40 && !pos1Flag && posFlag && this.age >= 10)
                    {
                        currentPos1 = currentPos;
                        pos1Flag    = true;
                        pos1Age     = this.age;
                    }
                    if (rand2 < 3 && !pos11Flag && pos1Flag && this.age >= 15 && verVal >= 1)
                    {
                        currentPos11 = currentPos1;
                        pos11Flag    = true;
                        pos11Age     = this.age;
                    }
                    if (rand2 < 3 && !pos12Flag && pos11Flag && this.age >= 25 && verVal >= 2)
                    {
                        currentPos12 = currentPos1;
                        pos12Flag    = true;
                        pos12Age     = this.age;
                    }
                    if (rand >= 40 && !pos2Flag && pos1Flag && this.age >= 20)
                    {
                        currentPos2 = currentPos;
                        pos2Flag    = true;
                        pos2Age     = this.age;
                    }
                    if (rand2 < 3 && !pos21Flag && pos2Flag && this.age >= 25 && verVal >= 1)
                    {
                        currentPos21 = currentPos2;
                        pos21Flag    = true;
                        pos21Age     = this.age;
                    }
                    if (rand2 < 3 && !pos22Flag && pos21Flag && this.age >= 35 && verVal >= 2)
                    {
                        currentPos22 = currentPos2;
                        pos22Flag    = true;
                        pos22Age     = this.age;
                    }
                    if (rand >= 40 && !pos3Flag && pos2Flag && this.age >= 30)
                    {
                        currentPos3 = currentPos;
                        pos3Flag    = true;
                        pos3Age     = this.age;
                    }
                    if (rand2 < 3 && !pos31Flag && pos3Flag && this.age >= 35 && verVal >= 1)
                    {
                        currentPos31 = currentPos3;
                        pos31Flag    = true;
                        pos31Age     = this.age;
                    }
                    if (rand >= 40 && !pos4Flag && pos3Flag && this.age >= 40)
                    {
                        currentPos4 = currentPos;
                        pos4Flag    = true;
                        pos4Age     = this.age;
                    }
                    if (rand >= 40 && !pos5Flag && pos4Flag && this.age >= 45)
                    {
                        currentPos5 = currentPos;
                        pos5Flag    = true;
                        pos5Age     = this.age;
                    }

                    //strike
                    if (posFlag && posFlagw)
                    {
                        currentPos = GetNewPos(currentPos, origin.x <= target.x, origin.z <= target.z, this.age >= (((duration + posAge) / 2)), 0, 0, xProb, 1 - xProb);
                        try
                        {
                            if ((currentPos.GetTerrain(base.Map).passability == Traversability.Impassable) || !currentPos.Walkable(base.Map))
                            {
                                this.posFlagw = false;
                            }
                            else
                            {
                                if (currentPos.x != origin.x & currentPos.z != origin.z)
                                {
                                    if (verVal >= 3)
                                    {
                                        this.FireExplosion(pwrVal, currentPos, map, 1.2f);
                                    }
                                    else
                                    {
                                        this.FireExplosion(pwrVal, currentPos, map, 0.4f);
                                    }
                                    this.lastStrike = this.age;
                                }
                            }
                        }
                        catch
                        {
                            this.posFlagw = false;
                        }
                    }
                    //1
                    if (pos1Flag && pos1Flagw)
                    {
                        currentPos1 = GetNewPos(currentPos1, origin.x <= target.x, origin.z <= target.z, this.age >= (((duration + pos1Age) / 2)), posx1weight, posz1weight, xProb, 1 - xProb);
                        try
                        {
                            if ((currentPos1.GetTerrain(base.Map).passability == Traversability.Impassable) || !currentPos1.Walkable(base.Map))
                            {
                                this.pos1Flagw = false;
                            }
                            else
                            {
                                if (currentPos1.x != origin.x & currentPos1.z != origin.z)
                                {
                                    if (verVal >= 3)
                                    {
                                        this.FireExplosion(pwrVal, currentPos1, map, 1.0f);
                                    }
                                    else
                                    {
                                        this.FireExplosion(pwrVal, currentPos1, map, 0.4f);
                                    }
                                }
                            }
                        }
                        catch
                        {
                            this.pos1Flagw = false;
                        }
                    }
                    if (pos11Flag && pos11Flagw)
                    {
                        currentPos11 = GetNewPos(currentPos11, origin.x <= target.x, origin.z <= target.z, this.age >= (((duration + pos11Age) / 2)), posx1weight * 1.5f, posz1weight * 1.5f, xProb, 1 - xProb);
                        try
                        {
                            if ((currentPos11.GetTerrain(base.Map).passability == Traversability.Impassable) || !currentPos11.Walkable(base.Map))
                            {
                                this.pos11Flagw = false;
                            }
                            else
                            {
                                if (currentPos11.x != origin.x & currentPos11.z != origin.z)
                                {
                                    if (verVal >= 3)
                                    {
                                        this.FireExplosion(pwrVal, currentPos11, map, 0.8f);
                                    }
                                    else
                                    {
                                        this.FireExplosion(pwrVal, currentPos11, map, 0.4f);
                                    }
                                }
                            }
                        }
                        catch
                        {
                            this.pos11Flagw = false;
                        }
                    }
                    if (pos12Flag && pos12Flagw)
                    {
                        currentPos12 = GetNewPos(currentPos12, origin.x <= target.x, origin.z <= target.z, this.age >= (((duration + pos12Age) / 2)), posx1weight * 2f, posz1weight * 2f, xProb, 1 - xProb);
                        try
                        {
                            if ((currentPos12.GetTerrain(base.Map).passability == Traversability.Impassable) || !currentPos12.Walkable(base.Map))
                            {
                                this.pos12Flagw = false;
                            }
                            else
                            {
                                if (currentPos12.x != origin.x & currentPos12.z != origin.z)
                                {
                                    if (verVal >= 3)
                                    {
                                        this.FireExplosion(pwrVal, currentPos12, map, 0.8f);
                                    }
                                    else
                                    {
                                        this.FireExplosion(pwrVal, currentPos12, map, 0.4f);
                                    }
                                }
                            }
                        }
                        catch
                        {
                            this.pos12Flagw = false;
                        }
                    }
                    //2
                    if (pos2Flag && pos2Flagw)
                    {
                        currentPos2 = GetNewPos(currentPos2, origin.x <= target.x, origin.z <= target.z, this.age >= (((duration + pos2Age) / 2)), posx2weight, posz2weight, xProb, 1 - xProb);
                        try
                        {
                            if ((currentPos2.GetTerrain(base.Map).passability == Traversability.Impassable) || !currentPos2.Walkable(base.Map))
                            {
                                this.pos2Flagw = false;
                            }
                            else
                            {
                                if (currentPos2.x != origin.x & currentPos2.z != origin.z)
                                {
                                    if (verVal >= 3)
                                    {
                                        this.FireExplosion(pwrVal, currentPos2, map, 1.0f);
                                    }
                                    else
                                    {
                                        this.FireExplosion(pwrVal, currentPos2, map, 0.4f);
                                    }
                                }
                            }
                        }
                        catch
                        {
                            this.pos2Flagw = false;
                        }
                    }
                    if (pos21Flag && pos21Flagw)
                    {
                        currentPos21 = GetNewPos(currentPos21, origin.x <= target.x, origin.z <= target.z, this.age >= (((duration + pos21Age) / 2)), posx2weight * 1.5f, posz2weight * 1.5f, xProb, 1 - xProb);
                        try
                        {
                            if ((currentPos21.GetTerrain(base.Map).passability == Traversability.Impassable) || !currentPos21.Walkable(base.Map))
                            {
                                this.pos21Flagw = false;
                            }
                            else
                            {
                                if (currentPos21.x != origin.x & currentPos21.z != origin.z)
                                {
                                    if (verVal >= 3)
                                    {
                                        this.FireExplosion(pwrVal, currentPos21, map, 0.8f);
                                    }
                                    else
                                    {
                                        this.FireExplosion(pwrVal, currentPos21, map, 0.4f);
                                    }
                                }
                            }
                        }
                        catch
                        {
                            this.pos21Flagw = false;
                        }
                    }
                    if (pos22Flag && pos22Flagw)
                    {
                        currentPos22 = GetNewPos(currentPos22, origin.x <= target.x, origin.z <= target.z, this.age >= (((duration + pos22Age) / 2)), posx2weight * 2f, posz2weight * 2f, xProb, 1 - xProb);
                        try
                        {
                            if ((currentPos22.GetTerrain(base.Map).passability == Traversability.Impassable) || !currentPos22.Walkable(base.Map))
                            {
                                this.pos22Flagw = false;
                            }
                            else
                            {
                                if (currentPos22.x != origin.x & currentPos22.z != origin.z)
                                {
                                    if (verVal >= 3)
                                    {
                                        this.FireExplosion(pwrVal, currentPos22, map, 0.8f);
                                    }
                                    else
                                    {
                                        this.FireExplosion(pwrVal, currentPos22, map, 0.4f);
                                    }
                                }
                            }
                        }
                        catch
                        {
                            this.pos22Flagw = false;
                        }
                    }
                    //3
                    if (pos3Flag && pos3Flagw)
                    {
                        currentPos3 = GetNewPos(currentPos3, origin.x <= target.x, origin.z <= target.z, this.age >= (((duration + pos3Age) / 2)), posx3weight, posz3weight, xProb, 1 - xProb);
                        try
                        {
                            if ((currentPos3.GetTerrain(base.Map).passability == Traversability.Impassable) || !currentPos3.Walkable(base.Map))
                            {
                                this.pos3Flagw = false;
                            }
                            else
                            {
                                if (verVal >= 3)
                                {
                                    this.FireExplosion(pwrVal, currentPos3, map, 1.0f);
                                }
                                else
                                {
                                    this.FireExplosion(pwrVal, currentPos3, map, 0.4f);
                                }
                            }
                        }
                        catch
                        {
                            this.pos3Flagw = false;
                        }
                    }
                    if (pos31Flag && pos31Flagw)
                    {
                        currentPos31 = GetNewPos(currentPos31, origin.x <= target.x, origin.z <= target.z, this.age >= (((duration + pos31Age) / 2)), posx3weight * 1.5f, posz3weight * 1.5f, xProb, 1 - xProb);
                        try
                        {
                            if ((currentPos31.GetTerrain(base.Map).passability == Traversability.Impassable) || !currentPos31.Walkable(base.Map))
                            {
                                this.pos31Flagw = false;
                            }
                            else
                            {
                                if (verVal >= 3)
                                {
                                    this.FireExplosion(pwrVal, currentPos31, map, 0.8f);
                                }
                                else
                                {
                                    this.FireExplosion(pwrVal, currentPos31, map, 0.4f);
                                }
                            }
                        }
                        catch
                        {
                            this.pos31Flagw = false;
                        }
                    }
                    //4
                    if (pos4Flag && pos4Flagw)
                    {
                        currentPos4 = GetNewPos(currentPos4, origin.x <= target.x, origin.z <= target.z, this.age >= (((duration + pos4Age) / 2)), posx4weight, posz4weight, xProb, 1 - xProb);
                        try
                        {
                            if ((currentPos4.GetTerrain(base.Map).passability == Traversability.Impassable) || !currentPos4.Walkable(base.Map))
                            {
                                this.pos4Flagw = false;
                            }
                            else
                            {
                                if (verVal >= 3)
                                {
                                    this.FireExplosion(pwrVal, currentPos4, map, 0.8f);
                                }
                                else
                                {
                                    this.FireExplosion(pwrVal, currentPos4, map, 0.4f);
                                }
                            }
                        }
                        catch
                        {
                            this.pos4Flagw = false;
                        }
                    }
                    //5
                    if (pos5Flag && pos5Flagw)
                    {
                        currentPos5 = GetNewPos(currentPos5, origin.x <= target.x, origin.z <= target.z, this.age >= (((duration + pos5Age) / 2)), posx5weight, posz5weight, xProb, 1 - xProb);
                        try
                        {
                            if ((currentPos5.GetTerrain(base.Map).passability == Traversability.Impassable) || !currentPos5.Walkable(base.Map))
                            {
                                this.pos5Flagw = false;
                            }
                            else
                            {
                                if (verVal >= 3)
                                {
                                    this.FireExplosion(pwrVal, currentPos5, map, 0.8f);
                                }
                                else
                                {
                                    this.FireExplosion(pwrVal, currentPos5, map, 0.4f);
                                }
                            }
                        }
                        catch
                        {
                            this.pos5Flagw = false;
                        }
                    }
                    //for (int i=0; i < j; i++)
                    //{
                    //    if (i == 10)
                    //    {
                    //        currentPos[i] = GetNewPos(currentPos[i], origin.x <= target.x, origin.z <= target.z, this.age >= (((duration - posAge[i]) / 2) + duration), 0, 0, xProb, 1-xProb);
                    //    }
                    //    else if (i < 3)
                    //    {
                    //        currentPos[i] = GetNewPos(currentPos[i], origin.x <= target.x, origin.z <= target.z, this.age >= (((duration - posAge[i]) / 2) + duration), posxWeight[i] * 3, poszWeight[i]*3, xProb, 1 - xProb);
                    //    }
                    //    else
                    //    {
                    //        currentPos[i] = GetNewPos(currentPos[i], origin.x <= target.x, origin.z <= target.z, this.age >= (((duration - posAge[i]) / 2) + duration), posxWeight[i] * 5, poszWeight[i] * 5, xProb, 1 - xProb);
                    //    }
                    //    this.FireExplosion(currentPos[i], map, 0.4f);
                    //    this.lastStrike = this.age;
                    //}

                    bool flag1 = this.age <= this.duration;
                    if (!flag1)
                    {
                        this.primed = false;
                        return;
                    }
                }
            }
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

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

            Pawn pawn   = this.launcher as Pawn;
            Pawn victim = hitThing as Pawn;

            CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>();
            MightPowerSkill      pwr  = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_AntiArmor.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AntiArmor_pwr");
            MightPowerSkill      ver  = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_AntiArmor.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AntiArmor_ver");
            MightPowerSkill      str  = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr");

            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;
            }
            if (settingsRef.AIHardMode && !pawn.IsColonist)
            {
                pwrVal = 3;
                verVal = 3;
            }
            this.Initialize(base.Position, pawn);

            if (victim != null && !victim.Dead && Rand.Chance(this.launcher.GetStatValue(StatDefOf.ShootingAccuracy, true)))
            {
                int dmg = GetWeaponDmg(pawn, this.def);
                if (!victim.RaceProps.IsFlesh)
                {
                    MoteMaker.ThrowMicroSparks(victim.Position.ToVector3(), map);
                    damageEntities(victim, null, dmg, DamageDefOf.Bullet);
                    MoteMaker.MakeStaticMote(victim.Position, pawn.Map, ThingDefOf.Mote_ExplosionFlash, 4f);
                    damageEntities(victim, null, GetWeaponDmgMech(pawn, dmg), DamageDefOf.Bullet);
                    MoteMaker.ThrowMicroSparks(victim.Position.ToVector3(), map);
                    for (int i = 0; i < 1 + verVal; i++)
                    {
                        GenExplosion.DoExplosion(newPos, map, Rand.Range((.1f) * (1 + verVal), (.3f) * (1 + verVal)), DamageDefOf.Bomb, this.launcher, (this.def.projectile.damageAmountBase / 4) * (1 + verVal), SoundDefOf.BulletImpactMetal, def, this.equipmentDef, null, 0f, 1, false, null, 0f, 1, 0f, true);
                        GenExplosion.DoExplosion(newPos, map, Rand.Range((.2f) * (1 + verVal), (.4f) * (1 + verVal)), DamageDefOf.Stun, this.launcher, (this.def.projectile.damageAmountBase / 2) * (1 + verVal), SoundDefOf.BulletImpactMetal, def, this.equipmentDef, null, 0f, 1, false, null, 0f, 1, 0f, true);
                        newPos = GetNewPos(newPos, pawn.Position.x <= victim.Position.x, pawn.Position.z <= victim.Position.z, false, 0, 0, xProb, 1 - xProb);
                        MoteMaker.ThrowMicroSparks(victim.Position.ToVector3(), base.Map);
                        MoteMaker.ThrowDustPuff(newPos, map, Rand.Range(1.2f, 2.4f));
                    }
                }
                else
                {
                    damageEntities(victim, null, dmg, DamageDefOf.Bullet);
                }
            }
            else
            {
                Log.Message("No valid target for anti armor shot or missed");
            }
        }
Beispiel #8
0
        public override void Impact_Override(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact_Override(hitThing);

            Pawn pawn = this.launcher as Pawn;

            ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();

            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 = pawn.GetComp <CompAbilityUserMight>().mightPwr;
            }
            else
            {
                CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill      pwr  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningBolt.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningBolt_pwr");
                MagicPowerSkill      ver  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningBolt.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningBolt_ver");
                pwrVal         = pwr.level;
                verVal         = ver.level;
                this.arcaneDmg = comp.arcaneDmg;
            }

            if (settingsRef.AIHardMode && !pawn.IsColonist)
            {
                pwrVal = 3;
                verVal = 3;
            }
            bool flag = hitThing != null;

            if (flag)
            {
                int        DamageAmount = Mathf.RoundToInt(this.def.projectile.GetDamageAmount(1, null) + (pwrVal * 6) * this.arcaneDmg);
                DamageInfo dinfo        = new DamageInfo(this.def.projectile.damageDef, DamageAmount, 0, this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown);
                hitThing.TakeDamage(dinfo);
                if (Rand.Chance(.6f))
                {
                    DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Stun, DamageAmount / 4, 0, this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown);
                    hitThing.TakeDamage(dinfo2);
                }

                bool flag2 = this.canStartFire && Rand.Range(0f, 1f) > this.startFireChance;
                if (flag2)
                {
                    hitThing.TryAttachFire(0.05f);
                }
                Pawn hitTarget;
                bool flag3 = (hitTarget = (hitThing as Pawn)) != null;
                if (flag3)
                {
                    this.PostImpactEffects(this.launcher as Pawn, hitTarget);
                    MoteMaker.ThrowMicroSparks(this.destination, base.Map);
                    MoteMaker.MakeStaticMote(this.destination, base.Map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                }
            }
            else
            {
                MoteMaker.MakeStaticMote(this.ExactPosition, base.Map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                MoteMaker.ThrowMicroSparks(this.ExactPosition, base.Map);
            }
            for (int i = 0; i <= verVal; i++)
            {
                SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None);
                SoundDefOf.Thunder_OnMap.PlayOneShot(info);
            }
            CellRect cellRect = CellRect.CenteredOn(hitThing.Position, 2);

            cellRect.ClipInsideMap(map);
            for (int i = 0; i < Rand.Range(verVal, verVal * 4); i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                this.StaticExplosion(randomCell, map, 0.4f);
            }
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;
            //base.Impact(hitThing);
            ThingDef def    = this.def;
            Pawn     victim = hitThing as Pawn;
            Thing    item   = hitThing as Thing;
            IntVec3  arg_pos_1;

            GenClamor.DoClamor(this, 2.1f, ClamorDefOf.Impact);
            Pawn pawn = this.launcher as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      pwr  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SummonExplosive.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SummonExplosive_pwr");
            MagicPowerSkill      ver  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SummonExplosive.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SummonExplosive_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;
            }
            if (settingsRef.AIHardMode && !pawn.IsColonist)
            {
                pwrVal = 3;
                verVal = 3;
            }
            CellRect cellRect = CellRect.CenteredOn(base.Position, 1);

            cellRect.ClipInsideMap(map);
            IntVec3 centerCell = cellRect.CenterCell;

            if (!this.primed)
            {
                duration += (verVal * 7200);
                duration  = (int)(duration * comp.arcaneDmg);
                arg_pos_1 = centerCell;

                if ((arg_pos_1.IsValid && arg_pos_1.Standable(map)))
                {
                    AbilityUser.SpawnThings tempPod = new SpawnThings();
                    IntVec3 shiftPos = centerCell;
                    centerCell.x++;

                    if (pwrVal == 1)
                    {
                        tempPod.def = ThingDef.Named("TM_ManaMine_I");
                    }
                    else if (pwrVal == 2)
                    {
                        tempPod.def = ThingDef.Named("TM_ManaMine_II");
                    }
                    else if (pwrVal == 3)
                    {
                        tempPod.def = ThingDef.Named("TM_ManaMine_III");
                    }
                    else
                    {
                        tempPod.def = ThingDef.Named("TM_ManaMine");
                    }
                    tempPod.spawnCount = 1;
                    try
                    {
                        Projectile_SummonExplosive.SingleSpawnLoop(tempPod, shiftPos, map, this.launcher, this.duration);
                    }
                    catch
                    {
                        Log.Message("Attempted to create an explosive but threw an unknown exception - recovering and ending attempt");
                        if (pawn != null)
                        {
                            comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_SummonExplosive);
                        }
                        this.age = this.duration;
                        return;
                    }

                    this.primed = true;
                }
                else
                {
                    Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                    if (comp.Mana != null)
                    {
                        comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_SummonExplosive);
                    }
                    this.duration = 0;
                }
            }

            this.age = this.duration;
            Destroy();
        }
Beispiel #10
0
        protected override bool TryCastShot()
        {
            bool flag = false;

            this.TargetsAoE.Clear();
            //this.UpdateTargets();
            this.FindTargets();
            MagicPowerSkill pwr = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SootheAnimal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SootheAnimal_pwr");

            pwrVal = pwr.level;
            if (base.CasterPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            {
                MightPowerSkill mpwr = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                pwrVal = mpwr.level;
            }
            bool flag2 = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1;

            if (flag2)
            {
                this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1);
            }
            for (int i = 0; i < this.TargetsAoE.Count; i++)
            {
                if (this.TargetsAoE[i].Thing.Faction != this.CasterPawn.Faction)
                {
                    Pawn newPawn = this.TargetsAoE[i].Thing as Pawn;

                    bool flag1 = (newPawn.mindState.mentalStateHandler.CurStateDef == MentalStateDefOf.ManhunterPermanent) || (newPawn.mindState.mentalStateHandler.CurStateDef == MentalStateDefOf.Manhunter);
                    if (flag1)
                    {
                        if (newPawn.kindDef.RaceProps.Animal)
                        {
                            newPawn.mindState.mentalStateHandler.Reset();
                            newPawn.jobs.StopAll();
                            MoteMaker.ThrowMicroSparks(newPawn.Position.ToVector3().normalized, newPawn.Map);
                            float sev = Rand.Range(pwrVal, 2 * pwrVal);
                            HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiManipulation, sev);
                            sev = Rand.Range(pwrVal, 2 * pwrVal);
                            HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiMovement, sev);
                            sev = Rand.Range(pwrVal, 2 * pwrVal);
                            HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiBreathing, sev);
                            sev = Rand.Range(pwrVal, 2 * pwrVal);
                            HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiSight, sev);
                            if (pwrVal > 0)
                            {
                                TM_MoteMaker.ThrowSiphonMote(newPawn.Position.ToVector3(), newPawn.Map, 1f);
                            }
                        }
                    }
                    if (!flag1)
                    {
                        if (newPawn.kindDef.RaceProps.Animal && (this.TargetsAoE[i].Thing.Faction == null || this.TargetsAoE[i].Thing.HostileTo(base.CasterPawn.Faction)))
                        {
                            newPawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, true, false, null);
                            float sev = Rand.Range(pwrVal, 2 * pwrVal);
                            HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Manipulation, sev);
                            sev = Rand.Range(pwrVal, 2 * pwrVal);
                            HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Movement, sev);
                            sev = Rand.Range(pwrVal, 2 * pwrVal);
                            HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Breathing, sev);
                            sev = Rand.Range(pwrVal, 2 * pwrVal);
                            HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Sight, sev);
                            MoteMaker.ThrowMicroSparks(newPawn.Position.ToVector3().normalized, newPawn.Map);
                            if (pwrVal > 0)
                            {
                                TM_MoteMaker.ThrowManaPuff(newPawn.Position.ToVector3(), newPawn.Map, 1f);
                            }
                            List <Pawn> potentialHostiles = new List <Pawn>();
                            potentialHostiles.Clear();
                            for (int j = 0; j < newPawn.Map.mapPawns.AllPawnsSpawned.Count; j++)
                            {
                                Pawn hostile = newPawn.Map.mapPawns.AllPawnsSpawned[j];
                                if (hostile.Faction.HostileTo(Faction.OfPlayerSilentFail))
                                {
                                    potentialHostiles.AddDistinct(hostile);
                                }
                            }
                            if (potentialHostiles.Count > 0)
                            {
                                Job job = new Job(JobDefOf.AttackMelee, potentialHostiles.RandomElement());
                                newPawn.jobs.TryTakeOrderedJob(job, JobTag.InMentalState);
                            }
                        }
                    }
                }
            }
            this.PostCastShot(flag, out flag);
            return(flag);
        }
Beispiel #11
0
        protected override bool TryCastShot()
        {
            // power affects enumerator
            // DamageWorker.DamageResult result = DamageWorker.DamageResult.MakeNew();
            Pawn caster = this.CasterPawn;
            CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      pwr  = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AdvancedHeal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AdvancedHeal_pwr");
            MagicPowerSkill      ver  = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AdvancedHeal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AdvancedHeal_ver");

            pwrVal = pwr.level;
            verVal = ver.level;
            if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            {
                MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                pwrVal = mpwr.level;
                verVal = mver.level;
            }

            Pawn pawn = (Pawn)this.currentTarget;
            bool flag = pawn != null && !pawn.Dead;

            if (flag)
            {
                int num = 3 + verVal;
                using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        BodyPartRecord rec   = enumerator.Current;
                        bool           flag2 = num > 0;

                        if (flag2)
                        {
                            int num2 = 1 + verVal;
                            ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                            if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode)
                            {
                                num2 = 5;
                            }
                            IEnumerable <Hediff_Injury> arg_BB_0 = pawn.health.hediffSet.GetHediffs <Hediff_Injury>();
                            Func <Hediff_Injury, bool>  arg_BB_1;

                            arg_BB_1 = ((Hediff_Injury injury) => injury.Part == rec);

                            foreach (Hediff_Injury current in arg_BB_0.Where(arg_BB_1))
                            {
                                bool flag4 = num2 > 0;
                                if (flag4)
                                {
                                    bool flag5 = current.CanHealNaturally() && !current.IsPermanent();
                                    if (flag5)
                                    {
                                        //current.Heal((float)((int)current.Severity + 1));
                                        if (!this.CasterPawn.IsColonist)
                                        {
                                            current.Heal(30.0f + (float)pwrVal * 3f); // power affects how much to heal
                                        }
                                        else
                                        {
                                            current.Heal((8.0f + (float)pwrVal * 5f) * comp.arcaneDmg); // power affects how much to heal
                                        }
                                        TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, 1f + .2f * pwrVal);
                                        TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .8f + .1f * pwrVal);
                                        num--;
                                        num2--;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }
Beispiel #12
0
        protected override bool TryCastShot()
        {
            bool flag = false;

            Map map = this.CasterPawn.Map;

            Pawn hitPawn = this.currentTarget.Thing as Pawn;
            Pawn caster  = this.CasterPawn;

            try
            {
                MagicPowerSkill pwr = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Regenerate.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Regenerate_pwr");
                MagicPowerSkill ver = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Regenerate.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Regenerate_ver");
                verVal    = ver.level;
                pwrVal    = pwr.level;
                arcaneDmg = caster.GetComp <CompAbilityUserMagic>().arcaneDmg;
                if (this.caster != null && caster.story != null && caster.story.traits != null && caster.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                {
                    MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                    MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                    pwrVal = mpwr.level;
                    verVal = mver.level;
                }
            }
            catch (NullReferenceException ex)
            {
                //ex
            }
            try
            {
                if (!hitPawn.DestroyedOrNull() & !hitPawn.Dead && hitPawn.Spawned && map != null)
                {
                    if (pwrVal == 3)
                    {
                        HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_Regeneration_III, Rand.Range(1f + verVal, 3f + (verVal * 3)) * this.arcaneDmg);
                        TM_MoteMaker.ThrowRegenMote(hitPawn.DrawPos, map, 1f + (.2f * (verVal + pwrVal)));
                    }
                    else if (pwrVal == 2)
                    {
                        HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_Regeneration_II, Rand.Range(1f + verVal, 3f + (verVal * 3)) * this.arcaneDmg);
                        TM_MoteMaker.ThrowRegenMote(hitPawn.DrawPos, map, 1f + (.2f * (verVal + pwrVal)));
                    }
                    else if (pwrVal == 1)
                    {
                        HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_Regeneration_I, Rand.Range(1f + verVal, 3f + (verVal * 3)) * this.arcaneDmg);
                        TM_MoteMaker.ThrowRegenMote(hitPawn.DrawPos, map, 1f + (.2f * (verVal + pwrVal)));
                    }
                    else
                    {
                        HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_Regeneration, Rand.Range(1f + verVal, 3f + (verVal * 3)) * this.arcaneDmg);
                        TM_MoteMaker.ThrowRegenMote(hitPawn.DrawPos, map, 1f + (.2f * (verVal + pwrVal)));
                    }
                }
                else
                {
                    Messages.Message("TM_NothingToRegenerate".Translate(), MessageTypeDefOf.NeutralEvent);
                }
            }
            catch (NullReferenceException ex)
            {
                //ex
            }
            this.PostCastShot(flag, out flag);
            return(flag);
        }
Beispiel #13
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def  = this.def;
            Pawn     pawn = this.launcher as Pawn;

            if (!this.initialized)
            {
                CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill      pwr  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CorpseExplosion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CorpseExplosion_pwr");
                MagicPowerSkill      ver  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CorpseExplosion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CorpseExplosion_ver");
                this.arcaneDmg = comp.arcaneDmg;
                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;
                }
                Initialize();

                CellRect cellRect = CellRect.CenteredOn(base.Position, 1);
                cellRect.ClipInsideMap(map);
                IntVec3 curCell = cellRect.CenterCell;
                if (curCell.InBounds(map) && curCell.IsValid)
                {
                    Pawn undead = curCell.GetFirstPawn(map);
                    bool flag   = undead != null && !undead.Dead;
                    if (flag)
                    {
                        if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadHD))
                        {
                            this.targetPawn = undead;
                        }
                        if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadAnimalHD))
                        {
                            this.targetPawn = undead;
                        }
                    }

                    Thing  corpseThing = curCell.GetFirstItem(map);
                    Corpse corpse      = null;
                    if (corpseThing != null)
                    {
                        bool validator = corpseThing is Corpse;
                        if (validator)
                        {
                            corpse = corpseThing as Corpse;
                            Pawn corpsePawn = corpse.InnerPawn;
                            if (corpsePawn.RaceProps.IsFlesh)
                            {
                                if (corpsePawn.RaceProps.Humanlike || corpsePawn.RaceProps.Animal)
                                {
                                    this.targetCorpse = corpse;
                                }
                            }
                        }
                    }
                }
            }

            if (this.targetPawn != null && !this.targetPawn.Destroyed)
            {
                if (this.age == 360)
                {
                    MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "6", -.5f);
                }
                if (this.age == 300)
                {
                    MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "5", -.5f);
                }
                if (this.age == 240)
                {
                    MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "4", -.5f);
                }
                if (this.age == 180)
                {
                    MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "3", -.5f);
                }
                if (this.age == 120)
                {
                    MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "2", -.5f);
                }
                if (this.age == 60)
                {
                    MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "1", -.5f);
                }
                if (this.age == 1)
                {
                    //explode
                    TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, 1.2f);
                    TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, .6f);
                    TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, .8f);
                    if (this.targetPawn.RaceProps.Humanlike)
                    {
                        this.targetPawn.inventory.DropAllNearPawn(this.targetPawn.Position, false, true);
                        this.targetPawn.equipment.DropAllEquipment(this.targetPawn.Position, false);
                        this.targetPawn.apparel.DropAll(this.targetPawn.Position, false);
                    }
                    GenExplosion.DoExplosion(this.targetPawn.Position, map, this.radius, TMDamageDefOf.DamageDefOf.TM_CorpseExplosion, this.launcher, Mathf.RoundToInt((Rand.Range(18f, 30f) + (5f * pwrVal)) * this.arcaneDmg), this.def.projectile.soundExplode, def, this.equipmentDef, null, 0f, 01, false, null, 0f, 0, 0.0f, true);
                    if (!this.targetPawn.Destroyed)
                    {
                        this.targetPawn.Destroy();
                    }
                }
            }

            if (this.targetCorpse != null && !this.targetCorpse.Destroyed)
            {
                if (this.age == 360)
                {
                    MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "6", -.5f);
                }
                if (this.age == 300)
                {
                    MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "5", -.5f);
                }
                if (this.age == 240)
                {
                    MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "4", -.5f);
                }
                if (this.age == 180)
                {
                    MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "3", -.5f);
                }
                if (this.age == 120)
                {
                    MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "2", -.5f);
                }
                if (this.age == 60)
                {
                    MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "1", -.5f);
                }
                if (this.age == 1)
                {
                    //explode
                    TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, 1.2f);
                    TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, .6f);
                    TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, .8f);
                    Pawn corpsePawn = this.targetCorpse.InnerPawn;
                    if (corpsePawn.RaceProps.Humanlike)
                    {
                        corpsePawn.inventory.DropAllNearPawn(this.targetCorpse.Position, false, true);
                        corpsePawn.equipment.DropAllEquipment(this.targetCorpse.Position, false);
                        corpsePawn.apparel.DropAll(this.targetCorpse.Position, false);
                    }
                    GenExplosion.DoExplosion(this.targetCorpse.Position, map, this.radius, TMDamageDefOf.DamageDefOf.TM_CorpseExplosion, this.launcher, Mathf.RoundToInt((Rand.Range(18f, 30f) + (5f * pwrVal)) * this.arcaneDmg), this.def.projectile.soundExplode, def, this.equipmentDef, null, 0f, 01, false, null, 0f, 0, 0.0f, true);
                    if (!this.targetCorpse.Destroyed)
                    {
                        this.targetCorpse.Destroy();
                    }
                }
            }
        }
Beispiel #14
0
        protected override bool TryCastShot()
        {
            Pawn caster = this.CasterPawn;
            Pawn pawn   = this.currentTarget.Thing as Pawn;
            CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();

            if (comp != null && !caster.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            {
                MagicPowerSkill pwr = comp.MagicData.MagicPowerSkill_Purify.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Purify_pwr");
                MagicPowerSkill ver = comp.MagicData.MagicPowerSkill_Purify.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Purify_ver");
                pwrVal    = pwr.level;
                verVal    = ver.level;
                arcaneDmg = comp.arcaneDmg;
            }
            else if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            {
                MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                pwrVal    = mpwr.level;
                verVal    = mver.level;
                arcaneDmg = caster.GetComp <CompAbilityUserMight>().mightPwr;
            }
            bool flag = pawn != null && !pawn.Dead;

            if (flag)
            {
                int num = Mathf.RoundToInt(1f + (.4f * verVal));
                using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        BodyPartRecord rec   = enumerator.Current;
                        bool           flag2 = num > 0;
                        if (flag2)
                        {
                            int num2 = 1 + verVal;
                            IEnumerable <Hediff_Injury> arg_BB_0 = pawn.health.hediffSet.GetHediffs <Hediff_Injury>();
                            Func <Hediff_Injury, bool>  arg_BB_1;

                            arg_BB_1 = ((Hediff_Injury injury) => injury.Part == rec);

                            foreach (Hediff_Injury current in arg_BB_0.Where(arg_BB_1))
                            {
                                bool flag4 = num2 > 0;
                                if (flag4)
                                {
                                    bool flag5 = !current.CanHealNaturally() && current.IsPermanent();
                                    if (flag5)
                                    {
                                        if (rec.def.tags.Contains(BodyPartTagDefOf.ConsciousnessSource))
                                        {
                                            if (pwrVal >= 1)
                                            {
                                                current.Heal(pwrVal * arcaneDmg);
                                                num--;
                                                num2--;
                                            }
                                        }
                                        else
                                        {
                                            current.Heal((2f + pwrVal * 2) * arcaneDmg);
                                            //current.Heal(5.0f + (float)pwrVal * 3f); // power affects how much to heal
                                            num--;
                                            num2--;
                                        }
                                        TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f);
                                        TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f);
                                    }
                                }
                            }
                        }
                    }
                }
                //if (pawn.RaceProps.Humanlike)
                //{
                using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Hediff rec   = enumerator.Current;
                        bool   flag2 = num > 0;
                        if (flag2)
                        {
                            if (rec.def.defName == "Cataract" || rec.def.defName == "HearingLoss" || rec.def.defName.Contains("ToxicBuildup"))
                            {
                                rec.Heal(.4f + .3f * pwrVal);
                                num--;
                            }
                            if ((rec.def.defName == "Blindness" || rec.def.defName.Contains("Asthma") || rec.def.defName == "Cirrhosis" || rec.def.defName == "ChemicalDamageModerate") && verVal >= 1)
                            {
                                rec.Heal(.3f + .2f * pwrVal);
                                if (rec.def.defName.Contains("Asthma"))
                                {
                                    pawn.health.RemoveHediff(rec);
                                }
                                num--;
                            }
                            if ((rec.def.defName == "Frail" || rec.def.defName == "BadBack" || rec.def.defName.Contains("Carcinoma") || rec.def.defName == "ChemicalDamageSevere") && verVal >= 2)
                            {
                                rec.Heal(.2f + .15f * pwrVal);
                                num--;
                            }
                            if ((rec.def.defName.Contains("Alzheimers") || rec.def.defName == "Dementia" || rec.def.defName.Contains("HeartArteryBlockage") || rec.def.defName == "PsychicShock" || rec.def.defName == "CatatonicBreakdown") && verVal >= 3)
                            {
                                rec.Heal(.1f + .1f * pwrVal);
                                num--;
                            }
                            if (rec.def.defName.Contains("Abasia") && verVal >= 3)
                            {
                                if (Rand.Chance(.25f + (.05f * pwrVal)))
                                {
                                    pawn.health.RemoveHediff(pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Abasia")));
                                    num--;
                                }
                                else
                                {
                                    MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Failed to remove Abasia...");
                                }
                            }
                            TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f);
                            TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f);
                        }
                    }
                }
                //}
                using (IEnumerator <Hediff_Addiction> enumerator = pawn.health.hediffSet.GetHediffs <Hediff_Addiction>().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Hediff_Addiction rec   = enumerator.Current;
                        bool             flag2 = num > 0;
                        if (flag2)
                        {
                            if (rec.Chemical.defName == "Alcohol" || rec.Chemical.defName == "Smokeleaf")
                            {
                                rec.Severity -= ((.3f + .3f * pwrVal) * arcaneDmg);
                                num--;
                            }
                            if ((rec.Chemical.defName == "GoJuice" || rec.Chemical.defName == "WakeUp") && verVal >= 1)
                            {
                                rec.Severity -= ((.25f + .25f * pwrVal) * arcaneDmg);
                                num--;
                            }
                            if (rec.Chemical.defName == "Psychite" && verVal >= 2)
                            {
                                rec.Severity -= ((.25f + .25f * pwrVal) * arcaneDmg);
                                num--;
                            }
                            if (verVal >= 3)
                            {
                                if (rec.Chemical.defName == "Luciferium" && (rec.Severity - ((.15f + .15f * pwrVal) * arcaneDmg) < 0))
                                {
                                    Hediff luciHigh = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("LuciferiumHigh"), false);
                                    pawn.health.RemoveHediff(luciHigh);
                                }
                                rec.Severity -= ((.15f + .15f * pwrVal) * arcaneDmg);
                                num--;
                            }
                            TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f);
                            TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f);
                        }
                    }
                }
            }
            return(true);
        }
Beispiel #15
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);

            if (!initialized)
            {
                SpawnThings spawnThing = new SpawnThings();
                pawn = this.launcher as Pawn;
                MagicPowerSkill        pwr         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SummonElemental.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SummonElemental_pwr");
                MagicPowerSkill        ver         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SummonElemental.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SummonElemental_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;
                }
                if (settingsRef.AIHardMode && !pawn.IsColonist)
                {
                    pwrVal = 3;
                    verVal = 3;
                }
                CellRect cellRect = CellRect.CenteredOn(this.Position, 1);
                cellRect.ClipInsideMap(map);

                IntVec3       centerCell = cellRect.CenterCell;
                System.Random random     = new System.Random();
                random = new System.Random();

                duration += (verVal * 900);

                int rnd = GenMath.RoundRandom(random.Next(0, 8));
                if (rnd < 2)
                {
                    spawnThing.factionDef = TorannMagicDefOf.TM_ElementalFaction;
                    spawnThing.spawnCount = 1;
                    spawnThing.temporary  = false;

                    if (pwrVal == 3)
                    {
                        for (int i = 0; i < 2; i++)
                        {
                            spawnThing.def     = TorannMagicDefOf.TM_LesserEarth_ElementalR;
                            spawnThing.kindDef = PawnKindDef.Named("TM_LesserEarth_Elemental");
                            SingleSpawnLoop(spawnThing, centerCell, map);
                        }
                        spawnThing.def     = TorannMagicDefOf.TM_GreaterEarth_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_GreaterEarth_Elemental");
                    }
                    else if (pwrVal == 2)
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_GreaterEarth_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_GreaterEarth_Elemental");
                    }
                    else if (pwrVal == 1)
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_Earth_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_Earth_Elemental");
                    }
                    else
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_LesserEarth_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_LesserEarth_Elemental");
                    }
                    MoteMaker.ThrowSmoke(centerCell.ToVector3(), map, pwrVal);
                    MoteMaker.ThrowMicroSparks(centerCell.ToVector3(), map);
                    SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f);
                }
                else if (rnd >= 2 && rnd < 4)
                {
                    spawnThing.factionDef = TorannMagicDefOf.TM_ElementalFaction;
                    spawnThing.spawnCount = 1;
                    spawnThing.temporary  = false;

                    if (pwrVal == 3)
                    {
                        for (int i = 0; i < 2; i++)
                        {
                            spawnThing.def     = TorannMagicDefOf.TM_LesserFire_ElementalR;
                            spawnThing.kindDef = PawnKindDef.Named("TM_LesserFire_Elemental");
                            SingleSpawnLoop(spawnThing, centerCell, map);
                        }
                        spawnThing.def     = TorannMagicDefOf.TM_GreaterFire_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_GreaterFire_Elemental");
                    }
                    else if (pwrVal == 2)
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_GreaterFire_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_GreaterFire_Elemental");
                    }
                    else if (pwrVal == 1)
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_Fire_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_Fire_Elemental");
                    }
                    else
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_LesserFire_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_LesserFire_Elemental");
                    }
                    MoteMaker.ThrowSmoke(centerCell.ToVector3(), map, pwrVal);
                    MoteMaker.ThrowMicroSparks(centerCell.ToVector3(), map);
                    MoteMaker.ThrowFireGlow(centerCell, map, pwrVal);
                    MoteMaker.ThrowHeatGlow(centerCell, map, pwrVal);
                }
                else if (rnd >= 4 && rnd < 6)
                {
                    spawnThing.factionDef = TorannMagicDefOf.TM_ElementalFaction;
                    spawnThing.spawnCount = 1;
                    spawnThing.temporary  = false;

                    if (pwrVal == 3)
                    {
                        for (int i = 0; i < 2; i++)
                        {
                            spawnThing.def     = TorannMagicDefOf.TM_LesserWater_ElementalR;
                            spawnThing.kindDef = PawnKindDef.Named("TM_LesserWater_Elemental");
                            SingleSpawnLoop(spawnThing, centerCell, map);
                        }
                        spawnThing.def     = TorannMagicDefOf.TM_GreaterWater_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_GreaterWater_Elemental");
                    }
                    else if (pwrVal == 2)
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_GreaterWater_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_GreaterWater_Elemental");
                    }
                    else if (pwrVal == 1)
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_Water_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_Water_Elemental");
                    }
                    else
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_LesserWater_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_LesserWater_Elemental");
                    }
                    MoteMaker.ThrowSmoke(centerCell.ToVector3(), map, pwrVal);
                    SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f);
                    MoteMaker.ThrowTornadoDustPuff(centerCell.ToVector3(), map, pwrVal, Color.blue);
                    MoteMaker.ThrowTornadoDustPuff(centerCell.ToVector3(), map, pwrVal, Color.blue);
                    MoteMaker.ThrowTornadoDustPuff(centerCell.ToVector3(), map, pwrVal, Color.blue);
                }
                else
                {
                    spawnThing.factionDef = TorannMagicDefOf.TM_ElementalFaction;
                    spawnThing.spawnCount = 1;
                    spawnThing.temporary  = false;

                    if (pwrVal == 3)
                    {
                        for (int i = 0; i < 2; i++)
                        {
                            spawnThing.def     = TorannMagicDefOf.TM_LesserWind_ElementalR;
                            spawnThing.kindDef = PawnKindDef.Named("TM_LesserWind_Elemental");
                            SingleSpawnLoop(spawnThing, centerCell, map);
                        }
                        spawnThing.def     = TorannMagicDefOf.TM_GreaterWind_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_GreaterWind_Elemental");
                    }
                    else if (pwrVal == 2)
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_GreaterWind_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_GreaterWind_Elemental");
                    }
                    else if (pwrVal == 1)
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_Wind_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_Wind_Elemental");
                    }
                    else
                    {
                        spawnThing.def     = TorannMagicDefOf.TM_LesserWind_ElementalR;
                        spawnThing.kindDef = PawnKindDef.Named("TM_LesserWind_Elemental");
                    }
                    MoteMaker.ThrowSmoke(centerCell.ToVector3(), map, 1 + pwrVal * 2);
                    SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f);
                    MoteMaker.ThrowTornadoDustPuff(centerCell.ToVector3(), map, pwrVal, Color.white);
                }

                SingleSpawnLoop(spawnThing, centerCell, map);

                this.age         = this.duration;
                this.initialized = true;
            }
        }
Beispiel #16
0
        protected override bool TryCastShot()
        {
            bool result = false;
            bool arg_40_0;

            CompAbilityUserMight comp = this.CasterPawn.GetComp <CompAbilityUserMight>();

            pwr = comp.MightData.MightPowerSkill_PhaseStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PhaseStrike_pwr");
            ver = comp.MightData.MightPowerSkill_PhaseStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PhaseStrike_ver");
            str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr");

            if (this.CasterPawn.equipment.Primary != null && !this.CasterPawn.equipment.Primary.def.IsRangedWeapon)
            {
                weaponComp      = base.CasterPawn.equipment.Primary;
                weaponDPS       = weaponComp.GetStatValue(StatDefOf.MeleeWeapon_AverageDPS, false) * .7f;
                dmgMultiplier   = weaponComp.GetStatValue(StatDefOf.MeleeWeapon_DamageMultiplier, false);
                pawnDPS         = base.CasterPawn.GetStatValue(StatDefOf.MeleeDPS, false);
                skillMultiplier = (.8f + (.025f * str.level));
                dmgNum          = Mathf.RoundToInt(skillMultiplier * dmgMultiplier * (pawnDPS + weaponDPS));
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                if (!this.CasterPawn.IsColonistPlayerControlled && settingsRef.AIHardMode)
                {
                    dmgNum += 10;
                }

                if (this.currentTarget != null && base.CasterPawn != null)
                {
                    arg_29_0 = this.currentTarget.Cell;
                    Vector3 vector = this.currentTarget.CenterVector3;
                    arg_40_0 = this.currentTarget.Cell.IsValid;
                    arg_41_0 = vector.InBounds(base.CasterPawn.Map);
                    arg_42_0 = true; // vector.ToIntVec3().Standable(base.CasterPawn.Map);
                }
                else
                {
                    arg_40_0 = false;
                }
                bool flag  = arg_40_0;
                bool flag2 = arg_41_0;
                bool flag3 = arg_42_0;
                if (flag)
                {
                    if (flag2 & flag3)
                    {
                        Pawn    p    = this.CasterPawn;
                        Map     map  = this.CasterPawn.Map;
                        IntVec3 pLoc = this.CasterPawn.Position;
                        if (p.IsColonistPlayerControlled)
                        {
                            try
                            {
                                ThingSelectionUtility.SelectNextColonist();
                                this.CasterPawn.DeSpawn();
                                //p.SetPositionDirect(this.currentTarget.Cell);
                                SearchForTargets(arg_29_0, (2f + (float)(.5f * ver.level)), map, p);
                                GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                                DrawBlade(p.Position.ToVector3Shifted(), 4f + (float)(ver.level));
                                p.drafter.Drafted = true;
                                ThingSelectionUtility.SelectPreviousColonist();
                            }
                            catch
                            {
                                if (!CasterPawn.Spawned)
                                {
                                    GenSpawn.Spawn(p, pLoc, map);
                                    p.drafter.Drafted = true;
                                    Log.Message("Phase strike threw exception - despawned pawn has been recovered at casting location");
                                }
                            }
                            this.Ability.PostAbilityAttempt();
                        }
                        else
                        {
                            this.CasterPawn.DeSpawn();
                            SearchForTargets(arg_29_0, (2f + (float)(.5f * ver.level)), map, p);
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            DrawBlade(p.Position.ToVector3Shifted(), 4f + (float)(ver.level));
                        }

                        //this.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                        //base.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                        //this.CasterPawn.pather.ResetToCurrentPosition();
                        result = true;
                    }
                    else
                    {
                        Messages.Message("InvalidTargetLocation".Translate(), MessageTypeDefOf.RejectInput);
                    }
                }
            }
            else
            {
                Messages.Message("MustHaveMeleeWeapon".Translate(new object[]
                {
                    this.CasterPawn.LabelCap
                }), MessageTypeDefOf.RejectInput);
                return(false);
            }

            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);
            Pawn pawn = this.launcher as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();

            pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Overwhelm.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Overwhelm_pwr");
            ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Overwhelm.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Overwhelm_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;
            }
            Map map = pawn.Map;

            if (pawn != null)
            {
                pos = pawn.Position;

                pos.x++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);
                pos.z--;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);
                pos.x--;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);
                pos.x--;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);
                pos.z++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);
                pos.z++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);
                pos.x++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);
                pos.x++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);


                pos.x++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x++;
                pos.z--;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x++;
                pos.z--;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.z--;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x -= 3;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x--;
                pos.z--;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x--;
                pos.z--;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x--;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.z += 3;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x--;
                pos.z++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x--;
                pos.z++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.z++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x += 3;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x++;
                pos.z++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x++;
                pos.z++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                pos.x++;
                HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                if (verVal >= 1)
                {
                    pos.x++;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.z--;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x -= 3;
                    pos.z--;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x -= 3;
                    pos.z++;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x--;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.z -= 3;
                    pos.x += 2;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.z -= 3;
                    pos.x--;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.z--;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x += 3;
                    pos.z += 2;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x += 3;
                    pos.z--;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x++;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.z += 3;
                    pos.x -= 2;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x += 3;
                    pos.z++;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x -= 6;
                    pos.z += 4;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x -= 4;
                    pos.z -= 6;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x += 6;
                    pos.z -= 4;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);
                }

                if (verVal >= 3)
                {
                    pos.x++;
                    pos.z++;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x += 2;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x--;
                    pos.z += 3;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x++;
                    pos.z += 3;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.z += 2;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x -= 3;
                    pos.z--;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x -= 3;
                    pos.z++;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x -= 2;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x++;
                    pos.z -= 3;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x--;
                    pos.z -= 3;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.z -= 2;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x += 3;
                    pos.z++;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x += 6;
                    pos.z -= 2;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.z += 10;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.x -= 10;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);

                    pos.z -= 10;
                    HolyExplosion(pwrVal, verVal, pos, map, 0.4f);
                }
            }
            else
            {
                Log.Warning("failed to cast");
            }
        }
Beispiel #18
0
        protected override bool TryCastShot()
        {
            // power affects enumerator
            //DamageWorker.DamageResult result = DamageWorker.DamageResult.MakeNew();
            Pawn caster = this.CasterPawn;
            CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();

            pwrVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Heal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Heal_pwr").level;
            verVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Heal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Heal_ver").level;
            if (caster.story.traits.HasTrait(TorannMagicDefOf.Priest))
            {
                pwrVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AdvancedHeal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AdvancedHeal_pwr").level;
                verVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AdvancedHeal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AdvancedHeal_ver").level;
            }
            else if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            {
                MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                pwrVal = mpwr.level;
                verVal = mver.level;
            }
            else if (caster.story.traits.HasTrait(TorannMagicDefOf.TM_Wanderer) || (comp.customClass != null && comp.customClass.classMageAbilities.Contains(TorannMagicDefOf.TM_Cantrips)))
            {
                int tmpPwrVal = (int)(caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_pwr").level / 5);
                int tmpVerVal = (int)(caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_ver").level / 5);
                pwrVal = (tmpPwrVal > pwrVal) ? tmpPwrVal : pwrVal;
                verVal = (tmpVerVal > verVal) ? tmpVerVal : verVal;
            }

            Pawn pawn       = (Pawn)this.currentTarget;
            bool flag       = pawn != null && !pawn.Dead && !TM_Calc.IsUndead(pawn);
            bool flagUndead = pawn != null && !pawn.Dead && TM_Calc.IsUndead(pawn);

            if (flag)
            {
                int num = 3 + verVal;
                using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        BodyPartRecord rec   = enumerator.Current;
                        bool           flag2 = num > 0;

                        if (flag2)
                        {
                            int num2 = 1 + verVal;
                            ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                            if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode)
                            {
                                num2 = 5;
                            }
                            IEnumerable <Hediff_Injury> arg_BB_0 = pawn.health.hediffSet.GetHediffs <Hediff_Injury>();
                            Func <Hediff_Injury, bool>  arg_BB_1;

                            arg_BB_1 = (Hediff_Injury injury) => injury.Part == rec;

                            foreach (Hediff_Injury current in arg_BB_0.Where(arg_BB_1))
                            {
                                bool flag4 = num2 > 0;
                                if (flag4)
                                {
                                    bool flag5 = current.CanHealNaturally() && !current.IsPermanent();
                                    if (flag5)
                                    {
                                        //current.Heal((float)((int)current.Severity + 1));
                                        if (!this.CasterPawn.IsColonist)
                                        {
                                            current.Heal(20.0f + ((float)pwrVal * 3f)); // power affects how much to heal
                                        }
                                        else
                                        {
                                            current.Heal((8.0f + ((float)pwrVal * 2f)) * comp.arcaneDmg); // power affects how much to heal
                                        }
                                        TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f);
                                        TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f);
                                        num--;
                                        num2--;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (flagUndead)
            {
                for (int i = 0; i < 2 + verVal; i++)
                {
                    TM_Action.DamageUndead(pawn, (5f + (3f * pwrVal)) * comp.arcaneDmg, this.CasterPawn);
                }
            }
            return(true);
        }
Beispiel #19
0
        protected override bool TryCastShot()
        {
            bool result  = false;
            Pawn p       = this.CasterPawn;
            Pawn hitPawn = this.currentTarget.Thing as Pawn;
            CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      pwr  = comp.MagicData.MagicPowerSkill_Dominate.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Dominate_pwr");
            MagicPowerSkill      ver  = comp.MagicData.MagicPowerSkill_Dominate.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Dominate_ver");
            MagicPowerSkill      eff  = comp.MagicData.MagicPowerSkill_Dominate.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Dominate_eff");

            verVal = ver.level;
            pwrVal = pwr.level;
            effVal = eff.level;
            ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
            if (settingsRef.AIHardMode && !p.IsColonist)
            {
                verVal = 3;
                pwrVal = 3;
                effVal = 3;
            }
            if (p.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            {
                MightPowerSkill mpwr = p.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                MightPowerSkill mver = p.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                MightPowerSkill meff = p.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_eff");
                pwrVal = mpwr.level;
                verVal = mver.level;
                effVal = meff.level;
            }

            if (this.currentTarget != null && p != null)
            {
                Map map = this.CasterPawn.Map;

                if (hitPawn != null && hitPawn is Pawn && !hitPawn.Dead)
                {
                    if (Rand.Chance(TM_Calc.GetSpellSuccessChance(p, hitPawn, true)))
                    {
                        Hediff hediff = new Hediff();
                        if (p.gender == Gender.Female || p.story.traits.HasTrait(TorannMagicDefOf.Succubus))
                        {
                            if (pwrVal == 3)
                            {
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_SDDominateHD_III, Rand.Range(1.5f + verVal, 3f + (verVal * 1)));
                                hediff = hitPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_SDDominateHD_III);
                            }
                            else if (pwrVal == 2)
                            {
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_SDDominateHD_II, Rand.Range(1.5f + verVal, 3f + (verVal * 1)));
                                hediff = hitPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_SDDominateHD_II);
                            }
                            else if (pwrVal == 1)
                            {
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_SDDominateHD_I, Rand.Range(1.5f + verVal, 3f + (verVal * 1)));
                                hediff = hitPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_SDDominateHD_I);
                            }
                            else
                            {
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_SDDominateHD, Rand.Range(1.5f + verVal, 3f + (verVal * 1)));
                                hediff = hitPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_SDDominateHD);
                            }
                            for (int i = 0; i < 4; i++)
                            {
                                TM_MoteMaker.ThrowShadowMote(hitPawn.Position.ToVector3(), map, Rand.Range(.6f, 1f));
                            }
                        }
                        if (p.gender == Gender.Male || p.story.traits.HasTrait(TorannMagicDefOf.Warlock))
                        {
                            if (pwrVal == 3)
                            {
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_WDDominateHD_III, Rand.Range(1.5f + verVal, 3f + (verVal * 1)));
                                hediff = hitPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_WDDominateHD_III);
                            }
                            else if (pwrVal == 2)
                            {
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_WDDominateHD_II, Rand.Range(1.5f + verVal, 3f + (verVal * 1)));
                                hediff = hitPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_WDDominateHD_II);
                            }
                            else if (pwrVal == 1)
                            {
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_WDDominateHD_I, Rand.Range(1.5f + verVal, 3f + (verVal * 1)));
                                hediff = hitPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_WDDominateHD_I);
                            }
                            else
                            {
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_WDDominateHD, Rand.Range(1.5f + verVal, 3f + (verVal * 1)));
                                hediff = hitPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_WDDominateHD);
                            }
                        }
                        HediffComp_Dominate hediffComp = hediff.TryGetComp <HediffComp_Dominate>();
                        hediffComp.EffVal = effVal;
                        hediffComp.VerVal = verVal;
                        if (hitPawn.IsColonist && !p.IsColonist)
                        {
                            TM_Action.SpellAffectedPlayerWarning(hitPawn);
                        }
                    }
                    else
                    {
                        MoteMaker.ThrowText(hitPawn.DrawPos, hitPawn.Map, "TM_ResistedSpell".Translate(), -1);
                    }
                }
                else
                {
                    Messages.Message("TM_NothingToDominate".Translate(), MessageTypeDefOf.NeutralEvent);
                }
                result = true;
            }

            this.burstShotsLeft = 0;
            return(result);
        }
Beispiel #20
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

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

            this.caster = this.launcher as Pawn;

            if (!this.initialized)
            {
                CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill      pwr  = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_HealingCircle.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_HealingCircle_pwr");
                MagicPowerSkill      ver  = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_HealingCircle.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_HealingCircle_ver");
                pwrVal = pwr.level;
                verVal = ver.level;
                if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                {
                    MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                    MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                    pwrVal = mpwr.level;
                    verVal = mver.level;
                }
                this.arcaneDmg = comp.arcaneDmg;
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                if (!caster.IsColonist && settingsRef.AIHardMode)
                {
                    pwrVal = 3;
                    verVal = 3;
                }
                this.radius   = this.def.projectile.explosionRadius;
                this.angle    = Rand.Range(-12, 12);
                this.duration = this.duration + (180 * (pwrVal + verVal));
                //TM_MoteMaker.MakePowerBeamMote(base.Position, base.Map, this.radius * 8f, 1.2f, this.duration/60f);
                this.initialized = true;
            }

            if (this.age >= this.lastWave)
            {
                if (this.age >= this.lastHeal + this.healDelay)
                {
                    switch (ringFrac)
                    {
                    case 0:
                        this.innerRing = 0;
                        this.outerRing = this.radius * ((ringFrac + .1f) / 5f);
                        TM_MoteMaker.MakePowerBeamMote(base.Position, base.Map, this.radius * 6f, 1.2f, this.waveDelay / 60f, (this.healDelay * 3f) / 60f, (this.healDelay * 2f) / 60f);
                        break;

                    case 1:
                        this.innerRing = this.outerRing;
                        this.outerRing = this.radius * ((ringFrac) / 5f);
                        break;

                    case 2:
                        this.innerRing = this.outerRing;
                        this.outerRing = this.radius * ((ringFrac) / 5f);
                        break;

                    case 3:
                        this.innerRing = this.outerRing;
                        this.outerRing = this.radius * ((ringFrac) / 5f);
                        break;

                    case 4:
                        this.innerRing = this.outerRing;
                        this.outerRing = this.radius * ((ringFrac) / 5f);
                        break;

                    case 5:
                        this.innerRing = this.outerRing;
                        this.outerRing = this.radius;
                        this.lastWave  = this.age + this.waveDelay;
                        break;
                    }
                    ringFrac++;
                    this.lastHeal = this.age;
                    Search(map);
                }
                if (ringFrac >= 6)
                {
                    ringFrac = 0;
                }
            }
            this.age++;
        }
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);
            ThingDef def = this.def;

            if (!this.initialized)
            {
                this.casterPawn = this.launcher as Pawn;
                CompAbilityUserMagic   comp        = casterPawn.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill        pwr         = comp.MagicData.MagicPowerSkill_ChronostaticField.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ChronostaticField_pwr");
                MagicPowerSkill        ver         = comp.MagicData.MagicPowerSkill_ChronostaticField.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ChronostaticField_ver");
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                pwrVal = pwr.level;
                verVal = ver.level;
                if (this.casterPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                {
                    MightPowerSkill mpwr = casterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                    MightPowerSkill mver = casterPawn.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 && !casterPawn.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>();
            }

            cellList = new List <IntVec3>();
            cellList.Clear();
            cellList = GenRadial.RadialCellsAround(base.Position, this.radius, true).ToList(); //this.radius instead of 2
            for (int i = 0; i < cellList.Count; i++)
            {
                if (cellList[i].IsValid && cellList[i].InBounds(this.Map))
                {
                    List <Thing> thingList = cellList[i].GetThingList(this.Map);
                    if (thingList != null && thingList.Count > 0)
                    {
                        for (int j = 0; j < thingList.Count; j++)
                        {
                            Pawn pawn = thingList[j] as Pawn;
                            if (pawn != null)
                            {
                                RemoveFireAt(thingList[j].Position);
                                if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.casterPawn, pawn, false) * (.6f + (.1f * verVal))))
                                {
                                    IntVec3 targetCell = pawn.Position;
                                    targetCell.z++;
                                    LaunchFlyingObect(targetCell, pawn, 1, Mathf.RoundToInt(Rand.Range(1400, 1800) * (1f + (.2f * pwrVal)) * this.arcaneDmg));
                                }
                                else
                                {
                                    MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "TM_ResistedSpell".Translate(), -1);
                                }
                            }
                        }
                    }
                }
            }
            this.age = this.duration;
            this.Destroy(DestroyMode.Vanish);
        }
Beispiel #22
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            if (this.Pawn.Spawned && !this.Pawn.Dead && !this.Pawn.Downed)
            {
                base.CompPostTick(ref severityAdjustment);
                if (base.Pawn != null & base.parent != null)
                {
                    if (!initialized)
                    {
                        initialized = true;
                        this.Initialize();
                    }
                }

                CompAbilityUserMight comp = this.Pawn.GetComp <CompAbilityUserMight>();
                if (this.doPsionicAttack)
                {
                    this.ticksTillPsionicStrike--;
                    if (this.ticksTillPsionicStrike <= 0)
                    {
                        this.doPsionicAttack = false;
                        MightPowerSkill ver = comp.MightData.MightPowerSkill_PsionicAugmentation.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicAugmentation_ver");
                        if (!threat.Destroyed && !threat.Dead)
                        {
                            TM_MoteMaker.MakePowerBeamMotePsionic(threat.DrawPos.ToIntVec3(), threat.Map, 2f, 2f, .7f, .1f, .6f);
                            DamageInfo dinfo2 = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_PsionicInjury, Rand.Range(6, 12) + (2 * ver.level), 0, -1, this.Pawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.threat);
                            this.threat.TakeDamage(dinfo2);
                        }
                    }
                }

                if (Find.TickManager.TicksGame % 60 == 0)
                {
                    severityAdjustment += (this.Pawn.GetStatValue(StatDefOf.PsychicSensitivity, false) * Rand.Range(.04f, .12f));
                    if (Find.Selector.FirstSelectedObject == this.Pawn)
                    {
                        HediffStage hediffStage = this.Pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_PsionicHD"), false).CurStage;
                        hediffStage.label = this.parent.Severity.ToString("0.00") + "%";
                    }

                    Hediff hediff = this.Pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_Artifact_PsionicBoostHD);
                    float  maxSev = 100;
                    if (hediff != null)
                    {
                        maxSev += hediff.Severity;
                    }
                    this.parent.Severity = Mathf.Clamp(this.parent.Severity, 0, maxSev);
                }

                if (comp.usePsionicAugmentationToggle)
                {
                    if (Find.TickManager.TicksGame % 600 == 0 && !this.Pawn.Drafted)
                    {
                        if (this.parent.Severity >= 95 && this.Pawn.CurJob.targetA.Thing != null)
                        {
                            DeterminePsionicHD();
                            if ((this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal > 20 && (this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 300 && this.Pawn.CurJob.locomotionUrgency >= LocomotionUrgency.Jog && this.Pawn.CurJob.bill == null)
                            {
                                this.parent.Severity -= 10f;
                                if (this.EffVal == 0)
                                {
                                    HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD"), 1f + .02f * this.EffVal);
                                }
                                else if (this.EffVal == 1)
                                {
                                    HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_I"), 1f + .02f * this.EffVal);
                                }
                                else if (this.EffVal == 2)
                                {
                                    HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_II"), 1f + .02f * this.EffVal);
                                }
                                else
                                {
                                    HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_III"), 1f + .02f * this.EffVal);
                                }
                                for (int i = 0; i < 12; i++)
                                {
                                    float direction = Rand.Range(0, 360);
                                    TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction);
                                }
                                comp.MightUserXP += Rand.Range(10, 15);
                            }
                            if (this.Pawn.CurJob.targetA.Thing != null)
                            {
                                if ((this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 2 && (this.Pawn.CurJob.bill != null || this.Pawn.CurJob.def.defName == "Sow" || this.Pawn.CurJob.def.defName == "FinishFrame" || this.Pawn.CurJob.def.defName == "Deconstruct" || this.Pawn.CurJob.def.defName == "Repair" || this.Pawn.CurJob.def.defName == "Clean" || this.Pawn.CurJob.def.defName == "Mine" || this.Pawn.CurJob.def.defName == "SmoothFloor" || this.Pawn.CurJob.def.defName == "SmoothWall" || this.Pawn.CurJob.def.defName == "Harvest" || this.Pawn.CurJob.def.defName == "HarvestDesignated" || this.Pawn.CurJob.def.defName == "CutPlant" || this.Pawn.CurJob.def.defName == "CutPlantDesignated"))
                                {
                                    this.parent.Severity -= 12f;
                                    if (this.PwrVal == 0)
                                    {
                                        HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD"), 1f + .02f * this.PwrVal);
                                    }
                                    else if (this.PwrVal == 1)
                                    {
                                        HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_I"), 1f + .02f * this.PwrVal);
                                    }
                                    else if (this.PwrVal == 2)
                                    {
                                        HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_II"), 1f + .02f * this.PwrVal);
                                    }
                                    else
                                    {
                                        HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_III"), 1f + .02f * this.PwrVal);
                                    }
                                    for (int i = 0; i < 12; i++)
                                    {
                                        float direction = Rand.Range(0, 360);
                                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction);
                                    }
                                    comp.MightUserXP += Rand.Range(10, 15);
                                }
                            }
                        }
                    }

                    if (this.parent.Severity >= 20)
                    {
                        DeterminePsionicHD();
                        if (Find.TickManager.TicksGame % 180 == 0 && (this.Pawn.Drafted || !this.Pawn.IsColonist) && ((this.Pawn.equipment.Primary != null && !this.Pawn.equipment.Primary.def.IsRangedWeapon) || this.Pawn.equipment.Primary == null))
                        {
                            if (this.Pawn.CurJob.targetA.Thing != null && this.Pawn.CurJob.targetA.Thing is Pawn)
                            {
                                //Log.Message("performing psionic dash - curjob " + this.Pawn.CurJob);
                                //Log.Message("curjob def " + this.Pawn.CurJob.def.defName);
                                //Log.Message("target " + this.Pawn.CurJob.targetA.Thing);
                                //Log.Message("target range " + (this.Pawn.CurJob.targetA.Thing.Position - this.Pawn.Position).LengthHorizontal);
                                Pawn  targetPawn     = this.Pawn.CurJob.targetA.Thing as Pawn;
                                float targetDistance = (this.Pawn.Position - targetPawn.Position).LengthHorizontal;
                                if (targetDistance > 3 && targetDistance < (12 + EffVal) && targetPawn.Map != null && !targetPawn.Downed)
                                {
                                    for (int i = 0; i < 12; i++)
                                    {
                                        float direction = Rand.Range(0, 360);
                                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction);
                                    }
                                    FlyingObject_PsionicLeap flyingObject = (FlyingObject_PsionicLeap)GenSpawn.Spawn(ThingDef.Named("FlyingObject_PsionicLeap"), this.Pawn.Position, this.Pawn.Map);
                                    flyingObject.Launch(this.Pawn, this.Pawn.CurJob.targetA.Thing, this.Pawn);
                                    HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicHD"), -3f);
                                    comp.Stamina.CurLevel -= .03f;
                                    comp.MightUserXP      += Rand.Range(20, 30);
                                }
                            }
                        }

                        if (this.nextPsionicAttack < Find.TickManager.TicksGame && this.Pawn.Drafted)
                        {
                            if (this.Pawn.CurJob.def != TorannMagicDefOf.JobDriver_PsionicBarrier && VerVal > 0)
                            {
                                this.threat = TM_Calc.FindNearbyEnemy(this.Pawn, 20 + (2 * verVal)); // GetNearbyTarget(20 + (2 * VerVal));
                                if (threat != null)
                                {
                                    //start psionic attack; ends after delay
                                    SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None);
                                    TorannMagicDefOf.TM_Implosion.PlayOneShot(info);
                                    Effecter psionicAttack = TorannMagicDefOf.TM_GiantExplosion.Spawn();
                                    psionicAttack.Trigger(new TargetInfo(threat.Position, threat.Map, false), new TargetInfo(threat.Position, threat.Map, false));
                                    psionicAttack.Cleanup();
                                    for (int i = 0; i < 12; i++)
                                    {
                                        float direction = Rand.Range(0, 360);
                                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction);
                                    }
                                    float weaponModifier = 1;
                                    if (this.Pawn.equipment.Primary != null)
                                    {
                                        if (this.Pawn.equipment.Primary.def.IsRangedWeapon)
                                        {
                                            StatModifier wpnMass = this.Pawn.equipment.Primary.def.statBases.FirstOrDefault((StatModifier x) => x.stat.defName == "Mass");
                                            weaponModifier = Mathf.Clamp(wpnMass.value, .8f, 6);
                                        }
                                        else //assume melee weapon
                                        {
                                            StatModifier wpnMass = this.Pawn.equipment.Primary.def.statBases.FirstOrDefault((StatModifier x) => x.stat.defName == "Mass");
                                            weaponModifier = Mathf.Clamp(wpnMass.value, .6f, 5);
                                        }
                                    }
                                    else //unarmed
                                    {
                                        weaponModifier = .4f;
                                    }
                                    this.nextPsionicAttack = Find.TickManager.TicksGame + (int)(Mathf.Clamp((600 - (60 * verVal)) * weaponModifier, 120, 900));
                                    float energyCost = Mathf.Clamp((10f - VerVal) * weaponModifier, 2f, 12f);
                                    HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicHD"), -energyCost);
                                    comp.MightUserXP           += Rand.Range(8, 12);
                                    this.doPsionicAttack        = true;
                                    this.ticksTillPsionicStrike = 24;
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #23
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;
                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;
                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, strikeNum, false);
                cellList         = targets.ToList <IntVec3>();
            }

            if (Find.TickManager.TicksGame % this.strikeDelay == 0)
            {
                int     force = (10 + (2 * pwrVal) - strikeNum);
                IntVec3 curCell;
                for (int i = 0; i < cellList.Count; i++)
                {
                    curCell = cellList[i];
                    Vector3 angle = GetVector(base.Position, curCell);
                    TM_MoteMaker.ThrowArcaneWaveMote(curCell.ToVector3(), pawn.Map, .3f * (curCell - base.Position).LengthHorizontal, .1f, .05f, .3f, 0, 3, (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat());
                    if (curCell.IsValid && curCell.InBounds(pawn.Map))
                    {
                        victim = curCell.GetFirstPawn(pawn.Map);
                        if (victim != null && !victim.Dead)
                        {
                            Vector3 launchVector      = GetVector(base.Position, victim.Position);
                            IntVec3 projectedPosition = victim.Position + (force * launchVector).ToIntVec3();
                            if (projectedPosition.IsValid && projectedPosition.InBounds(pawn.Map))
                            {
                                damageEntities(victim, force * (.2f * verVal), DamageDefOf.Blunt);
                                LaunchFlyingObect(projectedPosition, victim, force);
                            }
                        }
                    }
                }
                strikeNum++;
                IEnumerable <IntVec3> newTargets = GenRadial.RadialCellsAround(base.Position, strikeNum, false);
                try
                {
                    cellList = newTargets.Except(targets).ToList <IntVec3>();
                }
                catch
                {
                    cellList = newTargets.ToList <IntVec3>();
                }
                targets = newTargets;
            }
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def    = this.def;
            Pawn     victim = hitThing as Pawn;

            Pawn pawn = this.launcher as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();

            pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningCloud.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningCloud_pwr");
            ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningCloud.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningCloud_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;
            }
            radius = (int)this.def.projectile.explosionRadius + (1 * verVal);

            CellRect cellRect = CellRect.CenteredOn(base.Position, radius - 3);

            cellRect.ClipInsideMap(map);
            IntVec3 randomCell = cellRect.RandomCell;

            duration = 900 + (verVal * 120);

            if (this.primed == true)
            {
                if (((this.shockDelay + this.lastStrike) < this.age))
                {
                    for (int i = 0; i < 4; i++)
                    {
                        randomCell = cellRect.RandomCell;
                        if (randomCell.InBounds(map))
                        {
                            victim = randomCell.GetFirstPawn(map);
                            if (victim != null)
                            {
                                damageEntities(victim, Mathf.RoundToInt((this.def.projectile.damageAmountBase + pwrVal) * this.arcaneDmg));
                            }
                        }
                    }

                    Vector3 loc2 = base.Position.ToVector3Shifted();
                    Vector3 loc  = randomCell.ToVector3Shifted();

                    bool rand1 = Rand.Range(0, 100) < 3;
                    bool rand2 = Rand.Range(0, 100) < 16;
                    if (rand1)
                    {
                        MoteMaker.ThrowSmoke(loc2, map, radius);
                        SoundDefOf.AmbientAltitudeWind.sustainFadeoutTime.Equals(30.0f);
                    }
                    if (rand2)
                    {
                        MoteMaker.ThrowSmoke(loc, map, 4f);
                    }

                    MoteMaker.ThrowMicroSparks(loc, map);
                    MoteMaker.ThrowLightningGlow(loc, map, 2f);

                    strikeInt++;
                    this.lastStrike = this.age;
                    this.shockDelay = Rand.Range(1, 3);

                    bool flag1 = this.age <= duration;
                    if (!flag1)
                    {
                        this.primed = false;
                    }
                }
            }
        }
Beispiel #25
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

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

            if (!initialized && this.age < this.duration && hitThing != null)
            {
                caster           = this.launcher as Pawn;
                hitPawn          = hitThing as Pawn;
                this.oldPosition = caster.Position;
                MightPowerSkill        pwr         = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Possess.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Possess_pwr");
                MightPowerSkill        ver         = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Possess.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Possess_ver");
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                pwrVal = pwr.level;
                verVal = ver.level;
                if (settingsRef.AIHardMode && !caster.IsColonist)
                {
                    pwrVal = 3;
                    verVal = 3;
                }
                this.duration += pwrVal * 300;
                if (hitPawn != null && hitPawn.Faction != null && hitPawn.RaceProps.Humanlike)
                {
                    possessedFlag = (hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD_I) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD_II) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD_III) ||
                                     hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD_I) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD_II) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD_III));
                    if (!hitPawn.Downed && !hitPawn.Dead && !possessedFlag && !hitPawn.IsPrisoner)
                    {
                        this.pFaction = hitPawn.Faction;
                        this.prisoner = hitPawn.IsPrisoner;
                        if (!caster.IsColonist && hitPawn.IsColonist)
                        {
                            List <WorkTypeDef> allWorkTypes = WorkTypeDefsUtility.WorkTypeDefsInPriorityOrder.ToList();
                            this.hitPawnWorkSetting = new List <int>();
                            this.hitPawnWorkSetting.Clear();
                            for (int i = 0; i < allWorkTypes.Count(); i++)
                            {
                                hitPawnWorkSetting.Add(hitPawn.workSettings.GetPriority(allWorkTypes[i]));
                            }
                        }

                        if (this.pFaction != caster.Faction)
                        {
                            if (Rand.Chance(TM_Calc.GetSpellSuccessChance(caster, hitPawn, true)))
                            {
                                //possess enemy or neutral
                                int weaponCount = 0;
                                if (hitPawn.equipment.PrimaryEq != null)
                                {
                                    weaponCount = 1;
                                }
                                this.inventoryCount = hitPawn.inventory.innerContainer.Count + hitPawn.apparel.WornApparelCount + weaponCount;
                                if (ModCheck.Validate.GiddyUp.Core_IsInitialized())
                                {
                                    ModCheck.GiddyUp.ForceDismount(caster);
                                    ModCheck.GiddyUp.ForceDismount(hitPawn);
                                }
                                hitPawn.SetFaction(caster.Faction, null);
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_DisguiseHD_II, 20f + 5f * pwrVal);
                                switch (verVal)
                                {
                                case 0:
                                    HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD, 20f + 5f * pwrVal);
                                    break;

                                case 1:
                                    HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD_I, 20f + 5f * pwrVal);
                                    break;

                                case 2:
                                    HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD_II, 20f + 5f * pwrVal);
                                    break;

                                case 3:
                                    HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD_III, 20f + 5f * pwrVal);
                                    break;
                                }
                                initialized = true;
                                MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1f);
                                MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1.2f);
                                MoteMaker.ThrowHeatGlow(caster.Position, caster.Map, .8f);
                                if (!caster.IsColonist)
                                {
                                    Lord    lord    = caster.GetLord();
                                    LordJob lordJob = caster.GetLord().LordJob;
                                    try
                                    {
                                        PawnDuty duty = caster.mindState.duty;
                                        hitPawn.mindState.duty = duty;
                                        lord.AddPawn(hitPawn);
                                    }
                                    catch
                                    {
                                        Log.Message("error attempting to assign a duty to pawn during possession");
                                    }
                                }
                                //loadPawn = caster;
                                //loadPawn.ThingID += Rand.Range(0, 214).ToString();
                                if (caster.IsColonist)
                                {
                                    //
                                    ModOptions.Constants.SetPawnInFlight(true);
                                    //
                                }
                                if (hitPawn.IsColonist && !caster.IsColonist)
                                {
                                    TM_Action.SpellAffectedPlayerWarning(hitPawn);
                                }
                                caster.DeSpawn();
                            }
                            else
                            {
                                MoteMaker.ThrowText(hitThing.DrawPos, hitThing.Map, "TM_ResistedSpell".Translate(), -1);
                                this.age = this.duration;
                                this.Destroy(DestroyMode.Vanish);
                            }
                        }
                        else
                        {
                            //possess friendly
                            if (ModCheck.Validate.GiddyUp.Core_IsInitialized())
                            {
                                ModCheck.GiddyUp.ForceDismount(caster);
                            }
                            HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_DisguiseHD_II, 20f + 5f * pwrVal);
                            switch (verVal)
                            {
                            case 0:
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD, 20f + 5f * pwrVal);
                                break;

                            case 1:
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD_I, 20f + 5f * pwrVal);
                                break;

                            case 2:
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD_II, 20f + 5f * pwrVal);
                                break;

                            case 3:
                                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD_III, 20f + 5f * pwrVal);
                                break;
                            }
                            initialized = true;
                            MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1f);
                            MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1.2f);
                            MoteMaker.ThrowHeatGlow(caster.Position, caster.Map, .8f);
                            caster.DeSpawn();
                        }
                    }
                    else
                    {
                        Messages.Message("TM_CannotPossessNow".Translate(
                                             caster.LabelShort,
                                             hitPawn.LabelShort
                                             ), MessageTypeDefOf.RejectInput);
                        this.age = this.duration;
                        this.Destroy(DestroyMode.Vanish);
                    }
                }
                else
                {
                    Messages.Message("TM_CannotPossess".Translate(
                                         caster.LabelShort,
                                         hitThing.LabelShort
                                         ), MessageTypeDefOf.RejectInput);
                    this.age = this.duration;
                    this.Destroy(DestroyMode.Vanish);
                }
            }
            else
            {
                if (!this.initialized)
                {
                    this.age = this.duration;
                    Destroy(DestroyMode.Vanish);
                }
            }

            if (hitPawn != null && (hitPawn.Downed || hitPawn.Dead))
            {
                this.age = this.duration;
            }
        }
Beispiel #26
0
        protected override void Impact(Thing hitThing)
        {
            Map  map  = this.launcher.Map;
            Pawn pawn = this.launcher as Pawn;

            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      pwr  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_pwr");
            MagicPowerSkill      ver  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_ver");

            effVal    = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_eff").level;
            verVal    = ver.level;
            pwrVal    = pwr.level;
            arcaneDmg = comp.arcaneDmg;
            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;
            }

            if (pawn.Position.IsValid && pawn.Position.Standable(map))
            {
                AbilityUser.SpawnThings tempPod = new SpawnThings();
                IntVec3 shiftPos = pawn.Position;

                tempPod.def = ThingDef.Named("TM_TechnoTurret_Base");
                Thing turretGun = new Thing();

                turretGun.def = ThingDef.Named("Gun_Mark-IV");
                if (this.verVal >= 5)
                {
                    tempPod.def   = ThingDef.Named("TM_TechnoTurret_Base_RL");
                    turretGun.def = ThingDef.Named("Gun_Mark-IV_RL");
                }
                if (this.verVal >= 10)
                {
                    tempPod.def   = ThingDef.Named("TM_TechnoTurret_Base_RL_MTR");
                    turretGun.def = ThingDef.Named("Gun_Mark-IV_RL_MTR");
                }

                turretGun.def.SetStatBaseValue(StatDefOf.AccuracyTouch, 0.8f + (.01f * pwrVal));
                turretGun.def.SetStatBaseValue(StatDefOf.AccuracyShort, 0.75f + (.01f * pwrVal));
                turretGun.def.SetStatBaseValue(StatDefOf.AccuracyMedium, 0.65f + (.01f * pwrVal));
                turretGun.def.SetStatBaseValue(StatDefOf.AccuracyLong, 0.35f + (.01f * pwrVal));
                turretGun.def.Verbs.FirstOrDefault().burstShotCount = Mathf.RoundToInt((6 + (.4f * pwrVal)) * this.arcaneDmg);
                turretGun.def.Verbs.FirstOrDefault().warmupTime     = 1.5f - (.03f * pwrVal);
                turretGun.def.Verbs.FirstOrDefault().range          = Mathf.RoundToInt((35 + verVal) * this.arcaneDmg);

                tempPod.def.building.turretGunDef = turretGun.def;

                tempPod.def.SetStatBaseValue(StatDefOf.MaxHitPoints, 200 + (10 * effVal));
                tempPod.spawnCount = 1;
                try
                {
                    this.turret = TM_Action.SingleSpawnLoop(pawn, tempPod, base.Position, map, 6000, true, false, pawn.Faction, true);
                    this.turret.def.building.turretBurstCooldownTime = 4.5f - (.1f * pwrVal);

                    Building_TechnoTurret b_tt = this.turret as Building_TechnoTurret;
                    b_tt.manPawn = pawn;
                    b_tt.iCell   = this.launcher.Position;

                    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));
                    }
                }
                catch
                {
                    comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_SummonPylon);
                    Log.Message("TM_Exception".Translate(
                                    pawn.LabelShort,
                                    "techno turret"
                                    ));
                }
            }
            else
            {
                Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                comp.Mana.GainNeed(comp.ActualManaCost(TorannMagicDefOf.TM_TechnoTurret));
            }


            if (turret != null && turret.Spawned && turret.Position.IsValid)
            {
                //turret.def.interactionCellOffset = (this.launcher.Position - base.Position);

                Job job = new Job(JobDefOf.ManTurret, turret);
                pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);

                //this.Ability.PostAbilityAttempt();
            }
            else
            {
                Log.Message("turret was null");
            }
            GenClamor.DoClamor(this, 2.1f, ClamorDefOf.Impact);
            Destroy();
            //base.Impact(hitThing);
        }
Beispiel #27
0
        protected override bool TryCastShot()
        {
            bool flag = false;
            CompAbilityUserMight comp = base.CasterPawn.GetComp <CompAbilityUserMight>();
            MightPowerSkill      pwr  = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_AnimalFriend.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AnimalFriend_pwr");
            MightPowerSkill      ver  = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_AnimalFriend.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AnimalFriend_ver");
            Pawn pawn   = this.CasterPawn;
            Pawn animal = this.currentTarget.Thing as Pawn;

            if (animal != null && animal.RaceProps.Animal && animal.RaceProps.IsFlesh)
            {
                Pawn oldbond = comp.bondedPet;
                if (animal == comp.bondedPet)
                {
                    Hediff animalBondHD = oldbond.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_RangerBondHD"));
                    if (animalBondHD != null && Rand.Chance(((1f + animalBondHD.ageTicks / 6000000) - oldbond.RaceProps.wildness)))
                    {
                        Messages.Message("TM_BondedAnimalReleaseToColony".Translate(
                                             oldbond.LabelShort,
                                             pawn.LabelShort
                                             ), MessageTypeDefOf.NeutralEvent);
                        MoteMaker.MakeInteractionBubble(oldbond, pawn, InteractionDefOf.Nuzzle.interactionMote, InteractionDefOf.Nuzzle.GetSymbol());
                        oldbond.health.RemoveHediff(animalBondHD);
                        DefMap <TrainableDef, int> steps = Traverse.Create(root: oldbond.training).Field(name: "steps").GetValue <DefMap <TrainableDef, int> >();
                        steps[TrainableDefOf.Tameness]  = 1;
                        steps[TrainableDefOf.Obedience] = 0;
                        steps[TrainableDefOf.Release]   = 0;
                        steps[TorannMagicDefOf.Haul]    = 0;
                        steps[TorannMagicDefOf.Rescue]  = 0;
                        comp.bondedPet = null;
                    }
                    else
                    {
                        Messages.Message("TM_BondedAnimalRelease".Translate(
                                             oldbond.LabelShort,
                                             pawn.LabelShort
                                             ), MessageTypeDefOf.NeutralEvent);
                        FleckMaker.ThrowSmoke(oldbond.DrawPos, oldbond.Map, 3f);
                        oldbond.Destroy();
                    }
                }
                else if (animal.Faction != null && animal.Faction != pawn.Faction)
                {
                    Messages.Message("TM_AnimalHasAllegience".Translate(
                                         ), MessageTypeDefOf.RejectInput);
                }
                else if (animal.health != null && animal.health.hediffSet != null && animal.health.hediffSet.HasHediff(HediffDef.Named("TM_RangerBondHD")))
                {
                    Messages.Message("TM_AnimalAlreadyHasBond".Translate(animal.LabelShort
                                                                         ), MessageTypeDefOf.RejectInput);
                }
                else
                {
                    if (animal.RaceProps.intelligence == Intelligence.Animal) // == TrainableIntelligenceDefOf.Intermediate || animal.RaceProps.TrainableIntelligence == TrainableIntelligenceDefOf.Advanced)
                    {
                        if ((animal.RaceProps.wildness <= .7f) || (animal.RaceProps.wildness <= .8f && pwr.level == 1) || (animal.RaceProps.wildness <= .9f && pwr.level == 2) || pwr.level == 3)
                        {
                            if (Rand.Chance(.6f + (.05f * pwr.level)) && Rand.Chance(((.7f + (.1f * pwr.level)) - animal.RaceProps.wildness) * 10))
                            {
                                if (comp.bondedPet != null && comp.bondedPet != animal)
                                {
                                    if (!oldbond.Destroyed)
                                    {
                                        if (!comp.bondedPet.Dead)
                                        {
                                            //bonding with another pet without first pet being dead or destroyed
                                            comp.bondedPet = null;
                                            Messages.Message("TM_BondedAnimalRelease".Translate(
                                                                 oldbond.LabelShort,
                                                                 pawn.LabelShort
                                                                 ), MessageTypeDefOf.NeutralEvent);
                                            if (oldbond.Map != null)
                                            {
                                                FleckMaker.ThrowSmoke(oldbond.DrawPos, oldbond.Map, 3f);
                                            }
                                            else
                                            {
                                                oldbond.ParentHolder.GetDirectlyHeldThings().Remove(oldbond);
                                            }
                                            oldbond.Destroy();
                                        }
                                    }
                                }
                                animal.SetFaction(pawn.Faction);
                                HealthUtility.AdjustSeverity(animal, TorannMagicDefOf.TM_RangerBondHD, -4f);
                                HealthUtility.AdjustSeverity(animal, TorannMagicDefOf.TM_RangerBondHD, .5f + ver.level);
                                comp.bondedPet = animal;
                                MoteMaker.MakeInteractionBubble(animal, pawn, InteractionDefOf.Nuzzle.interactionMote, InteractionDefOf.Nuzzle.GetSymbol());
                                TM_Action.TrainAnimalFull(animal, pawn);
                            }
                            else
                            {
                                Messages.Message("TM_FailedRangerBond".Translate(
                                                     animal.LabelShort,
                                                     pawn.LabelShort,
                                                     (Mathf.Clamp(Mathf.RoundToInt(((.7f + (.1f * pwr.level)) - animal.RaceProps.wildness) * 1000f), 0, 100 - (40 - (5 * pwr.level))))
                                                     ), MessageTypeDefOf.NeutralEvent);
                                if (animal.Faction == null && Rand.Chance(animal.RaceProps.manhunterOnTameFailChance))
                                {
                                    animal.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter, null, true, false, null);
                                }
                            }
                        }
                        else
                        {
                            Messages.Message("TM_RangerNotExperienced".Translate(
                                                 animal.LabelShort,
                                                 pawn.LabelShort,
                                                 (animal.RaceProps.wildness * 100).ToString("F"),
                                                 (.7f + .1f * pwr.level) * 100
                                                 ), MessageTypeDefOf.NeutralEvent);
                        }
                    }
                    else
                    {
                        Messages.Message("TM_AnimalIncapableOfBond".Translate(
                                             animal.LabelShort,
                                             pawn.LabelShort
                                             ), MessageTypeDefOf.NeutralEvent);
                    }
                }
            }
            this.PostCastShot(flag, out flag);
            return(flag);
        }
        protected override bool TryCastShot()
        {
            bool result = false;
            Pawn p      = this.CasterPawn;
            CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      pwr  = comp.MagicData.MagicPowerSkill_DeathMark.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_DeathMark_pwr");
            MagicPowerSkill      ver  = comp.MagicData.MagicPowerSkill_DeathMark.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_DeathMark_ver");

            verVal         = ver.level;
            pwrVal         = pwr.level;
            this.arcaneDmg = comp.arcaneDmg;
            if (p.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            {
                MightPowerSkill mpwr = p.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                MightPowerSkill mver = p.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                pwrVal = mpwr.level;
                verVal = mver.level;
            }

            if (this.currentTarget != null && base.CasterPawn != null)
            {
                Map map = this.CasterPawn.Map;
                this.TargetsAoE.Clear();
                this.UpdateTargets();
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                for (int i = 0; i < this.TargetsAoE.Count; i++)
                {
                    if (this.TargetsAoE[i].Thing is Pawn)
                    {
                        Pawn victim = this.TargetsAoE[i].Thing as Pawn;
                        if (!victim.RaceProps.IsMechanoid)
                        {
                            if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, victim, true)))
                            {
                                HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_DeathMarkCurse"), (Rand.Range(1f + pwrVal, 4 + 2 * pwrVal) * this.arcaneDmg));
                                TM_MoteMaker.ThrowSiphonMote(victim.DrawPos, victim.Map, 1f);
                                if (comp.Pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_LichHD"), false))
                                {
                                    comp.PowerModifier += 1;
                                }

                                if (Rand.Chance(verVal * .2f))
                                {
                                    if (Rand.Chance(verVal * .1f)) //terror
                                    {
                                        HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_Terror"), Rand.Range(3f * verVal, 5f * verVal) * this.arcaneDmg);
                                        TM_MoteMaker.ThrowDiseaseMote(victim.DrawPos, victim.Map, 1f, .5f, .2f, .4f);
                                        MoteMaker.ThrowText(victim.DrawPos, victim.Map, "Terror", -1);
                                    }
                                    if (Rand.Chance(verVal * .1f)) //berserk
                                    {
                                        if (victim.mindState != null && victim.RaceProps != null && victim.RaceProps.Humanlike)
                                        {
                                            victim.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, "cursed", true, false, null);
                                            MoteMaker.ThrowMicroSparks(victim.DrawPos, victim.Map);
                                            MoteMaker.ThrowText(victim.DrawPos, victim.Map, "Berserk", -1);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                MoteMaker.ThrowText(victim.DrawPos, victim.Map, "TM_ResistedSpell".Translate(), -1);
                            }
                        }
                    }
                }

                result = true;
            }

            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            GenClamor.DoClamor(this, 2.1f, ClamorDefOf.Ability);
            Destroy();

            Pawn pawn = this.launcher as Pawn;

            ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();

            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 = pawn.GetComp <CompAbilityUserMight>().mightPwr;
            }
            else
            {
                CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill      pwr  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningStorm.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningStorm_pwr");
                MagicPowerSkill      ver  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningStorm.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningStorm_ver");
                pwrVal         = pwr.level;
                verVal         = ver.level;
                this.arcaneDmg = comp.arcaneDmg;
            }

            if (settingsRef.AIHardMode && !pawn.IsColonist)
            {
                pwrVal = 3;
                verVal = 3;
            }

            duration = 480 + (verVal * 60);
            CellRect cellRect = CellRect.CenteredOn(base.Position, 8);

            cellRect.ClipInsideMap(map);

            if (this.primed == true)
            {
                if (((this.boltDelay + this.lastStrike) < this.age))
                {
                    IntVec3 randomCell = cellRect.RandomCell;
                    if (randomCell.IsValid && randomCell.InBounds(base.Map))
                    {
                        //Map.weatherManager.eventHandler.AddEvent(new WeatherEvent_LightningStrike(map, randomCell));
                        Map.weatherManager.eventHandler.AddEvent(new TM_WeatherEvent_MeshFlash(map, randomCell, TM_MatPool.standardLightning, DamageDefOf.Flame, this.launcher, -1, 1.9f, 1f, 1.5f));
                        this.LightningBlast(pwrVal, randomCell, map, 2.2f);
                        strikeInt++;
                        this.lastStrike = this.age;
                        this.boltDelay  = Rand.Range(8 - (pwrVal), 40 - (pwrVal * 4));

                        bool flag1 = this.age <= duration;
                        if (!flag1)
                        {
                            this.primed = false;
                            map.weatherDecider.DisableRainFor(0);
                            map.weatherDecider.StartNextWeather();
                        }
                    }
                }
            }
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

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

            Pawn caster = this.launcher as Pawn;

            if (!this.initialized)
            {
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                CompAbilityUserMagic   comp        = caster.GetComp <CompAbilityUserMagic>();

                pwrVal = comp.MagicData.MagicPowerSkill_Sabotage.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Sabotage_pwr").level;
                verVal = comp.MagicData.MagicPowerSkill_Sabotage.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Sabotage_ver").level;
                if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                {
                    MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                    MightPowerSkill mver = caster.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 && !caster.IsColonist)
                {
                    pwrVal = 3;
                    verVal = 3;
                }
                SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, this.Map, false), MaintenanceType.None);
                info.pitchFactor  = .5f;
                info.volumeFactor = .8f;
                SoundDefOf.PsychicPulseGlobal.PlayOneShot(info);
                Effecter SabotageEffect = TorannMagicDefOf.TM_SabotageExplosion.Spawn();
                SabotageEffect.Trigger(new TargetInfo(base.Position, this.Map, false), new TargetInfo(base.Position, this.Map, false));
                SabotageEffect.Cleanup();
                targetCells       = GenRadial.RadialCellsAround(base.Position, this.def.projectile.explosionRadius, true).ToList();
                this.targetThings = new List <SabotageThing>();
                this.targetThings.Clear();
                this.initialized = true;

                Pawn     targetPawn     = null;
                Building targetBuilding = null;

                for (int i = 0; i < this.targetCells.Count; i++)
                {
                    var targetCell = this.targetCells[i];
                    if (Rand.Chance((.5f + (.1f * verVal)) * this.arcaneDmg))
                    {
                        float rnd = Rand.Range(0, 1f);
                        targetPawn = targetCell.GetFirstPawn(this.Map);
                        if (targetPawn != null)
                        {
                            if (TM_Calc.IsRobotPawn(targetPawn))
                            {
                                TM_Action.DoAction_SabotagePawn(targetPawn, caster, rnd, pwrVal, this.arcaneDmg, this.launcher);
                                this.age = this.duration;
                            }
                            else
                            {
                                targetPawn = null;
                                //Log.Message("pawn not a robot, mechanoid, or android");
                            }
                        }

                        targetBuilding = targetCell.GetFirstBuilding(this.Map);
                        if (targetPawn == null && targetBuilding != null)
                        {
                            CompPower       compP = targetBuilding.GetComp <CompPower>();
                            CompPowerTrader cpt   = targetBuilding.GetComp <CompPowerTrader>();
                            if (compP != null && compP.Props.basePowerConsumption != 0 && cpt != null && cpt.powerOutputInt != 0)
                            {
                                if (true)
                                {
                                    //stun/electrical explosion
                                    GenExplosion.DoExplosion(targetBuilding.Position, base.Map, 2 + pwrVal + Mathf.RoundToInt(cpt.powerOutputInt / 400), DamageDefOf.Stun, null);
                                    GenExplosion.DoExplosion(targetBuilding.Position, base.Map, 1 + pwrVal + Mathf.RoundToInt(cpt.powerOutputInt / 600), TMDamageDefOf.DamageDefOf.TM_ElectricalBurn, null);
                                }
                                else
                                {
                                }
                            }

                            Building_Battery targetBattery = targetBuilding as Building_Battery;
                            if (targetBattery != null && targetBattery.def.thingClass.ToString() == "RimWorld.Building_Battery")
                            {
                                CompPowerBattery compB = targetBattery.GetComp <CompPowerBattery>();
                                if (rnd <= .5f)
                                {
                                    Traverse.Create(root: targetBattery).Field(name: "ticksToExplode").SetValue(Rand.Range(40, 130) - (5 * pwrVal));
                                    compB.SetStoredEnergyPct(.81f);
                                }
                                else
                                {
                                    GenExplosion.DoExplosion(targetBattery.Position, base.Map, 2 + pwrVal + Mathf.RoundToInt(compB.StoredEnergy / 200), DamageDefOf.EMP, null);
                                    compB.DrawPower(compB.StoredEnergy);
                                }
                            }

                            Building_TurretGun targetTurret = targetBuilding as Building_TurretGun;
                            if (targetTurret != null && targetTurret.gun != null)
                            {
                                if (rnd <= .5f)
                                {
                                    targetTurret.SetFaction(Faction.OfAncientsHostile, null);
                                }
                                else
                                {
                                    GenExplosion.DoExplosion(targetTurret.Position, base.Map, 2 + pwrVal, TMDamageDefOf.DamageDefOf.TM_ElectricalBurn, null); //20 default damage
                                }
                            }
                        }
                        else
                        {
                            //Log.Message("no thing to sabotage");
                        }
                        targetPawn     = null;
                        targetBuilding = null;
                    }
                }
            }
            else if (this.targetThings.Count > 0)
            {
                this.age = this.duration;
            }
            else
            {
                this.age = this.duration;
            }
        }