public CombatWeapon GetWeapon(CombatUnit target) { CombatWeapon picked = null; float damage = 0; float singleAttackDamage = 0; int framesUntilNextAttack = 0; foreach (CombatWeapon weapon in Weapons) { if (target.IsAir && !weapon.AttacksAir && !target.IsGround) { continue; } if (target.IsGround && !weapon.AttacksGround && !target.IsAir) { continue; } int newSingleAttackDamage = weapon.GetDamage(target); int newFramesUntilNextAttack = weapon.GetFramesUntilNextAttack(); float newDamage = newSingleAttackDamage * weapon.Attacks / newFramesUntilNextAttack; if (newDamage < damage) { continue; } picked = weapon; damage = newDamage; singleAttackDamage = newSingleAttackDamage; framesUntilNextAttack = newFramesUntilNextAttack; } return(picked); }
public void Attack(SimulationState state, CombatWeapon weapon, CombatUnit target, bool isSecondaryAttack, float partDamage) { float singleAttackDamage = weapon.GetDamage(target) * partDamage; int framesUntilNextAttack = weapon.GetFramesUntilNextAttack(); target.DealDamage(state, singleAttackDamage, false); if (!isSecondaryAttack) { FramesUntilNextAttack = framesUntilNextAttack; } PreviousAttackTarget = target; if (weapon.Attacks > 1) { if (isSecondaryAttack) { AdditionalAttacksRemaining--; } else { AdditionalAttacksRemaining = weapon.Attacks - 1; } SecondaryAttackFrame = state.SimulationFrame + weapon.FramesUntilSecondaryAttack; SecondaryAttackWeapon = weapon; } }
public static CombatWeapon FromWeapon(Weapon weapon) { CombatWeapon result = new CombatWeapon(); result.Damage = (int)weapon.Damage; if (weapon.DamageBonus != null && weapon.DamageBonus.Count > 0) { if (weapon.DamageBonus.Count >= 2 && Tyr.Debug) { throw new ArgumentException("Only one bonus damage supported."); } result.BonusDamage = (int)weapon.DamageBonus[0].Bonus; result.BonusDamageAttribute = FromAttribute(weapon.DamageBonus[0].Attribute); } result.AttacksAir = weapon.Type == Weapon.Types.TargetType.Air || weapon.Type == Weapon.Types.TargetType.Any; result.AttacksGround = weapon.Type == Weapon.Types.TargetType.Ground || weapon.Type == Weapon.Types.TargetType.Any; result.Speed = weapon.Speed; result.Range = (int)weapon.Range; result.Attacks = (int)weapon.Attacks; if (weapon.Attacks > 1) { if (weapon.Speed < 1.24) { result.FramesUntilSecondaryAttack = 4; } else { result.FramesUntilSecondaryAttack = 5; } } return(result); }
public void Attack(SimulationState state, CombatWeapon weapon, CombatUnit target, bool isSecondaryAttack) { Attack(state, weapon, target, isSecondaryAttack, 1); }