Пример #1
0
        protected override bool TryCastShot()
        {
            bool  result = false;
            bool  arg_40_0;
            Thing targetThing = this.currentTarget.Thing;

            if (this.currentTarget != null && base.CasterPawn != null)
            {
                IntVec3 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 = targetThing is Pawn;
            }
            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;
                    Pawn targetPawn = targetThing as Pawn;
                    bool drafted    = p.Drafted;
                    bool tDrafted   = false;
                    if (targetThing is Pawn && targetPawn.IsColonist && targetPawn.Drafted)
                    {
                        tDrafted = true;
                    }
                    Map     map        = this.CasterPawn.Map;
                    IntVec3 cell       = this.CasterPawn.Position;
                    IntVec3 targetCell = targetPawn.Position;
                    try
                    {
                        if (this.CasterPawn.IsColonist)
                        {
                            this.CasterPawn.DeSpawn();
                            targetPawn.DeSpawn();
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            GenSpawn.Spawn(targetPawn, cell, map);
                            p.drafter.Drafted          = drafted;
                            targetPawn.drafter.Drafted = tDrafted;
                            CameraJumper.TryJumpAndSelect(p);
                            CompAbilityUserMight comp = this.CasterPawn.GetComp <CompAbilityUserMight>();
                            MightPowerSkill      ver  = comp.MightData.MightPowerSkill_Transpose.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Transpose_ver");
                            if (ver.level < 1)
                            {
                                HealthUtility.AdjustSeverity(p, HediffDef.Named("TM_DisorientedVomit"), 1f);
                            }
                            HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_ReversalHD, 2f + (ver.level));
                            if (targetPawn.HostileTo(this.CasterPawn) && targetPawn.needs.food != null)
                            {
                                if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, targetPawn, true)))
                                {
                                    HealthUtility.AdjustSeverity(targetPawn, HediffDef.Named("TM_DisorientedVomit"), 1f);
                                }
                                else
                                {
                                    MoteMaker.ThrowText(targetPawn.DrawPos, targetPawn.Map, "TM_ResistedSpell".Translate(), -1);
                                }
                            }
                            else
                            {
                                if (ver.level < 2 && targetPawn.needs.food != null)
                                {
                                    HealthUtility.AdjustSeverity(targetPawn, HediffDef.Named("TM_DisorientedVomit"), 1f);
                                }
                            }
                        }
                        else
                        {
                            this.CasterPawn.DeSpawn();
                            targetPawn.DeSpawn();
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            GenSpawn.Spawn(targetPawn, cell, map);
                            if (targetPawn.IsColonist && !p.IsColonist)
                            {
                                TM_Action.SpellAffectedPlayerWarning(targetPawn);
                            }
                        }
                    }
                    catch
                    {
                        Log.Message("Exception occured when trying to transpose - recovered pawns at original positions");
                        if (!this.CasterPawn.Spawned)
                        {
                            GenSpawn.Spawn(p, cell, map);
                        }
                        if (!targetPawn.Spawned)
                        {
                            GenSpawn.Spawn(targetPawn, targetCell, map);
                        }
                    }
                    //this.Ability.PostAbilityAttempt();

                    //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
            {
                Log.Warning("failed to TryCastShot");
            }
            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }
Пример #2
0
        protected override bool TryCastShot()
        {
            bool flag = false;

            this.TargetsAoE.Clear();
            this.UpdateTargets();
            MagicPowerSkill pwr = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Polymorph.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Polymorph_pwr");
            MagicPowerSkill ver = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Polymorph.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Polymorph_ver");

            verVal = ver.level;
            pwrVal = pwr.level;
            CompAbilityUserMagic comp = base.CasterPawn.GetComp <CompAbilityUserMagic>();

            this.arcaneDmg = base.CasterPawn.GetComp <CompAbilityUserMagic>().arcaneDmg;
            this.duration += (600 * verVal);

            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");
                MightPowerSkill mver = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                pwrVal = mpwr.level;
                verVal = mver.level;
            }
            ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
            if (settingsRef.AIHardMode && !this.CasterPawn.IsColonist)
            {
                verVal = 2;
                pwrVal = 3;
            }
            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++)
            {
                Pawn newPawn = this.TargetsAoE[i].Thing as Pawn;
                if (newPawn != this.CasterPawn)
                {
                    CompPolymorph compPoly = newPawn.GetComp <CompPolymorph>();
                    if (compPoly != null && compPoly.Original != null && compPoly.TicksLeft > 0)
                    {
                        compPoly.Temporary = true;
                        compPoly.TicksLeft = 0;
                    }
                    else
                    {
                        float enchantChance = .5f;
                        if (newPawn.RaceProps.IsFlesh)
                        {
                            enchantChance = (.5f + (.1f * pwr.level) + TM_Calc.GetSpellSuccessChance(this.CasterPawn, newPawn));
                        }
                        else
                        {
                            enchantChance = (.0f + (.2f * pwr.level) + TM_Calc.GetSpellSuccessChance(this.CasterPawn, newPawn));
                        }
                        if (Rand.Chance(enchantChance) && newPawn.GetComp <CompPolymorph>() != null)
                        {
                            FactionDef fDef = TorannMagicDefOf.TM_SummonedFaction;
                            if (newPawn.Faction != null)
                            {
                                fDef = newPawn.Faction.def;
                            }
                            SpawnThings spawnThing = new SpawnThings();
                            spawnThing.factionDef = fDef;
                            spawnThing.spawnCount = 1;
                            spawnThing.temporary  = false;

                            GetPolyMinMax(newPawn);

                            spawnThing = TM_Action.AssignRandomCreatureDef(spawnThing, this.min, this.max);
                            if (spawnThing.def == null || spawnThing.kindDef == null)
                            {
                                spawnThing.def     = ThingDef.Named("Rat");
                                spawnThing.kindDef = PawnKindDef.Named("Rat");
                                Log.Message("random creature was null");
                            }

                            Pawn polymorphedPawn = TM_Action.PolymorphPawn(this.CasterPawn, newPawn, newPawn, spawnThing, newPawn.Position, true, duration);

                            if (polymorphedPawn.Faction != this.CasterPawn.Faction && polymorphedPawn.mindState != null && Rand.Chance(Mathf.Clamp((.2f * this.pwrVal), 0f, .5f)))
                            {
                                polymorphedPawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, "wild beast!", true, false, null, true);
                            }

                            if (this.verVal >= 3)
                            {
                                polymorphedPawn.GetComp <CompPolymorph>().Temporary = false;
                            }

                            MoteMaker.ThrowSmoke(newPawn.DrawPos, newPawn.Map, 2);
                            MoteMaker.ThrowMicroSparks(newPawn.DrawPos, newPawn.Map);
                            MoteMaker.ThrowHeatGlow(newPawn.Position, newPawn.Map, 2);

                            newPawn.DeSpawn();
                        }
                        else
                        {
                            MoteMaker.ThrowText(newPawn.DrawPos, newPawn.Map, "TM_ResistedSpell".Translate(), -1);
                        }
                    }
                }
            }
            this.PostCastShot(flag, out flag);
            return(flag);
        }
Пример #3
0
        protected override bool TryCastShot()
        {
            Pawn p   = this.CasterPawn;
            Map  map = this.CasterPawn.Map;
            CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>();

            pawns.Clear();
            plants.Clear();
            GenClamor.DoClamor(p, this.UseAbilityProps.TargetAoEProperties.range, ClamorDefOf.Ability);
            Effecter snapeFreezeED = TorannMagicDefOf.TM_SnapFreezeED.Spawn();

            snapeFreezeED.Trigger(new TargetInfo(this.currentTarget.Cell, map, false), new TargetInfo(this.currentTarget.Cell, map, false));
            snapeFreezeED.Cleanup();
            SoundInfo info = SoundInfo.InMap(new TargetInfo(this.currentTarget.Cell, map, false), MaintenanceType.None);

            info.pitchFactor  = .4f;
            info.volumeFactor = 1.2f;
            TorannMagicDefOf.TM_WindLowSD.PlayOneShot(info);
            TargetInfo ti = new TargetInfo(this.currentTarget.Cell, map, false);

            TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, 3f, 0f, .1f, .4f, 1.2f, -3f);
            float classBonus = 1f;

            if (p.story != null && p.story.traits != null && p.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost))
            {
                classBonus = 1.5f;
            }
            if (this.currentTarget != null && p != null && comp != null)
            {
                this.arcaneDmg = comp.arcaneDmg;
                this.TargetsAoE.Clear();
                this.FindTargets();
                float energy = -125000 * this.arcaneDmg * classBonus;
                GenTemperature.PushHeat(this.currentTarget.Cell, p.Map, energy);
                for (int i = 0; i < pawns.Count; i++)
                {
                    if (!pawns[i].RaceProps.IsMechanoid && pawns[i].RaceProps.body.AllPartsVulnerableToFrostbite.Count > 0)
                    {
                        float distanceModifier = 1f / (pawns[i].Position - currentTarget.Cell).LengthHorizontal;
                        if (distanceModifier > 1f)
                        {
                            distanceModifier = 1f;
                        }
                        int bites = Mathf.RoundToInt(Rand.Range(1f, 5f) * classBonus);
                        for (int j = 0; j < bites; j++)
                        {
                            if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier))
                            {
                                TM_Action.DamageEntities(pawns[i], pawns[i].def.race.body.AllPartsVulnerableToFrostbite.RandomElement(), Rand.Range(10, 20) * distanceModifier, 1f, DamageDefOf.Frostbite, p);
                            }
                            if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier))
                            {
                                HealthUtility.AdjustSeverity(pawns[i], HediffDefOf.Hypothermia, distanceModifier / 5f);
                            }
                        }
                    }
                }
                for (int i = 0; i < plants.Count; i++)
                {
                    float distanceModifier = 1f / (plants[i].Position - currentTarget.Cell).LengthHorizontal;
                    if (distanceModifier > 1f)
                    {
                        distanceModifier = 1f;
                    }
                    if (plants[i].def.plant.IsTree)
                    {
                        if (Rand.Chance(distanceModifier / 2f))
                        {
                            plants[i].MakeLeafless(Plant.LeaflessCause.Cold);
                        }
                    }
                    else
                    {
                        if (Rand.Chance(distanceModifier))
                        {
                            plants[i].MakeLeafless(Plant.LeaflessCause.Cold);
                        }
                    }
                    plants[i].Notify_ColorChanged();
                }
                List <IntVec3> cellList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range, true).ToList();
                bool           raining  = map.weatherManager.RainRate > 0f || map.weatherManager.SnowRate > 0f;
                for (int i = 0; i < cellList.Count; i++)
                {
                    cellList[i] = cellList[i].ClampInsideMap(map);
                    SnowUtility.AddSnowRadial(cellList[i], map, 2.4f, Rand.Range(.08f, .13f));
                    TM_FleckMaker.ThrowGenericFleck(FleckDefOf.AirPuff, cellList[i].ToVector3Shifted(), map, 2.5f, .05f, .05f, Rand.Range(2f, 3f), Rand.Range(-60, 60), .5f, -70, Rand.Range(0, 360));
                }
                List <IntVec3> windList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range + 1, true).Except(cellList).ToList();
                for (int i = 0; i < windList.Count; i++)
                {
                    windList[i] = windList[i].ClampInsideMap(map);
                    Vector3 angle = TM_Calc.GetVector(windList[i], this.currentTarget.Cell);
                    TM_FleckMaker.ThrowGenericFleck(FleckDefOf.AirPuff, windList[i].ToVector3Shifted(), map, Rand.Range(1.2f, 2f), .45f, Rand.Range(0f, .25f), .5f, -200, Rand.Range(3, 5), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), Rand.Range(0, 360));
                }
            }

            this.burstShotsLeft = 0;
            return(true);
        }
Пример #4
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);
        }
