]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/attsub.c
Replace "roll0(N) + M" by "roll(N) + M-1"
[empserver] / src / lib / subs / attsub.c
index 63aeff6f2ababff266bbce8f927ef704dd3ac0e7..ef22fac45b158ebbf784344c0827b4094e0349fe 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
  *  Known contributors to this file:
  *     Ken Stevens, 1995
  *     Steve McClure, 1996-2000
- *     Markus Armbruster, 2006-2011
+ *     Markus Armbruster, 2006-2012
  */
 
 #include <config.h>
 
 #include <ctype.h>
 #include <math.h>
+#include "chance.h"
 #include "combat.h"
 #include "empobj.h"
 #include "file.h"
@@ -1836,12 +1837,12 @@ att_fight(int combat_mode, struct combat *off, struct emp_qelem *olist,
      * since a single dead guy normally wouldn't cause a commander to
      * rethink his strategies, but 50 dead guys might.
      */
-    odds += (random() % 11 - 5) / 100.0;
+    odds += (roll(11) - 6) / 100.0;
     if (odds < 0.0)
        odds = 0.1;
     if (odds > 1.0)
        odds = 1.0;
-    recalctime = 8 + (random() % 43);
+    recalctime = 7 + roll(43);
     while (!success && ototal) {
        if (chance(odds)) {
            pr("!");
@@ -1857,9 +1858,9 @@ att_fight(int combat_mode, struct combat *off, struct emp_qelem *olist,
        if (((a_cas + d_cas) % 70) == 69)
            pr("\n");
        if (recalctime-- <= 0) {
-           recalctime = 8 + (random() % 43);
+           recalctime = 7 + roll(43);
            odds = att_calcodds(ototal, dtotal);
-           odds += (random() % 11 - 5) / 100.0;
+           odds += (roll(11) - 6) / 100.0;
            if (odds < 0.0)
                odds = 0.1;
            if (odds > 1.0)