]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/shpsub.c
Replace common pattern by new LIMIT_TO()
[empserver] / src / lib / subs / shpsub.c
index 364e54870c40cf0813ff57852020b1db46e393a7..0682fc22b61f6d253d68103bcb8474a62538bcd2 100644 (file)
@@ -29,7 +29,7 @@
  *  Known contributors to this file:
  *     Ken Stevens, 1995
  *     Steve McClure, 1996-2000
- *     Markus Armbruster, 2006-2010
+ *     Markus Armbruster, 2006-2013
  */
 
 #include <config.h>
@@ -871,11 +871,8 @@ shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget)
        teff = ship.shp_tech / (ship.shp_tech + 200.0);
        /* raise 4.5 for better interception -KHS */
        hitchance = (int)(gun * eff * teff * 4.5) - hardtarget;
-       if (hitchance < 0)
-           hitchance = 0;
-       if (hitchance > 100)
-           hitchance = 100;
-       hit = roll(100) <= hitchance;
+       hitchance = LIMIT_TO(hitchance, 0, 100);
+       hit = pct_chance(hitchance);
 
        mpr(bombown, "%s anti-missile system activated...%s\n",
            cname(ship.shp_own),