Пример #5
0
        public static Pawn PolymorphPawn(Pawn caster, Pawn original, Pawn polymorphFactionPawn, SpawnThings spawnables, IntVec3 position, bool temporary, int duration)
        {
            Pawn polymorphPawn = null;
            bool flag          = spawnables.def != null;

            if (flag)
            {
                Faction faction = TM_Action.ResolveFaction(polymorphFactionPawn, spawnables);
                bool    flag2   = spawnables.def.race != null;
                if (flag2)
                {
                    bool flag3 = spawnables.kindDef == null;
                    if (flag3)
                    {
                        Log.Error("Missing kinddef");
                    }
                    else
                    {
                        try
                        {
                            if (ModCheck.Validate.GiddyUp.Core_IsInitialized())
                            {
                                ModCheck.GiddyUp.ForceDismount(original);
                            }
                        }
                        catch
                        {
                        }

                        Pawn newPawn = new Pawn();

                        newPawn = (Pawn)PawnGenerator.GeneratePawn(spawnables.kindDef, faction);
                        newPawn.AllComps.Add(new CompPolymorph());
                        CompPolymorph compPoly = newPawn.GetComp <CompPolymorph>();
                        //CompProperties_Polymorph props = new CompProperties_Polymorph();
                        //compPoly.Initialize(props);

                        if (compPoly != null)
                        {
                            compPoly.ParentPawn     = newPawn;
                            compPoly.Spawner        = caster;
                            compPoly.Temporary      = temporary;
                            compPoly.TicksToDestroy = duration;
                            compPoly.Original       = original;
                        }
                        else
                        {
                            Log.Message("CompPolymorph was null.");
                        }

                        try
                        {
                            GenSpawn.Spawn(newPawn, position, original.Map);
                            polymorphPawn = newPawn;

                            polymorphPawn.drafter   = new Pawn_DraftController(polymorphPawn);
                            polymorphPawn.equipment = new Pawn_EquipmentTracker(polymorphPawn);
                            polymorphPawn.story     = new Pawn_StoryTracker(polymorphPawn);

                            //polymorphPawn.apparel = new Pawn_ApparelTracker(polymorphPawn);
                            //polymorphPawn.mindState = new Pawn_MindState(polymorphPawn);
                            //polymorphPawn.thinker = new Pawn_Thinker(polymorphPawn);
                            //polymorphPawn.jobs = new Pawn_JobTracker(polymorphPawn);
                            //polymorphPawn.records = new Pawn_RecordsTracker(polymorphPawn);
                            //polymorphPawn.skills = new Pawn_SkillTracker(polymorphPawn);
                            //PawnComponentsUtility.AddAndRemoveDynamicComponents(polymorphPawn, true);

                            polymorphPawn.Name   = original.Name;
                            polymorphPawn.gender = original.gender;

                            if (original.health.hediffSet.HasHediff(HediffDef.Named("TM_SoulBondPhysicalHD")) || original.health.hediffSet.HasHediff(HediffDef.Named("TM_SoulBondMentalHD")))
                            {
                                TM_Action.TransferSoulBond(original, polymorphPawn);
                            }
                        }
                        catch (NullReferenceException ex)
                        {
                            Log.Message("TM_Exception".Translate(
                                            caster.LabelShort,
                                            ex.ToString()
                                            ));
                            polymorphPawn = null;
                        }
                        if (polymorphPawn != null && newPawn.Faction != null && newPawn.Faction != Faction.OfPlayer)
                        {
                            Lord lord = null;
                            if (newPawn.Map.mapPawns.SpawnedPawnsInFaction(faction).Any((Pawn p) => p != newPawn))
                            {
                                Predicate <Thing> validator = (Thing p) => p != newPawn && ((Pawn)p).GetLord() != null;
                                Pawn p2 = (Pawn)GenClosest.ClosestThing_Global(newPawn.Position, newPawn.Map.mapPawns.SpawnedPawnsInFaction(faction), 99999f, validator, null);
                                lord = p2.GetLord();
                            }
                            bool flag4 = lord == null;
                            if (flag4)
                            {
                                LordJob_DefendPoint lordJob = new LordJob_DefendPoint(newPawn.Position);
                                lord = LordMaker.MakeNewLord(faction, lordJob, original.Map, null);
                            }
                            lord.AddPawn(newPawn);
                        }
                    }
                }
                else
                {
                    Log.Message("Missing race");
                }
            }
            return(polymorphPawn);
        }
Пример #6
0
        protected override bool TryCastShot()
        {
            bool result = false;
            bool arg_40_0;

            Pawn pawn = this.CasterPawn;
            Map  map  = this.CasterPawn.Map;

            if (pawn != null && !pawn.Downed)
            {
                if (pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_InvisibilityHD, false))
                {
                    using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff rec = enumerator.Current;
                            if (rec.def == TorannMagicDefOf.TM_InvisibilityHD)
                            {
                                pawn.health.RemoveHediff(rec);
                            }
                        }
                    }
                    TM_MoteMaker.ThrowManaPuff(pawn.DrawPos, pawn.Map, .75f);
                    TM_MoteMaker.ThrowManaPuff(pawn.DrawPos, pawn.Map, .75f);
                    TM_MoteMaker.ThrowSiphonMote(pawn.DrawPos, pawn.Map, 1f);
                }
                else
                {
                    HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_InvisibilityHD, Mathf.RoundToInt(20f * pawn.GetComp <CompAbilityUserMagic>().arcaneDmg));
                    TM_MoteMaker.ThrowManaPuff(pawn.DrawPos, pawn.Map, .75f);
                    TM_MoteMaker.ThrowManaPuff(pawn.DrawPos, pawn.Map, 1);
                    TM_MoteMaker.ThrowManaPuff(pawn.DrawPos, pawn.Map, .75f);
                    List <Pawn> allPawns = this.CasterPawn.Map.mapPawns.AllPawnsSpawned;
                    for (int i = 0; i < allPawns.Count; i++)
                    {
                        if (allPawns[i].Faction != null && allPawns[i].HostileTo(this.CasterPawn.Faction) && allPawns[i].CurJob != null && allPawns[i].CurJob.targetA != null && allPawns[i].CurJob.targetA.Thing == this.CasterPawn)
                        {
                            allPawns[i].jobs.EndCurrentJob(Verse.AI.JobCondition.InterruptForced, true);
                        }
                    }
                    if (this.CasterPawn.TryGetComp <CompAbilityUserMagic>()?.MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_ver").level >= 12)
                    {
                        HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_InvisibilityHD, 5f);
                        TM_Action.DoAction_HealPawn(this.CasterPawn, this.CasterPawn, 3, 7);
                    }
                }
                arg_40_0 = true;
            }
            else
            {
                arg_40_0 = false;
            }
            bool flag = arg_40_0;

            if (flag)
            {
            }
            else
            {
                Log.Warning("failed to TryCastShot");
            }
            this.burstShotsLeft = 0;

            return(result);
        }
Пример #7
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            CompAbilityUserMagic comp = this.pawn.GetComp <CompAbilityUserMagic>();
            Toil discordance          = new Toil();
            Pawn target = this.TargetThingA as Pawn;

            discordance.initAction = delegate
            {
                if (age > duration)
                {
                    this.EndJobWith(JobCondition.Succeeded);
                }
                if (target.DestroyedOrNull())
                {
                    this.EndJobWith(JobCondition.Errored);
                }
                if (target.Map == null)
                {
                    this.EndJobWith(JobCondition.Errored);
                }
                if (target.Dead)
                {
                    this.EndJobWith(JobCondition.Succeeded);
                }
                Map map = this.pawn.Map;
                ticksLeftThisToil = 10;
                headDamageCount   = 0;
            };
            discordance.tickAction = delegate
            {
                if (Find.TickManager.TicksGame % this.moteFrequency == 0)
                {
                    TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f));
                    float    angle = Rand.Range(0, 360);
                    ThingDef mote  = TorannMagicDefOf.Mote_Psi_Grayscale;
                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Psi_Grayscale, this.pawn.DrawPos, this.pawn.Map, Rand.Range(.25f, .6f), .1f, .05f, .05f, 0, Rand.Range(4f, 6f), angle, angle);
                }
                if (Find.TickManager.TicksGame % this.discordFrequency == 0)
                {
                    Vector3 headPos = target.DrawPos;
                    headPos.z += .3f;
                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Bolt, headPos, target.Map, .6f, .5f, .1f, .5f, Rand.Range(-10, 10), Rand.Range(.4f, .6f), Rand.Range(-90, 90), Rand.Range(0, 360));
                    float manaCost = comp.ActualManaCost(TorannMagicDefOf.TM_Discord);
                    if (comp.Mana.CurLevel >= manaCost && !target.DestroyedOrNull() && !target.Dead && target.Map != null)
                    {
                        comp.Mana.CurLevel -= manaCost;
                        float ch = TM_Calc.GetSpellSuccessChance(this.pawn, target, true);
                        if (target.Faction == this.pawn.Faction)
                        {
                            HealthUtility.AdjustSeverity(target, TorannMagicDefOf.TM_DiscordSafeHD, .4f * ch);
                            Hediff hd = target.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_DiscordHD);
                            if (hd != null && hd.Severity > 5)
                            {
                                if (Rand.Chance(.2f))
                                {
                                    TM_Action.DamageEntities(target, null, 6, DamageDefOf.Stun, this.pawn);
                                }
                            }
                        }
                        else
                        {
                            HealthUtility.AdjustSeverity(target, TorannMagicDefOf.TM_DiscordHD, .4f * ch);
                            Hediff hd = target.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_DiscordHD);
                            if (hd != null && hd.Severity > 5)
                            {
                                BodyPartRecord bpr  = target.health.hediffSet.GetBrain();
                                BodyPartRecord head = target.health.hediffSet.GetNotMissingParts().FirstOrDefault((BodyPartRecord x) => x.def == BodyPartDefOf.Head);
                                if (bpr != null)
                                {
                                    if (Rand.Chance(.22f * ch))
                                    {
                                        for (int i = 0; i < 2; i++)
                                        {
                                            TM_MoteMaker.ThrowBloodSquirt(headPos, target.Map, Rand.Range(.6f, 1f));
                                        }
                                        TM_Action.DamageEntities(target, bpr, Rand.Range(1, 3), 2f, TMDamageDefOf.DamageDefOf.TM_DistortionDD, this.pawn);
                                        headDamageCount++;
                                    }
                                    else if (Rand.Chance((.07f * ch) + (headDamageCount * .3f)) && head != null)
                                    {
                                        for (int i = 0; i < 3; i++)
                                        {
                                            TM_MoteMaker.ThrowBloodSquirt(headPos, target.Map, Rand.Range(.6f, 1f));
                                        }
                                        for (int i = 0; i < 3; i++)
                                        {
                                            float moteSize      = Rand.Range(.5f, .8f);
                                            float solidTime     = Rand.Range(.6f, .8f);
                                            float fadeOutTime   = Rand.Range(.2f, .4f);
                                            float velocity      = Rand.Range(1.5f, 2.5f);
                                            float velocityAngle = Rand.Range(0f, 360f);
                                            for (int j = 0; j < 3; j++)
                                            {
                                                TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BloodSquirt, headPos, target.Map, moteSize - (.1f * j), solidTime + (.1f * j), 0f, fadeOutTime + (.05f * j), Rand.Range(-50, 50), velocity + (.5f * j), velocityAngle, Rand.Range(0, 360));
                                            }
                                        }
                                        TM_Action.DamageEntities(target, head, Rand.Range(50, 80), 2f, TMDamageDefOf.DamageDefOf.TM_DistortionDD, this.pawn);
                                    }
                                }
                            }
                        }
                        if (target.Dead)
                        {
                            this.age = this.duration;
                        }
                    }
                    else
                    {
                        this.age = this.duration;
                    }
                }
                age++;
                ticksLeftThisToil = Mathf.RoundToInt((float)(duration - age) / (float)duration * 100f);
                if (age > duration)
                {
                    this.EndJobWith(JobCondition.Succeeded);
                }
            };
            discordance.defaultCompleteMode = ToilCompleteMode.Delay;
            discordance.defaultDuration     = this.duration;
            discordance.WithProgressBar(TargetIndex.A, delegate
            {
                if (this.pawn.DestroyedOrNull() || this.pawn.Dead || this.pawn.Downed)
                {
                    return(1f);
                }
                return(1f - ((float)discordance.actor.jobs.curDriver.ticksLeftThisToil / 100));
            }, false, 0f);
            discordance.AddFinishAction(delegate
            {
            });
            yield return(discordance);
        }
