7 #include "gb/commands/enslave.h" 13 #include "gb/GB_server.h" 14 #include "gb/buffers.h" 15 #include "gb/files_shl.h" 16 #include "gb/getplace.h" 20 #include "gb/shlmisc.h" 23 void enslave(
const command_t &argv, GameObj &g) {
24 const player_t Playernum = g.player;
25 const governor_t Governor = g.governor;
32 auto shipno = string_to_shipnum(argv[1]);
34 auto s = getship(*shipno);
39 if (testship(Playernum, Governor, *s)) {
42 if (s->type != ShipType::STYPE_OAP) {
43 sprintf(buf,
"This ship is not an %s.\n", Shipnames[ShipType::STYPE_OAP]);
44 notify(Playernum, Governor, buf);
47 if (s->whatorbits != ScopeLevel::LEVEL_PLAN) {
48 sprintf(buf,
"%s doesn't orbit a planet.\n", ship_to_string(*s).c_str());
49 notify(Playernum, Governor, buf);
52 if (!enufAP(Playernum, Governor, Stars[s->storbits]->AP[Playernum - 1],
56 auto p = getplanet(s->storbits, s->pnumorbits);
57 if (p.info[Playernum - 1].numsectsowned == 0) {
58 g.out <<
"You don't have a garrison on the planet.\n";
63 attack = aliens = def = 0;
65 if (p.info[i - 1].numsectsowned && i != Playernum) {
67 def += p.info[i - 1].destruct;
72 g.out <<
"There is no one else on this planet to enslave!\n";
76 Race = races[Playernum - 1];
78 Shiplist shiplist(p.ships);
79 for (
auto s2 : shiplist) {
80 if (s2.alive && s2.active) {
81 if (p.info[s2.owner].numsectsowned && s2.owner != Playernum)
83 else if (s2.owner == Playernum)
84 attack += s2.destruct;
88 deductAPs(Playernum, Governor, APcount, (
int)s->storbits, 0);
90 g.out <<
"\nFor successful enslavement this ship and the other ships here\n";
91 g.out <<
"that are yours must have a weapons\n";
92 g.out <<
"capacity greater than twice that the enemy can muster, including\n";
93 g.out <<
"the planet and all ships orbiting it.\n";
94 sprintf(buf,
"\nTotal forces bearing on %s: %d\n", prin_ship_orbits(&*s),
96 notify(Playernum, Governor, buf);
98 sprintf(telegram_buf,
"ALERT!!!\n\nPlanet /%s/%s ", Stars[s->storbits]->name,
99 Stars[s->storbits]->pnames[s->pnumorbits]);
101 if (def <= 2 * attack) {
102 p.slaved_to = Playernum;
103 putplanet(p, Stars[s->storbits], (
int)s->pnumorbits);
106 sprintf(buf,
"ENSLAVED by %s!!\n", ship_to_string(*s).c_str());
107 strcat(telegram_buf, buf);
108 sprintf(buf,
"All material produced here will be\ndiverted to %s coffers.",
110 strcat(telegram_buf, buf);
113 "\nEnslavement successful. All material produced here will\n");
114 notify(Playernum, Governor, buf);
115 sprintf(buf,
"be diverted to %s.\n", Race->name);
116 notify(Playernum, Governor, buf);
118 "You must maintain a garrison of 0.1%% the population of the\n");
119 notify(Playernum, Governor, buf);
121 "planet (at least %.0f); otherwise there is a 50%% chance that\n",
123 notify(Playernum, Governor, buf);
124 sprintf(buf,
"enslaved population will revolt.\n");
125 notify(Playernum, Governor, buf);
127 sprintf(buf,
"repulsed attempt at enslavement by %s!!\n",
128 ship_to_string(*s).c_str());
129 strcat(telegram_buf, buf);
130 sprintf(buf,
"Enslavement repulsed, defense/attack Ratio : %d to %d.\n",
132 strcat(telegram_buf, buf);
134 g.out <<
"Enslavement repulsed.\n";
135 g.out <<
"You needed more weapons bearing on the planet...\n";
139 if (p.info[i - 1].numsectsowned && i != Playernum)
140 warn(i, Stars[s->storbits]->governor[i - 1], telegram_buf);
void enslave(const command_t &argv, GameObj &g)