2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * anti.c: Take action against che
30 * Known contributors to this file:
59 struct nstr_sect nstr;
64 int milkilled, chekilled;
65 double odds, damil, dache;
69 if (!snxtsct(&nstr, player->argp[1]))
73 while (nxtsct(&nstr, §)) {
77 pr(" sect subversion activity report\n");
78 pr(" ---- --------------------------\n");
80 getvec(VT_COND, cond, (char *)§, EF_SECTOR);
81 mil = getvar(V_MILIT, (char *)§, EF_SECTOR);
82 che = get_che_value(cond[C_CHE]);
83 target = get_che_cnum(cond[C_CHE]);
84 avail_mil = sect.sct_mobil / 2;
87 prxy("%4d,%-4d ", sect.sct_x, sect.sct_y, player->cnum);
89 pr("No available mil or mob in sector.\n");
92 pr("Sector mobility/troop strength will allow %d troops to engage.\n", avail_mil);
94 if (target == player->cnum) {
100 while (amil != 0 && ache != 0 && mob > 1) {
103 odds = (dache * 2.0 / (damil + dache));
104 odds /= hap_fact(getnatp(sect.sct_own),
105 getnatp(sect.sct_oldown));
109 milkilled = milkilled + 1;
112 chekilled = chekilled + 1;
115 if (mil - milkilled > 0) {
116 sect.sct_mobil = sect.sct_mobil - chekilled - milkilled;
117 putvar(V_MILIT, mil - milkilled, (char *)§, EF_SECTOR);
120 set_che_value(cond[C_CHE], ache);
121 putvar(V_CHE, cond[C_CHE], (char *)§, EF_SECTOR);
123 pr(" Body count: Military %d - Guerillas %d.\n",
124 milkilled, chekilled);
126 pr(" Partisans cleared out of this sector for now.\n");
128 pr(" Partisans still active in this sector.\n");
131 if (opt_MOB_ACCESS) {
133 -(etu_per_update / sect_mob_neg_factor);
137 sect.sct_loyal = sect.sct_loyal * 0.5;
138 n_cheleft = (random() % 4);
139 /* 75% chance some che will get left */
141 /* Ok, now leave anywhere from 16% to 25% of the che */
142 n_cheleft = (ache / (n_cheleft + 3));
144 set_che_value(cond[C_CHE], n_cheleft);
147 putvar(V_MILIT, ache, (char *)§, EF_SECTOR);
148 putvar(V_CHE, cond[C_CHE], (char *)§, EF_SECTOR);
149 if (sect.sct_own == sect.sct_oldown)
151 makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x,
153 makenotlost(EF_SECTOR, sect.sct_oldown, 0, sect.sct_x,
155 sect.sct_own = sect.sct_oldown;
156 sect.sct_off = 1; /* Turn the sector off */
158 pr(" Partisans take over the sector. You blew it.\n");
159 wu(0, sect.sct_oldown,
160 "Sector %s regained from Partisan activity.\n",
161 xyas(nstr.x, nstr.y, sect.sct_oldown));
164 pr(" Body count: Military 0 - Guerillas 0.\n");
165 pr(" Partisans cleared out of this sector for now.\n");
168 pr("%d sector%s\n", nsect, splur(nsect));