mirror of
				https://github.com/vegapnk/RJW-Genes.git
				synced 2024-08-15 00:23:31 +00:00 
			
		
		
		
	Made Aphrodisiac have a bigger range, less effect and easier to track application. seperate file
This commit is contained in:
		
							parent
							
								
									8d38fd00c6
								
							
						
					
					
						commit
						5b33563472
					
				
					 3 changed files with 64 additions and 45 deletions
				
			
		
							
								
								
									
										43
									
								
								Common/Defs/HediffDefs/Hediffs_Aphrodisiac.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								Common/Defs/HediffDefs/Hediffs_Aphrodisiac.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
<?xml version="1.0" encoding="utf-8" ?>
 | 
			
		||||
<Defs>
 | 
			
		||||
 | 
			
		||||
    <!-- Actually, there are no pheromones for humans that we are aware of, did you know? There are smells we are conditioned to like, but actual pheromones are not known for humans. But, this is a game, so fuck it I guess? -->
 | 
			
		||||
	<HediffDef>
 | 
			
		||||
		<defName>rjw_genes_aphrodisiac_pheromone</defName>
 | 
			
		||||
		<hediffClass>HediffWithComps</hediffClass>
 | 
			
		||||
		<label>induced libido</label>
 | 
			
		||||
		<description>sex drive increasing due to smelling aphrodisiac pheromones.</description>
 | 
			
		||||
		<defaultLabelColor>(1,0,0.5)</defaultLabelColor>
 | 
			
		||||
		<maxSeverity>1.0</maxSeverity>
 | 
			
		||||
		<comps>
 | 
			
		||||
			<li Class="HediffCompProperties_SeverityPerDay">
 | 
			
		||||
				<severityPerDay>-4.0</severityPerDay>
 | 
			
		||||
			</li>
 | 
			
		||||
		</comps>
 | 
			
		||||
		<stages>
 | 
			
		||||
			<li>
 | 
			
		||||
				<label>wearing off</label>
 | 
			
		||||
				<statFactors>
 | 
			
		||||
					<SexFrequency>1.25</SexFrequency>
 | 
			
		||||
				</statFactors>
 | 
			
		||||
			</li>
 | 
			
		||||
			<li>
 | 
			
		||||
				<minSeverity>0.35</minSeverity>
 | 
			
		||||
				<label>moderate</label>
 | 
			
		||||
				
 | 
			
		||||
				<statFactors>
 | 
			
		||||
					<SexFrequency>1.8</SexFrequency>
 | 
			
		||||
				</statFactors>
 | 
			
		||||
			</li>
 | 
			
		||||
			<li>
 | 
			
		||||
				<minSeverity>0.9</minSeverity>
 | 
			
		||||
				<label>strong</label>
 | 
			
		||||
				
 | 
			
		||||
				<statFactors>
 | 
			
		||||
					<SexFrequency>2.5</SexFrequency>
 | 
			
		||||
				</statFactors>
 | 
			
		||||
			</li>
 | 
			
		||||
		</stages>
 | 
			
		||||
	</HediffDef>
 | 
			
		||||
 | 
			
		||||
</Defs>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,26 +1,5 @@
 | 
			
		|||
<?xml version="1.0" encoding="utf-8" ?>
 | 
			
		||||
<Defs>
 | 
			
		||||
	<HediffDef>
 | 
			
		||||
		<defName>rjw_genes_aphrodisiac_pheromone</defName>
 | 
			
		||||
		<hediffClass>HediffWithComps</hediffClass>
 | 
			
		||||
		<label>induced libido</label>
 | 
			
		||||
		<description>sex drive increasing due to smelling aphrodisiac pheromones.</description>
 | 
			
		||||
		<defaultLabelColor>(1,0,0.5)</defaultLabelColor>
 | 
			
		||||
		<maxSeverity>1.0</maxSeverity>
 | 
			
		||||
		<comps>
 | 
			
		||||
			<li Class="HediffCompProperties_SeverityPerDay">
 | 
			
		||||
				<severityPerDay>-24.0</severityPerDay>
 | 
			
		||||
			</li>
 | 
			
		||||
		</comps>
 | 
			
		||||
		<stages>
 | 
			
		||||
			<li>
 | 
			
		||||
				<becomeVisible>true</becomeVisible>
 | 
			
		||||
				<statFactors>
 | 
			
		||||
					<SexFrequency>2</SexFrequency> <!--This is a lie, it gets changed when applied -->
 | 
			
		||||
				</statFactors>
 | 
			
		||||
			</li>
 | 
			
		||||
		</stages>
 | 
			
		||||
	</HediffDef>
 | 
			
		||||
	
 | 
			
		||||
	<HediffDef>
 | 
			
		||||
		<defName>rjw_genes_fertilin_lost</defName>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,21 +5,30 @@ using RimWorld;
 | 
			
		|||
