Jump to content

YOU'VE REACHED THE MAX AMOUNT OF ANIMALS IN YOUR FARM! (lies)

Closed 1.1.0

Covfefe
Covfefe

Posted (edited)

only the bear is alive but it says my farm is full?

252490_20250405222838_1.png.3d0ae11c1cccae6decca33b9cc8a5fdc.png

252490_20250405222943_1.png.8ba1781f620cc4311b431232c7dc946b.png

Edited by Covfefe
Covfefe

Posted

just found out they're in the sky!

252490_20250405223901_1.png.5dc9da3e295528b05639e04a475a1e68.png

Covfefe

Posted

ok so stags and boars spawn in the sky while bears and wolves stay in the pen

252490_20250405224308_1.png.61dcee0fb22aa92907d9f16ead36f41a.png

 

i'm gonna make a new farm and try again since i updated the plugin

Razor

Posted

Try removing the celling and see if that has an effect?

 

Covfefe

Posted

made a new farm and boars and stags are still in the sky instead of farm

Razor

Posted

Just now, Covfefe said:

made a new farm and boars and stags are still in the sky instead of farm

try and remove the celing does that change anything?

Covfefe

Posted

1 minute ago, Razor said:

try and remove the celing does that change anything?

Still spawned in the sky with no ceiling

252490_20250405225055_1.png.1ebab512e25c06ebb52300a955a1582d.png

Covfefe

Posted (edited)

here's what grok has to say about it

Quote

The issue where only boars and stags spawn in the sky in your AnimalFarm plugin for Rust likely stems from how the spawning logic interacts with the IsFoundation flag and the navigation mesh (NavMesh) or terrain height calculations. Let's analyze the problem and identify potential causes based on your code.

Key Observations

Spawning Logic:

The SpawnPig method (line 1346) is responsible for spawning animals (boars, stags, bears, and wolves) and adjusts their spawn position based on the IsFoundation flag.

If IsFoundation is false, the y coordinate of the spawn position is set to the terrain height using TerrainMeta.HeightMap.GetHeight(pos) (line 1349), and then it attempts to find a valid NavMesh position with FindPointOnNavmesh (line 1350).

If IsFoundation is true, the spawn position is used as-is without terrain or NavMesh adjustment.

Animal-Specific Behavior:

You mentioned that only boars and stags spawn in the sky, while bears and wolves do not. This suggests a difference in how their spawn positions are calculated or applied.

In the BuyBear and BuyWolf methods (lines 2476 and 2500), the spawn position is calculated with a random z offset (UnityEngine.Random.Range(2.5f, 4.5f)), while BuyPig (boars) and BuyStag use GetBestSpawnPosition without such an offset.

Foundation vs. Non-Foundation Farms:

If IsFoundation is true, the animals should spawn relative to the hitch trough’s position without terrain adjustment, which could place them above the ground if the trough is elevated (e.g., on a foundation).

If IsFoundation is false, the terrain height and NavMesh should constrain the spawn position, but this might fail for boars and stags due to how their positions are generated or processed.

NavMesh and Pathfinding:

The CustomFarmAnimalBrain class enables NavMesh usage only when IsFoundation is true (line 1883). For non-foundation farms, it uses a basic pathfinder, which might not properly ground the animals if their initial spawn position is incorrect.

Likely Causes

Here are the potential reasons why boars and stags spawn in the sky, while bears and wolves do not:

Spawn Position Calculation:

In FarmBehavior.GenerateRoam (line 2339), the roam positions (used by GetBestSpawnPosition) are calculated relative to the hitch trough’s position. For foundation-based farms, the y coordinate is adjusted downward by 8.7 units (y = hitch.transform.position.y - 8.7f). If this adjustment is insufficient or the foundation height varies, boars and stags might spawn above the ground.

Bears and wolves, however, use a different spawn position in BuyBear and BuyWolf (random z offset directly from the hitch trough), which might coincidentally align better with the ground level.

NavMesh Failure:

The FindPointOnNavmesh method (line 1498) attempts to find a valid NavMesh position within a 4-unit radius. If this fails (e.g., no NavMesh exists at the spawn point), it returns null, and the animal spawns at the unadjusted position, potentially in the air. This might affect boars and stags more if their spawn positions (GetBestSpawnPosition) are less likely to intersect with the NavMesh than the random offsets used for bears and wolves.

Foundation Check Inconsistency:

The IsFoundation flag determines whether terrain height or NavMesh adjustments are applied. If this flag is incorrectly set (e.g., due to a bug in OnEntityBuilt at line 1219), boars and stags might not get proper grounding, while bears and wolves might benefit from a different spawn logic that accidentally works better.

Initialization Timing:

The ReInItFarms coroutine (line 229) reloads farms and spawns animals with their saved states. If the IsFoundation flag or spawn positions are not correctly restored, boars and stags might spawn at incorrect heights, especially if their GetBestSpawnPosition logic differs from bears and wolves.

Quote

Conclusion

The most likely culprit is a mismatch between the spawn position (GetBestSpawnPosition) for boars and stags and the expected ground level, exacerbated by foundation-based farms not properly adjusting the y coordinate or NavMesh failing to ground them. Bears and wolves avoid this issue due to their different spawn position logic. Start by logging the spawn positions and testing the IsFoundation behavior, then apply one of the fixes above based on your findings.

 

Edited by Covfefe
Razor

Posted

2 minutes ago, Covfefe said:

here's what grok has to say about it

 

Ya i must of medssed that part up roled that part back.

 

Covfefe

Posted

just noticed if the foundation is too close to the navmesh dirt, the wolf will choose the dirt instead of the foundation

252490_20250405230548_1.png.8699a498a91678fedbfaaa15650cb6ce.png252490_20250405230643_1.png.7443070abe8a58cb7f58cdd72a9fc011.png

Razor

Posted (edited)

4 minutes ago, Covfefe said:

just noticed if the foundation is too close to the navmesh dirt, the wolf will choose the dirt instead of the foundation

252490_20250405230548_1.png.8699a498a91678fedbfaaa15650cb6ce.png252490_20250405230643_1.png.7443070abe8a58cb7f58cdd72a9fc011.png

 

 

If the foundation is low to the ground they will glitch threw it there is not much i can do as its rust. and there not ment to be on foundation

 

Edited by Razor
  • Like 1
Razor

Posted

Changed Status from Pending to Closed

1.7m

Downloads

Total number of downloads.

7.9k

Customers

Total customers served.

119.5k

Files Sold

Total number of files sold.

2.4m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.