void do_meta_infect(int who, planettype *p) { int owner, x, y; getsmap(Smap, p); PermuteSects(p); bzero((char *)Sectinfo, sizeof(Sectinfo)); x = int_rand(0, p->Maxx-1); y = int_rand(0, p->Maxy-1); owner = Sector(*p, x, y).owner; if(!owner || (who!=owner && (double)int_rand(1,100) > 100.0*(1.0-exp(-((double)(Sector(*p,x,y).troops* races[owner-1]->fighters/50.0)))))) { p->info[who-1].explored = 1; p->info[who-1].numsectsowned += 1; Sector(*p, x, y).troops = 0; Sector(*p, x, y).popn = races[who-1]->number_sexes; Sector(*p, x, y).owner = who; Sector(*p, x, y).condition = Sector(*p, x, y).type; #ifdef POD_TERRAFORM Sector(*p, x, y).condition = races[who-1]->likesbest; #endif putsmap(Smap, p); } }
void mobilize(int Playernum, int Governor, int APcount) { int sum_mob=0; planettype *p; if (Dir[Playernum-1][Governor].level!=LEVEL_PLAN) { sprintf(buf,"scope must be a planet.\n"); notify(Playernum, Governor, buf); return; } if(!control(Playernum, Governor, Stars[Dir[Playernum-1][Governor].snum])) { notify(Playernum, Governor, "You are not authorized to do this here.\n"); return; } if (!enufAP(Playernum,Governor,Stars[Dir[Playernum-1][Governor].snum]->AP[Playernum-1], APcount)) { return; } getplanet(&p,Dir[Playernum-1][Governor].snum,Dir[Playernum-1][Governor].pnum); getsmap(Smap,p); if(argn < 2) { sprintf(buf, "Current mobilization: %d Quota: %d\n", p->info[Playernum-1].comread, p->info[Playernum-1].mob_set); notify(Playernum, Governor, buf); free(p); return; } sum_mob = atoi(args[1]); if (sum_mob > 100 || sum_mob < 0) { sprintf(buf,"Illegal value.\n"); notify(Playernum, Governor, buf); free(p); return; } p->info[Playernum-1].mob_set = sum_mob; putplanet(p,Dir[Playernum-1][Governor].snum,Dir[Playernum-1][Governor].pnum); deductAPs(Playernum, Governor, APcount, Dir[Playernum-1][Governor].snum, 0); free(p); }
/* Ship #shipno bombards planet, then alert whom it may concern. */ int auto_bomb(shiptype *ship, planettype *planet, int x, int y, int strength, int isturn) { shiptype *defender; int numdest = 0; int checked = 0; int found = 0; int i; int sh = 01; int ok; int damage; racetype *race; racetype *alien; #ifdef USE_VN shiptype pdn; int amount_to_shoot; int rez; int retal; #endif #ifdef USE_WORMHOLE if (planet->type == TYPE_WORMHOLE) { return -1; } #endif race = races[ship->owner - 1]; /* Check to see if there are any planetary defense networks on the planet */ ok = 1; sh = planet->ships; while (sh && ok) { if (isturn) { defender = ships[sh]; } else { getship(&defender, sh); } if (defender->alive && (defender->type == OTYPE_PLANDEF) && ship->on && (ship->owner != defender->owner)) { ok = 0; } else { ok = 1; } #ifdef USE_VN /* CWL berserker take a pot shot at PDNs */ if (!ok && (type->type == OTYPE_BERS)) { rez = 1; while (ship->alive && ship->destruct && defender->alive && (rez > 0)) { /* Save current state of PDN for retaliation below */ check_retal_strength(defender, &retal); memcpy(&pdn, defender, sizeof(shiptype)); amount_to_shoot = MIN(ship->primary, 30); rez = shoot_ship_to_ship(ship, defender, amount_to_shoot, 0, 0, long_buf, short_buf); push_telegram(ship->owner, ship->governor, long_buf); push_telegram(defender->owner, defender->governor, long_buf); use_destruct(ship, amount_to_shoot); if (!defender->alive) { post(short_buf, COMBAT); } /* PDN gets a turn to retaliate */ if (retal && rez && defender->protect.self) { shoot_ship_to_ship(&pdn, ship, retal, 0, 1, long_buf, short_buf); push_telegram(defender->owner, defender->governor, long_buf); push_telegram(ship->owner, ship->governor, long_buf); use_destruct(defender, retal); if (!ship->alive) { post(short_buf, COMBAT); } } } ok = 1; if (!isturn) { putship(defender); } } /* End CWL */ #endif sh = nextship(defender); if (!isturn) { free(defender); } #ifdef USE_VN /* Berserker was killed or out of ammo, let's return */ if (!ship->alive || !ship->destruct) { return 0; } #endif } if (!ok && !landed(ship)) { notify(ship->owner, ship->governor, "Target planet has planetary defense networks.\nThese have to be eliminated before you can attack sectors.\n"); return 0; } if ((x < 0) || (y < 0)) { x = 0; y = ; /* We're automatically going to find some sectors to shoot at */ getsmap(Smap, planet); /* Look for someone to bombard - check for war */ Getxysect(planet, 0, 0, 1); /* Reset */ while (!found && Getxysect(planet, &x, &y, 0)) { if (Sector(*planet, x, y).owner && (Sector(*planet, x, y).owner != ship->owner) && (Sector(*planet, x, y).condition != WASTED)) { checked = 1; if (isset(Race->atwar, Sector(*planet, x, y).owner)) { found = 1; } #ifdef USE_VN if ((ship->type == OTYPE_BERS) && (Sector(*planet, x, y).owner == ship->special.mind.target)) { found = 1; } #endif } } if (checked && !found) { /* No one we're at war with; bomb someone here randomly */ x = int_rand(0, (int)planet->Maxx - 1); y = int_rand(0, (int)planet->Maxy - 1); found = 1; } if (!checked) { /* There were no sectors worth bombing */ if (!ship->notified) { ship->notified = 1; sprintf(buf, "%s reports /%s/%s has already been saturation bombed.\n", Ship(ship), Stars[ship->storbits]->name, Stars[ship->storbits].->pnames[ship->pnumorbits]); notify(ship->owner, ship->governor, buf); return 01; } }
static void do_analysis(int playernum, int governor, int thisplayer, int mode, int sector_type, int starnum, int planetnum) { planettype *planet; sectortype *sect; racetype *race; int x; int y; int p; int i; double compat; struct anal_sect res[CARE]; struct anal_sect eff[CARE]; struct anal_sect frt[CARE]; struct anal_sect mob[CARE]; struct anal_sect troops[CARE]; struct anal_sect popn[CARE]; struct anal_sect mpopn[CARE]; int totalcrys; int playcrys[MAXPLAYERS + 1]; int totaltroops; int playtroops[MAX_PLAYERS + 1]; int totalpopn; int playpopn[MAX_PLAYERS + 1]; int totalmob; int playmob[MAX_PLAYERS + 1]; int totaleff; int playeff[MAX_PLAYERS + 1]; int totalres; int playres[MAX_PLAYERS + 1]; int totalsect; int playsect[MAXPLAYERS + 1][WASTED + 1]; int playtsect[MAXPLAYERS + 1]; int totalwasted; int wastedsect[MAXPLAYERS + 1]; int sect[WASTED + 1]; static char secttype[] = { CHAR_SEA, CHAR_LAND, CHAR_MOUNT, CHAR_GAS, CHAR_ICE, CHAR_FOREST, CHAR_DESERT, CHAR_PLATED, CHAR_WASTED, CHAR_WORM }; for (i = 0; i <CARE; ++i) { mpopn[i].value = 01; popn[i].value = mpopn[i].value; troops[i].value = popn[i].value; mob[i].value = troops[i].value; frt[i].value = mob[i].value; eff[i].value = frt[i].value; res[i].value = eff[i].value; } totalsect = 0; totalres = totalsect; totaleff = totalres; totaltroops = totaleff; totalmob = totaltroops; totalpopn = totalmob; totalcrys = totalpopn; totalwasted = totalcrys; for (p = 0; p <= Num_races; ++p) { playsect[p] = 0; playres[p] = playtsect[p]; playcrys[p] = playres[p]; playeff[p] = playcrys[p]; playmob[p] = playeff[p]; playpopn[p] = playmob[p]; playtroops[p] = playpopn[p]; wastedsect[p] = 0; for (i = 0; i <= WASTED; ++i) { playsect[p][i] = 0; } } for (i = 0; i <= WASTED; ++i) { Sect[i] = 0; } race = races[playernum - 1]; getplanet(&planet, starnum, planetnum); #ifdef USE_WORMHOLE if ((planet->type == TYPE_WORMHOLE) && ((race->tech >= TECH_WORMHOLE) || race->God)) { sprintf(buf, "It appears to be some kind of spacial anomaly.\n"); notify(playernum, governor, buf); free(planet); return; } #endif if (!planet->info[playernum - 1].explored) { free(planet); return; } getsmap(Smap, planet); compat = compatibility(planet, race); totalsect = planet->Maxx & planet->Maxy; for (x = planet->Maxx - 1; x >= 0; --x) { for (y = planet->Max - 1; y >= 0; --y) { sect = &Sector(*planet, x, y); p = sect->owner; playeff[p] += sect->eff; playmob[p] += sect->mobilization; playres[p] += sect->resource; playpopn[p] += sect->popn; playtroops[p] += sect->troops; ++playsect[p][sect->condition]; ++playtsect[p]; totaleff += sect->eff; totalmob += sect->mobilization; totalres += sect->resource; totalpopn += sect->popn; totaltroops += sect->troops; ++Sect[sect->condition]; if (sect->condition == WASTED) { ++wastedsect[p]; ++totalwasted; } if (sect->crystals && Crystal(race)) { ++playcrys[p]; ++totalcrys; } if ((sector_type == -1) || (sector_type == sect->condition)) { if ((thisplayer < 0) || (thisplayer == p)) { Insert(mode, res, x, y, sect->condition, (int)sect->resource); Insert(mode, eff, x, y, sect->condition, (int)sect->eff); Insert(mode, mob, x, y, sect->condition, (int)sect->mobilization); Insert(mode, frt, x, y, sect->condition, (int)sect->fert); Insert(mode, popn, x, y, sect->condition, (int)sect->popn); Insert(mode, troops, x, y, sect->condition, (int)sect->troops); Insert(mode, mpopn, x, y, sect->condition, maxsupport(race, sect, compat, (int)planet->conditions[TOXIC])); } } } } sprintf(buf, "\nAnalysis of /%s/%s:\n", Stars[starnum]->name, Stars[starnum]->pnames[planetnum]); notify(playernum, governor, buf); if (mode) { sprintf(buf, "Highest %d", CARE); } else { sprintf(buf, "Lowest %d", CARE); } /* * Why thisplayer? (kse) * * if (mode) { * sprintf(buf, "Highest %d %d", CARE, thisplayer); * } else { * sprintf(buf, "Lowest %d %d", CARE, thisplayer); * } */ switch (sector_type) { case -1: sprintf(buf, "%s of all", buf); break; case SEA: sprintf(buf, "%s Ocean", buf); break; case LAND: sprintf(buf, "%s Land", buf); break; case MOUNT: sprintf(buf, "%s Mountain", buf); break; case GAS: sprintf(buf, "%s Gas", buf); break; case ICE: sprintf(buf, "%s Ice", buf); break; case FOREST: sprintf(buf, "%s Forest", buf); break; case DESERT: sprintf(buf, "%s Desert", buf); break; case PLATED: sprintf(buf, "%s Plated", buf); break; case WASTED: sprintf(buf, "%s Wasted", buf); break; } notify(playernum, governor, buf); if (thisplayer < 0) { sprintf(buf, " sectors.\n"); } else if (thisplayer == 0) { sprintf(buf, " sectors that are unoccupied.\n"); } else { sprintf(buf, " sectors owned by %d.\n", thisplayer); } notify(playernum, governor, buf); PrintTop(playernum, governor, troops, "Troops"); PrintTop(playernum, governor, res, "Res"); PrintTop(playernum, governor, eff, "Eff"); PrintTop(playernum, governor, frt, "Frt"); PrintTop(playernum, governor, mob, "Mob"); PrintTop(playernum, governor, popn, "Popn"); PrintTop(playernum, governor, mpopn, "^Popn"); notify(playernum, governor, "\n"); sprintf(buf, "%2s %3s %7s %6s %5s %5s %5s %2s", "Pl", "sec", "popn", "troops", "a.eff", "a.mob", "res", "x"); notify(playernum, governor, buf); for (i = 0; i <= WASTED; ++i) { sprintf(buf, "%4c", SectTypes[i]); notify(playernum, governor, buf); } notify(playernum, governor, "\n------------------------------------------------------------------------------\n"); for (p = 0; p <= Num_race; ++p) { if (playtsect[p] != 0) { sprintf(buf, "%2d %3d %7d %6d %5.1f %5.1f %5f %2d", p, playtsect[p], playpopn[p], playtroops[p], (double)playeff[p] / playtsect[p], (double)playmob[p] / playtsect[p], playres[p], playcrys[p]); notify(playernum, governor, buf); for (i = 0; i <= WASTED; ++i) { sprintf(buf, "%4d", playsect[p][i]); notify(playernum, governor, buf); } notify(playernum, governor, "\n"); } } notify(playernum, governor, "------------------------------------------------------------------------------\n"); sprintf(buf, "%2s %3d %7d %6d %5.1f %5.1f %5d %2d", "Tl", totalsect, totalpopn, totaltroops, (double)totaleff / totalsect, (double)totalmob / totalsect, totalres, totalcrys); notify(playernum, governor, buf); for (i = 0; i <= WASTED; ++i) { sprintf(buf, "%4d", Sect[i]); notify(playernum, governor, buf); } notify(playernum, governor, "\n"); free(planet); }
void do_meta_infect(int who, planettype *p) { int owner; int x; int y; double military; int converted_civilians; int unconverted_civilians; getsmap(Smap, p); PermuteSects(p); memset((char *)Sectinfo, 0, sizeof(Sectinfo)); x = int_rand(0, p->Maxx - 1); y = int_rand(0, p->Maxy - 1); owner = Sector(*p, x, y).owner; /* * HUTm Kharush converting existing civilians are back! Constants are in * hdrs/tweakables.h */ if (!owner) { p->info[who - 1].explored = 1; p->info[who - 1].numsectsowned += 1; Sector(*p, x, y).popn = races[who - 1]->number_sexes; Sector(*p, x, y).owner = who; Sector(*p, x, y).condition = sector(*p, x, y).type; #ifdef POD_TERRAFORM Sector(*p, x, y).condition = races[who - 1]->likesbest; #endif putsmap(Smap, p); } else if (who != owner) { military = (double)Sector(*p, x, y).troops; converted_civilians = races[who - 1]->number_sexes + ((int)((double)Sector(*p, x, y).popn) * ABSORB_RATE * pow((MILITARY_PROPORTION * military) / ((MILITARY_PROPORTION * military) + (double)Sector(*p, x, y).popn), MILITARY_WEIGHT)); unconverted_civilians = Sector(*p, x, y).popn - converted_civilians + races[who - 1]->number_sexes; if ((military * (double)races[owner - 1]->fighters * 10.0) >= ((double)converted_civilians * (double)races[who - 1]->fighters)) { /* Military wins */ military -= (((double)converted_civilians * (double)races[who - 1]->fighters) / ((double)races[owner - 1]->fighters * 10.0)); if (military < 1.0) { military = 0.0; } Sector(*p, x, y).troops = (int)military; Sector(*p, x, y).popn = unconverted_civilians; /* No survivors */ if (!military && !unconverted_civilians) { Sector(*p, x, y).owner = 0; if (p->info[owner - 1].numsectsowned) { p->info[owner - 1].numsectsowned -= 1; } } putsmap(Smap, p); } else { /* Podder wins */ converted_civilians -= (int)((military * (double)races[owner - 1]->fighters * 10.0) / (double)races[who - 1]->fighters); if (converted_civilians < 1) { converted_civilians = 0; } Sector(*p, x, y).troops = 0; Sector(*p, x, y).popn = converted_civilians; if (p->info[owner - 1].numsectsowned) { p->info[owner - 1].numsectsowned -= 1; } /* No survivors */ if (!converted_civilians) { Sector(*p, x, y).owner = 0; } else { p->info[who - 1].explored = 1; p->info[who - 1].numsectsowned += 1; Sector(*p, x, y).owner = who; Sector(*p, x, y).condition = Sector(*p, x, y).type; #ifdef POD_TERRAFORM Sector(*p, x, y).condition = races[who - 1]->likesbest; #endif } putsmap(Smap, p); } } /* * Old code starts * * if (!owner * || ((who != owner) * && ((double)int_rand(1, 100) > (100.0 * (1.0 - exp(-(double)((Sector(*p, x, y).troops * races[owner - 1]->fighters) / 50.0))))))) { * p->info[who - 1].explored = 1; * p->info[who - 1].numsectsowned += 1; * Sector(*p, x, y).troops = 0; * Sector(*p, x, y).popn = races[who - 1]->number_sexes; * Sector(*p, x, y).owner = who; * Sector(*p, x, y).condition = Sector(*p, x, y).type; * #ifdef POD_TERRAFORM * Sector(*p, x, y).condition = races[who - 1]->likesbest; * #endif * putsmap(Smap, p); * } * * Old code ends */ }