Пример #1
0
        public override void Tick()
        {
            if (!initialized)
            {
                this.nextSearch = Find.TickManager.TicksGame + Rand.Range(30, 40);
                this.range      = 20 + pwrVal;
                initialized     = true;
            }
            else if (Find.TickManager.TicksGame >= this.nextSearch)
            {
                this.nextSearch = Find.TickManager.TicksGame + Rand.Range(60, 70);

                target = TM_Calc.FindNearbyInjuredPawn(this.Position, this.Map, this.Faction, (int)range, 0f, true);
                if (target != null)
                {
                    TM_Action.DoAction_HealPawn(null, target, 1, Rand.Range(1f, 3f) * arcanePwr * (1f + (.04f * pwrVal)));
                    Vector3 totemPos = this.DrawPos;
                    totemPos.z += 1.3f;
                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Healing_Small, totemPos, this.Map, 1.5f, .6f, .1f, 1f, 0, 0, 0, 0);
                    for (int i = 0; i < 2; i++)
                    {
                        Vector3 pos = target.DrawPos;
                        pos.x += Rand.Range(-.3f, .3f);
                        pos.z += Rand.Range(-.25f, .5f);
                        TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Healing_Small, pos, this.Map, (.2f * (1f + (i * .5f))), Rand.Range(.05f, .15f), Rand.Range(.05f, .25f), Rand.Range(.1f, .3f), 0, 0, 0, 0);
                    }
                }
            }
            base.Tick();
        }
Пример #2
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(.9f, 1.5f), .05f, 0f, .1f, 0, 0f, 0f, 0f);
                    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(.6f, 1.1f), .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 - .0006f * 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 + (Rand.Range(8, 12) + (.5f * EffVal))), repairBuilding.MaxHitPoints);
                            comp.Mana.CurLevel      -= (.03f - .0006f * EffVal);
                            comp.MagicUserXP        += Rand.Range(4, 5);
                            this.ticksBitWorking     = 8;
                            this.moteLoc             = repairBuilding.DrawPos;
                        }
                        Pawn damagedRobot = damagedThing as Pawn;
                        if (damagedRobot != null)
                        {
                            TM_Action.DoAction_HealPawn(this.Pawn, damagedRobot, 1, (4 + .4f * EffVal));
                            comp.Mana.CurLevel  -= (.03f - .0006f * EffVal);
                            comp.MagicUserXP    += Rand.Range(4, 6);
                            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 + (25 + (2 * 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, (8 + .4f * 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;
                            float acc            = 15f + (PwrVal / 3f);
                            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 += Mathf.RoundToInt(Rand.Range(-targetDistance / acc, targetDistance / acc)); //grenades were 8
                                rndTargetCell.z += Mathf.RoundToInt(Rand.Range(-targetDistance / acc, targetDistance / acc));
                                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.Gas_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.Gas_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);
                                //}
                                Projectile p = (Projectile)(GenSpawn.Spawn(ThingDef.Named("Projectile_TM_BitTechLaser"), this.Pawn.Position, this.Pawn.Map, WipeMode.Vanish));
                                //float launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, ltiTarget.Cell)).ToAngleFlat();

                                SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None);
                                info.pitchFactor  = 1.5f;
                                info.volumeFactor = .9f;
                                SoundDef.Named("Shot_ChargeBlaster").PlayOneShot(info);

                                if (rndTargetCell == targetThing.Position)
                                {
                                    p.Launch(this.Pawn, comp.bitPosition, targetThing, targetThing, ProjectileHitFlags.IntendedTarget, false, null, null);
                                }
                                else
                                {
                                    p.Launch(this.Pawn, comp.bitPosition, ltiTarget, targetThing, ProjectileHitFlags.All, false, null, null);
                                }
                                this.nextBitGrenade = 3 + Find.TickManager.TicksGame;
                                this.bitGrenadeCount--;
                                if (this.bitGrenadeCount == 0)
                                {
                                    this.bitGrenadeCount = 3 + (int)((this.PwrVal) / 5);
                                    this.nextBitGrenade  = Find.TickManager.TicksGame + (180 - 3 * PwrVal);
                                    comp.Mana.CurLevel  -= (.06f - (.001f * this.PwrVal));
                                    comp.MagicUserXP    += Rand.Range(8, 12);
                                }
                            }
                            else if (this.nextBitGrenade < Find.TickManager.TicksGame && this.bitGrenadeCount <= 0)
                            {
                                this.bitGrenadeCount = 3 + (int)((this.PwrVal) / 5);
                                this.nextBitGrenade  = Find.TickManager.TicksGame + (180 - 3 * PwrVal);
                            }
                        }
                    }
                }
            }
        }
