protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; PawnKindDef smallMonster = WyvernUtility.GetRandomSmallMonsterForEvent(map); if (smallMonster == null) { return(false); } IntVec3 intVec; if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null)) { return(false); } int freeColonistsCount = map.mapPawns.FreeColonistsCount; float randomInRange = IncidentWorker_SmallMonsterAppear.CountPerColonistRange.RandomInRange; float f = (float)freeColonistsCount * randomInRange; int num = Mathf.Clamp(GenMath.RoundRandom(f), 1, 10); for (int i = 0; i < num; i++) { IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null); Pawn newThing = PawnGenerator.GeneratePawn(smallMonster, null); Pawn newSmallMonster = (Pawn)GenSpawn.Spawn(newThing, loc, map, WipeMode.Vanish); newSmallMonster.needs.food.CurLevelPercentage = 1f; } Find.LetterStack.ReceiveLetter("LetterLabelSmallMonsterAppear".Translate(), "LetterTextSmallMonsterAppear".Translate(smallMonster.label.CapitalizeFirst()), LetterDefOf.NeutralEvent, new TargetInfo(intVec, map, false), null, null); return(true); }
public override void CompTickRare() { base.CompTickRare(); if (!LoadedModManager.GetMod <MonsterHunterRimworldMod>().GetSettings <MonsterHunterRimworldModSettings>().elderDragonWeatherEffects) { return; } if (!(parent is Pawn elderDragon)) { return; } if (!WyvernUtility.IsElderDragon(elderDragon)) { return; } if (elderDragon.Dead) { return; } Map map = elderDragon.Map; if (map == null) { return; } WeatherDef newWeather = new WeatherDef(); newWeather = WeatherDef.Named("RainyThunderstorm"); if (map.weatherManager.curWeather != newWeather) { map.weatherManager.TransitionTo(newWeather); } }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; PawnKindDef elderDragon = WyvernUtility.GetRandomElderDragonForEvent(map); if (elderDragon == null) { return(false); } IntVec3 intVec; if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null)) { return(false); } IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null); Pawn newThing = PawnGenerator.GeneratePawn(elderDragon, null); Pawn newElderDragon = (Pawn)GenSpawn.Spawn(newThing, loc, map, WipeMode.Vanish); newElderDragon.needs.food.CurLevelPercentage = 1f; List <Pawn> wildlifeAnimals = map.mapPawns.AllPawnsSpawned.FindAll(p => p != newElderDragon && p.Faction == null && p.RaceProps.Animal && !p.health.Dead); foreach (Pawn wildlifeAnimal in wildlifeAnimals) { if (WyvernUtility.IsElderDragon(wildlifeAnimal)) { if (!WyvernUtility.IsSameSpecies(newElderDragon, wildlifeAnimal)) { if (wildlifeAnimal.IsFighting()) { continue; } if (newElderDragon.jobs.TryTakeOrderedJob(new Job(JobDefOf.AttackMelee, wildlifeAnimal))) { Messages.Message("TurfWarLabel".Translate().CapitalizeFirst(), newElderDragon, MessageTypeDefOf.NeutralEvent); } if (wildlifeAnimal.jobs.TryTakeOrderedJob(new Job(JobDefOf.AttackMelee, newElderDragon))) { Messages.Message("TurfWarLabel".Translate().CapitalizeFirst(), wildlifeAnimal, MessageTypeDefOf.NeutralEvent); } } continue; } if (Rand.Chance(0.2f) || LoadedModManager.GetMod <MonsterHunterRimworldMod>().GetSettings <MonsterHunterRimworldModSettings>().elderDragonScareAnimals) { continue; // animals will flee with a 80% chance } JobGiver_ExitMapPanic jobFlee = new JobGiver_ExitMapPanic(); ThinkResult thinkResult = jobFlee.TryIssueJobPackage(wildlifeAnimal, new JobIssueParams() { maxDistToSquadFlag = 500 }); wildlifeAnimal.jobs.TryTakeOrderedJob(thinkResult.Job); } Find.LetterStack.ReceiveLetter("LetterLabelElderDragonAppear".Translate(), "LetterTextElderDragonAppear".Translate(newElderDragon.Label.CapitalizeFirst()), LetterDefOf.ThreatSmall, new TargetInfo(intVec, map, false), null, null); return(true); }
protected override bool CanFireNowSub(IncidentParms parms) { if (!base.CanFireNowSub(parms)) { return(false); } Map map = (Map)parms.target; if (WyvernUtility.GetRandomSmallMonsterForEvent(map) == null) { return(false); } IntVec3 intVec; return(RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null)); }
protected override bool CanFireNowSub(IncidentParms parms) { if (!base.CanFireNowSub(parms)) { return(false); } if (GenTicks.TicksGame < GenDate.TicksPerDay * LoadedModManager.GetMod <MonsterHunterRimworldMod>().GetSettings <MonsterHunterRimworldModSettings>().minElderDragonEventDelay) { return(false); } Map map = (Map)parms.target; if (WyvernUtility.GetRandomElderDragonForEvent(map) == null) { return(false); } IntVec3 intVec; return(RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null)); }
public override void CompTickRare() { base.CompTickRare(); if (!LoadedModManager.GetMod <MonsterHunterRimworldMod>().GetSettings <MonsterHunterRimworldModSettings>().elderDragonWeatherEffects) { return; } if (!(parent is Pawn elderDragon)) { return; } if (!WyvernUtility.IsElderDragon(elderDragon)) { return; } if (elderDragon.Dead) { return; } Map map = elderDragon.Map; if (map == null) { return; } GameConditionManager gameConditionManager = map.GameConditionManager; if (gameConditionManager.ConditionIsActive(GameConditionDefOf.ToxicFallout)) { return; } int duration = Mathf.RoundToInt(0.5f * 60000f); // lasts half a day after elder dragon dies GameCondition cond = GameConditionMaker.MakeCondition(GameConditionDefOf.ToxicFallout, duration); gameConditionManager.RegisterCondition(cond); }
public override void CompTickRare() { base.CompTickRare(); if (!(parent is Pawn largeMonster)) { return; } if (largeMonster.Faction != null) { return; } Map map = largeMonster.Map; if (map == null) { return; } if (largeMonster.IsFighting() || largeMonster.Downed || largeMonster.Dead) { return; } List <Pawn> possibleTargetsToFight = map.mapPawns.AllPawnsSpawned.FindAll(p => p.RaceProps.Animal && p.Faction == null && !p.IsFighting() && !p.Downed && !p.Dead && !WyvernUtility.IsSameSpecies(p, largeMonster) && p.Position.DistanceTo(largeMonster.Position) < Props.maxFightRange && p.TryGetComp <CompTurfWar>() != null); if (possibleTargetsToFight.Count == 0) { return; } Pawn targetToFight = possibleTargetsToFight.RandomElement(); if (largeMonster.jobs.TryTakeOrderedJob(new Job(JobDefOf.AttackMelee, targetToFight))) { Messages.Message("TurfWarLabel".Translate().CapitalizeFirst(), largeMonster, MessageTypeDefOf.NeutralEvent); } if (targetToFight.jobs.TryTakeOrderedJob(new Job(JobDefOf.AttackMelee, largeMonster))) { Messages.Message("TurfWarLabel".Translate().CapitalizeFirst(), targetToFight, MessageTypeDefOf.NeutralEvent); } }