Skip to content

Commit 6e45d65

Browse files
Fixes to offering wordings.
Forced Revia to auto-generate Bloodlust trait if one somehow spawns without it. Added Stonecutting as a default tech for Revia scenario. Added alternative method of levelling Soul Reaping. Trophies or raw meat can be offered to gain Palestones. Palestones are less efficient than Bloodstones, but are easier to get in large quantities. Refactor of blessing invocation, to allow for easier addition of different ways to gain blessings.
1 parent afe97c5 commit 6e45d65

18 files changed

+329
-47
lines changed

1.1/Assemblies/ReviaRace.dll

1.5 KB
Binary file not shown.

1.1/Defs/MiscItemDefs/Bloodstone.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<useLabel>Make offering</useLabel>
3737
</li>
3838
<li Class="CompProperties_UseEffect">
39-
<compClass>ReviaRace.Comps.InvokeBlessing</compClass>
39+
<compClass>ReviaRace.Comps.InvokeGreaterBlessing</compClass>
4040
</li>
4141
</comps>
4242
</ThingDef>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Defs>
3+
<ThingDef ParentName="ResourceBase">
4+
<defName>ReviaRacePalestone</defName>
5+
<label>palestone</label>
6+
<description>A lesser blessing given by the Revian pantheon. Supposedly confers divine favour on the user.</description>
7+
<thingClass>ThingWithComps</thingClass>
8+
<techLevel>Archotech</techLevel>
9+
<graphicData>
10+
<texPath>Things/Item/Health/HealthItem</texPath>
11+
<graphicClass>Graphic_Single</graphicClass>
12+
<drawSize>0.80</drawSize>
13+
<color>(220, 220, 200)</color>
14+
</graphicData>
15+
<stackLimit>2000</stackLimit>
16+
<thingCategories>
17+
<li>Artifacts</li>
18+
</thingCategories>
19+
<tradeTags>
20+
<li>Artifact</li>
21+
</tradeTags>
22+
<tradeability>Sellable</tradeability>
23+
<statBases>
24+
<Mass>0.01</Mass>
25+
<MarketValue>20</MarketValue>
26+
<MaxHitPoints>1000</MaxHitPoints>
27+
<Flammability>0.0</Flammability>
28+
<DeteriorationRate>0.0</DeteriorationRate>
29+
<Beauty>4</Beauty>
30+
</statBases>
31+
<altitudeLayer>Item</altitudeLayer>
32+
<tickerType>Never</tickerType>
33+
<comps>
34+
<li Class="CompProperties_Usable">
35+
<useJob>UseArtifact</useJob>
36+
<useLabel>Make offering</useLabel>
37+
</li>
38+
<li Class="CompProperties_UseEffect">
39+
<compClass>ReviaRace.Comps.InvokeLesserBlessing</compClass>
40+
</li>
41+
</comps>
42+
</ThingDef>
43+
</Defs>

1.1/Defs/RaceDefs/ReviaRace.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,9 @@
429429
<li>
430430
<compClass>ReviaRace.Comps.SoulReaper</compClass>
431431
</li>
432+
<li>
433+
<compClass>ReviaRace.Comps.ReviaRaceOnSpawn</compClass>
434+
</li>
432435
</comps>
433436
</AlienRace.ThingDef_AlienRace>
434437
</Defs>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Defs>
3+
<RecipeDef>
4+
<defName>ReviaRaceSacrificeElephantTusk</defName>
5+
<label>sacrifice elephant tusk</label>
6+
<description>Sacrifice an elephant tusk to honour the bloody gods of the Revian pantheon.</description>
7+
<jobString>Sacrificing to the gods.</jobString>
8+
<workAmount>240</workAmount>
9+
<workSpeedStat>ButcheryFleshSpeed</workSpeedStat>
10+
<workSkill>Cooking</workSkill>
11+
<efficiencyStat>ButcheryFleshEfficiency</efficiencyStat>
12+
<effectWorking>Smelt</effectWorking>
13+
<soundWorking>Recipe_Smelt</soundWorking>
14+
<ingredients>
15+
<li>
16+
<filter>
17+
<thingDefs>
18+
<li>ElephantTusk</li>
19+
</thingDefs>
20+
</filter>
21+
<count>1</count>
22+
</li>
23+
</ingredients>
24+
<products>
25+
<ReviaRacePalestone>128</ReviaRacePalestone>
26+
</products>
27+
<recipeUsers>
28+
<li>ReviaSacrificeSpot</li>
29+
</recipeUsers>
30+
</RecipeDef>
31+
</Defs>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Defs>
3+
<RecipeDef>
4+
<defName>ReviaRaceSacrificeRawMeat</defName>
5+
<label>sacrifice raw meat</label>
6+
<description>Sacrifice some raw meat to honour the bloody gods of the Revian pantheon.</description>
7+
<jobString>Sacrificing to the gods.</jobString>
8+
<workAmount>240</workAmount>
9+
<workSpeedStat>ButcheryFleshSpeed</workSpeedStat>
10+
<workSkill>Cooking</workSkill>
11+
<efficiencyStat>ButcheryFleshEfficiency</efficiencyStat>
12+
<effectWorking>ButcherFlesh</effectWorking>
13+
<soundWorking>Recipe_ButcherCorpseFlesh</soundWorking>
14+
<allowMixingIngredients>true</allowMixingIngredients>
15+
<ingredientValueGetterClass>IngredientValueGetter_Nutrition</ingredientValueGetterClass>
16+
<fixedIngredientFilter>
17+
<categories>
18+
<li>MeatRaw</li>
19+
</categories>
20+
<specialFiltersToDisallow>
21+
<li>AllowPlantFood</li>
22+
<li>AllowRotten</li>
23+
</specialFiltersToDisallow>
24+
</fixedIngredientFilter>
25+
<ingredients>
26+
<li>
27+
<filter>
28+
<categories>
29+
<li>MeatRaw</li>
30+
</categories>
31+
</filter>
32+
<count>20</count>
33+
</li>
34+
</ingredients>
35+
<products>
36+
<ReviaRacePalestone>100</ReviaRacePalestone>
37+
</products>
38+
<recipeUsers>
39+
<li>ReviaSacrificeSpot</li>
40+
</recipeUsers>
41+
</RecipeDef>
42+
</Defs>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Defs>
3+
<RecipeDef>
4+
<defName>ReviaRaceSacrificeThrumboHorn</defName>
5+
<label>sacrifice thrumbo horn</label>
6+
<description>Sacrifice a thrumbo horn to honour the bloody gods of the Revian pantheon.</description>
7+
<jobString>Sacrificing to the gods.</jobString>
8+
<workAmount>240</workAmount>
9+
<workSpeedStat>ButcheryFleshSpeed</workSpeedStat>
10+
<workSkill>Cooking</workSkill>
11+
<efficiencyStat>ButcheryFleshEfficiency</efficiencyStat>
12+
<effectWorking>Smelt</effectWorking>
13+
<soundWorking>Recipe_Smelt</soundWorking>
14+
<ingredients>
15+
<li>
16+
<filter>
17+
<thingDefs>
18+
<li>ThrumboHorn</li>
19+
</thingDefs>
20+
</filter>
21+
<count>1</count>
22+
</li>
23+
</ingredients>
24+
<products>
25+
<ReviaRacePalestone>1024</ReviaRacePalestone>
26+
</products>
27+
<recipeUsers>
28+
<li>ReviaSacrificeSpot</li>
29+
</recipeUsers>
30+
</RecipeDef>
31+
</Defs>

1.1/Defs/Scenarios/ReviaExclave.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
<method>Standing</method>
2323
<visible>false</visible>
2424
</li>
25+
26+
<!-- Starting research -->
27+
<li Class="ScenPart_StartingResearch">
28+
<def>StartingResearch</def>
29+
<project>Stonecutting</project>
30+
</li>
2531

2632
<!--Player starting things-->
2733
<li Class="ScenPart_StartingThing_Defined">

Source/Comps/InvokeBlessing.cs

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,73 +8,97 @@
88

