public bool CanResetTargetingMode(out bool updateResetTick) { updateResetTick = false; // World pawns are exempt to player restrictions if (parent.Map == null) { return(Find.TickManager.TicksGame < _resetTargetingModeTick); } // If player's set it to never reset, if the mode is already default or if it isn't time to update if (TargetingModesSettings.TargModeResetFrequencyInt == 0 || _targetingMode == TargetingModesUtility.DefaultTargetingMode || Find.TickManager.TicksGame < _resetTargetingModeTick) { return(false); } // If the parent pawn is drafted or considered in dangerous combat if (Pawn != null && (Pawn.Drafted || GenAI.InDangerousCombat(Pawn))) { updateResetTick = true; return(false); } // If the parent is a turret and is targeting something if (parent is Building_Turret turret && turret.CurrentTarget != null) { updateResetTick = true; return(false); } return(true); }
protected override Job TryGiveJob(Pawn pawn) { IntVec3 c; if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn)) { return(null); } Pawn t; if (KidnapAIUtility.TryFindGoodKidnapVictim(pawn, 18f, out t, null) && !GenAI.InDangerousCombat(pawn)) { return(new Job(JobDefOf.Kidnap) { targetA = t, targetB = c, count = 1 }); } return(null); }
// Token: 0x060004D1 RID: 1233 RVA: 0x0003100C File Offset: 0x0002F40C protected override Job TryGiveJob(Pawn pawn) { IntVec3 c; if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn)) { c = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(XenomorphDefOf.RRY_EggXenomorphFertilized), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), 9999f, null, null, 0, -1, false, RegionType.Set_Passable, false).Position; } Pawn t; if (TryFindGoodKidnapVictim(pawn, 18f, out t, null) && !GenAI.InDangerousCombat(pawn)) { return(new Job(JobDefOf.Kidnap) { targetA = t, targetB = c, count = 1 }); } return(null); }
protected override Job TryGiveJob(Pawn pawn) { if (!RCellFinder.TryFindBestExitSpot(pawn, out IntVec3 spot)) { return(null); } if (KidnapAIUtility.TryFindGoodKidnapVictim(pawn, 18f, out Pawn victim) && !GenAI.InDangerousCombat(pawn)) { Job job = new Job(JobDefOf.Kidnap); job.targetA = victim; job.targetB = spot; job.count = 1; return(job); } return(null); }
public override bool ActivateOn(Lord lord, TriggerSignal signal) { if (signal.type == TriggerSignalType.Tick && Find.TickManager.TicksGame % 120 == 0 && Find.TickManager.TicksGame - lord.lastPawnHarmTick > 300) { TriggerData_PawnCycleInd data = this.Data; data.pawnCycleInd++; if (data.pawnCycleInd >= lord.ownedPawns.Count) { data.pawnCycleInd = 0; } if (lord.ownedPawns.Any <Pawn>()) { Pawn pawn = lord.ownedPawns[data.pawnCycleInd]; Pawn pawn2; if (pawn.Spawned && !pawn.Downed && pawn.MentalStateDef == null && KidnapAIUtility.TryFindGoodKidnapVictim(pawn, 8f, out pawn2, null) && !GenAI.InDangerousCombat(pawn)) { return(true); } } } return(false); }
public override void LordToilTick() { if (cover && Find.TickManager.TicksGame % 181 == 0) { List <Thing> list = null; for (int i = 0; i < lord.ownedPawns.Count; i++) { Pawn pawn = lord.ownedPawns[i]; if (!pawn.Downed && pawn.mindState.duty.def == DutyDefOf.AssaultColony) { Thing target = null; if (TryFindGoodOpportunisticTaskTarget(pawn, out target, list) && !base.Map.reservationManager.IsReservedByAnyoneOf(target, lord.faction) && !GenAI.InDangerousCombat(pawn)) { pawn.mindState.duty = new PawnDuty(DutyDef); pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); if (list == null) { list = new List <Thing>(); } list.Add(target); } } } } }
public override void UpdateAllDuties() { List <Thing> list = null; for (int i = 0; i < lord.ownedPawns.Count; i++) { Pawn pawn = lord.ownedPawns[i]; Thing target = null; if (!cover || (TryFindGoodOpportunisticTaskTarget(pawn, out target, list) && !GenAI.InDangerousCombat(pawn))) { if (pawn.mindState.duty == null || pawn.mindState.duty.def != DutyDef) { pawn.mindState.duty = new PawnDuty(DutyDef); pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); } if (list == null) { list = new List <Thing>(); } list.Add(target); } else { pawn.mindState.duty = new PawnDuty(DutyDefOf.AssaultColony); } } }
protected override Job TryGiveJob(Pawn pawn) { IntVec3 vec; if (!RCellFinder.TryFindBestExitSpot(pawn, out vec)) { return(null); } List <Thing> steelVehicle = new List <Thing>(); foreach (Vehicle_Turret vehicle_Cart in ToolsForHaulUtility.CartTurret) { if (ToolsForHaulUtility.IsDriver(pawn)) { break; } if (pawn.RaceProps.Animal || !pawn.RaceProps.Humanlike || !pawn.RaceProps.hasGenders) { break; } if (!vehicle_Cart.IsBurning() && vehicle_Cart.Position.InHorDistOf(pawn.Position, 12f) && !vehicle_Cart.mountableComp.IsMounted && (float)vehicle_Cart.HitPoints / vehicle_Cart.MaxHitPoints > 0.2f && vehicle_Cart.VehicleSpeed >= pawn.GetStatValue(StatDefOf.MoveSpeed) && pawn.CanReserveAndReach(vehicle_Cart, PathEndMode.InteractionCell, Danger.Deadly)) { steelVehicle.Add(vehicle_Cart); } } foreach (Vehicle_Cart vehicle_Cart in ToolsForHaulUtility.Cart) { if (ToolsForHaulUtility.IsDriver(pawn)) { break; } if (pawn.RaceProps.Animal || !pawn.RaceProps.Humanlike || !pawn.RaceProps.hasGenders) { break; } if (!vehicle_Cart.IsBurning() && vehicle_Cart.Position.InHorDistOf(pawn.Position, 12f) && !vehicle_Cart.mountableComp.IsMounted && (float)vehicle_Cart.HitPoints / vehicle_Cart.MaxHitPoints > 0.2f && vehicle_Cart.VehicleSpeed >= pawn.GetStatValue(StatDefOf.MoveSpeed) && pawn.CanReserveAndReach(vehicle_Cart, PathEndMode.InteractionCell, Danger.Deadly)) { steelVehicle.Add(vehicle_Cart); } } if (steelVehicle.Any() && !GenAI.InDangerousCombat(pawn)) { IOrderedEnumerable <Thing> orderedEnumerable = steelVehicle.OrderBy(x => x.Position.DistanceToSquared(pawn.Position)); Job job = new Job(HaulJobDefOf.Mount); orderedEnumerable.First().SetFaction(null); job.targetA = orderedEnumerable.First(); return(job); } Thing thing; if (StealAIUtility.TryFindBestItemToSteal(pawn.Position, 12f, out thing, pawn) && !GenAI.InDangerousCombat(pawn)) { return(new Job(JobDefOf.Steal) { targetA = thing, targetB = vec, maxNumToCarry = Mathf.Min(thing.stackCount, (int)(pawn.GetStatValue(StatDefOf.CarryingCapacity) / thing.def.VolumePerUnit)) }); } return(null); }
// Token: 0x060004D1 RID: 1233 RVA: 0x0003100C File Offset: 0x0002F40C protected override Job TryGiveJob(Pawn pawn) { if (!SettingsHelper.latest.AllowPredalienImpregnations) { return(null); } if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("JobGiver_PredalienImpregnate TryGiveJob")); } Pawn t; if (XenomorphKidnapUtility.TryFindGoodImpregnateVictim(pawn, 18f, out t, null) && !GenAI.InDangerousCombat(pawn)) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("victim found: {0}", t.LabelShortCap)); } return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_PredalienImpregnate) { targetA = t }); } return(null); }
// Token: 0x060004D1 RID: 1233 RVA: 0x0003100C File Offset: 0x0002F40C protected override Job TryGiveJob(Pawn pawn) { float Searchradius = HuntingRange; Map map = pawn.Map; IntVec3 c = IntVec3.Invalid; Pawn Victim = null; if (!pawn.isXenomorph(out Comp_Xenomorph xenomorph) || map == null) { return(null); } MapComponent_HiveGrid hiveGrid = pawn.Map.HiveGrid(); /* * if (GenAI.InDangerousCombat(pawn)) * { * Log.Warning(string.Format("{0} is InDangerousCombat", pawn.NameShortColored)); * } */ if (XenomorphKidnapUtility.TryFindGoodKidnapVictim(pawn, Searchradius, out Victim, null, forceRoofed, allowCocooned, minRadius, allowHosts) && !GenAI.InDangerousCombat(pawn)) { if (xenomorph.HiveLoc.IsValid && xenomorph.HiveLoc.InBounds(map) && xenomorph.HiveLoc != IntVec3.Zero) { c = xenomorph.HiveLoc; } /* * else * if (!hiveGrid.Hivelist.NullOrEmpty()) * { * c = hiveGrid.Hivelist.RandomElement().Position; * } * else * if (!hiveGrid.HiveLoclist.NullOrEmpty()) * { * c = hiveGrid.HiveLoclist.RandomElement(); * } * else */ bool selected = pawn.Map != null?Find.Selector.SelectedObjects.Contains(pawn) && (Prefs.DevMode) : false; if (c != IntVec3.Invalid && Victim != null && pawn.CanReach(c, PathEndMode.ClosestTouch, Danger.Deadly, true, TraverseMode.PassAllDestroyableThings)) { Predicate <IntVec3> validator = delegate(IntVec3 y) { bool roofed = (y.Roofed(pawn.Map) && this.forceRoofed) || !this.forceRoofed; bool adjacent = c.AdjacentTo8WayOrInside(y); bool filled = y.Filled(pawn.Map); bool edifice = y.GetEdifice(pawn.Map).DestroyedOrNull(); bool building = y.GetFirstBuilding(pawn.Map).DestroyedOrNull(); bool thingA = y.GetThingList(pawn.Map).Any(x => x.GetType() == typeof(Building_XenoEgg) && x.GetType() == typeof(Building_XenomorphCocoon) && x.GetType() == typeof(HiveLike)); // Log.Message(string.Format("{0}, adjacent: {1}, filled: {2}, edifice: {3}, building: {4}", y, !adjacent, !filled, edifice, building)); return(!adjacent && !filled && edifice && building && !thingA && roofed && pawn.CanReserveAndReach(y, PathEndMode.OnCell, Danger.Deadly, layer: ReservationLayerDefOf.Floor)); }; if (pawn.GetLord() != null && pawn.GetLord() is Lord lord) { // Log.Message(string.Format("TryFindGoodHiveLoc pawn.GetLord() != null")); } else { // Log.Message(string.Format("TryFindGoodHiveLoc pawn.GetLord() == null")); } if (pawn.mindState.duty.def != XenomorphDefOf.RRY_Xenomorph_DefendAndExpandHive && pawn.mindState.duty.def != XenomorphDefOf.RRY_Xenomorph_DefendHiveAggressively) { pawn.mindState.duty = new PawnDuty(XenomorphDefOf.RRY_Xenomorph_DefendAndExpandHive, c, 40f); } if (RCellFinder.TryFindRandomCellNearWith(c, validator, pawn.Map, out IntVec3 lc, 2, 8)) { return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_Kidnap) { targetA = Victim, targetB = lc, targetC = lc.RandomAdjacentCell8Way(), count = 1 }); } } else { Log.Error("No suitable hive location found"); // if (Find.Selector.SelectedObjects.Contains(pawn)) Log.Message(string.Format("{0} something went wrong", this)); } } else { // Log.Error("No suitable Victim found"); } return(null); }
// Token: 0x060004D1 RID: 1233 RVA: 0x0003100C File Offset: 0x0002F40C protected override Job TryGiveJob(Pawn pawn) { float Searchradius = MaxRange; IntVec3 c = IntVec3.Invalid; if (Searchradius == 0) { if (pawn.mindState.duty != null) { if (pawn.mindState.duty.focus.Cell.GetThingList(pawn.Map).Any(x => x.def == XenomorphDefOf.RRY_Xenomorph_Hive)) { Searchradius = 7f; } if (pawn.mindState.duty.focus.Cell.GetThingList(pawn.Map).Any(x => x.def == XenomorphDefOf.RRY_Xenomorph_Hive_Child)) { Searchradius = 3f; } if (pawn.mindState.duty.focus.Cell.GetThingList(pawn.Map).Any(x => x.def == XenomorphDefOf.RRY_Xenomorph_Hive_Slime)) { Searchradius = 5f; } } } if (XenomorphKidnapUtility.TryFindGoodKidnapVictim(pawn, Searchradius, out Pawn t, null, this.forceRoofed, true, MinRange) && !GenAI.InDangerousCombat(pawn)) { if (XenomorphKidnapUtility.TryFindGoodHiveLoc(pawn, out c, t, true, !this.forceRoofed, this.forceCanDig)) { ThingDef namedA = XenomorphDefOf.RRY_Xenomorph_Cocoon_Humanoid; ThingDef namedB = XenomorphDefOf.RRY_Xenomorph_Cocoon_Animal; bool selected = pawn.Map != null?Find.Selector.SelectedObjects.Contains(pawn) && (Prefs.DevMode) : false; if (c != IntVec3.Invalid && t != null && pawn.CanReach(c, PathEndMode.ClosestTouch, Danger.Deadly, true, TraverseMode.PassAllDestroyableThings)) { Predicate <IntVec3> validator = delegate(IntVec3 y) { bool roofed = (y.Roofed(pawn.Map) && this.forceRoofed) || !this.forceRoofed; bool adjacent = c.AdjacentTo8WayOrInside(y); bool filled = y.Filled(pawn.Map); bool edifice = y.GetEdifice(pawn.Map).DestroyedOrNull(); bool building = y.GetFirstBuilding(pawn.Map).DestroyedOrNull(); bool thingA = y.GetFirstThing(pawn.Map, namedA).DestroyedOrNull(); bool thingB = y.GetFirstThing(pawn.Map, namedB).DestroyedOrNull(); if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("{0}, adjacent: {1}, filled: {2}, edifice: {3}, building: {4}", y, !adjacent, !filled, edifice, building)); } return(!adjacent && !filled && edifice && building && thingA && thingB && roofed); }; if (pawn.GetLord() != null && pawn.GetLord() is Lord lord) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("TryFindGoodHiveLoc pawn.GetLord() != null")); } } else { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("TryFindGoodHiveLoc pawn.GetLord() == null")); } } if (pawn.mindState.duty.def != XenomorphDefOf.RRY_Xenomorph_DefendAndExpandHive && pawn.mindState.duty.def != XenomorphDefOf.RRY_Xenomorph_DefendHiveAggressively) { pawn.mindState.duty = new PawnDuty(XenomorphDefOf.RRY_Xenomorph_DefendAndExpandHive, c, 40f); } if (RCellFinder.TryFindRandomCellNearWith(c, validator, pawn.Map, out IntVec3 lc, 2, 6)) { return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_Kidnap) { targetA = t, targetB = lc, count = 1 }); } } else { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("{0} something went wrong", this)); } } } else { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("{0} No Cocooning spot Found", this)); } } }
protected override Job TryGiveJob(Pawn pawn) { IntVec3 c = default(IntVec3); if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn)) { return(null); } Thing thing = default(Thing); if (StealAIUtility.TryFindBestItemToSteal(pawn.Position, pawn.Map, 12f, out thing, pawn, (List <Thing>)null) && !GenAI.InDangerousCombat(pawn)) { Job job = new Job(JobDefOf.Steal); job.targetA = thing; job.targetB = c; job.count = Mathf.Min(thing.stackCount, (int)(pawn.GetStatValue(StatDefOf.CarryingCapacity, true) / thing.def.VolumePerUnit)); return(job); } return(null); }
public override Job TryGiveJob(Pawn pawn) { float Searchradius = SearchRadius; IntVec3 c = IntVec3.Invalid; if (pawn.kindDef == AdeptusPawnKindDefOf.OG_Necron_Tomb_Spyder) { if (TombSpyderUtility.TryFindGoodRepairTarget(pawn, Searchradius, out Pawn pt, null) && !GenAI.InDangerousCombat(pawn)) { return(new Job(AdeptusJobDefOf.OG_XB_Job_Necron_TombSpyderRepair) { targetA = pt, count = 1 }); } else { if (TombSpyderUtility.TryFindGoodRessTarget(pawn, Searchradius, out Corpse ct, null) && !GenAI.InDangerousCombat(pawn)) { return(new Job(AdeptusJobDefOf.OG_XB_Job_Necron_TombSpyderRepair) { targetA = ct, count = 1 }); } } }
protected override Job TryGiveJob(Pawn pawn) { if (!RCellFinder.TryFindBestExitSpot(pawn, out IntVec3 spot)) { return(null); } if (StealAIUtility.TryFindBestItemToSteal(pawn.Position, pawn.Map, 12f, out Thing item, pawn) && !GenAI.InDangerousCombat(pawn)) { Job job = new Job(JobDefOf.Steal); job.targetA = item; job.targetB = spot; job.count = Mathf.Min(item.stackCount, (int)(pawn.GetStatValue(StatDefOf.CarryingCapacity) / item.def.VolumePerUnit)); return(job); } return(null); }
static bool Prefix(LordToil_DoOpportunisticTaskOrCover __instance) { if (!__instance.cover || Find.TickManager.TicksGame % 181 > RefcellRespeedConfig.currentTimeMultiplier - 1) { return(false); } List <Thing> alreadyTakenTargets = (List <Thing>)null; for (int index = 0; index < __instance.lord.ownedPawns.Count; ++index) { Pawn ownedPawn = __instance.lord.ownedPawns[index]; if (!ownedPawn.Downed && ownedPawn.mindState.duty.def == DutyDefOf.AssaultColony) { Thing target = (Thing)null; if (__instance.TryFindGoodOpportunisticTaskTarget(ownedPawn, out target, alreadyTakenTargets) && !__instance.Map.reservationManager.IsReservedByAnyoneOf((LocalTargetInfo)target, __instance.lord.faction) && !GenAI.InDangerousCombat(ownedPawn)) { ownedPawn.mindState.duty = new PawnDuty(__instance.DutyDef); ownedPawn.jobs.EndCurrentJob(JobCondition.InterruptForced); if (alreadyTakenTargets == null) { alreadyTakenTargets = new List <Thing>(); } alreadyTakenTargets.Add(target); } } } return(false); }
protected override Job TryGiveJob(Pawn pawn) { IntVec3 c; Job result; Thing thing; if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn)) { result = null; } else if (StealAIUtility.TryFindBestItemToSteal(pawn.Position, pawn.Map, 12f, out thing, pawn, null) && !GenAI.InDangerousCombat(pawn)) { result = new Job(JobDefOf.Steal) { targetA = thing, targetB = c, count = Mathf.Min(thing.stackCount, (int)(pawn.GetStatValue(StatDefOf.CarryingCapacity, true) / thing.def.VolumePerUnit)) }; } else { result = null; } return(result); }
static bool Prefix(ref Trigger_KidnapVictimPresent __instance, ref bool __result, ref Lord lord, ref TriggerSignal signal) { if (signal.type == TriggerSignalType.Tick && Find.TickManager.TicksGame % 120 < RefcellRespeedConfig.currentTimeMultiplier) { if (__instance.data == null || !(__instance.data is TriggerData_PawnCycleInd)) { BackCompatibility.TriggerDataPawnCycleIndNull(__instance); } if (Find.TickManager.TicksGame - lord.lastPawnHarmTick > 300) { TriggerData_PawnCycleInd data = __instance.Data; ++data.pawnCycleInd; if (data.pawnCycleInd >= lord.ownedPawns.Count) { data.pawnCycleInd = 0; } if (lord.ownedPawns.Any <Pawn>()) { Pawn ownedPawn = lord.ownedPawns[data.pawnCycleInd]; if (ownedPawn.Spawned && !ownedPawn.Downed && (ownedPawn.MentalStateDef == null && KidnapAIUtility.TryFindGoodKidnapVictim(ownedPawn, 8f, out Pawn _)) && !GenAI.InDangerousCombat(ownedPawn)) { __result = true; return(false); } } } } __result = false; return(false); }
// Token: 0x060004D1 RID: 1233 RVA: 0x0003100C File Offset: 0x0002F40C protected override Job TryGiveJob(Pawn pawn) { float Searchradius = HuntingRange; IntVec3 c = IntVec3.Invalid; if (XenomorphKidnapUtility.TryFindGoodKidnapVictim(pawn, Searchradius, out Pawn t, null) && !GenAI.InDangerousCombat(pawn)) { if (XenomorphKidnapUtility.TryFindGoodHiveLoc(pawn, t, out c)) { ThingDef namedA = XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon; ThingDef namedB = XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon; bool selected = pawn.Map != null?Find.Selector.SelectedObjects.Contains(pawn) && (Prefs.DevMode) : false; if (c != IntVec3.Invalid && t != null && pawn.CanReach(c, PathEndMode.ClosestTouch, Danger.Deadly, true, TraverseMode.PassAllDestroyableThings)) { Predicate <IntVec3> validator = delegate(IntVec3 y) { bool adjacent = c.AdjacentTo8WayOrInside(y); bool filled = y.Filled(pawn.Map); bool edifice = y.GetEdifice(pawn.Map).DestroyedOrNull(); bool building = y.GetFirstBuilding(pawn.Map).DestroyedOrNull(); bool thingA = y.GetFirstThing(pawn.Map, namedA).DestroyedOrNull(); bool thingB = y.GetFirstThing(pawn.Map, namedB).DestroyedOrNull(); //Log.Message(string.Format("{0} {1} {2} {3} {4} {5}", y, !adjacent, !filled, edifice, building, thing)); return(!adjacent && !filled && edifice && building && thingA && thingB); }; bool b = RCellFinder.TryFindRandomCellNearWith(c, validator, pawn.Map, out IntVec3 lc, 6, 12); return(new Job(XenomorphDefOf.RRY_Job_XenomorphKidnap) { targetA = t, targetB = lc, count = 1 }); } else { if (Find.Selector.SelectedObjects.Contains(pawn)) { Log.Message(string.Format("{0} something went wrong", this)); } } } else { if (Find.Selector.SelectedObjects.Contains(pawn)) { Log.Message(string.Format("{0} No Cocooning spot Found", this)); } } }
protected override Job TryGiveJob(Pawn pawn) { IntVec3 c = default(IntVec3); if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn)) { return(null); } Pawn t = default(Pawn); if (KidnapAIUtility.TryFindGoodKidnapVictim(pawn, 18f, out t, (List <Thing>)null) && !GenAI.InDangerousCombat(pawn)) { Job job = new Job(JobDefOf.Kidnap); job.targetA = t; job.targetB = c; job.count = 1; return(job); } return(null); }