protected override IEnumerable<Toil> MakeNewToils() { //this.EndOnDespawned(TargetIndex.A, JobCondition.Succeeded); //this.FailOn(hunterIsKilled); //yield return Toils_Combat.TrySetJobToUseAttackVerb(); //Toil gotoPosition = Toils_Combat.GotoCastPosition(TargetIndex.A); //yield return gotoPosition; //Toil jump = Toils_Jump.JumpIfTargetNotHittable(TargetIndex.A, gotoPosition); //yield return jump; //Log.Message(string.Concat(pawn, " trying to kill ", TargetA)); //yield return Toils_Combat.TrySetJobToUseAttackVerb(); //yield return Toils_Combat.CastVerb(TargetIndex.A); //yield return Toils_Jump.Jump(jump); Toil followAndAttack = new Toil(); followAndAttack.tickAction = () => { Pawn actor = followAndAttack.actor; Job curJob = actor.jobs.curJob; Thing t = curJob.GetTarget(TargetIndex.A).Thing; Pawn pawn2 = t as Pawn; if (pawn.Faction != Faction.OfColony) { actor.mindState.broken.StartBrokenState(DefDatabase<SK_Enviro.AI.BrokenStateDef>.GetNamed("HungerState")); } if (t.Faction == Faction.OfColony) { Find.TickManager.slower.SignalForceNormalSpeedShort(); } if ((t != actor.pather.Destination.Thing) || (!pawn.pather.Moving && !pawn.Position.AdjacentTo8WayOrInside(t))) { actor.pather.StartPath(t, PathEndMode.Touch); } else if (pawn.Position.AdjacentTo8WayOrInside(t)) { if (((t is Pawn) && pawn2.Downed) && !curJob.killIncappedTarget) { EndJobWith(JobCondition.Succeeded); } if (actor.natives.TryMeleeAttack(t)) { this.numMeleeAttacksLanded++; if (numMeleeAttacksLanded >= curJob.maxNumMeleeAttacks) { EndJobWith(JobCondition.Succeeded); } } } }; followAndAttack.defaultCompleteMode = ToilCompleteMode.Never; followAndAttack.EndOnDespawned(TargetIndex.A, JobCondition.Succeeded); followAndAttack.FailOn(hunterIsKilled); yield return followAndAttack; }
protected override IEnumerable<Toil> MakeNewToils() { this.FailOnDestroyed<JobDriver_AnimalEatCorpse>(TargetIndex.A); this.FailOnDespawnedIfNonNull<JobDriver_AnimalEatCorpse>(TargetIndex.A); this.FailOn<JobDriver_AnimalEatCorpse>(eaterIsKilled); Toil resCorpse = new Toil(); resCorpse.initAction = new Action(() => { Pawn actor = resCorpse.actor; Thing target = resCorpse.actor.CurJob.GetTarget(TargetIndex.A).Thing; if (!target.SpawnedInWorld || !Find.Reservations.CanReserve(actor, target, 1)) { actor.jobs.EndCurrentJob(JobCondition.Incompletable); } else { Find.Reservations.Reserve(actor, target, 1); } }); resCorpse.defaultCompleteMode = ToilCompleteMode.Instant; yield return resCorpse; yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch); yield return Toils_General.Wait(60); Toil stripCorpse = new Toil { defaultCompleteMode = ToilCompleteMode.Instant }; stripCorpse.initAction = new Action(doStripCorpse); yield return stripCorpse; yield return Toils_General.Wait(60); Toil chewCorpse = new Toil { defaultCompleteMode = ToilCompleteMode.Instant }; chewCorpse.initAction = new Action(doChewCorpse); chewCorpse.WithEffect(EffecterDef.Named("EatMeat"), TargetIndex.A); chewCorpse.EndOnDespawned(TargetIndex.A); yield return chewCorpse; }
public Toil BashIt() { Toil bashIt = new Toil(); bashIt.tickAction = delegate { Pawn actor = bashIt.actor; Job curJob = actor.jobs.curJob; Thing t = curJob.GetTarget(TargetIndex.B).Thing; if (actor.natives.TryMeleeAttack(t)) { this.numMeleeAttacksLanded++; if (numMeleeAttacksLanded >= curJob.maxNumMeleeAttacks) { EndJobWith(JobCondition.Succeeded); } } }; bashIt.defaultCompleteMode = ToilCompleteMode.Never; bashIt.EndOnDespawned(TargetIndex.B, JobCondition.Succeeded); bashIt.FailOn(hunterIsKilled); return bashIt; }