<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40761 >

add an effect which changes shield upkeep to gold upkeep; it is activated 
if 'The Corporation' is researched

depends on ticket 40619, 40759, 40760

compile tested and also with a short game

diff -ur freeciv-2.1.99svn15584.gold2//ai/aicity.c freeciv-2.1.99svn15584.gold3//ai/aicity.c
--- freeciv-2.1.99svn15584.gold2//ai/aicity.c	2009-04-12 00:54:48.778626659 +0200
+++ freeciv-2.1.99svn15584.gold3//ai/aicity.c	2009-04-12 00:53:25.000000000 +0200
@@ -715,6 +715,7 @@
     break;
     /* This has no effect for AI */
   case EFT_VISIBLE_WALLS:
+  case EFT_SHIELD2GOLD_FACTOR:
     break;
   case EFT_LAST:
     freelog(LOG_ERROR, "Bad effect type.");
diff -ur freeciv-2.1.99svn15584.gold2//common/effects.c freeciv-2.1.99svn15584.gold3//common/effects.c
--- freeciv-2.1.99svn15584.gold2//common/effects.c	2009-01-05 11:54:25.000000000 +0100
+++ freeciv-2.1.99svn15584.gold3//common/effects.c	2009-04-11 20:32:40.410628886 +0200
@@ -117,7 +117,8 @@
   "Output_Inc_Tile_Celebrate",
   "City_Unhappy_Size",
   "Upgrade_Price_Pct",
-  "Visible_Walls"
+  "Visible_Walls",
+  "Shield2Gold_Factor"
 };
 
 static bool initialized = FALSE;
diff -ur freeciv-2.1.99svn15584.gold2//common/effects.h freeciv-2.1.99svn15584.gold3//common/effects.h
--- freeciv-2.1.99svn15584.gold2//common/effects.h	2009-01-05 11:54:25.000000000 +0100
+++ freeciv-2.1.99svn15584.gold3//common/effects.h	2009-04-11 20:32:40.490129766 +0200
@@ -105,6 +105,8 @@
   EFT_CITY_UNHAPPY_SIZE, /* all citizens after this are unhappy */
   EFT_UPGRADE_PRICE_PCT,
   EFT_VISIBLE_WALLS,     /* City should use walls gfx */
+  EFT_SHIELD2GOLD_FACTOR, /* [x%] gold upkeep instead of [1] shield upkeep
+                           * for units */
   EFT_LAST	/* keep this last */
 };
 
diff -ur freeciv-2.1.99svn15584.gold2//common/unittype.c freeciv-2.1.99svn15584.gold3//common/unittype.c
--- freeciv-2.1.99svn15584.gold2//common/unittype.c	2009-01-05 11:54:25.000000000 +0100
+++ freeciv-2.1.99svn15584.gold3//common/unittype.c	2009-04-12 00:13:51.698127364 +0200
@@ -144,13 +144,34 @@
 int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer,
                       Output_type_id otype)
 {
-  int val = ut->upkeep[otype];
+  int val = ut->upkeep[otype], gold_upkeep_factor;
 
   if (get_player_bonus(pplayer, EFT_FANATICS)
       && BV_ISSET(ut->flags, F_FANATIC)) {
     /* Special case: fanatics have no upkeep under fanaticism. */
     return 0;
   }
+
+  /* switch shild upkeep to gold upkeep if
+     - the effect 'EFT_SHIELD2GOLD_FACTOR' is non-zero (it gives the
+        conversion factor in percent)
+     Should the ai know about this? - MaPfa */
+  gold_upkeep_factor = get_player_bonus(pplayer, EFT_SHIELD2GOLD_FACTOR);
+  gold_upkeep_factor = (gold_upkeep_factor > 0) ? gold_upkeep_factor : 0;
+  if (gold_upkeep_factor > 0) {
+    switch (otype) {
+      case O_GOLD:
+        val = ceil((0.01 * gold_upkeep_factor) * ut->upkeep[O_SHIELD]);
+        break;
+      case O_SHIELD:
+        val = 0;
+        break;
+      default:
+        /* fallthru */
+        break;
+    }
+  }
+
   val *= get_player_output_bonus(pplayer, get_output_type(otype), 
                                  EFT_UPKEEP_FACTOR);
   return val;
diff -ur freeciv-2.1.99svn15584.gold2//data/default/effects.ruleset freeciv-2.1.99svn15584.gold3//data/default/effects.ruleset
--- freeciv-2.1.99svn15584.gold2//data/default/effects.ruleset	2009-01-05 11:55:06.000000000 +0100
+++ freeciv-2.1.99svn15584.gold3//data/default/effects.ruleset	2009-04-11 20:32:40.942131386 +0200
@@ -1981,11 +1981,19 @@
     { "type", "name", "range"
       "Tech", "Flight", "Player"
     }
-    
+
 [effect_railroad_trade_revenue_reduce]
 name    = "Trade_Revenue_Bonus"
 value   = -585
 reqs    =
     { "type", "name", "range"
       "Tech", "Railroad", "Player"
-    }    
+    }
+
+[effect_upkeep_shield2gold]
+name    = "Shield2Gold_Factor"
+value   = 200
+reqs    =
+    { "type", "name", "range"
+      "Tech", "The Corporation", "Player"
+    }
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to