Skip to content

Commit

Permalink
changes + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Killface1980 committed Nov 18, 2017
1 parent b5c0545 commit 7e2d2c4
Show file tree
Hide file tree
Showing 72 changed files with 652 additions and 256 deletions.
Binary file modified Assemblies/FacialStuff.dll
Binary file not shown.
Binary file modified Assemblies/FacialStuff_Legacy.dll
Binary file not shown.
7 changes: 6 additions & 1 deletion Defs/JobDefs/Clutter_Jobs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
<driverClass>FacialStuff.FaceStyling_Bench.Job_FaceStyling</driverClass>
<reportString>Going to the styling station.</reportString>
</JobDef>
<!--

<JobDef>
<defName>Possess</defName>
<driverClass>FacialStuff.AI.JobDriver_Possess</driverClass>
<reportString>haunting TargetA.</reportString>
</JobDef> <!--
<JobDef>
<defName>ChangeAppearance</defName>
<driverClass>FacialStuff.FaceStyling_Bench.Job_FaceStylingJoy</driverClass>
Expand Down
36 changes: 36 additions & 0 deletions Defs/MentalStateDefs/MentalStates_Mood_FS.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>

<!-- Mental breaks: extreme -->

<MentalBreakDef>
<defName>Possessed</defName>
<mentalState>Possessed</mentalState>
<baseCommonality>0.1</baseCommonality>
<intensity>Extreme</intensity>
</MentalBreakDef>
<MentalStateDef ParentName="BaseMentalState">
<defName>Possessed</defName>
<stateClass>FacialStuff.AI.MentalState_Possessed</stateClass>
<workerClass>FacialStuff.AI.MentalStateWorker_Possessed</workerClass>
<label>possessed</label>
<category>Aggro</category>
<moodRecoveryThought>Catharsis</moodRecoveryThought>
<blockNormalThoughts>true</blockNormalThoughts>
<nameColor>(0.9,0.2,0.5)</nameColor>
<beginLetterLabel>possessed</beginLetterLabel>
<beginLetter>{0} possessed!</beginLetter>
<beginLetterDef>ThreatSmall</beginLetterDef>
<minTicksBeforeRecovery>5000</minTicksBeforeRecovery>
<recoveryMtbDays>0.3</recoveryMtbDays>
<maxTicksBeforeRecovery>60000</maxTicksBeforeRecovery>
<recoveryMessage>{0} is no longer possessed.</recoveryMessage>
<baseInspectLine>Mental state: Possession</baseInspectLine>
<stateEffecter>Berserk</stateEffecter>
<tale>MentalStateBerserk</tale>
<recoverFromSleep>true</recoverFromSleep>
<unspawnedCanDo>true</unspawnedCanDo>
</MentalStateDef>


</Defs>
27 changes: 27 additions & 0 deletions Defs/ThinkTreeDefs/SubTrees_MiscFS.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>

<ThinkTreeDef>
<defName>MentalStatesFS</defName>
<insertTag>Humanlike_PostMentalState</insertTag>
<insertPriority>1</insertPriority>
<thinkRoot Class="ThinkNode_Priority">
<subNodes>
<li Class="ThinkNode_ConditionalMentalState">
<state>Possessed</state>
<subNodes>
<li Class="ThinkNode_Priority">
<subNodes>
<li Class="FacialStuff.AI.JobGiver_Possess"/>
<li Class="JobGiver_WanderColony">
<maxDanger>Deadly</maxDanger>
</li>
</subNodes>
</li>
</subNodes>
</li>
</subNodes>
</thinkRoot>
</ThinkTreeDef>

</Defs>
2 changes: 1 addition & 1 deletion Source/FacialStuffLegacy/HarmonyPatches.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ReSharper disable All

