public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            Need_ForcePool forcePool = pawn.needs.TryGetNeed<Need_ForcePool>();

            if (forcePool == null)
            {
                return ThinkResult.NoJob;
            }

            CompForceUser compForce = pawn.TryGetComp<CompForceUser>();
            if (compForce == null)
            {
                return ThinkResult.NoJob;
            }

            Trait sensitiveTrait = pawn.story.traits.GetTrait(ProjectJediDefOf.PJ_ForceSensitive);
            if (sensitiveTrait != null)
            {
                return ThinkResult.NoJob;
            }

            if (compForce.ForceData.TicksUntilMeditate > Find.TickManager.TicksAbs)
            {
                return ThinkResult.NoJob;
            }

            if (forcePool.CurCategory > ForcePoolCategory.Strong)
            {
                return ThinkResult.NoJob;
            }

            return base.TryIssueJobPackage(pawn, jobParams);
        }
Example #2
0
        public override float GetPriority(Pawn pawn)
        {
            //Log.Message("Priority");
            Need_ForcePool forcePool = pawn.needs.TryGetNeed <Need_ForcePool>();

            if (forcePool == null)
            {
                return(0f);
            }
            CompForceUser compForce = pawn.TryGetComp <CompForceUser>();

            if (compForce.canMeditateTicks > Find.TickManager.TicksAbs)
            {
                return(0f);
            }
            if (forcePool.CurCategory > ForcePoolCategory.Steady)
            {
                return(0f);
            }
            if (forcePool.CurLevelPercentage < 0.5)
            {
                return(9.5f);
            }
            return(0f);
        }
Example #3
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell));

            yield return(new Toil
            {
                initAction = delegate
                {
                    this.faceDir = ((!this.CurJob.def.faceDir.IsValid) ? Rot4.Random : this.CurJob.def.faceDir);
                },
                tickAction = delegate
                {
                    this.pawn.Drawer.rotator.FaceCell(this.pawn.Position + this.faceDir.FacingCell);
                    this.pawn.GainComfortFromCellIfPossible();
                    if (this.pawn.TryGetComp <CompForceUser>() != null)
                    {
                        CompForceUser forceComp = this.pawn.GetComp <CompForceUser>();
                        if (Find.TickManager.TicksGame % 60 == 0)
                        {
                            forceComp.ForceUserXP++;
                        }
                        Need_ForcePool poolForce = this.pawn.needs.TryGetNeed <Need_ForcePool>();
                        if (poolForce != null)
                        {
                            if (poolForce.CurLevel < 0.99f)
                            {
                                poolForce.CurLevel += 0.0005f;
                            }
                            else
                            {
                                this.EndJobWith(JobCondition.Succeeded);
                            }
                        }
                    }
                    //JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, 1f);
                },
                defaultCompleteMode = ToilCompleteMode.Delay,
                defaultDuration = 1800
            });
        }
Example #4
0
        public override DamageResult Apply(DamageInfo dinfo, Thing thing)
        {
            DamageResult result = DamageResult.MakeNew();
            result.totalDamageDealt = 0f;
            if (thing is ProjectJedi.PawnGhost)
            {
                Messages.Message("PJ_ForceGhostResisted".Translate(), MessageTypeDefOf.NegativeEvent);
                return result;
            }

            Pawn pawn = thing as Pawn;
            if (pawn != null)
            {
                if (dinfo.Instigator != null)
                {
                    Pawn caster = dinfo.Instigator as Pawn;
                    if (caster != null)
                    {
                        CompForceUser victimForce = pawn.GetComp<CompForceUser>();
                        int maxInjuries = 2;
                        int maxHeals = 0;
                        int maxPoolDamage = 30;

                        if (victimForce != null)
                        {
                            if (victimForce.IsForceUser)
                            {
                                Need_ForcePool victimForcePool = victimForce.ForcePool;
                                if (victimForcePool != null)
                                {
                                    if (victimForcePool.CurLevel > 0.1f)
                                    {
                                        //Turn 0.01f into 1, or 1.0 into 100.
                                        int victimForceInt = System.Convert.ToInt32(victimForcePool.CurLevel * 100);
                                       //Log.Message("Victim Force Pool = " + victimForceInt.ToString());
                                        Need_ForcePool casterPool = caster.needs.TryGetNeed<Need_ForcePool>();
                                        if (casterPool != null)
                                        {
                                            Messages.Message("PJ_ForceDrainOne".Translate(new object[]
                                                {
                                                    caster.Label,
                                                    pawn.Label
                                                }), MessageTypeDefOf.SilentInput);
                                            for (int i = 0; i < Mathf.Min(victimForceInt, maxPoolDamage); i++)
                                            {
                                                if (casterPool.CurLevel >= 0.99f) break;
                                                casterPool.CurLevel += 0.01f;
                                                victimForcePool.CurLevel -= 0.05f;
                                            }
                                            return result;
                                        }
                                    }
                                }
                            }
                        }

                        Messages.Message("PJ_ForceDrainTwo".Translate(new object[]
                            {
                               caster.Label,
                               pawn.Label
                            }), MessageTypeDefOf.SilentInput);

                        foreach (BodyPartRecord rec in pawn.health.hediffSet.GetNotMissingParts().InRandomOrder<BodyPartRecord>())
                        {
                            if (maxInjuries > 0)
                            {
                                pawn.TakeDamage(new DamageInfo(DamageDefOf.Burn, new IntRange(5, 10).RandomInRange, -1, caster, rec));
                                maxInjuries--;
                                maxHeals++;
                            }
                        }

                        int maxInjuriesPerBodypart;
                        foreach (BodyPartRecord rec in caster.health.hediffSet.GetInjuredParts())
                        {
                            if (maxHeals > 0)
                            {
                                maxInjuriesPerBodypart = 2;
                                foreach (Hediff_Injury current in from injury in caster.health.hediffSet.GetHediffs<Hediff_Injury>() where injury.Part == rec select injury)
                                {
                                    if (maxInjuriesPerBodypart > 0)
                                    {
                                        if (current.CanHealNaturally() && !current.IsOld()) // basically check for scars and old wounds
                                        {
                                            current.Heal((int)current.Severity + 1);
                                            maxHeals--;
                                            maxInjuriesPerBodypart--;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

            }

            return result;
        }