include/land.h File Reference

#include <time.h>
#include "item.h"
#include "queue.h"
#include "retreat.h"
#include "types.h"

Include dependency graph for land.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lndstr
struct  lchrstr

Defines

#define LND_TYPE_MAX   30
#define LAND_MINEFF   10
#define LAND_MINFIREEFF   40
#define L_ENGINEER   bit(1)
#define L_SUPPLY   bit(2)
#define L_SECURITY   bit(3)
#define L_LIGHT   bit(4)
#define L_MARINE   bit(5)
#define L_RECON   bit(6)
#define L_RADAR   bit(7)
#define L_ASSAULT   bit(8)
#define L_FLAK   bit(9)
#define L_SPY   bit(10)
#define L_TRAIN   bit(11)
#define L_HEAVY   bit(12)
#define LND_ATTDEF(b, t)
#define LND_SPD(b, t)
#define LND_VUL(b, t)
#define LND_VIS(b, t)   (b)
#define LND_SPY(b, t)   (b)
#define LND_RAD(b, t)   (b)
#define LND_FRG(b, t)
#define LND_DAM(b, t)
#define LND_ACC(b, t)
#define LND_AMM(b, t)   (b)
#define LND_AAF(b, t)
#define LND_FC(b, t)   (b)
#define LND_FU(b, t)   (b)
#define LND_XPL(b, t)   (b)
#define LND_MXL(b, t)   (b)
#define LND_BLD_WORK(lcm, hcm)   (20 + (lcm) + 2 * (hcm))
#define LND_SPY_DETECT_CHANCE(eff)   ((110-(eff))/100.0)
#define getland(n, p)   ef_read(EF_LAND, (n), (p))
#define putland(n, p)   ef_write(EF_LAND, (n), (p))
#define getlandp(n)   ((struct lndstr *)ef_ptr(EF_LAND, (n)))

Enumerations

enum  { LND_AIROPS_EFF = 50 }

Functions

void lnd_sweep (struct emp_qelem *, int, int, natid)
int lnd_interdict (struct emp_qelem *, coord, coord, natid)
void lnd_sel (struct nstr_item *, struct emp_qelem *)
int lnd_check_mines (struct emp_qelem *)
double lnd_pathcost (struct lndstr *, double)
int lnd_mobtype (struct lndstr *)
double lnd_mobcost (struct lndstr *, struct sctstr *)
double attack_val (int, struct lndstr *)
double defense_val (struct lndstr *)
void lnd_print (struct ulist *, char *)
void lnd_delete (struct ulist *, char *)
int lnd_take_casualty (int, struct ulist *, int)
void lnd_submil (struct lndstr *, int)
void lnd_takemob (struct emp_qelem *, double)
int lnd_spyval (struct lndstr *)
double intelligence_report (int, struct lndstr *, int, char *)
int count_sect_units (struct sctstr *)
void count_units (struct shpstr *)
void lnd_count_units (struct lndstr *)
void lnd_mar (struct emp_qelem *, double *, double *, int *, natid)
int lnd_hardtarget (struct lndstr *)
int lnd_mar_one_sector (struct emp_qelem *, int, natid, int)
int lnd_support (natid, natid, coord, coord, int)
int lnd_can_attack (struct lndstr *)
int lnd_fortify (struct lndstr *lp, int hard_amt)
void lnd_set_tech (struct lndstr *, int)

Variables

lchrstr lchr [30+2]


Define Documentation

#define getland ( n,
 )     ef_read(EF_LAND, (n), (p))

Definition at line 177 of file land.h.

Referenced by ac_planedamage(), att_get_combat(), check_land_ok(), edit(), fort(), get_land(), land_bomb(), lboa(), lnd_damage(), lnd_mar(), lnd_postread(), lnd_prewrite(), mission_pln_equip(), multifire(), pinflak_planedamage(), pln_airbase_ok(), pln_equip(), pln_postread(), put_combat(), retreat_land(), and use_ammo().

#define getlandp (  )     ((struct lndstr *)ef_ptr(EF_LAND, (n)))

Definition at line 179 of file land.h.

Referenced by do_fallout(), lnd_prewrite(), look_land(), mob_land(), prod_land(), shp_prewrite(), and upd_slmilcosts().

#define L_ASSAULT   bit(8)

Definition at line 139 of file land.h.

Referenced by ask_olist(), boar(), and tend_land().

#define L_ENGINEER   bit(1)

Definition at line 132 of file land.h.

Referenced by ask_olist(), contains_engineer(), has_helpful_engineer(), landmine(), lnd_hit_mine(), lnd_sweep(), retreat_land1(), upd_land(), and work().

#define L_FLAK   bit(9)

Definition at line 140 of file land.h.

Referenced by ac_landflak().

#define L_HEAVY   bit(12)

Definition at line 143 of file land.h.

Referenced by load_land_land(), and load_land_ship().

#define L_LIGHT   bit(4)

Definition at line 135 of file land.h.

Referenced by load_land_ship(), and tend_land().

#define L_MARINE   bit(5)

Definition at line 136 of file land.h.

Referenced by attack_val(), defense_val(), intelligence_report(), and take_move_in_mob().

#define L_RADAR   bit(7)

Definition at line 138 of file land.h.

Referenced by radar().

#define L_RECON   bit(6)

Definition at line 137 of file land.h.

Referenced by lnd_spyval(), and spy().

#define L_SECURITY   bit(3)

Definition at line 134 of file land.h.

Referenced by do_conv(), guerrilla(), shoo(), and take_casualties().

#define L_SPY   bit(10)

Definition at line 141 of file land.h.

Referenced by assa(), attack_val(), buil(), count_sect_units(), defense_val(), do_look(), gen_power(), get_mob_support(), land_damage(), lnd_mar(), lnd_mar_one_sector(), lnd_take_casualty(), load_land_ship(), look_land(), prunits(), put_combat(), sabo(), satdisp_units(), satmap(), show_land_build(), show_land_capab(), show_land_stats(), take_def(), takeover(), tend_land(), and unitsatxy().

#define L_SUPPLY   bit(2)

Definition at line 133 of file land.h.

Referenced by fuel(), lnd_can_attack(), lnd_pathcost(), and s_commod().

#define L_TRAIN   bit(11)

Definition at line 142 of file land.h.

Referenced by lnd_mar(), and lnd_mobtype().

#define LAND_MINEFF   10

Definition at line 46 of file land.h.

Referenced by ask_olist(), attack_val(), build_land(), count_land_planes(), defense_val(), dounit(), get_land(), lnd_count_units(), lnd_postread(), lnd_prewrite(), lnd_take_casualty(), pln_postread(), prod_land(), retreat_land1(), takeover(), takeover_land(), unitsatxy(), and upd_land().

#define LAND_MINFIREEFF   40

Definition at line 47 of file land.h.

Referenced by lnd_support(), multifire(), perform_mission(), and quiet_bigdef().

#define LND_AAF ( b,
 ) 

Value:

((b * (1.0 + ((sqrt(t) / 100.0) * 3.0))) > 127  \
                       ? 127 : (b * (1.0 + ((sqrt(t) / 100.0) * 3.0))))

Definition at line 164 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_ACC ( b,
 ) 

Value:

((b * (1.0 - ((sqrt(t) / 100.0) * 1.1))) < 0    \
                       ? 0 : (b * (1.0 - ((sqrt(t) / 100.0) * 1.1))))

Definition at line 161 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_AMM ( b,
 )     (b)

Definition at line 163 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_ATTDEF ( b,
 ) 

Value:

(((b) * (1.0 + ((sqrt((t)) / 100.0) * 4.0)))    \
                          > 127 ? 127 :                                 \
                          ((b) * (1.0 + ((sqrt((t)) / 100.0) * 4.0))))

Definition at line 145 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_BLD_WORK ( lcm,
hcm   )     (20 + (lcm) + 2 * (hcm))

Definition at line 172 of file land.h.

Referenced by build_land(), landrepair(), lupgr(), and show_land_build().

#define LND_DAM ( b,
 ) 

Value:

