private void PortalPawn(Pawn pawn) { FleckMaker.ThrowLightningGlow(pawn.DrawPos, pawn.Map, 1f); TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); pawn.DeSpawn(); GenSpawn.Spawn(pawn, this.PortalDestinationPosition, this.PortalDestinationMap); TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); FleckMaker.ThrowHeatGlow(pawn.Position, pawn.Map, 1.6f); }
protected override IEnumerable <Toil> MakeNewToils() { Toil doFor = new Toil() { initAction = () => { this.comp = this.pawn.GetComp <CompAbilityUserMagic>(); this.markedPawn = comp.soulBondPawn; }, tickAction = () => { if (!markedPawn.Spawned) { this.EndJobWith(JobCondition.Succeeded); } if (age > durationTicks) { this.EndJobWith(JobCondition.Succeeded); } if (Find.TickManager.TicksGame % 12 == 0) { TM_MoteMaker.ThrowCastingMote(this.pawn.DrawPos, this.pawn.Map, Rand.Range(1.2f, 2f)); TM_MoteMaker.ThrowShadowMote(markedPawn.DrawPos, markedPawn.Map, Rand.Range(.8f, 1.2f), Rand.Range(-200, 200), Rand.Range(1, 2), Rand.Range(1.5f, 2f)); } if (Find.TickManager.TicksGame % 6 == 0) { TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Siphon, markedPawn.DrawPos, markedPawn.Map, Rand.Range(.15f, .3f), Rand.Range(.2f, .4f), Rand.Range(.1f, .2f), Rand.Range(.3f, .5f), Rand.Range(-300, 300), Rand.Range(.5f, 3f), Rand.Range(-90, 90), 0); } age++; }, defaultCompleteMode = ToilCompleteMode.Never }; doFor.defaultDuration = this.durationTicks; doFor.WithProgressBar(TargetIndex.A, delegate { if (this.pawn.DestroyedOrNull() || this.pawn.Dead || this.pawn.Downed) { return(1f); } return(1f - ((float)doFor.actor.jobs.curDriver.ticksLeftThisToil / this.durationTicks)); }, false, 0f); yield return(doFor); }
//public override bool TryMakePreToilReservations(bool errorOnFailed) //{ // if(TargetA.Thing != null) // { // return true; // } // if (pawn.Reserve(TargetA, this.job, 1, 1, null, errorOnFailed)) // { // return true; // } // return false; //} protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Misc.ThrowColonistAttackingMote(TargetIndex.A)); this.verb = this.pawn.CurJob.verbToUse as Verb_UseAbility; if (base.TargetA.HasThing && base.TargetA.Thing is Pawn && (!pawn.Position.InHorDistOf(base.TargetA.Cell, pawn.CurJob.verbToUse.verbProps.range) || !Verb.UseAbilityProps.canCastInMelee)) { //if (!base.GetActor().IsFighting() ? true : !verb.UseAbilityProps.canCastInMelee && !this.job.endIfCantShootTargetFromCurPos) //{ Toil toil = Toils_Combat.GotoCastPosition(TargetIndex.A, false); yield return(toil); //toil = null; //} } if (this.Context == AbilityContext.Player) { Find.Targeter.targetingSource = this.verb; } Pawn targetPawn = null; if (this.TargetThingA != null) { targetPawn = TargetThingA as Pawn; } if (targetPawn != null) { //yield return Toils_Combat.CastVerb(TargetIndex.A, false); Toil combatToil = new Toil(); //combatToil.FailOnDestroyedOrNull(TargetIndex.A); //combatToil.FailOnDespawnedOrNull(TargetIndex.A); //combatToil.FailOnDowned(TargetIndex.A); //CompAbilityUserMagic comp = this.pawn.GetComp<CompAbilityUserMagic>(); //JobDriver curDriver = this.pawn.jobs.curDriver; combatToil.initAction = delegate { this.verb = combatToil.actor.jobs.curJob.verbToUse as Verb_UseAbility; this.duration = (int)((this.verb.verbProps.warmupTime * 60) * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false)); if (this.pawn.RaceProps.Humanlike) { //if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) //{ // RemoveMimicAbility(verb); //} if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.TM_Psionic)) { PsionicEnergyCost(verb); } if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.DeathKnight)) { HateCost(verb); } if (verb.Ability.CooldownTicksLeft != -1) { this.EndJobWith(JobCondition.Incompletable); } } LocalTargetInfo target = combatToil.actor.jobs.curJob.GetTarget(TargetIndex.A); verb.TryStartCastOn(target, false, true); using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III) { this.pawn.health.RemoveHediff(rec); } } } }; combatToil.tickAction = delegate { if (this.pawn.Downed) { EndJobWith(JobCondition.InterruptForced); } if (Find.TickManager.TicksGame % 12 == 0) { if (verb.Ability.Def == TorannMagicDefOf.TM_Artifact_TraitThief || verb.Ability.Def == TorannMagicDefOf.TM_Artifact_TraitInfuse) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi_Arcane"), pawn.DrawPos, pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } else { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); } } this.duration--; if (!wildCheck && this.duration <= 6) { wildCheck = true; if (this.pawn.story != null && this.pawn.story.traits != null && this.pawn.story.traits.HasTrait(TorannMagicDefOf.ChaosMage) && Rand.Chance(.1f)) { verb.Ability.PostAbilityAttempt(); TM_Action.DoWildSurge(this.pawn, this.pawn.GetComp <CompAbilityUserMagic>(), (MagicAbility)verb.Ability, (TMAbilityDef)verb.Ability.Def, TargetA); EndJobWith(JobCondition.InterruptForced); } } }; combatToil.AddFinishAction(delegate { if (this.duration <= 5 && !this.pawn.DestroyedOrNull() && !this.pawn.Dead && !this.pawn.Downed) { //ShootLine shootLine; //bool validTarg = verb.TryFindShootLineFromTo(pawn.Position, TargetLocA, out shootLine); //bool inRange = (pawn.Position - TargetLocA).LengthHorizontal < verb.verbProps.range; //if (inRange && validTarg) //{ verb.Ability.PostAbilityAttempt(); this.pawn.ClearReservationsForJob(this.job); //} } }); //if (combatToil.actor.CurJob != this.job) //{ // curDriver.ReadyForNextToil(); //} combatToil.defaultCompleteMode = ToilCompleteMode.FinishedBusy; this.pawn.ClearReservationsForJob(this.job); yield return(combatToil); //Toil toil2 = new Toil() //{ // initAction = () => // { // if (curJob.UseAbilityProps.isViolent) // { // JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn); // } // }, // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil2; //Toil toil1 = new Toil() //{ // initAction = () => curJob.Ability.PostAbilityAttempt(), // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil1; } else { if ((pawn.Position - TargetLocA).LengthHorizontal < verb.verbProps.range) { if (TargetLocA.IsValid && TargetLocA.InBounds(pawn.Map) && !TargetLocA.Fogged(pawn.Map)) //&& TargetLocA.Walkable(pawn.Map) { ShootLine shootLine; bool validTarg = verb.TryFindShootLineFromTo(pawn.Position, TargetLocA, out shootLine); if (validTarg) { //yield return Toils_Combat.CastVerb(TargetIndex.A, false); //Toil toil2 = new Toil() //{ // initAction = () => // { // if (curJob.UseAbilityProps.isViolent) // { // JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn); // } // }, // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil2; this.duration = (int)((verb.verbProps.warmupTime * 60) * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false)); Toil toil = new Toil(); toil.initAction = delegate { this.verb = toil.actor.jobs.curJob.verbToUse as Verb_UseAbility; if (this.pawn.RaceProps.Humanlike) { //if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) //{ // RemoveMimicAbility(verb); //} if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.TM_Psionic)) { PsionicEnergyCost(verb); } if (verb.Ability.CooldownTicksLeft != -1) { this.EndJobWith(JobCondition.Incompletable); } } LocalTargetInfo target = toil.actor.jobs.curJob.GetTarget(TargetIndex.A); //TargetLocA; // bool canFreeIntercept2 = false; verb.TryStartCastOn(target, false, canFreeIntercept2); using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III) { this.pawn.health.RemoveHediff(rec); } } } }; toil.tickAction = delegate { if (Find.TickManager.TicksGame % 12 == 0) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); } this.duration--; if (!wildCheck && this.duration <= 6) { wildCheck = true; if (this.pawn.story != null && this.pawn.story.traits != null && this.pawn.story.traits.HasTrait(TorannMagicDefOf.ChaosMage) && Rand.Chance(.1f)) { bool completeJob = TM_Action.DoWildSurge(this.pawn, this.pawn.GetComp <CompAbilityUserMagic>(), (MagicAbility)verb.Ability, (TMAbilityDef)verb.Ability.Def, TargetA); if (!completeJob) { verb.Ability.PostAbilityAttempt(); EndJobWith(JobCondition.InterruptForced); } } } }; toil.AddFinishAction(delegate { if (this.duration <= 5 && !this.pawn.DestroyedOrNull() && !this.pawn.Dead && !this.pawn.Downed) { verb.Ability.PostAbilityAttempt(); } this.pawn.ClearReservationsForJob(this.job); }); toil.defaultCompleteMode = ToilCompleteMode.FinishedBusy; yield return(toil); //Toil toil1 = new Toil() //{ // initAction = () => curJob.Ability.PostAbilityAttempt(), // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil1; } else { //No LoS if (pawn.IsColonist) { Messages.Message("TM_OutOfLOS".Translate( pawn.LabelShort ), MessageTypeDefOf.RejectInput); } pawn.ClearAllReservations(false); } } else { pawn.ClearAllReservations(false); } } else { if (pawn.IsColonist) { //out of range Messages.Message("TM_OutOfRange".Translate(), MessageTypeDefOf.RejectInput); } } } }
protected override IEnumerable <Toil> MakeNewToils() { CompAbilityUserMagic comp = this.pawn.GetComp <CompAbilityUserMagic>(); Toil discordance = new Toil(); Pawn target = this.TargetThingA as Pawn; discordance.initAction = delegate { if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } if (target.DestroyedOrNull()) { this.EndJobWith(JobCondition.Errored); } if (target.Map == null) { this.EndJobWith(JobCondition.Errored); } if (target.Dead) { this.EndJobWith(JobCondition.Succeeded); } Map map = this.pawn.Map; ticksLeftThisToil = 10; headDamageCount = 0; }; discordance.tickAction = delegate { if (Find.TickManager.TicksGame % this.moteFrequency == 0) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); float angle = Rand.Range(0, 360); ThingDef mote = TorannMagicDefOf.Mote_Psi_Grayscale; TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Psi_Grayscale, this.pawn.DrawPos, this.pawn.Map, Rand.Range(.25f, .6f), .1f, .05f, .05f, 0, Rand.Range(4f, 6f), angle, angle); } if (Find.TickManager.TicksGame % this.discordFrequency == 0) { Vector3 headPos = target.DrawPos; headPos.z += .3f; TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Bolt, headPos, target.Map, .6f, .5f, .1f, .5f, Rand.Range(-10, 10), Rand.Range(.4f, .6f), Rand.Range(-90, 90), Rand.Range(0, 360)); float manaCost = comp.ActualManaCost(TorannMagicDefOf.TM_Discord); if (comp.Mana.CurLevel >= manaCost && !target.DestroyedOrNull() && !target.Dead && target.Map != null) { comp.Mana.CurLevel -= manaCost; float ch = TM_Calc.GetSpellSuccessChance(this.pawn, target, true); if (target.Faction == this.pawn.Faction) { HealthUtility.AdjustSeverity(target, TorannMagicDefOf.TM_DiscordSafeHD, .4f * ch); Hediff hd = target.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_DiscordHD); if (hd != null && hd.Severity > 5) { if (Rand.Chance(.2f)) { TM_Action.DamageEntities(target, null, 6, DamageDefOf.Stun, this.pawn); } } } else { HealthUtility.AdjustSeverity(target, TorannMagicDefOf.TM_DiscordHD, .4f * ch); Hediff hd = target.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_DiscordHD); if (hd != null && hd.Severity > 5) { BodyPartRecord bpr = target.health.hediffSet.GetBrain(); BodyPartRecord head = target.health.hediffSet.GetNotMissingParts().FirstOrDefault((BodyPartRecord x) => x.def == BodyPartDefOf.Head); if (bpr != null) { if (Rand.Chance(.22f * ch)) { for (int i = 0; i < 2; i++) { TM_MoteMaker.ThrowBloodSquirt(headPos, target.Map, Rand.Range(.6f, 1f)); } TM_Action.DamageEntities(target, bpr, Rand.Range(1, 3), 2f, TMDamageDefOf.DamageDefOf.TM_DistortionDD, this.pawn); headDamageCount++; } else if (Rand.Chance((.07f * ch) + (headDamageCount * .3f)) && head != null) { for (int i = 0; i < 3; i++) { TM_MoteMaker.ThrowBloodSquirt(headPos, target.Map, Rand.Range(.6f, 1f)); } for (int i = 0; i < 3; i++) { float moteSize = Rand.Range(.5f, .8f); float solidTime = Rand.Range(.6f, .8f); float fadeOutTime = Rand.Range(.2f, .4f); float velocity = Rand.Range(1.5f, 2.5f); float velocityAngle = Rand.Range(0f, 360f); for (int j = 0; j < 3; j++) { TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BloodSquirt, headPos, target.Map, moteSize - (.1f * j), solidTime + (.1f * j), 0f, fadeOutTime + (.05f * j), Rand.Range(-50, 50), velocity + (.5f * j), velocityAngle, Rand.Range(0, 360)); } } TM_Action.DamageEntities(target, head, Rand.Range(50, 80), 2f, TMDamageDefOf.DamageDefOf.TM_DistortionDD, this.pawn); } } } } if (target.Dead) { this.age = this.duration; } } else { this.age = this.duration; } } age++; ticksLeftThisToil = Mathf.RoundToInt((float)(duration - age) / (float)duration * 100f); if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } }; discordance.defaultCompleteMode = ToilCompleteMode.Delay; discordance.defaultDuration = this.duration; discordance.WithProgressBar(TargetIndex.A, delegate { if (this.pawn.DestroyedOrNull() || this.pawn.Dead || this.pawn.Downed) { return(1f); } return(1f - ((float)discordance.actor.jobs.curDriver.ticksLeftThisToil / 100)); }, false, 0f); discordance.AddFinishAction(delegate { }); yield return(discordance); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(building); Toil reserveTargetA = Toils_Reserve.Reserve(building); yield return(reserveTargetA); comp = this.pawn.GetComp <CompAbilityUserMagic>(); portalBldg = TargetA.Thing as Building_TMPortal; arcaneCapacitor = TargetA.Thing as Building_TMArcaneCapacitor; dmp = TargetA.Thing as Building_TM_DMP; bldg = TargetA.Thing as Building; Toil gotoPortal = new Toil() { initAction = () => { //pawn.pather.StartPath(portalBldg.InteractionCell, PathEndMode.OnCell); if (pawn.pather != null && bldg.InteractionCell != null) { pawn.pather.StartPath(bldg.InteractionCell, PathEndMode.OnCell); } }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return(gotoPortal); Toil chargePortal = new Toil() { initAction = () => { if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } if (comp != null && comp.Mana != null && comp.Mana.CurLevel < .01f) { this.EndJobWith(JobCondition.Succeeded); } else if (bldg.def.defName == "TM_DimensionalManaPocket") { this.duration = 220; } }, tickAction = () => { if (age > (effectsAge + ticksTillEffects)) { this.effectsAge = this.age; TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); Vector3 moteDirection = TM_Calc.GetVector(this.pawn.Position, bldg.Position); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Shadow, pawn.DrawPos, pawn.Map, Rand.Range(.4f, .6f), Rand.Range(.1f, .2f), .04f, Rand.Range(.1f, .2f), 300, 5f, (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); } if (age > (chargeAge + ticksTillCharge)) { if (bldg.def.defName == "TM_Portal") { comp.Mana.CurLevel -= .01f; portalBldg.ArcaneEnergyCur += .01f; xpNum += 3; } else if (bldg.def.defName == "TM_ArcaneCapacitor") { comp.Mana.CurLevel -= .01f; arcaneCapacitor.ArcaneEnergyCur += 1f; } else if (bldg.def.defName == "TM_DimensionalManaPocket") { comp.Mana.CurLevel -= .05f; dmp.ArcaneEnergyCur += 4f; age += 4; } else { age = duration; } chargeAge = age; } age++; if (age > duration) { AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } if (comp.Mana.CurLevel < .1f) { AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } if (comp.Mana.CurLevel < .05f && bldg.def.defName == "TM_DimensionalManaPocket") { //AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } if (portalBldg != null && portalBldg.ArcaneEnergyCur >= 1f) { AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } if (arcaneCapacitor != null && arcaneCapacitor.ArcaneEnergyCur >= arcaneCapacitor.TargetArcaneEnergyPct) { //AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } if (dmp != null && dmp.ArcaneEnergyCur >= dmp.TargetArcaneEnergyPct) { //AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } }, defaultCompleteMode = ToilCompleteMode.Never }; yield return(chargePortal); }
protected override IEnumerable <Toil> MakeNewToils() { bool flag; yield return(Toils_Misc.ThrowColonistAttackingMote(TargetIndex.A)); Verb_UseAbility curJob = this.pawn.CurJob.verbToUse as Verb_UseAbility; if (base.TargetA.HasThing) { flag = (!base.GetActor().IsFighting() ? true : !curJob.UseAbilityProps.canCastInMelee); if (flag) { Toil toil = Toils_Combat.GotoCastPosition(TargetIndex.A, false); yield return(toil); toil = null; } } if (this.Context == AbilityContext.Player) { Find.Targeter.targetingVerb = curJob; } Pawn targetPawn = null; if (this.TargetThingA != null) { targetPawn = TargetThingA as Pawn; } if (targetPawn != null) { //yield return Toils_Combat.CastVerb(TargetIndex.A, false); Toil combatToil = new Toil(); combatToil.FailOnDestroyedOrNull(TargetIndex.A); combatToil.FailOnDespawnedOrNull(TargetIndex.A); //combatToil.FailOnDowned(TargetIndex.A); //CompAbilityUserMagic comp = this.pawn.GetComp<CompAbilityUserMagic>(); this.duration = (int)((curJob.verbProps.warmupTime * 60) * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false)); //JobDriver curDriver = this.pawn.jobs.curDriver; combatToil.initAction = delegate { arg_45_0 = combatToil.actor.jobs.curJob.verbToUse; if (this.pawn.RaceProps.Humanlike) { if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { CompAbilityUserMight mightComp = this.pawn.GetComp <CompAbilityUserMight>(); CompAbilityUserMagic magicComp = this.pawn.GetComp <CompAbilityUserMagic>(); if (mightComp.mimicAbility != null && mightComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { mightComp.RemovePawnAbility(mightComp.mimicAbility); } if (magicComp.mimicAbility != null && magicComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { magicComp.RemovePawnAbility(magicComp.mimicAbility); } } } LocalTargetInfo target = combatToil.actor.jobs.curJob.GetTarget(TargetIndex.A); // bool canFreeIntercept2 = false; arg_45_0.TryStartCastOn(target, false, false); using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III) { this.pawn.health.RemoveHediff(rec); } } } }; combatToil.tickAction = delegate { if (Find.TickManager.TicksGame % 12 == 0) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); } this.duration--; }; combatToil.AddFinishAction(delegate { if (this.duration <= 5) { curJob.Ability.PostAbilityAttempt(); } }); //if (combatToil.actor.CurJob != this.job) //{ // curDriver.ReadyForNextToil(); //} combatToil.defaultCompleteMode = ToilCompleteMode.FinishedBusy; yield return(combatToil); //Toil toil2 = new Toil() //{ // initAction = () => // { // if (curJob.UseAbilityProps.isViolent) // { // JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn); // } // }, // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil2; //Toil toil1 = new Toil() //{ // initAction = () => curJob.Ability.PostAbilityAttempt(), // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil1; } else { if ((pawn.Position - TargetLocA).LengthHorizontal < curJob.verbProps.range) { if (TargetLocA.IsValid && TargetLocA.InBounds(pawn.Map) && !TargetLocA.Fogged(pawn.Map) && TargetLocA.Walkable(pawn.Map)) { ShootLine shootLine; bool validTarg = curJob.TryFindShootLineFromTo(pawn.Position, TargetLocA, out shootLine); if (validTarg) { //yield return Toils_Combat.CastVerb(TargetIndex.A, false); //Toil toil2 = new Toil() //{ // initAction = () => // { // if (curJob.UseAbilityProps.isViolent) // { // JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn); // } // }, // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil2; this.duration = (int)((curJob.verbProps.warmupTime * 60) * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false)); Toil toil = new Toil(); toil.initAction = delegate { arg_45_0 = toil.actor.jobs.curJob.verbToUse; if (this.pawn.RaceProps.Humanlike) { if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { CompAbilityUserMight mightComp = this.pawn.GetComp <CompAbilityUserMight>(); CompAbilityUserMagic magicComp = this.pawn.GetComp <CompAbilityUserMagic>(); if (mightComp.mimicAbility != null && mightComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { mightComp.RemovePawnAbility(mightComp.mimicAbility); } if (magicComp.mimicAbility != null && magicComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { magicComp.RemovePawnAbility(magicComp.mimicAbility); } } } LocalTargetInfo target = toil.actor.jobs.curJob.GetTarget(TargetIndex.A); bool canFreeIntercept2 = false; arg_45_0.TryStartCastOn(target, false, canFreeIntercept2); using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III) { this.pawn.health.RemoveHediff(rec); } } } }; toil.tickAction = delegate { if (Find.TickManager.TicksGame % 12 == 0) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); } this.duration--; }; toil.AddFinishAction(delegate { if (this.duration <= 5) { curJob.Ability.PostAbilityAttempt(); } }); toil.defaultCompleteMode = ToilCompleteMode.FinishedBusy; yield return(toil); //Toil toil1 = new Toil() //{ // initAction = () => curJob.Ability.PostAbilityAttempt(), // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil1; } else { //No LoS if (pawn.IsColonist) { Messages.Message("TM_OutOfLOS".Translate(new object[] { pawn.LabelShort }), MessageTypeDefOf.RejectInput); } } } } else { if (pawn.IsColonist) { //out of range Messages.Message("TM_OutOfRange".Translate(), MessageTypeDefOf.RejectInput); } } } }
protected override IEnumerable<Toil> MakeNewToils() { this.FailOnDestroyedOrNull(building); Toil reserveTargetA = Toils_Reserve.Reserve(building); yield return reserveTargetA; comp = pawn.GetComp<CompAbilityUserMagic>(); portalBldg = TargetA.Thing as Building_TMPortal; Toil gotoPortal = new Toil() { initAction = () => { pawn.pather.StartPath(portalBldg.InteractionCell, PathEndMode.OnCell); }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return gotoPortal; Toil chargePortal = new Toil() { initAction = () => { if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } if(comp.Mana.CurLevel < .01f) { this.EndJobWith(JobCondition.Succeeded); } }, tickAction = () => { if (age > (effectsAge + ticksTillEffects)) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Shadow, pawn.DrawPos, pawn.Map, Rand.Range(.4f, .6f), Rand.Range(.1f, .2f), .04f, Rand.Range(.1f, .2f), 300, 5f, Rand.Range(-10, 10), 0); } if (age > (chargeAge + ticksTillCharge)) { comp.Mana.CurLevel -= .01f; portalBldg.ArcaneEnergyCur += .01f; chargeAge = age; } age++; if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } if (comp.Mana.CurLevel < .01f) { this.EndJobWith(JobCondition.Succeeded); } if (portalBldg.ArcaneEnergyCur >= 1f) { this.EndJobWith(JobCondition.Succeeded); } }, defaultCompleteMode = ToilCompleteMode.Never }; yield return chargePortal; }
protected override IEnumerable <Toil> MakeNewToils() { if (TargetA.Thing != null) { targetThing = TargetA.Thing; } Toil gotoThing = new Toil() { initAction = () => { pawn.pather.StartPath(TargetA, PathEndMode.Touch); }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return(gotoThing); Toil doSpell = new Toil(); doSpell.initAction = delegate { if (ability != null) { this.duration = (int)(ability.Def.MainVerb.warmupTime * 60 * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false)); } if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } if (targetThing != null && (targetThing.DestroyedOrNull() || targetThing.Map == null)) { this.EndJobWith(JobCondition.Incompletable); } if (targetThing != null) { this.pawn.rotationTracker.FaceTarget(targetThing); } }; doSpell.tickAction = delegate { if (targetThing != null && (targetThing.DestroyedOrNull() || targetThing.Map == null)) { this.EndJobWith(JobCondition.Incompletable); } age++; ticksLeftThisToil = duration - age; if (Find.TickManager.TicksGame % 12 == 0) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); } if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } }; doSpell.defaultCompleteMode = ToilCompleteMode.Never; doSpell.defaultDuration = this.duration; doSpell.AddFinishAction(delegate { if (ability != null) { if (ability.Def == TorannMagicDefOf.TM_Transmutate && targetThing != null) { bool flagRawResource = false; bool flagStuffItem = false; bool flagNoStuffItem = false; bool flagNutrition = false; bool flagCorpse = false; TM_Calc.GetTransmutableThingFromCell(targetThing.Position, pawn, out flagRawResource, out flagStuffItem, out flagNoStuffItem, out flagNutrition, out flagCorpse); TM_Action.DoTransmutate(pawn, targetThing, flagNoStuffItem, flagRawResource, flagStuffItem, flagNutrition, flagCorpse); } else if (ability.Def == TorannMagicDefOf.TM_RegrowLimb) { AbilityUser.SpawnThings tempThing = new SpawnThings(); tempThing.def = ThingDef.Named("SeedofRegrowth"); Verb_RegrowLimb.SingleSpawnLoop(tempThing, TargetA.Cell, pawn.Map); } ability.PostAbilityAttempt(); } //AssignXP(); }); yield return(doSpell); }