Skip to content

Commit

Permalink
4.3.6, zombies no longer eat teleported colonists
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Oct 6, 2023
1 parent afb6f92 commit ba5ebdc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<li>Multiplayer</li>
</incompatibleWith>
<packageId>brrainz.zombieland</packageId>
<modVersion>4.3.5.0</modVersion>
<modVersion>4.3.6.0</modVersion>
<steamAppId>928376710</steamAppId>
<description>Do you like The Walking Dead? Are you afraid of The Undead? Good. Because this mod will give you the Heebie-jeebies!

Expand Down
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>net.pardeike.rimworld.mod.zombieland</identifier>
<version>4.3.5.0</version>
<version>4.3.6.0</version>
<targetVersions>
<li>1.4.0</li>
</targetVersions>
Expand Down
Binary file modified Assemblies/ZombieLand.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ModName>ZombieLand</ModName>
<ModFileName>ZombieLand</ModFileName>
<Repository>https://github.com/pardeike/Zombieland</Repository>
<ModVersion>4.3.5.0</ModVersion>
<ModVersion>4.3.6.0</ModVersion>
<ProjectGuid>{34AA2AF2-8E82-4C5B-8ABA-9AC53DA7C110}</ProjectGuid>
</PropertyGroup>

Expand Down
9 changes: 9 additions & 0 deletions Source/JobDriver_Stumble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ public class JobDriver_Stumble : JobDriver

public Thing eatTarget;
public Pawn lastEatTarget;
public IntVec3 lastEatTargetPosition;
public int eatDelayCounter;
public int eatDelay;

void InitAction()
{
destination = IntVec3.Invalid;
lastEatTargetPosition = IntVec3.Invalid;
}

public override void ExposeData()
Expand All @@ -27,12 +29,16 @@ public override void ExposeData()
Scribe_Values.Look(ref destination, "destination", IntVec3.Invalid);
Scribe_References.Look(ref eatTarget, "eatTarget");
Scribe_References.Look(ref lastEatTarget, "lastEatTarget");
Scribe_Values.Look(ref lastEatTargetPosition, "lastEatTargetPosition", IntVec3.Invalid);
Scribe_Values.Look(ref eatDelayCounter, "eatDelayCounter");

// previous versions of Zombieland stored the inner pawn of a corpse
// in the eatTarget. We have since then changed it to contain the corpse
// itself. For older saves, we need to convert this.
//
// we also need to update lastEatTargetPosition since it was not present
// in older saves
//
if (Scribe.mode == LoadSaveMode.PostLoadInit)
{
if (eatTarget is Pawn p && p.Map != null)
Expand All @@ -43,6 +49,9 @@ public override void ExposeData()
.OfType<Corpse>()
.FirstOrDefault(c => c.InnerPawn == eatTarget);
}

// update lastEatTargetPosition
lastEatTargetPosition = lastEatTarget?.Position ?? IntVec3.Invalid;
}
}

Expand Down
6 changes: 4 additions & 2 deletions Source/ZombieStateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,11 @@ public static bool Eat(this JobDriver_Stumble driver, Zombie zombie, PheromoneGr
if (zombie.hasTankyShield != -1f || zombie.hasTankyHelmet != -1f || zombie.hasTankySuit != -1f)
return false;

if (driver.eatTarget != null && driver.eatTarget.Spawned == false)
if (driver.eatTarget != null && (driver.eatTarget.Spawned == false || driver.eatTarget.Position != driver.lastEatTargetPosition))
{
driver.eatTarget = null;
driver.lastEatTarget = null;
driver.lastEatTargetPosition = IntVec3.Invalid;
driver.eatDelayCounter = 0;
}
if (driver.eatTarget == null && grid.GetZombieCount(zombie.Position) <= 2)
Expand Down Expand Up @@ -371,7 +372,8 @@ static bool LeanAndDelay(this JobDriver_Stumble driver, Zombie zombie, Pawn eatT
if (eatTargetPawn != driver.lastEatTarget)
{
driver.lastEatTarget = eatTargetPawn;
zombie.rotationTracker.FaceCell(driver.eatTarget.Position);
driver.lastEatTargetPosition = eatTargetPawn.Position;
zombie.rotationTracker.FaceCell(driver.lastEatTargetPosition);
if (zombie.Drawer.leaner is ZombieLeaner zombieLeaner)
{
var offset = (driver.eatTarget.Position.ToVector3() - zombie.Position.ToVector3()) * 0.5f;
Expand Down

0 comments on commit ba5ebdc

Please sign in to comment.