namespace FacialStuff.Detouring
namespace FacialStuff.Harmony
{
using System.Collections.Generic;
using System.Linq;
Expand Down
200 changes: 200 additions & 0 deletions Source/RW_FacialStuff/AI/JobDriver_Possess.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FacialStuff.AI
{
using FacialStuff.newStuff;

using RimWorld;

using Verse;
using Verse.AI;
using Verse.Sound;

public class JobDriver_Possess : JobDriver
{
private Pawn Target
{
get
{
return (Pawn)(Thing)base.pawn.CurJob.GetTarget(TargetInd);
}
}

public override bool TryMakePreToilReservations()
{
return true;
}
private int ticksLeft;

private TargetIndex TargetInd = TargetIndex.A;
private TargetIndex VomitInd = TargetIndex.B;

protected override IEnumerable<Toil> MakeNewToils()
{
Toil newToils = this.HaveFunWithDemons().WithEffect(EffecterDefOf.Vomit, this.TargetInd)
.PlaySustainerOrSound(() => SoundDef.Named("Vomit"));

yield return Toils_Interpersonal.GotoInteractablePosition(this.TargetInd).FailOnDespawnedOrNull(this.TargetInd);

yield return InsultingSpreeDelayToil();
yield return Toils_Interpersonal.WaitToBeAbleToInteract(this.pawn);

Toil finalgoto = Toils_Interpersonal.GotoInteractablePosition(this.TargetInd);
finalgoto.socialMode = RandomSocialMode.Off;
yield return finalgoto;

yield return newToils;


yield return InteractToil();
}

private Toil HaveFunWithDemons()
{
Toil toil = new Toil();
this.pawn.GetCompFace(out CompFace compFace);

toil.initAction = delegate
{
// this.ticksLeft = Rand.Range(300, 900);
this.ticksLeft = Rand.Range(450, 1200);
int num2 = 0;
IntVec3 c;
while (true)
{
c = this.pawn.Position + GenAdj.AdjacentCellsAndInside[Rand.Range(0, 9)];
num2++;
if (num2 > 12)
{
c = this.pawn.Position;
break;
}
if (c.InBounds(this.pawn.Map) && c.Standable(this.pawn.Map)) break;
}
this.job.targetB = c;
this.pawn.pather.StopDead();

DefDatabase<SoundDef>.GetNamed("Pawn_Cat_Angry").PlayOneShot(new TargetInfo(this.pawn.Position, this.pawn.Map)); // GenExplosion.DoExplosion(
// this.pawn.Position,
// this.pawn.Map,
// 2,
// DamageDefOf.Smoke,
// null,
// 0,
// DefDatabase<SoundDef>.GetNamed("Explosion_Smoke"));
// for (int i = 0; i < 2; i++)
// {
// var loc = this.pawn.Position.ToVector3Shifted();
// var map = this.pawn.Map;
// MoteMaker.ThrowSmoke(loc, map, 1f);
// MoteMaker.ThrowMicroSparks(loc, map);
// MoteMaker.ThrowLightningGlow(loc, map, 1f);
// }
};

int accellerator = 25;
toil.tickAction = delegate
{

if (this.ticksLeft % 60 == 0)
{

// MoteMaker.ThrowFireGlow(this.pawn.Position, this.pawn.Map, 0.1f);
}
// if (this.ticksLeft % 45 == 0)
// {
// MoteMaker.ThrowHeatGlow(this.pawn.Position, this.pawn.Map, 0.3f);
// }
if (this.ticksLeft % accellerator == 0)
{
compFace?.HeadRotator.RotateRandomly();
// MoteMaker.ThrowSmoke(this.pawn.Position.ToVector3(), this.pawn.Map, 0.2f);
if (accellerator > 20)
{
accellerator--;
}
else if (accellerator < 37)
{
accellerator++;
}
}

if (this.ticksLeft % 150 == 149)
{
DefDatabase<SoundDef>.GetNamed("Pawn_Cat_Angry")
.PlayOneShot(new TargetInfo(this.pawn.Position, this.pawn.Map));
FilthMaker.MakeFilth(
this.job.targetA.Cell,
this.Map,
ThingDefOf.FilthVomit,
this.pawn.LabelIndefinite(),
1);
if (this.pawn.needs.food.CurLevelPercentage > 0.10000000149011612)
{
this.pawn.needs.food.CurLevel -=
(float)(this.pawn.needs.food.MaxLevel * 0.02);
}
}
if (this.ticksLeft % 50 == 0)
{
FilthMaker.MakeFilth(
this.pawn.Position.RandomAdjacentCell8Way(),
this.Map,
ThingDefOf.FilthVomit,
this.pawn.LabelIndefinite(),
1);
}
this.ticksLeft--;
if (this.ticksLeft <= 0)
{
this.ReadyForNextToil();
TaleRecorder.RecordTale(TaleDefOf.Vomited, this.pawn);
}
};

toil.AddFinishAction(() => { compFace?.HeadRotator.SetUnPossessed(); });

toil.defaultCompleteMode = ToilCompleteMode.Never;
return toil;
}

private Toil InsultingSpreeDelayToil()
{
Action action = delegate
{
MentalState_Possessed mentalState_InsultingSpree = base.pawn.MentalState as MentalState_Possessed;
if (mentalState_InsultingSpree != null && Find.TickManager.TicksGame - mentalState_InsultingSpree.lastInsultTicks < 300)// 1200)
return;
base.pawn.jobs.curDriver.ReadyForNextToil();
};
Toil toil = new Toil();
toil.initAction = action;
toil.tickAction = action;
toil.socialMode = RandomSocialMode.Off;
toil.defaultCompleteMode = ToilCompleteMode.Never;
return toil;
}

private Toil InteractToil()
{
return Toils_General.Do(delegate
{
if (base.pawn.interactions.TryInteractWith(this.Target, InteractionDefOf.Insult))
{
MentalState_Possessed mentalState_InsultingSpree = base.pawn.MentalState as MentalState_Possessed;
if (mentalState_InsultingSpree != null)
{
mentalState_InsultingSpree.lastInsultTicks = Find.TickManager.TicksGame;
if (mentalState_InsultingSpree.target == this.Target)
{
mentalState_InsultingSpree.insultedTargetAtLeastOnce = true;
}
}
}
});
}
}
}
22 changes: 22 additions & 0 deletions Source/RW_FacialStuff/AI/JobGiver_Possess.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RimWorld.JobGiver_InsultingSpree

using RimWorld;

using Verse;
using Verse.AI;

namespace FacialStuff.AI
{
public class JobGiver_Possess : ThinkNode_JobGiver
{
protected override Job TryGiveJob(Pawn pawn)
{
MentalState_Possessed mentalStatePossessed = pawn.MentalState as MentalState_Possessed;
if (mentalStatePossessed != null && mentalStatePossessed.target != null && pawn.CanReach(mentalStatePossessed.target, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn))
{
return new Job(DefDatabase<JobDef>.GetNamed("Possess"), mentalStatePossessed.target);
}
return null;
}
}
}
27 changes: 27 additions & 0 deletions Source/RW_FacialStuff/AI/MentalStateWorker_Possessed.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Verse.AI.MentalStateWorker_InsultingSpreeAll

using System.Collections.Generic;

using Verse;
using Verse.AI;

namespace FacialStuff.AI
{
public class MentalStateWorker_Possessed : MentalStateWorker
{
private static List<Pawn> candidates = new List<Pawn>();

public override bool StateCanOccur(Pawn pawn)
{
if (!base.StateCanOccur(pawn))
{
return false;
}

InsultingSpreeMentalStateUtility.GetInsultCandidatesFor(pawn, candidates, true);
bool result = candidates.Count >= 2;
candidates.Clear();
return result;
}
}
}
Loading

0 comments on commit 7e2d2c4

Please sign in to comment.