((t) ?                               \
                       ((b) * (logx((t), 60.0) < 1.0 ? 1.0 : \
                               logx((t), 60.0))) : (b))

Definition at line 158 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_FC ( b,
 )     (b)

Definition at line 166 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_FRG ( b,
 ) 

Value:

((t) ?                               \
                       ((b) * (logx((t), 35.0) < 1.0 ? 1.0 : \
                               logx((t), 35.0))) : (b))

Definition at line 155 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_FU ( b,
 )     (b)

Definition at line 167 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_MXL ( b,
 )     (b)

Definition at line 169 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_RAD ( b,
 )     (b)

Definition at line 154 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_SPD ( b,
 ) 

Value:

((b * (1.0 + ((sqrt(t) / 100.0) * 2.1))) > 127  \
                       ? 127 : (b * (1.0 + ((sqrt(t) / 100.0) * 2.1))))

Definition at line 148 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_SPY ( b,
 )     (b)

Definition at line 153 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_SPY_DETECT_CHANCE ( eff   )     ((110-(eff))/100.0)

Definition at line 175 of file land.h.

Referenced by count_sect_units(), lnd_mar_one_sector(), look_land(), prunits(), sabo(), takeover(), and unitsatxy().

#define LND_TYPE_MAX   30

Definition at line 45 of file land.h.

#define LND_VIS ( b,
 )     (b)

Definition at line 152 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_VUL ( b,
 ) 

Value:

((b * (1.0 - ((sqrt(t) / 100.0) * 1.1))) < 0    \
                       ? 0 : (b * (1.0 - ((sqrt(t) / 100.0) * 1.1))))

Definition at line 150 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define LND_XPL ( b,
 )     (b)

Definition at line 168 of file land.h.

Referenced by lnd_set_tech(), and show_land_stats().

#define putland ( n,
 )     ef_write(EF_LAND, (n), (p))

Definition at line 178 of file land.h.

Referenced by add(), army(), ask_olist(), assa(), att_reacting_units(), attack_val(), build_land(), check_trade(), count_land_planes(), defense_val(), detonate(), do_conv(), fort(), fuel(), grab_sect(), grab_ship(), has_supply(), knockdown(), land_bomb(), landmine(), lload(), lnd_check_mines(), lnd_count_units(), lnd_damage(), lnd_delete(), lnd_mar_one_sector(), lnd_mess(), lnd_prewrite(), lnd_sel(), lnd_sweep(), load_land_land(), load_land_ship(), lrange(), lretr(), ltend(), lupgr(), mission_pln_equip(), morale(), multifire(), perform_mission(), pln_equip(), put_combat(), put_land(), put_plane_on_land(), quiet_bigdef(), retreat_land(), retreat_land1(), s_commod(), sabo(), scra(), scuttle_land(), scuttle_ship(), sectdamage(), shp_prewrite(), supp(), take_plane_off_land(), takeover_land(), tend_land(), use_ammo(), use_supply(), and work().


Enumeration Type Documentation

anonymous enum

Enumerator:
LND_AIROPS_EFF 

Definition at line 183 of file land.h.

00183      {
00184     LND_AIROPS_EFF = 50         /* min. efficiency for air ops */
00185 };


Function Documentation

double attack_val ( int  ,
struct lndstr  
)

Definition at line 58 of file lndsub.c.

References A_ASSAULT, A_ATTACK, A_BOARD, assault_penalty, I_MILIT, int, lchrstr::l_flags, L_MARINE, L_SPY, LAND_MINEFF, lchr, lndstr::lnd_att, lndstr::lnd_effic, lndstr::lnd_item, lndstr::lnd_type, lndstr::lnd_uid, and putland.

Referenced by ask_olist(), and get_ototal().

00059 {
00060     int men;
00061     double value;
00062     struct lchrstr *lcp;
00063 
00064     if (lp->lnd_effic < LAND_MINEFF) {
00065         putland(lp->lnd_uid, lp);
00066         return 0;
00067     }
00068 
00069     lcp = &lchr[(int)lp->lnd_type];
00070 
00071 /* Spies always count as 1 during assaults.  If they are the only ones
00072    in the assault, they get to sneak on anyway. */
00073 
00074     if (lcp->l_flags & L_SPY && combat_mode == A_ASSAULT)
00075         return 1;
00076 
00077     men = lp->lnd_item[I_MILIT];
00078     value = men * lp->lnd_att * lp->lnd_effic / 100.0;
00079 
00080     switch (combat_mode) {
00081     case A_ATTACK:
00082         return value;
00083     case A_ASSAULT:
00084         if (!(lcp->l_flags & L_MARINE))
00085             return assault_penalty * value;
00086         break;
00087     case A_BOARD:
00088         if (!(lcp->l_flags & L_MARINE))
00089             return assault_penalty * men;
00090     }
00091 
00092     return value;
00093 }

int count_sect_units ( struct sctstr  ) 

Definition at line 402 of file lndsub.c.

References chance(), EF_LAND, lchrstr::l_flags, L_SPY, land(), lchr, LND_SPY_DETECT_CHANCE, ni, nxtitem(), snxtitem_all(), and sp.

Referenced by spyline().

00403 {
00404     int count = 0;
00405     struct nstr_item ni;
00406     struct lndstr land;
00407 
00408     snxtitem_all(&ni, EF_LAND);
00409     while (nxtitem(&ni, &land)) {
00410         if (!land.lnd_own)
00411             continue;
00412         if (land.lnd_x != sp->sct_x || land.lnd_y != sp->sct_y)
00413             continue;
00414         /* Don't always see spies */
00415         if (lchr[(int)land.lnd_type].l_flags & L_SPY) {
00416             if (!(chance(LND_SPY_DETECT_CHANCE(land.lnd_effic))))
00417                 continue;
00418         }
00419         /* Got here, report it */
00420         ++count;
00421     }
00422 
00423     return count;
00424 }

Here is the call graph for this function:

void count_units ( struct shpstr  ) 

Definition at line 427 of file lndsub.c.

References EF_LAND, land(), ni, nxtitem(), putship, SHIP_MINEFF, snxtitem_xy(), and sp.

Referenced by load_land_ship(), put_combat(), shi(), sstat(), tend_land(), and unit_list().

00428 {
00429     struct nstr_item ni;
00430     struct lndstr land;
00431     int nland = 0;
00432 
00433     if (sp->shp_effic < SHIP_MINEFF)
00434         return;
00435 
00436     snxtitem_xy(&ni, EF_LAND, sp->shp_x, sp->shp_y);
00437     while (nxtitem(&ni, &land)) {
00438         if (land.lnd_own == 0)
00439             continue;
00440         if (land.lnd_ship == sp->shp_uid)
00441             nland++;
00442     }
00443 
00444     if (sp->shp_nland != nland) {
00445         sp->shp_nland = nland;
00446         putship(sp->shp_uid, sp);
00447     }
00448 }

Here is the call graph for this function:

double defense_val ( struct lndstr  ) 

Definition at line 96 of file lndsub.c.

References double, I_MILIT, int, lchrstr::l_flags, L_MARINE, L_SPY, LAND_MINEFF, land_mob_max, lchr, lndstr::lnd_def, lndstr::lnd_effic, lndstr::lnd_harden, lndstr::lnd_item, lndstr::lnd_land, lndstr::lnd_ship, lndstr::lnd_type, lndstr::lnd_uid, and putland.

Referenced by att_reacting_units(), get_dtotal(), and units_in_sector().

00097 {
00098     int men;
00099     double value;
00100     struct lchrstr *lcp;
00101 
00102     if (lp->lnd_effic < LAND_MINEFF) {
00103         putland(lp->lnd_uid, lp);
00104         return 0;
00105     }
00106 
00107     lcp = &lchr[(int)lp->lnd_type];
00108 
00109     men = lp->lnd_item[I_MILIT];
00110 
00111     if ((lp->lnd_ship >= 0 || lp->lnd_land >= 0) &&
00112         !(lcp->l_flags & L_MARINE))
00113         return men;
00114 
00115     value = men * lp->lnd_def * lp->lnd_effic / 100.0;
00116     value *= ((double)land_mob_max + lp->lnd_harden) / land_mob_max;
00117 
00118     /* If there are military on the unit, you get at least a 1
00119        man defensive unit, except for spies */
00120     if (value < 1.0 && men > 0 && !(lcp->l_flags & L_SPY))
00121         return 1;
00122 
00123     return value;
00124 }

