Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2005:
[Freeciv-Dev] (PR#14113) NUCLEAR_PROOF effect
Home

[Freeciv-Dev] (PR#14113) NUCLEAR_PROOF effect

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#14113) NUCLEAR_PROOF effect
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Mon, 26 Sep 2005 03:02:52 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This patch adds probability to the NUCLEAR_PROOF effect, allowing
modpacks in which sdi defences are less then 100% accurate.
--
mateusz
? civscore.log
? client/diff.diff
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.240
diff -u -r1.240 aicity.c
--- ai/aicity.c 30 Aug 2005 19:21:50 -0000      1.240
+++ ai/aicity.c 26 Sep 2005 09:57:45 -0000
@@ -493,7 +493,8 @@
          break;
        case EFT_NUKE_PROOF:
          if (ai->threats.nuclear) {
-           v += pcity->size * unit_list_size(ptile->units) * (capital + 1);
+           v += pcity->size * unit_list_size(ptile->units) * (capital + 1)
+                * amount / 100;
          }
          break;
        case EFT_REVEAL_MAP:
Index: common/combat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/combat.c,v
retrieving revision 1.62
diff -u -r1.62 combat.c
--- common/combat.c     4 Aug 2005 21:34:40 -0000       1.62
+++ common/combat.c     26 Sep 2005 09:57:52 -0000
@@ -18,6 +18,8 @@
 #include <assert.h>
 #include <math.h>
 
+#include "rand.h"
+
 #include "game.h"
 #include "log.h"
 #include "map.h"
@@ -334,15 +336,17 @@
 }
 
 /**************************************************************************
-  a wrapper function returns 1 if there is a sdi-defense close to the square
+  Try defending against nuclear attack, if succed return a city which 
+  had enough luck and EFT_NUKE_PROOF.
+  If the attack was succesful return NULL.
 **************************************************************************/
-struct city *sdi_defense_close(const struct player *owner,
+struct city *sdi_try_defend(const struct player *owner,
                               const struct tile *ptile)
 {
   square_iterate(ptile, 2, ptile1) {
     struct city *pcity = tile_get_city(ptile1);
     if (pcity && (!pplayers_allied(city_owner(pcity), owner))
-       && get_city_bonus(pcity, EFT_NUKE_PROOF) > 0) {
+       && myrand(100) < get_city_bonus(pcity, EFT_NUKE_PROOF)) {
       return pcity;
     }
   } square_iterate_end;
Index: common/combat.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/combat.h,v
retrieving revision 1.17
diff -u -r1.17 combat.h
--- common/combat.h     22 Jul 2005 16:18:05 -0000      1.17
+++ common/combat.h     26 Sep 2005 09:57:52 -0000
@@ -44,7 +44,7 @@
 
 bool unit_really_ignores_citywalls(const struct unit *punit);
 bool unit_on_fortress(const struct unit *punit);
-struct city *sdi_defense_close(const struct player *owner,
+struct city *sdi_try_defend(const struct player *owner,
                               const struct tile *ptile);
 
 int get_attack_power(const struct unit *punit);
Index: data/civ1/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/effects.ruleset,v
retrieving revision 1.7
diff -u -r1.7 effects.ruleset
--- data/civ1/effects.ruleset   10 May 2005 19:08:55 -0000      1.7
+++ data/civ1/effects.ruleset   26 Sep 2005 09:57:53 -0000
@@ -678,7 +678,7 @@
 
 [effect_sdi_defense]
 name   = "Nuke_Proof"
-value  = 1
+value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "SDI Defense", "City"
Index: data/civ2/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/effects.ruleset,v
retrieving revision 1.10
diff -u -r1.10 effects.ruleset
--- data/civ2/effects.ruleset   2 Aug 2005 06:39:49 -0000       1.10
+++ data/civ2/effects.ruleset   26 Sep 2005 09:58:01 -0000
@@ -941,7 +941,7 @@
 
 [effect_sdi_defense]
 name   = "Nuke_Proof"
-value  = 1
+value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "SDI Defense", "City"
Index: data/default/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/effects.ruleset,v
retrieving revision 1.12
diff -u -r1.12 effects.ruleset
--- data/default/effects.ruleset        22 Aug 2005 21:15:49 -0000      1.12
+++ data/default/effects.ruleset        26 Sep 2005 09:58:01 -0000
@@ -971,7 +971,7 @@
 
 [effect_sdi_defense]
 name   = "Nuke_Proof"
-value  = 1
+value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "SDI Defense", "City"
Index: data/history/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/effects.ruleset,v
retrieving revision 1.8
diff -u -r1.8 effects.ruleset
--- data/history/effects.ruleset        2 Aug 2005 06:39:49 -0000       1.8
+++ data/history/effects.ruleset        26 Sep 2005 09:58:01 -0000
@@ -600,7 +600,7 @@
 
 [effect_sdi_defense]
 name   = "Nuke_Proof"
-value  = 1
+value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "SDI Defense", "City"
Index: doc/README.effects
===================================================================
RCS file: /home/freeciv/CVS/freeciv/doc/README.effects,v
retrieving revision 1.14
diff -u -r1.14 README.effects
--- doc/README.effects  2 Aug 2005 06:39:49 -0000       1.14
+++ doc/README.effects  26 Sep 2005 09:58:01 -0000
@@ -65,7 +65,7 @@
 
 "No_Sink_Deep" - prevent certain sea units from sinking in deep sea
 
-"Nuke_Proof"   - nuclear attacks will fail within AMOUNT distance
+"Nuke_Proof"   - nuclear attacks will fail with amount percent probability
 
 "Pollu_Pop_Pct"        - increases pollution caused by population by AMOUNT 
percent
 
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.352
diff -u -r1.352 unithand.c
--- server/unithand.c   15 Sep 2005 17:41:27 -0000      1.352
+++ server/unithand.c   26 Sep 2005 09:58:02 -0000
@@ -779,7 +779,7 @@
   }
 
   if (unit_flag(punit, F_NUCLEAR)) {
-    if ((pcity = sdi_defense_close(unit_owner(punit), def_tile))) {
+    if ((pcity = sdi_try_defend(unit_owner(punit), def_tile))) {
       notify_player(pplayer, punit->tile, E_UNIT_LOST_ATT,
                       _("Your Nuclear missile was shot down by"
                         " SDI defences, what a waste."));

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#14113) NUCLEAR_PROOF effect, Mateusz Stefek <=