Пример #8
0
        protected override bool TryCastShot()
        {
            Pawn pawn = base.CasterPawn;
            Map  map  = pawn.Map;

            CompAbilityUserMight comp = caster.TryGetComp <CompAbilityUserMight>();

            pwrVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_60mmMortar, "TM_60mmMortar", "_pwr", true);
            verVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_60mmMortar, "TM_60mmMortar", "_ver", true);
            effVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_60mmMortar, "TM_60mmMortar", "_eff", true);

            if ((pawn.Position.IsValid && pawn.Position.Standable(map)))
            {
                AbilityUser.SpawnThings tempPod = new SpawnThings();
                IntVec3 shiftPos = TM_Calc.GetEmptyCellForNewBuilding(pawn.Position, map, 1.6f, false, 0);

                tempPod.def        = TorannMagicDefOf.TM_60mmMortar_Base;
                tempPod.spawnCount = 1;

                if (shiftPos != default(IntVec3))
                {
                    try
                    {
                        this.mortar = TM_Action.SingleSpawnLoop(pawn, tempPod, shiftPos, map, 1200, true, false, pawn.Faction);

                        for (int i = 0; i < 3; i++)
                        {
                            Vector3 rndPos = this.mortar.DrawPos;
                            rndPos.x += Rand.Range(-.5f, .5f);
                            rndPos.z += Rand.Range(-.5f, .5f);
                            TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SparkFlash"), rndPos, map, Rand.Range(.6f, .8f), .1f, .05f, .05f, 0, 0, 0, Rand.Range(0, 360));
                            MoteMaker.ThrowSmoke(rndPos, map, Rand.Range(.8f, 1.2f));
                        }
                    }
                    catch
                    {
                        comp.Stamina.CurLevel += comp.ActualStaminaCost(TorannMagicDefOf.TM_60mmMortar);
                        Log.Message("TM_Exception".Translate(
                                        pawn.LabelShort,
                                        "60mm Mortar"
                                        ));
                    }
                }
                else
                {
                    Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                    comp.Stamina.GainNeed(comp.ActualStaminaCost(TorannMagicDefOf.TM_60mmMortar));
                }
            }
            else
            {
                Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                comp.Stamina.GainNeed(comp.ActualStaminaCost(TorannMagicDefOf.TM_60mmMortar));
            }


            if ((mortar != null && mortar.Spawned && mortar.Position.IsValid))
            {
                this.Ability.PostAbilityAttempt();
                mortar.def.interactionCellOffset = (caster.Position - mortar.Position);
                Job job = new Job(JobDefOf.ManTurret, mortar);
                pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                //this.Ability.PostAbilityAttempt();
            }
            else
            {
                Log.Message("mortar was null");
            }

            return(false);
        }
Пример #9
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();
                    }
                }

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

                if (this.ticksBitWorking > 0 && this.nextBitEffect < Find.TickManager.TicksGame && this.moteLoc != Vector3.zero)
                {
                    Vector3 rndVec = this.moteLoc;
                    rndVec.x += Rand.Range(-.15f, .15f);
                    rndVec.z += Rand.Range(-.15f, .15f);
                    TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SparkFlash"), rndVec, this.Pawn.Map, Rand.Range(.8f, 1.3f), .05f, 0f, .1f, 0, 0f, 0f, 0f);
                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Enchanting, comp.bitPosition, this.Pawn.Map, Rand.Range(0.35f, 0.43f), .2f, .05f, Rand.Range(.4f, .6f), Rand.Range(-200, 200), 0, 0, 0);
                    this.ticksBitWorking--;
                    this.nextBitEffect = Find.TickManager.TicksGame + Rand.Range(6, 10);
                    if (this.ticksBitWorking == 0)
                    {
                        this.moteLoc = Vector3.zero;
                    }
                }

                if (comp.useTechnoBitToggle)
                {
                    if (Find.TickManager.TicksGame % 60 == 0)
                    {
                        DetermineHDRank();
                    }
                    if (Find.TickManager.TicksGame % 600 == 0 && !this.Pawn.Drafted)
                    {
                        if (comp.Mana.CurLevelPercentage >= .9f && comp.Mana.CurLevel >= (.06f - (.001f * this.VerVal)) && this.Pawn.CurJob.targetA.Thing != null)
                        {
                            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 == "FinishFrame" || this.Pawn.CurJob.def.defName == "Deconstruct" || this.Pawn.CurJob.def.defName == "Repair" || this.Pawn.CurJob.def.defName == "Mine" || this.Pawn.CurJob.def.defName == "SmoothFloor" || this.Pawn.CurJob.def.defName == "SmoothWall"))
                                {
                                    comp.Mana.CurLevel -= (.05f - (.001f * this.VerVal));
                                    HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_BitAssistHD"), .5f + 1f * this.VerVal);
                                    comp.MagicUserXP    += Rand.Range(6, 8);
                                    this.ticksBitWorking = 8;
                                    this.moteLoc         = this.Pawn.CurJob.targetA.Thing.DrawPos;
                                }
                            }
                        }
                    }

                    if (comp.useTechnoBitRepairToggle && Find.TickManager.TicksGame % (160 - 3 * EffVal) == 0 && this.Pawn.Drafted && comp.Mana.CurLevel >= (.03f - .0008f * EffVal))
                    {
                        Thing    damagedThing   = TM_Calc.FindNearbyDamagedThing(this.Pawn, Mathf.RoundToInt(5 + .33f * EffVal));
                        Building repairBuilding = damagedThing as Building;
                        if (repairBuilding != null)
                        {
                            repairBuilding.HitPoints = Mathf.Min(Mathf.RoundToInt(repairBuilding.HitPoints + (6 + (.3f * EffVal))), repairBuilding.MaxHitPoints);
                            comp.Mana.CurLevel      -= (.03f - .0006f * EffVal);
                            comp.MagicUserXP        += Rand.Range(3, 4);
                            this.ticksBitWorking     = 8;
                            this.moteLoc             = repairBuilding.DrawPos;
                        }
                        Pawn damagedRobot = damagedThing as Pawn;
                        if (damagedRobot != null)
                        {
                            TM_Action.DoAction_HealPawn(this.Pawn, damagedRobot, 1, (3 + .3f * EffVal));
                            comp.Mana.CurLevel  -= (.03f - .0006f * EffVal);
                            comp.MagicUserXP    += Rand.Range(3, 4);
                            this.ticksBitWorking = 5;
                            this.moteLoc         = damagedRobot.DrawPos;
                        }
                    }

                    if (comp.useTechnoBitRepairToggle && Find.TickManager.TicksGame % (600 - 6 * EffVal) == 0 && !this.Pawn.Drafted && comp.Mana.CurLevel >= .05f)
                    {
                        Thing    damagedThing   = TM_Calc.FindNearbyDamagedThing(this.Pawn, Mathf.RoundToInt(10 + .5f * EffVal));
                        Building repairBuilding = damagedThing as Building;
                        if (repairBuilding != null)
                        {
                            repairBuilding.HitPoints = Mathf.Min(repairBuilding.HitPoints + (20 + EffVal), repairBuilding.MaxHitPoints);
                            comp.Mana.CurLevel      -= (.05f - .0008f * EffVal);
                            comp.MagicUserXP        += Rand.Range(9, 11);
                            this.ticksBitWorking     = 8;
                            this.moteLoc             = repairBuilding.DrawPos;
                        }
                        Pawn damagedRobot = damagedThing as Pawn;
                        if (damagedRobot != null)
                        {
                            TM_Action.DoAction_HealPawn(this.Pawn, damagedRobot, 2, (6 + .3f * EffVal));
                            comp.Mana.CurLevel  -= (.05f - .0008f * EffVal);
                            comp.MagicUserXP    += Rand.Range(9, 11);
                            this.ticksBitWorking = 5;
                            this.moteLoc         = damagedRobot.DrawPos;
                        }
                    }

                    if (comp.Mana.CurLevel >= .1f && (this.Pawn.Drafted || !this.Pawn.IsColonist))
                    {
                        if (this.Pawn.TargetCurrentlyAimingAt != null && (this.Pawn.CurJob.def.defName == "AttackStatic" || this.Pawn.CurJob.def.defName == "Wait_Combat") && this.nextBitGrenade < Find.TickManager.TicksGame)
                        {
                            float maxRange       = 25 + this.PwrVal;
                            Thing targetThing    = this.Pawn.TargetCurrentlyAimingAt.Thing;
                            float targetDistance = (this.Pawn.Position - targetThing.Position).LengthHorizontal;
                            if (TM_Calc.HasLoSFromTo(this.Pawn.Position, this.Pawn.TargetCurrentlyAimingAt.Thing, this.Pawn as Thing, 2f, maxRange) && targetThing.Map != null && this.bitGrenadeCount > 0)
                            {
                                IntVec3 rndTargetCell = targetThing.Position;
                                rndTargetCell.x += (int)Rand.Range(-targetDistance / 8f, targetDistance / 8f);
                                rndTargetCell.z += (int)Rand.Range(-targetDistance / 8f, targetDistance / 8f);
                                LocalTargetInfo ltiTarget = rndTargetCell;
                                if (this.bitGrenadeCount == 2)
                                {
                                    //launch emp grenade
                                    Projectile projectile  = (Projectile)GenSpawn.Spawn(ThingDef.Named("Projectile_TMEMPGrenade"), this.Pawn.Position, this.Pawn.Map, WipeMode.Vanish);
                                    float      launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, ltiTarget.Cell)).ToAngleFlat();
                                    for (int m = 0; m < 4; m++)
                                    {
                                        TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_Smoke, comp.bitPosition, this.Pawn.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(3f, 5f), launchAngle += Rand.Range(-25, 25), Rand.Range(0, 360));
                                    }
                                    SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None);
                                    info.pitchFactor  = 2f;
                                    info.volumeFactor = .6f;
                                    SoundDef.Named("Mortar_LaunchA").PlayOneShot(info);
                                    projectile.def.projectile.speed          = 20 + PwrVal;
                                    projectile.def.projectile.explosionDelay = Rand.Range(80, 120) - (4 * PwrVal);
                                    projectile.Launch(this.Pawn, comp.bitPosition, ltiTarget, targetThing, ProjectileHitFlags.All, null, null);
                                }
                                else
                                {
                                    //fire he grenade
                                    Projectile projectile  = (Projectile)GenSpawn.Spawn(ThingDef.Named("Projectile_TMFragGrenade"), this.Pawn.Position, this.Pawn.Map, WipeMode.Vanish);
                                    float      launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, ltiTarget.Cell)).ToAngleFlat();
                                    for (int m = 0; m < 4; m++)
                                    {
                                        TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_Smoke, comp.bitPosition, this.Pawn.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(3f, 5f), launchAngle += Rand.Range(-25, 25), Rand.Range(0, 360));
                                    }
                                    SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None);
                                    info.pitchFactor  = 1.4f;
                                    info.volumeFactor = .5f;
                                    SoundDef.Named("Mortar_LaunchA").PlayOneShot(info);
                                    projectile.def.projectile.speed          = 20 + PwrVal;
                                    projectile.def.projectile.explosionDelay = Rand.Range(80, 120) - (4 * PwrVal);
                                    projectile.Launch(this.Pawn, comp.bitPosition, ltiTarget, targetThing, ProjectileHitFlags.All, null, null);
                                }
                                this.nextBitGrenade = 18 + Find.TickManager.TicksGame;
                                this.bitGrenadeCount--;
                                if (this.bitGrenadeCount == 0)
                                {
                                    this.bitGrenadeCount = 1 + (int)((this.PwrVal) / 5);
                                    this.nextBitGrenade  = Find.TickManager.TicksGame + (600 - 6 * PwrVal);
                                    comp.Mana.CurLevel  -= (.08f - (.001f * this.PwrVal));
                                    comp.MagicUserXP    += Rand.Range(12, 18);
                                }
                            }
                            else if (this.nextBitGrenade < Find.TickManager.TicksGame && this.bitGrenadeCount <= 0)
                            {
                                this.bitGrenadeCount = 1 + (int)((this.PwrVal) / 5);
                                this.nextBitGrenade  = Find.TickManager.TicksGame + (600 - 6 * PwrVal);
                            }
                        }
                    }
                }
            }
        }
