Example #1
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map  map  = (Map)parms.target;
            Pawn pawn = PawnGenerator.GeneratePawn(GrimmUtility.GetRandomGrimmBalanced(), FactionUtility.DefaultFactionFrom(RWBYDefOf.Creatures_of_Grimm));

            if (!parms.spawnCenter.IsValid && !RCellFinder.TryFindRandomPawnEntryCell(out parms.spawnCenter, map, CellFinder.EdgeRoadChance_Hostile, false, null))
            {
                return(false);
            }
            parms.spawnRotation = Rot4.FromAngleFlat((map.Center - parms.spawnCenter).AngleFlat);
            IntVec3 loc = CellFinder.RandomClosewalkCellNear(parms.spawnCenter, map, 8, null);

            if (pawn is Pawn_Grimm pawn_Grimm)
            {
                pawn_Grimm.SetAttractGrimmTimer();
            }
            GenSpawn.Spawn(pawn, loc, map, parms.spawnRotation, WipeMode.Vanish, false);
            string label = "LetterLabelGrimmWandersIn".Translate();
            string text  = "LetterTextGrimmWandersIn".Translate();

            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.ThreatSmall, pawn);
            return(true);
        }
Example #2
0
        public override void Tick()
        {
            base.Tick();
            if (Downed)
            {
                if (lastTakenDamageFrom is Pawn killer && killer.RaceProps.Humanlike && killer.story.traits.HasTrait(RWBYDefOf.Semblance_Weiss) && killer.TryGetComp <CompAbilityUserAura>() is CompAbilityUserAura compAbilityUserAura && compAbilityUserAura.IsInitialized)
                {
                    if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Boarbatusk)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonBoar))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonBoar);
                        }
                    }
                    else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Beowolf)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonBeowolf))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonBeowolf);
                        }
                    }
                    else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Ursa)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonUrsa))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonUrsa);
                        }
                    }
                    else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Griffon)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonGriffon))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonGriffon);
                        }
                    }
                    else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Nevermore)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonNevermore))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonNevermore);
                        }
                    }
                    else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Lancer)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonLancer))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonLancer);
                        }
                    }
                    else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_LancerQueen)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonLancerQueen))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonLancerQueen);
                        }
                    }
                    else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_DeathStalker)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonDeathStalker))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonDeathStalker);
                        }
                    }
                    else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Nuckelavee)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonNuckelavee))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonNuckelavee);
                        }
                    }
                    else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Apathy)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonApathy))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonApathy);
                        }
                    }
                }
                Kill(null);
            }
            attractGrimmTimer--;
            nuckelaveeTimer--;

            if (this.Map != null && this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Nuckelavee && nuckelaveeTimer > 0 && nuckelaveeTimer % 2500 == 0 && !this.InMentalState) // Nuckelavee spawn more Grimm
            {
                Pawn    pawn = PawnGenerator.GeneratePawn(GrimmUtility.GetRandomGrimmBalanced(), FactionUtility.DefaultFactionFrom(RWBYDefOf.Creatures_of_Grimm));
                IntVec3 loc  = CellFinder.RandomClosewalkCellNear(this.Position, this.Map, 8, null);
                if (pawn is Pawn_Grimm pawn_Grimm)
                {
                    pawn_Grimm.SetNuckelaveeTimer(nuckelaveeTimer);
                }
                GenSpawn.Spawn(pawn, loc, this.Map, this.Rotation, WipeMode.Vanish, false);
            }

            if (this.Map != null && this.IsHashIntervalTick(30000) && this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Apathy && !this.InMentalState && this.Map.mapPawns.AllPawnsSpawned.FindAll(p => p.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Apathy).Count() < this.Map.mapPawns.ColonistCount * 10) // Apathy spawn more Apathy
            {
                Pawn    pawn = PawnGenerator.GeneratePawn(RWBYDefOf.Grimm_Apathy, FactionUtility.DefaultFactionFrom(RWBYDefOf.Creatures_of_Grimm));
                IntVec3 loc  = CellFinder.RandomClosewalkCellNear(this.Position, this.Map, 8, null);
                if (pawn is Pawn_Grimm pawn_Grimm)
                {
                    pawn_Grimm.SetNuckelaveeTimer(nuckelaveeTimer);
                }
                GenSpawn.Spawn(pawn, loc, this.Map, this.Rotation, WipeMode.Vanish, false);
            }

            if (nuckelaveeTimer == 0)
            {
                if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Nuckelavee && !this.InMentalState)
                {
                    Messages.Message("MessageTextNuckelaveeTriggered".Translate().CapitalizeFirst(), this, MessageTypeDefOf.NegativeEvent);
                }
                TriggerAggro();
            }

            if (attractGrimmTimer == 0)
            {
                IncidentDef     localDef        = IncidentDefOf.RaidEnemy;
                IncidentParms   parms           = StorytellerUtility.DefaultParmsNow(localDef.category, Map);
                StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain);
                parms              = storytellerComp.GenerateParms(localDef.category, parms.target);
                parms.faction      = FactionUtility.DefaultFactionFrom(RWBYDefOf.Creatures_of_Grimm);
                parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack;
                localDef.Worker.TryExecute(parms);
                TriggerAggro();
            }
        }