diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index 643715a..3c6968a 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ diff --git a/1.6/1.6/Defs/HediffDefs/ARA_GuardianPsyField_Hediff.xml b/1.6/1.6/Defs/HediffDefs/ARA_GuardianPsyField_Hediff.xml index 562ab54..0b5e5e1 100644 --- a/1.6/1.6/Defs/HediffDefs/ARA_GuardianPsyField_Hediff.xml +++ b/1.6/1.6/Defs/HediffDefs/ARA_GuardianPsyField_Hediff.xml @@ -14,9 +14,14 @@ 5.9 - 150 + 1500 3200 60 + + + 0.5 + 0.1 + 0.01 true diff --git a/Source/ArachnaeSwarm/ThingComp_GuardianPsyField.cs b/Source/ArachnaeSwarm/ThingComp_GuardianPsyField.cs index 6b62d70..fde8b4a 100644 --- a/Source/ArachnaeSwarm/ThingComp_GuardianPsyField.cs +++ b/Source/ArachnaeSwarm/ThingComp_GuardianPsyField.cs @@ -13,6 +13,11 @@ namespace ArachnaeSwarm public int rechargeDelay = 3200; // Ticks after breaking public int rechargeHitPointsIntervalTicks = 60; // Ticks to restore 1 HP + // New properties for psyfocus/entropy mechanics + public float psyfocusCostForFullRecharge = 0.5f; // 50% psyfocus cost + public float entropyGainPerDamage = 0.5f; // 1 entropy per 2 damage + public float hitPointsPctPerInterval = 0.01f; // Restore 1% of max HP per interval + public bool interceptGroundProjectiles = true; public bool interceptAirProjectiles = true; public bool interceptNonHostileProjectiles = false; @@ -36,6 +41,7 @@ namespace ArachnaeSwarm private int lastInterceptTicks = -999999; private int ticksToReset = 0; // Cooldown timer public int currentHitPoints; + private bool wasNotAtFullHp = false; // Tracks if shield was damaged before recharge // --- Properties --- public CompProperties_GuardianPsyField Props => (CompProperties_GuardianPsyField)props; @@ -86,9 +92,24 @@ namespace ArachnaeSwarm Reset(); } } - else if (currentHitPoints < HitPointsMax && this.parent.IsHashIntervalTick(Props.rechargeHitPointsIntervalTicks)) + else if (currentHitPoints < HitPointsMax) { - currentHitPoints++; + wasNotAtFullHp = true; // Mark that the shield was damaged + if(this.parent.IsHashIntervalTick(Props.rechargeHitPointsIntervalTicks)) + { + currentHitPoints += (int)(HitPointsMax * Props.hitPointsPctPerInterval); + if(currentHitPoints > HitPointsMax) currentHitPoints = HitPointsMax; + } + } + else if (wasNotAtFullHp && currentHitPoints >= HitPointsMax) + { + // Shield just reached full charge + wasNotAtFullHp = false; + if (PawnOwner.psychicEntropy != null && Props.psyfocusCostForFullRecharge > 0) + { + float maxPsyfocus = PawnOwner.GetStatValue(StatDefOf.PsychicEntropyMax); + PawnOwner.psychicEntropy.OffsetPsyfocusDirectly(-maxPsyfocus * Props.psyfocusCostForFullRecharge); + } } } @@ -104,10 +125,19 @@ namespace ArachnaeSwarm // --- Interception Success --- lastInterceptTicks = Find.TickManager.TicksGame; - Props.interceptEffecter?.Spawn(PawnOwner.Position, PawnOwner.Map).Cleanup(); + // Spawn effect at the point of interception, not the shield center + Props.interceptEffecter?.Spawn(projectile.ExactPosition.ToIntVec3(), PawnOwner.Map).Cleanup(); + float damageAmount = projectile.DamageAmount; + + // Add entropy based on damage + if (PawnOwner.psychicEntropy != null && Props.entropyGainPerDamage > 0) + { + PawnOwner.psychicEntropy.TryAddEntropy(damageAmount * Props.entropyGainPerDamage, overLimit: true); + } + // Consume Hitpoints - currentHitPoints -= (int)projectile.DamageAmount; + currentHitPoints -= (int)damageAmount; if (currentHitPoints <= 0) { Break();