13 #include "gb/GB_server.h" 14 #include "gb/buffers.h" 15 #include "gb/defense.h" 16 #include "gb/files_shl.h" 18 #include "gb/getplace.h" 23 #include "gb/shlmisc.h" 24 #include "gb/tweakables.h" 25 #include "gb/utils/rand.h" 37 void load(
const command_t &argv, GameObj &g) {
38 player_t Playernum = g.player;
39 governor_t Governor = g.governor;
41 int mode = argv[0] ==
"load" ? 0 : 1;
44 unsigned char diff = 0;
57 if (argv.size() < 2) {
59 g.out <<
"Load what?\n";
61 g.out <<
"Unload what?\n";
66 nextshipno = start_shiplist(g, argv[1]);
69 if (in_list(Playernum, argv[1], *s, &nextshipno) &&
70 authorized(Governor, *s)) {
71 if (s->owner != Playernum || !s->alive) {
76 sprintf(buf,
"%s is irradiated and inactive.\n",
77 ship_to_string(*s).c_str());
78 notify(Playernum, Governor, buf);
82 if (s->whatorbits == ScopeLevel::LEVEL_UNIV) {
83 if (!
enufAP(Playernum
, Governor
, Sdata.AP[Playernum - 1]
, APcount
)) {
88 Stars[s->storbits]->AP[Playernum - 1]
, APcount
))
91 sprintf(buf,
"%s is not landed or docked.\n",
92 ship_to_string(*s).c_str());
93 notify(Playernum, Governor, buf);
97 if (s->whatdest == ScopeLevel::LEVEL_PLAN) {
98 sprintf(buf,
"%s at %d,%d\n", ship_to_string(*s).c_str(), s->land_x,
100 notify(Playernum, Governor, buf);
101 if (s->storbits != g.snum || s->pnumorbits != g.pnum) {
102 notify(Playernum, Governor,
103 "Change scope to the planet this ship is landed on.\n");
108 if (!s->destshipno) {
109 sprintf(buf,
"%s is not docked.\n", ship_to_string(*s).c_str());
113 if (!getship(&s2, (
int)s->destshipno)) {
114 g.out <<
"Destination ship is bogus.\n";
118 if (!s2->alive || !(s->whatorbits == ScopeLevel::LEVEL_SHIP ||
119 s2->destshipno == shipno)) {
123 s->whatdest = ScopeLevel::LEVEL_UNIV;
125 sprintf(buf,
"%s is not docked.\n", ship_to_string(*s2).c_str());
126 notify(Playernum, Governor, buf);
131 if (
overloaded(s2
) && s2->whatorbits == ScopeLevel::LEVEL_SHIP) {
132 sprintf(buf,
"%s is overloaded!\n", ship_to_string(*s2).c_str());
133 notify(Playernum, Governor, buf);
138 sprintf(buf,
"%s docked with %s\n", ship_to_string(*s).c_str(),
139 ship_to_string(*s2).c_str());
140 notify(Playernum, Governor, buf);
142 if (s2->owner != Playernum) {
143 sprintf(buf,
"Player %d owns that ship.\n", s2->owner);
144 notify(Playernum, Governor, buf);
151 amt = std::stoi(argv[3]);
155 if (mode) amt = -amt;
157 if (amt < 0 && s->type == ShipType::OTYPE_VN) {
158 g.out <<
"You can't unload VNs.\n";
166 if (!sh && (commod ==
'c' || commod ==
'm'))
174 diff ? 0 :
MIN(s2->crystals, max_crystals(*s) - s->crystals);
176 diff ? 0 : -
MIN(s->crystals, max_crystals(*s2) - s2->crystals);
178 uplim =
MIN(p.info[Playernum - 1].crystals,
179 max_crystals(*s) - s->crystals);
180 lolim = -s->crystals;
185 uplim = diff ? 0 :
MIN(s2->popn, max_crew(*s) - s->popn);
186 lolim = diff ? 0 : -
MIN(s->popn, max_crew(*s2) - s2->popn);
188 uplim =
MIN(sect.popn, max_crew(*s) - s->popn);
194 uplim = diff ? 0 :
MIN(s2->troops, max_mil(*s) - s->troops);
195 lolim = diff ? 0 : -
MIN(s->troops, max_mil(*s2) - s2->troops);
197 uplim =
MIN(sect.troops, max_mil(*s) - s->troops);
204 diff ? 0 :
MIN(s2->destruct, max_destruct(*s) - s->destruct);
205 lolim = -
MIN(s->destruct, max_destruct(*s2) - s2->destruct);
207 uplim =
MIN(p.info[Playernum - 1].destruct,
208 max_destruct(*s) - s->destruct);
209 lolim = -s->destruct;
215 diff ? 0 :
MIN((
int)s2->fuel, (
int)max_fuel(*s) - (
int)s->fuel);
216 lolim = -
MIN((
int)s->fuel, (
int)max_fuel(*s2) - (
int)s2->fuel);
218 uplim =
MIN((
int)p.info[Playernum - 1].fuel,
219 (
int)max_fuel(*s) - (
int)s->fuel);
220 lolim = -(
int)s->fuel;
225 if (s->type == ShipType::STYPE_SHUTTLE &&
226 s->whatorbits != ScopeLevel::LEVEL_SHIP)
227 uplim = diff ? 0 : s2->resource;
230 diff ? 0 :
MIN(s2->resource, max_resource(*s) - s->resource);
231 if (s2->type == ShipType::STYPE_SHUTTLE &&
232 s->whatorbits != ScopeLevel::LEVEL_SHIP)
233 lolim = -s->resource;
235 lolim = -
MIN(s->resource, max_resource(*s2) - s2->resource);
237 uplim =
MIN(p.info[Playernum - 1].resource,
238 max_resource(*s) - s->resource);
239 lolim = -s->resource;
243 g.out <<
"No such commodity valid.\n";
249 if (amt < lolim || amt > uplim) {
250 sprintf(buf,
"you can only transfer between %d and %d.\n", lolim,
252 notify(Playernum, Governor, buf);
259 Race = races[Playernum - 1];
261 if (amt == 0) amt = (mode ? lolim : uplim);
269 }
else if (sect.owner && sect.owner != Playernum) {
271 "That sector is already occupied by another player!\n");
272 notify(Playernum, Governor, buf);
282 if (!sect.popn && !sect.troops && amt < 0) {
283 p.info[Playernum - 1].numsectsowned++;
284 p.info[Playernum - 1].mob_points += sect.mobilization;
285 sect.owner = Playernum;
286 sprintf(buf,
"sector %d,%d COLONIZED.\n", s->land_x, s->land_y);
287 notify(Playernum, Governor, buf);
291 p.info[Playernum - 1].popn -= amt;
292 if (!sect.popn && !sect.troops) {
293 p.info[Playernum - 1].numsectsowned--;
294 p.info[Playernum - 1].mob_points -= sect.mobilization;
296 sprintf(buf,
"sector %d,%d evacuated.\n", s->land_x, s->land_y);
297 notify(Playernum, Governor, buf);
302 s->mass += amt * Race->mass;
303 sprintf(buf,
"crew complement of %s is now %lu.\n",
304 ship_to_string(*s).c_str(), s->popn);
305 notify(Playernum, Governor, buf);
313 }
else if (sect.owner && sect.owner != Playernum) {
315 "That sector is already occupied by another player!\n");
316 notify(Playernum, Governor, buf);
325 if (!(sect.popn + sect.troops) && amt < 0) {
326 p.info[Playernum - 1].numsectsowned++;
327 p.info[Playernum - 1].mob_points += sect.mobilization;
328 sect.owner = Playernum;
329 sprintf(buf,
"sector %d,%d OCCUPIED.\n", s->land_x, s->land_y);
330 notify(Playernum, Governor, buf);
334 p.info[Playernum - 1].troops -= amt;
335 if (!(sect.troops + sect.popn)) {
336 p.info[Playernum - 1].numsectsowned--;
337 p.info[Playernum - 1].mob_points -= sect.mobilization;
339 sprintf(buf,
"sector %d,%d evacuated.\n", s->land_x, s->land_y);
340 notify(Playernum, Governor, buf);
345 s->mass += amt * Race->mass;
346 sprintf(buf,
"troop complement of %s is now %lu.\n",
347 ship_to_string(*s).c_str(), s->troops);
348 notify(Playernum, Governor, buf);
356 p.info[Playernum - 1].destruct -= amt;
360 sprintf(buf,
"%d destruct transferred.\n", amt);
361 notify(Playernum, Governor, buf);
363 sprintf(buf,
"\n%s ", ship_to_string(*s).c_str());
364 notify(Playernum, Governor, buf);
366 sprintf(buf,
"now boobytrapped.\n");
368 sprintf(buf,
"no longer boobytrapped.\n");
370 notify(Playernum, Governor, buf);
377 p.info[Playernum - 1].crystals -= amt;
379 sprintf(buf,
"%d crystal(s) transferred.\n", amt);
380 notify(Playernum, Governor, buf);
384 s2->fuel -= (
double)amt;
387 p.info[Playernum - 1].fuel -= amt;
389 sprintf(buf,
"%d fuel transferred.\n", amt);
390 notify(Playernum, Governor, buf);
397 p.info[Playernum - 1].resource -= amt;
399 sprintf(buf,
"%d resources transferred.\n", amt);
400 notify(Playernum, Governor, buf);
403 g.out <<
"No such commodity.\n";
415 sprintf(buf,
"%d resources transferred.\n", amt);
416 notify(Playernum, Governor, buf);
417 sprintf(
bufr,
"%d Resources\n", amt);
420 sprintf(buf,
"%d fuel transferred.\n", amt);
421 notify(Playernum, Governor, buf);
422 sprintf(
buff,
"%d Fuel\n", amt);
425 sprintf(buf,
"%d destruct transferred.\n", amt);
426 notify(Playernum, Governor, buf);
427 sprintf(
bufd,
"%d Destruct\n", amt);
431 sprintf(buf,
"%d crystals transferred.\n", amt);
432 notify(Playernum, Governor, buf);
433 sprintf(
bufd,
"%d Crystal(s)\n", amt);
436 sprintf(buf,
"%d popn transferred.\n", amt);
437 notify(Playernum, Governor, buf);
438 sprintf(
bufc,
"%d %s\n", amt,
439 Race->Metamorph ?
"tons of biomass" :
"population");
442 sprintf(buf,
"%d military transferred.\n", amt);
443 notify(Playernum, Governor, buf);
444 sprintf(
bufm,
"%d %s\n", amt,
445 Race->Metamorph ?
"tons of biomass" :
"population");
453 if (commod ==
'c' || commod ==
'm') {
460 if (s->type == ShipType::OTYPE_TRANSDEV && s->special.transport.target &&
471 player_t Playernum = g.player;
472 governor_t Governor = g.governor;
476 shipnum_t nextshipno;
482 if (argv.size() < 2) {
483 g.out <<
"Jettison what?\n";
487 nextshipno = start_shiplist(g, argv[1]);
490 if (in_list(Playernum, argv[1], *s, &nextshipno) &&
491 authorized(Governor, *s)) {
492 if (s->owner != Playernum || !s->alive) {
497 g.out <<
"Ship is landed, cannot jettison.\n";
502 sprintf(buf,
"%s is irradiated and inactive.\n",
503 ship_to_string(*s).c_str());
504 notify(Playernum, Governor, buf);
508 if (s->whatorbits == ScopeLevel::LEVEL_UNIV) {
509 if (!
enufAP(Playernum
, Governor
, Sdata.AP[Playernum - 1]
, APcount
)) {
514 Stars[s->storbits]->AP[Playernum - 1]
, APcount
)) {
520 amt = std::stoi(argv[3]);
524 Race = races[Playernum - 1];
531 sprintf(buf,
"%d crystal%s jettisoned.\n", amt,
532 (amt == 1) ?
"" :
"s");
533 notify(Playernum, Governor, buf);
540 s->mass -= amt * Race->mass;
541 sprintf(buf,
"%d crew %s into deep space.\n", amt,
542 (amt == 1) ?
"hurls itself" :
"hurl themselves");
543 notify(Playernum, Governor, buf);
544 sprintf(buf,
"Complement of %s is now %lu.\n",
545 ship_to_string(*s).c_str(), s->popn);
546 notify(Playernum, Governor, buf);
552 sprintf(buf,
"%d military %s into deep space.\n", amt,
553 (amt == 1) ?
"hurls itself" :
"hurl themselves");
554 notify(Playernum, Governor, buf);
555 sprintf(buf,
"Complement of ship #%lu is now %lu.\n", shipno,
557 notify(Playernum, Governor, buf);
559 s->mass -= amt * Race->mass;
566 sprintf(buf,
"%d destruct jettisoned.\n", amt);
567 notify(Playernum, Governor, buf);
569 sprintf(buf,
"\n%s ", ship_to_string(*s).c_str());
570 notify(Playernum, Governor, buf);
572 g.out <<
"still boobytrapped.\n";
574 g.out <<
"no longer boobytrapped.\n";
583 sprintf(buf,
"%d fuel jettisoned.\n", amt);
584 notify(Playernum, Governor, buf);
591 sprintf(buf,
"%d resources jettisoned.\n", amt);
592 notify(Playernum, Governor, buf);
597 g.out <<
"No such commodity valid.\n";
607 player_t Playernum = g.player;
608 governor_t Governor = g.governor;
609 if (amt == 0) amt = max;
611 g.out <<
"Nice try.\n";
615 sprintf(buf,
"You can jettison at most %d\n", max);
616 notify(Playernum, Governor, buf);
622 void dump(
const command_t &argv, GameObj &g) {
623 player_t Playernum = g.player;
624 governor_t Governor = g.governor;
633 if (!
enufAP(Playernum
, Governor
, Stars[g.snum]->AP[Playernum - 1]
, APcount
))
636 if (!(player = get_player(argv[1]))) {
637 sprintf(buf,
"No such player.\n");
638 notify(Playernum, Governor, buf);
641 r = races[player - 1];
644 g.out <<
"Cheater!\n";
650 Race = races[Playernum - 1];
652 g.out <<
"Cheater!\n";
656 g.out <<
"Only leaders are allowed to use dump.\n";
661 if (argv.size() < 3) {
662 for (star = 0; star < Sdata.numstars; star++) {
665 if (
isset(Stars[star]->explored, Playernum)) {
666 setbit(Stars[star]->explored, player);
668 for (size_t i = 0; i < Stars[star]->numplanets; i++) {
670 if (planet.info[Playernum - 1].explored) {
671 planet.info[player - 1].explored = 1;
679 for (size_t i = 2; i < argv.size(); i++) {
680 where = getplace(g, argv[i], 1);
681 if (!where.err && where.level != ScopeLevel::LEVEL_UNIV &&
682 where.level != ScopeLevel::LEVEL_SHIP) {
684 getstar(&Stars[star], star);
686 if (
isset(Stars[star]->explored, Playernum)) {
687 setbit(Stars[star]->explored, player);
689 for (j = 0; j < Stars[star]->numplanets; j++) {
690 auto planet = getplanet(star, j);
691 if (planet.info[Playernum - 1].explored) {
692 planet.info[player - 1].explored = 1;
693 putplanet(planet, Stars[star], j);
696 putstar(Stars[star], star);
704 sprintf(buf,
"%s [%d] has given you exploration data.\n", Race->name,
706 warn_race(player, buf);
707 g.out <<
"Exploration Data transferred.\n";
711 player_t Playernum = g.player;
712 governor_t Governor = g.governor;
717 if (g.level != ScopeLevel::LEVEL_PLAN) {
718 sprintf(buf,
"You need to be in planet scope to do this.\n");
719 notify(Playernum, Governor, buf);
723 if (!
enufAP(Playernum
, Governor
, Stars[g.snum]->AP[Playernum - 1]
, APcount
))
726 if (!(player = get_player(argv[1]))) {
727 sprintf(buf,
"No such player.\n");
728 notify(Playernum, Governor, buf);
734 sscanf(argv[2].c_str(),
"%c", &commod);
736 resource_t give = std::stoul(argv[3]);
738 sprintf(temp,
"%s/%s:", Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum]);
741 if (give > planet.info[Playernum - 1].resource) {
742 sprintf(buf,
"You don't have %lu on this planet.\n", give);
743 notify(Playernum, Governor, buf);
745 planet.info[Playernum - 1].resource -= give;
746 planet.info[player - 1].resource += give;
748 "%s %lu resources transferred from player %d to player #%d\n",
749 temp, give, Playernum, player);
750 notify(Playernum, Governor, buf);
751 warn_race(player, buf);
756 if (give > planet.info[Playernum - 1].crystals) {
757 sprintf(buf,
"You don't have %lu on this planet.\n", give);
758 notify(Playernum, Governor, buf);
760 planet.info[Playernum - 1].crystals -= give;
761 planet.info[player - 1].crystals += give;
763 "%s %lu crystal(s) transferred from player %d to player #%d\n",
764 temp, give, Playernum, player);
765 notify(Playernum, Governor, buf);
766 warn_race(player, buf);
770 if (give > planet.info[Playernum - 1].fuel) {
771 sprintf(buf,
"You don't have %lu fuel on this planet.\n", give);
772 notify(Playernum, Governor, buf);
774 planet.info[Playernum - 1].fuel -= give;
775 planet.info[player - 1].fuel += give;
776 sprintf(buf,
"%s %lu fuel transferred from player %d to player #%d\n",
777 temp, give, Playernum, player);
778 notify(Playernum, Governor, buf);
779 warn_race(player, buf);
783 if (give > planet.info[Playernum - 1].destruct) {
784 sprintf(buf,
"You don't have %lu destruct on this planet.\n", give);
785 notify(Playernum, Governor, buf);
787 planet.info[Playernum - 1].destruct -= give;
788 planet.info[player - 1].destruct += give;
790 "%s %lu destruct transferred from player %d to player #%d\n",
791 temp, give, Playernum, player);
792 notify(Playernum, Governor, buf);
793 warn_race(player, buf);
797 sprintf(buf,
"What?\n");
798 notify(Playernum, Governor, buf);
806 void mount(
const command_t &argv, GameObj &g) {
807 const player_t Playernum = g.player;
808 const governor_t Governor = g.governor;
810 mnt = argv[0] ==
"mount";
814 shipnum_t nextshipno;
816 nextshipno = start_shiplist(g, argv[1]);
818 if (in_list(Playernum, argv[1], *ship, &nextshipno) &&
819 authorized(Governor, *ship)) {
821 notify(Playernum, Governor,
822 "This ship is not equipped with a crystal mount.\n");
826 if (ship->mounted && mnt) {
827 g.out <<
"You already have a crystal mounted.\n";
831 if (!ship->mounted && !mnt) {
832 g.out <<
"You don't have a crystal mounted.\n";
836 if (!ship->mounted && mnt) {
837 if (!ship->crystals) {
838 g.out <<
"You have no crystals on board.\n";
844 g.out <<
"Mounted.\n";
845 }
else if (ship->mounted && !mnt) {
846 if (ship->crystals == max_crystals(*ship)) {
847 notify(Playernum, Governor,
848 "You can't dismount the crystal. Max " 849 "allowed already on board.\n");
855 g.out <<
"Dismounted.\n";
856 if (ship->hyper_drive.charge || ship->hyper_drive.ready) {
857 ship->hyper_drive.charge = 0;
858 ship->hyper_drive.ready = 0;
859 g.out <<
"Discharged.\n";
861 if (ship->laser && ship->fire_laser) {
862 ship->fire_laser = 0;
863 g.out <<
"Laser deactivated.\n";
866 g.out <<
"Weird error in 'mount'.\n";
908 s->mass += (
double)amt * mass;
913 s->mass += (
double)amt * mass;
917 player_t Playernum = g.player;
918 governor_t Governor = g.governor;
921 Playernum = Race->Playernum;
924 g.out <<
"Origin ship not landed.\n";
927 if (s->storbits != g.snum || s->pnumorbits != g.pnum) {
928 sprintf(buf,
"Change scope to the planet the ship is landed on!\n");
929 notify(Playernum, Governor, buf);
933 g.out <<
"Origin device is damaged.\n";
936 if (!getship(&s2, (
int)s->special.transport.target)) {
937 sprintf(buf,
"The hopper seems to be blocked.\n");
938 notify(Playernum, Governor, buf);
941 if (!s2->alive || s2->type != ShipType::OTYPE_TRANSDEV || !s2->on) {
942 sprintf(buf,
"The target device is not receiving.\n");
943 notify(Playernum, Governor, buf);
948 g.out <<
"Target ship not landed.\n";
953 g.out <<
"Target device is damaged.\n";
958 sprintf(buf,
"Zap\07!\n");
959 notify(Playernum, Governor, buf);
963 sprintf(buf,
"%lu resources transferred.\n", s->resource);
964 notify(Playernum, Governor, buf);
965 sprintf(
bufr,
"%lu Resources\n", s->resource);
971 sprintf(buf,
"%g fuel transferred.\n", s->fuel);
972 notify(Playernum, Governor, buf);
973 sprintf(
buff,
"%g Fuel\n", s->fuel);
980 sprintf(buf,
"%d destruct transferred.\n", s->destruct);
981 notify(Playernum, Governor, buf);
982 sprintf(
bufd,
"%d Destruct\n", s->destruct);
988 s2->mass += s->popn * Race->mass;
991 sprintf(buf,
"%lu population transferred.\n", s->popn);
992 notify(Playernum, Governor, buf);
993 sprintf(
bufc,
"%lu %s\n", s->popn,
994 Race->Metamorph ?
"tons of biomass" :
"population");
995 s->mass -= s->popn * Race->mass;
1001 s2->crystals += s->crystals;
1003 sprintf(buf,
"%d crystal(s) transferred.\n", s->crystals);
1004 notify(Playernum, Governor, buf);
1005 sprintf(
bufx,
"%d crystal(s)\n", s->crystals);
1011 if (s2->owner != s->owner) {
1012 sprintf(telegram_buf,
"Audio-vibatory-physio-molecular transport device #");
1013 sprintf(buf,
"%s gave your ship %s the following:\n",
1014 ship_to_string(*s).c_str(), ship_to_string(*s2).c_str());
1015 strcat(telegram_buf, buf);
1016 strcat(telegram_buf,
bufr);
1017 strcat(telegram_buf,
bufd);
1018 strcat(telegram_buf,
buff);
1019 strcat(telegram_buf,
bufc);
1020 strcat(telegram_buf,
bufm);
1021 strcat(telegram_buf,
bufx);
1022 warn(s2->owner, s2->governor, telegram_buf);
1030 return (s->whatorbits == ScopeLevel::LEVEL_SHIP && s->destshipno == shipno);
1034 Sector §,
int what,
int people) {
1035 player_t Playernum = g.player;
1036 governor_t Governor = g.governor;
1053 notify(Playernum, Governor,
1054 "You have to unload to assault alien sectors.\n");
1057 ground_assaults[Playernum - 1][sect.owner - 1][g.snum] += 1;
1058 Race = races[Playernum - 1];
1059 alien = races[sect.owner - 1];
1061 alien->translate[Playernum - 1] =
1062 MIN(alien->translate[Playernum - 1] + 5, 100);
1063 Race->translate[sect.owner - 1] =
1064 MIN(Race->translate[sect.owner - 1] + 5, 100);
1066 oldowner = (
int)sect.owner;
1067 oldgov = Stars[g.snum]->governor[sect.owner - 1];
1070 ship->popn -= people;
1072 ship->troops -= people;
1073 ship->mass -= people * Race->mass;
1074 sprintf(buf,
"%d %s unloaded...\n", people, what ==
CIV ?
"civ" :
"mil");
1075 notify(Playernum, Governor, buf);
1076 sprintf(buf,
"Crew compliment %lu civ %lu mil\n", ship->popn, ship->troops);
1077 notify(Playernum, Governor, buf);
1079 sprintf(buf,
"%d %s assault %lu civ/%lu mil\n", people,
1080 what ==
CIV ?
"civ" :
"mil", sect.popn, sect.troops);
1082 notify(Playernum, Governor, buf);
1084 old2popn = sect.popn;
1085 old3popn = sect.troops;
1087 defense = Defensedata[sect.condition];
1089 (
int)ship->armor
, defense
, 1.0 - (
double)ship->damage / 100.0
, 1090 alien->likes[sect.condition]
, &astrength
, &dstrength
, 1091 &casualties
, &casualties2
, &casualties3
);
1092 sprintf(buf,
"Attack: %.2f Defense: %.2f.\n", astrength, dstrength);
1093 notify(Playernum, Governor, buf);
1095 if (!(sect.popn + sect.troops)) {
1099 absorbed = int_rand(0, old2popn + old3popn);
1100 sprintf(buf,
"%d alien bodies absorbed.\n", absorbed);
1101 notify(Playernum, Governor, buf);
1102 sprintf(buf,
"Metamorphs have absorbed %d bodies!!!\n", absorbed);
1103 notify(oldowner, oldgov, buf);
1106 sect.popn = people + absorbed;
1107 else if (what ==
MIL) {
1108 sect.popn = absorbed;
1109 sect.troops = people;
1111 sect.owner = Playernum;
1112 adjust_morale(Race, alien, (
int)alien->fighters);
1115 if (alien->absorb) {
1116 absorbed = int_rand(0, oldpopn - people);
1117 sprintf(buf,
"%d alien bodies absorbed.\n", absorbed);
1118 notify(oldowner, oldgov, buf);
1119 sprintf(buf,
"Metamorphs have absorbed %d bodies!!!\n", absorbed);
1120 notify(Playernum, Governor, buf);
1121 sect.popn += absorbed;
1124 sprintf(buf,
"Loading %d %s\n", people, what ==
CIV ?
"civ" :
"mil");
1125 notify(Playernum, Governor, buf);
1127 ship->popn += people;
1129 ship->troops += people;
1130 ship->mass -= people * Race->mass;
1131 adjust_morale(alien, Race, (
int)Race->fighters);
1133 sprintf(telegram_buf,
"/%s/%s: %s [%d] %s assaults %s [%d] %c(%d,%d) %s\n",
1134 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum], Race->name,
1135 Playernum, ship_to_string(*ship).c_str(), alien->name,
1136 alien->Playernum, Dessymbols[sect.condition], ship->land_x,
1137 ship->land_y, (sect.owner == Playernum ?
"VICTORY" :
"DEFEAT"));
1139 if (sect.owner == Playernum) {
1140 sprintf(buf,
"VICTORY! The sector is yours!\n");
1141 notify(Playernum, Governor, buf);
1142 sprintf(buf,
"Sector CAPTURED!\n");
1143 strcat(telegram_buf, buf);
1145 sprintf(buf,
"%d %s move in.\n", people,
1146 what ==
CIV ?
"civilians" :
"troops");
1147 notify(Playernum, Governor, buf);
1149 planet->info[Playernum - 1].numsectsowned++;
1150 planet->info[Playernum - 1].mob_points += sect.mobilization;
1151 planet->info[oldowner - 1].numsectsowned--;
1152 planet->info[oldowner - 1].mob_points -= sect.mobilization;
1154 sprintf(buf,
"The invasion was repulsed; try again.\n");
1155 notify(Playernum, Governor, buf);
1156 sprintf(buf,
"You fought them off!\n");
1157 strcat(telegram_buf, buf);
1159 if (!(sect.popn + sect.troops + people)) {
1160 sprintf(buf,
"You killed all of them!\n");
1161 strcat(telegram_buf, buf);
1163 Race->translate[oldowner - 1] =
MIN(Race->translate[oldowner - 1] + 5, 100);
1166 sprintf(buf,
"Oh no! They killed your party to the last man!\n");
1167 notify(Playernum, Governor, buf);
1169 alien->translate[Playernum - 1] =
1170 MIN(alien->translate[Playernum - 1] + 5, 100);
1175 sprintf(buf,
"Casualties: You: %d civ/%d mil, Them: %d %s\n", casualties2,
1176 casualties3, casualties, what ==
CIV ?
"civ" :
"mil");
1177 strcat(telegram_buf, buf);
1178 warn(oldowner, oldgov, telegram_buf);
1179 sprintf(buf,
"Casualties: You: %d %s, Them: %d civ/%d mil\n", casualties,
1180 what ==
CIV ?
"civ" :
"mil", casualties2, casualties3);
1181 notify(Playernum, Governor, buf);
void mount(const command_t &argv, GameObj &g)
void use_fuel(Ship *s, double amt)
void rcv_resource(Ship *s, int amt)
void rcv_fuel(Ship *s, double amt)
Planet getplanet(const starnum_t star, const planetnum_t pnum)
void putsector(const Sector &s, const Planet &p, const int x, const int y)
void rcv_popn(Ship *s, int amt, double mass)
void dump(const command_t &argv, GameObj &g)
void deductAPs(const player_t Playernum, const governor_t Governor, unsigned int n, starnum_t snum, int sdata)
void jettison(const command_t &argv, GameObj &g)
int enufAP(int Playernum, int Governor, unsigned short AP, int x)
void load(const command_t &argv, GameObj &g)
static void unload_onto_alien_sector(GameObj &, Planet *, Ship *, Sector &, int, int)
void use_destruct(Ship *s, int amt)
void transfer(const command_t &argv, GameObj &g)
void putstar(startype *s, starnum_t snum)
shipnum_t do_shiplist(Ship **s, shipnum_t *nextshipno)
void getsdata(struct stardata *S)
void putplanet(const Planet &p, startype *star, const int pnum)
void use_resource(Ship *s, int amt)
void getstar(startype **s, int star)
void rcv_destruct(Ship *s, int amt)
void rcv_troops(Ship *s, int amt, double mass)
static int jettison_check(GameObj &, int, int)
static void do_transporter(racetype *Race, GameObj &g, Ship *s)
static int landed_on(Ship *, shipnum_t)
Sector getsector(const Planet &p, const int x, const int y)
void ground_attack(racetype *Race, racetype *alien, int *people, int what, population_t *civ, population_t *mil, unsigned int def1, unsigned int def2, double alikes, double dlikes, double *astrength, double *dstrength, int *casualties, int *casualties2, int *casualties3)