99
namespace ReviaRace.Comps
1010
{
11-
public class InvokeBlessing : CompUseEffect
11+
public abstract class InvokeBlessing : CompUseEffect
1212
{
1313
public override void DoEffect(Pawn pawn)
1414
{
1515
base.DoEffect(pawn);
16-
var srComp = pawn.GetComp<SoulReaper>();
17-
Messages.Message($"{pawn.Name} offers some bloodstones to the bloody god.", pawn, MessageTypeDefOf.NeutralEvent, false);
1816

19-
if (pawn.MapHeld == null || srComp == null)
17+
if (!ViabilityCheck(pawn))
2018
{
21-
Messages.Message($"Invalid target. srcomp null = {srComp == null}", pawn, MessageTypeDefOf.CautionInput, false);
2219
return;
2320
}
2421

25-
var soulReapTier = srComp.GetSoulReapTier();
26-
if (soulReapTier == -1)
27-
{
28-
Messages.Message("The bloodstone does nothing for the uninitiated...", pawn, MessageTypeDefOf.NegativeEvent, false);
29-
return;
30-
}
31-
else if (soulReapTier == 9)
32-
{
33-
Messages.Message($"{pawn.Name} is already at the height of {pawn.ProSubj()} power!", pawn, MessageTypeDefOf.NeutralEvent, false);
34-
return;
35-
}
22+
var srComp = pawn.GetComp<SoulReaper>();
23+
var srTier = srComp.GetSoulReapTier();
24+
var cost = CalculateAdvanceCost(srTier);
3625

37-
// Check that we have enough bloodstones in the stack to proceed.
38-
int cost = CalculateAdvanceCost(soulReapTier);
3926
if (cost > parent.stackCount)
4027
{
41-
Messages.Message($"{pawn.Name}'s offering was rejected. The blood god demands more blood.", pawn, MessageTypeDefOf.NeutralEvent, false);
28+
Messages.Message($"{pawn.NameShortColored}'s offering was rejected. The blood god demands more blood.", pawn, MessageTypeDefOf.NeutralEvent, false);
29+
Messages.Message($"{cost} {parent.LabelNoCount}s were demanded.", pawn, MessageTypeDefOf.NeutralEvent, false);
4230
return;
31+
}
32+
else
33+
{
34+
DecrementOnUse(pawn, cost);
35+
IncreaseSoulReapTier(pawn);
4336
}
37+
}
38+
39+
/// <summary>
40+
/// Increase the soul reap tier of this pawn.
41+
/// </summary>
42+
/// <param name="pawn">The pawn to increase the Soul Reap tier of.</param>
43+
protected void IncreaseSoulReapTier(Pawn pawn)
44+
{
45+
var srComp = pawn.GetComp<SoulReaper>();
46+
var soulReapTier = srComp.GetSoulReapTier();
4447

4548
// Blood for the blood god! Skulls for the skull throne!
4649
srComp.RemoveSoulReapHediffs();
4750
srComp.AddSoulReapTier(soulReapTier + 1);
48-
Messages.Message($"The blessing has succeeded, and {pawn.Name} has grown stronger.", pawn, MessageTypeDefOf.PositiveEvent);
51+
52+
Messages.Message($"The blessing has succeeded, and {pawn.NameShortColored} has grown stronger.", pawn, MessageTypeDefOf.PositiveEvent);
53+
}
4954

50-
// Destroy the bloodstones that were used up. If there were exactly enough, destroy the stack.
55+
/// <summary>
56+
/// Decrement the number of consumed items. If the count would be zero or less, destroy the stack.
57+
/// </summary>
58+
/// <param name="pawn">The pawn using the stack.</param>
59+
/// <param name="cost">The cost of the invocation.</param>
60+
protected void DecrementOnUse(Pawn pawn, int cost)
61+
{
62+
Messages.Message($"{cost} {parent.LabelNoCount}(s) were consumed in {pawn.NameShortColored}'s offering.", pawn, MessageTypeDefOf.NeutralEvent);
5163
if (parent.stackCount == cost)
5264
{
5365
parent.Destroy();
5466
}
55-
else
67+
else if (parent.stackCount > cost)
5668
{
5769
parent.stackCount -= cost;
5870
}
71+
else
72+
{
73+
throw new ArgumentException("Attempting to use more items than is available!");
74+
}
5975
}
6076

77+
protected abstract int CalculateAdvanceCost(int tier);
78+
6179
/// <summary>
62-
/// The cost of advancing is 2 ^ (n-2) bloodstones,
80+
/// Checks if the pawn is eligible to advance soul reap tiers.
6381
/// </summary>
64-
/// <param name="pawn">The pawn to check</param>
65-
/// <returns>True if the random number generated passes the RNG check.
66-
/// False if the hediff wasn't a soulreap that can be levelled up,
67-
/// or if the RNG check failed.</returns>
68-
private int CalculateAdvanceCost(int tier)
82+
/// <param name="pawn"></param>
83+
/// <returns></returns>
84+
protected bool ViabilityCheck(Pawn pawn)
6985
{
70-
if (tier == -1 || tier == 9)
86+
var srComp = pawn.GetComp<SoulReaper>();
87+
Messages.Message($"{pawn.Name} offers some {parent.LabelNoCount}s to the bloody god.", pawn, MessageTypeDefOf.NeutralEvent, false);
88+
89+
var soulReapTier = srComp.GetSoulReapTier();
90+
if (soulReapTier == -1)
7191
{
72-
return -1;
92+
Messages.Message($"The {parent.LabelNoCount} does nothing for the uninitiated...", pawn, MessageTypeDefOf.NegativeEvent, false);
93+
return false;
94+
}
95+
else if (soulReapTier == 9)
96+
{
97+
Messages.Message($"{pawn.NameShortColored} is already at the height of {pawn.ProSubj()} power!", pawn, MessageTypeDefOf.NeutralEvent, false);
98+
return false;
7399
}
74100

75-
double cost = Math.Max(1.0, Math.Pow(2, tier - 2));
76-
77-
return (int)cost;
101+
return true;
78102
}
79103
}
80104
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using RimWorld;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Verse;
8+
9+
namespace ReviaRace.Comps
10+
{
11+
public class InvokeGreaterBlessing : InvokeBlessing
12+
{
13+
/// <summary>
14+
/// The cost of advancing is 2 ^ (n-2) bloodstones,
15+
/// </summary>
16+
/// <param name="pawn">The pawn to check</param>
17+
/// <returns>The cost (in bloodstones) required to advance the Soul Reap tier.</returns>
18+
protected override int CalculateAdvanceCost(int tier)
19+
{
20+
if (tier == -1 || tier == 9)
21+
{
22+
return -1;
23+
}
24+
25+
double cost = Math.Max(1.0, Math.Pow(2, tier - 2));
26+
27+
return (int)cost;
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)