protected override IEnumerable <Toil> MakeNewToils() { Toil to = new Toil() { initAction = delegate { ticksLeft = Rand.Range(300, 900); int num = 0; IntVec3 c; while (true) { c = pawn.Position + GenAdj.AdjacentCellsAndInside[Rand.Range(0, 9)]; num++; if (num > 12) { break; } if (c.InBounds(pawn.Map) && c.Standable(pawn.Map)) { goto IL_A1; } } c = pawn.Position; IL_A1: pawn.CurJob.targetA = c; pawn.Drawer.rotator.FaceCell(c); pawn.pather.StopDead(); }, tickAction = delegate { int curTicks = ticksLeft; if (curTicks % 150 == 149) { FilthMaker.MakeFilth(pawn.CurJob.targetA.Cell, pawn.Map, ThingDefOf.FilthBlood, pawn.LabelIndefinite(), 1); if (pawn.BloodNeed() is Need_Blood n && n.CurBloodPoints > 0) { n.AdjustBlood(-1); } } ticksLeft--; if (curTicks - 1 <= 0) { ReadyForNextToil(); TaleRecorder.RecordTale(TaleDefOf.Vomited, new object[] { pawn }); } } }; to.defaultCompleteMode = ToilCompleteMode.Never; to.WithEffect(EffecterDef.Named("ROMV_BloodVomit"), TargetIndex.A); to.PlaySustainerOrSound(() => SoundDef.Named("Vomit")); yield return(to); }
/// <summary> /// Start or maintain the laser drill effecter. /// </summary> public void StartOrMaintainLaserDrillEffecter() { if (this.laserDrillEffecter == null) { this.laserDrillEffecter = new Effecter(EffecterDef.Named("LaserDrill")); } else { this.laserDrillEffecter.EffectTick(new TargetInfo(this.targetPosition, this.Map), new TargetInfo(this.Position, this.Map)); } }
/* Look for mineable resources and add them to the Mine */ public static void Setup() { // localized title-case capitalization class CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; // usage: textInfo.ToTitleCase(string) List <RecipeDef> RecipeDefs = DefDatabase <RecipeDef> .AllDefsListForReading; List <ThingDef> ThingDefs = DefDatabase <ThingDef> .AllDefsListForReading; // scan all the things for (int someThing = 0; someThing < ThingDefs.Count; someThing++) { // select things with deep commonality if (ThingDefs[someThing].deepCommonality > 0) { // Create recipe RecipeDef recipe = new RecipeDef(); recipe.defName = "Excavate".Translate(ThingDefs[someThing].defName); Log.Message("LogMessageFoundResource".Translate(ThingDefs[someThing].label) + "LogMessageAddedRecipe".Translate(recipe.defName)); recipe.label = "Mine".Translate(ThingDefs[someThing].label, " "); recipe.description = "Mine".Translate(ThingDefs[someThing].label, "."); recipe.jobString = "Mining".Translate(ThingDefs[someThing].label); recipe.effectWorking = EffecterDef.Named("Smith"); recipe.efficiencyStat = StatDefOf.MiningSpeed; recipe.workAmount = 332 * ThingDefs[someThing].GetStatValueAbstract(StatDefOf.MarketValue, null); recipe.workSkill = SkillDefOf.Mining; recipe.workSkillLearnFactor = 0.25f; recipe.products.Add(new ThingCountClass(ThingDefs[someThing], 1)); recipe.fixedIngredientFilter = new ThingFilter(); recipe.defaultIngredientFilter = new ThingFilter(); // add bill to mineshaft recipe.recipeUsers = new List <ThingDef>(); recipe.recipeUsers.Add(ThingDef.Named("Mineshaft")); RecipeDefs.Add(recipe); } // has deepCommonality } // loop through things } // Setup
private float ApplyToPawn(DamageInfo dinfo, Pawn pawn) { if (dinfo.Amount <= 0) { return(0f); } if (!DebugSettings.enablePlayerDamage && pawn.Faction == Faction.OfPlayer) { return(0f); } if (!dinfo.Part.HasValue) { dinfo.SetPart(new BodyPartDamageInfo(null, null)); } DamageWorker_AddInjuryCR.LocalInjuryResult localInjuryResult = DamageWorker_AddInjuryCR.LocalInjuryResult.MakeNew(); if (dinfo.Def.spreadOut) { if (pawn.apparel != null) { List <Apparel> wornApparel = pawn.apparel.WornApparel; for (int i = wornApparel.Count - 1; i >= 0; i--) { this.CheckApplySpreadDamage(dinfo, wornApparel[i]); } } if (pawn.equipment != null && pawn.equipment.Primary != null) { this.CheckApplySpreadDamage(dinfo, pawn.equipment.Primary); } if (pawn.inventory != null) { ThingContainer container = pawn.inventory.container; for (int j = container.Count - 1; j >= 0; j--) { this.CheckApplySpreadDamage(dinfo, container[j]); } } } if (!this.FragmentDamageForDamageType(dinfo, pawn, ref localInjuryResult)) { this.ApplyDamagePartial(dinfo, pawn, ref localInjuryResult); this.CheckDuplicateSmallPawnDamageToPartParent(dinfo, pawn, ref localInjuryResult); } if (localInjuryResult.wounded) { DamageWorker_AddInjuryCR.PlayWoundedVoiceSound(dinfo, pawn); pawn.Drawer.Notify_DamageApplied(dinfo); DamageWorker_AddInjuryCR.InformPsychology(dinfo, pawn); } if (localInjuryResult.headshot && pawn.Spawned) { MoteThrower.ThrowText(new Vector3((float)pawn.Position.x + 1f, (float)pawn.Position.y, (float)pawn.Position.z + 1f), "Headshot".Translate(), Color.white, -1); if (dinfo.Instigator != null) { Pawn pawn2 = dinfo.Instigator as Pawn; if (pawn2 != null) { pawn2.records.Increment(RecordDefOf.Headshots); } } } if (localInjuryResult.absorbed) { if (pawn.health.deflectionEffecter == null) { pawn.health.deflectionEffecter = EffecterDef.Named("ArmorRating").Spawn(); } pawn.health.deflectionEffecter.Trigger(pawn, pawn); } else { ImpactSoundUtility.PlayImpactSound(pawn, dinfo.Def.impactSoundType); } return(localInjuryResult.totalDamageDealt); }
protected override IEnumerable <Toil> MakeNewToils() { var checkIncaseJobWasCancelledPreviously = new Toil { initAction = () => { var curMap = this.GetActor().MapHeld; var lastCorpse = curMap.listerThings.AllThings.FirstOrDefault(x => x is Corpse c && c.InnerPawn.health.hediffSet.HasHediff(UvhashDefOf.Uvhash_TattooParalysis)); if (lastCorpse != null) { this.job.SetTarget(TargetIndex.A, lastCorpse); } } }; var prepareToTransformCorpse = new Toil(); prepareToTransformCorpse.initAction = delegate { Pawn actor = prepareToTransformCorpse.actor; Corpse corpse = this.Corpse; if (corpse == null) { Pawn prey = this.Prey; if (prey == null) { actor.jobs.EndCurrentJob(JobCondition.Incompletable, true); return; } corpse = prey.Corpse; if (corpse == null || !corpse.Spawned) { actor.jobs.EndCurrentJob(JobCondition.Incompletable, true); return; } } corpse.SetForbidden(actor.Faction != Faction.OfPlayer, false); actor.CurJob.SetTarget(TargetIndex.A, corpse); }; var goToCorpse = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch); var goToPreyPos = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch); var gotoCastPos = Toils_Combat.GotoCastPosition(TargetIndex.A, true).JumpIfDespawnedOrNull(TargetIndex.A, prepareToTransformCorpse).FailOn(() => Find.TickManager.TicksGame > this.jobStartTick + 5000); var moveIfCannotHit = Toils_Jump.JumpIfTargetNotHittable(TargetIndex.A, goToPreyPos); var castSpell = new Toil { defaultCompleteMode = ToilCompleteMode.Delay }; castSpell.WithProgressBarToilDelay(TargetIndex.A); castSpell.defaultDuration = 1200; castSpell.AddPreInitAction(() => { curReport = "BloodMage_CastingOn".Translate(TargetA.Thing.Label); moteThrown = UvhashUtility.ThrowMagicMote(1f, this.GetActor()); moteThrown.LifeSpanOffset += 99999f; moteTarget.LifeSpanOffset += 99999f; moteTarget = UvhashUtility.ThrowMagicMote(TargetA.Thing.def.race.baseBodySize, TargetA.Thing); }); castSpell.tickAction = () => { if (moteThrown != null) { moteThrown.exactPosition = this.GetActor().DrawPos; } if (moteTarget != null) { moteTarget.exactPosition = TargetA.Thing.DrawPos; } if (Find.TickManager.TicksGame % 15 == 0) { MoteMaker.ThrowText(this.GetActor().DrawPos + new Vector3(new FloatRange(-1, 1).RandomInRange, 0, new FloatRange(-1, 1).RandomInRange), this.GetActor().MapHeld, cultMadText.RandomElement(), Color.red); //MoteMaker.ThrowText(this.TargetA.Thing.DrawPos + new Vector3(new FloatRange(-1, 1).RandomInRange, 0, new FloatRange(-1, 1).RandomInRange), this.GetActor().MapHeld, cultMadText.RandomElement(), Color.red); } }; castSpell.PlaySustainerOrSound(UvhashDefOf.Uvhash_BloodMagicCastingSustainer); castSpell.AddFinishAction(() => { if (!Prey.Downed) { HealthUtility.AdjustSeverity(Prey, UvhashDefOf.Uvhash_TattooParalysis, 1.0f); } curReport = ""; if (moteThrown != null) { moteThrown.LifeSpanOffset -= 999999f; } if (moteTarget != null) { moteTarget.LifeSpanOffset -= 999999f; } }); var executeTarget = new Toil { defaultCompleteMode = ToilCompleteMode.Delay }; executeTarget.WithProgressBarToilDelay(TargetIndex.B); executeTarget.defaultDuration = 200; executeTarget.AddFinishAction(() => { ExecutionUtility.DoExecutionByCut(this.GetActor(), Prey); }); Toil transformCorpse = new Toil(); transformCorpse.defaultCompleteMode = ToilCompleteMode.Delay; transformCorpse.WithEffect(() => EffecterDef.Named("ButcherFlesh"), TargetIndex.A); transformCorpse.WithProgressBarToilDelay(TargetIndex.A); transformCorpse.defaultDuration = 800; transformCorpse.AddPreInitAction(() => { Messages.Message("BloodBookCreation_Message".Translate(new object[] { this.pawn.LabelCap, this.Prey.Label }), MessageTypeDefOf.NeutralEvent); }); var destroyCorpseAndSpawnBook = new Toil(); destroyCorpseAndSpawnBook.initAction = () => { var corpsePos = Corpse.PositionHeld; var corpseMap = Corpse.MapHeld; Corpse.Destroy(); FilthMaker.MakeFilth(corpsePos, corpseMap, ThingDefOf.FilthBlood, Rand.Range(1, 2)); for (int i = 0; i < 10; i++) { FilthMaker.MakeFilth(corpsePos.RandomAdjacentCell8Way(), corpseMap, ThingDefOf.FilthBlood, Rand.Range(1, 2)); this.GetActor().filth.GainFilth(ThingDefOf.FilthBlood); } var book = (ThingWithComps_LiberCruoris)ThingMaker.MakeThing(UvhashDefOf.Uvhash_LiberCruoris); GenPlace.TryPlaceThing(book, corpsePos, corpseMap, ThingPlaceMode.Near); Find.World.GetComponent <WorldComponent_Uvhash>().CurrentCrystalStage = CrystalStage.BookCreated; this.GetActor().MentalState.RecoverFromState(); this.GetActor().TryGetComp <CompBloodMage>().BloodMageLevel = 1; UvhashUtility.ShowMessageBox("BloodBookCreatedDesc".Translate(this.GetActor()).AdjustedFor(this.GetActor()), "BloodBookCreated".Translate()); }; yield return(new Toil { initAction = delegate { this.jobStartTick = Find.TickManager.TicksGame; } }); yield return(checkIncaseJobWasCancelledPreviously); yield return(Toils_Jump.JumpIf(goToCorpse, () => Prey.Dead)); yield return(Toils_Jump.JumpIf(goToPreyPos, () => Prey.Downed)); yield return(Toils_Combat.TrySetJobToUseAttackVerb()); yield return(gotoCastPos.FailOn(() => this.GetActor().IsFighting())); yield return(castSpell); yield return(goToPreyPos); yield return(executeTarget); yield return(prepareToTransformCorpse); yield return(goToCorpse); yield return(transformCorpse); yield return(destroyCorpseAndSpawnBook); this.AddFinishAction(() => { if (moteThrown != null) { moteThrown.LifeSpanOffset -= 999999f; } if (moteTarget != null) { moteTarget.LifeSpanOffset -= 999999f; } }); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.A); //Define Toil maxTicks = Rand.Range(60, 600); ticksLeft = maxTicks; willPee = maxTicks > 500; toilHunkerDown = new Toil { initAction = delegate { //int num = 0; //IntVec3 intVec; //while (true) //{ // intVec = pawn.Position + GenAdj.AdjacentCellsAndInside[Rand.Range(0, 9)]; // num++; // if (num > 12) // { // intVec = pawn.Position; // break; // } // if (intVec.InBounds() && intVec.Standable()) // { // break; // } //} //pawn.CurJob.targetB = intVec; //pawn.Drawer.rotator.FaceCell(intVec); toilHunkerDown.actor.pather.StopDead(); }, tickAction = delegate { ticksLeft--; if (willPee) { if (ticksLeft % maxTicks == maxTicks - 1) { // MoteMaker.ThrowMetaIcon(pawn.Position, ThingDefOf.Mote_Heart); // FilthMaker.MakeFilth(pawn.CurJob.targetB.Cell, CR_ThingDefOf.FilthPee, pawn.LabelIndefinite(), 1); FilthMaker.MakeFilth(pawn.Position, pawn.Map, CR_ThingDefOf.FilthPee, pawn.LabelIndefinite(), 1); } } if (ticksLeft <= 0) { ReadyForNextToil(); if (willPee) { TaleRecorder.RecordTale(WetHimself, pawn); } } }, defaultCompleteMode = ToilCompleteMode.Never, }; CompSuppressable comp = pawn.TryGetComp <CompSuppressable>(); toilHunkerDown.FailOn(() => comp == null); if (comp != null) { float distToSuppressor = (pawn.Position - comp.suppressorLoc).LengthHorizontal; toilHunkerDown.FailOn(() => distToSuppressor < CompSuppressable.minSuppressionDist); toilHunkerDown.FailOn(() => !comp.isHunkering); } // bug can get the willPee if it's initialized, define the bool more accessable if (willPee) { toilHunkerDown.WithEffect(EffecterDef.Named("Pee"), TargetIndex.A); } // Start Toil yield return(toilHunkerDown); if (GetCoverPositionFrom(pawn, comp.suppressorLoc, maxCoverDist * 1.5f, out coverPosition) && Rand.Value > 0.5) { if (coverPosition != pawn.Position) { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.actor; actor.Map.pawnDestinationManager.ReserveDestinationFor(pawn, coverPosition); actor.pather.StartPath(coverPosition, PathEndMode.OnCell); }; toil.defaultCompleteMode = ToilCompleteMode.PatherArrival; // Shame, shame, shame, shame! if (willPee) { toil.WithEffect(EffecterDef.Named("Pee"), TargetIndex.A); } yield return(toil); } } yield break; }