IsValidAgainst() public method

Checks if the weapon is valid against (can target) the actor.
public IsValidAgainst ( Actor victim, Actor firedBy ) : bool
victim Actor
firedBy Actor
return bool
コード例 #1
0
ファイル: Combat.cs プロジェクト: Berzeger/OpenRA
		static float GetDamageToInflict(WPos pos, Actor target, WarheadInfo warhead, WeaponInfo weapon, float modifier, bool withFalloff)
		{
			// don't hit air units with splash from ground explosions, etc
			if (!weapon.IsValidAgainst(target))
				return 0;

			var healthInfo = target.Info.Traits.GetOrDefault<HealthInfo>();
			if (healthInfo == null)
				return 0;

			var rawDamage = (float)warhead.Damage;
			if (withFalloff)
			{
				var distance = Math.Max(0, (target.CenterPosition - pos).Length - healthInfo.Radius.Range);
				var falloff = (float)GetDamageFalloff(distance * 1f / warhead.Spread.Range);
				rawDamage = (float)(falloff * rawDamage);
			}

			return (float)(rawDamage * modifier * (float)warhead.EffectivenessAgainst(target.Info));
		}
コード例 #2
0
ファイル: Combat.cs プロジェクト: TiriliPiitPiit/OpenRA
        static float GetDamageToInflict(WPos pos, Actor target, WarheadInfo warhead, WeaponInfo weapon, float modifier)
        {
            // don't hit air units with splash from ground explosions, etc
            if (!weapon.IsValidAgainst(target))
                return 0f;

            var health = target.Info.Traits.GetOrDefault<HealthInfo>();
            if( health == null ) return 0f;

            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.Info);

            return (float)(rawDamage * multiplier);
        }