double intelligence_report ( int  ,
struct lndstr ,
int  ,
char *   
)

Definition at line 329 of file lndsub.c.

References chance(), I_MILIT, int, lchrstr::l_flags, L_MARINE, lchr, lndstr::lnd_def, lndstr::lnd_effic, lndstr::lnd_item, lndstr::lnd_own, lndstr::lnd_ship, lndstr::lnd_tech, lndstr::lnd_type, lndstr::lnd_vis, MAX, pr(), prland(), roll(), roundintby(), and wu().

Referenced by att_get_defense(), att_reacting_units(), get_dlist(), and prunits().

00331 {
00332     struct lchrstr *lcp;
00333     char buf1[80], buf2[80], buf3[80];
00334     double estimate = 0.0;      /* estimated defense value */
00335 
00336     if (destination == 0)
00337         return 0;
00338 
00339     if (lp->lnd_own == 0)
00340         return 0;
00341 
00342     lcp = &lchr[(int)lp->lnd_type];
00343 
00344     memset(buf1, 0, sizeof(buf1));
00345     memset(buf2, 0, sizeof(buf2));
00346     memset(buf3, 0, sizeof(buf3));
00347     if (chance((spy + lp->lnd_vis) / 10.0)) {
00348         if (destination == player->cnum)
00349             pr("%s %s", mess, prland(lp));
00350         else
00351             sprintf(buf1, "%s %s", mess, prland(lp));
00352 
00353         estimate = lp->lnd_item[I_MILIT];
00354 
00355         if (chance((spy + lp->lnd_vis) / 20.0)) {
00356             if (destination == player->cnum)
00357                 pr(" (eff %d, mil %d",
00358                    roundintby(lp->lnd_effic, 5),
00359                    roundintby(lp->lnd_item[I_MILIT], 10));
00360             else
00361                 sprintf(buf2, " (eff %d, mil %d",
00362                         roundintby(lp->lnd_effic, 5),
00363                         roundintby(lp->lnd_item[I_MILIT], 10));
00364             estimate = lp->lnd_item[I_MILIT] * lp->lnd_effic / 100.0;
00365 
00366             if (chance((spy + lp->lnd_vis) / 20.0)) {
00367                 int t;
00368                 t = lp->lnd_tech - 20 + roll(40);
00369                 t = MAX(t, 0);
00370                 if (destination == player->cnum)
00371                     pr(", tech %d)\n", t);
00372                 else
00373                     sprintf(buf3, ", tech %d)\n", t);
00374             } else {
00375                 if (destination == player->cnum)
00376                     pr(")\n");
00377                 else
00378                     sprintf(buf3, ")\n");
00379             }
00380         } else {
00381             if (destination == player->cnum)
00382                 pr("\n");
00383             else
00384                 sprintf(buf2, "\n");
00385         }
00386     }
00387 
00388     if (destination != player->cnum) {
00389         wu(0, destination, "%s%s%s", buf1, buf2, buf3);
00390     }
00391 
00392     if (lp->lnd_ship < 0 || lcp->l_flags & L_MARINE)
00393         estimate *= lp->lnd_def;
00394 
00395     return estimate;
00396 }

Here is the call graph for this function:

int lnd_can_attack ( struct lndstr  ) 

Definition at line 1207 of file lndsub.c.

References int, lchrstr::l_flags, L_SUPPLY, lchr, and lndstr::lnd_type.

Referenced by ask_olist(), att_reacting_units(), and mission().

01208 {
01209     struct lchrstr *lcp = &lchr[(int)lp->lnd_type];
01210 
01211     if (lcp->l_flags & L_SUPPLY)
01212         return 0;
01213 
01214     return 1;
01215 }

int lnd_check_mines ( struct emp_qelem  ) 

Definition at line 685 of file lndsub.c.

References chance(), ulist::chrp, contains_engineer(), DMINE_LHITCHANCE, emp_remque(), getsect, empobj_storage::land, lnd_hit_mine(), lndstr::lnd_own, lndstr::lnd_uid, lndstr::lnd_x, lndstr::lnd_y, putland, putsect, emp_qelem::q_back, SCT_BSPAN, sctstr::sct_mines, sctstr::sct_oldown, sctstr::sct_type, and ulist::unit.

Referenced by do_unit_move(), lnd_mar_one_sector(), and move_in_land().

00686 {
00687     struct emp_qelem *qp;
00688     struct emp_qelem *next;
00689     struct ulist *llp;
00690     struct sctstr sect;
00691     int stopping = 0;
00692     int with_eng = contains_engineer(land_list);
00693 
00694     for (qp = land_list->q_back; qp != land_list; qp = next) {
00695         next = qp->q_back;
00696         llp = (struct ulist *)qp;
00697         getsect(llp->unit.land.lnd_x, llp->unit.land.lnd_y, &sect);
00698         if (sect.sct_oldown == llp->unit.land.lnd_own)
00699             continue;
00700         if (sect.sct_type == SCT_BSPAN)
00701             continue;
00702         if (!sect.sct_mines)
00703             continue;
00704         if (chance(DMINE_LHITCHANCE(sect.sct_mines) / (1 + 2 * with_eng))) {
00705             lnd_hit_mine(&llp->unit.land, ((struct lchrstr *)llp->chrp));
00706             sect.sct_mines--;
00707             putsect(&sect);
00708             putland(llp->unit.land.lnd_uid, &llp->unit.land);
00709             if (!llp->unit.land.lnd_own) {
00710                 stopping = 1;
00711                 emp_remque(qp);
00712                 free(qp);
00713             }
00714         }
00715     }
00716     return stopping;
00717 }

Here is the call graph for this function:

void lnd_count_units ( struct lndstr  ) 

Definition at line 451 of file lndsub.c.

References EF_LAND, land(), LAND_MINEFF, lndstr::lnd_effic, lndstr::lnd_nland, lndstr::lnd_uid, lndstr::lnd_x, lndstr::lnd_y, ni, nxtitem(), putland, and snxtitem_xy().

Referenced by land(), load_land_land(), load_land_ship(), and put_combat().

00452 {
00453     struct nstr_item ni;
00454     struct lndstr land;
00455     int nland = 0;
00456 
00457     if (lp->lnd_effic < LAND_MINEFF)
00458         return;
00459 
00460     snxtitem_xy(&ni, EF_LAND, lp->lnd_x, lp->lnd_y);
00461     while (nxtitem(&ni, &land)) {
00462         if (land.lnd_own == 0)
00463             continue;
00464         if (land.lnd_land == lp->lnd_uid)
00465             nland++;
00466     }
00467 
00468     if (lp->lnd_nland != nland) {
00469         lp->lnd_nland = nland;
00470         putland(lp->lnd_uid, lp);
00471     }
00472 }

Here is the call graph for this function:

void lnd_delete ( struct ulist ,
char *   
)

Definition at line 136 of file lndsub.c.

References emp_remque(), lnd_print(), and putland.

Referenced by ask_move_in(), assa(), get_land(), get_ototal(), kill_land(), lnd_mar_one_sector(), lnd_take_casualty(), and send_reacting_units_home().

00137 {
00138     if (s)
00139         lnd_print(llp, s);
00140     putland(llp->unit.land.lnd_uid, &llp->unit.land);
00141     emp_remque((struct emp_qelem *)llp);
00142     free(llp);
00143 }

Here is the call graph for this function:

int lnd_fortify ( struct lndstr lp,
int  hard_amt 
)

Definition at line 1223 of file lndsub.c.

References has_helpful_engineer(), int, land_mob_max, lndstr::lnd_harden, lndstr::lnd_land, lndstr::lnd_mobil, lndstr::lnd_own, lndstr::lnd_ship, lndstr::lnd_x, lndstr::lnd_y, and MIN.

