Skip to content

Commit

Permalink
balancing and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Jan 8, 2023
1 parent 8888a5a commit 9500ee7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 38 deletions.
Binary file modified 1.4/Assemblies/ZombieLand.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Source/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void DoWindowContentsInternal(ref SettingsGroup settings, ref List
list.Dialog_Checkbox("EnemiesAttackZombies", ref settings.enemiesAttackZombies);
list.Dialog_Checkbox("AnimalsAttackZombies", ref settings.animalsAttackZombies);
list.Gap(10f);
list.Dialog_IntSlider("WallPushing", n => n == 0 ? "Off".TranslateSimple() : n.ToString(), ref settings.minimumZombiesForWallPushing, 0, 32);
list.Dialog_IntSlider("WallPushing", n => n == 0 ? "Off".TranslateSimple() : n.ToString(), ref settings.minimumZombiesForWallPushing, 0, 48);
list.Gap(30f);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ public static void CastBlockBubble(Pawn attacker, Pawn defender)

static readonly ThingDef[] bumps = new ThingDef[] { CustomDefs.BumpSmall, CustomDefs.BumpMedium, CustomDefs.BumpLarge };
static readonly float[] nextBumps = new float[] { 0f, 0f, 0f };
public static void RandomBump(Map map, Vector3 pos, int idx)
public static void CastBumpMote(Map map, Vector3 pos, int idx)
{
var now = Time.time;
if (now < nextBumps[idx])
Expand Down
2 changes: 1 addition & 1 deletion Source/ZombieSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public class SettingsGroup : IExposable, ICloneable
public bool disableRandomApparel = false;
public bool floatingZombies = true;
public float childChance = 0.02f;
public int minimumZombiesForWallPushing = 16;
public int minimumZombiesForWallPushing = 24;

// unused
public int suicideBomberIntChance = 1;
Expand Down
66 changes: 31 additions & 35 deletions Source/ZombieStateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,19 @@ public static bool CheckWallPushing(Zombie zombie, PheromoneGrid grid)

var totalZombies = grid.GetZombieCount(pos);
var wallCount = 0;
IntVec3 wallCell = IntVec3.Invalid;
for (var i = 0; i < 4; i++)
{
var adjacent = pos + pushDirections[i];
if (adjacent.InBounds(map) == false)
continue;

totalZombies += grid.GetZombieCount(adjacent);
if (adjacent.IsWallOrDoor(map))
{
wallCell = adjacent;
wallCount++;
}
}
if (wallCount == 1)
totalZombies += 4;
Expand All @@ -121,48 +128,37 @@ public static bool CheckWallPushing(Zombie zombie, PheromoneGrid grid)
{
var diff = 3 - (minimum - totalZombies);
if (diff >= 0)
Tools.RandomBump(map, pos.ToVector3Shifted(), diff);
Tools.CastBumpMote(map, pos.ToVector3Shifted(), diff);
return false;
}

var tickManager = Find.CurrentMap.GetComponent<TickManager>();

for (var i = 0; i < 4; i++)
{
var direction = pushDirections[i];
var wallCell = pos + direction;
if (wallCell.InBounds(map) == false)
continue;

if (wallCell.IsWallOrDoor(map) == false)
continue;

var destination = wallCell + direction;
if (destination.WalkableBy(map, zombie) == false)
continue;
if (wallCount != 1)
return false;

var roof = zombie.Map.roofGrid.RoofAt(destination);
if (roof == RoofDefOf.RoofRockThick || roof == RoofDefOf.RoofRockThin)
continue;
var destination = wallCell + wallCell - pos;
if (destination.WalkableBy(map, zombie) == false)
return false;

if (tickManager.allZombiesCached.Any(z => z.Position == destination || z.wanderDestination == destination))
continue;
var roof = zombie.Map.roofGrid.RoofAt(destination);
if (roof == RoofDefOf.RoofRockThick || roof == RoofDefOf.RoofRockThin)
return false;

zombie.wallPushProgress = 0f;
zombie.wallPushStart = pos.ToVector3Shifted();
zombie.wallPushDestination = destination.ToVector3Shifted();
if (Constants.USE_SOUND)
CustomDefs.WallPushing.PlayOneShot(SoundInfo.InMap(new TargetInfo(pos, map)));
if (ZombieSettings.Values.dangerousSituationMessage)
if ("DangerousSituation".RunThrottled(5f))
{
var text = "ZombiesAreBeingPushedOverYourWalls".Translate();
Find.LetterStack.ReceiveLetter("DangerousSituation".Translate(), text, CustomDefs.DangerousSituation, zombie);
}
return true;
}
var tickManager = Find.CurrentMap.GetComponent<TickManager>();
if (tickManager.allZombiesCached.Any(z => z.Position == destination))
return false;

return false;
zombie.wallPushProgress = 0f;
zombie.wallPushStart = pos.ToVector3Shifted();
zombie.wallPushDestination = destination.ToVector3Shifted();
if (Constants.USE_SOUND)
CustomDefs.WallPushing.PlayOneShot(SoundInfo.InMap(new TargetInfo(pos, map)));
if (ZombieSettings.Values.dangerousSituationMessage)
if ("DangerousSituation".RunThrottled(5f))
{
var text = "ZombiesAreBeingPushedOverYourWalls".Translate();
Find.LetterStack.ReceiveLetter("DangerousSituation".Translate(), text, CustomDefs.DangerousSituation, zombie);
}
return true;
}

// handle roped zombies =====================================================================
Expand Down

0 comments on commit 9500ee7

Please sign in to comment.