protected override bool TryCastShot() { bool result = false; Pawn p = this.CasterPawn; CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = comp.MagicData.MagicPowerSkill_DeathMark.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_DeathMark_pwr"); MagicPowerSkill ver = comp.MagicData.MagicPowerSkill_DeathMark.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_DeathMark_ver"); verVal = ver.level; pwrVal = pwr.level; this.arcaneDmg = comp.arcaneDmg; if (p.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = p.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); MightPowerSkill mver = p.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); pwrVal = mpwr.level; verVal = mver.level; } if (this.currentTarget != null && base.CasterPawn != null) { Map map = this.CasterPawn.Map; this.TargetsAoE.Clear(); //this.UpdateTargets(); this.FindTargets(); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); for (int i = 0; i < this.TargetsAoE.Count; i++) { if (this.TargetsAoE[i].Thing is Pawn) { Pawn victim = this.TargetsAoE[i].Thing as Pawn; if (!victim.RaceProps.IsMechanoid) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, victim, true))) { HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_DeathMarkCurse"), (Rand.Range(1f + pwrVal, 4 + 2 * pwrVal) * this.arcaneDmg)); TM_MoteMaker.ThrowSiphonMote(victim.DrawPos, victim.Map, 1.4f); if (comp.Pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_LichHD"), false)) { comp.PowerModifier += 1; } if (Rand.Chance(verVal * .2f)) { if (Rand.Chance(verVal * .1f)) //terror { HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_Terror"), Rand.Range(3f * verVal, 5f * verVal) * this.arcaneDmg); TM_MoteMaker.ThrowDiseaseMote(victim.DrawPos, victim.Map, 1f, .5f, .2f, .4f); MoteMaker.ThrowText(victim.DrawPos, victim.Map, "Terror", -1); } if (Rand.Chance(verVal * .1f)) //berserk { if (victim.mindState != null && victim.RaceProps != null && victim.RaceProps.Humanlike) { victim.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, "cursed", true, false, null); FleckMaker.ThrowMicroSparks(victim.DrawPos, victim.Map); MoteMaker.ThrowText(victim.DrawPos, victim.Map, "Berserk", -1); } } } if (victim.IsColonist && !base.CasterPawn.IsColonist) { TM_Action.SpellAffectedPlayerWarning(victim); } } else { MoteMaker.ThrowText(victim.DrawPos, victim.Map, "TM_ResistedSpell".Translate(), -1); } } } } result = true; } this.burstShotsLeft = 0; //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60; return(result); }
public void DecreaseAllergy(Pawn pawn) { HealthUtility.AdjustSeverity(pawn, this.hediff, -gainRate); }
protected bool CheckSurgeryFailAndroid(Pawn surgeon, Pawn patient, List <Thing> ingredients, BodyPartRecord part, Bill bill) { var num = 1f; if (!patient.RaceProps.IsMechanoid) { num *= surgeon.GetStatValue(StatDefOf.AndroidSurgerySuccessChance); } if (patient.InBed()) { num *= patient.CurrentBed().GetStatValue(StatDefOf.AndroidSurgerySuccessChance); } num *= recipe.surgerySuccessChanceFactor; if (surgeon.InspirationDef == InspirationDefOf.Inspired_Surgery && !patient.RaceProps.IsMechanoid) { if (num < 1f) { num = 1f - (1f - num) * 0.1f; } surgeon.mindState.inspirationHandler.EndInspiration(InspirationDefOf.Inspired_Surgery); } if (Rand.Chance(num)) { return(false); } if (Rand.Chance(recipe.deathOnFailedSurgeryChance)) { HealthUtility.GiveInjuriesOperationFailureCatastrophic(patient, part); if (!patient.Dead) { patient.Kill(null); } Messages.Message("MessageMedicalOperationFailureFatalAndroid".Translate(surgeon.LabelShort, patient.LabelShort, recipe.label), patient, MessageTypeDefOf.NegativeHealthEvent); } else if (Rand.Chance(0.5f)) { if (Rand.Chance(0.1f)) { Messages.Message("MessageMedicalOperationFailureRidiculousAndroid".Translate(surgeon.LabelShort, patient.LabelShort), patient, MessageTypeDefOf.NegativeHealthEvent); HealthUtility.GiveInjuriesOperationFailureRidiculous(patient); } else { Messages.Message("MessageMedicalOperationFailureCatastrophicAndroid".Translate(surgeon.LabelShort, patient.LabelShort), patient, MessageTypeDefOf.NegativeHealthEvent); HealthUtility.GiveInjuriesOperationFailureCatastrophic(patient, part); } } else { Messages.Message("MessageMedicalOperationFailureMinorAndroid".Translate(surgeon.LabelShort, patient.LabelShort), patient, MessageTypeDefOf.NegativeHealthEvent); HealthUtility.GiveInjuriesOperationFailureMinor(patient, part); } if (!patient.Dead) { TryGainBotchedSurgeryThought(patient, surgeon); } return(true); }
protected override bool TryCastShot() { bool flag = false; CompAbilityUserMight comp = base.CasterPawn.GetComp <CompAbilityUserMight>(); MightPowerSkill pwr = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_AnimalFriend.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AnimalFriend_pwr"); MightPowerSkill ver = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_AnimalFriend.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AnimalFriend_ver"); Pawn pawn = this.CasterPawn; Pawn animal = this.currentTarget.Thing as Pawn; if (animal != null && animal.RaceProps.Animal && animal.RaceProps.IsFlesh) { if (animal.RaceProps.TrainableIntelligence == TrainableIntelligenceDefOf.Intermediate || animal.RaceProps.TrainableIntelligence == TrainableIntelligenceDefOf.Advanced) { if ((animal.RaceProps.wildness <= .7f) || (animal.RaceProps.wildness <= .8f && pwr.level == 1) || (animal.RaceProps.wildness <= .9f && pwr.level == 2) || pwr.level == 3) { if (Rand.Chance((1 - animal.RaceProps.wildness) * 10)) { if (comp.bondedPet != null && comp.bondedPet != animal) { Pawn oldbond = comp.bondedPet; if (!oldbond.Dead || !oldbond.Destroyed) { Messages.Message("TM_BondedAnimalRelease".Translate(new object[] { oldbond.LabelShort, pawn.LabelShort }), MessageTypeDefOf.NeutralEvent); MoteMaker.ThrowSmoke(oldbond.DrawPos, oldbond.Map, 3f); oldbond.Destroy(); } } animal.SetFaction(pawn.Faction); HealthUtility.AdjustSeverity(animal, TorannMagicDefOf.TM_RangerBondHD, -4f); HealthUtility.AdjustSeverity(animal, TorannMagicDefOf.TM_RangerBondHD, .5f + ver.level); comp.bondedPet = animal; if (animal.RaceProps.TrainableIntelligence == TrainableIntelligenceDefOf.Intermediate) { while (!animal.training.IsCompleted(TrainableDefOf.Obedience)) { animal.training.Train(TrainableDefOf.Obedience, pawn); } while (!animal.training.IsCompleted(TrainableDefOf.Release)) { animal.training.Train(TrainableDefOf.Release, pawn); } } if (animal.RaceProps.TrainableIntelligence == TrainableIntelligenceDefOf.Advanced) { while (!animal.training.IsCompleted(TrainableDefOf.Obedience)) { animal.training.Train(TrainableDefOf.Obedience, pawn); } while (!animal.training.IsCompleted(TrainableDefOf.Release)) { animal.training.Train(TrainableDefOf.Release, pawn); } while (!animal.training.IsCompleted(TorannMagicDefOf.Rescue)) { animal.training.Train(TorannMagicDefOf.Rescue, pawn); } if (animal.BodySize > .4) { while (!animal.training.IsCompleted(TorannMagicDefOf.Haul)) { animal.training.Train(TorannMagicDefOf.Haul, pawn); } } } } else { Messages.Message("TM_FailedRangerBond".Translate(new object[] { animal.LabelShort, pawn.LabelShort, ((1 - animal.RaceProps.wildness) * 10f) }), MessageTypeDefOf.NeutralEvent); } } else { Messages.Message("TM_RangerNotExperienced".Translate(new object[] { animal.LabelShort, pawn.LabelShort }), MessageTypeDefOf.NeutralEvent); } } else { Messages.Message("TM_AnimalIncapableOfBond".Translate(new object[] { animal.LabelShort, pawn.LabelShort }), MessageTypeDefOf.NeutralEvent); } } this.PostCastShot(flag, out flag); return(flag); }
public override void CompPostTick(ref float severityAdjustment) { if (this.Pawn.Spawned && !this.Pawn.Dead && !this.Pawn.Downed) { base.CompPostTick(ref severityAdjustment); if (base.Pawn != null & base.parent != null) { if (!initialized) { initialized = true; this.Initialize(); } } CompAbilityUserMight comp = this.Pawn.GetComp <CompAbilityUserMight>(); if (this.doPsionicAttack) { this.ticksTillPsionicStrike--; if (this.ticksTillPsionicStrike <= 0) { this.doPsionicAttack = false; MightPowerSkill ver = comp.MightData.MightPowerSkill_PsionicAugmentation.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicAugmentation_ver"); if (!threat.Destroyed && !threat.Dead) { TM_MoteMaker.MakePowerBeamMotePsionic(threat.DrawPos.ToIntVec3(), threat.Map, 2f, 2f, .7f, .1f, .6f); DamageInfo dinfo2 = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_PsionicInjury, Rand.Range(6, 12) + (2 * ver.level), 0, -1, this.Pawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.threat); this.threat.TakeDamage(dinfo2); } } } if (Find.TickManager.TicksGame % 60 == 0) { severityAdjustment += (this.Pawn.GetStatValue(StatDefOf.PsychicSensitivity, false) * Rand.Range(.04f, .12f)); if (Find.Selector.FirstSelectedObject == this.Pawn) { HediffStage hediffStage = this.Pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_PsionicHD"), false).CurStage; hediffStage.label = this.parent.Severity.ToString("0.00") + "%"; } } if (comp.usePsionicAugmentationToggle) { if (Find.TickManager.TicksGame % 600 == 0 && !this.Pawn.Drafted) { if (this.parent.Severity >= 95 && this.Pawn.CurJob.targetA.Thing != null) { DeterminePsionicHD(); if ((this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal > 20 && (this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 300 && this.Pawn.CurJob.locomotionUrgency >= LocomotionUrgency.Jog && this.Pawn.CurJob.bill == null) { this.parent.Severity -= 10f; if (this.EffVal == 0) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD"), 1f + .02f * this.EffVal); } else if (this.EffVal == 1) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_I"), 1f + .02f * this.EffVal); } else if (this.EffVal == 2) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_II"), 1f + .02f * this.EffVal); } else { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_III"), 1f + .02f * this.EffVal); } for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } } if (this.Pawn.CurJob.targetA.Thing != null && (this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 2 && this.Pawn.CurJob.bill != null) { this.parent.Severity -= 6f; if (this.PwrVal == 0) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD"), 1f + .02f * this.PwrVal); } else if (this.PwrVal == 1) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_I"), 1f + .02f * this.PwrVal); } else if (this.PwrVal == 2) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_II"), 1f + .02f * this.PwrVal); } else { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_III"), 1f + .02f * this.PwrVal); } for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } } } } if (this.parent.Severity >= 20) { DeterminePsionicHD(); if (Find.TickManager.TicksGame % 180 == 0 && (this.Pawn.Drafted || !this.Pawn.IsColonist) && this.Pawn.equipment.Primary != null && !this.Pawn.equipment.Primary.def.IsRangedWeapon) { if (this.Pawn.CurJob.targetA.Thing != null && this.Pawn.CurJob.targetA.Thing is Pawn) { float targetDistance = (this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal; if (targetDistance > 3 && targetDistance < (12 + EffVal)) { for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } FlyingObject_PsionicLeap flyingObject = (FlyingObject_PsionicLeap)GenSpawn.Spawn(ThingDef.Named("FlyingObject_PsionicLeap"), this.Pawn.Position, this.Pawn.Map); flyingObject.Launch(this.Pawn, this.Pawn.CurJob.targetA.Thing, this.Pawn); HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicHD"), -5f); } } } if (Find.TickManager.TicksGame % (600 - (60 * VerVal)) == 0 && this.Pawn.Drafted) { if (this.Pawn.CurJob.def != TorannMagicDefOf.JobDriver_PsionicBarrier && VerVal > 0) { this.threat = GetNearbyTarget(20 + (4 * VerVal)); if (threat != null) { //start psionic attack; ends after delay SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); TorannMagicDefOf.TM_Implosion.PlayOneShot(info); Effecter psionicAttack = TorannMagicDefOf.TM_GiantExplosion.Spawn(); psionicAttack.Trigger(new TargetInfo(threat.Position, threat.Map, false), new TargetInfo(threat.Position, threat.Map, false)); psionicAttack.Cleanup(); for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicHD"), -(9f - VerVal)); this.doPsionicAttack = true; this.ticksTillPsionicStrike = 24; } } } } } } }
public static void ApplyState(Thing thing, AttackThingState state, bool pawnHealthStateDead = false) { //полезное из игры: RecoverFromUnwalkablePositionOrKill if (state.StackCount > 0 && thing.stackCount != state.StackCount) { Loger.Log("Client ApplyState Set StackCount " + thing.stackCount.ToString() + " -> " + state.StackCount.ToString()); thing.stackCount = state.StackCount; } if (thing.Position.x != state.Position.x || thing.Position.z != state.Position.z) { thing.Position = state.Position.Get(); if (thing is Pawn) { var pawn = (Pawn)thing; try { pawn.Notify_Teleported(true, true); } catch (Exception ext) { Loger.Log("Client ApplyState Exception " + ext.ToString()); } pawn.Drawer.DrawTrackerTick(); } } if (thing is Fire) { (thing as Fire).fireSize = (float)state.HitPoints / 10000f; } else { if (thing.def.useHitPoints) { Loger.Log("Client ApplyState Set HitPoints " + thing.HitPoints.ToString() + " -> " + state.HitPoints.ToString()); thing.HitPoints = state.HitPoints; } } if (thing is Pawn) { var pawn = thing as Pawn; if ((int)pawn.health.State != (int)state.DownState) { if (pawn.health.State == PawnHealthState.Dead) { Loger.Log("Client ApplyState Set pawn state is Dead! Error to change on " + state.DownState.ToString()); } else if (state.DownState == AttackThingState.PawnHealthState.Dead) { if (pawnHealthStateDead) { Loger.Log("Client ApplyState Set pawn state (1): " + pawn.health.State.ToString() + " -> " + state.DownState.ToString()); HealthUtility.DamageUntilDead(pawn); //PawnKill(pawn); } } else if (state.DownState == AttackThingState.PawnHealthState.Down) { Loger.Log("Client ApplyState Set pawn state (2): " + pawn.health.State.ToString() + " -> " + state.DownState.ToString()); //todo! Применяем наркоз? HealthUtility.DamageUntilDowned(pawn, false); } else { Loger.Log("Client ApplyState Set pawn state (3): " + pawn.health.State.ToString() + " -> " + state.DownState.ToString()); //полное лечение pawn.health.Notify_Resurrected(); } } } }
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 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)), 1f); } num--; num2--; } } } } } } } } }
public override void PostTick() { base.PostTick(); if (!(pawn.VampComp() is CompVampire v)) { return; } if (!initialized) { initialized = true; if (!firstVampire) { if (sire == null) { sire = VampireRelationUtility.FindSireFor(pawn, bloodline, generation).VampComp(); } if (generation < 0) { generation = sire.Generation + 1; } if (bloodline == null) { bloodline = sire.Bloodline; } } if (v.IsVampire && v.Sire == null) { v.InitializeVampirism(sire?.AbilityUser ?? null, bloodline, generation, firstVampire); } pawn.Drawer.renderer.graphics.ResolveAllGraphics(); } if (Find.TickManager.TicksGame % 60 != 0) { return; } if (v.InSunlight) { HealthUtility.AdjustSeverity(pawn, VampDefOf.ROMV_SunExposure, 0.001f); } if (v.BloodPool?.CurLevelPercentage < 0.3f) { HealthUtility.AdjustSeverity(pawn, VampDefOf.ROMV_TheBeast, 0.001f); } //Remove nonsensical hediffs if (pawn.health.hediffSet is HediffSet hdSet) { if (hdSet.GetFirstHediffOfDef(HediffDefOf.Hypothermia) is Hediff hypoThermia) { hdSet.hediffs.Remove(hypoThermia); } else if (hdSet.GetFirstHediffOfDef(HediffDefOf.Heatstroke) is Hediff heatStroke) { hdSet.hediffs.Remove(heatStroke); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.GutWorms) is Hediff gutWorms) { hdSet.hediffs.Remove(gutWorms); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.MuscleParasites) is Hediff muscleParasites) { hdSet.hediffs.Remove(muscleParasites); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.FibrousMechanites) is Hediff fibrousMechanites) { hdSet.hediffs.Remove(fibrousMechanites); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.SensoryMechanites) is Hediff sensoryMechanites) { hdSet.hediffs.Remove(sensoryMechanites); } } //If no generational bonus exists... if (!pawn.health.hediffSet.HasHediff(pawn.GenerationDef())) { HealthUtility.AdjustSeverity(pawn, pawn.GenerationDef(), 1.0f); } }
protected override void Impact(Thing hitThing) { Map map = base.Map; //base.Impact(hitThing); ThingDef def = this.def; Pawn hitPawn = hitThing as Pawn; Pawn caster = this.launcher as Pawn; CompAbilityUserMagic compHitPawn = hitPawn.GetComp <CompAbilityUserMagic>(); CompAbilityUserMagic compCaster = caster.GetComp <CompAbilityUserMagic>(); if (hitPawn != null && !hitPawn.Dead && !caster.Dead && !caster.Downed && caster != null) { if (hitPawn.Faction != caster.Faction) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(caster, hitPawn, true))) { if (compHitPawn != null && compHitPawn.IsMagicUser) { MagicPowerSkill regen = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_global_regen.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_regen_pwr"); float manaDrained = compHitPawn.Mana.CurLevel; if (manaDrained > (.5f * compCaster.arcaneDmg)) { manaDrained = (.5f * compCaster.arcaneDmg); } compHitPawn.Mana.CurLevel -= manaDrained; compCaster.Mana.CurLevel += (manaDrained * .6f) * (1 + regen.level * .05f); //TM_MoteMaker.ThrowSiphonMote(hitPawn.Position.ToVector3Shifted(), hitPawn.Map, 1f); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Siphon, hitPawn.DrawPos, hitPawn.Map, 1.2f, .05f, .15f, .65f, -300, .2f, Rand.Range(0, 360), Rand.Range(0, 360)); TM_MoteMaker.ThrowManaPuff(caster.DrawPos, caster.Map, 1f); if (compCaster.MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_pwr").level >= 6) { float sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiManipulation, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiMovement, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiBreathing, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiSight, sev); TM_MoteMaker.ThrowSiphonMote(hitPawn.Position.ToVector3(), hitPawn.Map, 1f); TM_MoteMaker.ThrowSiphonMote(hitPawn.Position.ToVector3(), hitPawn.Map, 1f); } } else if (hitPawn.health != null && hitPawn.health.hediffSet != null && hitPawn.Map != null) { float sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiManipulation, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiMovement, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiBreathing, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiSight, sev); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Siphon, hitPawn.DrawPos, hitPawn.Map, 1.2f, .05f, .15f, .65f, -300, .2f, Rand.Range(0, 360), Rand.Range(0, 360)); } } else { MoteMaker.ThrowText(hitPawn.DrawPos, hitPawn.Map, "TM_ResistedSpell".Translate(), -1); } } else { if (compHitPawn != null && compHitPawn.IsMagicUser) { MagicPowerSkill regen = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_global_regen.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_regen_pwr"); float manaDrained = compHitPawn.Mana.CurLevel; if (manaDrained > .5f) { manaDrained = .5f; } compHitPawn.Mana.CurLevel -= manaDrained / compCaster.arcaneDmg; compCaster.Mana.CurLevel += (manaDrained * .6f) * (1 + regen.level * .05f) * compCaster.arcaneDmg; TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Siphon, hitPawn.DrawPos, hitPawn.Map, 1.2f, .05f, .15f, .65f, -300, .2f, Rand.Range(0, 360), Rand.Range(0, 360)); TM_MoteMaker.ThrowManaPuff(caster.Position.ToVector3(), caster.Map, 1f); if (compCaster.MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_pwr").level >= 6) { float sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(caster, TorannMagicDefOf.TM_Manipulation, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(caster, TorannMagicDefOf.TM_Movement, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(caster, TorannMagicDefOf.TM_Breathing, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(caster, TorannMagicDefOf.TM_Sight, sev); TM_MoteMaker.ThrowManaPuff(caster.Position.ToVector3(), caster.Map, 1f); TM_MoteMaker.ThrowManaPuff(caster.Position.ToVector3(), caster.Map, 1f); } } else if (hitPawn.health != null && hitPawn.health.hediffSet != null) { float sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiManipulation, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiMovement, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiBreathing, sev); sev = Rand.Range(0, 10) * compCaster.arcaneDmg; HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_AntiSight, sev); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Siphon, hitPawn.DrawPos, hitPawn.Map, 1.2f, .05f, .15f, .65f, -300, .2f, Rand.Range(0, 360), Rand.Range(0, 360)); } } } Destroy(); }
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); }
private void AddPsionicShock(Pawn pawn) { System.Random rand = new System.Random(); int psychicSensitivity = 0; bool?shouldGiveHeartAttack = null; bool?shouldSedate = null; if (pawn.story?.traits != null && pawn.story.traits.HasTrait(TraitDef.Named("PsychicSensitivity"))) { Trait psychicSensitivityTrait = pawn.story.traits.GetTrait(TraitDef.Named("PsychicSensitivity")); psychicSensitivity = psychicSensitivityTrait.Degree; } // If they're Psychically Deaf, do nothing: if (psychicSensitivity == -2) { return; } // If they're Psychically Dull, don't give them a heart attack. else if (psychicSensitivity == -1) { shouldGiveHeartAttack = false; } // If they're Psychically Sensitive, make sure they're passed out for a few hours. else if (psychicSensitivity == 1) { shouldSedate = true; } // If they're Psychically Hypersensitive, unfortunately, it will mean instant death :-( else if (psychicSensitivity >= 2) { Messages.Message(pawn.NameStringShort + " was psychically supersensitive and died because of the psionic blast.", MessageSound.SeriousAlert); HealthUtility.GiveInjuriesToKill(pawn); } Hediff shock = HediffMaker.MakeHediff(HediffDefOf.PsychicShock, pawn, null); pawn.health.AddHediff(shock, null, null); if (shouldGiveHeartAttack == null) { shouldGiveHeartAttack = rand.Next(1, 11) >= 3; } if (shouldGiveHeartAttack == true) { this.CauseHeartAttack(pawn); } if (shouldSedate == null) { int likelihood = rand.Next(1, 11); Log.Message(pawn.NameStringShort + " should sedate? " + likelihood); shouldSedate = likelihood >= 6; } if (shouldSedate == true) { this.CauseSedation(pawn); } DamageInfo psionicIntensity = new DamageInfo(DamageDefOf.Stun, 50); pawn.TakeDamage(psionicIntensity); }
public override void Effect(Pawn target) { base.Effect(target); HealthUtility.AdjustSeverity(target, HediffDef.Named("HeartAttack"), 1.0f); }
public void ApplyHediffsAndMentalStates(Pawn victim) { try { //Log.Message("ApplyHediffsAndMentalStates"); if (localApplyMentalStates != null) { if (localApplyMentalStates.Count > 0) { foreach (var mentalStateGiver in localApplyMentalStates) { var success = false; var checkValue = Rand.Value; var str = localAbilityDef.LabelCap + " (" + Caster.LabelShort + ")"; if (checkValue <= mentalStateGiver.applyChance) { if (mentalStateGiver.mentalStateDef == MentalStateDefOf.Berserk && victim.RaceProps.intelligence < Intelligence.Humanlike) { if (Caster == victim || CanOverpower(Caster, victim)) { success = true; victim.mindState.mentalStateHandler.TryStartMentalState( MentalStateDefOf.Manhunter, str, true); } } else { if (Caster == victim || CanOverpower(Caster, victim)) { success = true; victim.mindState.mentalStateHandler.TryStartMentalState( mentalStateGiver.mentalStateDef, str, true); } } } if (success) { victim.Drawer.Notify_DebugAffected(); MoteMaker.ThrowText(victim.DrawPos, victim.Map, mentalStateGiver.mentalStateDef.LabelCap + ": " + StringsToTranslate.AU_CastSuccess, -1f); } else { MoteMaker.ThrowText(victim.DrawPos, victim.Map, mentalStateGiver.mentalStateDef.LabelCap + ": " + StringsToTranslate.AU_CastFailure, -1f); } } } } if (localApplyHediffs != null) { if (localApplyHediffs.Count > 0) { foreach (var hediffs in localApplyHediffs) { var success = false; if (Rand.Value <= hediffs.applyChance) { if (victim == Caster || CanOverpower(Caster, victim)) { HealthUtility.AdjustSeverity(victim, hediffs.hediffDef, hediffs.severity); //Hediff newHediff = HediffMaker.MakeHediff(hediffs.hediffDef, victim, null); //victim.health.AddHediff(newHediff, null, null); //newHediff.Severity = hediffs.severity; success = true; } } if (success) { victim.Drawer.Notify_DebugAffected(); MoteMaker.ThrowText(victim.DrawPos, victim.Map, hediffs.hediffDef.LabelCap + ": " + StringsToTranslate.AU_CastSuccess, -1f); } else { MoteMaker.ThrowText(victim.DrawPos, victim.Map, StringsToTranslate.AU_CastFailure, -1f); } } } } } catch (NullReferenceException e) { Log.Message(e.ToString()); } }
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); }
public override void DoEffect(Pawn user) { if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.Gifted)) { Trait giftedTrait = new Trait(); if (parent.def.defName == "BookOfInnerFire" || parent.def.defName == "Torn_BookOfInnerFire") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.InnerFire, 4, false)); if (parent.def.defName == "BookOfInnerFire") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } //this.parent.Destroy(DestroyMode.Vanish); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfHeartOfFrost" || parent.def.defName == "Torn_BookOfHeartOfFrost") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.HeartOfFrost, 4, false)); if (parent.def.defName == "BookOfHeartOfFrost") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfStormBorn" || parent.def.defName == "Torn_BookOfStormBorn") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.StormBorn, 4, false)); if (parent.def.defName == "BookOfStormBorn") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfArcanist" || parent.def.defName == "Torn_BookOfArcanist") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Arcanist, 4, false)); if (parent.def.defName == "BookOfArcanist") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfValiant" || parent.def.defName == "Torn_BookOfValiant") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Paladin, 4, false)); if (parent.def.defName == "BookOfValiant") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfSummoner" || parent.def.defName == "Torn_BookOfSummoner") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Summoner, 4, false)); if (parent.def.defName == "BookOfSummoner") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfDruid" || parent.def.defName == "Torn_BookOfNature") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Druid, 4, false)); if (parent.def.defName == "BookOfDruid") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfNecromancer" || parent.def.defName == "Torn_BookOfUndead") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Necromancer, 4, false)); if (parent.def.defName == "BookOfNecromancer") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfPriest" || parent.def.defName == "Torn_BookOfPriest") { FixTrait(user, user.story.traits.allTraits); FixPriestSkills(user); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Priest, 4, false)); if (parent.def.defName == "BookOfPriest") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfBard" || parent.def.defName == "Torn_BookOfBard") { if (!user.story.WorkTagIsDisabled(WorkTags.Social)) { FixTrait(user, user.story.traits.allTraits); FixBardSkills(user); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.TM_Bard, 0, false)); if (parent.def.defName == "BookOfBard") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else { Messages.Message("TM_NotSocialCapable".Translate( user.LabelShort ), MessageTypeDefOf.RejectInput); } } else if (parent.def.defName == "BookOfDemons" || parent.def.defName == "Torn_BookOfDemons") { FixTrait(user, user.story.traits.allTraits); if (user.gender == Gender.Male) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Warlock, 4, false)); } else if (user.gender == Gender.Female) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Succubus, 4, false)); } else { Log.Message("No gender found - assigning random trait."); if (Rand.Chance(.5f)) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Succubus, 4, false)); } else { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Warlock, 4, false)); } } if (parent.def.defName == "BookOfDemons") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfEarth" || parent.def.defName == "Torn_BookOfEarth") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Geomancer, 4, false)); if (parent.def.defName == "BookOfEarth") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfMagitech" || parent.def.defName == "Torn_BookOfMagitech") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Technomancer, 4, false)); if (parent.def.defName == "BookOfMagitech") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfHemomancy" || parent.def.defName == "Torn_BookOfHemomancy") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.BloodMage, 4, false)); if (parent.def.defName == "BookOfHemomancy") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfEnchanter" || parent.def.defName == "Torn_BookOfEnchanter") { FixTrait(user, user.story.traits.allTraits); user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Enchanter, 4, false)); if (parent.def.defName == "BookOfEnchanter") { HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f); } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def.defName == "BookOfQuestion") { int attempts = 0; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); FixTrait(user, user.story.traits.allTraits); RetryBookOfQuestion :; if (attempts < 50) { int rnd = Mathf.RoundToInt(Rand.RangeInclusive(0, 15)); switch (rnd) { case 0: if (settingsRef.Demonkin) { if (user.gender == Gender.Male) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Warlock, 4, false)); } else if (user.gender == Gender.Female) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Succubus, 4, false)); } else { Log.Message("No gender found."); } } else { attempts++; goto RetryBookOfQuestion; } break; case 15: if (settingsRef.Demonkin) { if (user.gender == Gender.Male) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Warlock, 4, false)); } else if (user.gender == Gender.Female) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Succubus, 4, false)); } else { Log.Message("No gender found."); } } else { attempts++; goto RetryBookOfQuestion; } break; case 1: if (settingsRef.Necromancer) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Necromancer, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 2: if (settingsRef.Druid) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Druid, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 3: if (settingsRef.Summoner) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Summoner, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 4: if (settingsRef.FireMage) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.InnerFire, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 5: if (settingsRef.IceMage) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.HeartOfFrost, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 6: if (settingsRef.LitMage) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.StormBorn, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 7: if (settingsRef.Arcanist) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Arcanist, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 8: if (settingsRef.Priest) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Priest, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 9: if (settingsRef.Bard) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.TM_Bard, 0, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 10: if (settingsRef.Paladin) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Paladin, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 11: if (settingsRef.Geomancer) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Geomancer, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 12: if (settingsRef.Technomancer) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Technomancer, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 13: if (settingsRef.BloodMage) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.BloodMage, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; case 14: if (settingsRef.Technomancer) { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Enchanter, 4, false)); } else { attempts++; goto RetryBookOfQuestion; } break; } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else { user.story.traits.GainTrait(new Trait(TorannMagicDefOf.Gifted, 2, false)); Messages.Message("Unable to find a valid class to assign after 50 attempts - ending attempt", MessageTypeDefOf.RejectInput); } } else { Messages.Message("NotArcaneBook".Translate(), MessageTypeDefOf.RejectInput); } } else { Messages.Message("NotGiftedPawn".Translate( user.LabelShort ), MessageTypeDefOf.RejectInput); } }
public override void Effect(Pawn target) { base.Effect(target); HealthUtility.AdjustSeverity(target, VampDefOf.ROMV_CrocodileTongueHediff, 1.0f); }
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { //If the part has no injuries, it's torture -- otherwise it's emergency surgery bool torture = IsClean(pawn, part); //Technically, we could refine this a bit more... it's not necessary to chop a limb off because they // have a broken bone. However, this is a "good enough" solution. It starts to get to the point of // subjectiveness on whether the surgery was valid or not. ///Amount of pain and suffering caused by removal of this part. float maxDamage = (float)part.def.hitPoints / 37.5f; bool failed = false; if (billDoer != null) { failed = CheckSurgeryFail(billDoer, pawn, ingredients, part, bill); if (!failed) { TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object [] { billDoer, pawn }); } SpawnThingsFromHediffs(pawn, part, billDoer.Position, billDoer.Map); } //Always dismember the part regardless of success if (!pawn.health.hediffSet.PartIsMissing(part)) //make sure any surgery failure didn't already chop off the part for us... yay...? { var dinfo = new DamageInfo(failed ? DamageDefOf.Cut : DamageDefOf.SurgicalCut, part.def.hitPoints, -1f, null, part, null); pawn.TakeDamage(dinfo); //[imagine sound effect: dull, sticky thud] } if (failed) { //whoops, I think I snagged an artery float severity = UnityEngine.Random.Range(0f, maxDamage); if (!pawn.health.hediffSet.HasHediff(HediffDefOf.BloodLoss)) { pawn.health.AddHediff(HediffDefOf.BloodLoss, null, null); } HealthUtility.AdjustSeverity(pawn, HediffDefOf.BloodLoss, severity); //New in version 4: more filth! yay! int arterial_bleeding = (int)Math.Sqrt(severity * 50f); while (arterial_bleeding-- > 0) { if (pawn.RaceProps.IsFlesh) { pawn.health.DropBloodFilth(); } } } ///// Version 4 additions ///// //Add wounds to body part(s) containing the part in question (either the next higher joint for a limb, or the surrounding body part for an organ) //If removing a cube, we need an opening as large as one of its sides (which is the 2/3 power -- 1/3 power is incision, 2/3 power is hole, 3/3 power is full avulsion) //Since most body parts in real life tend toward flat and oblong this isn't the best rule of thumb to follow, but it works great for its inherent simplicity. //e.g., to remove lung (20 HP) we will cause 1+floor(20**2/3) = 8 HP of damage to the torso to get it out bool reachedsurface = false; //(part.depth != BodyPartDepth.Inside); var currentpart = part.parent; int partdamage = 1 + (int)(Math.Pow(part.def.hitPoints * part.def.hitPoints, 0.33333)); while (partdamage > 0 && !reachedsurface && currentpart != null) { var dinfo2 = new DamageInfo(failed ? DamageDefOf.Cut : DamageDefOf.SurgicalCut, partdamage, -1f, null, currentpart, null); pawn.TakeDamage(dinfo2); if (currentpart.depth == BodyPartDepth.Outside) { reachedsurface = true; } currentpart = currentpart.parent; } //Produce blood if (pawn.RaceProps.IsFlesh) { pawn.health.DropBloodFilth(); } //Produce waste chunks of meat (getting into Mad Max (2015) levels of squick here) except when removing solid parts (bones) int meatCount = (int)(part.def.hitPoints / 2.0f); if (meatCount > 0 && pawn.RaceProps.IsFlesh && pawn.RaceProps.meatDef != null && !part.def.IsSolid(part, pawn.health.hediffSet.hediffs)) { var meat = ThingMaker.MakeThing(pawn.RaceProps.meatDef, null); meat.stackCount = Verse.Rand.Range(Math.Max(meatCount / 2, 1), meatCount); GenPlace.TryPlaceThing(meat, pawn.Position, billDoer.Map, ThingPlaceMode.Near, null); } //Cause pain from the procedure var pain = LocalDefOf.JTFieldSurgeryPain; if (pain != null) { HealthUtility.AdjustSeverity(pawn, pain, maxDamage); var removed_parts = new List <BodyPartRecord> (); removed_parts.Add(part); //Increase pain based on every extremity also lost (phantom pain, so only by half) foreach (BodyPartRecord child in pawn.RaceProps.body.AllParts) { BodyPartRecord core = pawn.RaceProps.body.corePart; //I presume no guarantees that this list is serialised, so parts will all attempt to trace back to the // core to see if they can find any other removed parts along the way. BodyPartRecord tracetocore = child.parent; while (tracetocore != core && tracetocore is BodyPartRecord) { if (removed_parts.Contains(tracetocore)) { removed_parts.Add(child); HealthUtility.AdjustSeverity(pawn, pain, (float)part.def.hitPoints / 75f); break; } tracetocore = tracetocore.parent; } } } //Apply thoughts if (!pawn.RaceProps.Humanlike) { return; } if (pawn.Dead) { if (torture) //A particularly brutal execution { ThoughtUtility.GiveThoughtsForPawnExecuted(pawn, PawnExecutionKind.GenericBrutal); if (billDoer.story.traits.HasTrait(TraitDefOf.Psychopath)) { Thought_Memory torturerSadist = (Thought_Memory)ThoughtMaker.MakeThought(LocalDefOf.JTFieldSurgeryTortureSadist); if (torturerSadist != null) { billDoer.needs.mood.thoughts.memories.TryGainMemory(torturerSadist, pawn); } } else { Thought_Memory torturerNormal = (Thought_Memory)ThoughtMaker.MakeThought(LocalDefOf.JTFieldSurgeryTorturer); if (torturerNormal != null) { billDoer.needs.mood.thoughts.memories.TryGainMemory(torturerNormal, pawn); } } } else //Emergency surgery //Each non-psychopathic colonist will feel bad that someone died because of their lack of preparation { var colonistDiedSurgery = (Thought_Memory)ThoughtMaker.MakeThought(LocalDefOf.JTFieldSurgeryColonistDiedSurgery); if (colonistDiedSurgery != null) { Map current_map = billDoer.Map; foreach (Pawn current in current_map.mapPawns.PawnsInFaction(billDoer.Faction)) { if (current != pawn && current.IsColonist && !current.story.traits.HasTrait(TraitDefOf.Psychopath)) { current.needs.mood.thoughts.memories.TryGainMemory(colonistDiedSurgery, pawn); } } } //Non-psychopathic doctors will feel bad if someone dies under the knife because they didn't use anaesthetic var killedFieldSurgery = (Thought_Memory)ThoughtMaker.MakeThought(LocalDefOf.JTFieldSurgeryKilledFieldSurgery); if (killedFieldSurgery != null && !billDoer.story.traits.HasTrait(TraitDefOf.Psychopath)) { billDoer.needs.mood.thoughts.memories.TryGainMemory(killedFieldSurgery, pawn); } } } else { //Always occurs: if tortured, upset about torture; if not tortured, upset about lack of anaesthetic var harmedMe = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDefOf.HarmedMe); pawn.needs.mood.thoughts.memories.TryGainMemory(harmedMe, billDoer); if (torture) { var tortureMasochist = (Thought_Memory)ThoughtMaker.MakeThought(LocalDefOf.JTFieldSurgeryTortureMasochist); if (tortureMasochist != null && pawn.story.traits.HasTrait(LocalDefOf.M*******t) && pawn.story.traits.HasTrait(LocalDefOf.Prosthophile)) { pawn.needs.mood.thoughts.memories.TryGainMemory(tortureMasochist, billDoer); } else { var tortured = (Thought_Memory)ThoughtMaker.MakeThought(LocalDefOf.JTFieldSurgeryTortureVictim); if (tortured != null) { pawn.needs.mood.thoughts.memories.TryGainMemory(tortured, billDoer); } } //Every colonist who is part of the colony is an accessory to torture var tortureWitness = (Thought_Memory)ThoughtMaker.MakeThought(LocalDefOf.JTFieldSurgeryTortureWitness); if (tortureWitness != null) { foreach (Pawn current in pawn.Map.mapPawns.FreeColonists) { if (current != pawn && current.IsColonist && !current.story.traits.HasTrait(TraitDefOf.Psychopath) && !current.story.traits.HasTrait(TraitDefOf.Cannibal)) { current.needs.mood.thoughts.memories.TryGainMemory(tortureWitness, billDoer); } } } //The person committing the torture will feel good if psychopath or cannibal, bad if normal //New in version 4, this also applies to cannibals (as they have obtained some meat chunks) if (billDoer.story.traits.HasTrait(TraitDefOf.Psychopath) || billDoer.story.traits.HasTrait(TraitDefOf.Cannibal)) { var torturerSadist = (Thought_Memory)ThoughtMaker.MakeThought(LocalDefOf.JTFieldSurgeryTortureSadist); if (torturerSadist != null) { billDoer.needs.mood.thoughts.memories.TryGainMemory(torturerSadist, pawn); } } else { var torturerNormal = (Thought_Memory)ThoughtMaker.MakeThought(LocalDefOf.JTFieldSurgeryTorturer); if (torturerNormal != null) { billDoer.needs.mood.thoughts.memories.TryGainMemory(torturerNormal, pawn); } } } } if (IsViolationOnPawn(pawn, part, Faction.OfPlayer)) { pawn.Faction.AffectGoodwillWith(billDoer.Faction, ViolationGoodwillImpact); } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; int raisedPawns = 0; Pawn pawn = this.launcher as Pawn; Pawn victim = hitThing as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); pwr = comp.MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_pwr"); ver = comp.MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_ver"); Thing corpseThing = null; IntVec3 curCell; IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.def.projectile.explosionRadius, true); for (int i = 0; i < targets.Count(); i++) { curCell = targets.ToArray <IntVec3>()[i]; TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .3f); if (curCell.InBounds(map)) { Corpse corpse = null; List <Thing> thingList; thingList = curCell.GetThingList(map); int z = 0; while (z < thingList.Count) { corpseThing = thingList[z]; if (corpseThing != null) { bool validator = corpseThing is Corpse; if (validator) { corpse = corpseThing as Corpse; Pawn undeadPawn = corpse.InnerPawn; CompRottable compRottable = corpse.GetComp <CompRottable>(); float rotStage = 0; if (compRottable != null && compRottable.Stage == RotStage.Dessicated) { rotStage = 1f; } if (compRottable != null) { rotStage += compRottable.RotProgressPct; } bool flag_SL = false; if (undeadPawn.def.defName == "SL_Runner" || undeadPawn.def.defName == "SL_Peon" || undeadPawn.def.defName == "SL_Archer" || undeadPawn.def.defName == "SL_Hero") { PawnGenerationRequest pgr = new PawnGenerationRequest(PawnKindDef.Named("Tribesperson"), pawn.Faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, false, true, 0, false, false, false, false, false, false, false, false, 0, null, 0); Pawn newUndeadPawn = PawnGenerator.GeneratePawn(pgr); GenSpawn.Spawn(newUndeadPawn, corpse.Position, corpse.Map, WipeMode.Vanish); corpse.Strip(); corpse.Destroy(DestroyMode.Vanish); rotStage = 1f; flag_SL = true; undeadPawn = newUndeadPawn; } if (!undeadPawn.def.defName.Contains("ROM_") && undeadPawn.RaceProps.IsFlesh && (undeadPawn.Dead || flag_SL) && undeadPawn.def.thingClass.FullName != "TorannMagic.TMPawnSummoned") { bool wasVampire = false; IEnumerable <ThingDef> enumerable = from hd in DefDatabase <HediffDef> .AllDefs where (def.defName == "ROM_Vampirism") select def; if (enumerable.Count() > 0) { bool hasVampHediff = undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_Vampirism")) || undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_GhoulHediff")); if (hasVampHediff) { wasVampire = true; } } if (!wasVampire) { undeadPawn.SetFaction(pawn.Faction); if (undeadPawn.Dead) { ResurrectionUtility.Resurrect(undeadPawn); } raisedPawns++; comp.supportedUndead.Add(undeadPawn); if (undeadPawn.kindDef != null && undeadPawn.kindDef.RaceProps != null && undeadPawn.kindDef.RaceProps.Animal) { RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, -4f); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, .5f + ver.level); undeadPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_UndeadAnimalHD).TryGetComp <HediffComp_Undead>().linkedPawn = pawn; HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage); if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Tameness).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Tameness)) { undeadPawn.training.Train(TrainableDefOf.Tameness, pawn); } } if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Obedience)) { undeadPawn.training.Train(TrainableDefOf.Obedience, pawn); } } if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Release).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Release)) { undeadPawn.training.Train(TrainableDefOf.Release, pawn); } } if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Haul).Accepted) { while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Haul)) { undeadPawn.training.Train(TorannMagicDefOf.Haul, pawn); } } if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Rescue).Accepted) { while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Rescue)) { undeadPawn.training.Train(TorannMagicDefOf.Rescue, pawn); } } undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds; undeadPawn.def.tradeability = Tradeability.None; } else if (undeadPawn.story != null && undeadPawn.story.traits != null && undeadPawn.needs != null && undeadPawn.playerSettings != null) { CompAbilityUserMagic compMagic = undeadPawn.GetComp <CompAbilityUserMagic>(); if (compMagic != null && TM_Calc.IsMagicUser(undeadPawn)) //(compMagic.IsMagicUser && !undeadPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) || { compMagic.Initialize(); compMagic.RemovePowers(true); } CompAbilityUserMight compMight = undeadPawn.GetComp <CompAbilityUserMight>(); if (compMight != null && TM_Calc.IsMightUser(undeadPawn)) //compMight.IsMightUser || { compMight.Initialize(); compMight.RemovePowers(true); } RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); RemovePsylinkAbilities(undeadPawn); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, -4f); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, .5f + ver.level); undeadPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_UndeadHD).TryGetComp <HediffComp_Undead>().linkedPawn = pawn; HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage); RedoSkills(undeadPawn, pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_LichHD"))); if (undeadPawn.story.traits.HasTrait(TorannMagicDefOf.ChaosMage)) { compMagic.RemovePawnAbility(TorannMagicDefOf.TM_ChaosTradition); } RemoveTraits(undeadPawn, undeadPawn.story.traits.allTraits); undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Undead"), 0, false)); undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Psychopath"), 0, false)); undeadPawn.needs.AddOrRemoveNeedsAsAppropriate(); RemoveClassHediff(undeadPawn); if (undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("DeathAcidifier"))) { Hediff hd = undeadPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("DeathAcidifier")); undeadPawn.health.RemoveHediff(hd); } //Color undeadColor = new Color(.2f, .4f, 0); //undeadPawn.story.hairColor = undeadColor; //CompAbilityUserMagic undeadComp = undeadPawn.GetComp<CompAbilityUserMagic>(); //if (undeadComp.IsMagicUser) //{ // undeadComp.ClearPowers(); //} List <SkillRecord> skills = undeadPawn.skills.skills; for (int j = 0; j < skills.Count; j++) { skills[j].passion = Passion.None; } undeadPawn.playerSettings.hostilityResponse = HostilityResponseMode.Attack; undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds; for (int h = 0; h < 24; h++) { undeadPawn.timetable.SetAssignment(h, TimeAssignmentDefOf.Work); } } } else { Messages.Message("Vampiric powers have prevented undead reanimation of " + undeadPawn.LabelShort, MessageTypeDefOf.RejectInput); } } } else if (corpseThing is Pawn) { Pawn undeadPawn = corpseThing as Pawn; if (undeadPawn != pawn && !TM_Calc.IsNecromancer(undeadPawn) && TM_Calc.IsUndead(corpseThing as Pawn)) { RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .6f); } } } z++; } } if (raisedPawns > pwr.level + 1) { i = targets.Count(); } } }
//True if the body part has nothing wrong with it, false otherwise static bool IsClean(Pawn pawn, BodyPartRecord part) { return(Verse.BodyPartRemovalIntent.Harvest == HealthUtility.PartRemovalIntent(pawn, part)); }
public override void CompPostTick(ref float severityAdjustment) { if (this.Pawn.Spawned && !this.Pawn.Dead && !this.Pawn.Downed) { base.CompPostTick(ref severityAdjustment); if (base.Pawn != null & base.parent != null) { if (!initialized) { initialized = true; this.Initialize(); } } CompAbilityUserMagic comp = this.Pawn.GetComp <CompAbilityUserMagic>(); if (this.ticksBitWorking > 0 && this.nextBitEffect < Find.TickManager.TicksGame && this.moteLoc != Vector3.zero) { Vector3 rndVec = this.moteLoc; rndVec.x += Rand.Range(-.15f, .15f); rndVec.z += Rand.Range(-.15f, .15f); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SparkFlash"), rndVec, this.Pawn.Map, Rand.Range(.9f, 1.5f), .05f, 0f, .1f, 0, 0f, 0f, 0f); rndVec = this.moteLoc; rndVec.x += Rand.Range(-.15f, .15f); rndVec.z += Rand.Range(-.15f, .15f); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SparkFlash"), rndVec, this.Pawn.Map, Rand.Range(.6f, 1.1f), .05f, 0f, .1f, 0, 0f, 0f, 0f); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Enchanting, comp.bitPosition, this.Pawn.Map, Rand.Range(0.35f, 0.43f), .2f, .05f, Rand.Range(.4f, .6f), Rand.Range(-200, 200), 0, 0, 0); this.ticksBitWorking--; this.nextBitEffect = Find.TickManager.TicksGame + Rand.Range(6, 10); if (this.ticksBitWorking == 0) { this.moteLoc = Vector3.zero; } } if (comp.useTechnoBitToggle) { if (Find.TickManager.TicksGame % 60 == 0) { DetermineHDRank(); } if (Find.TickManager.TicksGame % 600 == 0 && !this.Pawn.Drafted) { if (comp.Mana.CurLevelPercentage >= .9f && comp.Mana.CurLevel >= (.06f - (.001f * this.VerVal)) && this.Pawn.CurJob.targetA.Thing != null) { if (this.Pawn.CurJob.targetA.Thing != null) { if ((this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 2 && (this.Pawn.CurJob.bill != null || this.Pawn.CurJob.def.defName == "FinishFrame" || this.Pawn.CurJob.def.defName == "Deconstruct" || this.Pawn.CurJob.def.defName == "Repair" || this.Pawn.CurJob.def.defName == "Mine" || this.Pawn.CurJob.def.defName == "SmoothFloor" || this.Pawn.CurJob.def.defName == "SmoothWall")) { comp.Mana.CurLevel -= (.05f - (.001f * this.VerVal)); HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_BitAssistHD"), .5f + 1f * this.VerVal); comp.MagicUserXP += Rand.Range(6, 8); this.ticksBitWorking = 8; this.moteLoc = this.Pawn.CurJob.targetA.Thing.DrawPos; } } } } if (comp.useTechnoBitRepairToggle && Find.TickManager.TicksGame % (160 - 3 * EffVal) == 0 && this.Pawn.Drafted && comp.Mana.CurLevel >= (.03f - .0006f * EffVal)) { Thing damagedThing = TM_Calc.FindNearbyDamagedThing(this.Pawn, Mathf.RoundToInt(5 + .33f * EffVal)); Building repairBuilding = damagedThing as Building; if (repairBuilding != null) { repairBuilding.HitPoints = Mathf.Min(Mathf.RoundToInt(repairBuilding.HitPoints + (Rand.Range(8, 12) + (.5f * EffVal))), repairBuilding.MaxHitPoints); comp.Mana.CurLevel -= (.03f - .0006f * EffVal); comp.MagicUserXP += Rand.Range(4, 5); this.ticksBitWorking = 8; this.moteLoc = repairBuilding.DrawPos; } Pawn damagedRobot = damagedThing as Pawn; if (damagedRobot != null) { TM_Action.DoAction_HealPawn(this.Pawn, damagedRobot, 1, (4 + .4f * EffVal)); comp.Mana.CurLevel -= (.03f - .0006f * EffVal); comp.MagicUserXP += Rand.Range(4, 6); this.ticksBitWorking = 5; this.moteLoc = damagedRobot.DrawPos; } } if (comp.useTechnoBitRepairToggle && Find.TickManager.TicksGame % (600 - 6 * EffVal) == 0 && !this.Pawn.Drafted && comp.Mana.CurLevel >= .05f) { Thing damagedThing = TM_Calc.FindNearbyDamagedThing(this.Pawn, Mathf.RoundToInt(10 + .5f * EffVal)); Building repairBuilding = damagedThing as Building; if (repairBuilding != null) { repairBuilding.HitPoints = Mathf.Min(repairBuilding.HitPoints + (25 + (2 * EffVal)), repairBuilding.MaxHitPoints); comp.Mana.CurLevel -= (.05f - .0008f * EffVal); comp.MagicUserXP += Rand.Range(9, 11); this.ticksBitWorking = 8; this.moteLoc = repairBuilding.DrawPos; } Pawn damagedRobot = damagedThing as Pawn; if (damagedRobot != null) { TM_Action.DoAction_HealPawn(this.Pawn, damagedRobot, 2, (8 + .4f * EffVal)); comp.Mana.CurLevel -= (.05f - .0008f * EffVal); comp.MagicUserXP += Rand.Range(9, 11); this.ticksBitWorking = 5; this.moteLoc = damagedRobot.DrawPos; } } if (comp.Mana.CurLevel >= .1f && (this.Pawn.Drafted || !this.Pawn.IsColonist)) { if (this.Pawn.TargetCurrentlyAimingAt != null && (this.Pawn.CurJob.def.defName == "AttackStatic" || this.Pawn.CurJob.def.defName == "Wait_Combat") && this.nextBitGrenade < Find.TickManager.TicksGame) { float maxRange = 25 + this.PwrVal; Thing targetThing = this.Pawn.TargetCurrentlyAimingAt.Thing; float targetDistance = (this.Pawn.Position - targetThing.Position).LengthHorizontal; float acc = 15f + (PwrVal / 3f); if (TM_Calc.HasLoSFromTo(this.Pawn.Position, this.Pawn.TargetCurrentlyAimingAt.Thing, this.Pawn as Thing, 2f, maxRange) && targetThing.Map != null && this.bitGrenadeCount > 0) { IntVec3 rndTargetCell = targetThing.Position; rndTargetCell.x += Mathf.RoundToInt(Rand.Range(-targetDistance / acc, targetDistance / acc)); //grenades were 8 rndTargetCell.z += Mathf.RoundToInt(Rand.Range(-targetDistance / acc, targetDistance / acc)); LocalTargetInfo ltiTarget = rndTargetCell; //if (this.bitGrenadeCount == 2) //{ // //launch emp grenade // Projectile projectile = (Projectile)GenSpawn.Spawn(ThingDef.Named("Projectile_TMEMPGrenade"), this.Pawn.Position, this.Pawn.Map, WipeMode.Vanish); // float launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, ltiTarget.Cell)).ToAngleFlat(); // for (int m = 0; m < 4; m++) // { // TM_MoteMaker.ThrowGenericMote(ThingDefOf.Gas_Smoke, comp.bitPosition, this.Pawn.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(3f, 5f), launchAngle += Rand.Range(-25, 25), Rand.Range(0, 360)); // } // SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); // info.pitchFactor = 2f; // info.volumeFactor = .6f; // SoundDef.Named("Mortar_LaunchA").PlayOneShot(info); // projectile.def.projectile.speed = 20 + PwrVal; // projectile.def.projectile.explosionDelay = Rand.Range(80, 120) - (4 * PwrVal); // projectile.Launch(this.Pawn, comp.bitPosition, ltiTarget, targetThing, ProjectileHitFlags.All, null, null); //} //else //{ // //fire he grenade // Projectile projectile = (Projectile)GenSpawn.Spawn(ThingDef.Named("Projectile_TMFragGrenade"), this.Pawn.Position, this.Pawn.Map, WipeMode.Vanish); // float launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, ltiTarget.Cell)).ToAngleFlat(); // for (int m = 0; m < 4; m++) // { // TM_MoteMaker.ThrowGenericMote(ThingDefOf.Gas_Smoke, comp.bitPosition, this.Pawn.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(3f, 5f), launchAngle += Rand.Range(-25, 25), Rand.Range(0, 360)); // } // SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); // info.pitchFactor = 1.4f; // info.volumeFactor = .5f; // SoundDef.Named("Mortar_LaunchA").PlayOneShot(info); // projectile.def.projectile.speed = 20 + PwrVal; // projectile.def.projectile.explosionDelay = Rand.Range(80, 120) - (4 * PwrVal); // projectile.Launch(this.Pawn, comp.bitPosition, ltiTarget, targetThing, ProjectileHitFlags.All, null, null); //} Projectile p = (Projectile)(GenSpawn.Spawn(ThingDef.Named("Projectile_TM_BitTechLaser"), this.Pawn.Position, this.Pawn.Map, WipeMode.Vanish)); //float launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, ltiTarget.Cell)).ToAngleFlat(); SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); info.pitchFactor = 1.5f; info.volumeFactor = .9f; SoundDef.Named("Shot_ChargeBlaster").PlayOneShot(info); if (rndTargetCell == targetThing.Position) { p.Launch(this.Pawn, comp.bitPosition, targetThing, targetThing, ProjectileHitFlags.IntendedTarget, false, null, null); } else { p.Launch(this.Pawn, comp.bitPosition, ltiTarget, targetThing, ProjectileHitFlags.All, false, null, null); } this.nextBitGrenade = 3 + Find.TickManager.TicksGame; this.bitGrenadeCount--; if (this.bitGrenadeCount == 0) { this.bitGrenadeCount = 3 + (int)((this.PwrVal) / 5); this.nextBitGrenade = Find.TickManager.TicksGame + (180 - 3 * PwrVal); comp.Mana.CurLevel -= (.06f - (.001f * this.PwrVal)); comp.MagicUserXP += Rand.Range(8, 12); } } else if (this.nextBitGrenade < Find.TickManager.TicksGame && this.bitGrenadeCount <= 0) { this.bitGrenadeCount = 3 + (int)((this.PwrVal) / 5); this.nextBitGrenade = Find.TickManager.TicksGame + (180 - 3 * PwrVal); } } } } } }
protected override bool TryCastShot() { bool result = false; bool arg_40_0; Pawn pawn = this.CasterPawn; if (pawn != null && !pawn.Downed) { if (pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_BlurHD, false)) { using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.def == TorannMagicDefOf.TM_BlurHD) { pawn.health.RemoveHediff(rec); } } } TM_MoteMaker.ThrowManaPuff(pawn.DrawPos, pawn.Map, .75f); TM_MoteMaker.ThrowManaPuff(pawn.DrawPos, pawn.Map, .75f); TM_MoteMaker.ThrowSiphonMote(pawn.DrawPos, pawn.Map, 1f); } else { CompAbilityUserMagic comp = pawn.TryGetComp <CompAbilityUserMagic>(); if (comp != null) { if (comp.maxMP >= TorannMagicDefOf.TM_Blur.upkeepEnergyCost) { HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_BlurHD, 1f); TM_MoteMaker.ThrowManaPuff(pawn.DrawPos, pawn.Map, .75f); TM_MoteMaker.ThrowManaPuff(pawn.DrawPos, pawn.Map, 1); TM_MoteMaker.ThrowManaPuff(pawn.DrawPos, pawn.Map, .75f); } else { Messages.Message("TM_NotEnoughManaToSustain".Translate( pawn.LabelShort, TorannMagicDefOf.TM_Blur.label ), MessageTypeDefOf.RejectInput); } } } arg_40_0 = true; } else { arg_40_0 = false; } bool flag = arg_40_0; if (flag) { } else { Log.Warning("failed to TryCastShot"); } this.burstShotsLeft = 0; return(result); }
public static IEnumerable <Gizmo> GraveGizmoGetter(Pawn AbilityUser, Building_Grave grave) { bool dFlag = false; string dReason = ""; if ((AbilityUser?.BloodNeed()?.CurBloodPoints ?? 0) <= 0) { dFlag = true; dReason = "ROMV_NoBloodRemaining".Translate(); } VitaeAbilityDef bloodAwaken = DefDatabase <VitaeAbilityDef> .GetNamedSilentFail("ROMV_VampiricAwaken"); if (!AbilityUser?.Dead ?? false) { yield return(new Command_Action() { defaultLabel = bloodAwaken.label, defaultDesc = bloodAwaken.GetDescription(), icon = bloodAwaken.uiIcon, action = delegate { AbilityUser.BloodNeed().AdjustBlood(-1); grave.EjectContents(); if (grave.def == VampDefOf.ROMV_HideyHole) { grave.Destroy(); } }, disabled = dFlag, disabledReason = dReason }); } VitaeAbilityDef bloodResurrection = DefDatabase <VitaeAbilityDef> .GetNamedSilentFail("ROMV_VampiricResurrection"); if (AbilityUser?.Corpse?.GetRotStage() < RotStage.Dessicated) { yield return(new Command_Action() { defaultLabel = bloodResurrection.label, defaultDesc = bloodResurrection.GetDescription(), icon = bloodResurrection.uiIcon, action = delegate { AbilityUser.Drawer.Notify_DebugAffected(); ResurrectionUtility.Resurrect(AbilityUser); MoteMaker.ThrowText(AbilityUser.PositionHeld.ToVector3(), AbilityUser.MapHeld, StringsToTranslate.AU_CastSuccess); AbilityUser.BloodNeed().AdjustBlood(-99999999); HealthUtility.AdjustSeverity(AbilityUser, VampDefOf.ROMV_TheBeast, 1.0f); MentalStateDef MentalState_VampireBeast = DefDatabase <MentalStateDef> .GetNamed("ROMV_VampireBeast"); AbilityUser.mindState.mentalStateHandler.TryStartMentalState(MentalState_VampireBeast, null, true); }, disabled = (AbilityUser?.BloodNeed()?.CurBloodPoints ?? 0) < 0 }); } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; if (!initialized && this.age < this.duration && hitThing != null) { caster = this.launcher as Pawn; hitPawn = hitThing as Pawn; this.oldPosition = caster.Position; MightPowerSkill pwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Possess.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Possess_pwr"); MightPowerSkill ver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Possess.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Possess_ver"); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); pwrVal = pwr.level; verVal = ver.level; if (settingsRef.AIHardMode && !caster.IsColonist) { pwrVal = 3; verVal = 3; } this.duration += pwrVal * 300; if (hitPawn != null && hitPawn.Faction != null && hitPawn.RaceProps.Humanlike) { possessedFlag = hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD_I) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD_II) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD_III) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD_I) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD_II) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD_III); if (!hitPawn.Downed && !hitPawn.Dead && !possessedFlag && !hitPawn.IsPrisoner) { this.pFaction = hitPawn.Faction; this.prisoner = hitPawn.IsPrisoner; if (!caster.IsColonist && hitPawn.IsColonist) { IEnumerable <WorkTypeDef> allWorkTypes = WorkTypeDefsUtility.WorkTypeDefsInPriorityOrder; this.hitPawnWorkSetting = new List <int>(); foreach (var workType in allWorkTypes) { hitPawnWorkSetting.Add(hitPawn.workSettings.GetPriority(workType)); } } if (this.pFaction != caster.Faction) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(caster, hitPawn, true))) { //possess enemy or neutral int weaponCount = 0; if (hitPawn.equipment.PrimaryEq != null) { weaponCount = 1; } this.inventoryCount = hitPawn.inventory.innerContainer.Count + hitPawn.apparel.WornApparelCount + weaponCount; if (ModCheck.Validate.GiddyUp.Core_IsInitialized()) { ModCheck.GiddyUp.ForceDismount(caster); ModCheck.GiddyUp.ForceDismount(hitPawn); } hitPawn.SetFaction(caster.Faction, null); HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_DisguiseHD_II, 20f + (5f * pwrVal)); switch (verVal) { case 0: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD, 20f + (5f * pwrVal)); break; case 1: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD_I, 20f + (5f * pwrVal)); break; case 2: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD_II, 20f + (5f * pwrVal)); break; case 3: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD_III, 20f + (5f * pwrVal)); break; } initialized = true; MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1f); MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1.2f); MoteMaker.ThrowHeatGlow(caster.Position, caster.Map, .8f); if (!caster.IsColonist) { Lord lord = caster.GetLord(); LordJob lordJob = caster.GetLord().LordJob; try { PawnDuty duty = caster.mindState.duty; hitPawn.mindState.duty = duty; lord.AddPawn(hitPawn); } catch { Log.Message("error attempting to assign a duty to pawn during possession"); } } //loadPawn = caster; //loadPawn.ThingID += Rand.Range(0, 214).ToString(); if (caster.IsColonist) { // ModOptions.Constants.SetPawnInFlight(true); // } if (hitPawn.IsColonist && !caster.IsColonist) { TM_Action.SpellAffectedPlayerWarning(hitPawn); } caster.DeSpawn(); } else { MoteMaker.ThrowText(hitThing.DrawPos, hitThing.Map, "TM_ResistedSpell".Translate(), -1); this.age = this.duration; this.Destroy(DestroyMode.Vanish); } } else { //possess friendly if (ModCheck.Validate.GiddyUp.Core_IsInitialized()) { ModCheck.GiddyUp.ForceDismount(caster); } HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_DisguiseHD_II, 20f + (5f * pwrVal)); switch (verVal) { case 0: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD, 20f + (5f * pwrVal)); break; case 1: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD_I, 20f + (5f * pwrVal)); break; case 2: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD_II, 20f + (5f * pwrVal)); break; case 3: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD_III, 20f + (5f * pwrVal)); break; } initialized = true; MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1f); MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1.2f); MoteMaker.ThrowHeatGlow(caster.Position, caster.Map, .8f); caster.DeSpawn(); } } else { Messages.Message("TM_CannotPossessNow".Translate( caster.LabelShort, hitPawn.LabelShort ), MessageTypeDefOf.RejectInput); this.age = this.duration; this.Destroy(DestroyMode.Vanish); } } else { Messages.Message("TM_CannotPossess".Translate( caster.LabelShort, hitThing.LabelShort ), MessageTypeDefOf.RejectInput); this.age = this.duration; this.Destroy(DestroyMode.Vanish); } } else { if (!this.initialized) { this.age = this.duration; Destroy(DestroyMode.Vanish); } } if (hitPawn != null && (hitPawn.Downed || hitPawn.Dead)) { this.age = this.duration; } }
public override void Effect(Pawn target) { base.Effect(target); HealthUtility.AdjustSeverity(this.CasterPawn, VampDefOf.ROMV_BatFormHediff, 1.0f); }
protected override bool TryCastShot() { Pawn p = this.CasterPawn; Map map = this.CasterPawn.Map; CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); pawns.Clear(); plants.Clear(); GenClamor.DoClamor(p, this.UseAbilityProps.TargetAoEProperties.range, ClamorDefOf.Ability); Effecter snapeFreezeED = TorannMagicDefOf.TM_SnapFreezeED.Spawn(); snapeFreezeED.Trigger(new TargetInfo(this.currentTarget.Cell, map, false), new TargetInfo(this.currentTarget.Cell, map, false)); snapeFreezeED.Cleanup(); SoundInfo info = SoundInfo.InMap(new TargetInfo(this.currentTarget.Cell, map, false), MaintenanceType.None); info.pitchFactor = .4f; info.volumeFactor = 1.2f; TorannMagicDefOf.TM_WindLowSD.PlayOneShot(info); TargetInfo ti = new TargetInfo(this.currentTarget.Cell, map, false); TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, 3f, 0f, .1f, .4f, 1.2f, -3f); float classBonus = 1f; if (p.story != null && p.story.traits != null && p.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost)) { classBonus = 1.5f; } if (this.currentTarget != null && p != null && comp != null) { this.arcaneDmg = comp.arcaneDmg; this.TargetsAoE.Clear(); this.FindTargets(); float energy = -125000 * this.arcaneDmg * classBonus; GenTemperature.PushHeat(this.currentTarget.Cell, p.Map, energy); for (int i = 0; i < pawns.Count; i++) { if (!pawns[i].RaceProps.IsMechanoid && pawns[i].RaceProps.body.AllPartsVulnerableToFrostbite.Count > 0) { float distanceModifier = 1f / (pawns[i].Position - currentTarget.Cell).LengthHorizontal; if (distanceModifier > 1f) { distanceModifier = 1f; } int bites = Mathf.RoundToInt(Rand.Range(1f, 5f) * classBonus); for (int j = 0; j < bites; j++) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier)) { TM_Action.DamageEntities(pawns[i], pawns[i].def.race.body.AllPartsVulnerableToFrostbite.RandomElement(), Rand.Range(10, 20) * distanceModifier, 1f, DamageDefOf.Frostbite, p); } if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier)) { HealthUtility.AdjustSeverity(pawns[i], HediffDefOf.Hypothermia, distanceModifier / 5f); } } } } for (int i = 0; i < plants.Count; i++) { float distanceModifier = 1f / (plants[i].Position - currentTarget.Cell).LengthHorizontal; if (distanceModifier > 1f) { distanceModifier = 1f; } if (plants[i].def.plant.IsTree) { if (Rand.Chance(distanceModifier / 2f)) { plants[i].MakeLeafless(Plant.LeaflessCause.Cold); } } else { if (Rand.Chance(distanceModifier)) { plants[i].MakeLeafless(Plant.LeaflessCause.Cold); } } plants[i].Notify_ColorChanged(); } List <IntVec3> cellList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range, true).ToList(); bool raining = map.weatherManager.RainRate > 0f || map.weatherManager.SnowRate > 0f; for (int i = 0; i < cellList.Count; i++) { cellList[i] = cellList[i].ClampInsideMap(map); SnowUtility.AddSnowRadial(cellList[i], map, 2.4f, Rand.Range(.08f, .13f)); TM_FleckMaker.ThrowGenericFleck(FleckDefOf.AirPuff, cellList[i].ToVector3Shifted(), map, 2.5f, .05f, .05f, Rand.Range(2f, 3f), Rand.Range(-60, 60), .5f, -70, Rand.Range(0, 360)); } List <IntVec3> windList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range + 1, true).Except(cellList).ToList(); for (int i = 0; i < windList.Count; i++) { windList[i] = windList[i].ClampInsideMap(map); Vector3 angle = TM_Calc.GetVector(windList[i], this.currentTarget.Cell); TM_FleckMaker.ThrowGenericFleck(FleckDefOf.AirPuff, windList[i].ToVector3Shifted(), map, Rand.Range(1.2f, 2f), .45f, Rand.Range(0f, .25f), .5f, -200, Rand.Range(3, 5), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), Rand.Range(0, 360)); } } this.burstShotsLeft = 0; return(true); }
public override void CompPostTick(ref float severityAdjustment) { if (base.Pawn != null & base.parent != null && !this.Pawn.Dead) { if (!initialized) { initialized = true; this.Initialize(); } base.CompPostTick(ref severityAdjustment); if (Find.TickManager.TicksGame % 60 == 0 && initialized) { DeterminePsionicHD(); severityAdjustment += (this.Pawn.GetStatValue(StatDefOf.PsychicSensitivity, false) * Rand.Range(.04f, .12f)); if (Find.Selector.FirstSelectedObject == this.Pawn) { HediffStage hediffStage = this.Pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_PsionicHD"), false).CurStage; hediffStage.label = this.parent.Severity.ToString("0.00") + "%"; } Hediff hediff = this.Pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_Artifact_PsionicBoostHD); float maxSev = 100; if (hediff != null) { maxSev += hediff.Severity; } this.parent.Severity = Mathf.Clamp(this.parent.Severity, 0, maxSev); } if (base.Pawn.Spawned && !this.Pawn.Downed && base.Pawn.Map != null && comp != null) { if (this.doPsionicAttack) { this.ticksTillPsionicStrike--; if (this.ticksTillPsionicStrike <= 0) { this.doPsionicAttack = false; if (threat != null && !threat.Destroyed && !threat.Dead && !threat.Downed) { TM_MoteMaker.MakePowerBeamMotePsionic(threat.DrawPos.ToIntVec3(), threat.Map, 2f, 2f, .7f, .1f, .6f); DamageInfo dinfo2 = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_PsionicInjury, Rand.Range(6, 12) * this.Pawn.GetStatValue(StatDefOf.PsychicSensitivity, false) + (2 * VerVal), 0, -1, this.Pawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.threat); this.threat.TakeDamage(dinfo2); } } } if (comp.usePsionicAugmentationToggle && this.Pawn.drafter != null && this.Pawn.CurJob != null) { if (Find.TickManager.TicksGame % 600 == 0 && !this.Pawn.Drafted) { if (this.parent.Severity >= 95 && this.Pawn.CurJob.targetA != null && this.Pawn.CurJob.targetA.Thing != null) { if ((this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal > 20 && (this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 300 && this.Pawn.CurJob.locomotionUrgency >= LocomotionUrgency.Jog && this.Pawn.CurJob.bill == null) { this.parent.Severity -= 10f; if (this.EffVal == 0) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD"), 1f + .02f * this.EffVal); } else if (this.EffVal == 1) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_I"), 1f + .02f * this.EffVal); } else if (this.EffVal == 2) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_II"), 1f + .02f * this.EffVal); } else { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_III"), 1f + .02f * this.EffVal); } for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } comp.MightUserXP += Rand.Range(10, 15); } if ((this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 2 && (this.Pawn.CurJob.bill != null || this.Pawn.CurJob.def.defName == "Sow" || this.Pawn.CurJob.def.defName == "FinishFrame" || this.Pawn.CurJob.def.defName == "Deconstruct" || this.Pawn.CurJob.def.defName == "Repair" || this.Pawn.CurJob.def.defName == "Clean" || this.Pawn.CurJob.def.defName == "Mine" || this.Pawn.CurJob.def.defName == "SmoothFloor" || this.Pawn.CurJob.def.defName == "SmoothWall" || this.Pawn.CurJob.def.defName == "Harvest" || this.Pawn.CurJob.def.defName == "HarvestDesignated" || this.Pawn.CurJob.def.defName == "CutPlant" || this.Pawn.CurJob.def.defName == "CutPlantDesignated")) { this.parent.Severity -= 12f; if (this.PwrVal == 0) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD"), 1f + .02f * this.PwrVal); } else if (this.PwrVal == 1) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_I"), 1f + .02f * this.PwrVal); } else if (this.PwrVal == 2) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_II"), 1f + .02f * this.PwrVal); } else { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_III"), 1f + .02f * this.PwrVal); } for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } comp.MightUserXP += Rand.Range(10, 15); } } } if (this.parent.Severity >= 20) { if (Find.TickManager.TicksGame % 180 == 0 && (this.Pawn.Drafted || !this.Pawn.IsColonist) && ((this.Pawn.equipment.Primary != null && !this.Pawn.equipment.Primary.def.IsRangedWeapon) || this.Pawn.equipment.Primary == null)) { if (this.Pawn.CurJob.targetA != null && this.Pawn.CurJob.targetA.Thing != null && this.Pawn.CurJob.targetA.Thing is Pawn && this.Pawn.CurJobDef == JobDefOf.AttackMelee) { //Log.Message("performing psionic dash - curjob " + this.Pawn.CurJob); //Log.Message("curjob def " + this.Pawn.CurJob.def.defName); //Log.Message("target " + this.Pawn.CurJob.targetA.Thing); //Log.Message("target range " + (this.Pawn.CurJob.targetA.Thing.Position - this.Pawn.Position).LengthHorizontal); Pawn targetPawn = this.Pawn.CurJob.targetA.Thing as Pawn; float targetDistance = (this.Pawn.Position - targetPawn.Position).LengthHorizontal; if (targetDistance > 3 && targetDistance < (12 + EffVal) && targetPawn.Map != null && !targetPawn.Downed) { for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } FlyingObject_PsionicLeap flyingObject = (FlyingObject_PsionicLeap)GenSpawn.Spawn(ThingDef.Named("FlyingObject_PsionicLeap"), this.Pawn.Position, this.Pawn.Map); flyingObject.Launch(this.Pawn, this.Pawn.CurJob.targetA.Thing, this.Pawn); HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicHD"), -3f); comp.Stamina.CurLevel -= .03f; comp.MightUserXP += Rand.Range(20, 30); } } } if (this.nextPsionicAttack < Find.TickManager.TicksGame && this.Pawn.Drafted && comp.usePsionicMindAttackToggle) { if (this.Pawn.CurJob.def != TorannMagicDefOf.JobDriver_PsionicBarrier && VerVal > 0) { this.threat = TM_Calc.FindNearbyEnemy(this.Pawn, 20 + (2 * verVal)); // GetNearbyTarget(20 + (2 * VerVal)); if (threat != null) { //start psionic attack; ends after delay SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); TorannMagicDefOf.TM_Implosion.PlayOneShot(info); Effecter psionicAttack = TorannMagicDefOf.TM_GiantExplosion.Spawn(); psionicAttack.Trigger(new TargetInfo(threat.Position, threat.Map, false), new TargetInfo(threat.Position, threat.Map, false)); psionicAttack.Cleanup(); for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } float weaponModifier = 1; if (this.Pawn.equipment.Primary != null) { if (this.Pawn.equipment.Primary.def.IsRangedWeapon) { StatModifier wpnMass = this.Pawn.equipment.Primary.def.statBases.FirstOrDefault((StatModifier x) => x.stat.defName == "Mass"); weaponModifier = Mathf.Clamp(wpnMass.value, .8f, 6); } else //assume melee weapon { StatModifier wpnMass = this.Pawn.equipment.Primary.def.statBases.FirstOrDefault((StatModifier x) => x.stat.defName == "Mass"); weaponModifier = Mathf.Clamp(wpnMass.value, .6f, 4); } } else //unarmed { weaponModifier = .4f; } this.nextPsionicAttack = Find.TickManager.TicksGame + (int)(Mathf.Clamp((600 - (60 * verVal)) * weaponModifier, 120, 900)); float energyCost = Mathf.Clamp((10f - VerVal) * weaponModifier, 2f, 12f); HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicHD"), -energyCost); comp.MightUserXP += Rand.Range(8, 12); this.doPsionicAttack = true; this.ticksTillPsionicStrike = 24; } } } } } } } }
public void GenerateWarfield(int battleZoneAbs, int battleZoneOrd, OG_OutpostData outpostData) { // Get a random hostile faction. int securityForcesCorpseNumber = Rand.Range(2, 4); int hostilesCorpseNumber = 0; FactionDef hostileFactionDef = null; Faction hostileFaction = null; float hostileFactionSelector = Rand.Value; if (hostileFactionSelector < 0.25f) { hostileFactionDef = FactionDefOf.Tribe; hostileFaction = Find.FactionManager.FirstFactionOfDef(hostileFactionDef); hostilesCorpseNumber = Rand.Range(6, 8); } else if (hostileFactionSelector < 0.5f) { hostileFactionDef = FactionDefOf.Pirate; hostileFaction = Find.FactionManager.FirstFactionOfDef(hostileFactionDef); hostilesCorpseNumber = Rand.Range(3, 5); } else if (hostileFactionSelector < 0.75f) { hostileFactionDef = FactionDefOf.SpacerHostile; hostileFaction = Find.FactionManager.FirstFactionOfDef(hostileFactionDef); hostilesCorpseNumber = Rand.Range(3, 5); } else { hostileFactionDef = FactionDefOf.Mechanoid; hostileFaction = Find.FactionManager.FirstFactionOfDef(hostileFactionDef); hostilesCorpseNumber = Rand.Range(1, 3); } // Spawn corpses. IntVec3 zoneOrigin = Zone.GetZoneOrigin(outpostData.areaSouthWestOrigin, battleZoneAbs, battleZoneOrd); for (int corpseIndex = 0; corpseIndex < securityForcesCorpseNumber + hostilesCorpseNumber; corpseIndex++) { int tries = 3; // Max 3 tries per corpse. bool validPositionIsFound = false; IntVec3 corpsePosition = new IntVec3(); for (int tryIndex = 0; tryIndex < tries; tryIndex++) { corpsePosition = zoneOrigin + new IntVec3(Rand.Range(1, Genstep_GenerateOutpost.zoneSideSize - 1), 0, Rand.Range(1, Genstep_GenerateOutpost.zoneSideSize - 1)); if (corpsePosition.GetEdifice() == null) { validPositionIsFound = true; break; } } if (validPositionIsFound == false) { continue; } // Generate the corpse according to the faction. Pawn corpse = null; if (corpseIndex < securityForcesCorpseNumber) { corpse = PawnGenerator.GeneratePawn(OG_Util.OutpostScoutDef, OG_Util.FactionOfMAndCo); } else { float pawnKindSelector = Rand.Value; PawnKindDef corpseKindDef = null; if (hostileFactionDef == FactionDefOf.Tribe) { if (pawnKindSelector < 0.4f) { corpseKindDef = PawnKindDef.Named("TribalWarrior"); } else if (pawnKindSelector < 0.8f) { corpseKindDef = PawnKindDef.Named("TribalArcher"); } else { corpseKindDef = PawnKindDef.Named("TribalChief"); } } else if (hostileFactionDef == FactionDefOf.Pirate) { if (pawnKindSelector < 0.25f) { corpseKindDef = PawnKindDef.Named("Drifter"); } else if (pawnKindSelector < 0.50f) { corpseKindDef = PawnKindDef.Named("Scavenger"); } else if (pawnKindSelector < 0.75f) { corpseKindDef = PawnKindDef.Named("Thrasher"); } else { corpseKindDef = PawnKindDef.Named("Pirate"); } } else if (hostileFactionDef == FactionDefOf.SpacerHostile) { if (pawnKindSelector < 0.25f) { corpseKindDef = PawnKindDef.Named("SpaceSoldier"); } else if (pawnKindSelector < 0.50f) { corpseKindDef = PawnKindDef.Named("MercenaryGunner"); } else if (pawnKindSelector < 0.75f) { corpseKindDef = PawnKindDef.Named("GrenadierDestructive"); } else { corpseKindDef = PawnKindDef.Named("MercenaryElite"); } } else if (hostileFactionDef == FactionDefOf.Mechanoid) { if (pawnKindSelector < 0.6f) { corpseKindDef = PawnKindDef.Named("Scyther"); } else { corpseKindDef = PawnKindDef.Named("Centipede"); } } corpse = PawnGenerator.GeneratePawn(corpseKindDef, hostileFaction); } GenSpawn.Spawn(corpse, corpsePosition); // Damage the weapon so the warfield effect is not too exploitable (otherwise, player can get good guns at game start). if (corpse.equipment.Primary != null) { corpse.equipment.Primary.HitPoints = (int)(Rand.Range(0.05f, 0.30f) * corpse.equipment.Primary.MaxHitPoints); } // "Kill the corpse". HealthUtility.GiveInjuriesToKill(corpse); // Make it rotten if outpost is abandonned. if (this.outpostData.isInhabited == false) { List <Thing> thingsList = corpsePosition.GetThingList(); foreach (Thing thing in thingsList) { if (thing.def.defName.Contains("Corpse")) { CompRottable rotComp = thing.TryGetComp <CompRottable>(); if (rotComp != null) { rotComp.rotProgress = 20f * GenDate.TicksPerDay; // 20 days so the corpse is dessicated. } } } } } // Destroy some sandbags in the zone. List <Thing> sandbagsList = Find.ListerThings.ThingsOfDef(ThingDefOf.Sandbags); for (int sandbagIndex = sandbagsList.Count - 1; sandbagIndex >= 0; sandbagIndex--) { Thing sandbag = sandbagsList[sandbagIndex]; if (sandbag.Position.InHorDistOf(this.Position, Genstep_GenerateOutpost.zoneSideSize / 2f) && (Rand.Value < 0.1f)) { // Manually spawn sandbag rubble and use Vanish instead of Kill to avoid spawning ugly metal remains. GenSpawn.Spawn(ThingDef.Named("SandbagRubble"), sandbag.Position); sandbag.Destroy(DestroyMode.Vanish); } } }
protected override bool TryCastShot() { bool flag = false; this.TargetsAoE.Clear(); //this.UpdateTargets(); this.FindTargets(); MagicPowerSkill pwr = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SootheAnimal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SootheAnimal_pwr"); pwrVal = pwr.level; if (base.CasterPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); pwrVal = mpwr.level; } bool flag2 = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1; if (flag2) { this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1); } for (int i = 0; i < this.TargetsAoE.Count; i++) { if (this.TargetsAoE[i].Thing.Faction != this.CasterPawn.Faction) { Pawn newPawn = this.TargetsAoE[i].Thing as Pawn; bool flag1 = (newPawn.mindState.mentalStateHandler.CurStateDef == MentalStateDefOf.ManhunterPermanent) || (newPawn.mindState.mentalStateHandler.CurStateDef == MentalStateDefOf.Manhunter); if (flag1) { if (newPawn.kindDef.RaceProps.Animal) { newPawn.mindState.mentalStateHandler.Reset(); newPawn.jobs.StopAll(); MoteMaker.ThrowMicroSparks(newPawn.Position.ToVector3().normalized, newPawn.Map); float sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiManipulation, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiMovement, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiBreathing, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiSight, sev); if (pwrVal > 0) { TM_MoteMaker.ThrowSiphonMote(newPawn.Position.ToVector3(), newPawn.Map, 1f); } } } if (!flag1) { if (newPawn.kindDef.RaceProps.Animal && (this.TargetsAoE[i].Thing.Faction == null || this.TargetsAoE[i].Thing.HostileTo(base.CasterPawn.Faction))) { newPawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, true, false, null); float sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Manipulation, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Movement, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Breathing, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Sight, sev); MoteMaker.ThrowMicroSparks(newPawn.Position.ToVector3().normalized, newPawn.Map); if (pwrVal > 0) { TM_MoteMaker.ThrowManaPuff(newPawn.Position.ToVector3(), newPawn.Map, 1f); } } } } } this.PostCastShot(flag, out flag); return(flag); }
/// <summary> /// Absorbs the attacker damage. /// </summary> /// <param name="defender">Defender doing the blocking.</param> /// <param name="dinfo">Describes the incoming damage.</param> /// <param name="ranged">Is this attack ranged or melee?</param> /// <returns>True if it absorbed damage successfully.</returns> public virtual bool AbsorbDamage(Pawn defender, DamageInfo dinfo, bool ranged) { bool absorbedDamage = false; //Check if we blocked the attack at all. if (ShieldProps.canBlockMelee && !ranged) { //Melee float baseStat = defender.GetStatValue(ShieldStatsDefOf.MeleeShieldBlockChance, true); float chance = baseStat * parent.GetStatValue(ShieldStatsDefOf.Shield_BaseMeleeBlockChance); //Log.Message("Melee block chance: " + chance.ToStringPercent()); if (Rand.Chance(chance)) { absorbedDamage = true; } } else if (ShieldProps.canBlockRanged && ranged) { //Ranged float baseStat = defender.GetStatValue(ShieldStatsDefOf.RangedShieldBlockChance, true); float chance = baseStat * parent.GetStatValue(ShieldStatsDefOf.Shield_BaseRangedBlockChance); //Log.Message("Ranged block chance: " + chance.ToStringPercent()); if (Rand.Chance(chance)) { absorbedDamage = true; } } if (!absorbedDamage) { return(false); } //Fatigue damage. if (absorbedDamage && ShieldProps.useFatigue) { float finalDamage = (float)dinfo.Amount * ShieldProps.damageToFatigueFactor; HealthUtility.AdjustSeverity(defender, ShieldHediffDefOf.ShieldFatigue, finalDamage); } //Take damage from attack. if (ShieldProps.shieldTakeDamage) { int finalDamage = Mathf.CeilToInt((float)dinfo.Amount * parent.GetStatValue(ShieldStatsDefOf.Shield_DamageAbsorbed)); DamageInfo shieldDamage = new DamageInfo(dinfo); shieldDamage.SetAmount(finalDamage); parent.TakeDamage(shieldDamage); } //Absorb damage if shield is still intact. if (parent.HitPoints > 0) { MakeBlockEffect(defender, dinfo, ranged); return(true); } return(false); }