]> git.pond.sub.org Git - empserver/commitdiff
convert shoot: Make security bonus proportional to efficiency
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 16 Sep 2016 11:30:47 +0000 (13:30 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:09:19 +0000 (20:09 +0200)
Land units with capability security reduce the mobility cost and have
their military count double, regardless of efficiency.  This lets
players get the benefits of a security unit at a discount: just don't
build it beyond 10%.

Count security unit's military times 1 + eff/100 instead of double.
Change the mobility bonus term from number of security units to sum of
security unit efficiency / 100.  Partial fix for bug#64.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/prototypes.h
src/lib/commands/conv.c
src/lib/commands/shoo.c
src/lib/subs/control.c

index d31ed61d5599e746cce70238ef1caca301a83b78..5ea7a47abe2b86cb010237825dc71a639544f1aa 100644 (file)
@@ -399,7 +399,7 @@ extern int check_trade_ok(struct trdstr *);
 /* coastal.c */
 extern void set_coastal(struct sctstr *, int, int);
 /* control.c */
-extern int security_strength(struct sctstr *, int *);
+extern double security_strength(struct sctstr *, int *);
 extern int military_control(struct sctstr *);
 extern int abandon_askyn(struct sctstr *, i_type, int, struct ulist *);
 extern int would_abandon(struct sctstr *, i_type, int, struct ulist *);
index 76a1523a72872d5476e742f1f5eba3b9a8010202..c617511044a323d2880b604206eb86057d24dd90 100644 (file)
@@ -48,7 +48,8 @@ conv(void)
     struct sctstr sect;
     struct nstr_sect nstr;
     int uwtoconvert, newuw, totaluw, uw;
-    int maxpop, civ, mil, nsec, adj_mob, mob;
+    int maxpop, civ, seceff, adj_mob, mob;
+    double secstr;
     double security_extra = 1.0;
 
     if (!snxtsct(&nstr, player->argp[1]))
@@ -66,11 +67,11 @@ conv(void)
        natp = getnatp(sect.sct_own);
        maxpop = max_pop(natp->nat_level[NAT_RLEV], &sect);
        civ = sect.sct_item[I_CIVIL];
-       mil = security_strength(&sect, &nsec);
+       secstr = security_strength(&sect, &seceff);
        /*
         * Must have military control to convert captured civs.
         */
-       if (mil * 10 < civ)
+       if (secstr * 10 < civ)
            continue;
        newuw = civ;
        if (newuw > uwtoconvert)
@@ -88,7 +89,7 @@ conv(void)
        mob = sect.sct_mobil * 5;
 
        /* security troops make conversion more effective */
-       security_extra = 1.0 + nsec / 10.0;
+       security_extra = 1.0 + seceff / 1000.0;
        adj_mob = ldround(((double)mob * security_extra), 1);
 
        if (adj_mob < newuw)
index 45f9e3290983641d3e809a0509edf72caa4e1591..28821a6ab14ed946aad8deafa35a242ada38caca 100644 (file)
@@ -28,6 +28,7 @@
  *
  *  Known contributors to this file:
  *     Dave Pare, 1986
+ *     Markus Armbruster, 2004-2016
  */
 
 #include <config.h>
@@ -43,13 +44,12 @@ shoo(void)
 {
     struct sctstr sect;
     struct nstr_sect nstr;
-    int nshot;
-    double m;
+    int seceff, nshot;
+    double secstr, m;
     i_type item;
     struct ichrstr *ip;
     int targets;
     char *p;
-    int mil, nsec;
     char prompt[128];
     char buf[1024];
 
@@ -66,21 +66,20 @@ shoo(void)
     while (nxtsct(&nstr, &sect)) {
        if (!player->owner)
            continue;
-       mil = security_strength(&sect, &nsec);
-       if (sect.sct_item[item] == 0 || sect.sct_item[I_CIVIL] > mil * 10)
+       secstr = security_strength(&sect, &seceff);
+       if (sect.sct_item[item] == 0 || sect.sct_item[I_CIVIL] > secstr * 10)
            continue;
        nshot = sect.sct_item[item] > targets ? targets : sect.sct_item[item];
        if (nshot > sect.sct_mobil * 5)
            nshot = sect.sct_mobil * 5;
        m = nshot / 5.0;
        /*
-        * Each security unit lowers the cost of
-        * shooting a person by 10%. However, you
-        * can't go lower than 50% of normal cost
+        * Security units reduce mobility cost of shooting people by
+        * 10% per 100% unit efficiency, up to a 50% reduction.
         */
-       if (nsec > 5)
-           nsec = 5;
-       m *= 1.0 - nsec * 0.1;
+       if (seceff > 500)
+           seceff = 500;
+       m *= 1.0 - seceff / 1000.0;
        if (nshot <= 0)
            continue;
        if (m < 0)
index 3fc5b1f95ed5d64984ac9159acc0eae3503adc1d..a2df3a3f78b6bcf59ce66faeddb35139b1048342 100644 (file)
 
 /*
  * Return strength of security detail in @sp.
- * Store number of land units with security capability in @nsecurity.
+ * Store sum of efficiency of land units with security capability in
+ * @seceffp.
  */
-int
-security_strength(struct sctstr *sp, int *nsecurity)
+double
+security_strength(struct sctstr *sp, int *seceffp)
 {
-    int strength;
-    int nsec;
+    double strength;
+    int seceff;
     struct nstr_item ni;
     struct lndstr land;
 
     strength = sp->sct_item[I_MILIT];
-    nsec = 0;
+    seceff = 0;
     snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
     while (nxtitem(&ni, &land)) {
        strength += land.lnd_item[I_MILIT];
        if (lchr[land.lnd_type].l_flags & L_SECURITY) {
-           strength += land.lnd_item[I_MILIT];
-           nsec++;
+           strength += land.lnd_item[I_MILIT] * land.lnd_effic / 100.0;
+           seceff += land.lnd_effic;
        }
     }
 
-    *nsecurity = nsec;
+    *seceffp = seceff;
     return strength;
 }