Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] (PR#2507) incite cost patch
Home

[Freeciv-Dev] (PR#2507) incite cost patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2507) incite cost patch
From: "Per I. Mathisen via RT" <rt@xxxxxxxxxxxxxx>
Date: Fri, 6 Dec 2002 15:27:26 -0800
Reply-to: rt@xxxxxxxxxxxxxx

This is Thomas' incite cost patch with my extensive modifications adapted
to current cvs.

Only one change since last time (apart from cvs adaptation): Celebrating
cities can now be incited, but at double price. Since we also get
stability bonuses from happy cities and bonuses from happy citizens, a
celebrating city should be extremely expensive, yet not impossible to
incite.

You should still be able to get cities at a bargain in the fringes of an
empire, far away from its capital, especially when combined with more
aggressive anti-ICS measures that keeps such cities in turmoil and
unhappiness. But cities close to your capital should be mostly safe from
incitement unless your opponent is awash in gold. Also Courthouse helps a
lot to keep prices up.

The effect of Courthouse should be configurable by general effects patch
eventually, and we may wish to delay this patch until after that. I don't
see any easy way to ruleset'ify the other rules, though.

  - Per

Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.199
diff -u -r1.199 cityturn.c
--- server/cityturn.c   2002/11/25 19:18:09     1.199
+++ server/cityturn.c   2002/12/06 23:18:03
@@ -1181,43 +1181,84 @@
 }
 
 /**************************************************************************
-  Sets the incite_revolt_cost field in the given city.
+  Returns the cost to incite a city. This depends on the size of the city,
+  the number of happy, unhappy and angry citizens, whether it is
+  celebrating, how close it is to the capital, how many units it has and
+  upkeeps, presence of courthouse and its buildings and wonders.
 **************************************************************************/
 int city_incite_cost(struct player *pplayer, struct city *pcity)
 {
   struct government *g = get_gov_pcity(pcity);
   struct city *capital;
-  int dist;
-  int incite_revolt_cost;
+  int dist, size, cost;
 
   if (city_got_building(pcity, B_PALACE)) {
-    incite_revolt_cost = INCITE_IMPOSSIBLE_COST;
-  } else {
-    incite_revolt_cost = city_owner(pcity)->economic.gold + 1000;
-    capital = find_palace(city_owner(pcity));
-    if (capital) {
-      int tmp = map_distance(capital->x, capital->y, pcity->x, pcity->y);
-      dist = MIN(32, tmp);
+    return INCITE_IMPOSSIBLE_COST;
+  }
+
+  /* Gold factor */
+  cost = city_owner(pcity)->economic.gold + 1000;
+
+  unit_list_iterate(map_get_tile(pcity->x,pcity->y)->units, punit) {
+    cost += unit_type(punit)->build_cost;
+  } unit_list_iterate_end;
+
+  /* Buildings */
+  built_impr_iterate(pcity, i) {
+    if (!is_wonder(i)) {
+      cost += improvement_value(i);
     } else {
-      /* No capital? Take max penalty! */
-      dist = 32;
-    }
-    if (city_got_building(pcity, B_COURTHOUSE)) {
-      dist /= 2; /* courthouse halves the distance penalty */
+      cost += improvement_value(i) * 2;
     }
-    if (g->fixed_corruption_distance != 0) {
-      dist = MIN(g->fixed_corruption_distance, dist);
-    }
-    incite_revolt_cost /= (dist + 3);
-    incite_revolt_cost *= pcity->size;
-    if (city_unhappy(pcity)) {
-      incite_revolt_cost /= 2;
-    }
-    if (unit_list_size(&map_get_tile(pcity->x,pcity->y)->units)==0) {
-      incite_revolt_cost /= 2;
+  } built_impr_iterate_end;
+
+  /* Stability bonuses */
+  if (!city_unhappy(pcity)
+      && g->index != game.government_when_anarchy) {
+    cost *= 2;
+  }
+  if (city_celebrating(pcity)) {
+    cost *= 2;
+  }
+
+  /* City is empty */
+  if (unit_list_size(&map_get_tile(pcity->x,pcity->y)->units) == 0) {
+    cost /= 2;
+  }
+
+  /* Buy back is cheap, conquered cities are also cheap */
+  if (pcity->owner != pcity->original) {
+    if (pplayer->player_no == pcity->original) {
+      cost /= 2;            /* buy back: 50% price reduction */
+    } else {
+      cost = cost * 2 / 3;  /* buy conquered: 33% price reduction */
     }
   }
-  return incite_revolt_cost;
+
+  /* Distance from capital */
+  capital = find_palace(city_owner(pcity));
+  if (capital) {
+    int tmp = map_distance(capital->x, capital->y, pcity->x, pcity->y);
+    dist = MIN(32, tmp);
+  } else {
+    /* No capital? Take max penalty! */
+    dist = 32;
+  }
+  if (city_got_building(pcity, B_COURTHOUSE)) {
+    dist /= 4;
+  }
+  if (g->fixed_corruption_distance != 0) {
+    dist = MIN(g->fixed_corruption_distance, dist);
+  }
+
+  size = MAX(1, pcity->size
+                + pcity->ppl_happy[4]
+                - pcity->ppl_unhappy[4]
+                - pcity->ppl_angry[4] * 3);
+  cost *= size;
+  cost = cost / (dist + 3);
+
+  return cost;
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]