2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2004, 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 * populace.c: Return workforce available
30 * Known contributors to this file:
48 populace(struct natstr *np, struct sctstr *sp, int etu)
55 int civ = sp->sct_item[I_CIVIL];
56 int mil = sp->sct_item[I_MILIT];
58 if (civ == 0 && mil > 0) {
61 sp->sct_oldown = sp->sct_own;
63 if (!civ && !mil && !sp->sct_item[I_UW]
64 && !has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) {
65 makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
70 if (sp->sct_own != sp->sct_oldown && sp->sct_loyal == 0) {
71 sp->sct_oldown = sp->sct_own;
74 hap = np->nat_level[NAT_HLEV];
75 edu = np->nat_level[NAT_ELEV];
76 tech = np->nat_level[NAT_TLEV];
77 pct = (double)((tech - 40) / 40.0 + edu / 3.0);
78 if (sp->sct_own == sp->sct_oldown && hap < pct &&
79 chance((double)(((double)pct - (double)hap) / (double)5.0))) {
81 * zap the loyalty of unhappy civilians.
82 * there is a 20% chance per hap point below the
83 * "recommended" amount of this happening.
85 n = roundavg(etu * 0.125);
88 n = sp->sct_loyal + (random() % n) + 1;
93 if (sp->sct_loyal > 65 && mil < civ / 20) {
96 work_red = sp->sct_loyal - (50 + (random() % 15));
97 n = sp->sct_work - work_red;
101 if (chance((double)work_red / 1000.0)) {
103 * small chance of rebellion...
104 * if work_red is (max) 67,
105 * then revolt chance is 6.7%
108 } else if (chance(.30) && sp->sct_own)
109 wu(0, sp->sct_own, "Civil unrest in %s!\n", ownxy(sp));
114 n -= roundavg(etu * 0.25);
116 n += roundavg(etu * 0.125);
122 if (sp->sct_loyal == 0) {
123 if (sp->sct_oldown != sp->sct_own) {
125 "Sector %s is now fully yours\n", ownxy(sp));
126 sp->sct_oldown = sp->sct_own;
134 total_work(int sctwork, int etu, int civil, int milit, int uw, int maxpop)
143 return (civil * sctwork / 100.0 + milit * 0.4 + uw) * etu / 100.0;