// Token: 0x0600007C RID: 124 RVA: 0x000067F8 File Offset: 0x000049F8 public static void RemoveTrait(Pawn pawn, Trait trait, string doer, MessageTypeDef MsgType, bool SendMsg = true) { var story = pawn.story; var remTrait = story != null ? (from x in story.traits.allTraits where x.def == trait.def select x).FirstOrDefault() : null; if (remTrait == null) { return; } var story2 = pawn.story; story2?.traits.allTraits.Remove(remTrait); TraitsUpdated(pawn); if (!SendMsg) { return; } var key = "MSExotic.TraitRemoved"; NamedArgument arg = pawn.LabelShort.CapitalizeFirst(); var trait2 = trait; Messages.Message(key.Translate(arg, trait2?.Label.CapitalizeFirst(), doer.CapitalizeFirst()), pawn, MsgType); }
public TransitionAction_Message(string message, MessageTypeDef messageType, string repeatAvoiderTag = null, float repeatAvoiderSeconds = 1f) { this.message = message; type = messageType; this.repeatAvoiderTag = repeatAvoiderTag; this.repeatAvoiderSeconds = repeatAvoiderSeconds; }
public override void ResolveReferencesSpecial() { if (messageType == null) { messageType = MessageTypeDefOf.PositiveEvent; } }
public override void AssignDebugData() { base.AssignDebugData(); inSignal = "DebugSignal" + Rand.Int; message = "Dev: Test"; messageType = MessageTypeDefOf.PositiveEvent; }
// Token: 0x0600007C RID: 124 RVA: 0x000067F8 File Offset: 0x000049F8 public static void RemoveTrait(Pawn pawn, Trait trait, string doer, MessageTypeDef MsgType, bool SendMsg = true) { Pawn_StoryTracker story = pawn.story; Trait remTrait = (story != null) ? (from x in story.traits.allTraits where x.def == trait.def select x).FirstOrDefault() : null; if (remTrait == null) { return; } if (pawn != null) { Pawn_StoryTracker story2 = pawn.story; if (story2 != null) { story2.traits.allTraits.Remove(remTrait); } } MSTraitChanger.TraitsUpdated(pawn); if (SendMsg) { string key = "MSExotic.TraitRemoved"; NamedArgument arg = pawn?.LabelShort.CapitalizeFirst(); Trait trait2 = trait; Messages.Message(key.Translate(arg, trait2?.Label.CapitalizeFirst(), doer.CapitalizeFirst()), pawn, MsgType, true); } }
public TransitionAction_Message(string message, MessageTypeDef messageType) { this.lookTarget = TargetInfo.Invalid; base..ctor(); this.message = message; this.type = messageType; }
public TransitionAction_Message(string message, MessageTypeDef messageType, Func <TargetInfo> lookTargetGetter, string repeatAvoiderTag = null, float repeatAvoiderSeconds = 1f) { this.message = message; type = messageType; this.lookTargetGetter = lookTargetGetter; this.repeatAvoiderTag = repeatAvoiderTag; this.repeatAvoiderSeconds = repeatAvoiderSeconds; }
private static bool Prefix(string text, LookTargets lookTargets, MessageTypeDef def) { if (def == MessageTypeDefOf.PawnDeath && lookTargets.TryGetPrimaryTarget().Thing is Pawn pawn && (pawn.IsEmptySleeve() || pawn.HasStack())) { return(false); } return(true); }
public TransitionAction_MessageDebug(string message, MessageTypeDef messageType, TargetInfo lookTarget, string repeatAvoiderTag = null, float repeatAvoiderSeconds = 1f) { this.message = message; type = messageType; this.lookTarget = lookTarget; this.repeatAvoiderTag = repeatAvoiderTag; this.repeatAvoiderSeconds = repeatAvoiderSeconds; }
public TransitionAction_Message(string message, MessageTypeDef messageType, string repeatAvoiderTag = null, float repeatAvoiderSeconds = 1f) { this.lookTarget = TargetInfo.Invalid; base..ctor(); this.message = message; this.type = messageType; this.repeatAvoiderTag = repeatAvoiderTag; this.repeatAvoiderSeconds = repeatAvoiderSeconds; }
// Token: 0x0600007D RID: 125 RVA: 0x000068C8 File Offset: 0x00004AC8 public static void AddTrait(Pawn pawn, Trait trait, string doer, MessageTypeDef MsgType, bool SendMsg = true) { var story = pawn?.story; story?.traits.GainTrait(trait); TraitsUpdated(pawn); if (SendMsg) { Messages.Message( "MSExotic.TraitAdded".Translate(pawn?.LabelShort.CapitalizeFirst(), trait?.Label.CapitalizeFirst(), doer.CapitalizeFirst()), pawn, MsgType); } }
public static void WakePatient(Pawn patientPawn, bool wakeNormally = true) { patientPawn.health.hediffSet.hediffs.RemoveAll((Hediff x) => x.def.defName == "MedPod_InducedComa"); string corticalStimulationType = wakeNormally ? "MedPod_CorticalStimulation" : "MedPod_CorticalStimulationImproper"; string popupMessage = wakeNormally ? "MedPod_Message_TreatmentComplete".Translate(patientPawn.LabelCap, patientPawn) : "MedPod_Message_TreatmentInterrupted".Translate(patientPawn.LabelCap, patientPawn); MessageTypeDef popupMessageType = wakeNormally ? MessageTypeDefOf.PositiveEvent : MessageTypeDefOf.NegativeHealthEvent; Messages.Message(popupMessage, patientPawn, popupMessageType, true); Hediff corticalStimulation = HediffMaker.MakeHediff(HediffDef.Named(corticalStimulationType), patientPawn); patientPawn.health.AddHediff(corticalStimulation); }
private static void ConditionalMessage(string text, LookTargets lookTargets, MessageTypeDef type, bool historical = true) { if (ModSettings.notifyOnFailure) { if (ModSettings.volatile_ForceAltMessage || ModSettings.FailureMaterialReturn == 1f) { Messages.Message(text.Split(new[] { '.' })[0] + ".", lookTargets, type, historical); } else { Messages.Message(text, lookTargets, type, historical); } } }
/// <summary> Add the aspect to this pawn at the given stage. </summary> public void Add([NotNull] Aspect aspect, int startStage = 0) { if (_aspects.Contains(aspect)) { Log.Warning($"trying to add aspect {aspect.Label} to pawn more then once"); return; } if (_aspects.Count(a => a.def == aspect.def) > 0) { Log.Warning($"trying to add an aspect with def {aspect.def.defName} to pawn {Pawn.Name} which already has an aspect of that def"); return; } int?addIndex = null; for (var index = 0; index < _aspects.Count; index++) { Aspect aspect1 = _aspects[index]; if (Comparer.Compare(aspect, aspect1) <= 0) { addIndex = index; } } if (addIndex != null) { _aspects.Insert(addIndex.Value, aspect); } else { _aspects.Add(aspect); } aspect.Added(Pawn, startStage); if (aspect.HasCapMods) { Pawn?.health?.capacities?.Notify_CapacityLevelsDirty(); } AspectStage cStage = aspect.CurrentStage; AspectAdded?.Invoke(this, aspect); if (PawnUtility.ShouldSendNotificationAbout(Pawn) && !string.IsNullOrEmpty(cStage.messageText)) { MessageTypeDef mDef = cStage.messageDef ?? MessageTypeDefOf.NeutralEvent; Messages.Message(cStage.messageText.AdjustedFor(Pawn), Pawn, mDef); } }
public static QuestPart_Message Message(this Quest quest, string message, MessageTypeDef messageType = null, bool getLookTargetsFromSignal = false, RulePack rules = null, LookTargets lookTargets = null, string inSignal = null) { QuestPart_Message questPart = new QuestPart_Message(); questPart.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal) ?? QuestGen.slate.Get <string>("inSignal"); questPart.messageType = messageType ?? MessageTypeDefOf.NeutralEvent; questPart.lookTargets = lookTargets; questPart.getLookTargetsFromSignal = getLookTargetsFromSignal; QuestGen.AddTextRequest("root", delegate(string x) { questPart.message = x; }, QuestGenUtility.MergeRules(rules, message, "root")); QuestGen.quest.AddPart(questPart); return(questPart); }
// Token: 0x0600007D RID: 125 RVA: 0x000068C8 File Offset: 0x00004AC8 public static void AddTrait(Pawn pawn, Trait trait, string doer, MessageTypeDef MsgType, bool SendMsg = true) { if (pawn != null) { Pawn_StoryTracker story = pawn.story; if (story != null) { story.traits.GainTrait(trait); } } MSTraitChanger.TraitsUpdated(pawn); if (SendMsg) { Messages.Message("MSExotic.TraitAdded".Translate(pawn?.LabelShort.CapitalizeFirst(), trait?.Label.CapitalizeFirst(), doer.CapitalizeFirst()), pawn, MsgType, true); } }
// Token: 0x06000056 RID: 86 RVA: 0x0000571C File Offset: 0x0000391C public static void DoMSImmunisation(Pawn p, ThingDef t) { bool Sickly = false; MessageTypeDef MsgType = MessageTypeDefOf.PositiveEvent; TraitDef Immunity = DefDatabase <TraitDef> .GetNamed("Immunity", true); if (p.story.traits.HasTrait(Immunity) && p != null) { Pawn_StoryTracker story = p.story; int?num; if (story == null) { num = null; } else { TraitSet traits = story.traits; num = ((traits != null) ? new int?(traits.GetTrait(Immunity).Degree) : null); } int?num2 = num; int num3 = -1; if (num2.GetValueOrDefault() == num3 & num2 != null) { Sickly = true; } } if (Sickly) { Pawn_StoryTracker story2 = p.story; Trait trait; if (story2 == null) { trait = null; } else { TraitSet traits2 = story2.traits; trait = (traits2?.GetTrait(Immunity)); } Trait ToGo = trait; MSTraitChanger.RemoveTrait(p, ToGo, t.label, MsgType, true); return; } Trait ToAdd = new Trait(Immunity, 1, false); MSTraitChanger.AddTrait(p, ToAdd, t.label, MsgType, true); }
// Token: 0x06000058 RID: 88 RVA: 0x000058E0 File Offset: 0x00003AE0 public static void DoMSCerebrax(Pawn p, ThingDef t) { int degree = 0; MessageTypeDef MsgType = MessageTypeDefOf.PositiveEvent; TraitDef Psych = DefDatabase <TraitDef> .GetNamed("PsychicSensitivity", true); if (p.story.traits.HasTrait(Psych)) { degree = p.story.traits.GetTrait(Psych).Degree; } if (degree == 2) { Pawn_StoryTracker story = p.story; Trait trait; if (story == null) { trait = null; } else { TraitSet traits = story.traits; trait = (traits?.GetTrait(Psych)); } Trait ToGo = trait; MSTraitChanger.RemoveTrait(p, ToGo, t.label, MsgType, true); Trait ToAdd = new Trait(Psych, 1, false); MSTraitChanger.AddTrait(p, ToAdd, t.label, MsgType, false); return; } if (degree == 1) { Pawn_StoryTracker story2 = p.story; Trait trait2; if (story2 == null) { trait2 = null; } else { TraitSet traits2 = story2.traits; trait2 = (traits2?.GetTrait(Psych)); } Trait ToGo2 = trait2; MSTraitChanger.RemoveTrait(p, ToGo2, t.label, MsgType, true); } }
public static void DoMessage(string message, MessageTypeDef type, GlobalTargetInfo target) { if (Settings.showNotifications) { if (Settings.playSounds) { Messages.Message(message, target, type); } else { Messages.Message(message, target, MessageTypeDefOf.SilentInput); } } else if (Settings.playSounds) { type.sound.PlayOneShotOnCamera(); } }
public void OnLevelChange(string baseMessage, MessageTypeDef messageType, SkillRecord skillRecord, Pawn pawn, int level, ThingDef moteDef, float scale, float rotationRate) { if (pawn.IsFreeColonist && this.pawnSkillTimerCache.EnoughTimeHasPassed(pawn, skillRecord.def)) { var text = string.Format(baseMessage, pawn.LabelShortCap, level, skillRecord.def.LabelCap); var message = new Message(text, messageType, new LookTargets(pawn)); Messages.Message(message, false); var mote = ThingMaker.MakeThing(moteDef) as Mote; mote.Scale = scale; mote.rotationRate = rotationRate; var position = pawn.DrawPos; mote.Attach(pawn); mote.exactPosition = position; GenSpawn.Spawn(mote, position.ToIntVec3(), Find.CurrentMap); } }
bool TryEnd(QuestState state, string formatter, MessageTypeDef messageType) { if (!Started) { Log.Error("Could not set quest to " + state + " (not started): " + Name); return(false); } if (Ended) { Log.Error("Could not set quest to " + state + " (already ended): " + Name); return(false); } this.state = state; UpdateHome(); /// OnEnd(); Messages.Message(formatter.Translate().Formatted(Name), Targets, messageType); return(true); }
public override void OnSkillLearned(SkillRecord skill, Pawn pawn, int oldSkillLevel) { if (oldSkillLevel != skill.levelInt) { string text = "MessageSkillChanged".Translate(new object[] { pawn.LabelShort, ("Skill" + skill.levelInt).Translate().ToLower(), skill.levelInt, skill.def.label }); MessageTypeDef flag = oldSkillLevel < skill.levelInt ? MessageTypeDefOf.PositiveEvent : MessageTypeDefOf.NegativeEvent; Messages.Message(text.CapitalizeFirst(), new TargetInfo(pawn.Position, pawn.Map, false), flag); } progress = Math.Max(progress, skill.levelInt); if (skill.levelInt >= this.def.targetValue) { Complete(); } }
public static void PushToFile() { if (writerDisabled) { Verse.Log.Warning($"{AchievementPointManager.AchievementTag} Cannot push to file. DebugWriter is disabled. Vanilla Achievements Expanded must be downloaded and in the mod list in order to use this feature."); Verse.Log.TryOpenLogWindow(); return; } Clear(); string successMessage = "SuccessfulWriteToFile".Translate(); MessageTypeDef messageType = MessageTypeDefOf.TaskCompletion; try { File.AppendAllLines(FullPath, messageLogs); } catch (Exception ex) { successMessage = $"Failed to push logs to file. Exception: {ex.Message}"; messageType = MessageTypeDefOf.RejectInput; } Messages.Message(successMessage, messageType); }
public static bool Prefix(ref Verb_Shoot __instance) { // Log.Warning("TryCastShot"); IAdvancedVerb entry = __instance.SpecialRules(); if (entry == null) { // Log.Message("no SpecialRules detected"); return(true); } bool UserEffect = entry.EffectsUser; HediffDef UserHediff = entry.UserEffect; float AddHediffChance = entry.EffectsUserChance; List <string> Immunitylist = entry.UserEffectImmuneList; string msg = string.Format(""); float failChance = entry.FailChance(__instance.EquipmentSource, out string reliabilityString); bool failed = false; if (failChance > 0f) { if (entry.Debug) { Log.Message("failChance: " + failChance); } Rand.PushState(); failed = Rand.Chance(failChance); Rand.PopState(); if (entry.Debug) { Log.Message((entry.GetsHot ? "Overheat" : "Jam") + " Chance: " + failChance + "% Result: " + (failed ? (entry.GetsHot ? "Overheated" : "Jamed") : "Passed")); } // Log.Message("failed: "+failed); } if (failed) { bool stillFire = true; bool canDamageWeapon = entry.HotDamageWeapon || entry.JamsDamageWeapon; MessageTypeDef msgDef = entry.GetsHot ? MessageTypeDefOf.NegativeHealthEvent : MessageTypeDefOf.SilentInput; float extraWeaponDamage = entry.HotDamageWeapon ? entry.HotDamage : entry.JamDamage; if (entry.GetsHot) { string overheat = "overheated"; string causing = "causing"; DamageDef damageDef = __instance.Projectile.projectile.damageDef; HediffDef HediffToAdd = damageDef.hediff; Pawn launcherPawn = __instance.caster as Pawn; Rand.PushState(); bool crit = Rand.Chance(entry.GetsHotCritChance); Rand.PopState(); bool critExplode = false; if (crit) { overheat = "critically overheated"; if (entry.GetsHotCritExplosion) { critExplode = Rand.Chance(entry.GetsHotCritExplosionChance); if (critExplode) { causing = "causing an explosion"; CriticalOverheatExplosion(__instance); } } } float ArmorPenetration = __instance.Projectile.projectile.GetArmorPenetration(__instance.EquipmentSource, null) * (crit ? 1f : 0.25f); float DamageAmount = __instance.Projectile.projectile.GetDamageAmount(__instance.EquipmentSource, null) * (crit ? 1f : 0.25f); msg = string.Format("{0}'s {1} " + overheat + ". ({2} chance) " + causing + " {3} damage", __instance.caster.LabelCap, __instance.EquipmentSource.LabelCap, failChance.ToStringPercent(), DamageAmount); float damageLeft = DamageAmount; List <BodyPartTagDef> tagDefs = new List <BodyPartTagDef>() { BodyPartTagDefOf.ManipulationLimbDigit, BodyPartTagDefOf.ManipulationLimbSegment }; List <BodyPartRecord> list = launcherPawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Outside, tagDefs).ToList <BodyPartRecord>(); if (list.NullOrEmpty()) { list = launcherPawn.health.hediffSet.GetNotMissingParts().Where(x => x.def.defName.Contains("Arm") || x.parent.def.defName.Contains("Arm")).ToList <BodyPartRecord>(); } if (list.NullOrEmpty()) { list = launcherPawn.health.hediffSet.GetNotMissingParts().Where(x => x.def.tags.Contains(BodyPartTagDefOf.ManipulationLimbCore) || x.def.tags.Contains(BodyPartTagDefOf.ManipulationLimbSegment) || x.def.tags.Contains(BodyPartTagDefOf.ManipulationLimbDigit)).ToList <BodyPartRecord>(); } if (!list.NullOrEmpty()) { while (damageLeft > 0f && !list.NullOrEmpty()) { Rand.PushState(); BodyPartRecord part = list.RandomElement(); list.Remove(part); float maxPartDamage = Math.Min(damageLeft, launcherPawn.health.hediffSet.GetPartHealth(part)); float amount = Rand.Range(1f, Math.Min(damageLeft, maxPartDamage)); Rand.PopState(); if (amount > 0) { /* * Hediff hediff = HediffMaker.MakeHediff(HediffToAdd, launcherPawn, part); * hediff.Severity = severity; * launcherPawn.health.AddHediff(hediff, part, null); */ DamageInfo info = new DamageInfo(damageDef, amount, ArmorPenetration, -1, __instance.EquipmentSource, part, __instance.EquipmentSource.def, DamageInfo.SourceCategory.ThingOrUnknown, __instance.CurrentTarget.Thing ?? null); launcherPawn.TakeDamage(info); damageLeft -= amount; } } } else { } Messages.Message(msg, MessageTypeDefOf.NegativeHealthEvent); } if (entry.Jams) { if (!__instance.GetsHot()) { msg = string.Format("{0}'s {1} had a weapon jam. ({2} chance)", __instance.caster.LabelCap, __instance.EquipmentSource.LabelCap, failChance.ToStringPercent()); Messages.Message(msg, MessageTypeDefOf.SilentInput); } float defaultCooldownTime = __instance.verbProps.defaultCooldownTime * 2; __instance.verbProps.defaultCooldownTime = defaultCooldownTime; if (canDamageWeapon) { if (extraWeaponDamage != 0f) { if (__instance.EquipmentSource != null) { if (__instance.EquipmentSource.HitPoints - (int)extraWeaponDamage >= 0) { __instance.EquipmentSource.HitPoints = __instance.EquipmentSource.HitPoints - (int)extraWeaponDamage; } else if (__instance.EquipmentSource.HitPoints - (int)extraWeaponDamage < 0) { __instance.EquipmentSource.HitPoints = 0; __instance.EquipmentSource.Destroy(); } } if (__instance.HediffCompSource != null) { /* * if (__instance.HediffCompSource.parent.Part.HitPoints - (int)extraWeaponDamage >= 0) * { * __instance.HediffCompSource.HitPoints = __instance.HediffCompSource.HitPoints - (int)extraWeaponDamage; * } * else if (__instance.HediffCompSource.HitPoints - (int)extraWeaponDamage < 0) * { * __instance.HediffCompSource.HitPoints = 0; * __instance.HediffCompSource.Destroy(); * } */ } } else { if (__instance.EquipmentSource != null) { if (__instance.EquipmentSource.HitPoints > 0) { __instance.EquipmentSource.HitPoints--; } } } } if (__instance.EquipmentSource != null) { SpinningLaserGun spinner = __instance.EquipmentSource as SpinningLaserGun; if (spinner != null) { spinner.state = SpinningLaserGunBase.State.Idle; spinner.ReachRotationSpeed(0, 0); } } return(false); } } if (__instance.UserEffect(out float Chance, out HediffDef Effect, out StatDef ResistStat, out List <string> ImmuneList)) { bool Immunityflag = false; Pawn launcherPawn = __instance.caster as Pawn; if (!Immunitylist.NullOrEmpty()) { foreach (var item in Immunitylist) { Immunityflag = launcherPawn.def.defName.Contains(item); if (Immunityflag) { // Log.Message(string.Format("{0} is immune to their {1}'s UseEffect", launcherPawn.LabelShortCap, __instance.EquipmentSource.LabelShortCap)); } } /* * List<string> list = GunExt.UserEffectImmuneList.Where(x => DefDatabase<ThingDef>.GetNamedSilentFail(x) != null).ToList(); * bool Immunityflag = list.Contains(launcherPawn.def.defName); * if (Immunityflag) * { * return; * } */ } if (!Immunityflag) { Rand.PushState(); var rand = Rand.Value; // This is a random percentage between 0% and 100% Rand.PopState(); // Log.Message(string.Format("GunExt.EffectsUser Effect: {0}, Chance: {1}, Roll: {2}, Result: {3}" + GunExt.ResistEffectStat != null ? ", Resist Stat: "+GunExt.ResistEffectStat.LabelCap+", Resist Amount"+ __instance.caster.GetStatValue(GunExt.ResistEffectStat, true) : null, GunExt.UserEffect.LabelCap, AddHediffChance, rand, rand <= AddHediffChance)); if (rand <= AddHediffChance) // If the percentage falls under the chance, success! { Rand.PushState(); var randomSeverity = Rand.Range(0.05f, 0.15f); Rand.PopState(); var effectOnPawn = launcherPawn?.health?.hediffSet?.GetFirstHediffOfDef(UserHediff); if (effectOnPawn != null) { effectOnPawn.Severity += randomSeverity; } else { Hediff hediff = HediffMaker.MakeHediff(UserHediff, launcherPawn, null); hediff.Severity = randomSeverity; launcherPawn.health.AddHediff(hediff, null, null); } } } } return(true); }
public virtual bool CheckFail(ref Verb_Shoot __instance) { string msg = string.Format(""); Thing gun = __instance.EquipmentSource; bool failed = false; float failChance = FailChance(gun, out string reliabilityString); if (failChance > 0f) { Rand.PushState(); failed = Rand.Chance(failChance); Rand.PopState(); if (Debug) { Log.Message((GetsHot ? "Overheat" : "Jam") + " Chance: " + failChance + "% Result: " + (failed ? (GetsHot ? "Overheated" : "Jamed") : "Passed")); } } if (failed) { bool stillFire = true; bool canDamageWeapon = HotDamageWeapon || JamsDamageWeapon; MessageTypeDef msgDef = GetsHot ? MessageTypeDefOf.NegativeHealthEvent : MessageTypeDefOf.SilentInput; float extraWeaponDamage = HotDamageWeapon ? HotDamage : JamDamage; if (GetsHot) { string overheat = "overheated"; string causing = "causing"; DamageDef damageDef = __instance.Projectile.projectile.damageDef; HediffDef HediffToAdd = damageDef.hediff; Pawn launcherPawn = __instance.caster as Pawn; Rand.PushState(); bool crit = Rand.Chance(GetsHotCritChance); Rand.PopState(); bool critExplode = false; if (crit) { overheat = "critically overheated"; if (GetsHotCritExplosion) { critExplode = Rand.Chance(GetsHotCritExplosionChance); if (critExplode) { causing = "causing an explosion"; CriticalOverheatExplosion(__instance); } } } float ArmorPenetration = __instance.Projectile.projectile.GetArmorPenetration(__instance.EquipmentSource, null) * (crit ? 1f : 0.25f); float DamageAmount = __instance.Projectile.projectile.GetDamageAmount(__instance.EquipmentSource, null) * (crit ? 1f : 0.25f); msg = string.Format("{0}'s {1} " + overheat + ". ({2} chance) " + causing + " {3} damage", __instance.caster.LabelCap, __instance.EquipmentSource.LabelCap, failChance.ToStringPercent(), DamageAmount); float damageLeft = DamageAmount; List <BodyPartTagDef> tagDefs = new List <BodyPartTagDef>() { BodyPartTagDefOf.ManipulationLimbDigit, BodyPartTagDefOf.ManipulationLimbSegment }; List <BodyPartRecord> list = launcherPawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Outside, tagDefs).ToList <BodyPartRecord>(); if (!list.NullOrEmpty()) { while (damageLeft > 0f && !list.NullOrEmpty()) { Rand.PushState(); BodyPartRecord part = list.RandomElement(); list.Remove(part); float maxPartDamage = Math.Min(damageLeft, launcherPawn.health.hediffSet.GetPartHealth(part)); float amount = Rand.Range(1f, Math.Min(damageLeft, maxPartDamage)); Rand.PopState(); if (amount > 0) { /* * Hediff hediff = HediffMaker.MakeHediff(HediffToAdd, launcherPawn, part); * hediff.Severity = severity; * launcherPawn.health.AddHediff(hediff, part, null); */ DamageInfo info = new DamageInfo(damageDef, amount, ArmorPenetration, -1, __instance.EquipmentSource, part, __instance.EquipmentSource.def, DamageInfo.SourceCategory.ThingOrUnknown, __instance.CurrentTarget.Thing ?? null); launcherPawn.TakeDamage(info); damageLeft -= amount; } } } } if (Jams) { if (!__instance.GetsHot()) { msg = string.Format("{0}'s {1} had a weapon jam. ({2} chance)", __instance.caster.LabelCap, __instance.EquipmentSource.LabelCap, failChance.ToStringPercent()); } float defaultCooldownTime = __instance.verbProps.defaultCooldownTime * 2; __instance.verbProps.defaultCooldownTime = defaultCooldownTime; if (canDamageWeapon) { if (extraWeaponDamage != 0f) { if (__instance.EquipmentSource != null) { if (__instance.EquipmentSource.HitPoints - (int)extraWeaponDamage >= 0) { __instance.EquipmentSource.HitPoints = __instance.EquipmentSource.HitPoints - (int)extraWeaponDamage; } else if (__instance.EquipmentSource.HitPoints - (int)extraWeaponDamage < 0) { __instance.EquipmentSource.HitPoints = 0; __instance.EquipmentSource.Destroy(); } } if (__instance.HediffCompSource != null) { /* * if (__instance.HediffCompSource.parent.Part.HitPoints - (int)extraWeaponDamage >= 0) * { * __instance.HediffCompSource.HitPoints = __instance.HediffCompSource.HitPoints - (int)extraWeaponDamage; * } * else if (__instance.HediffCompSource.HitPoints - (int)extraWeaponDamage < 0) * { * __instance.HediffCompSource.HitPoints = 0; * __instance.HediffCompSource.Destroy(); * } */ } } else { if (__instance.EquipmentSource != null) { if (__instance.EquipmentSource.HitPoints > 0) { __instance.EquipmentSource.HitPoints--; } } } } if (__instance.EquipmentSource != null) { SpinningLaserGun spinner = __instance.EquipmentSource as SpinningLaserGun; if (spinner != null) { spinner.state = SpinningLaserGunBase.State.Idle; spinner.ReachRotationSpeed(0, 0); } } } Messages.Message(msg, msgDef); } return(failed); }
public static void Message(string str, MessageTypeDef type) { Messages.Message(str, type, RuntimeGC.Settings.ArchiveMessageGeneral); }
public static void DoMessage(string message, MessageTypeDef type) { DoMessage(message, type, TargetInfo.Invalid); }
public ActivationResult(string message, MessageTypeDef messageType) { Message = message; MessageType = messageType; }
public MessageResult(string message, MessageTypeDef type) { this.message = message; this.type = type; }
public static DamageInfo GetForceDamage(DamageInfo cloneSource, Pawn Caster, Thing target) { if (Caster != null) { if (Caster.isPsyker(out int Level, out float Mult)) { // log.message(Caster.NameShortColored + " Level " + Level + " Mult " + Mult); if (cloneSource.Weapon != null) { Thing Weapon = null; if (cloneSource.Weapon.IsWeapon) { foreach (var item in Caster.equipment.AllEquipmentListForReading) { if (item.def == cloneSource.Weapon) { Weapon = item; } } } else if (cloneSource.Weapon.IsApparel) { foreach (var item in Caster.apparel.WornApparel) { if (item.def == cloneSource.Weapon) { Weapon = item; } } } if (Weapon != null) { Weapon = Caster.equipment.Primary; } CompWeapon_MeleeSpecialRules WeaponRules = Weapon.TryGetCompFast <CompWeapon_MeleeSpecialRules>(); CompForceWeaponActivatableEffect compForce = Weapon.TryGetCompFast <CompForceWeaponActivatableEffect>(); if (WeaponRules != null || compForce != null) { if (WeaponRules?.ForceWeapon ?? compForce != null) { bool requiresPsyker = WeaponRules?.ForceEffectRequiresPsyker ?? compForce.ForceEffectRequiresPsyker; bool casterPsychiclySensitive = Caster.RaceProps.Humanlike && (Caster.story.traits.HasTrait(TraitDefOf.PsychicSensitivity) || Caster.story.traits.HasTrait(DefDatabase <TraitDef> .GetNamedSilentFail("Psyker"))); bool Activate = false; if ((casterPsychiclySensitive || !requiresPsyker) && target.def.category == ThingCategory.Pawn && target is Pawn Victim) { int casterPsychiclySensitiveDegree = casterPsychiclySensitive ? Caster.story.traits.DegreeOfTrait(TraitDefOf.PsychicSensitivity) : 0; if ((casterPsychiclySensitiveDegree >= 1 || !requiresPsyker)) { float?casterPsychicSensitivity = Caster.GetStatValue(StatDefOf.PsychicSensitivity, true) * 100f; bool targetPsychiclySensitive = Victim.RaceProps.Humanlike && Victim.story.traits.HasTrait(TraitDefOf.PsychicSensitivity); float?targetPsychicSensitivity = Victim.GetStatValue(StatDefOf.PsychicSensitivity, true) * 100f; if (targetPsychiclySensitive == true) { int targetPsychiclySensitiveDegree = Victim.story.traits.DegreeOfTrait(TraitDefOf.PsychicSensitivity); if (targetPsychiclySensitiveDegree == -1) { targetPsychicSensitivity = Victim.def.statBases.GetStatValueFromList(StatDefOf.PsychicSensitivity, 1.5f) * 100f; } else if (targetPsychiclySensitiveDegree == -2) { targetPsychicSensitivity = Victim.def.statBases.GetStatValueFromList(StatDefOf.PsychicSensitivity, 2f) * 100f; } } else /*int targetPsychiclySensitiveDegree = 0;*/ } { { float CasterMood = Caster.needs.mood.CurLevelPercentage; float VictimMood = Victim?.needs?.mood != null ? Victim.needs.mood.CurLevelPercentage : 1; Rand.PushState(); float?casterRoll = Rand.Range(0, (int)casterPsychicSensitivity) * CasterMood; float?targetRoll = Rand.Range(0, (int)targetPsychicSensitivity) * VictimMood; Rand.PopState(); casterRoll = (casterRoll - (targetPsychicSensitivity / 2)); Activate = (casterRoll > targetRoll); // log.message(string.Format("Caster:{0}, Victim:{1}", casterRoll, targetRoll)); if (Activate) { DamageDef damDef = WeaponRules?.ForceWeaponEffect ?? compForce.ForceWeaponEffect; float damAmount = cloneSource.Amount; float armorPenetration = cloneSource.ArmorPenetrationInt; Rand.PushState(); BodyPartRecord bodyPart = Rand.Chance(0.05f) && Victim.RaceProps.body.AllParts.Any(x => x.def.defName.Contains("Brain")) ? Victim.RaceProps.body.AllParts.Find(x => x.def.defName.Contains("Brain")) : null; Rand.PopState(); BodyPartGroupDef bodyPartGroupDef = null; HediffDef hediffDef = WeaponRules?.ForceWeaponHediff ?? compForce.ForceWeaponHediff; damAmount = Rand.Range(damAmount * 0.1f, damAmount * 0.5f); ThingDef source = cloneSource.Weapon; Thing caster = Caster; Vector3 direction = (target.Position - Caster.Position).ToVector3(); float num = damAmount; DamageInfo mainDinfo = new DamageInfo(damDef, num, 2, -1f, caster, bodyPart, source, DamageInfo.SourceCategory.ThingOrUnknown, null); mainDinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); mainDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef); mainDinfo.SetWeaponHediff(hediffDef); mainDinfo.SetAngle(direction); Victim.TakeDamage(mainDinfo); Map map = Caster.Map; IntVec3 position = target.Position; Map map2 = map; float explosionRadius = 0f; Thing launcher = Weapon; SoundDef soundExplode = WeaponRules?.ForceWeaponTriggerSound ?? compForce.ForceWeaponTriggerSound; Thing thing = target; GenExplosion.DoExplosion(position, map2, explosionRadius, damDef, launcher, (int)damAmount, armorPenetration, soundExplode, source, null, thing, null, 0f, 0, false, null, 0, 0, 0, false); TaggedString msg = "AdeptusMechanicus.ForceStrike"; MessageTypeDef typeDef = MessageTypeDefOf.NegativeHealthEvent; float KillChance = WeaponRules?.ForceWeaponKillChance ?? compForce.ForceWeaponKillChance; if (KillChance != 0) { Rand.PushState(); float KillRoll = Rand.Range(0, 100); if (Rand.Chance(KillChance)) { typeDef = MessageTypeDefOf.PawnDeath; } Rand.PopState(); } if (typeDef == MessageTypeDefOf.PawnDeath) { Victim.Kill(mainDinfo); } if (Victim.Faction == Faction.OfPlayer) { Messages.Message(string.Format("AdeptusMechanicus.Force_Strike ".Translate(), Victim.Name, typeDef == MessageTypeDefOf.PawnDeath ? "slain" : "blasted"), typeDef); } return(mainDinfo); } } } } } } } } } return(cloneSource); }