示例#1
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map         = (Map)parms.target;
            PawnKindDef pawnKindDef = PawnKindDef.Named("AA_ArcticLion");
            IntVec3     intVec;

            if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal))
            {
                return(false);
            }
            List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(pawnKindDef, map.Tile, 300);
            Rot4        rot  = Rot4.FromAngleFlat((map.Center - intVec).AngleFlat);

            for (int i = 0; i < list.Count; i++)
            {
                Pawn    pawn = list[i];
                IntVec3 loc  = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null);
                GenSpawn.Spawn(pawn, loc, map, rot, WipeMode.Vanish, false);
                pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null, false);
                pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(60000, 120000);
                pawn.health.AddHediff(HediffDef.Named("AA_InvisibleArcticLion"));
            }
            Find.LetterStack.ReceiveLetter("LetterLabelManhuntingArcticLion".Translate(), "ManhuntingArcticLion".Translate(), LetterDefOf.ThreatBig, null, null, null);
            Find.TickManager.slower.SignalForceNormalSpeedShort();

            return(true);
        }
示例#2
0
    protected override bool TryExecuteWorker(IncidentParms parms)
    {
        var map = (Map)parms.target;

        if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, map.Tile, out var pawnKindDef))
        {
            return(false);
        }

        if (!RCellFinder.TryFindRandomPawnEntryCell(out var intVec, map, CellFinder.EdgeRoadChance_Animal))
        {
            return(false);
        }

        var list = ManhunterPackIncidentUtility.GenerateAnimals(pawnKindDef, map.Tile, parms.points * 0.2f);
        var rot  = Rot4.FromAngleFlat((map.Center - intVec).AngleFlat);

        for (var i = 0; i < list.Count; i++)
        {
            var deviljho = PawnKindDefOf.Deviljho;
            var pawn     = PawnGenerator.GeneratePawn(deviljho);
            var loc      = CellFinder.RandomClosewalkCellNear(intVec, map, 10);
            GenSpawn.Spawn(pawn, loc, map, rot);
            pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(60000, 135000);
        }

        Find.LetterStack.ReceiveLetter("LetterLabelDeviljho".Translate(),
                                       "Deviljholetter".Translate(pawnKindDef.GetLabelPlural()), LetterDefOf.ThreatBig, list[0]);
        Find.TickManager.slower.SignalForceNormalSpeedShort();
        LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical);
        LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important);
        return(true);
    }
示例#3
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map        = (Map)parms.target;
            PawnKindDef bossKind   = def.pawnKind;
            PawnKindDef animalKind = GetAnimalKind(parms.points, map.Tile);

            if (bossKind == null || animalKind == null || ManhunterPackIncidentUtility.GetAnimalsCount(animalKind, (parms.points * PointsFactor) - bossKind.combatPower) <= 0)
            {
                return(false);
            }
            IntVec3 result = parms.spawnCenter;

            if (!result.IsValid && !RCellFinder.TryFindRandomPawnEntryCell(out result, map, CellFinder.EdgeRoadChance_Animal))
            {
                return(false);
            }

            List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(bossKind, map.Tile, bossKind.combatPower, 1);

            list.AddRange(ManhunterPackIncidentUtility.GenerateAnimals(animalKind, map.Tile, (parms.points * PointsFactor) - bossKind.combatPower, parms.pawnCount));
            Rot4 rot = Rot4.FromAngleFlat((map.Center - result).AngleFlat);

            for (int i = 0; i < list.Count; i++)
            {
                Pawn    pawn = list[i];
                IntVec3 loc  = CellFinder.RandomClosewalkCellNear(result, map, 10);
                QuestUtility.AddQuestTag(GenSpawn.Spawn(pawn, loc, map, rot), parms.questTag);
                pawn.health.AddHediff(HediffDefOf.Scaria);
                pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent);
                pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(AnimalsStayDurationMin, AnimalsStayDurationMax);
            }

            TaggedString labelString = null;

            if (def.letterLabel != null)
            {
                labelString = def.letterLabel;
            }
            else
            {
                labelString = "LetterLabelManhunterPackArrived".Translate();
            }

            TaggedString textString = null;

            if (def.letterText != null)
            {
                textString = def.letterText;
            }
            else
            {
                textString = "ManhunterPackArrived".Translate(animalKind.GetLabelPlural());
            }

            SendStandardLetter(labelString, textString, LetterDefOf.ThreatBig, parms, list[0]);
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical);
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important);
            return(true);
        }
