Author: cazfi
Date: Thu Aug  4 12:02:45 2016
New Revision: 33454

URL: http://svn.gna.org/viewcvs/freeciv?rev=33454&view=rev
Log:
Added "Stealings_Ignore" effect type.

Adopted from feature request by Edgaras Ĺ eputis <morphles>

See patch #4787

Modified:
    trunk/ai/default/daieffects.c
    trunk/common/effects.h
    trunk/doc/README.effects
    trunk/fc_version
    trunk/server/diplomats.c

Modified: trunk/ai/default/daieffects.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/daieffects.c?rev=33454&r1=33453&r2=33454&view=diff
==============================================================================
--- trunk/ai/default/daieffects.c       (original)
+++ trunk/ai/default/daieffects.c       Thu Aug  4 12:02:45 2016
@@ -534,6 +534,7 @@
   case EFT_CASUS_BELLI_SUCCESS:
   case EFT_ACTION_ODDS_PCT:
   case EFT_BORDER_VISION:
+  case EFT_STEALINGS_IGNORE:
     break;
     /* This has no effect for AI */
   case EFT_VISIBLE_WALLS:

Modified: trunk/common/effects.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/effects.h?rev=33454&r1=33453&r2=33454&view=diff
==============================================================================
--- trunk/common/effects.h      (original)
+++ trunk/common/effects.h      Thu Aug  4 12:02:45 2016
@@ -283,6 +283,8 @@
 #define SPECENUM_VALUE110NAME "Action_Odds_Pct"
 #define SPECENUM_VALUE111 EFT_BORDER_VISION
 #define SPECENUM_VALUE111NAME "Border_Vision"
+#define SPECENUM_VALUE112 EFT_STEALINGS_IGNORE
+#define SPECENUM_VALUE112NAME "Stealings_Ignore"
 /* keep this last */
 #define SPECENUM_COUNT EFT_COUNT
 #include "specenum_gen.h"

Modified: trunk/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.effects?rev=33454&r1=33453&r2=33454&view=diff
==============================================================================
--- trunk/doc/README.effects    (original)
+++ trunk/doc/README.effects    Thu Aug  4 12:02:45 2016
@@ -288,6 +288,14 @@
 will get an AMOUNT percent bonus. All Spy_Resistant's are summed before being 
 applied.
 
+Stealings_Ignore
+    When determining how difficult it is to steal a tech from enemy, AMOUNT
+previous times tech has been stolen from the city is ignored. Negative amount
+means that number of times tech has already been stolen from target city does
+not affect current attempt at all. With this effect it's possible to allow
+diplomats to steal tech multiple times from the same city, or make it easier
+for spies.
+
 Move_Bonus
     Add amount movement to units. Use UnitClass' requirement with range of 
 'Local' to give it a specific class of units only.

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=33454&r1=33453&r2=33454&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Thu Aug  4 12:02:45 2016
@@ -56,7 +56,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Aug.01"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Aug.04"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/diplomats.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/diplomats.c?rev=33454&r1=33453&r2=33454&view=diff
==============================================================================
--- trunk/server/diplomats.c    (original)
+++ trunk/server/diplomats.c    Thu Aug  4 12:02:45 2016
@@ -605,6 +605,8 @@
   struct research *presearch, *cresearch;
   struct player *cplayer;
   int count;
+  int bonus;
+  int times;
   Tech_type_id tech_stolen;
 
   /* We have to check arguments. They are sent to us by a client,
@@ -627,7 +629,7 @@
     /* Can't choose target. Will steal a random tech. */
     technology = A_UNSET;
   }
-  
+
   /* Targeted technology should be a ruleset defined tech,
    * "At Spy's Discretion" (A_UNSET) or a future tech (A_FUTURE). */
   if (technology == A_NONE
@@ -669,10 +671,21 @@
 
   log_debug("steal-tech: infiltrated");
 
+  bonus = get_unit_bonus(pdiplomat, EFT_STEALINGS_IGNORE);
+  if (bonus < 0) {
+    /* Negative effect value means infinite bonus */
+    times = 0;
+  } else {
+    times = pcity->server.steal - bonus;
+    if (times < 0) {
+      times = 0;
+    }
+  }
+
   /* Check if the Diplomat/Spy succeeds with his/her task. */
   /* (Twice as difficult if target is specified.) */
   /* (If already stolen from, impossible for Diplomats and harder for Spies.) 
*/
-  if (pcity->server.steal > 0 && !unit_has_type_flag(pdiplomat, UTYF_SPY)) {
+  if (times > 0 && !unit_has_type_flag(pdiplomat, UTYF_SPY)) {
     /* Already stolen from: Diplomat always fails! */
     count = 1;
     log_debug("steal-tech: difficulty: impossible");
@@ -683,17 +696,17 @@
       /* Targeted steal tech is more difficult. */
       count++;
     }
-    count += pcity->server.steal;
+    count += times;
     log_debug("steal-tech: difficulty: %d", count);
     /* Determine success or failure. */
     while (count > 0) {
-      if (fc_rand (100) >= game.server.diplchance) {
+      if (fc_rand(100) >= game.server.diplchance) {
         break;
       }
       count--;
     }
   }
-  
+
   if (count > 0) {
     if (pcity->server.steal > 0 && !unit_has_type_flag(pdiplomat, UTYF_SPY)) {
       notify_player(pplayer, city_tile(pcity),
@@ -721,7 +734,7 @@
                               city_tile(pcity), city_link(pcity));
     wipe_unit(pdiplomat, ULR_CAUGHT, cplayer);
     return FALSE;
-  } 
+  }
 
   tech_stolen = steal_a_tech(pplayer, cplayer, technology);
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to