Пример #3
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);
        }
        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--;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil gotoSpot = new Toil()
            {
                initAction = () =>
                {
                    pawn.pather.StartPath(TargetLocA, PathEndMode.OnCell);
                },
                defaultCompleteMode = ToilCompleteMode.PatherArrival
            };

            yield return(gotoSpot);

            Toil doFor = new Toil()
            {
                initAction = () =>
                {
                    chiHD = this.pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD, false);
                    CompAbilityUserMight comp = this.pawn.GetComp <CompAbilityUserMight>();
                    if (comp != null && chiHD != null)
                    {
                        effVal = comp.MightData.MightPowerSkill_Meditate.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Meditate_eff").level;
                        pwrVal = comp.MightData.MightPowerSkill_Meditate.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Meditate_pwr").level;
                        verVal = comp.MightData.MightPowerSkill_Meditate.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Meditate_ver").level;
                    }
                    else
                    {
                        Log.Warning("No Chi Hediff or Might Comp found.");
                        this.EndJobWith(JobCondition.Errored);
                    }
                    if (this.age > this.durationTicks)
                    {
                        this.EndJobWith(JobCondition.InterruptForced);
                    }
                },
                tickAction = () =>
                {
                    if (Find.TickManager.TicksGame % 12 == 0)
                    {
                        Vector3 rndPos = this.pawn.DrawPos;
                        rndPos.x += (Rand.Range(-.5f, .5f));
                        rndPos.z += Rand.Range(-.4f, .6f);
                        float   direction = (this.pawn.DrawPos - rndPos).ToAngleFlat();
                        Vector3 startPos  = rndPos;
                        TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Chi_Grayscale, startPos, this.pawn.Map, Rand.Range(.1f, .22f), 0.2f, .3f, .2f, 30, .2f * (rndPos - this.pawn.DrawPos).MagnitudeHorizontal(), direction, direction);
                    }
                    if (Find.TickManager.TicksGame % 60 == 0)
                    {
                        List <Hediff> afflictionList = TM_Calc.GetPawnAfflictions(this.pawn);
                        List <Hediff> addictionList  = TM_Calc.GetPawnAddictions(this.pawn);

                        if (chiHD != null)
                        {
                            if (chiHD.Severity > 1)
                            {
                                chiMultiplier = 5;
                            }
                            else
                            {
                                chiMultiplier = 1;
                            }
                        }
                        else
                        {
                            chiHD = this.pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD, false);
                            if (chiHD == null)
                            {
                                Log.Warning("No chi found on pawn performing meditate job");
                                this.EndJobWith(JobCondition.InterruptForced);
                            }
                        }
                        if (TM_Calc.IsPawnInjured(this.pawn, 0))
                        {
                            TM_Action.DoAction_HealPawn(this.pawn, this.pawn, 1, Rand.Range(.25f, .4f) * chiMultiplier * (1 + (.1f * pwrVal)));
                            chiHD.Severity -= 1f;
                        }
                        else if (afflictionList != null && afflictionList.Count > 0)
                        {
                            Hediff hediff = afflictionList.RandomElement();
                            hediff.Severity -= .001f * chiMultiplier * (1 + (.1f * pwrVal));
                            if (hediff.Severity <= 0)
                            {
                                this.pawn.health.RemoveHediff(hediff);
                            }
                            HediffComp_Disappears hediffTicks = hediff.TryGetComp <HediffComp_Disappears>();
                            if (hediffTicks != null)
                            {
                                int ticksToDisappear = Traverse.Create(root: hediffTicks).Field(name: "ticksToDisappear").GetValue <int>();
                                ticksToDisappear -= Mathf.RoundToInt(10000 * (chiMultiplier * (1 + (.1f * pwrVal))));
                                Traverse.Create(root: hediffTicks).Field(name: "ticksToDisappear").SetValue(ticksToDisappear);
                            }
                            chiHD.Severity -= 1f;
                        }
                        else if (addictionList != null && addictionList.Count > 0)
                        {
                            Hediff hediff = addictionList.RandomElement();
                            hediff.Severity -= .0015f * chiMultiplier * (1 + (.1f * pwrVal));
                            if (hediff.Severity <= 0)
                            {
                                this.pawn.health.RemoveHediff(hediff);
                            }
                            chiHD.Severity -= 1f;
                        }
                        else if (BreakRiskAlertUtility.PawnsAtRiskMinor.Contains(this.pawn) || BreakRiskAlertUtility.PawnsAtRiskMajor.Contains(this.pawn) || BreakRiskAlertUtility.PawnsAtRiskExtreme.Contains(this.pawn))
                        {
                            this.pawn.needs.mood.CurLevel += .004f * chiMultiplier * (1 + (.1f * verVal));
                            chiHD.Severity -= 1f;
                        }
                        else
                        {
                            chiHD.Severity += (Rand.Range(.2f, .3f) * (1 + (effVal * .1f)));
                            try
                            {
                                this.pawn.needs.rest.CurLevel += (.003f * (1 + (.1f * verVal)));
                                this.pawn.needs.joy.CurLevel  += (.004f * (1 + (.1f * verVal)));
                                this.pawn.needs.mood.CurLevel += .001f * (1 + (.1f * verVal));
                            }
                            catch (NullReferenceException ex)
                            {
                                //ex
                            }
                        }
                    }
                    if (chiHD != null)
                    {
                        HediffComp_Chi chiComp = chiHD.TryGetComp <HediffComp_Chi>();
                        if (chiComp != null && chiHD.Severity >= chiComp.maxSev)
                        {
                            this.age = durationTicks;
                        }
                    }
                    if (age >= durationTicks)
                    {
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                    age++;
                },
                defaultCompleteMode = ToilCompleteMode.Never
            };

            doFor.defaultDuration = this.durationTicks;
            doFor.WithProgressBar(TargetIndex.A, delegate
            {
                if (this.pawn.DestroyedOrNull() || this.pawn.Dead || this.pawn.Downed)
                {
                    return(1f);
                }
                return(1f - (float)doFor.actor.jobs.curDriver.ticksLeftThisToil / this.durationTicks);
            }, false, 0f);
            yield return(doFor);
        }
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);
            if (!this.initialized)
            {
                this.caster = this.launcher as Pawn;
                CompAbilityUserMight comp = caster.GetComp <CompAbilityUserMight>();
                //pwrVal = caster.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_GraveBlade.FirstOrDefault((MightPowerSkill x) => x.label == "TM_GraveBlade_pwr").level;
                //verVal = caster.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_GraveBlade.FirstOrDefault((MightPowerSkill x) => x.label == "TM_GraveBlade_ver").level;
                verVal = TM_Calc.GetMightSkillLevel(caster, comp.MightData.MightPowerSkill_GraveBlade, "TM_GraveBlade", "_ver", true);
                pwrVal = TM_Calc.GetMightSkillLevel(caster, comp.MightData.MightPowerSkill_GraveBlade, "TM_GraveBlade", "_pwr", true);
                //ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                this.arcaneDmg = comp.mightPwr;
                //if (settingsRef.AIHardMode && !caster.IsColonist)
                //{
                //    pwrVal = 3;
                //    verVal = 3;
                //}
                this.radius        = this.def.projectile.explosionRadius;
                this.duration      = 10 + (int)(this.radius * 20);
                this.innerCellList = GenRadial.RadialCellsAround(base.Position, this.radius, true).ToList();
                this.ringCellList  = GenRadial.RadialCellsAround(base.Position, this.radius + 1, false).Except(innerCellList).ToList();
                this.effectIndex2  = ringCellList.Count / 2;
                this.initialized   = true;
            }

            if (this.Map != null)
            {
                if (Find.TickManager.TicksGame % this.effectDelay == 0)
                {
                    Vector3 drawIndex1 = this.ringCellList[effectIndex1].ToVector3Shifted();
                    drawIndex1.x += Rand.Range(-.35f, .35f);
                    drawIndex1.z += Rand.Range(-.35f, .35f);
                    Vector3 drawIndex2 = this.ringCellList[effectIndex2].ToVector3Shifted();
                    drawIndex2.x += Rand.Range(-.35f, .35f);
                    drawIndex2.z += Rand.Range(-.35f, .35f);
                    TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SpiritFlame"), drawIndex1, this.Map, Rand.Range(.4f, .8f), .1f, 0, .6f, 0, Rand.Range(.4f, 1f), Rand.Range(-20, 20), Rand.Range(-20, 20));
                    TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SpiritFlame"), drawIndex2, this.Map, Rand.Range(.4f, .8f), .1f, 0, .6f, 0, Rand.Range(.4f, 1f), Rand.Range(-20, 20), Rand.Range(-20, 20));
                    this.effectIndex1++;
                    this.effectIndex2++;
                    if (this.effectIndex1 >= ringCellList.Count)
                    {
                        this.effectIndex1 = 0;
                    }
                    if (this.effectIndex2 >= ringCellList.Count)
                    {
                        this.effectIndex2 = 0;
                    }
                }
                if (Find.TickManager.TicksGame % this.strikeDelay == 0 && !this.caster.DestroyedOrNull())
                {
                    IntVec3 centerCell = innerCellList.RandomElement();
                    IEnumerable <IntVec3> targetCells = GenRadial.RadialCellsAround(centerCell, 2f, true);
                    foreach (var target in targetCells)
                    {
                        IntVec3 curCell = target;
                        Pawn    victim  = curCell.GetFirstPawn(this.Map);
                        if (victim != null && !victim.Destroyed && !victim.Dead && victim != this.caster)
                        {
                            TM_Action.DamageEntities(victim, null, (Rand.Range(10, 16) + (2 * pwrVal)) * this.arcaneDmg, TMDamageDefOf.DamageDefOf.TM_Spirit, this.launcher);
                            if (!this.caster.DestroyedOrNull() && !this.caster.Dead && Rand.Chance(verVal))
                            {
                                TM_Action.DoAction_HealPawn(this.caster, this.caster, 1, (Rand.Range(6, 10) + (2 * verVal)) * this.arcaneDmg);
                                TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SpiritRetaliation"), this.caster.DrawPos, this.caster.Map, Rand.Range(1f, 1.2f), Rand.Range(.1f, .15f), 0, Rand.Range(.1f, .2f), -600, 0, 0, Rand.Range(0, 360));
                                TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SpiritRetaliation"), this.caster.DrawPos, this.caster.Map, Rand.Range(1f, 1.2f), Rand.Range(.1f, .15f), 0, Rand.Range(.1f, .2f), 600, 0, 0, Rand.Range(0, 360));
                            }
                            if (Rand.Chance(verVal))
                            {
                                if (!victim.IsWildMan() && victim.RaceProps.Humanlike && victim.mindState != null && !victim.InMentalState)
                                {
                                    try
                                    {
                                        Job job = new Job(JobDefOf.FleeAndCower);
                                        //victim.mindState.mentalStateHandler.TryStartMentalState(TorannMagicDefOf.TM_PanicFlee);
                                    }
                                    catch (NullReferenceException)
                                    {
                                    }
                                }
                            }
                        }
                    }
                    TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_GraveBlade"), centerCell.ToVector3Shifted(), this.Map, Rand.Range(1f, 1.6f), .15f, .1f, .2f, 0, Rand.Range(4f, 6f), 0, 0);
                }
            }
        }