Пример #10
0
        protected override bool TryCastShot()
        {
            CellRect cellRect = CellRect.CenteredOn(this.currentTarget.Cell, 1);
            Map      map      = base.CasterPawn.Map;

            cellRect.ClipInsideMap(map);

            IntVec3 centerCell = cellRect.CenterCell;
            //FlyingObject flyingPawn = new FlyingObject();
            Pawn summonablePawn = new Pawn();

            bool pflag = true;

            Thing summonableThing = centerCell.GetFirstPawn(map);

            if (summonableThing == null)
            {
                pflag           = false;
                summonableThing = centerCell.GetFirstItem(map);
            }
            else
            {
                pVect          = summonableThing.TrueCenter();
                pVect.x        = base.caster.TrueCenter().x;
                pVect.z        = base.caster.TrueCenter().z;
                pVect.y        = 0f;
                summonablePawn = summonableThing as Pawn;
                if (summonablePawn != base.CasterPawn)
                {
                    //flyingPawn = (FlyingObject)GenSpawn.Spawn(ThingDef.Named("TM_SummonedPawn"), summonableThing.Position, summonableThing.Map);
                }
                else
                {
                    //flyingPawn = null;
                    summonableThing = null;
                    Messages.Message("TM_CantSummonSelf".Translate(), MessageTypeDefOf.NegativeEvent);
                }
            }

            bool result = false;
            bool arg_40_0;

            if (this.currentTarget != null && base.CasterPawn != null)
            {
                arg_40_0 = this.currentTarget.Cell.IsValid;
            }
            else
            {
                arg_40_0 = false;
            }
            bool flag = arg_40_0;

            if (flag)
            {
                if (summonableThing != null)
                {
                    if (pflag)// && flyingPawn != null)
                    {
                        //Thing p = summonablePawn;
                        if (!summonablePawn.RaceProps.Humanlike || summonablePawn.Faction == this.CasterPawn.Faction)
                        {
                            summonablePawn.DeSpawn();
                            GenSpawn.Spawn(summonablePawn, base.CasterPawn.Position, map);
                        }
                        else if (summonablePawn.RaceProps.Humanlike && summonablePawn.Faction != this.CasterPawn.Faction && Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, summonablePawn, true)))
                        {
                            //summonablePawn.DeSpawn();
                            //GenSpawn.Spawn(p, base.caster.Position, base.CasterPawn.Map, Rot4.North, false);

                            //Pawn p = summonablePawn;
                            summonablePawn.DeSpawn();
                            //p.SetPositionDirect(this.currentTarget.Cell);
                            GenSpawn.Spawn(summonablePawn, base.CasterPawn.Position, map);
                            //flyingPawn = null;
                            if (summonablePawn.IsColonist && !base.CasterPawn.IsColonist)
                            {
                                TM_Action.SpellAffectedPlayerWarning(summonablePawn);
                            }
                            //summonablePawn.Position = base.CasterPawn.Position;
                            //p.jobs.StopAll(false);
                        }
                        else
                        {
                            MoteMaker.ThrowText(summonablePawn.DrawPos, summonablePawn.Map, "TM_ResistedSpell".Translate(), -1);
                        }
                    }
                    else
                    {
                        summonableThing.DeSpawn(DestroyMode.Vanish);
                        GenPlace.TryPlaceThing(summonableThing, this.CasterPawn.Position, this.CasterPawn.Map, ThingPlaceMode.Near);
                        //summonableThing.Position = base.CasterPawn.Position;
                        //summonableThing.Rotation = Rot4.North;
                        //summonableThing.SetPositionDirect(base.CasterPawn.InteractionCell);
                    }
                    result = true;
                }
            }
            else
            {
                Log.Warning("failed to TryCastShot");
            }
            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }
        public void HealLinkedPawnWounds()
        {
            List <IntVec3> cellList = GenRadial.RadialCellsAround(this.linkedPawn.Position, .4f + this.bfbVer, true).ToList();

            for (int i = 0; i < cellList.Count; i++)
            {
                Pawn healedPawn = cellList[i].GetFirstPawn(this.linkedPawn.Map);
                if (healedPawn != null && healedPawn.Faction != null && healedPawn.Faction == linkedPawn.Faction)
                {
                    TM_Action.DoAction_HealPawn(this.linkedPawn, healedPawn, 1, (1f + .35f * this.bfbVer) * (1 + bleedRate));
                    if (healedPawn == linkedPawn)
                    {
                        Vector3 revDir = this.linkedPawn.DrawPos - (2 * this.directionToLinkedPawn);
                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_BloodMist"), revDir, this.Pawn.Map, Rand.Range(.8f, 1f), .2f, 0.05f, 1f, Rand.Range(-50, 50), Rand.Range(2f, 3f), (Quaternion.AngleAxis(90, Vector3.up) * this.directionToLinkedPawn).ToAngleFlat(), Rand.Range(0, 360));
                    }
                }
            }
            if (this.bfbVer > 0)
            {
                Effecter BFBEffect = TorannMagicDefOf.TM_BFBEffecter.Spawn();
                BFBEffect.Trigger(new TargetInfo(this.linkedPawn.Position, this.linkedPawn.Map, false), new TargetInfo(this.linkedPawn.Position, this.linkedPawn.Map, false));
                BFBEffect.Cleanup();
            }
            int num = 1;

            using (IEnumerator <BodyPartRecord> enumerator = linkedPawn.health.hediffSet.GetInjuredParts().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BodyPartRecord rec   = enumerator.Current;
                    bool           flag2 = num > 0;
                    if (flag2)
                    {
                        int num2 = 1;
                        IEnumerable <Hediff_Injury> arg_BB_0 = linkedPawn.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))
                                    {
                                        current.Heal(Rand.Range(.03f, .05f));
                                    }
                                    else
                                    {
                                        current.Heal(Rand.Range(.15f, .25f));
                                        //current.Heal(5.0f + (float)pwrVal * 3f); // power affects how much to heal
                                        num--;
                                        num2--;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #12
0
        protected override bool TryCastShot()
        {
            bool flagRawResource = false;
            bool flagStuffItem   = false;
            bool flagNoStuffItem = false;
            bool flagNutrition   = false;
            bool flagCorpse      = false;


            Thing transmutateThing = TM_Calc.GetTransmutableThingFromCell(this.currentTarget.Cell, this.CasterPawn, out flagRawResource, out flagStuffItem, out flagNoStuffItem, out flagNutrition, out flagCorpse, true);

            //List<Thing> thingList = this.currentTarget.Cell.GetThingList(caster.Map);

            //for (int i = 0; i < thingList.Count; i++)
            //{
            //    if (thingList[i] != null && !(thingList[i] is Pawn) && !(thingList[i] is Building))
            //    {
            //        //if (thingList[i].def.thingCategories != null && thingList[i].def.thingCategories.Count > 0 && (thingList[i].def.thingCategories.Contains(ThingCategoryDefOf.ResourcesRaw) || thingList[i].def.thingCategories.Contains(ThingCategoryDefOf.StoneBlocks) || thingList[i].def.defName == "RawMagicyte"))
            //        if (thingList[i].def.MadeFromStuff && verVal >= 3)
            //        {
            //            //Log.Message("stuff item");
            //            flagStuffItem = true;
            //            transmutateThing = thingList[i];
            //            break;
            //        }
            //        if(!thingList[i].def.MadeFromStuff && thingList[i].TryGetComp<CompQuality>() != null && verVal >= 3)
            //        {
            //            //Log.Message("non stuff item");
            //            flagNoStuffItem = true;
            //            transmutateThing = thingList[i];
            //            break;
            //        }
            //        if ((thingList[i].def.statBases != null && thingList[i].GetStatValue(StatDefOf.Nutrition) > 0) && !(thingList[i] is Corpse) && verVal >= 1)
            //        {
            //            //Log.Message("food item");
            //            flagNutrition = true;
            //            transmutateThing = thingList[i];
            //            break;
            //        }
            //        if(thingList[i] is Corpse && verVal >= 2)
            //        {
            //            //Log.Message("corpse");
            //            flagCorpse = true;
            //            transmutateThing = thingList[i];
            //            break;
            //        }
            //        if (thingList[i].def != null && !thingList[i].def.IsIngestible && ((thingList[i].def.stuffProps != null && thingList[i].def.stuffProps.categories != null && thingList[i].def.stuffProps.categories.Count > 0) || thingList[i].def.defName == "RawMagicyte" || thingList[i].def.IsWithinCategory(ThingCategoryDefOf.ResourcesRaw) || thingList[i].def.IsWithinCategory(ThingCategoryDefOf.Leathers)))
            //        {
            //            //Log.Message("resource");
            //            flagRawResource = true;
            //            transmutateThing = thingList[i];
            //            break;
            //        }
            //    }
            //}

            if (transmutateThing != null)
            {
                TM_Action.DoTransmutate(this.CasterPawn, transmutateThing, flagNoStuffItem, flagRawResource, flagStuffItem, flagNutrition, flagCorpse);
            }
            else
            {
                Messages.Message("TM_NoThingToTransmutate".Translate(
                                     this.CasterPawn.LabelShort
                                     ), MessageTypeDefOf.RejectInput);
            }

            this.burstShotsLeft = 0;
            return(false);
        }
Пример #13
0
        protected override void Impact(Thing hitThing)
        {
            if (!this.initialized)
            {
                this.pawn = this.launcher as Pawn;
                CompAbilityUserMagic   comp        = pawn.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill        pwr         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AccelerateTime.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AccelerateTime_pwr");
                MagicPowerSkill        ver         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AccelerateTime.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AccelerateTime_ver");
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                pwrVal = pwr.level;
                verVal = ver.level;
                if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                {
                    MightPowerSkill mpwr = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                    MightPowerSkill mver = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                    pwrVal = mpwr.level;
                    verVal = mver.level;
                }
                this.arcaneDmg = comp.arcaneDmg;
                if (settingsRef.AIHardMode && !pawn.IsColonist)
                {
                    pwrVal = 3;
                    verVal = 3;
                }
                this.strikeDelay = this.strikeDelay - verVal;
                this.radius      = this.def.projectile.explosionRadius;
                this.duration    = Mathf.RoundToInt(this.radius * this.strikeDelay);
                this.initialized = true;
                this.targets     = GenRadial.RadialCellsAround(base.Position, this.radius, true);
                //cellList = targets.ToList<IntVec3>();
            }


            Pawn targetPawn = this.intendedTarget.Thing as Pawn;

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

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

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

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

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

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

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

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

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

            Effecter AreaAccelEffect = TorannMagicDefOf.TM_TimeAccelerationAreaEffecter.Spawn();

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

            this.age = this.duration;
            this.Destroy(DestroyMode.Vanish);
        }
Пример #14
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            base.CompPostTick(ref severityAdjustment);
            if (base.Pawn != null & base.parent != null)
            {
                if (!initialized)
                {
                    initialized = true;
                    this.Initialize();
                }
            }
            this.age++;
            if (!this.Pawn.DestroyedOrNull() && !this.Pawn.Dead)
            {
                if (age > lastRegen + regenRate)
                {
                    HealthUtility.AdjustSeverity(base.Pawn, this.Def, -0.3f);
                    this.lastRegen = this.age;
                    Pawn pawn = this.Pawn;

                    TM_MoteMaker.ThrowRegenMote(pawn.DrawPos, pawn.Map, 1f);
                    bool flag = TM_Calc.IsUndead(pawn);
                    if (!flag)
                    {
                        ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                        int num = 1; // + ver.level;
                        if (settingsRef.AIHardMode && !pawn.IsColonist)
                        {
                            num = 2;
                        }

                        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; // + ver.level;
                                    if (settingsRef.AIHardMode && !pawn.IsColonist)
                                    {
                                        num2 = 2;
                                    }
                                    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 (!pawn.IsColonist)
                                                {
                                                    current.Heal(10f + (1.5f * hediffPwr));
                                                }
                                                else
                                                {
                                                    current.Heal(4f + (.5f * hediffPwr));
                                                }
                                                num--;
                                                num2--;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        TM_Action.DamageUndead(pawn, 2f + (1f * hediffPwr), null);
                    }
                }
            }
        }
Пример #15
0
        public void GetAffectedPawns(IntVec3 center, Map map)
        {
            Pawn victim = null;
            IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(center, this.def.projectile.explosionRadius, true);

            foreach (var curCell in targets)
            {
                if (curCell.InBounds(map) && curCell.IsValid)
                {
                    victim = curCell.GetFirstPawn(map);
                }

                if (victim != null && victim.Faction == this.caster.Faction && !victim.Dead)
                {
                    if (verVal >= 1)
                    {
                        HealthUtility.AdjustSeverity(victim, TorannMagicDefOf.TM_HediffTimedInvulnerable, 1f);
                        Hediff hd = victim.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_HediffTimedInvulnerable);
                        HediffComp_Disappears hdc = hd.TryGetComp <HediffComp_Disappears>();
                        if (hdc != null)
                        {
                            hdc.ticksToDisappear += 360;
                        }
                    }
                    if (verVal >= 2)
                    {
                        Pawn pawn       = victim;
                        bool flag       = pawn != null && !pawn.Dead && !TM_Calc.IsUndead(pawn);
                        bool undeadFlag = pawn != null && !pawn.Dead && TM_Calc.IsUndead(pawn);
                        if (flag)
                        {
                            int num = 3;
                            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;
                                        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.caster.IsColonist)
                                                    {
                                                        current.Heal(20.0f); // power affects how much to heal
                                                    }
                                                    else
                                                    {
                                                        current.Heal(5.0f * this.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 (verVal >= 3)
                    {
                        HealthUtility.AdjustSeverity(victim, HediffDef.Named("BestowMightHD"), 1f);
                    }
                }
                if (victim != null && !victim.Dead && TM_Calc.IsUndead(victim))
                {
                    TM_Action.DamageUndead(victim, Rand.Range(5f, 12f) * this.arcaneDmg, this.launcher);
                }
            }
        }
        protected override bool TryCastShot()
        {
            CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      eff  = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_EnchanterStone.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_EnchanterStone_eff");
            MagicPowerSkill      ver  = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_EnchanterStone.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_EnchanterStone_ver");

            effVal = eff.level;
            verVal = ver.level;

            List <Thing> thingList = this.currentTarget.Cell.GetThingList(this.CasterPawn.Map);
            Thing        newThing  = null;

            if (thingList != null && thingList.Count > 0)
            {
                for (int i = 0; i < thingList.Count; i++)
                {
                    Thing thing = thingList[i];
                    if (thing != null && thing.def.EverHaulable)
                    {
                        if (thing.def == ThingDefOf.Silver)
                        {
                            if (thing.stackCount >= 500)
                            {
                                if (verVal >= 1)
                                {
                                    thing.SplitOff(500).Destroy();
                                    newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Silver, null);
                                }
                                else
                                {
                                    Messages.Message("TM_CannotCreateStone".Translate(
                                                         this.CasterPawn.LabelShort,
                                                         thing.def.label
                                                         ), MessageTypeDefOf.RejectInput);
                                }
                                break;
                            }
                            else
                            {
                                Messages.Message("InsufficientMaterialForArtifact".Translate(
                                                     thing.def.label
                                                     ), MessageTypeDefOf.RejectInput);
                            }
                        }
                        else if (thing.def == ThingDefOf.Gold)
                        {
                            if (thing.stackCount >= 50)
                            {
                                if (verVal >= 3)
                                {
                                    thing.SplitOff(50).Destroy();
                                    newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Gold, null);
                                }
                                else
                                {
                                    Messages.Message("TM_CannotCreateStone".Translate(
                                                         this.CasterPawn.LabelShort,
                                                         thing.def.label
                                                         ), MessageTypeDefOf.RejectInput);
                                }
                                break;
                            }
                            else
                            {
                                Messages.Message("InsufficientMaterialForArtifact".Translate(
                                                     thing.def.label
                                                     ), MessageTypeDefOf.RejectInput);
                            }
                        }
                        else if (thing.def == ThingDef.Named("Jade"))
                        {
                            if (thing.stackCount >= 50)
                            {
                                if (verVal >= 2)
                                {
                                    thing.SplitOff(50).Destroy();
                                    newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Jade, null);
                                }
                                else
                                {
                                    Messages.Message("TM_CannotCreateStone".Translate(
                                                         this.CasterPawn.LabelShort,
                                                         thing.def.label
                                                         ), MessageTypeDefOf.RejectInput);
                                }
                                break;
                            }
                            else
                            {
                                Messages.Message("InsufficientMaterialForArtifact".Translate(
                                                     thing.def.label
                                                     ), MessageTypeDefOf.RejectInput);
                            }
                        }
                        else if (thing.def == TorannMagicDefOf.RawMagicyte)
                        {
                            if (thing.stackCount >= 100)
                            {
                                if (verVal >= 3)
                                {
                                    thing.SplitOff(100).Destroy();
                                    newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Magicyte, null);
                                }
                                else
                                {
                                    Messages.Message("TM_CannotCreateStone".Translate(
                                                         this.CasterPawn.LabelShort,
                                                         thing.def.label
                                                         ), MessageTypeDefOf.RejectInput);
                                }
                                break;
                            }
                            else
                            {
                                Messages.Message("InsufficientMaterialForArtifact".Translate(
                                                     thing.def.label
                                                     ), MessageTypeDefOf.RejectInput);
                            }
                        }
                        else if (thing.def == ThingDefOf.Steel)
                        {
                            if (thing.stackCount >= 75)
                            {
                                if (verVal >= 1)
                                {
                                    thing.SplitOff(75).Destroy();
                                    newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Steel, null);
                                }
                                else
                                {
                                    Messages.Message("TM_CannotCreateStone".Translate(
                                                         this.CasterPawn.LabelShort,
                                                         thing.def.label
                                                         ), MessageTypeDefOf.RejectInput);
                                }
                                break;
                            }
                            else
                            {
                                Messages.Message("InsufficientMaterialForArtifact".Translate(
                                                     thing.def.label
                                                     ), MessageTypeDefOf.RejectInput);
                            }
                        }
                        else if (thing.def == ThingDefOf.MedicineHerbal)
                        {
                            if (thing.stackCount >= 10)
                            {
                                if (verVal >= 2)
                                {
                                    thing.SplitOff(10).Destroy();
                                    newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Medicine, null);
                                }
                                else
                                {
                                    Messages.Message("TM_CannotCreateStone".Translate(
                                                         this.CasterPawn.LabelShort,
                                                         thing.def.label
                                                         ), MessageTypeDefOf.RejectInput);
                                }
                                break;
                            }
                            else
                            {
                                Messages.Message("InsufficientMaterialForArtifact".Translate(
                                                     thing.def.label
                                                     ), MessageTypeDefOf.RejectInput);
                            }
                        }
                        else if (thing.def == ThingDefOf.WoodLog)
                        {
                            if (thing.stackCount >= 75)
                            {
                                if (verVal >= 2)
                                {
                                    thing.SplitOff(75).Destroy();
                                    newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Wood, null);
                                }
                                else
                                {
                                    Messages.Message("TM_CannotCreateStone".Translate(
                                                         this.CasterPawn.LabelShort,
                                                         thing.def.label
                                                         ), MessageTypeDefOf.RejectInput);
                                }
                                break;
                            }
                            else
                            {
                                Messages.Message("InsufficientMaterialForArtifact".Translate(
                                                     thing.def.label
                                                     ), MessageTypeDefOf.RejectInput);
                            }
                        }
                        else if (thing.def.defName == "LotR_Iron")
                        {
                            if (thing.stackCount >= 75)
                            {
                                if (verVal >= 1)
                                {
                                    thing.SplitOff(75).Destroy();
                                    newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Iron, null);
                                }
                                else
                                {
                                    Messages.Message("TM_CannotCreateStone".Translate(
                                                         this.CasterPawn.LabelShort,
                                                         thing.def.label
                                                         ), MessageTypeDefOf.RejectInput);
                                }
                                break;
                            }
                            else
                            {
                                Messages.Message("InsufficientMaterialForArtifact".Translate(
                                                     thing.def.label
                                                     ), MessageTypeDefOf.RejectInput);
                            }
                        }
                        else if (thing.def.defName == "ChunkSlate")
                        {
                            thing.Destroy();
                            newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Slate, null);
                            break;
                        }
                        else if (thing.def.defName == "ChunkMarble")
                        {
                            thing.Destroy();
                            newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Marble, null);
                            break;
                        }
                        else if (thing.def.defName == "ChunkSandstone")
                        {
                            thing.Destroy();
                            newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Sandstone, null);
                            break;
                        }
                        else if (thing.def.defName == "ChunkGranite")
                        {
                            thing.Destroy();
                            newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Granite, null);
                            break;
                        }
                        else if (thing.def.defName == "ChunkLimestone")
                        {
                            thing.Destroy();
                            newThing = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_Limestone, null);
                            break;
                        }
                    }
                }
            }
            else
            {
                Messages.Message("TM_InvalidTarget".Translate(
                                     this.CasterPawn.LabelShort,
                                     this.verbProps.label
                                     ), MessageTypeDefOf.RejectInput);
            }

            if (newThing != null)
            {
                if (comp.enchanterStones == null)
                {
                    comp.enchanterStones = new HashSet <Thing>();
                }
                GenPlace.TryPlaceThing(newThing, this.currentTarget.Cell, this.CasterPawn.Map, ThingPlaceMode.Near);
                comp.enchanterStones.Add(newThing);

                TM_Action.TransmutateEffects(this.currentTarget.Cell, this.CasterPawn);
            }

            this.burstShotsLeft = 0;
            return(false);
        }
Пример #17
0
        protected override bool TryCastShot()
        {
            Pawn caster = this.CasterPawn;
            CompAbilityUserMagic comp      = caster.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      ver       = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_ConsumeCorpse.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ConsumeCorpse_ver");
            MagicPowerSkill      manaRegen = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_global_regen.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_regen_pwr");

            Thing undeadThing = this.currentTarget.Thing;

            if (undeadThing is Pawn)
            {
                Pawn undead = (Pawn)undeadThing;

                bool flag = undead != null && !undead.Dead;
                if (flag)
                {
                    if (TM_Calc.IsUndead(undead))
                    {
                        if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadHD))
                        {
                            comp.Mana.CurLevel += (.225f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                            ConsumeHumanoid(undead);
                            if (ver.level > 0)
                            {
                                HealCaster(caster, 2 + ver.level, 2, (5f + ver.level) * comp.arcaneDmg);
                            }
                            undead.Destroy();
                        }
                        else if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadAnimalHD))
                        {
                            comp.Mana.CurLevel += (.18f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                            ConsumeAnimalKind(undead);
                            if (ver.level > 0)
                            {
                                HealCaster(caster, 2, 2, (3 + ver.level) * comp.arcaneDmg);
                            }
                            undead.Destroy();
                        }
                        else if (undead.def == TorannMagicDefOf.TM_SkeletonLichR)
                        {
                            comp.Mana.CurLevel += (.15f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                            TM_Action.DamageUndead(undead, Rand.Range(10, 20), caster);
                        }
                        else if (undead.def == TorannMagicDefOf.TM_GiantSkeletonR || undead.def == TorannMagicDefOf.TM_SkeletonR)
                        {
                            TM_Action.DamageUndead(undead, Rand.Range(15, 30), caster);
                        }
                        else
                        {
                            TM_Action.DamageUndead(undead, Rand.Range(10, 20), caster);
                        }
                    }
                    else
                    {
                        Messages.Message("TM_CannotUseOnLiving".Translate(), MessageTypeDefOf.RejectInput);
                    }
                }
            }


            IntVec3      target      = this.currentTarget.Cell;
            Thing        corpseThing = null;
            Corpse       corpse      = null;
            List <Thing> thingList;

            thingList = target.GetThingList(caster.Map);
            int i = 0;

            while (i < thingList.Count)
            {
                corpseThing = thingList[i];
                if (corpseThing != null)
                {
                    bool validator = corpseThing is Corpse;
                    if (validator)
                    {
                        corpse = corpseThing as Corpse;
                        Pawn undeadPawn = corpse.InnerPawn;
                        if ((undeadPawn.RaceProps.IsFlesh || TM_Calc.IsUndead(undeadPawn)) && (!TM_Calc.IsRobotPawn(undeadPawn)))
                        {
                            if (undeadPawn.RaceProps.Humanlike && !undeadPawn.RaceProps.Animal)
                            {
                                if (!corpse.IsNotFresh())
                                {
                                    comp.Mana.CurLevel += (.13f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                                    if (caster.needs != null && caster.needs.rest != null)
                                    {
                                        caster.needs.rest.CurLevel += .3f;
                                    }
                                    if (caster.needs != null && caster.needs.mood != null)
                                    {
                                        caster.needs.mood.CurLevel += .3f;
                                    }
                                    ConsumeHumanoid(corpse);
                                    if (ver.level > 0)
                                    {
                                        HealCaster(caster, 1 + ver.level, 1 + ver.level, (2f + ver.level) * comp.arcaneDmg);
                                    }
                                }
                                else
                                {
                                    comp.Mana.CurLevel += (.09f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                                    ConsumeHumanoid(corpse);
                                }
                                corpse.Destroy();
                            }
                            else if (undeadPawn.RaceProps.Animal || TM_Calc.IsUndead(undeadPawn))
                            {
                                if (!corpse.IsNotFresh())
                                {
                                    comp.Mana.CurLevel += (.09f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                                    if (caster.needs != null && caster.needs.food != null)
                                    {
                                        caster.needs.food.CurLevel += .4f;
                                    }
                                    ConsumeAnimalKind(corpse);
                                    if (ver.level > 0)
                                    {
                                        HealCaster(caster, 1, 1, (2f + ver.level) * comp.arcaneDmg);
                                    }
                                }
                                else
                                {
                                    comp.Mana.CurLevel += (.07f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                                    ConsumeAnimalKind(corpse);
                                }
                                corpse.Destroy();
                            }
                            else
                            {
                                Messages.Message("TM_CannontConsumeCorpseType".Translate(), MessageTypeDefOf.RejectInput);
                            }
                        }
                        else
                        {
                            Messages.Message("TM_InvalidCorpseType".Translate(), MessageTypeDefOf.RejectInput);
                        }
                    }
                }
                i++;
            }

            return(false);
        }
        protected new void Impact(Thing hitThing)
        {
            bool flag = hitThing == null;

            if (flag)
            {
                Pawn pawn;
                bool flag2 = (pawn = (base.Position.GetThingList(base.Map).FirstOrDefault((Thing x) => x == this.assignedTarget) as Pawn)) != null;
                if (flag2)
                {
                    hitThing = pawn;
                }
            }
            bool hasValue = this.impactDamage.HasValue;

            if (hasValue)
            {
                for (int i = 0; i < this.timesToDamage; i++)
                {
                    bool flag3 = this.damageLaunched;
                    if (flag3)
                    {
                        this.flyingThing.TakeDamage(this.impactDamage.Value);
                    }
                    else
                    {
                        hitThing.TakeDamage(this.impactDamage.Value);
                    }
                }
                bool flag4 = this.explosion;
                if (flag4)
                {
                    GenExplosion.DoExplosion(base.Position, base.Map, 0.9f, DamageDefOf.Stun, this, -1, 0, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                }
            }
            try
            {
                SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f);
                this.FireExplosion(pwrVal, verVal, base.Position, base.Map, (1.2f + (float)(verVal * .8f)));
                if (!pawn.IsColonist)
                {
                    this.FireExplosion(3, 3, base.Position, base.Map, (1.2f + (float)(3 * .8f)));
                }
                MoteMaker.ThrowSmoke(pawn.Position.ToVector3(), base.Map, (0.8f + (float)(verVal * .8f)));

                for (int i = 0; i < (2 + verVal); i++)
                {
                    expCell1 = GetNewPos(expCell1, this.origin.x <= this.DestinationCell.x, this.origin.z <= this.DestinationCell.z, false, 0, 0, xProb, 1 - xProb);
                    MoteMaker.ThrowSmoke(expCell1.ToVector3(), base.Map, 1.6f);
                    expCell2 = GetNewPos(expCell2, this.origin.x <= this.DestinationCell.x, this.origin.z <= this.DestinationCell.z, false, 0, 0, 1 - xProb, xProb);
                    MoteMaker.ThrowSmoke(expCell2.ToVector3(), base.Map, 1.6f);
                }
                for (int i = 0; i < (4 + (3 * verVal)); i++)
                {
                    CellRect cellRect = CellRect.CenteredOn(expCell1, (1 + verVal));
                    cellRect.ClipInsideMap(base.Map);
                    IntVec3 randomCell = cellRect.RandomCell;
                    this.FireExplosion(pwrVal, verVal, randomCell, base.Map, .4f);
                    cellRect   = CellRect.CenteredOn(expCell2, (1 + verVal));
                    randomCell = cellRect.RandomCell;
                    this.FireExplosion(pwrVal, verVal, randomCell, base.Map, .4f);
                }

                GenSpawn.Spawn(this.flyingThing, base.Position, base.Map);

                ModOptions.Constants.SetPawnInFlight(false);
                Pawn p = this.flyingThing as Pawn;
                TM_Action.SearchAndTaunt(p, 3f, 5, .7f);
                HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_HediffShield, .25f);
                RemoveInvul(p);
                if (p.IsColonist)
                {
                    p.drafter.Drafted = true;
                    CameraJumper.TryJumpAndSelect(p);
                }
                this.Destroy(DestroyMode.Vanish);
            }
            catch
            {
                GenSpawn.Spawn(this.flyingThing, base.Position, base.Map);
                ModOptions.Constants.SetPawnInFlight(false);
                Pawn p = this.flyingThing as Pawn;
                RemoveInvul(p);
                if (p.IsColonist)
                {
                    p.drafter.Drafted = true;
                }
                this.Destroy(DestroyMode.Vanish);
            }
        }
        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;

            try
            {
                CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>();
                //MightPowerSkill pwr = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_AntiArmor.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AntiArmor_pwr");
                verVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_AntiArmor, "TM_AntiArmor", "_ver", true);
                pwrVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_AntiArmor, "TM_AntiArmor", "_pwr", true);
                //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.ShootingAccuracyPawn, true)))
                {
                    int   dmg             = GetWeaponDmg(pawn);
                    bool  flagFleshType   = victim.RaceProps.FleshType != FleshTypeDefOf.Normal;
                    float num             = TM_Calc.GetOverallArmor(victim, StatDefOf.ArmorRating_Sharp);
                    bool  flagArmorAmount = num > 1f;
                    if (flagArmorAmount || flagFleshType)
                    {
                        MoteMaker.ThrowMicroSparks(victim.Position.ToVector3(), map);
                        TM_Action.DamageEntities(victim, null, dmg, 1.5f, this.def.projectile.damageDef, pawn);
                        MoteMaker.MakeStaticMote(victim.Position, pawn.Map, ThingDefOf.Mote_ExplosionFlash, 4f);
                        TM_Action.DamageEntities(victim, null, GetWeaponDmgMech(pawn, dmg), 1.5f, this.def.projectile.damageDef, pawn);
                        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.GetDamageAmount(1, null) / 4 * (1 + verVal), .4f, SoundDefOf.MetalHitImportant, def, this.equipmentDef, null, 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.GetDamageAmount(1, null) / 2 * (1 + verVal), .4f, SoundDefOf.MetalHitImportant, def, this.equipmentDef, null, 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));
                        }
                        DestroyArmor(victim, 4, 100);
                    }
                    else
                    {
                        TM_Action.DamageEntities(victim, null, dmg, 1.5f, this.def.projectile.damageDef, pawn);
                    }
                }
                else
                {
                    Log.Message("No valid target for anti armor shot or missed");
                }
            }
            catch (NullReferenceException)
            {
                //
            }
        }
Пример #20
0
        public override void Tick()
        {
            age++;
            Vector3 exactPosition = this.ExactPosition;

            this.ticksToImpact--;

            if (!initialized)
            {
                Initialize();
                if (this.glowing && this.glowCenter != default(IntVec3))
                {
                    this.shouldGlow = true;
                }
            }

            if (Find.TickManager.TicksGame % this.chargeFrequency == 0)
            {
                LightEnergy += ChargeAmount;
            }

            bool dFlag = false;

            if (this.pawn.DestroyedOrNull())
            {
                dFlag = true;
                this.Destroy(DestroyMode.Vanish);
            }
            else if (!this.pawn.Spawned || this.pawn.Map != this.Map || this.pawn.Map == null)
            {
                solAction = SoLAction.Limbo;
                dFlag     = true;
                this.delayCount++;
                if (delayCount >= 300)
                {
                    StopGlow();
                    this.shouldGlow = false;
                    this.Destroy(DestroyMode.Vanish);
                }
                if (this.delayCount == 10)
                {
                    MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, 1f);
                    MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, .7f);
                    MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, .4f);
                }
            }
            else if (this.shouldDismiss)
            {
                if (this.glowing)
                {
                    this.glowCenter = default(IntVec3);
                    StopGlow();
                    this.Destroy(DestroyMode.Vanish);
                }
            }

            if (!dFlag)
            {
                bool flag = !this.ExactPosition.InBounds(base.Map);
                if (flag)
                {
                    if (!this.pawn.DestroyedOrNull() && this.pawn.Spawned)
                    {
                        base.Position      = pawn.Position;
                        this.destination   = GetCasterOffset_Exact;
                        this.speed         = speed_dash;
                        this.ticksToImpact = this.StartingTicksToImpact;
                    }
                    this.ticksToImpact++;
                    base.Position = this.ExactPosition.ToIntVec3();
                }
                else if (this.solAction == SoLAction.Limbo)
                {
                    UpdateAction(this.solAction);
                }
                else
                {
                    base.Position = this.ExactPosition.ToIntVec3();
                    if (Find.TickManager.TicksGame % ActionDelay == 0)
                    {
                        DoAction();
                    }
                    bool flag2 = this.ticksToImpact <= 0;
                    if (flag2)
                    {
                        if (this.shouldDismiss)
                        {
                            bool flag3 = this.DestinationCell.InBounds(base.Map);
                            if (flag3)
                            {
                                base.Position = this.DestinationCell;
                            }
                            this.ImpactSomething();
                        }
                        else
                        {
                            UpdateSoLPower();
                            if (this.curveVariance > 0)
                            {
                                if ((this.curvePoints.Count() - 1) > this.destinationCurvePoint)
                                {
                                    this.origin = curvePoints[destinationCurvePoint];
                                    this.destinationCurvePoint++;
                                    this.destination   = this.curvePoints[this.destinationCurvePoint];
                                    this.ticksToImpact = this.StartingTicksToImpact;
                                }
                                else
                                {
                                    bool flag3 = this.DestinationCell.InBounds(base.Map);
                                    if (flag3)
                                    {
                                        base.Position = this.DestinationCell;
                                    }
                                    this.origin = this.ExactPosition;
                                    solAction   = SoLAction.Pending;
                                    UpdateAction(solAction);
                                }
                            }
                            else
                            {
                                bool flag3 = this.DestinationCell.InBounds(base.Map);
                                if (flag3)
                                {
                                    base.Position = this.DestinationCell;
                                }
                                if (this.solAction == SoLAction.ChargeAttacking)
                                {
                                    ActualLightCost(5f);
                                    int moteAngle = Mathf.RoundToInt(Vector3Utility.ToAngleFlat(this.origin - this.destination) - 90f);
                                    TM_Action.DamageEntities(this.assignedTarget, null, Rand.Range(10f, 15f) * LightPotency, TMDamageDefOf.DamageDefOf.TM_BurningLight, this.pawn);
                                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_LightShield, this.ExactPosition, this.Map, 1.5f, .1f, 0f, .2f, 0, 2f, moteAngle, moteAngle);
                                }

                                this.origin = this.destination;
                                solAction   = SoLAction.Pending;
                                UpdateAction(solAction);
                            }
                        }
                    }

                    if (this.nextMoteTick <= this.age && solAction != SoLAction.Limbo)
                    {
                        DrawMotes();
                    }
                }
            }
        }
