Skip to content

Commit

Permalink
Zombieland v1.9.12
Browse files Browse the repository at this point in the history
Fix convert to zombie event
Make tank zombie not dig through mountains
Increase strength for tank zombies
Make suicide and tank zombie attack/smash quicker
  • Loading branch information
pardeike committed May 14, 2018
1 parent e568017 commit 1f2cfa3
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 34 deletions.
Binary file modified Assemblies/ZombieLand.dll
Binary file not shown.
24 changes: 14 additions & 10 deletions Source/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,15 @@ static void Postfix(ref IAttackTarget __result, Predicate<Thing> validator, IAtt
{
// the following can be improved by choosing targets that
// are not too close. unsolved problem: we do not know how
// to relocate shooeters yet
// to relocate shooters yet
//
var maxRangeSquared = (int)(props.range * props.range);
var tickManager = attacker.Map.GetComponent<TickManager>();
var pos = attacker.Position;
Func<Zombie, int> zombiePrioritySorter = delegate (Zombie zombie)
{
var score = maxRangeSquared - pos.DistanceToSquared(zombie.Position);
if (zombie.bombTickingInterval != -1f)
if (zombie.IsSuicideBomber)
score += 30;
if (zombie.IsTanky)
score += 20;
Expand Down Expand Up @@ -1607,7 +1607,7 @@ static void Postfix(PawnRenderer __instance, Vector3 drawLoc)
Verse.TickManager tm = null;
var orientation = zombie.Rotation;

if (zombie.bombTickingInterval != -1f)
if (zombie.IsSuicideBomber)
{
tm = Find.TickManager;
var currentTick = tm.TicksAbs;
Expand Down Expand Up @@ -1788,7 +1788,7 @@ static void Postfix(PawnGraphicSet __instance)
var zombie = __instance.pawn as Zombie;
if (zombie == null) return;

if (zombie.bombTickingInterval != -1f)
if (zombie.IsSuicideBomber)
{
var apparel = new Apparel() { def = ThingDef.Named("Apparel_BombVest") };
ApparelGraphicRecord record;
Expand Down Expand Up @@ -1860,7 +1860,7 @@ static bool Prefix(Thing thing, StatDef stat, ref float __result)
}
if (zombie.hasTankyShield != -1f || zombie.hasTankyHelmet != -1f || zombie.hasTankySuit != -1f)
{
__result = 1000f;
__result = 5000f;
return false;
}
switch (zombie.story.bodyType)
Expand Down Expand Up @@ -1910,7 +1910,7 @@ static bool Prefix(Thing thing, StatDef stat, ref float __result)
{
if (zombie.IsTanky)
{
__result = 0.001f * Find.TickManager.TickRateMultiplier;
__result = 0.002f * Find.TickManager.TickRateMultiplier;
return false;
}

Expand Down Expand Up @@ -2207,10 +2207,14 @@ static bool Prefix(Pawn pawn, ref int amountInt, BodyPartRecord part, DamageDef
if (zombie == null)
return true;

var difficulty = Find.Storyteller.difficulty.difficulty;
if (amountInt > 25)
amountInt = 25 + (int)Math.Sqrt(amountInt - 26);

if (zombie.hasTankyShield > 0f)
{
PlayTink(zombie);
zombie.hasTankyShield -= amountInt / 200f;
zombie.hasTankyShield -= amountInt / (1f + difficulty * 150f);
if (zombie.hasTankyShield < 0f)
zombie.hasTankyShield = -1f;
__result = -1;
Expand All @@ -2223,7 +2227,7 @@ static bool Prefix(Pawn pawn, ref int amountInt, BodyPartRecord part, DamageDef
if (zombie.hasTankyHelmet > 0f)
{
PlayTink(zombie);
zombie.hasTankyHelmet -= amountInt / 10f;
zombie.hasTankyHelmet -= amountInt / (1f + difficulty * 10f);
if (zombie.hasTankyHelmet < 0f)
zombie.hasTankyHelmet = -1f;
__result = -1;
Expand All @@ -2235,7 +2239,7 @@ static bool Prefix(Pawn pawn, ref int amountInt, BodyPartRecord part, DamageDef
if (zombie.hasTankySuit > 0f)
{
PlayTink(zombie);
zombie.hasTankySuit -= amountInt / 100f;
zombie.hasTankySuit -= amountInt / (1f + difficulty * 100f);
if (zombie.hasTankySuit < 0f)
zombie.hasTankySuit = -1f;
__result = -1;
Expand All @@ -2246,7 +2250,7 @@ static bool Prefix(Pawn pawn, ref int amountInt, BodyPartRecord part, DamageDef
// still a tough zombie even if we hit the body but some armor is left
if (zombie.hasTankyHelmet > 0f || zombie.hasTankySuit > 0f)
{
var toughnessLevel = 1; // TODO scale from 1..n with difficulty
var toughnessLevel = Find.Storyteller.difficulty.difficulty;
amountInt = (amountInt + toughnessLevel) / (toughnessLevel + 1);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.9.11.0")]
[assembly: AssemblyFileVersion("1.9.11.0")]
[assembly: AssemblyVersion("1.9.12.0")]
[assembly: AssemblyFileVersion("1.9.12.0")]
3 changes: 2 additions & 1 deletion Source/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,10 @@ public static void ConvertToZombie(ThingWithComps thing, bool force = false)
var compQuality = newApparel.TryGetComp<CompQuality>();
if (compQuality != null)
compQuality.SetQuality(QualityCategory.Shoddy, ArtGenerationContext.Colony);

zombie.apparel.Notify_ApparelAdded(newApparel);
}
});
zombie.apparel.Notify_ApparelAdded(null); // unused arg

if (thing is Corpse)
{
Expand Down
6 changes: 3 additions & 3 deletions Source/Zombie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class Zombie : Pawn, IDisposable
public float bombTickingInterval = -1f;
public bool bombWillGoOff;
public int lastBombTick;
public bool IsSuicideBomber => bombTickingInterval != -1;

// toxic splasher
public bool isToxicSplasher = false;
Expand Down Expand Up @@ -149,7 +150,7 @@ void Dispose(bool disposing)

public override void Kill(DamageInfo? dinfo, Hediff exactCulprit = null)
{
if (bombTickingInterval != -1f)
if (IsSuicideBomber)
{
bombTickingInterval = -1f;
bombWillGoOff = false;
Expand Down Expand Up @@ -307,9 +308,8 @@ public void CustomTick()
natives?.NativeVerbsTick();
Drawer?.DrawTrackerTick();
rotationTracker?.RotationTrackerTick();
health?.HealthTick();
}

health?.HealthTick();
}

if (state == ZombieState.Emerging)
Expand Down
32 changes: 15 additions & 17 deletions Source/ZombieStateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ public static bool ShouldDie(this JobDriver_Stumble driver, Zombie zombie)
return true;
}

if (zombie.bombTickingInterval != -1f)
if (zombie.IsSuicideBomber)
{
if (zombie.bombWillGoOff && zombie.EveryNTick(NthTick.Every10))
zombie.bombTickingInterval -= 2f;
if (zombie.bombTickingInterval <= 0f)
{
zombie.bombTickingInterval = -1f;
zombie.Kill(null);
return true;
}
Expand Down Expand Up @@ -326,11 +325,14 @@ public static bool Track(this JobDriver_Stumble driver, Zombie zombie, Pheromone
//
public static bool Smash(this JobDriver_Stumble driver, Zombie zombie, bool checkSmashable, bool onylWhenNotRaging)
{
if (driver.destination.IsValid && checkSmashable == false)
return false;
if (zombie.wasMapPawnBefore == false && zombie.IsSuicideBomber == false && zombie.IsTanky == false)
{
if (driver.destination.IsValid && checkSmashable == false)
return false;

if (onylWhenNotRaging && zombie.raging > 0 && zombie.wasMapPawnBefore == false)
return false;
if (onylWhenNotRaging && zombie.raging > 0)
return false;
}

var building = CanSmash(zombie);
if (building == null)
Expand Down Expand Up @@ -388,7 +390,7 @@ public static bool RageMove(this JobDriver_Stumble driver, Zombie zombie, Pherom
}

// next tanky move is on a building
if (newPos.GetEdifice(zombie.Map) is Building)
if (newPos.GetEdifice(zombie.Map) is Building building && (building as Mineable) == null)
return Smash(driver, zombie, checkSmashable, false);

// next move is on a door
Expand Down Expand Up @@ -566,9 +568,6 @@ static Thing CanAttack(Zombie zombie)

static Building CanSmash(Zombie zombie)
{
if (zombie.EveryNTick(NthTick.Every15) == false && zombie.IsTanky == false)
return null;

var map = zombie.Map;
var basePos = zombie.Position;
var attackColonistsOnly = (ZombieSettings.Values.attackMode == AttackMode.OnlyColonists);
Expand All @@ -580,13 +579,12 @@ static Building CanSmash(Zombie zombie)
var pos = info.GetParent(basePos, false);
if (pos.IsValid == false)
pos = info.GetParent(basePos, true);
if (pos.IsValid && pos.GetEdifice(zombie.Map) is Building building && (attackColonistsOnly == false || building.Faction == playerFaction))
if (pos.IsValid && pos.GetEdifice(zombie.Map) is Building building && (building as Mineable) == null && (attackColonistsOnly == false || building.Faction == playerFaction))
return building;
return null;
}

var isSuicideBomber = zombie.bombTickingInterval != -1f;
if (isSuicideBomber == false && zombie.IsTanky == false && zombie.wasMapPawnBefore == false)
if (zombie.IsSuicideBomber == false && zombie.IsTanky == false && zombie.wasMapPawnBefore == false)
{
if (ZombieSettings.Values.smashMode == SmashMode.Nothing) return null;
if (ZombieSettings.Values.smashOnlyWhenAgitated && zombie.state != ZombieState.Tracking && zombie.raging == 0) return null;
Expand All @@ -598,7 +596,7 @@ static Building CanSmash(Zombie zombie)
adjIndex4[nextIndex] = c;
prevIndex4 = nextIndex;

if (ZombieSettings.Values.smashMode == SmashMode.DoorsOnly && isSuicideBomber == false)
if (ZombieSettings.Values.smashMode == SmashMode.DoorsOnly && zombie.IsSuicideBomber == false)
{
for (var i = 0; i < 4; i++)
{
Expand All @@ -611,7 +609,7 @@ static Building CanSmash(Zombie zombie)
}
}

if (ZombieSettings.Values.smashMode == SmashMode.AnyBuilding || isSuicideBomber || zombie.IsTanky)
if (ZombieSettings.Values.smashMode == SmashMode.AnyBuilding || zombie.IsSuicideBomber || zombie.IsTanky)
{
var grid = map.thingGrid;
for (var i = 0; i < 4; i++)
Expand All @@ -623,14 +621,14 @@ static Building CanSmash(Zombie zombie)
foreach (var thing in grid.ThingsListAtFast(pos))
{
var building = thing as Building;
if (building == null)
if (building == null || (building as Mineable) != null)
continue;

var buildingDef = building.def;
var factionCondition = (attackColonistsOnly == false || building.Faction == playerFaction);
if (buildingDef.useHitPoints && buildingDef.building.isNaturalRock == false && factionCondition)
{
if (isSuicideBomber)
if (zombie.IsSuicideBomber)
{
zombie.bombWillGoOff = true;
return null;
Expand Down
2 changes: 1 addition & 1 deletion Source/ZombieWanderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ bool ValidFloodCell(Map map, IntVec3 cell, IntVec3 from, bool ignoreBuildings)
if (pathGrid.WalkableFast(cell) == false)
{
if (ignoreBuildings)
return edificeGrid != null && edificeGrid[cell] is Building;
return edificeGrid != null && edificeGrid[cell] is Building building && (building as Mineable) == null;
return false;
}

Expand Down

0 comments on commit 1f2cfa3

Please sign in to comment.