Skip to content

Commit

Permalink
v3.0.1 fixes melee calculations and allows zombie bites only on close…
Browse files Browse the repository at this point in the history
… interactions
  • Loading branch information
pardeike committed Mar 7, 2022
1 parent 401ab66 commit d0ba634
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Binary file modified 1.3/Assemblies/ZombieLand.dll
Binary file not shown.
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>3.0.0.0</version>
<version>3.0.1.0</version>
<targetVersions>
<li>1.0.0</li>
<li>1.1.0</li>
Expand Down
14 changes: 11 additions & 3 deletions Source/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -842,14 +842,22 @@ static bool Prefix(Verb_MeleeAttack __instance, ref bool __result)
// allow mentally broken colonists to use smart melee: if (pawn.mindState.mentalStateHandler.InMentalState) return true;

var pos = pawn.Position;
var posX = pos.x;
var posZ = pos.z;
var vecs = GenAdj.AdjacentCellsAround;
var thingGrid = pawn.Map.thingGrid;
var concurrentAttacks = GenAdj.AdjacentCellsAround
.SelectMany(vec => thingGrid.ThingsAt(pos + vec))
.OfType<Zombie>()
.Select(zombie => zombie.CurJob)
.Where(job => job?.def == JobDefOf.AttackMelee)
.Sum(job => job.targetA.Thing == pawn ? (zombie.IsTanky ? 2 : 1) : 0);
.Where(zombie => zombie.ropedBy == null && zombie.paralyzedUntil == 0)
.Where(zombie =>
{
var zombiePos = zombie.Position;
var dist = posX == zombiePos.x || posZ == zombiePos.z ? 1.1f : 2.2f;
var res = (pawn.DrawPos - zombie.DrawPos).MagnitudeHorizontalSquared() <= dist;
return res;
})
.Sum(_zombie => zombie.IsTanky ? 2 : 1);
if (concurrentAttacks <= limit)
if (__instance.GetDamageDef() == CustomDefs.ZombieBite)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/ZombieLand.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<OutputPath>..\1.3\Assemblies\</OutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Version>3.0.0.0</Version>
<Version>3.0.1.0</Version>
<Copyright>Copyright © 2017</Copyright>
</PropertyGroup>

Expand Down

0 comments on commit d0ba634

Please sign in to comment.