namespace RJW_Genes
 | 
			
		||||
{
 | 
			
		||||
    public class Gene_Aphrodisiac_Pheromones : Gene
 | 
			
		||||
    {   
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        // Default XML Setting is that it looses 4 Severity per day - so a "fully libido" gives 6h boost. 
 | 
			
		||||
        // This means that adding +.25 equals 1.5h of Libido. 
 | 
			
		||||
        // Tick Speed is hence set to 0.5h 
 | 
			
		||||
 | 
			
		||||
        const int APHRODISIAC_DISTANCE = 25;
 | 
			
		||||
        const int TICK_INTERVAL = 60000 / 48 ; // 60k = 1 day, we want 0.5h which is 1/48th of 1 day. 
 | 
			
		||||
 | 
			
		||||
        const float SEXFREQ_THRESHOLD = 0.5f;
 | 
			
		||||
 | 
			
		||||
        // Summary: once every one hour check for all pawns nearby and in line of sight (same room) and add/renew a hediff which lasts for 1 hour.
 | 
			
		||||
        public override void Tick()
 | 
			
		||||
        {
 | 
			
		||||
            base.Tick();
 | 
			
		||||
            if (this.pawn.IsHashIntervalTick(2500) && this.pawn.Map != null)
 | 
			
		||||
            if (this.pawn.IsHashIntervalTick(TICK_INTERVAL) && this.pawn.Map != null)
 | 
			
		||||
            {
 | 
			
		||||
                // Only spread pheromones if sexdrive above 1
 | 
			
		||||
                float sexfrequency = this.pawn.GetStatValue(StatDef.Named("SexFrequency"));
 | 
			
		||||
                if(sexfrequency > 1f)
 | 
			
		||||
                if(sexfrequency > SEXFREQ_THRESHOLD)
 | 
			
		||||
                {
 | 
			
		||||
                    foreach (Pawn pawn in this.AffectedPawns(this.pawn.Position, this.pawn.Map))
 | 
			
		||||
                    {
 | 
			
		||||
                        this.InduceAphrodisiac(pawn, sexfrequency);
 | 
			
		||||
                        this.InduceAphrodisiac(pawn);
 | 
			
		||||
                    }
 | 
			
		||||
                }               
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +40,7 @@ namespace RJW_Genes
 | 
			
		|||
            foreach (Pawn pawn in map.mapPawns.AllPawns)
 | 
			
		||||
            {
 | 
			
		||||
                if (pawn != null && this.pawn != null && pawn != this.pawn 
 | 
			
		||||
                    && pos.DistanceTo(pawn.Position) < 5 && GenSight.LineOfSight(pos, pawn.Position, pawn.Map) 
 | 
			
		||||
                    && pos.DistanceTo(pawn.Position) < APHRODISIAC_DISTANCE && GenSight.LineOfSight(pos, pawn.Position, pawn.Map) 
 | 
			
		||||
                    && !GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_aphrodisiac_pheromones))
 | 
			
		||||
                {
 | 
			
		||||
                    yield return pawn;
 | 
			
		||||
| 
						 | 
				
			
			@ -41,33 +50,21 @@ namespace RJW_Genes
 | 
			
		|||
            yield break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Applies or renews a hediff which increases sexdrive for 6 hours
 | 
			
		||||
        private void InduceAphrodisiac(Pawn pawn, float sexfrequency)
 | 
			
		||||
        private void InduceAphrodisiac(Pawn pawn)
 | 
			
		||||
        {
 | 
			
		||||
            Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.rjw_genes_aphrodisiac_pheromone);
 | 
			
		||||
            Hediff aphrodisiac = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.rjw_genes_aphrodisiac_pheromone);
 | 
			
		||||
            
 | 
			
		||||
            if (hediff != null)
 | 
			
		||||
            if (aphrodisiac != null)
 | 
			
		||||
            {
 | 
			
		||||
                hediff.Severity = 1f;
 | 
			
		||||
                aphrodisiac.Severity += 0.25f;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                Hediff aphrodisiac = HediffMaker.MakeHediff(HediffDefOf.rjw_genes_aphrodisiac_pheromone, pawn);
 | 
			
		||||
                foreach (StatModifier stat in aphrodisiac.CurStage.statFactors)
 | 
			
		||||
                {
 | 
			
		||||
                    if (stat.stat.defName == "SexFrequency")
 | 
			
		||||
                    {
 | 
			
		||||
                        stat.value = ModifySexfrequency(pawn, sexfrequency);
 | 
			
		||||
                        pawn.health.AddHediff(aphrodisiac);
 | 
			
		||||
                    }                    
 | 
			
		||||
                }
 | 
			
		||||
                aphrodisiac = HediffMaker.MakeHediff(HediffDefOf.rjw_genes_aphrodisiac_pheromone, pawn);
 | 
			
		||||
                aphrodisiac.Severity = 0.5f;
 | 
			
		||||
                pawn.health.AddHediff(aphrodisiac);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Function to modify aphrodisiac strength, currently has no effect, but provides an easy hook for other modders and patches.
 | 
			
		||||
        public float ModifySexfrequency(Pawn pawn, float sexfrequency)
 | 
			
		||||
        {
 | 
			
		||||
            return sexfrequency;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue