Trying to learn more about infestations, why is this happening?

Started by Ronar1, August 04, 2018, 03:44:55 AM

Previous topic - Next topic

Ronar1

https://imgur.com/a/sivnnP2

So I've done some research and have learned quite a bit about infestations. One big question is, why does the giant box to the left of the base have such an uneven distribution for infestation chance? Also why do the rooms to the right still have an infestation chance despite being lit up and such? Is this a result of being deeper in the mountain or because those rooms are recently dug out and still need cleaning? Is there any way I can force the infestation to be completely in the big room without sacrificing comfortable temperature? Currently I've forced temperature in the big room to be much higher to test some stuff so don't mind the lack of heaters to keep it warm.

Edit: This is for the latest 1.0 updates.

Panzer

If I recall correctly the bugs prefer rocky ground and darkness, thats why theres such a high chance in that area. Bug hives used to die under -21C  by the way, dont know if thats still the case though.

Ronar1

Quote from: Panzer on August 04, 2018, 03:53:04 AM
If I recall correctly the bugs prefer rocky ground and darkness, thats why theres such a high chance in that area. Bug hives used to die under -21C  by the way, dont know if thats still the case though.

Yeah I tried to light everything up with lamps except that room. So when you say rocky ground, do smooth floors have a difference vs rugged stone floors or do they both count as rocky for spawning purposes? Or did you mean rock chunks increased the spawn chances? Also I believe bugs have a better range of temperature tolerance in one of the patches in 1.0, but I'm not 100% sure, just remember someone mentioning that.

Greep

The reason the room to the left gets deeper blue the further it goes in is exactly what it looks like:  the game checks each cell to see how far it is from an area that isn't underground and gives more weight the deeper it is.  It does a weird mix of codey stuff to determine "how far" but that's not terribly important.

Actually, everyone seems to always bring up wanting to know how infestations work so people are just going to keep asking until someone posts this, so... yay code guts:

private static float GetScoreAt(IntVec3 cell, Map map)
{
   if ((float)(int)distToColonyBuilding[cell] > 30f)
   {
      return 0f; <-- 0 means never.  If all parts of the map are 0, the infestation does not happen.  Bigger number means more likely.
   }
   if (!cell.Walkable(map)) <--don't worry about this
   {
      return 0f;
   }
   if (cell.Fogged(map)) <-- don't worry about this
   {
      return 0f;
   }
   if (CellHasBlockingThings(cell, map)) <-- can't spawn on pawns, other hives.  YES on buildings tho
   {
      return 0f;
   }
   if (cell.Roofed(map) && cell.GetRoof(map).isThickRoof)
   {
      Region region = cell.GetRegion(map, RegionType.Set_Passable);
      if (region == null)
      {
         return 0f;
      }
      if (closedAreaSize[cell] < 2) <- technically you can block a mountain infestation by making all your rooms 1x1
      {
         return 0f;
      }
      float temperature = cell.GetTemperature(map);
      if (temperature < -17f) <-17C hard cap.  Don't worry about the f, it's celsius
      {
         return 0f;
      }
      float mountainousnessScoreAt = GetMountainousnessScoreAt(cell, map);
      if (mountainousnessScoreAt < 0.17f) <-- won't happen on very small hills
      {
         return 0f;
      }
      int num = StraightLineDistToUnroofed(cell, map);
      float num2 = regionsDistanceToUnroofed.TryGetValue(region, out num2) ? Mathf.Min(num2, (float)num * 4f) : ((float)num * 1.15f); <-- regions are blocky, why your left room has squares
      num2 = Mathf.Pow(num2, 1.55f);
      float num3 = Mathf.InverseLerp(0f, 12f, (float)num);
      float num4 = Mathf.Lerp(1f, 0.18f, map.glowGrid.GameGlowAt(cell, false)); <-- 18% less likely at full light, more likely if darker
      float num5 = 1f - Mathf.Clamp(DistToBlocker(cell, map) / 11f, 0f, 0.6f); <--probably not important
      float num6 = Mathf.InverseLerp(-17f, -7f, temperature); <-- soft cap at -7C hard cap at -17C
      float f = num2 * num3 * num5 * mountainousnessScoreAt * num4 * num6; <--math
      f = Mathf.Pow(f, 1.2f);
      if (f < 7.5f) <-- huh.. didn't know that.  Guess you can stop a shallow infestation altogether outside of mountains using light or removing roofs
      {
         return 0f;
      }
      return f;
   }
   return 0f;
}
1.0 Mods: Raid size limiter:
https://ludeon.com/forums/index.php?topic=42721.0

MineTortoise:
https://ludeon.com/forums/index.php?topic=42792.0
HELLO!

(WIPish)Strategy Mode: The experienced player's "vanilla"
https://ludeon.com/forums/index.php?topic=43044.0

Ronar1


erdrik

Quote from: Greep on August 04, 2018, 04:22:44 AM
...
      if (closedAreaSize[cell] < 2) <- technically you can block a mountain infestation by making all your rooms 1x1
      {
         return 0f;
      }
...

Is this up to date?
Because Tynan implied 1x1's were intended, when I reported it as a bug.

Greep

It's up to date.  I'd have to do more digging to find out the exact reason, and I'm too lazy.  It's possible that the actual spawners for hives themselves have a bit of randomization once they determine a spot, or maybe there just is a bug.  To be clear, though, 2x2 should be allowed, as well as 1x2, just not 1x1.  Maybe it counts the doors themselves as part of the enclosed space?  *shrug*
1.0 Mods: Raid size limiter:
https://ludeon.com/forums/index.php?topic=42721.0

MineTortoise:
https://ludeon.com/forums/index.php?topic=42792.0
HELLO!

(WIPish)Strategy Mode: The experienced player's "vanilla"
https://ludeon.com/forums/index.php?topic=43044.0

zizard

Quote from: erdrik on August 04, 2018, 08:35:37 AM
Quote from: Greep on August 04, 2018, 04:22:44 AM
...
      if (closedAreaSize[cell] < 2) <- technically you can block a mountain infestation by making all your rooms 1x1
      {
         return 0f;
      }
...

Is this up to date?
Because Tynan implied 1x1's were intended, when I reported it as a bug.

Maybe he didn't realise that the doors were there beforehand?

RawCode

infestation is event like any other, like fallout or volcanic winter.
when event is triggered, game roll infestation scores for each cell on map, cells that fit specific reqs are put into list and random one is selected.


private static void CalculateLocationCandidates(Map map)
{
InfestationCellFinder.locationCandidates.Clear();
InfestationCellFinder.CalculateTraversalDistancesToUnroofed(map);
InfestationCellFinder.CalculateClosedAreaSizeGrid(map);
InfestationCellFinder.CalculateDistanceToColonyBuildingGrid(map);
for (int i = 0; i < map.Size.z; i++)
{
for (int j = 0; j < map.Size.x; j++)
{
IntVec3 cell = new IntVec3(j, 0, i);
float scoreAt = InfestationCellFinder.GetScoreAt(cell, map);
if (scoreAt > 0f)
{
InfestationCellFinder.locationCandidates.Add(new InfestationCellFinder.LocationCandidate(cell, scoreAt));
}
}
}
}


there is no randomness involved on candidate calculation, with specific knowledge you can ensure, that infestation will happen inside specific room if happen at all.