Пример #21
0
        protected override bool TryCastShot()
        {
            Pawn caster = base.CasterPawn;

            CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();

            verVal        = comp.MagicData.MagicPowerSkill_Shapeshift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Shapeshift_ver").level;
            pwrVal        = comp.MagicData.MagicPowerSkill_Shapeshift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Shapeshift_pwr").level;
            effVal        = comp.MagicData.MagicPowerSkill_Shapeshift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Shapeshift_eff").level;
            this.duration = this.duration + (360 * effVal);
            bool flag = caster != null && !caster.Dead;

            if (flag)
            {
                CompPolymorph compPoly = caster.GetComp <CompPolymorph>();
                if (compPoly != null && compPoly.Original != null && compPoly.TicksLeft > 0)
                {
                    compPoly.Temporary = true;
                    compPoly.TicksLeft = 0;
                }
                else
                {
                    FactionDef fDef = TorannMagicDefOf.TM_SummonedFaction;
                    if (caster.Faction != null)
                    {
                        fDef = caster.Faction.def;
                    }
                    SpawnThings spawnThing = new SpawnThings();
                    spawnThing.factionDef = fDef;
                    spawnThing.spawnCount = 1;
                    spawnThing.temporary  = false;

                    spawnThing.kindDef = PawnKindDef.Named("TM_Dire_Wolf");
                    spawnThing.def     = ThingDef.Named("TM_Dire_WolfR");
                    if (spawnThing.def == null || spawnThing.kindDef == null)
                    {
                        spawnThing.def     = ThingDef.Named("Rat");
                        spawnThing.kindDef = PawnKindDef.Named("Rat");
                        Log.Message("random creature was null");
                    }

                    Pawn polymorphedPawn = TM_Action.PolymorphPawn(this.CasterPawn, caster, caster, spawnThing, caster.Position, true, duration);

                    if (this.effVal >= 3)
                    {
                        polymorphedPawn.GetComp <CompPolymorph>().Temporary = false;
                    }

                    MoteMaker.ThrowSmoke(polymorphedPawn.DrawPos, caster.Map, 2);
                    MoteMaker.ThrowMicroSparks(polymorphedPawn.DrawPos, caster.Map);
                    MoteMaker.ThrowHeatGlow(polymorphedPawn.Position, caster.Map, 2);
                    //caster.DeSpawn();

                    HealthUtility.AdjustSeverity(polymorphedPawn, HediffDef.Named("TM_ShapeshiftHD"), .5f + (1f * pwrVal));
                }

                //SoundInfo info = SoundInfo.InMap(new TargetInfo(caster.Position, caster.Map, false), MaintenanceType.None);
                //info.pitchFactor = 1.0f;
                //info.volumeFactor = 1.0f;
                //TorannMagicDefOf.TM_FastReleaseSD.PlayOneShot(info);
                //TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_PowerWave"), caster.DrawPos, caster.Map, .8f, .2f, .1f, .1f, 0, 1f, 0, Rand.Chance(.5f) ? 0 : 180);
            }
            return(true);
        }
Пример #22
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 && !TM_Calc.IsUndead(pawn);
            bool undeadFlag = 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(30.0f + (float)pwrVal * 3f); // power affects how much to heal
                                        }
                                        else
                                        {
                                            current.Heal((14.0f + (float)pwrVal * 3f) * 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--;
                                    }
                                }
                            }
                            using (IEnumerator <Hediff> enumerator1 = pawn.health.hediffSet.GetHediffsTendable().GetEnumerator())
                            {
                                while (enumerator1.MoveNext())
                                {
                                    if (num > 0)
                                    {
                                        Hediff rec1 = enumerator1.Current;
                                        if (rec1.TendableNow() && rec1.Bleeding && rec1 is Hediff_MissingPart)
                                        {
                                            Traverse.Create(root: rec1).Field(name: "isFreshInt").SetValue(false);
                                            num--;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (undeadFlag)
            {
                for (int i = 0; i < 2 + verVal; i++)
                {
                    TM_Action.DamageUndead(pawn, (8.0f + (float)pwrVal * 5f) * comp.arcaneDmg, this.CasterPawn);
                }
            }
            return(true);
        }
Пример #23
0
        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();
                this.FindTargets();
                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, 1.4f);
                                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);
                                            FleckMaker.ThrowMicroSparks(victim.DrawPos, victim.Map);
                                            MoteMaker.ThrowText(victim.DrawPos, victim.Map, "Berserk", -1);
                                        }
                                    }
                                }
                                if (victim.IsColonist && !base.CasterPawn.IsColonist)
                                {
                                    TM_Action.SpellAffectedPlayerWarning(victim);
                                }
                            }
                            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);
        }
Пример #24
0
 private void StartTaunt(Map map, LocalTargetInfo target)
 {
     this.castingCompleteTick = Find.TickManager.TicksGame + this.Props.tauntAttackDelay;
     TM_Action.PawnActionDelay(this.Pawn, this.Props.tauntAttackDelay, target, this.Pawn.meleeVerbs.TryGetMeleeVerb(this.Pawn));
     this.shouldDoTaunt = true;
 }
        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);
                    this.turret.def.building.turretBurstCooldownTime = 4.5f - (.1f * pwrVal);

                    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");
            }
            base.Impact(hitThing);
        }
Пример #26
0
        protected override bool TryCastShot()
        {
            bool continueAttack = true;

            if (this.CasterPawn.equipment.Primary == null)
            {
                Thing target = this.currentTarget.Thing;
                if (target != null && this.burstShotsLeft > 0)
                {
                    int            dmgNum  = this.GetAttackDmg(this.CasterPawn);
                    BodyPartRecord hitPart = null;
                    DamageDef      dmgType = TMDamageDefOf.DamageDefOf.TM_TigerStrike;
                    if (verVal > 0 && Rand.Chance(.1f))
                    {
                        TM_Action.DamageEntities(target, null, 4, DamageDefOf.Stun, this.CasterPawn);
                    }
                    if (verVal > 1 && Rand.Chance(.4f) && target is Pawn)
                    {
                        if (TM_Calc.IsMagicUser(target as Pawn))
                        {
                            CompAbilityUserMagic compMagic = target.TryGetComp <CompAbilityUserMagic>();
                            float manaDrain = Mathf.Clamp(compMagic.Mana.CurLevel, 0, .25f);
                            this.CasterPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD).Severity += (manaDrain * 100);
                            compMagic.Mana.CurLevel -= manaDrain;
                        }
                        else if (TM_Calc.IsMightUser(target as Pawn))
                        {
                            CompAbilityUserMight compMight = target.TryGetComp <CompAbilityUserMight>();
                            float staminaDrain             = Mathf.Clamp(compMight.Stamina.CurLevel, 0, .25f);
                            this.CasterPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD).Severity += (staminaDrain * 100);
                            compMight.Stamina.CurLevel -= staminaDrain;
                        }
                    }
                    if (verVal > 2 && Rand.Chance(.1f) && target is Pawn)
                    {
                        Pawn targetPawn = target as Pawn;
                        IEnumerable <BodyPartRecord> rangeOfParts = (targetPawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.BloodPumpingSource).Concat(
                                                                         targetPawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.BloodFiltrationSource).Concat(
                                                                             targetPawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.BreathingPathway).Concat(
                                                                                 targetPawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.SightSource)))));

                        hitPart = rangeOfParts.RandomElement();
                        dmgNum  = Mathf.RoundToInt(dmgNum * 1.4f);
                    }
                    //DamageInfo dinfo2 = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_TigerStrike, dmgNum, 0, (float)-1, this.CasterPawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown);
                    TM_Action.DamageEntities(target, hitPart, dmgNum, dmgType, this.CasterPawn);
                    Vector3 strikeEndVec = this.currentTarget.CenterVector3;
                    strikeEndVec.x += Rand.Range(-.2f, .2f);
                    strikeEndVec.z += Rand.Range(-.2f, .2f);
                    Vector3 strikeStartVec = this.CasterPawn.DrawPos;
                    strikeStartVec.z += Rand.Range(-.2f, .2f);
                    strikeStartVec.x += Rand.Range(-.2f, .2f);
                    Vector3 angle = TM_Calc.GetVector(strikeStartVec, strikeEndVec);
                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_TigerStrike, strikeStartVec, this.CasterPawn.Map, .4f, .08f, .03f, .05f, 0, 8f, (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat());
                    if (!target.DestroyedOrNull() && target is Pawn)
                    {
                        Pawn targetPawn = target as Pawn;
                        if (targetPawn.Downed || targetPawn.Dead)
                        {
                            continueAttack = false;
                        }
                    }
                    if (this.burstShotsLeft <= (10 - (4 + verVal)))
                    {
                        this.burstShotsLeft = 0;
                        continueAttack      = false;
                    }
                }
            }
            else
            {
                Messages.Message("MustBeUnarmed".Translate(
                                     this.CasterPawn.LabelCap,
                                     this.verbProps.label
                                     ), MessageTypeDefOf.RejectInput);
                this.burstShotsLeft = 0;
                return(false);
            }
            return(continueAttack);
        }
Пример #27
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)
                        {
                            IEnumerable <WorkTypeDef> allWorkTypes = WorkTypeDefsUtility.WorkTypeDefsInPriorityOrder;
                            this.hitPawnWorkSetting = new List <int>();
                            foreach (var workType in allWorkTypes)
                            {
                                hitPawnWorkSetting.Add(hitPawn.workSettings.GetPriority(workType));
                            }
                        }

                        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;
            }
        }
Пример #28
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            base.CompPostTick(ref severityAdjustment);
            bool flag = base.Pawn != null;

            if (flag)
            {
                if (!initialized)
                {
                    initialized = true;
                    this.Initialize();
                }
            }

            if (Find.TickManager.TicksGame % 16 == 0)
            {
                IEnumerable <Hediff> hdEnum = this.Pawn.health.hediffSet.GetHediffs <Hediff>();
                foreach (Hediff hd in hdEnum)
                {
                    if (hd.def.defName == "SpaceHypoxia")
                    {
                        this.Pawn.health.RemoveHediff(hd);
                        break;
                    }
                }
            }

            if (Find.TickManager.TicksGame % 6000 == 0)
            {
                TM_Action.UpdateAnimalTraining(base.Pawn);
            }
            bool flag4 = Find.TickManager.TicksGame % 600 == 0 && this.Pawn.def != TorannMagicDefOf.TM_SkeletonR && this.Pawn.def != TorannMagicDefOf.TM_GiantSkeletonR;

            if (flag4)
            {
                UpdateHediff();
                necroValid = false;
                if (base.Pawn != null && !linkedPawn.DestroyedOrNull())
                {
                    necroValid = true;
                    lichStrike = 0;
                }
                else
                {
                    lichStrike++;
                }

                if (!necroValid && lichStrike > 2)
                {
                    if (base.Pawn.Map != null)
                    {
                        TM_MoteMaker.ThrowScreamMote(base.Pawn.Position.ToVector3(), base.Pawn.Map, .8f, 255, 255, 255);
                        base.Pawn.Kill(null, null);
                    }
                    else
                    {
                        base.Pawn.Kill(null, null);
                    }
                }
                else
                {
                    List <Need> needs = base.Pawn.needs.AllNeeds;
                    for (int i = 0; i < needs.Count; i++)
                    {
                        if (needs[i].def == NeedDefOf.Food || needs[i].def == NeedDefOf.Joy || needs[i].def == NeedDefOf.Rest || needs[i].def.defName == "Mood" || needs[i].def.defName == "Beauty" ||
                            needs[i].def.defName == "Comfort" || needs[i].def.defName == "Outdoors" || needs[i].def.defName == "RoomSize")
                        {
                            needs[i].CurLevel = needs[i].MaxLevel;
                        }
                    }
                    //if (base.Pawn.needs.food != null)
                    //{
                    //    base.Pawn.needs.food.CurLevel = base.Pawn.needs.food.MaxLevel;
                    //}
                    //if (base.Pawn.needs.rest != null)
                    //{
                    //    base.Pawn.needs.rest.CurLevel = base.Pawn.needs.rest.MaxLevel;
                    //}

                    //if (base.Pawn.IsColonist)
                    //{
                    //    base.Pawn.needs.beauty.CurLevel = .5f;
                    //    base.Pawn.needs.comfort.CurLevel = .5f;
                    //    base.Pawn.needs.joy.CurLevel = .5f;
                    //    base.Pawn.needs.mood.CurLevel = .5f;
                    //    base.Pawn.needs.space.CurLevel = .5f;
                    //}
                    Pawn pawn = base.Pawn;
                    int  num  = 1;
                    int  num2 = 1;

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

                            if (flag2)
                            {
                                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 flag3 = num2 > 0;
                                    if (flag3)
                                    {
                                        bool flag5 = current.CanHealNaturally() && !current.IsPermanent();
                                        if (flag5)
                                        {
                                            current.Heal(2.0f);
                                            num--;
                                            num2--;
                                        }
                                        else
                                        {
                                            current.Heal(1.0f);
                                            num--;
                                            num2--;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffsTendable().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff rec = enumerator.Current;
                            if (rec.TendableNow()) // && !currentTendable.IsPermanent()
                            {
                                rec.Tended(1, 1);
                            }
                        }
                    }

                    using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff rec = enumerator.Current;
                            if (!rec.IsPermanent())
                            {
                                if (rec.def.defName == "Cataract" || rec.def.defName == "HearingLoss" || rec.def.defName.Contains("ToxicBuildup") || rec.def.defName == "Abasia" || rec.def.defName == "BloodRot")
                                {
                                    pawn.health.RemoveHediff(rec);
                                }
                                if ((rec.def.defName == "Blindness" || rec.def.defName.Contains("Asthma") || rec.def.defName == "Cirrhosis" || rec.def.defName == "ChemicalDamageModerate") || rec.def.defName == "Scaria")
                                {
                                    pawn.health.RemoveHediff(rec);
                                }
                                if ((rec.def.defName == "Frail" || rec.def.defName == "BadBack" || rec.def.defName.Contains("Carcinoma") || rec.def.defName == "ChemicalDamageSevere"))
                                {
                                    pawn.health.RemoveHediff(rec);
                                }
                                if ((rec.def.defName.Contains("Alzheimers") || rec.def.defName == "Dementia" || rec.def.defName.Contains("HeartArteryBlockage") || rec.def.defName == "CatatonicBreakdown"))
                                {
                                    pawn.health.RemoveHediff(rec);
                                }
                            }
                            if (rec.def.makesSickThought)
                            {
                                pawn.health.RemoveHediff(rec);
                            }
                            if (rec.def.defName.Contains("Pregnant") || rec.def.defName == "DrugOverdose")
                            {
                                pawn.health.RemoveHediff(rec);
                            }
                        }
                    }
                    CompHatcher cp_h = this.Pawn.TryGetComp <CompHatcher>();
                    if (cp_h != null)
                    {
                        Traverse.Create(root: cp_h).Field(name: "gestateProgress").SetValue(0);
                    }
                    CompMilkable cp_m = this.Pawn.TryGetComp <CompMilkable>();
                    if (cp_m != null)
                    {
                        Traverse.Create(root: cp_m).Field(name: "fullness").SetValue(0);
                    }
                }
            }
        }
