Пример #1
0
        public void GainPatron(ChaosGods forcedPatron, bool UseForcedPatron)
        {
            if (PawnAfflictionProps == null)
            {
                PawnAfflictionProps        = new AfflictionProperty();
                PawnAfflictionProps.Patron = ChaosGods.Undivided;
            }

            if (UseForcedPatron)
            {
                PawnAfflictionProps.Patron = forcedPatron;
                this.Patron = PawnAfflictionProps.Patron;
            }
            else
            {
                if (pawn.Faction.def.GetType() == typeof(FactionDefUniform))
                {
                    FactionDefUniform Facdef = this.pawn.Faction.def as FactionDefUniform;

                    if (Facdef.PreferredChaosGod == ChaosGods.Undivided)
                    {
                        PawnAfflictionProps.Patron = ChaosGods.Undivided;
                    }
                    else
                    {
                        PawnAfflictionProps.Patron = Facdef.PreferredChaosGod;
                    }
                }

                if (PawnAfflictionProps == null)
                {
                    PawnAfflictionProps        = new AfflictionProperty();
                    PawnAfflictionProps.Patron = ChaosGods.Undivided;
                }

                if (PawnAfflictionProps.Patron == ChaosGods.Undivided)
                {
                    if (Rand.Range(0.1f, 1f) > 0.5f)
                    {
                        this.Patron = ChaosGods.Undivided;
                    }
                    else
                    {
                        this.Patron = (ChaosGods)Rand.RangeInclusive(1, 4);
                    }
                }
                else
                {
                    this.Patron = PawnAfflictionProps.Patron;
                }
            }

            patronInfo.PatronName = Patron.ToString();
            GeneratePatronTraits(pawn);
            this.SoulTraits.Remove(DevotionTrait);
            DevotionTrait = new SoulTrait(CorruptionDefOfs.Devotion, Rand.RangeInclusive(0, 2));
            this.SoulTraits.Add(DevotionTrait);
            if (pawn.story == null)
            {
                pawn.story = new Pawn_StoryTracker(pawn);
            }
            //         Hediff chaosmark = HediffMaker.MakeHediff(ChaosMarkDef(this.patronInfo.PatronName), this.pawn,null);
            //         this.pawn.health.hediffSet.AddHediffDirect(chaosmark);
            if (this.pawn.Drawer != null && this.pawn.story != null)
            {
                if (this.pawn.Drawer.renderer != null)
                {
                    if (this.pawn.Drawer.renderer.graphics != null && this.pawn.apparel != null)
                    {
                        LongEventHandler.ExecuteWhenFinished(delegate
                        {
                            this.pawn.Drawer.renderer.graphics.ResolveApparelGraphics();
                            PortraitsCache.SetDirty(this.pawn);
                        });
                    }
                }
            }
            this.NoPatron = false;
        }
Пример #2
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;
            }
        }
Пример #3
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);
                }
            }
        }