public override void CompPostMerged(Hediff other) { base.CompPostMerged(other); HediffComp_Disappears hediffComp_Disappears = other.TryGetComp <HediffComp_Disappears>(); if (hediffComp_Disappears != null && hediffComp_Disappears.ticksToDisappear > this.ticksToDisappear) { this.ticksToDisappear = hediffComp_Disappears.ticksToDisappear; } }
public void ApplyHaste(Pawn p) { HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_HasteHD, .5f); HediffComp_Disappears hdComp = p.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_HasteHD).TryGetComp <HediffComp_Disappears>(); if (hdComp != null) { hdComp.ticksToDisappear = 300; } }
public void SearchAndTaunt() { List <Pawn> mapPawns = this.Pawn.Map.mapPawns.AllPawnsSpawned; List <Pawn> tauntTargets = new List <Pawn>(); tauntTargets.Clear(); if (mapPawns != null && mapPawns.Count > 0) { for (int i = 0; i < mapPawns.Count; i++) { Pawn victim = mapPawns[i]; if (!victim.DestroyedOrNull() && !victim.Dead && victim.Map != null && !victim.Downed && victim.mindState != null && !victim.InMentalState && victim.jobs != null) { if (this.Pawn.Faction.HostileTo(victim.Faction) && (victim.Position - this.Pawn.Position).LengthHorizontal < tauntRange) { tauntTargets.Add(victim); } } if (tauntTargets.Count >= tauntTargetsMax) { break; } } for (int i = 0; i < tauntTargets.Count; i++) { if (Rand.Chance(tauntChance)) { //Log.Message("taunting " + threatPawns[i].LabelShort + " doing job " + threatPawns[i].CurJobDef.defName + " with follow radius of " + threatPawns[i].CurJob.followRadius); if (tauntTargets[i].CurJobDef == JobDefOf.Follow || tauntTargets[i].CurJobDef == JobDefOf.FollowClose) { Job job = new Job(JobDefOf.AttackMelee, this.Pawn); tauntTargets[i].jobs.TryTakeOrderedJob(job, JobTag.Misc); } HealthUtility.AdjustSeverity(tauntTargets[i], TorannMagicDefOf.TM_TauntHD, 1); Hediff hd = tauntTargets[i].health?.hediffSet?.GetFirstHediffOfDef(TorannMagicDefOf.TM_TauntHD); HediffComp_Disappears comp_d = hd.TryGetComp <HediffComp_Disappears>(); if (comp_d != null) { comp_d.ticksToDisappear = 600; } HediffComp_Taunt comp_t = hd.TryGetComp <HediffComp_Taunt>(); if (comp_t != null) { comp_t.tauntTarget = this.Pawn; } MoteMaker.ThrowText(tauntTargets[i].DrawPos, tauntTargets[i].Map, "Taunted!", -1); } else { MoteMaker.ThrowText(tauntTargets[i].DrawPos, tauntTargets[i].Map, "TM_ResistedSpell".Translate(), -1); } } } }
private void AccelerateHediff(Pawn pawn, int ticks) { float totalBleedRate = 0; using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; HediffComp_Immunizable immuneComp = rec.TryGetComp <HediffComp_Immunizable>(); if (immuneComp != null) { if (immuneComp.Def.CompProps <HediffCompProperties_Immunizable>() != null) { float immuneSevDay = immuneComp.Def.CompProps <HediffCompProperties_Immunizable>().severityPerDayNotImmune; if (immuneSevDay != 0 && !rec.FullyImmune()) { rec.Severity += ((immuneSevDay * ticks * this.parent.Severity) / (24 * 2500)); } } } HediffComp_SeverityPerDay sevDayComp = rec.TryGetComp <HediffComp_SeverityPerDay>(); if (sevDayComp != null) { if (sevDayComp.Def.CompProps <HediffCompProperties_SeverityPerDay>() != null) { float sevDay = sevDayComp.Def.CompProps <HediffCompProperties_SeverityPerDay>().severityPerDay; if (sevDay != 0) { rec.Severity += ((sevDay * ticks * this.parent.Severity) / (24 * 2500)); } } } HediffComp_Disappears tickComp = rec.TryGetComp <HediffComp_Disappears>(); if (tickComp != null) { int ticksToDisappear = Traverse.Create(root: tickComp).Field(name: "ticksToDisappear").GetValue <int>(); if (ticksToDisappear != 0) { Traverse.Create(root: tickComp).Field(name: "ticksToDisappear").SetValue(ticksToDisappear - (Mathf.RoundToInt(60 * this.parent.Severity))); } } if (rec.Bleeding) { totalBleedRate += rec.BleedRate; } } if (totalBleedRate != 0) { HealthUtility.AdjustSeverity(pawn, HediffDefOf.BloodLoss, (totalBleedRate * 60 * this.parent.Severity) / (24 * 2500)); } } }
public override void CompPostTick(ref float severityAdjustment) { if (!parent.pawn.Awake() || parent.pawn.health == null || parent.pawn.health.InPainShock || !parent.pawn.Spawned) { return; } if (!Props.hideMoteWhenNotDrafted || parent.pawn.Drafted) { if (Props.mote != null && (mote == null || mote.Destroyed)) { mote = MoteMaker.MakeAttachedOverlay(parent.pawn, Props.mote, Vector3.zero); } if (mote != null) { mote.Maintain(); } } List <Pawn> list = null; list = parent.pawn.Map.mapPawns.PawnsInFaction(parent.pawn.Faction); foreach (Pawn item in list) { if (item.Dead || item.health == null || item == parent.pawn || !(item.Position.DistanceTo(parent.pawn.Position) <= Props.range) || !Props.targetingParameters.CanTarget(item) || ((Props.affectSameDef) && (item.def != parent.pawn.def))) { continue; } Hediff hediff = item.health.hediffSet.GetFirstHediffOfDef(Props.hediff); if (hediff == null) { hediff = item.health.AddHediff(Props.hediff, item.health.hediffSet.GetBrain()); hediff.Severity = Props.initialSeverity; HediffComp_Link hediffComp_Link = hediff.TryGetComp <HediffComp_Link>(); if (hediffComp_Link != null) { hediffComp_Link.drawConnection = true; hediffComp_Link.other = parent.pawn; } } HediffComp_Disappears hediffComp_Disappears = hediff.TryGetComp <HediffComp_Disappears>(); if (hediffComp_Disappears == null) { Log.Error("HediffComp_GiveHediffsInRange has a hediff in props which does not have a HediffComp_Disappears"); } else { hediffComp_Disappears.ticksToDisappear = 5; } } }
public void DoStrike(Thing target) { if (target != null && target is Pawn) { Pawn t = target as Pawn; if (t.Faction == null || (t.Faction != null && t.Faction != this.Pawn.Faction)) { for (int i = 0; i < 4; i++) { if (!t.DestroyedOrNull() && !t.Dead && t.Map != null) { int dmg = shadowStrikeDamage + pwrVal; if (Rand.Chance(shadowStrikeCritChance)) { dmg *= 3; } BodyPartRecord bpr = t.health.hediffSet.GetRandomNotMissingPart(DamageDefOf.Stab, BodyPartHeight.Undefined, BodyPartDepth.Outside); TM_Action.DamageEntities(target, bpr, dmg, Rand.Range(0f, .5f), DamageDefOf.Stab, this.Pawn); Vector3 rndPos = t.DrawPos; rndPos.x += Rand.Range(-.2f, .2f); rndPos.z += Rand.Range(-.2f, .2f); TM_MoteMaker.ThrowBloodSquirt(rndPos, t.Map, Rand.Range(.6f, 1f)); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_CrossStrike, rndPos, t.Map, Rand.Range(.6f, 1f), .4f, 0f, Rand.Range(.2f, .5f), 0, 0, 0, Rand.Range(0, 360)); } } if (!t.DestroyedOrNull() && !t.Dead && !t.Downed) { Job job = new Job(JobDefOf.AttackMelee, t); this.Pawn.jobs.TryTakeOrderedJob(job); } } } HealthUtility.AdjustSeverity(this.Pawn, TorannMagicDefOf.TM_ShadowCloakHD, .2f); HediffComp_Disappears hdComp = this.Pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ShadowCloakHD).TryGetComp <HediffComp_Disappears>(); if (hdComp != null) { hdComp.ticksToDisappear = this.invisDuration; } ApplyHaste(this.Pawn); }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); if (Find.TickManager.TicksGame % 21 == 0) { bool firingAtTarget = this.Pawn.TargetCurrentlyAimingAt != null && this.Pawn.TargetCurrentlyAimingAt.Thing != null; bool hasTargetedJob = this.Pawn.CurJob != null && this.Pawn.CurJob.targetA != null && this.Pawn.CurJob.targetA.Thing is Pawn; if (firingAtTarget || hasTargetedJob) { HediffComp_Disappears hdComp = base.Pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ShadowSlayerCloakHD).TryGetComp <HediffComp_Disappears>(); if (hdComp != null) { hdComp.ticksToDisappear -= Rand.Range(40, 60); if (hdComp.ticksToDisappear <= 0) { Effecter InvisEffect = TorannMagicDefOf.TM_InvisibilityEffecter.Spawn(); InvisEffect.Trigger(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), new TargetInfo(this.Pawn.Position, this.Pawn.Map, false)); InvisEffect.Cleanup(); } } } } }
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest) { base.Apply(target, dest); Pawn pawn = target.Pawn; Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.PsychicLove); if (firstHediffOfDef != null) { pawn.health.RemoveHediff(firstHediffOfDef); } Hediff_PsychicLove hediff_PsychicLove = (Hediff_PsychicLove)HediffMaker.MakeHediff(HediffDefOf.PsychicLove, pawn, pawn.health.hediffSet.GetBrain()); hediff_PsychicLove.target = dest.Thing; HediffComp_Disappears hediffComp_Disappears = hediff_PsychicLove.TryGetComp <HediffComp_Disappears>(); if (hediffComp_Disappears != null) { float effectDuration = parent.def.EffectDuration; effectDuration *= pawn.GetStatValue(StatDefOf.PsychicSensitivity); hediffComp_Disappears.ticksToDisappear = effectDuration.SecondsToTicks(); } pawn.health.AddHediff(hediff_PsychicLove); }
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest) { Pawn target2 = Props.applyToSelf ? parent.pawn : target.Pawn; if (target2 == null){return;} Hediff hediff = Props.hediffDef != null ? HediffMaker.MakeHediff(Props.hediffDef, target2, Props.onlyBrain ? target2.health.hediffSet.GetBrain() : null) : null; if (hediff != null) { HediffComp_Disappears hediffComp_Disappears = hediff.TryGetComp<HediffComp_Disappears>(); if (hediffComp_Disappears != null) { hediffComp_Disappears.ticksToDisappear = GetDurationSeconds(target2).SecondsToTicks(); } target2.health.AddHediff(hediff); } Hediff hediff2 = HediffMaker.MakeHediff(Props.hediffDef2, target2, Props.onlyBrain ? target2.health.hediffSet.GetBrain() : null); hediff2.Severity = Props.stacks; if (!(hediff2 is HediffStacks)) return; ((HediffStacks)hediff2).stacks = Props.stacks; ((HediffStacks)hediff2).duration = GetDurationSeconds(target2).SecondsToTicks(); ((HediffStacks)hediff2).link = hediff; target2.health.AddHediff(hediff2); }
private void ReverseHediff(Pawn pawn, int ticks) { float totalBleedRate = 0; using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec != null) { HediffComp_Immunizable immuneComp = rec.TryGetComp <HediffComp_Immunizable>(); if (immuneComp != null) { if (immuneComp.Def.CompProps <HediffCompProperties_Immunizable>() != null) { float immuneSevDay = immuneComp.Def.CompProps <HediffCompProperties_Immunizable>().severityPerDayNotImmune; if (immuneSevDay != 0 && !rec.FullyImmune()) { rec.Severity -= ((immuneSevDay * ticks * this.parent.Severity) / (2500)); } } } HediffComp_SeverityPerDay sevDayComp = rec.TryGetComp <HediffComp_SeverityPerDay>(); if (sevDayComp != null) { if (sevDayComp.Def.CompProps <HediffCompProperties_SeverityPerDay>() != null) { float sevDay = sevDayComp.Def.CompProps <HediffCompProperties_SeverityPerDay>().severityPerDay; if (sevDay != 0) { bool drugTolerance = false; HediffComp_DrugEffectFactor drugEffectComp = rec.TryGetComp <HediffComp_DrugEffectFactor>(); if (drugEffectComp != null) { if (drugEffectComp.Def.CompProps <HediffCompProperties_DrugEffectFactor>().chemical != null) { drugTolerance = true; } } if (!drugTolerance) { rec.Severity -= ((sevDay * ticks * this.parent.Severity) / (1000)); } } } } HediffComp_Disappears tickComp = rec.TryGetComp <HediffComp_Disappears>(); if (tickComp != null) { int ticksToDisappear = Traverse.Create(root: tickComp).Field(name: "ticksToDisappear").GetValue <int>(); if (ticksToDisappear != 0) { Traverse.Create(root: tickComp).Field(name: "ticksToDisappear").SetValue(ticksToDisappear + (Mathf.RoundToInt(ticks * this.parent.Severity))); } } if (rec.Bleeding) { totalBleedRate += rec.BleedRate; } } } if (totalBleedRate != 0) { HealthUtility.AdjustSeverity(pawn, HediffDefOf.BloodLoss, -(totalBleedRate * ticks * this.parent.Severity) / (24 * 2500)); } } List <Hediff> hediffList = pawn.health.hediffSet.GetHediffs <Hediff>().ToList(); if (hediffList != null && hediffList.Count > 0) { for (int i = 0; i < hediffList.Count; i++) { Hediff rec = hediffList[i]; if (rec != null && rec != this.parent) { if (rec.def.scenarioCanAdd || rec.def.isBad) { if ((rec.ageTicks - 1000) < 0) { if (rec.def.defName.Contains("TM_")) { if (rec.def.isBad && rec.def != TorannMagicDefOf.TM_ResurrectionHD) { this.Pawn.health.RemoveHediff(rec); break; } } else { List <BodyPartRecord> bpList = pawn.RaceProps.body.AllParts; List <BodyPartRecord> replacementList = new List <BodyPartRecord>(); replacementList.Clear(); for (int j = 0; j < bpList.Count; j++) { BodyPartRecord record = bpList[j]; if (pawn.health.hediffSet.hediffs.Any((Hediff x) => x.Part == record) && (record.parent == null || pawn.health.hediffSet.GetNotMissingParts().Contains(record.parent)) && (!pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(record) || pawn.health.hediffSet.HasDirectlyAddedPartFor(record))) { replacementList.Add(record); } } Hediff_MissingPart mphd = rec as Hediff_MissingPart; if (mphd != null && mphd.Part != null) { if (replacementList.Contains(mphd.Part)) { if (RemoveChildParts(mphd)) { break; } else { if (this.Pawn.needs != null && this.Pawn.needs.mood != null && this.Pawn.needs.mood.thoughts != null && this.Pawn.needs.mood.thoughts.memories != null) { this.Pawn.needs.mood.thoughts.memories.TryGainMemory(TorannMagicDefOf.TM_PhantomLimb); } } } else { goto IgnoreHediff; } } this.Pawn.health.RemoveHediff(rec); i = hediffList.Count; break; IgnoreHediff :; } } else { rec.ageTicks -= 1000; } } } } } //using (IEnumerator<Hediff> enumerator = pawn.health.hediffSet.GetHediffs<Hediff>().GetEnumerator()) //{ // while (enumerator.MoveNext()) // { // Hediff rec = enumerator.Current; // if (rec != null && rec != this.parent) // { // if ((rec.ageTicks - 2500) < 0) // { // if (rec.def.defName.Contains("TM_")) // { // if (rec.def.isBad) // { // this.Pawn.health.RemoveHediff(rec); // } // } // else // { // this.Pawn.health.RemoveHediff(rec); // } // } // else // { // rec.ageTicks -= 2500; // } // } // } //} }
public void GetAffectedPawns(IntVec3 center, Map map) { Pawn victim = null; IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(center, this.def.projectile.explosionRadius, true); foreach (var curCell in targets) { if (curCell.InBounds(map) && curCell.IsValid) { victim = curCell.GetFirstPawn(map); } if (victim != null && victim.Faction == this.caster.Faction && !victim.Dead) { if (verVal >= 1) { HealthUtility.AdjustSeverity(victim, TorannMagicDefOf.TM_HediffTimedInvulnerable, 1f); Hediff hd = victim.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_HediffTimedInvulnerable); HediffComp_Disappears hdc = hd.TryGetComp <HediffComp_Disappears>(); if (hdc != null) { hdc.ticksToDisappear += 360; } } if (verVal >= 2) { Pawn pawn = victim; bool flag = pawn != null && !pawn.Dead && !TM_Calc.IsUndead(pawn); bool undeadFlag = pawn != null && !pawn.Dead && TM_Calc.IsUndead(pawn); if (flag) { int num = 3; using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { int num2 = 1; IEnumerable <Hediff_Injury> arg_BB_0 = pawn.health.hediffSet.GetHediffs <Hediff_Injury>(); Func <Hediff_Injury, bool> arg_BB_1; arg_BB_1 = (Hediff_Injury injury) => injury.Part == rec; foreach (Hediff_Injury current in arg_BB_0.Where(arg_BB_1)) { bool flag4 = num2 > 0; if (flag4) { bool flag5 = current.CanHealNaturally() && !current.IsPermanent(); if (flag5) { //current.Heal((float)((int)current.Severity + 1)); if (!this.caster.IsColonist) { current.Heal(20.0f); // power affects how much to heal } else { current.Heal(5.0f * this.arcaneDmg); // power affects how much to heal } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f); num--; num2--; } } } } } } } } if (verVal >= 3) { HealthUtility.AdjustSeverity(victim, HediffDef.Named("BestowMightHD"), 1f); } } if (victim != null && !victim.Dead && TM_Calc.IsUndead(victim)) { TM_Action.DamageUndead(victim, Rand.Range(5f, 12f) * this.arcaneDmg, this.launcher); } } }
private void SetRecallHediffs() { comp.recallHediffList = new List <Hediff>(); comp.recallHediffList.Clear(); comp.recallHediffDefSeverityList = new List <float>(); comp.recallHediffDefSeverityList.Clear(); comp.recallHediffDefTicksRemainingList = new List <int>(); comp.recallHediffDefTicksRemainingList.Clear(); comp.recallInjuriesList = new List <Hediff_Injury>(); comp.recallInjuriesList.Clear(); for (int i = 0; i < this.CasterPawn.health.hediffSet.hediffs.Count; i++) { if (!this.CasterPawn.health.hediffSet.hediffs[i].IsPermanent() && this.CasterPawn.health.hediffSet.hediffs[i].def != TorannMagicDefOf.TM_MagicUserHD && !this.CasterPawn.health.hediffSet.hediffs[i].def.defName.Contains("TM_HediffEnchantment") && !this.CasterPawn.health.hediffSet.hediffs[i].def.defName.Contains("TM_Artifact") && this.CasterPawn.health.hediffSet.hediffs[i].def != TorannMagicDefOf.TM_MightUserHD && this.CasterPawn.health.hediffSet.hediffs[i].def != TorannMagicDefOf.TM_BloodHD && this.CasterPawn.health.hediffSet.hediffs[i].def != TorannMagicDefOf.TM_ChiHD && this.CasterPawn.health.hediffSet.hediffs[i].def != TorannMagicDefOf.TM_PsionicHD) { if (this.CasterPawn.health.hediffSet.hediffs[i] is Hediff_Injury) { Hediff_Injury rhd = this.CasterPawn.health.hediffSet.hediffs[i] as Hediff_Injury; Hediff_Injury hediff = new Hediff_Injury(); //hediff = TM_Calc.Clone<Hediff>(this.CasterPawn.health.hediffSet.hediffs[i]); hediff.def = rhd.def; hediff.Part = rhd.Part; Traverse.Create(root: hediff).Field(name: "visible").SetValue(rhd.Visible); Traverse.Create(root: hediff).Field(name: "severityInt").SetValue(rhd.Severity); //hediff.Severity = rhd.Severity; hediff.ageTicks = rhd.ageTicks; comp.recallInjuriesList.Add(hediff); } else if (this.CasterPawn.health.hediffSet.hediffs[i] is Hediff_MissingPart || this.CasterPawn.health.hediffSet.hediffs[i] is Hediff_AddedPart || this.CasterPawn.health.hediffSet.hediffs[i].def.defName == "PsychicAmplifier") { //do nothing } else if (this.CasterPawn.health.hediffSet.hediffs[i] is Hediff_Addiction) { //Hediff_Addiction rhd = this.CasterPawn.health.hediffSet.hediffs[i] as Hediff_Addiction; } else if (this.CasterPawn.health.hediffSet.hediffs[i].def.defName == "LuciferiumHigh") { //do nothing } else { Hediff rhd = this.CasterPawn.health.hediffSet.hediffs[i] as Hediff; //Log.Message("sev def is " + rhd.def.defName); if (rhd != null) { Hediff hediff = new Hediff(); //hediff = TM_Calc.Clone<Hediff>(this.CasterPawn.health.hediffSet.hediffs[i]); hediff.def = rhd.def; hediff.loadID = rhd.loadID; hediff.Part = rhd.Part; //foreach(HediffComp hdc in rhd.comps) //{ // if(hdc is HediffComp_Disappears) // { // HediffComp_Disappears rhd_comp = hdc as HediffComp_Disappears; // HediffComp_Disappears hdc_d = new HediffComp_Disappears(); // hdc_d.ticksToDisappear = rhd_comp.ticksToDisappear; // hediff.comps.Add(hdc_d); // } // else // { // hediff.comps.Add(hdc); // } //} //Traverse.Create(root: hediff).Field(name: "visible").SetValue(rhd.Visible); //Traverse.Create(root: hediff).Field(name: "severityInt").SetValue(rhd.Severity); hediff.ageTicks = rhd.ageTicks; //Log.Message("saving hediff " + hediff.def.defName + " with severity " + rhd.Severity); comp.recallHediffList.Add(hediff); comp.recallHediffDefSeverityList.Add(rhd.Severity); HediffComp_Disappears hdc_d = rhd.TryGetComp <HediffComp_Disappears>(); if (hdc_d != null) { //Log.Message("hediff has disappears at ticks " + hdc_d.ticksToDisappear); comp.recallHediffDefTicksRemainingList.Add(hdc_d.ticksToDisappear); } else { comp.recallHediffDefTicksRemainingList.Add(-1); } } //else //{ // Hediff _rhd = this.CasterPawn.health.hediffSet.hediffs[i]; // if(_rhd != null) // { // HediffWithComps hediff = new HediffWithComps(); // hediff.def = rhd.def; // hediff.loadID = rhd.loadID; // hediff.Part = rhd.Part; // Traverse.Create(root: hediff).Field(name: "visible").SetValue(rhd.Visible); // Traverse.Create(root: hediff).Field(name: "severityInt").SetValue(rhd.Severity); // hediff.Severity = rhd.Severity; // hediff.ageTicks = rhd.ageTicks; // comp.recallHediffList.Add(hediff); // } //} } //Log.Message("adding " + this.CasterPawn.health.hediffSet.hediffs[i].def + " at severity " + this.CasterPawn.health.hediffSet.hediffs[i].Severity); } } //Log.Message("hediffs set"); }
private void AccelerateHediff(Pawn pawn, int ticks) { float totalBleedRate = 0; using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; HediffComp_Immunizable immuneComp = rec.TryGetComp <HediffComp_Immunizable>(); if (immuneComp != null) { if (immuneComp.Def.CompProps <HediffCompProperties_Immunizable>() != null) { float immuneSevDay = immuneComp.Def.CompProps <HediffCompProperties_Immunizable>().severityPerDayNotImmune; if (immuneSevDay != 0 && !rec.FullyImmune()) { rec.Severity += immuneSevDay * ticks * this.parent.Severity / (24 * 2500); } } } HediffComp_SeverityPerDay sevDayComp = rec.TryGetComp <HediffComp_SeverityPerDay>(); if (sevDayComp != null) { if (sevDayComp.Def.CompProps <HediffCompProperties_SeverityPerDay>() != null) { float sevDay = sevDayComp.Def.CompProps <HediffCompProperties_SeverityPerDay>().severityPerDay; if (sevDay != 0) { rec.Severity += sevDay * ticks * this.parent.Severity / (24 * 2500); } } } HediffComp_Disappears tickComp = rec.TryGetComp <HediffComp_Disappears>(); if (tickComp != null) { int ticksToDisappear = Traverse.Create(root: tickComp).Field(name: "ticksToDisappear").GetValue <int>(); if (ticksToDisappear != 0) { Traverse.Create(root: tickComp).Field(name: "ticksToDisappear").SetValue(ticksToDisappear - Mathf.RoundToInt(60 * this.parent.Severity)); } } Hediff_Pregnant hdp = this.Pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Pregnant")) as Hediff_Pregnant; if (hdp != null) { hdp.Severity += 1f / (this.Pawn.RaceProps.gestationPeriodDays * (2500f / this.parent.Severity)); } CompEggLayer eggComp = this.Pawn.TryGetComp <CompEggLayer>(); if (eggComp != null) { float eggProgress = Traverse.Create(root: eggComp).Field(name: "eggProgress").GetValue <float>(); bool isActive = Active(eggComp); if (isActive) { eggProgress += 1f / (eggComp.Props.eggLayIntervalDays * (2500f / this.parent.Severity)); Traverse.Create(root: eggComp).Field(name: "eggProgress").SetValue(eggProgress); } } //CompHasGatherableBodyResource gatherComp = this.Pawn.TryGetComp<CompHasGatherableBodyResource>(); //if (gatherComp != null) //{ // float gatherProgress = gatherComp.Fullness; // int rate = Traverse.Create(root: gatherComp).Field(name: "GatherResourcesIntervalDays").GetValue<int>(); // bool isActive = Active(); // if (isActive) // { // gatherProgress += (1f / ((float)(rate * (2500f / this.parent.Severity)))); // Traverse.Create(root: gatherComp).Field(name: "fullness").SetValue(gatherProgress); // } //} CompMilkable milkComp = this.Pawn.TryGetComp <CompMilkable>(); if (milkComp != null) { float milkProgress = milkComp.Fullness; int rate = milkComp.Props.milkIntervalDays; bool isActive = Active(milkComp); if (isActive) { milkProgress += 1f / ((float)(rate * (2500f / this.parent.Severity))); Traverse.Create(root: milkComp).Field(name: "fullness").SetValue(milkProgress); } } if (rec.Bleeding) { totalBleedRate += rec.BleedRate; } } if (totalBleedRate != 0) { HealthUtility.AdjustSeverity(pawn, HediffDefOf.BloodLoss, totalBleedRate * 60 * this.parent.Severity / (24 * 2500)); } } }
protected override IEnumerable <Toil> MakeNewToils() { Toil gotoSpot = new Toil() { initAction = () => { pawn.pather.StartPath(TargetLocA, PathEndMode.OnCell); }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return(gotoSpot); Toil doFor = new Toil() { initAction = () => { chiHD = this.pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD, false); CompAbilityUserMight comp = this.pawn.GetComp <CompAbilityUserMight>(); if (comp != null && chiHD != null) { effVal = comp.MightData.MightPowerSkill_Meditate.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Meditate_eff").level; pwrVal = comp.MightData.MightPowerSkill_Meditate.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Meditate_pwr").level; verVal = comp.MightData.MightPowerSkill_Meditate.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Meditate_ver").level; } else { Log.Warning("No Chi Hediff or Might Comp found."); this.EndJobWith(JobCondition.Errored); } if (this.age > this.durationTicks) { this.EndJobWith(JobCondition.InterruptForced); } }, tickAction = () => { if (Find.TickManager.TicksGame % 12 == 0) { Vector3 rndPos = this.pawn.DrawPos; rndPos.x += (Rand.Range(-.5f, .5f)); rndPos.z += Rand.Range(-.4f, .6f); float direction = (this.pawn.DrawPos - rndPos).ToAngleFlat(); Vector3 startPos = rndPos; TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Chi_Grayscale, startPos, this.pawn.Map, Rand.Range(.1f, .22f), 0.2f, .3f, .2f, 30, .2f * (rndPos - this.pawn.DrawPos).MagnitudeHorizontal(), direction, direction); } if (Find.TickManager.TicksGame % 60 == 0) { List <Hediff> afflictionList = TM_Calc.GetPawnAfflictions(this.pawn); List <Hediff> addictionList = TM_Calc.GetPawnAddictions(this.pawn); if (chiHD != null) { if (chiHD.Severity > 1) { chiMultiplier = 5; } else { chiMultiplier = 1; } } else { chiHD = this.pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD, false); if (chiHD == null) { Log.Warning("No chi found on pawn performing meditate job"); this.EndJobWith(JobCondition.InterruptForced); } } if (TM_Calc.IsPawnInjured(this.pawn, 0)) { TM_Action.DoAction_HealPawn(this.pawn, this.pawn, 1, Rand.Range(.25f, .4f) * chiMultiplier * (1 + (.1f * pwrVal))); chiHD.Severity -= 1f; } else if (afflictionList != null && afflictionList.Count > 0) { Hediff hediff = afflictionList.RandomElement(); hediff.Severity -= .001f * chiMultiplier * (1 + (.1f * pwrVal)); if (hediff.Severity <= 0) { this.pawn.health.RemoveHediff(hediff); } HediffComp_Disappears hediffTicks = hediff.TryGetComp <HediffComp_Disappears>(); if (hediffTicks != null) { int ticksToDisappear = Traverse.Create(root: hediffTicks).Field(name: "ticksToDisappear").GetValue <int>(); ticksToDisappear -= Mathf.RoundToInt(10000 * (chiMultiplier * (1 + (.1f * pwrVal)))); Traverse.Create(root: hediffTicks).Field(name: "ticksToDisappear").SetValue(ticksToDisappear); } chiHD.Severity -= 1f; } else if (addictionList != null && addictionList.Count > 0) { Hediff hediff = addictionList.RandomElement(); hediff.Severity -= .0015f * chiMultiplier * (1 + (.1f * pwrVal)); if (hediff.Severity <= 0) { this.pawn.health.RemoveHediff(hediff); } chiHD.Severity -= 1f; } else if (BreakRiskAlertUtility.PawnsAtRiskMinor.Contains(this.pawn) || BreakRiskAlertUtility.PawnsAtRiskMajor.Contains(this.pawn) || BreakRiskAlertUtility.PawnsAtRiskExtreme.Contains(this.pawn)) { this.pawn.needs.mood.CurLevel += .004f * chiMultiplier * (1 + (.1f * verVal)); chiHD.Severity -= 1f; } else { chiHD.Severity += (Rand.Range(.2f, .3f) * (1 + (effVal * .1f))); try { this.pawn.needs.rest.CurLevel += (.003f * (1 + (.1f * verVal))); this.pawn.needs.joy.CurLevel += (.004f * (1 + (.1f * verVal))); this.pawn.needs.mood.CurLevel += .001f * (1 + (.1f * verVal)); } catch (NullReferenceException ex) { //ex } } } if (chiHD != null) { HediffComp_Chi chiComp = chiHD.TryGetComp <HediffComp_Chi>(); if (chiComp != null && chiHD.Severity >= chiComp.maxSev) { this.age = durationTicks; } } if (age >= durationTicks) { this.EndJobWith(JobCondition.Succeeded); } 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); }
protected override bool TryCastShot() { bool result = false; bool flag = false; if (this.currentTarget != null && base.CasterPawn != null) { IntVec3 arg_29_0 = this.currentTarget.Cell; Vector3 vector = this.currentTarget.CenterVector3; flag = this.currentTarget.Cell.IsValid && vector.InBounds(base.CasterPawn.Map) && this.currentTarget.Thing != null && this.currentTarget.Thing is Pawn; } if (flag) { Pawn p = this.CasterPawn; Pawn targetPawn = this.currentTarget.Thing as Pawn; Map map = this.CasterPawn.Map; IntVec3 cell = this.CasterPawn.Position; bool draftFlag = this.CasterPawn.Drafted; CompAbilityUserMagic comp = p.TryGetComp <CompAbilityUserMagic>(); if (comp != null) { pwrVal = comp.MagicData.MagicPowerSkill_ShadowWalk.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ShadowWalk_pwr").level; verVal = comp.MagicData.MagicPowerSkill_ShadowWalk.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ShadowWalk_ver").level; } try { if (this.CasterPawn.IsColonist) { ModOptions.Constants.SetPawnInFlight(true); this.CasterPawn.DeSpawn(); GenSpawn.Spawn(p, this.currentTarget.Cell, map); p.drafter.Drafted = draftFlag; CameraJumper.TryJumpAndSelect(p); ModOptions.Constants.SetPawnInFlight(false); } else { ModOptions.Constants.SetPawnInFlight(true); this.CasterPawn.DeSpawn(); GenSpawn.Spawn(p, this.currentTarget.Cell, map); ModOptions.Constants.SetPawnInFlight(false); } if (pwrVal > 0) { HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_ShadowCloakHD, .5f); HediffComp_Disappears hdComp = p.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ShadowCloakHD).TryGetComp <HediffComp_Disappears>(); if (hdComp != null) { hdComp.ticksToDisappear = 60 + (60 * pwrVal); } } if (verVal > 0) { TM_Action.DoAction_HealPawn(p, p, 1 + verVal, 6 + verVal); if (targetPawn.Faction != null && targetPawn.Faction == p.Faction) { if (verVal > 1) { TM_Action.DoAction_HealPawn(p, targetPawn, verVal, 4 + verVal); } if (verVal > 2) { HealthUtility.AdjustSeverity(targetPawn, TorannMagicDefOf.TM_ShadowCloakHD, .5f); HediffComp_Disappears hdComp = targetPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ShadowCloakHD).TryGetComp <HediffComp_Disappears>(); if (hdComp != null) { hdComp.ticksToDisappear = 180; } ThingDef fog = TorannMagicDefOf.Fog_Shadows; fog.gas.expireSeconds.min = 4; fog.gas.expireSeconds.max = 4; GenExplosion.DoExplosion(p.Position, p.Map, 2, TMDamageDefOf.DamageDefOf.TM_Toxin, caster, 0, 0, TMDamageDefOf.DamageDefOf.TM_Toxin.soundExplosion, null, null, null, fog, 1f, 1, false, null, 0f, 0, 0.0f, false); } } } for (int i = 0; i < 6; i++) { Vector3 rndPos = p.DrawPos; rndPos.x += Rand.Range(-1.5f, 1.5f); rndPos.z += Rand.Range(-1.5f, 1.5f); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_ShadowCloud, rndPos, p.Map, Rand.Range(.8f, 1.2f), .6f, .05f, Rand.Range(.7f, 1f), Rand.Range(-40, 40), Rand.Range(0, 1f), Rand.Range(0, 360), Rand.Range(0, 360)); } } catch { if (!this.CasterPawn.Spawned) { GenSpawn.Spawn(p, cell, map); Log.Message("Exception occured when trying to blink - recovered pawn at position ability was used from."); } } result = true; } else { Messages.Message("InvalidTargetLocation".Translate(), MessageTypeDefOf.RejectInput); } this.burstShotsLeft = 0; return(result); }
public void DoStrike(Thing target) { if (target != null && target is Pawn) { Pawn t = target as Pawn; if (t.Faction == null || (t.Faction != null && t.Faction != caster.Faction)) { //List<BodyPartRecord> partList = new List<BodyPartRecord>(); //partList.Clear(); //for (int i = 0; i < t.RaceProps.body.AllParts.Count; i++) //{ // BodyPartRecord part = t.RaceProps.body.AllParts[i]; // if (part.depth == BodyPartDepth.Outside) // { // partList.Add(part); // } //} for (int i = 0; i < 4; i++) { if (!t.DestroyedOrNull() && !t.Dead && t.Map != null) { int dmg = Mathf.RoundToInt(this.weaponDamage); if (Rand.Chance(critChance)) { dmg *= 3; } BodyPartRecord bpr = t.health.hediffSet.GetRandomNotMissingPart(DamageDefOf.Stab, BodyPartHeight.Undefined, BodyPartDepth.Outside); TM_Action.DamageEntities(target, bpr, dmg, Rand.Range(0f, .5f), DamageDefOf.Stab, this.caster); Vector3 rndPos = t.DrawPos; rndPos.x += Rand.Range(-.2f, .2f); rndPos.z += Rand.Range(-.2f, .2f); TM_MoteMaker.ThrowBloodSquirt(rndPos, t.Map, Rand.Range(.6f, 1f)); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_CrossStrike, rndPos, t.Map, Rand.Range(.6f, 1f), .4f, 0f, Rand.Range(.2f, .5f), 0, 0, 0, Rand.Range(0, 360)); } } if (!t.DestroyedOrNull() && !t.Dead && !t.Downed && caster.IsColonist) { caster.drafter.Drafted = true; Job job = new Job(JobDefOf.AttackMelee, t); caster.jobs.TryTakeOrderedJob(job, JobTag.DraftedOrder); } } } if (verVal >= 1) { int invisDuration = 120; if (verVal >= 2) { invisDuration = 180; } HealthUtility.AdjustSeverity(caster, TorannMagicDefOf.TM_ShadowCloakHD, .2f); HediffComp_Disappears hdComp = caster.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ShadowCloakHD).TryGetComp <HediffComp_Disappears>(); if (hdComp != null) { hdComp.ticksToDisappear = invisDuration; } } if (verVal >= 3) { int radius = 2; if (verVal >= 5) { radius = 3; } float sev = 1.5f; if (verVal >= 4) { sev = 2.2f; } List <Pawn> targetList = TM_Calc.FindPawnsNearTarget(caster, radius, caster.Position, true); if (targetList != null && targetList.Count > 0) { for (int i = 0; i < targetList.Count; i++) { if (targetList[i].RaceProps.IsFlesh) { HealthUtility.AdjustSeverity(targetList[i], TorannMagicDefOf.TM_NightshadeToxinHD, Rand.Range(.7f * sev, 1.3f * sev)); } } } ThingDef fog = TorannMagicDefOf.Fog_Shadows; fog.gas.expireSeconds.min = 2; fog.gas.expireSeconds.max = 3; GenExplosion.DoExplosion(caster.Position, caster.Map, radius, TMDamageDefOf.DamageDefOf.TM_Toxin, caster, 0, 0, TMDamageDefOf.DamageDefOf.TM_Toxin.soundExplosion, null, null, null, fog, 1f, 1, false, null, 0f, 0, 0.0f, false); for (int i = 0; i < 6; i++) { Vector3 rndPos = caster.DrawPos; rndPos.x += Rand.Range(-.5f, .5f); rndPos.z += Rand.Range(-.5f, .5f); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_ShadowCloud, rndPos, caster.Map, Rand.Range(.6f, 1f), .4f, .05f, Rand.Range(.2f, .5f), Rand.Range(-40, 40), Rand.Range(1, 2f), Rand.Range(0, 360), Rand.Range(0, 360)); } } ApplyHaste(caster); }