This commit is contained in:
2025-09-07 18:26:43 +08:00
parent acfc078f91
commit b954781675
2 changed files with 8 additions and 2 deletions

Binary file not shown.

View File

@@ -127,14 +127,20 @@ namespace ArachnaeSwarm
// --- AOE Damage Logic --- // --- AOE Damage Logic ---
// Damage other hostiles in the path. // Damage other hostiles in the path.
float aoeDamage = this.initialDamage + (((Vector3)StartVecInfo.GetValue(this) - this.DrawPos).magnitude * this.damagePerTile); float distanceTravelled = ((Vector3)StartVecInfo.GetValue(this) - this.DrawPos).magnitude;
var aoeDinfo = new DamageInfo(this.collisionDamageDef, aoeDamage, 1f, -1, this.FlyingPawn); float currentAOEDamage = this.initialDamage + (distanceTravelled * this.damagePerTile);
foreach (var thing in GenRadial.RadialDistinctThingsAround(this.Position, this.Map, 1.0f, false)) foreach (var thing in GenRadial.RadialDistinctThingsAround(this.Position, this.Map, 1.0f, false))
{ {
if (thing != this.FlyingPawn && thing != this && thing != primaryTarget.Thing) if (thing != this.FlyingPawn && thing != this && thing != primaryTarget.Thing)
{ {
if (thing is Pawn pawn && !pawn.Downed && pawn.HostileTo(this.FlyingPawn)) if (thing is Pawn pawn && !pawn.Downed && pawn.HostileTo(this.FlyingPawn))
{ {
// --- CRITICAL FIX ---
// Create a *new* DamageInfo object for each target.
// Reusing the same dinfo object causes its damage value to be modified (e.g., by armor),
// resulting in subsequent targets taking zero damage.
var aoeDinfo = new DamageInfo(this.collisionDamageDef, currentAOEDamage, 1f, -1, this.FlyingPawn);
pawn.TakeDamage(aoeDinfo); pawn.TakeDamage(aoeDinfo);
} }
} }