public override void CompTick()
 {
     base.CompTick();
     if (this.parent.GetComp <CompEquippable>().PrimaryVerb.CasterPawn == null && LastGainTick > Find.TickManager.TicksGame)
     {
         Pawn p = this.parent.GetComp <CompEquippable>().PrimaryVerb.CasterPawn;
         ChaosFollowerPawnKindDef pdef = p.kindDef as ChaosFollowerPawnKindDef;
         Need_Soul n_soul     = p.needs.TryGetNeed <Need_Soul>();
         var       resistence = pdef.AfflictionProperty.ResolveFactor;
         n_soul.GainNeed(amount(cprops.Category, resistence));
         LastGainTick = Find.TickManager.TicksGame + 120;
     }
 }
Exemple #2
0
 public static void GenerateInitialHediffsPostFix(Pawn pawn, PawnGenerationRequest request)
 {
     if (pawn.needs != null)
     {
         Need_Soul soul = pawn.needs.TryGetNeed <Need_Soul>();
         if (soul != null)
         {
             ChaosFollowerPawnKindDef pdef = pawn.kindDef as ChaosFollowerPawnKindDef;
             if (pdef != null)
             {
                 soul.GenerateHediffsAndImplants(pdef);
             }
         }
     }
 }
Exemple #3
0
        public override void PostSpawnSetup()
        {
            base.PostSpawnSetup();
            this.psykerPowerManager = new PsykerPowerManager(this);
            ChaosFollowerPawnKindDef pdef = this.psyker.kindDef as ChaosFollowerPawnKindDef;

            if (pdef != null && pdef.RenamePawns)
            {
                string rawName = NameGenerator.GenerateName(pdef.OverridingNameRulePack, delegate(string x)
                {
                    NameTriple nameTriple4 = NameTriple.FromString(x);
                    nameTriple4.ResolveMissingPieces(null);
                    return(!nameTriple4.UsedThisGame);
                }, false);
                NameTriple nameTriple = NameTriple.FromString(rawName);
                nameTriple.CapitalizeNick();
                nameTriple.ResolveMissingPieces(null);
                psyker.Name = nameTriple;
            }
        }
Exemple #4
0
        public void GenerateHediffsAndImplants(ChaosFollowerPawnKindDef pdef)
        {
            if (pdef.AdditionalImplantCount.min > 0)
            {
                int num = Rand.RangeInclusive(pdef.AdditionalImplantCount.min, pdef.AdditionalImplantCount.max);
                for (int i = 0; i < num; i++)
                {
                    PawnTechHediffsGenerator.GeneratePartsAndImplantsFor(this.pawn);
                }
            }
            if (!pdef.DisallowedStartingHediffs.NullOrEmpty())
            {
                foreach (HediffDef def in pdef.DisallowedStartingHediffs)
                {
                    this.pawn.health.hediffSet.hediffs.RemoveAll(x => x.def == def);
                }
            }

            if (!pdef.ForcedStartingHediffs.NullOrEmpty())
            {
                foreach (HediffDef hediffDef in pdef.ForcedStartingHediffs)
                {
                    Hediff current = HediffMaker.MakeHediff(hediffDef, this.pawn, null);
                    this.pawn.health.AddHediff(current);
                }
            }

            if (!pdef.ForcedStartingImplantRecipes.NullOrEmpty() && !pdef.ForcedStartingImplantRecipes.NullOrEmpty())
            {
                foreach (RecipeDef recipeDef in pdef.ForcedStartingImplantRecipes)
                {
                    if (!recipeDef.targetsBodyPart || recipeDef.Worker.GetPartsToApplyOn(pawn, recipeDef).Any <BodyPartRecord>())
                    {
                        recipeDef.Worker.ApplyOnPawn(pawn, recipeDef.Worker.GetPartsToApplyOn(pawn, recipeDef).Any <BodyPartRecord>() ? recipeDef.Worker.GetPartsToApplyOn(pawn, recipeDef).RandomElement <BodyPartRecord>() : null, null, new List <Thing>());
                    }
                }
            }
        }
Exemple #5
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;
            }
        }
Exemple #6
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);
                }
            }
        }