Referenced by do_mob_land(), and fort().

01224 {
01225     int hard_amt;
01226     double mob_used, mult;
01227 
01228     if (lp->lnd_ship >= 0 || lp->lnd_land >= 0)
01229         return 0;
01230 
01231     mob_used = MIN(lp->lnd_mobil, mob);
01232     if (mob_used < 0)
01233         return 0;
01234 
01235     mult = has_helpful_engineer(lp->lnd_x, lp->lnd_y, lp->lnd_own)
01236         ? 1.5 : 1.0;
01237 
01238     hard_amt = (int)(mob_used * mult);
01239     if (lp->lnd_harden + hard_amt > land_mob_max) {
01240         hard_amt = land_mob_max - lp->lnd_harden;
01241         mob_used = ceil(hard_amt / mult);
01242     }
01243 
01244     lp->lnd_mobil -= (int)mob_used;
01245     lp->lnd_harden += hard_amt;
01246     lp->lnd_harden = MIN(lp->lnd_harden, land_mob_max);
01247 
01248     return hard_amt;
01249 }

Here is the call graph for this function:

int lnd_hardtarget ( struct lndstr  ) 

Definition at line 908 of file lndsub.c.

References dchrstr::d_dstr, dchr, getsect, lndstr::lnd_effic, lndstr::lnd_spd, lndstr::lnd_vis, lndstr::lnd_x, lndstr::lnd_y, and sctstr::sct_type.

Referenced by land_bomb(), and lnd_easiest_target().

00909 {
00910     struct sctstr sect;
00911 
00912     getsect(lp->lnd_x, lp->lnd_y, &sect);
00913     return (int)((lp->lnd_effic / 100.0) *
00914                  (10 + dchr[sect.sct_type].d_dstr * 2 + lp->lnd_spd / 2.0
00915                   - lp->lnd_vis));
00916 }

int lnd_interdict ( struct emp_qelem ,
coord  ,
coord  ,
natid   
)

Definition at line 885 of file lndsub.c.

References lnd_damage(), lnd_easiest_target(), lnd_missile_interdiction(), MI_INTERDICT, opt_NO_FORT_FIRE, and unit_interdict().

Referenced by ask_move_in(), and lnd_mar_one_sector().

00886 {
00887     int stopping = 0;
00888 
00889 #if 0
00890     if (!opt_NO_FORT_FIRE)
00891 /* Steve M. - commented out for now until abuse is decided upon */
00892         stopping |= lnd_fort_interdiction(list, newx, newy, victim);
00893 #endif
00894 
00895     stopping |=
00896         lnd_damage(list,
00897                    unit_interdict(newx, newy, victim, "land units",
00898                                   lnd_easiest_target(list), MI_INTERDICT));
00899 
00900     stopping |=
00901         lnd_damage(list,
00902                    lnd_missile_interdiction(list, newx, newy, victim));
00903     return stopping;
00904 }

Here is the call graph for this function:

void lnd_mar ( struct emp_qelem ,
double ,
double ,
int ,
natid   
)

Definition at line 529 of file lndsub.c.

References ALLIED, cname(), emp_remque(), getland, getnatp, getrel(), getsect, I_MILIT, lchrstr::l_flags, L_SPY, L_TRAIN, land(), empobj_storage::land, lchr, lndstr::lnd_item, lnd_mess(), lndstr::lnd_type, lndstr::lnd_uid, ulist::mobil, mpr(), prland(), emp_qelem::q_back, sctstr::sct_own, ulist::unit, and xyas().

Referenced by do_unit_move(), and march().