示例#4
0
 protected void CaravanAmbushManhuntersNoTreasure(Caravan caravan)
 {
     LongEventHandler.QueueLongEvent(delegate
     {
         IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, caravan);
         //make sure a minimum point threshold is hit
         if (incidentParms.points < MinimumPointThreshold)
         {
             incidentParms.points = MinimumPointThreshold;
         }
         PawnKindDef animalKind;
         if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.AdjustedPoints(incidentParms.points), incidentParms.target.Tile, out animalKind) && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.AdjustedPoints(incidentParms.points), -1, out animalKind))
         {
             Log.Warning("Could not find any valid animal kind for " + this.def + " incident. Going with Wargs", false);
             animalKind = ThingDefOfVanilla.Warg;
         }
         List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(animalKind, incidentParms.target.Tile, this.AdjustedPoints(incidentParms.points));
         Map map          = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, list, false);
         for (int i = 0; i < list.Count; i++)
         {
             list[i].mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null, false);
         }
         Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
         GlobalTargetInfo lookTarget   = (!list.Any <Pawn>()) ? GlobalTargetInfo.Invalid : new GlobalTargetInfo(list[0].Position, map, false);
         Find.LetterStack.ReceiveLetter("LetterLabelIMAmbushLGE".Translate(), "LetterIMAmbushLGE".Translate(), LetterDefOf.ThreatBig, lookTarget, null);
     }, "GeneratingMapForNewEncounter", false, null);
 }
