public bool CanOverpowerMind(Pawn caster, Thing hitThing)
 {
     if (hitThing is Pawn)
     {
         Pawn             target      = hitThing as Pawn;
         PsykerPowerLevel casterPower = caster.needs.TryGetNeed <Need_Soul>().PsykerPowerLevel;
         PsykerPowerLevel targetPower = target.needs.TryGetNeed <Need_Soul>().PsykerPowerLevel;
         if (casterPower >= targetPower && targetPower != PsykerPowerLevel.Omega || target.Faction == Faction.OfPlayer)
         {
             if (!target.Faction.HostileTo(Faction.OfPlayer) && target.Faction != Faction.OfPlayer)
             {
                 target.Faction.AffectGoodwillWith(Faction.OfPlayer, -10);
             }
             return(true);
         }
         else
         {
             if (!target.Faction.HostileTo(Faction.OfPlayer))
             {
                 target.Faction.AffectGoodwillWith(Faction.OfPlayer, -30);
             }
             Caster.health.AddHediff(HediffDefOf.PsychicShock);
             return(false);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        public static void PsykerShockEvents(CompPsyker psycomp, PsykerPowerLevel spellPowerLevel)
        {
            float chance = CalculatePsykerShockProbability(psycomp, spellPowerLevel);

            if (Rand.Range(0f, 1f) < chance)
            {
                float severity = Rand.Range(0f, 1f);
                if (severity < 0.1f)
                {
                    psycomp.psyker.health.AddHediff(CorruptionDefOfs.DemonicPossession);
                    return;
                }
                else if (severity < 0.3f)
                {
                    Hediff hediff = HediffMaker.MakeHediff(HediffDefOf.PsychicShock, psycomp.psyker, null);
                    psycomp.psyker.health.AddHediff(hediff, null, null);
                    return;
                }
                else
                {
                    Job vomit = new Job(JobDefOf.Vomit);
                    vomit.playerForced = true;
                    psycomp.psyker.jobs.StartJob(vomit, JobCondition.InterruptForced, null, false, true, null);
                    return;
                }
            }
        }
 private string PsykerPowerLevelToolTip(PsykerPowerLevel level)
 {
     switch (level)
     {
         case (PsykerPowerLevel.Omega):
             {
                 return "PsykerLevelDescOmega".Translate(new object[]
                 {
                     SelPawn.NameStringShort
                 });
             }
         case (PsykerPowerLevel.Sigma):
             {
                 return "PsykerLevelDescSigma".Translate(new object[]
                 {
                     SelPawn.NameStringShort
                 });
             }
         case (PsykerPowerLevel.Rho):
             {
                 return "PsykerLevelDescRho".Translate(new object[]
                 {
                     SelPawn.NameStringShort
                 });
             }
         case (PsykerPowerLevel.Iota):
             {
                 return "PsykerLevelDescIota".Translate(new object[]
                 {
                     SelPawn.NameStringShort
                 });
             }
         case (PsykerPowerLevel.Zeta):
             {
                 return "PsykerLevelDescZeta".Translate(new object[]
                 {
                     SelPawn.NameStringShort
                 });
             }
         case (PsykerPowerLevel.Epsilon):
             {
                 return "PsykerLevelDescEpsilon".Translate(new object[]
                 {
                     SelPawn.NameStringShort
                 });
             }
         case (PsykerPowerLevel.Delta):
             {
                 return "PsykerLevelDescDelta".Translate(new object[]
                 {
                     SelPawn.NameStringShort
                 });
             }
         default:
             {
                 return null;
             }
     }
 }
Ejemplo n.º 4
0
        public bool CheckAvailablePowerSlots(PsykerPowerLevel leveltocheck)
        {
            int powers         = compPsyker.Powers.FindAll(x => x.powerdef.PowerLevel == leveltocheck).Count;
            int availableslots = (from entry in PowerLevelSlots where entry.Key == leveltocheck select entry.Value).FirstOrDefault();

            if (powers <= availableslots)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 5
0
        private static float CalculatePsykerShockProbability(CompPsyker psycomp, PsykerPowerLevel spellPowerLevel)
        {
            float num         = 0f;
            int   psykerPower = (int)psycomp.soul.PsykerPowerLevel;
            int   spellPower  = (int)spellPowerLevel;

            num = 0.2f - (Mathf.Pow(spellPower - psykerPower, 2)) / 100;
            if (num < 0.01f)
            {
                num = 0.01f;
            }
            return(num);
        }
Ejemplo n.º 6
0
        public override void SetInitialLevel()
        {
            InitiatePsykerComp();
            //           try
            //           {
            //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Berserker);
            //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_WarpBolt);
            //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Temptation);
            //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Purgatus);
            //           }
            //           catch
            //           { }
            ChaosFollowerPawnKindDef pdef = this.pawn.kindDef as ChaosFollowerPawnKindDef;

            if (pdef != null && pdef.AfflictionProperty != null)
            {
                PawnAfflictionProps      = new AfflictionProperty();
                this.PawnAfflictionProps = pdef.AfflictionProperty;
                int pllow = (int)this.PawnAfflictionProps.LowerPsykerPowerLimit;
                int plup  = (int)this.PawnAfflictionProps.UpperAfflictionLimit;
                this.PsykerPowerLevel = (PsykerPowerLevel)Rand.RangeInclusive(pllow, plup);

                if (PawnAfflictionProps.IsImmune)
                {
                    this.curLevelInt   = 0.99f;
                    this.DevotionTrait = new SoulTrait(CorruptionDefOfs.Devotion, PawnAfflictionProps.ImmuneDevotionDegree);
                    this.IsImmune      = true;
                }
                else if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
                {
                    this.IsImmune    = true;
                    this.curLevelInt = Rand.Range(0.86f, 0.99f);
                    this.NoPatron    = true;
                }
                else
                {
                    float afup   = pdef.AfflictionProperty.UpperAfflictionLimit;
                    float afdown = pdef.AfflictionProperty.LowerAfflictionLimit;
                    this.curLevelInt = (Rand.Range(afup, afdown));
                }
                if (PawnAfflictionProps.UseOtherFaith)
                {
                    this.patronInfo.PatronName = PawnAfflictionProps.IsofFaith.ToString();
                }
                this.CulturalTolerance = PawnAfflictionProps.PrimaryToleranceCategory;
            }
            else
            {
                PawnAfflictionProps    = new AfflictionProperty();
                this.PsykerPowerLevel  = (PsykerPowerLevel)Rand.RangeInclusive(0, Enum.GetValues(typeof(PsykerPowerLevel)).Length - 1);
                this.CulturalTolerance = (CulturalToleranceCategory)Rand.RangeInclusive(0, 2);
                if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
                {
                    this.IsImmune    = true;
                    this.curLevelInt = Rand.Range(0.86f, 0.99f);
                    this.NoPatron    = true;
                }
                else
                {
                    this.curLevelInt = Rand.Range(0.01f, 0.99f);
                }
            }

            if (this.PawnAfflictionProps.CommmonPsykerPowers != null)
            {
                for (int i = 0; i < this.PawnAfflictionProps.CommmonPsykerPowers.Count; i++)
                {
                    try
                    {
                        this.compPsyker.PowerManager.AddPsykerPower(this.PawnAfflictionProps.CommmonPsykerPowers[i]);
                    }
                    catch
                    { }
                }
            }

            if (CorruptionDefOfs.Devotion.SDegreeDatas == null)
            {
                Log.Message("No stdata");
            }

            if (this.SoulTraits.NullOrEmpty())
            {
                if ((PawnAfflictionProps != null && PawnAfflictionProps.IsImmune))
                {
                    this.DevotionTrait = new SoulTrait(CorruptionDefOfs.Devotion, PawnAfflictionProps.ImmuneDevotionDegree);
                    this.IsImmune      = true;
                }
                else
                {
                    this.DevotionTrait = new SoulTrait(CorruptionDefOfs.Devotion, Rand.RangeInclusive(-2, 2));
                }
                this.SoulTraits.Insert(0, DevotionTrait);
            }
            if (PawnAfflictionProps.CommonSoulTrait != null && !this.SoulTraits.Any(x => x.SDef == PawnAfflictionProps.CommonSoulTrait))
            {
                this.SoulTraits.Add(new SoulTrait(PawnAfflictionProps.CommonSoulTrait, 0));
            }

            if (this.curLevelInt < 0.3f && NoPatron == true)
            {
                GainPatron(ChaosGods.Undivided, false);
            }
            if (NoPatron == false)
            {
                if (curLevelInt > 0.3f)
                {
                    curLevelInt = 0.3f;
                }
            }
            if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
            {
                this.IsImmune = true;
            }
        }
Ejemplo n.º 7
0
        public override void SetInitialLevel()
        {
            if (!SoulInitialized)
            {
                FieldInfo info = typeof(StatsReportUtility).GetField("cachedDrawEntries", BindingFlags.NonPublic | BindingFlags.Static);
                if (info != null)
                {
                    List <StatDrawEntry> entries = info.GetValue(this.pawn) as List <StatDrawEntry>;
                    if (!entries.NullOrEmpty())
                    {
                        entries.Add(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "Patron", this.Patron.ToString(), 3));
                        entries.Add(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "CulturalToleranceStat".Translate(), this.Patron.ToString(), 2));
                        entries.Add(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "PurityOfSoulStat".Translate(), this.CurLevel.ToString(), 1));
                    }
                }

                //           try
                //           {
                //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Berserker);
                //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_WarpBolt);
                //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Temptation);
                //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Purgatus);
                //           }
                //           catch
                //           { }

                InitiatePsykerComp();

                ChaosFollowerPawnKindDef pdef = this.pawn.kindDef as ChaosFollowerPawnKindDef;
                //       Log.Message("Name is: " + this.pawn.Name.ToStringFull);
                if (pdef != null)
                {
                    if (pdef.UseFixedGender)
                    {
                        this.pawn.gender = pdef.FixedGender;
                    }
                    if (pdef.AfflictionProperty != null)
                    {
                        PawnAfflictionProps      = new AfflictionProperty();
                        this.PawnAfflictionProps = pdef.AfflictionProperty;
                        int pllow = (int)this.PawnAfflictionProps.LowerPsykerPowerLimit;
                        int plup  = (int)this.PawnAfflictionProps.UpperAfflictionLimit;
                        this.PsykerPowerLevel = (PsykerPowerLevel)Rand.RangeInclusive(pllow, plup);

                        if (PawnAfflictionProps.IsImmune)
                        {
                            this.curLevelInt   = 0.99f;
                            this.DevotionTrait = new SoulTrait(C_SoulTraitDefOf.Devotion, PawnAfflictionProps.ImmuneDevotionDegree);
                            this.IsImmune      = true;
                        }
                        else if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
                        {
                            this.IsImmune    = true;
                            this.curLevelInt = Rand.Range(0.86f, 0.99f);
                            this.NoPatron    = true;
                        }
                        else
                        {
                            float afup   = pdef.AfflictionProperty.UpperAfflictionLimit;
                            float afdown = pdef.AfflictionProperty.LowerAfflictionLimit;
                            this.curLevelInt = (Rand.Range(afup, afdown));
                        }
                        if (PawnAfflictionProps.UseOtherFaith)
                        {
                            this.patronInfo.PatronName = PawnAfflictionProps.IsofFaith.ToString();
                        }
                        this.CulturalTolerance = PawnAfflictionProps.PrimaryToleranceCategory;
                    }
                }
                else
                {
                    PawnAfflictionProps = new AfflictionProperty();
                    float pNum = Rand.GaussianAsymmetric(2.5f, 0.45f, 2);
                    if (pNum < 0)
                    {
                        pNum = 0;
                    }
                    else if (pNum > 7)
                    {
                        pNum = 7;
                    }
                    this.PsykerPowerLevel = (PsykerPowerLevel)pNum;

                    this.CulturalTolerance = (CulturalToleranceCategory)Rand.RangeInclusive(0, 2);
                    if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
                    {
                        this.IsImmune    = true;
                        this.curLevelInt = Rand.Range(0.86f, 0.99f);
                        this.NoPatron    = true;
                    }
                    else
                    {
                        this.curLevelInt = Rand.Range(0.4f, 0.99f);
                    }
                }

                if (this.PawnAfflictionProps.CommmonPsykerPowers != null)
                {
                    for (int i = 0; i < this.PawnAfflictionProps.CommmonPsykerPowers.Count; i++)
                    {
                        try
                        {
                            this.compPsyker.psykerPowerManager.AddPsykerPower(this.PawnAfflictionProps.CommmonPsykerPowers[i]);
                        }
                        catch
                        { }
                    }
                }

                if (this.DevotionTrait == null)
                {
                    if ((PawnAfflictionProps != null && PawnAfflictionProps.IsImmune))
                    {
                        this.DevotionTrait = new SoulTrait(C_SoulTraitDefOf.Devotion, PawnAfflictionProps.ImmuneDevotionDegree);
                        this.IsImmune      = true;
                    }
                    else
                    {
                        this.DevotionTrait = new SoulTrait(C_SoulTraitDefOf.Devotion, Rand.RangeInclusive(-2, 2));
                    }
                }
                if (PawnAfflictionProps.CommonSoulTrait != null)
                {
                    this.CommonSoulTrait = new SoulTrait(PawnAfflictionProps.CommonSoulTrait, 0);
                }

                if (this.curLevelInt < 0.3f && NoPatron == true)
                {
                    GainPatron(ChaosGods.Undivided, false);
                }
                if (NoPatron == false)
                {
                    if (curLevelInt > 0.3f)
                    {
                        curLevelInt = 0.3f;
                    }
                }
                if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
                {
                    this.IsImmune = true;
                }

                this.SoulInitialized = true;

                if (this.compPsyker.patronName != patronInfo.PatronName)
                {
                    this.compPsyker.patronName = patronInfo.PatronName;
                    PortraitsCache.SetDirty(this.pawn);
                }
            }
        }