Пример #29
0
        //public override bool TryMakePreToilReservations(bool errorOnFailed)
        //{
        //    if(TargetA.Thing != null)
        //    {
        //        return true;
        //    }
        //    if (pawn.Reserve(TargetA, this.job, 1, 1, null, errorOnFailed))
        //    {
        //        return true;
        //    }
        //    return false;
        //}

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

            this.verb = this.pawn.CurJob.verbToUse as Verb_UseAbility;
            if (base.TargetA.HasThing && base.TargetA.Thing is Pawn && (!pawn.Position.InHorDistOf(base.TargetA.Cell, pawn.CurJob.verbToUse.verbProps.range) || !Verb.UseAbilityProps.canCastInMelee))
            {
                //if (!base.GetActor().IsFighting() ? true : !verb.UseAbilityProps.canCastInMelee && !this.job.endIfCantShootTargetFromCurPos)
                //{
                Toil toil = Toils_Combat.GotoCastPosition(TargetIndex.A, false);
                yield return(toil);
                //toil = null;
                //}
            }
            if (this.Context == AbilityContext.Player)
            {
                Find.Targeter.targetingSource = this.verb;
            }
            Pawn targetPawn = null;

            if (this.TargetThingA != null)
            {
                targetPawn = TargetThingA as Pawn;
            }

            if (targetPawn != null)
            {
                //yield return Toils_Combat.CastVerb(TargetIndex.A, false);
                Toil combatToil = new Toil();
                //combatToil.FailOnDestroyedOrNull(TargetIndex.A);
                //combatToil.FailOnDespawnedOrNull(TargetIndex.A);
                //combatToil.FailOnDowned(TargetIndex.A);
                //CompAbilityUserMagic comp = this.pawn.GetComp<CompAbilityUserMagic>();
                //JobDriver curDriver = this.pawn.jobs.curDriver;
                combatToil.initAction = delegate
                {
                    this.verb = combatToil.actor.jobs.curJob.verbToUse as Verb_UseAbility;
                    if (verb != null && verb.verbProps != null)
                    {
                        this.duration = (int)(this.verb.verbProps.warmupTime * 60 * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false));

                        if (this.pawn.RaceProps.Humanlike)
                        {
                            //if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                            //{
                            //    RemoveMimicAbility(verb);
                            //}

                            if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.TM_Psionic))
                            {
                                PsionicEnergyCost(verb);
                            }

                            if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.DeathKnight))
                            {
                                HateCost(verb);
                            }

                            if (verb.Ability?.CooldownTicksLeft != -1)
                            {
                                this.EndJobWith(JobCondition.Incompletable);
                            }
                        }


                        LocalTargetInfo target = combatToil.actor.jobs.curJob.GetTarget(TargetIndex.A);
                        if (target != null)
                        {
                            verb.TryStartCastOn(target, false, true);
                        }
                        using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                Hediff rec = enumerator.Current;
                                if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III)
                                {
                                    this.pawn.health.RemoveHediff(rec);
                                }
                            }
                        }
                    }
                    else
                    {
                        this.EndJobWith(JobCondition.Errored);
                    }
                };
                combatToil.tickAction = delegate
                {
                    if (this.pawn.Downed)
                    {
                        EndJobWith(JobCondition.InterruptForced);
                    }
                    if (Find.TickManager.TicksGame % 12 == 0)
                    {
                        if (verb.Ability.Def == TorannMagicDefOf.TM_Artifact_TraitThief || verb.Ability.Def == TorannMagicDefOf.TM_Artifact_TraitInfuse)
                        {
                            float direction = Rand.Range(0, 360);
                            TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi_Arcane"), pawn.DrawPos, pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction);
                        }
                        else
                        {
                            TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f));
                        }
                    }

                    this.duration--;
                    if (!wildCheck && this.duration <= 6)
                    {
                        wildCheck = true;
                        if (this.pawn.story != null && this.pawn.story.traits != null && this.pawn.story.traits.HasTrait(TorannMagicDefOf.ChaosMage) && Rand.Chance(.1f))
                        {
                            verb.Ability.PostAbilityAttempt();
                            TM_Action.DoWildSurge(this.pawn, this.pawn.GetComp <CompAbilityUserMagic>(), (MagicAbility)verb.Ability, (TMAbilityDef)verb.Ability.Def, TargetA);
                            EndJobWith(JobCondition.InterruptForced);
                        }
                    }
                };
                combatToil.AddFinishAction(delegate
                {
                    if (this.duration <= 5 && !this.pawn.DestroyedOrNull() && !this.pawn.Dead && !this.pawn.Downed)
                    {
                        //ShootLine shootLine;
                        //bool validTarg = verb.TryFindShootLineFromTo(pawn.Position, TargetLocA, out shootLine);
                        //bool inRange = (pawn.Position - TargetLocA).LengthHorizontal < verb.verbProps.range;
                        //if (inRange && validTarg)
                        //{
                        TMAbilityDef tmad = (TMAbilityDef)verb.Ability.Def;
                        if (tmad != null && tmad.relationsAdjustment != 0 && targetPawn.Faction != null && targetPawn.Faction != this.pawn.Faction && !targetPawn.Faction.HostileTo(this.pawn.Faction))
                        {
                            targetPawn.Faction.TryAffectGoodwillWith(this.pawn.Faction, tmad.relationsAdjustment, true, false, null, null);
                        }
                        verb.Ability.PostAbilityAttempt();
                        this.pawn.ClearReservationsForJob(this.job);
                        //}
                    }
                });
                //if (combatToil.actor.CurJob != this.job)
                //{
                //    curDriver.ReadyForNextToil();
                //}
                combatToil.defaultCompleteMode = ToilCompleteMode.FinishedBusy;
                this.pawn.ClearReservationsForJob(this.job);
                yield return(combatToil);
                //Toil toil2 = new Toil()
                //{
                //    initAction = () =>
                //    {
                //        if (curJob.UseAbilityProps.isViolent)
                //        {
                //            JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn);
                //        }
                //    },
                //    defaultCompleteMode = ToilCompleteMode.Instant
                //};
                //yield return toil2;
                //Toil toil1 = new Toil()
                //{
                //    initAction = () => curJob.Ability.PostAbilityAttempt(),
                //    defaultCompleteMode = ToilCompleteMode.Instant
                //};
                //yield return toil1;
            }
            else
            {
                if (verb != null && verb.verbProps != null && (pawn.Position - TargetLocA).LengthHorizontal < verb.verbProps.range)
                {
                    if (TargetLocA.IsValid && TargetLocA.InBounds(pawn.Map) && !TargetLocA.Fogged(pawn.Map))  //&& TargetLocA.Walkable(pawn.Map)
                    {
                        ShootLine shootLine;
                        bool      validTarg = verb.TryFindShootLineFromTo(pawn.Position, TargetLocA, out shootLine);
                        if (validTarg)
                        {
                            //yield return Toils_Combat.CastVerb(TargetIndex.A, false);
                            //Toil toil2 = new Toil()
                            //{
                            //    initAction = () =>
                            //    {
                            //        if (curJob.UseAbilityProps.isViolent)
                            //        {
                            //            JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn);
                            //        }

                            //    },
                            //    defaultCompleteMode = ToilCompleteMode.Instant
                            //};
                            //yield return toil2;
                            this.duration = (int)(verb.verbProps.warmupTime * 60 * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false));
                            Toil toil = new Toil();
                            toil.initAction = delegate
                            {
                                this.verb = toil.actor.jobs.curJob.verbToUse as Verb_UseAbility;
                                if (this.pawn.RaceProps.Humanlike)
                                {
                                    //if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                                    //{
                                    //    RemoveMimicAbility(verb);
                                    //}

                                    if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.TM_Psionic))
                                    {
                                        PsionicEnergyCost(verb);
                                    }

                                    if (verb.Ability?.CooldownTicksLeft != -1)
                                    {
                                        this.EndJobWith(JobCondition.Incompletable);
                                    }
                                }
                                LocalTargetInfo target            = toil.actor.jobs.curJob.GetTarget(TargetIndex.A); //TargetLocA;  //
                                bool            canFreeIntercept2 = false;
                                if (target != null)
                                {
                                    verb.TryStartCastOn(target, false, canFreeIntercept2);
                                }
                                using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                                {
                                    while (enumerator.MoveNext())
                                    {
                                        Hediff rec = enumerator.Current;
                                        if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III)
                                        {
                                            this.pawn.health.RemoveHediff(rec);
                                        }
                                    }
                                }
                            };
                            toil.tickAction = delegate
                            {
                                if (Find.TickManager.TicksGame % 12 == 0)
                                {
                                    TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f));
                                }
                                this.duration--;
                                if (!wildCheck && this.duration <= 6)
                                {
                                    wildCheck = true;
                                    if (this.pawn.story != null && this.pawn.story.traits != null && this.pawn.story.traits.HasTrait(TorannMagicDefOf.ChaosMage) && Rand.Chance(.1f))
                                    {
                                        bool completeJob = TM_Action.DoWildSurge(this.pawn, this.pawn.GetComp <CompAbilityUserMagic>(), (MagicAbility)verb.Ability, (TMAbilityDef)verb.Ability.Def, TargetA);
                                        if (!completeJob)
                                        {
                                            verb.Ability.PostAbilityAttempt();
                                            EndJobWith(JobCondition.InterruptForced);
                                        }
                                    }
                                }
                            };
                            toil.AddFinishAction(delegate
                            {
                                if (this.duration <= 5 && !this.pawn.DestroyedOrNull() && !this.pawn.Dead && !this.pawn.Downed)
                                {
                                    verb.Ability.PostAbilityAttempt();
                                }
                                this.pawn.ClearReservationsForJob(this.job);
                            });
                            toil.defaultCompleteMode = ToilCompleteMode.FinishedBusy;
                            yield return(toil);

                            //Toil toil1 = new Toil()
                            //{
                            //    initAction = () => curJob.Ability.PostAbilityAttempt(),
                            //    defaultCompleteMode = ToilCompleteMode.Instant
                            //};
                            //yield return toil1;
                        }
                        else
                        {
                            //No LoS
                            if (pawn.IsColonist)
                            {
                                Messages.Message("TM_OutOfLOS".Translate(
                                                     pawn.LabelShort
                                                     ), MessageTypeDefOf.RejectInput);
                            }
                            pawn.ClearAllReservations(false);
                        }
                    }
                    else
                    {
                        pawn.ClearAllReservations(false);
                    }
                }
                else
                {
                    if (pawn.IsColonist)
                    {
                        //out of range
                        Messages.Message("TM_OutOfRange".Translate(), MessageTypeDefOf.RejectInput);
                    }
                }
            }
        }
Пример #30
0
 public void ApplyShield(Pawn pawn)
 {
     ApplyHediffs(pawn);
     FleckMaker.ThrowLightningGlow(pawn.DrawPos, pawn.Map, 1.5f);
     TM_Action.DisplayShield(pawn, 5f);
 }