Change WeaponInfo.EffectivenessAgainst to take ActorInfo.
This commit is contained in:
@@ -48,12 +48,15 @@ namespace OpenRA.GameRules
|
||||
[Desc("Whether we should prevent prone response for infantry.")]
|
||||
public readonly bool PreventProne = false;
|
||||
|
||||
public float EffectivenessAgainst(Actor self)
|
||||
public float EffectivenessAgainst(ActorInfo ai)
|
||||
{
|
||||
var health = self.Info.Traits.GetOrDefault<HealthInfo>();
|
||||
if (health == null) return 0f;
|
||||
var armor = self.Info.Traits.GetOrDefault<ArmorInfo>();
|
||||
if (armor == null || armor.Type == null) return 1;
|
||||
var health = ai.Traits.GetOrDefault<HealthInfo>();
|
||||
if (health == null)
|
||||
return 0f;
|
||||
|
||||
var armor = ai.Traits.GetOrDefault<ArmorInfo>();
|
||||
if (armor == null || armor.Type == null)
|
||||
return 1;
|
||||
|
||||
float versus;
|
||||
return Versus.TryGetValue(armor.Type, out versus) ? versus : 1;
|
||||
@@ -140,7 +143,7 @@ namespace OpenRA.GameRules
|
||||
if (targetable == null || !ValidTargets.Intersect(targetable.TargetTypes).Any())
|
||||
return false;
|
||||
|
||||
if (Warheads.All(w => w.EffectivenessAgainst(a) <= 0))
|
||||
if (Warheads.All(w => w.EffectivenessAgainst(a.Info) <= 0))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace OpenRA.Mods.RA
|
||||
foreach (var t in world.FindTilesInCircle(targetTile, warhead.Size[0]))
|
||||
foreach (var unit in world.FindActorsInBox(t, t))
|
||||
unit.InflictDamage(firedBy,
|
||||
(int)(warhead.Damage * warhead.EffectivenessAgainst(unit)), warhead);
|
||||
(int)(warhead.Damage * warhead.EffectivenessAgainst(unit.Info)), warhead);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ namespace OpenRA.Mods.RA
|
||||
var distance = (int)Math.Max(0, (target.CenterPosition - pos).Length * Game.CellSize / 1024 - health.Radius);
|
||||
var falloff = (float)GetDamageFalloff(distance / warhead.Spread);
|
||||
var rawDamage = (float)(warhead.Damage * modifier * falloff);
|
||||
var multiplier = (float)warhead.EffectivenessAgainst(target);
|
||||
var multiplier = (float)warhead.EffectivenessAgainst(target.Info);
|
||||
|
||||
return (float)(rawDamage * multiplier);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user