00001 /* 00002 * Empire - A multi-player, client/server Internet based war game. 00003 * Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak, 00004 * Ken Stevens, Steve McClure 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 * --- 00021 * 00022 * See files README, COPYING and CREDITS in the root of the source 00023 * tree for related information and legal notices. It is expected 00024 * that future projects/authors will amend these files as needed. 00025 * 00026 * --- 00027 * 00028 * age.c: Age people 00029 * 00030 * Known contributors to this file: 00031 * Dave Pare, 1986 00032 */ 00033 00034 #include <config.h> 00035 00036 #include "update.h" 00037 00038 void 00039 age_levels(int etu) 00040 { 00041 float best_tech, best_res; 00042 struct natstr *np; 00043 int i; 00044 double level; 00045 double delta; 00046 int deltares; 00047 00048 best_tech = 0.0; 00049 best_res = 0.0; 00050 for (i = 0; NULL != (np = getnatp(i)); i++) { 00051 if (np->nat_stat != STAT_ACTIVE) 00052 continue; 00053 00054 if (best_tech < np->nat_level[NAT_TLEV]) 00055 best_tech = np->nat_level[NAT_TLEV]; 00056 if (best_res < np->nat_level[NAT_RLEV]) 00057 best_res = np->nat_level[NAT_RLEV]; 00058 if (level_age_rate != 0.0) { 00059 delta = np->nat_level[NAT_RLEV] * etu / (100 * level_age_rate); 00060 np->nat_level[NAT_RLEV] -= delta; 00061 delta = np->nat_level[NAT_TLEV] * etu / (100 * level_age_rate); 00062 np->nat_level[NAT_TLEV] -= delta; 00063 } 00064 /* 00065 * age reserves by 1% per every 24 etus 00066 */ 00067 deltares = -roundavg(np->nat_reserve * etu / 2400.0); 00068 if (deltares != 0) 00069 np->nat_reserve += deltares; 00070 /* Chad Zabel - above number is negative ( was a -= there 00071 which was wrong. */ 00072 } 00073 best_tech /= 5; 00074 best_res /= 5; 00075 for (i = 0; NULL != (np = getnatp(i)); i++) { 00076 if (np->nat_stat < STAT_SANCT || np->nat_stat == STAT_GOD) 00077 continue; 00078 level = np->nat_level[NAT_TLEV]; 00079 if (level < best_tech && chance(0.2)) 00080 np->nat_level[NAT_TLEV] += (best_tech - level) / 3; 00081 level = np->nat_level[NAT_RLEV]; 00082 if (level < best_res && chance(0.2)) 00083 np->nat_level[NAT_RLEV] += (best_res - level) / 3; 00084 } 00085 }
1.5.2