Пример #7
0
        protected override bool TryCastShot()
        {
            bool result = false;
            bool flag   = false;

            if (this.currentTarget != null && base.CasterPawn != null)
            {
                IntVec3 arg_29_0 = this.currentTarget.Cell;
                Vector3 vector   = this.currentTarget.CenterVector3;
                flag = this.currentTarget.Cell.IsValid && vector.InBounds(base.CasterPawn.Map) && this.currentTarget.Thing != null && this.currentTarget.Thing is Pawn;
            }

            if (flag)
            {
                Pawn    p                 = this.CasterPawn;
                Pawn    targetPawn        = this.currentTarget.Thing as Pawn;
                Map     map               = this.CasterPawn.Map;
                IntVec3 cell              = this.CasterPawn.Position;
                bool    draftFlag         = this.CasterPawn.Drafted;
                CompAbilityUserMagic comp = p.TryGetComp <CompAbilityUserMagic>();
                if (comp != null)
                {
                    pwrVal = comp.MagicData.MagicPowerSkill_ShadowWalk.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ShadowWalk_pwr").level;
                    verVal = comp.MagicData.MagicPowerSkill_ShadowWalk.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ShadowWalk_ver").level;
                }
                try
                {
                    if (this.CasterPawn.IsColonist)
                    {
                        ModOptions.Constants.SetPawnInFlight(true);
                        this.CasterPawn.DeSpawn();
                        GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                        p.drafter.Drafted = draftFlag;
                        CameraJumper.TryJumpAndSelect(p);
                        ModOptions.Constants.SetPawnInFlight(false);
                    }
                    else
                    {
                        ModOptions.Constants.SetPawnInFlight(true);
                        this.CasterPawn.DeSpawn();
                        GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                        ModOptions.Constants.SetPawnInFlight(false);
                    }
                    if (pwrVal > 0)
                    {
                        HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_ShadowCloakHD, .5f);
                        HediffComp_Disappears hdComp = p.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ShadowCloakHD).TryGetComp <HediffComp_Disappears>();
                        if (hdComp != null)
                        {
                            hdComp.ticksToDisappear = 60 + (60 * pwrVal);
                        }
                    }
                    if (verVal > 0)
                    {
                        TM_Action.DoAction_HealPawn(p, p, 1 + verVal, 6 + verVal);
                        if (targetPawn.Faction != null && targetPawn.Faction == p.Faction)
                        {
                            if (verVal > 1)
                            {
                                TM_Action.DoAction_HealPawn(p, targetPawn, verVal, 4 + verVal);
                            }
                            if (verVal > 2)
                            {
                                HealthUtility.AdjustSeverity(targetPawn, TorannMagicDefOf.TM_ShadowCloakHD, .5f);
                                HediffComp_Disappears hdComp = targetPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ShadowCloakHD).TryGetComp <HediffComp_Disappears>();
                                if (hdComp != null)
                                {
                                    hdComp.ticksToDisappear = 180;
                                }
                                ThingDef fog = TorannMagicDefOf.Fog_Shadows;
                                fog.gas.expireSeconds.min = 4;
                                fog.gas.expireSeconds.max = 4;
                                GenExplosion.DoExplosion(p.Position, p.Map, 2, TMDamageDefOf.DamageDefOf.TM_Toxin, caster, 0, 0, TMDamageDefOf.DamageDefOf.TM_Toxin.soundExplosion, null, null, null, fog, 1f, 1, false, null, 0f, 0, 0.0f, false);
                            }
                        }
                    }
                    for (int i = 0; i < 6; i++)
                    {
                        Vector3 rndPos = p.DrawPos;
                        rndPos.x += Rand.Range(-1.5f, 1.5f);
                        rndPos.z += Rand.Range(-1.5f, 1.5f);
                        TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_ShadowCloud, rndPos, p.Map, Rand.Range(.8f, 1.2f), .6f, .05f, Rand.Range(.7f, 1f), Rand.Range(-40, 40), Rand.Range(0, 1f), Rand.Range(0, 360), Rand.Range(0, 360));
                    }
                }
                catch
                {
                    if (!this.CasterPawn.Spawned)
                    {
                        GenSpawn.Spawn(p, cell, map);
                        Log.Message("Exception occured when trying to blink - recovered pawn at position ability was used from.");
                    }
                }

                result = true;
            }
            else
            {
                Messages.Message("InvalidTargetLocation".Translate(), MessageTypeDefOf.RejectInput);
            }
            this.burstShotsLeft = 0;
            return(result);
        }