private static HashSet <HediffDef> GetDiseaseList() { HashSet <HediffDef> diseases = new HashSet <HediffDef>(); IEnumerable <HediffDef> enumerable = from def in DefDatabase <HediffDef> .AllDefs where true select def; List <TMDefs.TM_CategoryHediff> diseaseList = HediffCategoryList.Named("TM_Category_Hediffs").diseases; foreach (HediffDef current in enumerable) { for (int i = 0; i < diseaseList.Count; i++) { if (current.defName == diseaseList[i].hediffDefname || (diseaseList[i].containsDefnameString && current.defName.Contains(diseaseList[i].hediffDefname)) || diseaseList[i].ToString() == "*") { //Log.Message("adding shotgun def " + current.defName); diseases.Add(current); } } } return(diseases); }
public static List <HediffDef> MechaniteList() { List <HediffDef> mechanites = new List <HediffDef>(); mechanites.Clear(); IEnumerable <HediffDef> enumerable = from def in DefDatabase <HediffDef> .AllDefs where (true) select def; List <TMDefs.TM_CategoryHediff> mechaniteList = HediffCategoryList.Named("TM_Category_Hediffs").mechanites; foreach (HediffDef current in enumerable) { for (int i = 0; i < mechaniteList.Count; i++) { if (current.defName == mechaniteList[i].hediffDefname || (mechaniteList[i].containsDefnameString && current.defName.Contains(mechaniteList[i].hediffDefname)) || mechaniteList[i].ToString() == "*") { //Log.Message("adding shotgun def " + current.defName); mechanites.AddDistinct(current); } } } return(mechanites); }
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); }
protected override bool TryCastShot() { Pawn caster = base.CasterPawn; Pawn pawn = this.currentTarget.Thing as Pawn; CompAbilityUserMagic comp = pawn.TryGetComp <CompAbilityUserMagic>(); bool flag = pawn != null; if (flag) { int num = 1; if (!pawn.DestroyedOrNull() && pawn.health != null || pawn.health.hediffSet != null && !pawn.Dead) { bool success = false; List <TMDefs.TM_CategoryHediff> mechaniteList = HediffCategoryList.Named("TM_Category_Hediffs").mechanites; using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; bool flag2 = num > 0; if (TM_Data.MechaniteList().Contains(rec.def)) { foreach (TMDefs.TM_CategoryHediff chd in mechaniteList) { if (chd.hediffDefname.Contains(rec.def.defName)) { if (comp != null) { if (chd.requiredSkillName != "TM_Purify_ver") { verVal = comp.MagicData.AllMagicPowerSkills.FirstOrDefault((MagicPowerSkill x) => x.label == chd.requiredSkillName).level; } if (chd.powerSkillName != "TM_Purify_pwr") { pwrVal = comp.MagicData.AllMagicPowerSkills.FirstOrDefault((MagicPowerSkill x) => x.label == chd.powerSkillName).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--; break; } else { MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Failed to remove " + rec.Label + " ..."); } break; } else { rec.Severity -= ((chd.severityReduction + (chd.powerSkillAdjustment * pwrVal)) * arcaneDmg); if ((rec.Severity < 0)) { if (chd.replacementHediffDefname != "") { HealthUtility.AdjustSeverity(pawn, HediffDef.Named(chd.replacementHediffDefname), chd.replacementHediffSeverity); } } success = true; num--; break; } } } } } else { if (rec.def.defName == "SensoryMechanites") { pawn.health.RemoveHediff(rec); HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_ReprogrammedSenMechanites_HD, .001f); num--; success = true; break; } else if (rec.def.defName == "FibrousMechanites") { pawn.health.RemoveHediff(rec); HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_ReprogrammedFibMechanites_HD, .001f); num--; success = true; break; } else if (rec.def.defName == "LymphaticMechanites") { pawn.health.RemoveHediff(rec); HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_ReprogrammedLymMechanites_HD, .001f); num--; success = true; break; } } } } if (success) { TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3(), pawn.Map, 1.5f); MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Mechanite Reprogramming" + ": " + StringsToTranslate.AU_CastSuccess, -1f); } else { Messages.Message("TM_CureDiseaseTypeFail".Translate(), MessageTypeDefOf.NegativeEvent); MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Mechanite Reprogramming" + ": " + StringsToTranslate.AU_CastFailure, -1f); } } else { MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Mechanite Reprogramming" + ": " + StringsToTranslate.AU_CastFailure, -1f); } } return(false); }
protected override bool TryCastShot() { Pawn caster = this.CasterPawn; Pawn pawn = this.currentTarget.Thing as Pawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); if (comp != null && !caster.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MagicPowerSkill pwr = comp.MagicData.MagicPowerSkill_Purify.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Purify_pwr"); MagicPowerSkill ver = comp.MagicData.MagicPowerSkill_Purify.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Purify_ver"); pwrVal = pwr.level; verVal = ver.level; arcaneDmg = comp.arcaneDmg; } else 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; arcaneDmg = caster.GetComp <CompAbilityUserMight>().mightPwr; } bool flag = pawn != null && !pawn.Dead; if (flag) { int num = Mathf.RoundToInt(1f + (.4f * verVal)); 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 + verVal; 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 (rec.def.tags.Contains(BodyPartTagDefOf.ConsciousnessSource)) { if (pwrVal >= 1) { current.Heal(pwrVal * arcaneDmg); num--; num2--; } } else { current.Heal((2f + (pwrVal * 2)) * arcaneDmg); //current.Heal(5.0f + (float)pwrVal * 3f); // power affects how much to heal num--; num2--; } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f); } } } } } } //if (pawn.RaceProps.Humanlike) //{ using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { if (TM_Data.AilmentList.Contains(rec.def)) { List <TMDefs.TM_CategoryHediff> ailmentList = HediffCategoryList.Named("TM_Category_Hediffs").ailments; foreach (TMDefs.TM_CategoryHediff chd in ailmentList) { if (chd.hediffDefname.Contains(rec.def.defName)) { 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); } 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 && chd.replacementHediffDefname != "") { HealthUtility.AdjustSeverity(pawn, HediffDef.Named(chd.replacementHediffDefname), chd.replacementHediffSeverity); } rec.Heal((chd.severityReduction + (chd.powerSkillAdjustment * pwrVal)) * arcaneDmg); num--; } } } } } else { if (rec.def.defName == "Cataract" || rec.def.defName == "HearingLoss" || rec.def.defName.Contains("ToxicBuildup")) { rec.Heal(.4f + (.3f * pwrVal)); num--; } if ((rec.def.defName == "Blindness" || rec.def.defName.Contains("Asthma") || rec.def.defName == "Cirrhosis" || rec.def.defName == "ChemicalDamageModerate") && verVal >= 1) { rec.Heal(.3f + (.2f * pwrVal)); if (rec.def.defName.Contains("Asthma")) { pawn.health.RemoveHediff(rec); } num--; } if ((rec.def.defName == "Frail" || rec.def.defName == "BadBack" || rec.def.defName.Contains("Carcinoma") || rec.def.defName == "ChemicalDamageSevere") && verVal >= 2) { rec.Heal(.25f + (.2f * pwrVal)); num--; } if ((rec.def.defName.Contains("Alzheimers") || rec.def.defName == "Dementia" || rec.def.defName.Contains("HeartArteryBlockage") || rec.def.defName == "PsychicShock" || rec.def.defName == "CatatonicBreakdown") && verVal >= 3) { rec.Heal(.15f + (.15f * pwrVal)); num--; } if (rec.def.defName.Contains("Abasia") && verVal >= 3) { if (Rand.Chance(.25f + (.05f * pwrVal))) { pawn.health.RemoveHediff(pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Abasia"))); num--; } else { MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Failed to remove Abasia..."); } } } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f); } } } //} using (IEnumerator <Hediff_Addiction> enumerator = pawn.health.hediffSet.GetHediffs <Hediff_Addiction>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff_Addiction rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { if (TM_Data.AddictionList.Contains(rec.def)) { List <TMDefs.TM_CategoryHediff> addictionList = HediffCategoryList.Named("TM_Category_Hediffs").addictions; foreach (TMDefs.TM_CategoryHediff chd in addictionList) { if (chd.hediffDefname.Contains(rec.def.defName)) { 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); } num--; } else { MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Failed to remove " + rec.Label + " ..."); } break; } else { if (rec.Chemical.defName == "Luciferium" && rec.Severity - ((chd.severityReduction + (chd.powerSkillAdjustment * pwrVal)) * arcaneDmg) <= 0) { Hediff luciHigh = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("LuciferiumHigh"), false); pawn.health.RemoveHediff(luciHigh); } rec.Severity -= (chd.severityReduction + (chd.powerSkillAdjustment * pwrVal)) * arcaneDmg; num--; } } } } } else { if (rec.Chemical.defName == "Alcohol" || rec.Chemical.defName == "Smokeleaf") { rec.Severity -= (.3f + (.3f * pwrVal)) * arcaneDmg; num--; } if ((rec.Chemical.defName == "GoJuice" || rec.Chemical.defName == "WakeUp") && verVal >= 1) { rec.Severity -= (.25f + (.25f * pwrVal)) * arcaneDmg; num--; } if (rec.Chemical.defName == "Psychite" && verVal >= 2) { rec.Severity -= (.25f + (.25f * pwrVal)) * arcaneDmg; num--; } if (verVal >= 3) { if (rec.Chemical.defName == "Luciferium" && (rec.Severity - ((.15f + (.15f * pwrVal)) * arcaneDmg) < 0)) { Hediff luciHigh = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("LuciferiumHigh"), false); pawn.health.RemoveHediff(luciHigh); } rec.Severity -= (.15f + (.15f * pwrVal)) * arcaneDmg; num--; } } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f); } } } } return(true); }