2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2017, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire 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 3 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, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * conv.c: Convert conquered populace into uw's
29 * Known contributors to this file:
31 * Markus Armbruster, 2004-2016
35 * format: convert <SECTS> <NUMBER PER SECTOR>
49 struct nstr_sect nstr;
50 int uwtoconvert, newuw, totaluw, uw;
51 int maxpop, civ, seceff, adj_mob, mob;
53 double security_extra = 1.0;
55 if (!snxtsct(&nstr, player->argp[1]))
57 uwtoconvert = onearg(player->argp[2], "Number to convert: ");
62 while (nxtsct(&nstr, §)) {
65 if (sect.sct_oldown == player->cnum)
67 natp = getnatp(sect.sct_own);
68 maxpop = max_pop(natp->nat_level[NAT_RLEV], §);
69 civ = sect.sct_item[I_CIVIL];
70 secstr = security_strength(§, &seceff);
72 * Must have military control to convert captured civs.
74 if (secstr * 10 < civ)
77 if (newuw > uwtoconvert)
79 uw = sect.sct_item[I_UW];
80 if (newuw > maxpop - uw)
85 * So entire civilian populations don't disappear immediately
86 * into re-education camps, charge a healthy mobility cost for
89 mob = sect.sct_mobil * 5;
91 /* security troops make conversion more effective */
92 security_extra = 1.0 + seceff / 1000.0;
93 adj_mob = ldround(((double)mob * security_extra), 1);
99 if (player->dolcost + newuw * 1.5 > natp->nat_money) {
100 pr("You can't afford to convert %d civilians in %s!\n",
101 newuw, xyas(sect.sct_x, sect.sct_y, player->cnum));
104 player->btused += (newuw - 1) / 100 + 1;
105 player->dolcost += newuw * 1.5;
108 sect.sct_item[I_UW] = newuw + uw;
110 sect.sct_item[I_CIVIL] = civ;
111 mob = roundavg(mob * 0.2);
112 if (mob > sect.sct_mobil)
113 mob = sect.sct_mobil;
114 sect.sct_mobil -= mob;
115 pr("%3d conquered civilians converted in %s (%d)\n",
116 newuw, xyas(sect.sct_x, sect.sct_y, player->cnum), uw + newuw);
118 sect.sct_oldown = sect.sct_own;
119 pr("%s is now completely yours.\n",
120 xyas(sect.sct_x, sect.sct_y, player->cnum));
125 pr("Total civilians converted: %d\n", totaluw);
126 pr("Paperwork at conversion places ... %d\n", player->btused);