00531 {
00532     struct emp_qelem *qp;
00533     struct emp_qelem *next;
00534     struct ulist *llp;
00535     struct sctstr sect;
00536     struct lndstr land;
00537     coord allx;
00538     coord ally;
00539     int first = 1;
00540     char mess[128];
00541     int rel;
00542 
00543     *minmobp = 9876.0;
00544     *maxmobp = -9876.0;
00545     *togetherp = 1;
00546     for (qp = list->q_back; qp != list; qp = next) {
00547         next = qp->q_back;
00548         llp = (struct ulist *)qp;
00549         getland(llp->unit.land.lnd_uid, &land);
00550         if (land.lnd_own != actor) {
00551             mpr(actor, "%s was disbanded at %s\n",
00552                 prland(&land), xyas(land.lnd_x, land.lnd_y, land.lnd_own));
00553             emp_remque((struct emp_qelem *)llp);
00554             free(llp);
00555             continue;
00556         }
00557         if (land.lnd_ship >= 0) {
00558             lnd_mess("is on a ship", llp);
00559             continue;
00560         }
00561         if (land.lnd_land >= 0) {
00562             lnd_mess("is on a unit", llp);
00563             continue;
00564         }
00565         if (!getsect(land.lnd_x, land.lnd_y, &sect)) {
00566             lnd_mess("was sucked into the sky by a strange looking spaceland", llp);    /* heh -KHS */
00567             continue;
00568         }
00569         if (!(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
00570             !(lchr[(int)llp->unit.land.lnd_type].l_flags & L_TRAIN) &&
00571             llp->unit.land.lnd_item[I_MILIT] == 0) {
00572             lnd_mess("has no mil on it to guide it", llp);
00573             continue;
00574         }
00575         rel = getrel(getnatp(sect.sct_own), player->cnum);
00576         if (sect.sct_own != land.lnd_own && rel != ALLIED &&
00577             !(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
00578             sect.sct_own) {
00579             sprintf(mess, "has been kidnapped by %s", cname(sect.sct_own));
00580             lnd_mess(mess, llp);
00581             continue;
00582         }
00583         if (first) {
00584             allx = land.lnd_x;
00585             ally = land.lnd_y;
00586             first = 0;
00587         }
00588         if (land.lnd_x != allx || land.lnd_y != ally)
00589             *togetherp = 0;
00590         if (land.lnd_mobil + 1 < (int)llp->mobil) {
00591             llp->mobil = land.lnd_mobil;
00592         }
00593         if (llp->mobil < *minmobp)
00594             *minmobp = llp->mobil;
00595         if (llp->mobil > *maxmobp)
00596             *maxmobp = llp->mobil;
00597         llp->unit.land = land;
00598     }
00599 }

Here is the call graph for this function:

int lnd_mar_one_sector ( struct emp_qelem ,
int  ,
natid  ,
int   
)

Definition at line 968 of file lndsub.c.

References ALLIED, AT_WAR, chance(), check_land_ok(), check_sect_ok(), cname(), DIR_VIEW, diroff, emp_initque(), emp_insque(), emp_remque(), FRIENDLY, getnatp, getrel(), getsect, HOSTILE, I_CIVIL, INT_RAIL, intrchr, lchrstr::l_flags, L_SPY, empobj_storage::land, lchr, lnd_check_mines(), lnd_delete(), lndstr::lnd_effic, lndstr::lnd_harden, lnd_interdict(), lnd_mess(), lnd_mobcost(), lndstr::lnd_mobil, lnd_mobtype(), lndstr::lnd_own, LND_SPY_DETECT_CHANCE, lnd_sweep(), lndstr::lnd_type, lndstr::lnd_uid, lndstr::lnd_x, lndstr::lnd_y, MOB_RAIL, ulist::mobil, MOBILIZATION, NEUTRAL, pr(), prland(), putland, putsect, emp_qelem::q_back, QEMPTY, sctstr::sct_own, sctstr::sct_rail, SCT_SANCT, sctstr::sct_type, SCT_WASTE, SCT_WATER, sctstr::sct_x, sctstr::sct_y, setrel(), SITZKRIEG, stop(), ulist::unit, unit_put(), want_to_abandon(), would_abandon(), wu(), xnorm(), xyas(), and ynorm().

Referenced by do_unit_move().

00970 {
00971     struct sctstr sect, osect;
00972     struct emp_qelem *qp;
00973     struct emp_qelem *qp2;
00974     struct emp_qelem *next;
00975     struct ulist *llp;
00976     struct emp_qelem cur, done;
00977     coord dx;
00978     coord dy;
00979     coord newx;
00980     coord newy;
00981     int stopping = 0;
00982     int visible;
00983     int stop;
00984     char dp[80];
00985     int rel;
00986     int oldown;
00987 
00988     if (dir <= DIR_STOP || dir >= DIR_VIEW) {
00989         unit_put(list, actor);
00990         return 1;
00991     }
00992     dx = diroff[dir][0];
00993     dy = diroff[dir][1];
00994     for (qp = list->q_back; qp != list; qp = next) {
00995         next = qp->q_back;
00996         llp = (struct ulist *)qp;
00997         getsect(llp->unit.land.lnd_x, llp->unit.land.lnd_y, &osect);
00998         oldown = osect.sct_own;
00999         newx = xnorm(llp->unit.land.lnd_x + dx);
01000         newy = ynorm(llp->unit.land.lnd_y + dy);
01001         getsect(newx, newy, &sect);
01002         rel = getrel(getnatp(sect.sct_own), player->cnum);
01003         if ((sect.sct_own != actor && rel != ALLIED &&
01004              !(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
01005              sect.sct_own) || (sect.sct_type == SCT_WATER ||
01006                                sect.sct_type == SCT_SANCT ||
01007                                sect.sct_type == SCT_WASTE)) {
01008             if (together) {
01009                 pr("can't go to %s\n", xyas(newx, newy, actor));
01010                 return 1;
01011             } else {
01012                 sprintf(dp, "can't go to %s", xyas(newx, newy, actor));
01013                 lnd_mess(dp, llp);
01014                 continue;
01015             }
01016         }
01017         if ((!intrchr[INT_RAIL].in_enable || sect.sct_rail == 0)
01018             && lnd_mobtype(&llp->unit.land) == MOB_RAIL) {
01019             if (together) {
01020                 pr("no rail system in %s\n", xyas(newx, newy, actor));
01021                 return 1;
01022             } else {
01023                 sprintf(dp, "has no rail system in %s",
01024                         xyas(newx, newy, actor));
01025                 lnd_mess(dp, llp);
01026                 continue;
01027             }
01028         }
01029         /* Note we check would_abandon first because we don't want
01030            to always have to do these checks */
01031         if (would_abandon(&osect, I_CIVIL, 0, &llp->unit.land)) {
01032             stop = 0;
01033             if (!want_to_abandon(&osect, I_CIVIL, 0, &llp->unit.land)) {
01034                 stop = 1;
01035             }
01036             /* now check stuff */
01037             if (!check_sect_ok(&sect))
01038                 return 1;
01039             if (!check_sect_ok(&osect))
01040                 return 1;
01041             for (qp2 = list->q_back; qp2 != list; qp2 = qp2->q_back) {
01042                 if (!check_land_ok(&((struct ulist *)qp2)->unit.land))
01043                     return 1;
01044             }
01045             if (stop) {
01046                 lnd_mess("stops", llp);
01047                 continue;
01048             }
01049         }
01050         if (llp->mobil <= 0.0) {
01051             lnd_mess("is out of mobility", llp);
01052             continue;
01053         }
01054         llp->unit.land.lnd_x = newx;
01055         llp->unit.land.lnd_y = newy;
01056         llp->mobil -= lnd_mobcost(&llp->unit.land, &sect);
01057         llp->unit.land.lnd_mobil = (int)llp->mobil;
01058         llp->unit.land.lnd_harden = 0;
01059         putland(llp->unit.land.lnd_uid, &llp->unit.land);
01060         putsect(&osect);
01061         getsect(osect.sct_x, osect.sct_y, &osect);
01062         if (osect.sct_own != oldown && oldown == player->cnum) {
01063             /* It was your sector, now it's not.  Simple :) */
01064             pr("You no longer own %s\n",
01065                xyas(osect.sct_x, osect.sct_y, player->cnum));
01066         }
01067         if (rel != ALLIED && sect.sct_own != actor && sect.sct_own) {   /* must be a spy */
01068             /* Always a 10% chance of getting caught. */
01069             if (chance(LND_SPY_DETECT_CHANCE(llp->unit.land.lnd_effic))) {
01070                 if (rel == NEUTRAL || rel == FRIENDLY) {
01071                     wu(0, sect.sct_own,
01072                        "%s unit spotted in %s\n", cname(player->cnum),
01073                        xyas(sect.sct_x, sect.sct_y, sect.sct_own));
01074                     setrel(sect.sct_own, llp->unit.land.lnd_own, HOSTILE);
01075                 } else if (rel == HOSTILE || rel == AT_WAR ||
01076                            rel == SITZKRIEG || rel == MOBILIZATION) {
01077                     wu(0, sect.sct_own,
01078                        "%s spy shot in %s\n", cname(player->cnum),
01079                        xyas(sect.sct_x, sect.sct_y, sect.sct_own));
01080                     pr("%s was shot and killed.\n", prland(&llp->unit.land));
01081                     llp->unit.land.lnd_effic = 0;
01082                     putland(llp->unit.land.lnd_uid, &llp->unit.land);
01083                     lnd_delete(llp, 0);
01084                 }
01085             }
01086         }
01087     }
01088     if (QEMPTY(list))
01089         return stopping;
01090     lnd_sweep(list, 0, 1, actor);
01091     stopping |= lnd_check_mines(list);
01092     if (QEMPTY(list))
01093         return stopping;
01094 
01095     /* interdict land units sector by sector */
01096     emp_initque(&cur);
01097     emp_initque(&done);
01098     while (!QEMPTY(list)) {
01099         llp = (struct ulist *)list->q_back;
01100         newx = llp->unit.land.lnd_x;
01101         newy = llp->unit.land.lnd_y;
01102         /* move units in NEWX,NEWY to cur */
01103         visible = 0;
01104         for (qp = list->q_back; qp != list; qp = next) {
01105             next = qp->q_back;
01106             llp = (struct ulist *)qp;
01107             if (llp->unit.land.lnd_x == newx && llp->unit.land.lnd_y == newy) {
01108                 emp_remque(qp);
01109                 emp_insque(qp, &cur);
01110                 if (!(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY))
01111                     visible = 1;
01112             }
01113         }
01114         /* interdict them */
01115         if (visible)
01116             stopping |= lnd_interdict(&cur, newx, newy, actor);
01117         /* move survivors to done */
01118         for (qp = cur.q_back; qp != &cur; qp = next) {
01119             next = qp->q_back;
01120             llp = (struct ulist *)qp;
01121             emp_remque(qp);
01122             emp_insque(qp, &done);
01123         }
01124     }
01125     /* assign surviving land units back to list */
01126     emp_insque(list, &done);
01127     emp_remque(&done);
01128 
01129     return stopping;
01130 }

Here is the call graph for this function:

double lnd_mobcost ( struct lndstr ,
struct sctstr  
)

Definition at line 962 of file lndsub.c.

References lnd_mobtype(), lnd_pathcost(), sector_mcost(), and sp.

Referenced by lnd_mar_one_sector(), lnd_take_casualty(), and retreat_land1().

00963 {
00964     return lnd_pathcost(lp, sector_mcost(sp, lnd_mobtype(lp)));
00965 }

Here is the call graph for this function:

int lnd_mobtype ( struct lndstr  ) 

Definition at line 955 of file lndsub.c.

References lchrstr::l_flags, L_TRAIN, lchr, lndstr::lnd_type, MOB_MARCH, and MOB_RAIL.

Referenced by ask_olist(), att_reacting_units(), lnd_mar_one_sector(), lnd_mobcost(), lnd_sel(), take_move_in_mob(), and unit_path().

00956 {
00957     return (lchr[(int)lp->lnd_type].l_flags & L_TRAIN)
00958         ? MOB_RAIL : MOB_MARCH;
00959 }

double lnd_pathcost ( struct lndstr ,
double   
)

Definition at line 937 of file lndsub.c.

References lchrstr::l_flags, L_SUPPLY, lchr, lndstr::lnd_effic, lndstr::lnd_spd, lndstr::lnd_tech, lndstr::lnd_type, and speed_factor().

Referenced by ask_olist(), att_reacting_units(), lnd_mobcost(), lnd_sweep(), and take_move_in_mob().

00938 {
00939     double effspd;
00940 
00941     effspd = lp->lnd_spd;
00942     if (lchr[(int)lp->lnd_type].l_flags & L_SUPPLY)
00943         effspd *= lp->lnd_effic * 0.01;
00944 
00945     /*
00946      * The return value must be PATHCOST times a factor that depends
00947      * only on the land unit.  Anything else breaks path finding.  In
00948      * particular, you can't add or enforce a minimum cost here.  Do
00949      * it in sector_mcost().
00950      */
00951     return pathcost * 5.0 * speed_factor(effspd, lp->lnd_tech);
00952 }

Here is the call graph for this function:

void lnd_print ( struct ulist ,
char *   
)

Definition at line 127 of file lndsub.c.

References empobj_storage::land, lndstr::lnd_own, pr(), prland(), ulist::unit, and wu().

Referenced by get_land(), lnd_delete(), lnd_take_casualty(), and move_in_land().

00128 {
00129     if (llp->unit.land.lnd_own == player->cnum)
00130         pr("%s %s\n", prland(&llp->unit.land), s);
00131     else
00132         wu(0, llp->unit.land.lnd_own, "%s %s\n", prland(&llp->unit.land), s);
00133 }

Here is the call graph for this function:

void lnd_sel ( struct nstr_item ,
struct emp_qelem  
)

Definition at line 475 of file lndsub.c.

References ulist::chrp, EF_LAND, emp_initque(), emp_insque(), int, land(), empobj_storage::land, lchr, lnd_mobtype(), MOB_MARCH, MOB_MOVE, ulist::mobil, ni, nxtitem(), ontradingblock(), opt_MARKET, pr(), prland(), putland, ulist::queue, and ulist::unit.

Referenced by march().

00476 {
00477     struct lndstr land;
00478     struct lchrstr *lcp;
00479     struct ulist *llp;
00480     int this_mot;
00481     int mobtype = MOB_MOVE;     /* indeterminate */
00482 
00483     emp_initque(list);
00484     while (nxtitem(ni, &land)) {
00485         if (!player->owner)
00486             continue;
00487         if (opt_MARKET) {
00488             if (ontradingblock(EF_LAND, &land)) {
00489                 pr("unit #%d inelligible - it's for sale.\n",
00490                    land.lnd_uid);
00491                 continue;
00492             }
00493         }
00494         /*
00495          * The marching code gets confused when trains and non-trains
00496          * march together.  Disallow for now.
00497          */
00498         this_mot = lnd_mobtype(&land);
00499         if (this_mot != mobtype) {
00500             if (mobtype == MOB_MOVE)
00501                 mobtype = this_mot;
00502             else if (mobtype == MOB_MARCH) {
00503                 pr("%s is a train and can't march with the leader.\n",
00504                    prland(&land));
00505                 continue;
00506             } else {
00507                 pr("%s can't rail-march with the leading train.\n",
00508                    prland(&land));
00509                 continue;
00510             }
00511         }
00512 
00513         lcp = &lchr[(int)land.lnd_type];
00514         land.lnd_mission = 0;
00515         land.lnd_rflags = 0;
00516         land.lnd_harden = 0;
00517         memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));
00518         putland(land.lnd_uid, &land);
00519         llp = malloc(sizeof(struct ulist));
00520         llp->chrp = (struct empobj_chr *)lcp;
00521         llp->unit.land = land;
00522         llp->mobil = land.lnd_mobil;
00523         emp_insque(&llp->queue, list);
00524     }
00525 }

Here is the call graph for this function:

void lnd_set_tech ( struct lndstr ,
int   
)

Definition at line 1255 of file lndsub.c.

References CANT_HAPPEN, float, int, lchrstr::l_aaf, lchrstr::l_acc, lchrstr::l_ammo, lchrstr::l_att, lchrstr::l_dam, lchrstr::l_def, lchrstr::l_frg, lchrstr::l_fuelc, lchrstr::l_fuelu, lchrstr::l_nland, lchrstr::l_nxlight, lchrstr::l_rad, lchrstr::l_spd, lchrstr::l_spy, lchrstr::l_tech, lchrstr::l_vis, lchrstr::l_vul, lchr, lndstr::lnd_aaf, LND_AAF, lndstr::lnd_acc, LND_ACC, LND_AMM, lndstr::lnd_ammo, lndstr::lnd_att, LND_ATTDEF, lndstr::lnd_dam, LND_DAM, lndstr::lnd_def, LND_FC, lndstr::lnd_frg, LND_FRG, LND_FU, lndstr::lnd_fuelc, lndstr::lnd_fuelu, lndstr::lnd_maxland, lndstr::lnd_maxlight, LND_MXL, lndstr::lnd_rad, LND_RAD, lndstr::lnd_spd, LND_SPD, lndstr::lnd_spy, LND_SPY, lndstr::lnd_tech, lndstr::lnd_type, lndstr::lnd_vis, LND_VIS, lndstr::lnd_vul, LND_VUL, and LND_XPL.

Referenced by build_land(), dounit(), and lupgr().

01256 {
01257     struct lchrstr *lcp = lchr + lp->lnd_type;
01258     int tech_diff = tlev - lcp->l_tech;
01259 
01260     if (CANT_HAPPEN(tech_diff < 0)) {
01261       tlev -= tech_diff;
01262       tech_diff = 0;
01263     }
01264 
01265     lp->lnd_tech = tlev;
01266     lp->lnd_att = (float)LND_ATTDEF(lcp->l_att, tech_diff);
01267     lp->lnd_def = (float)LND_ATTDEF(lcp->l_def, tech_diff);
01268     lp->lnd_vul = (int)LND_VUL(lcp->l_vul, tech_diff);
01269     lp->lnd_spd = (int)LND_SPD(lcp->l_spd, tech_diff);
01270     lp->lnd_vis = (int)LND_VIS(lcp->l_vis, tech_diff);
01271     lp->lnd_spy = (int)LND_SPY(lcp->l_spy, tech_diff);
01272     lp->lnd_rad = (int)LND_RAD(lcp->l_rad, tech_diff);
01273     lp->lnd_frg = (int)LND_FRG(lcp->l_frg, tech_diff);
01274     lp->lnd_acc = (int)LND_ACC(lcp->l_acc, tech_diff);
01275     lp->lnd_dam = (int)LND_DAM(lcp->l_dam, tech_diff);
01276     lp->lnd_ammo = (int)LND_AMM(lcp->l_ammo, tech_diff);
01277     lp->lnd_aaf = (int)LND_AAF(lcp->l_aaf, tech_diff);
01278     lp->lnd_fuelc = (int)LND_FC(lcp->l_fuelc, tech_diff);
01279     lp->lnd_fuelu = (int)LND_FU(lcp->l_fuelu, tech_diff);
01280     lp->lnd_maxlight = (int)LND_XPL(lcp->l_nxlight, tech_diff);
01281     lp->lnd_maxland = (int)LND_MXL(lcp->l_nland, tech_diff);
01282 }

int lnd_spyval ( struct lndstr  ) 

Definition at line 320 of file lndsub.c.

References lchrstr::l_flags, L_RECON, lchr, lndstr::lnd_effic, lndstr::lnd_spy, and lndstr::lnd_type.

Referenced by ask_olist(), att_reacting_units(), and get_dlist().

00321 {
00322     if (lchr[(int)lp->lnd_type].l_flags & L_RECON)
00323         return lp->lnd_spy * (lp->lnd_effic / 100.0) + 2;
00324     else
00325         return lp->lnd_spy * (lp->lnd_effic / 100.0);
00326 }

void lnd_submil ( struct lndstr ,
int   
)

Definition at line 313 of file lndsub.c.

References I_MILIT, and lndstr::lnd_item.

Referenced by lnd_take_casualty(), and take_casualties().

00314 {
00315     int new = lp->lnd_item[I_MILIT] - num;
00316     lp->lnd_item[I_MILIT] = new < 0 ? 0 : new;
00317 }

int lnd_support ( natid  ,
natid  ,
coord  ,
coord  ,
int   
)

Definition at line 1138 of file lndsub.c.

References ALLIED, AT_WAR, cname(), dist(), EF_LAND, effrange(), getnatp, getrel(), has_supply(), I_GUN, I_MILIT, I_SHELL, land(), LAND_MINFIREEFF, landunitgun(), mapdist(), N_FIRE_BACK, N_FIRE_L_ATTACK, ni, nreport(), nxtitem(), prland(), roll(), roundrange(), snxtitem_all(), use_supply(), wu(), and xyas().

Referenced by get_dsupport(), and get_osupport().

01139 {
01140     struct nstr_item ni;
01141     struct lndstr land;
01142     int rel, rel2;
01143     double dam = 0.0;
01144     int dist;
01145     int shell;
01146     int gun;
01147     int range;
01148 
01149     snxtitem_all(&ni, EF_LAND);
01150     while (nxtitem(&ni, &land)) {
01151         if (land.lnd_frg == 0)
01152             continue;
01153         if ((land.lnd_x == x) && (land.lnd_y == y))
01154             continue;
01155         if (land.lnd_ship >= 0)
01156             continue;
01157         if (land.lnd_land >= 0)
01158             continue;
01159         if (land.lnd_effic < LAND_MINFIREEFF)
01160             continue;
01161         /* Do we have mil? */
01162         if (land.lnd_item[I_MILIT] <= 0)
01163             continue;
01164         rel = getrel(getnatp(land.lnd_own), attacker);
01165         rel2 = getrel(getnatp(land.lnd_own), victim);
01166         if ((land.lnd_own != attacker) &&
01167             ((rel != ALLIED) || (rel2 != AT_WAR)))
01168             continue;
01169 
01170         /* do we have supplies? */
01171         if (!has_supply(&land))
01172             continue;
01173 
01174         /* are we in range? */
01175         dist = mapdist(land.lnd_x, land.lnd_y, x, y);
01176 
01177         range = roundrange(effrange(land.lnd_frg, land.lnd_tech));
01178         if (dist > range)
01179             continue;
01180 
01181         shell = land.lnd_item[I_SHELL];
01182         gun = land.lnd_item[I_GUN];
01183 
01184         if (shell == 0 || gun == 0)
01185             continue;
01186 
01187         use_supply(&land);
01188         if (defending)
01189             nreport(land.lnd_own, N_FIRE_BACK, victim, 1);
01190         else
01191             nreport(land.lnd_own, N_FIRE_L_ATTACK, victim, 1);
01192         if (roll(100) < land.lnd_acc) {
01193             dam += landunitgun(land.lnd_effic, land.lnd_dam, gun,
01194                                land.lnd_ammo, shell) / 2;
01195         } else {
01196             dam += landunitgun(land.lnd_effic, land.lnd_dam, gun,
01197                                land.lnd_ammo, shell);
01198         }
01199         if (land.lnd_own != attacker)
01200             wu(0, land.lnd_own,
01201                "%s supported %s at %s\n",
01202                prland(&land), cname(attacker), xyas(x, y, land.lnd_own));
01203     }
01204     return (int)dam;
01205 }

Here is the call graph for this function:

void lnd_sweep ( struct emp_qelem ,
int  ,
int  ,
natid   
)

Definition at line 602 of file lndsub.c.

References chance(), ulist::chrp, getsect, I_SHELL, int, ITEM_MAX, L_ENGINEER, empobj_storage::land, lndstr::lnd_harden, lndstr::lnd_item, lnd_mess(), lndstr::lnd_mobil, lndstr::lnd_own, lnd_pathcost(), lndstr::lnd_uid, lndstr::lnd_x, lndstr::lnd_y, ulist::mobil, mpr(), prland(), putland, putsect, emp_qelem::q_back, SCT_BSPAN, sctstr::sct_item, sctstr::sct_mines, sctstr::sct_oldown, sctstr::sct_type, and ulist::unit.

Referenced by do_unit_move(), lnd_mar_one_sector(), and move_in_land().

00604 {
00605     struct emp_qelem *qp;
00606     struct emp_qelem *next;
00607     struct ulist *llp;
00608     struct sctstr sect;
00609     int mines, m, max, sshells, lshells;
00610 
00611     for (qp = land_list->q_back; qp != land_list; qp = next) {
00612         next = qp->q_back;
00613         llp = (struct ulist *)qp;
00614         if (!(((struct lchrstr *)llp->chrp)->l_flags & L_ENGINEER)) {
00615             if (verbose)
00616                 mpr(actor, "%s is not an engineer!\n",
00617                     prland(&llp->unit.land));
00618             continue;
00619         }
00620         if (takemob && llp->mobil < 0.0) {
00621             if (verbose)
00622                 lnd_mess("is out of mobility", llp);
00623             continue;
00624         }
00625         getsect(llp->unit.land.lnd_x, llp->unit.land.lnd_y, &sect);
00626         if (sect.sct_oldown == llp->unit.land.lnd_own) {
00627             if (verbose)
00628                 mpr(actor,
00629                     "%s is in a sector completely owned by you.  Don't bother digging up mines there!\n",
00630                     prland(&llp->unit.land));
00631             continue;
00632         }
00633         if (sect.sct_type == SCT_BSPAN) {
00634             if (verbose)
00635                 mpr(actor, "%s is on a bridge.  No mines there!\n",
00636                     prland(&llp->unit.land));
00637             continue;
00638         }
00639         if (takemob) {
00640             llp->mobil -= lnd_pathcost(&llp->unit.land, 0.2);
00641             llp->unit.land.lnd_mobil = (int)llp->mobil;
00642             llp->unit.land.lnd_harden = 0;
00643         }
00644         putland(llp->unit.land.lnd_uid, &llp->unit.land);
00645         if (!(mines = sect.sct_mines))
00646             continue;
00647         max = ((struct lchrstr *)llp->chrp)->l_item[I_SHELL];
00648         lshells = llp->unit.land.lnd_item[I_SHELL];
00649         sshells = sect.sct_item[I_SHELL];
00650         for (m = 0; mines > 0 && m < max * 2; m++) {
00651             if (chance(0.5 * ((struct lchrstr *)llp->chrp)->l_att)) {
00652                 mpr(actor, "Sweep...\n");
00653                 mines--;
00654                 if (lshells < max)
00655                     ++lshells;
00656                 else if (sshells < ITEM_MAX)
00657                     ++sshells;
00658             }
00659         }
00660         sect.sct_mines = mines;
00661         llp->unit.land.lnd_item[I_SHELL] = lshells;
00662         sect.sct_item[I_SHELL] = sshells;
00663         putland(llp->unit.land.lnd_uid, &llp->unit.land);
00664         putsect(&sect);
00665     }
00666 }

Here is the call graph for this function:

int lnd_take_casualty ( int  ,
struct ulist ,
int   
)

Definition at line 146 of file lndsub.c.

References A_DEFEND, att_mode, ulist::chrp, diroff, getsect, I_CIVIL, I_MILIT, int, L_SPY, empobj_storage::land, LAND_MINEFF, ldround(), lnd_delete(), lndstr::lnd_effic, lndstr::lnd_harden, lndstr::lnd_item, lndstr::lnd_land, lndstr::lnd_mission, lnd_mobcost(), lndstr::lnd_mobil, lndstr::lnd_own, lnd_print(), lndstr::lnd_retreat, lndstr::lnd_ship, lnd_submil(), lndstr::lnd_x, lndstr::lnd_y, ulist::mobil, nowned, orig(), pr(), roll(), sctstr::sct_item, SCT_MOUNT, sctstr::sct_own, sctstr::sct_type, sctstr::sct_x, sctstr::sct_y, ulist::unit, and xyas().

00149 {
00150     int eff_eq;
00151     int n;
00152     int biggest;
00153     int civs;
00154     int nowned;
00155     coord ret_x, ret_y;
00156     coord bx, by;
00157     struct sctstr sect;
00158     int ret_chance;
00159     char buf[1024];
00160     int taken;
00161     int nowhere_to_go = 0;
00162     struct sctstr rsect;
00163     double mobcost, bmcost;
00164     signed char orig;
00165     int mob;
00166 
00167     taken = llp->unit.land.lnd_item[I_MILIT];
00168     /* Spies always die */
00169     if (((struct lchrstr *)llp->chrp)->l_flags & L_SPY) {
00170         eff_eq = 100;
00171         llp->unit.land.lnd_effic = 0;
00172     } else {
00173         eff_eq = ldround(cas * 100.0 /
00174             ((struct lchrstr *)llp->chrp)->l_mil, 1);
00175         llp->unit.land.lnd_effic -= eff_eq;
00176         lnd_submil(&llp->unit.land, cas);
00177     }
00178 
00179     if (llp->unit.land.lnd_effic < LAND_MINEFF) {
00180         sprintf(buf, "dies %s %s!",
00181                 combat_mode ? att_mode[combat_mode] : "defending",
00182                 xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
00183                      llp->unit.land.lnd_own));
00184         lnd_delete(llp, buf);
00185         /* Since we killed the unit, we killed all the mil on it */
00186         return taken;
00187     } else {
00188         /* Ok, now, how many did we take off? (sould be the diff) */
00189         taken = taken - llp->unit.land.lnd_item[I_MILIT];
00190     }
00191 
00192     if (llp->unit.land.lnd_effic >= llp->unit.land.lnd_retreat)
00193         return taken;
00194 
00195     /* we're being boarded */
00196     if (llp->unit.land.lnd_ship >= 0 && combat_mode == A_DEFEND)
00197         return taken;
00198 
00199     /* we're being boarded */
00200     if (llp->unit.land.lnd_land >= 0 && combat_mode == A_DEFEND)
00201         return taken;
00202 
00203     /* Have to make a retreat check */
00204 
00205     ret_chance = llp->unit.land.lnd_retreat - llp->unit.land.lnd_effic;
00206     if (roll(100) < ret_chance) {
00207         pr("\n");
00208         lnd_print(llp, "fails morale check!");
00209         llp->unit.land.lnd_mission = 0;
00210         llp->unit.land.lnd_harden = 0;
00211         if (llp->unit.land.lnd_ship >= 0 || llp->unit.land.lnd_land >= 0)
00212             nowhere_to_go = 1;
00213         else if (combat_mode == A_DEFEND) {
00214             /*
00215              * defending unit.. find a place to send it
00216              * strategy: look for the most-populated 
00217              * adjacent sector that is owned by the unit
00218              * player->owner. Charge mob..
00219              */
00220             biggest = -1;
00221             nowned = 0;
00222             for (n = 1; n <= 6; ++n) {
00223                 ret_x = llp->unit.land.lnd_x + diroff[n][0];
00224                 ret_y = llp->unit.land.lnd_y + diroff[n][1];
00225                 getsect(ret_x, ret_y, &sect);
00226                 if (sect.sct_own != llp->unit.land.lnd_own)
00227                     continue;
00228                 if (sect.sct_type == SCT_MOUNT)
00229                     continue;
00230                 mobcost = lnd_mobcost(&llp->unit.land, &rsect);
00231                 if (mobcost < 0)
00232                     continue;
00233                 ++nowned;
00234                 civs = sect.sct_item[I_CIVIL];
00235                 if (civs > biggest) {
00236                     biggest = civs;
00237                     bx = sect.sct_x;
00238                     by = sect.sct_y;
00239                     bmcost = mobcost;
00240                 }
00241             }
00242             if (!nowned)
00243                 nowhere_to_go = 1;
00244             else {
00245                 /* retreat to bx,by */
00246                 llp->unit.land.lnd_x = bx;
00247                 llp->unit.land.lnd_y = by;
00248                 /* FIXME landmines */
00249                 getsect(bx, by, &rsect);
00250                 mob = llp->unit.land.lnd_mobil - (int)bmcost;
00251                 if (mob < -127)
00252                     mob = -127;
00253                 orig = llp->unit.land.lnd_mobil;
00254                 llp->unit.land.lnd_mobil = (signed char)mob;
00255                 if (llp->unit.land.lnd_mobil > orig)
00256                     llp->unit.land.lnd_mobil = -127;
00257                 sprintf(buf, "retreats at %d%% efficiency to %s!",
00258                         llp->unit.land.lnd_effic,
00259                         xyas(bx, by, llp->unit.land.lnd_own));
00260                 lnd_delete(llp, buf);
00261             }
00262         } else {                /* attacking from a sector */
00263             sprintf(buf, "leaves the battlefield at %d%% efficiency",
00264                     llp->unit.land.lnd_effic);
00265             if ((llp->unit.land.lnd_mobil - (int)llp->mobil) < -127)
00266                 llp->unit.land.lnd_mobil = -127;
00267             else
00268                 llp->unit.land.lnd_mobil -= (int)llp->mobil;
00269             llp->mobil = 0.0;
00270             lnd_delete(llp, buf);
00271         }
00272     }
00273     if (nowhere_to_go) {
00274         /* nowhere to go.. take more casualties */
00275         llp->unit.land.lnd_effic -= 10;
00276         lnd_submil(&llp->unit.land, ((struct lchrstr *)llp->chrp)->l_mil / 10);
00277         if (llp->unit.land.lnd_effic < LAND_MINEFF)
00278             lnd_delete(llp, "has nowhere to retreat, and dies!");
00279         else
00280             lnd_print(llp,
00281                       "has nowhere to retreat and takes extra losses!");
00282     }
00283 
00284     return taken;
00285 }

Here is the call graph for this function:

void lnd_takemob ( struct emp_qelem ,
double   
)

Definition at line 288 of file lndsub.c.

References combat_mob, empobj_storage::land, ldround(), lndstr::lnd_mobil, emp_qelem::q_forw, and ulist::unit.

Referenced by att_fight().

00289 {
00290     struct emp_qelem *qp, *next;
00291     struct ulist *llp;
00292     int new;
00293     int mcost = ldround(combat_mob * loss, 1);
00294 
00295     for (qp = list->q_forw; qp != list; qp = next) {
00296         next = qp->q_forw;
00297         llp = (struct ulist *)qp;
00298 /*
00299                 if (chance(loss))
00300                         use_supply(&llp->unit.land);
00301                 if (llp->unit.land.lnd_mission == MI_RESERVE)
00302                         new = llp->unit.land.lnd_mobil - mcost/2;
00303                 else
00304  */
00305         new = llp->unit.land.lnd_mobil - mcost;
00306         if (new < -127)
00307             new = -127;
00308         llp->unit.land.lnd_mobil = (signed char)new;
00309     }
00310 }

Here is the call graph for this function:


Variable Documentation

struct lchrstr lchr[30+2]

Definition at line 45 of file land.c.

Referenced by ac_landflak(), ask_olist(), assa(), att_get_combat(), att_reacting_units(), attack_val(), boar(), buil(), build_land(), count_sect_units(), defense_val(), do_conv(), do_look(), dounit(), ef_elt_byname(), emp_obj_chr_name(), fit_plane_on_land(), fuel(), gen_power(), get_empobj_chr(), get_land(), get_minimum(), guerrilla(), has_helpful_engineer(), init_lchr(), intelligence_report(), land(), land_damage(), landmine(), landrepair(), lcarg(), lnd_can_attack(), lnd_mar(), lnd_mar_one_sector(), lnd_mobtype(), lnd_pathcost(), lnd_sel(), lnd_set_tech(), lnd_spyval(), load_comm_land(), load_land_land(), load_land_ship(), look_land(), lrange(), lretr(), lsta(), ltend(), lupgr(), make_new_list(), mission(), prland(), prunits(), radar(), retreat_land1(), s_commod(), sabo(), satdisp_units(), satmap(), scra(), shoo(), spy(), starv_units(), take_casualties(), takeover(), tend_land(), trade_desc(), trade_nameof(), unit_type_name(), unitsatxy(), upd_land(), and work().


Generated on Fri Mar 28 11:01:22 2008 for empserver by  doxygen 1.5.2