private void ReadFormXML() { ItemThingDefs newThingDefs = (ItemThingDefs)this.def; if (newThingDefs != null) { HediffToAdd = newThingDefs.HediffToAdd; BodyPartToHediff = newThingDefs.BodyPartToHediff; HediffSeverityStage = newThingDefs.HediffSeverityStage; } }
// Token: 0x060039DE RID: 14814 RVA: 0x001B8078 File Offset: 0x001B6478 private IEnumerable <DamageInfo> DamageInfosToApply(LocalTargetInfo target) { Pawn hitPawn = (Pawn)target; bool flag = XenomorphUtil.isInfectablePawn(hitPawn); float tgtmelee = 0f; float tgtdodge = 0f; float armourBlunt = 0f; float armourSharp = 0f; float armourHeat = 0f; float armour = 0f; if (hitPawn.RaceProps.Humanlike) { tgtmelee = hitPawn.skills.GetSkill(SkillDefOf.Melee).Level; } if (hitPawn.RaceProps.Humanlike) { tgtdodge = hitPawn.GetStatValue(StatDefOf.MeleeDodgeChance); } if (hitPawn.RaceProps.Humanlike) { if (hitPawn.apparel.WornApparel.Count > 0 && hitPawn.apparel.WornApparel is List <Apparel> wornApparel) { for (int i = 0; i < wornApparel.Count; i++) { bool flag2 = wornApparel[i].def.apparel.CoversBodyPart(Head); if (flag2) { armourBlunt = wornApparel[i].def.statBases.GetStatOffsetFromList(StatDefOf.ArmorRating_Blunt); // hitPawn.GetStatValue(StatDefOf.ArmorRating_Blunt, false); armourSharp = wornApparel[i].def.statBases.GetStatOffsetFromList(StatDefOf.ArmorRating_Sharp); //hitPawn.GetStatValue(StatDefOf.ArmorRating_Sharp, false); armourHeat = wornApparel[i].def.statBases.GetStatOffsetFromList(StatDefOf.ArmorRating_Heat); //hitPawn.GetStatValue(StatDefOf.ArmorRating_Heat, false); armour = (armourBlunt + armourSharp + armourHeat); // Log.Message(string.Format("Pawn: {4}\narmourBlunt: {0}, armourSharp: {1}, armourHeat: {2}, Total Armour {3}", armourBlunt, armourSharp, armourHeat, armour, wornApparel[i].LabelShortCap)); } } } } float InfecterRoll = (Rand.Value * 100) * (1 - tgtdodge); float InfectionDefence = 50 + tgtmelee + (armour * 10); if ((InfecterRoll > InfectionDefence || hitPawn.Downed) && flag && hitPawn is Pawn && !hitPawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Anesthetic)) { infect = true; } else { infect = false; } float damAmount = this.verbProps.AdjustedMeleeDamageAmount(this, base.CasterPawn); float armorPenetration = this.verbProps.AdjustedArmorPenetration(this, base.CasterPawn); DamageDef damDef = this.verbProps.meleeDamageDef; BodyPartGroupDef bodyPartGroupDef = null; HediffDef hediffDef = null; damAmount = Rand.Range(damAmount * 0.8f, damAmount * 1.2f); if (base.CasterIsPawn) { bodyPartGroupDef = this.verbProps.AdjustedLinkedBodyPartsGroup(this.tool); if (damAmount >= 1f) { if (base.HediffCompSource != null) { hediffDef = base.HediffCompSource.Def; } } else { damAmount = 1f; damDef = DamageDefOf.Blunt; } } ThingDef source; if (base.EquipmentSource != null) { source = base.EquipmentSource.def; } else { source = base.CasterPawn.def; } Vector3 direction = (target.Thing.Position - base.CasterPawn.Position).ToVector3(); DamageDef def = damDef; float num = damAmount; float num2 = armorPenetration; Thing caster = this.caster; DamageInfo mainDinfo = new DamageInfo(def, num, num2, -1f, caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null); mainDinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); mainDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef); mainDinfo.SetWeaponHediff(hediffDef); mainDinfo.SetAngle(direction); yield return(mainDinfo); if (this.surpriseAttack && ((this.verbProps.surpriseAttack != null && !this.verbProps.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>()) || (this.tool != null && this.tool.surpriseAttack != null && !this.tool.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>()))) { IEnumerable <ExtraMeleeDamage> extraDamages = Enumerable.Empty <ExtraMeleeDamage>(); if (this.verbProps.surpriseAttack != null && this.verbProps.surpriseAttack.extraMeleeDamages != null) { extraDamages = extraDamages.Concat(this.verbProps.surpriseAttack.extraMeleeDamages); } if (this.tool != null && this.tool.surpriseAttack != null && !this.tool.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>()) { extraDamages = extraDamages.Concat(this.tool.surpriseAttack.extraMeleeDamages); } foreach (ExtraMeleeDamage extraDamage in extraDamages) { int extraDamageAmount = GenMath.RoundRandom(extraDamage.AdjustedDamageAmount(this, base.CasterPawn)); float extraDamageArmorPenetration = extraDamage.AdjustedArmorPenetration(this, base.CasterPawn); def = extraDamage.def; num2 = (float)extraDamageAmount; num = extraDamageArmorPenetration; caster = this.caster; DamageInfo extraDinfo = new DamageInfo(def, num2, num, -1f, caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null); extraDinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); extraDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef); extraDinfo.SetWeaponHediff(hediffDef); extraDinfo.SetAngle(direction); yield return(extraDinfo); } } yield break; }
public static bool IsUndeadNotVamp(Pawn pawn) { if (pawn != null) { bool flag_Hediff = false; if (pawn.health != null) { if (pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_UndeadHD"), false) || pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_UndeadAnimalHD"), false) || pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_LichHD"), false) || pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_UndeadStageHD"), false)) { flag_Hediff = true; } } bool flag_DefName = false; if (pawn.def.defName == "SL_Runner" || pawn.def.defName == "SL_Peon" || pawn.def.defName == "SL_Archer" || pawn.def.defName == "SL_Hero") { flag_DefName = true; } bool flag_Trait = false; if (pawn.story != null && pawn.story.traits != null) { if (pawn.story.traits.HasTrait(TorannMagicDefOf.Undead)) { flag_Trait = true; } } bool isUndead = flag_Hediff || flag_DefName || flag_Trait; return(isUndead); } return(false); }
public static void roll_for_syphilis_damage(Pawn p) { Hediff syp = p.health.hediffSet.GetFirstHediffOfDef(std.syphilis.hediff_def); if (syp == null || !(syp.Severity >= 0.60f) || syp.FullyImmune()) { return; } // A 30% chance per day of getting any permanent damage works out to ~891 in 1 million for each roll // The equation is (1-x)^(60000/150)=.7 // Important Note: // this function is called from Need_Sex::NeedInterval(), where it involves a needsex_tick and a std_tick to actually trigger this roll_for_syphilis_damage. // j(this is not exactly the same as the value in Need_Sex, that value is 0, but here j should be 1) std_ticks per this function called, k needsex_ticks per std_tick, 150 ticks per needsex_tick, and x is the chance per 150 ticks, // The new equation should be .7 = (1-x)^(400/kj) // 1-x = .7^(kj/400), x =1-.7^(kj/400) // Since k=10,j=1, so kj=10, new x is 1-.7^(10/400)=0.0088772362, let it be 888/100000 //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); if (Rand.RangeInclusive(1, 100000) <= 888) { BodyPartRecord part; float sev; var parts = p.RaceProps.body.AllParts; float rv = Rand.Value; if (rv < 0.10f) { part = parts.Find(bpr => string.Equals(bpr.def.defName, "Brain")); sev = 1.0f; } else if (rv < 0.50f) { part = parts.Find(bpr => string.Equals(bpr.def.defName, "Liver")); sev = Rand.RangeInclusive(1, 3); } else if (rv < 0.75f) { //LeftKidney, probably part = parts.Find(bpr => string.Equals(bpr.def.defName, "Kidney")); sev = Rand.RangeInclusive(1, 2); } else { //RightKidney, probably part = parts.FindLast(bpr => string.Equals(bpr.def.defName, "Kidney")); sev = Rand.RangeInclusive(1, 2); } if (part != null && !p.health.hediffSet.PartIsMissing(part) && !p.health.hediffSet.HasDirectlyAddedPartFor(part)) { DamageDef vir_dam = DefDatabase <DamageDef> .GetNamed("ViralDamage"); HediffDef dam_def = HealthUtility.GetHediffDefFromDamage(vir_dam, p, part); Hediff_Injury inj = (Hediff_Injury)HediffMaker.MakeHediff(dam_def, p, null); inj.Severity = sev; inj.TryGetComp <HediffComp_GetsPermanent>().IsPermanent = true; p.health.AddHediff(inj, part, null); string message_title = std.syphilis.label + " Damage"; string baby_pronoun = p.gender == Gender.Male ? "his" : "her"; string message_text = "RJW_Syphilis_Damage_Message".Translate(xxx.get_pawnname(p), baby_pronoun, part.def.label, std.syphilis.label); Find.LetterStack.ReceiveLetter(message_title, message_text, LetterDefOf.ThreatSmall, p); } } }
protected override Job TryGiveJob(Pawn pawn) { //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called0"); //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 0 " + SexUtility.ReadyForLovin(pawn)); //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 1 " + (xxx.need_some_sex(pawn) <= 1f)); //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 2 " + !(SexUtility.ReadyForLovin(pawn) || xxx.need_some_sex(pawn) <= 1f)); //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 1 " + Find.TickManager.TicksGame); //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 2 " + pawn.mindState.canLovinTick); if (pawn.Drafted) { return(null); } if (pawn.health.hediffSet.HasHediff(HediffDef.Named("Hediff_RapeEnemyCD")) || !pawn.health.capacities.CanBeAwake || !(SexUtility.ReadyForLovin(pawn) || xxx.need_some_sex(pawn) <= 1f)) { //if (pawn.health.hediffSet.HasHediff(HediffDef.Named("Hediff_RapeEnemyCD")) || !pawn.health.capacities.CanBeAwake || (SexUtility.ReadyForLovin(pawn) || xxx.is_human(pawn) ? xxx.need_some_sex(pawn) <= 1f : false)) return(null); } if (!xxx.can_rape(pawn)) { return(null); } //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) can rape"); JobDef_RapeEnemy rapeEnemyJobDef = null; int?highestPriority = null; foreach (JobDef_RapeEnemy job in DefDatabase <JobDef_RapeEnemy> .AllDefs) { if (job.CanUseThisJobForPawn(pawn)) { if (highestPriority == null) { rapeEnemyJobDef = job; highestPriority = job.priority; } else if (job.priority > highestPriority) { rapeEnemyJobDef = job; highestPriority = job.priority; } } } //Log.Message("[RJW] JobGiver_RapeEnemy::ChoosedJobDef( " + xxx.get_pawnname(pawn) + " ) - " + rapeEnemyJobDef.ToString() + " choosed"); Pawn victim = rapeEnemyJobDef?.FindVictim(pawn, pawn.Map); //Log.Message("[RJW] JobGiver_RapeEnemy::FoundVictim( " + xxx.get_pawnname(victim) + " )"); //prevents 10 job stacks error, no idea whats the prob with JobDriver_Rape //if (victim != null) pawn.health.AddHediff(HediffDef.Named("Hediff_RapeEnemyCD"), null, null, null); return(victim != null ? new Job(rapeEnemyJobDef, victim) : null); /* * else * { * //--Log.Message("[RJW]" + this.GetType().ToString() + "::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - unable to find victim"); * pawn.mindState.canLovinTick = Find.TickManager.TicksGame + Rand.Range(75, 150); * } */ //else { //--Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - too fast to play next"); } }
public override void PostIngested(Pawn ingester) { if (this.Props.Addictive && ingester.RaceProps.IsFlesh) { HediffDef addictionHediffDef = this.Props.chemical.addictionHediff; Hediff_Addiction hediff_Addiction = AddictionUtility.FindAddictionHediff(ingester, this.Props.chemical); Hediff hediff = AddictionUtility.FindToleranceHediff(ingester, this.Props.chemical); float num = (hediff == null) ? 0f : hediff.Severity; if (hediff_Addiction != null) { hediff_Addiction.Severity += this.Props.existingAddictionSeverityOffset; } else if (Rand.Value < this.Props.addictiveness && num >= this.Props.minToleranceToAddict) { ingester.health.AddHediff(addictionHediffDef, null, null, null); if (PawnUtility.ShouldSendNotificationAbout(ingester)) { Find.LetterStack.ReceiveLetter("LetterLabelNewlyAddicted".Translate(new object[] { this.Props.chemical.label }).CapitalizeFirst(), "LetterNewlyAddicted".Translate(new object[] { ingester.LabelShort, this.Props.chemical.label }).AdjustedFor(ingester, "PAWN").CapitalizeFirst(), LetterDefOf.NegativeEvent, ingester, null, null); } AddictionUtility.CheckDrugAddictionTeachOpportunity(ingester); } if (addictionHediffDef.causesNeed != null) { Need need = ingester.needs.AllNeeds.Find((Need x) => x.def == addictionHediffDef.causesNeed); if (need != null) { float needLevelOffset = this.Props.needLevelOffset; AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(ingester, this.Props.chemical, ref needLevelOffset); need.CurLevel += needLevelOffset; } } Hediff firstHediffOfDef = ingester.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.DrugOverdose, false); float num2 = (firstHediffOfDef == null) ? 0f : firstHediffOfDef.Severity; if (num2 < 0.9f && Rand.Value < this.Props.largeOverdoseChance) { float num3 = Rand.Range(0.85f, 0.99f); HealthUtility.AdjustSeverity(ingester, HediffDefOf.DrugOverdose, num3 - num2); if (ingester.Faction == Faction.OfPlayer) { Messages.Message("MessageAccidentalOverdose".Translate(new object[] { ingester.LabelIndefinite(), this.parent.LabelNoCount }).CapitalizeFirst(), ingester, MessageTypeDefOf.NegativeHealthEvent, true); } } else { float num4 = this.Props.overdoseSeverityOffset.RandomInRange / ingester.BodySize; if (num4 > 0f) { HealthUtility.AdjustSeverity(ingester, HediffDefOf.DrugOverdose, num4); } } } if (this.Props.isCombatEnhancingDrug && !ingester.Dead) { ingester.mindState.lastTakeCombatEnhancingDrugTick = Find.TickManager.TicksGame; } if (ingester.drugs != null) { ingester.drugs.Notify_DrugIngested(this.parent); } }
private static bool on_begin_DoBirthSpawn(ref Pawn mother, ref Pawn father) { //--Log.Message("patches_pregnancy::PATCH_Hediff_Pregnant::DoBirthSpawn() called"); if (mother == null) { Log.Error("Hediff_Pregnant::DoBirthSpawn() - no mother defined -> exit"); return(false); } //vanilla debug? if (mother.gender == Gender.Male) { Log.Error("Hediff_Pregnant::DoBirthSpawn() - mother is male -> exit"); return(false); } // get a reference to the hediff we are applying //do birth for vanilla pregnancy Hediff //if using rjw pregnancies - add RJW pregnancy Hediff and birth it instead Hediff_Pregnant self = (Hediff_Pregnant)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Pregnant")); if (self != null) { return(ProcessVanillaPregnancy(self, mother, father)); } // do birth for existing RJW pregnancies if (ProcessRJWPregnancy(mother, father)) { return(false); } return(ProcessDebugPregnancy(mother, father)); }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); if (base.Pawn != null & base.parent != null) { if (!initialized) { initialized = true; this.Initialize(); } } this.age++; if (age == duration) { HealthUtility.AdjustSeverity(base.Pawn, HediffDef.Named("TM_NanoStimulantWithdrawalHD"), 1 - (.03f * this.hediffPwr)); Pawn pawn = base.Pawn as Pawn; TM_MoteMaker.ThrowRegenMote(pawn.DrawPos, pawn.Map, 1f); bool flag = pawn != null; if (flag) { ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); int num = 2 + Mathf.RoundToInt(this.hediffPwr * .2f); if (settingsRef.AIHardMode && !pawn.IsColonist) { num = 5; } using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { int num2 = 3 + Mathf.RoundToInt(this.hediffPwr * .35f); // + ver.level; if (settingsRef.AIHardMode && !pawn.IsColonist) { num2 = 5; } 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) { if (!pawn.IsColonist) { current.Heal(10f); } else { current.Heal(2f + (.35f * hediffPwr)); } if (Rand.Chance(.4f + (.02f * hediffPwr))) { current.Tended(Rand.Range(.4f + (.02f * this.hediffPwr), .5f + (.03f * this.hediffPwr))); } num--; num2--; } } } } } } } } }
/// <summary>Gets the boost to the specific hediff.</summary> /// <param name="hediff">The hediff.</param> /// <returns></returns> public float GetBoost(HediffDef hediff) { return(hediffFilter.PassesFilter(hediff) ? productionBoost : 0); }
public override IEnumerable <BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe) { BodyPartRecord part = pawn.RaceProps.body.corePart; if (recipe.appliedOnFixedBodyParts[0] != null) { part = pawn.RaceProps.body.AllParts.Find(x => x.def == recipe.appliedOnFixedBodyParts[0]); } if (part != null && pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy_mech"), part, true)) { Hediff_MechanoidPregnancy pregnancy = (Hediff_MechanoidPregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_mech")); //Log.Message("RJW_pregnancy_mech hack check: " + pregnancy.is_checked); if (pregnancy.is_checked) { yield return(part); } } }
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { if (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy_mech"))) { Hediff_MechanoidPregnancy pregnancy = (Hediff_MechanoidPregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_mech")); pregnancy.Hack(); } }
protected override bool TryCastShot() { Pawn caster = base.CasterPawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); verVal = comp.MagicData.MagicPowerSkill_Shapeshift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Shapeshift_ver").level; pwrVal = comp.MagicData.MagicPowerSkill_Shapeshift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Shapeshift_pwr").level; effVal = comp.MagicData.MagicPowerSkill_Shapeshift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Shapeshift_eff").level; this.duration = Mathf.RoundToInt((this.duration + (360 * effVal)) * comp.arcaneDmg); bool flag = caster != null && !caster.Dead; if (flag) { CompPolymorph compPoly = caster.GetComp <CompPolymorph>(); if (compPoly != null && compPoly.Original != null && compPoly.TicksLeft > 0) { compPoly.Temporary = true; compPoly.TicksLeft = 0; } else { FactionDef fDef = TorannMagicDefOf.TM_SummonedFaction; if (caster.Faction != null) { fDef = caster.Faction.def; } SpawnThings spawnThing = new SpawnThings(); spawnThing.factionDef = fDef; spawnThing.spawnCount = 1; spawnThing.temporary = false; spawnThing.kindDef = PawnKindDef.Named("TM_Dire_Wolf"); spawnThing.def = ThingDef.Named("TM_Dire_WolfR"); if (spawnThing.def == null || spawnThing.kindDef == null) { spawnThing.def = ThingDef.Named("Rat"); spawnThing.kindDef = PawnKindDef.Named("Rat"); Log.Message("random creature was null"); } Pawn polymorphedPawn = TM_Action.PolymorphPawn(this.CasterPawn, caster, caster, spawnThing, caster.Position, true, duration, caster.Faction); if (this.effVal >= 3) { polymorphedPawn.GetComp <CompPolymorph>().Temporary = false; } MoteMaker.ThrowSmoke(polymorphedPawn.DrawPos, caster.Map, 2); MoteMaker.ThrowMicroSparks(polymorphedPawn.DrawPos, caster.Map); MoteMaker.ThrowHeatGlow(polymorphedPawn.Position, caster.Map, 2); //caster.DeSpawn(); HealthUtility.AdjustSeverity(polymorphedPawn, HediffDef.Named("TM_ShapeshiftHD"), .5f + (1f * pwrVal)); } //SoundInfo info = SoundInfo.InMap(new TargetInfo(caster.Position, caster.Map, false), MaintenanceType.None); //info.pitchFactor = 1.0f; //info.volumeFactor = 1.0f; //TorannMagicDefOf.TM_FastReleaseSD.PlayOneShot(info); //TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_PowerWave"), caster.DrawPos, caster.Map, .8f, .2f, .1f, .1f, 0, 1f, 0, Rand.Chance(.5f) ? 0 : 180); } return(true); }
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { // We don't check if the surgery fails, because even if the surgery is a failure the fetus will still die if (billDoer != null) { TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[] { billDoer, pawn }); //if (base.CheckSurgeryFail (billDoer, pawn, ingredients, part) == false) { if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part, bill) == false) { if (PawnUtility.ShouldSendNotificationAbout(pawn) || PawnUtility.ShouldSendNotificationAbout(billDoer)) { string text; if (!this.recipe.successfullyRemovedHediffMessage.NullOrEmpty()) { text = string.Format(this.recipe.successfullyRemovedHediffMessage, billDoer.LabelShort, pawn.LabelShort); } else { text = "MessageSuccessfullyRemovedHediff".Translate(new object[] { billDoer.LabelShort, pawn.LabelShort, this.recipe.removesHediff.label }); } Messages.Message(text, pawn, MessageTypeDefOf.TaskCompletion); } } } Hediff_HumanPregnancy preggo = (Hediff_HumanPregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("HumanPregnancy")); if (preggo.IsLateTerm()) { // Give bad thoughts related to late abortions pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("LateTermAbortion"), null); if (preggo.GestationProgress >= 0.97f) { Thought_Memory abortion_thought = pawn.needs.mood.thoughts.memories.OldestMemoryOfDef(ThoughtDef.Named("LateTermAbortion")); if (abortion_thought == null) { Log.Error("ChildrenMod: Failed to add late term abortion thought!"); } // Very late term abortion abortion_thought.SetForcedStage(abortion_thought.CurStageIndex + 1); } // Give bad thoughts related to late abortions pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("LateTermAbortion"), null); if (preggo.GestationProgress >= 0.97f) { Thought_Memory abortion_thought = pawn.needs.mood.thoughts.memories.OldestMemoryOfDef(ThoughtDef.Named("LateTermAbortion")); // Very late term abortion abortion_thought.SetForcedStage(abortion_thought.CurStageIndex + 1); } // Remove the fetus preggo.Miscarry(true); } else { pawn.health.RemoveHediff(preggo); } }
public void RemoveHediffDefOn( Pawn pawn, HediffDef hediffDef, BodyPartRecord bodyPartRecord ) { if( ( pawn == null )|| ( hediffDef == null )|| ( bodyPartRecord == null ) ) { return; } var hediff = pawn.health.hediffSet.hediffs.FirstOrDefault( diff => ( ( diff.Part == bodyPartRecord )&& ( diff.def == hediffDef ) ) ); if( hediff == null ) { return; } pawn.health.hediffSet.hediffs.Remove( hediff ); }
public override IEnumerable <BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe) { BodyPartRecord part = pawn.RaceProps.body.corePart; if (recipe.appliedOnFixedBodyParts[0] != null) { part = pawn.RaceProps.body.AllParts.Find(x => x.def == recipe.appliedOnFixedBodyParts[0]); } if (part != null) { bool isMatch = Hediff_BasePregnancy.KnownPregnancies() // For every known pregnancy .Where(x => pawn.health.hediffSet.HasHediff(HediffDef.Named(x), true) && recipe.removesHediff == HediffDef.Named(x)) // Find matching bodyparts .Select(x => (Hediff_BasePregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named(x))) // get pregnancy hediff .Where(pregnancy => pregnancy.is_checked) // Find checked pregnancies (should be visible pregnancies there?) .Any(); // return true if found something if (isMatch) { yield return(part); } } }
protected override bool TryCastShot() { Pawn caster = base.CasterPawn; Pawn pawn = this.currentTarget.Thing as Pawn; comp = caster.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = comp.MagicData.MagicPowerSkill_Stoneskin.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Stoneskin_pwr"); MagicPowerSkill ver = comp.MagicData.MagicPowerSkill_Stoneskin.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Stoneskin_ver"); pwrVal = pwr.level; verVal = ver.level; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { pwrVal = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr").level; verVal = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver").level; } if (settingsRef.AIHardMode && !caster.IsColonist) { pwrVal = 3; verVal = 3; } if (pawn != null) { IEnumerable <Pawn> enumerable = from geomancer in caster.Map.mapPawns.AllPawnsSpawned where (geomancer.RaceProps.Humanlike && geomancer.story.traits.HasTrait(TorannMagicDefOf.Geomancer)) select geomancer; List <Pawn> geomancers = enumerable.ToList(); for (int i = 0; i < geomancers.Count(); i++) { CompAbilityUserMagic comp = geomancers[i].GetComp <CompAbilityUserMagic>(); if (comp.stoneskinPawns.Contains(pawn)) { comp.stoneskinPawns.Remove(pawn); } } if (pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_StoneskinHD"), false)) { Hediff hediff = new Hediff(); hediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_StoneskinHD")); if (hediff.Severity < 4 + pwrVal) { ApplyStoneskin(pawn); } else { RemoveHediffs(pawn); comp.stoneskinPawns.Remove(pawn); SoundInfo info = SoundInfo.InMap(new TargetInfo(pawn.Position, pawn.Map, false), MaintenanceType.None); info.pitchFactor = .7f; SoundDefOf.EnergyShield_Broken.PlayOneShot(info); MoteMaker.ThrowLightningGlow(pawn.DrawPos, pawn.Map, 1.5f); } } else { ApplyStoneskin(pawn); } } return(true); }
public void ApplyHediffDefOn( Pawn pawn, HediffDef hediffDef, BodyPartRecord bodyPartRecord ) { if( ( pawn == null )|| ( hediffDef == null )|| ( bodyPartRecord == null ) ) { return; } if( pawn.health.hediffSet.HasHediff( hediffDef, bodyPartRecord ) ) { return; } pawn.health.AddHediff( hediffDef, bodyPartRecord ); }
public static List <Texture2D> iconList(Pawn current) { HediffLeader h1 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader1")); HediffLeader h2 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader2")); HediffLeader h3 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader3")); HediffLeader h4 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader4")); if (h2 != null) { return(ModTextures.icons_leader2); } if (h3 != null) { return(ModTextures.icons_leader3); } if (h4 != null) { return(ModTextures.icons_leader4); } return(ModTextures.icons_leader1); }
public static bool Prefix(ref AbilitesExtended.Verb_EquipmentLaunchProjectile __instance) { // Log.Warning("TryCastShot"); bool GetsHot = __instance.verbProperties.GetsHot; bool Jams = __instance.verbProperties.Jams; bool GetsHotCrit = __instance.verbProperties.GetsHotCrit; float GetsHotCritChance = __instance.verbProperties.GetsHotCritChance; bool GetsHotCritExplosion = __instance.verbProperties.GetsHotCritExplosion; float GetsHotCritExplosionChance = __instance.verbProperties.GetsHotCritExplosionChance; bool canDamageWeapon = __instance.verbProperties.HotDamageWeapon || __instance.verbProperties.JamsDamageWeapon; float extraWeaponDamage = (Jams && __instance.verbProperties.JamsDamageWeapon) ? __instance.verbProperties.JamDamage : (GetsHot && __instance.verbProperties.HotDamageWeapon) ? __instance.verbProperties.HotDamage : 0f; bool TwinLinked = __instance.verbProperties.TwinLinked; bool Multishot = __instance.verbProperties.Multishot; int ScattershotCount = __instance.verbProperties.ScattershotCount; bool UserEffect = __instance.verbProperties.EffectsUser; HediffDef UserHediff = __instance.verbProperties.UserEffect; float AddHediffChance = __instance.verbProperties.EffectsUserChance; List <string> Immunitylist = __instance.verbProperties.UserEffectImmuneList; if ((GetsHot && AMSettings.Instance.AllowGetsHot) || (Jams && AMSettings.Instance.AllowJams)) { string msg = string.Format(""); string reliabilityString; float failChance; AbilitesExtended.StatPart_Reliability.GetReliability(__instance.verbProperties, out reliabilityString, out failChance); failChance = GetsHot ? (failChance / 10) : (failChance / 100); Rand.PushState(); bool fails = Rand.Chance(failChance); Rand.PopState(); if (fails) { if (GetsHot) { DamageDef damageDef = __instance.Projectile.projectile.damageDef; HediffDef HediffToAdd = damageDef.hediff; float ArmorPenetration = __instance.Projectile.projectile.GetArmorPenetration(__instance.EquipmentSource, null); float DamageAmount = 0; Pawn launcherPawn = __instance.caster as Pawn; Rand.PushState(); bool getshotcrit = Rand.Chance(GetsHotCritChance); Rand.PopState(); if (getshotcrit) { DamageAmount = __instance.Projectile.projectile.GetDamageAmount(__instance.EquipmentSource, null); msg = string.Format("{0}'s {1} critically overheated. ({2} chance) causing {3} damage", __instance.caster.LabelCap, __instance.EquipmentSource.LabelCap, failChance.ToStringPercent(), DamageAmount); Rand.PushState(); if (GetsHotCritExplosion && Rand.Chance(GetsHotCritExplosionChance)) { CriticalOverheatExplosion(ref __instance); } Rand.PopState(); } else { DamageAmount = __instance.Projectile.projectile.GetDamageAmount(__instance.EquipmentSource, null); msg = string.Format("{0}'s {1} overheated. ({2} chance) causing {3} damage", __instance.caster.LabelCap, __instance.EquipmentSource.LabelCap, failChance.ToStringPercent(), DamageAmount); } float maxburndmg = DamageAmount / 10; while (DamageAmount > 0f) { List <BodyPartRecord> list = launcherPawn.health.hediffSet.GetNotMissingParts().Where(x => x.def.defName.Contains("Finger") || x.def.defName.Contains("Hand")).ToList <BodyPartRecord>(); if (list.NullOrEmpty()) { list = launcherPawn.health.hediffSet.GetNotMissingParts().Where(x => x.def.defName.Contains("Arm") || x.def.defName.Contains("Shoulder")).ToList <BodyPartRecord>(); } if (list.NullOrEmpty()) { list = launcherPawn.health.hediffSet.GetNotMissingParts().Where(x => x.def.tags.Contains(BodyPartTagDefOf.ManipulationLimbCore) || x.def.tags.Contains(BodyPartTagDefOf.ManipulationLimbSegment) || x.def.tags.Contains(BodyPartTagDefOf.ManipulationLimbDigit)).ToList <BodyPartRecord>(); } if (list.NullOrEmpty()) { break; } else { BodyPartRecord part = list.RandomElement(); Hediff hediff; Rand.PushState(); float severity = Rand.Range(Math.Min(0.1f, DamageAmount), Math.Min(DamageAmount, maxburndmg)); Rand.PopState(); hediff = HediffMaker.MakeHediff(HediffToAdd, launcherPawn, null); hediff.Severity = severity; launcherPawn.health.AddHediff(hediff, part, null); DamageAmount -= severity; } } Messages.Message(msg, MessageTypeDefOf.NegativeHealthEvent); } else { msg = string.Format("{0}'s {1} had a weapon jam. ({2} chance)", __instance.caster.LabelCap, __instance.EquipmentSource.LabelCap, failChance.ToStringPercent()); Messages.Message(msg, MessageTypeDefOf.SilentInput); } float defaultCooldownTime = __instance.verbProps.defaultCooldownTime * 2; __instance.verbProps.defaultCooldownTime = defaultCooldownTime; if (canDamageWeapon) { if (extraWeaponDamage != 0f) { if (__instance.EquipmentSource != null) { if (__instance.EquipmentSource.HitPoints - (int)extraWeaponDamage >= 0) { __instance.EquipmentSource.HitPoints = __instance.EquipmentSource.HitPoints - (int)extraWeaponDamage; } else if (__instance.EquipmentSource.HitPoints - (int)extraWeaponDamage < 0) { __instance.EquipmentSource.HitPoints = 0; __instance.EquipmentSource.Destroy(); } } if (__instance.HediffCompSource != null) { /* * if (__instance.HediffCompSource.parent.Part..HitPoints - (int)extraWeaponDamage >= 0) * { * __instance.HediffCompSource.HitPoints = __instance.HediffCompSource.HitPoints - (int)extraWeaponDamage; * } * else if (__instance.HediffCompSource.HitPoints - (int)extraWeaponDamage < 0) * { * __instance.HediffCompSource.HitPoints = 0; * __instance.HediffCompSource.Destroy(); * } */ } } else { if (__instance.EquipmentSource != null) { if (__instance.EquipmentSource.HitPoints > 0) { __instance.EquipmentSource.HitPoints--; } } } } if (Jams) { if (__instance.EquipmentSource != null) { SpinningLaserGun spinner = (SpinningLaserGun)__instance.EquipmentSource; if (spinner != null) { spinner.state = SpinningLaserGunBase.State.Idle; spinner.ReachRotationSpeed(0, 0); } } return(false); } } } if (ScattershotCount > 0 && Multishot && AMSettings.Instance.AllowMultiShot || TwinLinked) { Traverse traverse = Traverse.Create(__instance); LocalTargetInfo currentTarget = (LocalTargetInfo)Verb_Shoot_TryCastShot_WeaponSpecialRules_Patch.currentTarget.GetValue(__instance); bool canHitNonTargetPawnsNow = (bool)Verb_Shoot_TryCastShot_WeaponSpecialRules_Patch.canHitNonTargetPawnsNow.GetValue(__instance); // Log.Message(string.Format("AllowMultiShot: {0} Projectile Count: {1}", AMASettings.Instance.AllowMultiShot && Multishot, ScattershotCount)); if (TwinLinked) { TryCastExtraShot(ref __instance, currentTarget, canHitNonTargetPawnsNow); } else { for (int i = 0; i < ScattershotCount; i++) { TryCastExtraShot(ref __instance, currentTarget, canHitNonTargetPawnsNow); } } } if (UserEffect && AMSettings.Instance.AllowUserEffects) { if (__instance.caster.def.category == ThingCategory.Pawn) { bool Immunityflag = false; Pawn launcherPawn = __instance.caster as Pawn; if (!Immunitylist.NullOrEmpty()) { foreach (var item in Immunitylist) { Immunityflag = launcherPawn.def.defName.Contains(item); if (Immunityflag) { // Log.Message(string.Format("{0} is immune to their {1}'s UseEffect", launcherPawn.LabelShortCap, __instance.EquipmentSource.LabelShortCap)); } } /* * List<string> list = GunExt.UserEffectImmuneList.Where(x => DefDatabase<ThingDef>.GetNamedSilentFail(x) != null).ToList(); * bool Immunityflag = list.Contains(launcherPawn.def.defName); * if (Immunityflag) * { * return; * } */ } if (!Immunityflag) { Rand.PushState(); var rand = Rand.Value; // This is a random percentage between 0% and 100% Rand.PopState(); // Log.Message(string.Format("GunExt.EffectsUser Effect: {0}, Chance: {1}, Roll: {2}, Result: {3}" + GunExt.ResistEffectStat != null ? ", Resist Stat: "+GunExt.ResistEffectStat.LabelCap+", Resist Amount"+ __instance.caster.GetStatValue(GunExt.ResistEffectStat, true) : null, GunExt.UserEffect.LabelCap, AddHediffChance, rand, rand <= AddHediffChance)); if (rand <= AddHediffChance) // If the percentage falls under the chance, success! { Rand.PushState(); var randomSeverity = Rand.Range(0.05f, 0.15f); Rand.PopState(); var effectOnPawn = launcherPawn?.health?.hediffSet?.GetFirstHediffOfDef(UserHediff); if (effectOnPawn != null) { effectOnPawn.Severity += randomSeverity; } else { Hediff hediff = HediffMaker.MakeHediff(UserHediff, launcherPawn, null); hediff.Severity = randomSeverity; launcherPawn.health.AddHediff(hediff, null, null); } } } } } return(true); }
protected override bool TryCastShot() { caster = base.CasterPawn; pawn = this.currentTarget.Thing as Pawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = comp.MagicData.MagicPowerSkill_SoulBond.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SoulBond_pwr"); MagicPowerSkill ver = comp.MagicData.MagicPowerSkill_SoulBond.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SoulBond_ver"); verVal = ver.level; pwrVal = pwr.level; bool flag = pawn != null && !pawn.Dead && pawn.RaceProps.Humanlike && pawn != caster; if (flag) { if (!pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadHD)) { if (pawn.Faction != this.CasterPawn.Faction) { Messages.Message("TM_CannotSoulBondUnwilling".Translate( caster.LabelShort, pawn.LabelShort ), MessageTypeDefOf.RejectInput); } else { flagSD = caster.gender == Gender.Female; flagWD = caster.gender == Gender.Male; if (comp.soulBondPawn != null) { oldBondPawn = comp.soulBondPawn; RemoveHediffs(); if (oldBondPawn == pawn) { comp.soulBondPawn = null; comp.spell_ShadowCall = false; comp.spell_ShadowStep = false; comp.RemovePawnAbility(TorannMagicDefOf.TM_ShadowCall); comp.RemovePawnAbility(TorannMagicDefOf.TM_ShadowStep); } else { if (pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_SoulBondPhysicalHD")) && flagSD) { Messages.Message("TM_CannotSoulBondAnother".Translate( caster.LabelShort, pawn.LabelShort ), MessageTypeDefOf.RejectInput); } else if (pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_SoulBondMentalHD")) && flagWD) { Messages.Message("TM_CannotSoulBondAnother".Translate( caster.LabelShort, pawn.LabelShort ), MessageTypeDefOf.RejectInput); } else { ApplyHediffs(); comp.soulBondPawn = pawn; } } } else { ApplyHediffs(); comp.spell_ShadowCall = true; comp.spell_ShadowStep = true; comp.AddPawnAbility(TorannMagicDefOf.TM_ShadowCall); comp.AddPawnAbility(TorannMagicDefOf.TM_ShadowStep); comp.soulBondPawn = pawn; } } } else { Messages.Message("TM_CannotSoulBondUndead".Translate( caster.LabelShort ), MessageTypeDefOf.RejectInput); } } else { Messages.Message("TM_CannotSoulBondThing".Translate( caster.LabelShort ), MessageTypeDefOf.RejectInput); } return(true); }
protected override bool TryCastShot() { Pawn caster = base.CasterPawn; Pawn pawn = this.currentTarget.Thing as Pawn; CompAbilityUserMagic comp = caster.TryGetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = comp.MagicData.MagicPowerSkill_CureDisease.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CureDisease_pwr"); MagicPowerSkill ver = comp.MagicData.MagicPowerSkill_CureDisease.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CureDisease_ver"); verVal = ver.level; pwrVal = pwr.level; this.arcaneDmg = caster.GetComp <CompAbilityUserMagic>().arcaneDmg; if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); pwrVal = mpwr.level; verVal = mver.level; } bool flag = pawn != null; if (flag) { int num = 1; float sevAdjustment = 0; if (pwrVal >= 2) { //apply immunity buff, 60k ticks in a day if (pwrVal == 3) { HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_DiseaseImmunity2HD, 5); pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_DiseaseImmunity2HD).TryGetComp <HediffComp_DiseaseImmunity>().verVal = verVal; } else { HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_DiseaseImmunityHD, 3); } } if (pwrVal >= 1) { sevAdjustment = 5; } else { sevAdjustment = (Rand.Range(0f, 1f) * this.arcaneDmg); } if (sevAdjustment >= .25f) { bool success = false; using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; bool flag2 = num > 0; if (TM_Data.AddictionList().Contains(rec.def)) { List <TMDefs.TM_CategoryHediff> diseaseList = HediffCategoryList.Named("TM_Category_Hediffs").diseases; foreach (TMDefs.TM_CategoryHediff chd in diseaseList) { if (chd.hediffDefname.Contains(rec.def.defName)) { if (comp != null && chd.requiredSkillName != "TM_Purify_ver") { pwrVal = comp.MagicData.AllMagicPowerSkills.FirstOrDefault((MagicPowerSkill x) => x.label == chd.powerSkillName).level; verVal = comp.MagicData.AllMagicPowerSkills.FirstOrDefault((MagicPowerSkill x) => x.label == chd.requiredSkillName).level; } if (verVal >= chd.requiredSkillLevel) { if (chd.removeOnCure) { if (Rand.Chance((chd.chanceToRemove + (chd.powerSkillAdjustment * pwrVal)) * arcaneDmg)) { pawn.health.RemoveHediff(rec); if (chd.replacementHediffDefname != "") { HealthUtility.AdjustSeverity(pawn, HediffDef.Named(chd.replacementHediffDefname), chd.replacementHediffSeverity); } success = true; num--; } else { MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Failed to remove " + rec.Label + " ..."); } break; } else { if (((rec.Severity - (chd.severityReduction + (chd.powerSkillAdjustment * pwrVal)) * arcaneDmg <= 0))) { if (chd.replacementHediffDefname != "") { HealthUtility.AdjustSeverity(pawn, HediffDef.Named(chd.replacementHediffDefname), chd.replacementHediffSeverity); } success = true; } rec.Severity -= ((chd.severityReduction + (chd.powerSkillAdjustment * pwrVal)) * arcaneDmg); num--; break; } } } } } else { if (rec.def.defName == "WoundInfection" || rec.def.defName.Contains("Flu") || rec.def.defName == "Animal_Flu" || rec.def.defName.Contains("Infection")) { //rec.Severity -= sevAdjustment; pawn.health.RemoveHediff(rec); success = true; } if (verVal >= 1 && (rec.def.defName == "GutWorms" || rec.def == HediffDefOf.Malaria || rec.def == HediffDefOf.FoodPoisoning)) { //rec.Severity -= sevAdjustment; pawn.health.RemoveHediff(rec); success = true; } if (verVal >= 2 && (rec.def.defName == "SleepingSickness" || rec.def.defName == "MuscleParasites") || rec.def == HediffDefOf.Scaria) { //rec.Severity -= sevAdjustment; pawn.health.RemoveHediff(rec); success = true; } if (verVal == 3 && (rec.def.makesSickThought && rec.def.isBad)) { //rec.Severity -= sevAdjustment; if (rec.def.defName == "BloodRot") { rec.Severity = 0.01f; MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Tended Blood Rot", -1f); rec.Tended_NewTemp(1f, 1f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3(), pawn.Map, 1.5f); return(false); } else if (rec.def.defName == "Abasia") { //do nothing } else { pawn.health.RemoveHediff(rec); success = true; } } } if (success) { break; } } } if (success == true) { TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3(), pawn.Map, 1.5f); MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Cure Disease" + ": " + StringsToTranslate.AU_CastSuccess, -1f); } else { Messages.Message("TM_CureDiseaseTypeFail".Translate(), MessageTypeDefOf.NegativeEvent); MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Cure Disease" + ": " + StringsToTranslate.AU_CastFailure, -1f); } } else { MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Cure Disease" + ": " + StringsToTranslate.AU_CastFailure, -1f); } } return(false); }
/// <summary> /// Calculates primary DamageInfo from verb, as well as secondary DamageInfos to apply (i.e. surprise attack stun damage). /// Also calculates the maximum body height an attack can target, so we don't get rabbits biting out a colonist's eye or something. /// </summary> /// <param name="target">The target damage is to be applied to</param> /// <returns>Collection with primary DamageInfo, followed by secondary types</returns> private IEnumerable <DamageInfo> DamageInfosToApply(LocalTargetInfo target, bool isCrit = false) { float damAmount = (float)this.verbProps.AdjustedMeleeDamageAmount(this, base.CasterPawn); float armorPenetration = this.verbProps.AdjustedArmorPenetration(this, base.CasterPawn); var critDamDef = CritDamageDef; DamageDef damDef = isCrit && critDamDef != DamageDefOf.Stun ? critDamDef : verbProps.meleeDamageDef; //Added isCrit check BodyPartGroupDef bodyPartGroupDef = null; HediffDef hediffDef = null; damAmount = UnityEngine.Random.Range(damAmount * 0.8f, damAmount * 1.2f); var verbpropsCE = this.verbProps as VerbPropertiesCE; if (base.CasterIsPawn) { bodyPartGroupDef = verbpropsCE.AdjustedLinkedBodyPartsGroupCE(this.tool as ToolCE); if (damAmount >= 1f) { if (this.HediffCompSource != null) { hediffDef = this.HediffCompSource.Def; } } else { damAmount = 1f; damDef = DamageDefOf.Blunt; } } ThingDef source; if (this.EquipmentSource != null) { source = this.EquipmentSource.def; } else { source = base.CasterPawn.def; } Vector3 direction = (target.Thing.Position - base.CasterPawn.Position).ToVector3(); Thing caster = this.caster; float num = GenMath.RoundRandom(damAmount); float num2 = isCrit ? armorPenetration * 2: armorPenetration; BodyPartHeight bodyRegion = GetBodyPartHeightFor(target); // Add check for body height DamageInfo mainDinfo = new DamageInfo(damDef, num, num2, -1f, caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null); mainDinfo.SetBodyRegion(bodyRegion, BodyPartDepth.Outside); mainDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef); mainDinfo.SetWeaponHediff(hediffDef); mainDinfo.SetAngle(direction); yield return(mainDinfo); // Apply secondary damage on surprise attack /* * if (!surpriseAttack || ((verbProps.surpriseAttack == null || verbProps.surpriseAttack.extraMeleeDamages.NullOrEmpty<ExtraMeleeDamage>()) || && tool != null || && tool.surpriseAttack != null || && !tool.surpriseAttack.extraMeleeDamages.NullOrEmpty<ExtraMeleeDamage>()) ||) ||{ || IEnumerable<ExtraMeleeDamage> extraDamages = Enumerable.Empty<ExtraMeleeDamage>(); || if (verbProps.surpriseAttack != null && verbProps.surpriseAttack.extraMeleeDamages != null) || { || extraDamages = extraDamages.Concat(tool.surpriseAttack.extraMeleeDamages); || } || if (tool != null && tool.surpriseAttack != null && !tool.surpriseAttack.extraMeleeDamages.NullOrEmpty<ExtraMeleeDamage>()) || { || extraDamages = extraDamages.Concat(tool.surpriseAttack.extraMeleeDamages); || } || foreach (ExtraMeleeDamage extraDamage in extraDamages) || { || int amount = GenMath.RoundRandom((float)extraDamage.amount * base.GetDamageFactorFor(base.CasterPawn)); || DamageInfo extraDinfo = new DamageInfo(extraDamage.def, amount, -1f, this.caster, null, source); || extraDinfo.SetBodyRegion(bodyRegion, BodyPartDepth.Outside); || extraDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef); || extraDinfo.SetWeaponHediff(hediffDef); || extraDinfo.SetAngle(direction); || yield return extraDinfo; || } ||} */ // Apply critical damage if (isCrit && critDamDef == DamageDefOf.Stun) { var critAmount = GenMath.RoundRandom(mainDinfo.Amount * 0.25f); var critDinfo = new DamageInfo(critDamDef, critAmount, armorPenetration, -1, caster, null, source); critDinfo.SetBodyRegion(bodyRegion, BodyPartDepth.Outside); critDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef); critDinfo.SetWeaponHediff(hediffDef); critDinfo.SetAngle(direction); yield return(critDinfo); } }
public static bool rendingWeapon(this HediffDef hediff) { return(hediff.defName.Contains("OG_RendingWeapon_")); }
protected override bool TryCastShot() { int logcount = 0; bool logging = VerbPropsOG.logging; // logging = true; // bool canDamageWeapon = VerbPropsOG.canDamageWeapon; // float extraWeaponDamage = VerbPropsOG.extraWeaponDamage; bool canJam = VerbPropsOG.canJam; string msg; string lmsg = string.Format("log {0} Reliable:{1}", logcount, Reliable); string reliabilityString; float jamsOn; StatPart_Reliability.GetReliability((ThingDef_GunOG)EquipmentSource, out reliabilityString, out jamsOn); logcount++; if (logging == true) { Log.Message(lmsg); } jamsOn = jamsOn++; float jamRoll = 0; logcount++; lmsg = string.Format("log {0} jamsOn {1}", logcount, jamsOn); if (logging == true) { Log.Message(lmsg); } if (VerbPropsOG.overheat == true) { jamRoll = (Rand.Range(0, 100)); } else { jamRoll = (Rand.Range(0, 1000)) / 10f; } logcount++; lmsg = string.Format("log {0} jamRoll {1}", logcount, jamRoll); if (logging == true) { Log.Message(lmsg); } if (jamRoll < jamsOn && canJam == true) { logcount++; lmsg = string.Format("log {0} VerbPropsOG.overheat {1}", logcount, VerbPropsOG.overheat); if (logging == true) { Log.Message(lmsg); } if (VerbPropsOG.overheat == true) { DamageDef damageDef = projectilePropsCE.damageDef; if (damageDef != null) { lmsg = string.Format("log {0} damageDef is null?:{1}", logcount, projectilePropsCE.damageDef.hediff); if (logging == true) { Log.Message(lmsg); } } HediffDef HediffToAdd = damageDef.hediff; float ArmorPenetration = projectilePropsCE.GetArmorPenetration(EquipmentSource, null); float overheatsOn = VerbPropsOG.overheatsOn; logcount++; lmsg = string.Format("log {0} overheatsOn {1}", logcount, overheatsOn); if (logging == true) { Log.Message(lmsg); } int DamageAmount = 0; float overheatRoll = (Rand.Range(0, 1000)) / 10f; logcount++; lmsg = string.Format("log {0} overheatRoll {1}", logcount, overheatRoll); if (logging == true) { Log.Message(lmsg); } Pawn launcherPawn = CasterPawn; if (overheatRoll < overheatsOn) { DamageAmount = Projectile.projectile.GetDamageAmount(EquipmentSource, null); msg = string.Format("{0}'s {1} critically overheated. ({2}/{3}) causing {4} damage", caster.LabelCap, EquipmentSource.LabelCap, jamRoll, jamsOn, DamageAmount); if (VerbPropsOG.criticaloverheatExplosion == true) { CriticalOverheatExplosion(); } } else { DamageAmount = Projectile.projectile.GetDamageAmount(EquipmentSource, null) / 10; msg = string.Format("{0}'s {1} overheated. ({2}/{3}) causing {4} damage", caster.LabelCap, EquipmentSource.LabelCap, jamRoll, jamsOn, DamageAmount); } bool hashediff = launcherPawn.health.hediffSet.HasHediff(HediffToAdd); logcount++; lmsg = string.Format("log {0} hashediff {1}", logcount, hashediff); if (logging == true) { Log.Message(lmsg); } var overheatOnPawn = launcherPawn?.health?.hediffSet?.GetFirstHediffOfDef(HediffToAdd); logcount++; lmsg = string.Format("log {0} overheatOnPawn {1}", logcount, overheatOnPawn); if (logging == true) { Log.Message(lmsg); } if (hashediff == true) { logcount++; lmsg = string.Format("log {0} overheatOnPawn Severity? {1}", logcount, overheatOnPawn.Severity); if (logging == true) { Log.Message(lmsg); } overheatOnPawn.Severity += DamageAmount; logcount++; lmsg = string.Format("log {0} overheatOnPawn.Severity {1}", logcount, overheatOnPawn.Severity); if (logging == true) { Log.Message(lmsg); } } else { logcount++; lmsg = string.Format("log {0} hashediff {1}", logcount, hashediff); if (logging == true) { Log.Message(lmsg); } logcount++; lmsg = string.Format("log {0} overheatOnPawn null?:{1}", logcount, overheatOnPawn); if (logging == true) { Log.Message(lmsg); } int affected = 0; foreach (var part in launcherPawn.RaceProps.body.AllParts.Where(x => x.def.defName.Contains("Hand") || x.def.defName.Contains("hand"))) { logcount++; lmsg = string.Format("log {0} part.def.hitPoints {1}", logcount, launcherPawn.health.hediffSet.PartIsMissing(part)); if (logging == true) { Log.Message(lmsg); } if (launcherPawn.health.hediffSet.PartIsMissing(part) == false && Rand.Chance(0.5f)) { logcount++; lmsg = string.Format("log {0} part.customLabel {1}", logcount, part.def.hitPoints); if (logging == true) { Log.Message(lmsg); } Hediff hediff = HediffMaker.MakeHediff(HediffToAdd, launcherPawn, null); hediff.Severity = Rand.Range(0, DamageAmount); launcherPawn.health.AddHediff(hediff, part, null); affected++; } } /* */ } Messages.Message(msg, MessageTypeDefOf.NegativeHealthEvent); } else { msg = string.Format("{0}'s {1} had a weapon jam. ({2}/{3})", caster.LabelCap, EquipmentSource.LabelCap, jamRoll, jamsOn); Messages.Message(msg, MessageTypeDefOf.SilentInput); } if (EquipmentSource.HitPoints > 0) { EquipmentSource.HitPoints--; } float defaultCooldownTime = this.verbProps.defaultCooldownTime * 2; return(false); } /* */ if (VerbPropsOG.canDamageWeapon) { if (VerbPropsOG.extraWeaponDamage != 0f) { if (EquipmentSource.HitPoints - (int)VerbPropsOG.extraWeaponDamage >= 0) { EquipmentSource.HitPoints = EquipmentSource.HitPoints - (int)VerbPropsOG.extraWeaponDamage; } else if (EquipmentSource.HitPoints - (int)VerbPropsOG.extraWeaponDamage < 0) { EquipmentSource.HitPoints = 0; } } else { if (EquipmentSource.HitPoints > 0) { EquipmentSource.HitPoints--; } } } bool flag = base.TryCastShot(); if (flag && base.CasterIsPawn) { base.CasterPawn.records.Increment(RecordDefOf.ShotsFired); } bool flag2 = flag && VerbPropsOG.pelletCount - 1 > 0; bool flag3 = flag2; if (flag3) { for (int i = 0; i < VerbPropsOG.pelletCount - 1; i++) { base.TryCastShot(); } } return(flag); }
public override float ValueFor(Pawn pawn) { if (pawn.skills == null) { return 1f; } int level = pawn.skills.GetSkill(this.skill).Level; // remove melee bonus for pawns: downed, sleeping/resting/lying, wearing armbinder if (pawn.Downed || pawn.GetPosture() != PawnPosture.Standing || pawn.health.hediffSet.HasHediff(HediffDef.Named("Armbinder"))) //|| pawn.health.hediffSet.HasHediff(HediffDef.Named("Yoke")) || pawn.health.hediffSet.HasHediff(HediffDef.Named("BoundHands"))) level = 0; return this.ValueAtLevel(level); }
private void ApplyDamagePartial(DamageInfo dinfo, Pawn pawn, ref DamageWorker_AddInjuryCR.LocalInjuryResult result) { BodyPartRecord exactPartFromDamageInfo = DamageWorker_AddInjuryCR.GetExactPartFromDamageInfo(dinfo, pawn); if (exactPartFromDamageInfo == null) { return; } // Only apply armor if we propagate damage to the outside or the body part itself is outside, secondary damage types should directly damage organs, bypassing armor bool involveArmor = !dinfo.InstantOldInjury && !result.deflected && (dinfo.Def.harmAllLayersUntilOutside || exactPartFromDamageInfo.depth == BodyPartDepth.Outside); int damageAmount = dinfo.Amount; if (involveArmor) { damageAmount = Utility.GetAfterArmorDamage(pawn, dinfo.Amount, exactPartFromDamageInfo, dinfo, true, ref result.deflected); } if ((double)damageAmount < 0.001) { result.absorbed = true; return; } // Shot absorbed and converted into blunt DamageDef_CR damageDefCR = dinfo.Def as DamageDef_CR; if (damageDefCR != null && damageDefCR.deflectable && result.deflected && dinfo.Def != Utility.absorbDamageDef) { // Get outer parent of struck part BodyPartRecord currentPart = exactPartFromDamageInfo; while (currentPart != null && currentPart.parent != null && currentPart.depth != BodyPartDepth.Outside) { currentPart = currentPart.parent; } DamageInfo dinfo2 = new DamageInfo(Utility.absorbDamageDef, damageAmount, dinfo.Instigator, new BodyPartDamageInfo(currentPart, false), dinfo.Source); this.ApplyDamagePartial(dinfo2, pawn, ref result); return; } //Creating the Hediff HediffDef hediffDefFromDamage = HealthUtility.GetHediffDefFromDamage(dinfo.Def, pawn, exactPartFromDamageInfo); Hediff_Injury hediff_Injury = (Hediff_Injury)HediffMaker.MakeHediff(hediffDefFromDamage, pawn, null); hediff_Injury.Part = exactPartFromDamageInfo; hediff_Injury.source = dinfo.Source; hediff_Injury.sourceBodyPartGroup = dinfo.LinkedBodyPartGroup; hediff_Injury.sourceHediffDef = dinfo.LinkedHediffDef; hediff_Injury.Severity = (float)damageAmount; if (dinfo.InstantOldInjury) { HediffComp_GetsOld hediffComp_GetsOld = hediff_Injury.TryGetComp <HediffComp_GetsOld>(); if (hediffComp_GetsOld != null) { hediffComp_GetsOld.IsOld = true; } else { Log.Error(string.Concat(new object[] { "Tried to create instant old injury on Hediff without a GetsOld comp: ", hediffDefFromDamage, " on ", pawn })); } } result.wounded = true; result.lastHitPart = hediff_Injury.Part; if (DamageWorker_AddInjuryCR.IsHeadshot(dinfo, hediff_Injury, pawn)) { result.headshot = true; } if (dinfo.InstantOldInjury && (hediff_Injury.def.CompPropsFor(typeof(HediffComp_GetsOld)) == null || hediff_Injury.Part.def.oldInjuryBaseChance == 0f || hediff_Injury.Part.def.IsSolid(hediff_Injury.Part, pawn.health.hediffSet.hediffs) || pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(hediff_Injury.Part))) { return; } this.FinalizeAndAddInjury(pawn, hediff_Injury, dinfo, ref result); this.CheckPropagateDamageToInnerSolidParts(dinfo, pawn, hediff_Injury, !dinfo.InstantOldInjury, damageAmount, ref result); this.CheckDuplicateDamageToOuterParts(dinfo, pawn, hediff_Injury, !dinfo.InstantOldInjury, damageAmount, ref result); }
public static bool IsUndead(Pawn pawn) { if (pawn != null) { bool flag_Hediff = false; if (pawn.health != null && pawn.health.hediffSet != null) { if (pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_UndeadHD"), false) || pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_UndeadAnimalHD"), false) || pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_LichHD"), false) || pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_UndeadStageHD"), false)) { flag_Hediff = true; } Hediff hediff = null; for (int i = 0; i < pawn.health.hediffSet.hediffs.Count; i++) { hediff = pawn.health.hediffSet.hediffs[i]; if (hediff.def.defName.Contains("ROM_Vamp")) { flag_Hediff = true; } } } bool flag_DefName = false; if (pawn.def.defName == "SL_Runner" || pawn.def.defName == "SL_Peon" || pawn.def.defName == "SL_Archer" || pawn.def.defName == "SL_Hero") { flag_DefName = true; } bool flag_Trait = false; if (pawn.story != null && pawn.story.traits != null) { if (pawn.story.traits.HasTrait(TorannMagicDefOf.Undead)) { flag_Trait = true; } } bool isUndead = flag_Hediff || flag_DefName || flag_Trait; return(isUndead); } return(false); }
public static string PostAbilityDesc(TMAbilityDef mightAbilityDef, CompAbilityUserMight mightUser, int maxCastingTicks) { string result = ""; StringBuilder stringBuilder = new StringBuilder(); bool flag = mightAbilityDef != null; if (flag) { string text = ""; string text2 = ""; string text3 = ""; float num = 0; float num2 = 0; num = mightUser.ActualStaminaCost(mightAbilityDef) * 100; if (mightAbilityDef == TorannMagicDefOf.TM_Whirlwind)//mightAbilityDef == TorannMagicDefOf.) { num2 = FlyingObject_Whirlwind.GetWeaponDmg(mightUser.Pawn); text2 = "TM_WhirlwindDamage".Translate( num2.ToString() ); } else if (mightAbilityDef == TorannMagicDefOf.TM_Cleave) { if (mightUser.Pawn.equipment.Primary != null && !mightUser.Pawn.equipment.Primary.def.IsRangedWeapon) { num2 = Mathf.Min((mightUser.Pawn.equipment.Primary.def.BaseMass * .15f) * 100f, 75f); text2 = "TM_CleaveChance".Translate( num2.ToString() ); } else { text2 = "TM_CleaveChance".Translate( num2.ToString() ); } } else if (mightAbilityDef == TorannMagicDefOf.TM_ShadowStrike) { num2 = Projectile_ShadowStrike.GetWeaponDmg(mightUser.Pawn); text2 = "TM_WeaponDamage".Translate( mightAbilityDef.label, num2.ToString() ); if (mightUser.Pawn.equipment.Primary != null && !mightUser.Pawn.equipment.Primary.def.IsRangedWeapon) { text3 = "TM_CritChance".Translate( mightAbilityDef.label, mightUser.weaponCritChance.ToString("P0") ); } else { text3 = "TM_CritChance".Translate( mightAbilityDef.label, "0" ); } } else if (mightUser.Pawn.equipment.Primary != null && mightUser.Pawn.equipment.Primary.def.IsRangedWeapon) { if (mightAbilityDef == TorannMagicDefOf.TM_Headshot) { num2 = Projectile_Headshot.GetWeaponDmg(mightUser.Pawn); text2 = "TM_WeaponDamage".Translate( mightAbilityDef.label, num2.ToString() ); } if (mightAbilityDef == TorannMagicDefOf.TM_AntiArmor) { num2 = Projectile_AntiArmor.GetWeaponDmg(mightUser.Pawn); float num3 = Projectile_AntiArmor.GetWeaponDmgMech(mightUser.Pawn, Mathf.RoundToInt(num2)); text2 = "TM_AntiArmorDamage".Translate( mightAbilityDef.label, num2.ToString(), num3.ToString() ); } if (mightAbilityDef == TorannMagicDefOf.TM_ArrowStorm || mightAbilityDef == TorannMagicDefOf.TM_ArrowStorm_I || mightAbilityDef == TorannMagicDefOf.TM_ArrowStorm_II || mightAbilityDef == TorannMagicDefOf.TM_ArrowStorm_III) { num2 = Projectile_ArrowStorm.GetWeaponDmg(mightUser.Pawn); int num3 = Mathf.RoundToInt(Projectile_ArrowStorm.GetWeaponAccuracy(mightUser.Pawn) * 100f); text2 = "TM_ArrowStormDamage".Translate( mightAbilityDef.label, num2.ToString(), num3.ToString() ); } if (mightAbilityDef == TorannMagicDefOf.TM_TempestStrike) { num2 = Projectile_TempestStrike.GetWeaponDmg(mightUser.Pawn); int num3 = Mathf.RoundToInt(Verb_TempestStrike.HitChance(mightUser.Pawn) * 100); text2 = "TM_ArrowStormDamage".Translate( mightAbilityDef.label, (num2.ToString() + " per strike\n"), num3.ToString() ); } if (mightAbilityDef == TorannMagicDefOf.TM_SuppressingFire) { num2 = Verb_SuppressingFire.GetShotCount(mightUser.Pawn); text2 = "TM_SuppressingFireCount".Translate(num2).ToString(); } if (mightAbilityDef == TorannMagicDefOf.TM_Buckshot) { num2 = Verb_Buckshot.GetShotCount(mightUser.Pawn); text2 = "TM_BuckshotFireCount".Translate(num2).ToString(); } } else if (mightUser.Pawn.equipment.Primary != null && !mightUser.Pawn.equipment.Primary.def.IsRangedWeapon) { if (mightAbilityDef == TorannMagicDefOf.TM_PhaseStrike || mightAbilityDef == TorannMagicDefOf.TM_PhaseStrike_I || mightAbilityDef == TorannMagicDefOf.TM_PhaseStrike_II || mightAbilityDef == TorannMagicDefOf.TM_PhaseStrike_III) { num2 = Mathf.RoundToInt(mightUser.weaponDamage * mightAbilityDef.weaponDamageFactor); text2 = "TM_WeaponDamage".Translate( mightAbilityDef.label, num2.ToString() ); } if (mightAbilityDef == TorannMagicDefOf.TM_BladeSpin) { num2 = Mathf.RoundToInt(mightUser.weaponDamage * mightAbilityDef.weaponDamageFactor); text2 = "TM_WeaponDamage".Translate( mightAbilityDef.label, num2.ToString() ); } if (mightAbilityDef == TorannMagicDefOf.TM_SeismicSlash) { num2 = Mathf.RoundToInt(mightUser.weaponDamage * mightAbilityDef.weaponDamageFactor * (1f + (.1f * mightUser.MightData.GetSkill_Power(mightAbilityDef).level))); text2 = "TM_WeaponDamage".Translate( mightAbilityDef.label, num2.ToString() ); } if (mightAbilityDef == TorannMagicDefOf.TM_TempestStrike) { num2 = Projectile_TempestStrike.GetWeaponDmg(mightUser.Pawn); text2 = "TM_WeaponDamage".Translate( mightAbilityDef.label, num2.ToString() ) + " per strike"; } } else if (mightUser.Pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_PsionicHD"), false)) { if (mightAbilityDef == TorannMagicDefOf.TM_PsionicBlast || mightAbilityDef == TorannMagicDefOf.TM_PsionicBlast_I || mightAbilityDef == TorannMagicDefOf.TM_PsionicBlast_II || mightAbilityDef == TorannMagicDefOf.TM_PsionicBlast_III) { num2 = 4 - (mightUser.MightData.MightPowerSkill_PsionicBlast.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicBlast_ver").level); text2 = "TM_PsionicInitialCost".Translate( 20 ) + "\n" + "TM_PsionicBlastAddCost".Translate( num2 ); } if (mightAbilityDef == TorannMagicDefOf.TM_PsionicDash) { num2 = 8 - (mightUser.MightData.MightPowerSkill_PsionicDash.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicDash_eff").level); text2 = "TM_PsionicInitialCost".Translate( num2 ); } if (mightAbilityDef == TorannMagicDefOf.TM_PsionicBarrier) { num2 = 8 - (mightUser.MightData.MightPowerSkill_PsionicDash.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicDash_eff").level); text2 = "TM_PsionicBarrierMaintenanceCost".Translate( 20 ) + "\n" + "TM_PsionicBarrierConversionRate".Translate( num2 ); } if (mightAbilityDef == TorannMagicDefOf.TM_PsionicStorm) { num2 = 65 - (5 * (mightUser.MightData.MightPowerSkill_PsionicStorm.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicStorm_eff").level)); text2 = "TM_PsionicInitialCost".Translate( num2 ); } } else if (TM_Calc.HasHateHediff(mightUser.Pawn) && (mightAbilityDef == TorannMagicDefOf.TM_Spite || mightAbilityDef == TorannMagicDefOf.TM_Spite_I || mightAbilityDef == TorannMagicDefOf.TM_Spite_II || mightAbilityDef == TorannMagicDefOf.TM_Spite_III)) { text2 = "TM_RequiresHateAmount".Translate( 20 ); } //else if (mightUser.Pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_ChiHD, false) && (mightAbilityDef == TorannMagicDefOf.TM_TigerStrike || mightAbilityDef == TorannMagicDefOf.TM_DragonStrike || mightAbilityDef == TorannMagicDefOf.TM_ThunderStrike)) //{ // //displays ability damage for active/passive attacks //} if (mightAbilityDef.chiCost != 0) { text = "TM_AbilityDescBaseChiCost".Translate( (mightAbilityDef.chiCost * 100).ToString("n1") ) + "\n" + "TM_AbilityDescAdjustedChiCost".Translate( (mightUser.ActualChiCost(mightAbilityDef) * 100).ToString("n1") ); } else { text = "TM_AbilityDescBaseStaminaCost".Translate( (mightAbilityDef.staminaCost * 100).ToString("n1") ) + "\n" + "TM_AbilityDescAdjustedStaminaCost".Translate( num.ToString("n1") ); } if (mightUser.coolDown != 1f && maxCastingTicks != 0) { text3 = "TM_AdjustedCooldown".Translate( ((maxCastingTicks * mightUser.coolDown) / 60).ToString("0.00") ); } bool flag2 = text != ""; if (flag2) { stringBuilder.AppendLine(text); } bool flag3 = text2 != ""; if (flag3) { stringBuilder.AppendLine(text2); } result = stringBuilder.ToString(); bool flag4 = text3 != ""; if (flag4) { stringBuilder.AppendLine(text3); } result = stringBuilder.ToString(); } return(result); }
public static bool HasHateHediff(Pawn pawn) { if (pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_HateHD_I"), false) || pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_HateHD_II"), false) || pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_HateHD_III"), false) || pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_HateHD"), false) || pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_HateHD_IV"), false) || pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_HateHD_V"), false)) { return(true); } return(false); }
public override bool CanCastPowerCheck(AbilityContext context, out string reason) { bool flag = base.CanCastPowerCheck(context, out reason); bool result; if (flag) { reason = ""; TMAbilityDef tmAbilityDef; bool flag1 = base.Def != null && (tmAbilityDef = (base.Def as TMAbilityDef)) != null; if (flag1) { bool flag4 = this.MightUser.Stamina != null; if (flag4) { bool flag5 = mightDef.staminaCost > 0f && this.ActualStaminaCost > this.MightUser.Stamina.CurLevel; if (flag5) { reason = "TM_NotEnoughStamina".Translate( base.Pawn.LabelShort ); result = false; return(result); } if (mightDef.chiCost > 0f) { bool flag6 = this.MightUser.Pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_ChiHD, false) ? (this.ActualChiCost * 100) > this.MightUser.Pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD, false).Severity : true; if (flag6) { reason = "TM_NotEnoughChi".Translate( base.Pawn.LabelShort ); result = false; return(result); } } bool flagNeed = mightDef.requiredNeed != null && this.MightUser.Pawn.needs.TryGetNeed(mightDef.requiredNeed) != null && this.MightUser.Pawn.needs.TryGetNeed(mightDef.requiredNeed).CurLevel > this.ActualNeedCost; if (flagNeed) { reason = "TM_NotEnoughEnergy".Translate( base.Pawn.LabelShort, mightDef.requiredNeed.label ); result = false; return(result); } bool flagHediff = mightDef.requiredHediff != null && this.MightUser.Pawn.health.hediffSet.HasHediff(mightDef.requiredHediff) && this.MightUser.Pawn.health.hediffSet.GetFirstHediffOfDef(mightDef.requiredHediff).Severity > this.ActualHediffCost; if (flagHediff) { reason = "TM_NotEnoughEnergy".Translate( base.Pawn.LabelShort, mightDef.requiredHediff.label ); result = false; return(result); } } } if (MightUser.specWpnRegNum == -1 && (this.mightDef == TorannMagicDefOf.TM_PistolWhip || this.mightDef == TorannMagicDefOf.TM_SuppressingFire || this.mightDef == TorannMagicDefOf.TM_Mk203GL || this.mightDef == TorannMagicDefOf.TM_Buckshot || this.mightDef == TorannMagicDefOf.TM_BreachingCharge)) { if (MightUser.Pawn.equipment != null && MightUser.Pawn.equipment.Primary != null) { reason = "TM_MustHaveWeaponType".Translate( base.Pawn.LabelShort, base.Pawn.equipment.Primary.def.label, "specialized weapon" ); } else { reason = "TM_IncompatibleWeapon".Translate(); } return(false); } List <Apparel> wornApparel = base.Pawn.apparel.WornApparel; for (int i = 0; i < wornApparel.Count; i++) { if (!wornApparel[i].AllowVerbCast(base.Pawn.Position, base.Pawn.Map, base.abilityUser.Pawn.TargetCurrentlyAimingAt, this.Verb) && (this.mightDef.defName == "TM_Headshot" || this.mightDef.defName == "TM_DisablingShot" || this.mightDef.defName == "TM_DisablingShot_I" || this.mightDef.defName == "TM_DisablingShot_II" || this.mightDef.defName == "TM_DisablingShot_III" || this.mightDef.defName == "TM_AntiArmor" || this.mightDef.defName == "TM_ArrowStorm" || this.mightDef.defName == "TM_ArrowStorm_I" || this.mightDef.defName == "TM_ArrowStorm_II" || this.mightDef.defName == "TM_ArrowStorm_III" || this.mightDef == TorannMagicDefOf.TM_PsionicStorm || this.mightDef.defName == "TM_PsionicBlast" || this.mightDef.defName == "TM_PsionicBlast_I" || this.mightDef.defName == "TM_PsionicBlast_II" || this.mightDef.defName == "TM_PsionicBlast_III" || this.mightDef == TorannMagicDefOf.TM_TempestStrike || this.mightDef == TorannMagicDefOf.TM_SuppressingFire || this.mightDef == TorannMagicDefOf.TM_Mk203GL || this.mightDef == TorannMagicDefOf.TM_Buckshot || this.mightDef.defName == "TM_Mimic")) { reason = "TM_ShieldBlockingPowers".Translate( base.Pawn.Label, wornApparel[i].Label ); return(false); } } if (TM_Calc.HasHateHediff(this.MightUser.Pawn) && this.MightUser.Pawn.story.traits.HasTrait(TorannMagicDefOf.DeathKnight)) { Hediff hediff = null; for (int h = 0; h < this.MightUser.Pawn.health.hediffSet.hediffs.Count; h++) { if (this.MightUser.Pawn.health.hediffSet.hediffs[h].def.defName.Contains("TM_HateHD")) { hediff = this.MightUser.Pawn.health.hediffSet.hediffs[h]; } } if (hediff != null) { if ((this.mightDef == TorannMagicDefOf.TM_Spite || this.mightDef == TorannMagicDefOf.TM_Spite_I || this.mightDef == TorannMagicDefOf.TM_Spite_II || this.mightDef == TorannMagicDefOf.TM_Spite_III) && hediff.Severity < 20f) { reason = "TM_NotEnoughHate".Translate( base.Pawn.LabelShort, "Spite" ); return(false); } } else { return(false); } } if (this.MightUser.Pawn.story.traits.HasTrait(TorannMagicDefOf.TM_Psionic)) { if (this.MightUser.Pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_PsionicHD"), false)) { float psiEnergy = this.MightUser.Pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_PsionicHD"), false).Severity; if ((this.mightDef.defName == "TM_PsionicBlast" || this.mightDef.defName == "TM_PsionicBlast_I" || this.mightDef.defName == "TM_PsionicBlast_II" || this.mightDef.defName == "TM_PsionicBlast_III") && psiEnergy < 20f) { reason = "TM_NotEnoughPsionicEnergy".Translate( base.Pawn.Label, "Psionic Blast" ); return(false); } if ((this.mightDef == TorannMagicDefOf.TM_PsionicDash && psiEnergy < 8f)) { reason = "TM_NotEnoughPsionicEnergy".Translate( base.Pawn.Label, "Psionic Dash" ); return(false); } int stormCost = 65 - (5 * (this.MightUser.MightData.MightPowerSkill_PsionicStorm.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicStorm_eff").level)); if ((this.mightDef == TorannMagicDefOf.TM_PsionicStorm && psiEnergy < stormCost)) { reason = "TM_NotEnoughPsionicEnergy".Translate( base.Pawn.Label, "Psionic Storm" ); return(false); } } else { return(false); } } TMAbilityDef tmad = this.mightDef; if (tmad != null && tmad.requiredWeaponsOrCategories != null && tmad.IsRestrictedByEquipment(this.Pawn)) { reason = "TM_IncompatibleWeaponType".Translate( base.Pawn.LabelShort, tmad.label); return(false); } result = true; } else { result = false; } return(result); }
// RimWorld.Verb_MeleeAttack public static void DamageInfosToApply_PostFix(Verb_MeleeAttack __instance, ref IEnumerable <DamageInfo> __result, LocalTargetInfo target) { var newList = new List <DamageInfo>(); //__result = null; var EquipmentSource = __instance.EquipmentSource; if (EquipmentSource != null) { //Log.Message("1"); var comp = EquipmentSource.AllComps.FirstOrDefault(x => x is OgsCompSlotLoadable.CompSlotLoadable); if (comp != null) { //Log.Message("2"); var compSlotLoadable = comp as OgsCompSlotLoadable.CompSlotLoadable; if (compSlotLoadable.Slots != null && compSlotLoadable.Slots.Count > 0) { //Log.Message("3"); var statSlots = compSlotLoadable.Slots.FindAll(z => !z.IsEmpty() && ((OgsCompSlotLoadable.SlotLoadableDef)z.def).doesChangeStats); if (statSlots != null && statSlots.Count > 0) { foreach (var slot in statSlots) { //Log.Message("5"); var slotBonus = slot.SlotOccupant.def.GetModExtension <SlottedBonusExtension>(); if (slotBonus != null) { //Log.Message("6"); var superClass = __instance.GetType().BaseType; if (slotBonus.damageDef != null) { //Log.Message("7"); var num = __instance.verbProps.AdjustedMeleeDamageAmount(__instance, __instance.CasterPawn); var def = __instance.verbProps.meleeDamageDef; BodyPartGroupDef weaponBodyPartGroup = null; HediffDef weaponHediff = null; if (__instance.CasterIsPawn) { if (num >= 1f) { weaponBodyPartGroup = __instance.verbProps.linkedBodyPartsGroup; if (__instance.HediffCompSource != null) { weaponHediff = __instance.HediffCompSource.Def; } } else { num = 1f; def = DamageDefOf.Blunt; } } //Log.Message("9"); ThingDef def2; if (__instance.EquipmentSource != null) { def2 = __instance.EquipmentSource.def; } else { def2 = __instance.CasterPawn.def; } //Log.Message("10"); var angle = (target.Thing.Position - __instance.CasterPawn.Position) .ToVector3(); //Log.Message("11"); var caster = __instance.caster; //Log.Message("12"); var newdamage = GenMath.RoundRandom(num); // Log.Message("applying damage "+newdamage+" out of "+num); var damageInfo = new DamageInfo(slotBonus.damageDef, newdamage, slotBonus.armorPenetration, -1f, caster, null, def2); damageInfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); damageInfo.SetWeaponBodyPartGroup(weaponBodyPartGroup); damageInfo.SetWeaponHediff(weaponHediff); damageInfo.SetAngle(angle); //Log.Message("13"); newList.Add(damageInfo); __result = newList.AsEnumerable(); } var vampiricEffect = slotBonus.vampiricHealChance; if (vampiricEffect != null) { //Log.Message("vampiricHealingCalled"); var randValue = Rand.Value; //Log.Message("randValue = " + randValue.ToString()); if (randValue <= vampiricEffect.chance) { MoteMaker.ThrowText(__instance.CasterPawn.DrawPos, __instance.CasterPawn.Map, "Vampiric Effect: Success", 6f); //MoteMaker.ThrowText(__instance.CasterPawn.DrawPos, __instance.CasterPawn.Map, "Success".Translate(), 6f); ApplyHealing(__instance.caster, vampiricEffect.woundLimit, target.Thing); } } } } } } } } }
//Patch for Caravan/Worldmap death //TBF //Patch death messages //TBF //Change Appearance, Traits and memories of pawns static void Regenerate(Pawn __instance) { // Health State Changes ---------------------------------------------------------------------------------------------------------- //Resurrect the __instance ResurrectionUtility.Resurrect(__instance); //Remove all bad hediffs foreach (Hediff h in __instance.health.hediffSet.GetHediffs <Hediff>()) { if (h.def.isBad) { __instance.health.RemoveHediff(h); } } //Add resurrection sickness __instance.health.AddHediff(HediffDef.Named("ResurrectionSickness")); //Remove current RegenHediff and add the next BodyPartRecord heart = __instance.health.hediffSet.GetNotMissingParts().First(bpr => bpr.def == BodyPartDefOf.Heart); HediffDef Regen1Def = HediffDef.Named("Regeneration01"); HediffDef Regen2Def = HediffDef.Named("Regeneration02"); HediffDef Regen3Def = HediffDef.Named("Regeneration03"); HediffDef Regen4Def = HediffDef.Named("Regeneration04"); HediffDef Regen5Def = HediffDef.Named("Regeneration05"); HediffDef Regen6Def = HediffDef.Named("Regeneration06"); HediffDef Regen7Def = HediffDef.Named("Regeneration07"); HediffDef Regen8Def = HediffDef.Named("Regeneration08"); HediffDef Regen9Def = HediffDef.Named("Regeneration09"); HediffDef Regen10Def = HediffDef.Named("Regeneration10"); HediffDef Regen11Def = HediffDef.Named("Regeneration11"); HediffDef Regen12Def = HediffDef.Named("Regeneration12"); HediffDef Regen13Def = HediffDef.Named("Regeneration13"); if (__instance.health.hediffSet.HasHediff(Regen1Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen1Def)); __instance.health.AddHediff(Regen2Def, heart); } else if (__instance.health.hediffSet.HasHediff(Regen2Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen2Def)); __instance.health.AddHediff(Regen3Def, heart); } else if (__instance.health.hediffSet.HasHediff(Regen3Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen3Def)); __instance.health.AddHediff(Regen4Def, heart); } else if (__instance.health.hediffSet.HasHediff(Regen4Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen4Def)); __instance.health.AddHediff(Regen5Def, heart); } else if (__instance.health.hediffSet.HasHediff(Regen5Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen5Def)); __instance.health.AddHediff(Regen6Def, heart); } else if (__instance.health.hediffSet.HasHediff(Regen6Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen6Def)); __instance.health.AddHediff(Regen7Def, heart); } else if (__instance.health.hediffSet.HasHediff(Regen7Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen7Def)); __instance.health.AddHediff(Regen8Def, heart); } else if (__instance.health.hediffSet.HasHediff(Regen8Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen8Def)); __instance.health.AddHediff(Regen9Def, heart); } else if (__instance.health.hediffSet.HasHediff(Regen9Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen9Def)); __instance.health.AddHediff(Regen10Def, heart); } else if (__instance.health.hediffSet.HasHediff(Regen10Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen10Def)); __instance.health.AddHediff(Regen11Def, heart); } else if (__instance.health.hediffSet.HasHediff(Regen11Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen11Def)); __instance.health.AddHediff(Regen12Def, heart); } else if (__instance.health.hediffSet.HasHediff(Regen12Def)) { __instance.health.RemoveHediff(__instance.health.hediffSet.GetFirstHediffOfDef(Regen12Def)); __instance.health.AddHediff(Regen13Def, heart); } // Visual Changes ---------------------------------------------------------------------------------------------------------- //Gender __instance.gender = GenderSwap(__instance.gender); //Skintone __instance.story.melanin = 0.01f * Rand.Range(10, 200); //Head var graphicPath = GraphicDatabaseHeadRecords.GetHeadRandom(__instance.gender, __instance.story.SkinColor, __instance.story.crownType).GraphicPath; Traverse.Create(__instance.story).Field("headGraphicPath").SetValue(graphicPath); //Hair __instance.story.hairDef = PawnHairChooser.RandomHairDefFor(__instance, FactionDefOf.PlayerColony); __instance.story.hairColor = HairColor(); //Body __instance.story.bodyType = BodySwap(__instance.gender); //Redraw the __instance to trigger the above affects __instance.Drawer.renderer.graphics.nakedGraphic = null; // Bio Changes ---------------------------------------------------------------------------------------------------------- //randomise traits __instance.story.traits.allTraits.Clear(); int i = 0; int rInt = Rand.RangeInclusive(1, 3); while (i < rInt) { TraitDef random = DefDatabase <TraitDef> .GetRandom(); Trait trait = new Trait(random, PawnGenerator.RandomTraitDegree(random), false); __instance.story.traits.GainTrait(trait); Trait trait2 = new Trait(random, PawnGenerator.RandomTraitDegree(random), false); __instance.story.traits.GainTrait(trait2); i++; } //Add Memory __instance.needs.mood.thoughts.memories.TryGainMemory(RegenerationThoughtDefs.RecentlyRegenerated, null); //Add debuff thought to all related colonists foreach (Pawn p in __instance.relations.RelatedPawns) { //Log.Warning("related to: " + p.Name); try { if (!p.health.Dead) { p.needs.mood.thoughts.memories.TryGainMemory(RegenerationThoughtDefs.KnownColonistRegeneratedSocial, __instance); p.needs.mood.thoughts.memories.TryGainMemory(RegenerationThoughtDefs.KnownColonistRegenerated); } } catch { Log.Warning("Couldn't add social debuff to " + p.Name); } } // Visual effects ------------------------------------------------------------------------------------------------------- //Glow effect (ugly approach, look at cleaning this up) MoteMaker.ThrowAirPuffUp(__instance.DrawPos, __instance.Map); MoteMaker.ThrowFireGlow(__instance.Position, __instance.Map, 3f); MoteMaker.ThrowFireGlow(__instance.Position, __instance.Map, 3f); MoteMaker.ThrowFireGlow(__instance.Position, __instance.Map, 3f); MoteMaker.ThrowFireGlow(__instance.Position, __instance.Map, 3f); MoteMaker.ThrowFireGlow(__instance.Position, __instance.Map, 3f); }
protected override bool TryCastShot() { bool result = false; CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); Pawn soulPawn = comp.soulBondPawn; if (soulPawn != null && !soulPawn.Dead && !soulPawn.Destroyed) { Pawn p = this.CasterPawn; bool drafted = this.CasterPawn.Drafted; bool soulPawnSpawned = soulPawn.Spawned; Map map = this.CasterPawn.Map; Map sMap = soulPawn.Map; if (sMap == null) { Hediff bondHediff = null; bondHediff = soulPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondPhysicalHD"), false); if (bondHediff != null) { HediffComp_SoulBondHost compS = bondHediff.TryGetComp <HediffComp_SoulBondHost>(); if (compS != null && compS.polyHost != null && !compS.polyHost.DestroyedOrNull() && !compS.polyHost.Dead) { soulPawn = compS.polyHost; soulPawnSpawned = true; } } bondHediff = null; bondHediff = soulPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondMentalHD"), false); if (bondHediff != null) { HediffComp_SoulBondHost compS = bondHediff.TryGetComp <HediffComp_SoulBondHost>(); if (compS != null && compS.polyHost != null && !compS.polyHost.DestroyedOrNull() && !compS.polyHost.Dead) { soulPawn = compS.polyHost; soulPawnSpawned = true; } } if (soulPawn.ParentHolder != null && soulPawn.ParentHolder is Caravan) { //Log.Message("caravan detected"); //p.DeSpawn(); Caravan van = soulPawn.ParentHolder as Caravan; van.AddPawn(p, true); Find.WorldPawns.PassToWorld(p); p.Notify_PassedToWorld(); Messages.Message("" + p.LabelShort + " has shadow stepped to a caravan with " + soulPawn.LabelShort, MessageTypeDefOf.NeutralEvent); goto fin; } } IntVec3 casterCell = this.CasterPawn.Position; IntVec3 targetCell = soulPawn.Position; if (p.Spawned && soulPawnSpawned) { try { p.DeSpawn(); GenSpawn.Spawn(p, targetCell, soulPawn.Map); if (drafted) { p.drafter.Drafted = true; } CameraJumper.TryJumpAndSelect(p); } catch { Log.Message("Exception occured when trying to shadow step to soul bound pawn - recovered caster at original position"); GenSpawn.Spawn(p, casterCell, map); } this.Ability.PostAbilityAttempt(); } else { Messages.Message("TM_BondedPawnNotSpawned".Translate( soulPawn.LabelShort), MessageTypeDefOf.RejectInput); } result = true; } else { Log.Warning("No soul bond found to shadow call."); } //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60; fin :; this.burstShotsLeft = 0; return(result); }
public Toil WanderAround(IntVec3 cell) { Toil toil = new Toil(); TargetInfo target = new TargetInfo(cell); TargetInfo target2 = null; TargetInfo target3 = null; Pawn pawn = this.pawn; int attempt = 0; while (attempt < 30) { target2 = new TargetInfo(target.Cell.RandomAdjacentCell8Way()); if (target2 != null && pawn.CanReach(target2, PathEndMode.OnCell, Danger.Deadly)) { target3 = target2; break; } attempt += 1; } if (target3 == null) return null; toil.initAction = delegate { this.CurJob.locomotionUrgency = LocomotionUrgency.Walk; pawn.pather.StartPath(target3, PathEndMode.OnCell); Pawn bloodyprey = TargetThingA as Pawn; if (bloodyprey != null) { if (pawn.needs.food.CurLevel < 0.9) { Pawn closestBloodyPrey = GenClosest.ClosestThingReachable(pawn.Position, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.Touch, TraverseParms.For(pawn)) as Pawn; if (closestBloodyPrey == null) { pawn.jobs.EndCurrentJob(JobCondition.Incompletable); } float nutrblood = pawn.needs.food.CurLevel + 0.10f; pawn.needs.food.CurLevel = nutrblood; List<BodyPartRecord> list = new List<BodyPartRecord>(); foreach (BodyPartRecord current in bloodyprey.RaceProps.body.AllParts) { list.Add(current); } BodyPartRecord BodyPartToAffect = null; for (int i = 0; i < list.Count; i++) { if (list.ElementAt(i).def == BodyPartToHediff) { BodyPartToAffect = list.ElementAt(i); break; } } if (HediffToAdd == null) { HediffToAdd = HediffDefOf.Malaria; } int rand = UnityEngine.Random.Range(1, 100); if (!bloodyprey.health.hediffSet.HasHediff(HediffToAdd) && rand > 95) { int num = UnityEngine.Random.Range(1, 100); if (BodyPartToAffect == null) { BodyPartToAffect = list.RandomElement(); } HediffDef malaria = HediffToAdd; malaria.initialSeverity = HediffSeverityStage; bloodyprey.health.AddHediff(malaria, BodyPartToAffect, null); } } } }; return toil; }