diff --git a/CHANGELOG.md b/CHANGELOG.md index 9de9d2c..ccab0fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,22 @@ Changes: - Cocoon Weaver Gene +- Spawn Spelopede Gene (Can re changed to spawn Megascarabs or other insects) + +Internal: + +- Renamed Abilities to have _ability_ in their name, to not exactly match the gene-defnames. Fixes: - Cockeater Ability has now Icon of Cockeater Gene - Cockeater now leaves a bite wound! +- Pythokin-Patch checks for Licentialabs (#30) + +ToDo: + +- Icons: Cocoon, Spelopede Spawn +- Sound: Spelopede Spawn # 1.1.4 diff --git a/Common/Defs/AbilityDefs/Ability_CocoonWeaver.xml b/Common/Defs/AbilityDefs/Ability_CocoonWeaver.xml index 06133a1..9e0e691 100644 --- a/Common/Defs/AbilityDefs/Ability_CocoonWeaver.xml +++ b/Common/Defs/AbilityDefs/Ability_CocoonWeaver.xml @@ -1,7 +1,7 @@ - rjw_genes_cocoonweaver + rjw_genes_ability_cocoonweaver Weaves the victim into a (self-sustaining) cocoon. The victim cannot move, but can be bred. Things/Mote/Heart diff --git a/Common/Defs/AbilityDefs/Ability_SpawnSpelopede.xml b/Common/Defs/AbilityDefs/Ability_SpawnSpelopede.xml new file mode 100644 index 0000000..771b61b --- /dev/null +++ b/Common/Defs/AbilityDefs/Ability_SpawnSpelopede.xml @@ -0,0 +1,37 @@ + + + + rjw_genes_ability_spawn_spelopede + + Generates a tame spelopede, ready to serve their master. + World/WorldObjects/Expanding/Insects + + true + false + + + Verb_CastAbility + 3 + False + False + 2 + + False + True + + + + False + 1800000 + + +
  • + RJW_Genes.CompAbilityEffect_SpawnSpelopede + Spelopede + true + 1.00 +
  • +
    +
    + +
    \ No newline at end of file diff --git a/Common/Defs/GeneDefs/GeneDefs_Hive.xml b/Common/Defs/GeneDefs/GeneDefs_Hive.xml index 8b6ab1f..5ea010c 100644 --- a/Common/Defs/GeneDefs/GeneDefs_Hive.xml +++ b/Common/Defs/GeneDefs/GeneDefs_Hive.xml @@ -10,13 +10,30 @@ 11 rjw_genes_hive -
  • rjw_genes_cocoonweaver
  • +
  • rjw_genes_ability_cocoonweaver
  • - rjw_genes_cocoonweaver + rjw_genes_ability_cocoonweaver 1 -1 + + rjw_genes_spawn_spelopede + + cocooner + Carriers of this gene can generate tame spelopedes. Higher psychic-sensitivity will spawn more spelopedes. + World/WorldObjects/Expanding/Insects + 11 + rjw_genes_hive + +
  • rjw_genes_ability_spawn_spelopede
  • +
    + + rjw_genes_ability_spawn_spelopede + + 1 + -1 +
    \ No newline at end of file diff --git a/Source/Genes/GeneUtility.cs b/Source/Genes/GeneUtility.cs index a6361aa..fa23fe7 100644 --- a/Source/Genes/GeneUtility.cs +++ b/Source/Genes/GeneUtility.cs @@ -127,26 +127,3 @@ namespace RJW_Genes } } - -/* -Exception in Verse.AI.ThinkNode_Priority TryIssueJobPackage: System.NullReferenceException: Object reference not set to an instance of an object - at RJW_Genes.GeneUtility.HasLowLifeForce (Verse.Pawn pawn) [0x00014] in < 881b7541af8144a78a14c9dad08e43c7 >:0 - at RJW_Genes.ThinkNode_ConditionalLowLifeForce.Satisfied(Verse.Pawn p) [0x00000] in < 881b7541af8144a78a14c9dad08e43c7 >:0 - at Verse.AI.ThinkNode_Conditional.TryIssueJobPackage(Verse.Pawn pawn, Verse.AI.JobIssueParams jobParams) [0x00000] in < 38562b1a2ab64eacb931fb5df05ca994 >:0 - at Verse.AI.ThinkNode_Priority.TryIssueJobPackage(Verse.Pawn pawn, Verse.AI.JobIssueParams jobParams) [0x00022] in < 38562b1a2ab64eacb931fb5df05ca994 >:0 -UnityEngine.StackTraceUtility:ExtractStackTrace() -Verse.Log:Error(string) -Verse.AI.ThinkNode_Priority:TryIssueJobPackage(Verse.Pawn, Verse.AI.JobIssueParams) -Verse.AI.ThinkNode_SubtreesByTag:TryIssueJobPackage(Verse.Pawn, Verse.AI.JobIssueParams) -Verse.AI.ThinkNode_Priority:TryIssueJobPackage(Verse.Pawn, Verse.AI.JobIssueParams) -Verse.AI.Pawn_JobTracker:DetermineNextJob(Verse.ThinkTreeDef &) -Verse.AI.Pawn_JobTracker:TryFindAndStartJob() -Verse.AI.Pawn_JobTracker:EndCurrentJob(Verse.AI.JobCondition, bool, bool) -Verse.AI.Pawn_JobTracker:JobTrackerTick() -Verse.Pawn:Tick() -Verse.TickList:Tick() -(wrapper dynamic - method) Verse.TickManager:Verse.TickManager.DoSingleTick_Patch2(Verse.TickManager) -Verse.TickManager:TickManagerUpdate() -Verse.Game:UpdatePlay() -Verse.Root_Play:Update() -*/ \ No newline at end of file diff --git a/Source/Genes/Hive/Abilities/CompAbilityEffect_SpawnSpelopede.cs b/Source/Genes/Hive/Abilities/CompAbilityEffect_SpawnSpelopede.cs new file mode 100644 index 0000000..4932949 --- /dev/null +++ b/Source/Genes/Hive/Abilities/CompAbilityEffect_SpawnSpelopede.cs @@ -0,0 +1,80 @@ +using Verse; +using RimWorld; +using rjw; +using RimWorld.Planet; +using System; + +namespace RJW_Genes +{ + /// + /// Spawns tame spelopedes at the caster. + /// + /// TODO: Play some sound? I think this can be done with some CompProperties. + /// + public class CompAbilityEffect_SpawnSpelopede : CompAbilityEffect + { + public CompProperties_AbilitySpawnSpelopede Props => (CompProperties_AbilitySpawnSpelopede) this.props; + + public override void Apply(LocalTargetInfo target, LocalTargetInfo dest) + { + base.Apply(target, dest); + + + int spelopedesToSpawn = CalculateSpelopedeAmount(); + if (RJW_Genes_Settings.rjw_genes_detailed_debug) ModLog.Message($"Using Spelopede Spawn, spawning {spelopedesToSpawn}"); + + for (int i = 0; i < spelopedesToSpawn; i++) { + var request = new PawnGenerationRequest( + this.Props.pawnKindDef, + faction: this.parent.pawn.Faction, + forceGenerateNewPawn: true, + fixedBiologicalAge: 0.0f, + fixedChronologicalAge: 0.0f, + canGeneratePawnRelations: false, + colonistRelationChanceFactor: 0.0f + ); + + + Pawn insect = PawnGenerator.GeneratePawn(request); + PawnUtility.TrySpawnHatchedOrBornPawn(insect, this.parent.pawn); + + if (Props.tamed) + { + insect.training.Train(TrainableDefOf.Tameness, this.parent.pawn, true); + insect.training.Train(TrainableDefOf.Obedience, this.parent.pawn, true); + insect.training.Train(TrainableDefOf.Release, this.parent.pawn, true); + + // I could do bonding here, but I think it's nicer if the queen is not "bonded" to their offspring. + } + } + + MakeDirt(1); + + if (RJW_Genes_Settings.rjw_genes_detailed_debug) ModLog.Message("Finished Spelopede Spawn"); + + } + + private int CalculateSpelopedeAmount() + { + Pawn caster = this.parent.pawn; + float spelopedes = Props.sensitivityMultiplier * caster.psychicEntropy.PsychicSensitivity; + return (spelopedes > 1.49f) ? (int)Math.Round(spelopedes) : 1; + } + + private void MakeDirt(int multiplier = 1) + { + Pawn caster = this.parent.pawn; + + FilthMaker.TryMakeFilth(caster.Position, caster.Map, ThingDefOf.Filth_AmnioticFluid, caster.LabelIndefinite(), count: Rand.Range(5,5*multiplier)); + } + + public override bool Valid(LocalTargetInfo target, bool throwMessages = false) + { + if (!target.Cell.Filled(this.parent.pawn.Map) && (target.Cell.GetEdifice(this.parent.pawn.Map) == null)) + return true; + if (throwMessages) + Messages.Message((string)("CannotUseAbility".Translate((NamedArgument)this.parent.def.label) + ": " + "AbilityOccupiedCells".Translate()), (LookTargets)target.ToTargetInfo(this.parent.pawn.Map), MessageTypeDefOf.RejectInput, false); + return false; + } + } +} diff --git a/Source/Genes/Hive/Abilities/CompProperties_AbilitySpawnSpelopede.cs b/Source/Genes/Hive/Abilities/CompProperties_AbilitySpawnSpelopede.cs new file mode 100644 index 0000000..1bf71df --- /dev/null +++ b/Source/Genes/Hive/Abilities/CompProperties_AbilitySpawnSpelopede.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; +using RimWorld; + +namespace RJW_Genes +{ + public class CompProperties_AbilitySpawnSpelopede : CompProperties_AbilityEffect + { + public PawnKindDef pawnKindDef; + public float sensitivityMultiplier; + public bool tamed; + public CompProperties_AbilitySpawnSpelopede() + { + this.compClass = typeof(CompAbilityEffect_SpawnSpelopede); + } + } +} diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index dbb4495..95fa262 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -87,7 +87,9 @@ + +