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 * sectdamage.c: Damage a sector
30 * Known contributors to this file:
54 sect_damage(struct sctstr *sp, int dam, struct emp_qelem *list)
63 sp->sct_effic = damage((int)sp->sct_effic, dam);
64 sp->sct_road = damage((int)sp->sct_road, dam);
65 sp->sct_rail = damage((int)sp->sct_rail, dam);
66 sp->sct_defense = damage((int)sp->sct_defense, dam);
67 if (!opt_DEFENSE_INFRA)
68 sp->sct_defense = sp->sct_effic;
72 if (sp->sct_mobil > 0)
73 sp->sct_mobil = damage((int)sp->sct_mobil, dam);
74 sp->sct_nv = vl_damage(dam,
75 sp->sct_vtype, sp->sct_vamt, (int)sp->sct_nv);
76 if (opt_EASY_BRIDGES == 0) {
77 if (sp->sct_effic < 20 && sp->sct_type == SCT_BHEAD)
80 if (sp->sct_effic < 20 && sp->sct_type == SCT_BSPAN)
88 sectdamage(struct sctstr *sp, int dam, struct emp_qelem *list)
90 extern double unit_damage;
96 double sector_strength();
98 /* Some sectors are harder/easier to kill.. */
99 /* Average sector has a dstr of 1, so adjust */
100 /* the damage accordingly. Makes forts a pain */
102 /* real_dam = (double)dam * (1.0/((((double)(dchr[sp->sct_type].d_dstr - 1))*(sp->sct_effic/100.0)) + 1.0));*/
103 real_dam = (double)dam *(1.0 / sector_strength(sp));
104 dam = ldround(real_dam, 1);
106 eff = sect_damage(sp, PERCENT_DAMAGE(dam), list);
108 /* Damage all the land units in the sector */
109 /* Units don't take full damage */
110 dam = ldround(DPERCENT_DAMAGE(dam * unit_damage), 1);
114 snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
115 while (nxtitem(&ni, (s_char *)&land)) {
118 landdamage(&land, dam);
119 putland(land.lnd_uid, &land);
125 snxtitem_xy(&ni, EF_PLANE, sp->sct_x, sp->sct_y);
126 while (nxtitem(&ni, (s_char *)&plane)) {
129 if (plane.pln_flags & PLN_LAUNCHED)
131 if (plane.pln_ship >= 0)
133 /* Is this plane flying in this list? */
134 if (ac_isflying(&plane, list))
136 planedamage(&plane, dam);
137 putplane(plane.pln_uid, &plane);