示例#5
0
        protected void TreasureWithManhunters(Caravan caravan)
        {
            List <Thing> rewardList = GenerateReward();

            for (int i = 0; i < rewardList.Count; i++)
            {
                caravan.AddPawnOrItem(rewardList[i], true);
            }
            LongEventHandler.QueueLongEvent(delegate
            {
                IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, caravan);
                //make sure a minimum point threshold is hit
                if (incidentParms.points < MinimumPointThreshold)
                {
                    incidentParms.points = MinimumPointThreshold + 100f;
                }
                PawnKindDef animalKind;
                if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.AdjustedPoints(incidentParms.points), incidentParms.target.Tile, out animalKind) && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.AdjustedPoints(incidentParms.points), -1, out animalKind))
                {
                    Log.Warning("Could not find any valid animal kind for " + this.def + " incident. Going with Wargs", false);
                    animalKind = ThingDefOfVanilla.Warg;
                }
                List <Pawn> pawnList = ManhunterPackIncidentUtility.GenerateAnimals(animalKind, incidentParms.target.Tile, this.AdjustedPoints(incidentParms.points));
                Map map = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, pawnList, false);
                for (int i = 0; i < pawnList.Count; i++)
                {
                    pawnList[i].mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null, false);
                }
                Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
                GlobalTargetInfo lookTarget   = (!pawnList.Any <Pawn>()) ? GlobalTargetInfo.Invalid : new GlobalTargetInfo(pawnList[0].Position, map, false);
                Find.LetterStack.ReceiveLetter("LetterLabelTreasureAmbushLGE".Translate(), "LetterTreasureAmbushLGE".Translate(GenThing.GetMarketValue(rewardList).ToStringMoney(null), GenLabel.ThingsLabel(rewardList, string.Empty)), LetterDefOf.ThreatBig, lookTarget, null);
            }, "GeneratingMapForNewEncounter", false, null);
        }
        // Token: 0x0600000E RID: 14 RVA: 0x0000221C File Offset: 0x0000041C
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map   = (Map)parms.target;
            PawnKindDef named = DefDatabase <PawnKindDef> .GetNamed("KillerRabbit", true);

            IntVec3 intVec;
            bool    flag = !RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null);
            bool    result;

            if (flag)
            {
                result = false;
            }
            else
            {
                List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(named, map.Tile, parms.points * 1f);
                Rot4        rot  = Rot4.FromAngleFlat((map.Center - intVec).AngleFlat);
                for (int i = 0; i < list.Count; i++)
                {
                    Pawn    pawn = list[i];
                    IntVec3 loc  = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null);
                    GenSpawn.Spawn(pawn, loc, map, rot, WipeMode.Vanish, false);
                    pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null, false);
                    pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(60000, 120000);
                }
                Find.LetterStack.ReceiveLetter(Translator.Translate("LetterLabelManhunterPackArrived"), TranslatorFormattedStringExtensions.Translate("ManhunterPackArrived", named.GetLabelPlural(-1)), LetterDefOf.ThreatBig, list[0], null, null);
                Find.TickManager.slower.SignalForceNormalSpeedShort();
                LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical);
                LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important);
                result = true;
            }
            return(result);
        }
        protected override List <Pawn> GeneratePawns(IncidentParms parms)
        {
            PawnKindDef animalKind;

            if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.AdjustedPoints(parms.points), parms.target.Tile, out animalKind) && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.AdjustedPoints(parms.points), -1, out animalKind))
            {
                Log.Error("Could not find any valid animal kind for " + this.def + " incident.", false);
                return(new List <Pawn>());
            }
            return(ManhunterPackIncidentUtility.GenerateAnimals(animalKind, parms.target.Tile, this.AdjustedPoints(parms.points)));
        }
        public override bool ManualDeterminParams()
        {
            Map map = (Map)parms.target;

            if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, map.Tile, out AnimalType))
            {
                return(false);
            }
            if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null))
            {
                return(false);
            }
            pawnList    = ManhunterPackIncidentUtility.GenerateAnimals(AnimalType, map.Tile, parms.points * 1f);
            AnimalNum   = pawnList.Count;
            lookTargets = new TargetInfo(intVec, map, false);
            return(true);
        }
示例#9
0
        private List <Thing> GetAnimals(PawnKindDef animalKind, Map map, float points)
        {
            List <Thing> animals = new List <Thing>();

            List <Pawn> pawns = ManhunterPackIncidentUtility.GenerateAnimals(animalKind, map.Tile, points * 1f);

            foreach (var pawn in pawns)
            {
                if (animals.Count >= 30)
                {
                    break;
                }

                animals.Add(pawn);
            }

            return(animals);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map = (Map)parms.target;
            PawnKindDef pawnKindDef;

            if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, map.Tile, out pawnKindDef))
            {
                return(false);
            }
            IntVec3 intVec;

            if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null))
            {
                return(false);
            }
            List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(pawnKindDef, map.Tile, parms.points * 1f);
            Rot4        rot  = Rot4.FromAngleFlat((map.Center - intVec).AngleFlat);

            for (int i = 0; i < list.Count; i++)
            {
                Pawn    pawn = list[i];
                IntVec3 loc  = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null);
                GenSpawn.Spawn(pawn, loc, map, rot, WipeMode.Vanish, false);
                pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null, false);
                pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(60000, 120000);
            }
            var text = "ManhunterPackArrived".Translate(pawnKindDef.GetLabelPlural(-1));

            if (Quote != null)
            {
                text += "\n\n";
                text += Helper.ReplacePlaceholder(Quote, animal: pawnKindDef.GetLabelPlural(-1));
            }

            Find.LetterStack.ReceiveLetter("LetterLabelManhunterPackArrived".Translate(), text, LetterDefOf.ThreatBig, list[0], null, null);
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical);
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important);
            return(true);
        }