How do raiders get generated?

Started by Albion, October 02, 2017, 03:01:04 PM

Previous topic - Next topic

Albion

Hey guys, I need some help figuring out the way raids and specifically the amount and kind of raiders are being generated.
I understand how the points for the raids are calculated (Wealth Items + (Wealth Buildings)/2 + Pawns * 42).

I also figured out that each faction def has it's own list of <pawnGroupMakers> to pick its raiders from.
However I wasn't really able to find/understand how exactly the PawnGroupMaker generates the actual raiders.
It basically boils down to the following questions:

Where exactly do the points come in and what exactly do they determine?
What are the values in the factionDef under PawnGroupMakers? What exactly do they influence?
Example:
<MercenarySlasher>70</MercenarySlasher>
<MercenaryElite>100</MercenaryElite>

In the factionDef for mechanoids I also found the following value: <maxPawnOptionCostFactor>
Does this increase/decrease the amount of points a single pawn is worth while generating? How does it influence the pawn generation?

I'm asking all this because I want to create a custom faction with custom PawnKindDefs to create raids with more competent and better equipped raiders.

CannibarRechter

Probably has some relationship to the below file matches:



../Decompile> ls -recurse *.cs | sls -pattern raid | sls -pattern points

RimWorld\IncidentParmsUtility.cs:26:                parms.points *= parms.raidStrategy.pointsFactor;
RimWorld\IncidentParmsUtility.cs:42:                parms.points = Mathf.Max(parms.points, parms.raidStrategy.Worker.MinimumPoints(parms.faction) * 1.05f);
RimWorld\IncidentWorker_Raid.cs:25:        protected abstract void ResolveRaidPoints(IncidentParms parms);
RimWorld\IncidentWorker_Raid.cs:99:            this.ResolveRaidPoints(parms);
RimWorld\IncidentWorker_RaidEnemy.cs:52:        protected override void ResolveRaidPoints(IncidentParms parms)
RimWorld\IncidentWorker_RaidEnemy.cs:56:                Log.Error("RaidEnemy is resolving raid points. They should always be set before initiating the
incident.");
RimWorld\IncidentWorker_RaidFriendly.cs:62:        protected override void ResolveRaidPoints(IncidentParms parms)
RimWorld\IncidentWorker_RefugeeChased.cs:10:        private const float RaidPointsFactor = 1.35f;
RimWorld\PawnGroupMakerUtility.cs:17:        private static readonly SimpleCurve MaxPawnCostPerRaidPointsCurve = new SimpleCurve
RimWorld\PawnGroupMakerUtility.cs:57:        private static readonly SimpleCurve DesireToSuppressCountPerRaidPointsCurve = new SimpleCurve
RimWorld\PawnGroupMakerUtility.cs:125:            float num = PawnGroupMakerUtility.MaxAllowedPawnGenOptionCost(parms.faction, points, parms.raidStrategy);
RimWorld\PawnGroupMakerUtility.cs:157:                float desireToSuppressCount =
PawnGroupMakerUtility.DesireToSuppressCountPerRaidPointsCurve.Evaluate(points);
RimWorld\PawnGroupMakerUtility.cs:191:        private static float MaxAllowedPawnGenOptionCost(Faction faction, float totalPoints, RaidStrategyDef
raidStrategy)
RimWorld\PawnGroupMakerUtility.cs:193:            float num = PawnGroupMakerUtility.MaxPawnCostPerRaidPointsCurve.Evaluate(totalPoints);
RimWorld\PawnGroupMakerUtility.cs:197:                num = Mathf.Min(num, totalPoints / raidStrategy.minPawns);
RimWorld\PawnGroupMakerUtility.cs:238:                            PawnGroupMakerUtility.MaxAllowedPawnGenOptionCost(fac, points,
RaidStrategyDefOf.ImmediateAttack),
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

Albion

Well true there is a relationship but from that file I still can't reverse engineer how the raiders get generated and how much points any given raider costs.
I looked in the assembly too but was unable to find the answer to my questions above.

CannibarRechter

Well, I don't really know the answer to your question. I was just showing you the technique I used to be exploring it. Typically, I use a lot of search pattern matches, find good candidate files, and start reading.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

Vindar

#4
from what i can tell, the numbers found in the faction defs, the <pawnGroupMakers> aren't tied to the number of pawns spawned, but rather the ratio at which specific pawns are spawned, ergo

lines 166-169 in Factions_Misc.xml

        <guards>
          <TribalWarrior>60</TribalWarrior>
          <TribalArcher>100</TribalArcher>
        </guards>

This is saying that for every 10 tribal archers spawned 6 tribal warriors will also be spawned, or if 16 pawns are spawned 10 will be archers and 6 will be warriors.

as far as how many are spawned that is determined by points. the game calculates a number rating for the colony(prolly what was stated in a post above), than spawns the amount of pawns related to that rating.

to find the number of pawns we have to look into a different file, specifically for this example:

PawnKindDefs_Humanlikes ~> PawnKinds_Tribal.xml

for the tribal warrior

line 17:
<combatPower>38</combatPower>

and for the tribal archer

Line 48:
    <combatPower>48</combatPower>

higher numbers means less pawns are spawned as each one takes up more points to spawn. lower numbers means more pawns are spawned.

not sure if that gives you what you need but hopefully it works.

P.S.
If anyone knows what <maxPawnOptionCostFactor> does i'm trying to figure it out myself. any insight would be appreciated (thats what i was looking for when i found this post)

CannibarRechter

It is used only once in the Core, in PawnGroupMakerUtility, thus:


private static float MaxAllowedPawnGenOptionCost(Faction faction, float totalPoints, RaidStrategyDef raidStrategy)
{
float num = PawnGroupMakerUtility.MaxPawnCostPerRaidPointsCurve.Evaluate(totalPoints);
num *= faction.def.maxPawnOptionCostFactor;
if (raidStrategy != null)
{
num = Mathf.Min(num, totalPoints / raidStrategy.minPawns);
}
num = Mathf.Max(num, faction.def.MinPointsToGenerateNormalPawnGroup() * 1.2f);
if (raidStrategy != null)
{
num = Mathf.Max(num, raidStrategy.Worker.MinMaxAllowedPawnGenOptionCost(faction) * 1.2f);
}
return num;
}
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects