309 lines
12 KiB
C#
309 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using LTS_Implants;
|
|
using RimWorld;
|
|
using UnityEngine;
|
|
using Verse;
|
|
|
|
namespace LTS_Implants
|
|
{
|
|
|
|
public class LTS_Hediff_PsychicReaper : Hediff
|
|
{
|
|
private int previousHumanKills = -1;
|
|
|
|
public override void PostAdd(DamageInfo? dinfo)
|
|
{
|
|
base.PostAdd(dinfo);
|
|
previousHumanKills = (int)pawn.records.GetValue(RecordDefOf.KillsHumanlikes);
|
|
}
|
|
|
|
public override void Notify_Spawned()
|
|
{
|
|
base.Notify_Spawned();
|
|
PostAdd(null);
|
|
}
|
|
|
|
public override void Tick()
|
|
{
|
|
base.Tick();
|
|
//Log.Message("Psychic Reaper Tick");
|
|
if (Find.TickManager.TicksGame % 10 == 0)
|
|
{
|
|
if ((int)pawn.records.GetValue(RecordDefOf.KillsHumanlikes) > previousHumanKills)
|
|
{
|
|
//Log.Message("Previous kills: " + previousHumanKills);
|
|
//Log.Message("Current kills: "+ (int)pawn.records.GetValue(RecordDefOf.KillsHumanlikes));
|
|
pawn.psychicEntropy.OffsetPsyfocusDirectly(0.05f*((int)pawn.records.GetValue(RecordDefOf.KillsHumanlikes) - previousHumanKills));//add 5 psyfocus per humanlike kill
|
|
}
|
|
previousHumanKills = (int)pawn.records.GetValue(RecordDefOf.KillsHumanlikes);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class LTS_Hediff_Voidlink : Hediff
|
|
{
|
|
public override bool ShouldRemove => false;
|
|
public override void Tick()
|
|
{
|
|
base.Tick();
|
|
if (Find.TickManager.TicksGame % 30 == 0)
|
|
{
|
|
Severity = Find.Anomaly.LevelDef.level;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class LTS_HediffCompProperties_MetalhorrorEmerge : HediffCompProperties
|
|
{
|
|
public string letterLabel;
|
|
|
|
public string letterText;
|
|
|
|
public LTS_HediffCompProperties_MetalhorrorEmerge()
|
|
{
|
|
compClass = typeof(LTS_HediffComp_MetalhorrorEmerge);
|
|
}
|
|
}
|
|
|
|
public class LTS_HediffComp_MetalhorrorEmerge : HediffComp
|
|
{
|
|
private static readonly IntRange StunDuration = new IntRange(120, 240);
|
|
|
|
public LTS_HediffCompProperties_MetalhorrorEmerge Props => (LTS_HediffCompProperties_MetalhorrorEmerge)props;
|
|
|
|
public override void Notify_SurgicallyRemoved(Pawn surgeon)
|
|
{
|
|
TentacleAttack(surgeon);
|
|
}
|
|
|
|
public override void Notify_SurgicallyReplaced(Pawn surgeon)
|
|
{
|
|
TentacleAttack(surgeon);
|
|
}
|
|
|
|
private void TentacleAttack(Pawn surgeon)
|
|
{
|
|
if (ModsConfig.AnomalyActive)
|
|
{
|
|
Pawn pawn = parent.pawn;
|
|
Pawn pawn2 = PawnGenerator.GeneratePawn(new PawnGenerationRequest(PawnKindDefOf.Metalhorror, Faction.OfEntities, PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, mustBeCapableOfViolence: false, 1f, forceAddFreeWarmLayerIfNeeded: false, allowGay: true, allowPregnant: false, allowFood: true, allowAddictions: true, inhabitant: false, certainlyBeenInCryptosleep: false, forceRedressWorldPawnIfFormerColonist: false, worldPawnFactionDoesntMatter: false, 0f, 0f, null, 1f, null, null, null, null, null, 0f, 0f));
|
|
GenSpawn.Spawn(pawn2, CellFinder.StandableCellNear(pawn.Position, pawn.Map, 2f), pawn.Map);
|
|
pawn2.stances.stunner.StunFor(StunDuration.RandomInRange, surgeon);
|
|
CompInspectStringEmergence compInspectStringEmergence = pawn2.TryGetComp<CompInspectStringEmergence>();
|
|
if (compInspectStringEmergence != null)
|
|
{
|
|
compInspectStringEmergence.sourcePawn = pawn;
|
|
}
|
|
TaggedString label = Props.letterLabel.Formatted(pawn.Named("PAWN"));
|
|
TaggedString text = Props.letterText.Formatted(pawn.Named("PAWN"));
|
|
Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.ThreatBig, pawn2);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public class LTS_Hediff_HyperAdrenalineGland : Hediff
|
|
{
|
|
private float totalDamageTaken;
|
|
|
|
public override void Notify_PawnPostApplyDamage(DamageInfo dinfo, float totalDamageDealt)
|
|
{
|
|
base.Notify_PawnPostApplyDamage(dinfo, totalDamageDealt);
|
|
if (pawn.Dead)
|
|
{
|
|
return;
|
|
}
|
|
//if (pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("PsychokeneticShield")) != null && ((pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("PsychokeneticShield"))) as LTS_ShieldHediff).PsychicShieldCurrentHealth > 0)
|
|
//{
|
|
// return;
|
|
//}
|
|
totalDamageTaken += totalDamageDealt;
|
|
if (!pawn.Dead && totalDamageTaken > 0f && !pawn.health.hediffSet.HasHediff(HediffDefOf.RageSpeed) && !pawn.health.Downed)
|
|
{
|
|
pawn.health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.RageSpeed, pawn));
|
|
if (pawn.Spawned)
|
|
{
|
|
EffecterDefOf.ChimeraRage.Spawn(pawn.Position, pawn.Map).Cleanup();
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Notify_Downed()
|
|
{
|
|
Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.RageSpeed);
|
|
if (firstHediffOfDef != null)
|
|
{
|
|
pawn.health.RemoveHediff(firstHediffOfDef);
|
|
}
|
|
}
|
|
|
|
public override void Tick()
|
|
{
|
|
base.Tick();
|
|
if (!pawn.Dead && pawn.health.summaryHealth.SummaryHealthPercent >= 0.98f)
|
|
{
|
|
Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.RageSpeed);
|
|
if (firstHediffOfDef != null)
|
|
{
|
|
pawn.health.RemoveHediff(firstHediffOfDef);
|
|
totalDamageTaken = 0f;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void ExposeData()
|
|
{
|
|
base.ExposeData();
|
|
Scribe_Values.Look(ref totalDamageTaken, "totalDamageTaken", 0f);
|
|
}
|
|
}
|
|
|
|
public class LTS_Hediff_DefensiveImpaler : Hediff
|
|
{
|
|
public override void Notify_PawnPostApplyDamage(DamageInfo dinfo, float totalDamageDealt)
|
|
{
|
|
base.Notify_PawnPostApplyDamage(dinfo, totalDamageDealt);
|
|
if (pawn.Dead)
|
|
{
|
|
return;
|
|
}
|
|
if (dinfo.Instigator != null && pawn.Position.InHorDistOf(dinfo.Instigator.Position, 1.5f))//attacker next to user //apply 6 stab damage, 20% penetration
|
|
{
|
|
//SoundDefOf..PlayOneShot(pawn);
|
|
//BattleLogEntry_DamageTaken battleLogEntry_DamageTaken = new BattleLogEntry_DamageTaken(pawn, RulePackDefOf.DamageEvent_UnnaturalDarkness);
|
|
//Find.BattleLog.Add(battleLogEntry_DamageTaken);
|
|
//dinfo.Instigator.TakeDamage(new DamageInfo(DamageDefOf.Stab, 6)).AssociateWithLog(battleLogEntry_DamageTaken);
|
|
dinfo.Instigator.TakeDamage(new DamageInfo(DamageDefOf.Stab, 6));
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
#region The Cube
|
|
|
|
|
|
public class CompProperties_PsychicBeguile : CompProperties_AbilityEffect
|
|
{
|
|
public CompProperties_PsychicBeguile()
|
|
{
|
|
this.compClass = typeof(CompAbilityEffect_PsychicBeguile);
|
|
}
|
|
public PawnRelationDef pawnRelationDef;
|
|
}
|
|
|
|
public class CompAbilityEffect_PsychicBeguile : CompAbilityEffect
|
|
{
|
|
public new CompProperties_PsychicBeguile Props
|
|
{
|
|
get
|
|
{
|
|
return (CompProperties_PsychicBeguile)this.props;
|
|
}
|
|
}
|
|
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
|
|
{
|
|
base.Apply(target, dest);
|
|
if (target.Pawn.Faction != parent.pawn.Faction)
|
|
{
|
|
target.Pawn.SetFaction(parent.pawn.Faction);
|
|
IncidentWorker.SendIncidentLetter(target.Pawn.Name + " beguiled!", parent.pawn.Name + " has used " + parent.pawn.Possessive() + " psychic beguiler to psychically manipulate " + target.Pawn.Name + ". " + target.Pawn.Name + " has become obsessed with " + parent.pawn.Name + " and is joining " + parent.pawn.Possessive() + " faction.", LetterDefOf.PositiveEvent, new IncidentParms(), target.Pawn, IncidentDefOf.WandererJoin);
|
|
}
|
|
target.Pawn.relations.AddDirectRelation(Props.pawnRelationDef, parent.pawn);
|
|
if(target.Pawn.health.hediffSet.TryGetHediff(HediffDefOf.CubeComa, out Hediff cubeComa))
|
|
{
|
|
target.Pawn.health.RemoveHediff(cubeComa);
|
|
}
|
|
if (target.Pawn.health.hediffSet.TryGetHediff(HediffDefOf.CubeInterest, out Hediff cubeInterest))
|
|
{
|
|
target.Pawn.health.RemoveHediff(cubeInterest);
|
|
}
|
|
if (target.Pawn.health.hediffSet.TryGetHediff(HediffDefOf.CubeWithdrawal, out Hediff cubeWithdrawal))
|
|
{
|
|
target.Pawn.health.RemoveHediff(cubeWithdrawal);
|
|
}
|
|
if (target.Pawn.health.hediffSet.TryGetHediff(HediffDefOf.CubeRage, out Hediff cubeRage))
|
|
{
|
|
target.Pawn.health.RemoveHediff(cubeRage);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class LTS_Hediff_ObsessionBerserkOnDeath : HediffWithComps
|
|
{
|
|
|
|
public override void Notify_PawnCorpseSpawned()
|
|
{
|
|
base.Notify_PawnCorpseSpawned();
|
|
List<Pawn> allHumanlikeSpawned = pawn.Corpse.Map.mapPawns.AllHumanlikeSpawned;
|
|
for (int i = 0; i < allHumanlikeSpawned.Count; i++)
|
|
{
|
|
Pawn otherPawn = allHumanlikeSpawned[i];
|
|
if (otherPawn.RaceProps.Humanlike && otherPawn.relations.GetDirectRelation(I_DefOf.PsychicBeguileObsessed, pawn) != null)
|
|
{
|
|
MentalBreakDefOf.BerserkShort.Worker.TryStart(otherPawn, "Target of obsession died", false);
|
|
}
|
|
}
|
|
}
|
|
public override void PostAdd(DamageInfo? dinfo)
|
|
{
|
|
base.PostAdd(dinfo);
|
|
RemoveCubeHediffs(pawn);
|
|
}
|
|
|
|
public void RemoveCubeHediffs(Pawn pawn)
|
|
{
|
|
if (pawn.health.hediffSet.TryGetHediff(HediffDefOf.CubeComa, out Hediff cubeComa))
|
|
{
|
|
pawn.health.RemoveHediff(cubeComa);
|
|
}
|
|
if (pawn.health.hediffSet.TryGetHediff(HediffDefOf.CubeInterest, out Hediff cubeInterest))
|
|
{
|
|
pawn.health.RemoveHediff(cubeInterest);
|
|
}
|
|
if (pawn.health.hediffSet.TryGetHediff(HediffDefOf.CubeWithdrawal, out Hediff cubeWithdrawal))
|
|
{
|
|
pawn.health.RemoveHediff(cubeWithdrawal);
|
|
}
|
|
if (pawn.health.hediffSet.TryGetHediff(HediffDefOf.CubeRage, out Hediff cubeRage))
|
|
{
|
|
pawn.health.RemoveHediff(cubeRage);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
public class LTS_Hediff_DeathRaiseAsShambler : HediffWithComps
|
|
{
|
|
//PawnKindDef spawnedPawn = PawnKindDefOf.Metalhorror;
|
|
|
|
public override void Notify_PawnDied(DamageInfo? dinfo, Hediff culprit = null)
|
|
{
|
|
base.Notify_PawnDied(dinfo, culprit);
|
|
if (pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.ShamblerCorpse) == null)
|
|
{
|
|
//Faction faction;
|
|
//if (pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.ShamblerCorpse) != null)
|
|
//{
|
|
// faction = pawn?.health?.hediffSet?.GetFirstHediffOfDef(HediffDef.Named("ScratchDeadlife"))
|
|
//}
|
|
//else
|
|
//{
|
|
// faction = pawn.Faction;
|
|
//}
|
|
|
|
|
|
Faction faction = dinfo.GetValueOrDefault().Instigator?.Faction ?? pawn.Faction;
|
|
if (pawn?.health?.hediffSet?.GetFirstHediffOfDef(HediffDef.Named("DeadlifeCollar")) != null) { faction = pawn.Faction; }
|
|
GasUtility.AddDeadifeGas(pawn.Position, pawn.MapHeld, faction, Mathf.CeilToInt(255));
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|