bonus mood, thinknode AI

This commit is contained in:
c0ffeeeeeeee 2020-11-05 22:03:16 -08:00
parent 1b49e235cf
commit da8939c4b8
9 changed files with 95 additions and 9 deletions

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<ThinkTreeDef>
<defName>FapWithToyTree</defName>
<insertTag>Humanlike_PostMentalState</insertTag>
<insertPriority>12</insertPriority> <!--A little lower than regular fap-->
<thinkRoot Class="ThinkNode_Priority">
<subNodes>
<li Class="rjw.ThinkNode_ConditionalSexChecks">
<subNodes>
<li Class="rjw.ThinkNode_ChancePerHour_Fappin">
<subNodes>
<li Class="RJW_ToysAndMasturbation.JobGiver_MasturbateWithToy"/>
</subNodes>
</li>
</subNodes>
</li>
</subNodes>
</thinkRoot>
</ThinkTreeDef>
</Defs>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<ThoughtDef>
<defName>UsedSexToy</defName>
<thoughtClass>Thought_Memory</thoughtClass>
<durationDays>1.0</durationDays>
<stackLimit>3</stackLimit>
<stackedEffectMultiplier>0.2</stackedEffectMultiplier>
<stages>
<li>
<label>Masturbated with toy</label>
<description>A step above just using your hand.</description>
<baseMoodEffect>4</baseMoodEffect>
</li>
</stages>
</ThoughtDef>
</Defs>

View File

@ -72,6 +72,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="Defs\JobDefs\Jobs_MasturbateToy.xml" />
<Content Include="Defs\ThinkTreeDefs\ThinkTrees_Masturbate.xml" />
<Content Include="Defs\ThoughtDefs\Thoughts_SexToy.xml" />
<Content Include="Patches\HumpshroomPatch.xml" />
<Content Include="Defs\ThingDefs\SexToys.xml" />
</ItemGroup>

View File

@ -13,6 +13,8 @@ namespace RJW_ToysAndMasturbation {
public static JobDef MasturbateWithToy;
public static ThoughtDef UsedSexToy;
static MasturbateToyDefOf() {
DefOfHelper.EnsureInitializedInCtor(typeof(JobDefOf));
}

View File

@ -32,7 +32,7 @@ namespace RJW_ToysAndMasturbation {
yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.A);
yield return Toils_Haul.StartCarryThing(TargetIndex.A);
if (!SexToyUtility.isRJWAnimationsLoaded || true /*True for now, anims come later; disable once created animations*/) {
if (!SexToyUtility.isRJWAnimationsLoaded || true /*True for now*/) {
//place down if anims isn't loaded
yield return Toils_Haul.CarryHauledThingToCell(TargetIndex.C);
yield return Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, Toils_Goto.GotoCell(TargetIndex.C, PathEndMode.OnCell), storageMode: false);
@ -66,6 +66,8 @@ namespace RJW_ToysAndMasturbation {
cleanup.AddQueuedTarget(TargetIndex.A, filth);
pawn.jobs.jobQueue.EnqueueFirst(cleanup);
}
//bonus mood
pawn.needs?.mood?.thoughts?.memories?.TryGainMemory(MasturbateToyDefOf.UsedSexToy);
};
yield return AfterToil;

View File

@ -21,20 +21,59 @@ namespace RJW_ToysAndMasturbation {
if (!xxx.can_be_fucked(pawn) && !xxx.can_fuck(pawn)) {
return null;
}
if ((SexUtility.ReadyForLovin(pawn) && (!xxx.is_whore(pawn) || pawn.IsPrisoner || xxx.is_slave(pawn))) || xxx.is_frustrated(pawn)) {
if (RJWPreferenceSettings.FapInBed && pawn.jobs.curDriver is JobDriver_LayDown) {
Building_Bed bed = ((JobDriver_LayDown)pawn.jobs.curDriver).Bed;
if (bed != null) {
return JobMaker.MakeJob(xxx.Masturbate, null, bed, bed.Position);
if(findSexToyOnMap(pawn, out Thing sexToy)) {
if ((SexUtility.ReadyForLovin(pawn) && (!xxx.is_whore(pawn) || pawn.IsPrisoner || xxx.is_slave(pawn))) || xxx.is_frustrated(pawn)) {
if (RJWPreferenceSettings.FapInBed && pawn.jobs.curDriver is JobDriver_LayDown) {
Building_Bed bed = ((JobDriver_LayDown)pawn.jobs.curDriver).Bed;
if (bed != null) {
Job j = JobMaker.MakeJob(MasturbateToyDefOf.MasturbateWithToy, sexToy, bed, bed.Position);
j.count = 1;
return j;
}
}
else if (RJWPreferenceSettings.FapEverywhere && (xxx.is_frustrated(pawn) || xxx.has_quirk(pawn, "Exhibitionist"))) {
Job j = JobMaker.MakeJob(MasturbateToyDefOf.MasturbateWithToy, sexToy, null, FapLocation(pawn));
j.count = 1;
return j;
}
}
else if (RJWPreferenceSettings.FapEverywhere && (xxx.is_frustrated(pawn) || xxx.has_quirk(pawn, "Exhibitionist"))) {
return JobMaker.MakeJob(xxx.Masturbate, null, null, FapLocation(pawn));
}
return null;
}
return null;
}
public static bool findSexToyOnMap(Pawn p, out Thing sexToy) {
Predicate<Thing> validator = delegate (Thing t) {
if(t.TryGetComp<CompSexToy>() == null) {
return false;
}
//homo check
if (t.TryGetComp<CompSexToy>().Props.primaryGender == p.gender ||
(t.TryGetComp<CompSexToy>().Props.primaryGender == Gender.Male && xxx.can_fuck(p) && (RJWPreferenceSettings.FeMalesex == RJWPreferenceSettings.AllowedSex.All || RJWPreferenceSettings.FeMalesex == RJWPreferenceSettings.AllowedSex.Homo)) ||
(t.TryGetComp<CompSexToy>().Props.primaryGender == Gender.Female && xxx.can_be_fucked(p) && (RJWPreferenceSettings.Malesex == RJWPreferenceSettings.AllowedSex.All || RJWPreferenceSettings.Malesex == RJWPreferenceSettings.AllowedSex.Homo)))
{
return true;
}
return false;
};
sexToy = GenClosest.ClosestThingReachable(p.Position, p.Map, ThingRequest.ForGroup(ThingRequestGroup.HaulableAlways), PathEndMode.OnCell, TraverseParms.For(p), validator: validator, maxDistance: 100);
if (sexToy != null)
return true;
return false;
}
}
}

View File

@ -9,6 +9,7 @@ using Verse;
namespace RJW_ToysAndMasturbation {
public class CompProperties_SexToy : CompProperties {
public Gender primaryGender = Gender.Female;
public CompProperties_SexToy() {
compClass = typeof(CompSexToy);
}

View File

@ -13,6 +13,8 @@ namespace RJW_ToysAndMasturbation {
public static IntVec3 FapLocation(Pawn p) => (new JobGiver_Masturbate()).FindFapLocation(p);
public CompProperties_SexToy Props => (CompProperties_SexToy)props;
public override IEnumerable<FloatMenuOption> CompFloatMenuOptions(Pawn pawn) {
if (!pawn.CanReach(parent, PathEndMode.Touch, Danger.Deadly)) {