public PlayLogEntry_InteractionConversation(InteractionDef intDef, Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks) : base(intDef, initiator, recipient, extraSentencePacks) { FieldInfo RuleStrings = typeof(RulePack).GetField("rulesStrings", BindingFlags.Instance | BindingFlags.NonPublic); this.rulesInit = (List <string>)RuleStrings.GetValue(intDef.logRulesInitiator); this.rulesRecip = (List <string>)RuleStrings.GetValue(intDef.logRulesRecipient); }
public Toil TryRecruitGuest(Pawn recruiter, Pawn guest) { var toil = new Toil { initAction = () => { if (!recruiter.ShouldRecruit(guest)) { return; } if (!recruiter.CanTalkTo(guest)) { return; } InteractionDef intDef = DefDatabase <InteractionDef> .GetNamed("CharmGuestAttempt"); recruiter.interactions.TryInteractWith(guest, intDef); var success = guest.CheckRecruitingSuccessful(recruiter); }, socialMode = RandomSocialMode.Off, defaultCompleteMode = ToilCompleteMode.Delay, defaultDuration = 350 }; toil.AddFailCondition(FailCondition); return(toil); }
public Toil TryImproveRelationship(Pawn recruiter, Pawn guest) { var toil = new Toil { initAction = () => { if (!recruiter.ShouldImproveRelationship(guest)) { return; } if (!recruiter.CanTalkTo(guest)) { return; } InteractionDef intDef = DefDatabase <InteractionDef> .GetNamed("GuestDiplomacy"); recruiter.interactions.TryInteractWith(guest, intDef); }, socialMode = RandomSocialMode.Off, defaultCompleteMode = ToilCompleteMode.Delay, defaultDuration = 350 }; toil.AddFailCondition(FailCondition); return(toil); }
public PlayLogEntry_Interaction(InteractionDef intDef, Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks) : base(null) { this.intDef = intDef; this.initiator = initiator; this.recipient = recipient; this.extraSentencePacks = extraSentencePacks; }
public void Clear() { def = null; targetA = LocalTargetInfo.Invalid; targetB = LocalTargetInfo.Invalid; targetC = LocalTargetInfo.Invalid; targetQueueA = null; targetQueueB = null; count = -1; countQueue = null; loadID = -1; startTick = -1; expiryInterval = -1; checkOverrideOnExpire = false; playerForced = false; placedThings = null; maxNumMeleeAttacks = int.MaxValue; maxNumStaticAttacks = int.MaxValue; locomotionUrgency = LocomotionUrgency.Jog; haulMode = HaulMode.Undefined; bill = null; commTarget = null; plantDefToSow = null; verbToUse = null; haulOpportunisticDuplicates = false; exitMapOnArrival = false; failIfCantJoinOrCreateCaravan = false; killIncappedTarget = false; ignoreForbidden = false; ignoreDesignations = false; canBash = false; canUseRangedWeapon = true; haulDroppedApparel = false; restUntilHealed = false; ignoreJoyTimeAssignment = false; doUntilGatheringEnded = false; overeat = false; attackDoorIfTargetLost = false; takeExtraIngestibles = 0; expireRequiresEnemiesNearby = false; lord = null; collideWithPawns = false; forceSleep = false; interaction = null; endIfCantShootTargetFromCurPos = false; endIfCantShootInMelee = false; checkEncumbrance = false; followRadius = 0f; endAfterTendedOnce = false; quest = null; mote = null; jobGiverThinkTree = null; jobGiver = null; workGiverDef = null; if (cachedDriver != null) { cachedDriver.job = null; } cachedDriver = null; }
/// <summary> /// Notify that the subject pawn has just socially interacted with the other pawn. /// <para/> /// Not to confuse with Notify... /// </summary> /// <param name="interactionDef"></param> public void Notify_SociallyInteractedRecently(InteractionDef interactionDef) { approxTicksSinceLastInteracted = 0; lastKnownInteraction = interactionDef; UpdateLastKnownOpinion(); LastKnownLifeState = PawnLifeState.ALIVE; }
static void AddInteractionThoughts([NotNull] Pawn recipient, [NotNull] InteractionDef intDef, bool __result) { if (!__result) { return; } if ((recipient.IsFormerHuman() || recipient.GetSapienceState()?.StateDef == SapienceStateDefOf.Animalistic) && recipient.needs?.mood != null) { var memory = intDef.GetModExtension <InstinctEffector>()?.thought; //hacky, should come up with a better solution eventually if (memory == null) { return; } if (DebugLogUtils.ShouldLog(LogLevel.Messages)) { var msg = $"giving {recipient.Name} memory {memory.defName}"; Log.Message(msg); } //social thoughts to? recipient.TryGainMemory(memory); } }
public void Notify_SubjectSociallyInteractedWithAnotherPawn(Pawn other, InteractionDef intDef) { if (CanAcceptOtherPawn(other)) { GetFriendshipMemoryForOther(other, true).Notify_SociallyInteractedRecently(intDef); } }
static void Postfix(Pawn_InteractionsTracker __instance, Pawn recipient, InteractionDef intDef) { // pawn is a private field, so we have to use reflection to access it. Pawn pawn = AccessTools.Field(__instance.GetType(), "pawn").GetValue(__instance) as Pawn; // bail if one of the pawns doesn't have any skills. if (pawn.skills == null || recipient.skills == null) { return; } if (pawn?.story?.traits?.HasTrait(GMT_DefOf.GMT_Teacher) ?? false) { // Make 2 attempts to teach a skill. Broad base of skills => better chance of teaching. for (int i = 0; i < 2; ++i) { SkillDef random = DefDatabase <SkillDef> .AllDefsListForReading.RandomElement <SkillDef>(); int diff = pawn.skills.GetSkill(random).Level - recipient.skills.GetSkill(random).Level; if (diff > 0) { recipient.skills.GetSkill(random).Learn(diff * GMT_Teacher_Helper.teacher_xp_per_level_difference * GMT_Teacher_Helper.teaching_factors.TryGetValue(intDef, 1.0f)); break; } } } }
public static void Prefix(Pawn recipient, ref InteractionDef intDef) { if (intDef == InteractionDefOf.Chitchat) { // Log.Warning($"replacing {intDef}"); intDef = TalkDefOf.Test; } }
public SavedJob(Job job) { def = job.def; targetA = job.targetA; targetB = job.targetB; targetC = job.targetC; targetQueueA = job.targetQueueA; targetQueueB = job.targetQueueB; count = job.count; countQueue = job.countQueue; startTick = job.startTick; expiryInterval = job.expiryInterval; checkOverrideOnExpire = job.checkOverrideOnExpire; playerForced = job.playerForced; placedThings = job.placedThings; maxNumMeleeAttacks = job.maxNumMeleeAttacks; maxNumStaticAttacks = job.maxNumStaticAttacks; locomotionUrgency = job.locomotionUrgency; haulMode = job.haulMode; bill = job.bill; commTarget = job.commTarget; plantDefToSow = job.plantDefToSow; verbToUse = job.verbToUse; haulOpportunisticDuplicates = job.haulOpportunisticDuplicates; exitMapOnArrival = job.exitMapOnArrival; failIfCantJoinOrCreateCaravan = job.failIfCantJoinOrCreateCaravan; killIncappedTarget = job.killIncappedTarget; ignoreForbidden = job.ignoreForbidden; ignoreDesignations = job.ignoreDesignations; canBash = job.canBash; canUseRangedWeapon = job.canUseRangedWeapon; haulDroppedApparel = job.haulDroppedApparel; restUntilHealed = job.restUntilHealed; ignoreJoyTimeAssignment = job.ignoreJoyTimeAssignment; doUntilGatheringEnded = job.doUntilGatheringEnded; overeat = job.overeat; attackDoorIfTargetLost = job.attackDoorIfTargetLost; takeExtraIngestibles = job.takeExtraIngestibles; expireRequiresEnemiesNearby = job.expireRequiresEnemiesNearby; lord = job.lord; collideWithPawns = job.collideWithPawns; forceSleep = job.forceSleep; interaction = job.interaction; endIfCantShootTargetFromCurPos = job.endIfCantShootTargetFromCurPos; endIfCantShootInMelee = job.endIfCantShootInMelee; checkEncumbrance = job.checkEncumbrance; followRadius = job.followRadius; endAfterTendedOnce = job.endAfterTendedOnce; quest = job.quest; mote = job.mote; reactingToMeleeThreat = job.reactingToMeleeThreat; wasOnMeditationTimeAssignment = job.wasOnMeditationTimeAssignment; psyfocusTargetLast = job.psyfocusTargetLast; //jobGiverThinkTree = job.jobGiverThinkTree; //jobGiver = job.jobGiver; workGiverDef = job.workGiverDef; ability = job.ability; }
public void MakeReply(InteractionDef intDef) { var time = GenTicks.TicksGame + interval; expireTick = time + 1; latestReplyCount += 1; SwapRoles(); DialogManager.Scheduled.Add(new Statement(Initiator, Recipient, time, intDef, this, latestReplyCount)); }
public Statement(Pawn emitter, Pawn recipient, int timing, InteractionDef intDef, Talk talk, int iteration) { Emitter = emitter; Reciever = recipient; Timing = timing; IntDef = intDef; Talk = talk; Iteration = iteration; }
public static bool Listener(Pawn recipient, InteractionDef intDef, Pawn ___pawn, ref bool __result) { if ((___pawn.IsBasicAndroidTier() || recipient.IsBasicAndroidTier()) && Utils.IgnoredInteractionsByBasicAndroids.Contains(intDef.defName)) { __result = false; return(false); } return(true); }
public static void Postfix(ref bool __result, Pawn pawn, InteractionDef interactionDef = null) { if (!__result) { return; } if (PeacekeeperUtility.IsPeacekeeper(pawn)) { __result = false; } }
static bool SubstituteInteraction(Pawn recipient, ref InteractionDef intDef, Pawn ___pawn) { var ext = intDef.GetModExtension <InteractionGroupExtension>(); InteractionDef alt = ext?.TryGetAlternativeFor(___pawn, recipient); if (alt != null) { intDef = alt; } return(true); }
public static void UseInteractive(InteractionDef interaction) { var ui = FindObjectOfType <UIVisual>(); var character = ui.Character; var targetCtx = new ScriptingContext() { ProcessingEntity = character, Host = ((NetworkEntity)ui.Interactive).Id }; if (interaction.Predicate.Def == null || interaction.Predicate.Def.Check(targetCtx)) { ((IImpactedEntity)character).RunImpact(null, interaction.Impact.Def); } }
protected Toil Interact(Pawn talkee, InteractionDef intDef, int duration) { var toil = new Toil { initAction = () => { PawnUtility.ForceWait(talkee, duration, pawn); TargetThingB = pawn; MoteMaker.MakeInteractionBubble(pawn, talkee, intDef.interactionMote, intDef.Symbol); }, socialMode = RandomSocialMode.Normal, defaultCompleteMode = ToilCompleteMode.Delay, defaultDuration = duration }; return(toil.WithProgressBarToilDelay(TargetIndex.B)); }
public void Reply() { if (remainingReplies > 0) { InteractionDef intDef = DefDatabase <InteractionDef> .GetNamed(Tag); if (intDef != null) { MakeReply(intDef); } else { Log.Warning($"[SpeakUp] {Initiator} talked about {Tag}, but there isn't an appropriate interactionDef to respond."); } } }
static void AddInteractionThoughts([NotNull] Pawn recipient, [NotNull] InteractionDef intDef, bool __result) { if (!__result) { return; } if ((recipient.IsFormerHuman() || recipient.GetSapienceState()?.StateDef == SapienceStateDefOf.Animalistic) && recipient.needs?.mood != null) { var memory = intDef.GetModExtension <InstinctEffector>()?.thought; //hacky, should come up with a better solution eventually if (memory == null) { return; } //social thoughts to? recipient.TryGainMemory(memory); } }
static void AddInteractionThoughts([NotNull] Pawn recipient, [NotNull] InteractionDef intDef, bool __result) { if (!__result) { return; } if (recipient.IsSapientOrFeralFormerHuman()) { var memory = intDef.GetModExtension <InstinctEffector>()?.thought; //hacky, should come up with a better solution eventually if (memory == null) { return; } //social thoughts to? recipient.TryGainMemory(memory); } }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOn(() => !Baby.InBed() || !Baby.Awake()); if (Chair != null) { this.FailOnDespawnedNullOrForbidden(TargetIndex.B); } yield return(Toils_Reserve.Reserve(TargetIndex.A)); if (Chair != null) { yield return(Toils_Reserve.Reserve(TargetIndex.B)); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.OnCell)); } else { yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); } yield return(Toils_Interpersonal.WaitToBeAbleToInteract(pawn)); yield return(new Toil { tickAction = delegate { Baby.needs.joy.GainJoy(job.def.joyGainRate * 0.000144f, job.def.joyKind); if (pawn.IsHashIntervalTick(320)) { InteractionDef intDef = (Rand.Value >= 0.8f) ? InteractionDefOf.DeepTalk : InteractionDefOf.Chitchat; pawn.interactions.TryInteractWith(Baby, intDef); } pawn.rotationTracker.FaceCell(Baby.Position); pawn.GainComfortFromCellIfPossible(); JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.None); if (pawn.needs.joy.CurLevelPercentage > 0.9999f && Baby.needs.joy.CurLevelPercentage > 0.9999f) { pawn.jobs.EndCurrentJob(JobCondition.Succeeded); } }, socialMode = RandomSocialMode.Off, defaultCompleteMode = ToilCompleteMode.Delay, defaultDuration = job.def.joyDuration }); }
static void Postfix(Pawn_InteractionsTracker __instance, Pawn recipient, InteractionDef intDef) { // pawn is a private field, so we have to use reflection to access it. Pawn pawn = AccessTools.Field(__instance.GetType(), "pawn").GetValue(__instance) as Pawn; if (pawn?.story?.traits?.HasTrait(GMT_DefOf.GMT_Boring) ?? false) { // Boring pawns don't find each other boring if (recipient?.story?.traits?.HasTrait(GMT_DefOf.GMT_Boring) ?? false) { return; } Hediff hediff = HediffMaker.MakeHediff(GMT_DefOf.GMT_Hediff_Bored, recipient); hediff.Severity = GMT_Boring_Helper.boring_severity * GMT_Boring_Helper.bored_factors.TryGetValue(intDef, 1.0f); recipient.health.AddHediff(hediff); } }
static bool SubstituteInteraction(Pawn recipient, ref InteractionDef intDef, Pawn ___pawn) { var ext = intDef.GetModExtension <InteractionGroupExtension>(); InteractionDef alt = ext?.TryGetAlternativeFor(___pawn, recipient); if (alt != null) { if (DebugLogUtils.ShouldLog(LogLevel.Messages)) { var msg = $"substituting {alt.defName} for {intDef.defName} on {___pawn.Name} -> {recipient.Name}"; Log.Message(msg); } intDef = alt; } return(true); }
public override void ExposeData() { base.ExposeData(); for (int i = 0; i < rulesInit.Capacity; i++) { if (i + 1 > this.rulesInit.Count) { this.rulesInit.Add("r_logentry->" + "ConversationEnd".Translate() + " [RECIPIENT_nameDef]."); } string ruleText = this.rulesInit[i]; Scribe_Values.Look(ref ruleText, "rulesInit" + i, "r_logentry->" + "ConversationEnd".Translate()); this.rulesInit[i] = ruleText; } /*for (int i = 0; i < rulesRecip.Capacity; i++) * { * if (i+1 > this.rulesRecip.Count) * { * this.rulesRecip.Add("logentry->" + "ConversationEnd".Translate() + " [other_nameShortIndef]."); * } * string ruleText = this.rulesRecip[i]; * Scribe_Values.Look(ref ruleText, "rulesRecip" + i, "logentry->" + "ConversationEnd".Translate() + " [other_nameShortIndef]."); * this.rulesRecip[i] = ruleText; * }*/ FieldInfo IntDef = typeof(PlayLogEntry_Interaction).GetField("intDef", BindingFlags.Instance | BindingFlags.NonPublic); InteractionDef newIntDef = new InteractionDef(); newIntDef.defName = "EndConversation"; FieldInfo Symbol = typeof(InteractionDef).GetField("symbol", BindingFlags.Instance | BindingFlags.NonPublic); Symbol.SetValue(newIntDef, Symbol.GetValue(InteractionDefOfPsychology.EndConversation)); newIntDef.label = "ConversationEnded".Translate(); FieldInfo RuleStrings = typeof(RulePack).GetField("rulesStrings", BindingFlags.Instance | BindingFlags.NonPublic); RulePack initPack = new RulePack(); RuleStrings.SetValue(initPack, this.rulesInit); newIntDef.logRulesInitiator = initPack; /*RulePack recipPack = new RulePack(); * RuleStrings.SetValue(recipPack, this.rulesRecip); * newIntDef.logRulesRecipient = recipPack;*/ IntDef.SetValue(this, newIntDef); }
public void MakeReply(InteractionDef intDef, bool swap = true) { var time = GenTicks.TicksGame + interval; if (swap) { SwapRoles(); } expireTick = time + 1; latestReplyCount += 1; if (Scheduled.Any(x => x.Emitter == nextInitiator && x.IntDef == intDef && x.Iteration == latestReplyCount)) { var talks = Scheduled.Select(x => x.Talk).Distinct().Where(y => y.nextInitiator == nextInitiator || y.nextRecipient == nextInitiator).Count(); Log.Error($"[SpeakUp] {nextInitiator} tried to repeat a reply for {intDef} while talking to {nextRecipient}.\n" + $"{nextInitiator} is participating in {talks} current talks"); return; } Scheduled.Add(new Statement(nextInitiator, nextRecipient, time, intDef, this, latestReplyCount)); }
Toil TryRecruit(TargetIndex recruiteeInd) { Toil toil = new Toil(); toil.initAction = (Action)(() => { Pawn actor = toil.actor; Pawn thing = (Pawn)actor.jobs.curJob.GetTarget(recruiteeInd).Thing; if (!thing.Spawned || !thing.Awake()) { return; } InteractionDef intDef = PMInteractionDefOf.FormerHumanTameAttempt; actor.interactions.TryInteractWith(thing, intDef); }); toil.socialMode = RandomSocialMode.Off; toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = 350; return(toil); }
private Toil BreakResistance(TargetIndex recruiteeInd) { Toil toil = new Toil(); toil.AddFinishAction(delegate { Pawn actor = toil.actor; Pawn pawn = (Pawn)actor.jobs.curJob.GetTarget(recruiteeInd).Thing; if (pawn.Spawned)// && pawn.Awake()) { InteractionDef intDef = BeatPrisonersDefOf.CM_Beat_Prisoners_Interaction_Prisoner_Beating_Conclusion; actor.interactions.TryInteractWith(pawn, intDef); } }); toil.socialMode = RandomSocialMode.Off; toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = 175; toil.activeSkill = () => SkillDefOf.Social; return(toil); }
public static void TryWorshipInteraction(Pawn preacher, Pawn recipient, InteractionDef intDef) { if (preacher == recipient) { Log.Warning(preacher + " tried to interact with self, interaction=" + intDef.defName); return; } //if (!tracker.CanInteractNowWith(recipient)) // return false; var extraSentencePacks = new List <RulePackDef>(); //if (intDef.initiatorThought != null) // Pawn_InteractionsTracker.AddInteractionThought(preacher, recipient, intDef.initiatorThought); //if (intDef.recipientThought != null && recipient.needs.mood != null) // Pawn_InteractionsTracker.AddInteractionThought(recipient, preacher, intDef.recipientThought); //if (intDef.initiatorXpGainSkill != null) // preacher.skills.Learn(intDef.initiatorXpGainSkill, (float)intDef.initiatorXpGainAmount, false); //if (intDef.recipientXpGainSkill != null && recipient.RaceProps.Humanlike) // recipient.skills.Learn(intDef.recipientXpGainSkill, (float)intDef.recipientXpGainAmount, false); var flag = false; if (recipient.RaceProps.Humanlike) { flag = recipient.interactions.CheckSocialFightStart(intDef, preacher); } if (!flag) { intDef.Worker.Interacted(preacher, recipient, extraSentencePacks, out _, out _, out _, out _); } MoteMaker.MakeInteractionBubble(preacher, recipient, intDef.interactionMote, intDef.Symbol); if (flag) { extraSentencePacks.Add(RulePackDefOf.Sentence_SocialFightStarted); } var entryInteraction = new PlayLogEntry_Interaction(intDef, preacher, recipient, extraSentencePacks); Find.PlayLog.Add(entryInteraction); }
private static void Postfix(bool __result, Pawn ___pawn, Pawn recipient, InteractionDef intDef) { if (__result) { if (intDef == InteractionDefOf.Insult) { if (Rand.Chance(0.1f)) { TaleRecorder.RecordTale(VSIE_DefOf.VSIE_InsultedMe, recipient, ___pawn); } } else if (intDef == InteractionDefOf.Chitchat || intDef == InteractionDefOf.DeepTalk) { if (Rand.Chance(0.1f)) { TaleRecorder.RecordTale(VSIE_DefOf.VSIE_WeHadNiceChat, recipient, ___pawn); TaleRecorder.RecordTale(VSIE_DefOf.VSIE_WeHadNiceChat, ___pawn, recipient); } } } }