39 static int pkg_id = 1000;
45 : campaign(c), squadron(0), mission(0), player_elem(0),
46 strike_group(0), strike_target(0), prime_target(0),
47 carrier_elem(0), ward(0), escort(0), airborne(false), airbase(false),
48 ownside(0), enemy(-1), mission_type(0), mission_info(0)
51 ::Print(
"ERROR - CMF campaign=0x%08x player_group=0x%08x\n",
58 switch (player_group->
Type()) {
78 ::Print(
"ERROR - CMF invalid player group: %s IFF %d\n",
103 ::Print(
"\n-----------------------------------------------\n");
105 ::
Print(
"CMF CreateMission() request: %s '%s'\n",
107 (
const char*) req->
Script());
110 ::Print(
"CMF CreateMission() request: %s %s\n",
117 if (request->GetPrimaryGroup()) {
118 switch (request->GetPrimaryGroup()->Type()) {
122 squadron = request->GetPrimaryGroup();
131 if (iff > 0 && iff !=
ownside) {
137 static int id_key = 1;
146 ::Print(
"CMF Created %03d '%s' %s\n\n",
148 (
const char*) info->
name,
155 sprintf_s(fname,
"msn%03d.def", info->
id);
157 fopen_s(&f, fname,
"w");
159 fprintf(f,
"%s\n", script.
data());
165 ::Print(
"CMF failed to create mission.\n");
209 sprintf_s(name,
"Fighter Mission %d",
id);
487 for (
int i = 0; i < units.
size(); i++) {
558 if (base_loc.
length() < 1) {
563 if (unit_index < 0 || unit_index > 0 && !exact) {
567 while (fabs(loc.
y) > fabs(loc.
x))
570 loc *= 10e3 + 9e3 * unit_index;
573 loc *= 2e3 + 2e3 * unit_index;
614 for (
int i = 0; i < (int) name.
length(); i++)
657 if (!fighter || !carrier)
return;
660 int maint_count = (live_count > 4) ? live_count / 2 : 0;
719 double delta = (pickup - elem->
Location()).length();
809 base_loc +=
Point(0, 0, 14.0e3);
853 if (!freight || freight->
CalcValue() < 1)
return;
894 if (zones[zones.
size()-1]->HasRegion(rgn2))
895 rgn2 = *zones[0]->GetRegions()[0];
897 rgn2 = *zones[zones.
size()-1]->GetRegions()[0];
917 if (!shuttle || shuttle->
CalcValue() < 1)
return;
991 if (!strike || strike->
CalcValue() < 1)
return;
1045 npt_loc =
Point(0, 0, 10.0e3);
1075 Point(0, 0, 30.0e3),
1104 bool escort_needed =
false;
1114 escort_needed =
true;
1128 while (++npt_iter) {
1185 patrol_loc = base_loc +
1189 patrol_loc = base_loc +
1199 int ntargets = (int)
Random(2.0,5.1);
1201 while (ntargets > 0) {
1229 double traverse =
PI;
1232 Point sweep_loc = base_loc;
1245 sweep_loc +=
Point(sin(a), -cos(a), 0) * 100.0e3;
1258 while (traverse > 0) {
1263 sweep_loc +=
Point(sin(a), -cos(a), 0) * 80.0e3;
1289 sweep_loc = base_loc;
1290 sweep_loc.
y += 30.0e3;
1326 if (!s || !s2)
return;
1329 bool second = ninbound > 2;
1332 while (ninbound--) {
1352 attacker = elem->
Name();
1419 if (!s || !s2)
return;
1471 while (++npt_iter) {
1519 if (delta.
length() >= 100e3) {
1520 Point mid = loc + delta * 0.5;
1657 mid = loc + (elem->
Location() - loc) * 0.5;
1744 else if (ttype < 12) {
1791 else if (ttype < 15) {
1883 if (!
mission || !elem)
return;
1896 if (carrier && !flying_start) {
1905 Point delta = r2 - r1;
1935 Point(0, 0, 30.0e3),
1948 if (!squadron)
return 0;
1963 ::Print(
"CMF - Insufficient fighters in squadron '%s' - %d required, %d available\n",
1964 squadron->
Name().
data(), count, avail);
2013 offset.
y = fabs(offset.
y);
2045 while (++subgroup && !result)
2046 result = FindCombatGroup(subgroup.
value(), type);
2063 while (++combatant && !result) {
2064 if (combatant->
GetIFF() == iff) {
2065 result = ::FindCombatGroup(combatant->
GetForce(), type);
2093 objectives +=
".\n";
2107 char player_info[256];
2121 sprintf_s(player_info,
"%d x %s %s '%s'",