From 94a51be2f7ff27d511395f3fde0170c9607b18d9 Mon Sep 17 00:00:00 2001 From: Vegapnk Date: Sun, 22 Jan 2023 10:46:56 +0100 Subject: [PATCH] Implemented Animal-Reduce for CockEater, documentation improvement. --- .../Abilities/CompAbilityEffect_CockEater.cs | 80 ++++++++++++------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/Source/Genes/Life_Force/Abilities/CompAbilityEffect_CockEater.cs b/Source/Genes/Life_Force/Abilities/CompAbilityEffect_CockEater.cs index d4d12ea..dc0f0fa 100644 --- a/Source/Genes/Life_Force/Abilities/CompAbilityEffect_CockEater.cs +++ b/Source/Genes/Life_Force/Abilities/CompAbilityEffect_CockEater.cs @@ -1,16 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Verse; -using UnityEngine; +using Verse; using RimWorld; using rjw; -using rjw.Modules.Interactions.Helpers; namespace RJW_Genes { + /// + /// The CockEater Ability bites off the first found non-artifical cock of an target pawn. + /// It will restore {MINIMUM_LIFEFORCE_GAIN} multiplied by up to 2-times the Cock-Size. + /// Consuming a "towering" cock will give 2*{MINIMUM_LIFEFORCE_GAIN}, resulting in default 0.5f LifeForce. + /// This number is reduced for consuming animals by Settings. + /// + /// Balancing note: With the Cock-Eaters a drain of 0.08 is normal per day. This means 1 average cock should hold for 3-4 days of fertilin-fuel and half a day for an animal. + /// public class CompAbilityEffect_CockEater : CompAbilityEffect { private new CompProperties_AbilityCockEater Props @@ -20,16 +21,20 @@ namespace RJW_Genes return (CompProperties_AbilityCockEater)this.props; } } + + public const float MINIMUM_LIFEFORCE_GAIN = 0.25f; + public override void Apply(LocalTargetInfo target, LocalTargetInfo dest) { base.Apply(target, dest); - Pawn pawn = target.Pawn; - if (pawn == null) + Pawn CockBiter = this.parent.pawn; + Pawn CockBittenPawn = target.Pawn; + if (CockBittenPawn == null) { return; } - var partBPR = Genital_Helper.get_genitalsBPR(pawn); - var parts = Genital_Helper.get_PartsHediffList(pawn, partBPR); + var partBPR = Genital_Helper.get_genitalsBPR(CockBittenPawn); + var parts = Genital_Helper.get_PartsHediffList(CockBittenPawn, partBPR); if (!parts.NullOrEmpty()) { foreach (Hediff part in parts) @@ -39,50 +44,67 @@ namespace RJW_Genes if (Genital_Helper.is_penis(part)) { - GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(this.parent.pawn), part.Severity); ; - pawn.health.RemoveHediff(part); - pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.rjw_genes_cock_eaten, pawn, null); - break; //Only one penis at the time + float gained_lifeforce = MINIMUM_LIFEFORCE_GAIN * (1 + part.Severity); + if (CockBittenPawn.IsAnimal()) + { + gained_lifeforce *= RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor; + } + // Increase LifeForce for Biter + GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(CockBiter), gained_lifeforce); + + // Handle Damage for Bitten + CockBittenPawn.health.RemoveHediff(part); + CockBittenPawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.rjw_genes_cock_eaten, CockBittenPawn, null); + + //Only one penis at the time + break; } } - } } + /// + /// For validity, there are a few checks: + /// 1. Target has Penis + /// 2. Target is either Colonist / Prisoner + /// 3. If the Target is an enemy, it must be downed. + /// public override bool Valid(LocalTargetInfo target, bool throwMessages = false) { - Pawn pawn = target.Pawn; - if (pawn != null) + Pawn CockBiteTarget = target.Pawn; + if (CockBiteTarget != null) { - bool flag = pawn.Faction == this.parent.pawn.Faction || pawn.IsPrisonerOfColony; - bool flag2 = pawn.HostileTo(this.parent.pawn); - bool flag3 = pawn.Downed; - if (!flag && !(flag2 && flag3)) + bool CockBiteTargetIsColonistOrPrisoner = CockBiteTarget.Faction == this.parent.pawn.Faction || CockBiteTarget.IsPrisonerOfColony; + bool CockBiteTargetIsHostile = CockBiteTarget.HostileTo(this.parent.pawn); + bool CockBiteTargetIsDowned = CockBiteTarget.Downed; + + if (!CockBiteTargetIsColonistOrPrisoner && !(CockBiteTargetIsHostile && CockBiteTargetIsDowned)) { if (throwMessages) { - if(flag2 && !flag3) + if(CockBiteTargetIsHostile && !CockBiteTargetIsDowned) { - Messages.Message(pawn.Name + " is hostile, but not downed.", pawn, MessageTypeDefOf.RejectInput, false); + Messages.Message(CockBiteTarget.Name + " is hostile, but not downed.", CockBiteTarget, MessageTypeDefOf.RejectInput, false); } - else if (!flag) + else if (!CockBiteTargetIsColonistOrPrisoner) { - Messages.Message(pawn.Name + " is not a part of the colony or hostile.", pawn, MessageTypeDefOf.RejectInput, false); + Messages.Message(CockBiteTarget.Name + " is not a part of the colony or hostile.", CockBiteTarget, MessageTypeDefOf.RejectInput, false); } } return false; } - if (!Genital_Helper.has_penis_fertile(pawn)) + if (!Genital_Helper.has_penis_fertile(CockBiteTarget)) { if (throwMessages) { - Messages.Message(pawn.Name + " has no penis", pawn, MessageTypeDefOf.RejectInput, false); + Messages.Message(CockBiteTarget.Name + " has no penis", CockBiteTarget, MessageTypeDefOf.RejectInput, false); } return false; } } return base.Valid(target, throwMessages); } + public override bool GizmoDisabled(out string reason) { Pawn_GeneTracker genes = this.parent.pawn.genes;