Convert weapon plumbing to use integer damage modifiers.

This commit is contained in:
Paul Chote
2014-08-17 17:33:50 +12:00
parent 8e8e02dae8
commit 57ba1b54b4
27 changed files with 75 additions and 75 deletions

View File

@@ -42,30 +42,31 @@ namespace OpenRA.GameRules
: new Dictionary<string, float>();
}
public override float EffectivenessAgainst(ActorInfo ai)
public override int EffectivenessAgainst(ActorInfo ai)
{
var health = ai.Traits.GetOrDefault<HealthInfo>();
if (health == null)
return 0f;
return 0;
var armor = ai.Traits.GetOrDefault<ArmorInfo>();
if (armor == null || armor.Type == null)
return 1f;
return 100;
// TODO: Change versus definitions to integer percentages
float versus;
return Versus.TryGetValue(armor.Type, out versus) ? versus : 1f;
return Versus.TryGetValue(armor.Type, out versus) ? (int)(versus * 100) : 100;
}
public override void DoImpact(Target target, Actor firedBy, float firepowerModifier)
public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
{
// Used by traits that damage a single actor, rather than a position
if (target.Type == TargetType.Actor)
DoImpact(target.Actor, firedBy, firepowerModifier);
DoImpact(target.Actor, firedBy, damageModifiers);
else
DoImpact(target.CenterPosition, firedBy, firepowerModifier);
DoImpact(target.CenterPosition, firedBy, damageModifiers);
}
public abstract void DoImpact(Actor target, Actor firedBy, float firepowerModifier);
public abstract void DoImpact(WPos pos, Actor firedBy, float firepowerModifier);
public abstract void DoImpact(Actor target, Actor firedBy, IEnumerable<int> damageModifiers);
public abstract void DoImpact(WPos pos, Actor firedBy, IEnumerable<int> damageModifiers);
}
}

View File

@@ -27,9 +27,9 @@ namespace OpenRA.GameRules
[Desc("Delay in ticks before applying the warhead effect.","0 = instant (old model).")]
public readonly int Delay = 0;
public abstract void DoImpact(Target target, Actor firedBy, float firepowerModifier);
public abstract void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers);
public virtual float EffectivenessAgainst(ActorInfo ai) { return 0f; }
public virtual int EffectivenessAgainst(ActorInfo ai) { return 0; }
public bool IsValidAgainst(Target target, World world, Actor firedBy)
{
@@ -59,7 +59,7 @@ namespace OpenRA.GameRules
public bool IsValidAgainst(Actor victim, Actor firedBy)
{
// If this warhead is ineffective against the target, then it is not a valid target
if (EffectivenessAgainst(victim.Info) <= 0f)
if (EffectivenessAgainst(victim.Info) <= 0)
return false;
// A target type is valid if it is in the valid targets list, and not in the invalid targets list.
@@ -84,7 +84,7 @@ namespace OpenRA.GameRules
public bool IsValidAgainst(FrozenActor victim, Actor firedBy)
{
// If this warhead is ineffective against the target, then it is not a valid target
if (EffectivenessAgainst(victim.Info) <= 0f)
if (EffectivenessAgainst(victim.Info) <= 0)
return false;
// A target type is valid if it is in the valid targets list, and not in the invalid targets list.

View File

@@ -19,7 +19,7 @@ namespace OpenRA.GameRules
public class ProjectileArgs
{
public WeaponInfo Weapon;
public float FirepowerModifier = 1.0f;
public IEnumerable<int> DamageModifiers;
public int Facing;
public WPos Source;
public Actor SourceActor;
@@ -144,13 +144,13 @@ namespace OpenRA.GameRules
return true;
}
public void Impact(WPos pos, Actor firedBy, float damageModifier)
public void Impact(WPos pos, Actor firedBy, IEnumerable<int> damageModifiers)
{
foreach (var wh in Warheads)
{
Action a;
a = () => wh.DoImpact(Target.FromPos(pos), firedBy, damageModifier);
a = () => wh.DoImpact(Target.FromPos(pos), firedBy, damageModifiers);
if (wh.Delay > 0)
firedBy.World.AddFrameEndTask(
w => w.Add(new DelayedAction(wh.Delay, a)));