Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2005:
[Freeciv-Dev] (PR#12800) idea: barbarian level 5 (nightmare)
Home

[Freeciv-Dev] (PR#12800) idea: barbarian level 5 (nightmare)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12800) idea: barbarian level 5 (nightmare)
From: "Brian Dunstan" <bdunstan149@xxxxxxxxx>
Date: Thu, 14 Apr 2005 18:46:00 -0700
Reply-to: bugs@xxxxxxxxxxx

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

I have noticed that the barbarian level 4 (raging
hordes)  does not have much rage in it.  For a
moderate to good player, they are not a major concern.

I am curious what people think of adding modifying the
option such that a more difficult level is available. 


The attached patch accomplishes this, adding barbarian
level 5 (nightmare).  Barbarians are generated each
turn with a shield cost equivalent to twice the
combined production of the non-barbarian players. 
This will be a major concern for any player.  A good
human player will be able to defeat these barbarians,
but the 'hard' AI has about a 50% chance of survival.  

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
diff -Nur -Xfreeciv/diff_ignore freeciv/common/game.h 
freeciv-altered/common/game.h
--- freeciv/common/game.h       2005-04-14 15:27:29.558372112 -0400
+++ freeciv-altered/common/game.h       2005-04-14 15:27:37.039234848 -0400
@@ -469,7 +469,7 @@
 
 #define GAME_DEFAULT_BARBARIANRATE   2
 #define GAME_MIN_BARBARIANRATE       0
-#define GAME_MAX_BARBARIANRATE       4
+#define GAME_MAX_BARBARIANRATE       5
 
 #define GAME_DEFAULT_ONSETBARBARIAN  (GAME_START_YEAR+ \
                                      
((GAME_DEFAULT_END_YEAR-(GAME_START_YEAR))/3))
diff -Nur -Xfreeciv/diff_ignore freeciv/server/barbarian.c 
freeciv-altered/server/barbarian.c
--- freeciv/server/barbarian.c  2005-04-14 15:27:29.516378496 -0400
+++ freeciv-altered/server/barbarian.c  2005-04-14 17:23:28.635431592 -0400
@@ -375,12 +375,16 @@
     return;
   }
 
-  /* do not harass small civs - in practice: do not uprise at the beginning */
-  if ((int)myrand(UPRISE_CIV_MORE) >
-           (int)city_list_size(victim->cities) -
-                UPRISE_CIV_SIZE/(game.barbarianrate-1)
-      || myrand(100) > get_gov_pcity(pc)->civil_war) {
-    return;
+  /* at barbarianrate 4 or below: do not harass small civs - in practice: 
+   * do not uprise at the beginning.
+   * At barbarian rate 5 (and above), harass everybody, all the time */
+  if(game.barbarianrate < 5) {
+    if ((int)myrand(UPRISE_CIV_MORE) >
+       (int)city_list_size(victim->cities) -
+       UPRISE_CIV_SIZE/(game.barbarianrate-1)
+       || myrand(100) > get_gov_pcity(pc)->civil_war) {
+      return;
+    }
   }
   freelog(LOG_DEBUG, "Barbarians are willing to fight");
 
@@ -462,8 +466,59 @@
     /* Allow barbarians on maps smaller than MAP_FACTOR */
     n = 1;
   }
-
-  for (i = 0; i < n * (game.barbarianrate - 1); i++) {
-    try_summon_barbarians();
+  
+  if(game.barbarianrate < 5) {
+    for (i = 0; i < n * (game.barbarianrate - 1); i++) {
+      try_summon_barbarians();
+    }
+  }
+  /* level>=5 nightmare.  Summon barbarian units of value
+   * approximately equal to twice the combined output of the 
+   * non-barbarian (human or AI) players.  Do not let total number
+   * of barbarian units exceed 500 */
+  else {
+    int barbarian_shields = 0;
+    int barbarian_units = 0;
+    int barbarian_units_total_value = 0;
+    int barbarian_unit_avg_value = 0;
+    int barbarian_unit_quota = 0;
+    int i = 0;
+
+    players_iterate(aplayer) {
+      if(!is_barbarian(aplayer)) {
+       city_list_iterate(aplayer->cities, acity) {
+         barbarian_shields += 2*MAX(acity->size, acity->prod[O_SHIELD]);
+       } city_list_iterate_end;
+      }
+      else if(aplayer->is_alive) {
+       barbarian_units += unit_list_size(aplayer->units);
+       unit_list_iterate(aplayer->units, punit) {
+         barbarian_units_total_value +=
+           unit_build_shield_cost(punit->type);
+       } unit_list_iterate_end;
+      }
+    } players_iterate_end;
+    
+    barbarian_unit_avg_value = 
+      (int)((float)barbarian_units_total_value / 
+           (float)barbarian_units);
+
+    barbarian_unit_quota = 
+      barbarian_units + 
+      MAX(1, barbarian_shields / barbarian_unit_avg_value);
+
+    barbarian_unit_quota = MIN(500, barbarian_unit_quota);
+
+    while (barbarian_units < barbarian_unit_quota && 
+          i < 1000)  {
+      try_summon_barbarians();
+      barbarian_units = 0;
+      players_iterate(aplayer) {
+       if(is_barbarian(aplayer) && aplayer->is_alive) {
+         barbarian_units += unit_list_size(aplayer->units);
+       }
+      } players_iterate_end;
+      i++;
+    }
   }
 }
diff -Nur -Xfreeciv/diff_ignore freeciv/server/settings.c 
freeciv-altered/server/settings.c
--- freeciv/server/settings.c   2005-04-14 15:27:29.471385336 -0400
+++ freeciv-altered/server/settings.c   2005-04-14 15:27:37.044234088 -0400
@@ -690,7 +690,8 @@
             "1 = barbarians only in huts \n"
             "2 = normal rate of barbarian appearance \n"
             "3 = frequent barbarian uprising \n"
-            "4 = raging hordes, lots of barbarians"), NULL, 
+            "4 = raging hordes, lots of barbarians \n"
+            "5 = nightmare, way too many barbarians"), NULL, 
          GAME_MIN_BARBARIANRATE, GAME_MAX_BARBARIANRATE, 
          GAME_DEFAULT_BARBARIANRATE)
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12800) idea: barbarian level 5 (nightmare), Brian Dunstan <=