private void rangedAttack(Model target, int ballisticSkillToUse) { int shots = ranged.shots; int hits = rollForRangedHits(shots, ballisticSkillToUse); if (hits == 0) { return; } int armourPiercingRating = ranged.armourPiercingRating; int unsavedHits = target.rollSaves(hits, armourPiercingRating); int weaponStrength = ranged.strength; target.inflictWounds(unsavedHits, weaponStrength); }
public void overwatch(Model target) { rangedAttack(target, 1); }
public bool meleeRangeCheck(Model target, Unit squad) { Point targetLocation = target.currentLocation; decimal targetBaseRadius = target.baseRadius; decimal distance = Global.getDistance(currentLocation, targetLocation); decimal meleeRange = targetBaseRadius + baseRadius; if (distance > meleeRange) { LinkedList<Model> allSquadMates = squad.allUnitMembers; foreach (Model squadMate in allSquadMates) { bool squadMateEngaged = squadMate.isEngaged; if (squadMateEngaged == false) { continue; } Point squadMateLocation = squadMate.currentLocation; distance = Global.getDistance(currentLocation, squadMateLocation); if (distance > Global.Ranges.coherency) { continue; } return true; } return false; } return true; }
public void normalRangedAttack(Model target) { rangedAttack(target, ballisticSkill); }
public void meleeCombat(Model enemy, Unit squad) { assaultWoundsInflicted = 0; bool isStillAlive = isAliveCheck(); if (isStillAlive == false) { return; } Announcer.announceModelAction(this, Announcer.ModelActions.melee, enemy); int targetWeaponSkill = enemy.weaponSkill; int meleeToHitScore = Global.getAssaultToHitScore(weaponSkill, targetWeaponSkill); int hits = rollForMeleeHits(attacks, meleeToHitScore); string addon = string.Format(" {0} hits", hits); Announcer.announceAction(Announcer.GeneralActions.score + addon); if (hits == 0) { return; } int armourPiercingRating = melee.armourPiercingRating; int unsavedHits = enemy.rollSaves(hits, armourPiercingRating, rangedCombat : false); addon = string.Format(" to avoid {0} hits", unsavedHits); Announcer.announceModelAction(enemy, Announcer.GeneralActions.fail + addon); int weaponStrength = melee.getWeaponStrength(strength); assaultWoundsInflicted = enemy.inflictWounds(unsavedHits, weaponStrength); Announcer.announceModelAction(this, Announcer.ModelActions.wound, enemy); }