public override DamageResult Apply(DamageInfo dinfo, Thing victim) { DamageResult result = DamageResult.MakeNew(); result.totalDamageDealt = 0f; if (victim is ProjectJedi.PawnGhost) { Messages.Message("PJ_ForceGhostResisted".Translate(), MessageTypeDefOf.NegativeEvent); return(result); } int amount = dinfo.Amount; caster = dinfo.Instigator as Pawn; switch (amount) { case 1: ApprenticeEffect(victim); break; case 2: AdeptEffect(victim); break; case 3: MasterEffect(victim); break; default: Log.Error(this.def.label + " only works with damages 1, 2, or 3"); break; } return(result); }
private DamageWorker.DamageResult ApplyToPawn(DamageInfo dinfo, Pawn pawn) { DamageResult result = DamageResult.MakeNew(); if (dinfo.Amount <= 0) { return(result); } if (!DebugSettings.enablePlayerDamage && pawn.Faction == Faction.OfPlayer) { return(result); } Map mapHeld = pawn.MapHeld; bool spawnedOrAnyParentSpawned = pawn.SpawnedOrAnyParentSpawned; BodyPartRecord consciousnessSource = pawn.def.race.body.AllParts.FirstOrDefault((BodyPartRecord x) => x.def == BodyPartDefOf.Brain || x.def.tags.Contains("ConsciousnessSource")); if (consciousnessSource != null) { Hediff pressure = pawn.health.hediffSet.GetFirstHediffOfDef(MonsterDefOf.ROM_IntracranialPressure); if (pressure == null) { pressure = HediffMaker.MakeHediff(MonsterDefOf.ROM_IntracranialPressure, pawn, consciousnessSource); pressure.Severity = 0.01f; pawn.health.AddHediff(pressure, consciousnessSource, null); } float resultDMG = pressure.Severity + Rand.Range(0.1f, 0.3f); pressure.Severity = Mathf.Clamp(resultDMG, 0.0f, 1.0f); result.totalDamageDealt += resultDMG; return(result); } return(result); }
public override DamageResult Apply(DamageInfo dinfo, Thing thing) { Pawn pawn = thing as Pawn; if (pawn != null) { Hediff hediff = HediffMaker.MakeHediff(dinfo.Def.hediff, pawn, null); hediff.Severity = (float)dinfo.Amount; pawn.health.AddHediff(hediff, null, dinfo); } return(DamageResult.MakeNew()); }
public override DamageResult Apply(DamageInfo dinfo, Thing victim) { DamageResult result = DamageResult.MakeNew(); Fire fire = victim as Fire; if (fire != null && !fire.Destroyed) { base.Apply(dinfo, victim); fire.fireSize -= (float)((float)dinfo.Amount * 0.0099999997764825821); if (fire.fireSize <= 0.10000000149011612) { fire.Destroy(DestroyMode.Vanish); } return result; } return result; }
public virtual DamageResult Apply(DamageInfo dinfo, Thing victim) { DamageResult result = DamageResult.MakeNew(); if (victim.SpawnedOrAnyParentSpawned) { ImpactSoundUtility.PlayImpactSound(victim, dinfo.Def.impactSoundType, victim.MapHeld); } if (victim.def.useHitPoints && dinfo.Def.harmsHealth) { result.totalDamageDealt = (float)Mathf.Min(victim.HitPoints, dinfo.Amount); victim.HitPoints -= (int)result.totalDamageDealt; if (victim.HitPoints <= 0) { victim.HitPoints = 0; victim.Kill(dinfo, null); } } return(result); }
public override DamageResult Apply(DamageInfo dinfo, Thing thing) { DamageResult result = DamageResult.MakeNew(); result.totalDamageDealt = 0f; if (thing is ProjectJedi.PawnGhost) { Messages.Message("PJ_ForceGhostResisted".Translate(), MessageTypeDefOf.NegativeEvent); return(result); } Pawn pawn = thing as Pawn; if (pawn != null) { int maxInjuries = 6; int maxInjuriesPerBodypart; foreach (BodyPartRecord rec in pawn.health.hediffSet.GetInjuredParts()) { if (maxInjuries > 0) { maxInjuriesPerBodypart = 2; foreach (Hediff_Injury current in from injury in pawn.health.hediffSet.GetHediffs <Hediff_Injury>() where injury.Part == rec select injury) { if (maxInjuriesPerBodypart > 0) { if (current.CanHealNaturally() && !current.IsOld()) // basically check for scars and old wounds { current.Heal((int)current.Severity + 1); maxInjuries--; maxInjuriesPerBodypart--; } } } } } } return(result); }
private DamageResult ApplyToPawn(DamageInfo dinfo, Pawn pawn) { DamageResult result = DamageResult.MakeNew(); if (dinfo.Amount <= 0) { return(result); } if (!DebugSettings.enablePlayerDamage && pawn.Faction == Faction.OfPlayer) { return(result); } Map mapHeld = pawn.MapHeld; bool spawnedOrAnyParentSpawned = pawn.SpawnedOrAnyParentSpawned; if (dinfo.Def.spreadOut) { if (pawn.apparel != null) { List <Apparel> wornApparel = pawn.apparel.WornApparel; for (int num = wornApparel.Count - 1; num >= 0; num--) { this.CheckApplySpreadDamage(dinfo, wornApparel[num]); } } if (pawn.equipment != null && pawn.equipment.Primary != null) { this.CheckApplySpreadDamage(dinfo, pawn.equipment.Primary); } if (pawn.inventory != null) { ThingOwner <Thing> innerContainer = pawn.inventory.innerContainer; for (int num2 = innerContainer.Count - 1; num2 >= 0; num2--) { this.CheckApplySpreadDamage(dinfo, innerContainer[num2]); } } } if (this.ShouldFragmentDamageForDamageType(dinfo)) { int num3 = Rand.RangeInclusive(3, 4); for (int i = 0; i < num3; i++) { DamageInfo dinfo2 = dinfo; dinfo2.SetAmount(dinfo.Amount / num3); this.ApplyDamageToPart(dinfo2, pawn, ref result); } } else { this.ApplyDamageToPart(dinfo, pawn, ref result); this.CheckDuplicateSmallPawnDamageToPartParent(dinfo, pawn, ref result); } if (result.wounded) { DamageWorker_AddInjury.PlayWoundedVoiceSound(dinfo, pawn); pawn.Drawer.Notify_DamageApplied(dinfo); DamageWorker_AddInjury.InformPsychology(dinfo, pawn); } if (result.headshot && pawn.Spawned) { IntVec3 position = pawn.Position; double x = (float)position.x + 1.0; IntVec3 position2 = pawn.Position; float y = (float)position2.y; IntVec3 position3 = pawn.Position; MoteMaker.ThrowText(new Vector3((float)x, y, (float)((float)position3.z + 1.0)), pawn.Map, "Headshot".Translate(), Color.white, -1f); if (dinfo.Instigator != null) { Pawn pawn2 = dinfo.Instigator as Pawn; if (pawn2 != null) { pawn2.records.Increment(RecordDefOf.Headshots); } } } if (result.deflected) { if (pawn.health.deflectionEffecter == null) { pawn.health.deflectionEffecter = EffecterDefOf.ArmorDeflect.Spawn(); } pawn.health.deflectionEffecter.Trigger(pawn, pawn); } else if (spawnedOrAnyParentSpawned) { ImpactSoundUtility.PlayImpactSound(pawn, dinfo.Def.impactSoundType, mapHeld); } return(result); }
public override DamageResult Apply(DamageInfo dinfo, Thing thing) { DamageResult result = DamageResult.MakeNew(); result.totalDamageDealt = 0f; if (thing is ProjectJedi.PawnGhost) { Messages.Message("PJ_ForceGhostResisted".Translate(), MessageTypeDefOf.NegativeEvent); return result; } Pawn pawn = thing as Pawn; if (pawn != null) { if (dinfo.Instigator != null) { Pawn caster = dinfo.Instigator as Pawn; if (caster != null) { CompForceUser victimForce = pawn.GetComp<CompForceUser>(); int maxInjuries = 2; int maxHeals = 0; int maxPoolDamage = 30; if (victimForce != null) { if (victimForce.IsForceUser) { Need_ForcePool victimForcePool = victimForce.ForcePool; if (victimForcePool != null) { if (victimForcePool.CurLevel > 0.1f) { //Turn 0.01f into 1, or 1.0 into 100. int victimForceInt = System.Convert.ToInt32(victimForcePool.CurLevel * 100); //Log.Message("Victim Force Pool = " + victimForceInt.ToString()); Need_ForcePool casterPool = caster.needs.TryGetNeed<Need_ForcePool>(); if (casterPool != null) { Messages.Message("PJ_ForceDrainOne".Translate(new object[] { caster.Label, pawn.Label }), MessageTypeDefOf.SilentInput); for (int i = 0; i < Mathf.Min(victimForceInt, maxPoolDamage); i++) { if (casterPool.CurLevel >= 0.99f) break; casterPool.CurLevel += 0.01f; victimForcePool.CurLevel -= 0.05f; } return result; } } } } } Messages.Message("PJ_ForceDrainTwo".Translate(new object[] { caster.Label, pawn.Label }), MessageTypeDefOf.SilentInput); foreach (BodyPartRecord rec in pawn.health.hediffSet.GetNotMissingParts().InRandomOrder<BodyPartRecord>()) { if (maxInjuries > 0) { pawn.TakeDamage(new DamageInfo(DamageDefOf.Burn, new IntRange(5, 10).RandomInRange, -1, caster, rec)); maxInjuries--; maxHeals++; } } int maxInjuriesPerBodypart; foreach (BodyPartRecord rec in caster.health.hediffSet.GetInjuredParts()) { if (maxHeals > 0) { maxInjuriesPerBodypart = 2; foreach (Hediff_Injury current in from injury in caster.health.hediffSet.GetHediffs<Hediff_Injury>() where injury.Part == rec select injury) { if (maxInjuriesPerBodypart > 0) { if (current.CanHealNaturally() && !current.IsOld()) // basically check for scars and old wounds { current.Heal((int)current.Severity + 1); maxHeals--; maxInjuriesPerBodypart--; } } } } } } } } return result; }